diff --git a/cron-products.php b/cron-products.php index 2f02c367..601f13ad 100644 --- a/cron-products.php +++ b/cron-products.php @@ -1,18 +1,27 @@ " . PHP_EOL; +} + $mdb = new medoo( [ 'database_type' => 'mysql', - 'database_name' => 'host439372_redline', + 'database_name' => 'host439372_b2b', 'server' => 'localhost', - 'username' => 'host439372_redline', - 'password' => 'zak2VVsmvAsqGFx7', + 'username' => 'host439372_b2b', + 'password' => 'BNbuvNMs22Dq48drp6Ee', 'charset' => 'utf8' ] ); +log_msg('Start: przeliczanie cen zestawów (pack).'); $rows = $mdb -> select( 'ps_product', '*', [ 'cache_is_pack' => 1 ] ); +log_msg('Znaleziono zestawów: ' . count($rows)); foreach ( $rows as $row ) { + log_msg('Przeliczam cenę zestawu ID: ' . $row['id_product']); $summary_price = 0; $rows2 = $mdb -> select( 'ps_pack', '*', [ 'id_product_pack' => $row['id_product'] ] ); foreach ( $rows2 as $row2 ) @@ -23,11 +32,16 @@ foreach ( $rows as $row ) $mdb -> update( 'ps_product', [ 'price' => $summary_price ], [ 'id_product' => $row['id_product'] ] ); $mdb -> update( 'ps_product_shop', [ 'price' => $summary_price ], [ 'id_product' => $row['id_product'] ] ); + log_msg('Zapisano cenę zestawu ID: ' . $row['id_product'] . ' = ' . $summary_price); } +log_msg('Start: przeliczanie stanów magazynowych zestawów (pack).'); + $rows = $mdb -> select( 'ps_product', '*', [ 'cache_is_pack' => 1 ] ); +log_msg('Znaleziono zestawów: ' . count($rows)); foreach ( $rows as $row ) { + log_msg('Przeliczam stan magazynowy zestawu ID: ' . $row['id_product']); $product_quantity = 999999999; $rows2 = $mdb -> select( 'ps_pack', '*', [ 'id_product_pack' => $row['id_product'] ] ); @@ -41,5 +55,7 @@ foreach ( $rows as $row ) } $mdb -> update( 'ps_stock_available', [ 'quantity' => $product_quantity ], [ 'id_product' => $row['id_product'] ] ); + log_msg('Zapisano stan magazynowy zestawu ID: ' . $row['id_product'] . ' = ' . $product_quantity); } +log_msg('Koniec: zakończono przetwarzanie zestawów.'); ?> \ No newline at end of file diff --git a/docs/.DS_Store b/docs/.DS_Store deleted file mode 100644 index c536509a..00000000 Binary files a/docs/.DS_Store and /dev/null differ diff --git a/docs/.htaccess b/docs/.htaccess deleted file mode 100644 index 3de9e400..00000000 --- a/docs/.htaccess +++ /dev/null @@ -1,10 +0,0 @@ -# Apache 2.2 - - Order deny,allow - Deny from all - - -# Apache 2.4 - - Require all denied - diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt deleted file mode 100644 index 24932952..00000000 --- a/docs/CHANGELOG.txt +++ /dev/null @@ -1,4824 +0,0 @@ -Copyright since 2007 PrestaShop SA and Contributors -PrestaShop is an International Registered Trademark & Property of PrestaShop SA - -NOTICE OF LICENSE - -This source file is subject to the Open Software License (OSL 3.0) -that is bundled with this package in the file LICENSE.md. -It is also available through the world-wide-web at this URL: -https://opensource.org/licenses/OSL-3.0 -If you did not receive a copy of the license and are unable to -obtain it through the world-wide-web, please send an email -to license@prestashop.com so we can send you a copy immediately. - -DISCLAIMER - -Do not edit or add to this file if you wish to upgrade PrestaShop to newer -versions in the future. If you wish to customize PrestaShop for your -needs please refer to https://devdocs.prestashop.com/ for more information. - -@author PrestaShop SA and Contributors -@copyright Since 2007 PrestaShop SA and Contributors -@license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - -Release Notes for PrestaShop 1.7 --------------------------------- -#################################### -# v1.7.7.1 - (2021-01-11) -#################################### - -- Back Office: - - Improvement: - - #22020: Take shop id into account when getting a language list for an order (by @matthieu-rolland) - - #22028: Update out of stock mail wording (by @jolelievre) - - Bug fix: - - #21692: Refresh order products when a product is added or deleted (by @sowbiba) - - #22535: Method assertCmsCategoryExists doesn't return anything, it throws an exception (by @PierreRambaud) - - #22082: Hide product quantity in Order view page when stock management is disabled (by @jolelievre) - - #22299: Use OrderDetail prices when modifying an Order (by @jolelievre) - - #21795: Fix wrong product quantity after adding a product triggering a free gift (by @matthieu-rolland) - - #22175: Added error when a customization is not found (by @Progi1984) - - #21912: Use language_code when locale is empty to get CLDR data (by @atomiix) - - #22171: When refreshing an order, display shipping price if needed (by @Progi1984) - - #22406: Fixed pagination in Product Quick Navigation Popup (by @Progi1984) - - #21977: Add debounce to quantity change of order create product (by @NeOMakinG) - - #22291: Fixed Pagination of Sell > Orders > Credits Slips page (by @Progi1984) - - #22214: Fix numeric_iso_code in the upgrade to 1.7.7.1 (by @atomiix) - - #22126: Fix bug on displayed price's calculation in BO order page under specific conditions (by @matthieu-rolland) - - #22246: Integrate ContextStateManager into refund handlers (by @jolelievre) - - #21568: Fixed in Create Order the update of cart rules when changing adress (by @Progi1984) - - #22189: Trigger input when a predefined message is applied (by @Progi1984) - - #22077: Create Order - Fix remove cart rule when amount is not reached (by @sowbiba) - - #22101: Fix product selections when creating/updating tags (by @atomiix) - - #22099: Fix employee filter for the Logs page (by @atomiix) - - #22059: Add Payments block refresher - Refresh when product is added or removed from Order (by @sowbiba) - - #21992: Make customer note TYPE_STRING instead of TYPE_HTML (by @atomiix) - - #21980: Fixed the error message for a combination with a min quantity for sale (by @Progi1984) -- Front Office: - - Bug fix: - - #22296: Center products on category list on mobile (by @NeOMakinG) - - #22241: Fix duplicated hook data after product page refresh (by @Hlavtox) - - #22103: Display combination image in product pack list (by @jolelievre) -- Core: - - Bug fix: - - #22532: Hook keys must be in lowercase (by @PierreRambaud) - - #22432: Don't redirect to http from https if it is homepage (by @ludoc) - - #22293: Use PS cache config as driver.cache (by @atomiix) - - #22274: Fix upgrade from ps < 1.7.0.0 (by @atomiix) - - #22289: Removed module Linklist update from upgrade script (by @Progi1984) - - #21988: Fix order detail total amount update when rounding is per item (by @matthieu-rolland) -- Tests: - - Improvement: - - #22198: Add static cache resets (by @matthieu-rolland) - - Refactoring: - - #22543: Add test 'Page for terms and conditions' (by @nesrineabdmouleh) - - #22523: Add test 'Activate merchandise returns' (by @nesrineabdmouleh) - - #22521: Refactoring alert blocks in UI tests (by @boubkerbribri) - - #22491: Add test 'View customer service message page' (by @nesrineabdmouleh) - - #22490: Add new FO tests 'Edit account information' (by @boubkerbribri) - - #22433: Add test 'Check to delete shop groups' (by @nesrineabdmouleh) - - #22446: Add test 'Quick edit order status' (by @nesrineabdmouleh) - - #22454: Add test 'Quick edit alias status' (by @nesrineabdmouleh) - - #22455: Add requirement block to README in UI tests (by @boubkerbribri) - - #22434: Refactoring FO login page in UI tests and add new page for create account page (by @boubkerbribri) - - #22428: Add new command to run all UI tests and check step identifiers in all campaigns (by @boubkerbribri) - - #22423: Add new test 'Change carrier position' (by @boubkerbribri) - - #22408: Rename functions in UI tests (by @boubkerbribri) - - #22345: Add tests on products page (by @boubkerbribri) - - #22012: Fix random fails in travis CI (by @boubkerbribri) - - #22209: Backport fix on UI sort tests (by @boubkerbribri) - - #22172: Backport UI tests (by @boubkerbribri) - -#################################### -# v1.7.7.0 - (2020-12-02) -#################################### - -- Back Office: - - Bug fix: - - #22191: Validate currency localized names (by @jolelievre) - - #22013: Handle parallel updates from CartRules when updating a product in Order (by @jolelievre) - - #22018: Order zero ratio for order detail tax (by @matks) - - #21781: Remove gifted quantity from product order quantity (by @sowbiba) - - #21994: Remove or cancel all products (by @jolelievre) - - #21721: Handle Shop context override in order editing (by @jolelievre) - - #21816: Remove useless logic Product customization images in Order Page and handle exotic chars in name (by @matks) - - #21853: Add missing use in CancelOrderProductHandler (by @matks) - - #21830: Correctly generate cart error messages (by @jolelievre) - - #21555: Fixed increment button when adding a product out of stock and with allow order (by @Progi1984) - - #21526: Improved Error message in New Order Page when adding a minimal product (by @Progi1984) - - #21557: Fix product pagination when adding a product in an empty order (by @atomiix) -- Front Office: - - Bug fix: - - #21981: Make sure favicon, stores_icon and logo are correctly settled for themes (by @PierreRambaud) -- Core: - - Bug fix: - - #22178: Set numeric_iso_code & precision in currency from CLDR when upgrading (by @atomiix) - - #22182: Update pear/archive_tar to 1.4.11 (by @PierreRambaud) - - #22174: Use displayHeader hook instead of Header (by @atomiix) - - #22164: Fix upgrade script from < 1.7.6.0 to 1.7.7.0 (by @atomiix) - - #22146: Remove --classmap-authoritative when building release (by @atomiix) - - #22130: Fix dependency which is targeting the v1.3.0 instead of the 1.3 branch (by @PierreRambaud) - - #21975: Correctly substring fields before update, remove duplicates and add missing sql queries (by @PierreRambaud) -- Installer: - - Improvement: - - #21957: Update latest native modules (by @jolelievre) - - Bug fix: - - #21953: Fix "column count doesn't match value count" error during upgrade (by @okom3pom) -- Localization: - - Improvement: - - #22063: Last translation updates (by @jolelievre) -- Tests: - - Refactoring: - - #22055: Delete spaces in the end of title name in faker for UI tests (by @boubkerbribri) - -#################################### -# v1.7.7.0-rc.1 - (2020-11-03) -#################################### - -- Back Office: - - Improvement: - - #21435: Add hooks for the AdminLoginController, AdminController, FrontController and Controller (by @PierreRambaud) - - #20903: [BC Break] Update Order amount when its addresses are modified (by @jolelievre) - - #21203: Build assets for 177 (by @jolelievre) - - #21190: Add missing security annotation on new 177 routes (by @jolelievre) - - #21025: Make legacy parameters from routing accessible in migrated pages (by @jolelievre) - - Bug fix: - - #21666: Recompute price tax excluded only when the price is different from catalog (by @jolelievre) - - #21574: Allow ContextStateManager to stash contexts (by @jolelievre) - - #21523: Several fixes found via PHPStan while mergin to develop (by @jolelievre) - - #21447: Synchronize OrderDetail with Cart when removing a voucher (by @PierreRambaud) - - #21467: Fix help link in Create order (by @atomiix) - - #21458: Two Time actionAdminLoginControllerResetBefore (by @okom3pom) - - #21432: Fixed Configuration when Disabling/Enabling Shop (by @Progi1984) - - #21326: Set order currency to added cart rule (by @sowbiba) - - #21331: Enable Gift and Recycled Packaging switches (by @matks) - - #21232: Fix tab modules list (by @sowbiba) - - #21343: Fix status dropdown of order listing page not being well displayed using rtl language (by @NeOMakinG) - - #21317: Notifications bell icon read fix (Backport) (by @okom3pom) - - #21344: Move product search controller that was not in the right place (by @jolelievre) - - #20882: Recompute specific price tax excluded when mismatch with price tax included (by @matthieu-rolland) - - #21310: Fix delete order state confirmation (by @sowbiba) - - #21195: Replaced SQL query to fetch modules hooked on stat hook by Hook function to have a singl Source of Truth (by @matks) - - #20760: Add Order - View customer details : Check if nav-bar exist to avoid console errors (by @sowbiba) - - #20628: Restore selectors in Order Page for GDPR to make GDPR module compliant with 1.7.7.0 (by @matks) - - #21045: Fix Features page throwing an exception after specific steps are made (by @atomiix) - - #21031: Fix bad range error when setting free shipping on a previously not free shipping carrier (by @atomiix) - - #21048: Fix [BO- Stores page] Sort by post code not working (by @PululuK) - - #20911: Fix glyph.png asset path (by @okom3pom) - - #20960: Fix bulk actions in Carriers page (by @atomiix) - - #20936: Fix navbar scroll on mobile display (by @sowbiba) - - #20902: Keep order detail from being updated in BO > Order detail page, when product doesn't exist anymore (by @matthieu-rolland) - - #20906: Duplicate product in order invoices (by @jolelievre) - - #20796: Fix OrderReturnState should not use soft delete (by @atomiix) - - #20798: Do not recalculate shipping if PS_ORDER_RECALCULATE_SHIPPING is false (by @atomiix) - - #20792: Fix cannot add twice a product out of stock but allowed to be ordered (by @atomiix) - - #20757: Save customer message on order creation from BO (by @sowbiba) - - #20734: Allow to create Order from BO using soft deleted address (by @matks) - - #20704: Expose missing route (by @atomiix) - - #20603: Redirect to customer when canceling new customer address creation (by @ks129) - - #20714: Fix max attribute on qty input of an out of stock attribute available on create order (by @NeOMakinG) - - #20684: Fix empty optional customization exception when creating BO order (by @atomiix) - - #20145: Product management and specific prices new rules in Order (by @jolelievre) - - #20755: Fix free shipping cart rules not added/deleted in create order (by @atomiix) - - #20729: Fix price width is too small on some devices by setting a min-width (by @NeOMakinG) - - #20644: Check for address id before creating CartAddress (by @atomiix) - - #20626: Fix duplicate ids in order page (by @PierreRambaud) -- Front Office: - - Improvement: - - #21507: Build core assets (by @jolelievre) - - #20920: Fix jquery migrate being loaded two times in FO (by @matthieu-rolland) - - Bug fix: - - #21362: Possibility to check if we're in product quick view mode (by @kpodemski) - - #20927: Avoid possible notice due to breaking change (by @kpodemski) - - #21297: Fix variable name in order_customer_comment.html.twig (by @okom3pom) - - #21266: Fix wrong combination image shown when clicking to zoom (by @atomiix) - - #20598: Do not reconvert discounts (by @atomiix) -- Core: - - Improvement: - - #21449: Update modules (blockreassurance/dashtrends/ps_checkpayment/welcome) (by @Progi1984) - - #21138: Add changelog for the 1.7.6.8 version (by @PierreRambaud) - - #21124: Bump version to 1.7.6.8, bump contactform version (by @PierreRambaud) - - #20794: Send an 'action' parameter to actionProductCancel hook (by @matthieu-rolland) - - #20738: Disable jquery migrate deprecation messages when prestashop debug mode is off (by @matthieu-rolland) - - Bug fix: - - #21609: Make PrestaShop compatible with composer 2.0 (by @atomiix) - - #21390: Fix getting proper cover for image (by @kpodemski) - - #GHSA-rc8c-v7rq-q392: Stored XSS in upload files (by @PierreRambaud) - - #GHSA-5cp2-r794-w37w: Potential XSS injection with contact form (by @PierreRambaud) - - #GHSA-fghq-8h87-826g: Blind SQLi in Catalog Product edition (by @PierreRambaud) - - #20992: Update live polyfill in BO, FO core theme, and remove it from FO classic theme (by @matthieu-rolland) - - #20741: Fix cumulative free gift + percentage discounts (by @atomiix) - - #20693: Cancel/Refunds... adding missing hooks and cancel product refactor (by @matthieu-rolland) - - #20758: Fix cumulative percentage behat test (by @matthieu-rolland) - - Refactoring: - - #20378: Use Computing precision instead of hardcoded 2 (by @matks) -- Installer: - - Improvement: - - #21178: Update modules for 177 (by @jolelievre) - - Bug fix: - - #20201: Fix throw InstallControllerHttpSystem::trans during installation process (by @mushroot) -- Localization: - - Improvement: - - #21607: Update translation catalogs (by @jolelievre) - - #21509: Update catalog with latest wordings (by @jolelievre) - - #21179: Update translation catalogues for 177 (by @jolelievre) -- Tests: - - Improvement: - - #21497: Improve behat config which did not use appropriate format for paths (by @jolelievre) - - #20850: Add behat tests for order shipping computing, and add new carriers fixtures (by @jolelievre) - - Bug fix: - - #21532: Update behat and gerkhin to allow debugging in PHPStorm (by @jolelievre) - - Refactoring: - - #21544: Fix image name for CRUD title test (by @boubkerbribri) - - #21512: Add tests 'Helper card' for catalog pages (by @boubkerbribri) - - #21508: Add test 'CRUD search engines' (by @boubkerbribri) - - #21505: Add test pagination stores (by @boubkerbribri) - - #21481: Add test 'Sort and pagination price rule' (by @nesrineabdmouleh) - - #21473: Add test 'Filter sort and pagination order status' (by @nesrineabdmouleh) - - #21462: Add var for visible selectors in methods (by @nesrineabdmouleh) - - #21459: Add test 'CRUD order status' (by @nesrineabdmouleh) - - #21452: Fix page name in orders tests (by @boubkerbribri) - - #21399: Add test 'Help card on attributes page' (by @boubkerbribri) - - #21405: Add test 'Filter, sort and pagination search engines' (by @boubkerbribri) - - #21403: Add test 'Sort and pagination countries table' (by @nesrineabdmouleh) - - #21411: Add test 'Sort and pagination states table' (by @nesrineabdmouleh) - - #21415: Add test 'Filter, sort and pagination tax rules group' (by @nesrineabdmouleh) - - #21433: Fix a small error in nightly 14-10-2020 (by @nesrineabdmouleh) - - #21402: Add test 'Sort and pagination zones table' (by @nesrineabdmouleh) - - #21385: Add test 'Filter and bulk actions catalog price rules' (by @nesrineabdmouleh) - - #21396: Add navigation when selecting pagination limit (by @boubkerbribri) - - #21367: Add test 'CRUD catalog price rule' (by @nesrineabdmouleh) - - #21334: Create state with only iso code that does not exist (by @boubkerbribri) - - #21341: Fix test 'CRUD carrier' in nightly 07/10/2020 (by @nesrineabdmouleh) - - #21339: Delete all references to ttc in UI folder (by @boubkerbribri) - - #21327: Create first test 'Computing precision set to 3' for UI tests new campaign 'Regression' (by @boubkerbribri) - - #21324: Add new test 'Change position for attributes and values' (by @boubkerbribri) - - #21308: Fix tests errors in nightly 04/10/2020 (by @nesrineabdmouleh) - - #21302: Change UI tests workflow name (by @boubkerbribri) - - #21255: Add test 'Sort and pagination shopping carts' (by @nesrineabdmouleh) - - #21265: Fix tests errors in nightly 02/10/2020 (by @nesrineabdmouleh) - - #21256: Fix test 'Filter shopping carts' (by @nesrineabdmouleh) - - #21188: Refactoring create cart rule and faker in tests (by @boubkerbribri) - - #21225: Add test 'Filter shopping carts' (by @nesrineabdmouleh) - - #21147: Add test 'Filter sort and pagination carriers' (by @nesrineabdmouleh) - - #21184: Avoid creating new state with existing iso code (by @boubkerbribri) - - #21162: Add a DB_SERVER global variable for tests (by @SD1982) - - #21182: Add test 'Pagination and sort cart rule' (by @nesrineabdmouleh) - - #21122: Add github action to check eslint and step identifier doubles for UI tests (by @boubkerbribri) - - #21139: Change faker for locations tests (by @boubkerbribri) - - #21123: Add test 'Sort and pagination attributes' (by @nesrineabdmouleh) - - #21064: Add test 'Crud carrier' (by @nesrineabdmouleh) - - #21116: Fix Error in last PR to force playwright@1.0.2 (by @boubkerbribri) - - #20935: Add test 'Bulk actions countries' (by @boubkerbribri) - - #21097: Downgrade playwright to version 1.0.2 (by @boubkerbribri) - - #21090: Unskip test 'Sort by post code' in stores page after fixing issue (by @boubkerbribri) - - #21089: Increase timeout for 'Sort' tests (by @boubkerbribri) - - #21043: Fix test context in 'Sort and pagination image settings' (by @nesrineabdmouleh) - - #21056: Fix tests errors in nightly 18-09-20 (by @boubkerbribri) - - #21040: Add test 'Sort Stores' (by @boubkerbribri) - - #20847: Add test 'Configure contact details' (by @nesrineabdmouleh) - - #20997: Add test 'Sort and pagination image settings' (by @nesrineabdmouleh) - - #21029: Delete force install playwright on docker (by @boubkerbribri) - - #20988: Fix 'CRUD Cart Rule' Test (by @boubkerbribri) - - #20932: Add test 'Bulk actions states' (by @boubkerbribri) - - #20961: Add test 'Filter, quick edit and bulk actions cart rules' (by @boubkerbribri) - - #20922: Add test 'CRUD states' (by @boubkerbribri) - - #20919: Add test 'Bulk actions zones' (by @boubkerbribri) - - #20913: Avoid creating the same name for different values using faker (by @boubkerbribri) - - #20899: Add test 'CRUD Zone' (by @boubkerbribri) - - #20896: Add test 'Filter and quick edit states' (by @boubkerbribri) - - #20876: Add test 'Filter and quick edit zone' (by @boubkerbribri) - - #20873: Improve pagination on customers test (by @boubkerbribri) - - #20883: Fix duplicates steps identifiers in UI tests (by @boubkerbribri) - - #20881: Add test 'Filter and quick edit countries' (by @boubkerbribri) - - #20859: Add test 'CRUD tax Rule' (by @nesrineabdmouleh) - - #20831: Add test 'CRUD country' (by @nesrineabdmouleh) - - #20802: Add test 'CRUD cart rule' (by @nesrineabdmouleh) - - #20759: Add test 'Bulk delete attributes' (by @boubkerbribri) - - #20724: Add test 'Default pack stock management' (by @nesrineabdmouleh) - - #20749: Add tests 'Filter features' and 'Filter feature values' (by @boubkerbribri) - - #20735: Add test 'CRUD attributes and values' (by @boubkerbribri) - - #20692: Add tests 'Filter attributes' and 'Filter attribute values' (by @boubkerbribri) - - #20683: Fix faker data - Title's name should take at most 20 characters (by @boubkerbribri) - - #20599: Functional tests - Add CRUD and Bulk actions tests for image types (by @boubkerbribri) - - #20551: Functional tests - Add tests 'CRUD and bulk delete Groups' (by @boubkerbribri) - -#################################### -# v1.7.7.0-beta.2 - (2020-08-18) -#################################### - -- Back Office: - - New feature: - - #19704: Migrate linked orders (by @matks) - - #19697: Add order sources in Order View page (by @matks) - - Improvement: - - #20529: Fix links in footer - https is better than http (by @matks) - - #20311: Mark deprecated order hooks for 1.7.7 as such (by @matks) - - #20124: Use /usr/sbin/sendmail instead of mail() in config wording (by @atomiix) - - #20039: Make customization image downloadable in BO order page (by @matthieu-rolland) - - #19903: Auto create symfony roles (by @jolelievre) - - #19854: Add trace information to Command/Query debugger (by @eternoendless) - - #19730: Enable fancybox for edit an address in View an Order page (by @matks) - - #19597: Add order table empty state (by @atomiix) - - #19582: Order products pagination (by @jolelievre) - - Bug fix: - - #20571: Return an int instead of a float (in some cases) for Pack::getQuantity() (by @atomiix) - - #20451: Fix TinyMCE error on product page (by @NeOMakinG) - - #20538: Fix order cart rule deletion (by @matthieu-rolland) - - #20524: Fix bad call in HTMLTemplateOrderSlip (by @matks) - - #20477: Fixed cast for primary key in PrestaShopCollection (by @Progi1984) - - #20492: Remove call to updateOrderInvoice - not needed anymore (by @matks) - - #20482: Set CartRule amount with tax in BO instead of without tax (by @atomiix) - - #20335: Remove discount from order (persist state) (by @jolelievre) - - #20457: Include product name and employee name in out of stock email (by @ks129) - - #20461: Fixed Modal "View pack content" (by @Progi1984) - - #20433: Dont show root category on category grid search results (by @matks) - - #20284: Order address country (by @jolelievre) - - #20198: Product supplier_reference is not updated when saving a product in the BO (by @PierreRambaud) - - #20319: Cannot remove attributes if token is disabled (by @PierreRambaud) - - #20303: Fix bad redirection after error in address controller - edit usecase (by @matks) - - #20263: Fix bad redirection after error in address controller (by @matks) - - #20111: Fix order max quantity (by @jolelievre) - - #20083: Refactoring of the Order Updater and multiple related bugfixes (by @jolelievre) - - #20166: Return Response to provide a good error message when import directory doesnt exist (by @matks) - - #20126: Correctly uncheck previous default combination (by @Amazzing) - - #19970: Create specific price when product price is updated in order (by @sowbiba) - - #19937: Fixed position action button in Order Page (by @Progi1984) - - #17399: Expand Categories search capabilities for categories listing home page and avoid going from subcategory to root category when using grid filters (by @matks) - - #19929: Fixes the import configuration save (by @Progi1984) - - #19955: Rename AddCustomizationFieldsCommand to AddCustomizationCommand (by @zuk3975) - - #19646: Synchronize cart_product and order_detail when quantity is changed (by @sowbiba) - - #19828: Check for ::GRID_ID when definition is AbstractGridDefinitionFactory (by @atomiix) - - #19778: Cast changelogs to array for twig (by @atomiix) - - #19698: Fix order view total discounts (by @zuk3975) - - #19712: Move smarty variables assignments in initHeader instead of init function (by @PierreRambaud) - - #19820: Hooks displayAdminOrderTabLink or displayAdminOrderTabContent displayed not escaped to allow raw HTML (by @clotaire202) - - #19796: Missing fancybox plugin in new theme pages (by @PierreRambaud) - - #19506: Handle AbstractGridDefinitionFactory compatibility (by @matks) - - #19716: Remove i18n access restrictions (by @PierreRambaud) - - #19546: Fix scrollbar on order page when adding product (by @antoinedamiron) - - #19448: Fix AdminModulesController fatal error (by @Matt75) - - #19452: Fix to show the Modules tab in the product editor - backport of #19216 to 1.7.7.x (by @matks) - - #18875: BO - Create Order page - Defined the order status relative to payment (by @Progi1984) - - #18456: Update cart currency when order currency changes (by @sowbiba) - - #18923: Multistore: Fix error when viewing an order with custom product made on secondary shop (by @matthieu-rolland) - - #19205: Fix catalog price rule - Currency sort and filter not working & save button design - Backports of #19020 and #19021 for 1.7.7.x (by @matks) - - #19108: Extend OrderController with FrameworkBundleAdminController instead of CommonController (by @zuk3975) - - #19103: Redirect to dashboard when employee default page is unauthorized (by @sowbiba) - - #19089: Fix bug keeping user from accessing his profile page in BO (by @matthieu-rolland) - - #19086: BO - New Product - In MultiLang BO, the default name input wasn't in the employee language (by @Progi1984) - - #19039: Fix product pagination in order with customization (by @atomiix) - - #19032: Update ps_themecusto to the latest version (by @atomiix) - - #19058: Refresh invoices total when product price is updated (by @sowbiba) - - #18580: In BO Product page, use ecotax excl. tax instead of tax incl. (by @matks) - - #17179: Fix free gift product in Order create page (by @zuk3975) - - Refactoring: - - #19981: Refactor cancel product and bug fix (by @matthieu-rolland) - - #18984: Remove legacy files for Order page (by @matks) -- Front Office: - - Improvement: - - #19706: Don't try to translate using domain unless the "d" parameter is present (by @eternoendless) - - Bug fix: - - #20555: Fix images quickview also updating product page by changing product i… (by @NeOMakinG) - - #19631: FO: fix cumulative percentage reduction amount value in cart (by @matthieu-rolland) - - #19896: Fix lang dropdown by adding jquery migrate (by @NeOMakinG) - - #19437: Make product image in list overridable (by @jolelievre) - - #19139: Do not use cache while checking if an order exists (by @PierreRambaud) - - #19456: Fix voucher display for single customer - backport of #19443 to 1.7.7.x (by @matks) - - #19395: Return 404 in frontoffice if return merchandise is disabed (by @clotaire202) - - #17502: Fix cart voucher values in cart summary and checkout summary (by @arouiadib) - - #19347: Use Country from global namespace (by @prestamodule) - - #18993: Fix discount display on multicurrency context (by @sowbiba) - - #18884: FO: Display 'free' as shipping cost in the cart when a cart rule grants free shipping (by @matthieu-rolland) -- Core: - - New feature: - - #19782: Allow modules to disable routing prefix with specific parameter (by @matks) - - Improvement: - - #20547: Update module productcommentsto v4.1.0 (by @matks) - - #20137: Computing precision: set minimum computing precision value to zero (by @matthieu-rolland) - - #20324: Set editorconfig to indent yml files using 4 spaces instead of two (by @eternoendless) - - #19461: Remove MBO-related api calls from core (by @atomiix) - - #19752: Update licenses headers (by @PierreRambaud) - - #19556: Update modules (contactform/ps_imageslider/ps_sharebuttons/statspersonalinfos) (by @Progi1984) - - Bug fix: - - #20570: Update _PS_JQUERY_VERSION_ to match the included jQuery version (by @eternoendless) - - #12578: Fix wrong use of alias when registering new hook (by @eternoendless) - - #20408: Fix bug on Invoices tax detail (by @matthieu-rolland) - - #20398: Fixed Cache Problem in Language & Currency (by @Progi1984) - - #15049: Fix wrong hook names (by @eternoendless) - - #20192: Remove tables upgrade lines related to gamification module (by @PierreRambaud) - - #18532: Increase precision for DECIMAL fields in database (by @atomiix) - - #19581: Fix bugs occuring when an order state is deleted but still assigned to orders (by @matthieu-rolland) - - #19858: Update jquery.live.polyfill npm dependency (by @PierreRambaud) - - #19657: Deprecate hookcount and add missing hook in hook.xml (by @atomiix) - - #19016: Add mapping for Doctrine core entities on front environment (by @jolelievre) - - #19409: Add missing index.php in upload directory (by @PierreRambaud) - - #18811: Introduce CompilerPass to perform ControllerAwareTrait injection (by @matks) - - #15871: Avoid error when trying to translate an invalid module (by @PululuK) - - #19063: Fix simplfied url not properly set for multilang categories (by @matthieu-rolland) - - #18697: Fix error when updating a used address with no DNI (by @shaffe-fr) - - #18845: Add tag controller.service_arguments to PrestaShop controllers (by @matks) - - #18851: Build assets for Beta (by @jolelievre) - - Refactoring: - - #19748: Update decimal library (by @jolelievre) -- Installer: - - Improvement: - - #19788: Allow user to choose to drop existing tables or not even when not in dev mode (by @Progi1984) - - #19694: Allow user to choose to install demo products or not even when not in dev mode (by @eternoendless) - - Bug fix: - - #20122: Fix session tables charset (by @jolelievre) - - #19887: Add missing comma (by @atomiix) - - #19274: Add a missing comma in 1.7.7.0 upgrade file (by @Quetzacoalt91) - - #18834: Remove newsletter registration during installation (by @PierreRambaud) -- Web Services: - - Bug fix: - - #18859: Defined Currency Context if needed in WebService Context (by @Progi1984) -- Localization: - - Improvement: - - #19897: Update German tax rates (by @Progi1984) - - #18902: Avoid nested wordings chains (by @jolelievre) -- Tests: - - Improvement: - - #20312: Improve combination tests, use IDs instead of names to check quantities (by @jolelievre) - - Bug fix: - - #18613: Cart rule order tests (by @jolelievre) - - Refactoring: - - #20586: Functional tests - Add test 'Filter image types' (by @boubkerbribri) - - #20486: Functional tests - Enable/Disable display attributes in product meta title (by @nesrineabdmouleh) - - #20569: Functional tests - Add new tests for stores page (by @boubkerbribri) - - #20559: Functional tests - Add test 'Filter stores' (by @boubkerbribri) - - #20543: Functional tests - Add test 'Filter groups' (by @boubkerbribri) - - #20539: Functional tests - Update exchange rate (by @nesrineabdmouleh) - - #20502: Functional tests - Add new test 'Create customer from create order page' (by @boubkerbribri) - - #20540: Functional tests - Add tests for seo pages (by @boubkerbribri) - - #20521: Functional tests - Add new test 'Configure module' (by @boubkerbribri) - - #20468: Functional tests - Search hook in Positions page (by @nesrineabdmouleh) - - #20460: Functional tests - Update test filter categories (by @boubkerbribri) - - #20450: Functional tests - Update linkchecker urls (by @boubkerbribri) - - #20459: Functional tests - Add new test 'Select default Theme' (by @boubkerbribri) - - #20440: Functional tests - Enable using loginCommon with different user than default one (by @boubkerbribri) - - #20439: Functional tests - Avoid 'home' as new category to create (by @boubkerbribri) - - #20418: Functional tests - Add tests for titles page (by @boubkerbribri) - - #20394: Functional tests - Add test 'Search customers in create order page' (by @boubkerbribri) - - #20302: Functional tests - Add update a language (by @nesrineabdmouleh) - - #20368: Functional tests - Add browser listeners to tests (by @boubkerbribri) - - #20360: Functional tests - Reset orders before going to order view page (by @boubkerbribri) - - #20318: Functional tests - Add new test 'View guest from orders page' (by @boubkerbribri) - - #20293: Functional tests - Add new test 'Carrier restrictions' (by @boubkerbribri) - - #20280: Functional tests - Create new test 'View customer from orders page' (by @boubkerbribri) - - #20241: Functional tests - Modify translation (by @nesrineabdmouleh) - - #20215: Functional tests - Add checking order status in FO after update status in BO (by @boubkerbribri) - - #20210: Functional tests - Add 'Sort orders' tests (by @boubkerbribri) - - #19997: Functional tests - Separate browser page and page objects (by @boubkerbribri) - - #20086: Functional tests - Test pagination of products table (by @nesrineabdmouleh) - - #20046: Functional tests - Do not skip steps in CRUD category and subcategory scenario (by @boubkerbribri) - - #19983: Functional tests - Update playwright version (by @nesrineabdmouleh) - - #19785: Functional tests - Delete unused selectors and methods (by @nesrineabdmouleh) - - #19920: Functional tests - Wait for neworkidle in wait for navigation function (by @boubkerbribri) - - #19727: Functional tests - Update linkchecker for playwright (by @boubkerbribri) - - #19802: Delete test identifiers redundant and license notice in all tests (by @nesrineabdmouleh) - - #19775: Functional tests - Improve delete categories by bulk action ad set required fields function (by @boubkerbribri) - - #19749: Functional tests - Fix wait for navigation and disable category tests (by @boubkerbribri) - - #19725: Functional tests - Increase timeout after disabling a category (by @boubkerbribri) - - #19653: Functional tests - Switch tests to playwright (instead of puppeteer) (by @boubkerbribri) - - #19489: Remove unused test (by @SimonGrn) - - #19339: Functional tests - Update tests contexts (by @boubkerbribri) - - #19235: Functional tests - Test pagination and sort of pages and categories (by @nesrineabdmouleh) - - #19208: Functional tests - Test pagination of suppliers table (by @nesrineabdmouleh) - - #19257: Functional tests - Delete bo base page shop params tests (by @boubkerbribri) - - #19210: Functional tests - Test pagination of files table (by @nesrineabdmouleh) - - #19206: Functional tests - Delete bo base page from design tests (by @boubkerbribri) - - #19202: Functional tests - Delete bo base page from catalog tests (by @boubkerbribri) - - #19223: Functional tests - Delete test filter stocks by categories (by @boubkerbribri) - - #19203: Functional tests - Pagination brands and addresses (by @nesrineabdmouleh) - - #19186: Functional tests - Test pagination of categories table (by @nesrineabdmouleh) - - #19194: Functional tests - Delete bo base page customers tests (by @boubkerbribri) - - #19185: Functional tests - Delete BoBasePage from order messages tests (by @boubkerbribri) - - #19183: Functional tests - Delete bo base page for advanced params tests (by @boubkerbribri) - - #19158: Functional tests - Test customers pagination (by @nesrineabdmouleh) - - #19160: Functional tests - Test addresses pagination (by @nesrineabdmouleh) - - #19138: Functional tests - Delete boBasePage for tests modules (by @boubkerbribri) - - #19153: Functional tests - Delete BoBasePage from payment tests (by @boubkerbribri) - - #19159: Functional tests - Delete bo base page from international tests (by @boubkerbribri) - - #19157: Functional tests - Delete bo base page from invoices tests (by @boubkerbribri) - - #19137: Functional tests - Sort order messages table (by @nesrineabdmouleh) - - #19027: Functional tests - Export sql query (by @nesrineabdmouleh) - - #19126: Functional tests - Sort all tables in monitoring page (by @nesrineabdmouleh) - - #19133: Functional tests - Delete boBasePage for functional tests orders (by @boubkerbribri) - - #19067: Functional tests - Sort profiles (by @nesrineabdmouleh) - - #19127: Functional tests - Delete bo base page from sanity tests (by @boubkerbribri) - - #19069: Functional tests - Profiles pagination (by @nesrineabdmouleh) - - #19088: Functional tests - Filter and sort files (by @nesrineabdmouleh) - - #19109: Functional tests - Add test subscribe to newsletter from BO (by @boubkerbribri) - - #19071: Functional tests - Add test taxes pagination (by @boubkerbribri) - - #19092: Functional tests - Edit home category (by @nesrineabdmouleh) - - #19074: Functional tests - Add test pagination order message (by @boubkerbribri) - - #19066: Functional test - Add test quick edit languages (by @boubkerbribri) - - #19004: Functional tests - Sort suppliers table (by @nesrineabdmouleh) - - #18990: Functional tests - Enable/Disable log emails (by @nesrineabdmouleh) - - #18977: Functional tests - Test pages pagination (by @nesrineabdmouleh) - - #18877: Functional tests - Change selectors for FO pages (by @nesrineabdmouleh) - - #18899: Functional tests - Country restrictions (by @nesrineabdmouleh) - - #18871: Functional tests - Update default currency (by @nesrineabdmouleh) - - #18963: Functional tests - Test page category pagination (by @nesrineabdmouleh) - - #18886: Functional tests - Fix test invoices and products settings (by @boubkerbribri) - - #18896: Functional tests - Change selectors for design pages (by @boubkerbribri) - - #18868: Functional tests - Change selectors for modules pages (by @boubkerbribri) - - #18922: Functional tests - Delete not working test (by @boubkerbribri) - - #18862: Functional tests - Change selectors for shop parameters pages (by @boubkerbribri) - - #18873: Functional tests - Change selectors for customers pages (by @boubkerbribri) - - #18870: Functional tests - Change selectors for customer services pages (by @boubkerbribri) - - #18878: Functional tests - Change selectors for international pages (by @boubkerbribri) - - #18866: Functional tests - Fix adding customer to voucher (by @boubkerbribri) - - #18849: Functional tests - Change selectors for catalog pages (by @boubkerbribri) - -#################################### -# v1.7.7.0-beta.1 - (2020-05-13) -#################################### - -- Back Office: - - New feature: - - #18464: Add modal to customer address listing on bulk action (by @matthieu-rolland) - - #18063: Use localized dates for order page (by @matks) - - #17752: Add Prev/Next order button in the Order page (by @tdavidsonas88) - - #17660: Migration of order view page printing functionality and layout changes - part 4 (by @matks) - - #17416: Migrate standard refund and return products in order page (by @jolelievre) - - #16820: Enable confirm modal for catalog > files listing for bulk delete action (by @matks) - - #16668: Integrate a Vue component to manage Currency customization in the BO (by @jolelievre) - - #16467: Migrate partial refund (by @matthieu-rolland) - - #16815: Unhide new migrated Catalog > Files Symfony page (by @matks) - - #16255: Migration of order view page messages block (by @tomas862) - - #14972: Add/Edit a currency with the CLDR implementation (by @jolelievre) - - #16065: Migrate Shipping block of new Order View page (by @sarjon) - - #14682: Add preview extension for Grids (by @sarjon) - - #15995: Migrate create order part 3. Implement vouchers managing (by @zuk3975) - - #16008: Add Order status update in Order View page (by @sarjon) - - #15908: Introduce list dropdown - used in order list page (by @tomas862) - - #14320: Introduce NumberMinMaxFilterType and IntegerMinMaxFilterType (by @tomas862) - - #14198: Add Commands/Queries Profiler tab (by @sarjon) - - #10780: Introduce custom error pages (by @sarjon) - - #13593: Automated hooks discovery and updating hooks list in xml and sql files for modern pages using Grid and FormBuilder (by @tomas862) - - Improvement: - - #18329: View order page: Display correction - 2 (by @NeOMakinG) - - #17385: Confirm modal on restoring currency settings (by @sowbiba) - - #17959: Enable new Orders page (by @matks) - - #17090: Allow "add address" and "add customer" and "edit address" buttons to be handled in modal (by @matks) - - #17702: Order Page: Keep email failure from blocking product cancellation (and some refactor) (by @matthieu-rolland) - - #17568: Increase order price font size and colors for better contrast (by @atomiix) - - #16287: Don't duplicate currencies in DB when creating a formerly deleted one (by @matthieu-rolland) - - #17583: Migration 1.7.7.x Register all new hooks (by @tdavidsonas88) - - #17478: Cherry picked the changes from develop related to Refactor UI kit form #16964 and applied to 1.7.7.x (by @tdavidsonas88) - - #17456: Introduces checkbox in list filter row (by @tomas862) - - #17287: Enable bulk delete modal for Languages, Taxes, CMS Pages, CMS Cats (by @matks) - - #17135: Orders > Product : Display "Stock Location" column only if it is not empty (by @Progi1984) - - #17211: Reintegrate partial refund in the order view page (by @jolelievre) - - #16722: Orders > Products : Display content of a pack (by @Progi1984) - - #17286: Enable bulk delete modal for Suppliers, Brands, Brand adresses (by @matks) - - #16150: Migrate order product management (by @sarjon) - - #17079: Improve modal object without using this (by @NeOMakinG) - - #16821: Add empty states for Catalog > Files and Orders > Credit slips pages (by @matks) - - #16658: Use tab attribute as fallback when a module does not have category (by @PierreRambaud) - - #16432: Module alias in webpack configuration for the new-theme (by @PierreRambaud) - - #16440: Added indexes for product reference and supplier_reference (by @Gamesh) - - #16570: Provides several UX improvements for order pages and allows to change order addresses (by @matks) - - #16662: Fix PHP docblocks (by @mfurga) - - #16552: Add generic ButtonBulkAction and javascript to handle open in tabs (by @jolelievre) - - #16318: Make migrated order page's grid rows clickable (by @matthieu-rolland) - - #16532: Remove useless debug controller actions (by @matks) - - #15958: New design on module positions page (by @Progi1984) - - #15707: Improve query performance in order status update due very slow StockManager.php queries (by @gennaris) - - #16304: Change wording of lifetime of BO cookies help label (by @atomiix) - - #16046: Migrate Documents block of Order View page (by @sarjon) - - #16084: Migrate Merchandise returns for Orders view (by @sarjon) - - #16281: Update wording and add a link in product options tab (by @marionf) - - #16278: Use https links to doc instead of http (by @matks) - - #16033: Introduces kpi design update for orders listing page - also includes layout changes for all kpi's in migrated pages (by @tomas862) - - #16088: Disable Customer group selection checkbox when single customer is set… (by @atomiix) - - #16224: Add tax information in combination table (by @marionf) - - #16230: Add tax information for ecotax field (by @marionf) - - #14809: Allow modifying email body contents (by @jolelievre) - - #16090: Implement new Order View header (by @sarjon) - - #16060: Minor improvements for Orders list (by @sarjon) - - #15798: Remove optin field from the employee creation form (by @matthieu-rolland) - - #15886: Improve pop up information on Category deletion (by @Progi1984) - - #15084: Remove price precision in admin shop preferences (by @matthieu-rolland) - - #15808: Introduce icons instead of dropdown column for Orders page list (by @tomas862) - - #15245: Update jQuery to 3.4.1 in the legacy Back Office pages (by @matthieu-rolland) - - #14396: Migrate Catalog > Attributes&Features > Features > Add new/edit feature page (blocked by faceted_search update) (by @rokaszygmantas) - - #15130: Simplify rendering of forms (by @sarjon) - - #15761: Fix order view page wordings (by @matks) - - #12855: Add Manufacturer Part Number in product codes (by @rblaurin) - - #14767: Behat tests for Seo & Urls page commands - some code improvements (by @tomas862) - - #15765: Fix parameter $id_hook phpdoc (by @JBWModules) - - #15484: Add Malagasy language (by @OneDotIT) - - #14689: Fix BO menu scrollbar size on small screens (by @PierreRambaud) - - #14679: Introduce automatic Tab registration with symfony routes, menu now handles disabled modules (by @jolelievre) - - #14586: Implement Circuit Breaker for fetching blog news (by @Progi1984) - - #14249: Case-insensitive hook dispatching (by @tomas862) - - #13198: Create SF command to return routes with missing _legacy_link (by @zuk3975) - - #13472: Create SF command to list tactician commands and queries (by @zuk3975) - - #13241: Add grid extension to disable filters submit button when filters are empty (by @zuk3975) - - Bug fix: - - #18812: Fix invoices refresh when adding product in an order (by @atomiix) - - #18764: Fix exception when deleting address from customer view (by @sowbiba) - - #18524: Remove ability to apply discount on all invoices in order view page (by @zuk3975) - - #18635: Show confirm modal when adding product with new invoice (by @zuk3975) - - #18566: Fix bad display of customizable product on create order page by removing margin and overflow (by @NeOMakinG) - - #18445: Fix tooltip on product buttons of Order View staying on the page after delete and not being visible when adding a product (by @NeOMakinG) - - #18200: Fix "weird behaviour when filling the quantity field with letters of symbols" (by @arouiadib) - - #18544: Show new invoice information when adding product with new invoice in BO Order (by @zuk3975) - - #18196: Refresh documents tab when adding product in order view page (by @atomiix) - - #18686: Rename CountryChoiceType options using camel case convention (by @jolelievre) - - #18641: Show confirmation modal before deleting order messages (by @zuk3975) - - #18348: Cart products update (by @jolelievre) - - #17852: Fix exception when adding negative amount/percentage discount in order view (by @atomiix) - - #18515: Fix some css to avoid max width on many languages (by @NeOMakinG) - - #18438: Fix currency buttons on edit and add page not aligned by adding styles and changing markup (by @NeOMakinG) - - #18437: Fix sidebar not displayed in BO order page (by @matthieu-rolland) - - #18204: BO : Order > Products : The block discounts was not displayed after adding a product (by @Progi1984) - - #17736: Fix products search results order in SearchProductsHandler (by @zuk3975) - - #18321: Do not stack free shipping vouchers on total: shipping fees applied once (by @matks) - - #18228: Improve common search controller for backward compatibility (by @jolelievre) - - #17850: Rework OrderRefundCalculator to use Number (by @zuk3975) - - #18416: Fix overflow on main-menu and adjust workaround on last items in menu (by @NeOMakinG) - - #18419: Fix currency symbol in orders list (by @sowbiba) - - #17927: Wrong prices in edit order with secondary currency (by @sowbiba) - - #18334: Add FancyBox in create order page details button (by @jolelievre) - - #18326: Fix messages block in order view page (by @zuk3975) - - #18373: Avoid date time split in Grids (by @jolelievre) - - #18205: BO : Add Product on Order : Use previous cart rather than creating a new one (by @Progi1984) - - #18347: Hide order preview stock location column if empty (by @atomiix) - - #18305: Fix count query with customer filter (by @atomiix) - - #17864: Extract order products to separate query (by @zuk3975) - - #17938: Fix conversion when adding payment to order (by @sowbiba) - - #17801: View and Create Order feedbacks corrections (by @NeOMakinG) - - #18164: Use hasBeenPaid instead of hasInvoice to enable refund feature (by @jolelievre) - - #18266: Add target options to index grid of orders on customer column (by @NeOMakinG) - - #17526: Fix customer address form (by @zuk3975) - - #17853: BO: Fix shipping price tax issue on order creation page (by @matthieu-rolland) - - #18288: Fix wrong number of orders when filter 'New client' on (by @atomiix) - - #18294: Return null when value is an empty string in ArabicToLatinDigitDataTransformer (by @atomiix) - - #18208: Increase quantity when adding an already added product when creating order (by @atomiix) - - #17975: Convert arabic/persian digits to latin digits in DatePickerType (by @atomiix) - - #18102: Fix sidebar submenu opening by changing style and adding JS (by @NeOMakinG) - - #18245: Fix orders page dropdown going under header by adding a flip false property (by @NeOMakinG) - - #18124: Modifying address from order should duplicate it and soft delete former address (by @jolelievre) - - #18246: Add check when adding a product in an order that it is not out of stock (by @jolelievre) - - #18168: Prevent adding or editing an invalid product quantity on order (by @jolelievre) - - #18202: Do not display shipping address when order is virtual product only (by @atomiix) - - #17861: Add vertical scroll to customization fields in BO order create page (by @zuk3975) - - #18091: Display gift message into migrated Order page (by @matks) - - #17881: Fix Search by product name & category doesn't work in the second of the Stocks page (by @arouiadib) - - #18146: After creating new voucher from orders/new, I get redirected to voucher list, not a new order (by @tdavidsonas88) - - #17849: Fix orders page dropdown going under header by removing the fixed property (by @NeOMakinG) - - #17672: Rework ChangeOrderCurrencyHandler to private methods (by @zuk3975) - - #17292: Fixes undefined vars in some migrated controllers (by @zuk3975) - - #18101: Fix typo in hook descriptions (by @jolelievre) - - #17476: Don't allow comma in order payment amount field (by @atomiix) - - #17986: Fix "Module Manager" menu item not being translatable (by @eternoendless) - - #17839: Wrap OrderController::viewAction in try-catch (by @zuk3975) - - #17482: Allow token for TokenisedUrlsListener class and in form using the method=GET attribute (by @PierreRambaud) - - #18054: In RTL I have to click 3 times on the checkbox to select the product (by @tdavidsonas88) - - #17985: Fix customer informations on order page when customer is a guest (by @matthieu-rolland) - - #18045: Fix selector for invoice note manager (by @tdavidsonas88) - - #17742: Fix country states input toggle on page load (by @zuk3975) - - #17650: Fixed display for first cell (select all & input) in grid (by @Progi1984) - - #17877: Fix bug when adding a discount on order page (by @matthieu-rolland) - - #17804: Fix bug when changing addresses on virtual product command (by @matthieu-rolland) - - #17913: Remove useless TinyMCE scripts from brand form pages (by @jolelievre) - - #17799: Order Page: Fix private note that cannot be emptied (by @matthieu-rolland) - - #17973: Fix pagination on migrated order listing (by @matthieu-rolland) - - #17884: Use constant for reduction type in CatalogPriceRuleGridDataFactory (by @zuk3975) - - #17796: Fix new wording without domain (by @eternoendless) - - #17535: Fix deleted customer's order preview/details (by @atomiix) - - #17700: Wrong address update when changing the shipping adresse of an order (by @atomiix) - - #17305: Adds optional DNI field and missing post_code handling in supplier form (by @zuk3975) - - #17220: Fix multiple bugs in order view page (by @zuk3975) - - #17641: Fixed Exception for not defined variables when editing a product quantity in an order (by @Progi1984) - - #17649: Fix wrong address edit link in order detail (by @atomiix) - - #17614: Missing assets generation (by @PierreRambaud) - - #17612: Fixed Empty Option in Smarty Form in Advanced Parameters > Performance (by @Progi1984) - - #17547: Fix grids, when search finds no result we still display filters and reset button (by @matks) - - #17448: Fix create order info missing (by @atomiix) - - #17531: Remove irrelevant Todo in order messages (by @zuk3975) - - #17444: Change tinymce lang when changeLanguage event is fired (by @NeOMakinG) - - #17465: Fix create order customization/combinations (by @atomiix) - - #17366: Added missing admin security annotations (by @RaimondasSapola) - - #17421: Delete free shipping voucher after creating an order on BO (by @zuk3975) - - #17445: Fix wrong address edit link (by @atomiix) - - #17241: Do not allow negative amount in order payment block (by @atomiix) - - #17325: Fix cart re-rendering after customer not found in Order creation (by @zuk3975) - - #17381: Show product customizations in the order BO page (by @atomiix) - - #17373: Fix currency localization (by @atomiix) - - #17413: Fixed warning about Maxmind DB in Geolocalization page (by @Progi1984) - - #17377: Fix modal not being hidden sometimes (by @atomiix) - - #17404: Fix order creation bug due to wrong computing precision (by @matthieu-rolland) - - #17191: Translate exception message when customer not found on address creation form (by @sowbiba) - - #17279: Fix monitoring page sorting (by @matks) - - #17331: ProfileId accepts int and string as input type although int value is required (by @jolelievre) - - #17291: Display symbols in form in case of error, remove DefaultLanguage constraint (by @jolelievre) - - #17180: Fix suppliers form description to be optional (by @zuk3975) - - #17232: Rebuild Create an Order page assets (by @matks) - - #17229: Recompute FOSJSRouting JSON file (by @matks) - - #17132: Javascript errors in BO's webservice and login page (by @matthieu-rolland) - - #16883: Fixed filtering for date in Back Office / Logs (by @PrestaworksNiklas) - - #16860: Fix United Kingdom VAT issue for all EU countries (by @jf-viguier) - - #16765: Fix recursive check of updated files (by @Darhazer) - - #16946: Modified the string in success alert for attachements bulk deletion (by @arouiadib) - - #16307: Cast employeeId to int in the bulk update employee command (by @atomiix) - - #16074: Prioritize customer search by id when saving an address (by @levyn) - - #16510: Avoid dropdowns from module page to appear under header element (by @NeOMakinG) - - #16560: Fix header for migrated Orders pages (by @matks) - - #16548: Use CMSCategory instead of CMS object model (by @PierreRambaud) - - #16542: Fix specific prices not being displayed in the BO (by @PierreRambaud) - - #16541: Fix pagination on product page listing (by @PierreRambaud) - - #16535: Fix TinyMCE not loading on safari in CMS page (by @NeOMakinG) - - #16530: Use country id while creating the Supplier form (by @PierreRambaud) - - #16457: Enable TinyMCE on add/edit supplier page BO (by @matks) - - #16461: Display display_name instead of name in theme card and add author.url (by @NeOMakinG) - - #16392: Fix error when trying to the change the quantity of a free product in an order in the BO (by @Progi1984) - - #16394: Fix typo in condition (by @mvorisek) - - #16375: Fix wrong case sensitiveness for email addresses (by @PierreRambaud) - - #16360: Fix output buffer not closed in Twig\HookExtension::renderHooksArray (by @jnvsor) - - #16319: Use customer group price display preference when displaying orders in BO (by @matks) - - #16312: Fix incorrect display value in Price Tab of admin product controller (by @WebXYAgency) - - #16159: Fix category checkbox redirect (by @atomiix) - - #16225: Fix prices display in new order page (by @sarjon) - - #16285: Fix ajax spinner not disappearing after Ajax is done (by @eternoendless) - - #16209: Use local fonts in BO default theme (by @eternoendless) - - #16271: Remove useless checkbox in product options tab for attached files (by @marionf) - - #16266: Fix ajax exception when search for a product in order creation page (by @matthieu-rolland) - - #16075: Some fixes to Orders page (by @sarjon) - - #16222: Fix error when deleting order cart rule (by @sarjon) - - #16175: Fix label not in place on BO products page in Filter by categories (by @atomiix) - - #16123: Delete supplier's address only if no other shops use it (by @atomiix) - - #16045: Fix swap-select values not being submitted in generated AdminController forms (by @L3RAZ) - - #15906: Fixes issue Undefined index _route (by @Gamesh) - - #16089: Fix "Invalid parameter: '' cannot be interpreted as a number" error (by @Progi1984) - - #16071: Fix "Call to a member function formatPrice() on null" fatal error (by @Progi1984) - - #15511: Make sure the keys used for translation are case sensitive (by @jocel1) - - #15926: Fix error SQL in getRecurseCategory method (by @marionf) - - #15909: Fix for product images in multishop BO (by @PrestaworksJonas) - - #15900: Replace usages of jQuery.live usages and add polyfill (by @matthieu-rolland) - - #15757: Fix monitoring grids id configuration (by @zuk3975) - - #15428: Add check for required fields in BO > Country > Address format (by @matthieu-rolland) - - #15514: Add condition to avoid duplicate invoice line. (by @FlorentinGarnier) - - #15111: Fix wording domains (by @eternoendless) - - #15712: Fix tabs on the product page when in Polish (by @Progi1984) - - #15546: Fix bad combination dropdown in cart rule (by @idnovate) - - #14925: Copy images from SCSS directory to the public directory when building the new theme (by @Progi1984) - - #15429: Fix Add an Employee Handler with int casting required (by @matks) - - #15397: Escape Employee email in avatar block (by @PierreRambaud) - - #15325: Remove reference to non existent css file (by @eternoendless) - - #14879: Allow changing the position of products in a category in the catalog > product page (by @PierreRambaud) - - #14168: Add missing check for CMS page category existence on create/edit actions (by @zuk3975) - - #14959: Add duplicate prices feature (by @202-ecommerce) - - #15005: Fix incorrect last visit date in the customer grid (by @cirykpopeye) - - #14977: Fix Search customer in specific group (by @khouloudbelguith) - - #13730: Fix wrong price display in BO when using a specific price in a different currency (by @123monsite-regis) - - #12903: Match multiline translation expressions in modules (by @unlocomqx) - - #12497: Fix issue with the link Manage tax rules in the pricing tab (by @khouloudbelguith) - - #13980: Execute displayAdminLogin hook without shop context (by @idnovate) - - #14656: Fix editing shop association in Category and Manufacturer (by @zuk3975) - - #14307: Fix manufacturers grid logo to not depend from shop context (by @zuk3975) - - #14543: Wrong path of products thumbnails in back office (by @matthieu-rolland) - - #14540: Update Import controller to get errors for bad category import (by @webmak) - - #14613: Fix broken translations in module list page (by @matthieu-rolland) - - #14466: Fix saving of selected BO language (by @rokaszygmantas) - - #14530: Use Preview link without option for seo preview (by @PierreRambaud) - - #14525: Fix php warning in php 7.2 in case of JSON output (by @202-ecommerce) - - #12997: Add disabled visual effect on disabled elements on the translation interface (by @francoispeyret) - - #14308: Fix wrong tax when duplicating product in BO with several taxes (multishop) (by @202-ecommerce) - - #14310: Adds missing fields validation in tax create/edit handlers (by @zuk3975) - - #14450: Whitelist filters for the Logs Page (by @Progi1984) - - #13959: Fix duplicate include of JS files in BO (by @idnovate) - - #14223: Fix unescaped dash in character group in autoloader regex (by @mvorisek) - - #14292: Update php-cs-fixer to latest version (by @MathiasReker) - - #13971: Fix dashboard sales stats to account for taxes and shipping costs (by @ComonSoft) - - #13894: Hook displayBackOfficeTop should be in nav container (by @jf-viguier) - - #13382: Remove money symbol from specific price reduction field (by @YeLnatSs) - - #14004: Fix generate path thumbnail image (by @dariusakafest) - - #13798: Use password input type for imap password field (by @marionf) - - #13571: Enable grid search button by default (by @zuk3975) - - #13572: Add FiltersSubmitButtonEnablerExtension to profiles page (by @zuk3975) - - #13454: Fix on product redirect in SEO tabs (by @YeLnatSs) - - #13425: Fix border inside tabs even when counter is empty (by @YeLnatSs) - - Refactoring: - - #18130: Use grid common search action where possible (1.7.7.x controllers only) (by @zuk3975) - - #17907: Fix TinyMCEEditor that shouldn't handle language switching by adding a TranslatableField (by @NeOMakinG) - - #17528: Fix all 1.7.7.x controllers and routes to comply with conventions (by @tdavidsonas88) - - #17715: Fix print css (by @matks) - - #17187: Delete migrated AdminRequestSqlController again - part 2 (by @matks) - - #17077: Remove unused legacy Customer Adresses files (by @matks) - - #17169: Refacto partial refund handler (by @jolelievre) - - #17175: Replace partialRefund form/builder/dataProvider with CancelProduct (by @matthieu-rolland) - - #16207: Migrate summary block of BO create order page (by @zuk3975) - - #15300: Migration for Sell > Customers > Addresses create/edit forms (by @RaimondasSapola) - - #15003: Migration Catalog > Files and Catalog > Files Edit and create forms (by @RaimondasSapola) - - #16588: Unhide monitoring sf page (by @matks) - - #16621: Remove legacy unused Order Slip files (by @matks) - - #13903: Migrate Sell > Orders > Credit slips page (by @zuk3975) - - #16267: Finish migration "Catalog > Monitoring" page (by @atomiix) - - #14288: Migrate Customer Service view (by @sarjon) - - #15229: Migration of Sell > Customers > Addresses page (by @RaimondasSapola) - - #13716: Migrate Sell > Catalog > Catalog price rule create/edit action (by @zuk3975) - - #15915: Migration of International > Taxes > Tax rules page (by @matks) - - #15982: Migrate product component for Orders page (by @RaimondasSapola) - - #16022: Migrate order action and status block (by @sarjon) - - #15901: Implement discounts management in Order View page (by @sarjon) - - #15899: Migrate BO order creation page - part 2. Handle shipping block (by @zuk3975) - - #15955: Migrate Customer block of Order view page (by @sarjon) - - #15778: Migrate Payment block of Order view page (by @sarjon) - - #14040: Migrate Sell > Catalog > Attributes & Features > Attributes list (by @zuk3975) - - #14864: Migrate Catalog > Files page (by @RaimondasSapola) - - #15814: Implement cart information providing in BO order creation page - part 1 (by @zuk3975) - - #15766: Prepare Twig templates for Add Order page (by @zuk3975) - - #15650: Migrate "Catalog > Brand & Suppliers > Suppliers create/edit action (by @matks) - - #13584: Migrate Sell > Catalog > Discounts > Catalog Price Rules list (by @zuk3975) - - #14707: Migration of "add cart rule" action (by @rokaszygmantas) - - #14991: Fix Monitoring grids data for multishop (by @zuk3975) - - #14869: Removes AdminPreferencesController again (by @matks) - - #14873: Remove AdminManufacturer controller again (by @matks) - - #14800: Add category to product CQRS command (by @matthieu-rolland) - - #14872: Delete migrated AdminCmsController again (by @matks) - - #13529: Migrate Sell > Catalog > Monitoring listing action (by @zuk3975) - - #13515: Migrate Sell > Catalog Brands & Suppliers > Suppliers view action (by @zuk3975) -- Front Office: - - New feature: - - #17410: Add FO hook displayFooterCategory (by @matks) - - #16013: New design for homepage slider on mobile (by @Progi1984) - - #14033: Introduce FO JS event showErrorNextToAddtoCartButton to handle shoppingcart error returns (by @matks) - - Improvement: - - #18221: Backport #16837 to 1.7.7.x : Add breadcrumbs to my account pages (by @matks) - - #17577: Prevent email enumeration (by @PierreRambaud) - - #16857: Changing brand page style (by @NeOMakinG) - - #16524: Switch select of ps_brandlist to a bootstrap dropdown (by @NeOMakinG) - - #16526: Change suppliers select into bootstrap dropdown (by @NeOMakinG) - - #16340: Fix bullets of bulleted lists being removed by default (by @rdy4ever) - - #16052: Fix Very strict selector div.delivery-option (by @davidglezz) - - #16180: Use Media Server for assets (CSS, JS, Images) (by @Progi1984) - - #16069: Change wording in FO when there is specific price by quantity (by @atomiix) - - #16063: Improve wording on order confirmation email (by @atomiix) - - #16126: Change checkout button wording (by @atomiix) - - #15916: Set emailsubscription input required (by @davidglezz) - - #15501: Updated blockReassurance in composer.json (by @Progi1984) - - #13517: Show free shipping indication only if appropriate (by @hacchus) - - #15750: Update jQuery to 3.4.1 in Core theme and Classic theme (by @matthieu-rolland) - - #15176: Enable modules to know the current checkout process step (by @matks) - - #15603: Allow access to Checkout process (by @matks) - - #15271: Use aria-label instead of .sr-only hidden span (by @davidglezz) - - #15354: Updated prestashop/ps_emailsubscription to 2.5.0, prestashop/ps_facetedsearch to 3.2.1, prestashop/ps_contactinfo to 3.2.0 (by @Progi1984) - - #15013: Fix URLs for non-default combinations (by @Amazzing) - - #14539: Make email display dependant on configuration from ps_contactinfo module (by @matthieu-rolland) - - #15055: Fix duplicate class attribute in HTML element (by @asf-harlock) - - #14710: Make last breadcrumb element not clickable (by @matthieu-rolland) - - #12883: Add breadcrumb to the suppliers page (by @SebBareyre) - - #12882: Add breadcrumb to the best sales page (by @SebBareyre) - - #12881: Add breadcrumb to the prices drop page (by @SebBareyre) - - #12880: Add breadcrumb to the new products page (by @SebBareyre) - - #14214: Handle shoppingcart error returns properly - part 2 (by @matks) - - #14437: Translate aria-label in modal close button (by @davidglezz) - - #14049: Allow template vars override in hook actionFrontControllerSetVariables (by @Matt75) - - #13383: UI improvements for classic theme (by @YeLnatSs) - - #14079: Update Smarty comments to reflect related blocks (by @prestamodule) - - Bug fix: - - #18427: Fix issue when there is a quantity discount on combination products (by @matthieu-rolland) - - #18743: Fix FO Exception after category add on multilang shop (by @sowbiba) - - #17917: Use appropriate hook name in contact right column (by @jolelievre) - - #18061: Order page: fix stock value update when editing a product (by @matthieu-rolland) - - #17843: Fix classic them subcategories in menu displayed hover menu by improving JS selector (by @NeOMakinG) - - #18073: Checkout address edition is failing due to missing id_address in action (by @PierreRambaud) - - #17767: Multishop - BO : Fix orders not appearing in order list for shared space shops (by @matthieu-rolland) - - #17901: The button add to cart shouldn't be enabled when minimal quantity > quantity (by @arouiadib) - - #17438: Fix submenu not displayed on mobile on classic theme (by @NeOMakinG) - - #17677: Reintroduce hook displayAdditionalCustomerAddressFields (by @eternoendless) - - #16863: Fix a bug where product images were not scrollable after product refresh (by @NeOMakinG) - - #17342: Make rewrite pattern non greedy (by @andromaque) - - #17349: Classic Theme : enable some hooks for BlockReassurance (by @Progi1984) - - #16520: Fix contact layout not working at all (by @NeOMakinG) - - #16574: Fix product cannot be deleted from cart IF another customization is made and not added to cart yet (by @Hlavtox) - - #16724: Fix multiple cart rules calculation (by @atomiix) - - #17005: Adding default "Select" when sort not up in FO is selected on category page (by @NeOMakinG) - - #16856: Show list bullets on product page and align it (by @NeOMakinG) - - #17002: Correcting price alignment on RTL language (by @NeOMakinG) - - #16915: Protect checkout forms to avoid submitting multiple times (by @atomiix) - - #16868: Show "No picture" image instead of broken one (by @prestamodule) - - #16638: Fix logic and display of customer's cart rules (by @Hlavtox) - - #16528: Change links block style in carrier process (by @NeOMakinG) - - #16571: Fix total tax in order confirmation (by @Hlavtox) - - #16531: Round remaining value of reduction amount (by @202-ecommerce) - - #16550: Fix var not displayed in emails when mail address is in uppercase (by @marionf) - - #16504: Display 3 products on the same line on home with 2 columns layout (by @NeOMakinG) - - #16503: Hide pack products' prices when the show price option is disabled (by @NeOMakinG) - - #16478: Fix shipping method design in payment tunnel (by @NeOMakinG) - - #16250: Fix wrong product alignment in product lists for smaller devices (by @rdy4ever) - - #16468: Fix issue where html tags from ps_emailsubscription module would be escaped and not interpreted as HTML (by @NeOMakinG) - - #16087: Fix no carriers in checkout bad cart rules (by @matks) - - #16147: Add CSS sizes for images in custom text block (by @Klemart3D) - - #16235: Fix how discounts are displayed in cart summary when using vouchers (by @matthieu-rolland) - - #16049: Fix number of DL & expiration date being displayed in the download virtual product mail (by @atomiix) - - #16114: Add missing placeholder in the Private Note textarea (by @atomiix) - - #16085: Get locale from Context current locale instead of repository in OrderDetailLazyArray (by @Progi1984) - - #15987: Check if customized product image exists before trying to delete it (by @jf-viguier) - - #16014: Fix html being displayed in download virtual product text mail (by @atomiix) - - #15872: Check mimum quantity for products in the basket order (by @matthieu-rolland) - - #15623: Do not allow to put item in cart if available quantity is 0 (by @matks) - - #15851: Fixed missing translation for tax label (by @JevgenijVisockij) - - #15706: Wrong combinaison reference in customer account order history (by @PululuK) - - #15799: Fix association of payment methods with delivery module (by @Seleda) - - #15840: Do not apply htmlentities before insterting message in db (by @matthieu-rolland) - - #15549: Fix calculation price in group reductions when in tax excluded mode (by @matthieu-rolland) - - #15297: Fix missing wrapper in quickview displayProductAdditionalInfo hook (by @dheerajwebkul) - - #15758: Fix image not correctly resized in FO product listing if height is too high (by @PierreRambaud) - - #14489: Disallow ordering a product that was transformed from regular into product with combinations (by @202-ecommerce) - - #15748: Use cover photo in listing instead of default combination (by @PierreRambaud) - - #13022: Remove deprecated customization constants & fix undefined index notice (by @shaffe-fr) - - #15739: Fix product not being added to cart after deleting product customisation (by @PeeyushAgrawalWebkul) - - #15710: Prevent rage clicking on checkout steps submit button (by @rdy4ever) - - #15216: Allow users to edit address alias during checkout (by @pauloffb) - - #15533: Disallow showing bad cart to FO user (by @matks) - - #15632: Remove unneccessary slash on Home category breadcrumb (by @JBWModules) - - #15399: Fix bug keeping users from choosing a carrier before cart order completion (by @matthieu-rolland) - - #15512: Fix unclosed

html tag (by @davidglezz) - - #15314: Fix not being able to remove automatically applied cart rule (by @damiandominella) - - #15352: Fix quicksearch results missing the category name (by @JulianEberius) - - #15368: Fix breadcrumb SEO (by @davidglezz) - - #15326: Fix color name not appearing over the color block in the product pages (by @dineshbadrukhiya) - - #15357: Fix typo and avoid card-block border show when note is empty (by @PrestaShark) - - #15276: Fix one column row without colspan (by @davidglezz) - - #14937: Fix display bug in classic theme when hooking the ps_emailsubscription module to the left column (by @Progi1984) - - #15167: Fix not product not appearing in search results after having enabled it (by @PeeyushAgrawalWebkul) - - #14727: Fix compile id {render} override issue on theme (by @202-ecommerce) - - #14819: Fix create account sitemap link (by @Thomas-lhuillier) - - #13677: Fix submenu hiding menu in classic theme (by @YeLnatSs) - - #14558: Implement Schema ItemList for products listing & Fix Schema Product (by @Progi1984) - - #14587: Fix issue when searching for long words in FO (by @matthieu-rolland) - - #14567: Remove image in about us CMS page (by @marionf) - - #14507: Fix bug in FO translations with multiple resources and tpl inclusions (by @202-ecommerce) - - #14422: Refactor theme usage of product flags - apply DRY (by @matks) - - #14452: Allow to buy a product without stock when other combinations have stock and unavailable product attributes are not displayed (by @Progi1984) - - #14263: Fix display voucher conversion between currencies (by @tomlev) - - #14385: Fixed duplicated block name (by @aleksiuno) - - #13804: Fix shared smarty compilation ID across shops / themes (by @202-ecommerce) - - #13687: Fix notice when trying to create a return for an order item that has already been returned (by @Codencode) - - #13704: Fix exclude discounted products on CartRule (by @tomlev) - - #13387: Fix image size in summary not limited (by @YeLnatSs) - - Refactoring: - - #15277: Combine two equal adjacent selectors (by @davidglezz) - - #15284: Make color and texture consistent when both are set (by @davidglezz) - - #16099: Make checkout js code easier to understand (by @atomiix) - - #15083: Use aria-label instead of hidden sr-only span in variant links (by @pojebunny) -- Core: - - New feature: - - #18475: Enable controllers as a service through autowiring (by @matks) - - #14428: Introduce fuzzy search (by @Lathanao) - - #14134: Combine consecutive issets() (by @Quetzacoalt91) - - #13384: Add naming convention linter (by @sarjon) - - #13200: Add SecurityAnnotation linter (by @sarjon) - - Improvement: - - #18201: Optimize the 1.7.7 translation catalog (by @matthieu-rolland) - - #18617: Make computing precision matching currency's display precision (by @matthieu-rolland) - - #17734: Register new hook displayFooterCategory for 1770 and rename order hooks (by @matks) - - #18050: Use proper computing precision in payment module (by @matthieu-rolland) - - #17889: Add displayAdditionalCustomerAddressFields hook during update (by @matthieu-rolland) - - #17731: Fix license headers (by @matks) - - #17149: Cancel product (by @matthieu-rolland) - - #17579: Update license headers 2020 (by @PierreRambaud) - - #17537: Increase timeout to download translation packages from 5 to 20 seconds (by @jolelievre) - - #13761: Add compatibility with PHP 7.3 (by @mickaelandrieu) - - #8770: Remove file 'fileType' when deleting images (by @marekhanus) - - #17067: PHPDocumentation on Category constructor (by @zalexki) - - #16714: Update composer.json requirements (by @gavinkalika) - - #17048: Update nginx configuration (by @PierreRambaud) - - #16144: Migrate hooks for new Order view page (by @sarjon) - - #16789: Security policy (by @PierreRambaud) - - #16383: Currencies are customizable and prices are shown accordingly (by @jolelievre) - - #16429: Upgrade Smarty to v3.1.34 (by @matks) - - #14894: Use utf8mb4 charset to support emoji (by @PierreRambaud) - - #16454: Add comments about DataLang (by @eternoendless) - - #16404: Improve cache for staticPrice for products with combinations (by @Progi1984) - - #16433: Update license headers (by @matks) - - #16316: Allow to define authorized MIME types in ImageManager::validateUpload() (by @Progi1984) - - #16310: Add ps_dataprivacy, productcomments and ps_crossselling as native modules (by @PierreRambaud) - - #15902: Use the correct environment depending on what you are doing (dev, test, and prod) (by @PierreRambaud) - - #16331: Add "total_shipping_tax_excl" and "total_shipping_tax_incl" in email data (by @yannicka) - - #16176: Increase maximum hook length to 191 characters (by @eternoendless) - - #15022: Migration of Sell > Customer Service > Merchandise Returns page (by @rokaszygmantas) - - #16241: Improve install doc (by @matks) - - #16237: Set Demo mode only if undefined (by @Quetzacoalt91) - - #16097: Improvement on product image generation for high definition images. (by @Prestaworks) - - #16041: Remove google plus from login footer (by @mohamedaitbella) - - #13636: Add zones for: Austria, Switzerland, Denkmark, Netherlands, Thailand (by @manfield) - - #15755: Make CLDR Specification\Number immutable (by @Progi1984) - - #14665: Allow to display/hide manufacturers and suppliers independently (by @matthieu-rolland) - - #15656: Update license headers (by @matks) - - #15723: Fix typos (by @Zzareb) - - #15551: Update php docs on currency class (by @zalexki) - - #15552: Update php docs for class customer (by @FlorianBergeron) - - #15557: Update php docs in class PaymentModule (by @FlorianBergeron) - - #15555: Fix php docs in class Mail (by @FlorianBergeron) - - #15550: Update php docs for link class (by @FlorianBergeron) - - #15520: Remove old docs files (by @matks) - - #15340: Update minimum compatibility to PHP 7.1.3 (by @eternoendless) - - #15393: Update php docs for PaymentModule::getCurrency() (by @v4lux) - - #14838: Update invalid characters in Customer Creation & Update error messages and tips (by @Progi1984) - - #14951: Update PrestaShopCollection.php docs on getFirst method return type (by @zalexki) - - #15010: Make EmployeeId accept integers only (by @gavinkalika) - - #15079: Fix phpdoc for parameter type in module::updatePosition() (by @zalexki) - - #14949: Update Module.php docs on version property type (by @zalexki) - - #13830: Remove duplicate var in cart.php (by @davidglezz) - - #13906: Update CLDR data to 35.1 (by @eternoendless) - - #14691: Update version to 1.7.7.0 (by @jolelievre) - - #14246: Add doctrine filters applicator (by @sarjon) - - #14545: Remove english emails since they are generated now (by @jolelievre) - - #14116: Do not set a cookie if it finally has not changed (by @jocel1) - - #14232: Fix string line ending (by @MathiasReker) - - #14233: Use __DIR__ constant (by @MathiasReker) - - #14165: Fix Phpdoc (by @Matt75) - - #13803: Make the movement of the Grid columns really easy (by @mickaelandrieu) - - #13818: Remove redundant condition in cart.php (by @davidglezz) - - #13606: Fix phpdoc on Module class (by @Matt75) - - #13486: Fix coding style on develop (by @matks) - - #13236: Add ajax support for @AdminSecurity annotation (by @sarjon) - - #13119: Allow hookAdditionalCustomerFormFields and --AddressFormFields to modify fields positions (by @rblaurin) - - Bug fix: - - #18851: Build assets for Beta (by @jolelievre) - - #18234: Fix guest to customer transformation issue (by @matthieu-rolland) - - #17561: Allow cyrilic domain names in email addresses (by @atomiix) - - #18144: Fix CartRule : Discount on selected product excluding discounted products (by @Progi1984) - - #17733: Unwanted spaces in 1.7.7.0.sql file (by @matks) - - #17288: Upgrade Symfony 3.4 (by @mvorisek) - - #17307: Do not force memory_limit in index_cli.php (by @PierreRambaud) - - #17254: Fix deleted products not being displayed in orders (by @atomiix) - - #17246: Update Cs Fixer configuration (by @PierreRambaud) - - #15942: Fix docker compose not being able to stat files (by @PierreRambaud) - - #16733: Fix new connection detection (by @mvorisek) - - #16635: Fix discount calculation if two gift-cartrules exist for the same product. (by @Hlavtox) - - #16586: Do not escape translations when using the legacy translator from the new one (by @PierreRambaud) - - #16459: Fix behavior of Module::isRegisteredInHook() (by @Matt75) - - #16410: Make sure to get correct lang fields for shop (by @kpodemski) - - #16465: Upgrade SQL scripts can use DB_NAME, release creator regex fix, Tab.enable upgrade script fixed (by @jolelievre) - - #16334: Fix wrong flag on some languages (by @eternoendless) - - #16213: Make id_order available everywhere where order_name is available (by @atomiix) - - #12379: Fix of the carrier choice in payment preferences, product editor and cart rules (by @Rolige) - - #16072: Remove require config.inc.php on all commands and fix a notice (by @202-ecommerce) - - #16111: Check that ShippingCostTax values are not null before being formatted (by @Progi1984) - - #15805: Fix Cannot use object of type ParameterBag as array (by @davidglezz) - - #15974: Fix wrong verification of number of languages (by @dariusakafest) - - #15967: Use midnight for birthdate verification (by @eternoendless) - - #15903: Hide bad vouchers that should not be displayed to customers (by @matks) - - #15616: Refuse empty customer first and last names (by @matks) - - #15642: Fix wrong breadcrumb on home category (by @jocel1) - - #15625: Properly cleanup the customization table if no more customized_data (by @jocel1) - - #15577: Update symfony/phpunit-bridge dependency for security reason (by @PierreRambaud) - - #15447: Re-enable port in shop domains (by @matks) - - #15437: Finalize Update License Command (by @matks) - - #15439: Give more memory to php-cs-fixer (by @matks) - - #15426: Fix license headers (by @matks) - - #14609: Fix modules translations files in theme erased by modules translations that are in modules folder (by @bm-services) - - #14702: Fixes wrong visitor group assumed on multistore (by @matthieu-rolland) - - #15027: Fix typo in Employee processing (by @gavinkalika) - - #14601: Revert removed templates for mail dynamic contents, order mails mainly, create MailPartialTemplateRenderer to manage this feature (by @jolelievre) - - #14859: Move i18n.prestashop.net into https and remove unwanted file (by @PierreRambaud) - - #14352: Move Cart secure_key setter at the right place (by @jocel1) - - #14089: Fix shop URL with port in header HOST (by @202-ecommerce) - - #14529: Fix position problem on a fresh install (by @PierreRambaud) - - #14560: Typo fix on bug issue template (by @PierreRambaud) - - #13983: Fix empty tag in webservice XML response (by @pumamood) - - #14403: Fix cookie collisions from PR # 14116 and improve overall security (by @mvorisek) - - #14043: Check if Combination id is set before deleting Associations from database to prevent accidentally removing all products without attributes from all carts (by @kazeno) - - #14273: Fix SQL error due do while not ended (by @123monsite-regis) - - #13711: Compare strictly value of hook name when getting modules registered on it (by @Quetzacoalt91) - - #13609: Fix dispatched hook on the Grid presenter: actionGridFilterFormModifier (by @mickaelandrieu) - - #13542: Merge 1.7.6.x to develop - 23/04/2019 (by @matks) - - #13232: Fix wrong cart calculation using rules with free Gift (by @123monsite-regis) - - Refactoring: - - #18564: Refactoring using OrderAmountUpdater (by @Progi1984) - - #15965: Implement CQRS on Notifications (by @atomiix) - - #15448: Replace uses of deprecated Tools::displayPrice in favor of Locale::formatPrice() (by @Progi1984) - - #14970: Migration of Order message page (by @sarjon) - - #15388: Migration of Orders View page (by @sarjon) - - #15371: Fix duplicate retrieval of attributes color list (by @lvancrayelynghe) - - #13988: Migrates Orders list - part 1 (by @sarjon) - - #14065: Migrate Shopping Carts view page (by @sarjon) - - #13712: Prepare Command API for migrating Order view page (by @sarjon) - - #13554: Prepares Command/Query API for migrating "Create order" page (by @sarjon) - - #13736: Replace all calls to $this->l() in controllers (by @eternoendless) -- Installer: - - Improvement: - - #17914: Add index on product table for fresh install (by @jolelievre) - - #16527: Check memory_limit during installation (by @PierreRambaud) - - #16104: Update order status colors (by @sarjon) - - #15888: Update jQuery to 3.4.1 in installation pages (by @matthieu-rolland) - - Bug fix: - - #17642: Fix SQL request for order detail (by @jolelievre) - - #16941: Bad wording when installation check (by @gavinkalika) - - #16506: Set minimum PHP version to 7.1.3 (and not 7.1) (by @eternoendless) - - #16305: Fix SQL upgrade for 1.7.7.0 (missing FROM) (by @matks) - - #15404: Update Postal Code of South Korea (by @khouloudbelguith) - - #15131: Fix permanent redirection in installer (by @mickaelandrieu) -- Web Services: - - Improvement: - - #8769: Auto generate link_rewrite and do not require it when creating category via webservice (by @marekhanus) - - Bug fix: - - #14899: Make the container available in WebService environment (by @Progi1984) -- Localization: - - New feature: - - #17763: Update catalog for 1.7.7.0 (by @jolelievre) - - #17645: Backport #16927 (by @atomiix) - - #16173: Add Ivory Coast as a supported country (by @SylNicky) - - Improvement: - - #16834: Switch zone for BA, LI, and UA (by @LouiseBonnard) - - #16690: Add Khmer language (by @LouiseBonnard) - - #16489: Remove unofficial languages from language packs (by @eternoendless) - - #16416: Added albanian & korean to the installer (by @Progi1984) - - #15627: Added states to India (by @Progi1984) - - #16078: Update Argentinian conversion and tax rates (by @LouiseBonnard) - - #16291: Update tax rates for several countries (by @eternoendless) - - #16079: Update Azerbaijani tax rates (by @LouiseBonnard) - - #16292: Add missing languages to localization packs (by @eternoendless) - - #16244: Update Costa Rican, Peruvian and Brazilian tax rates (by @LouiseBonnard) - - #16218: Add and update tax rates (by @LouiseBonnard) - - #16190: Update Moldavian tax rates (by @LouiseBonnard) - - #16189: Update Japanese tax rates (by @LouiseBonnard) - - #16193: Update Norwegian tax rates (by @LouiseBonnard) - - #16181: Update Ecuadorian tax rates (by @LouiseBonnard) - - #16188: Update Iranian tax rates (by @LouiseBonnard) - - #16182: Update Egyptian tax rates (by @LouiseBonnard) - - #16183: Update Fijian tax rates (by @LouiseBonnard) - - #16186: Update Indonesian tax rates (by @LouiseBonnard) - - #16185: Update Guyanan tax rates (by @LouiseBonnard) - - #16187: Update Israeli tax rates (by @LouiseBonnard) - - #16179: Update Dominican Republic tax rates (by @LouiseBonnard) - - #16161: Update Colombian tax rates (by @LouiseBonnard) - - #16160: Update Swiss tax rates (by @LouiseBonnard) - - #16000: Update Indian tax rates (by @ashishsharawat) - - #16055: Update Greek tax rates (by @LouiseBonnard) - - #16020: Update Turkish currency sign (by @LouiseBonnard) - - #15968: Update Swedish tax rates (by @LouiseBonnard) - - #15969: Update Mexican tax rates (by @LouiseBonnard) - - #15618: Switched zone for Croatia from "Europe (non-UE)" to "Europe" (by @Progi1984) - - Bug fix: - - #18420: Change error message for invalid product quantity (by @jolelievre) - - #18504: Fix wording in classic guest mail template (by @jolelievre) - - #17757: Fix cancel product type translation domain (by @jolelievre) - - Refactoring: - - #18652: Remove useless traduction wordings and exception codes (by @jolelievre) - - #16347: Update CLDR to latest version 36 (2019-10-04) (by @ziegenberg) -- Tests: - - New feature: - - #17094: Add twig lint check and move bash script from tests-legacy to tests (by @matks) - - Improvement: - - #18540: Improve nightly log reports (by @PierreRambaud) - - #17965: Add HTML IDs and classes to View Customer BO page (by @matks) - - #17532: Fix PHP CS Fixer configuration: disable single_line_throw and backport #17328 (by @matks) - - #17028: Behat tests for Customer, Address features handlers (by @tdavidsonas88) - - #16525: Behat tests for orders in the Back Office. Various Behat features created and scenarios added (by @tdavidsonas88) - - #16966: Cover Category CommandHandlers and QueryHandlers by behat tests (by @tdavidsonas88) - - #16776: Cover Contact CommandHandlers and QueryHandlers by behat tests (by @tdavidsonas88) - - #16807: Travis: update config for dpl v2 (by @mvorisek) - - #16712: Add unit test for profile ID test (by @gavinkalika) - - #16757: Add behat tests for miscellaneous command/handlers: SwitchDebugMode, CloseShowcaseCard, GetShowcaseCardIsClosed, GenerateThemeMailTemplates, AddEmployee (by @tdavidsonas88) - - #16317: Only trigger deploy on cron task, and tests on push / pull requests (by @PierreRambaud) - - #15586: Remove deprecated StarterTheme tests (by @matks) - - #14971: Trigger nightly report (by @PierreRambaud) - - #14670: Add Behat tests for Customer commands (by @sarjon) - - #14725: Move travis scope from 5.6 to 7.1 (by @matks) - - #14287: Behat tests for Category (by @sarjon) - - #14231: Remove expectedException PHPUnit annotation (by @MathiasReker) - - #14109: Cover Webservice key management with Behat tests (by @sarjon) - - #14235: Remove unused imports (by @MathiasReker) - - #14234: Add missing braces (by @MathiasReker) - - #13790: Add Behat tests for Currency Domain (by @sarjon) - - #13862: Improve E2E report (by @PierreRambaud) - - #13018: Only run deploy if the triggered commit is recent (by @PierreRambaud) - - #13495: Add behat tests for customer Commands and Queries (part 1) (by @matks) - - Bug fix: - - #18548: Composer failed to be installed properly (by @PierreRambaud) - - #18339: Fix behat tests that add payments (by @jolelievre) - - #18239: Update tests data with taxes to fix behat tests (by @jolelievre) - - #18023: Modify test data generation to handle price with taxes (by @jolelievre) - - #17746: Restore GA for PHP CS Fixer (by @matks) - - #17643: CS fix (by @jolelievre) - - #16809: Fix date parsing in tests when TZ is changed to non-UTC during tests (by @mvorisek) - - #16998: Fix #16997 - assertion of first/classic theme from unsorted list (by @mvorisek) - - #15912: Fix missing currency in behat test (by @matthieu-rolland) - - #15848: Fix E2E dockerfile as npm is not anymore in the nodejs package (by @PierreRambaud) - - #15519: Fix Close browser after each scenario (by @boubkerbribri) - - #15161: Remove another faulty e2e test from Travis (by @matks) - - #14531: Remove another faulty e2e test from Travis (by @matks) - - #14491: Disable Selenium Guest scenario as it fails randomly (by @matks) - - #13826: Enable global kernel for legacy compatibility for Behat tests (by @matks) - - #13827: Revert "Only run deploy if the triggered commit is recent" (by @PierreRambaud) - - #13824: Update tests and package-lock (by @PierreRambaud) - - Refactoring: - - #18843: Functional tests - Create edit view voucher in customer information page (by @nesrineabdmouleh) - - #18840: Functional tests - Change selectors for advanced params pages (by @boubkerbribri) - - #18832: Functional tests - Change selectors orders pages (by @boubkerbribri) - - #18804: Change selectors (by @SimonGrn) - - #18800: Functional tests - Fix number of element in table for emails logs page (by @boubkerbribri) - - #18797: Functional tests - Refacto tests order settings (by @boubkerbribri) - - #18775: Functional tests - Renaming functions in files.js (by @boubkerbribri) - - #18774: Functional tests - Fix test filter email logs (by @boubkerbribri) - - #18575: Functional tests - Fix delete with bulk actions address (by @nesrineabdmouleh) - - #18753: Functional tests - Fix test name export languages (by @boubkerbribri) - - #18477: Functional tests - Product settings label oos allowed/denied backorders (by @nesrineabdmouleh) - - #18754: Functional tests - View customer (by @nesrineabdmouleh) - - #18756: Functional tests - Add test delivery time out of stocks (by @boubkerbribri) - - #18745: Functional tests - Improve test 'Filter stocks by categories' (by @boubkerbribri) - - #18718: Functional tests - Refacto credit slips tests (by @boubkerbribri) - - #18716: Functional tests - Fix tests enable brands and suppliers pages (by @boubkerbribri) - - #18720: Functional tests - change url for reporting (by @SimonGrn) - - #18688: Update README files for tests directory (by @SimonGrn) - - #18682: Functional tests - Fix wrong import for tests modules (by @boubkerbribri) - - #18670: Fix tests that are always green when the shop is broken (by @nesrineabdmouleh) - - #18677: Functional tests - Fix call for module (by @SimonGrn) - - #18639: Functional tests - Moving FO pages (by @boubkerbribri) - - #18669: Functional tests - Add delete modal to test bulk delete order messages (by @boubkerbribri) - - #18662: Functional tests - Fix customer creation in BO (by @boubkerbribri) - - #18631: Functional tests - Refacto orders and invoices tests (by @boubkerbribri) - - #18616: Functional tests - Add test download sample files for import (by @boubkerbribri) - - #18621: Functional tests - Add test 'Update default products order' (by @boubkerbribri) - - #18577: Functional tests - Update some tests titles (by @boubkerbribri) - - #18207: Functional tests - Product settings enable/disable display discounted price (by @nesrineabdmouleh) - - #18505: Functional tests - Payment > Preferences test group restrictions (by @nesrineabdmouleh) - - #18490: Functional tests - Add test 'Send a test email' (by @boubkerbribri) - - #18436: Functional tests - Add test 'Enable delivery time in stock products' (by @boubkerbribri) - - #18486: Functional tests - Fix test filter stocks by category (by @boubkerbribri) - - #18426: Functional tests - Add test for order setting gift options (by @boubkerbribri) - - #18452: Functional tests - Add tests Help card for pages employees, profiles, db backups, sql manager and webservice (by @boubkerbribri) - - #18457: Functional tests - Add filter customer to 'Filter orders' tests (by @boubkerbribri) - - #18465: Functional tests - Add test 'Export languages' in translations page (by @boubkerbribri) - - #18442: Functional tests - Add tests help card for pages Localization, Currencies and Languages (by @boubkerbribri) - - #18435: Functional tests - Localization test default language (by @nesrineabdmouleh) - - #18422: Functional tests - Product settings test label of in-stock products (by @nesrineabdmouleh) - - #18401: Functional tests - Filter delete and delete with bulk actions email (by @nesrineabdmouleh) - - #18375: Functional tests - Product settings enable/disable stock management (by @nesrineabdmouleh) - - #18332: Functional tests - Wait for navigation in go to maintenance tab function (by @boubkerbribri) - - #18369: Functional tests - Add test 'Sort cms pages' (by @boubkerbribri) - - #18367: Functional tests - Add tests helper card for brands and suppliers (by @boubkerbribri) - - #18350: Functional tests - Add test 'Bulk update orders status' (by @boubkerbribri) - - #18313: Functional tests - CRUD sql query (by @nesrineabdmouleh) - - #18371: Functional tests - Order settings enable/disable terms of service (by @nesrineabdmouleh) - - #18308: Functional tests - Add test 'Check delivery slip downloaded from list' (by @boubkerbribri) - - #18311: Functional tests - Add new client filter to order test (by @boubkerbribri) - - #18342: Functional tests - Add test 'Filter stocks by category' (by @boubkerbribri) - - #18290: Functional tests - Test minimum purchase total required in order to validate the order (by @nesrineabdmouleh) - - #18317: Functional tests - Add test 'Update number of products displayed per page' (by @boubkerbribri) - - #18306: Functional tests - Add test 'Check invoice downloaded from orders list' (by @boubkerbribri) - - #18161: Functional tests - Add test Enable and disable B2B mode (by @boubkerbribri) - - #18269: Functional tests - Add test 'Help card' for Stocks page (by @nesrineabdmouleh) - - #18268: Functional tests - Add test 'Help card' for Monitoring page (by @nesrineabdmouleh) - - #18272: Functional tests - Add test 'Export Orders' (by @boubkerbribri) - - #18267: Functional tests - Fix update successful message on addresses page (by @boubkerbribri) - - #18197: Functional tests - Order settings enable/disable reordering option (by @nesrineabdmouleh) - - #18231: Functional tests - Fix default timeout for waiting for selector (by @boubkerbribri) - - #18242: Functional tests - Add test 'Help card' for orders page (by @boubkerbribri) - - #18250: Functional tests - Add test 'Filter orders' (by @boubkerbribri) - - #18216: Functional tests - Retry to create Browser 3 times if first one fails (by @boubkerbribri) - - #18224: Functional tests - Product settings enable/disable allow ordering out of stock (by @nesrineabdmouleh) - - #18227: Functional tests - Fix selector for tests categories (by @boubkerbribri) - - #17981: Functional tests - Fix invoices and credit slips tests (by @boubkerbribri) - - #18198: Fix test 'display unavailable product attributes' (by @boubkerbribri) - - #18180: Functional tests - Add tests 'Help card' for customers and addresses (by @boubkerbribri) - - #18178: Functional tests - Add test 'Export brands' (by @boubkerbribri) - - #18112: Functional tests - Refactoring products tests (by @boubkerbribri) - - #18191: Functional tests - Order settings enable/disable guest checkout (by @nesrineabdmouleh) - - #18158: Functional tests - Add test 'Export customers' (by @boubkerbribri) - - #18148: Functional tests - Customer settings enable/disable partner offer (by @nesrineabdmouleh) - - #18174: Functional tests - Product settings separator of attribute anchor on the product links (by @nesrineabdmouleh) - - #17805: Functional tests - Order settings enable/disable final summary (by @nesrineabdmouleh) - - #17891: Functional tests - Product settings enable/disable display unavailable product attributes (by @nesrineabdmouleh) - - #18081: Functional tests - Enable/Disable multistore (by @nesrineabdmouleh) - - #18145: Functional tests - Customer settings ask for birth date (by @nesrineabdmouleh) - - #18143: Functional tests - Shop Parameters > Traffic & SEO test helper card (by @nesrineabdmouleh) - - #18156: Functional tests - Fix nightly 16-03 (by @boubkerbribri) - - #18149: Functional tests - Add test Export Categories to csv (by @boubkerbribri) - - #18133: Functional tests - Design > Pages test helper card (by @nesrineabdmouleh) - - #17921: Functional tests - Enable disable webservice key (by @nesrineabdmouleh) - - #18071: Functional tests - Customers set required fields (by @nesrineabdmouleh) - - #18002: Functional tests - Refacto customer settings redisplay cart at login (by @nesrineabdmouleh) - - #17982: Functional tests - Categories page test helper card (by @nesrineabdmouleh) - - #18056: Functional tests - Back to default sort in test 'Sort Products' (by @boubkerbribri) - - #18001: Functional tests - Refacto product settings default activation status (by @nesrineabdmouleh) - - #17998: Functional tests - Refacto product settings force update friendly URL (by @nesrineabdmouleh) - - #17997: Functional tests- Refacto product settings new days number (by @nesrineabdmouleh) - - #17996: Functional tests - Refacto product settings catalog mode (by @nesrineabdmouleh) - - #17989: Functional tests - Refacto product settings display remaining quantities (by @nesrineabdmouleh) - - #17974: Functional tests - Refacto product settings display available quantities (by @nesrineabdmouleh) - - #17948: Functional tests - Fix problem of generate files by date for nightly 29-02 (by @nesrineabdmouleh) - - #17960: Functional tests - Accept GDPR if only exist (by @boubkerbribri) - - #17910: Functional tests - Improving FO tests by adding wait for cart to disappear (by @boubkerbribri) - - #17699: Functional Tests - Product settings choose quantity discounts based on (by @nesrineabdmouleh) - - #17872: Functional tests - Invoices > Other options - delete check legal free text from scenario (by @nesrineabdmouleh) - - #17836: Funtional tests - Fix employee faker (by @boubkerbribri) - - #17795: Functional tests - Payment>Preferences Configure currency restriction (by @nesrineabdmouleh) - - #17829: Functional tests - Shop Parameters> General enable/disable display brands (by @nesrineabdmouleh) - - #17754: Functional tests - Product settings display remaining quantity in product page (by @nesrineabdmouleh) - - #17828: Functional tests - Shop Parameters> General enable/disable display suppliers (by @nesrineabdmouleh) - - #17779: Functional tests - Add new tests 'Sort categories' and 'Change category position' (by @boubkerbribri) - - #17824: Functional tests - Fix sending emails in nightly (by @boubkerbribri) - - #17772: Functional tests - Add test 'Sort Addresses' (by @boubkerbribri) - - #17775: Functional tests - Customer settings enable/disable send email after registration (by @nesrineabdmouleh) - - #17762: Functional tests - Add test 'Import localization pack' (by @boubkerbribri) - - #17756: Functional tests - Add test 'Sort customers' (by @boubkerbribri) - - #17741: Functional tests - Add test 'Sort contacts' (by @boubkerbribri) - - #17735: Functional tests - Adding wait for navigation in goToHomePage function (by @boubkerbribri) - - #17722: Functional tests - Product settings Enable/Disable display available quantities (by @nesrineabdmouleh) - - #17724: Functional tests - Add test 'Sort brands and addresses' (by @boubkerbribri) - - #17720: Functional tests - Add test 'Sort products' (by @boubkerbribri) - - #17710: Functional tests - Add movement check after update stocks quantity (by @boubkerbribri) - - #17714: Functional tests - Fix Sort tests (by @boubkerbribri) - - #17697: Functional tests - Add test 'Sort Taxes' (by @boubkerbribri) - - #17708: Functional tests - Fix validation message selector name (by @nesrineabdmouleh) - - #17605: Functional tests - Product settings enable/disable default activation status (by @nesrineabdmouleh) - - #17640: Functional tests - Customer settings enable/disable re-display cart at login (by @nesrineabdmouleh) - - #17693: Functional tests - Add test 'Sort languages' (by @boubkerbribri) - - #17530: Functional tests - Add context to functional tests (Modules And Design) (by @boubkerbribri) - - #17534: Functional tests - Add context for advanced params tests (by @boubkerbribri) - - #17543: Functional tests - Add context for shop params tests (by @boubkerbribri) - - #17567: Functional tests - Add context to international tests (by @boubkerbribri) - - #17582: Functional tests - Add context to customers, addresses and customer service tests (by @boubkerbribri) - - #17674: Functional tests - Add context to catalog tests (by @boubkerbribri) - - #17678: Functional tests - Add context to orders tests (by @boubkerbribri) - - #17652: Functional tests - Fix monitoring test (by @nesrineabdmouleh) - - #17620: Functional tests - 02_orders/ Reduce legal free text length to 10 characters (by @nesrineabdmouleh) - - #17624: Functional tests - Product settings enable/disable force update friendly url (by @nesrineabdmouleh) - - #17566: Functional tests - CRUD web service key (by @nesrineabdmouleh) - - #17555: Functional tests - Product settings max size short description (by @nesrineabdmouleh) - - #17559: Functional tests - Fix select all grid selector (by @boubkerbribri) - - #17388: Functional tests - Product settings test new days number (by @nesrineabdmouleh) - - #17518: Functional test - Add data file for module categories (by @boubkerbribri) - - #17499: Functional tests - Add new test Filter modules by categories (by @boubkerbribri) - - #17495: Functional tests - Add test for monitoring product without description (by @boubkerbribri) - - #17440: Functional tests - Add new test bulk actions languages (by @boubkerbribri) - - #17443: Functional tests - Add delete modal for tests (taxes and cms pages) (by @boubkerbribri) - - #17418: Functional tests - adding additional information to tests (by @boubkerbribri) - - #17405: Functional tests - Improve test enableDisableAccentedURL (by @boubkerbribri) - - #17386: Functional tests - Enable unofficial currency (by @boubkerbribri) - - #17375: Functional tests - Enable disable accented url (by @nesrineabdmouleh) - - #17372: Functional tests - Activate tests Profiles (by @boubkerbribri) - - #17213: Functional tests - Enable disable catalog mode from product settings page (by @nesrineabdmouleh) - - #17329: Functional tests - Fix delete with bulk actions (brand, brand address, supplier) tests (by @nesrineabdmouleh) - - #17301: Functional tests - Enable/Disable friendly url (by @nesrineabdmouleh) - - #17281: Functional tests - Addresses bulk actions (by @nesrineabdmouleh) - - #17216: Functional tests - CRUD customer address (by @nesrineabdmouleh) - - #17272: Functional tests - Limit the legal free text length to 50 (by @nesrineabdmouleh) - - #17202: Functional tests - Add numbers for all directories (by @nesrineabdmouleh) - - #17201: Functional Tests - Fix "emailThemes/01_previewEmailThemes" test (by @nesrineabdmouleh) - - #17183: Sanity tests - Fix CRUD standard product with combinations test (by @nesrineabdmouleh) - - #17168: Functional tests - Fix test customer bulk action (by @boubkerbribri) - - #17167: Functional Tests - Fix Enable Disable shop automated test (by @SimonGrn) - - #17155: Refacto partial refund along with behat tests (by @jolelievre) - - #17154: Functional tests - Fix test employee and maintenance (by @boubkerbribri) - - #17129: Functional tests - Set FR text value for custom maintenance text (by @nesrineabdmouleh) - - #17092: Functional tests - Fix other options test (by @nesrineabdmouleh) - - #17091: Functional tests - Fix Crud language test (by @boubkerbribri) - - #17084: Functional tests - Fix error in the test Enable/Disable invoices (by @nesrineabdmouleh) - - #16632: Replace deprecated "create_function" (by @mvorisek) - - #17076: Tests - Fix dockerfile for puppeteer (by @boubkerbribri) - - #17027: Functional tests - add test 'Filter modules by status' (by @boubkerbribri) - - #17061: Functional tests - Add base page for localization (by @boubkerbribri) - - #17066: Functional tests - Update confirm delete files method (by @boubkerbribri) - - #17060: Functional tests - Filter addresses table (by @nesrineabdmouleh) - - #17047: Functional tests - Enable disable image in delivery slip file (by @nesrineabdmouleh) - - #17049: Functional tests - Contact bulk actions (by @nesrineabdmouleh) - - #17052: Functional tests - Add new test 'Crud language test' (by @boubkerbribri) - - #17029: Functional Tests - Enable/Disable shop (by @nesrineabdmouleh) - - #16963: Functional tests - add test 'filter languages' (by @boubkerbribri) - - #17041: Functional tests - Fix tests brands and skip test Create unofficial currencies (by @boubkerbribri) - - #17009: Functional tests - add test 'Preview Email Themes' (by @boubkerbribri) - - #16967: Functional Tests - Add number verification for delivery slip file (by @nesrineabdmouleh) - - #16962: Functional tests - Crud contact (by @nesrineabdmouleh) - - #17013: Functional tests - Separate tests team employees and profiles (by @boubkerbribri) - - #17017: Functional tests - Update file bulk action delete message (by @boubkerbribri) - - #17006: Functional tests - Fix supplier name and zip code (by @boubkerbribri) - - #17003: Functional tests - Fix date format (mm/dd/yyyy) (by @nesrineabdmouleh) - - #16960: Functional Tests - Add prefix verification for delivery slip file (by @nesrineabdmouleh) - - #16922: Functional tests - Add Bulk actions for file tests (by @nesrineabdmouleh) - - #16905: Functional Tests - Add monitoring products test (by @boubkerbribri) - - #16923: Functional tests - Bulk delete backups (by @boubkerbribri) - - #16959: Functional tests - Add new test : CRUD Seo Page (by @boubkerbribri) - - #16914: Functional Test - Add new test : filter SEO pages grid (by @boubkerbribri) - - #16931: Functional tests - add test filter stocks by status (by @boubkerbribri) - - #16886: Functional Tests - Generate delivery slip by date (by @nesrineabdmouleh) - - #16909: Functional tests - Add filter contacts tests (by @nesrineabdmouleh) - - #16908: Functional Test - Add new test CRUD files (by @boubkerbribri) - - #16900: Functional tests - Disable tests profile including creation (by @boubkerbribri) - - #16897: Tests - Fix tests : invoices options (by @boubkerbribri) - - #16884: Functional Tests - Test credit slip options (by @nesrineabdmouleh) - - #16882: Functional Tests - Generate credit slip by date (by @nesrineabdmouleh) - - #16881: Functional tests - Fix tests 'CRUD customer' and 'CRUD Category' (by @boubkerbribri) - - #16831: Functional Tests - Create, check and filter credit slips (by @nesrineabdmouleh) - - #16875: Functional Tests - Delete Category from monitoring page (by @boubkerbribri) - - #16772: Functional Tests - Test prefix in the invoice file name (by @nesrineabdmouleh) - - #16861: Functional test : Activate Employees bulk actions test (by @boubkerbribri) - - #16848: Functional tests - add test Create DB Backup (by @boubkerbribri) - - #16756: Functional tests - Add test Create unofficial currency (by @boubkerbribri) - - #16775: Functional Tests - Enable/Disable current year in the invoice file name (by @nesrineabdmouleh) - - #16801: Functional tests - add test create and delete link widget (by @boubkerbribri) - - #16791: Functional Tests - Test some options in the invoice file (by @nesrineabdmouleh) - - #16771: Functionnal tests - Add test "Filter and bulk delete order messages" (by @boubkerbribri) - - #16784: Tests - Fix checkout FO (by @boubkerbribri) - - #16747: Functional Tests - Enable/Disable tax breakdown (by @nesrineabdmouleh) - - #16766: Functional test - Fix global variable call in the test (by @nesrineabdmouleh) - - #16748: Functional tests - Fix expect on test currencies (by @boubkerbribri) - - #16761: Functional test - CRUD order message (by @boubkerbribri) - - #16764: Tests - Fix sanity on nightly (by @boubkerbribri) - - #16759: Functional Tests - Enable/Disable product image in the invoice (by @nesrineabdmouleh) - - #16750: Sanity tests - Can't install prestashop with same db in prod mode (by @boubkerbribri) - - #16731: Tests - Disable dev mode while testing with docker (by @boubkerbribri) - - #16727: Functional tests - Fix test CRUD profile (by @boubkerbribri) - - #16721: Functional tests - Fix echange rate on test currency (by @boubkerbribri) - - #16708: Tests - Fix eslint errors on linkchecker (by @boubkerbribri) - - #16699: Functional Tests - add test create official currency (by @boubkerbribri) - - #16705: Functional tests - Add test 'Bulk Edit Quantity in stocks' (by @boubkerbribri) - - #16659: Tests Update README.md and DOCKER.md (by @boubkerbribri) - - #16679: Functional Tests - Fix describe message for generate invoice by date/status (by @nesrineabdmouleh) - - #16681: Tests - Fix errors in functional tests (by @boubkerbribri) - - #16674: Functional Tests - Add BO tests for invoice options Enable/Disable (by @nesrineabdmouleh) - - #16666: Tests - Running tests with user root (by @boubkerbribri) - - #16655: Functional Tests - Add BO tests for generate invoice by status (by @nesrineabdmouleh) - - #16647: Tests - Using pptruser to run tests with download (by @boubkerbribri) - - #16644: Tests - Fix logout used in Employee tests (by @boubkerbribri) - - #16566: Functional Tests - Add BO tests for generate invoice by date (by @nesrineabdmouleh) - - #16612: Functional tests - Adding test update Quantity on catalog-stocks page (by @boubkerbribri) - - #16534: Tests - Adding scripts to run puppteer tests on nightly for develop (by @boubkerbribri) - - #16564: Tests - Fixing tests 04_filterAndQuickEditCategories (functional campaign) (by @boubkerbribri) - - #16533: Test- Update functional test Supplier (by @boubkerbribri) - - #16496: Tests - Fix test CRUD Page Category in functional campaign (by @boubkerbribri) - - #16492: Tests - Skip all scenarios Employees bulk actions (by @boubkerbribri) - - #16479: Tests - Using foreach for sanity tests products (by @boubkerbribri) - - #16480: Tests - Using foreach for sanity tests orders (by @boubkerbribri) - - #16469: Functional tests - fix Employees tests (by @boubkerbribri) - - #16127: Functional Tests - Add BO tests for Design>Pages (by @nesrineabdmouleh) - - #16289: Functional Tests - Add BO tests for Team>employees and profiles (by @nesrineabdmouleh) - - #16456: Functional tests - add simple filter tests for stocks (by @boubkerbribri) - - #16376: Functional Tests - Add BO tests for Filter And Quick Edit products (by @nesrineabdmouleh) - - #16448: Running Sanity and functional tests faster (by @boubkerbribri) - - #16450: Tests - Replace duplicated steps with foreach in brands tests (by @boubkerbribri) - - #16408: Tests - Replace duplicated steps with foreach in customers tests (by @boubkerbribri) - - #16407: Tests - Replace duplicated steps with foreach in categories tests (by @boubkerbribri) - - #16414: Tests - Replace duplicated steps with foreach in taxes tests (by @boubkerbribri) - - #16403: Tests - Replace duplicated steps with foreach for brands tests (by @boubkerbribri) - - #16405: Tests - Replace duplicated steps with foreach in suppliers tests (by @boubkerbribri) - - #16399: Tests - Delete replaces in tests Taxes (by @boubkerbribri) - - #16395: Tests - Delete replaces in tests Customers (by @boubkerbribri) - - #16330: Tests - Delete replaces in tests and use new methods instead (by @boubkerbribri) - - #16387: Tests - Delete replaces in tests categories (by @boubkerbribri) - - #16373: Tests - Using employees demo file for installation (by @boubkerbribri) - - #16371: Tests - Delete replaces and use new methods instead in Supplier tests (by @boubkerbribri) - - #16332: Tests - using same demo elements (by @boubkerbribri) - - #16296: Functional Tests - Add BO tests for Supplier (by @boubkerbribri) - - #16297: Functional tests - Using the correct element in loop for brands tests (by @boubkerbribri) - - #16309: Tests - Separate BO pages (by @boubkerbribri) - - #16216: Tests - Add functional tests command to package.json (by @boubkerbribri) - - #16194: Tests - Refactoring puppeteer tests (by @boubkerbribri) - - #16125: Functional Tests - Add BO tests for Brands (by @boubkerbribri) - - #16156: Tests - Update name of catalog Menu link in BO (by @boubkerbribri) - - #15988: Functional Tests - Add tests for categories (by @nesrineabdmouleh) - - #15980: Linkchecker update (by @SimonGrn) - - #16018: Sanity Tests - Refacto of all tests (by @boubkerbribri) - - #16005: Tests - Adding env file for docker (by @boubkerbribri) - - #15978: Functional Tests - Add BO tests for taxes (by @boubkerbribri) - - #15984: Test - Improve quick view product (by @boubkerbribri) - - #15905: Tests - Add module alias (by @boubkerbribri) - - #15865: Functional Tests - Add BO tests for customers (by @boubkerbribri) - - #15868: Update puppeteer Tests description on package.json (by @boubkerbribri) - - #15811: Tests - Fix Login Test (by @boubkerbribri) - - #15790: Tests - Remove chai from Page Objects (by @boubkerbribri) - - #15772: Tests - Fix global Vars in linkchecker (by @boubkerbribri) - - #15754: Tests - Change structure of file globals.js (by @boubkerbribri) - - #15735: Sanity Tests with puppeteer - Refacto of InstallShopTest (by @boubkerbribri) - - #15651: Add common FO page - Puppeteer (by @nesrineabdmouleh) - - #15730: Update ReadMe file for puppeteer tests folder (by @boubkerbribri) - - #15634: Add demo data files and fix the concerned tests - Sanity tests (by @nesrineabdmouleh) - - #15630: Moving login test in a commonTests directory (by @boubkerbribri) - - #15584: Replace mocha scenario and test with describe and it functions (by @boubkerbribri) - - #15556: Add Sanity tests on travis build (by @boubkerbribri) - - #15509: Remove the smoke tests campaign - Puppeteer (by @nesrineabdmouleh) - - #15470: Add Checkout FO to Sanity tests puppeteer (by @boubkerbribri) - - #15421: Cart FO tests with puppeteer - Sanity tests campaign (by @nesrineabdmouleh) - - #15422: Add Sanity tests products BO (by @boubkerbribri) - - #15415: Fixing esLint errors in project (by @boubkerbribri) - - #15355: Adding sanity tests products BO (by @boubkerbribri) - - #14170: Add Behat tests for CMS page commands (by @zuk3975) - - #15312: Order BO tests with puppeteer - Sanity tests campaign (by @nesrineabdmouleh) - - #15389: Catalog FO tests with puppeteer - Sanity tests campaign (by @nesrineabdmouleh) - - #14132: Behavioral tests for Tax commands (by @zuk3975) - - #15301: Renaming data names - Smoke tests (by @nesrineabdmouleh) - - #15262: Sort smoke tests by adding number to the names (by @boubkerbribri) - - #14145: Behavioral tests for Manufacturer commands (by @zuk3975) - - #15163: Docker for test AutoUpgrade (by @boubkerbribri) - - #15206: Smoke tests - Fix the product selector in the FO (by @nesrineabdmouleh) - - #15156: Adding new Test UpgradeShop with puppeteer (by @boubkerbribri) - - #15155: Update expect usage in puppeteer tests (by @boubkerbribri) - - #15151: All BO classes should inherit from BObasePage (by @boubkerbribri) - - #15031: Fix install prestashop test - Smoke tests (by @nesrineabdmouleh) - - #15024: Rename files and test directory - Smoke tests campaign (by @nesrineabdmouleh) - - #14902: Check the Front Office test with puppeteer - Smoke tests campaign (by @nesrineabdmouleh) - - #14825: Fix some minor problems on the "crawling BO" smoke test (by @SimonGrn) - - #14815: Add a new smoke test: crawling BO (by @SimonGrn) - - #14764: Install prestashop test with puppeteer (by @boubkerbribri) - - #14593: First POM implementation (by @SimonGrn) - - #14612: Update docker for puppeteer (by @boubkerbribri) - - #14508: Integrate Puppeteer to check links on FO and BO (by @mbadrani) - - #13772: Correct usage of fixtures on behat tests for taxes (by @tomlev) - -#################################### -# v1.7.6.9 - (2020-11-16) -#################################### -- Core: - - Bug fix: - - #GHSA-frf2-c9q3-qg9m: Improper Access Control with submitReorder function (by @PierreRambaud) - -#################################### -# v1.7.6.8 - (2020-09-24) -#################################### -- Core: - - Improvement: - - #21124: Bump version to 1.7.6.8, bump contactform version (by @PierreRambaud) - - Bug fix: - - #GHSA-rc8c-v7rq-q392: Stored XSS in upload files (by @PierreRambaud) - - #GHSA-5cp2-r794-w37w: Potential XSS injection with contact form (by @PierreRambaud) - - #GHSA-fghq-8h87-826g: Blind SQLi in Catalog Product edition (by @PierreRambaud) - -#################################### -# v1.7.6.7 - (2020-07-03) -#################################### -- Front Office: - - Bug fix: - - #20052: Fix product page event theme sided not getting fired (by @NeOMakinG) - -#################################### -# v1.7.6.6 - (2020-07-01) -#################################### -- Back Office: - - Bug fix: - - #19814: Change buttons in modal bulk of module page to avoid black color (by @NeOMakinG) - - #18975: BO - Customer View page - Added Green alert when editing a voucher (by @Progi1984) - - #19942: Cast changelogs to array for twig - Backport of #19778 (by @atomiix) - - #19718: Remove i18n access restrictions (by @PierreRambaud) - - #19990: Fix BO page Module permission checks (by @jolelievre) -- Front Office: - - Improvement: - - #19800: Add a new selector in order to select the product page more precisely (by @NeOMakinG) -- Core: - - Improvement: - - #19943: Update Composer dependencies and prestashop module versions (by @PierreRambaud) - - #19980: Update version number to 1.7.6.6 (by @matks) - - #19979: Update outdated assets in 176x (by @matks) - - #19984: Update license headers for PS 1.7.6.6 (by @matks) - - Bug fix: - - #19010: Added missing required_once for Datas class (by @atomiix) - - #19986: Fix php7-only code into 1766 (by @matks) - - #20018: Remove COLLATION placeholder from 1.7.6.6.sql (by @matks) - - #GHSA-mc98-xjm3-c4fm - External control of configuration setting in the dashboard (by @PierreRambaud) - - #GHSA-997j-f42g-x57c - Information exposure in upload directory (by @PierreRambaud) - - #GHSA-492w-2pp5-xhvg - Information disclosure in release archive (by @PierreRambaud) - - #GHSA-ccvh-jh5x-mpg4 - Improper authentication (by @PierreRambaud) - - #GHSA-xp3x-3h8q-c386 - Improper access controls in Carrier page, Module Manager and Module Positions (by @PierreRambaud) - - #GHSA-qgh4-95j7-p3vj - Reflected XSS in product page (by @PierreRambaud) - - #GHSA-v4pg-q2cv-f7x4 - Stored XSS in AdminQuickAccesses (by @PierreRambaud) -- Web Services: - - Bug fix: - - #18969: Make api backward compatible for Currencies (by @atomiix) - -#################################### -# v1.7.6.5 - (2020-04-17) -#################################### -- Back Office: - - Bug fix: - - #18637: Fix sidebar not displayed in BO Add employee page (by @Progi1984) - - #18607: Fix wrong number of "Last emails" in BO - Customer View page (by @PululuK) - - #17920: Wrong redirection when using the quick search for a category (by @PululuK) - - #18064: Fix error when trying to translate Serbian using the BO interface (by @eternoendless) -- Front Office: - - Bug fix: - - #18633: Convert cart rule value when order currency is different (by @sowbiba) - - #18493: Change product redirection rules to redirect to valid attribute url (by @jolelievre) - - #18103: Duplicate address when submitting a form with errors (by @PierreRambaud) -- Core: - - Improvement: - - #18638: Update version to 1.7.6.5 (by @PierreRambaud) - - Bug fix: - - #GHSA-cvjj-grfv-f56w - Improper access control on product page with combinations, attachments and specific prices (by @PierreRambaud) - - #GHSA-4wxg-33h3-3w5r - Improper access control on product attributes page (by @PierreRambaud) - - #GHSA-r6rp-6gv6-r9hq - Improper access control on customers search (by @PierreRambaud) - - #GHSA-74vp-ww64-w2gm - Improper Access Control (by @PierreRambaud) - - #GHSA-98j8-hvjv-x47j - Reflected XSS related in import page (by @PierreRambaud) - - #GHSA-j3r6-33hf-m8wh - Reflected XSS with back parameter (by @PierreRambaud) - - #GHSA-mrpj-67mq-3fr5 - Reflected XSS on Exception page (by @PierreRambaud) - - #GHSA-q6pr-42v5-v97q - Reflected XSS on AdminCarts page (by @PierreRambaud) - - #GHSA-rpg3-f23r-jmqv - Reflected XSS on Search page (by @PierreRambaud) - - #GHSA-m2x6-c2c6-pjrx - Reflected XSS with dashboard calendar (by @PierreRambaud) - - #GHSA-375w-q56h-h7qc - Open redirection when using back parameter (by @PierreRambaud) - - #GHSA-87jh-7xpg-6v93 - Reflected XSS on AdminFeatures page (by @PierreRambaud) - - #GHSA-7fmr-5vcc-329j - Reflected XSS on AdminAttributesGroups page (by @PierreRambaud) - - #GHSA-48vj-vvr6-jj4f - Reflected XSS in security compromised page (by @PierreRambaud) - -- Installer: - - Bug fix: - - #18491: Installation under CLI doesn't take BASE_URI and Apache rewrite in consideration (by @PierreRambaud) - - #18451: Use scandir instead of readdir to get sorted entities (by @PierreRambaud) -- Tests: - - Bug fix: - - #18309: Change test fixtures that need to be in the future (by @jolelievre) - -#################################### -# v1.7.6.4 - (2020-03-02) -#################################### -- Back Office: - - Bug fix: - - #17711: Fix a bug on safari where SEO preview on create page was not updated (by @NeOMakinG) - - #17613: Files translations.css and product_page.css do not exist (by @PierreRambaud) - - #17395: Can't explore a category when all subcats are disabled (by @PululuK) -- Front Office: - - Improvement: - - #17638: Prevent email enumeration (by @PierreRambaud) - - Bug fix: - - #17457: Disable add-to-cart button when product/attribute combination is not available (by @sowbiba) - - #16616: Fix round remaining value of reduction amount (backport #16531) (by @matks) - - #17608: Email subject doesn't support html entities (by @Progi1984) -- Core: - - Bug fix: - - #17846: Fix exception thrown when editing a customer with a bad email address (by @atomiix) - - #17433: Do not escape translations when using the legacy translator from the new one (by @Progi1984) - - #17306: Do not force memory_limit in index_cli.php (by @PierreRambaud) - -#################################### -# v1.7.6.3 - (2020-01-20) -#################################### -- Back Office: - - Improvement: - - #17036: Protect modules vendor folder on install/upgrade/enable (by @jolelievre) - - Bug fix: - - #16906: Handle profile name above 32 chars exception (by @atomiix) - - #17087: Define alert message when error are found in Category Form (by @Progi1984) - - #17065: Fix encoding on product name in viewed product (by @Progi1984) - - #17071: Fix recursive check of updated files - backport of #16765 (by @matks) - - #16742: Can't export data more than filters limits (by @PierreRambaud) - - #16696: Fix email theme permission (by @atomiix) - - #16746: Attributes bo_css & bo_theme can be empty (by @PierreRambaud) - - #16729: Cost price & unit price are erased when saving with a supplier (by @PierreRambaud) - - #16888: Fix customer comment template (by @jolelievre) - - #16294: Fix email not translated when installing a new language (by @atomiix) - - #16648: Fix customer statuses not being able to toggle when optin field is required (by @matthieu-rolland) -- Front Office: - - Bug fix: - - #17248: Added RTL Style for Classic Theme (by @Progi1984) - - #16852: Fix a bug where changing quantity on product quickview adds products tags on ever products (by @NeOMakinG) - - #17030: Ignore rtl assets and remove _rtl.css files (by @NeOMakinG) -- Core: - - Bug fix: - - #17050: Quick access error when having a wrong url (by @PierreRambaud) - - #16893: Fix yml config parse typo (by @mvorisek) - - #16522: Prevent getter from changing class state (by @eternoendless) - - Refactoring: - - #17130: Make $localizedSymbols variable to be compatible with develop (by @atomiix) -- Web Services: - - Bug fix: - - #17069: Fix Currency i18n fields issue in webservice (by @atomiix) - -#################################### -# v1.7.6.2 - (2019-11-28) -#################################### -- Back Office: - - Bug fix: - - #16365: Viewed products - the date is showing product id - not a date (by @khouloudbelguith) - - #16265: Fix category checkbox redirect (Backport #16159) (by @atomiix) - - #16153: Add missing field type DNI in brand address form (by @jolelievre) - - #16158: Fix filter not being taken into account in grid export (by @matthieu-rolland) - - #16172: Remove constraint on siret in CustomerType (by @matthieu-rolland) - - #16047: Handle multistore customers sharing in customers listing at group level (by @matks) - - #16036: Add redirect routes on security annotation of Category pages (by @jolelievre) - - #15643: Allow CLDR to display deleted/inactive currencies (by @jolelievre) - - #15859: Add clickable row option for grid actions (by @jolelievre) - - #15880: Fix wrong data mapping in export (by @eternoendless) - - #15855: Allow anonymous mode for AdminController (by @PierreRambaud) - - #15856: Must use min-with instead max-widght for the Profile button (by @PierreRambaud) - - #15685: Unable to create new supplier when VAT identification number is mandatory (by @PierreRambaud) - - #15665: Wrong selector expression, unable to move parent category (by @PierreRambaud) - - #15660: Fix tracking url in Theme and Logo page (by @jolelievre) - - #15658: Use empty legacy action parameter (by @jolelievre) - - #15382: Remove useless and buggy identifier computation (by @jolelievre) -- Front Office: - - Bug fix: - - #16423: Use default attribute when no one are passed in front page (by @PierreRambaud) - - #16274: Fix contact us email display (by @atomiix) - - #15964: Use product url (including combination) rather than canonical one in the miniatures (by @jolelievre) - - #15963: Add rel="nofollow" to prestashop website link (by @matks) - - #15930: Fix on product-flags class for product cards (by @Progi1984) -- Core: - - Improvement: - - #16203: Update version to 1.7.6.2 (by @atomiix) - - Bug fix: - - #16500: Incorrect email subject and template variable {shop_name} (by @PierreRambaud) - - #16335: Update id_order_state at the right place (by @atomiix) - - #16258: Remove unnecessary require_once config.inc (by @matks) - - #16026: Remove final keyword from Lang entity (by @jolelievre) - - #15917: Define use_debug_toolbar even if it's not set in parameters.php (by @PierreRambaud) - - #15691: Cart rules mustn't be auto added automatically in some cases (by @PierreRambaud) - - #15621: Revert "Fix lang table multi-store data issue" (by @matks) - - #15731: Webservices shouldn't display warning when running with fpm or Nginx (by @PierreRambaud) - - #15515: SqlTranslator must throw a NotFoundResourceException (by @PierreRambaud) -- Tests: - - Bug fix: - - #15847: Npm is not anymore in the nodejs package (by @PierreRambaud) - - #15895: Add management of an env var to disable debug toolbar in travis tests (by @jolelievre) - - #15590: Remove selenium tests (by @PierreRambaud) - -#################################### -# v1.7.6.1 - (2019-08-26) -#################################### -- Back Office: - - Bug fix: - - #15173: CLDR has access to all currencies regardless of the current shop (by @jolelievre) - - #15139: Make module and email translations work again when using a theme other than classic (by @eternoendless) - - #14966: Keep BO from using two different translators in parallel (by @matthieu-rolland) - - #15030: Get all categories in category tree form (not only enabled ones) (by @matthieu-rolland) - - #14962: Fix error preventing to translate backoffice wordings when using a theme other than classic (by @eternoendless) - - #15017: Improve translation test module (by @eternoendless) - - #14721: Manage edit/view link for customers in HelperList (by @jolelievre) - - #15036: Fix supplier display after import (by @jolelievre) - - #14719: Scan translation keys from email themes (by @jolelievre) - - #14938: Fix error when loading theme that includes a translations directory but no translations (by @eternoendless) - - #14926: Fix logs filtering (by @sarjon) - - #14671: Make sure token is properly used in legacy context (by @PierreRambaud) - - #14914: Date picker calendar is shown in wrong place when rendered downwards in grid (by @PierreRambaud) - - #14828: Cannot save the "No Picture Image" (by @PierreRambaud) - - #14805: Fix unclosed div tag (by @sarjon) - - #14701: Fix log delete all action on Logs page (by @matks) - - #14605: Do not use encodeURIComponent with POST data (by @PierreRambaud) - - #14673: Fix Orders view page link to transform guest to customer (by @matks) -- Front Office: - - Bug fix: - - #15042: Only disable following steps in the checkout process when the current step has a continue button (by @jolelievre) - - #14945: Fixed {firstname} typo in order customer comment mail in 1.7.6.x (by @dheerajwebkul) - - #14786: Sprintf function broken in 1.7.6 for custom module templates (by @roja45) - - #14863: Prevent uninstall of Product Comments module (by @templatin) -- Core: - - Improvement: - - #14579: Fix many things that were supposed to be removed during build not being removed (by @eternoendless) - - Bug fix: - - #15132: Fix abstract service declaration (by @eternoendless) - - #14711: Update Decimal library to 1.2.0 (by @eternoendless) - - #14833: Bad currency format for Czech language (by @PierreRambaud) - - #14664: Update precision and numeric iso code of currencies (by @Quetzacoalt91) -- Installer: - - Bug fix: - - #14620: Init properly the Kernel on major *manual* upgrades (by @Quetzacoalt91) - - #14739: Keep Composer.lock file in release (by @jolelievre) -- Web Services: - - Bug fix: - - #14953: Initialize container in WebService environment (by @matthieu-rolland) -- Localization: - - Bug fix: - - #15051: Fix translations (by @jolelievre) -- Tests: - - Refactoring: - - #14356: Fix "02_autoupgrade" in install_upgrade campaign (by @nesrineabdmouleh) - -#################################### -# v1.7.6.0 - (2019-07-09) -#################################### -- Back Office: - - Bug fix: - - #14532: Check if index.php file exists before ignoring it (by @jolelievre) -- Core: - - Refactoring: - - #14552: Use variable instead of recomputing (by @jolelievre) - -#################################### -# v1.7.6.0 RC 2 - (2019-07-05) -#################################### -- Back Office: - - Bug fix: - - #14460: Ignore index.php files in Doctrine entities scanning - - #14401: Fix grid calendar - -- Front Office: - - Bug fix: - - #14444: Check if selected address belongs to user - - #14395: Classic theme force all type number to not have arrows - -- Core: - - Improvement: - - #14438: Testing the factory with number and price specifications - - Bug fix: - - #14453: Update facetedsearch to 3.0.6 - - #14400: Wrong way to retrieve CLDR information - -#################################### -# v1.7.6.0 RC 1 - (2019-06-25) -#################################### -- Back Office: - - Improvement: - - #14239: Introduce the usage of Module user-displayable exceptions to handle module errors (part 2) - - #14008: Adds missing form data arguments in hooks - - #13779: Allow to overwrite theme mails if they have modules OR mail templates - - #13722: Filter themes without override in email generation form - - Bug fix: - - #14364: View button doesn't have href - - #14331: Handle bad theme error nicely - - #14290: Extend customer page - - #14259: Avoid bug when creating manually created a language - - #14248: Cannot use accented URL with arabic language - - #14242: Module form_rest() outside div - - #14220: Set schema form rendered when it contains no children - - #14189: Fix manufacturer controller using wrong DomainException ns - - #14172: Add missing form_errors for identifiable object forms - - #13984: Fix bo categories - - #14152: Adjust employee avatar size - - #14156: Add missing null check in EditCmsPageHandler - - #14101: Fix missing permission roles - - #14137: Adds missing form_rest in Shop Parameters > Preferences - - #14107: Do not allow the selection of any subcategories - - #14084: Fixes updating name and symbol for currency - - #14021: Improved error handling when theme is uploaded or activated - - #14091: Do not use specific prices when displaying price with tax in BO product catalog - - #14029: Missing legacy link for themes page - - #14028: Add explanations about SEO cards - - #14030: Add missing legacy link for translations routes - - #13875: Added help property (backported from Symfony 4 framework) - - #14007: Fix currency precision from CLDR at install - - #13774: Includes missing theme & logo page validation handling for logo and icon images - - #13916: Fixes saving private note about customer from order page - - #13820: Fixes form_rest placing - - #13956: Restore legacy controller and template files deleted late in beta - - #13840: Fix resetting sort and items per page on list filters reset action - - #13887: Fix saving customer with required fields - - #13813: Fixes toggling Category status in Monitoring page - - #13866: Fix cart rule calculation for free gift - - #13857: Missing legacy links fix for employess controller - - #13797: Adds missing legacy links for currency controller - - #13777: Incorrect translation arguments passed in cms page form - - #13690: Theme and logo page design fixes - - #13821: Fix manufacturers, taxes lists id filtering - - #13165: Fix multilanguage fields configuration - - #13764: Fixes customer view url in notifications bar - - #13763: Fix help sidebar display in Customers page - - #13765: Fix sql manager bulk actions - -- Front Office: - - Improvement: - - #14180: Improve right block on cart and checkout page - - #14138: Add comment in Customer registration form, add better error message - - Bug fix: - - #14325: Refresh product flags on ajax call when product page is refreshed - - #14298: Fix english mail generation on fresh install - - #14309: Simplify the installation language to its minimum - - #14296: Fix carrier display in order confirmation email - - #14251: Fix categories wordbreak - - #14190: You need to be authenticated to play with addresses - - #14166: Fix categories cover images which had an incorrect format - - #14163: Add missing quotes in error message - - #13370: Fix cart refresh after voucher removal - - #14075: Fix: If Ask for birth date option is disabled, an exception is displayed in the FO - - #13905: Step clickable and not - Checkout page - - #12891: Fix bug on block social in footer - - #13780: Fix displayed discount on tax excluded cart display - -- Core: - - Improvement: - - #14284: Update to Faceted search 3.0.5 - - #13925: Add getter for current locale - - #14197: Update facetedsearch dependency - - #14010: Update some license headers that were outdated - - #14011: Update outdated CSS assets - - #13778: Add new hooks for Symfony migrated pages in XML install file and SQL upgrade - - Bug fix: - - #14324: Use Admin.Actions instead Admin.International.Help - - #14316: Reapply changes from PR switching on PHPSpreadsheet - - #14300: &= prevents result to be a boolean - - #13795: Updates to Domain - - #13919: Tax must be returned depending on PS_TAX_DISPLAY only - - #13923: Make sure index exist before getting value for gift message - - #14027: Fix BC break on Toggle column parameter - - #13885: Force array cache for doctrine - - #13808: Update Symfony to latest patch version to fix ICU version problem - - #13665: Final retail price is not displayed due to missing CLDR files - -- Installer: - - Bug fix: - - #14243: Fix translation catalogue - - #14225: Update facetedsearch cache - -#################################### -# v1.7.6.0-beta.1 - (2019-05-13) -#################################### -- Back Office: - - New feature: - - #13221: Allow trans() to fall back on the legacy translation system when used with modules (by @eternoendless) - - #12974: Cms page category listing position update (by @tomas862) - - #13004: Integrate new modern mail theme (compiled from MJML) (by @jolelievre) - - #12981: Migration of "Design -> pages -> cms page listing" (by @tomas862) - - #12647: Migration of "Design -> pages -> add new / edit page category" (by @tomas862) - - #12163: Migration of shop parameters->contact->contacts add new edit contact form (by @tomas862) - - #12706: Kpis list are now customizables using hooks (by @mickaelandrieu) - - #10595: Migration of "Shop parameters >Traffic & SEO > SEO & URL > Add new / edit page" form (by @tomas862) - - #12046: Introduce Mail Template Generator (by @jolelievre) - - #10877: Migration of "Design > Pages" page cms category listing (by @tomas862) - - #11894: Migration of international/localization/currencies page form and some exchange rate actions (by @tomas862) - - #12128: Add migrated customers page helper card (by @matks) - - #11153: Migration of "Catalog > Brand & Suppliers > Suppliers" listing (by @tomas862) - - #10774: Migration of "International > Localization > Currencies" page listing (by @tomas862) - - #11484: Add final price column in products list (by @PrestaShark) - - #10992: Migrate Customer view page (by @sarjon) - - #11408: Migrate Categories Add/Edit actions - tests fixed (by @matks) - - #11049: Add Helper Card to Employees page (by @sarjon) - - #11075: Improve AdminSecurity and DemoRestricted annotations to allow to pass query parameters to keep (by @tomas862) - - #10120: Migration of Advanced Parameters -> Import (Step 2) (by @rokaszygmantas) - - #10790: Migrate Employee options configuration (by @sarjon) - - Improvement: - - #13603: Add id for orders view page to ease E2E testing (by @matks) - - #13404: Add missing showcase card in CMS page (by @tomas862) - - #13234: Add Showcase card in Categories page (by @sarjon) - - #13158: Fix error bubbling inside the translatable type (by @tomas862) - - #13125: Add CMS page listing position update functionality (by @tomas862) - - #13048: Integrate mail generator (by @jolelievre) - - #12331: Migration of Theme & Logo page with style and ux improvements (by @tomas862) - - #12436: Introduces new File type input design for all new and migrated back-office pages (by @tomas862) - - #13123: Display shop path in Information page (by @unlocomqx) - - #12707: New design for employee profile [Back-Office] (by @YeLnatSs) - - #13033: Filter out registered hooks in module positions list (by @unlocomqx) - - #12914: Significantly reduce number of SQL requests to get the employee authorizations (by @Quetzacoalt91) - - #13095: Update dashboard links (by @eternoendless) - - #13012: Update Twig to v1.38 (by @matks) - - #12850: "Module Manager" tab should be the first tab in Modules Tab (by @rblaurin) - - #12214: Migrate "Advanced Parameters > Team > Employees > Add new employee" page (by @rokaszygmantas) - - #12928: Allow multiple grids on same page (by @jolelievre) - - #12971: Enable customers page (by @sarjon) - - #12945: Build assets (by @matks) - - #12644: Add margin between buttons on Traffic & SEO page (by @YeLnatSs) - - #12699: Refacto addons store controller and handle addons failure (by @matks) - - #12838: Replace hardcoded currency sign in specific price form (by @metineren) - - #12784: Add module main class parse error to log message (by @teemumantynen) - - #12717: Add re-usable rewrite link copier service (by @tomas862) - - #12505: Improve error handling in migrated controllers (by @sarjon) - - #12761: Remove timeout from product image upload (by @JohnMidity) - - #12713: Enable usage of roles for Module Updates and Module Alerts pages and manage access (by @matks) - - #12622: Refactor AddonsStoreController to use annotations and some improvements (by @matks) - - #12316: Update access rules for SystemInformationController and MemcacheServer (by @matks) - - #10911: Build new theme using Webpack 4 (by @CaptainYouz) - - #12094: Refactor OrderPreferencesController to use annotations (by @matks) - - #12076: Refacto ProductPreferencesController to use annotations (by @matks) - - #12074: Refacto PreferencesController to use annotations (by @matks) - - #12098: Refactor Shipping/ referencesController to use annotations (by @matks) - - #12097: Refacto PaymentMethodsController to use annotations (by @matks) - - #12099: Refactor MaintenanceController to use annotations (by @matks) - - #12077: Refacto ThemeCatalogController to use annotations (by @matks) - - #11439: Migrate Customer list actions (by @sarjon) - - #11561: Migrate legacy import logic to adapters and hide Import page 2 (by @rokaszygmantas) - - #11877: Align grid search and reset buttons to the right (by @tomas862) - - #11481: Add cover & menu thumbnail images deleting for category (by @sarjon) - - #11919: Use env variable for admin dir with default value in assets build script (by @spolischook) - - #11785: Update dependencies with security breaches (by @jolelievre) - - #11732: Avoid using short bool (by @MathiasReker) - - #11735: Elseif instead of else if (by @MathiasReker) - - #11739: Remove blackslash (by @MathiasReker) - - #11741: Use brackets for index brace (by @MathiasReker) - - #11235: Prevent unnecessary Order objects from being created in Admin Orders (by @mnastalski) - - #10199: Fix quantity placeholder issue in the Stock management page (by @CaptainYouz) - - #11160: Form handling improvements in import page step 1 and 2 (by @rokaszygmantas) - - #11095: Update grid design regarding grid gear icon position and dropdown toggle icon modification (by @tomas862) - - #11266: Allow BO hooks to use the method $this->render() (by @Quetzacoalt91) - - #11093: Set sortable flag by default to "true" on ToggleColumn (by @tomas862) - - Bug fix: - - #13381: Use tinymce in migrated pages (by @matks) - - #13481: Improve preview and test mail feature, improve and fix a few templates (by @jolelievre) - - #13643: Fixes incorrect hook names for identifiable object forms. (by @tomas862) - - #13219: ScrollIntoView if field is invalid (by @PierreRambaud) - - #13623: Fix categories deleting in bulk action (by @sarjon) - - #13372: Add missing security annotations (by @rokaszygmantas) - - #13504: Fix backoffice translations for third-party modules (by @eternoendless) - - #13576: Fix deleting profile (by @sarjon) - - #13563: Do not get data from null currency (by @Quetzacoalt91) - - #13233: Enable 'back' GET parameter management (by @tomas862) - - #13550: Add missing check in Manufacturer image uploader (by @zuk3975) - - #13547: Deprecate Language::installEmailsLanguagePack (by @jolelievre) - - #13484: Fixes Categories grid filtering by position (by @sarjon) - - #13535: Fix responsive showcase cards (by @YeLnatSs) - - #13508: Enable ChoiceTree javascript in manufacturers form (by @zuk3975) - - #13528: Fix calendar overflow (by @zuk3975) - - #13152: Updates characters length for Category meta fields (by @sarjon) - - #13477: Fix issue on order with free gift (by @tomlev) - - #13439: Improvements on LegacyUrlConverter, "tab" alias, insensitive and prevent infinite redirection loop (by @jolelievre) - - #13431: Fix parameters list in product lookup (by @Quetzacoalt91) - - #13434: Remove material icons on SQL manager page (by @marionf) - - #13429: Build outdated assets for 1.7.6.x (by @matks) - - #13367: Remove deactivated currencies from new CLDR (by @tomlev) - - #13351: Mail generator fixes (by @jolelievre) - - #13363: Fix syntax error in tpl (by @Quetzacoalt91) - - #13349: Make all grids responsive (by @eternoendless) - - #13273: Fix domain errors (by @matks) - - #13264: Restores deleted generatable_text_widget from template (by @sarjon) - - #13216: Enable help bar on suppliers page (by @PierreRambaud) - - #13199: Fix Profiles form twig template compatibility with twig v2 (by @matks) - - #13108: Fix missing lang entries in Configuration (by @rblaurin) - - #13177: Fix notice undefined index: icon on Design -> Positions (by @Matt75) - - #13161: Remove icons from Customers form (by @sarjon) - - #12931: Make footer on product page spread itself when the menu is hidden (by @dineshbadrukhiya) - - #13157: Fix Add/Edit brand icon (by @matks) - - #13145: Fix bug with incorrect error display within the forms (by @tomas862) - - #13093: Add missing label and delete legacy tax controller as it was migrated (by @rokaszygmantas) - - #13105: Validate theme zip file and show error messages (by @rokaszygmantas) - - #13088: Ensure translations are always saved with the selected theme in back office (by @mickaelandrieu) - - #13122: Fix notice when iso code does not exist in array (by @Quetzacoalt91) - - #13104: Fix bad variable in Customers Add/Edit template (by @matks) - - #13094: Fix product demo link_rewrite (by @marionf) - - #13079: Fix visual glitches in new theme (by @eternoendless) - - #13054: Escape all import output data (by @PierreRambaud) - - #13043: Fix to handle fancybox customer creation in Add an Order page (by @matks) - - #13063: Module Manager: Use categoryParentEnglishName instead of category name (by @PierreRambaud) - - #13066: Fix npm install not working anymore on new-theme (by @PierreRambaud) - - #12523: Solved problem with texture upload when attribute has hex color (by @kpodemski) - - #13049: Fix BO scaling in mobile (by @eternoendless) - - #12705: Update OrderHistory to manage {followup} & {shipping_number} vars in all email templates, not only in in_transit template (by @jf-viguier) - - #12946: Fix recurring technical error when saving modifications in a Carrier (by @Matt75) - - #12897: Enable lite display for new theme (by @matks) - - #12874: Fix Symfony console crash because of DocumentationLinkProvider service definition (by @jolelievre) - - #12788: Remove html escaping of errors (by @bilfeldt) - - #12794: Add missing columns in products_import.csv (by @rblaurin) - - #12730: Fix fatal error in product catalog when short description is too long (by @rblaurin) - - #12751: Fix saving shop association in migrated add/edit forms (by @rokaszygmantas) - - #12787: Add legacy links to all meta page routes (by @tomas862) - - #12711: Fix shipping cost becoming free if more than a half or available quantity ordered (by @LedCloud) - - #12723: Fix specific price without discount being added (by @rblaurin) - - #12709: Refactor MetaController to secure search usage (by @matks) - - #12716: Prevent including jQuery in the new theme (by @eternoendless) - - #12668: Fix help sidebar when adding/editing language (by @sarjon) - - #12465: Fix duplicate HTML id (by @mickaelandrieu) - - #12563: Fix error in admin panel when visiting a category that's not under Index (by @mowcixo) - - #12597: The lang parameter in the url is now shop dependent (by @helgvor-stoll) - - #12471: Use AdminSecurity annotation for ajax call for Sql Manager (by @matks) - - #12479: Avoid module sorting function warnings when module data is invalid (by @matks) - - #8993: Fix HTML formated configuration not saved (by @shaffe-fr) - - #11175: Allow product default supplier reference to be updated, if the product supplier is already attached to the product (by @simondaigre) - - #12240: Adds missing argument in MetaController which caused page crash (by @tomas862) - - #12096: Fix access rights to Administration page (by @matks) - - #12140: Default carrier name was displayed as 0 (by @Gitdyr) - - #11693: Fix search feature value and pagination (by @studiox3) - - #12052: SERP: Avoid mutating a prop directly + fix url encode (by @PierreRambaud) - - #11854: Add customer_message table name into SQL request (by @Klemart3D) - - #11932: Can't sort tax included for now (by @PierreRambaud) - - #11936: Description has a max length and can not exceeded (by @PierreRambaud) - - #11922: Fix searching issue in the Credit Slips page (by @khouloudbelguith) - - #11907: Fix error when updating the product details in order (by @PeeyushAgrawalWebkul) - - #11851: Fix error "getimagesize(): php_network_getaddresses" when trying to change the order status to payment accepted (by @PierreRambaud) - - #11850: Fix header (by @PierreRambaud) - - #11200: Fix address changes not impacted when creating an order from another order (by @jf-viguier) - - #11201: Addresses changes not impacted when creating an order from another order (by @jf-viguier) - - #11526: Fix wrong protocol in the File Manager Dialog (by @freakstatic) - - #11535: Display the right front url in multistore menu (by @jolelievre) - - #10981: Change BO product list price source for multistore (by @mafisz) - - #11256: Fixes error reported in #9687, regarding carrier list in the modal to ... (by @manfield) - - #11424: Improvement needs on hover of "Ok" button of source code modal on product page (by @dineshbadrukhiya) - - #10904: Fix date filtering in AdminSpecificPriceRuleController (by @Matt75) - - #11179: Fix sorting issue in the webservice page (by @khouloudbelguith) - - #10535: Fix typos (by @MathiasReker) - - #10930: Allow product import to change previous id_category_default when you force ID (by @itisco) - - #10939: Fix bad annotation in AttributeGroupLang, AttributeLang and TabLang (by @Fabuloops) - - #10808: Adjusted URL to be SSL agnostic (by @alu-) - - #10924: Fix right side block of attribute and attribute groups in combination tab not appearing (by @dineshbadrukhiya) - - #10781: Fixes new webservice list behavior in multishop context and fixes warning message display (by @tomas862) - - Refactoring: - - #13466: Brand and address export actions (by @zuk3975) - - #13251: Removes unnecessary return on update everywhere (by @tomas862) - - #13144: Cms page fixes (by @zuk3975) - - #13162: Tax page fixes (by @zuk3975) - - #13164: Manufacturer page fixes (by @zuk3975) - - #13159: Remove 'Constraint' suffix from TypedRegex constraint and validator (by @zuk3975) - - #12795: Brand address create/edit actions migration (by @zuk3975) - - #12995: Migrate Cms page create/edit actions (by @zuk3975) - - #13076: Migrate Add/Edit Profiles page (by @sarjon) - - #13014: Final Migration of Categories page (by @sarjon) - - #13067: Fix manufacturers namespace typos and wrong typecasts in commands (by @zuk3975) - - #12735: Brands create/edit migration (by @zuk3975) - - #12641: Migrate tax create/edit form (by @zuk3975) - - #12912: Fix Traffic and SEO route paths (by @matks) - - #12423: Taxes list migration (by @zuk3975) - - #12610: Taxes Options configuration form migration (by @zuk3975) - - #11470: Improve birthdate validation (by @zessx) - - #11723: Migrate customer Add/Edit actions (by @sarjon) - - #11519: Migrate Customers KPIs and required fields configuration (by @sarjon) - - #11527: Migrate customer view actions (by @sarjon) -- Front Office: - - New feature: - - #13103: Introduce new hooks displayProductActions & displayPersonalInformationTop (by @Quetzacoalt91) - - Improvement: - - #13047: New design for prices and taxes (by @YeLnatSs) - - #13135: Add variable to tell if prices are tax included or not (by @eternoendless) - - #13009: Change product canonical url to parent, no more redirection (by @jolelievre) - - #12564: Allow Doctrine entities in modules, make doctrine available for FO, modules autoload on FO (by @jolelievre) - - #11943: Improve performance by avoiding parsing YAML files during ModuleManagerBuilder init (by @jocel1) - - #10253: Add modal-dialog-centered class to classic theme (by @CaptainYouz) - - #12748: Remove obsolete P3P policy (by @MathiasReker) - - #12753: Allow ipv6 to be used in htaccess redirects (by @Quetzacoalt91) - - #12017: Weak token implementation (by @PierreRambaud) - - #11534: Move scroll forcing from core to classic (by @dennispw) - - #10487: Added breadcrumb to the manufacturers pages (by @SebBareyre) - - #11661: Reset quantity value to min value after adding to cart (by @jolelievre) - - #11614: Allow modules to add custom product flags (by @kpodemski) - - #11607: Remove useless space (by @MathiasReker) - - #11491: Classic theme footer block design improvement (by @dineshbadrukhiya) - - #11455: Remove unnecessary spaces on header of the checkout page (by @dineshbadrukhiya) - - #11362: Dont expose Powered-By: Prestashop (by @MathiasReker) - - #11215: Remove inline-style color in test-data (by @dineshbadrukhiya) - - #10769: Keep variant id_attribute in ProductLazyArray (by @Piraito) - - Bug fix: - - #13664: Remove id_attribute parameter from product link when it is equal to 0 (by @jolelievre) - - #13617: Fix not null voucher with free shipping producing php error (by @tomlev) - - #13635: Fix product link should not include attribute parameter equals to zero (by @jolelievre) - - #13407: Fix labels display computing (by @jolelievre) - - #13578: Automatically add dni field in Address format for countries which need it (by @jolelievre) - - #13440: Change checkout behaviour (needs to be validated after meeting) (by @jolelievre) - - #13411: Hide tax label in front when tax display is disabled in the shop (by @jolelievre) - - #13525: Fix currency display on not existing language (by @tomlev) - - #13003: Add behat tests for free shipping (by @tomlev) - - #13261: Fix lang on currency install (by @tomlev) - - #13201: Fix search results if shop has non-default 'visitor' group and categories that are only accessible for the non-default visitor group (by @fgschaefer) - - #13218: Fix breadcrumb in search results page leads to 404 page (by @PierreRambaud) - - #12872: Fix label "Web only" (by @YeLnatSs) - - #13150: Add a missing space that could trigger an SQL error (by @chrisvanberg) - - #13106: Do not go to the latest step when you change a previous step state in checkout (by @PierreRambaud) - - #12893: Fix bug on contact when mail is too long (by @YeLnatSs) - - #13081: Empty filter should not be shown (by @PierreRambaud) - - #11688: Fix catalog mode in products list and product page (by @jolelievre) - - #12391: Fix Broken Authentication and Session Management (by @arnaudschaeffer) - - #12892: Limit carrier image size on checkout page (by @YeLnatSs) - - #12964: Wrong specific price refresh on product page with combinations (by @PierreRambaud) - - #12965: Fix wrong cart calculation when using cart rule with virtual products (by @tomlev) - - #12817: Robots should not index search content (by @watou) - - #12733: Changed the regex to force space and hyphen in postcode validation (by @jojotjebaby) - - #12696: Fix missing comma in sql upgrade file (by @tomlev) - - #12403: Attribute min not allowed on element input at this point, change type from text to number (by @dominictayloruk) - - #12406: Revert "Fix translation on account creation email error" (by @marionf) - - #12341: Use show_price to display price in schema.org tags (by @arnaudschaeffer) - - #12227: Fix ps_viewedproduct in classic theme (by @SharakPL) - - #10341: Fix main page slider display on all devices (by @CaptainYouz) - - #12023: When downloading a virtual good, check if the order was made by the current user (by @garnele007) - - #10297: Fix image dimensions in Product Card view (by @CaptainYouz) - - #11726: Force DNI fields required if associated Country needs it (by @jolelievre) - - #10294: Fix minimum order amount for secondary currency (by @sadlyblue) - - #11754: Fix wrong discount details on order page / on invoice (by @tomlev) - - #11608: Fix deprecated jquery shortcut function 'load' (by @Fabuloops) - - #11745: Fix for password recovery error messages (by @web-fu) - - #11656: Correctly display percentage in cart (by @jolelievre) - - #11645: Fix discount computing to take combination into account (by @jolelievre) - - #11604: Fix wrong html attribute (by @SebBareyre) - - #11576: Add .gif support to webpack.config.js (by @adviva) - - #11605: Remove useless space (by @SebBareyre) - - #11495: Fix category description below the image (by @dineshbadrukhiya) - - #11563: Fix typo for "Environment" comment (by @Klemart3D) - - #9041: Fix override of ProductController (by @nenes25) - - #11103: Fix discount display when display preference is set without tax (by @tomlev) - - #11282: Convert customization price to current currency (by @unlocomqx) - - #11419: Noto Sans fonts updated to version 2.001 hinted (by @ProBackup-nl) - - #10867: Remove inline-style of Arial font (by @MathiasReker) - - #10643: Fix password validation message when password is too short (by @rdy4ever) -- Core: - - New feature: - - #12708: Deprecate admin endpoints outside index.php (by @Quetzacoalt91) - - #11321: Translation Manager of Back Office can now manage legacy translations of modules (by @mickaelandrieu) - - #9337: Migrate "Brands" listing page (a.k.a manufacturers) (by @sarjon) - - #12758: Added a Theme Enabler command (by @mickaelandrieu) - - #10455: New CLDR implementation (by @tomlev) - - #12284: Include script handler to manage installation of modules (by @mickaelandrieu) - - #12089: Implement AbstractTypedCollection with tests (by @jolelievre) - - #10974: Implement form handlers for SqlManager form - part 1 (by @sarjon) - - #10839: Migrate languages list (by @sarjon) - - #10197: Added a schema generator (by @mickaelandrieu) - - #9132: Add hook for extra fields on customer address form (by @PeeyushAgrawalWebkul) - - #10816: Migrate "Layout customization" part of Them & Logo controller (by @sarjon) - - #10797: Migrate Employee list (by @sarjon) - - #10864: Implement image source parser (by @sarjon) - - #10160: Migrate categories listing (by @sarjon) - - Improvement: - - #13735: Update native modules (by @eternoendless) - - #13402: Add new hooks of 1.7.6.0 in fixtures (by @Quetzacoalt91) - - #13238: Update themes folders license headers (by @matks) - - #13239: Update js folder license headers (by @matks) - - #13237: Update tests folders license headers (by @matks) - - #13235: Update src folder license headers (by @matks) - - #12941: Remove unnecessary return on update (by @eternoendless) - - #12999: Remove calls to old CLDR (by @Quetzacoalt91) - - #13141: Performance: avoid useless attributes queries (by @123monsite-regis) - - #12996: Domain improvements: naming and namespace (by @sarjon) - - #11730: Use of static instead of ClassName (by @MathiasReker) - - #11970: Unary operator spaces (by @MathiasReker) - - #11977: Function declaration (by @MathiasReker) - - #11975: Space after semicolon (by @MathiasReker) - - #13008: Adds phpdoc on range objectmodel (by @Matt75) - - #12782: Fixes for migrated Categories add/edit actions (by @sarjon) - - #12956: Customization - improve phpdoc and constants usage (by @Matt75) - - #12959: Make Tools curl throw an exception when it fails in dev mode (by @matks) - - #10406: Document and add tests to Faceted Search system (by @mickaelandrieu) - - #12251: Improve version (by @eternoendless) - - #12749: Remove 9 duplicates from array in getProductAttributeWhitelist(). Items sorted to check dupes. (by @toslan) - - #12810: Install ps_faviconnotificationbo automatically (by @eternoendless) - - #12808: Deprecate Cart::addExtraCarriers() (by @eternoendless) - - #12570: Add Drag & Drop styling for category position column (by @sarjon) - - #12346: Add Category form builder & handler (by @sarjon) - - #12498: Add showcase card for Suppliers list (by @sarjon) - - #12598: Restore composer file (by @PierreRambaud) - - #12532: Updated Core using new version of Composer script handler (by @mickaelandrieu) - - #12208: Add filter on the modules folder to avoid caching all files by Twig (by @Quetzacoalt91) - - #10783: Migration of Advanced Parameters > Team > Profiles page. (by @rokaszygmantas) - - #11968: Switch case space (by @MathiasReker) - - #11859: Replace tabs with spaces in htaccess (by @MathiasReker) - - #11961: Improvements in the Domain namespace (by @sarjon) - - #12247: Bump version to 1.7.6.0 (by @eternoendless) - - #12222: Add notice for docker-compose (by @PierreRambaud) - - #12211: Add breadcrumb to the search results page (by @SebBareyre) - - #11992: Replace calls to is_null by comparison (by @MathiasReker) - - #12082: Update Nginx configuration for multishop (by @PierreRambaud) - - #12150: Allow specific versions of libs to be ignored (by @Quetzacoalt91) - - #12031: Make pre-commit execute linter only if php files have been staged (by @eternoendless) - - #11985: PHP unit test case static method calls (by @MathiasReker) - - #11899: Introduce HelperList title_icon property (by @matks) - - #11866: Order imports (by @MathiasReker) - - #11867: Remove unneeded curly braces (by @MathiasReker) - - #11869: Remove unneeded control parentheses (by @MathiasReker) - - #11857: Replace tabs with spaces (by @MathiasReker) - - #11823: Fix namespace (by @MathiasReker) - - #11781: Fix blank lines: Add and remove (by @MathiasReker) - - #11729: Use binary mode to write files (by @MathiasReker) - - #10486: Split grid service definitions in separate files (by @sarjon) - - #10533: Add old product ID on actionProductAdd hook when duplicating a product (by @duGuillaume) - - #10975: Introduced a new function for Products.php for retrive a product ID given it reference (by @runningz) - - #11696: Combine consecutive issets (by @MathiasReker) - - #11708: Modernize types casting (by @MathiasReker) - - #11710: Include is not a function (by @MathiasReker) - - #11695: Array indentation (by @MathiasReker) - - #11685: Fix php-cs-fixer "non printable character" (by @MathiasReker) - - #11736: Remove unused imports (by @MathiasReker) - - #11757: Remove empty statement (by @MathiasReker) - - #11744: Fix PhpDoc Validate::isColor() (by @EdouardTack) - - #11697: Combine consecutive unsets (by @MathiasReker) - - #11635: Improve use of protocol (by @MathiasReker) - - #11738: No PHP closing tag and no EOL (by @MathiasReker) - - #11712: Normalize use of operators (by @MathiasReker) - - #11733: Add function type (by @MathiasReker) - - #11734: Remove comma in single array (by @MathiasReker) - - #11709: Use echo instead of print (by @MathiasReker) - - #11707: Do not use alias functions (by @MathiasReker) - - #11704: Remove useless return (by @MathiasReker) - - #11703: Do not use short echo tags (by @MathiasReker) - - #11701: Use logical operators (by @MathiasReker) - - #11699: Hash to slash comment (by @MathiasReker) - - #11694: Align multiline comment (by @MathiasReker) - - #11653: Allow override of _PS_DEBUG_PROFILING_ (by @SebBareyre) - - #11678: Fix use of protocol (by @MathiasReker) - - #11672: Non printable character (by @MathiasReker) - - #11643: Additional PHP Improvements (by @MathiasReker) - - #11666: Fully qualified strict types (by @MathiasReker) - - #11667: Heredoc to nowdoc (by @MathiasReker) - - #11671: Use constant instead of function (by @MathiasReker) - - #11669: Improve error suppression (by @MathiasReker) - - #11566: Build all the assets using a single command (by @eternoendless) - - #11313: Only call ntree regeneration at this end of a WS call and optimize regenerateEntireNtree (by @jocel1) - - #11510: Add PHP 7.3 polyfills (by @Quetzacoalt91) - - #11397: Add total_shipping_tax_excl, incl in email data (by @sitte) - - #11417: Lossless compression of all images (by @MathiasReker) - - #11246: Replace deprecated library PhpExcel by PhpSpreadsheet (by @MartinFinkenflugel) - - #11249: Fix declaration of method arguments (by @Seleda) - - #11140: Remove unreachable code (by @idnovate) - - #11139: Deprecate legacy Db service (by @sarjon) - - #10770: Update CacheClearer adapter (by @sarjon) - - #10777: Migration of Shop parameters > Contact > Contacts page. (by @rokaszygmantas) - - #10834: Allow release creator to be run without version parameter (by @Quetzacoalt91) - - #10699: Change getcwd() for __DIR__ (by @DanielBoettner) - - #10704: Add TranslatableType (by @sarjon) - - #9247: Add themes in gitignore (except classic) (by @Quetzacoalt91) - - Bug fix: - - #13684: Wrong discount subtotal when customergroup is set to use ex taxes (by @tomlev) - - #13604: Forbid URLS to be added in customer names (by @PierreRambaud) - - #13605: Add missing translation domains (by @matks) - - #13560: Remove duplicate method call (by @eternoendless) - - #13540: Update upgrade scripts to PS 1.7.6.0 (by @Quetzacoalt91) - - #13470: Removes GetDefaultGroupHandler adapter (by @sarjon) - - #13435: Fixes option for MaterialMultipleChoiceTableType (by @sarjon) - - #13409: Do not call removed cldr lib (by @Quetzacoalt91) - - #13353: Fixes default Customer group overriding (by @sarjon) - - #13189: Harmonize Grids naming (by @sarjon) - - #13256: Fixes to Customer subdomain & controller (by @sarjon) - - #13246: Add missing hook description (by @eternoendless) - - #13242: Add missing hook description for additionalCustomerAddressFields (by @eternoendless) - - #13222: Do not try to install an unsupported language (by @PierreRambaud) - - #13208: Fix broken page when requesting a duplicate _legacy_link (by @PierreRambaud) - - #13209: Properly set error headers (by @jocel1) - - #13146: Fixes missing fields validation in Language command handlers (by @sarjon) - - #13115: Fix strpos arguments order (by @quasilyte) - - #12550: Improve the way VAT is managed for price calculation (by @prestamodule) - - #13057: Fix search action configuration for grids (by @sarjon) - - #12967: Foward $locale to Translate::getModuleTranslation() (by @eternoendless) - - #11962: Do not stripslashes value from _GET & _POST (by @PierreRambaud) - - #12960: DoctrineBuilderExtension uses YamlParser for its config (by @jolelievre) - - #12940: Do not look for translations if no locale (by @matks) - - #12841: Add deprecation notice for hook actionAjaxDieBefore (by @eternoendless) - - #12803: Fallback on language code when locale is empty (by @Quetzacoalt91) - - #12756: Fix bug when overriding the Address class (by @dariusakafest) - - #12739: Revert new theme to Webpack 2 (by @PierreRambaud) - - #12559: Remove translations from db when Language is deleted (by @sarjon) - - #12152: Fix timezone standard is ignored (by @michaesc) - - #11764: Fix undefined property (by @idnovate) - - #12473: Order Creation: fix out of stock status (by @rGaillard) - - #12484: Fix missing tag for CustomerType (by @sarjon) - - #12124: Remove unwanted umask (by @PierreRambaud) - - #12399: Actually use arguments passed to CountryDataProvider->getCountries() (by @TysonAndre) - - #12397: Fix use of array_merge in HookFinder->addExpectedInstanceClasses (by @TysonAndre) - - #12367: Move PositionColumn in its original folder (by @Quetzacoalt91) - - #12344: Fix translation on account creation email error (by @SebBareyre) - - #11442: Fixed the problem with the type of a return value in Module::onInstall() (by @zapalm) - - #12139: Fix some Symfony service definitions (by @matks) - - #12125: Fix bad GridFactory service definition (by @matks) - - #12014: Unify algorithm for calculating average tax rate for products in a cart (by @eternoendless) - - #12010: Make filtering of LazyArrays return a new instance (by @eternoendless) - - #12015: Fix typo in example Nginx config file (by @mwht) - - #11809: Fix misuse of information returned by getimagesize (by @olivier-monaco) - - #11876: Fix lang table multi-store data issue (by @Dan-Orchard) - - #11892: Fix missing const definition (by @sarjon) - - #11895: Fix categories grid id (by @sarjon) - - #11884: Do not allow null for low_stock_alert (by @eternoendless) - - #11706: Fix implode calls (by @MathiasReker) - - #11679: Fix issue with deleting a category with subcategories on Multistore (by @MathiasReker) - - #11691: Fix bug on pdf logo path (by @SebBareyre) - - #11747: Convert comments to php docs in some cases (by @MathiasReker) - - #11731: Fix typo in Phpdoc (by @MathiasReker) - - #11714: Fix line ending (by @MathiasReker) - - #11711: Add missing braces (by @MathiasReker) - - #11559: Keep first try of translator initialization in memory (by @Quetzacoalt91) - - #11564: Fix shop name in the subject of mail (by @khouloudbelguith) - - #9034: Added missing Rewrite base on Api rule (by @123monsite-regis) - - #10465: Fixed bug on inc/dec product quantity in cart with vouchers discounts (by @sete391) - - #11469: Fix SQL update when last_connection_date is null (by @Quetzacoalt91) - - #11204: Fix incorrect comparison when out of stock (by @andromaque) - - #11202: Fix a bug where PrestaShop cookie is set on every page when a cookie value is NULL (by @jocel1) - - #11214: Handle bad address use case for Carrier Tax Rate (by @matks) - - #11151: Fix MailsProvider service declaration name (by @mickaelandrieu) - - #11168: Remove Throwable from core (by @sarjon) - - #10917: Add getConfiguration to PrestaShopBundle (by @Quetzacoalt91) - - #10536: Delete search indexes after deleting a product (by @MathiasReker) - - #10722: Update Smarty and Symfony to latest (by @eternoendless) - - #9042: Fix controller override (by @nenes25) - - #12243: Update gitignore (by @PierreRambaud) - - #13171: Outdated assets (by @PierreRambaud) - - Refactoring: - - #12926: Migration of Manufacturers view action (by @sarjon) - - #11783: Migrate customers searching via ajax (by @sarjon) - - #12766: Remove duplicate CLDR service (by @matks) - - #12447: Remove legacy Webservice controller (by @sarjon) - - #12446: Enable new Languages page (by @sarjon) - - #12398: Fix unused variables where straightforward to do so (by @TysonAndre) - - #12293: Migrate actions of Languages list (by @sarjon) - - #12400: Remove a harmless duplicate array entry in PositionsController (by @TysonAndre) - - #12263: Migrate Add/Edit actions for webservice keys (by @sarjon) - - #11997: Happy new year 2019 (by @Quetzacoalt91) - - #11135: Migrate Employees list actions (by @sarjon) - - #12249: Migrate legacy test TermsAndConditionsTest and refactor related class (by @matks) - - #11885: Migration of Languages adding/editing (by @sarjon) - - #11169: Migrate Theme & Logo (by @sarjon) - - #12022: Use Symfony Cache Clear in ModuleManager instead of deprecated CacheClearer (by @matks) - - #10916: Migrate customers listing (by @sarjon) -- Installer: - - New feature: - - #12864: Remove ps_legalcompliance from composer.json (by @Quetzacoalt91) - - Improvement: - - #13734: Update translations catalogue for 1.7.6 (by @eternoendless) - - #13069: Update demo features (by @marionf) - - Bug fix: - - #13471: Set null values when trying to retrieve the non-existing default shop (by @Quetzacoalt91) - - #13223: Fix SQL syntax error in upgrade file to PS 1.7.6 (by @Quetzacoalt91) - - #13078: Revert "Fix delivery slips failure when upgrading" (by @Quetzacoalt91) - - #12666: Fix delivery slips failure when upgrading (by @rblaurin) - - #12155: Fix fixtures not generating thumbnails (by @PierreRambaud) - - #12141: Change php requirements in INSTALL.txt (by @PierreRambaud) - - #9366: Don't display the system step if mandatory requirements are OK (by @rGaillard) -- Web Services: - - Improvement: - - #12329: API and Products: Add missing combination IDs in the pack content (by @Quetzacoalt91) - - #11938: Make customer's product customization information reachable in WebServices (by @eternoendless) - - Bug fix: - - #12836: Fixes fatal error when trying to get the images of a product with no images (by @mowcixo) - - #12201: Fix SQL exception when creating a product_option without values (by @mowcixo) - - #11902: Fix API error with php 7.2 (by @DelecroixQuentin) - - #11192: Correctly call hook for product update in Product class (by @alexll) -- Localization: - - Bug fix: - - #10843: Fix typo in download_product.txt (by @antonellamarengo) - - Refactoring: - - #12747: Fix PhpDoc for AttributeGroupCore::getAttributes() (by @BadPixxel) -- Tests: - - New feature: - - #13167: Move lint checks in GitHub action (by @Quetzacoalt91) - - #12091: Geo-location: By IP address (by @ansar21mallouli) - - #12086: Location: zone and country (by @ansar21mallouli) - - #12049: Change position, unhook and transplant a module (by @ansar21mallouli) - - #12030: Filters by category in catalog page (by @ansar21mallouli) - - #12001: Filters in catalog page (by @ansar21mallouli) - - #12007: Delivery slip test (by @YosraAk) - - #11897: Generate invoice pdf by date and status (by @hadrich-hatem) - - #11891: Credit slip, credit slip pdf and credit slip options (by @hadrich-hatem) - - #11804: Localization: local units and configuration (by @ansar21mallouli) - - #11800: Create, edit and delete feature (by @hadrich-hatem) - - #11768: Import localization pack (by @ansar21mallouli) - - #11766: Create, edit, delete, exchange rate currency (by @ansar21mallouli) - - #9309: Check buttons in header product page (by @hadrich-hatem) - - #9312: Check order details (selenium tests) (by @fatmaBouchekoua) - - #11184: Advanced localization (by @ansar21mallouli) - - #9341: Identity (Selenium tests) (by @fatmaBouchekoua) - - Improvement: - - #13356: Adds unit tests for FormHandlerFactory (by @sarjon) - - #13176: Allow to use date as parameter for nightly builds (by @PierreRambaud) - - #13127: Do not run tests with the StarterTheme anymore (by @Quetzacoalt91) - - #13052: Remove usage of TRAVIS_BUILD_DIR (by @PierreRambaud) - - #12804: Use string value for CSRF token in DeliveryControllerTest (by @matks) - - #12793: Allow Travis phpHigh build to fail as it is an informative check, not not a mandatory check (by @matks) - - #12495: Add a descriptif comment for the broken test "installation language <> country " (by @YosraAk) - - #12490: Add a descriptive comment for the broken test "create_edit_delete_contact" (by @YosraAk) - - #12488: Add a descriptif comment for the broken test "create_edit_delete_language" (by @YosraAk) - - #12496: Add a descriptif comment for the broken test "autoupgrade" (by @YosraAk) - - #12494: Add a descriptif comment for the broken test "sort filter file" (by @YosraAk) - - #12493: Add a descriptif comment for the broken test "linkWidget" (by @YosraAk) - - #12492: Add a descriptif comment for the broken test "page" (by @YosraAk) - - #12491: Add a descriptif comment for the broken test "category" (by @YosraAk) - - #12487: Add a descriptif comment for the broken test "configuration" (by @YosraAk) - - #12482: Add a descriptif comment for the broken test "Delete category" (by @YosraAk) - - #12486: Add a descriptif comment for the broken test "read_more_module" (by @YosraAk) - - #12485: Add a descriptif comment for the broken test "create_feature" (by @YosraAk) - - #12481: Add a descriptif comment for the broken test "create_product_with_combination" (by @YosraAk) - - #12480: Add a descriptif comment for the broken test "shopping_carts_view" (by @YosraAk) - - #12021: Add unit tests for CommandBus, DocumentationLinkProvider and UrlFileChecker (by @matks) - - #12378: Improve report files generation (by @PierreRambaud) - - #12369: Fix deprecation notices reported by Composer (by @Quetzacoalt91) - - #12304: Add unit tests for Core IdentifiableObject classes (by @matks) - - #12324: Separate nightly tests and reports (by @PierreRambaud) - - #12298: Improve logging for nightly tests (by @PierreRambaud) - - #12232: Add unit tests for Core/Kpi (by @matks) - - #12256: Wrong duration time while combine nightly tests reports (by @PierreRambaud) - - #12183: Restore survival test for Import page (by @matks) - - #12188: Add test link id (by @ansar21mallouli) - - #11725: Nightly tests build on Google Cloud Platform (by @PierreRambaud) - - #11920: Add advice when lint fails + Display all files in error in Travis lint job (by @Quetzacoalt91) - - #12060: Enable PHP CS Fixer on tests folder (by @matks) - - #11865: PHP unit set up tear down visibility (by @MathiasReker) - - #11677: Fix wrong name (by @MathiasReker) - - #11674: Simplify PHP unit construct (by @MathiasReker) - - #11675: Simplify PHP unit expectations (by @MathiasReker) - - #11676: Use camelcase instead of snakecase in functions (by @MathiasReker) - - #11565: Allow tests high and fix conflicts in file (by @PierreRambaud) - - #11237: Improved survival tests (by @mickaelandrieu) - - #10724: Clean php-cs-fixer files (by @matks) - - #9421: Update test high : create product with combination/create virtual … (by @fouratachour) - - Bug fix: - - #13464: Apply CS Fixer on 1.7.6.x (by @Quetzacoalt91) - - #13113: Fix typo on static (by @Quetzacoalt91) - - #12574: Fix PositionsControllerTest for good (by @jolelievre) - - #12238: Wrong directory to check if there are files reported by mochawesome (by @PierreRambaud) - - #12225: Add a json check when running report combine (by @PierreRambaud) - - #12210: Update nightly tests (by @PierreRambaud) - - #12166: Update php-cs-fixer to a recent version to be compatible with PHP7.3 (by @PierreRambaud) - - #12079: Fix static cache reset on ObjectModel (by @tomlev) - - #10477: Added an Error Data Listener (by @mickaelandrieu) - - #12013: Isolate legacy tests into suites to fix develop branch (by @matks) - - #11898: Fix travis script for running tests and fix broken tests (by @matks) - - #11549: Fix unable to build tests container (by @PierreRambaud) - - #11306: Fix linter jobs of Travis (by @Quetzacoalt91) - - Refactoring: - - #13686: Add close welcome module for tests 11_international (by @boubkerbribri) - - #13683: Add close welcome module for tests 10_modules (by @boubkerbribri) - - #13680: Fix tests customer (by @boubkerbribri) - - #13630: Fix Onboarding close method (by @boubkerbribri) - - #13656: Fix for tests in order test suite (by @SimonGrn) - - #13657: Fix the check of the success message when saving and deleting a currency (by @nesrineabdmouleh) - - #13667: Fix test Feature 1 create edit delete feature (by @boubkerbribri) - - #13676: Add close welcome modal for tests Manufacturer (by @boubkerbribri) - - #13693: Fix first test of the order test suite (by @SimonGrn) - - #13696: Add welcome module for tests discount (by @boubkerbribri) - - #13700: Fix test 3 of the shop parameters test suite (by @SimonGrn) - - #13637: Add handling of the welcome modal and document the blocking issue for the last step (by @SimonGrn) - - #13661: Fix for test 4 of the order test suite after canonical url fix (by @SimonGrn) - - #13651: Adding close welcome module in tests product (by @boubkerbribri) - - #13659: Adding close welcome module in tests Attribute (by @boubkerbribri) - - #13612: Fix test 05 create order without account (by @boubkerbribri) - - #13615: Fix test Product suite full (by @nesrineabdmouleh) - - #13545: Fix test Employee Suite Full (by @boubkerbribri) - - #13616: Fix method used to change quantity (by @SimonGrn) - - #13602: Fix for test 2 of the orders test suite (by @SimonGrn) - - #13502: Fix test Category suite full (by @boubkerbribri) - - #13597: Fix test 09_delivery_slips_pdf_and_options (by @boubkerbribri) - - #13570: Fix broken selectors and logic for the test suite 9 (customer) (by @SimonGrn) - - #13588: Fixing some tests orders (by @boubkerbribri) - - #13581: Fix test feature update (by @ntiepresta) - - #13568: Fix tests 10_module Suite Full (by @boubkerbribri) - - #13561: Fix for tests 1 and 2 of the shop parameters test suite (by @SimonGrn) - - #13503: FIx test Create Attribute Suite Full (by @boubkerbribri) - - #13534: Fix tests manufacturer (by @boubkerbribri) - - #13552: Fix tests International/localization and international/taxes (by @boubkerbribri) - - #13536: Fixes e2e broken selectors (by @mbadrani) - - #12634: Behat cart tests (by @tomlev) - - #12679: Add some fixes to the campaign full (by @YosraAk) - - #12678: Create virtual product (by @ansar21mallouli) - - #12431: Update product quantity test (by @YosraAk) - - #12362: Go to next and previous page test (by @ansar21mallouli) - - #12355: Print the delivery slip (by @ansar21mallouli) - - #12351: Update create order in FO test (by @YosraAk) - - #12343: Print invoice order (by @ansar21mallouli) - - #12317: Create order in BO test (by @ansar21mallouli) - - #12315: Create order as a guest test and update readme file (by @YosraAk) - - #12289: Update sort module test (by @ansar21mallouli) - - #12281: Update zip module test (by @YosraAk) - - #12266: Migrate ImageTagSourceParserTest in tests folder (by @matks) - - #12272: Add checkFile step after downloading a file (by @YosraAk) - - #12245: Update check notifications test (by @ansar21mallouli) - - #12219: Update click on discover test (by @ansar21mallouli) - - #12220: Update file tests (by @YosraAk) - - #12217: Update search module test (by @ansar21mallouli) - - #12206: Installation test (by @ansar21mallouli) - - #12190: Update check the addons catalog page test (by @ansar21mallouli) - - #12181: Update onboarding test (by @YosraAk) - - #12122: Add a new brand address test (by @ansar21mallouli) - - #12115: Update create manufacturers test (by @ansar21mallouli) - - #12112: Update bulk actions in catalog page test (by @ansar21mallouli) - - #12104: Update delete shopping cart test (by @ansar21mallouli) - - #12067: Add some fixes to the campaign full (by @YosraAk) - - #12054: Migrate legacy unit test for Hashing (by @matks) - - #12045: Update autoupgrade test (by @YosraAk) - - #11776: Fix campaign full tests on develop branch (by @YosraAk) - - #11525: Introduce modern unit tests for new test structure (by @matks) - - #11529: Migrate tests-legacy tests to namespace LegacyTests (by @matks) - - #11464: Cleanup /tests directory (by @sarjon) - -#################################### -# v1.7.5.2 - (2019-05-02) -#################################### -- Core: - - Bug fix: - - #13599: Forbid URLs to be added in customer names (by @PierreRambaud) - - #13580: Fixed dispatched hook on the Grid presenter (by @mickaelandrieu) - - #13567: Improve name validation (by @eternoendless) - - #13549: Forbid URLs to be inserted into Name fields (by @matks) -- Tests: - - Refactoring: - - #13583: Fix selector in E2E tests for addons catalog page and another one in the autoupgrade test (by @nesrineabdmouleh) - -#################################### -# v1.7.5.1 - (2019-02-18) -#################################### -- Back Office: - - Bug fix: - - #12507: Add hookDispatcher in GridFactory constructor, HookDispatcherAwareTrait has a safer getter - - #12234: Force refresh of tinymce editors in product page step 1 - - #12402: Fix first attribute generation when not choosing first attribute - - #12372: Fix provider warehouse routes - - #12370: RTL fixes: profile, select and notification dropdown, popover tooltips, stock quantity arrows - - #12395: Change stock alert z index to be on top of header - - #12354: Fix cancel button on Safari browser - - #12361: Refacto SearchParameters and SearchParametersResolver for pagination - - #12205: Fix bulk module actions - - #12277: Prevent usage of enter key in search hook input - - #12236: SERP: Textarea from tinymce requires jquery to return the text value - - #12016: Update module & service link in upgrade - - #12196: Fix RTL glitches - - #12111: Keep showcase cards closed - - #11923: Fix error in SERP component when using non-alphanumeric characters - -- Front Office: - - Improvement: - - #12327: Make it possible to enable/disable attribute name on page title - - Bug fix: - - #12337: Slow combination update due to delay before request - -- Core: - - Bug fix: - - #12543: Update vulnerable dependencies - - #12389: Fixed grid hook calls - - #12292: Allow arabic numbers in link rewrite - - #12106: Robots.txt with multilang/multishop - - #11995: Fix undefined INTL_IDNA_VARIANT_UTS46 if intl ICU < 4.6 - - #11814: Fix typos and duplicate code in upgrade SQL - -- Installer: - - Bug fix: - - #11937: Check if intl is installed in installer - -#################################### -# v1.7.5.0 - (2018-12-17) -#################################### -- Front Office: - - Bug fix: - - #11777: Do not perform updateProductRequest() AJAX call if no valid data input - -#################################### -# v1.7.5.0 RC 1 - (2018-12-10) -#################################### -- Back Office: - - Improvement: - - #11533: Disable oProxyCommand when imap.enable_insecure_rsh does not exists - - #11466: Revert separated module buttons - - #11147: PositionColummn UI/UX modifications - - Bug fix: - - #11644: Fix ID replacement in urls generated by symfony - - #11584: Fix displayAdminProductsExtra hook content display in V1.7.5.0 beta - - #11600: Translate module categories - - #11572: Clear cache on module action - - #11579: Remove deprecated functions - - #11531: Fix all miswritten getAdminLink calls in templates - - #11339: Fix default values on import page - - #11508: Escape javascript and html strings - - #11475: Impossible to change position of products - - #11486: Fix layout - - #11478: Changes the redirection url after store update - - #11279: Allow product ordering on explicit request - - #11463: Fix admin translation redirect - - #11448: Remove useless trad files in install for persian - - #11447: Escape everything! - - #11421: Display configure button only if module is configurable - - #11416: Fix customer/address delete resulting in error on cart page - - #11410: Changing primary domain name no longer reindexes simplified URLs - - #11309: Add LegacyContext::getLegacyAdminLink - - #11407: Module manager sorting - - #11394: Fix crashing for bulk actions - - #11384: Add an rtlfix file to correctly hide the right side bar in rtl languages - - #11311: Be able to disable Help Link on Back Office pages - - #11337: Show more logs in admin - - #11344: Manage redirection after email translation - - #11312: Prevent short description limit to be set at 0 - - #10956: Fix product features - - #11287: Fix filemanager security breaches - -- Front Office: - - Bug fix: - - #10964: Fix bug in ajax quantity refresh - - #11261: Fixed inconsistent locale in Front Office - -- Core: - - Improvement: - - #11070: Feature/module manager categories - - #11058: Add Hindi, Mexican & Bosnian languages - - Bug fix: - - #11603: Fixed CVE-2018-19277 - - #11601: Update ps_checkpayment to latest version - - #11376: Some strings need to be escaped - - #11385: Fix missing dot in wording - - #11345: Update translations catalog - - #10845: Minor services naming fix - - #11300: Fix error on tab unregistration when handled by the module - - #9316: Fix Cart::autoAddToCart using undefined customer when called from BO - -- Installer: - - Improvement: - - #11357: Improve install warning message for beta builds - -#################################### -# v1.7.5.0 beta 1 - (2018-11-08) -#################################### -- Back Office: - - New feature: - - #10906: Add new native module ps_faviconnotificationbo - - #10414: Link modules routes, position column and extension, GridPositionUpdater - - #10422: Add stock location through ps_stock_available table - - #10234: Migration of Shop parameters -> Traffic & Seo -> Seo & urls page - - #9444: Add search engine result preview on product page - - #10208: Migration of Advanced Parameters -> Webservice -> listing - - #9465: Enable 'edit specific price' button on BO Product page which opens a pop-in - - #9449: Migration of Improve -> International -> Translations page - - #9305: Introduce ToggleColumn for Grid component - - #9310: Migrate "Configure > Advanced Parameters > Webservices" - part 1 (configuration form) - - #9457: Enable Logs page - - #9377: Migrate E-mail page - - #8984: Introduced advanced and reusable search system - - #9153: Be able to declare modern controllers in modules - - #9192: Migrate Payment methods page - - Improvement: - - #11035: Optimize legacy links in dev mode - - #11063: Improve PositionColumn to allow more route params - - #10868: Manage backward compatibility of legacy links - - #10901: Make Logger stdout configurable using env variables - - #10725: Hide delete button on ordered cart - - #10569: Update Grid definition Ids - - #10529: Implement empty states aka Showcase blocks - - #10440: Change categories in Module Manager - - #10485: Minor migrated Webservice improvements - - #9287: Separate module action buttons - - #10426: Handle boolean returns from RequestSql validation - - #10416: Improve perceived form horizontal alignment - - #10311: Small improvements for Webservice list - - #10358: Update list and settings layout - - #10265: Move Logs page JS to appropriate location - - #9471: Build Back Office default theme using Webpack 4 - - #10170: Small ux optimizations - - #9454: Notifications tab + new hierarchy - - #9451: Replace PrestaTrust property with setter - - #9228: Migrate module positions - - #9447: Migrate Backup page - - #9430: Update modern forms layout - - #8710: Improved Product catalogAction - - #9206: Migrate "Configure > Advanced Parameters > Database > SQL Manager" page - - #9397: Update style of forms on new pages - - #8690: Improved performance of Product List page - - #9410: Improve grid search and reset buttons - - #9306: Add a link to the addons' favicon generator - - #9242: Introducing reusable way to display KPIs blocks in Back Office modern pages - - #9225: Migrate "Improve > Payment > Preferences" page - - #9210: Duplicate array keys - - #9137: Improve routing of PrestaShop application - - #9139: Migrate Sell > Orders > Delivery Slips - - Bug fix: - - #11182: The deletion of themes must depends on Employee permissions - - #10898: Fixed performance rights on Performance Clear Cache action - - #11136: Fix param name on email delete all bulk action - - #11123: Make the E2E tests wait for the first load of the BO with welcome module enabled - - #11111: Revert "Apply quotes around the column names would make all the SQL r… - - #11071: Avoid glitch on checkbox click - - #10991: Fix sorting issue in the SQL Manager page - - #10861: Fix fixed height of TinyMce fields - - #10718: Add missing styles on empty state SEO & Traffic page - - #11032: Min height product image dropzone - - #10936: Prevent unvalidated form without checkboxes - - #10436: Style issue on BO - - #10968: Fix General options configuration - - #10967: Fix Bad annotations (backport of #10939) - - #10949: Update help panel position on legacy pages - - #10856: Fatal error when saving product with tags - - #10946: Allow errors without field to be displayed on product form - - #10950: Update module breadcrumb in category page - - #10810: Allow URL in search result preview to be live updated - - #10684: Avoid displaying the addon modal twice, change form names/IDs to avoid collision - - #10857: Use parent javascripts used for displaying help - - #10862: Fixes bug when filter reset functionality sometimes does not work - - #10751: [BO] Fix bug when filter stores by name or address - - #10835: Fix import module - - #10814: Restore legacy sql manager page 175 - - #10778: Enable pagination when offset is set - - #10788: Allow url in search preview to use several lines - - #10796: Reuse getAdminLink instead of copy pasting its content - - #10752: Use the right PrestaShop namespace for twig templates - - #10735: Module translations aren't working when using Smarty Extend into TPL in BO - - #10741: Fix import form alignment - - #10728: FilterParametersUpdater manages filters in a better way - - #10462: Fix wrong display of the brand page - - #10726: Module manager improvement (search, categories, configure button) - - #10736: Use new routes for quick access - - #10681: Fix module catalog js & css issues - - #10705: Move position column template - - #10656: Fix grid ids in migrated JS - - #10601: Use attr('data-') instead of data - - #10448: Fatal error while adding tags - - #10382: Bug when advanced stock management is enabled in Product Shipping page - - #10571: Fix broken service definition - - #8237: Fixed bug in AdminGroupsController when adding ModulesRestrictions to group in multishop configuration - - #10435: Removed onclick from URL column in BO Shop URLs - - #10427: Get link of the first ACTIVE tab in nav - - #10295: Display the company name in outstanding orders - - #10291: Fix the display of textarea in the category page - - #10375: Fix category tree in BO Products Catalog page - - #10361: Only load Vue Serp component if available - - #10135: PDF documents unformatted - - #9324: Fixed the Show SQL query action - - #10202: Fix 'edit specific price' modal behavior bugs and display - - #9453: Allow import entity to be preselected - - #10322: Wrong variable name - - #10326: Manage getAdminBaseLink in LegacyContext::getAdminLink - - #10302: Images aren't displayed in combinations with new products - - #10281: Fixed minor issues on Logs Grid page - - #10260: Fix help sidebar not working in the Stock page - - #10223: Fixed DB backup page - - #10221: Product Page: fix visual glitches in categories filter - - #10242: Fix wrong translations - - #10233: HookDispatcher dispatchMultiple doesn't exists anymore - - #10169: Images aren't displayed in combinations - - #10201: Errors when saving memcached configuration - - #10165: Add form handler for Translations settings forms - - #10139: Remove legacy AdminBackup controller - - #9352: Fix 'recommended modules' popin behavior in BO - - #9466: Fix combination generation - - #10042: With undefined function call (Fixed #10041) - - #9450: Modify Link::getAdminLink in MultipleShop mode - - #9407: Display NOK PrestaShop requirements - - #9455: Removed all translations errors from localization page - - #9334: Fix sample file download & fields load via ajax in Import - - #9399: Fix ajax in 500 in product page - - #9389: Fixed path to updated files in System Information page - - #9259: Make PrestaShop fully compatible with Twig 2+ - - #9369: Combinations not working when token is disabled - - #9318: Make documentation link on the dashboard point to the 1.7 docs instead of 1.6 - - #9333: Small fixes for Sell -> Orders -> Invoices page - - #9267: Unable to copy theme translations - - #9286: Grid/reset action - - #9300: Fix grid sorting by - - #9265: Can't upload an image in the product page - - #9255: Fix rendering of theme catalog page - - #9235: Corrects a bug when importing store contacts - - #9215: Adapted module URLs for new routing - - #9195: Fixed mixed up display in some cases at partial refunds - - #9198: Add use statement for AppKernel - - #9171: Fixed namespace of Delivery Slips controller - - #9170: Fix smarty condition count - - #9149: Error with quota fields - -- Front Office: - - Improvement: - - #11156: Rollback product canonical - - #11084: Update modules for new 1.7.5 version - - #11015: Adding/Deleting voucher on checkout payment step should refresh amount on payment block - - #10229: Mobile Menu: improve UX/UI of the mobile menu - - #10484: Fix: classic theme footer block design #10483 - - #9459: Show the category block in the list page on first page only - - #9472: Modify category pagination for SEO purposes - - #9362: Add breadcrumb to the contact page - - #9456: Modify product canonical url and title value - - #10207: Voucher button is too long in Cart - - #9458: Change brand and supplier default rule for SEO purposes - - #9463: Change the default redirection behaviour to product category - - #9417: Override CustomerAddressForm->submit method more easily - - #9097: Fix phone fieldtype - - #9110: Make checkbox labels clickable on the classic theme - - Bug fix: - - #11055: Fix minimum quantity blocking - - #10812: Display the specific reference for each combination's product - - #10447: Double h1 tag on category page - - #10750: Do not display product Reference if empty - - #10428: Fixes issue #10417 incorrect argument order - - #10438: Fix for Issue #10433 : Update lastName and firstName max size - - #10267: Product List: pack flag visual problem - - #10350: Fix empty row when social title is empty - - #10347: Fix htaccess to support Apache 2.4 webservers - - #10352: Fix htaccess to support Apache 2.4 webservers - - #10279: Check minimal quantity - - #10254: Fix getTotalWeight Notice - - #10232: Generate front core assets - - #10230: Add magic methods on LazyArray classes for object-like use - - #9387: Fix for browser back button on product page - - #10195: Fix the bootstrap classes for left-column ID - - #9405: Error when adding product in cart or editing quantity - - #9469: Do not display product Specific References if empty - - #9462: Fix wrong rules in robots.txt - - #9441: Fix 403 error when accessing localhost using IPv6 (Maxmind Database exists) - - #9422: Add missing appendArray in OrderReturnLazyArray (BOOM-6039) - - #9433: Add customizations field in product whitelist - - #9445: Change out of stock condition with greater or equals - - #9446: Fix welcome page variable injection by adding missing % - - #9429: Add formatted field file_size_formatted in attachments - - #9390: Combination issue while trying to change size on a product page - - #9403: Convert ProductLazyArray when using render function - - #9368: Detect if there is already GET param in URL - - #9372: Update OrderFollowController.php - - #9381: Fix label "Use this address for invoice too'" - - #9373: Prevent users from doubleclick on Payment button from #9351 - - #9276: Fix product quantity in order return details table - - #9353: Correctly handle hyphens in search index - - #9219: Fix delivery time not shown - - #9214: Fix products pagination without URL rewriting - - #9211: Updated page parameter name in Link and Meta classes - - #9069: Fix gift wrapping fees - -- Core: - - New feature: - - #9281: Allow overriding of every part of Grid templates - - #9460: Implementation of CQRS in SqlManager page - - #10241: Add Tactician command/query bus - - #9344: Add function to display information message - - #9230: Migration of Sell > Orders > Invoices page - - #9094: Migrate Improve > Shipping > Preferences controller - - #8990: Introduced Grid system - - #9116: Migrate localization page - - #9174: Added a service to manage PrestaShop versions (may deprecate _PS_VERSION_) - - #9121: Make commands from PrestaShop modules available in PrestaShop application - - #9007: Migrate Shop parameters -> Order settings page - - Improvement: - - #11068: Prevent CS Fixer from adding a trailing dot to the first paragraph of phpdoc - - #11078: Update dependency for security reason - - #10905: Update catalog - - #10883: Missing translations - - #10863: Update translations catalog for 1.7.5 - - #10662: Update native modules - - #10464: Undeclared property in the PaymentModule class - - #9292: Update pull-request template with additional PR types - - #9402: Improve grid data providers - - #9356: Add new variable in product.php, to sort features in front - - #10219: Minor grid improvements - - #8744: Prefer Hook::coreRenderWidget - - #10151: Replaced Forge URL with GitHub issues - - #9396: Update version to 1.7.5.0 - - #10138: Avoid a DB query in Address:isUsed() in case of new Address - - #9470: Refactored the Grid component - - #10110: Replace Forge with GitHub issues in PR template - - #9440: Ease CustomerAddressForm customization - - #9437: Introducing HookDispatcherInterface - - #9554: Update links to use GitHub issues in README.md and CONTRIBUTING.md - - #9467: Build core theme using Webpack 4 and jQuery 2.2.4 - - #9461: Update Readme - - #9442: Decouple filters and columns - - #9428: Added a new hook to custom SwiftMessage before sending mail - - #9452: Small naming update in grid - - #7612: Added new actionFrontControllerSetVariables hook - - #9291: Small FrameworkBundleAdminController clean up - - #9426: Add comment line to Address.php - - #9432: Make it unnecessary to append a '_' to the controller name when using the AdminSecurity annotation - - #9424: Issues templates - - #9404: Add gsitemap - - #9320: Phpdocs2 - - #9384: Update README.md - - #9342: Make grid.js more extendable - - #8904: Add new presenter implementation optimized for performances (lazy loading) - - #9319: Phpdocs - - #9250: Implement addBefore() & addAfter() methods of ColumnCollection - - #9264: Avoid AJAX request if we didn't have a refresh URL in the core cart JS file - - #9293: Rename routing file catalog.yml to _catalog.yml to follow routing structure - - #9282: Cleanup ModuleTemplateLoader - - #9283: Update column naming - - #9256: Improve resolving of column options - - #9254: Merge 1.7.4.x in develop - - #9201: Refactor Version class and client code and add unit tests - - #9208: Glob and scandir without sorting are faster - - #9229: Merge 1.7.4.x in develop - - #9207: Replace array_push calls behaving as $array[] since it works faster than invoking functions in PHP - - #9199: Introduced Survival tests for new modern pages - - #9205: Improve form choice providers - - #9209: Callable calls in loops, repetitive calls - - #9204: Remove leftover routing files - - #9176: Migrate "Improve > International > Localization > Geolocation" page - - #9066: Refactor Dispatcher::useDefaultController() - - #9182: Merge 1.7.4.x in develop - - #9154: Migrate Theme Catalog Page of Design Section - - #9162: Remove useless line for meta_title - - #8956: Add customization ID to cart ajax response and updateCart event data - - #9163: Case mismatch in class/function/method call - - #9155: Updated contributor list - - #9146: Merge 1.7.4.x in develop - - #9037: Permit IDE completion with PHP doc - - #9096: Clean up service yml files - - #9067: Refactor Controller class (minor changes) - - #9115: 1.7.4.x into develop - - #9109: 1.7.4.x into develop - - #9053: Add missing package-lock.json files - - #9091: Update develop with 1.7.4.x changes - - #9056: Deprecate polyfill function array_replace() - - #9068: Refactor Cart::checkQuantities() - - #9062: Improved errors management if Dev mode is enabled - - #9071: Refactor AbstractCartTest - - #9061: Removed redundant checks and added docblock in Tools::getIsset function - - #9035: Add package-lock.json file - - Bug fix: - - #10446: Increase max size of reference, meta_title, meta_description email, password, firstname, lastname and company. - - #11066: Fix wording in wrong domain - - #11076: Fix wordings - - #10933: Fix translation catalog - - #11030: Harmonize migrated controllers - - #10865: Fix compatibility with PHP 5.6 for PS exception - - #10840: Update Smarty and Symfony to latest - - #10837: Remove rebuild of SymfonyRequirements file after every composer run - - #10795: Use https only for API calls and limit use of guzzle - - #10696: Check $sfRouter before using it - - #10743: Execute query modification hook before fetching data - - #10376: Update HTML purifier - - #10419: Change Javascript indent to 2 spaces, per AirBnb rules - - #10363: Fix undefined method in query parser - - #10337: Remove hard-coded-version in assets URL - - #9475: Make title different from meta title on CMS for SEO purpose - - #10287: Fixed pre-commit hook script - - #10227: Fixed error with inheritance - - #9343: Fix function comment of Module class - - #10200: Bring back Addons Catalog controller - - #10218: Fix falsy value returned by upgrade script - - #10182: Fix deprecated call to Tools::replaceByAbsoluteURL - - #10155: Fix trusted modules cache creation - - #9474: Files from translations folder can not be accessed - - #9436: Remove unused taxes - - #9244: Fixed Apache Optimization - - #9285: Allow more than 36 products per page - - #9386: Merge 1.7.4.2 into develop - - #9047: Fixed nginx config for symfony controllers - - #9289: Version/update release creator - - #9145: Bug correction when changing shipped state - - #9231: Fixed missing call of ObjectModel hooks in CMSCategory::delete() - - #9257: Allow overriding getRobotsContent in Tools.php - - #9234: Fix override handling when PS_DISABLE_OVERRIDES is used - - #9243: Fix show sql action in logs page - - #9120: Fix empty text transformer to not treat zero as empty text - - #9241: Fix Version service namespace usage - - #9203: Fixed bug with friendly URLs and Media Servers - - #9190: Fixed DataConfigurationInterface PHPDoc - - #9105: Check if key exists before checking the value - - #9156: Fix missing security event listeners registration - - #9140: Update composer dependencies - - #9122: Add safety returns after ajaxRender calls - - #9039: Ajax will never die - - #9095: Fix translations order settings and remove unused templates - - #9050: Fix HookConfigurator: Filter certain non-arrays from theme.yml - - #9098: Rename variable $producPropertiesCache (fix typo) - -- Installer: - - New feature: - - #9401: Check at installation if PrestaShop version is the latest - - Improvement: - - #10909: Made the installed theme configurable - - #9340: Update rel="noopener noreferrer" - - #10106: Add Galician language in the installer - - #10104: Add Latvian language in the installer - - #9414: Add arabic language in installer - - #9411: Indian Localization improved - - Bug fix: - - #11206: Installer: always clean test assets even if filesystem tests fail, an… - - #11209: Ignore irrelevant SF warning aout composer at install - - #10296: Init Kernel when possible during installation process - - #10410: Fix fixtures inconsistencies - - #9464: Fix geolocation whitelist - - #9425: Fix step name retrieved in the installer - - #9409: Symfony requirements file now compatible with PHP 7.2 - -- Web Services: - - Bug fix: - - #10117: Fix bug shipping number is empty in {followup} - - #9439: Fix Error 500 from API request with PHP 7.2 - - #9202: Preserve position in category when adding a new Product using Web services - -#################################### -# v1.7.4.4 - (2018-11-06) -#################################### -- Back Office: - - Bug fix: - - #11228: Avoid warning in WebServiceRequest - - #11285: Fix filemanager security breaches - -#################################### -# v1.7.4.3 - (2018-07-27) -#################################### -- Core: - - Bug fix: - - #10829: Hide arguments in debug trace page - -#################################### -# v1.7.4.2 - (2018-07-27) -#################################### -- Back Office: - - Bug fix: - - #9358: AdminSearchController.php : Parameter must be an array or an object that implements Countable - - #9359: Allow configuration to save html data - - #9330: It is impossible to create a SQL query "SELECT" - SQL Manager page - - #9326: Module translations aren't working when using Smarty Extend into TPL - - #9327: Fixed Product form when stock management is disabled - - #9322: Backward compatibility of $this->isCached() in modules - - #9279: Fix detection of APCu on Performance page -- Front Office: - - Bug fix: - - #9378: Generate core.js - - #9374: Fix multishop price calculation - - #9364: Fix JS error after add to cart - - #9365: Wrong generated template path when using getCurrentSubTemplate with a full path name. - - #9357: Core.js typeerror after updatecart - - #9335: Url does not update when changing product attributes -- Core: - - Bug fix: - - #9348: Fixed a misnamed variable - - #9345: Can't install prestashop in dev mode with open_basedir - - #9339: Fix bug extra space: htaccess directive order -- Installer: - - Improvement: - - #9361: Set allow_url_fopen optional in the system step - - Bug fix: - - #9371: Ntree regeneration should be done also if the entity arg is empty during install - - #9355: Allow to install PrestaShop without allow_url_fopen enabled -- Tests: - - Improvement: - - #9321: Add some fixes to the script and update scenario of onboarding - -#################################### -# v1.7.4.1 - (2018-07-16) -#################################### -- Back Office: - - Improvement: - - #9311: Apply shop context in configuration - - Bug fix: - - #9299: Fix error while duplicating a product when catalog specific price rules are stored - - #9297: Fix display when a module uses $this->bootstrap = false; - - #9261: Update Controller name for link generation to modules catalog - - #9268: Added .htaccess to var folder -- Front Office: - - Bug fix: - - #9315: Fix not visible category display - - #9295: Fix free shipping display on cart - - #9270: Apache 2.4 configuration - - #9252: Add combinations in cart summary -- Core: - - Bug fix: - - #9288: Fix Cart::isVirtualCart() method when cart is empty - - #9298: Fix/remove mbo from tests - - #9220: Ability to use widget block from specific hook - - #9269: Update ps_themecusto to version 1.0.6 - - #9237: Fixed bug with friendly URLs and Media Servers - - #9101: Fix have cart rule today -- Installer: - - Improvement: - - #9302: Reduce the number of ajax calls if the fixtures are not too larges and if there's enough memory available - - Bug fix: - - #9271: Catch more exceptions during install & display the error intead of a JS error - - #9258: Limit subquery results in upgrade sql 1.7.0.0 - -#################################### -# v1.7.4.0 - (2018-07-03) -#################################### -- Back Office: - - New feature: - - #9117: Add theme custo - - #8920: Migrate Shop Parameters -> Customer Settings - - #8680: Migration of page Shop Parameters > Product Settings - - #8705: Introduce switch type in forms - - #8604: Migration of page Shop Parameters > General > Maintenance - - Improvement: - - #9189: Hide disabled level 3 tabs in the BO - - #8914: Improve header BO design - - #9102: Update BO theme to Bootstrap 4 final - - #5102: Select not ordered cart directly in SQL instead of excluding ordered cart in PHP - - #9008: Use getBoolean() instead of get() when configuration is bool in Product Settings page - - #8927: Remove default theme schemes (no longer used) - - #8947: Hooks for recommended modules & themes - - #8908: Refactored Form Handling management - - #8916: Add tips in the back office to improve user experience - - #8637: Update back-office menu style - - #8837: Replace Open Sans font with Vazir font for Farsi (BO new theme) - - #8836: Replace Open Sans font with Vazir font for Farsi (BO default theme) - - #8896: Optimize breadcrumb computation performances - - #8814: Module tab new subtree - - #8523: Migrate Logs page to Symfony - - #8924: Refactored Back Office controllers - - #8368: Implement dynamic form customization - - #8859: Passing language ID for Store object instance - - #8899: Optimize stock queries - - #8790: Optimize reserved product quantity update - - #8515: Upgrade Symfony to 3.4 LTS - - #8645: Modify string for product page - - #8489: Improved Product pages templates management - - #8547: Better performance in order template - - #8557: Added more informations from args in Hooks profiler - - #8365: Migrate Administration Page to Symfony - - #8244: Show installed modules by default instead of the modules selection - - #8479: Removed old emailing category - - Bug fix: - - #9223: SSL field is only available is accessed using HTTPS protocol - - #9221: We should be able to activate SSL - - #9212: Fix position of PrestaShop logo when in RTL - - #9194: Handle 1.7 method in update function 'add_new_tab' - - #9183: restore missing translation keys - - #9173: Registered all namespaces in ModuleTemplateLoader class - - #9181: Use CustomerPreferencesFormHandler to handle specific tabs toggling for B2B mode - - #9175: Missing requirement message - - #9169: Fix product attachment list - - #9160: Fix 500 while getting order total - - #9133: Regression with DatePicker and checkboxes on stock page (catalogue > stock) - - #9157: State filter in catalog page doesn't work - - #9151: Fix undefined method trans() when loggin on the marketplace from the module page - - #9143: Fix unknown key route error in customer settings page - - #9082: Error while searching for a product - - #9089: Catch module theme installation error, add error message for invalid module - - #9028: Introduced re-usable authorization system - - #9118: Fix BO login icons - - #9113: Fix wrong css file on BO login page - - #9106: Add a product removal confirmation - - #9077: Update welcome module version - - #9076: Fixed duplicate carts in back office - - #9084: Saved confirmation message isn't displayed anymore in translation page - - #9074: Ordering product in BO doesn't work - - #9086: Fix template on attachment delete - - #9081: Can't enable maintenance mode - - #9046: Reduced permission levels for theme edition - - #9051: Bad link in breadcrumbs in symfony pages - - #9044: Fix delivery time labels not displayed - - #9040: Fix Smarty.class.php class not found - - #8938: Display tabs on the module page with the generic method - - #9023: Avoid infinite redirects if unhandled exception during BO authentication - - #8838: Fix tinymce RTL text direction - - #9004: Fixed search on manufacturer's name - - #8995: Display the notification count on the proper tab - - #8932: Fix display error on module selection list - - #8830: Fix uninitialized $moreStepLabels in AdminImportController - - #8945: Return default values when api is unavailable - - #8933: Fix bug on saving store hours - - #8895: Allow override of every modern template - - #8918: Add unlimited timeout to dropzone configuration - - #8700: Admin permission detection of Role classe name - - #8909: Allow autoloading in modules for services use in BO - - #8944: Hide Logs page - - #8923: Fixed url redirection on Administration page - - #8912: Fixed template path - - #8910: Collect all hooks for the debugger - - #8890: Fix display of image form in product page - - #8864: Removed almost all deprecations on Product page - - #8863: Fixed misuse of magic routing - - #8529: Fix bug alignment sidebar menuCollapse Admin theme - - #8865: Fixed CCC settings - - #8872: Validator:validateValue is not available in Symfony3 - - #8613: Fixes AdminController's processDeleteImage() redirect after URL - - #8672: Move submit button to the right in sf forms - - #8580: Added Back Office missing roles - - #8611: Fixed bad display manufacturer when multishop - - #8617: Fix/suppliers block refresh - - #8588: Add parameter to setMedia - - #8599: Move Advanced Parameters section to Configure section (Cherry pick) - - #8524: Fixed forms deprecation (Symfony3) on performance page - - #8481: Don't display error if AdminShopGroup doesn't exist - -- Front Office: - - Improvement: - - #8774: Ajax calls for product availability status in front refactored - - #8833: Hide empty list if all variations are out of stock - - #8469: Add a few optimisations to speed up the display of the order history page and to allow potential override to skip unneeded costly informations - - #8792: Update url in Readme :) - - #8741: Improve SEO - Hn tags in Classic Theme - - #8652: SEO - Add hreflang links for multilang pages - - #8563: Add FORCE INDEX to workaround bug in MySQL - - #8474: Allow developers to add items to breadcrumb from tpl - - Bug fix: - - #9172: Fix auto-remove carrier-specific voucher when changing carrier - - #9138: [FO] Fix notice on brands page - - #9227: Add alt tag for images categories - - #9134: Fix undefined index on supplier page in FO - - #9080: Fix Punycode problem when register - - #9055: The special offers are disappearing suddenly - - #9036: Fix infinite loop on multiple vouchers - - #9073: Fix gift wrapping fees added even if not checked - - #9027: Fix wrong schema of "InStock" for Out of stock products - - #8972: Discount / Wrong variable use in loop for mobile - - #9017: Fix wrong parameter verification, allowing redirection to arbitrary URL - - #9016: Corrected email subscription form input type - - #8411: Refactor Cart getOrderTotal - - #8902: Display the "No Image" image for Products with no image - - #8884: QUERY_STRING is not set on all environments - - #8866: Fixed breadcrumb links in ProductController - - #8823: Fixed broken search after #8741 - - #8636: An error on servers with PHP 7+ - - #8548: Remove useless die in StoresController - -- Core: - - New feature: - - #8781: Getting Currency data from Currency data layers middleware stack - - #8888: New Locale integration tests - - #8935: CLDR : Replace legacy number and price formatting - - #8246: Make PS compatible with PHP 7.2 - - #8882: Migrate import page - - #8883: Migrate ShopParameters->General page - - #8732: CLDR reference data (files) reader - - #8722: CLDR Locale Cache data layer - - #8718: Renamed locale and currency data objects (no more use of "bag") - - #8698: CLDR Data layers - - #8693: Number specification Repository, Locale Repository - - #8683: Locale entity needs to aggregate Price Specifications (one by installed currency) - - #8667: CLDR currency (interface, entity and repository) - - #8662: Moved CLDR to Core - - #8597: CLDR number formatter - - #8581: CLDR specification entities - - Improvement: - - #9167: Update native module versions - - #9079: Added $result (from facet) in hook filterProductSearch - - #9048: Removed if statment - - #9038: Update pull request template - - #9022: Make bin/console executable - - #8996: New doc block for method, reduced code of method - - #9020: Update to right name, markdown with links and more - - #9021: Create LICENCE.md - - #9018: Add copyright information to the license. - - #8979: Move administration page to proper location - - #8980: Remove deprecated message for DataCollectorInterface - - #8970: Improved readability - - #8959: Able to pass hook as a parameter - - #7944: Call getPackageShippingCost of modules even if carrier is free - - #8929: Merge 1.7.3.1 into develop - - #8853: Make override of object models easy - - #8876: Disable Symfony tokenization in routing - - #8270: Allow modifying IdentityController to save personal information without password - - #8514: Added GroupBy option for actionAdminProductsListingFieldsModifier hook - - #8885: Improve PrestaShopBundle config structure - - #8811: Merge 1.7.3.x - - #8764: Change all links to PrestaShop Help/Addons/Developers from http to https - - #8756: Update license headers for 2018 - - #8709: OrderDetailsController should use Tools::getRemoteAddr() function instead of instead of $_SERVER['REMOTE_ADDR'] - - #8656: Fix services naming - - #8663: Merge 1.7.3.x into develop - - #8623: Merge 1.7.3.x into develop - - #8625: Update README.md - - #8583: Add help for upgrade file - - #8566: Use official Smarty lib - - #8606: Fixed newsletter registration date doc - - #8561: Make Symfony form management more robust - - #8602: Handle form request after authorization check in PerformanceController - - #8546: Add some missing Phpdoc in SpecificPrice - - #8405: Update PrestaShop deps: Symfony3, PHP 5.6 and PHPUnit 5.7 - - #8486: Refactor code in ControllerCore and AbstractFormCore - - #8483: Module name in order details data - - Bug fix: - - #9233: Updated dependencies - - #9226: Fixed access to Front Office container from modules - - #9216: Make deprecation warnings opt-in - - #9188: Fix wrong test in left join condition - - #9064: Fixed list of activated modules - - #9054: Added missing use statment in AddonsCollection class - - #9024: Merge 1.7.3.2 into develop - - #9029: Revert CLDR integration - - #8985: Fixed order gets wrong status when ordered all qty of the product. - - #9010: Check if template_vars if an array before merge in OrderHistory::sendEmail() - - #8767: Show prices within a tax if it's needed - - #8998: Create missing subfolders in folder override/classes - - #8954: Allowed robots access to assets requierd to be mobile-friendly - - #8976: Set cache driver in container instead of env var CACHE_DRIVER - - #8982: Merge 1.7.3.x into develop - - #8831: Better handling of invalid modules from Addons API - - #8962: Properly handle set of the PK value in the EntityMapper - - #8960: Fixed undefined class constant - - #8600: Fix fatal on array_merge if query in addMissingProductFields returns no result - - #8757: Prevent using "¤" and "|" as customer name - - #8928: Change php version in server configuration - - #8926: Fix deprecation message - - #8754: Fix non-filtered meta by filterHtmlContent hook - - #8743: Fix the links sent in the mails (multilingualism) - - #8685: Fixed link_rewrite argument for getImageLink(). - - #8689: Fix translator in prod mode - - #8674: Rename old paths of cache and logs for SF 3 - - #8694: Product name error if not english - - #8399: Fix search relevance wrong sort order - - #8458: Default AJAX Relevance search sort order is wrong - - #8577: Synced 1.7.3 into develop - - #8582: On CLI, display simple information on PrestaShopException - - #8576: Added new gitignore directives about translation packs - - #8573: Added docs about CSV import samples - - #8558: Merge 1.7 into develop - - #8530: Merge 1.7.3 into develop - - #8511: Fix array declaration - - #8488: Fix robots.txt, exclude order param - -- Installer: - - New feature: - - #7721: Add docker compose - - Improvement: - - #8889: Add tests for getDirectories - - #8788: Speed up test_dir with a lot of files present in a directory - - #8789: Do not call search::indexation at each entity creation - - #8668: Allow to setup the shop with SSL by default using CLI installer - - Bug fix: - - #9052: Fix error populating tables when installing in Greek - - #8981: Set explicit version of MySQL in docker-compose.yml - - #8020: Fix not handled new tab ID during migration - - #8556: Fix store hours migration - -- Localization: - - Improvement: - - #8997: Fix TVA rate in Tunisia - - Bug fix: - - #9200: Fix duplicate wording - - #9196: Fix wrong translation domain - - #9197: Fix duplicate wording - - -#################################### -# v1.7.3.4 - (2018-06-27) -#################################### -- Core: - - Improvement: - - #9222: Improve cookie encryption - -#################################### -# v1.7.3.3 - (2018-05-24) -#################################### -- Back Office: - - Bug fix: - - #9026: Fixed display error on back office module selection list -- Front Office: - - New feature: - - #9099: Follow-up to: display GDPR consent checkbox in contactform - - Improvement: - - #9104: Add compliance to GDPR law for ps_emailsubscription module - -#################################### -# v1.7.3.2 - (2018-05-03) -#################################### -- Back Office: - - Improvement: - - #8834: Adds missing Persian translations for data and samples - - Bug fix: - - #8752: Check product availability before validating orders - - #8975: Fix broken "you must first create a new language" link in BO Translations - - #8965: Fix theme install with prestatrust modules - - #8517: Fixed bug when using 2 swap in 1 form - - #8948: Fixed update of combinations - - #8762: Specific price created for a cart is displayed in the front end as the product price -- Front Office: - - Improvement: - - #8835: Replace Noto Sans font with Vazir font for Farsi in Classic theme - - Bug fix: - - #9005: Fix cannot order oos product even if it's allowed - - #8951: Fix error display on cart quantity edition - - #8946: Fix button show password height on Safari - - #8940: Check product availability in order step - - #8931: Out of stock message display only if customer can order the product -- Core: - - Bug fix: - - #8973: Fixed undefined class constant - - #8850: Fix profile permission array construction - - #8679: Catch Throwable errors on CLI install and check Theme instance in context -- Installer: - - Improvement: - - #8843: Minor install improvements - - Bug fix: - - #8949: Remove addition of . folder in release archives -- Localization: - - Improvement: - - #8832: Update Iran tax rate - -#################################### -# v1.7.3.1 - (2018-04-09) -#################################### -- Back Office: - - New feature: - - #8849: Add User club and UserVoice on BO link footer - - Improvement: - - #8664: Change employee icon - - #8500: Make sure shop list in header is scrollable with lot of items - - #8780: Improve BO speed by removing menu images - - #8725: Replace Google+ link on BO footer by Youtube link - - Bug fix: - - #8925: Stop generating RTL css file for the default theme using SASS - - #8921: Fixed CDN management in Performance page - - #8871: Improved rendering of combinations in Product page - - #8779: Little css override for modal title - - #8631: Request module zip for upgrade ONLY when the version available is higher - - #8714: Update loaded details from database on module action - - #8696: Fix translation issue during language install - - #8648: Fix modal backdrop not removed when uninstalling a module - - #8618: Fix type warning in order detail - - #8525: "No tax" price option is now well saved in admin product page - - #8476: Fix customer search in new order form - - #8234: Fixed bug on save specific price priority for specific product -- Front Office: - - Bug fix: - - #8873: Fix contactform module issues - - #8856: Fixed undefined variables when an url is called in ajax - - #8847: Override advertising module on classic template to fix image width - - #8845: Fix search bar on header when it moves from hook and improve header structure #2 - - #7775: Resolve incompatibility between canonical redirections, attributes and product route not only containing rewrite - - #8846: Fix menu width and submenu hover on header - - #8522: Fixed specific price percentage rounding on front product page -- Core: - - Improvement: - - #8867: Rely on the right legacy container if available on modules - - #8584: Update toCamelCase - - #8795: Minor improvements during install - - Bug fix: - - #8922: Fixed access to Front Office container from modules - - #8766: Show unit price within a tax in order confirmation e-mail - - #8607: Fix pack stock issues - - #8711: Default AJAX Relevance search sort order is wrong - - #8803: Stop full object exposure on the front end - - #8708: Debug of Tools::strReplaceFirst that do not correctly compare the return of strpos + PhpDoc - - #8498: Fixed bug on reorder with free gift in the cart - - #8543: Layout broken by cache clear - - #8669: Make sure all adresses are reset on cart - - #8462: Fix empty module return on actionEmailSendBefore breaks all email send - - #8277: CustomerAddressFormatter states were queried without the status (active) check causing disabling states in BO useless -- Installer: - - Improvement: - - #8860: Make the dezipper great again - - #8806: Sample products in FA - - Bug fix: - - #8913: Fix issue with pack in fixtures (installer) - - #8891: Fix dezipper redirect - - #8858: Include docs when creating zip build -- Tests: - - New feature: - - #8812: Delete product - - #8829: Add script for screenshot display on Travis - - Improvement: - - #8881: Check the pagination of product in the Front Office - - #8898: Check generated combinations table - - #8903: Add some fixes to the script - - #8813: Check the product discount in the Front Office - - #8805: Reset module Welcome if the RESUME button does not exist - - #8878: Check the appearance of tinymce field on the product page - - #8854: Check the change of the default combination from the edition page - - #8819: Fix sort product script - - #8810: Check the total price in the shopping cart - - #8815: Re-enable functional tests - - Bug fix: - - #8842: Fixed Travis build (update Chrome browser version) - - #8746: Make file copy on ModuleSelfConfiguration mockable - -#################################### -# v1.7.3.0 - (2018-02-28) -#################################### -- Back Office: - - New feature: - - #8378: Integration of PrestaTrust in module management - - #8419: Product Page - Shipping: delivery times - - #8396: Send an email on low stock - - #8390: Add Icelandic as supported language - - #8249: Display "Generate RTL stylesheets" section - - #8218: Add bulk edition in stocks - - #8293: Low-stock alert configuration in the Product Page - - Improvement: - - #8796: Update theme preview image - - #8659: Re-enable uglify on the new theme - - #8559: Fix search bar style on symfony pages - - #8502: Unavailable product message is now the same for any action in cart page - - #8495: Improved how to detect if a module is a payment module - - #8401: Add a new hook on AdminCutomers view > Addresses actions - - #8472: Customized Debug toolbar with PrestaShop application information - - #8271: Add multiple feature with the same type but different values to product - - #8326: Fix stock design - - #8026: Translate store schedules, name and address from BO - - #8372: Migrate Modules Catalogue page to Symfony - - #8385: Wording for 1.7.3 - - #8395: Add translation domains to legacy templates - - #8254: Migrate System information page to Symfony - - #8318: Fix translations page new ui kit - - #8311: Fix module page new ui kit - - #8297: Fix product page new ui kit - - #8284: Catalog page with new ui kit - - #8278: Use the brand new UI Kit - - #8260: Remove CSS included directly in twig files - - #8202: Add caching for theme yaml file - - #8208: Add active filter in stock management - - #8204: Fix str2url js with new chars - - #8127: Do not throw exception on API request error for module categories - - Bug fix: - - #8777: Fix directory listing - - #8761: use json_encode instead of serialize - - #8737: Fixed combination images selection - - #8704: Support Arabic numbers in the Product page - - #8702: Fix RTL visual glitches - - #8671: Fix visual regressions on Firefox - - #8697: Added Back Office missing roles - - #8616: Fix dropdown buttons space - - #8610: Fixed undefined function .size using jQuery 3 - - #8574: Moved Advanced Parameters section to Configure section - - #8569: Fix category filter dropdown glitches - - #8550: Introduced a consistent method to get route name if Hooks dispatched in modern pages - - #8562: Fix alert boxes using bulleted lists - - #8565: Fixed mass action fields positioning in admin catalog page - - #8545: Urlencode to prevent some XSS injection - - #8526: Fixed display of Category tree on Product page - - #8555: Restore tooltips on performance symfony page - - #8552: Notifs dropdown open/close is bugged on SF pages - - #8553: Fix UI kit problems - - #8549: Fixed Hooks data collector display - - #8520: Fix modal display on product page - - #8521: Update style of product combination tokens - - #8496: Fixed category tree arrows behavior - - #8509: Update the default product order with ID desc - - #8512: Fix menu collapse button alignment - - #8507: Avoid null as caching system in shop params - - #8501: Fixed PrestaShop version on Addons Store url iframe - - #8506: Fix smtp undefined in system information - - #8503: Fix/undefined none cache option - - #8494: Reduce javascript execution time on product pages - - #8491: Fixed admin category tree radio buttons positioning - - #8265: Remove duplicate call to trans for modules - - #8480: Fixed PrestaShop docs link in debug toolbar - - #8477: Added displayDashboardToolbarTopMenu and displayDashboardToolbarIcons hooks - - #8442: Fixed duplication of hooks in pages migrated to Symfony - - #8468: Fix wrong typehinting on attribute prices - - #8461: Fixing data duplication when using 1-click upgrade multiple times - - #8456: Fix JS error on Performance page - - #8440: Invalid path to look at config.defines.inc file permissions - - #8451: Fix several UI problems - - #8452: Catalog controler wrongly use by default desc sorting instead of "last" - - #8436: Fixed invalid selector on feature removal (Product page) - - #8438: Fixed product url preview - - #8421: Module page quicks - - #7986: Fixed bug where address required fields were required for any address type (customer, brand...) - - #8391: Fixed missing translations of Information System page - - #8097: Fix save carrier with invalid ranges - - #8413: Empty default label for product configuration - - #8414: Fix the button of add a new customization field in the product page - - #8406: Fix low-stock display - - #8269: Refacto of module permission checks - - #8255: Fix import products without Force all ID numbers - - #8388: RTL fixtures and improvements in BO - - #8370: Fixed silenced error - - #8375: Fix product page blocks spacing - - #8377: Fixed minor visual issue in Information page - - #8355: Fix product pages tabs - - #8359: Fix module dropdown - - #8322: Fix stock alert - - #8147: Display transporter block in RTL - - #8148: Fix bug employee thumbnail - - #8253: Add class to fix input style bug in AdminOrders controller - - #8163: Fix encoded back URL - - #8066: Allow admin folder name inside quick access link - - #8203: Fix width of column too small of pdf invoice - - #8149: Change attribute groupe name with not public name for BO - -- Front Office: - - Improvement: - - #8739: Demo products - - #8264: Improve performance of subselect query when fetching attributes of current group - - #7924: Add amount discount on product thumbnails - - #8060: Make the store email clickable in the footer - - Bug fix: - - #8490: Fix undefined offset on new products - - #8478: Fix shopping cart when allow checkout with wrongly product - - #8447: Add cover to allowed properties in ajax requests - - #7873: Fix bug after removing product customization - - #8435: Fixed bug where invalid address message is displayed only for billing address even if both are invalid - - #8348: Fix SQL error when product search starts with an hyphen - - #8416: Display properly ps_linklist on classic with widgets - - #8425: Use regexp instead of simple explode for complex attributes in CartPresenter - - #7975: Fix checkout exception when adding required field to address - - #8408: Missing name attribute form date fields - - #8382: Remove mistake ltr directions in rtl css files - - #8351: Add id_product_attribute to productLink - - #8331: Display errors on change password (lost) - - #8314: Fix the except_pages in theme.yml - - #8281: Fixes wrong images on order confirmation page with simple products - - #8225: Use PS_GUEST_CHECKOUT_ENABLED ... only in checkout - - #8195: Reintroduced the guest allowance check in FrontController. - - #8207: Fixed bug in the link tracking number for the detail order - -- Core: - - New feature: - - #8513: Add the possibility to build a release version - - #8342: Make modules act like Symfony Bundles - - #8467: RTL - Merge conflict - - #8347: Added methods to check in which context module is executed - - #8327: Added a new collector for Hooks - - #8300: Import / Export features from the Stock Overview page - - #8248: Change CSS files path to RTL stylesheets if needed - - #8243: Add new method to generate RTL stylesheets - - #8128: Sample config file for Nginx server - - Improvement: - - #8713: String to translate for 1.7.3 - - #8691: Add RTL generation for modules and some rtl fixtures - - #8657: Integrate RTL CSS generation in the core - - #8605: Specify version for all PS native modules - - #8570: Set version on prestashop/translationtools-bundle - - #8527: Enable the Symfony serializer service - - #8402: Optimize cart rule performances - - #8455: Make urls available on maintenance & restricted country templates - - #8465: Remove useless method from Customer class - - #8403: Optimise shipping cost computation - - #8381: Remove risky and useless sprintf() calls - - #8409: Improve cache - - #8453: Improve order presenter performance - - #8441: Use DISTINCT in query to improve uninstall() method in Module class - - #8279: Migrate Performance page to Symfony - - #8415: Remove product description length limit - - #8209: Remove useless call to addRoute for multilanguages shops - - #8410: Improve getContextualValue performances by reducing the number of calls to getOrderTotal - - #8392: Improved loading of translations - - #8339: Array-check in additional form fields from modules - - #8317: CSS fixtures for Right-to-Left languages - - #8268: Add possibility to reset modules in theme.yml - - #8289: Add export folder to the file .gitignore - - #8220: Product settings: availabilty label and delivery time configuration - - #8252: Add context in legacy module translation function - - #8242: RTL fix: Add a library to composer.json file - - #8241: Fix json file and some translation for Persian language - - #8188: Clean some variables/code - - #8217: Make SymfonyContainer available from 1 location - - #8183: Clean some variables/code - - #7997: Fix coding standards issues - - #8048: Pass param content_only param to overrideLayoutTemplate call - - #8117: Improve database connection character set declaration - - #8083: Remove confusion about cart rule code check - - Bug fix: - - #8794: Fix customizable demo product without customizable field - - #8719: Fix missing CLDR supplemental directory - - #8643: Removed duplicate line in upgrade file - - #8608: Missing japanese lang flag - - #8589: Fix issue with tmp dir - - #8586: Fix release creation - - #8572: Change default file_get_content default timeout - - #8460: Validate::isDateOrNull() should accept '0000-00-00' - - #8470: Be able to identify a modern page in modules - - #8471: Allow to sort bestsellers by sales - - #8459: Force query build arg_separator to & - - #8362: Fixed bug in Access::getRoles() - - #8432: Fix fatal $sql_values string to array - - #8417: Fix missing cache invalidation in the backoffice - - #8407: Fixing missing employee in ModuleManagerBuilder - - #8307: Fix bug js and css cache file name don't change - - #8261: CustomerAddressFormCore validation was not working fine with hook… - - #8386: Rebuild all assets with UI kit beta - - #8354: Update composer dependencies - - #8352: Fix already defined class during upgrade process from 1.6 to 1.7 - - #8328: Add DB prefix in delete() method all time $add_prefix is set to true - - #8302: Change version phpExcel for PHP7 - - #8291: Fix merge problem - - #8247: Fixed issue with empty locale - - #8134: Fixed bug in addMissingProductFields that gives array_merge the p… - - #8198: The t must be capital in namespace - - #8181: Change visibility of properties in class CheckoutSession - - #8214: Fixed foreach warning on empty hook return - - #7799: searchTag now uses product_shop.visibility - -- Installer: - - New feature: - - #8336: More Japanese for installer - - #8299: Adding Japanese to the installer - - #8245: Generate RTL stylsheets when installation language is RTL - - Improvement: - - #8306: Add a new quick access - - #8219: Updating the PrestaShop images for installer last step - - #8189: Change order for Countries/Zones/States tabs - - Bug fix: - - #8670: Fix store hours migration - - #8484: Display generic exception message when error occurs on cli installation - - #8257: Change installation tutorial link to 1.7 version - - #8192: Write permission must be check for app/Resources/translations - - #8193: Use proper folder for theme templates - -- Web Services: - - Bug fix: - - #8393: Remove obsolete unescaping on JSON output - -#################################### -# v1.7.2.5 - (2018-02-21) -#################################### -- Back Office: - - Bug fix: - - #8755: Fix directory listing - - #8772: Replace serialize with json_encode - -- Core: - - Bug fix: - - #8591: Update Translation Bundle version in composer - -#################################### -# v1.7.2.4 - (2017-10-24) -#################################### -- Front Office: - - Bug fix: - - #8433: Fix product information leak on the front office - -#################################### -# v1.7.2.3 - (2017-10-05) -#################################### -- Back Office: - - Improvement: - - #7810: Add a loading spinner into product page - - Bug fix: - - #8366: Use default country instead of translator locale for marketplace API - - #7938: Update bulk action combinations number after delete or add combination - - #8232: Fixed bug in AdminCartRulesController when limiting the validity … - - #8346: Fix the currency display in supply order - - #8287: Fix the category search in the product page - - #8288: Fix displaying empty zip code of tax rule - -- Front Office: - - Bug fix: - - #7848: Fix switching combination when the product is offline - - #7781: Add error message when updating quantity wanted input - - #8283: Currency exchange fixes on product page - -- Core: - - Improvement: - - #8360: Fixing the version for core modules ps_legalcompliance ps_linklist ps_customtext ps_customeraccountlinks - - Bug fix: - - #8380: Fix Context::getTranslator() cache - - #8361: Fix conflict between two cart rules and a single product cart - - #8213: Voucher issue fix - -- Web Services: - - Bug fix: - - #8275: Fix update product with WS - -#################################### -# v1.7.2.2 - (2017-08-31) -#################################### -- Back Office: - - Bug fix: - - #8238: Fix wrong final combination price if BC Math is not available - - #8063: Display texture image in combination form - - #8057: Save before generate combinations - - #8266: Fix error while reaching AdminModules - -- Front Office: - - Improvement: - - #8082: Scroll top to product list when paginate - -- Core: - - Improvement: - - #8212: Optimize specific price computing by executing the query only when needed - - Bug fix: - - #8210: Fix missing product limit/offset when ordering by price on Sale page - - #8138: Fix tax calculation when vat number is used - -#################################### -# v1.7.2.1 - (2017-08-16) -#################################### -- Back Office: - - Improvement: - - #8140: Update modules page design - - Bug fix: - - #8236: Fix module modal layout - - #8046: Fix legacy submenu laptop - - #8141: Fix the module "translate" button with the new link of translation page - - #8173: Fix the search error with white spaces in stock page - - #8160: Fix the style of product reference in the stock management page - - #8166: Fix the misalignment of the search button in the stock page - - #8167: Fix the search tags in the stock management - -- Front Office: - - Improvement: - - #8205: Fix custom content link opening in the same page - - #8145: Fix custom content link opening in the same page - - #7855: Add link to products for Pack - - Bug fix: - - #8206: Fix flags on products front-office - - #8152: Make the slider appears on Mobile view - - #8191: Fix flags on products front-office - - #8155: Fix the style of forgotten password page - - #8169: Fix typo in bootstrap class - - #7716: Fix displaying product thumbnails - - #8111: Fix unclosed tag - - #8170: Limit the description's image by the size of description's frame - -- Core: - - Improvement: - - #8201: Speed up search queries (17) - - Bug fix: - - #8228: Optimise synchronization stock sql - - #8215: Add translations in database when importing theme - - #8165: Use MessageCatalog function to get all message - - #8186: Improve stock sql performance - -- Installer: - - Bug fix: - - #8021: Use correct module name column for authorization role - - -#################################### -# v1.7.2.0 - (2017-07-20) -#################################### -- Back Office: - - New feature: - - #8080: Translations confirmation modal - - #7808: Add tooltips on product's combination image - - #8031: Placeholder width in declination page - - #8027: Currencies live exchanges rates upload - - #7910: Can translate submenu tab! - - #7865: Fix redirect payment module retrieving good category - - Improvement: - - #8096: Add ids to recommended-payment & carriers & others - - #8098: Wording update for 1.7.2 catalog - - #8004: Fix displayed combination creation field - - #8008: Clean AdminProductsController - - #7911: Fix style of selected customer in product page - - #7835: Translations page rework & Stock management - - #7956: Remove length validation from ISBN field - - #7972: 1.7.2 wording update - BO + FO - - #7980: Fix html tags to get the current ISO country code - - #7942: Code Optimization - - #7933: Add translation domains to more BO templates - - #7820: Improve tag tips in product page - - #7887: Allow filtering of modules by display name inside the translations controller - - #7882: Add translations domains to BO templates - - #7613: Add new hooks to admin product page - - #7839: Add sprintf check constraint on translations - - #7834: Use most used tax for product creation on BO - - #7863: Add firstname & lastname on address form - - #7784: Complete category tooltip in Product Page - - #7735: Add translation domains to order templates - - #7706: Rewrite string to translate it more easily - - #7715: Change text tooltip in SEO - - #7618: Update addons authentication form - - Bug fix: - - #8161: Fix reset translation button - - #8074: Fix authorization panel - - #8129: Fix translations behavior - - #8135: Last wording update for 1.7.2.x - - #8093: Fix stock management filters - - #8094: Fix stock datepicker - - #8119: Fix the display of placeholder in combinations tab - - #8076: Fix upgrade button with update from disk - - #8107: Fix module enabling when ~ in theme.yml - - #8085: Fix JS event thrown on module uninstall - - #8106: Fix the upload quota for the product image - - #8120: Update catalog - - #8109: Fix the weird syntax in customer information page - - #8095: Feedback on translation page - - #8077: Revert Stock to singular - - #8068: Stock Management fixes - - #8065: Feedback on translation page - - #8054: Fix api category tree - - #8059: Fix missing use in ModuleDataUpdater - - #8052: Fix strings for specific price rules - - #7939: Fix the categories tree - - #8003: Fixed import store in backoffice - - #8044: Fix the conversion_rate in the order_payment table - - #8045: GSA quick fixes - - #8039: Translations feedback - - #7934: Fix float conversion from strings using comma as decimal separator - - #8041: Feedback stock management - - #8024: Fix legacy submenu laptop - - #8016: Display module confirm uninstall message - - #8014: Show Duplicate option when multishop selected - - #8007: Update Country in Store Contacts CSV File - - #7983: Add discount to cart - - #7853: Fix selecting category for product - - #7923: Fix displayed price on cart (HT/TTC) - - #7989: "Slightly" improve performance on Modules > notifications tab - - #7987: Fallback datepicker if needed - - #7978: Update diplayed module count on successful uninstall - - #7922: Fix redirection when filtering in attribute's value - - #7916: Fix min width to select filters - - #7964: Fix flush of local cache when adding a new specific price - - #7698: Unable to unselect the last image associated to a combination - - #7894: Fix bug when having more than three product image - - #7955: Don't get admin notifications while it's all disabled - - #7957: Add Missing space - - #7951: Fix displayed shortcut in product page - - #7937: Add missing simple quote in Design -> Images view - - #7932: Fix fatal on order page - - #7921: Fix trans errors of old translation page - - #7903: Fix moving module from a hook to another one - - #7837: Image not displayed in BO when creating new store - - #7898: Merge PRs from 1.7.1.x - - #7861: Bug with override AdminProductsController - - #7864: Fix recommended modules popup on legacy BO - - #7875: Fix datepicker design - - #7817: Introduce tinymce constraint & fixed short_description length - - #7809: No order notification message was wrong - - #7792: Remove all bourbon deprecations - - #7777: Make module actions translatable - - #7763: Updated path in maintenance message - - #7623: Avoid silencious fail of simple category creation from product form - - #7680: Fixed javascript bug on form submission - - #7662: Fix show currency name in tab "Catalog Price Rules" for option "All currencies" - - #7590: Fix bug on uploading too large images -- Front Office: - - New feature: - - #7833: Added message delivery information on checkout process - - Improvement: - - #8034: Apache rules for .woff2 font files - - #7998: Format error message - - #7990: Remove banner hidden class for mobile device - - #7564: Enabling category canonical redirection - - #7780: Allow to define module front controllers layout - - #7661: Update wording cart-detailed-actions.tpl - - #7566: Send response data to emitted events - - #7521: Consistency & additionnal infos - - #7554: Allow HTML in notifications - - #7688: Introduce new hooks for main wrapper - - #7880: Feat/classic improvements - - #7836: Harmonization of Brand name variable - wording - - #7813: Close thumbs modal when area under thumbs is clicked - - #7020: Improve front-end accessibility - - #7681: Improve readability on Classic theme - - Bug fix: - - #8142: Fix the price update on quantity change on cart - - #8121: Limit the description's image by the size of description's frame - - #8132: Fix the height of the "Show password" button - - #8088: Auto width for the selector on product page - - #8012: Show the forbiden message on product page - - #8040: Wrong close of 'product_tabs' {block} in product.tpl - - #7959: Empty customization ID after adding to cart - - #8009: Remove contact form after submit - - #8036: Fix cart front - - #8005: Fix legal compliance in footer in mobile display - - #8010: Make the edit link translatable - - #7952: Add class selected to selected address - - #8019: Missing product-flag class on product miniature - - #8006: Fix classic responsive - - #7992: Fix refresh availability of product - - #7994: Optimize search::find queries - - #7816: Order in catalog for calculate vouchers - - #7926: Fix mobile style toggling - - #7909: Wording checkout delivery - - #7907: Edit address for a Guest - - #7866: Fixed full size order-item table - - #7796: Fix address form Ajax refresh - - #7602: Let translate the edit label on order checkout -- Core: - - New feature: - - #8053: Add theme configurator translation & update catalog - - #7760: Allow free order - - #7889: Introduce module self configurator feature - - #7825: Handle multishop in console commands - - #7778: Remove lang dependancies for module manager and add cli command - - #7840: Add command to check duplicates in translation catalog - - #7567: Introduce release script - - Improvement: - - #7941: Add total amount TTC in credit slip - - #7523: Change all OrderController private methods and var to protected - - #7304: Fixed processChangeProductInCart method - - #7931: Update comments of Validate class - - #7678: Disable php in the "img" directory - - #7827: Fix spelling from conversation to conversion rate. - - #7912: Increase carrier delay length - - #7899: Refactoring naming - - #5082: Override admin and front controllers of modules - - #7871: Failure during module catalog fetch do not throw an exception anymore - - #7666: Use HTTPS where available in README.md - - #7606: Updates README.md file. - - Bug fix: - - #8118: Extract theme with default translation in any language - - #8101: Fix the tab permissions when only one profile - - #8103: Fix get attributes in order presenter - - #8124: Remove Finder from depency injection - - #8108: Fix update prefix sql - - #8070: Module tab registration must check filenames - - #8056: Fix type of errors variable in module configuration feature - - #8058: Fix missing @Template annotation created by refactoring - - #8047: License, composer, catalog, assets - - #8028: Update regex for tab registration - - #7996: Fix product with combinations auto-indexation - - #7984: Fix module loading for upgrade process and version displayed - - #7966: Use the right array index while getting controller tab name - - #7862: Throw module events right after each action and remove reset - - #7962: Fix wrong keys for cache - - #7557: Increase size of the hours column in PREFIX_store db table - - #7965: Allow .ico to /img, provide error server - - #7936: Fix value giftWrapping in OrderPresenter.php - - #7563: Update customerExists function in Customer.php - - #7915: Rethrow an exception instead of calling die when there is an erro… - - #7914: Changed SearchController extend to allow override - - #7904: Initialize getSynopsisDetails() output as an array instead of '' - - #7811: Display the login form after an failed authentication - - #7838: Return empty array instead of false. - - #7872: Display translated strings properly in SF debugger! - - #7852: Improve upgrade command - - #7611: Removed setSortOption in ProductSearchQuery - - #7609: Removed return duplication from search provider -- Installer: - - New feature: - - #7744: Adding 5 languages to the installer (SK, UK, ET, EL, FI) - - Improvement: - - #7977: Drop unused fields from ps_product_lang - - Bug fix: - - #8087: Translate fixtures with CLI install - - #8049: Reflect new Finnish tax rate in tax rule group names - - #8055: Fix update sql for upgrade - - #7981: Fix upgrade from very old versions - - #8018: URL update for installer - - #7993: Avoid INSTALL_PATH re-define error - - #7879: Set allow_url_fopen mandatory - - #7832: Fix install/upgrade/upgrade.php for php-5.4 syntax - - #7601: Use new module name for OrderState creation -- Web Services: - - Bug fix: - - #7664: Retrieve text only from selected customization - - #5352: Fix webservice unit_price_ratio set to 0 -- Localization: - - New feature: - - #7828: New localization packs - DZ, KR, MA, ZA - - Improvement: - - #7949: India states update - - #8000: Install Deutsch instead of Deutsch CH for Switzerland - - #7696: Update colombian tax rate - - #7818: Replace EN (US) by EN (UK) in UK localization pack - - -#################################### -# v1.7.1.2 - (2017-06-07) -#################################### -- Back Office: - - Bug fix: - - #7891: Set value for Short Desc - - #7860: Deny legacy module page view - - #7789: Message Customer on order details page - - #7801: Choose Theme on Mail Translation - - #7790: Add a scrollbar for TinyMCE - - #7783: Versions completions for the max value - - #7807: Partial revert of 0c42257 to fix profiling mode in BO - - - Front Office: - - Bug fix: - - #7795: Fix allow order value - - #7773: Fix for CMS tree on sitemap - - #7785: Fix slide down of carrier extra content in order funnel - - #7797: Translate file upload button label - - #7805: Fix word break classic - - #7762: Allow image for categories when no description - - #7761: Refresh product line on quantity change in cart & Show discount to cart summary - - #7747: Fix the except_pages in theme.yml - - #7745: Fix radio buttons on faceted search - - #7759: Convert voucher value - - - Core: - - Bug fix: - - #7901: Use composer cacert file by default - - #7826: Allowed redirect protocol with Tools::file_get_content (curl) - - #7800: Fix assets path when theme has the same name than PS - - #7770: Return array when it's wanted if the hook doesn't exist - - #7766: Fix displayError when string is using sprintf - - #7740: Fix missing {url entity=product id=X} - - #7752: Upgrade theme modules & disabling them in the same time that the theme - - - Installer: - - Bug fix: - - #7846: Fix install/upgrade/upgrade.php for php-5.4 syntax - - - Web Services: - - Bug fix: - - #7732: Change variable from string to array for php 7 - - -#################################### -# v1.7.1.1 - (2017-04-19) -#################################### -- Back Office: - - Bug fix: - - #7769: Fix the datepicker to use locale instead of iso code - - #7738: Fix access to domainized modules translations - - #7723: Fix catalog ASC sorting - - #7724: Fix translations theme export on Windows - - #7690: Incorrect translation on Symfony page (problems with TinyMCE) - - #7730: Alphabetically sort features on product page - - - Front Office: - - Bug fix: - - #7710: Fix country change in checkout form - - #7742: Fix for image change in zoom modal window - - #7734: Catch the exception when a template is missing in prod mode - - #7720: Display product reference when product has no combination - - #7689: Save zero to id_state if country has no states - - #7729: Fixed display amount with good taxes - - #7726: Fixed Terms and conditions popup on mobile not possible to close - - #7693: Password controller must be in SSL when available - - - Core: - - Bug fix: - - #7776: Fix cache on install - - #7753: Added nullable for Tab entity - - #7746: Doctrine without foreign for autoupgrade backup - - #7714: Module code cleanup and fix module action in details modal - - #7739: Allow modules compliancy on 3 digits - - - Installer: - - Improvement: - - #7743: Allow 255 char to company field in Adress - - -#################################### -# v1.7.1.0 - (2017-04-03) -#################################### -- Back Office: - - New feature: - - #7619: Add responsive nav-bar - - #7529: Product module page - - #7508: Mail in-transit improvement (webservice, markup) - - #7491: Allow to exclude tax and shipping in affiliation sales total - - #7287: Add counter to the inputs - - #6906: Implement "Update all" modules feature - - Improvement: - - #7596: Add displayProductPageDrawer hook - - #7570: Notification after theme reset, warning about images regeneration - - #7576: Remove useless meta_title - - #7573: Two wordings on the module tab of the product page - - #7551: Restore compiled assets - - #7516: Check if hook exists before get hook module exec list - - #7439: Header BO responsive (legacy part) - - #7497: Display shipping max. refundable amount in order partial refund form - - #7206: Update wording form.html.twig - - #7435: Remove initForm* from old product controller - - #7467: Update comment for jQuery migrate - - #7256: Add notifications counter - - #7421: Remove useless isset - - #7405: Domains tree on translations page now on more than 2 levels - - #7373: Add a new hook on dashboard - - #7364: Sort products in descending order - - #7315: Fix integration issues with translation page - - #7352: Reduce width of brand select input - - #7320: Only display the module you want to translate - - #7254: Add redirect to category for product not available - - #6712: Rename the productDisplayButtons hook to productDisplayAdditionalInfo - - #7308: Add version to help api feedback - - #7280: Change locales json - - #7175: Test admin controllers - - #7025: Add translation domains to Adv. param controllers 2 - - #7238: Harmonize wording cms.xml tab.xml - - #6990: Change Stores controller option from 'Status' to 'Active' - - #7100: Add some more translation domains to controllers - - #7230: Change PS color for tinymce - - #7188: Add text format selector to TinyMCE - - #6743: Implement optionnal but specific action to display on module page - - #7015: Set new product cover when current is deleted - - #7098: Removed sensor parameter from Google Maps JS API - - #6776: Do not display empty module categories - - #3915: Removed _includeContainer ; never more used - - Bug fix: - - #7701: Fix access denied on Customers Service - - #7668: Implode Translation Permission - - #7670: Allow upgrade for modules coming from Must-have json - - #7646: Fix imageFolder path for colorPicker inputs - - #7665: Fix inactive request in HookEvent - - #7663: Fix issue of Module notification page after 1.7.0.x backport - - #7648: Fix product attachments lookup - - #7585: Fix placeholder width in product options - - #7627: Fix wrong domain for product module page - - #7616: Fix getAvailableFields malformed json - - #7599: Fix required custom field alignment - - #7584: Employee permissions not saved - - #7586: Fix chosen width - - #7542: Update default catalog & compile assets - - #7572: Fix bug with TinyMCE button - - #7574: Fix tab registration (non-instantiated module) - - #7568: Fix default products sorting order - - #7559: Fix filter image icon - - #7552: Callback on HelperList should have highest priority - - #7546: Prevent widgets to break back-office - - #7544: Fix module configure button when in dropdown - - #7535: Fix desktop menu regressions - - #7534: Remove call to an undefined attribute - - #7520: Fix minors integration issues on sidebar - - #7513: Refresh forms for specific price - - #7514: Fix product customization duplication - - #7511: Fix back-office order - - #7503: Add missing attributes on function removeProduct - - #7507: Fix unclosed tag - - #7496: You can now search for a customer with several words - - #7492: Add missing metadata to translations catalogues on export - - #7486: Fix incorrect product-list-colors caching - - #7489: Update deleteFeatures() for Multi-shop - - #7481: Bug Fix on Save product - - #7479: Fix problem with default combination - - #6950: BO: allow disabled by item in Helper Form - - #7474: Fix Administering email setting whith/without log - - #7455: Fix Module configure permission - - #7473: Update ObjectModelCore::getFieldsLang - - #7470: Fix image doesn't exists - - #7449: Update keyboard shortcuts in product page - - #7462: Update invoice pdf - - #7459: Fix id_order ambiguous search - - #7454: Fixed use of hook return value in customer address validation - - #7444: Update the dashboardTop hook - - #7436: Remove tinymce synchronous loading - - #7415: Display correct quantities for shared stock - - #7428: Update wording AdminPerformanceController.php - - #7150: Fix "Uncaught ReferenceError: prestashop is not defined" - - #7395: Add the disabled categories in product page - - #7406: Custom error-layout for maintenance/restricted country page - - #7404: Replace "Default-bootstrap" in Translations tab - - #7390: Changed ID column name in CSV products export - - #7389: Fix translation page integration issues - - #7380: Remove wrong URL encoding from AdminStockMvtController - - #7371: Fix nested categories cache id - - #7366: Fix wrong domain - - #7332: Redirect with message when root category is not available for a shop - - #6997: Fix buttons alignments on modal on import page - - #7139: Fix product redirection from back office search results - - #7341: Update version on profile configuration page - - #6775: Add potential email error in order bulk action message failure. - - #6833: Deleted space and : in sql manager page - - #7330: Fix email translation edit when file doesn't exist - - #7115: Fix "Other translations" save action - - #7281: Module action template can now be used everywhere - - #7282: Fix selection of boolean option - - #7260: Set product image container to static position - - #7270: Add number of selected images in edit combination page - - #7255: Remove hardcoded version from help links - - #7196: Update keyboard shortcut in product page for preview - - #7251: Fix quick links with apostrophes - - #7236: Partial refund tax method always tax incl. - - #7039: Fix friendly url text on product page - - #7071: Add hints on some category fields - - #7229: Do not check module download on upgrade - - #7052: Fixed help wording for Tax Rules Group - - #7210: Fix date filter on dashboard when entering BO - - #7215: TinyMCE media plugin shouldn't be activated twice - - #7204: Fix import information display - - #7171: Fix rights issues on legacy module page - - #6942: Fix modules translation form - - #7180: Fixed "new client" column in orders list - - #6935: Fix localization pack import - - #7174: Fix warning on BO - - #6988: Clear cache on url rewriting settings modification - - #6996: Fix products alignment in delivery slip pdf - - #7019: Fix fancybox on cart rules conditions - - #6970: Fix virtual product file removal - - #6976: Fix error on layout when warnings exist - - #7023: Fix permission issues when creating modules sandbox folders recursively - - #6742: Fixed file attachment on product form - - #7050: Fix fallback dataformate duplicate value - - #7060: Fix save product when empty name in default lang - - #7136: Fixed search and redirection to module - - #6992: Fixed warning on AdminStore Controller - - #7010: Disable FK checks during DB export - - #7007: Display preview button in 13 inches - - #6930: Fixed bulk actions affecting single products - - #7048: Fix access to payment preferences - - #6926: Fixed payment methods of carriers - - #6978: Fixed security issue on SpecificPrice class - - #6957: Fix email preview in translation page - - #6955: Fix updating positions when sorting products - - #6953: Fix recommended modules modal window - - #6941: Fix email translations - - #6936: Return empty array on API error for customer data - - #6920: Fixed translation choice in BO - - #6891: Remove z-index of ps tagger reset button - - #6921: Removed warning notice on translation - - #6898: Fixed imagesController icons - - #6764: Add hotkeys on product page - - #6797: Display missing hook (displayCustomerAccountForm) - - #6825: Fixed wrong order detail updated - - #6858: Fixed css animation on onboarding - - #6868: Fix theme export - - #6812: Encrypt modules cookies - - #6857: Fixed error compile - - #6799: Add missing hook call for actionSubmitAccountBefore - - #6748: Fixed customers registration in Back Office - - #6811: Fixed border style of translation textarea - - #6805: Remove synchronous call to the CLDR - - #6778: Fix create combination - - #6793: Fixed employee password validation - - #6792: Use the correct email template for employee password recovery - - #6758: Fixed load of Jquery-ui JS/CSS cache - - #6750: Fixed delete combination on product - - - Front Office: - - New feature: - - #7675: Allow delivery module to confirm the checkout step - - #6903: Ported emailalert on classic - - #6886: Ported ps_crosseling module on classic - - #6881: Ported module ps_viewedproduct on classic - - #6878: Ported ps_specials module on classic - - #6877: Ported ps_newsproduct on classic - - #6871: Ported ps_supplierlist on classic & some fix on ps_brandlist - - #6866: Ported module ps_brandlist on classic - - #6828: Ported module ps_rssfeed for classic - - #6800: Ported module ps_productinfo for classic - - #6820: Ported bestsellers module on classic - - Improvement: - - #7575: Restore hook displayProductListReviews on catalog - - #6908: Add customization message - - #7478: Expose checkout process to inheriting classes - - #7362: Add smarty blocks everywhere - - #7384: Fix alerts icons and margin - - #7309: Integrate sitemap - - #7344: Hide virtual product download link until it's paid - - #7314: Integrate forgotten password alerts - - #7243: Add "quick_view" block to classic theme - - #7199: Fix "There is 0 product." label - - #7076: Add external libraries - - #7104: Add missing translation keys in home slider - - #6875: Replace Open Sans with Noto Sans - - #6766: Export translations when exporting theme - - Bug fix: - - #7694: Fixed a typo in template Product - - #7684: Incorrect event dataset call - - #7686: Fix Mixed-Content issues when SSL partially enabled - - #7657: Fix translation cache preventing load of new language - - #7603: Validate lengths of fields submitted from registration form - - #7636: Fix wrong translation/variable syntax - - #7617: Fix out of stock combination hiding - - #7561: Remove fakepath - - #7598: Fix registration form validation - - #7594: Restore hook displayBanner - - #7533: Fix url rewrite starting with numbers - - #7518: Fix front initcontent and My account display - - #7512: Fix a problem when a voucher is added on checkout - - #7500: Add cart in prestashop javascript object - - #7368: Allow HTML in customization when it's displayed by a module - - #7475: Fix hook name due to conflict resolution - - #7372: Bug fix for specific product combination cases - - #7461: Add manufacturer name in cart products - - #7453: Fix %email% are not replaced by user's email when asking a new password - - #7446: Remove wrong opening table tag - - #7445: Fix div tag in ordersummary header - - #7433: Fix button on the same line in order confirmation modal - - #7116: Fix some facets design - - #5053: Orders amount currency fixed - - #7410: Redirect to 404 when CMS page doesn't exist - - #7409: Fix empty title tag in CMS category - - #7345: Product with 0 quantity should be buyable when stock management is disabled - - #7361: Mobile Cart - Carriers Improperly integrated - - #7378: Fix FrontController#setTemplate default locale parameter - - #7365: Mobile Cart - Improperly integrated Fields - - #7272: Fixed bug when logged in customer can access login/registration p… - - #7358: Fix duplicate payment submissions and address initialization - - #7343: Check whether order is paid before serving a virtual product download - - #6597: Add carriage return to store information - - #7329: Fix arrow click & position - - #7323: Fix fatal when requesting product refresh without product id in cart - - #7297: Fix clean filter event handler - - #7264: Display Add to cart button in product listing - - #7259: Fix missing displayNavFullWidth into checkout - - #7247: Fix search bar icon display - - #7182: Remove useless vars display_column_* - - #7202: Fix order return format in OrderReturnPresenter - - #7009: Remove box-shadow around contact form in classic - - #7170: Fix classic's override of ps_imageslider - - #6995: Fix empty cart on logout display - - #6972: Add missing nofilter after display hook - - #7166: Fix total products label - - #7037: Fix breadcrumb margin on classic - - #7042: Add download link for virtual products - - #6987: Fix changing combination when catalog mode is enabled - - #6980: Fix undefined event in core.js - - #6905: Fix category images generation - - #6892: Revert to Bootstrap 4 alpha 4 - - #6847: Fix geolocation - - #6829: Fix PDF generation by removing non existing files requirement - - #6790: Replaced placeholder with email in notification - - #6808: Fix fatal on Best Sales - - #6741: Properly translate isbn, ean and upc - - #6774: Ported ps_categoryproducts for classic theme - - #6780: Add missing link on footer - - #6752: Remove extra tag block closed - - - Core: - - New feature: - - #5922: Install module tabs automatically - - #7291: Happy new Year PrestaShop! - - Improvement: - - #7621: Allows multiple retro names for a hook - - #7685: Don't update url_rewrite with upside lang - - #7679: Upside down language for crowdin - - #7669: Updated wording - - #7625: All we need to autoupgrade! - - #7577: Improved model namescape handling - - #7592: Default catalog update - - #7562: Add missing domains - - #7536: Add windows 8.1 & 10 to guest useragent - - #7532: Use Address:initialize to manage default state in one area - - #7522: Make sure that invoice siblings are related to the same order id - - #7524: Revert "Check if hook exists before get hook module exec list" - - #7495: Remove some globals - - #7490: Pass the object we're displaying to the action{$controller}FormMo… - - #6959: Convert namespaced object model class names to hook compatible names - - #7480: Sql fix & documentation - - #7468: Allow rel="nofollow" in anchors - - #7443: Add actionEmailSendBefore hook - - #6327: Deprecate getOrderByCartId method, add alternative - - #7456: Pass variables of hook `actionProductSearchComplete` by link - - #7442: Add new hook 'actionClearCache' - - #7440: Add new hook actionOutputHTMLBefore - - #7403: Make email templates parent/child compatible - - #7413: Optimized products counting in BO product list - - #7269: Webservices now show PS validation errors - - #7289: Code standard fixes & improvements - - #7335: Re-introduce server media - - #6911: Added dependency injection container in legacy - - #7142: Replace specific cache management with doctrine cache for module catalog - - #7298: Add file line number where the error occured - - #7265: Product.php optimization if not $id_cart - - #7183: Add app/config/config.php to gitignore - - #7093: Move entity repositories in existing subfolder - - #7178: Use ModuleZipManager for addons downloads - - #7177: Doctrine optimizations - - #6734: Generate robots.txt on install - - #7095: Add Reply-To recipient name to Mail::send() - - #7157: Be able to send an e-mail with multiple BCC - - #6694: Send email in English if current language don't have email template - - #6918: Allowed to add remote assets - - #6753: Improve global performances - - Bug fix: - - #7719: Delete unique key name for ps_profile_lang - - #7711: Use trans() instead of undefined l() - - #7700: Fixes needed for upgrade - - #7708: Use the browser country prior to the shop one - - #7705: Hide upside down language - - #7652: Rename id_product_redirected variable - - #7683: Remove clear cache for autoupgrade - - #7674: Fix ThemeValidator for child themes - - #7653: Fix invoice generation - - #7589: Fix missing reference symbol into Product::getProductProperties - - #7635: Update robot.txt using english - - #7629: Merge 1.7.0.x on 1.7.1.x - - #7633: Fix doctrine association between translation and lang - - #7597: Change CLDR url - - #7593: Fix the product page - - #7587: Increase curl timeout to 60s - - #7509: Format price for noPackPrice in product and Gift wrapping - - #7569: Fix entity integrity for upgrade - - #7538: Add composer.lock in order to fix composer install - - #7539: Update licences - - #7531: Payment method title extended to 255 characters - - #6681: Fix work authorization for (back|front)-office. After transition from RC1 to RC2. - - #7519: Fix fatal when no product to set in CategorySearchProvider - - #7312: Fixed Huge Bug for passed validation - - #7505: Fix nonexistent field on customer - - #7501: Do not display related product id customer can't see it - - #7485: Don't convert already converted currency - - #7502: Prevents problem with missing params in getWidgetVariables() - - #7499: Use UTF-8 for PaymentOptions - - #7482: Use default state for tax purposes - - #7488: Allow quotes in translation strings - - #7483: Update Mail lang settings - - #7148: Fix send to multiple addresses with different names - - #7477: Only link orders with same cart - - #7476: IdLang shouldn't be <= 0 - - #7471: Fix installation & tab entity - - #7472: Add "use instead" doc on method display as deprecated when possible - - #7463: Use boolean variables for tracking configuration value type - - #7466: Improvement in SpecificPrice::getSpecificPrice - - #7464: Calculate carrier price on the real order price - - #7460: Superfluous table alias - - #7457: Harmonize hook - - #7438: Add 2 new hooks actionDispatcherBefore and actionDispatcherAfter - - #7452: Revert "CO: fix Validate::isUnsignedInt" - - #7441: Add displayAfterProductThumb hook - - #7437: Use 1.7.1 modules - - #7430: Fixed rendering condition of default groups form - - #7429: Fix Validate::isUnsignedInt - - #7293: Fix dependencies definitions - - #7382: Use shop email as sender for template order_customer_comment - - #7334: Remove smartyDump() in Smarty config - - #7425: Update composer with modules - - #7420: Use the right modules branch - - #6928: Fix Cart cache key on CartRules - - #7401: Change some translated strings - - #7412: Fix logger namespace for ServiceLocator - - #7402: Update doc import files - - #7400: Fix array_merge call on null - - #7399: Fix pdf header - - #7393: Deprecate Tools::displayError() - - #6527: Fixed Geolocation behavior for NON existing countries - - #7386: Fix empty query - - #7316: Fixed bug that erases current customization fields - - #7277: Improve MARIA DB compatibility - - #7348: Fix wrong domain - - #7346: Fix getPriceWithoutReduct default id_product_attribute - - #7321: Improved translator performances - - #6722: Fix uncaught IOException on module deletion - - #7311: Introduce new hooks filtered & use it for product/category/brand/supplier/cms & html content - - #7313: Add actionSearch hook on ProductSearchProvider - - #7328: Fix store image & implement generation - - #7163: Enable the cart rule feature when updating one if it's enabled - - #7222: Fixed method Order::isVirtual - - #7257: Impossible to uninstall module when overridden file is missing - - #7241: Add native email missing - - #7194: Fix issue on translations without params - - #7235: Fix getImageLink for watermark module - - #7237: Fix pack price calc when using non-default attributes - - #7225: Fix missing subfolder in Repository namespace - - #6904: Fixes for module upgrade with zip upload - - #7211: Add missing SQL alias - - #7176: Set size limits on Doctrine Translation entity - - #7164: Update Mail::send documentation - - #7096: Use english email template as fallback in getEmailTemplateContent - - #7056: Restore deprecated method - - #7061: Fix command description - - #7111: Fix notice on $currency_to which may be null - - #7109: Fix unregisteration of Stylesheet by ID - - #7108: Fix unregisteration of JavaScript by ID - - #7014: Removed realpath for assets - - #6966: Fixed tools var - - #7126: Merge 1.7.0.x on develop - - #7081: Fixed CORS setting the header - - #7069: Protect translations display against XSS injections - - #7034: Use the locale to fallback on the good one in CLDR Repository - - #6927: Fix sprintf condition - - #6974: Created temporary file in cache directory - - #6929: Fix Cookie standalone mode - - #7013: Load autoload first - - #6994: Fixed on included files for autoupgrade - - #6848: Refresh CA bundle - - #6925: Prevent password reset on user check by email - - #6902: Fix PHP version for composer - - #6895: Fixed path windows assets - - #6890: Fixed translation render - - #6883: Fix multilang configuration insert - - #6803: Fix AJAX sync calls - Partial revert of 840fb00 - - #6856: Cart cache key should take id_zone into account - - #6849: Fixed missing escape - - #6872: Fixed path for windows - - #6831: Use module_name to get error on upload - - #6798: Hook:exec should always return an array when array_return = true - - #6837: Fix fatal if payment module return a non array result - - #6761: Clean installation files from deleted hooks - - #6816: Fixed hook & moved hook before body - - #6802: Configured Twig autoescape option - - #6779: Fixed module cache with 2 systems - - #6745: Fixed path for asset directory - - #6755: Fixed customer account add/update hook call - - #6739: Fix changed namespace - - - Installer: - - New feature: - - #7021: Adding country Tanzania - - Improvement: - - #7691: Remove awaiting Paypal order status - - #7517: Refactoring of the upgrade, to be easily usable in the auto upgrade module - - #7363: Update install with trans from crowdin - - #7302: Refacto 1.7.1.0.sql & remove 1.7.1.x.sql - - #7306: Add installed modules to quick access - - #7083: Updated tabs in FR - - #6939: Increase memory limit - - #6859: Declare default timezone when none is available - - Bug fix: - - #7638: Fix language refresh on dropdown change - - #7579: Avoid ERR_TOO_MANY_REDIRECTS at install - - #7571: Fix installation for languages without fixtures - - #7375: Fix error message display in installer - - #7374: Import sql upgrade from 1.6.x - - #6965: Add missing hooks actionObjectProductInCartDelete(Before|After) - - #7082: Small fixes for installer - - #7283: Do not launch install wizard if no write access to the cache folder - - #7057: Change india address form - - #7138: Fix wrong extension in the install.txt - - #7085: Update configuration.xml in SV - - #6817: Do not create parameters.php during install - - #7064: Install.txt file & documentation link update - - #7032: Required fileinfo extension - - #7053: Fix settings migration script - - #6967: Caught broken environment exception - - #6944: Add default message on ajax error in installer - - #6887: Add JSON, SimpleXML and DOM extensions as install requirements - - #6818: Clear the cache before trying to update the DB schema - - #6864: Fixed redirect on installer - - #6854: Add cURL check at installation - - #6845: Fix BDD required during install - - #6769: Added PS_MAINTENANCE_TEXT key in database - - - Web Services: - - Bug fix: - - #6910: Add watermark to new product images - -#################################### -# v1.7.0.5 - (2017-02-06) -#################################### -- Back Office: - - Bug fix: - - #7450: Fix some automator problem - - #7408: Fix deletion of virtual product attachment - - #7396: Fix products actions - - #7383: Add some cast on variables - - #7394: Fix fatal on getModulesToEnable() - - #7379: Fix image icon - - #7318: Fix saving decimals in AdminProduct combination form - - #7301: Translate categories tree in product page - - #7325: Add success message when import localization is ok - - #7324: No default reference on catalog - - #7326: Fix attachment file - - - Front Office: - - Bug fix: - - #7410: Redirect to 404 when CMS page doesn't exist - - #7340: Fix translations error from module with sprintf - - #6972: Add missing nofilter after display hook - - - Core: - - Improvement: - - #7360: Add config.php to the file .gitignore - - #7353: Update Israel VAT to 17% - - Bug fix: - - #7465: Protect some folders - - #7424: Update composer with modules - - #7354: Filter theme / module inputs - - #7418: Alter currency name to varchar(64) - - #7419: Use the right modules branch - - #7411: Refacto to get translation files - - #7407: Do not load index.php file in catalogue - - #7397: Fix email override path - - #7387: Fallback dataformate duplicate value - - #7347: Use the right attributes separator into the cart - - #7388: Fix clear media cache - - #7385: Fix function call - - #7351: Replace PCRE e modifier with callback - - -#################################### -# v1.7.0.4 - (2017-01-10) -#################################### -- Back Office: - - Bug fix: - - #7303: Add some test before use finfo - - #7292: Fix log page email hint - - #7295: Fix the customer thread timeline display - - #7118: Add parent menu permission if sub-menu is selected - - #7252: Fix product page ajax calls when url contains numbers - - #7193: Fix modules translation form - - #7271: Fix import theme for windows & special name - - #7267: Fix preview button action - - - Front Office: - - Bug fix: - - #7286: Use the right wording when guest is disabled - - #7195: Fix wrong displayed discount when it's higher than price - - #7162: Add error message when ordering number of item greater than quantity - - #7186: Always return a current order state - - #7185: Fix quick view in safari browser - - #7276: Add option with product to getManufacturer, getSupplier - - #7278: Do not let Classic override jQuery - - #7266: Fix category images generation - - #7248: Fix multishop popup design - - #7297: Fix clean filter event handler - - - Core: - - Bug fix: - - #7310: Protect translated strings from XSS - - #7114: Set curl as main solution and fopen as fallback - - #7279: Fix escaped translations - - #7275: Fix module translations priority - - #7263: Fix module uninstall when overridden file is missing - - #7194: Fix issue on translations without params - - - Installer: - - Bug fix: - - #7307: Fix croatian install adding quick_access - - #7296: Adding missing tabs in IT + VN + SR, and other tab updates - - #7274: Fix installer in Canadian and catalog cache - - #7284: Fix localization install for language not in data/lang - - #7294: Use the right locale for French Canadian - - -#################################### -# v1.7.0.3 - (2016-12-16) -#################################### -- Back Office: - - Bug fix: - - #7169: Add Request to hook parameters - - #7151: Allow installed modules translation from translation page - - #7024: Fixed product permissions - - #7153: Update docs & compile - - #7143: Fixed image of module on Payment page - - #7091: Fix some of the functions on the product page (JS) - - #7090: Fix error when saving traslations (1.7.0.0) - - #7028: Removed module card on uninstall - - #7215: TinyMCE media plugin shouldn't be activated twice - - - Front Office: - - Bug fix: - - #7130: Fix nav header menu icon on classic - - #7046: Fix classic css override of featuredproduct - - #7160: Fix sort by text display - - #7131: Fix bootstrap version - - #7077: Fix "too much recursion" error on ajax search - - #7078: Fix select filter & filter criteria by ajax - - - Core: - - Improvement: - - #6984: Use the right languages name - - #7146: Updated README - - Bug fix: - - #7224: Removed finfo use for theme upload - - #7205: Fix warnings in translate.php - - #7200: Fix module install and blank screen after PS install - - #7197: Check in Symfony catalog for translations for native modules - - #7191: Shutdown addons client on error - - #7190: Escape translated strings to prevent XSS - - #7187: Fix already defines smarty function - - #7184: Fix inactive scope for request in HookManager - - #7173: Revert "BO: fixed other XSS issues on translation module page" - - #7165: Licences & assets - - #7156: Fix SmartyLazyLoader for multiple smarty instances - - #7087: Protect translations display against XSS injections - - #7129: Fix timeout option for guzzle config - - #7144: Use default catalog as a fallback - - #7119: Use PhpParser to check parse errors in modules - - #7134: Fix mails with invoices - - #7080: Add unit price to order confirmation mail (1.7.0.0) - - #7096: Use english email template as fallback in getEmailTemplateContent - - -#################################### -# v1.7.0.2 - (2016-11-23) -#################################### -- Back Office: - - Bug fix: - - #7070: Fixed bulk actions affecting single products - - #7058: Disable FK checks during DB export - - #7063: Fix related product removal - - #7008: Display preview button on 13 inches - - #6958: Fix email preview in translation page - -- Front Office: - - Bug fix: - - #7027: Filtered embedded product properties - - #7043: Add download link for virtual products - -- Core: - - Improvement: - - #7022: Allowed to add remote assets - - Bug fix: - - #7038: Send email in English if current language don't have email template - - #7026: Protect translations display against XSS injections - - #7033: Use the locale to fallback on the good one in CLDR Repository - - #6986: Fix sprintf condition - - #7054: Fix Cookie standalone mode - - -#################################### -# v1.7.0.1 - (2016-11-16) -#################################### -- Back Office: - - Bug fix: - - #6975: Fix updating positions when sorting products - - #6977: Fixed security issue on SpecificPrice class - - #6952: Fix recommended modules modal window - - #6962: Fixed translation choice in BO - - #6951: Fixed notice on module translations - - #6940: Fix email translations - - #6937: Return empty array on API error for customer data - -- Front Office: - - Bug fix: - - #6991: Fix changing combination when catalog mode is enabled - - #6979: Fix undefined event in core.js - -- Core: - - Improvement: - - #6982: Improved performances on Windows/NFS filesytem - - Bug fix: - - #7012: Load autoload earlier - - #6971: Fixed on included files for autoupgrade - - #6989: Fix fatal if payment module return a non array result - - #6973: Created temporary file in cache directory - - #6969: Prevent password reset on user check by email - - -#################################### -# v1.7.0.0 - (2016-11-03) -#################################### - New Release! diff --git a/docs/csv_import/.htaccess b/docs/csv_import/.htaccess deleted file mode 100644 index c914413e..00000000 --- a/docs/csv_import/.htaccess +++ /dev/null @@ -1,10 +0,0 @@ -# Apache 2.2 - - Order allow,deny - Allow from all - - -# Apache 2.4 - - Require all granted - diff --git a/docs/csv_import/addresses_import.csv b/docs/csv_import/addresses_import.csv deleted file mode 100644 index c4549418..00000000 --- a/docs/csv_import/addresses_import.csv +++ /dev/null @@ -1,17 +0,0 @@ -Address ID;Alias*;Active (0/1);Customer e-mail*;Customer ID;Manufacturer;Supplier;Company;Lastname*;Firstname*;Address 1*;Address 2;Zipcode*;City*;Country*;State;Other;Phone;Mobile Phone;VAT number;DNI -1;Peter.Pan / New York;1;Peter.Pan@prestashop.com;;;;;Pan;Peter;360W, 42nd Street;;12001;New York;United States;New York;;01 02 03 04 05;06 02 03 04 05;;; -2;Wendy.Moira.Darling / New York;1;Wendy.Moira.Darling@prestashop.com;;;;;Darling;Wendy Moira;360W, 42nd Street;;12001;New York;United States;New York;;01 02 03 04 05;06 02 03 04 05;;; -3;Wendy.Moira.Darling / London;1;Wendy.Moira.Darling@prestashop.com;;;;;Darling;Wendy Moira;Lansdowne road 50 London;Kensington;W11;London;United Kingdom;;;01 02 03 04 05;06 02 03 04 05;;; -4;Tiger.Lily / Arizona;1;Tiger.Lily@prestashop.com;;;;;Lily;Tiger;Brackin Ranch Road;;86001;Flagstaff;United States;Arizona;;01 02 03 04 05;06 02 03 04 05;;; -5;Tiger.Lily / Le Chesnay;1;Tiger.Lily@prestashop.com;;;;;Lily;Tiger;53 passage des pas sages;;78150;Le Chesnay;France;;;01 02 03 04 05;06 02 03 04 05;;; -6;James.Hook / Home;1;James.Hook@prestashop.com;;;;;Hook;James;Mass Gravesite;P.O. Box 007;2101;Cayman Brac;Cayman Islands;;;01 02 03 04 05;06 02 03 04 05;;; -7;James Hook / Pro;1;James.Hook@prestashop.com;;;;Räuber Schätze GmBH;Hook;James;12 Leipziger Platz;;13505;Berlin;Germany;;;01 02 03 04 05;06 02 03 04 05;;; -8;Tinker.Bell / Napaiiri;1;Tinker.Bell@prestashop.com;;;;Santa Clauss Inc.;Bell;Tinker;Tähtikuja 1;;96930;Napapiiri;Finland;;;01 02 03 04 05;06 02 03 04 05;;; -9;Smee / Fiji;1;Bob.Smee@prestashop.com;;;;;Smee;Bob;Cross Island rd 321;Vanua Levu;;Savusavu;Fiji;;;01 02 03 04 05;06 02 03 04 05;;; -10;Smee / Portland;1;Bob.Smee@prestashop.com;;;;Lattice Semiconductor;Smee;Bob;5555 NE Moore Ct;;97124;Hillsboro;United States;Oregon;;01 02 03 04 05;06 02 03 04 05;;; -11;Tictac Crocodile / Home;1;Tictac.Crocodile@prestashop.com;;;;;Crocodile;Tictac;Old State Rd 4A;Saddlebunch keys;33040;Bay Point;United States;Florida;Beware the Shark :);01 02 03 04 05;06 02 03 04 05;;; -12;Apple / address1;1;;;Apple;;;Doe;John;1–6 Infinite Loop;;95014;Cupertino;United States;California;;01 02 03 04 05;06 02 03 04 05;;; -13;Shure / address1;1;;;Shure;;;Non-Doe;John;5800W Touhy Avenue;;60714;Niles;United States;Illinois;;01 02 03 04 05;06 02 03 04 05;;; -14;Shure / address2;1;;;Shure;;;Schuss-mayer;Kurt;Jakob-Dieffenbacher-Str. 12;;75031;Eppingen;Germany;;;01 02 03 04 05;06 02 03 04 05;;; -15;UPS / address1;1;;;;U.P.S;;Austin;Steve;55NE Glenlake Parkway;;30328;Atlanta;United States;Georgia;;01 02 03 04 05;06 02 03 04 05;;; -16;FedEX / address1;1;;;;FedEX;;Noland;Chuck;3640 Hacks Cross Rd;;32125;Memphis;United States;Tennessee;;01 02 03 04 05;06 02 03 04 05;;; diff --git a/docs/csv_import/alias_import.csv b/docs/csv_import/alias_import.csv deleted file mode 100644 index 00a21893..00000000 --- a/docs/csv_import/alias_import.csv +++ /dev/null @@ -1,5 +0,0 @@ -Alias ID;Alias *;Search *;Active (0/1) -1;ano, anno, nona;nano;1 -2;ipdo, idop, podi;ipod;1 -3;McBook, Mbcook;MacBook;1 -4;Blekin;Belkin;1 diff --git a/docs/csv_import/categories_import.csv b/docs/csv_import/categories_import.csv deleted file mode 100644 index c358fff2..00000000 --- a/docs/csv_import/categories_import.csv +++ /dev/null @@ -1,4 +0,0 @@ -Category ID;Active (0/1);Name *;Parent category;Root category (0/1);Description;Meta title;Meta keywords;Meta description;URL rewritten;Image URL -10;1;iPods;Home;0;Now that you can buy movies from the iTunes Store and sync them to your iPod, the whole world is your theater.;Meta title-iPods;Meta keywords-iPods;Meta description-iPods;music-ipods;http://yourlinktotheimage.com/img1000.jpg -11;1;Accessories;Home;0;Wonderful accessories for your iPod;Meta title-Accessories;Meta keywords-Accessories;Meta description-Accessories;accessories-ipod;http://yourlinktotheimage.com/img1001.jpg -12;1;Laptops;Home;0;The latest Intel processor, a bigger hard drive, plenty of memory, and even more new features all fit inside just one liberating inch. The new Mac laptops have the performance, power, and connectivity of a desktop computer. Without the desk part.;Meta title-Laptops;Meta keywords-Laptops;Meta description-Laptops;laptops;http://yourlinktotheimage.com/img1002.jpg diff --git a/docs/csv_import/combinations_import.csv b/docs/csv_import/combinations_import.csv deleted file mode 100644 index 2ba7a2c5..00000000 --- a/docs/csv_import/combinations_import.csv +++ /dev/null @@ -1,28 +0,0 @@ -Product ID*;Attribute (Name:Type:Position)*;Value (Value:Position)*;Supplier reference;Reference;EAN13;UPC;Wholesale price;Impact on price;Ecotax;Quantity;Minimal quantity;Low stock level;Impact on weight;Default (0 = No, 1 = Yes);Combination available date;Image position;Image URLs (x,y,z...);Image alt texts (x,y,z...);ID / Name of shop;Advanced Stock Managment;Depends on stock;Warehouse -1;Color:color:0, Disk space:select:1;Blue:0, 16GB:1;RF-Nano-Blue-16GB;RP-Nano-Blue-16GB;0000080446392;116052426077;100;40;0;10;1;;0;0;2014-01-01;1;http://youdomain.com/img.jpg,http://youdomain.com/img.jpg;First alt text,Second alt text;1;0;0;0; -1;Color:color:0, Disk space:select:1;Blue:0, 8GB:1;RF-Nano-Blue-8GB;RP-Nano-Blue-8GB;0000080446393;457698445011;80;0;0;10;1;0;0;0;2014-01-02;2;http://youdomain.com/img.jpg;First alt text;0;0;0; -1;Color:color:0, Disk space:select:1;Yellow:0, 16GB:1;RF-Nano-Yellow-16GB;RP-Nano-Yellow-16GB;0000080446394;541661772012;100;40;0;10;1;1;0;0;2014-01-03;3;http://youdomain.com/img.jpg;First alt text;0;0;0; -1;Color:color:0, Disk space:select:1;Yellow:0, 8GB:1;RF-Nano-Yellow-8GB;RP-Nano-Yellow-8GB;0000080446395;080064075921;80;0;0;10;1;2;0;1;2014-01-04;4;http://youdomain.com/img.jpg;First alt text;0;0;0; -1;Color:color:0, Disk space:select:1;Metal:0, 16GB:1;RF-Nano-Metal-16GB;RP-Nano-Metal-16GB;0000080446396;943284585394;100;40;0;10;1;3;0;0;2014-01-05;5;http://youdomain.com/img.jpg;First alt text;0;0;0; -1;Color:color:0, Disk space:select:1;Metal:0, 8GB:1;RF-Nano-Metal-8GB;RP-Nano-Metal-8GB;0000080446397;779589194980;80;0;0;10;1;;0;0;2014-01-06;6;http://youdomain.com/img.jpg;First alt text;0;0;0; -1;Color:color:0, Disk space:select:1;Black:0, 16GB:1;RF-Nano-Black-16GB;RP-Nano-Black-16GB;0000080446398;633319125866;100;40;0;10;1;0;0;0;2014-01-07;7;http://youdomain.com/img.jpg;First alt text;0;0;0; -1;Color:color:0, Disk space:select:1;Black:0, 8GB:1;RF-Nano-Black-8GB;RP-Nano-Black-8GB;0000080446399;397444719890;80;0;0;10;1;1;0;0;2014-01-08;8;http://youdomain.com/img.jpg;First alt text;0;0;0; -1;Color:color:0, Disk space:select:1;Orange:0, 16GB:1;RF-Nano-Orange-16GB;RP-Nano-Orange-16GB;0000080446400;295437962413;100;40;0;10;1;2;0;0;2014-01-09;9;http://youdomain.com/img.jpg;First alt text;0;0;0; -1;Color:color:0, Disk space:select:1;Orange:0, 8GB:1;RF-Nano-Orange-8GB;RP-Nano-Orange-8GB;0000080446401;879526174964;80;0;0;10;1;3;0;0;2014-01-10;10;http://youdomain.com/img.jpg;First alt text;0;0;0; -1;Color:color:0, Disk space:select:1;Pink:0, 16GB:1;RF-Nano-Pink-16GB;RP-Nano-Pink-16GB;0000080446402;850089888307;100;40;0;10;1;;0;0;2014-01-11;11;http://youdomain.com/img.jpg;First alt text;0;0;0; -1;Color:color:0, Disk space:select:1;Pink:0, 8GB:1;RF-Nano-Pink-8GB;RP-Nano-Pink-8GB;0000080446403;681363175404;80;0;0;10;1;0;0;0;2014-01-12;12;http://youdomain.com/img.jpg;First alt text;0;0;0; -1;Color:color:0, Disk space:select:1;Green:0, 16GB:1;RF-Nano-Green-16GB;RP-Nano-Green-16GB;0000080446404;343278201887;100;40;0;10;1;1;0;0;2014-01-13;13;http://youdomain.com/img.jpg;First alt text;0;0;0; -1;Color:color:0, Disk space:select:1;Green:0, 8GB:1;RF-Nano-Green-8GB;RP-Nano-Green-8GB;0000080446405;910409113499;80;0;0;10;1;2;0;0;2014-01-14;14;http://youdomain.com/img.jpg;First alt text;0;0;0; -1;Color:color:0, Disk space:select:1;Purple:0, 16GB:1;RF-Nano-Purple-16GB;RP-Nano-Purple-16GB;0000080446406;835747175053;100;40;0;10;1;3;0;0;2014-01-15;15;http://youdomain.com/img.jpg;First alt text;0;0;0; -1;Color:color:0, Disk space:select:1;Purple:0, 8GB:1;RF-Nano-Purple-8GB;RP-Nano-Purple-8GB;0000080446407;825739577313;80;0;0;10;1;;0;0;2014-01-16;16;http://youdomain.com/img.jpg;First alt text;0;0;0; -2;Color:color:0;Metal:0;RF-Shuffle-Metal;RP-Shuffle-Metal;0685387000000;623892618739;40;0;0;12;1;0;0;1;2014-01-17;1;http://youdomain.com/img.jpg;First alt text;0;0;0; -2;Color:color:0;Blue:0;RF-Shuffle-Blue;RP-Shuffle-Blue;0685387000000;848279119061;40;0;0;12;1;1;0;0;2014-01-18;2;http://youdomain.com/img.jpg;First alt text;0;0;0; -2;Color:color:0;Pink:0;RF-Shuffle-Pink;RP-Shuffle-Pink;0685387000000;745140261407;40;0;0;12;1;2;0;0;2014-01-19;3;http://youdomain.com/img.jpg;First alt text;0;0;0; -2;Color:color:0;Green:0;RF-Shuffle-Green;RP-Shuffle-Green;0685387000000;180143857886;40;0;0;12;1;3;0;0;2014-01-20;4;http://youdomain.com/img.jpg;First alt text;0;0;0; -3;Color:color:0, Disk space:select:1, ICU:select:2;Metal:0, 80GB Parallel ATA Drive @ 4200 rpm:1, 1.60GHz Intel Core 2 Duo:2;RF-MacBookAir80GB-1.6MHz;RP-MacBookAir80GB-1.6MHz;0123457000000;959149242374;0;750;0;10;1;;0;0;2014-01-21;1;http://youdomain.com/img.jpg;First alt text;0;0;0; -3;Color:color:0, Disk space:select:1, ICU:select:2;Metal:0, 80GB Parallel ATA Drive @ 4200 rpm:1, 1.80GHz Intel Core 2 Duo:2;RF-MacBookAir80GB-1.6MHz;RP-MacBookAir80GB-1.6MHz;0123457000000;110179337894;0;0;0;10;1;0;0;1;2014-01-22;2;http://youdomain.com/img.jpg;First alt text;0;0;0; -3;Color:color:0, Disk space:select:1, ICU:select:2;Metal:0, Optional 64GB solid-state drive:1, 1.60GHz Intel Core 2 Duo:2;RF-MacBookAir64GB-1.8MHz;RP-MacBookAir64GB-1.8MHz;0123457000000;576786535242;0;225;0;10;1;1;0;0;2014-01-23;3;http://youdomain.com/img.jpg;First alt text;0;0;0; -3;Color:color:0, Disk space:select:1, ICU:select:2;Metal:0, Optional 64GB solid-state drive:1, 1.60GHz Intel Core 2 Duo:2;RF-MacBookAir64GB-1.8MHz;RP-MacBookAir64GB-1.8MHz;0123457000000;288200093419;0;975;0;10;1;2;0;0;2014-01-24;4;http://youdomain.com/img.jpg;First alt text;0;0;0; -5;Disk space:select:1;8GB:0;RF-IpodTouch8GB;RP-IpodTouch8GB;8456120000000;626733005930;200;0;0;10;1;3;0;1;2014-01-25;1;http://youdomain.com/img.jpg;First alt text;0;0;0; -5;Disk space:select:1;16GB:0;RF-IpodTouch16GB;RP-IpodTouch16GB;8456120000000;604116319829;250;75;0;10;1;;0;0;2014-01-26;2;http://youdomain.com/img.jpg;First alt text;0;0;0; -5;Disk space:select:1;32GB:0;RF-IpodTouch32GB;RP-IpodTouch32GB;8456120000000;635894030063;300;150;0;10;1;0;0;0;2014-01-27;3;http://youdomain.com/img.jpg;First alt text;0;0;0; diff --git a/docs/csv_import/customers_import.csv b/docs/csv_import/customers_import.csv deleted file mode 100644 index ddd2a588..00000000 --- a/docs/csv_import/customers_import.csv +++ /dev/null @@ -1,10 +0,0 @@ -Customer ID;Active (0/1);Titles ID (Mr = 1, Ms = 2, else 0);Email *;Password *;Birthday (yyyy-mm-dd);Last Name *;First Name *;Newsletter (0/1);Opt-in (0/1);Registration date (yyyy-mm-dd);Groups (x,y,z...);Default group ID -1;1;1;Peter.Pan@prestashop.com;123456789;1987-04-02;Pan;Peter;1;0;2015-01-10;Customer;3 -2;1;2;Wendy.Moira.Darling@prestashop.com;123456789;1989-11-12;Darling;Wendy Moira;1;0;2014-05-12;Customer;3 -3;1;2;Tiger.Lily@prestashop.com;123456789;1982-02-28;Lily;Tiger;1;0;2013-09-25;Customer;3 -4;1;1;James.Hook@prestashop.com;123456789;1952-12-04;Hook;James;0;1;2015-07-13;Customer, Carribean;4 -5;1;2;Tinker.Bell@prestashop.com;123456789;1900-01-01;Bell;Tinker;1;1;2015-03-05;Customer;3 -6;1;1;Bob.Smee@prestashop.com;123456789;1971-10-21;Smee;Bob;1;1;2013-04-29;Customer;3 -7;1;1;Tictac.Crocodile@prestashop.com;123456789;1991-09-27;Crocodile;Tictac;0;0;2014-10-30;Customer, Carribean;4 -8;1;1;Jack.Banning@prestashop.com;123456789;2003-07-05;Banning;Jack;0;0;2014-12-10;Kids;5 -9;0;2;Maggie.Banning@prestashop.com;123456789;2006-02-27;Banning;Maggie;0;0;2015-07-11;Kids;5 diff --git a/docs/csv_import/index.php b/docs/csv_import/index.php deleted file mode 100644 index 76cd9dd3..00000000 --- a/docs/csv_import/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/docs/csv_import/manufacturers_import.csv b/docs/csv_import/manufacturers_import.csv deleted file mode 100644 index 2635dd72..00000000 --- a/docs/csv_import/manufacturers_import.csv +++ /dev/null @@ -1,63 +0,0 @@ -Manufacturer ID;Active (0/1);Name *;Description;Short description;Meta title;Meta keywords;Meta description;Image URL -1;1;Apple;"

The company was founded on April 1, 1976, and incorporated as Apple Computer, Inc. on January 3, 1977.The word ""Computer"" was removed from its name on January 9, 2007, the same day Steve Jobs introduced the iPhone, reflecting its shifted focus towards consumer electronics.

Apple is the world's second-largest information technology company by revenue after Samsung Electronics, and the world's third-largest mobile phone maker after Samsung and Nokia.Fortune magazine named Apple the most admired company in the United States in 2008, and in the world from 2008 to 2012. However, the company has received criticism for its contractors' labor practices, and for Apple's own environmental and business practices.

As of May 2013, Apple maintains 408 retail stores in fourteen countries as well as the online Apple Store and iTunes Store, the latter of which is the world's largest music retailer. Apple is the largest publicly traded corporation in the world by market capitalization, with an estimated value of US$415 billion as of March 2013. As of Sept 29 2012, the company had 72,800 permanent full-time employees and 3,300 temporary full-time employees worldwide. Its worldwide annual revenue in 2012 totalled $156 billion. In May 2013, Apple entered the top ten of the Fortune 500 list of companies for the first time, rising 11 places above its 2012 ranking to take the sixth position.

-

-

(For more, go to the original article on Wikipedia)

";"

-
-
-

-

Apple Inc., formerly Apple Computer, Inc., is an American multinational corporation headquartered in Cupertino, California that designs, develops, and sells consumer electronics, computer software and personal computers.

";MetaTitle-Apple;MetaKeywords-Apple;Meta description-Apple;http://localhost/prestashop/img/m/1.jpg -2;1;Shure;"


-

Company history

-

Shure was founded by Sidney N. Shure in 1925 as ""The Shure Radio Company"", selling radio parts kits in the days before complete manufactured radios were available. The company's office was located at 19 South Wells Street in downtown Chicago, Illinois. The following year, Shure published its first direct mail catalog, which was one of only six radio parts catalogs in the United States at the time. By 1928, the company had grown to over 75 employees, and Sidney's brother, Samuel J. Shure, joined the company, which was renamed Shure Brothers Company. The company moved into new offices at 335 West Madison Street in Chicago. In 1929, with the advent of the Great Depression and the increased availability of factory-built radios, Shure Brothers Company was forced to greatly reduce their staff and became the exclusive US distributor of a small microphone manufacturer. In 1930, Samuel J. Shure left the company.

-

In 1931, Shure and engineer Ralph Glover began development of the first Shure microphone, and the following year, the Model 33N Two-Button Carbon Microphone was introduced, making Shure one of only four microphone manufacturers in the U.S.. Shure's first condenser microphone, crystal microphone, and microphone suspension support system (for which they received their first patent) were all introduced that same decade. In 1939, Shure introduced the Model 55 Unidyne Microphone, which went on to become one of the world's most recognized microphones.

-

In 1941, Shure was contracted by the United States armed forces to supply microphones during World War II, and by the following year, the T-17B was the microphone most widely used by the U.S. Army and Navy. Shure also manufactured throat, headset, and oxygen mask microphones, and adopted the United States Military Standard for all Shure microphones.

-

By the mid-1940s, Shure was also manufacturing and supplying phonograph cartridges to major phonograph manufacturers including Philco, RCA, Emerson, Magnavox, Admiral, and Motorola, and was the largest producer of phonograph cartridges in the U.S. at that time. Among Shure's innovations in phonograph cartridge design was Ralph Glover and Ben Bauer's ""needle-tilt"" principle for minimizing record wear while improving sound reproduction, and Jim Kogen's engineering concept of ""trackability."" Shure produced the first phonograph cartridge capable of playing both long-playing and 78 rpm records, the first cartridge with tracking force of only one gram, and the first cartridge meeting the requirements of stereo recording. At the peak of Shure's phonograph cartridge production, the company was producing approximately 28,000 cartridges per day, with 25,000 of those coming from a Shure phonograph cartridge plant in Phoenix, Arizona. After the introduction of compact discs in the 1980s reduced the demand for phonograph cartridges, Shure closed the Phoenix facility but continued manufacturing phonograph cartridges, and continues to manufacture them today.

-

Shure also developed and produced products for medical applications. In 1937, their 66A piezoelectric stethophone was designed to accurately reproduce chest sounds, and in the early 1960s, the SP-5, SP-5S and SP-6 stethoscope pickups were produced. Shure also produced hearing aid cartridges used in hearing aid products from manufacturers like Maico, Telex, Dictograph, Otarian, Vocalite, and Trimm.

-

In 1956, Shure moved its corporate headquarters to Hartrey Avenue in Evanston, Illinois, where it remained for 47 years. Beginning in the 1956, Shure manufactured magnetic tape recording heads and two years later, the company announced it was ready to mass-produce 4-ch recording heads. By 1964, however, Shure announced it would no longer produce tape recording heads due to increased competition.

-

In 1953, Shure introduced their first wireless microphone system for performers, and in 1959, they introduced the Unidyne III Microphone, which was the predecessor to the SM57, which would be introduced, along with the SM58, six years later. Shure also produced portable equipment for broadcast field recording like Vocal Master, the M67 Portable Mixer, and the FP31 Portable Mixer. In 1990, Shure entered the wireless microphone market with the L-Series.

-

In 1981, James Kogen, Executive Vice President, Operations, was promoted to President and General Manager of Shure. In 1995, Sidney N. Shure died at the age of 93, and Rose L. Shure was elected Chairman of the Board of Directors. In 1996, James Kogen retired; Santo (Sandy) LaMantia, Vice President of Engineering, was named President and CEO. Shure Brothers Incorporated was officially renamed Shure Incorporated in 1999.

-

In 2001, Shure acquired the Popper Stopper brand of studio pop filters from Middle Atlantic Products Inc. The following year, Shure adopted hearing conservation as the company’s corporate cause and established the Shure Bid for Hearing program. In 2003, Shure moved into new corporate headquarters in Niles, Illinois, into a building designed by architect Helmut Jahn which was originally the headquarters of HA•LO Industries. The 65,000-square-foot (6,000 m2) Technology Annex designed by Krueck and Sexton Architects, opened in 2005, houses Shure's Performance Listening Center. In 2008, Shure celebrated the opening of The S.N. Shure Theater and Interactive Display at their corporate headquarters.

-

International offices

- -

Production facility expansion

- -


-

(For more, go to the original article on Wikipedia)

";"

-

-

-

Shure Incorporated is an American corporation originally founded by Sidney N. Shure in Chicago, Illinois in 1925 as a supplier of radio parts kits. The company became a consumer and professional audio-electronics manufacturer of microphones, wireless microphone systems, phonograph cartridges, discussion systems, mixers, and digital signal processing.

-

The company also produces listening products, including headphones, high-end earbuds and personal monitor systems.

";MetaTitle-Shure;MetaKeywords-Shure;Meta description-Shure;http://localhost/prestashop/img/m/2.jpg -3;1;Sony;"


-

History

-

Sony found its beginning in the wake of World War II. In 1946, Masaru Ibuka started an electronics shop in a bomb-damaged department store building in Tokyo. The company had $530 in capital and a total of eight employees. The next year, he was joined by his colleague, Akio Morita, and they founded a company called Tokyo Tsushin Kogyo (Tokyo Telecommunications Engineering Corporation). The company built Japan's first tape recorder, called the Type-G. In 1958 the company name was changed to Sony.

-

In the early 1950s, Ibuka traveled in the United States and heard about Bell Labs' invention of the...

-

(For more, go to the original article on Wikipedia)

";"

-

-

-


-

Sony Corporation, commonly referred to as Sony, is a Japanese multinational conglomerate corporation headquartered in Konan Minato, Tokyo, Japan. Its diversified business is primarily focused on the electronics, game, entertainment and financial services sectors. The company is one of the leading manufacturers of electronic products for the consumer and professional markets. Sony is ranked 87th on the 2012 list of Fortune Global 500.

";MetaTitle-Sony;MetaKeywords-Sony;Meta description-Sony;http://localhost/prestashop/img/m/3.jpg -4;1;Samsung;"

Samsung was founded by Lee Byung-chul in 1938 as a trading company. Over the next three decades the group diversified into areas including food processing, textiles, insurance, securities and retail. Samsung entered the electronics industry in the late 1960s and the construction and shipbuilding industries in the mid-1970s; these areas would drive its subsequent growth. Following Lee's death in 1987, Samsung was separated into four business groups – Samsung Group, Shinsegae Group, CJ Group and Hansol Group. Since the 1990s Samsung has increasingly globalized its activities, and electronics, particularly mobile phones and semiconductors, have become its most important source of income.

-

Notable Samsung industrial subsidiaries include Samsung Electronics (the world's largest information technology company measured by 2012 revenues, and 4th in market value), Samsung Heavy Industries (the world's 2nd-largest shipbuilder measured by 2010 revenues), and Samsung Engineering and Samsung C&T (respectively the world's 13th and 36th-largest construction companies). Other notable subsidiaries include Samsung Life Insurance (the world's 14th-largest life insurance company), Samsung Everland (operator of Everland Resort, the oldest theme park in South Korea), Samsung Techwin (an aerospace, surveillance and defense company) and Cheil Worldwide (the world's 16th-largest advertising agency measured by 2011 revenues).

-

Samsung has a powerful influence on South Korea's economic development, politics, media and culture, and has been a major driving force behind the ""Miracle on the Han River"". Its affiliate companies produce around a fifth of South Korea's total exports. Samsung's revenue was equal to 17% of the South Korea's $1,082 billion GDP.

-

In 2013, Samsung began construction on building the world's largest ...

-

(For more, go to the original article on Wikipedia)

";"


-
-
-
-


-

Samsung Group is a South Korean multinational conglomerate company headquartered in Samsung Town, Seoul. It comprises numerous subsidiaries and affiliated businesses, most of them united under the Samsung brand, and is the largest South Korean chaebol (business conglomerate).

";MetaTitle-Samsung;MetaKeywords-Samsung;Meta description-Samsung;http://localhost/prestashop/img/m/4.jpg diff --git a/docs/csv_import/products_import.csv b/docs/csv_import/products_import.csv deleted file mode 100644 index 01faa8e0..00000000 --- a/docs/csv_import/products_import.csv +++ /dev/null @@ -1,8 +0,0 @@ -Product ID;Active (0/1);Name *;Categories (x,y,z...);Price tax excluded;Tax rules ID;Wholesale price;On sale (0/1);Discount amount;Discount percent;Discount from (yyyy-mm-dd);Discount to (yyyy-mm-dd);Reference #;Supplier reference #;Supplier;Manufacturer;EAN13;UPC;Ecotax;Width;Height;Depth;Weight;Delivery time of in-stock products;Delivery time of out-of-stock products with allowed orders;Quantity;Minimal quantity;Low stock level;Send me an email when the quantity is under this level;Visibility;Additional shipping cost;Unity;Unit price;Summary;Description;Tags (x,y,z...);Meta title;Meta keywords;Meta description;URL rewritten;Text when in stock;Text when backorder allowed;Available for order (0 = No, 1 = Yes);Product available date;Product creation date;Show price (0 = No, 1 = Yes);Image URLs (x,y,z...);Image alt texts (x,y,z...);Delete existing images (0 = No, 1 = Yes);Feature(Name:Value:Position);Available online only (0 = No, 1 = Yes);Condition;Customizable (0 = No, 1 = Yes);Uploadable files (0 = No, 1 = Yes);Text fields (0 = No, 1 = Yes);Out of stock action;Virtual product;File URL;Number of allowed downloads;Expiration date;Number of days;ID / Name of shop;Advanced stock management;Depends On Stock;Warehouse;Acessories (x,y,z...) -1;1;iPod Nano;iPods;100;1;80;1;;5.5;2013-06-01;2018-12-31;RP-demo_1;RF-demo_1;Applestore;Apple;1234567890123;;1;0.6;0.2;0.4;0.068357;;;160;1;0;0;;;;;

New design.

;

New design.

;apple, ipod, nano;Meta title-Nano;Meta keywords-Nano;Meta description-Nano;iPod-Nano;In Stock;Current supply. Ordering availlable;1;2013-03-01;2013-01-01;1;http://localhost/prestashop/img/p/1/5/15.jpg,http://localhost/prestashop/img/p/2/3/23.jpg;First alt text,Second alt text;0;;0;new;0;0;0;0;0;;;;;0;0;0;0; -2;1;iPod shuffle;iPods;60;1;40;1;;;2013-06-01;2018-12-31;RP-demo_2;RF-demo_2;Applestore;Apple;1234567890123;;1;0.1;0.1;0.1;0.027563;;;120;1;1;0;both;;;;

New design.

;

New design.

;ipod, shuffle;Meta title-Shuffle;Meta keywords-Shuffle;Meta description-Shuffle;iPod-shuffle;In Stock;Current supply. Ordering availlable;1;2013-03-01;2013-01-02;1;http://localhost/prestashop/img/p/2/3/23.jpg;First alt text;0;;0;new;0;0;0;0;0;;;;;0;0;0;0; -3;1;MacBook Air;Laptops;1500;1;1000;1;100;;2013-06-01;2018-12-31;RP-demo_3;RF-demo_3;Applestore;Apple;1234567890123;;2;1.31;0.3;1;2.976846;;;400;1;2;0;catalog;;;;

New design.

;

New design.

;MacBook, Air;Meta title-McBookAir;Meta keywords-McBookAir;Meta description-McBookAir;MacBook-Air;In Stock;Current supply. Ordering availlable;1;2013-03-01;2013-01-03;1;http://localhost/prestashop/img/p/1/1.jpg;First alt text;1;;0;new;0;0;0;0;0;;;;;0;0;0;0; -4;1;MacBook;Laptops;1150;1;750;1;;;2013-06-01;2018-12-31;RP-demo_4;RF-demo_4;Applestore;Apple;1234567890123;;2;1.31;0.3;1;4.454244;;;75;1;3;1;search;;;;

New design.

;

New design.

;MacBook, Pro;Meta title-McBookPro;Meta keywords-McBookPro;Meta description-McBookPro;MacBook;In Stock;Current supply. Ordering availlable;1;2013-03-01;2013-01-04;1;http://localhost/prestashop/img/p/6/6.jpg;First alt text;1;;0;new;0;0;0;0;0;;;;;0;0;0;0; -5;1;iPod touch;iPods;240;1;150;1;;;2013-06-01;2018-12-31;RP-demo_5;RF-demo_5;Applestore;Apple;1234567890123;;1;0.6;0.2;0.4;0.194046;;;120;1;;0;none;;;;

New design.

;

New design.

;Ipod touch;Meta title-IpodTouch;Meta keywords-IpodTouch;Meta description-IpodTouch;iPod-touch;In Stock;Current supply. Ordering availlable;1;2013-03-01;2013-01-05;1;http://localhost/prestashop/img/p/7/7.jpg;First alt text;0;;1;used;0;0;0;0;0;;;;;0;0;0;0; -6;1;Belkin Leather Folio for iPod nano - Black / Chocolate;Accessories;25;1;150;1;;;2013-06-01;2018-12-31;RP-demo_6;RF-demo_6;Nippon Electronic Import;Belkin;1234567890123;;0;0.6;0.2;0.4;0.038588;;;25;1;0;1;;20;;;

New design.

;

New design.

;Folio, leather;Meta title-BelkinLeatherFolio;Meta keywords-BelkinLeatherFolio;Meta description-BelkinLeatherFolio;Belkin-Leather-Folio-for-iPod-nano---Black-Chocolate;In Stock;Current supply. Ordering availlable;1;2013-03-01;2013-01-06;1;http://localhost/prestashop/img/p/1/3/13.jpg;First alt text;0;;1;refurbished;0;0;0;0;0;;;;;0;0;0;0; -7;1;Shure SE210 Sound-Isolating Earphones for iPod and iPhone;Accessories;125;2;80;1;;;2013-06-01;2018-12-31;RP-demo_7;RF-demo_7;Shure Online Store;Shure;1234567890123;;0;0.1;0.1;0.1;0.040793;;;15;1;1;1;;;;;

New design.

;

New design.

;Headphones;Meta title-ShureEarphones;Meta keywords-ShureEarphones;Meta description-ShureEarphones;Shure-SE210-Sound-Isolating-Earphones-for-iPod-and-iPhone;In Stock;Current supply. Ordering availlable;1;2013-03-01;2013-01-07;1;http://localhost/prestashop/img/p/1/4/14.jpg;First alt text;0;;1;new;0;0;0;0;0;;;;;0;0;0;0; diff --git a/docs/csv_import/store_contacts.csv b/docs/csv_import/store_contacts.csv deleted file mode 100644 index 375efa31..00000000 --- a/docs/csv_import/store_contacts.csv +++ /dev/null @@ -1,6 +0,0 @@ -Store ID;active;name;address1;address2;postcode;state;city;country;latitude;longitude;phone;fax;email;note;hours;image -1;1;Dade County;3030 SW 8th St Miami;;33135;Florida;Miami;United States;25.76500500;-80.24379700;;;;;"09:00 - 19:00,09:00 - 19:00,09:00 - 19:00,09:00 - 19:00,09:00 - 19:00,10:00 - 16:00,10:00 - 16:00";http://yourlinktotheimage.com/img1.jpg -2;1;E Fort Lauderdale;1000 Northeast 4th Ave Fort Lauderdale;;33304;Florida;Miami;United States;26.13793600;-80.13943500;;;;;"09:00 - 19:00,09:00 - 19:00,09:00 - 19:00,09:00 - 19:00,09:00 - 19:00,10:00 - 16:00,10:00 - 16:00";http://yourlinktotheimage.com/img2.jpg -3;1;Pembroke Pines;11001 Pines Blvd Pembroke Pines;;33026;Florida;Miami;United States;26.00998700;-80.29447200;;;;;"09:00 - 19:00,09:00 - 19:00,09:00 - 19:00,09:00 - 19:00,09:00 - 19:00,10:00 - 16:00,10:00 - 16:00";http://yourlinktotheimage.com/img3.jpg -4;1;Coconut Grove;2999 SW 32nd Avenue;;33133;Florida;Miami;United States;25.73629600;-80.24479700;;;;;"09:00 - 19:00,09:00 - 19:00,09:00 - 19:00,09:00 - 19:00,09:00 - 19:00,10:00 - 16:00,10:00 - 16:00";http://yourlinktotheimage.com/img4.jpg -5;1;N Miami/Biscayne;12055 Biscayne Blvd;;33181;Florida;Miami;United States;25.88674000;-80.16329200;;;;;"09:00 - 19:00,09:00 - 19:00,09:00 - 19:00,09:00 - 19:00,09:00 - 19:00,10:00 - 16:00,10:00 - 16:00";http://yourlinktotheimage.com/img5.jpg diff --git a/docs/csv_import/suppliers_import.csv b/docs/csv_import/suppliers_import.csv deleted file mode 100644 index a7720885..00000000 --- a/docs/csv_import/suppliers_import.csv +++ /dev/null @@ -1,4 +0,0 @@ -Supplier ID;Active (0/1);Name *;Description;Short description;Meta title;Meta keywords;Meta description;Image URL -1;1;Applestore;

The Apple Store is a chain of retail stores owned and operated by Apple Inc., dealing in computers and consumer electronics. The stores sell Macintosh personal computers, software, iPods, iPads, iPhones, third-party accessories, and other consumer electronics such as Apple TV. Some high profile stores feature a Theatre for presentations and workshops and a Studio for training with Apple products; all stores offer a Genius Bar for technical support and repairs, as well as free workshops available to the public. Under the leadership of Ron Johnson, the former Senior Vice President of Retail Operations, the Apple Stores have, according to an article in the New York Times, been responsible for "[turning] the boring computer sales floor into a sleek playroom filled with gadgets".

;Meta title-Applestore;Meta keywords-Applestore;Meta description-Applestore;http://localhost/prestashop/img/su/Pic-of-this-supplier.jpg -2;1;Shure Online Store;

- No description -

;

- No description -

;Meta title-Shure Online Store;Meta keywords-Shure Online Store;Meta description-Shure Online Store;http://localhost/prestashop/img/su/Pic-of-this-supplier-2.jpg -3;1;Nippon Electronic Import;

- No description -

;

- No description -

;Meta title-Nippon Electronic Import;Meta keywords-Nippon Electronic Import;Meta description-Nippon Electronic Import;http://localhost/prestashop/img/su/Pic-of-this-supplier-3.jpg diff --git a/docs/csv_import/supply_orders_details_import.csv b/docs/csv_import/supply_orders_details_import.csv deleted file mode 100644 index bfc16136..00000000 --- a/docs/csv_import/supply_orders_details_import.csv +++ /dev/null @@ -1,21 +0,0 @@ -Supply Order Reference *;Product ID *;Product Attribute ID;Unit Price (tax excl.)*;Quantity Expected *;Discount Rate;Tax Rate -Ref Apple 01;1;1;100;25;0;19,6 -Ref Apple 01;1;2;80;25;0;19,6 -Ref Apple 01;1;3;100;25;0;19,6 -Ref Apple 01;1;4;80;25;0;19,6 -Ref Apple 01;1;5;100;25;0;19,6 -Ref Apple 01;1;6;80;25;0;19,6 -Ref Apple 01;1;7;100;25;0;19,6 -Ref Apple 01;1;8;80;25;0;19,6 -Ref Apple 01;1;9;100;25;0;19,6 -Ref Apple 01;1;10;80;25;0;19,6 -Ref Apple 01;1;11;100;25;0;19,6 -Ref Apple 01;1;12;80;25;0;19,6 -Ref Apple 01;1;13;100;25;0;19,6 -Ref Apple 01;1;14;80;25;0;19,6 -Ref Apple 01;1;15;100;25;0;19,6 -Ref Apple 01;1;16;80;25;0;19,6 -Ref Apple 01;2;17;40;25;0;19,6 -Ref Apple 01;2;18;40;25;0;19,6 -Ref Apple 01;2;19;40;25;0;19,6 -Ref Apple 01;2;20;40;25;0;19,6 diff --git a/docs/csv_import/supply_orders_import.csv b/docs/csv_import/supply_orders_import.csv deleted file mode 100644 index 30d1777d..00000000 --- a/docs/csv_import/supply_orders_import.csv +++ /dev/null @@ -1,5 +0,0 @@ -Supply Order ID;Supplier ID *;Lang ID;Warehouse ID *;Currency ID *;Supply Order Reference *;Delivery Date (Y-M-D)*;Discount Rate;Template -1;1;1;1;1;Ref Apple 01;2013-11-01;; -2;3;1;1;1;Nippon Electronic Import;2013-11-01;; -3;2;1;1;1;Shure Online Store;2013-11-01;; -4;1;1;2;2;Ref Apple 02;2013-11-01;; diff --git a/docs/docker/nginx_fpm/prestashop-fpm/Dockerfile b/docs/docker/nginx_fpm/prestashop-fpm/Dockerfile deleted file mode 100644 index d1be5113..00000000 --- a/docs/docker/nginx_fpm/prestashop-fpm/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -FROM php:7.1-fpm-alpine -ARG UID=1001 - -RUN apk add --no-cache \ - tzdata \ - zlib-dev \ - libjpeg-turbo-dev \ - libmcrypt-dev \ - pcre-dev \ - libpng-dev \ - freetype-dev \ - libxml2-dev \ - icu-dev - -ENV TZ Europe/Paris - -RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ - && docker-php-ext-install iconv intl pdo_mysql mbstring soap gd zip - -RUN docker-php-source extract \ - && if [ -d "/usr/src/php/ext/mysql" ]; then docker-php-ext-install mysql; fi \ - && if [ -d "/usr/src/php/ext/mcrypt" ]; then docker-php-ext-install mcrypt; fi \ - && if [ -d "/usr/src/php/ext/opcache" ]; then docker-php-ext-install opcache; fi \ - && docker-php-source delete - -COPY prestashop-php.ini /usr/local/etc/php/conf.d/prestashop-php.ini - -RUN adduser -D -H -u ${UID} prestashop diff --git a/docs/docker/nginx_fpm/prestashop-fpm/prestashop-php.ini b/docs/docker/nginx_fpm/prestashop-fpm/prestashop-php.ini deleted file mode 100644 index 338279cd..00000000 --- a/docs/docker/nginx_fpm/prestashop-fpm/prestashop-php.ini +++ /dev/null @@ -1,14 +0,0 @@ -[PHP] - -; This directive determines whether or not PHP will recognize code between -; tags as PHP source which should be processed as such. It is -; generally recommended that should be used and that this feature -; should be disabled, as enabling it may result in issues when generating XML -; documents, however this remains supported for backward compatibility reasons. -; Note that this directive does not control the tags as PHP source which should be processed as such. It is -; generally recommended that should be used and that this feature -; should be disabled, as enabling it may result in issues when generating XML -; documents, however this remains supported for backward compatibility reasons. -; Note that this directive does not control the - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/docs/licenses/LICENSE.txt b/docs/licenses/LICENSE.txt deleted file mode 100644 index a77cc9fd..00000000 --- a/docs/licenses/LICENSE.txt +++ /dev/null @@ -1,89 +0,0 @@ -Copyright (c) Since 2007 PrestaShop. - -Open Software License v. 3.0 (OSL-3.0) - -This Open Software License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: - -Licensed under the Open Software License version 3.0 - -1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: -a) to reproduce the Original Work in copies, either alone or as part of a collective work; -b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; -c) to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Open Software License; -d) to perform the Original Work publicly; and -e) to display the Original Work publicly. - -2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. - -3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. - -4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. - -5) External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). - -6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. - -7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. - -8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. - -9) Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). - -10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. - -11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. - -12) Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. - -13) Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. - -14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - -15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. - -16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Open Software License" or "OSL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. - -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- - -Academic Free License ("AFL") v. 3.0 - -This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: - -Licensed under the Academic Free License version 3.0 - -1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: -a) to reproduce the Original Work in copies, either alone or as part of a collective work; -b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; -c) to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License; -d) to perform the Original Work publicly; and -e) to display the Original Work publicly. - -2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. - -3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. - -4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. - -5) External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). - -6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. - -7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. - -8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. - -9) Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). - -10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. - -11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. - -12) Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. - -13) Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. - -14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. - -15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. - -16) Modification of This License. This License is Copyright © 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. diff --git a/docs/licenses/cropper.txt b/docs/licenses/cropper.txt deleted file mode 100644 index f696f253..00000000 --- a/docs/licenses/cropper.txt +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (c) 2006, David Spurr (www.defusion.org.uk) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the David Spurr nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -http://www.opensource.org/licenses/bsd-license.php \ No newline at end of file diff --git a/docs/licenses/fileuploader.txt b/docs/licenses/fileuploader.txt deleted file mode 100644 index 85515c28..00000000 --- a/docs/licenses/fileuploader.txt +++ /dev/null @@ -1,20 +0,0 @@ -File uploader component is licensed under the following licenses, choose one that suits your needs better. - -- MIT license - -The MIT License (MIT) -Copyright (c) 2010 Andrew Valums - -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. - -- GNU GPL 2 or later -http://www.gnu.org/licenses/gpl-2.0.txt - -- GNU LGPL 2 or later -http://www.gnu.org/licenses/lgpl-2.0.txt - -© 2010 Andrew Valums diff --git a/docs/licenses/fonts/open-sans.txt b/docs/licenses/fonts/open-sans.txt deleted file mode 100644 index d6456956..00000000 --- a/docs/licenses/fonts/open-sans.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/docs/licenses/fonts/ubuntu-condensed.txt b/docs/licenses/fonts/ubuntu-condensed.txt deleted file mode 100644 index ae78a8f9..00000000 --- a/docs/licenses/fonts/ubuntu-condensed.txt +++ /dev/null @@ -1,96 +0,0 @@ -------------------------------- -UBUNTU FONT LICENCE Version 1.0 -------------------------------- - -PREAMBLE -This licence allows the licensed fonts to be used, studied, modified and -redistributed freely. The fonts, including any derivative works, can be -bundled, embedded, and redistributed provided the terms of this licence -are met. The fonts and derivatives, however, cannot be released under -any other licence. The requirement for fonts to remain under this -licence does not require any document created using the fonts or their -derivatives to be published under this licence, as long as the primary -purpose of the document is not to be a vehicle for the distribution of -the fonts. - -DEFINITIONS -"Font Software" refers to the set of files released by the Copyright -Holder(s) under this licence and clearly marked as such. This may -include source files, build scripts and documentation. - -"Original Version" refers to the collection of Font Software components -as received under this licence. - -"Modified Version" refers to any derivative made by adding to, deleting, -or substituting -- in part or in whole -- any of the components of the -Original Version, by changing formats or by porting the Font Software to -a new environment. - -"Copyright Holder(s)" refers to all individuals and companies who have a -copyright ownership of the Font Software. - -"Substantially Changed" refers to Modified Versions which can be easily -identified as dissimilar to the Font Software by users of the Font -Software comparing the Original Version with the Modified Version. - -To "Propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification and with or without charging -a redistribution fee), making available to the public, and in some -countries other activities as well. - -PERMISSION & CONDITIONS -This licence does not grant any rights under trademark law and all such -rights are reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of the Font Software, to propagate the Font Software, subject to -the below conditions: - -1) Each copy of the Font Software must contain the above copyright -notice and this licence. These can be included either as stand-alone -text files, human-readable headers or in the appropriate machine- -readable metadata fields within text or binary files as long as those -fields can be easily viewed by the user. - -2) The font name complies with the following: -(a) The Original Version must retain its name, unmodified. -(b) Modified Versions which are Substantially Changed must be renamed to -avoid use of the name of the Original Version or similar names entirely. -(c) Modified Versions which are not Substantially Changed must be -renamed to both (i) retain the name of the Original Version and (ii) add -additional naming elements to distinguish the Modified Version from the -Original Version. The name of such Modified Versions must be the name of -the Original Version, with "derivative X" where X represents the name of -the new work, appended to that name. - -3) The name(s) of the Copyright Holder(s) and any contributor to the -Font Software shall not be used to promote, endorse or advertise any -Modified Version, except (i) as required by this licence, (ii) to -acknowledge the contribution(s) of the Copyright Holder(s) or (iii) with -their explicit written permission. - -4) The Font Software, modified or unmodified, in part or in whole, must -be distributed entirely under this licence, and must not be distributed -under any other licence. The requirement for fonts to remain under this -licence does not affect any document created using the Font Software, -except any version of the Font Software extracted from a document -created using the Font Software may only be distributed under this -licence. - -TERMINATION -This licence becomes null and void if any of the above conditions are -not met. - -DISCLAIMER -THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF -COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE -COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL -DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER -DEALINGS IN THE FONT SOFTWARE. diff --git a/docs/licenses/index.php b/docs/licenses/index.php deleted file mode 100644 index 76cd9dd3..00000000 --- a/docs/licenses/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/docs/licenses/php-sql-parser.txt b/docs/licenses/php-sql-parser.txt deleted file mode 100644 index c3e2031e..00000000 --- a/docs/licenses/php-sql-parser.txt +++ /dev/null @@ -1,12 +0,0 @@ -Copyright (c) 2011, greenlion (http://code.google.com/p/php-sql-parser/) -All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - * Neither the name of the David Spurr nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -http://www.opensource.org/licenses/bsd-license.php \ No newline at end of file diff --git a/docs/licenses/tinymce-smarty-swift.txt b/docs/licenses/tinymce-smarty-swift.txt deleted file mode 100644 index 070b42c7..00000000 --- a/docs/licenses/tinymce-smarty-swift.txt +++ /dev/null @@ -1,460 +0,0 @@ -TinyMCE, Smarty and Swift are licenced under LGPL : - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS diff --git a/docs/server_config/nginx.conf.dist b/docs/server_config/nginx.conf.dist deleted file mode 100644 index cef3dfa4..00000000 --- a/docs/server_config/nginx.conf.dist +++ /dev/null @@ -1,196 +0,0 @@ -# ------------------------------------------------------------------------------------------------- -# The following file is provided as-is by PrestaShop as an example configuration for your Nginx server. -# It may be incomplete, and remember you must adapt it for your own server's needs! -# Based on the work of MattLoyeD and Michael Dekker. -# ------------------------------------------------------------------------------------------------- - -server { - # Ipv4 - listen 80; - - # IPv6 - # listen [::]:80; - - # SSL Ipv4 & v6 - # listen 443 ssl; - # listen [::]:443 ssl; - - # Your SSL Certificates, don't forget to take a look at Certbot (https://certbot.eff.org) - # ssl_certificate /etc/ssl/fullchain.pem; - # ssl_certificate_key /etc/ssl/privkey.pem; - - # ssl_session_timeout 24h; - # ssl_session_cache shared:SSL:10m; - # ssl_protocols TLSv1 TLSv1.1 TLSv1.2; - # ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:RSA+3DES:AES128-SHA:!ADH:!AECDH:!MD5; - # ssl_prefer_server_ciphers on; - # Do not forget to create this file before with OpenSSL : "openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048" - # ssl_dhparam /etc/nginx/ssl/dhparam.pem; - - # [REQUIRED EDIT] Your domain name goes here - server_name server_name example.com www.example.com; - - # [REQUIRED EDIT] Absolute path to your website root on the filesystem - root /path/to/prestashop; - - index index.php; - - # Redirect 404 errors to prestashop - error_page 404 /index.php?controller=404; - - # Gzip Settings, convert all types. - gzip on; - gzip_vary on; - gzip_proxied any; - - # Can be enhance to 5, but it can slow you server - # gzip_comp_level 5; - # gzip_min_length 256; - - gzip_types - application/atom+xml - application/javascript - application/json - application/ld+json - application/manifest+json - application/rss+xml - application/vnd.geo+json - application/vnd.ms-fontobject - application/x-font-ttf - application/x-web-app-manifest+json - application/xhtml+xml - application/xml - font/opentype - image/bmp - image/svg+xml - image/x-icon - text/cache-manifest - text/css - text/plain - text/vcard - text/vnd.rim.location.xloc - text/vtt - text/x-component - text/x-cross-domain-policy; - - gzip_disable "MSIE [1-6]\.(?!.*SV1)"; - - # HSTS (Force clients to interact with your website using HTTPS only) - # For enhanced security, register your site here: https://hstspreload.org/ - # WARNING: Don't use this if your site is not fully on HTTPS! - # add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" preload; always; - - # Cloudflare / Max CDN fix - location ~* \.(eot|otf|ttf|woff(?:2)?)$ { - add_header Access-Control-Allow-Origin *; - } - - # Do not save logs for these - location = /favicon.ico { - auth_basic off; - allow all; - log_not_found off; - access_log off; - } - - location = /robots.txt { - auth_basic off; - allow all; - log_not_found off; - access_log off; - } - - # [REQUIRED EDIT IF MULTILANG] - # rewrite ^/fr$ /fr/ redirect; - # rewrite ^/fr/(.*) /$1; - - # Images - rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$1$2$3.jpg last; - rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$1$2$3$4.jpg last; - rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$1$2$3$4$5.jpg last; - rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5$6.jpg last; - rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6$7.jpg last; - rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7$8.jpg last; - rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8$9.jpg last; - rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9$10.jpg last; - rewrite ^/c/([0-9]+)(-[.*_a-zA-Z0-9-]*)(-[0-9]+)?/.+.jpg$ /img/c/$1$2$3.jpg last; - rewrite ^/c/([a-zA-Z_-]+)(-[0-9]+)?/.+.jpg$ /img/c/$1$2.jpg last; - - # AlphaImageLoader for IE and fancybox - rewrite ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ js/jquery/plugins/fancybox/images/$1.$2 last; - - # Web service API - rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last; - - # Installation sandbox - rewrite ^(/install(?:-dev)?/sandbox)/(.*) /$1/test.php last; - - # [REQUIRED EDIT] Change this block to your admin folder - location /admin-dev/ { - if (!-e $request_filename) { - rewrite ^/.*$ /admin-dev/index.php last; - } - } - - - # File security - # .htaccess .DS_Store .htpasswd etc - location ~ /\. { - deny all; - } - # Source code directories - location ~ ^/(app|bin|cache|classes|config|controllers|docs|localization|override|src|tests|tools|translations|travis-scripts|vendor|var)/ { - deny all; - } - # vendor in modules directory - location ~ ^/modules/.*/vendor/ { - deny all; - } - # Prevent exposing other sensitive files - location ~ \.(yml|log|tpl|twig|sass)$ { - deny all; - } - - # Prevent injection of php files - location /upload { - location ~ \.php$ { - deny all; - } - } - location /img { - location ~ \.php$ { - deny all; - } - } - - # PHP FPM part - location ~ \.php$ { - # Verify that the file exists, redirect to index if not - try_files $fastcgi_script_name /index.php$uri&$args =404; - - fastcgi_index index.php; - - # Environment variables for PHP - fastcgi_split_path_info ^(.+\.php)(/.+)$; - - include fastcgi_params; - - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - - # [REQUIRED EDIT] Connection to PHP-FPM - choose one - # fastcgi_pass 127.0.0.1:9000; - fastcgi_pass unix:/run/php/php7.0-fpm.sock; - - fastcgi_keep_conn on; - fastcgi_read_timeout 30s; - fastcgi_send_timeout 30s; - - # In case of long loading or 502 / 504 errors - # fastcgi_buffer_size 256k; - # fastcgi_buffers 256 16k; - # fastcgi_busy_buffers_size 256k; - client_max_body_size 10M; - } -} diff --git a/download/.htaccess b/download/.htaccess deleted file mode 100644 index 3de9e400..00000000 --- a/download/.htaccess +++ /dev/null @@ -1,10 +0,0 @@ -# Apache 2.2 - - Order deny,allow - Deny from all - - -# Apache 2.4 - - Require all denied - diff --git a/download/index.php b/download/index.php deleted file mode 100644 index 76cd9dd3..00000000 --- a/download/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/firmeslink/.htaccess b/firmeslink/.htaccess deleted file mode 100644 index 896fbc5a..00000000 --- a/firmeslink/.htaccess +++ /dev/null @@ -1,2 +0,0 @@ -Order deny,allow -Deny from all \ No newline at end of file diff --git a/firmeslink/documents/.htaccess b/firmeslink/documents/.htaccess deleted file mode 100644 index 896fbc5a..00000000 --- a/firmeslink/documents/.htaccess +++ /dev/null @@ -1,2 +0,0 @@ -Order deny,allow -Deny from all \ No newline at end of file diff --git a/firmeslink/documents/6/1/5/4/8/61548-2.pdf b/firmeslink/documents/6/1/5/4/8/61548-2.pdf deleted file mode 100644 index 5278d0a2..00000000 Binary files a/firmeslink/documents/6/1/5/4/8/61548-2.pdf and /dev/null differ diff --git a/firmeslink/documents/6/2/9/2/6/62926-2.pdf b/firmeslink/documents/6/2/9/2/6/62926-2.pdf deleted file mode 100644 index dcac6ff8..00000000 Binary files a/firmeslink/documents/6/2/9/2/6/62926-2.pdf and /dev/null differ diff --git a/firmeslink/documents/6/4/0/2/2/64022-2.pdf b/firmeslink/documents/6/4/0/2/2/64022-2.pdf deleted file mode 100644 index 67d9beaa..00000000 Binary files a/firmeslink/documents/6/4/0/2/2/64022-2.pdf and /dev/null differ diff --git a/firmeslink/documents/6/4/0/9/2/64092-2.pdf b/firmeslink/documents/6/4/0/9/2/64092-2.pdf deleted file mode 100644 index c7dc4d49..00000000 Binary files a/firmeslink/documents/6/4/0/9/2/64092-2.pdf and /dev/null differ diff --git a/firmeslink/documents/6/4/1/3/6/64136-2.pdf b/firmeslink/documents/6/4/1/3/6/64136-2.pdf deleted file mode 100644 index 734eab9b..00000000 Binary files a/firmeslink/documents/6/4/1/3/6/64136-2.pdf and /dev/null differ diff --git a/firmeslink/documents/6/4/1/9/3/64193-2.pdf b/firmeslink/documents/6/4/1/9/3/64193-2.pdf deleted file mode 100644 index 088398d4..00000000 Binary files a/firmeslink/documents/6/4/1/9/3/64193-2.pdf and /dev/null differ diff --git a/firmeslink/documents/6/4/2/0/5/64205-2.pdf b/firmeslink/documents/6/4/2/0/5/64205-2.pdf deleted file mode 100644 index 59f1d563..00000000 Binary files a/firmeslink/documents/6/4/2/0/5/64205-2.pdf and /dev/null differ diff --git a/firmeslink/documents/6/4/2/0/6/64206-2.pdf b/firmeslink/documents/6/4/2/0/6/64206-2.pdf deleted file mode 100644 index ffaa896b..00000000 Binary files a/firmeslink/documents/6/4/2/0/6/64206-2.pdf and /dev/null differ diff --git a/firmeslink/documents/6/4/2/0/9/64209-2.pdf b/firmeslink/documents/6/4/2/0/9/64209-2.pdf deleted file mode 100644 index 35682adf..00000000 Binary files a/firmeslink/documents/6/4/2/0/9/64209-2.pdf and /dev/null differ diff --git a/firmeslink/documents/6/4/2/1/4/64214-2.pdf b/firmeslink/documents/6/4/2/1/4/64214-2.pdf deleted file mode 100644 index e3952842..00000000 Binary files a/firmeslink/documents/6/4/2/1/4/64214-2.pdf and /dev/null differ diff --git a/firmeslink/documents/6/4/2/7/6/64276-2.pdf b/firmeslink/documents/6/4/2/7/6/64276-2.pdf deleted file mode 100644 index 31358e67..00000000 Binary files a/firmeslink/documents/6/4/2/7/6/64276-2.pdf and /dev/null differ diff --git a/firmeslink/documents/6/4/2/7/7/64277-2.pdf b/firmeslink/documents/6/4/2/7/7/64277-2.pdf deleted file mode 100644 index b4e54125..00000000 Binary files a/firmeslink/documents/6/4/2/7/7/64277-2.pdf and /dev/null differ diff --git a/firmeslink/documents/6/4/2/7/8/64278-2.pdf b/firmeslink/documents/6/4/2/7/8/64278-2.pdf deleted file mode 100644 index 4ce0b0ef..00000000 Binary files a/firmeslink/documents/6/4/2/7/8/64278-2.pdf and /dev/null differ diff --git a/firmeslink/documents/index.php b/firmeslink/documents/index.php deleted file mode 100644 index 32ed750d..00000000 --- a/firmeslink/documents/index.php +++ /dev/null @@ -1,3 +0,0 @@ - Array - ( - [0] => Array - ( - [id_custom_field] => 1 - [field_type] => boolean - [field_validation] => - [field_placement] => shipping - [position] => 0 - [assoc_shops] => 1 - [value_required] => 0 - [editable] => 0 - [extensions] => jpg - [products] => - [attachment_size] => 2.00 - [show_customer] => 1 - [show_email] => 0 - [show_admin] => 1 - [active] => 1 - [dependant] => 0 - [dependant_field] => 0 - [dependant_value] => 0 - [id_heading] => 0 - [created_time] => 0000-00-00 00:00:00 - [update_time] => 0000-00-00 00:00:00 - [field_name] => Chcę otrzymać fakturę - [field_value] => Yes - ) - - [1] => Array - ( - [id_custom_field] => 2 - [field_type] => text - [field_validation] => - [field_placement] => shipping - [position] => 1 - [assoc_shops] => 1 - [value_required] => 0 - [editable] => 0 - [extensions] => jpg - [products] => - [attachment_size] => 2.00 - [show_customer] => 1 - [show_email] => 0 - [show_admin] => 1 - [active] => 1 - [dependant] => 1 - [dependant_field] => 1 - [dependant_value] => 1 - [id_heading] => 0 - [created_time] => 0000-00-00 00:00:00 - [update_time] => 0000-00-00 00:00:00 - [field_name] => Firma - [field_value] => Project-Pro - ) - - [2] => Array - ( - [id_custom_field] => 3 - [field_type] => text - [field_validation] => - [field_placement] => shipping - [position] => 2 - [assoc_shops] => 1 - [value_required] => 0 - [editable] => 0 - [extensions] => jpg - [products] => - [attachment_size] => 2.00 - [show_customer] => 1 - [show_email] => 0 - [show_admin] => 1 - [active] => 1 - [dependant] => 1 - [dependant_field] => 1 - [dependant_value] => 1 - [id_heading] => 0 - [created_time] => 0000-00-00 00:00:00 - [update_time] => 0000-00-00 00:00:00 - [field_name] => NIP - [field_value] => 5170167517 - ) - - [3] => Array - ( - [id_custom_field] => 4 - [field_type] => text - [field_validation] => - [field_placement] => shipping - [position] => 3 - [assoc_shops] => 1 - [value_required] => 0 - [editable] => 0 - [extensions] => jpg - [products] => - [attachment_size] => 2.00 - [show_customer] => 1 - [show_email] => 0 - [show_admin] => 1 - [active] => 1 - [dependant] => 1 - [dependant_field] => 1 - [dependant_value] => 1 - [id_heading] => 0 - [created_time] => 0000-00-00 00:00:00 - [update_time] => 0000-00-00 00:00:00 - [field_name] => Adres - [field_value] => Okulickiego 18/1 - ) - - [4] => Array - ( - [id_custom_field] => 5 - [field_type] => text - [field_validation] => - [field_placement] => shipping - [position] => 4 - [assoc_shops] => 1 - [value_required] => 0 - [editable] => 0 - [extensions] => jpg - [products] => - [attachment_size] => 2.00 - [show_customer] => 1 - [show_email] => 0 - [show_admin] => 1 - [active] => 1 - [dependant] => 1 - [dependant_field] => 1 - [dependant_value] => 1 - [id_heading] => 0 - [created_time] => 0000-00-00 00:00:00 - [update_time] => 0000-00-00 00:00:00 - [field_name] => Miasto - [field_value] => Rzeszów - ) - - [5] => Array - ( - [id_custom_field] => 6 - [field_type] => text - [field_validation] => - [field_placement] => shipping - [position] => 5 - [assoc_shops] => 1 - [value_required] => 0 - [editable] => 0 - [extensions] => jpg - [products] => - [attachment_size] => 2.00 - [show_customer] => 1 - [show_email] => 0 - [show_admin] => 1 - [active] => 1 - [dependant] => 1 - [dependant_field] => 1 - [dependant_value] => 1 - [id_heading] => 0 - [created_time] => 0000-00-00 00:00:00 - [update_time] => 0000-00-00 00:00:00 - [field_name] => Kod pocztowy - [field_value] => 35-222 - ) - - ) - -) diff --git a/src/.DS_Store b/src/.DS_Store deleted file mode 100644 index 054dcb0c..00000000 Binary files a/src/.DS_Store and /dev/null differ diff --git a/src/.htaccess b/src/.htaccess deleted file mode 100644 index 3de9e400..00000000 --- a/src/.htaccess +++ /dev/null @@ -1,10 +0,0 @@ -# Apache 2.2 - - Order deny,allow - Deny from all - - -# Apache 2.4 - - Require all denied - diff --git a/src/Adapter/Addons/AddonsDataProvider.php b/src/Adapter/Addons/AddonsDataProvider.php deleted file mode 100644 index da6173df..00000000 --- a/src/Adapter/Addons/AddonsDataProvider.php +++ /dev/null @@ -1,229 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Addons; - -use Exception; -use PhpEncryption; -use PrestaShop\PrestaShop\Adapter\Module\ModuleZipManager; -use PrestaShopBundle\Service\DataProvider\Admin\AddonsInterface; -use PrestaShopBundle\Service\DataProvider\Marketplace\ApiClient; -use Symfony\Component\HttpFoundation\Request; - -/** - * Data provider for new Architecture, about Addons. - * - * This class will provide data from Addons API - */ -class AddonsDataProvider implements AddonsInterface -{ - /** - * @var bool - */ - protected static $is_addons_up = true; - - /** - * @var ApiClient - */ - private $marketplaceClient; - - /** - * @var ModuleZipManager - */ - private $zipManager; - - /** - * @var PhpEncryption - */ - private $encryption; - - /** - * @var string the cache directory location - */ - public $cacheDir; - - public function __construct(ApiClient $apiClient, ModuleZipManager $zipManager) - { - $this->marketplaceClient = $apiClient; - $this->zipManager = $zipManager; - $this->encryption = new PhpEncryption(_NEW_COOKIE_KEY_); - } - - /** - * @param $module_id - * - * @return bool - * - * @throws Exception - */ - public function downloadModule($module_id) - { - $params = [ - 'id_module' => $module_id, - 'format' => 'json', - ]; - - // Module downloading - try { - $module_data = $this->request('module_download', $params); - } catch (Exception $e) { - if (!$this->isAddonsAuthenticated()) { - throw new Exception('Error sent by Addons. You may need to be logged.', 0, $e); - } else { - throw new Exception('Error sent by Addons. You may be not allowed to download this module.', 0, $e); - } - } - - $temp_filename = tempnam($this->cacheDir, 'mod'); - if (file_put_contents($temp_filename, $module_data) !== false) { - $this->zipManager->storeInModulesFolder($temp_filename); - - return true; - } else { - throw new Exception('Cannot store module content in temporary folder !'); - } - } - - /** - * @return bool - * - * @todo Does this function should be in a User related class ? - */ - public function isAddonsAuthenticated() - { - $request = Request::createFromGlobals(); - - return $request->cookies->get('username_addons', false) - && $request->cookies->get('password_addons', false); - } - - /** - * {@inheritdoc} - */ - public function request($action, $params = []) - { - if (!$this->isAddonsUp()) { - throw new Exception('Previous call failed and disabled client.'); - } - - // We merge the addons credentials - if ($this->isAddonsAuthenticated()) { - $params = array_merge($this->getAddonsCredentials(), $params); - } - - $this->marketplaceClient->reset(); - - try { - switch ($action) { - case 'native': - return $this->marketplaceClient->getNativesModules(); - case 'service': - return $this->marketplaceClient->getServices(); - case 'native_all': - return $this->marketplaceClient->setIsoCode('all') - ->getNativesModules(); - case 'must-have': - return $this->marketplaceClient->getMustHaveModules(); - case 'customer': - return $this->marketplaceClient->getCustomerModules($params['username_addons'], $params['password_addons']); - case 'customer_themes': - return $this->marketplaceClient - ->setUserMail($params['username_addons']) - ->setPassword($params['password_addons']) - ->getCustomerThemes(); - case 'check_customer': - return $this->marketplaceClient - ->setUserMail($params['username_addons']) - ->setPassword($params['password_addons']) - ->getCheckCustomer(); - case 'check_module': - return $this->marketplaceClient - ->setUserMail($params['username_addons']) - ->setPassword($params['password_addons']) - ->setModuleName($params['module_name']) - ->setModuleKey($params['module_key']) - ->getCheckModule(); - case 'module_download': - if ($this->isAddonsAuthenticated()) { - return $this->marketplaceClient - ->setUserMail($params['username_addons']) - ->setPassword($params['password_addons']) - ->getModuleZip($params['id_module']); - } - - return $this->marketplaceClient->getModuleZip($params['id_module']); - case 'module': - return $this->marketplaceClient->getModule($params['id_module']); - case 'install-modules': - return $this->marketplaceClient->getPreInstalledModules(); - case 'categories': - return $this->marketplaceClient->getCategories(); - } - } catch (Exception $e) { - self::$is_addons_up = false; - - throw $e; - } - } - - /** - * @return array - * - * @throws Exception - */ - protected function getAddonsCredentials() - { - $request = Request::createFromGlobals(); - $username = $this->encryption->decrypt($request->cookies->get('username_addons')); - $password = $this->encryption->decrypt($request->cookies->get('password_addons')); - - return [ - 'username_addons' => $username, - 'password_addons' => $password, - ]; - } - - /** Does this function should be in a User related class ? **/ - public function getAddonsEmail() - { - $request = Request::createFromGlobals(); - $username = $this->encryption->decrypt($request->cookies->get('username_addons')); - - return [ - 'username_addons' => $username, - ]; - } - - /** - * Check if a request has already failed. - * - * @return bool - */ - public function isAddonsUp() - { - return self::$is_addons_up; - } -} diff --git a/src/Adapter/Address/AbstractAddressHandler.php b/src/Adapter/Address/AbstractAddressHandler.php deleted file mode 100644 index f1d4339c..00000000 --- a/src/Adapter/Address/AbstractAddressHandler.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Address; - -use Address; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\InvalidAddressFieldException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; -use PrestaShopException; - -/** - * Provides reusable methods for address command/query handlers - */ -abstract class AbstractAddressHandler -{ - /** - * @param AddressId $addressId - * - * @return Address - * - * @throws AddressException - * @throws AddressNotFoundException - */ - protected function getAddress(AddressId $addressId) - { - try { - $address = new Address($addressId->getValue()); - } catch (PrestaShopException $e) { - throw new AddressException('Failed to create new address', 0, $e); - } - - if ($address->id !== $addressId->getValue()) { - throw new AddressNotFoundException(sprintf('Address with id "%s" was not found.', $addressId->getValue())); - } - - return $address; - } - - /** - * Deletes legacy Address - * - * @param Address $address - * - * @return bool - * - * @throws AddressException - */ - protected function deleteAddress(Address $address): bool - { - try { - return $address->delete(); - } catch (PrestaShopException $e) { - throw new AddressException(sprintf('An error occurred when deleting Address object with id "%s".', $address->id)); - } - } - - /** - * @param Address $address - * - * @throws InvalidAddressFieldException - * @throws PrestaShopException - */ - protected function validateAddress(Address $address): void - { - if (true !== ($validateResult = $address->validateFields(false, true)) - || true !== ($validateResult = $address->validateFieldsLang(false, true))) { - throw new InvalidAddressFieldException(sprintf('Address fields contain invalid values: %s', $validateResult)); - } - } -} diff --git a/src/Adapter/Address/AbstractCustomerAddressHandler.php b/src/Adapter/Address/AbstractCustomerAddressHandler.php deleted file mode 100644 index b6ec69f5..00000000 --- a/src/Adapter/Address/AbstractCustomerAddressHandler.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Address; - -use CustomerAddress; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressException; -use PrestaShopDatabaseException; - -abstract class AbstractCustomerAddressHandler extends AbstractAddressHandler -{ - /** - * @return string[] - * - * @throws AddressException - */ - protected function getRequiredFields(): array - { - try { - $requiredFields = (new CustomerAddress())->getFieldsRequiredDatabase(); - } catch (PrestaShopDatabaseException $e) { - throw new AddressException('Something went wrong while retrieving required fields for address', 0, $e); - } - - if (empty($requiredFields)) { - return []; - } - - $fields = []; - - foreach ($requiredFields as $field) { - $fields[] = $field['field_name']; - } - - return $fields; - } -} diff --git a/src/Adapter/Address/AbstractManufacturerAddressHandler.php b/src/Adapter/Address/AbstractManufacturerAddressHandler.php deleted file mode 100644 index 0f27c951..00000000 --- a/src/Adapter/Address/AbstractManufacturerAddressHandler.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Address; - -use Address; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; - -/** - * Provides reusable methods for manufacturer address address command/query handlers - * - * @deprecated Since 1.7.7 Use AbstractAddressHandler instead - */ -abstract class AbstractManufacturerAddressHandler -{ - /** - * Gets legacy Address - * - * @param AddressId $addressId - * - * @return Address - * - * @throws AddressNotFoundException - */ - protected function getAddress(AddressId $addressId) - { - $address = new Address($addressId->getValue()); - - if ($address->id !== $addressId->getValue()) { - throw new AddressNotFoundException(sprintf('Address with id "%s" was not found.', $addressId->getValue())); - } - - return $address; - } -} diff --git a/src/Adapter/Address/CommandHandler/AddCustomerAddressHandler.php b/src/Adapter/Address/CommandHandler/AddCustomerAddressHandler.php deleted file mode 100644 index 348caafe..00000000 --- a/src/Adapter/Address/CommandHandler/AddCustomerAddressHandler.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Address\CommandHandler; - -use Address; -use PrestaShop\PrestaShop\Adapter\Address\AbstractAddressHandler; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\AddCustomerAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler\AddCustomerAddressHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\CannotAddAddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; -use PrestaShopException; - -final class AddCustomerAddressHandler extends AbstractAddressHandler implements AddCustomerAddressHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws AddressException - * @throws AddressConstraintException - * @throws CannotAddAddressException - */ - public function handle(AddCustomerAddressCommand $command): AddressId - { - $address = $this->createAddressFromCommand($command); - - try { - $this->validateAddress($address); - - if (false === $address->add()) { - throw new CannotAddAddressException(sprintf('Failed to add new address "%s"', $command->getAddress())); - } - } catch (PrestaShopException $e) { - throw new AddressException(sprintf('An error occurred when adding new address "%s"', $command->getAddress())); - } - - return new AddressId((int) $address->id); - } - - /** - * @param AddCustomerAddressCommand $command - * - * @return Address - */ - private function createAddressFromCommand(AddCustomerAddressCommand $command): Address - { - $address = new Address(); - - $address->id_customer = $command->getCustomerId()->getValue(); - $address->lastname = $command->getLastName(); - $address->firstname = $command->getFirstName(); - $address->address1 = $command->getAddress(); - $address->id_country = $command->getCountryId()->getValue(); - $address->city = $command->getCity(); - $address->alias = $command->getAddressAlias(); - $address->postcode = $command->getPostCode(); - $address->address2 = $command->getAddress2(); - $address->dni = $command->getDni(); - $address->company = $command->getCompany(); - $address->vat_number = $command->getVatNumber(); - $address->id_state = $command->getStateId()->getValue(); - $address->phone = $command->getHomePhone(); - $address->phone_mobile = $command->getMobilePhone(); - $address->other = $command->getOther(); - - return $address; - } -} diff --git a/src/Adapter/Address/CommandHandler/AddManufacturerAddressHandler.php b/src/Adapter/Address/CommandHandler/AddManufacturerAddressHandler.php deleted file mode 100644 index 3c5337c5..00000000 --- a/src/Adapter/Address/CommandHandler/AddManufacturerAddressHandler.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Address\CommandHandler; - -use Address; -use PrestaShop\PrestaShop\Adapter\Address\AbstractAddressHandler; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\AddManufacturerAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler\AddManufacturerAddressHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; -use PrestaShopException; - -/** - * Adds manufacturer address using legacy object model - */ -final class AddManufacturerAddressHandler extends AbstractAddressHandler implements AddManufacturerAddressHandlerInterface -{ - /** - * @param AddManufacturerAddressCommand $command - * - * @return AddressId - * - * @throws AddressException - */ - public function handle(AddManufacturerAddressCommand $command) - { - $address = $this->createAddressFromCommand($command); - - try { - $this->validateAddress($address); - if (false === $address->add()) { - throw new AddressException(sprintf('Failed to add new address "%s"', $command->getAddress())); - } - } catch (PrestaShopException $e) { - throw new AddressException(sprintf('An error occurred when adding new address "%s"', $command->getAddress())); - } - - return new AddressId((int) $address->id); - } - - /** - * @param AddManufacturerAddressCommand $command - * - * @return Address - */ - private function createAddressFromCommand(AddManufacturerAddressCommand $command) - { - $address = new Address(); - $address->id_manufacturer = $command->getManufacturerId(); - $address->lastname = $command->getLastName(); - $address->firstname = $command->getFirstName(); - $address->address1 = $command->getAddress(); - $address->address2 = $command->getAddress2(); - $address->postcode = $command->getPostCode(); - $address->id_country = $command->getCountryId(); - $address->city = $command->getCity(); - $address->id_state = $command->getStateId(); - $address->phone = $command->getHomePhone(); - $address->phone_mobile = $command->getMobilePhone(); - $address->other = $command->getOther(); - $address->dni = $command->getDni(); - $address->alias = 'manufacturer'; - - return $address; - } -} diff --git a/src/Adapter/Address/CommandHandler/BulkDeleteAddressHandler.php b/src/Adapter/Address/CommandHandler/BulkDeleteAddressHandler.php deleted file mode 100644 index d8025f88..00000000 --- a/src/Adapter/Address/CommandHandler/BulkDeleteAddressHandler.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Address\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Address\AbstractAddressHandler; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\BulkDeleteAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler\BulkDeleteAddressHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\BulkDeleteAddressException; - -/** - * Handles command which deletes addresses in bulk action - */ -final class BulkDeleteAddressHandler extends AbstractAddressHandler implements BulkDeleteAddressHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws BulkDeleteAddressException - */ - public function handle(BulkDeleteAddressCommand $command) - { - $errors = []; - - foreach ($command->getAdressIds() as $addressId) { - try { - $address = $this->getAddress($addressId); - - if (!$this->deleteAddress($address)) { - $errors[] = $address->id; - } - } catch (AddressException $e) { - $errors[] = $addressId->getValue(); - } - } - - if (!empty($errors)) { - throw new BulkDeleteAddressException($errors, 'Failed to delete all of selected addresses'); - } - } -} diff --git a/src/Adapter/Address/CommandHandler/DeleteAddressHandler.php b/src/Adapter/Address/CommandHandler/DeleteAddressHandler.php deleted file mode 100644 index 5c1f4432..00000000 --- a/src/Adapter/Address/CommandHandler/DeleteAddressHandler.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Address\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Address\AbstractAddressHandler; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\DeleteAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler\DeleteAddressHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\DeleteAddressException; - -/** - * Handles command which deletes address - */ -final class DeleteAddressHandler extends AbstractAddressHandler implements DeleteAddressHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(DeleteAddressCommand $command) - { - $addressId = $command->getAddressId(); - $address = $this->getAddress($addressId); - - if (!$this->deleteAddress($address)) { - throw new DeleteAddressException(sprintf('Cannot delete Address object with id "%s".', $addressId->getValue()), DeleteAddressException::FAILED_DELETE); - } - } -} diff --git a/src/Adapter/Address/CommandHandler/EditCartAddressHandler.php b/src/Adapter/Address/CommandHandler/EditCartAddressHandler.php deleted file mode 100644 index 657952c3..00000000 --- a/src/Adapter/Address/CommandHandler/EditCartAddressHandler.php +++ /dev/null @@ -1,172 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Address\CommandHandler; - -use Cart; -use PrestaShop\PrestaShop\Adapter\Validate; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\EditCartAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\EditCustomerAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler\EditCartAddressHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler\EditCustomerAddressHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\CannotUpdateCartAddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; -use PrestaShop\PrestaShop\Core\Domain\Cart\CartAddressType; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\State\Exception\StateConstraintException; -use PrestaShopException; - -/** - * EditCartAddressHandler manages an address update, it then updates cart - * relation to the newly created address. - */ -class EditCartAddressHandler implements EditCartAddressHandlerInterface -{ - /** - * @var EditCustomerAddressHandlerInterface - */ - private $addressHandler; - - /** - * @param EditCustomerAddressHandlerInterface $addressHandler - */ - public function __construct(EditCustomerAddressHandlerInterface $addressHandler) - { - $this->addressHandler = $addressHandler; - } - - /** - * {@inheritdoc} - * - * @throws AddressConstraintException - * @throws CannotUpdateCartAddressException - * @throws CountryConstraintException - * @throws StateConstraintException - */ - public function handle(EditCartAddressCommand $command): AddressId - { - try { - $cart = new Cart($command->getCartId()->getValue()); - if (!Validate::isLoadedObject($cart) || $command->getCartId()->getValue() !== (int) $cart->id) { - throw new CartNotFoundException(sprintf('Cart with id "%d" was not found', $command->getCartId()->getValue())); - } - - $addressCommand = $this->createEditAddressCommand($command, $cart); - /** @var AddressId $addressId */ - $addressId = $this->addressHandler->handle($addressCommand); - - switch ($command->getAddressType()) { - case CartAddressType::DELIVERY_ADDRESS_TYPE: - $cart->id_address_delivery = $addressId->getValue(); - break; - case CartAddressType::INVOICE_ADDRESS_TYPE: - $cart->id_address_invoice = $addressId->getValue(); - break; - } - if (!$cart->update()) { - throw new CannotUpdateCartAddressException(sprintf('An error occurred when updating address for cart "%d"', $command->getCartId()->getValue())); - } - } catch (PrestaShopException $e) { - throw new CannotUpdateCartAddressException(sprintf('An error occurred when updating address for cart "%d"', $command->getCartId()->getValue())); - } - - return $addressId; - } - - /** - * @param EditCartAddressCommand $cartCommand - * - * @return EditCustomerAddressCommand - * - * @throws AddressConstraintException - * @throws CountryConstraintException - * @throws StateConstraintException - * @throws PrestaShopException - */ - private function createEditAddressCommand(EditCartAddressCommand $cartCommand, Cart $cart): EditCustomerAddressCommand - { - $addressId = null; - switch ($cartCommand->getAddressType()) { - case CartAddressType::DELIVERY_ADDRESS_TYPE: - $addressId = (int) $cart->id_address_delivery; - break; - case CartAddressType::INVOICE_ADDRESS_TYPE: - $addressId = (int) $cart->id_address_invoice; - break; - } - $addressCommand = new EditCustomerAddressCommand($addressId); - if (null !== $cartCommand->getAddressAlias()) { - $addressCommand->setAddressAlias($cartCommand->getAddressAlias()); - } - if (null !== $cartCommand->getFirstName()) { - $addressCommand->setFirstName($cartCommand->getFirstName()); - } - if (null !== $cartCommand->getLastName()) { - $addressCommand->setLastName($cartCommand->getLastName()); - } - if (null !== $cartCommand->getAddress()) { - $addressCommand->setAddress($cartCommand->getAddress()); - } - if (null !== $cartCommand->getCity()) { - $addressCommand->setCity($cartCommand->getCity()); - } - if (null !== $cartCommand->getPostCode()) { - $addressCommand->setPostCode($cartCommand->getPostCode()); - } - if (null !== $cartCommand->getCountryId()) { - $addressCommand->setCountryId($cartCommand->getCountryId()->getValue()); - } - if (null !== $cartCommand->getDni()) { - $addressCommand->setDni($cartCommand->getDni()); - } - if (null !== $cartCommand->getCompany()) { - $addressCommand->setCompany($cartCommand->getCompany()); - } - if (null !== $cartCommand->getVatNumber()) { - $addressCommand->setVatNumber($cartCommand->getVatNumber()); - } - if (null !== $cartCommand->getAddress2()) { - $addressCommand->setAddress2($cartCommand->getAddress2()); - } - if (null !== $cartCommand->getStateId()) { - $addressCommand->setStateId($cartCommand->getStateId()->getValue()); - } - if (null !== $cartCommand->getHomePhone()) { - $addressCommand->setHomePhone($cartCommand->getHomePhone()); - } - if (null !== $cartCommand->getMobilePhone()) { - $addressCommand->setMobilePhone($cartCommand->getMobilePhone()); - } - if (null !== $cartCommand->getOther()) { - $addressCommand->setOther($cartCommand->getOther()); - } - - return $addressCommand; - } -} diff --git a/src/Adapter/Address/CommandHandler/EditCustomerAddressHandler.php b/src/Adapter/Address/CommandHandler/EditCustomerAddressHandler.php deleted file mode 100644 index 52516de1..00000000 --- a/src/Adapter/Address/CommandHandler/EditCustomerAddressHandler.php +++ /dev/null @@ -1,169 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Address\CommandHandler; - -use Address; -use Country; -use PrestaShop\PrestaShop\Adapter\Address\AbstractAddressHandler; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\EditCustomerAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler\EditCustomerAddressHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\CannotAddAddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\CannotUpdateAddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\DeleteAddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; -use PrestaShopException; - -/** - * Handles update of customer address - */ -final class EditCustomerAddressHandler extends AbstractAddressHandler implements EditCustomerAddressHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws AddressException - * @throws AddressConstraintException - * @throws CannotUpdateAddressException - */ - public function handle(EditCustomerAddressCommand $command): AddressId - { - try { - $editedAddress = $this->getAddressFromCommand($command); - $this->validateAddress($editedAddress); - - // The address is used by an order so it is not edited directly, instead a copy is created and - if ($editedAddress->isUsed()) { - // Get a copy of current address - $copyAddress = new Address($editedAddress->id); - - // Reset ID to force recreating a new address - $editedAddress->id = $editedAddress->id_address = null; - - // We consider this address as necessarily NOT deleted, in case you were editing a deleted address - // from an order then the newly edited address should not be deleted, so that you can select it - $editedAddress->deleted = 0; - if (false === $editedAddress->save()) { - throw new CannotAddAddressException(sprintf('Failed to add new address "%s"', $command->getAddress())); - } - // Soft delete the former address - if (false === $copyAddress->delete()) { - throw new DeleteAddressException(sprintf('Cannot delete Address object with id "%s".', $copyAddress->id), DeleteAddressException::FAILED_DELETE); - } - } elseif (false === $editedAddress->update()) { - throw new CannotUpdateAddressException(sprintf('Failed to update address "%s"', $editedAddress->id)); - } - } catch (PrestaShopException $e) { - throw new AddressException(sprintf('An error occurred when updating address "%s"', $command->getAddressId()->getValue())); - } - - return new AddressId((int) $editedAddress->id); - } - - /** - * @param EditCustomerAddressCommand $command - * - * @return Address - * - * @throws AddressException - * @throws AddressNotFoundException - */ - private function getAddressFromCommand(EditCustomerAddressCommand $command): Address - { - $address = $this->getAddress($command->getAddressId()); - - if (null !== $command->getLastName()) { - $address->lastname = $command->getLastName(); - } - - if (null !== $command->getFirstName()) { - $address->firstname = $command->getFirstName(); - } - - if (null !== $command->getAddress()) { - $address->address1 = $command->getAddress(); - } - - if (null !== $command->getPostCode()) { - $address->postcode = $command->getPostCode(); - } - - if (null !== $command->getCountryId()) { - $address->id_country = $command->getCountryId()->getValue(); - } - - if (null !== $command->getStateId()) { - $address->id_state = $command->getStateId()->getValue(); - } elseif (null !== $command->getCountryId()) { - // If country was changed but not state we check if state value needs to be reset - $country = new Country($command->getCountryId()->getValue()); - if (!$country->contains_states) { - $address->id_state = 0; - } - } - - if (null !== $command->getCity()) { - $address->city = $command->getCity(); - } - - if (null !== $command->getAddressAlias()) { - $address->alias = $command->getAddressAlias(); - } - - if (null !== $command->getAddress2()) { - $address->address2 = $command->getAddress2(); - } - - if (null !== $command->getDni()) { - $address->dni = $command->getDni(); - } - - if (null !== $command->getCompany()) { - $address->company = $command->getCompany(); - } - - if (null !== $command->getVatNumber()) { - $address->vat_number = $command->getVatNumber(); - } - - if (null !== $command->getHomePhone()) { - $address->phone = $command->getHomePhone(); - } - - if (null !== $command->getMobilePhone()) { - $address->phone_mobile = $command->getMobilePhone(); - } - - if (null !== $command->getOther()) { - $address->other = $command->getOther(); - } - - return $address; - } -} diff --git a/src/Adapter/Address/CommandHandler/EditManufacturerAddressHandler.php b/src/Adapter/Address/CommandHandler/EditManufacturerAddressHandler.php deleted file mode 100644 index 919b553a..00000000 --- a/src/Adapter/Address/CommandHandler/EditManufacturerAddressHandler.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Address\CommandHandler; - -use Address; -use Country; -use PrestaShop\PrestaShop\Adapter\Address\AbstractAddressHandler; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\EditManufacturerAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler\EditManufacturerAddressHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressException; -use PrestaShopException; - -/** - * Handles command which edits manufacturer address - */ -final class EditManufacturerAddressHandler extends AbstractAddressHandler implements EditManufacturerAddressHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(EditManufacturerAddressCommand $command) - { - $addressId = $command->getAddressId(); - $address = $this->getAddress($addressId); - $this->populateAddressWithData($address, $command); - - try { - $this->validateAddress($address); - if (!$address->update()) { - throw new AddressException(sprintf('Cannot update address with id "%s"', $address->id)); - } - } catch (PrestaShopException $e) { - throw new AddressException(sprintf('Cannot update address with id "%s"', $address->id)); - } - } - - /** - * Populates Address object with given data - * - * @param $address - * @param EditManufacturerAddressCommand $command - */ - private function populateAddressWithData(Address $address, $command) - { - if (null !== $command->getManufacturerId()) { - $address->id_manufacturer = $command->getManufacturerId(); - } - if (null !== $command->getLastName()) { - $address->lastname = $command->getLastName(); - } - if (null !== $command->getFirstName()) { - $address->firstname = $command->getFirstName(); - } - if (null !== $command->getAddress()) { - $address->address1 = $command->getAddress(); - } - if (null !== $command->getAddress2()) { - $address->address2 = $command->getAddress2(); - } - if (null !== $command->getPostCode()) { - $address->postcode = $command->getPostCode(); - } - if (null !== $command->getCity()) { - $address->city = $command->getCity(); - } - if (null !== $command->getCountryId()) { - $address->id_country = $command->getCountryId(); - } - if (null !== $command->getStateId()) { - $address->id_state = $command->getStateId(); - } elseif (null !== $command->getCountryId()) { - // If country was changed but not state we check if state value needs to be reset - $country = new Country($command->getCountryId()); - if (!$country->contains_states) { - $address->id_state = 0; - } - } - if (null !== $command->getHomePhone()) { - $address->phone = $command->getHomePhone(); - } - if (null !== $command->getMobilePhone()) { - $address->phone_mobile = $command->getMobilePhone(); - } - if (null !== $command->getOther()) { - $address->other = $command->getOther(); - } - if (null !== $command->getDni()) { - $address->dni = $command->getDni(); - } - } -} diff --git a/src/Adapter/Address/CommandHandler/EditOrderAddressHandler.php b/src/Adapter/Address/CommandHandler/EditOrderAddressHandler.php deleted file mode 100644 index ad5e5248..00000000 --- a/src/Adapter/Address/CommandHandler/EditOrderAddressHandler.php +++ /dev/null @@ -1,188 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Address\CommandHandler; - -use Order; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\EditCustomerAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\EditOrderAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler\EditCustomerAddressHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler\EditOrderAddressHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\CannotUpdateOrderAddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; -use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\ChangeOrderDeliveryAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\ChangeOrderInvoiceAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\ChangeOrderDeliveryAddressHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\ChangeOrderInvoiceAddressHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\OrderAddressType; -use PrestaShop\PrestaShop\Core\Domain\State\Exception\StateConstraintException; -use PrestaShopException; - -/** - * EditOrderAddressCommandHandler manages an address update, it then updates order and cart - * relation to the newly created address. - */ -class EditOrderAddressHandler implements EditOrderAddressHandlerInterface -{ - /** - * @var EditCustomerAddressHandlerInterface - */ - private $addressHandler; - - /** - * @var ChangeOrderDeliveryAddressHandlerInterface - */ - private $deliveryAddressHandler; - - /** - * @var ChangeOrderInvoiceAddressHandlerInterface - */ - private $invoiceAddressHandler; - - /** - * @param EditCustomerAddressHandlerInterface $addressHandler - * @param ChangeOrderDeliveryAddressHandlerInterface $deliveryAddressHandler - * @param ChangeOrderInvoiceAddressHandlerInterface $invoiceAddressHandler - */ - public function __construct( - EditCustomerAddressHandlerInterface $addressHandler, - ChangeOrderDeliveryAddressHandlerInterface $deliveryAddressHandler, - ChangeOrderInvoiceAddressHandlerInterface $invoiceAddressHandler - ) { - $this->addressHandler = $addressHandler; - $this->deliveryAddressHandler = $deliveryAddressHandler; - $this->invoiceAddressHandler = $invoiceAddressHandler; - } - - /** - * {@inheritdoc} - * - * @throws AddressConstraintException - * @throws CannotUpdateOrderAddressException - * @throws CountryConstraintException - * @throws StateConstraintException - */ - public function handle(EditOrderAddressCommand $command): AddressId - { - try { - $addressCommand = $this->createEditAddressCommand($command); - /** @var AddressId $addressId */ - $addressId = $this->addressHandler->handle($addressCommand); - - switch ($command->getAddressType()) { - case OrderAddressType::DELIVERY_ADDRESS_TYPE: - $this->deliveryAddressHandler->handle(new ChangeOrderDeliveryAddressCommand( - $command->getOrderId()->getValue(), $addressId->getValue() - )); - break; - case OrderAddressType::INVOICE_ADDRESS_TYPE: - $this->invoiceAddressHandler->handle(new ChangeOrderInvoiceAddressCommand( - $command->getOrderId()->getValue(), $addressId->getValue() - )); - break; - } - } catch (PrestaShopException $e) { - throw new CannotUpdateOrderAddressException(sprintf('An error occurred when updating address for order "%s"', $command->getOrderId()->getValue())); - } - - return $addressId; - } - - /** - * @param EditOrderAddressCommand $orderCommand - * - * @return EditCustomerAddressCommand - * - * @throws AddressConstraintException - * @throws CountryConstraintException - * @throws StateConstraintException - * @throws PrestaShopException - */ - private function createEditAddressCommand(EditOrderAddressCommand $orderCommand): EditCustomerAddressCommand - { - $order = new Order($orderCommand->getOrderId()->getValue()); - $addressId = null; - switch ($orderCommand->getAddressType()) { - case OrderAddressType::DELIVERY_ADDRESS_TYPE: - $addressId = (int) $order->id_address_delivery; - break; - case OrderAddressType::INVOICE_ADDRESS_TYPE: - $addressId = (int) $order->id_address_invoice; - break; - } - $addressCommand = new EditCustomerAddressCommand($addressId); - if (null !== $orderCommand->getAddressAlias()) { - $addressCommand->setAddressAlias($orderCommand->getAddressAlias()); - } - if (null !== $orderCommand->getFirstName()) { - $addressCommand->setFirstName($orderCommand->getFirstName()); - } - if (null !== $orderCommand->getLastName()) { - $addressCommand->setLastName($orderCommand->getLastName()); - } - if (null !== $orderCommand->getAddress()) { - $addressCommand->setAddress($orderCommand->getAddress()); - } - if (null !== $orderCommand->getCity()) { - $addressCommand->setCity($orderCommand->getCity()); - } - if (null !== $orderCommand->getPostCode()) { - $addressCommand->setPostCode($orderCommand->getPostCode()); - } - if (null !== $orderCommand->getCountryId()) { - $addressCommand->setCountryId($orderCommand->getCountryId()->getValue()); - } - if (null !== $orderCommand->getDni()) { - $addressCommand->setDni($orderCommand->getDni()); - } - if (null !== $orderCommand->getCompany()) { - $addressCommand->setCompany($orderCommand->getCompany()); - } - if (null !== $orderCommand->getVatNumber()) { - $addressCommand->setVatNumber($orderCommand->getVatNumber()); - } - if (null !== $orderCommand->getAddress2()) { - $addressCommand->setAddress2($orderCommand->getAddress2()); - } - if (null !== $orderCommand->getStateId()) { - $addressCommand->setStateId($orderCommand->getStateId()->getValue()); - } - if (null !== $orderCommand->getHomePhone()) { - $addressCommand->setHomePhone($orderCommand->getHomePhone()); - } - if (null !== $orderCommand->getMobilePhone()) { - $addressCommand->setMobilePhone($orderCommand->getMobilePhone()); - } - if (null !== $orderCommand->getOther()) { - $addressCommand->setOther($orderCommand->getOther()); - } - - return $addressCommand; - } -} diff --git a/src/Adapter/Address/CommandHandler/SetRequiredFieldsForAddressHandler.php b/src/Adapter/Address/CommandHandler/SetRequiredFieldsForAddressHandler.php deleted file mode 100644 index 5de8e368..00000000 --- a/src/Adapter/Address/CommandHandler/SetRequiredFieldsForAddressHandler.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Address\CommandHandler; - -use CustomerAddress; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\SetRequiredFieldsForAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler\SetRequiredFieldsForAddressHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\CannotSetRequiredFieldsForAddressException; -use PrestaShopDatabaseException; - -/** - * Handles command which sets required fields for address. - * - * @internal - */ -final class SetRequiredFieldsForAddressHandler implements SetRequiredFieldsForAddressHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CannotSetRequiredFieldsForAddressException - */ - public function handle(SetRequiredFieldsForAddressCommand $command) - { - $address = new CustomerAddress(); - - try { - if ($address->addFieldsRequiredDatabase($command->getRequiredFields())) { - return; - } - } catch (PrestaShopDatabaseException $e) { - } - - throw new CannotSetRequiredFieldsForAddressException(sprintf('Cannot set "%s" required fields for customer', implode(',', $command->getRequiredFields()))); - } -} diff --git a/src/Adapter/Address/QueryHandler/GetCustomerAddressForEditingHandler.php b/src/Adapter/Address/QueryHandler/GetCustomerAddressForEditingHandler.php deleted file mode 100644 index 2d142118..00000000 --- a/src/Adapter/Address/QueryHandler/GetCustomerAddressForEditingHandler.php +++ /dev/null @@ -1,100 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Address\QueryHandler; - -use Customer; -use PrestaShop\PrestaShop\Adapter\Address\AbstractCustomerAddressHandler; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Address\Query\GetCustomerAddressForEditing; -use PrestaShop\PrestaShop\Core\Domain\Address\QueryHandler\GetCustomerAddressForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\QueryResult\EditableCustomerAddress; -use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Country\ValueObject\CountryId; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; -use PrestaShop\PrestaShop\Core\Domain\State\Exception\StateConstraintException; -use PrestaShop\PrestaShop\Core\Domain\State\ValueObject\StateId; -use PrestaShopException; - -/** - * Handles query which gets customer address for editing - */ -final class GetCustomerAddressForEditingHandler extends AbstractCustomerAddressHandler implements GetCustomerAddressForEditingHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws AddressException - * @throws AddressNotFoundException - * @throws CustomerException - * @throws CustomerNotFoundException - * @throws CountryConstraintException - * @throws StateConstraintException - */ - public function handle(GetCustomerAddressForEditing $query): EditableCustomerAddress - { - $addressId = $query->getAddressId(); - $address = $this->getAddress($addressId); - - try { - $customerId = new CustomerId((int) $address->id_customer); - $customer = new Customer($customerId->getValue()); - } catch (PrestaShopException $e) { - throw new CustomerException('Failed to get customer', 0, $e); - } - - if ($customer->id !== $customerId->getValue()) { - throw new CustomerNotFoundException($customerId, sprintf('Customer with id "%s" was not found.', $customerId->getValue())); - } - - $editableCustomerAddress = new EditableCustomerAddress( - $addressId, - $customerId, - $customer->email, - $address->alias, - $address->firstname, - $address->lastname, - $address->address1, - $address->city, - new CountryId((int) $address->id_country), - $address->postcode, - $address->dni, - $address->company, - $address->vat_number, - $address->address2, - new StateId($address->id_state), - $address->phone, - $address->phone_mobile, - $address->other, - $this->getRequiredFields() - ); - - return $editableCustomerAddress; - } -} diff --git a/src/Adapter/Address/QueryHandler/GetManufacturerAddressForEditingHandler.php b/src/Adapter/Address/QueryHandler/GetManufacturerAddressForEditingHandler.php deleted file mode 100644 index c0747f8e..00000000 --- a/src/Adapter/Address/QueryHandler/GetManufacturerAddressForEditingHandler.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Address\QueryHandler; - -use PrestaShop\PrestaShop\Adapter\Address\AbstractAddressHandler; -use PrestaShop\PrestaShop\Core\Domain\Address\Query\GetManufacturerAddressForEditing; -use PrestaShop\PrestaShop\Core\Domain\Address\QueryHandler\GetManufacturerAddressForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\QueryResult\EditableManufacturerAddress; - -/** - * Handles query which gets manufacturer address for editing - */ -final class GetManufacturerAddressForEditingHandler extends AbstractAddressHandler implements GetManufacturerAddressForEditingHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GetManufacturerAddressForEditing $query) - { - $addressId = $query->getAddressId(); - - $address = $this->getAddress($addressId); - - return new EditableManufacturerAddress( - $addressId, - $address->lastname, - $address->firstname, - $address->address1, - $address->city, - (int) $address->id_manufacturer, - (int) $address->id_country, - $address->address2, - $address->postcode, - (int) $address->id_state, - $address->phone, - $address->phone_mobile, - $address->other, - $address->dni - ); - } -} diff --git a/src/Adapter/Address/QueryHandler/GetRequiredFieldsForAddressHandler.php b/src/Adapter/Address/QueryHandler/GetRequiredFieldsForAddressHandler.php deleted file mode 100644 index 4cdb5083..00000000 --- a/src/Adapter/Address/QueryHandler/GetRequiredFieldsForAddressHandler.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Address\QueryHandler; - -use PrestaShop\PrestaShop\Adapter\Address\AbstractCustomerAddressHandler; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\Query\GetRequiredFieldsForAddress; -use PrestaShop\PrestaShop\Core\Domain\Address\QueryHandler\GetRequiredFieldsForAddressHandlerInterface; - -/** - * Handles query which gets required fields for address - * - * @internal - */ -final class GetRequiredFieldsForAddressHandler extends AbstractCustomerAddressHandler implements GetRequiredFieldsForAddressHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws AddressException - */ - public function handle(GetRequiredFieldsForAddress $query): array - { - return $this->getRequiredFields(); - } -} diff --git a/src/Adapter/AddressFactory.php b/src/Adapter/AddressFactory.php deleted file mode 100644 index 884d66cf..00000000 --- a/src/Adapter/AddressFactory.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use Address; - -/** - * Class responsible of creation of Address ObjectModel. - */ -class AddressFactory -{ - /** - * Initialize an address corresponding to the specified id address or if empty to the - * default shop configuration. - * - * @param int|null $id_address - * @param bool $with_geoloc - * - * @return Address - */ - public function findOrCreate($id_address = null, $with_geoloc = false) - { - $func_args = func_get_args(); - - return call_user_func_array(['\\Address', 'initialize'], $func_args); - } - - /** - * Check if an address exists depending on given $id_address. - * - * @param $id_address - * - * @return bool - */ - public function addressExists($id_address) - { - return Address::addressExists($id_address); - } -} diff --git a/src/Adapter/Admin/AbstractAdminQueryBuilder.php b/src/Adapter/Admin/AbstractAdminQueryBuilder.php deleted file mode 100644 index 96127b13..00000000 --- a/src/Adapter/Admin/AbstractAdminQueryBuilder.php +++ /dev/null @@ -1,221 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Admin; - -use PrestaShop\PrestaShop\Adapter\Validate; -use Symfony\Component\Process\Exception\LogicException; - -/** - * Base class for data provider, to give common Adapter functions. - * - * Contains methods to compile SQL from parseable arrays of select, tables, joins, where, etc... - */ -abstract class AbstractAdminQueryBuilder -{ - const FILTERING_LIKE_BOTH = 'LIKE \'%%%s%%\''; - const FILTERING_LIKE_LEFT = 'LIKE \'%%%s\''; - const FILTERING_LIKE_RIGHT = 'LIKE \'%s%%\''; - const FILTERING_EQUAL_NUMERIC = '= %s'; - const FILTERING_EQUAL_STRING = '= \'%s\''; - - /** - * @var string|null - */ - private $lastCompiledSql = null; - - /** - * @param array $whereArray - * - * @return mixed|string - */ - private function compileSqlWhere(array $whereArray) - { - $operator = 'AND'; - $s = []; - while ($item = array_shift($whereArray)) { - if ($item == 'OR') { - $operator = 'OR'; - } elseif ($item == 'AND') { - $operator = 'AND'; - } else { - $s[] = (is_array($item) ? $this->compileSqlWhere($item) : $item); - } - } - if (count($s) == 1) { - return $s[0]; - } - - return '(' . implode(' ' . $operator . ' ', $s) . ')'; - } - - /** - * Compiles a SQL query (SELECT), from a group of associative arrays. - * - * @see \PrestaShop\PrestaShop\Adapter\Product\AdminProductDataProvider::getCatalogProductList() for an example. - * - * Format example for $table: - * $table = array( - * 'p' => 'product', // First table: a simple name - * 'pl' => array( // Next: arrays to set join properly - * 'table' => 'product_lang', - * 'join' => 'LEFT JOIN', - * 'on' => 'pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.$idLang.' AND pl.`id_shop` = '.$idShop - * ), - * 'sav' => array( - * 'table' => 'stock_available', - * 'join' => 'LEFT JOIN', - * 'on' => 'sav.`id_product` = p.`id_product` AND sav.`id_product_attribute` = 0 AND sav.id_shop_group = 1 AND sav.id_shop = 0' - * ), - * ... - * ); - * - * Format example for $select: - * $select = array( - * 'id_product' => array('table' => 'p', 'field' => 'id_product', 'filtering' => self::FILTERING_EQUAL_NUMERIC), - * 'reference' => array('table' => 'p', 'field' => 'reference', 'filtering' => self::FILTERING_LIKE_BOTH), - * ... - * ); - * - * Format example for $where: - * $where = array( - * 'AND', // optional if AND, mandatory if OR. - * 1, // First condition: let 1 here if there is no condition, then "WHERE 1;" will work better than "WHERE ;" - * array('OR', '2', '3'), - * array( - * 'AND', - * array('OR', '4', '5'), - * array('6', '7') - * ) - * ); - * In the WHERE, it's up to you to build each condition string. You can use the 'filtering' data in the $select array to help you: - * $where[] = $select[$field]['table'].'.`'.$select[$field]['field'].'` '.sprintf($select[$field]['filtering'], $filterValue); - * - * Format example for $order: - * $order = array('name ASC', 'id_product DESC'); - * - * @param array[array[mixed]] $select - * @param array[mixed] $table - * @param array[mixed] $where - * @param array[string] $groupBy - * @param array[string] $order - * @param string $limit - * - * @throws LogicException if SQL elements cannot be joined - * - * @return string the SQL query ready to be executed - */ - protected function compileSqlQuery(array $select, array $table, array $where = [], array $groupBy = [], array $order = [], $limit = null) - { - $sql = []; - - // SELECT - $s = []; - foreach ($select as $alias => $field) { - $a = is_string($alias) ? ' AS `' . $alias . '`' : ''; - if (is_array($field)) { - if (isset($field['table'])) { - $s[] = ' ' . $field['table'] . '.`' . $field['field'] . '` ' . $a; - } elseif (isset($field['select'])) { - $s[] = ' ' . $field['select'] . $a; - } - } else { - $s[] = ' ' . $field . $a; - } - } - if (count($s) === 0) { - throw new LogicException('Compile SQL failed: No field to SELECT!'); - } - $sql[] = 'SELECT SQL_CALC_FOUND_ROWS' . implode(',' . PHP_EOL, $s); - - // FROM / JOIN - $s = []; - foreach ($table as $alias => $join) { - if (!is_array($join)) { - if (count($s) > 0) { - throw new LogicException('Compile SQL failed: cannot join the table ' . $join . ' into SQL query without JOIN sepcs.'); - } - $s[0] = ' `' . _DB_PREFIX_ . $join . '` ' . $alias; - } else { - if (count($s) === 0) { - throw new LogicException('Compile SQL failed: cannot join the table alias ' . $alias . ' into SQL query before to insert initial table.'); - } - $s[] = ' ' . $join['join'] . ' `' . _DB_PREFIX_ . $join['table'] . '` ' . $alias . ((isset($join['on'])) ? ' ON (' . $join['on'] . ')' : ''); - } - } - if (count($s) === 0) { - throw new LogicException('Compile SQL failed: No table to insert into FROM!'); - } - $sql[] = 'FROM ' . implode(' ' . PHP_EOL, $s); - - // WHERE (recursive call) - if (count($where)) { - $s = $this->compileSqlWhere($where); - if (strlen($s) > 0) { - $sql[] = 'WHERE ' . $s . PHP_EOL; - } - } - - // GROUP BY - if (!empty($groupBy)) { - $sql[] = 'GROUP BY ' . implode(', ', array_map('pSQL', $groupBy)) . PHP_EOL; - } - - // ORDER - if (count($order) > 0) { - $goodOrder = []; - foreach ($order as $o) { - $value = explode(' ', $o); - if (!empty($value) && 2 === count($value) && Validate::isOrderBy($value[0]) && Validate::isOrderWay($value[1])) { - $goodOrder[] = ' `' . bqSQL($value[0]) . '` ' . $value[1]; - } - } - - if (count($goodOrder) > 0) { - $sql[] = 'ORDER BY ' . implode(', ', $goodOrder) . PHP_EOL; - } - } - - // LIMIT - if ($limit) { - $sql[] = 'LIMIT ' . $limit . PHP_EOL; - } - - $this->lastCompiledSql = implode(' ' . PHP_EOL, $sql) . ';'; - - return $this->lastCompiledSql; - } - - /** - * Returns the last SQL query that was compiled on this Provider. - * - * @return string The last SQL query that was compiled with $this->compileSqlQuery() - */ - public function getLastCompiledSql() - { - return $this->lastCompiledSql; - } -} diff --git a/src/Adapter/Admin/LegacyBlockHelperSubscriber.php b/src/Adapter/Admin/LegacyBlockHelperSubscriber.php deleted file mode 100644 index 76ebbf55..00000000 --- a/src/Adapter/Admin/LegacyBlockHelperSubscriber.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Admin; - -use PrestaShopBundle\Service\Hook\RenderingHookEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * Adds listeners to renderhook Twig function, to let adding legacy helpers like Kpi, etc... - */ -class LegacyBlockHelperSubscriber implements EventSubscriberInterface -{ - /** - * Returns an array of event names this subscriber wants to listen to. - * - * @return array The listeners array - */ - public static function getSubscribedEvents() - { - return [ - 'legacy_block_kpi' => ['renderKpi', 0], - ]; - } - - /** - * Renders a Kpi block for a given legacy controller name. - * - * @param RenderingHookEvent $event - * - * @throws \Exception - */ - public function renderKpi(RenderingHookEvent $event) - { - if (!array_key_exists('kpi_controller', $event->getHookParameters())) { - throw new \Exception('The legacy_kpi hook need a kpi_controller parameter (legacy controller full class name).'); - } - - $controller = $event->getHookParameters()['kpi_controller']; - $controller = new $controller('new-theme'); - $renderKpis = $controller->renderKpis() !== null ? $controller->renderKpis() : []; - - $event->setContent($renderKpis); - } -} diff --git a/src/Adapter/Admin/NotificationsConfiguration.php b/src/Adapter/Admin/NotificationsConfiguration.php deleted file mode 100644 index 5f741462..00000000 --- a/src/Adapter/Admin/NotificationsConfiguration.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Admin; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * Manages the configuration data about notifications options. - */ -class NotificationsConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'show_notifs_new_orders' => $this->configuration->getBoolean('PS_SHOW_NEW_ORDERS'), - 'show_notifs_new_customers' => $this->configuration->getBoolean('PS_SHOW_NEW_CUSTOMERS'), - 'show_notifs_new_messages' => $this->configuration->getBoolean('PS_SHOW_NEW_MESSAGES'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - $errors = []; - - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_SHOW_NEW_ORDERS', (bool) $configuration['show_notifs_new_orders']); - $this->configuration->set('PS_SHOW_NEW_CUSTOMERS', (bool) $configuration['show_notifs_new_customers']); - $this->configuration->set('PS_SHOW_NEW_MESSAGES', (bool) $configuration['show_notifs_new_messages']); - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['show_notifs_new_orders'], - $configuration['show_notifs_new_customers'], - $configuration['show_notifs_new_messages'] - ); - } -} diff --git a/src/Adapter/Admin/PagePreference.php b/src/Adapter/Admin/PagePreference.php deleted file mode 100644 index 6aa26801..00000000 --- a/src/Adapter/Admin/PagePreference.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Admin; - -use AppKernel; -use Db; -use PrestaShopBundle\Service\TransitionalBehavior\AdminPagePreferenceInterface; -use Symfony\Component\HttpFoundation\Session\SessionInterface; -use Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage; - -/** - * Adapter to know which page's version to display. - * - * This implementation gives methods to use to take decision: - * - if we should display the new refactored page, or the old legacy one. - * - if we should display the switch on the admin layout to change this setting. - * - * Data is stored in the cookie, as legacy does. - */ -class PagePreference implements AdminPagePreferenceInterface -{ - /** - * @var SessionInterface - */ - private $session; - - public function __construct(SessionInterface $session) - { - if ($session->isStarted()) { - $this->session = $session; - } else { - $sessionClass = get_class($session); - $this->session = new $sessionClass(new PhpBridgeSessionStorage()); - } - } - - /** - * {@inheritdoc} - */ - public function getTemporaryShouldUseLegacyPage($page) - { - if (!$page) { - throw new \InvalidParameterException('$page parameter missing'); - } - - return $this->session->has('should_use_legacy_page_for_' . $page) && $this->session->get('should_use_legacy_page_for_' . $page, 0) == 1; - } - - /** - * {@inheritdoc} - */ - public function setTemporaryShouldUseLegacyPage($page, $useLegacy) - { - if (!$page) { - throw new \InvalidParameterException('$page parameter missing'); - } - - if ((bool) $useLegacy) { - $this->session->set('should_use_legacy_page_for_' . $page, 1); - } else { - $this->session->remove('should_use_legacy_page_for_' . $page); - } - } - - /** - * {@inheritdoc} - */ - public function getTemporaryShouldAllowUseLegacyPage($page = null) - { - // Dev mode: always shown - if (_PS_MODE_DEV_) { - return true; - } - - $version = Db::getInstance()->getValue('SELECT `value` FROM `' . _DB_PREFIX_ . 'configuration` WHERE `name` = "PS_INSTALL_VERSION"'); - if (!$version) { - return false; - } - $installVersion = explode('.', $version); - $currentVersion = explode('.', AppKernel::VERSION); - - // Prod mode, depends on the page - switch ($page) { - case 'product': - // never show it for Product page in production mode. - return false; - default: - // show only for 1.7.x - if ($currentVersion[0] != '1' || $currentVersion[1] != '7') { - return false; - } - // show only if upgrade from older version than current one - if ($installVersion[0] >= $currentVersion[0] || $installVersion[1] >= $currentVersion[1]) { - return false; - } - } - - return true; - } -} diff --git a/src/Adapter/Admin/UrlGenerator.php b/src/Adapter/Admin/UrlGenerator.php deleted file mode 100644 index f1808aae..00000000 --- a/src/Adapter/Admin/UrlGenerator.php +++ /dev/null @@ -1,130 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Admin; - -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use ReflectionClass; -use Symfony\Component\Process\Exception\LogicException; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Routing\RequestContext; -use Symfony\Component\Routing\Router; - -/** - * This UrlGeneratorInterface implementation (in a Sf service) will provides Legacy URLs. - * - * To be used by Symfony controllers, to generate a link to a Legacy page. - * Call an instance of it through the Symfony container: - * $container->get('prestashop.core.admin.url_generator_legacy'); - * Or via the UrlGeneratorFactory (as Sf service): - * $container->get('prestashop.core.admin.url_generator_factory')->forLegacy(); - */ -class UrlGenerator implements UrlGeneratorInterface -{ - /** - * @var LegacyContext - */ - private $legacyContext; - - /** - * @var Router - */ - private $router; - - /** - * Constructor. - * - * @param LegacyContext $legacyContext - * @param Router - */ - public function __construct(LegacyContext $legacyContext, Router $router) - { - $this->legacyContext = $legacyContext; - $this->router = $router; - } - - /** - * {@inheritdoc} - */ - public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) - { - // By default, consider given parameters in legacy format (no mapping if route not found). - $legacyController = $name; - $legacyParameters = $parameters; - - // resolve route & legacy mapping - list($legacyController, $legacyParameters) = $this->getLegacyOptions($name, $parameters); - - return $this->legacyContext->getAdminLink($legacyController, true, $legacyParameters); - } - - /** - * Try to get controller & parameters with mapping options. - * - * If failed to find options, then return the input values. - * - * @param string $routeName - * @param string[] $parameters The route parameters to convert - * - * @return array[] An array with: the legacy controller name, then the parameters array - */ - final public function getLegacyOptions($routeName, $parameters = []) - { - $legacyController = $routeName; - $legacyParameters = $parameters; - - $route = $this->router->getRouteCollection()->get($routeName); - if ($route) { - if ($route->hasDefault('_legacy_controller')) { - $legacyController = $route->getDefault('_legacy_controller'); - if ($route->hasDefault('_legacy_param_mapper_class') && $route->hasDefault('_legacy_param_mapper_method')) { - $class = $route->getDefault('_legacy_param_mapper_class'); - $method = $route->getDefault('_legacy_param_mapper_method'); - $method = (new ReflectionClass('\\' . $class))->getMethod($method); - $legacyParameters = $method->invoke(($method->isStatic()) ? null : $method->getDeclaringClass()->newInstance(), $parameters); - } - } - } - - return [$legacyController, $legacyParameters]; - } - - /** - * {@inheritdoc} - */ - public function setContext(RequestContext $context) - { - throw new LogicException('Cannot use this UrlGeneratorInterface implementation with a Symfony context. Please call AdminUrlGeneratorFactory::forLegacy() to reach the right instance.'); - } - - /** - * {@inheritdoc} - */ - public function getContext() - { - throw new LogicException('Cannot use this UrlGeneratorInterface implementation with a Symfony context. Please call AdminUrlGeneratorFactory::forLegacy() to reach the right instance.'); - } -} diff --git a/src/Adapter/Assets/AssetUrlGeneratorTrait.php b/src/Adapter/Assets/AssetUrlGeneratorTrait.php deleted file mode 100644 index e74dbff7..00000000 --- a/src/Adapter/Assets/AssetUrlGeneratorTrait.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -namespace PrestaShop\PrestaShop\Adapter\Assets; - -use Tools as ToolsLegacy; - -trait AssetUrlGeneratorTrait -{ - /** - * @var string - */ - protected $fqdn; - - /** - * @param string $fullPath - * - * @return string - */ - protected function getUriFromPath($fullPath) - { - return str_replace($this->configuration->get('_PS_ROOT_DIR_'), rtrim($this->configuration->get('__PS_BASE_URI__'), '/'), $fullPath); - } - - /** - * @param string $fullUri - * - * @return string - */ - protected function getPathFromUri($fullUri) - { - if ('' !== ($trimmedUri = rtrim($this->configuration->get('__PS_BASE_URI__'), '/'))) { - return $this->configuration->get('_PS_ROOT_DIR_') . preg_replace('#\\' . $trimmedUri . '#', '', $fullUri, 1); - } - - return $this->configuration->get('_PS_ROOT_DIR_') . $fullUri; - } - - /** - * @return string - */ - protected function getFQDN() - { - if (null === $this->fqdn) { - if ($this->configuration->get('PS_SSL_ENABLED') && ToolsLegacy::usingSecureMode()) { - $this->fqdn = $this->configuration->get('_PS_BASE_URL_SSL_'); - } else { - $this->fqdn = $this->configuration->get('_PS_BASE_URL_'); - } - } - - return $this->fqdn; - } -} diff --git a/src/Adapter/Attachment/AbstractAttachmentHandler.php b/src/Adapter/Attachment/AbstractAttachmentHandler.php deleted file mode 100644 index 026432a7..00000000 --- a/src/Adapter/Attachment/AbstractAttachmentHandler.php +++ /dev/null @@ -1,150 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Attachment; - -use Attachment; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CleanHtml; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\DefaultLanguage; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\DeleteAttachmentException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\ValueObject\AttachmentId; -use PrestaShopException; -use Symfony\Component\Validator\Validator\ValidatorInterface; - -/** - * Abstract attachment handler - */ -abstract class AbstractAttachmentHandler -{ - /** - * @var ValidatorInterface - */ - private $validator; - - /** - * @param ValidatorInterface $validator - */ - public function __construct(ValidatorInterface $validator) - { - $this->validator = $validator; - } - - /** - * @param array $localizedTexts - * - * @throws AttachmentConstraintException - */ - protected function assertHasDefaultLanguage(array $localizedTexts) - { - $errors = $this->validator->validate($localizedTexts, new DefaultLanguage()); - - if (0 !== count($errors)) { - throw new AttachmentConstraintException('Missing name in default language', AttachmentConstraintException::MISSING_NAME_IN_DEFAULT_LANGUAGE); - } - } - - /** - * @param array $localizedDescription - * - * @throws AttachmentConstraintException - */ - protected function assertDescriptionContainsCleanHtml(array $localizedDescription) - { - foreach ($localizedDescription as $description) { - $errors = $this->validator->validate($description, new CleanHtml()); - - if (0 !== count($errors)) { - throw new AttachmentConstraintException(sprintf('Given description "%s" contains javascript events or script tags', $description), AttachmentConstraintException::INVALID_DESCRIPTION); - } - } - } - - /** - * @return string - */ - protected function getUniqueFileName(): string - { - $uniqueFileName = sha1(uniqid()); - - return $uniqueFileName; - } - - /** - * @param Attachment $attachment - * - * @throws AttachmentConstraintException - * @throws PrestaShopException - */ - protected function assertValidFields(Attachment $attachment) - { - if (!$attachment->validateFields(false) && !$attachment->validateFieldsLang(false)) { - throw new AttachmentConstraintException('Attachment contains invalid field values', AttachmentConstraintException::INVALID_FIELDS); - } - } - - /** - * @param AttachmentId $attachmentId - * - * @return Attachment - * - * @throws AttachmentNotFoundException - */ - protected function getAttachment(AttachmentId $attachmentId): Attachment - { - $attachmentIdValue = $attachmentId->getValue(); - try { - $attachment = new Attachment($attachmentIdValue); - } catch (PrestaShopException $e) { - throw new AttachmentNotFoundException(sprintf('Attachment with id "%s" was not found.', $attachmentId->getValue())); - } - - if ($attachment->id !== $attachmentId->getValue()) { - throw new AttachmentNotFoundException(sprintf('Attachment with id "%s" was not found.', $attachmentId->getValue())); - } - - return $attachment; - } - - /** - * Deletes legacy Attachment - * - * @param Attachment $attachment - * - * @return bool - * - * @throws DeleteAttachmentException - */ - protected function deleteAttachment(Attachment $attachment): bool - { - try { - return $attachment->delete(); - } catch (PrestaShopException $e) { - throw new DeleteAttachmentException(sprintf('An error occurred when deleting Attachment object with id "%s".', $attachment->id)); - } - } -} diff --git a/src/Adapter/Attachment/CommandHandler/AddAttachmentHandler.php b/src/Adapter/Attachment/CommandHandler/AddAttachmentHandler.php deleted file mode 100644 index 7224549b..00000000 --- a/src/Adapter/Attachment/CommandHandler/AddAttachmentHandler.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Attachment\CommandHandler; - -use Attachment; -use PrestaShop\PrestaShop\Adapter\Attachment\AbstractAttachmentHandler; -use PrestaShop\PrestaShop\Adapter\File\Uploader\AttachmentFileUploader; -use PrestaShop\PrestaShop\Core\Domain\Attachment\AttachmentFileUploaderInterface; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Command\AddAttachmentCommand; -use PrestaShop\PrestaShop\Core\Domain\Attachment\CommandHandler\AddAttachmentHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\CannotAddAttachmentException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\EmptyFileException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\ValueObject\AttachmentId; -use PrestaShopException; -use Symfony\Component\Validator\Validator\ValidatorInterface; - -/** - * Handles attachment creation and file uploading procedures - */ -final class AddAttachmentHandler extends AbstractAttachmentHandler implements AddAttachmentHandlerInterface -{ - /** - * @var AttachmentFileUploader - */ - protected $fileUploader; - - /** - * @param ValidatorInterface $validator - * @param AttachmentFileUploaderInterface $fileUploader - */ - public function __construct(ValidatorInterface $validator, AttachmentFileUploaderInterface $fileUploader) - { - parent::__construct($validator); - - $this->fileUploader = $fileUploader; - } - - /** - * {@inheritdoc} - * - * @throws AttachmentConstraintException - * @throws AttachmentException - * @throws AttachmentNotFoundException - */ - public function handle(AddAttachmentCommand $command): AttachmentId - { - try { - if ($command->getFilePathName() === null) { - throw new EmptyFileException('No file found to be uploaded'); - } - - $attachment = new Attachment(); - - $this->assertDescriptionContainsCleanHtml($command->getLocalizedDescriptions()); - $this->assertHasDefaultLanguage($command->getLocalizedNames()); - - $uniqueFileName = $this->getUniqueFileName(); - - $attachment->description = $command->getLocalizedDescriptions(); - $attachment->name = $command->getLocalizedNames(); - $attachment->file_name = $command->getOriginalName(); - $attachment->file = $uniqueFileName; - $attachment->mime = $command->getMimeType(); - - $this->assertValidFields($attachment); - - $this->fileUploader->upload($command->getFilePathName(), $uniqueFileName, $command->getFileSize()); - - if (false === $attachment->add()) { - throw new CannotAddAttachmentException('Failed to add attachment'); - } - } catch (PrestaShopException $e) { - throw new AttachmentException('An unexpected error occurred when adding attachment', 0, $e); - } - - return new AttachmentId($attachment->id); - } -} diff --git a/src/Adapter/Attachment/CommandHandler/BulkDeleteAttachmentsHandler.php b/src/Adapter/Attachment/CommandHandler/BulkDeleteAttachmentsHandler.php deleted file mode 100644 index e6388050..00000000 --- a/src/Adapter/Attachment/CommandHandler/BulkDeleteAttachmentsHandler.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Attachment\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Attachment\AbstractAttachmentHandler; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Command\BulkDeleteAttachmentsCommand; -use PrestaShop\PrestaShop\Core\Domain\Attachment\CommandHandler\BulkDeleteAttachmentsHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\BulkDeleteAttachmentsException; - -/** - * Bulk delete attachments handler - */ -final class BulkDeleteAttachmentsHandler extends AbstractAttachmentHandler implements BulkDeleteAttachmentsHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws BulkDeleteAttachmentsException - */ - public function handle(BulkDeleteAttachmentsCommand $command) - { - $errors = []; - - foreach ($command->getAttachmentIds() as $attachmentId) { - try { - $attachment = $this->getAttachment($attachmentId); - - if (!$this->deleteAttachment($attachment)) { - $errors[] = $attachment->id; - } - } catch (AttachmentException $e) { - $errors[] = $attachmentId->getValue(); - } - } - - if (!empty($errors)) { - throw new BulkDeleteAttachmentsException($errors, 'Failed to delete all of selected attachments'); - } - } -} diff --git a/src/Adapter/Attachment/CommandHandler/DeleteAttachmentHandler.php b/src/Adapter/Attachment/CommandHandler/DeleteAttachmentHandler.php deleted file mode 100644 index 09730822..00000000 --- a/src/Adapter/Attachment/CommandHandler/DeleteAttachmentHandler.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Attachment\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Attachment\AbstractAttachmentHandler; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Command\DeleteAttachmentCommand; -use PrestaShop\PrestaShop\Core\Domain\Attachment\CommandHandler\DeleteAttachmentHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\DeleteAttachmentException; - -/** - * Delete attachment handler - */ -final class DeleteAttachmentHandler extends AbstractAttachmentHandler implements DeleteAttachmentHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws DeleteAttachmentException - * @throws AttachmentNotFoundException - */ - public function handle(DeleteAttachmentCommand $command) - { - $attachment = $this->getAttachment($command->getAttachmentId()); - - if (!$this->deleteAttachment($attachment)) { - throw new DeleteAttachmentException(sprintf('Cannot delete Attachment object with id "%s".', $attachment->id)); - } - } -} diff --git a/src/Adapter/Attachment/CommandHandler/EditAttachmentHandler.php b/src/Adapter/Attachment/CommandHandler/EditAttachmentHandler.php deleted file mode 100644 index f24b0133..00000000 --- a/src/Adapter/Attachment/CommandHandler/EditAttachmentHandler.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Attachment\CommandHandler; - -use Attachment; -use PrestaShop\PrestaShop\Adapter\Attachment\AbstractAttachmentHandler; -use PrestaShop\PrestaShop\Adapter\File\Uploader\AttachmentFileUploader; -use PrestaShop\PrestaShop\Core\Domain\Attachment\AttachmentFileUploaderInterface; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Command\EditAttachmentCommand; -use PrestaShop\PrestaShop\Core\Domain\Attachment\CommandHandler\EditAttachmentHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\CannotUpdateAttachmentException; -use PrestaShopException; -use Symfony\Component\Validator\Validator\ValidatorInterface; - -/** - * Handles editing of attachment and file uploading procedures - */ -final class EditAttachmentHandler extends AbstractAttachmentHandler implements EditAttachmentHandlerInterface -{ - /** - * @var AttachmentFileUploader - */ - protected $fileUploader; - - /** - * @param ValidatorInterface $validator - * @param AttachmentFileUploaderInterface $fileUploader - */ - public function __construct(ValidatorInterface $validator, AttachmentFileUploaderInterface $fileUploader) - { - parent::__construct($validator); - - $this->fileUploader = $fileUploader; - } - - /** - * {@inheritdoc} - * - * @throws AttachmentConstraintException - * @throws AttachmentException - * @throws AttachmentNotFoundException - * @throws CannotUpdateAttachmentException - */ - public function handle(EditAttachmentCommand $command) - { - $attachmentIdValue = $command->getAttachmentId()->getValue(); - - try { - $attachment = new Attachment($attachmentIdValue); - } catch (PrestaShopException $e) { - throw new AttachmentNotFoundException(sprintf('Attachment with id "%s" was not found.', $attachmentIdValue)); - } - - if ($attachment->id !== $attachmentIdValue) { - throw new AttachmentNotFoundException(sprintf('Attachment with id "%s" was not found.', $attachmentIdValue)); - } - - $this->updateAttachmentFromCommandData($attachment, $command); - } - - /** - * @param Attachment $attachment - * @param EditAttachmentCommand $command - * - * @throws AttachmentConstraintException - * @throws AttachmentException - * @throws AttachmentNotFoundException - * @throws CannotUpdateAttachmentException - */ - private function updateAttachmentFromCommandData(Attachment $attachment, EditAttachmentCommand $command) - { - try { - if (!$attachment->validateFields(false) && !$attachment->validateFieldsLang(false)) { - throw new AttachmentConstraintException('Attachment contains invalid field values', AttachmentConstraintException::INVALID_FIELDS); - } - - $this->assertDescriptionContainsCleanHtml($command->getLocalizedDescriptions()); - $this->assertHasDefaultLanguage($command->getLocalizedNames()); - - $attachment->description = $command->getLocalizedDescriptions(); - $attachment->name = $command->getLocalizedNames(); - - $this->assertValidFields($attachment); - - if (null !== $command->getPathName()) { - $uniqueFileName = $this->getUniqueFileName(); - - $attachment->file_name = $command->getOriginalFileName(); - $attachment->file = $uniqueFileName; - $attachment->mime = $command->getMimeType(); - - $this->assertValidFields($attachment); - - $this->fileUploader->upload( - $command->getPathName(), - $uniqueFileName, - $command->getFileSize(), - $command->getAttachmentId()->getValue() - ); - } - - if (false === $attachment->update()) { - throw new CannotUpdateAttachmentException('Failed to update attachment'); - } - } catch (PrestaShopException $e) { - throw new AttachmentException('An unexpected error occurred when updating attachment', 0, $e); - } - } -} diff --git a/src/Adapter/Attachment/QueryHandler/GetAttachmentForEditingHandler.php b/src/Adapter/Attachment/QueryHandler/GetAttachmentForEditingHandler.php deleted file mode 100644 index 00fc65b0..00000000 --- a/src/Adapter/Attachment/QueryHandler/GetAttachmentForEditingHandler.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Attachment\QueryHandler; - -use Attachment; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Query\GetAttachmentForEditing; -use PrestaShop\PrestaShop\Core\Domain\Attachment\QueryHandler\GetAttachmentForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Attachment\QueryResult\EditableAttachment; -use PrestaShopException; -use SplFileInfo; - -/** - * Handles command that gets attachment for editing - * - * @internal - */ -final class GetAttachmentForEditingHandler implements GetAttachmentForEditingHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws AttachmentNotFoundException - */ - public function handle(GetAttachmentForEditing $query): EditableAttachment - { - $attachmentIdValue = $query->getAttachmentId()->getValue(); - - try { - $attachment = new Attachment($attachmentIdValue); - } catch (PrestaShopException $e) { - throw new AttachmentNotFoundException(sprintf('Attachment with id "%s" was not found.', $attachmentIdValue)); - } - - if ($attachment->id !== $attachmentIdValue) { - throw new AttachmentNotFoundException(sprintf('Attachment with id "%s" was not found.', $attachmentIdValue)); - } - - $filePath = _PS_DOWNLOAD_DIR_ . $attachment->file; - $file = file_exists($filePath) ? new SplFileInfo($filePath) : null; - - $editableAttachment = new EditableAttachment( - $attachment->file_name, - $attachment->name, - $attachment->description - ); - - if (null !== $file) { - $editableAttachment->setFile($file); - } - - return $editableAttachment; - } -} diff --git a/src/Adapter/Attachment/QueryHandler/GetAttachmentHandler.php b/src/Adapter/Attachment/QueryHandler/GetAttachmentHandler.php deleted file mode 100644 index 316fb8e2..00000000 --- a/src/Adapter/Attachment/QueryHandler/GetAttachmentHandler.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Attachment\QueryHandler; - -use PrestaShop\PrestaShop\Adapter\Attachment\AbstractAttachmentHandler; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Query\GetAttachment; -use PrestaShop\PrestaShop\Core\Domain\Attachment\QueryHandler\GetAttachmentHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Attachment\QueryResult\Attachment; - -/** - * Provides path and original file name of attachment - */ -final class GetAttachmentHandler extends AbstractAttachmentHandler implements GetAttachmentHandlerInterface -{ - /** - * @var string - */ - private $downloadDirectory; - - /** - * @param string $downloadDirectory - */ - public function __construct(string $downloadDirectory) - { - $this->downloadDirectory = $downloadDirectory; - } - - /** - * {@inheritdoc} - * - * @throws AttachmentNotFoundException - */ - public function handle(GetAttachment $query): Attachment - { - $attachment = $this->getAttachment($query->getAttachmentId()); - $path = $this->downloadDirectory . $attachment->file; - - if (!file_exists($path)) { - throw new AttachmentNotFoundException(sprintf('Attachment file was not found at %s', $path)); - } - - return new Attachment( - $path, - $attachment->file_name - ); - } -} diff --git a/src/Adapter/Attribute/AbstractAttributeHandler.php b/src/Adapter/Attribute/AbstractAttributeHandler.php deleted file mode 100644 index b368b14d..00000000 --- a/src/Adapter/Attribute/AbstractAttributeHandler.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Attribute; - -use Attribute; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Exception\AttributeException; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Exception\AttributeNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\ValueObject\AttributeId; -use PrestaShopException; - -/** - * Provides common methods for attribute command/query handlers - */ -abstract class AbstractAttributeHandler -{ - /** - * @param AttributeId $attributeId - * - * @return Attribute - * - * @throws AttributeException - */ - protected function getAttributeById($attributeId) - { - $idValue = $attributeId->getValue(); - - try { - $attribute = new Attribute($idValue); - - if ($attribute->id !== $idValue) { - throw new AttributeNotFoundException(sprintf('Attribute with id "%s" was not found.', $idValue)); - } - } catch (PrestaShopException $e) { - throw new AttributeException(sprintf('An error occurred when trying to get attribute with id %s', $idValue)); - } - - return $attribute; - } - - /** - * @param Attribute $attribute - * - * @return bool - * - * @throws AttributeException - */ - protected function deleteAttribute(Attribute $attribute) - { - try { - return $attribute->delete(); - } catch (PrestaShopException $e) { - throw new AttributeException(sprintf('An error occurred when trying to delete attribute with id %s', $attribute->id)); - } - } -} diff --git a/src/Adapter/Attribute/AdminAttributeGeneratorControllerWrapper.php b/src/Adapter/Attribute/AdminAttributeGeneratorControllerWrapper.php deleted file mode 100644 index 67a1a4ad..00000000 --- a/src/Adapter/Attribute/AdminAttributeGeneratorControllerWrapper.php +++ /dev/null @@ -1,131 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Attribute; - -use AdminAttributeGeneratorController; -use Combination; -use Context; -use Product; -use SpecificPriceRule; -use Stock; -use StockAvailable; -use Symfony\Component\Translation\TranslatorInterface; -use Tools; -use Validate; - -/** - * Admin controller wrapper for new Architecture, about Category admin controller. - */ -class AdminAttributeGeneratorControllerWrapper -{ - /** - * @var TranslatorInterface - */ - private $translator; - - public function __construct() - { - $context = Context::getContext(); - $this->translator = $context->getTranslator(); - } - - /** - * Generate product attributes. - * - * @param object $product The product - * @param array $options The array with all attributes combinations - */ - public function processGenerate($product, $options) - { - SpecificPriceRule::disableAnyApplication(); - - //add combination if not already exists - $combinations = array_values(AdminAttributeGeneratorController::createCombinations(array_values($options))); - $combinationsValues = array_values(array_map(function () use ($product) { - return [ - 'id_product' => $product->id, - ]; - }, $combinations)); - - $product->generateMultipleCombinations($combinationsValues, $combinations, false); - - Product::updateDefaultAttribute($product->id); - SpecificPriceRule::enableAnyApplication(); - SpecificPriceRule::applyAllRules([(int) $product->id]); - } - - /** - * Delete a product attribute. - * - * @param int $idAttribute The attribute ID - * @param int $idProduct The product ID - * - * @return array - */ - public function ajaxProcessDeleteProductAttribute($idAttribute, $idProduct) - { - if (!Combination::isFeatureActive()) { - return false; - } - - if ($idProduct && Validate::isUnsignedId($idProduct) && Validate::isLoadedObject($product = new Product($idProduct))) { - if (($depends_on_stock = StockAvailable::dependsOnStock($idProduct)) && StockAvailable::getQuantityAvailableByProduct($idProduct, $idAttribute)) { - return [ - 'status' => 'error', - 'message' => $this->translator->trans('It is not possible to delete a combination while it still has some quantities in the Advanced Stock Management. You must delete its stock first.', [], 'Admin.Catalog.Notification'), - ]; - } else { - $product->deleteAttributeCombination((int) $idAttribute); - $product->checkDefaultAttributes(); - Tools::clearColorListCache((int) $product->id); - if (!$product->hasAttributes()) { - $product->cache_default_attribute = 0; - $product->update(); - } else { - Product::updateDefaultAttribute($idProduct); - } - - if ($depends_on_stock && !Stock::deleteStockByIds($idProduct, $idAttribute)) { - return [ - 'status' => 'error', - 'message' => $this->translator->trans('Error while deleting the stock', [], 'Admin.Catalog.Notification'), - ]; - } else { - return [ - 'status' => 'ok', - 'message' => $this->translator->trans('Successful deletion', [], 'Admin.Catalog.Notification'), - ]; - } - } - } else { - return [ - 'status' => 'error', - 'message' => $this->translator->trans('You cannot delete this attribute.', [], 'Admin.Catalog.Notification'), - ]; - } - } -} diff --git a/src/Adapter/Attribute/AttributeDataProvider.php b/src/Adapter/Attribute/AttributeDataProvider.php deleted file mode 100644 index 1c498338..00000000 --- a/src/Adapter/Attribute/AttributeDataProvider.php +++ /dev/null @@ -1,131 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Attribute; - -use Attribute; -use Combination; -use Context; -use Db; -use Product; -use Shop; - -/** - * This class will provide data from DB / ORM about Attributes. - */ -class AttributeDataProvider -{ - /** - * Get all attributes for a given language. - * - * @param int $id_lang Language id - * @param bool $not_null Get only not null fields if true - * - * @return array Attributes - */ - public static function getAttributes($id_lang, $not_null = false) - { - return Attribute::getAttributes($id_lang, $not_null); - } - - /** - * Get all attributes ids for a given group. - * - * @param int $id_group Attribute group id - * @param bool $not_null Get only not null fields if true - * - * @return array Attributes - */ - public static function getAttributeIdsByGroup($id_group, $not_null = false) - { - if (!Combination::isFeatureActive()) { - return []; - } - - $result = Db::getInstance()->executeS(' - SELECT DISTINCT a.`id_attribute` - FROM `' . _DB_PREFIX_ . 'attribute_group` ag - LEFT JOIN `' . _DB_PREFIX_ . 'attribute` a - ON a.`id_attribute_group` = ag.`id_attribute_group` - ' . Shop::addSqlAssociation('attribute_group', 'ag') . ' - ' . Shop::addSqlAssociation('attribute', 'a') . ' - WHERE ag.`id_attribute_group` = ' . (int) $id_group . ' - ' . ($not_null ? 'AND a.`id_attribute` IS NOT NULL' : '') . ' - ORDER BY a.`position` ASC - '); - - return array_map(function ($a) { - return $a['id_attribute']; - }, $result); - } - - /** - * Get combination for a product. - * - * @param int $idProduct - * - * @return array Combinations - */ - public function getProductCombinations($idProduct) - { - $context = Context::getContext(); - - //get product - $product = new Product((int) $idProduct, false); - if (!is_object($product) || empty($product->id)) { - return false; - } - - $allCombinations = $product->getAttributeCombinations(1, false); - $allCombinationsIds = array_map(function ($o) { - return $o['id_product_attribute']; - }, $allCombinations); - - $combinations = []; - foreach ($allCombinationsIds as $combinationId) { - $combinations[] = $product->getAttributeCombinationsById($combinationId, $context->employee->id_lang)[0]; - } - - return $combinations; - } - - /** - * Get combination images ids. - * - * @param int $idAttribute - * - * @return array - */ - public function getImages($idAttribute) - { - return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT a.`id_image` as id - FROM `' . _DB_PREFIX_ . 'product_attribute_image` a - ' . Shop::addSqlAssociation('product_attribute', 'a') . ' - WHERE a.`id_product_attribute` = ' . (int) $idAttribute . ' - '); - } -} diff --git a/src/Adapter/Attribute/CommandHandler/BulkDeleteAttributeHandler.php b/src/Adapter/Attribute/CommandHandler/BulkDeleteAttributeHandler.php deleted file mode 100644 index f5972bc1..00000000 --- a/src/Adapter/Attribute/CommandHandler/BulkDeleteAttributeHandler.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Attribute\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Attribute\AbstractAttributeHandler; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Command\BulkDeleteAttributeCommand; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\CommandHandler\BulkDeleteAttributeHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Exception\AttributeException; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Exception\DeleteAttributeException; - -/** - * Handles command which deletes attributes in bulk action using legacy object model - */ -final class BulkDeleteAttributeHandler extends AbstractAttributeHandler implements BulkDeleteAttributeHandlerInterface -{ - /** - * @param BulkDeleteAttributeCommand $command - * - * @throws AttributeException - */ - public function handle(BulkDeleteAttributeCommand $command) - { - foreach ($command->getAttributeIds() as $attributeId) { - $attribute = $this->getAttributeById($attributeId); - - if (false === $this->deleteAttribute($attribute)) { - throw new DeleteAttributeException(sprintf('Failed to delete attribute with id "%s"', $attribute->id), DeleteAttributeException::FAILED_BULK_DELETE); - } - } - } -} diff --git a/src/Adapter/Attribute/CommandHandler/DeleteAttributeHandler.php b/src/Adapter/Attribute/CommandHandler/DeleteAttributeHandler.php deleted file mode 100644 index 23efd12d..00000000 --- a/src/Adapter/Attribute/CommandHandler/DeleteAttributeHandler.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Attribute\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Attribute\AbstractAttributeHandler; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Command\DeleteAttributeCommand; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\CommandHandler\DeleteAttributeHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Exception\AttributeException; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Exception\DeleteAttributeException; - -/** - * Handles command which deletes the Attribute using legacy object model - */ -final class DeleteAttributeHandler extends AbstractAttributeHandler implements DeleteAttributeHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws AttributeException - */ - public function handle(DeleteAttributeCommand $command) - { - $attribute = $this->getAttributeById($command->getAttributeId()); - - if (false === $this->deleteAttribute($attribute)) { - throw new DeleteAttributeException(sprintf('Failed to delete attribute with id "%s".', $attribute->id), DeleteAttributeException::FAILED_DELETE); - } - } -} diff --git a/src/Adapter/AttributeGroup/AbstractAttributeGroupHandler.php b/src/Adapter/AttributeGroup/AbstractAttributeGroupHandler.php deleted file mode 100644 index f55680a6..00000000 --- a/src/Adapter/AttributeGroup/AbstractAttributeGroupHandler.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\AttributeGroup; - -use AttributeGroup; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception\AttributeGroupException; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception\AttributeGroupNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\ValueObject\AttributeGroupId; -use PrestaShopException; - -/** - * Provides reusable methods for attribute group handlers - */ -abstract class AbstractAttributeGroupHandler -{ - /** - * @param AttributeGroupId $attributeGroupId - * - * @return AttributeGroup - * - * @throws AttributeGroupException - */ - protected function getAttributeGroupById($attributeGroupId) - { - $idValue = $attributeGroupId->getValue(); - - try { - $attributeGroup = new AttributeGroup($idValue); - - if ($attributeGroup->id !== $idValue) { - throw new AttributeGroupNotFoundException(sprintf('Attribute group with id "%s" was not found.', $idValue)); - } - } catch (PrestaShopException $e) { - throw new AttributeGroupException(sprintf('An error occurred when trying to get attribute group with id %s', $idValue)); - } - - return $attributeGroup; - } - - /** - * @param AttributeGroup $attributeGroup - * - * @return bool - * - * @throws AttributeGroupException - */ - protected function deleteAttributeGroup(AttributeGroup $attributeGroup) - { - try { - return $attributeGroup->delete(); - } catch (PrestaShopException $e) { - throw new AttributeGroupException(sprintf('An error occurred when trying to delete attribute with id %s', $attributeGroup->id)); - } - } -} diff --git a/src/Adapter/AttributeGroup/AttributeGroupViewDataProvider.php b/src/Adapter/AttributeGroup/AttributeGroupViewDataProvider.php deleted file mode 100644 index ee25cd9c..00000000 --- a/src/Adapter/AttributeGroup/AttributeGroupViewDataProvider.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\AttributeGroup; - -use AttributeGroup; -use PrestaShop\PrestaShop\Core\AttributeGroup\AttributeGroupViewDataProviderInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception\AttributeGroupException; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception\AttributeGroupNotFoundException; -use PrestaShopException; - -/** - * Provides data required for attribute group view action using legacy object models - */ -final class AttributeGroupViewDataProvider implements AttributeGroupViewDataProviderInterface -{ - /** - * @var int - */ - private $contextLangId; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param int $contextLangId - * @param ConfigurationInterface $configuration - */ - public function __construct($contextLangId, ConfigurationInterface $configuration) - { - $this->contextLangId = $contextLangId; - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function isColorGroup($attributeGroupId) - { - $attributeGroup = $this->getAttributeGroupById($attributeGroupId); - - return (bool) $attributeGroup->is_color_group; - } - - /** - * {@inheritdoc} - */ - public function getAttributeGroupNameById($attributeGroupId) - { - $attributeGroup = $this->getAttributeGroupById($attributeGroupId); - - if (!isset($attributeGroup->name[$this->contextLangId])) { - return $attributeGroup->name[$this->configuration->get('PS_LANG_DEFAULT')]; - } - - return $attributeGroup->name[$this->contextLangId]; - } - - /** - * Gets legacy AttributeGroup object by provided id - * - * @param int $attributeGroupId - * - * @return AttributeGroup - * - * @throws AttributeGroupException - * @throws AttributeGroupNotFoundException - */ - private function getAttributeGroupById($attributeGroupId) - { - try { - $attributeGroup = new AttributeGroup($attributeGroupId); - - if ($attributeGroup->id !== $attributeGroupId) { - throw new AttributeGroupNotFoundException(sprintf('Attribute group with id "%s" was not found.', $attributeGroupId)); - } - } catch (PrestaShopException $e) { - throw new AttributeGroupException(sprintf('An error occurred when trying to get attribute group with id %s', $attributeGroupId)); - } - - return $attributeGroup; - } -} diff --git a/src/Adapter/AttributeGroup/CommandHandler/BulkDeleteAttributeGroupHandler.php b/src/Adapter/AttributeGroup/CommandHandler/BulkDeleteAttributeGroupHandler.php deleted file mode 100644 index b3835af3..00000000 --- a/src/Adapter/AttributeGroup/CommandHandler/BulkDeleteAttributeGroupHandler.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\AttributeGroup\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\AttributeGroup\AbstractAttributeGroupHandler; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Command\BulkDeleteAttributeGroupCommand; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\CommandHandler\BulkDeleteAttributeGroupHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception\DeleteAttributeGroupException; - -/** - * Handles command which deletes multiple attribute groups using legacy object model - */ -final class BulkDeleteAttributeGroupHandler extends AbstractAttributeGroupHandler implements BulkDeleteAttributeGroupHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(BulkDeleteAttributeGroupCommand $command) - { - foreach ($command->getAttributeGroupIds() as $attributeGroupId) { - $attributeGroup = $this->getAttributeGroupById($attributeGroupId); - - if (false === $this->deleteAttributeGroup($attributeGroup)) { - throw new DeleteAttributeGroupException(sprintf('Failed to delete attribute group with id "%s"', $attributeGroupId->getValue()), DeleteAttributeGroupException::FAILED_BULK_DELETE); - } - } - } -} diff --git a/src/Adapter/AttributeGroup/CommandHandler/DeleteAttributeGroupHandler.php b/src/Adapter/AttributeGroup/CommandHandler/DeleteAttributeGroupHandler.php deleted file mode 100644 index b56679df..00000000 --- a/src/Adapter/AttributeGroup/CommandHandler/DeleteAttributeGroupHandler.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\AttributeGroup\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\AttributeGroup\AbstractAttributeGroupHandler; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Command\DeleteAttributeGroupCommand; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\CommandHandler\DeleteAttributeGroupHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception\AttributeGroupException; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception\DeleteAttributeGroupException; - -/** - * Handles command which deletes attribute group using legacy object model - */ -final class DeleteAttributeGroupHandler extends AbstractAttributeGroupHandler implements DeleteAttributeGroupHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws AttributeGroupException - */ - public function handle(DeleteAttributeGroupCommand $command) - { - $attributeGroupId = $command->getAttributeGroupId(); - $attributeGroup = $this->getAttributeGroupById($attributeGroupId); - - if (false === $this->deleteAttributeGroup($attributeGroup)) { - throw new DeleteAttributeGroupException(sprintf('Failed deleting attribute group with id "%s"', $attributeGroupId->getValue()), DeleteAttributeGroupException::FAILED_DELETE); - } - } -} diff --git a/src/Adapter/Backup/Backup.php b/src/Adapter/Backup/Backup.php deleted file mode 100644 index bb6604c5..00000000 --- a/src/Adapter/Backup/Backup.php +++ /dev/null @@ -1,108 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Backup; - -use DateTimeImmutable; -use PrestaShop\PrestaShop\Adapter\Entity\PrestaShopBackup; -use PrestaShop\PrestaShop\Core\Backup\BackupInterface; - -/** - * Class Backup represents single database backup. - * - * @internal - */ -final class Backup implements BackupInterface -{ - /** - * @var PrestaShopBackup - */ - private $legacyBackup; - - /** - * @var string - */ - private $fileName; - - /** - * @param string $fileName Backup file name - */ - public function __construct($fileName) - { - $this->fileName = $fileName; - $this->legacyBackup = new PrestaShopBackup($fileName); - } - - /** - * {@inheritdoc} - */ - public function getFileName() - { - return $this->fileName; - } - - /** - * {@inheritdoc} - */ - public function getFilePath() - { - return $this->legacyBackup->getBackupPath() . $this->getFileName(); - } - - /** - * {@inheritdoc} - */ - public function getUrl() - { - return $this->legacyBackup->getBackupURL(); - } - - /** - * {@inheritdoc} - */ - public function getSize() - { - return filesize($this->legacyBackup->id); - } - - /** - * {@inheritdoc} - */ - public function getAge() - { - return time() - $this->getDate()->getTimestamp(); - } - - /** - * {@inheritdoc} - */ - public function getDate() - { - list($timestamp) = explode('-', $this->fileName); - - return new DateTimeImmutable('@' . $timestamp); - } -} diff --git a/src/Adapter/Backup/BackupRemover.php b/src/Adapter/Backup/BackupRemover.php deleted file mode 100644 index c10d0ef1..00000000 --- a/src/Adapter/Backup/BackupRemover.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Backup; - -use PrestaShop\PrestaShop\Adapter\Entity\PrestaShopBackup; -use PrestaShop\PrestaShop\Core\Backup\BackupInterface; -use PrestaShop\PrestaShop\Core\Backup\Manager\BackupRemoverInterface; - -/** - * Class BackupRemover deletes given backup. - * - * @internal - */ -final class BackupRemover implements BackupRemoverInterface -{ - /** - * {@inheritdoc} - */ - public function remove(BackupInterface $backup) - { - $legacyBackup = new PrestaShopBackup($backup->getFileName()); - - return $legacyBackup->delete(); - } -} diff --git a/src/Adapter/Backup/BackupRepository.php b/src/Adapter/Backup/BackupRepository.php deleted file mode 100644 index c74c92e1..00000000 --- a/src/Adapter/Backup/BackupRepository.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Backup; - -use PrestaShop\PrestaShop\Adapter\Entity\PrestaShopBackup; -use PrestaShop\PrestaShop\Core\Backup\BackupCollection; -use PrestaShop\PrestaShop\Core\Backup\Repository\BackupRepositoryInterface; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Finder\SplFileInfo; - -/** - * Class BackupRepository is responsible for providing available backups. - * - * @internal - */ -final class BackupRepository implements BackupRepositoryInterface -{ - /** - * {@inheritdoc} - */ - public function retrieveBackups() - { - $backupFinder = (new Finder()) - ->files() - ->in(PrestaShopBackup::getBackupPath()) - ->name('/^([_a-zA-Z0-9\-]*[\d]+-[a-z\d]+)\.sql(\.gz|\.bz2)?$/') - ->depth(0); - - $backups = new BackupCollection(); - - /** @var SplFileInfo $file */ - foreach ($backupFinder as $file) { - $backups->add(new Backup($file->getFilename())); - } - - return $backups; - } -} diff --git a/src/Adapter/Backup/DatabaseBackupCreator.php b/src/Adapter/Backup/DatabaseBackupCreator.php deleted file mode 100644 index 0dd133dd..00000000 --- a/src/Adapter/Backup/DatabaseBackupCreator.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Backup; - -use PrestaShop\PrestaShop\Adapter\Entity\PrestaShopBackup; -use PrestaShop\PrestaShop\Core\Backup\Exception\BackupException; -use PrestaShop\PrestaShop\Core\Backup\Exception\DirectoryIsNotWritableException; -use PrestaShop\PrestaShop\Core\Backup\Manager\BackupCreatorInterface; - -/** - * Class DatabaseBackupCreator is responsible for creating database backups. - * - * @internal - */ -final class DatabaseBackupCreator implements BackupCreatorInterface -{ - /** - * {@inheritdoc} - */ - public function createBackup() - { - ini_set('max_execution_time', 0); - - if (!is_writable(PrestaShopBackup::getBackupPath())) { - throw new DirectoryIsNotWritableException('To create backup, its directory must be writable'); - } - - $legacyBackup = new PrestaShopBackup(); - if (!$legacyBackup->add()) { - throw new BackupException('Failed to create backup'); - } - - $backupFilePathParts = explode(DIRECTORY_SEPARATOR, $legacyBackup->id); - - return new Backup(end($backupFilePathParts)); - } -} diff --git a/src/Adapter/BestSales/BestSalesProductSearchProvider.php b/src/Adapter/BestSales/BestSalesProductSearchProvider.php deleted file mode 100644 index 8a04889f..00000000 --- a/src/Adapter/BestSales/BestSalesProductSearchProvider.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\BestSales; - -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchProviderInterface; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchResult; -use PrestaShop\PrestaShop\Core\Product\Search\SortOrder; -use PrestaShop\PrestaShop\Core\Product\Search\SortOrderFactory; -use ProductSale; -use Symfony\Component\Translation\TranslatorInterface; -use Tools; - -class BestSalesProductSearchProvider implements ProductSearchProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var SortOrderFactory - */ - private $sortOrderFactory; - - public function __construct( - TranslatorInterface $translator - ) { - $this->translator = $translator; - $this->sortOrderFactory = new SortOrderFactory($this->translator); - } - - /** - * @param ProductSearchContext $context - * @param ProductSearchQuery $query - * - * @return ProductSearchResult - */ - public function runQuery( - ProductSearchContext $context, - ProductSearchQuery $query - ) { - $sortBySales = (new SortOrder('product', 'sales', 'desc'))->setLabel( - $this->translator->trans('Sales, highest to lowest', [], 'Shop.Theme.Catalog') - ); - - if (!Tools::getValue('order', 0)) { - $query->setSortOrder($sortBySales); - } - - if (!$products = ProductSale::getBestSales( - $context->getIdLang(), - $query->getPage(), - $query->getResultsPerPage(), - $query->getSortOrder()->toLegacyOrderBy(), - $query->getSortOrder()->toLegacyOrderWay() - )) { - $products = []; - } - - $count = (int) ProductSale::getNbSales(); - - $result = new ProductSearchResult(); - - if (!empty($products)) { - $result - ->setProducts($products) - ->setTotalProductsCount($count); - - $result->setAvailableSortOrders( - [ - $sortBySales, - (new SortOrder('product', 'name', 'asc'))->setLabel( - $this->translator->trans('Name, A to Z', [], 'Shop.Theme.Catalog') - ), - (new SortOrder('product', 'name', 'desc'))->setLabel( - $this->translator->trans('Name, Z to A', [], 'Shop.Theme.Catalog') - ), - (new SortOrder('product', 'price', 'asc'))->setLabel( - $this->translator->trans('Price, low to high', [], 'Shop.Theme.Catalog') - ), - (new SortOrder('product', 'price', 'desc'))->setLabel( - $this->translator->trans('Price, high to low', [], 'Shop.Theme.Catalog') - ), - ] - ); - } - - return $result; - } -} diff --git a/src/Adapter/CMS/CMSDataProvider.php b/src/Adapter/CMS/CMSDataProvider.php deleted file mode 100644 index 6335f6f7..00000000 --- a/src/Adapter/CMS/CMSDataProvider.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS; - -use CMS; - -/** - * Class CMSDataProvider provides CMS data using legacy code. - */ -class CMSDataProvider -{ - /** - * Gets all CMS pages. - * - * @param int $languageId - * - * @return array - */ - public function getCMSPages($languageId = null) - { - return CMS::listCms($languageId); - } - - /** - * Gets one CMS object by ID. - * - * @param int $cmsId - * - * @return CMS - */ - public function getCMSById($cmsId) - { - return new CMS($cmsId); - } - - /** - * Gets CMS choices for choice type. - * - * @param int $languageId - * - * @return array - */ - public function getCMSChoices($languageId = null) - { - $choices = []; - - foreach ($this->getCMSPages($languageId) as $cms) { - $choices[$cms['meta_title']] = $cms['id_cms']; - } - - return $choices; - } -} diff --git a/src/Adapter/CMS/Page/CommandHandler/AbstractCmsPageHandler.php b/src/Adapter/CMS/Page/CommandHandler/AbstractCmsPageHandler.php deleted file mode 100644 index c76bd338..00000000 --- a/src/Adapter/CMS/Page/CommandHandler/AbstractCmsPageHandler.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler; - -use CMS; -use CMSCategory; -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryNotFoundException; -use PrestaShopException; - -/** - * Abstraction which holds all common functions required for cms page functionality. - * - * @internal - */ -abstract class AbstractCmsPageHandler extends AbstractObjectModelHandler -{ - /** - * Gets cms object if it exists. If it does not exist it throws exceptions. - * - * @param int $cmsId - * - * @return CMS - * - * @throws CmsPageException - */ - protected function getCmsPageIfExistsById($cmsId) - { - try { - $cms = new CMS($cmsId); - - if (0 >= $cms->id) { - throw new CmsPageNotFoundException(sprintf('Cms page with id "%s" not found', $cmsId)); - } - } catch (PrestaShopException $exception) { - throw new CmsPageException(sprintf('An error occurred when trying to get cms page with id %s', $cmsId)); - } - - return $cms; - } - - /** - * Checks whether cms page category exists by provided id. - * - * @param $cmsCategoryId - * - * @throws CmsPageCategoryException - */ - protected function assertCmsCategoryExists($cmsCategoryId) - { - try { - $cmsCategory = new CMSCategory($cmsCategoryId); - if (0 >= $cmsCategory->id) { - throw new CmsPageCategoryNotFoundException(sprintf('Cms page category with id "%s" not found', $cmsCategoryId)); - } - } catch (PrestaShopException $exception) { - throw new CmsPageCategoryException(sprintf('An error occurred when trying to get cms page category with id %s', $cmsCategoryId)); - } - } -} diff --git a/src/Adapter/CMS/Page/CommandHandler/AddCmsPageHandler.php b/src/Adapter/CMS/Page/CommandHandler/AddCmsPageHandler.php deleted file mode 100644 index de47853c..00000000 --- a/src/Adapter/CMS/Page/CommandHandler/AddCmsPageHandler.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler; - -use CMS; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\AddCmsPageCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\CommandHandler\AddCmsPageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CannotAddCmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\ValueObject\CmsPageId; -use PrestaShopException; - -/** - * Handles AddCmsPageCommand using legacy object model - */ -final class AddCmsPageHandler extends AbstractCmsPageHandler implements AddCmsPageHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(AddCmsPageCommand $command) - { - $cms = $this->createCmsFromCommand($command); - - try { - if (false === $cms->validateFields(false) || false === $cms->validateFieldsLang(false)) { - throw new CmsPageException('Cms page contains invalid field values'); - } - - if (false === $cms->add()) { - throw new CannotAddCmsPageException('Failed to add cms page'); - } - $this->associateWithShops($cms, $command->getShopAssociation()); - } catch (PrestaShopException $e) { - throw new CmsPageException('An unexpected error occurred when adding cms page', 0, $e); - } - - return new CmsPageId((int) $cms->id); - } - - /** - * @param AddCmsPageCommand $command - * - * @return CMS - */ - protected function createCmsFromCommand(AddCmsPageCommand $command) - { - $cmsCategoryId = $command->getCmsPageCategory()->getValue(); - $this->assertCmsCategoryExists($cmsCategoryId); - - $cms = new CMS(); - $cms->id_cms_category = $cmsCategoryId; - $cms->meta_title = $command->getLocalizedTitle(); - $cms->head_seo_title = $command->getLocalizedMetaTitle(); - $cms->meta_description = $command->getLocalizedMetaDescription(); - $cms->meta_keywords = $command->getLocalizedMetaKeyword(); - $cms->link_rewrite = $command->getLocalizedFriendlyUrl(); - $cms->content = $command->getLocalizedContent(); - $cms->indexation = $command->isIndexedForSearch(); - $cms->active = $command->isDisplayed(); - - return $cms; - } -} diff --git a/src/Adapter/CMS/Page/CommandHandler/BulkDeleteCmsPageHandler.php b/src/Adapter/CMS/Page/CommandHandler/BulkDeleteCmsPageHandler.php deleted file mode 100644 index 40fa53a6..00000000 --- a/src/Adapter/CMS/Page/CommandHandler/BulkDeleteCmsPageHandler.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\BulkDeleteCmsPageCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\CommandHandler\BulkDeleteCmsPageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CannotDeleteCmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShopException; - -/** - * Deletes multiple cms pages - */ -final class BulkDeleteCmsPageHandler extends AbstractCmsPageHandler implements BulkDeleteCmsPageHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CmsPageException - */ - public function handle(BulkDeleteCmsPageCommand $command) - { - try { - foreach ($command->getCmsPages() as $cmsPageId) { - $cms = $this->getCmsPageIfExistsById($cmsPageId->getValue()); - - if (false === $cms->delete()) { - throw new CannotDeleteCmsPageException(sprintf('An error occurred when deleting cms page with id %s', $cmsPageId->getValue()), CannotDeleteCmsPageException::FAILED_BULK_DELETE); - } - } - } catch (PrestaShopException $exception) { - throw new CmsPageException('An unexpected error occurred when deleting cms page', 0, $exception); - } - } -} diff --git a/src/Adapter/CMS/Page/CommandHandler/BulkDisableCmsPageHandler.php b/src/Adapter/CMS/Page/CommandHandler/BulkDisableCmsPageHandler.php deleted file mode 100644 index c28b9f2e..00000000 --- a/src/Adapter/CMS/Page/CommandHandler/BulkDisableCmsPageHandler.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\BulkDisableCmsPageCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\CommandHandler\BulkDisableCmsPageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CannotDisableCmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageNotFoundException; -use PrestaShopException; - -/** - * Disables multiple cms pages. - */ -final class BulkDisableCmsPageHandler extends AbstractCmsPageHandler implements BulkDisableCmsPageHandlerInterface -{ - /** - * {@inheritdoc} - * - * @param BulkDisableCmsPageCommand $command - * - * @throws CannotDisableCmsPageException - * @throws CmsPageException - * @throws CmsPageNotFoundException - */ - public function handle(BulkDisableCmsPageCommand $command) - { - try { - $this->disableCmsPages($command); - } catch (PrestaShopException $exception) { - throw new CmsPageException('An error occurred when bulk disabling the cms pages', 0, $exception); - } - } - - /** - * @param BulkDisableCmsPageCommand $command - * - * @throws CannotDisableCmsPageException - * @throws PrestaShopException - * @throws \PrestaShopDatabaseException - * @throws CmsPageException - * @throws CmsPageNotFoundException - */ - private function disableCmsPages(BulkDisableCmsPageCommand $command) - { - foreach ($command->getCmsPages() as $cmsPage) { - $cms = $this->getCmsPageIfExistsById($cmsPage->getValue()); - - $cms->active = false; - - if (false === $cms->update()) { - throw new CannotDisableCmsPageException(sprintf('Failed to disable cms page with id %s', $cmsPage->getValue())); - } - } - } -} diff --git a/src/Adapter/CMS/Page/CommandHandler/BulkEnableCmsPageHandler.php b/src/Adapter/CMS/Page/CommandHandler/BulkEnableCmsPageHandler.php deleted file mode 100644 index 6f2ce07c..00000000 --- a/src/Adapter/CMS/Page/CommandHandler/BulkEnableCmsPageHandler.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\BulkEnableCmsPageCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\CommandHandler\BulkEnableCmsPageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CannotEnableCmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageNotFoundException; -use PrestaShopException; - -/** - * Enables multiple cms pages. - */ -final class BulkEnableCmsPageHandler extends AbstractCmsPageHandler implements BulkEnableCmsPageHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CmsPageException - */ - public function handle(BulkEnableCmsPageCommand $command) - { - try { - $this->enableCmsPages($command); - } catch (PrestaShopException $exception) { - throw new CmsPageException('An error occurred when bulk enabling the cms pages', 0, $exception); - } - } - - /** - * @param BulkEnableCmsPageCommand $command - * - * @throws CannotEnableCmsPageException - * @throws CmsPageException - * @throws PrestaShopException - * @throws \PrestaShopDatabaseException - * @throws CmsPageNotFoundException - */ - private function enableCmsPages(BulkEnableCmsPageCommand $command) - { - foreach ($command->getCmsPages() as $cmsPage) { - $cms = $this->getCmsPageIfExistsById($cmsPage->getValue()); - - $cms->active = true; - - if (false === $cms->update()) { - throw new CannotEnableCmsPageException(sprintf('Failed to enable cms page with id %s', $cmsPage->getValue())); - } - } - } -} diff --git a/src/Adapter/CMS/Page/CommandHandler/DeleteCmsPageHandler.php b/src/Adapter/CMS/Page/CommandHandler/DeleteCmsPageHandler.php deleted file mode 100644 index 739575d3..00000000 --- a/src/Adapter/CMS/Page/CommandHandler/DeleteCmsPageHandler.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\DeleteCmsPageCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\CommandHandler\DeleteCmsPageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CannotDeleteCmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShopException; - -/** - * Deletes given cms page. - */ -final class DeleteCmsPageHandler extends AbstractCmsPageHandler implements DeleteCmsPageHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CmsPageException - */ - public function handle(DeleteCmsPageCommand $command) - { - $cms = $this->getCmsPageIfExistsById($command->getCmsPageId()->getValue()); - - try { - if (false === $cms->delete()) { - throw new CannotDeleteCmsPageException(sprintf('An error occurred when deleting cms page with id %s', $command->getCmsPageId()->getValue()), CannotDeleteCmsPageException::FAILED_DELETE); - } - } catch (PrestaShopException $e) { - throw new CmsPageException(sprintf('An unexpected error occurred when deleting cms page with id %s', $command->getCmsPageId()->getValue()), 0, $e); - } - } -} diff --git a/src/Adapter/CMS/Page/CommandHandler/EditCmsPageHandler.php b/src/Adapter/CMS/Page/CommandHandler/EditCmsPageHandler.php deleted file mode 100644 index 3c6e4a58..00000000 --- a/src/Adapter/CMS/Page/CommandHandler/EditCmsPageHandler.php +++ /dev/null @@ -1,121 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler; - -use CMS; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\EditCmsPageCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\CommandHandler\EditCmsPageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CannotEditCmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShopException; - -/** - * Edits cms page - */ -final class EditCmsPageHandler extends AbstractCmsPageHandler implements EditCmsPageHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CmsPageException - * @throws CmsPageCategoryException - */ - public function handle(EditCmsPageCommand $command) - { - $cms = $this->createCmsFromCommand($command); - - try { - if (false === $cms->validateFields(false) || false === $cms->validateFieldsLang(false)) { - throw new CmsPageException('Cms page contains invalid field values'); - } - if (false === $cms->update()) { - throw new CannotEditCmsPageException(sprintf('Failed to update cms page with id %s', $command->getCmsPageId()->getValue())); - } - if (null !== $command->getShopAssociation()) { - $this->associateWithShops($cms, $command->getShopAssociation()); - } - } catch (PrestaShopException $e) { - throw new CmsPageException(sprintf('An unexpected error occurred when editing cms page with id %s', $command->getCmsPageId()->getValue()), 0, $e); - } - } - - /** - * @param EditCmsPageCommand $command - * - * @return CMS - * - * @throws CmsPageException - * @throws CmsPageNotFoundException - * @throws CmsPageCategoryException - */ - private function createCmsFromCommand(EditCmsPageCommand $command) - { - $cms = $this->getCmsPageIfExistsById($command->getCmsPageId()->getValue()); - - if (null !== $command->getCmsPageCategoryId()) { - $this->assertCmsCategoryExists($command->getCmsPageCategoryId()->getValue()); - - $cms->id_cms_category = $command->getCmsPageCategoryId()->getValue(); - } - - if (null !== $command->getLocalizedTitle()) { - $cms->meta_title = $command->getLocalizedTitle(); - } - - if (null !== $command->getLocalizedMetaTitle()) { - $cms->head_seo_title = $command->getLocalizedMetaTitle(); - } - - if (null !== $command->getLocalizedMetaDescription()) { - $cms->meta_description = $command->getLocalizedMetaDescription(); - } - - if (null !== $command->getLocalizedMetaKeyword()) { - $cms->meta_keywords = $command->getLocalizedMetaKeyword(); - } - - if (null !== $command->getLocalizedFriendlyUrl()) { - $cms->link_rewrite = $command->getLocalizedFriendlyUrl(); - } - - if (null !== $command->getLocalizedContent()) { - $cms->content = $command->getLocalizedContent(); - } - - if (null !== $command->isIndexedForSearch()) { - $cms->indexation = $command->isIndexedForSearch(); - } - - if (null !== $command->isDisplayed()) { - $cms->active = $command->isDisplayed(); - } - - return $cms; - } -} diff --git a/src/Adapter/CMS/Page/CommandHandler/ToggleCmsPageStatusHandler.php b/src/Adapter/CMS/Page/CommandHandler/ToggleCmsPageStatusHandler.php deleted file mode 100644 index b592caca..00000000 --- a/src/Adapter/CMS/Page/CommandHandler/ToggleCmsPageStatusHandler.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\ToggleCmsPageStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\CommandHandler\ToggleCmsPageStatusHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CannotToggleCmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShopException; - -/** - * Changes the status of cms page. - */ -final class ToggleCmsPageStatusHandler extends AbstractCmsPageHandler implements ToggleCmsPageStatusHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CmsPageException - */ - public function handle(ToggleCmsPageStatusCommand $command) - { - $cms = $this->getCmsPageIfExistsById($command->getCmsPageId()->getValue()); - - try { - if (false === $cms->toggleStatus()) { - throw new CannotToggleCmsPageException(sprintf('Failed to toggle cms page with id %s status', $command->getCmsPageId()->getValue())); - } - } catch (PrestaShopException $exception) { - throw new CmsPageException(sprintf('An unexpected error occurred when toggling cms page with id %s status', $command->getCmsPageId()->getValue())); - } - } -} diff --git a/src/Adapter/CMS/Page/QueryHandler/GetCmsCategoryIdForRedirectionHandler.php b/src/Adapter/CMS/Page/QueryHandler/GetCmsCategoryIdForRedirectionHandler.php deleted file mode 100644 index 491920da..00000000 --- a/src/Adapter/CMS/Page/QueryHandler/GetCmsCategoryIdForRedirectionHandler.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\Page\QueryHandler; - -use PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler\AbstractCmsPageHandler; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Query\GetCmsCategoryIdForRedirection; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\QueryHandler\GetCmsCategoryIdHandlerForRedirectionInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * This class is used for getting the id which is used later on to redirect to the right page after certain controller - * actions. - */ -final class GetCmsCategoryIdForRedirectionHandler extends AbstractCmsPageHandler implements GetCmsCategoryIdHandlerForRedirectionInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GetCmsCategoryIdForRedirection $query) - { - try { - $cms = $this->getCmsPageIfExistsById($query->getCmsPageId()->getValue()); - $categoryId = (int) $cms->id_cms_category; - } catch (CmsPageException $exception) { - $categoryId = CmsPageCategoryId::ROOT_CMS_PAGE_CATEGORY_ID; - } - - return new CmsPageCategoryId($categoryId); - } -} diff --git a/src/Adapter/CMS/Page/QueryHandler/GetCmsPageForEditingHandler.php b/src/Adapter/CMS/Page/QueryHandler/GetCmsPageForEditingHandler.php deleted file mode 100644 index 9e99d8e3..00000000 --- a/src/Adapter/CMS/Page/QueryHandler/GetCmsPageForEditingHandler.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\Page\QueryHandler; - -use Link; -use PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler\AbstractCmsPageHandler; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Query\getCmsPageForEditing; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\QueryHandler\GetCmsPageForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\QueryResult\EditableCmsPage; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShopException; - -/** - * Gets cms page for editing - */ -final class GetCmsPageForEditingHandler extends AbstractCmsPageHandler implements GetCmsPageForEditingHandlerInterface -{ - /** - * @var Link - */ - private $link; - - /** - * @var int - */ - private $langId; - - /** - * @param Link $link - * @param int $langId - */ - public function __construct(Link $link, $langId) - { - $this->link = $link; - $this->langId = $langId; - } - - /** - * @param GetCmsPageForEditing $query - * - * @return EditableCmsPage - * - * @throws CmsPageException - * @throws CmsPageCategoryException - * @throws CmsPageNotFoundException - */ - public function handle(getCmsPageForEditing $query) - { - $cmsPageId = $query->getCmsPageId()->getValue(); - $cms = $this->getCmsPageIfExistsById($cmsPageId); - - try { - return new EditableCmsPage( - (int) $cms->id, - (int) $cms->id_cms_category, - $cms->meta_title, - $cms->head_seo_title, - $cms->meta_description, - $cms->meta_keywords, - $cms->link_rewrite, - $cms->content, - $cms->indexation, - $cms->active, - $cms->getAssociatedShops(), - $this->link->getCMSLink($cms, null, null, $this->langId) - ); - } catch (PrestaShopException $e) { - throw new CmsPageException(sprintf('An error occurred when getting cms page for editing with id "%s"', $cmsPageId)); - } - } -} diff --git a/src/Adapter/CMS/PageCategory/CategoriesProvider.php b/src/Adapter/CMS/PageCategory/CategoriesProvider.php deleted file mode 100644 index 3deb9cd6..00000000 --- a/src/Adapter/CMS/PageCategory/CategoriesProvider.php +++ /dev/null @@ -1,130 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\PageCategory; - -use Db; -use DbQuery; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; -use PrestaShopDatabaseException; - -/** - * Class CategoriesProvider is responsible for providing cms page categories data. - */ -class CategoriesProvider -{ - /** - * @var int - */ - private $contextLanguageId; - - /** - * @var array - */ - private $contextShopIds; - - /** - * @param int $contextLanguageId - * @param array $contextShopIds - */ - public function __construct( - $contextLanguageId, - array $contextShopIds - ) { - $this->contextLanguageId = (int) $contextLanguageId; - $this->contextShopIds = array_map(function ($item) { return (int) $item; }, $contextShopIds); - } - - /** - * Gets all nested cms page categories. - * - * @return array - * - * @throws PrestaShopDatabaseException - */ - public function getAllNestedCategories() - { - return $this->collectNestedCategoriesIdsAndNames(CmsPageCategoryId::ROOT_CMS_PAGE_CATEGORY_ID); - } - - /** - * Gets recursive category ids and names - * - * @param int $cmsPageCategoryId - * - * @return array - [ - * 'id_cms_category' => 1, - * 'name' => 'root category', - * 'children' => [...] - * ] - * - * @throws PrestaShopDatabaseException - */ - private function collectNestedCategoriesIdsAndNames($cmsPageCategoryId) - { - $mainCategoryQuery = new DbQuery(); - $mainCategoryQuery - ->select('c.`id_cms_category`, cl.`name`') - ->from('cms_category', 'c') - ->innerJoin( - 'cms_category_lang', - 'cl', - 'cl.`id_cms_category` = c.`id_cms_category`' - ) - ->where('c.`id_cms_category` = ' . (int) $cmsPageCategoryId) - ->where('cl.`id_lang` = ' . $this->contextLanguageId) - ->where('cl.`id_shop` IN (' . implode(',', $this->contextShopIds) . ')') - ->groupBy('c.`id_cms_category`') - ; - - $result = Db::getInstance()->getRow($mainCategoryQuery); - $categories = is_array($result) ? $result : []; - - $childrenQuery = new DbQuery(); - $childrenQuery - ->select('c.`id_cms_category`, cl.`name`') - ->from('cms_category', 'c') - ->innerJoin( - 'cms_category_lang', - 'cl', - 'cl.`id_cms_category` = c.`id_cms_category`' - ) - ->where('c.`id_parent` = ' . (int) $cmsPageCategoryId) - ->where('cl.`id_lang` = ' . $this->contextLanguageId) - ->where('cl.`id_shop` IN (' . implode(',', $this->contextShopIds) . ')') - ->groupBy('c.`id_cms_category`') - ; - - $childCategories = Db::getInstance()->executeS($childrenQuery); - $childCategories = is_array($childCategories) ? $childCategories : []; - - foreach ($childCategories as $childCategory) { - $categories['children'][] = $this->collectNestedCategoriesIdsAndNames($childCategory['id_cms_category']); - } - - return $categories; - } -} diff --git a/src/Adapter/CMS/PageCategory/CommandHandler/AbstractCmsPageCategoryHandler.php b/src/Adapter/CMS/PageCategory/CommandHandler/AbstractCmsPageCategoryHandler.php deleted file mode 100644 index 4f27fe0e..00000000 --- a/src/Adapter/CMS/PageCategory/CommandHandler/AbstractCmsPageCategoryHandler.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CleanHtml; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\DefaultLanguage; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\IsUrlRewrite; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryConstraintException; -use Symfony\Component\Validator\Validator\ValidatorInterface; - -/** - * Holds the abstraction required for Adding or updating the cms page category. - */ -abstract class AbstractCmsPageCategoryHandler extends AbstractObjectModelHandler -{ - /** - * @var ValidatorInterface - */ - private $validator; - - /** - * @param ValidatorInterface $validator - */ - public function __construct(ValidatorInterface $validator) - { - $this->validator = $validator; - } - - /** - * @param array $localisedTexts - * - * @return bool - */ - protected function assertHasDefaultLanguage(array $localisedTexts) - { - $errors = $this->validator->validate($localisedTexts, new DefaultLanguage()); - - return 0 === count($errors); - } - - /** - * @param array $localisedUrls - * - * @throws CmsPageCategoryConstraintException - */ - protected function assertIsValidLinkRewrite(array $localisedUrls) - { - foreach ($localisedUrls as $localisedUrl) { - $errors = $this->validator->validate($localisedUrl, new IsUrlRewrite()); - - if (0 !== count($errors)) { - throw new CmsPageCategoryConstraintException(sprintf('Given friendly url "%s" is not valid for link rewrite', $localisedUrl), CmsPageCategoryConstraintException::INVALID_LINK_REWRITE); - } - } - } - - /** - * @param array $localisedDescription - * - * @throws CmsPageCategoryConstraintException - */ - protected function assertDescriptionContainsCleanHtml(array $localisedDescription) - { - foreach ($localisedDescription as $description) { - $errors = $this->validator->validate($description, new CleanHtml()); - - if (0 !== count($errors)) { - throw new CmsPageCategoryConstraintException(sprintf('Given description "%s" contains javascript events or script tags', $description), CmsPageCategoryConstraintException::INVALID_DESCRIPTION); - } - } - } -} diff --git a/src/Adapter/CMS/PageCategory/CommandHandler/AddCmsPageCategoryHandler.php b/src/Adapter/CMS/PageCategory/CommandHandler/AddCmsPageCategoryHandler.php deleted file mode 100644 index ea67b22c..00000000 --- a/src/Adapter/CMS/PageCategory/CommandHandler/AddCmsPageCategoryHandler.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CommandHandler; - -use CMSCategory; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\AddCmsPageCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\CommandHandler\AddCmsPageCategoryHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CannotAddCmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; -use PrestaShopException; - -/** - * Adds cms page category - */ -final class AddCmsPageCategoryHandler extends AbstractCmsPageCategoryHandler implements AddCmsPageCategoryHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CmsPageCategoryException - */ - public function handle(AddCmsPageCategoryCommand $command) - { - if (!$this->assertHasDefaultLanguage($command->getLocalisedName())) { - throw new CmsPageCategoryConstraintException('Missing name in default language', CmsPageCategoryConstraintException::MISSING_DEFAULT_LANGUAGE_FOR_NAME); - } - - if (!$this->assertHasDefaultLanguage($command->getLocalisedFriendlyUrl())) { - throw new CmsPageCategoryConstraintException('Missing friendly url in default language', CmsPageCategoryConstraintException::MISSING_DEFAULT_LANGUAGE_FOR_FRIENDLY_URL); - } - - $this->assertIsValidLinkRewrite($command->getLocalisedFriendlyUrl()); - $this->assertDescriptionContainsCleanHtml($command->getLocalisedDescription()); - - try { - $cmsPageCategory = new CMSCategory(); - $cmsPageCategory->name = $command->getLocalisedName(); - $cmsPageCategory->active = $command->isDisplayed(); - $cmsPageCategory->id_parent = $command->getParentId()->getValue(); - $cmsPageCategory->description = $command->getLocalisedDescription(); - $cmsPageCategory->meta_title = $command->getLocalisedMetaTitle(); - $cmsPageCategory->meta_description = $command->getLocalisedMetaDescription(); - $cmsPageCategory->meta_keywords = $command->getLocalisedMetaKeywords(); - - $cmsPageCategory->link_rewrite = $command->getLocalisedFriendlyUrl(); - - if (false === $cmsPageCategory->add()) { - throw new CannotAddCmsPageCategoryException('Failed to add cms page category'); - } - - $this->associateWithShops($cmsPageCategory, $command->getShopAssociation()); - } catch (PrestaShopException $exception) { - throw new CmsPageCategoryException('An unexpected error occurred when adding cms page category', 0, $exception); - } - - return new CmsPageCategoryId((int) $cmsPageCategory->id); - } -} diff --git a/src/Adapter/CMS/PageCategory/CommandHandler/BulkDeleteCmsPageCategoryHandler.php b/src/Adapter/CMS/PageCategory/CommandHandler/BulkDeleteCmsPageCategoryHandler.php deleted file mode 100644 index f9a9c6ae..00000000 --- a/src/Adapter/CMS/PageCategory/CommandHandler/BulkDeleteCmsPageCategoryHandler.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CommandHandler; - -use CMSCategory; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\BulkDeleteCmsPageCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\CommandHandler\BulkDeleteCmsPageCategoryHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CannotDeleteCmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryNotFoundException; -use PrestaShopException; - -/** - * Class BulkDeleteCmsPageCategoryHandler is responsible for deleting multiple cms page categories. - */ -final class BulkDeleteCmsPageCategoryHandler implements BulkDeleteCmsPageCategoryHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CmsPageCategoryException - */ - public function handle(BulkDeleteCmsPageCategoryCommand $command) - { - try { - foreach ($command->getCmsPageCategoryIds() as $cmsPageCategoryId) { - $entity = new CMSCategory($cmsPageCategoryId->getValue()); - - if (0 >= $entity->id) { - throw new CmsPageCategoryNotFoundException(sprintf('Cms category object with id "%s" has not been found for deleting.', $cmsPageCategoryId->getValue())); - } - - if (false === $entity->delete()) { - throw new CannotDeleteCmsPageCategoryException(sprintf('Unable to delete cms category object with id "%s"', $cmsPageCategoryId->getValue()), CannotDeleteCmsPageCategoryException::FAILED_BULK_DELETE); - } - } - } catch (PrestaShopException $e) { - throw new CmsPageCategoryException('Unexpected error occurred when handling bulk delete cms category', 0, $e); - } - } -} diff --git a/src/Adapter/CMS/PageCategory/CommandHandler/BulkDisableCmsPageCategoryHandler.php b/src/Adapter/CMS/PageCategory/CommandHandler/BulkDisableCmsPageCategoryHandler.php deleted file mode 100644 index d05ef260..00000000 --- a/src/Adapter/CMS/PageCategory/CommandHandler/BulkDisableCmsPageCategoryHandler.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CommandHandler; - -use CMSCategory; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\BulkDisableCmsPageCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\CommandHandler\BulkDisableCmsPageCategoryHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CannotDisableCmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryNotFoundException; -use PrestaShopException; - -/** - * Class BulkDisableCmsPageCategoryHandler is responsible for deleting multiple cms page categories. - */ -final class BulkDisableCmsPageCategoryHandler implements BulkDisableCmsPageCategoryHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CmsPageCategoryException - */ - public function handle(BulkDisableCmsPageCategoryCommand $command) - { - try { - foreach ($command->getCmsPageCategoryIds() as $cmsPageCategoryId) { - $entity = new CMSCategory($cmsPageCategoryId->getValue()); - - if (0 >= $entity->id) { - throw new CmsPageCategoryNotFoundException(sprintf('Cms category object with id "%s" has not been found for disabling status.', $cmsPageCategoryId->getValue())); - } - - $entity->active = false; - - if (false === $entity->update()) { - throw new CannotDisableCmsPageCategoryException(sprintf('Unable to disable cms category object with id "%s"', $cmsPageCategoryId->getValue())); - } - } - } catch (PrestaShopException $e) { - throw new CmsPageCategoryException('Unexpected error occurred when handling bulk disable cms category', 0, $e); - } - } -} diff --git a/src/Adapter/CMS/PageCategory/CommandHandler/BulkEnableCmsPageCategoryHandler.php b/src/Adapter/CMS/PageCategory/CommandHandler/BulkEnableCmsPageCategoryHandler.php deleted file mode 100644 index 009dfb7a..00000000 --- a/src/Adapter/CMS/PageCategory/CommandHandler/BulkEnableCmsPageCategoryHandler.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CommandHandler; - -use CMSCategory; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\BulkEnableCmsPageCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\CommandHandler\BulkEnableCmsPageCategoryHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CannotEnableCmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryNotFoundException; -use PrestaShopException; - -/** - * Class BulkEnableCmsPageCategoryCommand is responsible for enabling cms category pages. - */ -final class BulkEnableCmsPageCategoryHandler implements BulkEnableCmsPageCategoryHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CmsPageCategoryException - */ - public function handle(BulkEnableCmsPageCategoryCommand $command) - { - try { - foreach ($command->getCmsPageCategoryIds() as $cmsPageCategoryId) { - $entity = new CMSCategory($cmsPageCategoryId->getValue()); - - if (0 >= $entity->id) { - throw new CmsPageCategoryNotFoundException(sprintf('Cms category object with id "%s" has not been found for enabling status.', $cmsPageCategoryId->getValue())); - } - - $entity->active = true; - - if (false === $entity->update()) { - throw new CannotEnableCmsPageCategoryException(sprintf('Unable to enable cms category object with id "%s"', $cmsPageCategoryId->getValue())); - } - } - } catch (PrestaShopException $e) { - throw new CmsPageCategoryException('Unexpected error occurred when handling bulk enable cms category', 0, $e); - } - } -} diff --git a/src/Adapter/CMS/PageCategory/CommandHandler/DeleteCmsPageCategoryHandler.php b/src/Adapter/CMS/PageCategory/CommandHandler/DeleteCmsPageCategoryHandler.php deleted file mode 100644 index 76ae1840..00000000 --- a/src/Adapter/CMS/PageCategory/CommandHandler/DeleteCmsPageCategoryHandler.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CommandHandler; - -use CMSCategory; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\DeleteCmsPageCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\CommandHandler\DeleteCmsPageCategoryHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CannotDeleteCmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryNotFoundException; -use PrestaShopException; - -/** - * Class DeleteCmsPageCategoryHandler is responsible for deleting cms page category. - */ -final class DeleteCmsPageCategoryHandler implements DeleteCmsPageCategoryHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CmsPageCategoryException - */ - public function handle(DeleteCmsPageCategoryCommand $command) - { - try { - $entity = new CMSCategory($command->getCmsPageCategoryId()->getValue()); - - if (0 >= $entity->id) { - throw new CmsPageCategoryNotFoundException(sprintf('Cms category object with id "%s" has not been found for deletion.', $command->getCmsPageCategoryId()->getValue())); - } - - if (false === $entity->delete()) { - throw new CannotDeleteCmsPageCategoryException(sprintf('Unable to delete cms category object with id "%s"', $command->getCmsPageCategoryId()->getValue()), CannotDeleteCmsPageCategoryException::FAILED_DELETE); - } - } catch (PrestaShopException $exception) { - throw new CmsPageCategoryException(sprintf('An error occurred when deleting cms category object with id "%s"', $command->getCmsPageCategoryId()->getValue()), 0, $exception); - } - } -} diff --git a/src/Adapter/CMS/PageCategory/CommandHandler/EditCmsPageCategoryHandler.php b/src/Adapter/CMS/PageCategory/CommandHandler/EditCmsPageCategoryHandler.php deleted file mode 100644 index e954064e..00000000 --- a/src/Adapter/CMS/PageCategory/CommandHandler/EditCmsPageCategoryHandler.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CommandHandler; - -use CMSCategory; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\EditCmsPageCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\CommandHandler\EditCmsPageCategoryHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CannotUpdateCmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryNotFoundException; -use PrestaShopException; - -/** - * Edits cms page category. - */ -final class EditCmsPageCategoryHandler extends AbstractCmsPageCategoryHandler implements EditCmsPageCategoryHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CmsPageCategoryException - */ - public function handle(EditCmsPageCategoryCommand $command) - { - try { - $cmsPageCategory = new CMSCategory($command->getCmsPageCategoryId()->getValue()); - - if (0 >= $cmsPageCategory->id) { - throw new CmsPageCategoryNotFoundException(sprintf('Unable to find cms page category with id "%s"', $cmsPageCategory->id)); - } - - if (null !== $command->getLocalisedName()) { - if (!$this->assertHasDefaultLanguage($command->getLocalisedName())) { - throw new CmsPageCategoryConstraintException('Missing name in default language', CmsPageCategoryConstraintException::MISSING_DEFAULT_LANGUAGE_FOR_NAME); - } - $cmsPageCategory->name = $command->getLocalisedName(); - } - - if (null !== $command->isDisplayed()) { - $cmsPageCategory->active = $command->isDisplayed(); - } - - if (null !== $command->getParentId()) { - $this->assertCmsCategoryCanBeMovedToParent( - $command->getCmsPageCategoryId()->getValue(), - $command->getParentId()->getValue() - ); - $cmsPageCategory->id_parent = $command->getParentId()->getValue(); - } - - if (null !== $command->getLocalisedDescription()) { - $this->assertDescriptionContainsCleanHtml($command->getLocalisedDescription()); - $cmsPageCategory->description = $command->getLocalisedDescription(); - } - - if (null !== $command->getLocalisedMetaTitle()) { - $cmsPageCategory->meta_title = $command->getLocalisedMetaTitle(); - } - - if (null !== $command->getLocalisedMetaDescription()) { - $cmsPageCategory->meta_description = $command->getLocalisedMetaDescription(); - } - - if (null !== $command->getLocalisedMetaKeywords()) { - $cmsPageCategory->meta_keywords = $command->getLocalisedMetaKeywords(); - } - - if (null !== $command->getLocalisedFriendlyUrl()) { - if (!$this->assertHasDefaultLanguage($command->getLocalisedFriendlyUrl())) { - throw new CmsPageCategoryConstraintException('Missing friendly url in default language', CmsPageCategoryConstraintException::MISSING_DEFAULT_LANGUAGE_FOR_FRIENDLY_URL); - } - $this->assertIsValidLinkRewrite($command->getLocalisedFriendlyUrl()); - - $cmsPageCategory->link_rewrite = $command->getLocalisedFriendlyUrl(); - } - - if (false === $cmsPageCategory->update()) { - throw new CannotUpdateCmsPageCategoryException('Failed to update cms page category'); - } - - if (null !== $command->getShopAssociation()) { - $this->associateWithShops($cmsPageCategory, $command->getShopAssociation()); - } - } catch (PrestaShopException $exception) { - throw new CmsPageCategoryException('An unexpected error occurred when updating cms page category', 0, $exception); - } - } - - /** - * Adds if the current category is not being moved to the same category or its own child. - * - * @param int $cmsCategoryId - * @param int $cmsCategoryParentId - * - * @throws CmsPageCategoryConstraintException - */ - private function assertCmsCategoryCanBeMovedToParent($cmsCategoryId, $cmsCategoryParentId) - { - if (!CMSCategory::checkBeforeMove($cmsCategoryId, $cmsCategoryParentId)) { - throw new CmsPageCategoryConstraintException(sprintf('Unable to move cms category "%s" to parent category "%s"', $cmsCategoryId, $cmsCategoryParentId), CmsPageCategoryConstraintException::CANNOT_MOVE_CATEGORY_TO_PARENT); - } - } -} diff --git a/src/Adapter/CMS/PageCategory/CommandHandler/ToggleCmsPageCategoryStatusHandler.php b/src/Adapter/CMS/PageCategory/CommandHandler/ToggleCmsPageCategoryStatusHandler.php deleted file mode 100644 index f48a04ce..00000000 --- a/src/Adapter/CMS/PageCategory/CommandHandler/ToggleCmsPageCategoryStatusHandler.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CommandHandler; - -use CMSCategory; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\ToggleCmsPageCategoryStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\CommandHandler\ToggleCmsPageCategoryStatusHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CannotToggleCmsPageCategoryStatusException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryNotFoundException; -use PrestaShopException; - -/** - * Class ToggleCmsPageCategoryStatusHandler is responsible for turning on and off cms page category status. - */ -final class ToggleCmsPageCategoryStatusHandler implements ToggleCmsPageCategoryStatusHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CmsPageCategoryException - */ - public function handle(ToggleCmsPageCategoryStatusCommand $command) - { - try { - $entity = new CMSCategory($command->getCmsPageCategoryId()->getValue()); - - if (0 >= $entity->id) { - throw new CmsPageCategoryNotFoundException(sprintf('Cms category object with id "%s" has not been found for status changing.', $command->getCmsPageCategoryId()->getValue())); - } - - if (false === $entity->toggleStatus()) { - throw new CannotToggleCmsPageCategoryStatusException(sprintf('Unable to toggle cms category with id "%s"', $command->getCmsPageCategoryId()->getValue())); - } - } catch (PrestaShopException $exception) { - throw new CmsPageCategoryException(sprintf('An error occurred when toggling status for cms page object with id "%s"', $command->getCmsPageCategoryId()->getValue()), 0, $exception); - } - } -} diff --git a/src/Adapter/CMS/PageCategory/QueryHandler/GetCmsPageCategoriesForBreadcrumbHandler.php b/src/Adapter/CMS/PageCategory/QueryHandler/GetCmsPageCategoriesForBreadcrumbHandler.php deleted file mode 100644 index f28a8db7..00000000 --- a/src/Adapter/CMS/PageCategory/QueryHandler/GetCmsPageCategoriesForBreadcrumbHandler.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\PageCategory\QueryHandler; - -use CMSCategory; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query\GetCmsPageCategoriesForBreadcrumb; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryHandler\GetCmsPageCategoriesForBreadcrumbHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryResult\Breadcrumb; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryResult\BreadcrumbItem; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; -use PrestaShopException; - -/** - * Class GetCmsPageCategoriesForBreadcrumbHandler is responsible for providing required data for displaying cms page category - * breadcrumbs. - */ -final class GetCmsPageCategoriesForBreadcrumbHandler implements GetCmsPageCategoriesForBreadcrumbHandlerInterface -{ - /** - * @var int - */ - private $contextLanguageId; - - /** - * @param int $contextLanguageId - */ - public function __construct($contextLanguageId) - { - $this->contextLanguageId = $contextLanguageId; - } - - /** - * {@inheritdoc} - * - * @throws CmsPageCategoryException - */ - public function handle(GetCmsPageCategoriesForBreadcrumb $query) - { - try { - $currentCategory = new CMSCategory( - $query->getCurrentCategoryId()->getValue(), - $this->contextLanguageId - ); - - if (0 >= $currentCategory->id) { - throw new CmsPageCategoryNotFoundException(sprintf('Cms category object with id "%s" has not been found for retrieving breadcrumbs', $query->getCurrentCategoryId()->getValue())); - } - - $rootCategory = new CMSCategory( - CmsPageCategoryId::ROOT_CMS_PAGE_CATEGORY_ID, - $this->contextLanguageId - ); - } catch (PrestaShopException $exception) { - throw new CmsPageCategoryException(sprintf('An error occurred when finding cms category object with id "%s" or root category by id "%s"', $query->getCurrentCategoryId()->getValue(), CmsPageCategoryId::ROOT_CMS_PAGE_CATEGORY_ID), 0, $exception); - } - - $rootCategoryData = [ - 'id_cms_category' => CmsPageCategoryId::ROOT_CMS_PAGE_CATEGORY_ID, - 'name' => $rootCategory->name, - ]; - - if (CmsPageCategoryId::ROOT_CMS_PAGE_CATEGORY_ID === $query->getCurrentCategoryId()->getValue()) { - return new Breadcrumb([ - new BreadcrumbItem( - (int) $rootCategoryData['id_cms_category'], - $rootCategoryData['name'] - ), - ]); - } - - $parentCategories = $currentCategory->getParentsCategories($this->contextLanguageId); - $parentCategories[] = $rootCategoryData; - $parentCategories = array_reverse($parentCategories); - - $categories = []; - foreach ($parentCategories as $category) { - $categories[] = new BreadcrumbItem( - (int) $category['id_cms_category'], - $category['name'] - ); - } - - return new Breadcrumb($categories); - } -} diff --git a/src/Adapter/CMS/PageCategory/QueryHandler/GetCmsPageCategoryForEditingHandler.php b/src/Adapter/CMS/PageCategory/QueryHandler/GetCmsPageCategoryForEditingHandler.php deleted file mode 100644 index b654d32a..00000000 --- a/src/Adapter/CMS/PageCategory/QueryHandler/GetCmsPageCategoryForEditingHandler.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\PageCategory\QueryHandler; - -use CMSCategory; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query\GetCmsPageCategoryForEditing; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryHandler\GetCmsPageCategoryForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryResult\EditableCmsPageCategory; -use PrestaShopException; - -/** - * Class GetCmsPageCategoryForEditingHandler is responsible for retrieving cms page category form data. - * - * @internal - */ -final class GetCmsPageCategoryForEditingHandler implements GetCmsPageCategoryForEditingHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CmsPageCategoryException - */ - public function handle(GetCmsPageCategoryForEditing $query) - { - try { - $cmsPageCategory = new CMSCategory($query->getCmsPageCategoryId()->getValue()); - - if (0 >= $cmsPageCategory->id) { - throw new CmsPageCategoryNotFoundException(sprintf('Cms category object with id "%s" has not been found', $query->getCmsPageCategoryId()->getValue())); - } - - $shopIds = is_array($cmsPageCategory->getAssociatedShops()) ? $cmsPageCategory->getAssociatedShops() : []; - } catch (PrestaShopException $exception) { - throw new CmsPageCategoryException(sprintf('An error occurred when retrieving cms page category data with id %s', $query->getCmsPageCategoryId()->getValue()), 0, $exception); - } - - return new EditableCmsPageCategory( - is_array($cmsPageCategory->name) ? $cmsPageCategory->name : [], - $cmsPageCategory->active, - (int) $cmsPageCategory->id_parent, - is_array($cmsPageCategory->description) ? $cmsPageCategory->description : [], - is_array($cmsPageCategory->meta_description) ? $cmsPageCategory->meta_description : [], - is_array($cmsPageCategory->meta_keywords) ? $cmsPageCategory->meta_keywords : [], - is_array($cmsPageCategory->meta_title) ? $cmsPageCategory->meta_title : [], - is_array($cmsPageCategory->link_rewrite) ? $cmsPageCategory->link_rewrite : [], - $shopIds - ); - } -} diff --git a/src/Adapter/CMS/PageCategory/QueryHandler/GetCmsPageCategoryNameForListingHandler.php b/src/Adapter/CMS/PageCategory/QueryHandler/GetCmsPageCategoryNameForListingHandler.php deleted file mode 100644 index d19cd31a..00000000 --- a/src/Adapter/CMS/PageCategory/QueryHandler/GetCmsPageCategoryNameForListingHandler.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\PageCategory\QueryHandler; - -use CMSCategory; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query\GetCmsPageCategoryNameForListing; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryHandler\GetCmsPageCategoryNameForListingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; -use Symfony\Component\HttpFoundation\RequestStack; - -/** - * Gets name by cms category which are used for display in cms listing. - */ -final class GetCmsPageCategoryNameForListingHandler implements GetCmsPageCategoryNameForListingHandlerInterface -{ - /** - * @var int - */ - private $contextLanguageId; - - /** - * @var RequestStack - */ - private $requestStack; - - /** - * @param int $contextLanguageId - * @param RequestStack $requestStack - */ - public function __construct( - $contextLanguageId, - RequestStack $requestStack - ) { - $this->contextLanguageId = $contextLanguageId; - $this->requestStack = $requestStack; - } - - /** - * {@inheritdoc} - */ - public function handle(GetCmsPageCategoryNameForListing $query) - { - $cmsCategory = new CMSCategory($this->getCmsCategoryIdFromRequest()); - - return isset($cmsCategory->name[$this->contextLanguageId]) ? $cmsCategory->name[$this->contextLanguageId] : ''; - } - - /** - * Gets id from request or fall-backs to the default one if not found. - * - * @return int - */ - private function getCmsCategoryIdFromRequest() - { - $currentRequest = $this->requestStack->getCurrentRequest(); - $categoryIdFromRequest = null; - if (null !== $currentRequest) { - $categoryIdFromRequest = $currentRequest->query->getInt('id_cms_category'); - } - - return $categoryIdFromRequest ?: CmsPageCategoryId::ROOT_CMS_PAGE_CATEGORY_ID; - } -} diff --git a/src/Adapter/CMS/PageCategory/QueryHandler/GetCmsPageParentCategoryIdForRedirectionHandler.php b/src/Adapter/CMS/PageCategory/QueryHandler/GetCmsPageParentCategoryIdForRedirectionHandler.php deleted file mode 100644 index 3221262a..00000000 --- a/src/Adapter/CMS/PageCategory/QueryHandler/GetCmsPageParentCategoryIdForRedirectionHandler.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CMS\PageCategory\QueryHandler; - -use CMSCategory; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query\GetCmsPageParentCategoryIdForRedirection; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryHandler\GetCmsPageParentCategoryIdForRedirectionHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; -use PrestaShopException; - -/** - * Class GetCmsPageParentCategoryIdForRedirectionHandler is responsible for providing cms page categories parent id - * for redirecting to the right controller after create, edit, delete, toggle actions. - */ -final class GetCmsPageParentCategoryIdForRedirectionHandler implements GetCmsPageParentCategoryIdForRedirectionHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CmsPageCategoryException - */ - public function handle(GetCmsPageParentCategoryIdForRedirection $query) - { - try { - $entity = new CMSCategory($query->getCmsPageCategoryId()->getValue()); - $parentId = (int) $entity->id_parent; - } catch (PrestaShopException $e) { - $parentId = CmsPageCategoryId::ROOT_CMS_PAGE_CATEGORY_ID; - } - - return new CmsPageCategoryId($parentId); - } -} diff --git a/src/Adapter/Cache/CacheAdapter.php b/src/Adapter/Cache/CacheAdapter.php deleted file mode 100644 index c300d7bc..00000000 --- a/src/Adapter/Cache/CacheAdapter.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cache; - -use Cache; - -/** - * Adapter for generic cache methods. - */ -class CacheAdapter -{ - /** - * @param string $key - * @param string $value - */ - public function store($key, $value) - { - return Cache::store($key, $value); - } - - /** - * @param string $key - * - * @return mixed - */ - public function retrieve($key) - { - return Cache::retrieve($key); - } - - /** - * @param string $key - * - * @return bool - */ - public function isStored($key) - { - return Cache::isStored($key); - } -} diff --git a/src/Adapter/Cache/CacheClearer.php b/src/Adapter/Cache/CacheClearer.php deleted file mode 100644 index b28e5c5f..00000000 --- a/src/Adapter/Cache/CacheClearer.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cache; - -use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface; - -/** - * Class able to clear application caches. - * - * @internal - */ -class CacheClearer -{ - /** - * @var CacheClearerInterface - */ - private $cacheClearerChain; - - /** - * @var CacheClearerInterface - */ - private $symfonyCacheClearer; - - /** - * @var CacheClearerInterface - */ - private $mediaCacheClearer; - - /** - * @var CacheClearerInterface - */ - private $smartyCacheClearer; - - /** - * @param CacheClearerInterface $cacheClearerChain - * @param CacheClearerInterface $symfonyCacheClearer - * @param CacheClearerInterface $mediaCacheClearer - * @param CacheClearerInterface $smartyCacheClearer - */ - public function __construct( - CacheClearerInterface $cacheClearerChain, - CacheClearerInterface $symfonyCacheClearer, - CacheClearerInterface $mediaCacheClearer, - CacheClearerInterface $smartyCacheClearer - ) { - $this->cacheClearerChain = $cacheClearerChain; - $this->symfonyCacheClearer = $symfonyCacheClearer; - $this->mediaCacheClearer = $mediaCacheClearer; - $this->smartyCacheClearer = $smartyCacheClearer; - } - - /** - * Clear all application caches. - * - * @deprecated since 1.7.6. Use CacheClearerChain instead. - */ - public function clearAllCaches() - { - @trigger_error( - 'Deprecated since 1.7.6, to be removed in 1.8. Use CacheClearerChain instead.', - E_USER_DEPRECATED - ); - - $this->cacheClearerChain->clear(); - } - - /** - * Clear Symfony cache. - * - * @deprecated since 1.7.6. Use SymfonyCacheClearer instead. - */ - public function clearSymfonyCache() - { - @trigger_error( - 'Deprecated since 1.7.6, to be removed in 1.8. Use SymfonyCacheClearer instead.', - E_USER_DEPRECATED - ); - - $this->symfonyCacheClearer->clear(); - } - - /** - * Clear media cache only. - * - * @deprecated since 1.7.6. Use MediaCacheClearer instead. - */ - public function clearMediaCache() - { - @trigger_error( - 'Deprecated since 1.7.6, to be removed in 1.8. Use MediaCacheClearer instead.', - E_USER_DEPRECATED - ); - - $this->mediaCacheClearer->clear(); - } - - /** - * Clear smarty cache only. - * - * @deprecated since 1.7.6. Use SmartyCacheClearer instead. - */ - public function clearSmartyCache() - { - @trigger_error( - 'Deprecated since 1.7.6, to be removed in 1.8. Use SmartyCacheClearer instead.', - E_USER_DEPRECATED - ); - - $this->smartyCacheClearer->clear(); - } -} diff --git a/src/Adapter/Cache/CachingConfiguration.php b/src/Adapter/Cache/CachingConfiguration.php deleted file mode 100644 index f4e8ba35..00000000 --- a/src/Adapter/Cache/CachingConfiguration.php +++ /dev/null @@ -1,157 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cache; - -use PrestaShop\PrestaShop\Adapter\Configuration\PhpParameters; -use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * This class manages Caching configuration for a Shop. - */ -class CachingConfiguration implements DataConfigurationInterface -{ - /** - * @var MemcacheServerManager - */ - private $memcacheServerManager; - - /** - * @var PhpParameters - */ - private $phpParameters; - - /** - * @var CacheClearerInterface - */ - private $symfonyCacheClearer; - - /** - * @var bool check if the caching is enabled - */ - private $isCachingEnabled; - - /** - * @var string the selected Caching system: 'CacheApc' for instance - */ - private $cachingSystem; - - /** - * @param MemcacheServerManager $memcacheServerManager - * @param PhpParameters $phpParameters - * @param CacheClearerInterface $symfonyCacheClearer - * @param $isCachingEnabled - * @param $cachingSystem - */ - public function __construct( - MemcacheServerManager $memcacheServerManager, - PhpParameters $phpParameters, - CacheClearerInterface $symfonyCacheClearer, - $isCachingEnabled, - $cachingSystem - ) { - $this->memcacheServerManager = $memcacheServerManager; - $this->phpParameters = $phpParameters; - $this->symfonyCacheClearer = $symfonyCacheClearer; - $this->isCachingEnabled = $isCachingEnabled; - $this->cachingSystem = $cachingSystem; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'use_cache' => $this->isCachingEnabled, - 'caching_system' => $this->cachingSystem, - 'servers' => $this->memcacheServerManager->getServers(), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - $errors = []; - - if ($this->validateConfiguration($configuration)) { - $errors = $this->updatePhpCacheConfiguration($configuration); - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['use_cache'], - $configuration['caching_system'], - $configuration['servers'] - ); - } - - /** - * Update the Php configuration for Cache feature and system. - * - * @return array the errors list during the update operation - */ - private function updatePhpCacheConfiguration(array $configuration) - { - $errors = []; - - if ( - $configuration['use_cache'] !== $this->isCachingEnabled - && null !== $configuration['caching_system'] - ) { - $this->phpParameters->setProperty('parameters.ps_cache_enable', $configuration['use_cache']); - } - - if ( - null !== $configuration['caching_system'] - && $configuration['caching_system'] !== $this->cachingSystem - ) { - $this->phpParameters->setProperty('parameters.ps_caching', $configuration['caching_system']); - } - - if (false === $this->phpParameters->saveConfiguration()) { - $errors[] = [ - 'key' => 'The settings file cannot be overwritten.', - 'domain' => 'Admin.Advparameters.Notification', - 'parameters' => [], - ]; - } - - $this->symfonyCacheClearer->clear(); - - return $errors; - } -} diff --git a/src/Adapter/Cache/Clearer/ClassIndexCacheClearer.php b/src/Adapter/Cache/Clearer/ClassIndexCacheClearer.php deleted file mode 100644 index 47093203..00000000 --- a/src/Adapter/Cache/Clearer/ClassIndexCacheClearer.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cache\Clearer; - -use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface; -use PrestaShopAutoload; - -/** - * Class ClassIndexCacheClearer clears current class index and generates new one. - * - * @internal - */ -final class ClassIndexCacheClearer implements CacheClearerInterface -{ - /** - * {@inheritdoc} - */ - public function clear() - { - PrestaShopAutoload::getInstance()->generateIndex(); - } -} diff --git a/src/Adapter/Cache/Clearer/MediaCacheClearer.php b/src/Adapter/Cache/Clearer/MediaCacheClearer.php deleted file mode 100644 index f8b21bda..00000000 --- a/src/Adapter/Cache/Clearer/MediaCacheClearer.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cache\Clearer; - -use Media; -use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface; - -/** - * Class MediaCacheClearer clears Front Office theme's Javascript & CSS cache. - * - * @internal - */ -final class MediaCacheClearer implements CacheClearerInterface -{ - /** - * {@inheritdoc} - */ - public function clear() - { - Media::clearCache(); - } -} diff --git a/src/Adapter/Cache/Clearer/SmartyCacheClearer.php b/src/Adapter/Cache/Clearer/SmartyCacheClearer.php deleted file mode 100644 index 28893632..00000000 --- a/src/Adapter/Cache/Clearer/SmartyCacheClearer.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cache\Clearer; - -use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface; -use Tools; - -/** - * Class SmartyCacheClearer clears Smarty cache. - * - * @internal - */ -final class SmartyCacheClearer implements CacheClearerInterface -{ - /** - * {@inheritdoc} - */ - public function clear() - { - Tools::clearSmartyCache(); - } -} diff --git a/src/Adapter/Cache/Clearer/SymfonyCacheClearer.php b/src/Adapter/Cache/Clearer/SymfonyCacheClearer.php deleted file mode 100644 index f34c14c8..00000000 --- a/src/Adapter/Cache/Clearer/SymfonyCacheClearer.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cache\Clearer; - -use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface; -use Tools; - -/** - * Class SymfonyCacheClearer clears Symfony cache directly from filesystem. - * - * @internal - */ -final class SymfonyCacheClearer implements CacheClearerInterface -{ - /** - * {@inheritdoc} - */ - public function clear() - { - Tools::clearSf2Cache(); - } -} diff --git a/src/Adapter/Cache/Clearer/XmlCacheClearer.php b/src/Adapter/Cache/Clearer/XmlCacheClearer.php deleted file mode 100644 index c0220085..00000000 --- a/src/Adapter/Cache/Clearer/XmlCacheClearer.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cache\Clearer; - -use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface; -use Tools; - -/** - * Class XmlCacheClearer clears cache under /config/xml/ directory. - * - * @internal - */ -final class XmlCacheClearer implements CacheClearerInterface -{ - /** - * {@inheritdoc} - */ - public function clear() - { - Tools::clearXMLCache(); - } -} diff --git a/src/Adapter/Cache/CombineCompressCacheConfiguration.php b/src/Adapter/Cache/CombineCompressCacheConfiguration.php deleted file mode 100644 index 38f29a6b..00000000 --- a/src/Adapter/Cache/CombineCompressCacheConfiguration.php +++ /dev/null @@ -1,225 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cache; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\Tools; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\Foundation\Filesystem\FileSystem as PsFileSystem; -use Symfony\Component\Filesystem\Exception\IOExceptionInterface; -use Symfony\Component\Filesystem\Filesystem; - -/** - * This class manages CCC features configuration for a Shop. - */ -class CombineCompressCacheConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - /** - * @var Filesystem - */ - private $filesystem; - - /** - * @var Tools - */ - private $tools; - - /** - * @var string Absolute path to the theme directory - */ - private $themePath; - - /** - * @var string Current active theme name - */ - private $themeName; - - public function __construct( - Configuration $configuration, - Filesystem $filesystem, - Tools $tools, - $themePath, - $themeName - ) { - $this->configuration = $configuration; - $this->filesystem = $filesystem; - $this->tools = $tools; - $this->themePath = $themePath; - $this->themeName = $themeName; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'smart_cache_css' => $this->configuration->getBoolean('PS_CSS_THEME_CACHE'), - 'smart_cache_js' => $this->configuration->getBoolean('PS_JS_THEME_CACHE'), - 'apache_optimization' => $this->configuration->getBoolean('PS_HTACCESS_CACHE_CONTROL'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - $errors = []; - - if ($this->validateConfiguration($configuration)) { - $this->updateCachesVersionsIfNeeded($configuration); - if ($configuration['smart_cache_css'] || $configuration['smart_cache_js']) { - // Manage JS & CSS Smart cache - if (!$this->createThemeCacheFolder()) { - $errors[] = [ - 'key' => 'To use Smarty Cache, the directory %directorypath% must be writable.', - 'domain' => 'Admin.Advparameters.Notification', - 'parameters' => [ - '%directorypath%' => $this->getThemeCacheFolder(), - ], - ]; - } - } - - // Manage Apache optimization - $apacheError = $this->manageApacheOptimization((bool) $configuration['apache_optimization']); - - if (count($apacheError) > 0) { - $errors[] = $apacheError; - } - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['smart_cache_css'], - $configuration['smart_cache_js'], - $configuration['apache_optimization'] - ); - } - - /** - * @return string Absolute path the the current active theme - */ - private function getThemeCacheFolder() - { - return $this->themePath . '/' . $this->themeName . '/cache/'; - } - - /** - * Creates Cache folder for the active theme. - * - * @return bool - */ - private function createThemeCacheFolder() - { - try { - $folder = $this->getThemeCacheFolder(); - $this->filesystem->mkdir($folder, PsFileSystem::DEFAULT_MODE_FOLDER); - - return true; - } catch (IOExceptionInterface $e) { - return false; - } - } - - /** - * Update Cache version of assets if needed. - * - * @param array the configuration - */ - private function updateCachesVersionsIfNeeded(array $configuration) - { - $cacheCSS = $configuration['smart_cache_css']; - $currentCacheCSS = $this->configuration->get('PS_CSS_THEME_CACHE'); - - $cacheJS = $configuration['smart_cache_js']; - $currentCacheJS = $this->configuration->get('PS_JS_THEME_CACHE'); - - if ($cacheCSS !== $currentCacheCSS) { - $cssCacheVersion = $this->configuration->get('PS_CCCCSS_VERSION') + 1; - $this->configuration->set('PS_CCCCSS_VERSION', $cssCacheVersion); - $this->configuration->set('PS_CSS_THEME_CACHE', $cacheCSS); - } - - if ($cacheJS !== $currentCacheJS) { - $jsCacheVersion = $this->configuration->get('PS_CCCJS_VERSION') + 1; - $this->configuration->set('PS_CCCCSS_VERSION', $jsCacheVersion); - $this->configuration->set('PS_JS_THEME_CACHE', $cacheJS); - } - } - - /** - * Creates .htaccess if Apache optimization feature is enabled. - * - * @param bool $enabled - * - * @return array not empty in case of error - */ - private function manageApacheOptimization($enabled) - { - $errors = []; - $isCurrentlyEnabled = (bool) $this->configuration->get('PS_HTACCESS_CACHE_CONTROL'); - - // feature activation - if (false === $isCurrentlyEnabled && true === $enabled) { - $this->configuration->set('PS_HTACCESS_CACHE_CONTROL', true); - if (!$this->tools->generateHtaccess()) { - $errors = [ - 'key' => 'Before being able to use this tool, you need to:[1][2]Create a blank .htaccess in your root directory.[/2][2]Give it write permissions (CHMOD 666 on Unix system).[/2][/1]', - 'domain' => 'Admin.Advparameters.Notification', - 'parameters' => [ - '[1]' => '
    ', - '[/1]' => '
', - '[2]' => '
  • ', - '[/2]' => '
  • ', - ], - ]; - $this->configuration->set('PS_HTACCESS_CACHE_CONTROL', false); - } - } - - if (true === $isCurrentlyEnabled && false === $enabled) { - $this->configuration->set('PS_HTACCESS_CACHE_CONTROL', false); - $this->tools->generateHtaccess(); - } - - return $errors; - } -} diff --git a/src/Adapter/Cache/MemcacheServerManager.php b/src/Adapter/Cache/MemcacheServerManager.php deleted file mode 100644 index 55ef6c54..00000000 --- a/src/Adapter/Cache/MemcacheServerManager.php +++ /dev/null @@ -1,121 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cache; - -use Doctrine\DBAL\Connection; -use Memcache; -use Memcached; - -/** - * This class manages Memcache(d) servers in "Configure > Advanced Parameters > Performance" page. - */ -class MemcacheServerManager -{ - /** - * @var Connection - */ - private $connection; - - /** - * @var string - */ - private $tableName; - - public function __construct(Connection $connection, $dbPrefix) - { - $this->connection = $connection; - $this->tableName = $dbPrefix . 'memcached_servers'; - } - - /** - * Add a memcache server. - * - * @param string $serverIp - * @param int $serverPort - * @param int $serverWeight - */ - public function addServer($serverIp, $serverPort, $serverWeight) - { - $this->connection->executeUpdate('INSERT INTO ' . $this->tableName . ' (ip, port, weight) VALUES(:serverIp, :serverPort, :serverWeight)', [ - 'serverIp' => $serverIp, - 'serverPort' => (int) $serverPort, - 'serverWeight' => (int) $serverWeight, - ]); - - return [ - 'id' => $this->connection->lastInsertId(), - 'server_ip' => $serverIp, - 'server_port' => $serverPort, - 'server_weight' => $serverWeight, - ]; - } - - /** - * Test if a Memcache configuration is valid. - * - * @param string $serverIp - * @param string @serverPort - * - * @return bool - */ - public function testConfiguration($serverIp, $serverPort) - { - if (extension_loaded('memcached')) { - $memcached = new Memcached(); - $memcached->addServer($serverIp, $serverPort); - $version = $memcached->getVersion(); - - return is_array($version) && false === in_array('255.255.255', $version, true); - } - - return true === @memcache_connect($serverIp, $serverPort); - } - - /** - * Delete a memcache server (a deletion returns the number of rows deleted). - * - * @param int $serverId_server id (in database) - * - * @return bool - */ - public function deleteServer($serverId) - { - $deletionSuccess = $this->connection->delete($this->tableName, ['id_memcached_server' => $serverId]); - - return 1 === $deletionSuccess; - } - - /** - * Get list of memcached servers. - * - * @return array - */ - public function getServers() - { - return $this->connection->fetchAll('SELECT * FROM ' . $this->tableName, []); - } -} diff --git a/src/Adapter/CacheManager.php b/src/Adapter/CacheManager.php deleted file mode 100644 index 8672b8a0..00000000 --- a/src/Adapter/CacheManager.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use Cache; - -/** - * Class CacheManager drives the cache behavior. - * - * Features to drive the legacy cache from new code architecture. - */ -class CacheManager -{ - /** - * Cleans the cache for specific cache key. - * - * @param $key - */ - public function clean($key) - { - Cache::clean($key); - } -} diff --git a/src/Adapter/Carrier/CarrierDataProvider.php b/src/Adapter/Carrier/CarrierDataProvider.php deleted file mode 100644 index f3baa446..00000000 --- a/src/Adapter/Carrier/CarrierDataProvider.php +++ /dev/null @@ -1,127 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Carrier; - -use Carrier; -use PrestaShop\PrestaShop\Adapter\Configuration; - -/** - * This class will provide data from DB / ORM about Category. - */ -class CarrierDataProvider -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * Get all carriers in a given language. - * - * @param int $id_lang Language id - * @param bool $active Returns only active carriers when true - * @param bool $delete - * @param bool|int $id_zone - * @param string|null $ids_group - * @param $modules_filters , possible values: - * PS_CARRIERS_ONLY - * CARRIERS_MODULE - * CARRIERS_MODULE_NEED_RANGE - * PS_CARRIERS_AND_CARRIER_MODULES_NEED_RANGE - * ALL_CARRIERS - * - * @return array Carriers - */ - public function getCarriers($id_lang, $active = false, $delete = false, $id_zone = false, $ids_group = null, $modules_filters = Carrier::PS_CARRIERS_ONLY) - { - return Carrier::getCarriers($id_lang, $active, $delete, $id_zone, $ids_group, $modules_filters); - } - - /** - * Get all active carriers in given language, usable for choice form type. - * - * @param int|null $languageId if not provided - will use the default language - * - * @return array carrier choices - */ - public function getActiveCarriersChoices($languageId = null) - { - if (null === $languageId) { - $languageId = $this->configuration->getInt('PS_LANG_DEFAULT'); - } - - $carriers = $this->getCarriers($languageId, true, false, false, null, $this->getAllCarriersConstant()); - $carriersChoices = []; - - foreach ($carriers as $carrier) { - $carriersChoices[$carrier['name']] = $carrier['id_carrier']; - } - - return $carriersChoices; - } - - /** - * Get carriers order by choices. - * - * @return array order by choices - */ - public function getOrderByChoices() - { - return [ - 'Price' => Carrier::SORT_BY_PRICE, - 'Position' => Carrier::SORT_BY_POSITION, - ]; - } - - /** - * Get carriers order way choices. - * - * @return array order way choices - */ - public function getOrderWayChoices() - { - return [ - 'Ascending' => Carrier::SORT_BY_ASC, - 'Descending' => Carrier::SORT_BY_DESC, - ]; - } - - /** - * Get the CarrierCore class ALL_CARRIERS constant value. - * - * @return int - */ - public function getAllCarriersConstant() - { - return Carrier::ALL_CARRIERS; - } -} diff --git a/src/Adapter/Carrier/CarrierOptionsConfiguration.php b/src/Adapter/Carrier/CarrierOptionsConfiguration.php deleted file mode 100644 index 6b61a89e..00000000 --- a/src/Adapter/Carrier/CarrierOptionsConfiguration.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Carrier; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * Class CarrierOptionsConfiguration is responsible for saving and loading Carrier Options configuration. - */ -class CarrierOptionsConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - /** - * CarrierOptionsConfiguration constructor. - * - * @param Configuration $configuration - */ - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'default_carrier' => $this->configuration->getInt('PS_CARRIER_DEFAULT'), - 'carrier_default_order_by' => $this->configuration->getInt('PS_CARRIER_DEFAULT_SORT'), - 'carrier_default_order_way' => $this->configuration->getInt('PS_CARRIER_DEFAULT_ORDER'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_CARRIER_DEFAULT', $configuration['default_carrier']); - $this->configuration->set('PS_CARRIER_DEFAULT_SORT', $configuration['carrier_default_order_by']); - $this->configuration->set('PS_CARRIER_DEFAULT_ORDER', $configuration['carrier_default_order_way']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['default_carrier'], - $configuration['carrier_default_order_by'], - $configuration['carrier_default_order_way'] - ); - } -} diff --git a/src/Adapter/Carrier/HandlingConfiguration.php b/src/Adapter/Carrier/HandlingConfiguration.php deleted file mode 100644 index 79a7dc10..00000000 --- a/src/Adapter/Carrier/HandlingConfiguration.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Carrier; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * Class HandlingConfiguration is responsible for saving and loading Handling options configuration. - */ -class HandlingConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - /** - * HandlingConfiguration constructor. - * - * @param Configuration $configuration - */ - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'shipping_handling_charges' => $this->configuration->get('PS_SHIPPING_HANDLING'), - 'free_shipping_price' => $this->configuration->get('PS_SHIPPING_FREE_PRICE'), - 'free_shipping_weight' => $this->configuration->get('PS_SHIPPING_FREE_WEIGHT'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_SHIPPING_HANDLING', $configuration['shipping_handling_charges']); - $this->configuration->set('PS_SHIPPING_FREE_PRICE', $configuration['free_shipping_price']); - $this->configuration->set('PS_SHIPPING_FREE_WEIGHT', $configuration['free_shipping_weight']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['shipping_handling_charges'], - $configuration['free_shipping_price'], - $configuration['free_shipping_weight'] - ); - } -} diff --git a/src/Adapter/Cart/AbstractCartHandler.php b/src/Adapter/Cart/AbstractCartHandler.php deleted file mode 100644 index 681827c5..00000000 --- a/src/Adapter/Cart/AbstractCartHandler.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart; - -use Cart; -use PrestaShop\PrestaShop\Adapter\Validate; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartException; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShopException; - -/** - * Provides reusable methods for cart handlers - * - * @internal - */ -abstract class AbstractCartHandler -{ - /** - * @param CartId $cartId - * - * @return Cart - * - * @throws CartNotFoundException - */ - protected function getCart(CartId $cartId) - { - try { - $cart = new Cart($cartId->getValue()); - } catch (PrestaShopException $e) { - throw new CartException(sprintf('An error occurred when trying to load cart with id "%s', $cartId->getValue())); - } - - if (!Validate::isLoadedObject($cart) || $cartId->getValue() !== (int) $cart->id) { - throw new CartNotFoundException(sprintf('Cart with id "%s" was not found', $cartId->getValue())); - } - - return $cart; - } -} diff --git a/src/Adapter/Cart/CartPresenter.php b/src/Adapter/Cart/CartPresenter.php deleted file mode 100644 index 170b2cdc..00000000 --- a/src/Adapter/Cart/CartPresenter.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart; - -/** - * @deprecated since 1.7.4.0 - * @see \PrestaShop\PrestaShop\Adapter\Presenter\Cart\CartPresenter - */ -class CartPresenter extends \PrestaShop\PrestaShop\Adapter\Presenter\Cart\CartPresenter -{ -} diff --git a/src/Adapter/Cart/CommandHandler/AddCartRuleToCartHandler.php b/src/Adapter/Cart/CommandHandler/AddCartRuleToCartHandler.php deleted file mode 100644 index fb3bcd2b..00000000 --- a/src/Adapter/Cart/CommandHandler/AddCartRuleToCartHandler.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\CommandHandler; - -use Cache; -use Cart; -use CartRule; -use Context; -use Currency; -use Customer; -use Language; -use PrestaShop\PrestaShop\Adapter\Cart\AbstractCartHandler; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\AddCartRuleToCartCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\AddCartRuleToCartHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartException; -use PrestaShop\PrestaShop\Core\Domain\CartRule\Exception\CartRuleValidityException; -use Shop; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * @internal - */ -final class AddCartRuleToCartHandler extends AbstractCartHandler implements AddCartRuleToCartHandlerInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @param TranslatorInterface $translator - * @param ContextStateManager $contextStateManager - */ - public function __construct( - TranslatorInterface $translator, - ContextStateManager $contextStateManager - ) { - $this->translator = $translator; - $this->contextStateManager = $contextStateManager; - } - - /** - * {@inheritdoc} - */ - public function handle(AddCartRuleToCartCommand $command) - { - $cart = $this->getCart($command->getCartId()); - $cartRule = new CartRule($command->getCartRuleId()->getValue()); - - $this->contextStateManager - ->setCart($cart) - ->setCurrency(new Currency($cart->id_currency)) - ->setLanguage(new Language($cart->id_lang)) - ->setCustomer(new Customer($cart->id_customer)) - ->setShop(new Shop($cart->id_shop)) - ; - - $errorMessage = $this->validateCartRule($cartRule, $cart); - - if ($errorMessage) { - $this->contextStateManager->restorePreviousContext(); - - throw new CartRuleValidityException($errorMessage); - } - - if (!$cart->addCartRule($cartRule->id)) { - $this->contextStateManager->restorePreviousContext(); - - throw new CartException('Failed to add cart rule to cart.'); - } - - $this->contextStateManager->restorePreviousContext(); - } - - /** - * Validates if the cart rule is applicable to cart - * - * Returns null if cart rule is valid. - * Returns translated error message if cart rule is not valid. - * - * @param CartRule $cartRule - * - * @return string|null - */ - private function validateCartRule(CartRule $cartRule, Cart $cart): ?string - { - Context::getContext()->cart = $cart; - $previousCartRules = $cart->getCartRules(); - $isValid = $cartRule->checkValidity(Context::getContext(), false, true); - - foreach ($previousCartRules as $previousCartRule) { - Cache::clean('getContextualValue_' . $previousCartRule['id_discount'] . '_*'); - } - - // if its valid, don't return any error message - if (true === $isValid) { - return null; - } - - // if its not valid, then this var contains translated error message - return $isValid; - } -} diff --git a/src/Adapter/Cart/CommandHandler/AddCustomizationHandler.php b/src/Adapter/Cart/CommandHandler/AddCustomizationHandler.php deleted file mode 100644 index 1b4c0971..00000000 --- a/src/Adapter/Cart/CommandHandler/AddCustomizationHandler.php +++ /dev/null @@ -1,202 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\CommandHandler; - -use Configuration; -use CustomizationField; -use ImageManager; -use PrestaShop\PrestaShop\Adapter\Cart\AbstractCartHandler; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\AddCustomizationCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\AddCustomizationHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Exception\FileUploadException; -use PrestaShop\PrestaShop\Core\Domain\Product\Customization\CustomizationSettings; -use PrestaShop\PrestaShop\Core\Domain\Product\Customization\Exception\CustomizationConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Product\Customization\Exception\CustomizationException; -use PrestaShop\PrestaShop\Core\Domain\Product\Customization\ValueObject\CustomizationId; -use PrestaShopException; -use Product; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Handles @var AddCustomizationCommand using legacy object model. - */ -final class AddCustomizationHandler extends AbstractCartHandler implements AddCustomizationHandlerInterface -{ - /** - * If customization fields are not required and none of them are provided - * then no customizations are saved and null returned. - * Else, saved customizationId is returned or exception is thrown. - * - * @param AddCustomizationCommand $command - * - * @return int - * - * @throws CartNotFoundException - * @throws CustomizationConstraintException - * @throws CustomizationException - * @throws FileUploadException - */ - public function handle(AddCustomizationCommand $command): ?CustomizationId - { - $productId = $command->getProductId()->getValue(); - - $cart = $this->getCart($command->getCartId()); - $product = new Product($productId); - - $customizationFields = $product->getCustomizationFieldIds(); - $customizationValues = $command->getCustomizationValuesByFieldIds(); - - foreach ($customizationFields as $customizationField) { - $customizationFieldId = (int) $customizationField['id_customization_field']; - $isRequired = (bool) $customizationField['required']; - - if ($isRequired && empty($customizationValues[$customizationFieldId])) { - throw new CustomizationConstraintException(sprintf('Customization field #%s is required', $customizationFieldId), CustomizationConstraintException::FIELD_IS_REQUIRED); - } - - if (empty($customizationValues[$customizationFieldId])) { - continue; - } - - try { - if (Product::CUSTOMIZE_TEXTFIELD == $customizationField['type']) { - $this->assertCustomTextField($customizationFieldId, $customizationValues[$customizationFieldId]); - - $customizationId = $cart->addTextFieldToProduct( - $productId, - $customizationFieldId, - Product::CUSTOMIZE_TEXTFIELD, - $customizationValues[$customizationFieldId], - true - ); - } else { - $fileName = $this->uploadImage($customizationValues[$customizationFieldId]); - - $customizationId = $cart->addPictureToProduct( - $productId, - $customizationFieldId, - Product::CUSTOMIZE_FILE, - $fileName, - true - ); - } - - if (false === $customizationId) { - throw new CustomizationException(sprintf('Failed to add customized data for customization field with id "%s"', $customizationFieldId)); - } - } catch (PrestaShopException $e) { - throw new CustomizationException(sprintf('An error occurred while trying to add customized data for customization field with id "%s"', $customizationFieldId)); - } - } - - if (!isset($customizationId)) { - return null; - } - - return new CustomizationId($customizationId); - } - - /** - * Uploads image from customized field - * - * @param UploadedFile $file - * - * @return string - * - * @throws FileUploadException - */ - private function uploadImage(UploadedFile $file): string - { - $this->validateUpload($file); - - //@todo: check if copy is okay to use instead of move_uploaded_file(this fails creating new request from global later) - //@todo: implement UploadedFile::move() instead of copy(); - if (!($tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS')) || !copy($file->getPathname(), $tmpName)) { - throw new FileUploadException('An error occurred during the image upload process.'); - } - $fileName = md5(uniqid('', true)); - $resized = ImageManager::resize($tmpName, _PS_UPLOAD_DIR_ . $fileName) && - ImageManager::resize( - $tmpName, - _PS_UPLOAD_DIR_ . $fileName . '_small', - (int) Configuration::get('PS_PRODUCT_PICTURE_WIDTH'), - (int) Configuration::get('PS_PRODUCT_PICTURE_HEIGHT') - ); - - if (!$resized) { - throw new FileUploadException('An error occurred when resizing the uploaded image'); - } - - unlink($tmpName); - - return $fileName; - } - - /** - * Validates uploaded image - * - * @param UploadedFile $file - * - * @throws FileUploadException - */ - private function validateUpload(UploadedFile $file): void - { - $maxFileSize = (int) Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE'); - - if ((int) $maxFileSize > 0 && $file->getSize() > (int) $maxFileSize) { - throw new FileUploadException(sprintf('Image is too large (%s kB). Maximum allowed: %s kB', $file->getSize() / 1024, $maxFileSize / 1024), UPLOAD_ERR_FORM_SIZE); - } - - if (!ImageManager::isRealImage($file->getPathname(), $file->getType()) || !ImageManager::isCorrectImageFileExt($file->getClientOriginalName(), null) || preg_match('/\%00/', $file->getClientOriginalName())) { - throw new FileUploadException('Image format not recognized, allowed formats are: .gif, .jpg, .png', UPLOAD_ERR_EXTENSION); - } - - if ($file->getError()) { - throw new FileUploadException('Error while uploading image', $file->getError()); - } - } - - /** - * @param int $customFieldId - * @param string $value - * - * @throws CustomizationConstraintException - */ - private function assertCustomTextField(int $customFieldId, string $value) - { - $customization = new CustomizationField($customFieldId); - - if ($customization->required && '' === $value) { - throw new CustomizationConstraintException(sprintf('Customization field #%s is required', $customFieldId), CustomizationConstraintException::FIELD_IS_REQUIRED); - } - - if (strlen($value) > CustomizationSettings::MAX_TEXT_LENGTH) { - throw new CustomizationConstraintException(sprintf('Customization field #%s value is too long', $customFieldId), CustomizationConstraintException::FIELD_IS_TOO_LONG); - } - } -} diff --git a/src/Adapter/Cart/CommandHandler/AddProductToCartHandler.php b/src/Adapter/Cart/CommandHandler/AddProductToCartHandler.php deleted file mode 100644 index 8a386173..00000000 --- a/src/Adapter/Cart/CommandHandler/AddProductToCartHandler.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Cart\AbstractCartHandler; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\AddCustomizationCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\AddProductToCartCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateProductQuantityInCartCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\AddCustomizationHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\AddProductToCartHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\UpdateProductQuantityInCartHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartConstraintException; - -/** - * Handles add product to cart command - */ -final class AddProductToCartHandler extends AbstractCartHandler implements AddProductToCartHandlerInterface -{ - /** - * @var AddCustomizationHandlerInterface - */ - private $addCustomizationHandler; - - /** - * @var UpdateProductQuantityInCartHandlerInterface - */ - private $updateProductQuantityInCartHandler; - - /** - * @param AddCustomizationHandlerInterface $addCustomizationHandler - * @param UpdateProductQuantityInCartHandlerInterface $updateProductQuantityInCartHandler - */ - public function __construct( - AddCustomizationHandlerInterface $addCustomizationHandler, - UpdateProductQuantityInCartHandlerInterface $updateProductQuantityInCartHandler - ) { - $this->addCustomizationHandler = $addCustomizationHandler; - $this->updateProductQuantityInCartHandler = $updateProductQuantityInCartHandler; - } - - /** - * {@inheritdoc} - */ - public function handle(AddProductToCartCommand $command): void - { - $cartIdValue = $command->getCartId()->getValue(); - $productIdValue = $command->getProductId()->getValue(); - $combinationId = null !== $command->getCombinationId() ? $command->getCombinationId()->getValue() : null; - $customizationId = null; - - if (!empty($command->getCustomizationsByFieldIds())) { - $customizationIdVO = $this->addCustomizationHandler->handle(new AddCustomizationCommand( - $cartIdValue, - $command->getProductId()->getValue(), - $command->getCustomizationsByFieldIds() - )); - if (null !== $customizationIdVO) { - $customizationId = $customizationIdVO->getValue(); - } - } - - $cart = $this->getCart($command->getCartId()); - $product = $cart->getProductQuantity($productIdValue, $combinationId, $customizationId); - - $quantity = $command->getQuantity() + (int) $product['quantity']; - $this->assertQuantityIsPositiveInt($quantity); - - $this->updateProductQuantityInCartHandler->handle(new UpdateProductQuantityInCartCommand( - $cartIdValue, - $productIdValue, - $quantity, - $combinationId, - $customizationId - )); - } - - /** - * @param int $quantity - * - * @throws CartConstraintException - */ - private function assertQuantityIsPositiveInt(int $quantity): void - { - if (0 > $quantity) { - throw new CartConstraintException( - sprintf('Quantity must be positive integer, but %s given.', $quantity), - CartConstraintException::INVALID_QUANTITY - ); - } - } -} diff --git a/src/Adapter/Cart/CommandHandler/CreateEmptyCustomerCartHandler.php b/src/Adapter/Cart/CommandHandler/CreateEmptyCustomerCartHandler.php deleted file mode 100644 index f6a63afe..00000000 --- a/src/Adapter/Cart/CommandHandler/CreateEmptyCustomerCartHandler.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\CommandHandler; - -use Cart; -use Configuration; -use Customer; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\CreateEmptyCustomerCartCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\CreateEmptyCustomerCartHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShopException; - -/** - * @internal - */ -final class CreateEmptyCustomerCartHandler implements CreateEmptyCustomerCartHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(CreateEmptyCustomerCartCommand $command) - { - $customer = new Customer($command->getCustomerId()->getValue()); - - $lastEmptyCartId = $customer->getLastEmptyCart(false); - - if ($lastEmptyCartId) { - $cart = new Cart($lastEmptyCartId); - } else { - $cart = $this->createEmptyCustomerCart($customer); - } - - return new CartId((int) $cart->id); - } - - /** - * @param Customer $customer - * - * @return Cart - * - * @throws PrestaShopException - */ - private function createEmptyCustomerCart(Customer $customer): Cart - { - $cart = new Cart(); - - $cart->recyclable = 0; - $cart->gift = 0; - $cart->id_customer = $customer->id; - $cart->secure_key = $customer->secure_key; - - $cart->id_shop = $customer->id_shop; - $cart->id_lang = (int) Configuration::get('PS_LANG_DEFAULT'); - $cart->id_currency = (int) Configuration::get('PS_CURRENCY_DEFAULT'); - - $addresses = $customer->getAddresses($cart->id_lang); - $addressId = !empty($addresses) ? (int) reset($addresses)['id_address'] : null; - $cart->id_address_delivery = $addressId; - $cart->id_address_invoice = $addressId; - - $cart->setNoMultishipping(); - $cart->save(); - - return $cart; - } -} diff --git a/src/Adapter/Cart/CommandHandler/RemoveCartRuleFromCartHandler.php b/src/Adapter/Cart/CommandHandler/RemoveCartRuleFromCartHandler.php deleted file mode 100644 index 03fe93a2..00000000 --- a/src/Adapter/Cart/CommandHandler/RemoveCartRuleFromCartHandler.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Cart\AbstractCartHandler; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\RemoveCartRuleFromCartCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\RemoveCartRuleFromCartHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartException; - -/** - * @internal - */ -final class RemoveCartRuleFromCartHandler extends AbstractCartHandler implements RemoveCartRuleFromCartHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(RemoveCartRuleFromCartCommand $command) - { - $cart = $this->getCart($command->getCartId()); - - if (!$cart->removeCartRule($command->getCartRuleId()->getValue())) { - throw new CartException(sprintf('Failed to remove cart rule with id "%d" from cart', $command->getCartRuleId()->getValue())); - } - } -} diff --git a/src/Adapter/Cart/CommandHandler/RemoveProductFromCartHandler.php b/src/Adapter/Cart/CommandHandler/RemoveProductFromCartHandler.php deleted file mode 100644 index 356bf982..00000000 --- a/src/Adapter/Cart/CommandHandler/RemoveProductFromCartHandler.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\CommandHandler; - -use Currency; -use Customer; -use Language; -use PrestaShop\PrestaShop\Adapter\Cart\AbstractCartHandler; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\RemoveProductFromCartCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\RemoveProductFromCartHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartException; -use Shop; - -/** - * Handles removing product from context cart. - * - * @internal - */ -final class RemoveProductFromCartHandler extends AbstractCartHandler implements RemoveProductFromCartHandlerInterface -{ - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @param ContextStateManager $contextStateManager - */ - public function __construct( - ContextStateManager $contextStateManager - ) { - $this->contextStateManager = $contextStateManager; - } - - /** - * {@inheritdoc} - */ - public function handle(RemoveProductFromCartCommand $command) - { - $cart = $this->getCart($command->getCartId()); - - $this->contextStateManager - ->setCart($cart) - ->setCurrency(new Currency($cart->id_currency)) - ->setLanguage(new Language($cart->id_lang)) - ->setCustomer(new Customer($cart->id_customer)) - ->setShop(new Shop($cart->id_shop)) - ; - - try { - $removed = $cart->deleteProduct( - $command->getProductId()->getValue(), - $command->getCombinationId() ?: 0, - $command->getCustomizationId() ?: 0 - ); - - if (!$removed) { - throw new CartException(sprintf('Failed to remove product with id "%d" from cart', $command->getProductId()->getValue())); - } - } finally { - $this->contextStateManager->restorePreviousContext(); - } - } -} diff --git a/src/Adapter/Cart/CommandHandler/SendCartToCustomerHandler.php b/src/Adapter/Cart/CommandHandler/SendCartToCustomerHandler.php deleted file mode 100644 index f116ec9e..00000000 --- a/src/Adapter/Cart/CommandHandler/SendCartToCustomerHandler.php +++ /dev/null @@ -1,142 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\CommandHandler; - -use Cart; -use Context; -use Customer; -use Language; -use Mail; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\SendCartToCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\SendCartToCustomerHanlderInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartException; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use Validate; - -/** - * @internal - */ -final class SendCartToCustomerHandler implements SendCartToCustomerHanlderInterface -{ - /** - * {@inheritdoc} - */ - public function handle(SendCartToCustomerCommand $command) - { - $cart = $this->getCart($command->getCartId()); - $customer = $this->getCustomer($cart->id_customer); - - $mailVars = [ - '{order_link}' => $this->generateCheckoutUrl($cart), - '{firstname}' => $customer->firstname, - '{lastname}' => $customer->lastname, - ]; - - $cartLanguage = new Language((int) $cart->id_lang); - - $emailWasSent = Mail::send( - (int) $cart->id_lang, - 'backoffice_order', - Context::getContext()->getTranslator()->trans( - 'Process the payment of your order', - [], - 'Emails.Subject', - $cartLanguage->locale - ), - $mailVars, - $customer->email, - $customer->firstname . ' ' . $customer->lastname, - null, - null, - null, - null, - _PS_MAIL_DIR_, - true, - $cart->id_shop - ); - - if (!$emailWasSent) { - throw new CartException('Failed to send email to customer.'); - } - } - - /** - * @param CartId $cartId - * - * @return Cart - * - * @throws CartNotFoundException - */ - private function getCart(CartId $cartId) - { - $cart = new Cart($cartId->getValue()); - - if (!Validate::isLoadedObject($cart)) { - throw new CartNotFoundException(sprintf('Cart with id "%d" was not found', $cartId->getValue())); - } - - return $cart; - } - - /** - * @param int $customerId - * - * @return Customer - * - * @throws CartException - */ - private function getCustomer($customerId) - { - $customer = new Customer($customerId); - - if (!Validate::isLoadedObject($customer)) { - throw new CartException(sprintf('Customer with id "%d" was not found', $customerId)); - } - - return $customer; - } - - /** - * @param Cart $cart - * - * @return string - */ - private function generateCheckoutUrl(Cart $cart) - { - return Context::getContext()->link->getPageLink( - 'order', - false, - (int) $cart->id_lang, - [ - 'step' => 3, - 'recover_cart' => $cart->id, - 'token_cart' => md5(_COOKIE_KEY_ . 'recover_cart_' . (int) $cart->id), - ] - ); - } -} diff --git a/src/Adapter/Cart/CommandHandler/UpdateCartAddressesHandler.php b/src/Adapter/Cart/CommandHandler/UpdateCartAddressesHandler.php deleted file mode 100644 index 683f0acd..00000000 --- a/src/Adapter/Cart/CommandHandler/UpdateCartAddressesHandler.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\CommandHandler; - -use Cart; -use PrestaShop\PrestaShop\Adapter\Cart\AbstractCartHandler; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateCartAddressesCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateCartCarrierCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\UpdateCartAddressesHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\UpdateCartCarrierHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartException; - -/** - * @internal - */ -final class UpdateCartAddressesHandler extends AbstractCartHandler implements UpdateCartAddressesHandlerInterface -{ - /** - * @var UpdateCartCarrierHandlerInterface - */ - private $updateCartCarrierHandler; - - /** - * @param UpdateCartCarrierHandlerInterface $updateCartCarrierHandler - */ - public function __construct(UpdateCartCarrierHandlerInterface $updateCartCarrierHandler) - { - $this->updateCartCarrierHandler = $updateCartCarrierHandler; - } - - /** - * @param UpdateCartAddressesCommand $command - */ - public function handle(UpdateCartAddressesCommand $command) - { - $cart = $this->getCart($command->getCartId()); - $this->fillCartWithCommandData($cart, $command); - - if (false === $cart->update()) { - throw new CartException(sprintf('Failed to update addresses for cart with id "%s"', $cart->id)); - } - - $this->updateCartCarrierHandler->handle(new UpdateCartCarrierCommand($cart->id, $cart->id_carrier)); - } - - /** - * Fetches updatable fields from command to cart - * - * @param Cart $cart - * @param UpdateCartAddressesCommand $command - */ - private function fillCartWithCommandData(Cart $cart, UpdateCartAddressesCommand $command): void - { - if ($command->getNewDeliveryAddressId()) { - // updateDeliveryAddressId() will actually allow the address change to be impacted on all - // other data linked to the cart delivery address (and it doesn't modify the invoice address) - $cart->updateDeliveryAddressId((int) $cart->id_address_delivery, $command->getNewDeliveryAddressId()->getValue()); - } - - if ($command->getNewInvoiceAddressId()) { - $cart->id_address_invoice = $command->getNewInvoiceAddressId()->getValue(); - } - } -} diff --git a/src/Adapter/Cart/CommandHandler/UpdateCartCarrierHandler.php b/src/Adapter/Cart/CommandHandler/UpdateCartCarrierHandler.php deleted file mode 100644 index 07458153..00000000 --- a/src/Adapter/Cart/CommandHandler/UpdateCartCarrierHandler.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\CommandHandler; - -use Carrier; -use Currency; -use Customer; -use Language; -use PrestaShop\PrestaShop\Adapter\Cart\AbstractCartHandler; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateCartCarrierCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\UpdateCartCarrierHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartConstraintException; -use Shop; -use Validate; - -/** - * @internal - */ -final class UpdateCartCarrierHandler extends AbstractCartHandler implements UpdateCartCarrierHandlerInterface -{ - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @param ContextStateManager $contextStateManager - */ - public function __construct(ContextStateManager $contextStateManager) - { - $this->contextStateManager = $contextStateManager; - } - - /** - * {@inheritdoc} - */ - public function handle(UpdateCartCarrierCommand $command) - { - $this->assertActiveCarrier($command->getNewCarrierId()); - - $cart = $this->getCart($command->getCartId()); - $this->contextStateManager - ->setCart($cart) - ->setCurrency(new Currency($cart->id_currency)) - ->setLanguage(new Language($cart->id_lang)) - ->setCustomer(new Customer($cart->id_customer)) - ->setShop(new Shop($cart->id_shop)) - ; - - try { - $cart->setDeliveryOption([ - (int) $cart->id_address_delivery => $this->formatLegacyDeliveryOptionFromCarrierId($command->getNewCarrierId()), - ]); - - $cart->update(); - } finally { - $this->contextStateManager->restorePreviousContext(); - } - } - - /** - * @param int $carrierId - * - * @throws CartConstraintException - */ - private function assertActiveCarrier(int $carrierId): void - { - if (0 === $carrierId) { - return; - } - - $carrier = new Carrier($carrierId); - - if (!Validate::isLoadedObject($carrier) || (int) $carrier->id !== $carrierId) { - throw new CartConstraintException(sprintf('Carrier with id "%d" was not found', $carrierId), CartConstraintException::INVALID_CARRIER); - } - if (!$carrier->active) { - throw new CartConstraintException(sprintf('Carrier with id "%d" is not active', $carrierId), CartConstraintException::INVALID_CARRIER); - } - } - - /** - * Delivery option consists of deliveryAddress and carrierId. - * - * Legacy multishipping feature used comma separated carriers in delivery option (e.g. {'1':'6,7'} - * Now that multishipping is gone - delivery option should consist of one carrier and one address. - * - * However the structure of deliveryOptions is still used with comma in legacy, so - * this method provides assurance for deliveryOption structure until major refactoring - * - * @param int $carrierId - * - * @return string - */ - private function formatLegacyDeliveryOptionFromCarrierId(int $carrierId): string - { - return sprintf('%d,', $carrierId); - } -} diff --git a/src/Adapter/Cart/CommandHandler/UpdateCartCurrencyHandler.php b/src/Adapter/Cart/CommandHandler/UpdateCartCurrencyHandler.php deleted file mode 100644 index 114d4f88..00000000 --- a/src/Adapter/Cart/CommandHandler/UpdateCartCurrencyHandler.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\CommandHandler; - -use Currency; -use PrestaShop\PrestaShop\Adapter\Cart\AbstractCartHandler; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateCartCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\UpdateCartCurrencyHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\CurrencyId; -use PrestaShopException; - -/** - * @internal - */ -final class UpdateCartCurrencyHandler extends AbstractCartHandler implements UpdateCartCurrencyHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(UpdateCartCurrencyCommand $command): void - { - $currency = $this->getCurrencyObject($command->getNewCurrencyId()); - - $this->assertCurrencyIsNotDeleted($currency); - $this->assertCurrencyIsActive($currency); - - $cart = $this->getCart($command->getCartId()); - $cart->id_currency = (int) $currency->id; - - try { - if (false === $cart->update()) { - throw new CartException('Failed to update cart currency.'); - } - } catch (PrestaShopException $e) { - throw new CartException(sprintf('An error occurred while trying to update currency for cart with id "%s"', $cart->id)); - } - } - - /** - * @param CurrencyId $currencyId - * - * @return Currency - * - * @throws CurrencyNotFoundException - */ - private function getCurrencyObject(CurrencyId $currencyId): Currency - { - $currency = new Currency($currencyId->getValue()); - - if ($currencyId->getValue() !== $currency->id) { - throw new CurrencyNotFoundException(sprintf('Currency with id "%s" was not found', $currencyId->getValue())); - } - - return $currency; - } - - /** - * @param Currency $currency - * - * @throws CurrencyException - */ - private function assertCurrencyIsActive(Currency $currency): void - { - if (!$currency->active) { - throw new CurrencyException(sprintf('Currency "%s" cannot be used in cart because it is disabled', $currency->iso_code), CurrencyException::IS_DISABLED); - } - } - - /** - * @param Currency $currency - * - * @throws CurrencyException - */ - private function assertCurrencyIsNotDeleted(Currency $currency): void - { - if ($currency->deleted) { - throw new CurrencyException(sprintf('Currency "%s" cannot be used in cart because it is deleted', $currency->iso_code), CurrencyException::IS_DELETED); - } - } -} diff --git a/src/Adapter/Cart/CommandHandler/UpdateCartDeliverySettingsHandler.php b/src/Adapter/Cart/CommandHandler/UpdateCartDeliverySettingsHandler.php deleted file mode 100644 index ad867186..00000000 --- a/src/Adapter/Cart/CommandHandler/UpdateCartDeliverySettingsHandler.php +++ /dev/null @@ -1,250 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\CommandHandler; - -use Cart; -use CartRule; -use PrestaShop\PrestaShop\Adapter\Cart\AbstractCartHandler; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateCartDeliverySettingsCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\UpdateCartDeliverySettingsHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartException; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\InvalidGiftMessageException; -use PrestaShop\PrestaShop\Core\Domain\CartRule\Exception\CannotDeleteCartRuleException; -use PrestaShop\PrestaShop\Core\Domain\CartRule\Exception\CartRuleException; -use PrestaShopException; -use Symfony\Component\Translation\TranslatorInterface; -use Validate; - -/** - * @internal - */ -final class UpdateCartDeliverySettingsHandler extends AbstractCartHandler implements UpdateCartDeliverySettingsHandlerInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param TranslatorInterface $translator - * @param ConfigurationInterface $configuration - */ - public function __construct(TranslatorInterface $translator, ConfigurationInterface $configuration) - { - $this->translator = $translator; - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function handle(UpdateCartDeliverySettingsCommand $command): void - { - $cart = $this->getCart($command->getCartId()); - - if (($command->getGiftMessage() !== null) && (!Validate::isMessage($command->getGiftMessage()))) { - throw new InvalidGiftMessageException(); - } - - $this->handleFreeShippingOption($cart, $command); - $shouldSaveCartAfterGiftOption = $this->handleGiftOption($cart, $command); - $shouldSaveCartAfterWrappingOption = $this->handleRecycledWrappingOption($cart, $command); - $shouldSaveCartAfterGiftMessageOption = $this->handleGiftMessageOption($cart, $command); - - $shouldSaveCart = ($shouldSaveCartAfterGiftOption - || $shouldSaveCartAfterWrappingOption - || $shouldSaveCartAfterGiftMessageOption); - - if ($shouldSaveCart) { - try { - if (false === $cart->update()) { - throw new CartException('Failed to update cart delivery settings'); - } - } catch (PrestaShopException $e) { - throw new CartException(sprintf('An error occurred while trying to update delivery settings for cart with id "%d"', $cart->id)); - } - } - } - - /** - * Sometimes, the cart rule to enable 'free shipping' exists - * but is not linked to the cart. We look for this cart rule - * to avoid creating duplicates. - * - * @param string $code - * - * @return CartRule|null - * - * @throws PrestaShopException - */ - private function getCartRuleForBackOfficeFreeShipping($code): ?CartRule - { - $cartRuleId = CartRule::getIdByCode($code); - - if (!$cartRuleId) { - return null; - } - - return new CartRule((int) $cartRuleId); - } - - /** - * @param Cart $cart - * @param string $backOfficeOrderCode - * - * @return CartRule - */ - private function createCartRule(Cart $cart, string $backOfficeOrderCode): CartRule - { - $freeShippingCartRule = new CartRule(); - $freeShippingCartRule->code = $backOfficeOrderCode; - $freeShippingCartRule->name = [ - $this->configuration->get('PS_LANG_DEFAULT') => $this->translator->trans( - 'Free Shipping', - [], - 'Admin.Orderscustomers.Feature' - ), - ]; - $freeShippingCartRule->id_customer = (int) $cart->id_customer; - $freeShippingCartRule->free_shipping = true; - $freeShippingCartRule->quantity = 1; - $freeShippingCartRule->quantity_per_user = 1; - $freeShippingCartRule->minimum_amount_currency = (int) $cart->id_currency; - $freeShippingCartRule->reduction_currency = (int) $cart->id_currency; - $freeShippingCartRule->date_from = date('Y-m-d H:i:s'); - $freeShippingCartRule->date_to = date('Y-m-d H:i:s', time() + 24 * 36000); - $freeShippingCartRule->active = 1; - $freeShippingCartRule->add(); - - return $freeShippingCartRule; - } - - /** - * This method works as follows: - * 1. if free shipping should be enabled, enable it - * 2. if free shipping should not be enabled and cart already does not have free shipping, do nothing - * 3.if free shipping should not be enabled and cart has free shipping, disable it - * - * @param Cart $cart - * @param UpdateCartDeliverySettingsCommand $command - * - * @throws CannotDeleteCartRuleException - */ - protected function handleFreeShippingOption(Cart $cart, UpdateCartDeliverySettingsCommand $command): void - { - $backOfficeOrderCode = sprintf('%s%s', CartRule::BO_ORDER_CODE_PREFIX, $cart->id); - - $freeShippingCartRule = $this->getCartRuleForBackOfficeFreeShipping($backOfficeOrderCode); - - $freeShippingShouldBeEnabled = $command->allowFreeShipping(); - - // Step 1 - if ($freeShippingShouldBeEnabled) { - if (null === $freeShippingCartRule) { - // there is not yet a 'free shipping' cart rule available in the system so we create it - $freeShippingCartRule = $this->createCartRule($cart, $backOfficeOrderCode); - } - $cart->addCartRule((int) $freeShippingCartRule->id); - - return; - } - - if (null === $freeShippingCartRule) { - return; - } - - $cart->removeCartRule((int) $freeShippingCartRule->id); - - try { - if (false === $freeShippingCartRule->delete()) { - throw new CannotDeleteCartRuleException(sprintf('Failed deleting cart rule #%s', $freeShippingCartRule->id)); - } - } catch (PrestaShopException $e) { - throw new CartRuleException(sprintf('An error occurred when trying to delete cart rule #%s', $freeShippingCartRule->id)); - } - } - - /** - * @param Cart $cart - * @param UpdateCartDeliverySettingsCommand $command - * - * @return bool should save the cart or not - * - * @throws CartException - * @throws PrestaShopException - */ - private function handleGiftOption(Cart $cart, UpdateCartDeliverySettingsCommand $command): bool - { - if ($command->isAGift() === null) { - return false; - } - - $cart->gift = $command->isAGift(); - - return true; - } - - /** - * @param Cart $cart - * @param UpdateCartDeliverySettingsCommand $command - * - * @return bool should save the cart or not - */ - private function handleRecycledWrappingOption(Cart $cart, UpdateCartDeliverySettingsCommand $command): bool - { - if ($command->useRecycledPackaging() === null) { - return false; - } - - $cart->recyclable = $command->useRecycledPackaging(); - - return true; - } - - /** - * @param Cart $cart - * @param UpdateCartDeliverySettingsCommand $command - * - * @return bool should save the cart or not - */ - private function handleGiftMessageOption(Cart $cart, UpdateCartDeliverySettingsCommand $command): bool - { - if ($command->getGiftMessage() === null) { - return false; - } - - $cart->gift_message = $command->getGiftMessage(); - - return true; - } -} diff --git a/src/Adapter/Cart/CommandHandler/UpdateCartLanguageHandler.php b/src/Adapter/Cart/CommandHandler/UpdateCartLanguageHandler.php deleted file mode 100644 index 350ee1d6..00000000 --- a/src/Adapter/Cart/CommandHandler/UpdateCartLanguageHandler.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\CommandHandler; - -use Language; -use PrestaShop\PrestaShop\Adapter\Cart\AbstractCartHandler; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateCartLanguageCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\UpdateCartLanguageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; -use PrestaShopException; - -/** - * @internal - */ -final class UpdateCartLanguageHandler extends AbstractCartHandler implements UpdateCartLanguageHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(UpdateCartLanguageCommand $command): void - { - $language = $this->getLanguageObject($command->getNewLanguageId()); - - $this->assertLanguageIsActive($language); - - $cart = $this->getCart($command->getCartId()); - $cart->id_lang = (int) $language->id; - - try { - if (false === $cart->update()) { - throw new CartException('Failed to update cart language'); - } - } catch (PrestaShopException $e) { - throw new CartException(sprintf('An error occurred while trying to update language for cart with id "%s"', $cart->id)); - } - } - - /** - * @param LanguageId $languageId - * - * @return Language - * - * @throws LanguageException - * @throws LanguageNotFoundException - */ - private function getLanguageObject(LanguageId $languageId): Language - { - try { - $lang = new Language($languageId->getValue()); - } catch (PrestaShopException $e) { - throw new LanguageException($languageId, sprintf('An error occurred when fetching language object with id %s', $languageId->getValue())); - } - - if ($languageId->getValue() !== $lang->id) { - throw new LanguageNotFoundException($languageId, sprintf('Language with id "%s" was not found', $languageId->getValue())); - } - - return $lang; - } - - /** - * @param Language $lang - * - * @throws LanguageException - */ - private function assertLanguageIsActive(Language $lang): void - { - if (!$lang->active) { - throw new LanguageException(sprintf('Language with id "%s" is not active', $lang->id), LanguageException::NOT_ACTIVE); - } - } -} diff --git a/src/Adapter/Cart/CommandHandler/UpdateProductPriceInCartHandler.php b/src/Adapter/Cart/CommandHandler/UpdateProductPriceInCartHandler.php deleted file mode 100644 index 29debc44..00000000 --- a/src/Adapter/Cart/CommandHandler/UpdateProductPriceInCartHandler.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Cart\AbstractCartHandler; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateProductPriceInCartCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\UpdateProductPriceInCartHandlerInterface; -use SpecificPrice; - -/** - * Updates product price in cart using SpecificPrice. - * - * @internal - */ -final class UpdateProductPriceInCartHandler extends AbstractCartHandler implements UpdateProductPriceInCartHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(UpdateProductPriceInCartCommand $command) - { - $cart = $this->getCart($command->getCartId()); - - $this->deleteSpecificPriceIfExists($command); - - $specificPrice = new SpecificPrice(); - $specificPrice->id_cart = (int) $cart->id; - $specificPrice->id_shop = 0; - $specificPrice->id_shop_group = 0; - $specificPrice->id_currency = 0; - $specificPrice->id_country = 0; - $specificPrice->id_group = 0; - $specificPrice->id_customer = (int) $cart->id_customer; - $specificPrice->id_product = (int) $command->getProductId()->getValue(); - $specificPrice->id_product_attribute = (int) $command->getCombinationId(); - $specificPrice->price = $command->getPrice(); - $specificPrice->from_quantity = 1; - $specificPrice->reduction = 0; - $specificPrice->reduction_type = 'amount'; - $specificPrice->from = '0000-00-00 00:00:00'; - $specificPrice->to = '0000-00-00 00:00:00'; - - $specificPrice->add(); - } - - /** - * Deletes specific price for cart & product if it already exists. - * - * @param UpdateProductPriceInCartCommand $command - */ - private function deleteSpecificPriceIfExists(UpdateProductPriceInCartCommand $command) - { - SpecificPrice::deleteByIdCart( - $command->getCartId()->getValue(), - $command->getProductId()->getValue(), - $command->getCombinationId() - ); - } -} diff --git a/src/Adapter/Cart/CommandHandler/UpdateProductQuantityInCartHandler.php b/src/Adapter/Cart/CommandHandler/UpdateProductQuantityInCartHandler.php deleted file mode 100644 index 5ed46322..00000000 --- a/src/Adapter/Cart/CommandHandler/UpdateProductQuantityInCartHandler.php +++ /dev/null @@ -1,249 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\CommandHandler; - -use Attribute; -use Cart; -use Context; -use Customer; -use PrestaShop\PrestaShop\Adapter\Cart\AbstractCartHandler; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateProductQuantityInCartCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler\UpdateProductQuantityInCartHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartException; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\MinimalQuantityException; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductCustomizationNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductException; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductOutOfStockException; -use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; -use Product; -use Shop; - -/** - * @internal - */ -final class UpdateProductQuantityInCartHandler extends AbstractCartHandler implements UpdateProductQuantityInCartHandlerInterface -{ - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @param ContextStateManager $contextStateManager - */ - public function __construct(ContextStateManager $contextStateManager) - { - $this->contextStateManager = $contextStateManager; - } - - /** - * {@inheritdoc} - */ - public function handle(UpdateProductQuantityInCartCommand $command) - { - $cart = $this->getCart($command->getCartId()); - $this->contextStateManager - ->setCart($cart) - ->setShop(new Shop($cart->id_shop)) - ; - - try { - $this->updateProductQuantityInCart($cart, $command); - } finally { - $this->contextStateManager->restorePreviousContext(); - } - } - - /** - * @param Cart $cart - * @param UpdateProductQuantityInCartCommand $command - * - * @throws CartConstraintException - * @throws CartException - * @throws ProductException - * @throws ProductNotFoundException - * @throws ProductOutOfStockException - */ - private function updateProductQuantityInCart(Cart $cart, UpdateProductQuantityInCartCommand $command): void - { - $previousQty = $this->findPreviousQuantityInCart($cart, $command); - $qtyDiff = abs($command->getNewQuantity() - $previousQty); - - if ($qtyDiff === 0) { - throw new CartConstraintException(sprintf('Cart quantity is already %d', $command->getNewQuantity()), CartConstraintException::UNCHANGED_QUANTITY); - } - - // $cart::updateQty needs customer context - $customer = new Customer($cart->id_customer); - Context::getContext()->customer = $customer; - - $this->assertOrderDoesNotExistForCart($cart); - - $product = $this->getProductObject($command->getProductId()); - $combinationIdValue = $command->getCombinationId() ? $command->getCombinationId()->getValue() : 0; - $customizationId = $command->getCustomizationId(); - - $this->assertProductIsInStock($product, $command); - $this->assertProductCustomization($product, $command); - - if ($previousQty < $command->getNewQuantity()) { - $action = 'up'; - } else { - $action = 'down'; - } - - $updateResult = $cart->updateQty( - $qtyDiff, - $command->getProductId()->getValue(), - $combinationIdValue, - $customizationId ? $customizationId->getValue() : false, - $action - ); - - if (!$updateResult) { - throw new CartException('Failed to update product quantity in cart'); - } - - // It seems that $updateResult can be -1, - // when adding product with less quantity than minimum required. - if ($updateResult < 0) { - $minQuantity = $combinationIdValue ? - Attribute::getAttributeMinimalQty($combinationIdValue) : - $product->minimal_quantity; - - throw new MinimalQuantityException('Minimum quantity of %d must be added to cart.', $minQuantity); - } - } - - /** - * @param Cart $cart - * - * @throws CartException - */ - private function assertOrderDoesNotExistForCart(Cart $cart) - { - if ($cart->orderExists()) { - throw new CartException(sprintf('Order for cart with id "%s" already exists.', $cart->id)); - } - } - - /** - * @param ProductId $productId - * - * @return Product - * - * @throws ProductNotFoundException - */ - private function getProductObject(ProductId $productId) - { - $product = new Product($productId->getValue(), true); - - if ($product->id !== $productId->getValue()) { - throw new ProductNotFoundException(sprintf('Product with id "%s" was not found', $productId->getValue())); - } - - return $product; - } - - /** - * @param Product $product - * @param UpdateProductQuantityInCartCommand $command - * - * @throws ProductOutOfStockException - */ - private function assertProductIsInStock(Product $product, UpdateProductQuantityInCartCommand $command) - { - if (null !== $command->getCombinationId()) { - $isAvailableWhenOutOfStock = Product::isAvailableWhenOutOfStock($product->out_of_stock); - $isEnoughQuantity = Attribute::checkAttributeQty( - $command->getCombinationId()->getValue(), - $command->getNewQuantity() - ); - - if (!$isAvailableWhenOutOfStock && !$isEnoughQuantity) { - throw new ProductOutOfStockException(sprintf('Product with id "%s" is out of stock, thus cannot be added to cart', $product->id)); - } - - return; - } - - if (!$product->checkQty($command->getNewQuantity())) { - throw new ProductOutOfStockException(sprintf('Product with id "%s" is out of stock, thus cannot be added to cart', $product->id)); - } - } - - /** - * If product is customizable and customization is not provided, - * then exception is thrown. - * - * @param Product $product - * @param UpdateProductQuantityInCartCommand $command - * - * @throws ProductCustomizationNotFoundException - */ - private function assertProductCustomization(Product $product, UpdateProductQuantityInCartCommand $command) - { - if (null === $command->getCustomizationId() && !$product->hasAllRequiredCustomizableFields()) { - throw new ProductCustomizationNotFoundException(sprintf( - 'Missing customization for product with id "%s"', - $product->id - )); - } - } - - /** - * @param Cart $cart - * @param UpdateProductQuantityInCartCommand $command - * - * @return int - */ - private function findPreviousQuantityInCart(Cart $cart, UpdateProductQuantityInCartCommand $command): int - { - $isCombination = ($command->getCombinationId() !== null); - $isCustomization = ($command->getCustomizationId() !== null); - - foreach ($cart->getProducts() as $cartProduct) { - $equalProductId = (int) $cartProduct['id_product'] === $command->getProductId()->getValue(); - if ($isCombination) { - if ($equalProductId && (int) $cartProduct['id_product_attribute'] === $command->getCombinationId()->getValue()) { - return (int) $cartProduct['quantity']; - } - } elseif ($isCustomization) { - if ($equalProductId && (int) $cartProduct['id_customization'] === $command->getCustomizationId()->getValue()) { - return (int) $cartProduct['quantity']; - } - } elseif ($equalProductId) { - return (int) $cartProduct['quantity']; - } - } - - return 0; - } -} diff --git a/src/Adapter/Cart/Comparator/CartProductUpdate.php b/src/Adapter/Cart/Comparator/CartProductUpdate.php deleted file mode 100644 index 27610060..00000000 --- a/src/Adapter/Cart/Comparator/CartProductUpdate.php +++ /dev/null @@ -1,142 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Cart\Comparator; - -use PrestaShop\PrestaShop\Core\Domain\Product\Combination\ValueObject\CombinationId; -use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; - -class CartProductUpdate -{ - /** - * @var ProductId - */ - private $productId; - - /** - * @var CombinationId|null - */ - private $combinationId; - - /** - * @var int - */ - private $deltaQuantity; - - /** - * @var bool - */ - private $created; - - /** - * @param int $productId - * @param int $combinationId - * @param int $deltaQuantity - * @param bool $created - */ - public function __construct(int $productId, int $combinationId, int $deltaQuantity, bool $created) - { - $this->productId = new ProductId($productId); - $this->combinationId = $combinationId > 0 ? new CombinationId($combinationId) : null; - $this->deltaQuantity = $deltaQuantity; - $this->created = $created; - } - - /** - * @param CartProductUpdate $cartProductUpdate - * - * @return bool - */ - public function productMatches(CartProductUpdate $cartProductUpdate): bool - { - if ($this->getProductId()->getValue() !== $cartProductUpdate->getProductId()->getValue()) { - return false; - } - $combinationIdValue = null !== $this->getCombinationId() ? $this->getCombinationId()->getValue() : 0; - $checkedIdValue = null !== $cartProductUpdate->getCombinationId() ? $cartProductUpdate->getCombinationId()->getValue() : 0; - - return $combinationIdValue === $checkedIdValue; - } - - /** - * @return ProductId - */ - public function getProductId(): ProductId - { - return $this->productId; - } - - /** - * @return CombinationId|null - */ - public function getCombinationId(): ?CombinationId - { - return $this->combinationId; - } - - /** - * @return int - */ - public function getDeltaQuantity(): int - { - return $this->deltaQuantity; - } - - /** - * @param int $deltaQuantity - * - * @return $this - */ - public function setDeltaQuantity(int $deltaQuantity): self - { - $this->deltaQuantity = $deltaQuantity; - - return $this; - } - - /** - * @return bool - */ - public function isCreated(): bool - { - return $this->created; - } - - /** - * @return array - */ - public function toArray(): array - { - return [ - 'id_product' => $this->productId->getValue(), - 'id_product_attribute' => null !== $this->combinationId ? $this->combinationId->getValue() : 0, - 'delta_quantity' => $this->deltaQuantity, - 'created' => $this->created, - ]; - } -} diff --git a/src/Adapter/Cart/Comparator/CartProductsComparator.php b/src/Adapter/Cart/Comparator/CartProductsComparator.php deleted file mode 100644 index ed0868e5..00000000 --- a/src/Adapter/Cart/Comparator/CartProductsComparator.php +++ /dev/null @@ -1,210 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Cart\Comparator; - -use Cart; - -/** - * This class saves a cart's products when it's created, you can then ask for the difference - * that happened on this cart. - */ -class CartProductsComparator -{ - /** - * @var Cart - */ - private $cart; - - /** - * @var array - */ - private $savedProducts; - - /** - * @param Cart $cart - */ - public function __construct(Cart $cart) - { - $this->cart = $cart; - $this->savedProducts = $cart->getProducts(true); - } - - /** - * Returns a list of products that were strictly updated (not created) compared to the state of the cart - * when this object was created, it removes the already known modified products provided as argument. - * - * @param CartProductUpdate[] $knownUpdates - * - * @return CartProductUpdate[] - */ - public function getUpdatedProducts(array $knownUpdates = []): array - { - $newProducts = $this->cart->getProducts(true); - $allUpdateProducts = $this->getAllUpdatedProducts($newProducts); - - return $this->filterKnownUpdates($allUpdateProducts, $knownUpdates); - } - - /** - * Returns a list of products that were strictly created (not updated) compared to the state of the cart - * when this object was created, it removes the already known modified products provided as argument. - * - * @param CartProductUpdate[] $knownUpdates - * - * @return CartProductUpdate[] - */ - public function getAdditionalProducts(array $knownUpdates = []): array - { - $newProducts = $this->cart->getProducts(true); - $allAdditionalProducts = $this->getAllAdditionalProducts($newProducts); - - return $this->filterKnownUpdates($allAdditionalProducts, $knownUpdates); - } - - /** - * Returns a list of products that were modified (created and/or updated) compared to the state of the cart - * when this object was created, it removes the already known modified products provided as argument. - * - * @param CartProductUpdate[] $knownUpdates - * - * @return CartProductUpdate[] - */ - public function getModifiedProducts(array $knownUpdates = []): array - { - $newProducts = $this->cart->getProducts(true); - $modifiedProducts = array_merge($this->getAllUpdatedProducts($newProducts), $this->getAllAdditionalProducts($newProducts)); - - return $this->filterKnownUpdates($modifiedProducts, $knownUpdates); - } - - /** - * Returns the list of updates for products that were not in the cart previously - * - * @param array[] $newProducts - * - * @return array - */ - private function getAllAdditionalProducts(array $newProducts): array - { - $additionalProducts = []; - foreach ($newProducts as $newProduct) { - // Then try and find the product in new products - $oldProduct = $this->getMatchingProduct($this->savedProducts, $newProduct); - if (null === $oldProduct) { - $additionalProducts[] = new CartProductUpdate( - (int) $newProduct['id_product'], - (int) $newProduct['id_product_attribute'], - (int) $newProduct['cart_quantity'], - true - ); - } - } - - return $additionalProducts; - } - - /** - * Returns a list of all products that were updated compared to the creation of this object. - * - * @param array[] $newProducts - * - * @return CartProductUpdate[] - */ - private function getAllUpdatedProducts(array $newProducts): array - { - $updatedProducts = []; - foreach ($this->savedProducts as $oldProduct) { - // Then try and find the product in new products - $newProduct = $this->getMatchingProduct($newProducts, $oldProduct); - if (null === $newProduct) { - $deltaQuantity = -(int) $oldProduct['cart_quantity']; - } else { - $deltaQuantity = (int) $newProduct['cart_quantity'] - (int) $oldProduct['cart_quantity']; - } - - if ($deltaQuantity) { - $updatedProducts[] = new CartProductUpdate( - (int) $oldProduct['id_product'], - (int) $oldProduct['id_product_attribute'], - $deltaQuantity, - false - ); - } - } - - return $updatedProducts; - } - - /** - * @param CartProductUpdate[] $updates - * @param CartProductUpdate[] $knownUpdates - * - * @return CartProductUpdate[] - */ - private function filterKnownUpdates(array $updates, array $knownUpdates): array - { - $filteredUpdates = []; - foreach ($updates as $updateProduct) { - foreach ($knownUpdates as $knownUpdate) { - if ($knownUpdate->productMatches($updateProduct)) { - $updateProduct->setDeltaQuantity( - $updateProduct->getDeltaQuantity() - $knownUpdate->getDeltaQuantity() - ); - - break; - } - } - if (0 !== $updateProduct->getDeltaQuantity()) { - $filteredUpdates[] = $updateProduct; - } - } - - return $filteredUpdates; - } - - /** - * @param array $products - * @param array $searchedProduct - * - * @return array|null - */ - private function getMatchingProduct(array $products, array $searchedProduct): ?array - { - return array_reduce($products, function ($carry, $item) use ($searchedProduct) { - if (null !== $carry) { - return $carry; - } - - $productMatch = $item['id_product'] == $searchedProduct['id_product']; - $combinationMatch = $item['id_product_attribute'] == $searchedProduct['id_product_attribute']; - - return $productMatch && $combinationMatch ? $item : null; - }); - } -} diff --git a/src/Adapter/Cart/QueryHandler/GetCartForOrderCreationHandler.php b/src/Adapter/Cart/QueryHandler/GetCartForOrderCreationHandler.php deleted file mode 100644 index 85421c3e..00000000 --- a/src/Adapter/Cart/QueryHandler/GetCartForOrderCreationHandler.php +++ /dev/null @@ -1,559 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\QueryHandler; - -use Address; -use AddressFormat; -use Carrier; -use Cart; -use CartRule; -use Currency; -use Customer; -use Language; -use Link; -use Message; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Adapter\Cart\AbstractCartHandler; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Cart\Query\GetCartForOrderCreation; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryHandler\GetCartForOrderCreationHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation\CartAddress; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation\CartDeliveryOption; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation\CartProduct; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation\CartShipping; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation\CartSummary; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation\Customization; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation\CustomizationFieldData; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShop\PrestaShop\Core\Localization\LocaleInterface; -use PrestaShopException; -use Product; -use Shop; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Handles GetCartForOrderCreation query using legacy object models - */ -final class GetCartForOrderCreationHandler extends AbstractCartHandler implements GetCartForOrderCreationHandlerInterface -{ - /** - * @var LocaleInterface - */ - private $locale; - - /** - * @var int - */ - private $contextLangId; - - /** - * @var Link - */ - private $contextLink; - - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param LocaleInterface $locale - * @param int $contextLangId - * @param Link $contextLink - * @param ContextStateManager $contextStateManager - * @param TranslatorInterface $translator - */ - public function __construct( - LocaleInterface $locale, - int $contextLangId, - Link $contextLink, - ContextStateManager $contextStateManager, - TranslatorInterface $translator - ) { - $this->locale = $locale; - $this->contextLangId = $contextLangId; - $this->contextLink = $contextLink; - $this->contextStateManager = $contextStateManager; - $this->translator = $translator; - } - - /** - * @param GetCartForOrderCreation $query - * - * @return CartForOrderCreation - * - * @throws CartNotFoundException - * @throws LocalizationException - * @throws PrestaShopException - */ - public function handle(GetCartForOrderCreation $query): CartForOrderCreation - { - $cart = $this->getCart($query->getCartId()); - $currency = new Currency($cart->id_currency); - $language = new Language($cart->id_lang); - - $this->contextStateManager - ->setCart($cart) - ->setCurrency($currency) - ->setLanguage($language) - ->setCustomer(new Customer($cart->id_customer)) - ->setShop(new Shop($cart->id_shop)) - ; - - try { - $addresses = $this->getAddresses($cart); - - if ($query->hideDiscounts()) { - $legacySummary = $cart->getSummaryDetails($cart->id_lang, true); - $products = $this->extractProductsWithGiftSplitFromLegacySummary($cart, $legacySummary, $currency); - } else { - $legacySummary = $cart->getRawSummaryDetails($cart->id_lang, true); - $products = $this->extractProductsFromLegacySummary($cart, $legacySummary, $currency); - } - - $result = new CartForOrderCreation( - $cart->id, - $products, - (int) $currency->id, - (int) $language->id, - $this->extractCartRulesFromLegacySummary($cart, $legacySummary, $currency, $query->hideDiscounts()), - $addresses, - $this->extractSummaryFromLegacySummary($legacySummary, $currency, $cart), - $addresses ? $this->extractShippingFromLegacySummary($cart, $legacySummary, $query->hideDiscounts()) : null - ); - - $this->contextStateManager->restorePreviousContext(); - } finally { - $this->contextStateManager->restorePreviousContext(); - } - - return $result; - } - - /** - * @param Cart $cart - * - * @return CartAddress[] - */ - private function getAddresses(Cart $cart): array - { - $customer = new Customer($cart->id_customer); - $cartAddresses = []; - - foreach ($customer->getAddresses($cart->id_lang) as $data) { - $addressId = (int) $data['id_address']; - $cartAddresses[$addressId] = $this->buildCartAddress($addressId, $cart); - } - - // Add addresses already assigned to cart if absent (in case they are deleted) - if (0 !== (int) $cart->id_address_delivery && !isset($cartAddresses[$cart->id_address_delivery])) { - $cartAddresses[$cart->id_address_delivery] = $this->buildCartAddress( - $cart->id_address_delivery, - $cart - ); - } - if (0 !== (int) $cart->id_address_invoice && !isset($cartAddresses[$cart->id_address_invoice])) { - $cartAddresses[$cart->id_address_invoice] = $this->buildCartAddress( - $cart->id_address_invoice, - $cart - ); - } - - return array_values($cartAddresses); - } - - /** - * @param int $addressId - * @param Cart $cart - * - * @return CartAddress - */ - private function buildCartAddress(int $addressId, Cart $cart): CartAddress - { - $address = new Address($addressId); - - return new CartAddress( - $address->id, - $address->alias, - AddressFormat::generateAddress($address, [], '
    '), - (int) $cart->id_address_delivery === $address->id, - (int) $cart->id_address_invoice === $address->id - ); - } - - /** - * @param Cart $cart - * @param array $legacySummary - * @param Currency $currency - * @param bool $hideDiscounts - * - * @return CartForOrderCreation\CartRule[] - */ - private function extractCartRulesFromLegacySummary(Cart $cart, array $legacySummary, Currency $currency, bool $hideDiscounts = false): array - { - $cartRules = []; - - foreach ($legacySummary['discounts'] as $discount) { - $cartRuleId = (int) $discount['id_cart_rule']; - $cartRules[$cartRuleId] = new CartForOrderCreation\CartRule( - (int) $discount['id_cart_rule'], - $discount['name'], - $discount['description'], - (new Number((string) $discount['value_tax_exc']))->round($currency->precision) - ); - } - - if ($hideDiscounts) { - foreach ($cart->getCartRules(CartRule::FILTER_ACTION_GIFT) as $giftRule) { - $giftRuleId = (int) $giftRule['id_cart_rule']; - $finalValue = new Number((string) $giftRule['value_tax_exc']); - - if (isset($cartRules[$giftRuleId])) { - // it is possible that one cart rule can have a gift product, but also have other conditions, - //so we need to sum their reduction values - /** @var CartForOrderCreation\CartRule $cartRule */ - $cartRule = $cartRules[$giftRuleId]; - $finalValue = $finalValue->plus(new Number($cartRule->getValue())); - } - - $cartRules[$giftRuleId] = new CartForOrderCreation\CartRule( - (int) $giftRule['id_cart_rule'], - $giftRule['name'], - $giftRule['description'], - $finalValue->round($currency->precision) - ); - } - } - - return $cartRules; - } - - /** - * @param Cart $cart - * @param array $legacySummary - * @param Currency $currency - * - * @return CartProduct[] - */ - private function extractProductsWithGiftSplitFromLegacySummary(Cart $cart, array $legacySummary, Currency $currency): array - { - $products = []; - $mergedGifts = $this->mergeGiftProducts($legacySummary['gift_products']); - - foreach ($legacySummary['products'] as $product) { - $productKey = $this->generateUniqueProductKey($product); - - //decrease product quantity for each identical product which is marked as gift - if (isset($mergedGifts[$productKey])) { - $identicalGiftedProduct = $mergedGifts[$productKey]; - $product['quantity'] -= $identicalGiftedProduct['quantity']; - } - - $products[] = $this->buildCartProduct($cart, $currency, $product); - } - - foreach ($mergedGifts as $product) { - $products[] = $this->buildCartProduct($cart, $currency, $product); - } - - return $products; - } - - /** - * @param Cart $cart - * @param array $legacySummary - * @param Currency $currency - * - * @return CartProduct[] - */ - private function extractProductsFromLegacySummary(Cart $cart, array $legacySummary, Currency $currency): array - { - $products = []; - foreach ($legacySummary['products'] as $product) { - $products[] = $this->buildCartProduct($cart, $currency, $product); - } - - return $products; - } - - /** - * @param array $giftProducts - * - * @return array - */ - private function mergeGiftProducts(array $giftProducts): array - { - $mergedGifts = []; - - foreach ($giftProducts as $giftProduct) { - $productKey = $this->generateUniqueProductKey($giftProduct); - - if (!isset($mergedGifts[$productKey])) { - // set first gift and make sure its quantity is 1. - $mergedGifts[$productKey] = $giftProduct; - $mergedGifts[$productKey]['quantity'] = 1; - } else { - //increase existing gift quantity by 1 - ++$mergedGifts[$productKey]['quantity']; - } - } - - return $mergedGifts; - } - - /** - * Forms a unique product key using combination and customization ids. - * - * @param array $product - * - * @return string - */ - private function generateUniqueProductKey(array $product): string - { - return sprintf( - '%s_%s_%s', - (int) $product['id_product'], - (int) $product['id_product_attribute'], - (int) $product['id_customization'] - ); - } - - /** - * @param Cart $cart - * @param array $legacySummary - * @param bool $hideDiscounts - * - * @return CartShipping|null - */ - private function extractShippingFromLegacySummary(Cart $cart, array $legacySummary, bool $hideDiscounts = true): ?CartShipping - { - $deliveryOptionsByAddress = $cart->getDeliveryOptionList(); - $deliveryAddress = (int) $cart->id_address_delivery; - - //Check if there is any delivery options available for cart delivery address - if (!array_key_exists($deliveryAddress, $deliveryOptionsByAddress)) { - return null; - } - - /** @var Carrier $carrier */ - $carrier = $legacySummary['carrier']; - $isFreeShipping = !empty($cart->getCartRules(CartRule::FILTER_ACTION_SHIPPING)); - - return new CartShipping( - $isFreeShipping && $hideDiscounts ? '0' : (string) $legacySummary['total_shipping'], - $isFreeShipping, - $this->fetchCartDeliveryOptions($deliveryOptionsByAddress, $deliveryAddress), - (int) $carrier->id ?: null, - (bool) $cart->gift, - (bool) $cart->recyclable, - $cart->gift_message - ); - } - - /** - * Fetch CartDeliveryOption[] DTO's from legacy array - * - * @param array $deliveryOptionsByAddress - * @param int $deliveryAddressId - * - * @return array - */ - private function fetchCartDeliveryOptions(array $deliveryOptionsByAddress, int $deliveryAddressId) - { - $deliveryOptions = []; - // legacy multishipping feature allowed to split cart shipping to multiple addresses. - // now when the multishipping feature is removed - // the list of carriers should be shared across whole cart for single delivery address - foreach ($deliveryOptionsByAddress[$deliveryAddressId] as $deliveryOption) { - foreach ($deliveryOption['carrier_list'] as $carrier) { - $carrier = $carrier['instance']; - // make sure there is no duplicate carrier - $deliveryOptions[(int) $carrier->id] = new CartDeliveryOption( - (int) $carrier->id, - $carrier->name, - $carrier->delay[$this->contextLangId] - ); - } - } - - //make sure array is not associative - return array_values($deliveryOptions); - } - - /** - * @param array $legacySummary - * @param Currency $currency - * @param Cart $cart - * - * @return CartSummary - * - * @throws LocalizationException - */ - private function extractSummaryFromLegacySummary(array $legacySummary, Currency $currency, Cart $cart): CartSummary - { - $cartId = (int) $cart->id; - - $discount = $this->locale->formatPrice(-1 * $legacySummary['total_discounts_tax_exc'], $currency->iso_code); - - $orderMessage = ''; - if ($message = Message::getMessageByCartId($cartId)) { - $orderMessage = $message['message']; - } - - return new CartSummary( - $this->locale->formatPrice($legacySummary['total_products'], $currency->iso_code), - $discount, - $this->locale->formatPrice($legacySummary['total_shipping'], $currency->iso_code), - $this->locale->formatPrice($legacySummary['total_shipping_tax_exc'], $currency->iso_code), - $this->locale->formatPrice($legacySummary['total_tax'], $currency->iso_code), - $this->locale->formatPrice($legacySummary['total_price'], $currency->iso_code), - $this->locale->formatPrice($legacySummary['total_price_without_tax'], $currency->iso_code), - $orderMessage, - $this->contextLink->getPageLink( - 'order', - false, - (int) $cart->id_lang, - http_build_query([ - 'step' => 3, - 'recover_cart' => $cartId, - 'token_cart' => md5(_COOKIE_KEY_ . 'recover_cart_' . $cartId), - ]) - ) - ); - } - - /** - * Provides product customizations data - * - * @param Cart $cart - * @param array $product the product array from legacy summary - * - * @return Customization|null - */ - private function getProductCustomizedData(Cart $cart, array $product): ?Customization - { - $customizationId = (int) $product['id_customization']; - - if (!$customizationId) { - return null; - } - - $customizations = Product::getAllCustomizedDatas( - $cart->id, - $cart->id_lang, - true, - null, - $customizationId - ); - - if ($customizations) { - $productCustomizedFieldsData = $this->getProductCustomizedFieldsData($customizations, $product); - } - - if (empty($productCustomizedFieldsData)) { - return null; - } - - return new CartForOrderCreation\Customization($customizationId, $productCustomizedFieldsData); - } - - /** - * Provides customized fields data for product - * - * @param array $customizations - * @param array $product - * - * @return array - */ - private function getProductCustomizedFieldsData(array $customizations, array $product) - { - $customizationFieldsData = []; - - if (isset($customizations[$product['id_product']][$product['id_product_attribute']])) { - foreach ($customizations[$product['id_product']][$product['id_product_attribute']] as $customizationByAddress) { - foreach ($customizationByAddress as $customization) { - if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) { - foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) { - $customizationFieldsData[] = new CustomizationFieldData( - Product::CUSTOMIZE_TEXTFIELD, - $text['name'], - $text['value'] - ); - } - } - - if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) { - foreach ($customization['datas'][Product::CUSTOMIZE_FILE] as $file) { - $customizationFieldsData[] = new CustomizationFieldData( - Product::CUSTOMIZE_FILE, - $file['name'], - _THEME_PROD_PIC_DIR_ . $file['value'] . '_small' - ); - } - } - } - } - } - - return $customizationFieldsData; - } - - /** - * @param Cart $cart - * @param Currency $currency - * @param array $product - * @param bool $isGift - * - * @return CartProduct - */ - private function buildCartProduct( - Cart $cart, - Currency $currency, - array $product - ): CartProduct { - return new CartProduct( - (int) $product['id_product'], - isset($product['id_product_attribute']) ? (int) $product['id_product_attribute'] : 0, - $product['name'], - isset($product['attributes_small']) ? $product['attributes_small'] : '', - $product['reference'], - \Tools::ps_round($product['price'], $currency->precision), - $product['quantity'], - \Tools::ps_round($product['total'], $currency->precision), - $this->contextLink->getImageLink($product['link_rewrite'], $product['id_image'], 'small_default'), - $this->getProductCustomizedData($cart, $product), - !empty($product['is_gift']) - ); - } -} diff --git a/src/Adapter/Cart/QueryHandler/GetCartForViewingHandler.php b/src/Adapter/Cart/QueryHandler/GetCartForViewingHandler.php deleted file mode 100644 index 9212f216..00000000 --- a/src/Adapter/Cart/QueryHandler/GetCartForViewingHandler.php +++ /dev/null @@ -1,314 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\QueryHandler; - -use Cart; -use Context; -use Currency; -use Customer; -use DateTime; -use Gender; -use Group; -use Order; -use PrestaShop\PrestaShop\Adapter\ImageManager; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Cart\Query\GetCartForViewing; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryHandler\GetCartForViewingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartView; -use PrestaShop\PrestaShop\Core\Localization\Locale; -use Product; -use StockAvailable; -use Validate; - -/** - * @internal - */ -final class GetCartForViewingHandler implements GetCartForViewingHandlerInterface -{ - /** - * @var ImageManager - */ - private $imageManager; - - /** - * @var Locale - */ - private $locale; - - /** - * @param ImageManager $imageManager - * @param Locale $locale - */ - public function __construct(ImageManager $imageManager, Locale $locale) - { - $this->imageManager = $imageManager; - $this->locale = $locale; - } - - /** - * {@inheritdoc} - */ - public function handle(GetCartForViewing $query) - { - $cartId = $query->getCartId()->getValue(); - $cart = new Cart($cartId); - - if ($cart->id !== $cartId) { - throw new CartNotFoundException(sprintf('Cart with id "%s" were not found', $cartId)); - } - - $customer = new Customer($cart->id_customer); - $currency = new Currency($cart->id_currency); - - $context = Context::getContext(); - $context->cart = $cart; - $context->currency = $currency; - $context->customer = $customer; - - $products = $cart->getProducts(); - $summary = $cart->getSummaryDetails(); - - $id_order = (int) Order::getIdByCartId($cart->id); - $order = new Order($id_order); - - if (Validate::isLoadedObject($order)) { - $tax_calculation_method = $order->getTaxCalculationMethod(); - $id_shop = (int) $order->id_shop; - } else { - $id_shop = (int) $cart->id_shop; - $tax_calculation_method = Group::getPriceDisplayMethod(Group::getCurrent()->id); - } - - if ($tax_calculation_method == PS_TAX_EXC) { - $total_products = $summary['total_products']; - $total_discounts = $summary['total_discounts_tax_exc']; - $total_wrapping = $summary['total_wrapping_tax_exc']; - $total_price = $summary['total_price_without_tax']; - $total_shipping = $summary['total_shipping_tax_exc']; - } else { - $total_products = $summary['total_products_wt']; - $total_discounts = $summary['total_discounts']; - $total_wrapping = $summary['total_wrapping']; - $total_price = $summary['total_price']; - $total_shipping = $summary['total_shipping']; - } - - foreach ($products as &$product) { - if ($tax_calculation_method == PS_TAX_EXC) { - $product['product_price'] = $product['price']; - $product['product_total'] = $product['total']; - } else { - $product['product_price'] = $product['price_wt']; - $product['product_total'] = $product['total_wt']; - } - - $product['qty_in_stock'] = StockAvailable::getQuantityAvailableByProduct( - $product['id_product'], - isset($product['id_product_attribute']) ? $product['id_product_attribute'] : null, - (int) $id_shop - ); - - $customized_datas = Product::getAllCustomizedDatas( - $context->cart->id, - null, - true, - null, - (int) $product['id_customization'] - ); - $context->cart->setProductCustomizedDatas($product, $customized_datas); - - if ($customized_datas) { - Product::addProductCustomizationPrice($product, $customized_datas); - } - } - - $customerStats = $customer->getStats(); - $gender = new Gender($customer->id_gender, $context->language->id); - - $products = $this->prepareProductForView($products, $currency, $context->language->id); - - $customerInformation = [ - 'id' => $customer->id, - 'first_name' => $customer->firstname, - 'last_name' => $customer->lastname, - 'gender' => $gender->name, - 'email' => $customer->email, - 'registration_date' => (new DateTime($customer->date_add))->format($context->language->date_format_lite), - 'valid_orders_count' => $customerStats['nb_orders'], - 'total_spent_since_registration' => $this->locale->formatPrice( - $customerStats['total_orders'] ?: 0, - $currency->iso_code - ), - ]; - - $orderInformation = [ - 'id' => $order->id, - 'placed_date' => (new DateTime($order->date_add))->format($context->language->date_format_lite), - ]; - - $cartSummary = [ - 'products' => $products, - 'cart_rules' => $this->getCartRulesForView($cart), - 'total_products' => $total_products, - 'total_products_formatted' => $this->locale->formatPrice($total_products, $currency->iso_code), - 'total_discounts' => $total_discounts, - 'total_discounts_formatted' => $this->locale->formatPrice($total_discounts, $currency->iso_code), - 'total_wrapping' => $total_wrapping, - 'total_wrapping_formatted' => $this->locale->formatPrice($total_wrapping, $currency->iso_code), - 'total_shipping' => $total_shipping, - 'total_shipping_formatted' => $this->locale->formatPrice($total_shipping, $currency->iso_code), - 'total' => $total_price, - 'total_formatted' => $this->locale->formatPrice($total_price, $currency->iso_code), - 'is_tax_included' => $tax_calculation_method == PS_TAX_INC, - ]; - - return new CartView($cart->id, $cart->id_currency, $customerInformation, $orderInformation, $cartSummary); - } - - /** - * @param array $products - * @param Currency $currency - * @param int $languageId - * - * @return array - */ - private function prepareProductForView(array $products, Currency $currency, int $languageId) - { - $formattedProducts = []; - - foreach ($products as $product) { - if ($product['id_product_attribute']) { - $image = Product::getCombinationImageById($product['id_product_attribute'], $languageId); - } else { - $image = Product::getCover($product['id_product']); - } - - $formattedProduct = [ - 'id' => $product['id_product'], - 'name' => $product['name'], - 'attributes' => isset($product['attributes']) ? $product['attributes'] : '', - 'reference' => $product['name'], - 'supplier_reference' => $product['supplier_reference'], - 'stock_quantity' => $product['qty_in_stock'], - 'customization_quantity' => $product['customizationQuantityTotal'], - 'cart_quantity' => $product['cart_quantity'], - 'total_price' => $product['product_total'], - 'unit_price' => $product['product_price'], - 'total_price_formatted' => $this->locale->formatPrice($product['product_total'], $currency->iso_code), - 'unit_price_formatted' => $this->locale->formatPrice($product['product_price'], $currency->iso_code), - 'image' => $this->imageManager->getThumbnailForListing($image['id_image']), - ]; - - if (isset($product['customizationQuantityTotal'])) { - $formattedProduct['cart_quantity'] = - $product['cart_quantity'] - $product['customizationQuantityTotal']; - } - - $productCustomization = []; - - if ($product['customizedDatas']) { - $formattedProduct['unit_price'] = $product['price_wt']; - $formattedProduct['unit_price_formatted'] = $this->locale->formatPrice($product['price_wt'], $currency->iso_code); - $formattedProduct['total_price'] = $product['total_customization_wt']; - $formattedProduct['total_price_formatted'] = $this->locale->formatPrice( - $product['total_customization_wt'], - $currency->iso_code - ); - $formattedProduct['quantity'] = $product['customizationQuantityTotal']; - - foreach ($product['customizedDatas'] as $customizationPerAddress) { - foreach ($customizationPerAddress as $customization) { - if (((int) $customization['id_customization'] !== (int) $product['id_customization']) && - count($customizationPerAddress) === 1 - ) { - continue; - } - - $productCustomization = [ - 'quantity' => $customization['quantity'], - 'fields' => [], - ]; - - foreach ($customization['datas'] as $type => $data) { - if (Product::CUSTOMIZE_FILE === $type) { - foreach ($data as $item) { - $productCustomization['fields'][] = [ - 'name' => $item['name'], - 'value' => $item['value'], - 'type' => 'customizable_file', - 'image' => _THEME_PROD_PIC_DIR_ . $item['value'] . '_small', - ]; - } - } elseif (Product::CUSTOMIZE_TEXTFIELD === $type) { - foreach ($data as $item) { - $productCustomization['fields'][] = [ - 'name' => $item['name'], - 'value' => $item['value'], - 'type' => 'customizable_text_field', - ]; - } - } - } - } - } - } - - $formattedProduct['customization'] = $productCustomization; - - $formattedProducts[] = $formattedProduct; - } - - return $formattedProducts; - } - - /** - * @param Cart $cart - * - * @return array - */ - private function getCartRulesForView(Cart $cart) - { - $cartRules = $cart->getCartRules(); - $cartRulesView = []; - - $cartCurrency = new Currency($cart->id_currency); - - foreach ($cartRules as $cartRule) { - $cartRulesView[] = [ - 'id' => $cartRule['id_cart_rule'], - 'name' => $cartRule['name'], - 'is_free_shipping' => !$cartRule['value_real'] && $cartRule['free_shipping'], - 'formatted_value' => $this->locale->formatPrice( - $cartRule['value_real'], - $cartCurrency->iso_code - ), - ]; - } - - return $cartRulesView; - } -} diff --git a/src/Adapter/Cart/QueryHandler/GetLastEmptyCustomerCartHandler.php b/src/Adapter/Cart/QueryHandler/GetLastEmptyCustomerCartHandler.php deleted file mode 100644 index 7dc18dbc..00000000 --- a/src/Adapter/Cart/QueryHandler/GetLastEmptyCustomerCartHandler.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Cart\QueryHandler; - -use Customer; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartException; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Cart\Query\GetLastEmptyCustomerCart; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryHandler\GetLastEmptyCustomerCartHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerNotFoundException; -use PrestaShopException; - -/** - * Gets last empty cart for customer using legacy object model - */ -final class GetLastEmptyCustomerCartHandler implements GetLastEmptyCustomerCartHandlerInterface -{ - /** - * @param GetLastEmptyCustomerCart $query - * - * @return CartId - * - * @throws CartException - * @throws CartNotFoundException - * @throws CustomerNotFoundException - * @throws CartConstraintException - */ - public function handle(GetLastEmptyCustomerCart $query): CartId - { - $customerId = $query->getCustomerId()->getValue(); - - try { - $customer = new Customer($customerId); - - if ($customer->id !== $customerId) { - throw new CustomerNotFoundException($query->getCustomerId(), sprintf('Customer with id "%s" was not found.', $customerId)); - } - - $cartId = $customer->getLastEmptyCart(false); - - if (false === $cartId) { - throw new CartNotFoundException(sprintf('Empty cart not found for customer with id "%s"', $customerId)); - } - } catch (PrestaShopException $e) { - throw new CartException(sprintf('An error occurred while trying to find empty cart for customer with id "%s"', $customerId)); - } - - return new CartId($cartId); - } -} diff --git a/src/Adapter/CartRule/CommandHandler/AddCartRuleHandler.php b/src/Adapter/CartRule/CommandHandler/AddCartRuleHandler.php deleted file mode 100644 index b97711d4..00000000 --- a/src/Adapter/CartRule/CommandHandler/AddCartRuleHandler.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CartRule\CommandHandler; - -use CartRule; -use PrestaShop\PrestaShop\Adapter\CartRule\LegacyDiscountApplicationType; -use PrestaShop\PrestaShop\Core\Domain\CartRule\Command\AddCartRuleCommand; -use PrestaShop\PrestaShop\Core\Domain\CartRule\CommandHandler\AddCartRuleHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CartRule\Exception\CartRuleConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CartRule\Exception\CartRuleException; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\CartRuleAction\CartRuleActionInterface; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\CartRuleId; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\DiscountApplicationType; -use PrestaShopException; - -/** - * Handles adding new cart rule using legacy logic. - */ -final class AddCartRuleHandler implements AddCartRuleHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(AddCartRuleCommand $command): CartRuleId - { - try { - $cartRule = $this->buildCartRuleFromCommandData($command); - - if (false === $cartRule->validateFields(false) || false === $cartRule->validateFieldsLang(false)) { - throw new CartRuleConstraintException('Cart rule contains invalid field values'); - } - if (false === $cartRule->add()) { - throw new CartRuleException('Failed to add new cart rule'); - } - } catch (PrestaShopException $e) { - throw new CartRuleException('An error occurred when trying to add new cart rule'); - } - - return new CartRuleId((int) $cartRule->id); - } - - /** - * @param AddCartRuleCommand $command - * - * @return CartRule - * - * @throws PrestaShopException - */ - private function buildCartRuleFromCommandData(AddCartRuleCommand $command): CartRule - { - $cartRule = new CartRule(); - - $cartRule->name = $command->getLocalizedNames(); - $cartRule->description = $command->getDescription(); - $cartRule->code = $command->getCode(); - $cartRule->highlight = $command->isHighlightInCart(); - $cartRule->partial_use = $command->isAllowPartialUse(); - $cartRule->priority = $command->getPriority(); - $cartRule->active = $command->isActive(); - - $this->fillCartRuleConditionsFromCommandData($cartRule, $command); - $this->fillCartRuleActionsFromCommandData($cartRule, $command); - - return $cartRule; - } - - /** - * Fills cart rule with conditions data from command. - * - * @param CartRule $cartRule - * @param AddCartRuleCommand $command - */ - private function fillCartRuleConditionsFromCommandData(CartRule $cartRule, AddCartRuleCommand $command): void - { - $cartRule->id_customer = null !== $command->getCustomerId() ? $command->getCustomerId()->getValue() : null; - - $cartRule->date_from = $command->getValidFrom()->format('Y-m-d H:i:s'); - $cartRule->date_to = $command->getValidTo()->format('Y-m-d H:i:s'); - - $minimumAmount = $command->getMinimumAmountCondition(); - $cartRule->minimum_amount = (string) $minimumAmount->getMoneyAmount()->getAmount(); - $cartRule->minimum_amount_currency = $minimumAmount->getMoneyAmount()->getCurrencyId()->getValue(); - $cartRule->minimum_amount_shipping = !$minimumAmount->isShippingExcluded(); - $cartRule->minimum_amount_tax = !$minimumAmount->isTaxExcluded(); - - $cartRule->quantity = $command->getTotalQuantity(); - $cartRule->quantity_per_user = $command->getQuantityPerUser(); - - $cartRule->country_restriction = $command->hasCountryRestriction(); - $cartRule->carrier_restriction = $command->hasCarrierRestriction(); - $cartRule->group_restriction = $command->hasGroupRestriction(); - $cartRule->cart_rule_restriction = $command->hasCartRuleRestriction(); - $cartRule->product_restriction = $command->hasProductRestriction(); - $cartRule->shop_restriction = $command->hasShopRestriction(); - } - - /** - * Fills cart rule with actions data from command. - * - * @param CartRule $cartRule - * @param AddCartRuleCommand $command - */ - private function fillCartRuleActionsFromCommandData(CartRule $cartRule, AddCartRuleCommand $command): void - { - $cartRuleAction = $command->getCartRuleAction(); - $amountDiscount = $cartRuleAction->getAmountDiscount(); - $percentageDiscount = $cartRuleAction->getPercentageDiscount(); - $giftProduct = $cartRuleAction->getGiftProduct(); - $cartRule->free_shipping = $cartRuleAction->isFreeShipping(); - - $cartRule->gift_product = null !== $giftProduct ? $giftProduct->getProductId()->getValue() : null; - $cartRule->gift_product_attribute = null !== $giftProduct ? $giftProduct->getProductAttributeId() : null; - $cartRule->reduction_amount = null !== $amountDiscount ? - (string) $amountDiscount->getMoneyAmount()->getAmount() : - null; - $cartRule->reduction_currency = null !== $amountDiscount ? - $amountDiscount->getMoneyAmount()->getCurrencyId()->getValue() : - null; - - // Legacy reduction_tax property is true when it's tax included, false when tax excluded. - $cartRule->reduction_tax = null !== $amountDiscount ? !$amountDiscount->isTaxExcluded() : null; - - $cartRule->reduction_percent = null !== $percentageDiscount ? $percentageDiscount->getPercentage() : null; - $cartRule->reduction_exclude_special = null !== $percentageDiscount ? - !$percentageDiscount->appliesToDiscountedProducts() : - null; - - $discountApplicationType = $command->getDiscountApplicationType(); - - if (null !== $discountApplicationType) { - $this->fillDiscountApplicationType( - $cartRule, - $command, - $cartRuleAction, - $discountApplicationType - ); - } - } - - /** - * @param CartRule $cartRule - * @param AddCartRuleCommand $command - * @param CartRuleActionInterface $cartRuleAction - * @param DiscountApplicationType $discountApplicationType - * - * @throws CartRuleConstraintException - */ - private function fillDiscountApplicationType( - CartRule $cartRule, - AddCartRuleCommand $command, - CartRuleActionInterface $cartRuleAction, - DiscountApplicationType $discountApplicationType - ): void { - $hasAmountDiscount = null !== $cartRuleAction->getAmountDiscount(); - $hasPercentageDiscount = null !== $cartRuleAction->getPercentageDiscount(); - - switch ($discountApplicationType->getValue()) { - case DiscountApplicationType::SELECTED_PRODUCTS: - if (!$hasPercentageDiscount) { - throw new CartRuleConstraintException('Cart rule, which is applied to selected products, must have percent discount type.', CartRuleConstraintException::INCOMPATIBLE_CART_RULE_ACTIONS); - } - - $cartRule->reduction_product = LegacyDiscountApplicationType::SELECTED_PRODUCTS; - - break; - case DiscountApplicationType::CHEAPEST_PRODUCT: - if (!$hasPercentageDiscount) { - throw new CartRuleConstraintException('Cart rule, which is applied to cheapest product, must have percent discount type.', CartRuleConstraintException::INCOMPATIBLE_CART_RULE_ACTIONS); - } - - $cartRule->reduction_product = LegacyDiscountApplicationType::CHEAPEST_PRODUCT; - - break; - case DiscountApplicationType::SPECIFIC_PRODUCT: - if (!$hasPercentageDiscount && !$hasAmountDiscount) { - throw new CartRuleConstraintException('Cart rule, which is applied to a specific product, ' . 'must have percentage or amount application type.', CartRuleConstraintException::INCOMPATIBLE_CART_RULE_ACTIONS); - } - - if (null === $command->getDiscountProductId()) { - throw new CartRuleConstraintException('Cart rule, which is applied to a specific product, must have a product specified.', CartRuleConstraintException::MISSING_DISCOUNT_APPLICATION_PRODUCT); - } - - $cartRule->reduction_product = $command->getDiscountProductId()->getValue(); - - break; - case DiscountApplicationType::ORDER_WITHOUT_SHIPPING: - if (!$hasAmountDiscount && !$hasPercentageDiscount) { - throw new CartRuleConstraintException('Cart rule, which is applied to whole order without shipping, ' . 'must have percentage or amount application type.', CartRuleConstraintException::INCOMPATIBLE_CART_RULE_ACTIONS); - } - - $cartRule->reduction_product = LegacyDiscountApplicationType::ORDER_WITHOUT_SHIPPING; - - break; - } - } -} diff --git a/src/Adapter/CartRule/LegacyDiscountApplicationType.php b/src/Adapter/CartRule/LegacyDiscountApplicationType.php deleted file mode 100644 index 31fad0ea..00000000 --- a/src/Adapter/CartRule/LegacyDiscountApplicationType.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CartRule; - -/** - * Legacy discount application types, used in cart rules, are defined in this class. - */ -final class LegacyDiscountApplicationType -{ - /** - * Discount is applied for selected products - */ - public const SELECTED_PRODUCTS = -2; - - /** - * Discount is applied to cheapest product - */ - public const CHEAPEST_PRODUCT = -1; - - /** - * Discount is applied to order without shipping - */ - public const ORDER_WITHOUT_SHIPPING = 0; - - /** - * Class used only for constants. - */ - private function __construct() - { - } -} diff --git a/src/Adapter/CartRule/QueryHandler/SearchCartRulesHandler.php b/src/Adapter/CartRule/QueryHandler/SearchCartRulesHandler.php deleted file mode 100644 index ce05ddcf..00000000 --- a/src/Adapter/CartRule/QueryHandler/SearchCartRulesHandler.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CartRule\QueryHandler; - -use CartRule; -use PrestaShop\PrestaShop\Core\Domain\CartRule\Query\SearchCartRules; -use PrestaShop\PrestaShop\Core\Domain\CartRule\QueryHandler\SearchCartRulesHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CartRule\QueryResult\FoundCartRule; - -/** - * Searches for cart rules by search phrase using legacy object model - */ -final class SearchCartRulesHandler implements SearchCartRulesHandlerInterface -{ - /** - * @var int - */ - private $contextLangId; - - /** - * @param int $contextLangId - */ - public function __construct(int $contextLangId) - { - $this->contextLangId = $contextLangId; - } - - /** - * @param SearchCartRules $query - * - * @return FoundCartRule[] - */ - public function handle(SearchCartRules $query): array - { - $searchPhrase = $query->getSearchPhrase(); - $foundCartRules = []; - $cartRules = CartRule::getCartsRuleByCode($searchPhrase, $this->contextLangId, true); - - foreach ($cartRules as $cartRule) { - $foundCartRules[] = new FoundCartRule( - (int) $cartRule['id_cart_rule'], - $cartRule['name'], - $cartRule['code'] - ); - } - - return $foundCartRules; - } -} diff --git a/src/Adapter/CatalogPriceRule/AbstractCatalogPriceRuleHandler.php b/src/Adapter/CatalogPriceRule/AbstractCatalogPriceRuleHandler.php deleted file mode 100644 index 00df9497..00000000 --- a/src/Adapter/CatalogPriceRule/AbstractCatalogPriceRuleHandler.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CatalogPriceRule; - -use DateTime; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CatalogPriceRuleConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CatalogPriceRuleException; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CatalogPriceRuleNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\ValueObject\CatalogPriceRuleId; -use PrestaShopException; -use SpecificPriceRule; - -/** - * Provides reusable methods for CatalogPriceRule handlers - */ -abstract class AbstractCatalogPriceRuleHandler -{ - /** - * Gets legacy SpecificPriceRule - * - * @param CatalogPriceRuleId $catalogPriceRuleId - * - * @return SpecificPriceRule - */ - protected function getSpecificPriceRule(CatalogPriceRuleId $catalogPriceRuleId): SpecificPriceRule - { - try { - $specificPriceRule = new SpecificPriceRule($catalogPriceRuleId->getValue()); - } catch (PrestaShopException $e) { - throw new CatalogPriceRuleException('Failed to create new SpecificPriceRule object', 0, $e); - } - - if ($specificPriceRule->id !== $catalogPriceRuleId->getValue()) { - throw new CatalogPriceRuleNotFoundException(sprintf('SpecificPriceRule with id "%s" was not found.', $catalogPriceRuleId->getValue())); - } - - return $specificPriceRule; - } - - /** - * Deletes legacy SpecificPriceRule - * - * @param SpecificPriceRule $specificPriceRule - * - * @return bool - * - * @throws CatalogPriceRuleException - */ - protected function deleteSpecificPriceRule(SpecificPriceRule $specificPriceRule) - { - try { - return $specificPriceRule->delete(); - } catch (PrestaShopException $e) { - throw new CatalogPriceRuleException(sprintf('An error occurred when deleting SpecificPriceRule object with id "%s".', $specificPriceRule->id)); - } - } - - /** - * @param DateTime $from - * @param DateTime $to - * - * @throws CatalogPriceRuleConstraintException - */ - protected function assertDateRangeIsNotInverse(DateTime $from, DateTime $to) - { - if ($from->diff($to)->invert) { - throw new CatalogPriceRuleConstraintException('The date time for catalog price rule cannot be inverse', CatalogPriceRuleConstraintException::INVALID_DATE_RANGE); - } - } -} diff --git a/src/Adapter/CatalogPriceRule/CommandHandler/AddCatalogPriceRuleHandler.php b/src/Adapter/CatalogPriceRule/CommandHandler/AddCatalogPriceRuleHandler.php deleted file mode 100644 index b2ae3f4d..00000000 --- a/src/Adapter/CatalogPriceRule/CommandHandler/AddCatalogPriceRuleHandler.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CatalogPriceRule\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\CatalogPriceRule\AbstractCatalogPriceRuleHandler; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command\AddCatalogPriceRuleCommand; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\CommandHandler\AddCatalogPriceRuleHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CatalogPriceRuleException; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\ValueObject\CatalogPriceRuleId; -use PrestaShopException; -use SpecificPriceRule; - -/** - * Handles adding new catalog price rule using legacy object model - */ -final class AddCatalogPriceRuleHandler extends AbstractCatalogPriceRuleHandler implements AddCatalogPriceRuleHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(AddCatalogPriceRuleCommand $command): CatalogPriceRuleId - { - try { - $specificPriceRule = $this->fetchSpecificPriceRuleFromCommand($command); - - if (false === $specificPriceRule->validateFields(false)) { - throw new CatalogPriceRuleException('Specific price rule contains invalid field values'); - } - - if (false === $specificPriceRule->add()) { - throw new CatalogPriceRuleException(sprintf('Failed to create specific price rule')); - } - $specificPriceRule->deleteConditions(); - $specificPriceRule->apply(); - } catch (PrestaShopException $e) { - throw new CatalogPriceRuleException('An unexpected error occurred while creating specific price rule', 0, $e); - } - - return new CatalogPriceRuleId((int) $specificPriceRule->id); - } - - /** - * @param AddCatalogPriceRuleCommand $command - * - * @return SpecificPriceRule - * - * @throws PrestaShopException - */ - private function fetchSpecificPriceRuleFromCommand(AddCatalogPriceRuleCommand $command): SpecificPriceRule - { - $specificPriceRule = new SpecificPriceRule(); - $specificPriceRule->name = $command->getName(); - $specificPriceRule->id_shop = $command->getShopId(); - $specificPriceRule->id_currency = $command->getCurrencyId(); - $specificPriceRule->id_country = $command->getCountryId(); - $specificPriceRule->id_group = $command->getGroupId(); - $specificPriceRule->from_quantity = $command->getFromQuantity(); - $specificPriceRule->price = $command->getPrice(); - $specificPriceRule->reduction_type = $command->getReduction()->getType(); - $specificPriceRule->reduction = (string) $command->getReduction()->getValue(); - $specificPriceRule->reduction_tax = $command->isTaxIncluded(); - - $from = $command->getDateTimeFrom(); - $to = $command->getDateTimeTo(); - - if ($from && $to) { - $this->assertDateRangeIsNotInverse($from, $to); - } - - if ($from) { - $specificPriceRule->from = $from->format('Y-m-d H:i:s'); - } - - if ($to) { - $specificPriceRule->to = $to->format('Y-m-d H:i:s'); - } - - return $specificPriceRule; - } -} diff --git a/src/Adapter/CatalogPriceRule/CommandHandler/BulkDeleteCatalogPriceRuleHandler.php b/src/Adapter/CatalogPriceRule/CommandHandler/BulkDeleteCatalogPriceRuleHandler.php deleted file mode 100644 index 7f5efe19..00000000 --- a/src/Adapter/CatalogPriceRule/CommandHandler/BulkDeleteCatalogPriceRuleHandler.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CatalogPriceRule\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\CatalogPriceRule\AbstractCatalogPriceRuleHandler; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command\BulkDeleteCatalogPriceRuleCommand; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\CommandHandler\BulkDeleteCatalogPriceRuleHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CannotDeleteCatalogPriceRuleException; - -/** - * Deletes catalog prices rules in bulk action using legacy object model - */ -final class BulkDeleteCatalogPriceRuleHandler extends AbstractCatalogPriceRuleHandler implements BulkDeleteCatalogPriceRuleHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(BulkDeleteCatalogPriceRuleCommand $command) - { - foreach ($catalogPriceRuleId = $command->getCatalogPriceRuleIds() as $catalogPriceRuleId) { - $specificPriceRule = $this->getSpecificPriceRule($catalogPriceRuleId); - - if (null === $this->deleteSpecificPriceRule($specificPriceRule)) { - throw new CannotDeleteCatalogPriceRuleException(sprintf('Cannot delete SpecificPriceRule object with id "%s".', $catalogPriceRuleId->getValue()), CannotDeleteCatalogPriceRuleException::FAILED_BULK_DELETE); - } - } - } -} diff --git a/src/Adapter/CatalogPriceRule/CommandHandler/DeleteCatalogPriceRuleHandler.php b/src/Adapter/CatalogPriceRule/CommandHandler/DeleteCatalogPriceRuleHandler.php deleted file mode 100644 index 4b606d2f..00000000 --- a/src/Adapter/CatalogPriceRule/CommandHandler/DeleteCatalogPriceRuleHandler.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CatalogPriceRule\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\CatalogPriceRule\AbstractCatalogPriceRuleHandler; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command\DeleteCatalogPriceRuleCommand; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\CommandHandler\DeleteCatalogPriceRuleHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CannotDeleteCatalogPriceRuleException; - -/** - * Handles deletion of catalog price rule using legacy object model - */ -final class DeleteCatalogPriceRuleHandler extends AbstractCatalogPriceRuleHandler implements DeleteCatalogPriceRuleHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(DeleteCatalogPriceRuleCommand $command) - { - $catalogPriceRuleId = $command->getCatalogPriceRuleId(); - $specificPriceRule = $this->getSpecificPriceRule($catalogPriceRuleId); - - if (null === $this->deleteSpecificPriceRule($specificPriceRule)) { - throw new CannotDeleteCatalogPriceRuleException(sprintf('Cannot delete SpecificPriceRule object with id "%s".', $catalogPriceRuleId->getValue()), CannotDeleteCatalogPriceRuleException::FAILED_DELETE); - } - } -} diff --git a/src/Adapter/CatalogPriceRule/CommandHandler/EditCatalogPriceRuleHandler.php b/src/Adapter/CatalogPriceRule/CommandHandler/EditCatalogPriceRuleHandler.php deleted file mode 100644 index 9ae44207..00000000 --- a/src/Adapter/CatalogPriceRule/CommandHandler/EditCatalogPriceRuleHandler.php +++ /dev/null @@ -1,152 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CatalogPriceRule\CommandHandler; - -use DateTime; -use PrestaShop\PrestaShop\Adapter\CatalogPriceRule\AbstractCatalogPriceRuleHandler; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command\EditCatalogPriceRuleCommand; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\CommandHandler\EditCatalogPriceRuleHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CannotUpdateCatalogPriceRuleException; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CatalogPriceRuleConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CatalogPriceRuleException; -use PrestaShop\PrestaShop\Core\Util\DateTime\DateTime as UtilsDateTime; -use PrestaShopException; -use SpecificPriceRule; - -/** - * Handles command which edits catalog price rule handler using legacy object model - */ -final class EditCatalogPriceRuleHandler extends AbstractCatalogPriceRuleHandler implements EditCatalogPriceRuleHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(EditCatalogPriceRuleCommand $command) - { - try { - $specificPriceRule = $this->fetchSpecificPriceRuleFromCommand($command); - - if (false === $specificPriceRule->validateFields(false)) { - throw new CatalogPriceRuleException('Specific price rule contains invalid field values'); - } - - if (false === $specificPriceRule->update()) { - throw new CannotUpdateCatalogPriceRuleException(sprintf('Failed to update specific price rule with id %s', $specificPriceRule->id)); - } - $specificPriceRule->deleteConditions(); - $specificPriceRule->apply(); - } catch (PrestaShopException $e) { - throw new CatalogPriceRuleException(sprintf('An unexpected error occurred when editing specific price rule with id %s', $command->getCatalogPriceRuleId()->getValue()), 0, $e); - } - } - - /** - * Creates SpecificPriceRule object from given command - * - * @param EditCatalogPriceRuleCommand $command - * - * @return SpecificPriceRule - * - * @throws PrestaShopException - */ - private function fetchSpecificPriceRuleFromCommand(EditCatalogPriceRuleCommand $command): SpecificPriceRule - { - $specificPriceRule = new SpecificPriceRule($command->getCatalogPriceRuleId()->getValue()); - $this->fetchDateRange($command, $specificPriceRule); - - if (null !== $command->getName()) { - $specificPriceRule->name = $command->getName(); - } - if (null !== $command->getShopId()) { - $specificPriceRule->id_shop = $command->getShopId(); - } - if (null !== $command->getCurrencyId()) { - $specificPriceRule->id_currency = $command->getCurrencyId(); - } - if (null !== $command->getCountryId()) { - $specificPriceRule->id_country = $command->getCountryId(); - } - if (null !== $command->getGroupId()) { - $specificPriceRule->id_group = $command->getGroupId(); - } - if (null !== $command->getFromQuantity()) { - $specificPriceRule->from_quantity = $command->getFromQuantity(); - } - if (null !== $command->getPrice()) { - $specificPriceRule->price = $command->getPrice(); - } - - if (null !== $command->isTaxIncluded()) { - $specificPriceRule->reduction_tax = $command->isTaxIncluded(); - } - if (null !== $command->getReduction()) { - $specificPriceRule->reduction_type = $command->getReduction()->getType(); - $specificPriceRule->reduction = $command->getReduction()->getValue(); - } - - return $specificPriceRule; - } - - /** - * Fetches date range from command to object model also asserting that the range is not inverse - * - * @param EditCatalogPriceRuleCommand $command - * @param SpecificPriceRule $specificPriceRule - * - * @throws CatalogPriceRuleConstraintException - */ - private function fetchDateRange(EditCatalogPriceRuleCommand $command, SpecificPriceRule $specificPriceRule) - { - $commandDateFrom = $command->getDateTimeFrom(); - $commandDateTo = $command->getDateTimeTo(); - - $modelDateFrom = $specificPriceRule->from; - $modelDateTo = $specificPriceRule->to; - - //if `date from` value is being updated - if (null !== $commandDateFrom) { - //and if `date to` is set in database - if (UtilsDateTime::NULL_VALUE !== $modelDateTo) { - //asserts that range between these values is not inverse - $this->assertDateRangeIsNotInverse($commandDateFrom, new DateTime($modelDateTo)); - } - - $specificPriceRule->from = $commandDateFrom->format('Y-m-d H:i:s'); - } - - //if `date to` value is being updated - if (null !== $commandDateTo) { - //and if `date from` is set in database - if (UtilsDateTime::NULL_VALUE !== $modelDateFrom) { - //asserts that range between these values is not inverse - $this->assertDateRangeIsNotInverse(new DateTime($modelDateFrom), $commandDateTo); - } - - $specificPriceRule->to = $commandDateTo->format('Y-m-d H:i:s'); - } - } -} diff --git a/src/Adapter/CatalogPriceRule/QueryHandler/GetCatalogPriceRuleForEditingHandler.php b/src/Adapter/CatalogPriceRule/QueryHandler/GetCatalogPriceRuleForEditingHandler.php deleted file mode 100644 index 5b00ca3c..00000000 --- a/src/Adapter/CatalogPriceRule/QueryHandler/GetCatalogPriceRuleForEditingHandler.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CatalogPriceRule\QueryHandler; - -use DateTime; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Adapter\CatalogPriceRule\AbstractCatalogPriceRuleHandler; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Query\GetCatalogPriceRuleForEditing; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\QueryHandler\GetCatalogPriceRuleForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\QueryResult\EditableCatalogPriceRule; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\ValueObject\CatalogPriceRuleId; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Reduction; -use PrestaShop\PrestaShop\Core\Util\DateTime\DateTime as DateTimeUtils; - -/** - * Handles command which gets catalog price rule for editing using legacy object model - */ -final class GetCatalogPriceRuleForEditingHandler extends AbstractCatalogPriceRuleHandler implements GetCatalogPriceRuleForEditingHandlerInterface -{ - /** - * @param GetCatalogPriceRuleForEditing $query - * - * @return EditableCatalogPriceRule - */ - public function handle(GetCatalogPriceRuleForEditing $query): EditableCatalogPriceRule - { - $catalogPriceRuleId = $query->getCatalogPriceRuleId(); - $specificPriceRule = $this->getSpecificPriceRule($catalogPriceRuleId); - - $from = $specificPriceRule->from; - $to = $specificPriceRule->to; - - return new EditableCatalogPriceRule( - new CatalogPriceRuleId((int) $specificPriceRule->id), - $specificPriceRule->name, - (int) $specificPriceRule->id_shop, - (int) $specificPriceRule->id_currency, - (int) $specificPriceRule->id_country, - (int) $specificPriceRule->id_group, - (int) $specificPriceRule->from_quantity, - new Number($specificPriceRule->price), - new Reduction($specificPriceRule->reduction_type, (float) $specificPriceRule->reduction), - (bool) $specificPriceRule->reduction_tax, - $from !== DateTimeUtils::NULL_VALUE ? new DateTime($from) : null, - $to !== DateTimeUtils::NULL_VALUE ? new DateTime($to) : null - ); - } -} diff --git a/src/Adapter/Category/AdminCategoryControllerWrapper.php b/src/Adapter/Category/AdminCategoryControllerWrapper.php deleted file mode 100644 index 1c1b4079..00000000 --- a/src/Adapter/Category/AdminCategoryControllerWrapper.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category; - -use AdminCategoriesController; - -/** - * Admin controller wrapper for new Architecture, about Category admin controller. - */ -class AdminCategoryControllerWrapper -{ - /** - * Get instance of legacy class AdminCategoriesController. - * - * @return AdminCategoriesController - */ - public function getInstance() - { - return new AdminCategoriesController(); - } -} diff --git a/src/Adapter/Category/CategoryDataProvider.php b/src/Adapter/Category/CategoryDataProvider.php deleted file mode 100644 index a0320c46..00000000 --- a/src/Adapter/Category/CategoryDataProvider.php +++ /dev/null @@ -1,271 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category; - -use Category; -use Context; -use ObjectModel; -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use Shop; - -/** - * This class will provide data from DB / ORM about Category. - */ -class CategoryDataProvider -{ - /** - * @var int - */ - private $languageId; - - /** @var array the list of existing active categories until root */ - private $categoryList; - - public function __construct(LegacyContext $context) - { - $this->languageId = $context->getLanguage()->id; - $categories = Category::getSimpleCategoriesWithParentInfos($this->languageId); - // index by categories and construct the categoryList - foreach ($categories as $category) { - $this->categoryList[$category['id_category']] = $category; - } - } - - /** - * Get a category. - * - * @param null $idCategory - * @param null $idLang - * @param null $idShop - * - * @throws \LogicException If the category id is not set - * - * @return Category - */ - public function getCategory($idCategory = null, $idLang = null, $idShop = null) - { - if (!$idCategory) { - throw new \LogicException('You need to provide a category id', 5002); - } - - $category = new Category($idCategory, $idLang, $idShop); - - if ($category) { - $category->image = Context::getContext()->link->getCatImageLink($category->name, $category->id); - } - - return $category; - } - - /** - * Get all nested categories. - * - * @param int|null $root_category - * @param bool|int $id_lang - * @param bool $active - * @param int|null $groups - * @param bool $use_shop_restriction - * @param string $sql_filter - * @param string $sql_sort - * @param string $sql_limit - * - * @return array categories - */ - public function getNestedCategories($root_category = null, $id_lang = false, $active = true, $groups = null, $use_shop_restriction = true, $sql_filter = '', $sql_sort = '', $sql_limit = '') - { - if (!$id_lang) { - $id_lang = $this->languageId; - } - - return Category::getNestedCategories($root_category, $id_lang, $active, $groups, $use_shop_restriction, $sql_filter, $sql_sort, $sql_limit); - } - - /** - * Return available categories Names - excluding Root category. - * - * @param int|null $root_category - * @param bool|int $id_lang - * @param bool $active return only active categories - * @param $groups - * @param bool $use_shop_restriction - * @param string $sql_filter - * @param string $sql_sort - * @param string $sql_limit - * - * @return array Categories - */ - public function getAllCategoriesName($root_category = null, $id_lang = false, $active = true, $groups = null, $use_shop_restriction = true, $sql_filter = '', $sql_sort = '', $sql_limit = '') - { - if (!$id_lang) { - $id_lang = $this->languageId; - } - - $categories = Category::getAllCategoriesName($root_category, $id_lang, $active, $groups, $use_shop_restriction, $sql_filter, $sql_sort, $sql_limit); - array_shift($categories); - - return $categories; - } - - /** - * Return a simple array id/name of categories for a specified product. - * - * @param \Product $product - * - * @return array Categories - */ - public function getCategoriesByProduct(ObjectModel $product) - { - $productCategories = $product->getCategories(); - - $results = []; - foreach ($productCategories as $productCategory) { - if (isset($this->categoryList[$productCategory])) { - $category = $this->categoryList[$productCategory]; - $results[] = [ - 'id' => $category['id_category'], - 'name' => $category['name'], - 'breadcrumb' => $this->getBreadCrumb($category['id_category']), - ]; - $productCategories[$category['name']] = $category['id_category']; - } - } - - return $results; - } - - /** - * Return a simple array id/name of categories. - * - * @return array Categories - */ - public function getCategoriesWithBreadCrumb() - { - $results = []; - foreach ($this->categoryList as $category) { - $results[] = [ - 'id' => $category['id_category'], - 'name' => $category['name'], - 'breadcrumb' => $this->getBreadCrumb($category['id_category']), - ]; - } - - return $results; - } - - /** - * Construct the breadcrumb using the already constructed list of all categories. - * - * @param int $categoryId - * @param string $delimiter - * - * @return string - */ - public function getBreadCrumb($categoryId, $delimiter = ' > ') - { - $categories = $this->getParentNamesFromList($categoryId); - $categories = array_reverse($categories, true); - - return implode($delimiter, $categories); - } - - /** - * @param int $categoryId - * - * @return array - */ - public function getParentNamesFromList($categoryId) - { - $categories = []; - - while (isset($this->categoryList[$categoryId])) { - $category = $this->categoryList[$categoryId]; - $categories[] = $category['name']; - $categoryId = $category['id_parent']; - } - - return $categories; - } - - /** - * Get Categories formatted like ajax_product_file.php using Category::getNestedCategories. - * - * @param $query - * @param $limit - * @param bool $nameAsBreadCrumb - * - * @return array - */ - public function getAjaxCategories($query, $limit, $nameAsBreadCrumb = false) - { - if (empty($query)) { - $query = ''; - } else { - $query = "AND cl.name LIKE '%" . pSQL($query) . "%'"; - } - - if (is_int($limit)) { - $limit = 'LIMIT ' . $limit; - } else { - $limit = ''; - } - - $searchCategories = Category::getAllCategoriesName( - null, - Context::getContext()->language->id, - true, - null, - true, - $query, - '', - $limit - ); - - $results = []; - foreach ($searchCategories as $category) { - $breadCrumb = $this->getBreadCrumb($category['id_category']); - $results[] = [ - 'id' => $category['id_category'], - 'name' => ($nameAsBreadCrumb ? $breadCrumb : $category['name']), - 'breadcrumb' => $breadCrumb, - 'image' => Context::getContext()->link->getCatImageLink($category['name'], $category['id_category']), - ]; - } - - return $results; - } - - /** - * @param int|null $idLang - * @param Shop|null $shop - * - * @return Category - */ - public function getRootCategory($idLang = null, Shop $shop = null) - { - return Category::getRootCategory($idLang, $shop); - } -} diff --git a/src/Adapter/Category/CategoryProductSearchProvider.php b/src/Adapter/Category/CategoryProductSearchProvider.php deleted file mode 100644 index 9530adf0..00000000 --- a/src/Adapter/Category/CategoryProductSearchProvider.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category; - -use Category; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchProviderInterface; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchResult; -use PrestaShop\PrestaShop\Core\Product\Search\SortOrderFactory; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Responsible of getting products for specific category. - */ -class CategoryProductSearchProvider implements ProductSearchProviderInterface -{ - private $translator; - private $category; - private $sortOrderFactory; - - public function __construct( - TranslatorInterface $translator, - Category $category - ) { - $this->translator = $translator; - $this->category = $category; - $this->sortOrderFactory = new SortOrderFactory($this->translator); - } - - /** - * @param ProductSearchContext $context - * @param ProductSearchQuery $query - * @param string $type - * - * @return array|false|int - * - * @throws \PrestaShopDatabaseException - */ - private function getProductsOrCount( - ProductSearchContext $context, - ProductSearchQuery $query, - $type = 'products' - ) { - if ($query->getSortOrder()->isRandom()) { - return $this->category->getProducts( - $context->getIdLang(), - 1, - $query->getResultsPerPage(), - null, - null, - $type !== 'products', - true, - true, - $query->getResultsPerPage() - ); - } else { - return $this->category->getProducts( - $context->getIdLang(), - $query->getPage(), - $query->getResultsPerPage(), - $query->getSortOrder()->toLegacyOrderBy(), - $query->getSortOrder()->toLegacyOrderWay(), - $type !== 'products' - ); - } - } - - /** - * @param ProductSearchContext $context - * @param ProductSearchQuery $query - * - * @return ProductSearchResult - * - * @throws \PrestaShopDatabaseException - */ - public function runQuery( - ProductSearchContext $context, - ProductSearchQuery $query - ) { - $products = $this->getProductsOrCount($context, $query, 'products'); - $count = $this->getProductsOrCount($context, $query, 'count'); - - $result = new ProductSearchResult(); - - if (!empty($products)) { - $result - ->setProducts($products) - ->setTotalProductsCount($count); - - $result->setAvailableSortOrders( - $this->sortOrderFactory->getDefaultSortOrders() - ); - } - - return $result; - } -} diff --git a/src/Adapter/Category/CategoryViewDataProvider.php b/src/Adapter/Category/CategoryViewDataProvider.php deleted file mode 100644 index 858396c7..00000000 --- a/src/Adapter/Category/CategoryViewDataProvider.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category; - -use Category; -use PrestaShop\PrestaShop\Adapter\Shop\Context; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Feature\FeatureInterface; -use Tools; - -/** - * Class CategoryViewDataProvider provides category view data for categories listing page. - * - * @internal - */ -class CategoryViewDataProvider -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var FeatureInterface - */ - private $multishopFeature; - - /** - * @var int - */ - private $contextLangId; - - /** - * @var Context - */ - private $shopContext; - - /** - * @param ConfigurationInterface $configuration - * @param FeatureInterface $multishopFeature - * @param Context $shopContext - * @param int $contextLangId - */ - public function __construct( - ConfigurationInterface $configuration, - FeatureInterface $multishopFeature, - Context $shopContext, - $contextLangId - ) { - $this->configuration = $configuration; - $this->multishopFeature = $multishopFeature; - $this->contextLangId = $contextLangId; - $this->shopContext = $shopContext; - } - - /** - * Get category view data. - * - * @param int $categoryId - * - * @return array - */ - public function getViewData($categoryId) - { - $category = new Category($categoryId); - - $categoriesWithoutParentCount = count(Category::getCategoriesWithoutParent()); - $categoriesTree = $category->getParentsCategories(); - - if (empty($categoriesTree) - && ($category->id != (int) $this->configuration->get('PS_ROOT_CATEGORY') || Tools::isSubmit('id_category')) - && $this->shopContext->isShopContext() - && !$this->multishopFeature->isUsed() - && $categoriesWithoutParentCount > 1 - ) { - $categoriesTree = [['name' => $category->name[$this->contextLangId]]]; - } - - $categoriesTree = array_reverse($categoriesTree); - - return [ - 'breadcrumb_tree' => $categoriesTree, - 'id' => $category->id, - 'id_parent' => $category->id_parent, - 'is_home_category' => $this->configuration->get('PS_HOME_CATEGORY') == $category->id, - 'name' => $category->name[$this->contextLangId], - ]; - } -} diff --git a/src/Adapter/Category/CommandHandler/AbstractDeleteCategoryHandler.php b/src/Adapter/Category/CommandHandler/AbstractDeleteCategoryHandler.php deleted file mode 100644 index 90169ba1..00000000 --- a/src/Adapter/Category/CommandHandler/AbstractDeleteCategoryHandler.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryDeleteMode; -use Product; -use Shop; - -/** - * Class AbstractDeleteCategoryHandler. - */ -abstract class AbstractDeleteCategoryHandler -{ - /** - * Handle products category after its deletion. - * - * @param int $parentCategoryId - * @param CategoryDeleteMode $mode - */ - protected function handleProductsUpdate($parentCategoryId, CategoryDeleteMode $mode) - { - $productsWithoutCategory = \Db::getInstance()->executeS(' - SELECT p.`id_product` - FROM `' . _DB_PREFIX_ . 'product` p - ' . Shop::addSqlAssociation('product', 'p') . ' - WHERE NOT EXISTS ( - SELECT 1 FROM `' . _DB_PREFIX_ . 'category_product` cp WHERE cp.`id_product` = p.`id_product` - ) - '); - - foreach ($productsWithoutCategory as $productWithoutCategory) { - $product = new Product((int) $productWithoutCategory['id_product']); - - if ($product->id) { - if (0 === $parentCategoryId || $mode->shouldRemoveProducts()) { - $product->delete(); - - continue; - } - - if ($mode->shouldDisableProducts()) { - $product->active = 0; - } - - $product->id_category_default = $parentCategoryId; - $product->addToCategories($parentCategoryId); - $product->save(); - } - } - } -} diff --git a/src/Adapter/Category/CommandHandler/AddCategoryHandler.php b/src/Adapter/Category/CommandHandler/AddCategoryHandler.php deleted file mode 100644 index 6877ba59..00000000 --- a/src/Adapter/Category/CommandHandler/AddCategoryHandler.php +++ /dev/null @@ -1,117 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category\CommandHandler; - -use Category; -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\AddCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler\AddCategoryHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CannotAddCategoryException; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; - -/** - * Adds new category using legacy object model. - * - * @internal - */ -final class AddCategoryHandler extends AbstractObjectModelHandler implements AddCategoryHandlerInterface -{ - /** - * {@inheritdoc} - * - * @param AddCategoryCommand $command - * - * @return CategoryId - */ - public function handle(AddCategoryCommand $command) - { - $category = $this->createCategoryFromCommand($command); - - return new CategoryId((int) $category->id); - } - - /** - * @param AddCategoryCommand $command - * - * @return Category - * - * @throws CannotAddCategoryException - * @throws CategoryConstraintException - */ - private function createCategoryFromCommand(AddCategoryCommand $command) - { - $category = new Category(); - $category->id_parent = $command->getParentCategoryId(); - $category->active = $command->isActive(); - - if (null !== $command->getLocalizedNames()) { - $category->name = $command->getLocalizedNames(); - } - - if (null !== $command->getLocalizedLinkRewrites()) { - $category->link_rewrite = $command->getLocalizedLinkRewrites(); - } - - if (null !== $command->getLocalizedDescriptions()) { - $category->description = $command->getLocalizedDescriptions(); - } - - if (null !== $command->getLocalizedMetaTitles()) { - $category->meta_title = $command->getLocalizedMetaTitles(); - } - - if (null !== $command->getLocalizedMetaDescriptions()) { - $category->meta_description = $command->getLocalizedMetaDescriptions(); - } - - if (null !== $command->getLocalizedMetaKeywords()) { - $category->meta_keywords = $command->getLocalizedMetaKeywords(); - } - - if (null !== $command->getAssociatedGroupIds()) { - $category->groupBox = $command->getAssociatedGroupIds(); - } - - if (false === $category->validateFields(false)) { - throw new CannotAddCategoryException('Invalid category data'); - } - - if (false === $category->validateFieldsLang(false)) { - throw new CannotAddCategoryException('Invalid category data'); - } - - if (false === $category->add()) { - throw new CannotAddCategoryException('Failed to add new category.'); - } - - if ($command->getAssociatedShopIds()) { - $this->associateWithShops($category, $command->getAssociatedShopIds()); - } - - return $category; - } -} diff --git a/src/Adapter/Category/CommandHandler/AddRootCategoryHandler.php b/src/Adapter/Category/CommandHandler/AddRootCategoryHandler.php deleted file mode 100644 index 06faa4cb..00000000 --- a/src/Adapter/Category/CommandHandler/AddRootCategoryHandler.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category\CommandHandler; - -use Category; -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\AddRootCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler\AddRootCategoryHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CannotAddCategoryException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryException; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; - -/** - * Class AddRootCategoryHandler. - */ -final class AddRootCategoryHandler extends AbstractObjectModelHandler implements AddRootCategoryHandlerInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - * - * @throws CannotAddCategoryException - */ - public function handle(AddRootCategoryCommand $command) - { - $category = $this->createRootCategoryFromCommand($command); - - return new CategoryId((int) $category->id); - } - - /** - * Creates legacy root category - * - * @param AddRootCategoryCommand $command - * - * @return Category - */ - private function createRootCategoryFromCommand(AddRootCategoryCommand $command) - { - $category = new Category(); - $category->is_root_category = true; - $category->level_depth = 1; - $category->id_parent = $this->configuration->get('PS_ROOT_CATEGORY'); - $category->name = $command->getLocalizedNames(); - $category->link_rewrite = $command->getLocalizedLinkRewrites(); - $category->active = $command->isActive(); - - if (null !== $command->getLocalizedDescriptions()) { - $category->description = $command->getLocalizedDescriptions(); - } - - if (null !== $command->getLocalizedMetaTitles()) { - $category->meta_title = $command->getLocalizedMetaTitles(); - } - - if (null !== $command->getLocalizedMetaDescriptions()) { - $category->meta_description = $command->getLocalizedMetaDescriptions(); - } - - if (null !== $command->getLocalizedMetaKeywords()) { - $category->meta_keywords = $command->getLocalizedMetaKeywords(); - } - - if (null !== $command->getAssociatedGroupIds()) { - $category->groupBox = $command->getAssociatedGroupIds(); - } - - if (false === $category->validateFields(false)) { - throw new CategoryException('Invalid data for root category creation'); - } - - if (false === $category->validateFieldsLang(false)) { - throw new CategoryException('Invalid data for root category creation'); - } - - if (false === $category->save()) { - throw new CannotAddCategoryException('Failed to create root category'); - } - - if ($command->getAssociatedShopIds()) { - $this->associateWithShops($category, $command->getAssociatedShopIds()); - } - - return $category; - } -} diff --git a/src/Adapter/Category/CommandHandler/BulkDeleteCategoriesHandler.php b/src/Adapter/Category/CommandHandler/BulkDeleteCategoriesHandler.php deleted file mode 100644 index 6904a926..00000000 --- a/src/Adapter/Category/CommandHandler/BulkDeleteCategoriesHandler.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category\CommandHandler; - -use Category; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\BulkDeleteCategoriesCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler\BulkDeleteCategoriesHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CannotDeleteRootCategoryForShopException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\FailedToDeleteCategoryException; - -/** - * Class BulkDeleteCategoriesHandler. - */ -final class BulkDeleteCategoriesHandler extends AbstractDeleteCategoryHandler implements BulkDeleteCategoriesHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CategoryNotFoundException - * @throws CannotDeleteRootCategoryForShopException - * @throws FailedToDeleteCategoryException - */ - public function handle(BulkDeleteCategoriesCommand $command) - { - foreach ($command->getCategoryIds() as $categoryId) { - $category = new Category($categoryId->getValue()); - - if (!$category->id) { - throw new CategoryNotFoundException($categoryId, sprintf('Category with id %s cannot be found.', var_export($categoryId->getValue(), true))); - } - - if ($category->isRootCategoryForAShop()) { - throw new CannotDeleteRootCategoryForShopException(sprintf('Shop\'s root category with id %s cannot be deleted.', var_export($categoryId->getValue(), true))); - } - - if (!$category->delete()) { - throw new FailedToDeleteCategoryException(sprintf('Failed to delete category with id %s', var_export($categoryId->getValue(), true))); - } - - $this->handleProductsUpdate((int) $category->id_parent, $command->getDeleteMode()); - } - } -} diff --git a/src/Adapter/Category/CommandHandler/BulkUpdateCategoriesStatusHandler.php b/src/Adapter/Category/CommandHandler/BulkUpdateCategoriesStatusHandler.php deleted file mode 100644 index cf6cf198..00000000 --- a/src/Adapter/Category/CommandHandler/BulkUpdateCategoriesStatusHandler.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category\CommandHandler; - -use Category; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\BulkUpdateCategoriesStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler\BulkUpdateCategoriesStatusHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CannotUpdateCategoryStatusException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryNotFoundException; - -/** - * Class ChangeCategoriesStatusHandler. - * - * @internal - */ -final class BulkUpdateCategoriesStatusHandler implements BulkUpdateCategoriesStatusHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CannotUpdateCategoryStatusException - * @throws CategoryNotFoundException - */ - public function handle(BulkUpdateCategoriesStatusCommand $command) - { - foreach ($command->getCategoryIds() as $categoryId) { - $entity = new Category($categoryId->getValue()); - $entity->active = $command->getNewStatus(); - - if (!$entity->id) { - throw new CategoryNotFoundException($categoryId, sprintf('Category with id "%s" was not found', $categoryId->getValue())); - } - - if (!$entity->update()) { - throw new CannotUpdateCategoryStatusException(sprintf('Cannot update status for category with id "%s"', $categoryId->getValue())); - } - } - } -} diff --git a/src/Adapter/Category/CommandHandler/DeleteCategoryCoverImageHandler.php b/src/Adapter/Category/CommandHandler/DeleteCategoryCoverImageHandler.php deleted file mode 100644 index db043a13..00000000 --- a/src/Adapter/Category/CommandHandler/DeleteCategoryCoverImageHandler.php +++ /dev/null @@ -1,171 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category\CommandHandler; - -use Category; -use ImageType; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\DeleteCategoryCoverImageCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler\DeleteCategoryCoverImageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CannotDeleteImageException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; -use Symfony\Component\Filesystem\Exception\IOException; -use Symfony\Component\Filesystem\Filesystem; - -/** - * Handles category cover image deleting command. - * - * @internal - */ -final class DeleteCategoryCoverImageHandler implements DeleteCategoryCoverImageHandlerInterface -{ - /** - * @var Filesystem - */ - private $filesystem; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param Filesystem $filesystem - * @param ConfigurationInterface $configuration - */ - public function __construct( - Filesystem $filesystem, - ConfigurationInterface $configuration - ) { - $this->filesystem = $filesystem; - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function handle(DeleteCategoryCoverImageCommand $command) - { - $categoryId = $command->getCategoryId(); - $category = new Category($categoryId->getValue()); - - $this->assertCategoryExists($categoryId, $category); - - $this->deleteCoverImage($category); - $this->deleteThumbnailImage($category); - $this->deleteTemporaryThumbnailImage($category); - $this->deleteImagesForAllTypes($category); - } - - /** - * @param CategoryId $categoryId - * @param Category $category - * - * @throws CategoryNotFoundException - */ - private function assertCategoryExists(CategoryId $categoryId, Category $category) - { - if ($category->id !== $categoryId->getValue()) { - throw new CategoryNotFoundException($categoryId, sprintf('Category with id "%s" was not found.', $categoryId->getValue())); - } - } - - /** - * @param Category $category - * - * @throws CannotDeleteImageException - */ - private function deleteCoverImage(Category $category) - { - if (false === $category->deleteImage(true)) { - throw new CannotDeleteImageException(sprintf('Cannot delete cover image for category with id "%s"', $category->id), CannotDeleteImageException::COVER_IMAGE); - } - } - - /** - * @param Category $category - * - * @throws CannotDeleteImageException - */ - private function deleteThumbnailImage(Category $category) - { - $thumbnailPath = $this->configuration->get('_PS_CAT_IMG_DIR_') . $category->id . '_thumb.jpg'; - - try { - if ($this->filesystem->exists($thumbnailPath)) { - $this->filesystem->remove($thumbnailPath); - } - } catch (IOException $e) { - throw new CannotDeleteImageException(sprintf('Cannot delete thumbnail image for category with id "%s"', $category->id), CannotDeleteImageException::THUMBNAIL_IMAGE, $e); - } - } - - /** - * @param Category $category - * - * @throws CannotDeleteImageException - */ - private function deleteTemporaryThumbnailImage(Category $category) - { - $temporaryThumbnailPath = $this->configuration->get('_PS_TMP_IMG_DIR_') . 'category_' . $category->id . '-thumb.jpg'; - - try { - if ($this->filesystem->exists($temporaryThumbnailPath)) { - $this->filesystem->remove($temporaryThumbnailPath); - } - } catch (IOException $e) { - throw new CannotDeleteImageException(sprintf('Cannot delete thumbnail image for category with id "%s"', $category->id), CannotDeleteImageException::THUMBNAIL_IMAGE, $e); - } - } - - /** - * @param Category $category - * - * @throws CannotDeleteImageException - */ - private function deleteImagesForAllTypes(Category $category) - { - $imageTypes = ImageType::getImagesTypes('categories'); - $imageTypeFormattedName = ImageType::getFormattedName('small'); - $categoryImageDir = $this->configuration->get('_PS_CAT_IMG_DIR_'); - - try { - foreach ($imageTypes as $imageType) { - $imagePath = $categoryImageDir . $category->id . '-' . $imageType['name'] . '.jpg'; - - if ($imageTypeFormattedName === $imageType['name'] - && $this->filesystem->exists($imagePath) - ) { - $this->filesystem->remove($imagePath); - } - } - } catch (IOException $e) { - throw new CannotDeleteImageException(sprintf('Cannot delete image with type "%s" for category with id "%s"', $imageType['name'], $category->id), CannotDeleteImageException::COVER_IMAGE, $e); - } - } -} diff --git a/src/Adapter/Category/CommandHandler/DeleteCategoryHandler.php b/src/Adapter/Category/CommandHandler/DeleteCategoryHandler.php deleted file mode 100644 index ab84e321..00000000 --- a/src/Adapter/Category/CommandHandler/DeleteCategoryHandler.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category\CommandHandler; - -use Category; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\DeleteCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler\DeleteCategoryHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CannotDeleteRootCategoryForShopException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\FailedToDeleteCategoryException; - -/** - * Class DeleteCategoryHandler. - */ -final class DeleteCategoryHandler extends AbstractDeleteCategoryHandler implements DeleteCategoryHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CategoryNotFoundException - * @throws CannotDeleteRootCategoryForShopException - * @throws FailedToDeleteCategoryException - */ - public function handle(DeleteCategoryCommand $command) - { - $categoryIdValue = $command->getCategoryId()->getValue(); - $category = new Category($categoryIdValue); - - if (!$category->id) { - throw new CategoryNotFoundException($command->getCategoryId(), sprintf('Category with id %s cannot be found.', var_export($categoryIdValue, true))); - } - - if ($category->isRootCategoryForAShop()) { - throw new CannotDeleteRootCategoryForShopException(sprintf('Shop\'s root category with id %s cannot be deleted.', var_export($categoryIdValue, true))); - } - - if (!$category->delete()) { - throw new FailedToDeleteCategoryException(sprintf('Failed to delete category with id %s', var_export($categoryIdValue, true))); - } - - $this->handleProductsUpdate((int) $category->id_parent, $command->getDeleteMode()); - } -} diff --git a/src/Adapter/Category/CommandHandler/DeleteCategoryMenuThumbnailImageHandler.php b/src/Adapter/Category/CommandHandler/DeleteCategoryMenuThumbnailImageHandler.php deleted file mode 100644 index e941bccf..00000000 --- a/src/Adapter/Category/CommandHandler/DeleteCategoryMenuThumbnailImageHandler.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category\CommandHandler; - -use Category; -use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\DeleteCategoryMenuThumbnailImageCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler\DeleteCategoryMenuThumbnailImageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CannotDeleteImageException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryNotFoundException; -use Symfony\Component\Filesystem\Exception\IOException; -use Symfony\Component\Filesystem\Filesystem; - -/** - * Handles command which deletes given category menu thumbnail. - * - * @internal - */ -final class DeleteCategoryMenuThumbnailImageHandler implements DeleteCategoryMenuThumbnailImageHandlerInterface -{ - /** - * @var Filesystem - */ - private $filesystem; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var CacheClearerInterface - */ - private $smartyCacheClearer; - - /** - * @param Filesystem $filesystem - * @param ConfigurationInterface $configuration - * @param CacheClearerInterface $smartyCacheClearer - */ - public function __construct( - Filesystem $filesystem, - ConfigurationInterface $configuration, - CacheClearerInterface $smartyCacheClearer - ) { - $this->filesystem = $filesystem; - $this->configuration = $configuration; - $this->smartyCacheClearer = $smartyCacheClearer; - } - - /** - * {@inheritdoc} - */ - public function handle(DeleteCategoryMenuThumbnailImageCommand $command) - { - $categoryId = $command->getCategoryId(); - $menuThumbnailId = $command->getMenuThumbnailId(); - - $category = new Category($categoryId->getValue()); - - if ($category->id !== $categoryId->getValue()) { - throw new CategoryNotFoundException($categoryId, sprintf('Category with id "%s" was not found', $categoryId)); - } - - $thumbnailPath = sprintf( - '%s%s-%s_thumb.jpg', - $this->configuration->get('_PS_CAT_IMG_DIR_'), - $category->id, - $menuThumbnailId->getValue() - ); - - try { - if ($this->filesystem->exists($thumbnailPath)) { - $this->filesystem->remove($thumbnailPath); - - $this->smartyCacheClearer->clear(); - } - } catch (IOException $e) { - throw new CannotDeleteImageException(sprintf('Cannot delete menu thumbnail with id "%s" for category with id "%s".', $menuThumbnailId->getValue(), $categoryId->getValue()), CannotDeleteImageException::MENU_THUMBNAIL_IMAGE, $e); - } - } -} diff --git a/src/Adapter/Category/CommandHandler/EditCategoryHandler.php b/src/Adapter/Category/CommandHandler/EditCategoryHandler.php deleted file mode 100644 index 0147c837..00000000 --- a/src/Adapter/Category/CommandHandler/EditCategoryHandler.php +++ /dev/null @@ -1,121 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category\CommandHandler; - -use Category; -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\EditCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler\EditCategoryHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CannotEditCategoryException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryNotFoundException; - -/** - * Class EditCategoryHandler. - * - * @internal - */ -final class EditCategoryHandler extends AbstractObjectModelHandler implements EditCategoryHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CategoryNotFoundException - */ - public function handle(EditCategoryCommand $command) - { - $category = new Category($command->getCategoryId()->getValue()); - - if (!$category->id) { - throw new CategoryNotFoundException($command->getCategoryId(), sprintf('Category with id "%s" cannot be found.', $command->getCategoryId()->getValue())); - } - - $this->updateCategoryFromCommandData($category, $command); - } - - /** - * Updates legacy object model with data from command - * - * @param Category $category - * @param EditCategoryCommand $command - * - * @throws CannotEditCategoryException - */ - private function updateCategoryFromCommandData(Category $category, EditCategoryCommand $command) - { - if (null !== $command->isActive()) { - $category->active = $command->isActive(); - } - - if (null !== $command->getParentCategoryId()) { - $category->id_parent = $command->getParentCategoryId(); - } - - if (null !== $command->getLocalizedNames()) { - $category->name = $command->getLocalizedNames(); - } - - if (null !== $command->getLocalizedLinkRewrites()) { - $category->link_rewrite = $command->getLocalizedLinkRewrites(); - } - - if (null !== $command->getLocalizedDescriptions()) { - $category->description = $command->getLocalizedDescriptions(); - } - - if (null !== $command->getLocalizedMetaTitles()) { - $category->meta_title = $command->getLocalizedMetaTitles(); - } - - if (null !== $command->getLocalizedMetaDescriptions()) { - $category->meta_description = $command->getLocalizedMetaDescriptions(); - } - - if (null !== $command->getLocalizedMetaKeywords()) { - $category->meta_keywords = $command->getLocalizedMetaKeywords(); - } - - if (null !== $command->getAssociatedGroupIds()) { - $category->groupBox = $command->getAssociatedGroupIds(); - } - - if (false === $category->validateFields(false)) { - throw new CannotEditCategoryException('Invalid data when updating category'); - } - - if (false === $category->validateFieldsLang(false)) { - throw new CannotEditCategoryException('Invalid data when updating category'); - } - - if (false === $category->update()) { - throw new CannotEditCategoryException(sprintf('Failed to edit Category with id "%s".', $category->id)); - } - - if ($command->getAssociatedShopIds()) { - $this->associateWithShops($category, $command->getAssociatedShopIds()); - } - } -} diff --git a/src/Adapter/Category/CommandHandler/EditRootCategoryHandler.php b/src/Adapter/Category/CommandHandler/EditRootCategoryHandler.php deleted file mode 100644 index 619fe93a..00000000 --- a/src/Adapter/Category/CommandHandler/EditRootCategoryHandler.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category\CommandHandler; - -use Category; -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\EditRootCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler\EditRootCategoryHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CannotEditCategoryException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryNotFoundException; - -/** - * Class EditRootCategoryHandler. - */ -final class EditRootCategoryHandler extends AbstractObjectModelHandler implements EditRootCategoryHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CannotEditCategoryException - * @throws CategoryNotFoundException - */ - public function handle(EditRootCategoryCommand $command) - { - $category = new Category($command->getCategoryId()->getValue()); - - if (!$category->id) { - throw new CategoryNotFoundException($command->getCategoryId(), sprintf('Category with id "%s" cannot be found.', $command->getCategoryId()->getValue())); - } - - $this->updateRootCategoryFromCommandData($category, $command); - } - - /** - * @param Category $category - * @param EditRootCategoryCommand $command - */ - private function updateRootCategoryFromCommandData(Category $category, EditRootCategoryCommand $command) - { - if (null !== $command->isActive()) { - $category->active = $command->isActive(); - } - - if (null !== $command->getLocalizedNames()) { - $category->name = $command->getLocalizedNames(); - } - - if (null !== $command->getLocalizedLinkRewrites()) { - $category->link_rewrite = $command->getLocalizedLinkRewrites(); - } - - if (null !== $command->getLocalizedDescriptions()) { - $category->description = $command->getLocalizedDescriptions(); - } - - if (null !== $command->getLocalizedMetaTitles()) { - $category->meta_title = $command->getLocalizedMetaTitles(); - } - - if (null !== $command->getLocalizedMetaDescriptions()) { - $category->meta_description = $command->getLocalizedMetaDescriptions(); - } - - if (null !== $command->getLocalizedMetaKeywords()) { - $category->meta_keywords = $command->getLocalizedMetaKeywords(); - } - - if (null !== $command->getAssociatedGroupIds()) { - $category->groupBox = $command->getAssociatedGroupIds(); - } - - if ($command->getAssociatedShopIds()) { - $this->associateWithShops($category, $command->getAssociatedShopIds()); - } - - if (false === $category->validateFields(false)) { - throw new CategoryException('Invalid data for updating category root'); - } - - if (false === $category->validateFieldsLang(false)) { - throw new CategoryException('Invalid data for updating category root'); - } - - if (false === $category->update()) { - throw new CannotEditCategoryException(sprintf('Failed to edit Category with id "%s".', $category->id)); - } - } -} diff --git a/src/Adapter/Category/CommandHandler/SetCategoryIsEnabledHandler.php b/src/Adapter/Category/CommandHandler/SetCategoryIsEnabledHandler.php deleted file mode 100644 index 729ed04b..00000000 --- a/src/Adapter/Category/CommandHandler/SetCategoryIsEnabledHandler.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category\CommandHandler; - -use Category; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\SetCategoryIsEnabledCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler\SetCategoryIsEnabledHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CannotUpdateCategoryStatusException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryNotFoundException; - -/** - * @internal - */ -final class SetCategoryIsEnabledHandler implements SetCategoryIsEnabledHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CategoryNotFoundException - * @throws CannotUpdateCategoryStatusException - */ - public function handle(SetCategoryIsEnabledCommand $command) - { - $categoryId = $command->getCategoryId()->getValue(); - $entity = new Category($categoryId); - - if (!$entity->id) { - throw new CategoryNotFoundException($command->getCategoryId(), sprintf('Category with id "%s" was not found', $categoryId)); - } - - if (!$entity->toggleStatus()) { - throw new CannotUpdateCategoryStatusException(sprintf('Cannot update status for category with id "%s"', $categoryId)); - } - } -} diff --git a/src/Adapter/Category/CommandHandler/UpdateCategoryPositionHandler.php b/src/Adapter/Category/CommandHandler/UpdateCategoryPositionHandler.php deleted file mode 100644 index b9088ce3..00000000 --- a/src/Adapter/Category/CommandHandler/UpdateCategoryPositionHandler.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category\CommandHandler; - -use Category; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\UpdateCategoryPositionCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler\UpdateCategoryPositionHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryNotFoundException; - -/** - * Updates category position using legacy object model - */ -final class UpdateCategoryPositionHandler implements UpdateCategoryPositionHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(UpdateCategoryPositionCommand $command) - { - $parentCategoryId = $command->getParentCategoryId()->getValue(); - $categoryId = $command->getCategoryId()->getValue(); - - $position = null; - - foreach ($command->getPositions() as $key => $value) { - list(, $positionParentCategoryId, $positionCategoryId) = explode('_', $value); - - if ((int) $positionParentCategoryId === $parentCategoryId && (int) $positionCategoryId === $categoryId) { - $position = $key; - - break; - } - } - - if (null === $position) { - throw new CategoryException('Category position cannot be updated'); - } - - $category = new Category($categoryId); - - if (!$category->id) { - throw new CategoryNotFoundException($command->getCategoryId(), sprintf('Category with id "%s" was not found', $categoryId)); - } - - if ($category->updatePosition($command->getWay(), $position)) { - /* Position '0' was not found in given positions so try to reorder parent category*/ - if (!$command->isFoundFirst()) { - Category::cleanPositions((int) $category->id_parent); - } - } - } -} diff --git a/src/Adapter/Category/QueryHandler/GetCategoryForEditingHandler.php b/src/Adapter/Category/QueryHandler/GetCategoryForEditingHandler.php deleted file mode 100644 index 4fe152b9..00000000 --- a/src/Adapter/Category/QueryHandler/GetCategoryForEditingHandler.php +++ /dev/null @@ -1,231 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category\QueryHandler; - -use Category; -use Db; -use ImageManager; -use ImageType; -use PDO; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Category\Query\GetCategoryForEditing; -use PrestaShop\PrestaShop\Core\Domain\Category\QueryHandler\GetCategoryForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\QueryResult\EditableCategory; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\MenuThumbnailId; -use PrestaShop\PrestaShop\Core\Image\Parser\ImageTagSourceParserInterface; -use Shop; - -/** - * Class GetCategoryForEditingHandler. - */ -final class GetCategoryForEditingHandler implements GetCategoryForEditingHandlerInterface -{ - /** - * @var ImageTagSourceParserInterface - */ - private $imageTagSourceParser; - - /** - * @param ImageTagSourceParserInterface $imageTagSourceParser - */ - public function __construct(ImageTagSourceParserInterface $imageTagSourceParser) - { - $this->imageTagSourceParser = $imageTagSourceParser; - } - - /** - * {@inheritdoc} - * - * @throws CategoryNotFoundException - */ - public function handle(GetCategoryForEditing $query) - { - $category = new Category($query->getCategoryId()->getValue()); - - if (!$category->id || (!$category->isAssociatedToShop() && Shop::getContext() == Shop::CONTEXT_SHOP)) { - throw new CategoryNotFoundException($query->getCategoryId(), sprintf('Category with id "%s" was not found', $query->getCategoryId()->getValue())); - } - - /** - * Select recursivly the subcategories in one SQL request - */ - $subcategories = Db::getInstance()->query( - 'SELECT id_category ' . - 'FROM ( ' . - ' SELECT * FROM `' . _DB_PREFIX_ . 'category`' . - ' ORDER BY id_parent, id_category' . - ') category_sorted, ' . - '(SELECT @pv := ' . (int) $category->id . ') initialisation ' . - 'WHERE FIND_IN_SET(id_parent, @pv) ' . - 'AND LENGTH(@pv := CONCAT(@pv, \',\', id_category))' - ); - - $editableCategory = new EditableCategory( - $query->getCategoryId(), - $category->name, - (bool) $category->active, - $category->description, - (int) $category->id_parent, - $category->meta_title, - $category->meta_description, - $category->meta_keywords, - $category->link_rewrite, - $category->getGroups(), - $category->getAssociatedShops(), - (bool) $category->is_root_category, - $this->getCoverImage($query->getCategoryId()), - $this->getThumbnailImage($query->getCategoryId()), - $this->getMenuThumbnailImages($query->getCategoryId()), - $subcategories->fetchAll(PDO::FETCH_COLUMN) - ); - - return $editableCategory; - } - - /** - * @param CategoryId $categoryId - * - * @return array|null cover image data or null if category does not have cover - */ - private function getCoverImage(CategoryId $categoryId) - { - $imageType = 'jpg'; - $image = _PS_CAT_IMG_DIR_ . $categoryId->getValue() . '.' . $imageType; - - $imageTag = ImageManager::thumbnail( - $image, - 'category' . '_' . $categoryId->getValue() . '.' . $imageType, - 350, - $imageType, - true, - true - ); - - $imageSize = file_exists($image) ? filesize($image) / 1000 : ''; - - if (empty($imageTag) || empty($imageSize)) { - return null; - } - - return [ - 'size' => sprintf('%skB', $imageSize), - 'path' => $this->imageTagSourceParser->parse($imageTag), - ]; - } - - /** - * @param CategoryId $categoryId - * - * @return array - */ - private function getThumbnailImage(CategoryId $categoryId) - { - $image = _PS_CAT_IMG_DIR_ . $categoryId->getValue() . '.jpg'; - $imageTypes = ImageType::getImagesTypes('categories'); - - if (count($imageTypes) > 0) { - $thumb = ''; - $imageTag = ''; - $formattedSmall = ImageType::getFormattedName('small'); - $imageType = new ImageType(); - foreach ($imageTypes as $k => $imageType) { - if ($formattedSmall == $imageType['name']) { - $thumb = _PS_CAT_IMG_DIR_ . $categoryId->getValue() . '-' . $imageType['name'] . '.jpg'; - if (is_file($thumb)) { - $imageTag = ImageManager::thumbnail( - $thumb, - 'category_' . (int) $categoryId->getValue() . '-thumb.jpg', - (int) $imageType['width'], - 'jpg', - true, - true - ); - } - } - } - - if (!is_file($thumb)) { - $thumb = $image; - $imageName = 'category_' . $categoryId->getValue() . '-thumb.jpg'; - - $imageTag = ImageManager::thumbnail($image, $imageName, 125, 'jpg', true, true); - ImageManager::resize( - _PS_TMP_IMG_DIR_ . $imageName, - _PS_TMP_IMG_DIR_ . $imageName, - (int) $imageType['width'], - (int) $imageType['height'] - ); - } - - $thumbSize = file_exists($thumb) ? filesize($thumb) / 1000 : false; - - if (empty($imageTag) || false === $thumbSize) { - return null; - } - - return [ - 'size' => sprintf('%skB', $thumbSize), - 'path' => $this->imageTagSourceParser->parse($imageTag), - ]; - } - - return null; - } - - /** - * @param CategoryId $categoryId - * - * @return array - */ - private function getMenuThumbnailImages(CategoryId $categoryId) - { - $menuThumbnails = []; - - foreach (MenuThumbnailId::ALLOWED_ID_VALUES as $id) { - $thumbnailPath = _PS_CAT_IMG_DIR_ . $categoryId->getValue() . '-' . $id . '_thumb.jpg'; - - if (file_exists($thumbnailPath)) { - $imageTag = ImageManager::thumbnail( - $thumbnailPath, - 'category_' . $categoryId->getValue() . '-' . $id . '_thumb.jpg', - 100, - 'jpg', - true, - true - ); - - $menuThumbnails[$id] = [ - 'path' => $this->imageTagSourceParser->parse($imageTag), - 'id' => $id, - ]; - } - } - - return $menuThumbnails; - } -} diff --git a/src/Adapter/Category/QueryHandler/GetCategoryIsEnabledHandler.php b/src/Adapter/Category/QueryHandler/GetCategoryIsEnabledHandler.php deleted file mode 100644 index c6ae80f8..00000000 --- a/src/Adapter/Category/QueryHandler/GetCategoryIsEnabledHandler.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Category\QueryHandler; - -use Category; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Category\Query\GetCategoryIsEnabled; -use PrestaShop\PrestaShop\Core\Domain\Category\QueryHandler\GetCategoryIsEnabledHandlerInterface; - -/** - * @internal - */ -final class GetCategoryIsEnabledHandler implements GetCategoryIsEnabledHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GetCategoryIsEnabled $query) - { - $categoryId = $query->getCategoryId()->getValue(); - $category = new Category($categoryId); - - if ($category->id !== $categoryId) { - throw new CategoryNotFoundException($query->getCategoryId(), sprintf('Category with id "%s" was not found.', $categoryId)); - } - - return (bool) $category->active; - } -} diff --git a/src/Adapter/ClassLang.php b/src/Adapter/ClassLang.php deleted file mode 100644 index 981551f6..00000000 --- a/src/Adapter/ClassLang.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -/** - * Not used in PrestaShop. - * - * @deprecated since 1.7.5, to be removed in 1.8 - */ -class ClassLang -{ - /** - * @var string - */ - private $locale; - - /** - * ClassLang constructor. - * - * @param $locale - */ - public function __construct($locale) - { - $this->locale = $locale; - } - - /** - * @param $className - * - * @return bool - */ - public function getClassLang($className) - { - if (!class_exists($className)) { - return false; - } - - return new $className($this->locale); - } -} diff --git a/src/Adapter/CombinationDataProvider.php b/src/Adapter/CombinationDataProvider.php deleted file mode 100644 index 8fd129f1..00000000 --- a/src/Adapter/CombinationDataProvider.php +++ /dev/null @@ -1,198 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use Combination; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Adapter\Product\ProductDataProvider; -use PrestaShop\PrestaShop\Core\Localization\Locale; -use PrestaShopBundle\Form\Admin\Type\CommonAbstractType; -use Product; - -/** - * This class will provide data from DB / ORM about product combination. - */ -class CombinationDataProvider -{ - /** - * @var LegacyContext - */ - private $context; - - /** - * @var ProductDataProvider - */ - private $productAdapter; - - /** - * @var Locale - */ - private $locale; - - /** - * @param Locale $locale - */ - public function __construct(Locale $locale) - { - $this->context = new LegacyContext(); - $this->productAdapter = new ProductDataProvider(); - $this->locale = $locale; - } - - /** - * Get a combination values. - * - * @deprecated since 1.7.3.1 really slow, use getFormCombinations instead. - * - * @param int $combinationId The id_product_attribute - * - * @return array combinations - */ - public function getFormCombination($combinationId) - { - $product = new Product((new Combination($combinationId))->id_product); - - return $this->completeCombination( - $product->getAttributeCombinationsById( - $combinationId, - $this->context->getContext()->language->id - ), - $product - ); - } - - /** - * Retrieve combinations data for a specific language id. - * - * @param array $combinationIds - * @param int $languageId - * - * @return array a list of formatted combinations - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - public function getFormCombinations(array $combinationIds, $languageId) - { - $productId = (new Combination($combinationIds[0]))->id_product; - $product = new Product($productId); - $combinations = []; - - foreach ($combinationIds as $combinationId) { - $combinations[$combinationId] = $this->completeCombination( - $product->getAttributeCombinationsById( - $combinationId, - $languageId - ), - $product - ); - } - - return $combinations; - } - - /** - * @param array $attributesCombinations - * @param Product $product - * - * @return array - */ - public function completeCombination($attributesCombinations, $product) - { - $combination = $attributesCombinations[0]; - - $attribute_price_impact = 0; - if ($combination['price'] > 0) { - $attribute_price_impact = 1; - } elseif ($combination['price'] < 0) { - $attribute_price_impact = -1; - } - - $attribute_weight_impact = 0; - if ($combination['weight'] > 0) { - $attribute_weight_impact = 1; - } elseif ($combination['weight'] < 0) { - $attribute_weight_impact = -1; - } - - $attribute_unity_price_impact = 0; - if ($combination['unit_price_impact'] > 0) { - $attribute_unity_price_impact = 1; - } elseif ($combination['unit_price_impact'] < 0) { - $attribute_unity_price_impact = -1; - } - - $finalPrice = (new Number((string) $product->price)) - ->plus(new Number((string) $combination['price'])) - ->toPrecision(CommonAbstractType::PRESTASHOP_DECIMALS); - - return [ - 'id_product_attribute' => $combination['id_product_attribute'], - 'attribute_reference' => $combination['reference'], - 'attribute_ean13' => $combination['ean13'], - 'attribute_isbn' => $combination['isbn'], - 'attribute_upc' => $combination['upc'], - 'attribute_mpn' => $combination['mpn'], - 'attribute_wholesale_price' => $combination['wholesale_price'], - 'attribute_price_impact' => $attribute_price_impact, - 'attribute_price' => $combination['price'], - 'attribute_price_display' => $this->locale->formatPrice($combination['price'], $this->context->getContext()->currency->iso_code), - 'final_price' => (string) $finalPrice, - 'attribute_priceTI' => '', - 'attribute_ecotax' => $combination['ecotax'], - 'attribute_weight_impact' => $attribute_weight_impact, - 'attribute_weight' => $combination['weight'], - 'attribute_unit_impact' => $attribute_unity_price_impact, - 'attribute_unity' => $combination['unit_price_impact'], - 'attribute_minimal_quantity' => $combination['minimal_quantity'], - 'attribute_low_stock_threshold' => $combination['low_stock_threshold'], - 'attribute_low_stock_alert' => (bool) $combination['low_stock_alert'], - 'available_date_attribute' => $combination['available_date'], - 'attribute_default' => (bool) $combination['default_on'], - 'attribute_location' => $this->productAdapter->getLocation($product->id, $combination['id_product_attribute']), - 'attribute_quantity' => $this->productAdapter->getQuantity($product->id, $combination['id_product_attribute']), - 'name' => $this->getCombinationName($attributesCombinations), - 'id_product' => $product->id, - ]; - } - - /** - * @param array $attributesCombinations - * - * @return string - */ - private function getCombinationName($attributesCombinations) - { - $name = []; - - foreach ($attributesCombinations as $attribute) { - $name[] = $attribute['group_name'] . ' - ' . $attribute['attribute_name']; - } - - return implode(', ', $name); - } -} diff --git a/src/Adapter/Configuration.php b/src/Adapter/Configuration.php deleted file mode 100644 index 0cb51c5a..00000000 --- a/src/Adapter/Configuration.php +++ /dev/null @@ -1,341 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use Combination; -use Configuration as ConfigurationLegacy; -use Feature; -use Language; -use PrestaShop\PrestaShop\Core\Domain\Configuration\ShopConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Shop\ValueObject\ShopConstraint; -use PrestaShopBundle\Exception\NotImplementedException; -use Shop; -use Symfony\Component\HttpFoundation\ParameterBag; - -/** - * Adapter of Configuration ObjectModel. - */ -class Configuration extends ParameterBag implements ShopConfigurationInterface -{ - /** - * @var Shop - */ - private $shop; - - public function __construct(array $parameters = []) - { - // Do nothing - if (!empty($parameters)) { - throw new \LogicException('No parameter can be handled in constructor. Use method set() instead.'); - } - } - - /** - * @throws NotImplementedException - */ - public function all() - { - throw new NotImplementedException(); - } - - /** - * {@inheritdoc} - */ - public function keys() - { - return array_keys($this->all()); - } - - /** - * {@inheritdoc} - */ - public function replace(array $parameters = []) - { - $this->add($parameters); - } - - /** - * {@inheritdoc} - */ - public function add(array $parameters = []) - { - foreach ($parameters as $key => $value) { - $this->set($key, $value); - } - } - - /** - * Returns constant defined by given $key if exists or check directly into PrestaShop - * \Configuration. - * - * @param string $key - * @param mixed $default The default value if the parameter key does not exist - * @param ShopConstraint|null $shopConstraint - * - * @return mixed - */ - public function get($key, $default = null, ShopConstraint $shopConstraint = null) - { - if (defined($key)) { - return constant($key); - } - - $shopId = $this->getShopId($shopConstraint); - $shopGroupId = $this->getShopGroupId($shopConstraint); - $isStrict = $this->isStrict($shopConstraint); - - //If configuration has never been accessed it is still empty and hasKey/isLangKey will always return false - if (!ConfigurationLegacy::configurationIsLoaded()) { - ConfigurationLegacy::loadConfiguration(); - } - - // if the key is multi lang related, we return an array with the value per language. - if (ConfigurationLegacy::isLangKey($key)) { - return $this->getLocalized($key, $shopId, $shopGroupId); - } - - // Since hasKey doesn't check manage the fallback shop > shop group > global, we handle it manually - $hasKey = ConfigurationLegacy::hasKey($key, null, null, $shopId); - if ($hasKey || $isStrict) { - return $hasKey ? ConfigurationLegacy::get($key, null, null, $shopId) : null; - } - - $hasKey = ConfigurationLegacy::hasKey($key, null, $shopGroupId); - if ($hasKey || $isStrict) { - return $hasKey ? ConfigurationLegacy::get($key, null, $shopGroupId) : null; - } - - if ($hasKey = ConfigurationLegacy::hasKey($key) || $isStrict) { - return $hasKey ? ConfigurationLegacy::get($key) : null; - } - - return $default; - } - - /** - * Set configuration value. - * - * @param string $key - * @param mixed $value - * @param ShopConstraint|null $shopConstraint - * @param array $options Options @deprecated Will be removed in next major - * - * @return $this - * - * @throws \Exception - */ - public function set($key, $value, ShopConstraint $shopConstraint = null, array $options = []) - { - // By default, set a piece of configuration for all available shops and shop groups - $shopGroupId = null; - $shopId = null; - - if ($this->shop instanceof Shop && null === $shopConstraint) { - $shopGroupId = $this->shop->id_shop_group; - $shopId = $this->shop->id; - } else { - $shopId = $this->getShopId($shopConstraint); - $shopGroupId = $this->getShopGroupId($shopConstraint); - } - - $html = isset($options['html']) ? (bool) $options['html'] : false; - - $success = ConfigurationLegacy::updateValue( - $key, - $value, - $html, - $shopGroupId, - $shopId - ); - - if (!$success) { - throw new \Exception('Could not update configuration'); - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function has($key, ShopConstraint $shopConstraint = null) - { - $shopId = $this->getShopId($shopConstraint); - $shopGroupId = $this->getShopGroupId($shopConstraint); - $isStrict = $this->isStrict($shopConstraint); - - $hasKey = ConfigurationLegacy::hasKey($key, null, null, $shopId); - if ($hasKey || $isStrict) { - return $hasKey; - } - - $hasKey = ConfigurationLegacy::hasKey($key, null, $shopGroupId); - if ($hasKey || $isStrict) { - return $hasKey; - } - - return ConfigurationLegacy::hasKey($key); - } - - /** - * Removes a configuration key. - * - * @param type $key - * - * @return type - */ - public function remove($key) - { - $success = \Configuration::deleteByName( - $key - ); - - if (!$success) { - throw new \Exception('Could not update configuration'); - } - - return $this; - } - - /** - * Unset configuration value. - * - * @param $key - * - * @return $this - * - * @throws \Exception - * - * @deprecated since version 1.7.4.0 - */ - public function delete($key) - { - $this->remove($key); - } - - /** - * {@inheritdoc} - */ - public function getIterator() - { - return new \ArrayIterator($this->all()); - } - - /** - * {@inheritdoc} - */ - public function count() - { - return count($this->all()); - } - - /** - * Return if Feature feature is active or not. - * - * @return bool - */ - public function featureIsActive() - { - return Feature::isFeatureActive(); - } - - /** - * Return if Combination feature is active or not. - * - * @return bool - */ - public function combinationIsActive() - { - return Combination::isFeatureActive(); - } - - /** - * Restrict updates of a piece of configuration to a single shop. - * - * @param Shop $shop - */ - public function restrictUpdatesTo(Shop $shop) - { - $this->shop = $shop; - } - - /** - * Get localized configuration in all languages - * - * @param string $key - * @param int|null $shopId - * @param int|null $shopGroupId - * - * @return array Array of langId => localizedConfiguration - */ - private function getLocalized($key, ?int $shopId = null, ?int $shopGroupId = null) - { - $configuration = []; - - foreach (Language::getIDs(false, $shopId ?: false) as $langId) { - $configuration[$langId] = ConfigurationLegacy::get($key, $langId, $shopGroupId, $shopId); - } - - return $configuration; - } - - /** - * @param ShopConstraint|null $shopConstraint - * - * @return int|null - */ - private function getShopId(?ShopConstraint $shopConstraint): ?int - { - return null !== $shopConstraint && null !== $shopConstraint->getShopId() - ? $shopConstraint->getShopId()->getValue() - : null - ; - } - - /** - * @param ShopConstraint|null $shopConstraint - * - * @return int|null - */ - private function getShopGroupId(?ShopConstraint $shopConstraint): ?int - { - return null !== $shopConstraint && null !== $shopConstraint->getShopGroupId() - ? $shopConstraint->getShopGroupId()->getValue() - : null - ; - } - - /** - * @param ShopConstraint|null $shopConstraint - * - * @return bool - */ - private function isStrict(?ShopConstraint $shopConstraint): bool - { - return null !== $shopConstraint ? $shopConstraint->isStrict() : false; - } -} diff --git a/src/Adapter/Configuration/CommandHandler/SwitchDebugModeHandler.php b/src/Adapter/Configuration/CommandHandler/SwitchDebugModeHandler.php deleted file mode 100644 index 283d4ba6..00000000 --- a/src/Adapter/Configuration/CommandHandler/SwitchDebugModeHandler.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Configuration\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Debug\DebugMode; -use PrestaShop\PrestaShop\Core\Domain\Configuration\Command\SwitchDebugModeCommand; -use PrestaShop\PrestaShop\Core\Domain\Configuration\CommandHandler\SwitchDebugModeHandlerInterface; - -/** - * Handles command that switches debug mode - * - * @internal - */ -final class SwitchDebugModeHandler implements SwitchDebugModeHandlerInterface -{ - /** - * @var DebugMode - */ - private $debugMode; - - /** - * @param DebugMode $debugMode - */ - public function __construct(DebugMode $debugMode) - { - $this->debugMode = $debugMode; - } - - /** - * {@inheritdoc} - */ - public function handle(SwitchDebugModeCommand $command) - { - $isDebugModeEnabled = $this->debugMode->isDebugModeEnabled(); - - if (!$isDebugModeEnabled && $command->enableDebugMode()) { - $this->debugMode->enable(); - - return; - } - - if ($isDebugModeEnabled && !$command->enableDebugMode()) { - $this->debugMode->disable(); - } - } -} diff --git a/src/Adapter/Configuration/KpiConfiguration.php b/src/Adapter/Configuration/KpiConfiguration.php deleted file mode 100644 index aea49564..00000000 --- a/src/Adapter/Configuration/KpiConfiguration.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Configuration; - -use ConfigurationKPI; -use PrestaShop\PrestaShop\Adapter\Configuration; - -/** - * Class KpiConfiguration provides access to legacy ConfigurationKpi methods. - */ -class KpiConfiguration extends Configuration -{ - /** - * Changes configuration definition before calling it's methods. - * - * @param $name - * @param $arguments - * - * @return mixed - */ - public function __call($name, $arguments) - { - if (is_callable([$this, $name])) { - ConfigurationKPI::setKpiDefinition(); - $result = call_user_func([$this, $name], $arguments); - ConfigurationKPI::unsetKpiDefinition(); - - return $result; - } - } -} diff --git a/src/Adapter/Configuration/LogsConfiguration.php b/src/Adapter/Configuration/LogsConfiguration.php deleted file mode 100644 index 57fa6777..00000000 --- a/src/Adapter/Configuration/LogsConfiguration.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Configuration; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * This class will manage Logs configuration for a Shop. - */ -class LogsConfiguration implements DataConfigurationInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return ['logs_by_email' => $this->configuration->get('PS_LOGS_BY_EMAIL')]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_LOGS_BY_EMAIL', $configuration['logs_by_email']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - $resolver = new OptionsResolver(); - $resolver - ->setRequired(['logs_by_email']) - ->resolve($configuration); - - return true; - } -} diff --git a/src/Adapter/Configuration/PhpParameters.php b/src/Adapter/Configuration/PhpParameters.php deleted file mode 100644 index 25787d56..00000000 --- a/src/Adapter/Configuration/PhpParameters.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Configuration; - -use InvalidArgumentException; -use Shudrum\Component\ArrayFinder\ArrayFinder; -use Symfony\Component\Filesystem\Exception\IOException; -use Symfony\Component\Filesystem\Filesystem; - -/** - * Class able to manage configuration stored in Php files. - */ -class PhpParameters -{ - /** - * @var array the current configuration - */ - private $configuration = []; - - /** - * @var string the PHP filename - */ - private $filename; - - public function __construct($filename) - { - if (!is_readable($filename)) { - throw new InvalidArgumentException("File $filename is not readable for configuration"); - } - - $this->filename = $filename; - $phpArray = require $this->filename; - $this->configuration = new ArrayFinder($phpArray); - } - - /** - * @return array return the complete configuration - */ - public function getConfiguration() - { - return $this->configuration->get(); - } - - /** - * Insert a value into configuration at the specified path. - * - * @param $propertyPath - * @param $value - */ - public function setProperty($propertyPath, $value) - { - $this->configuration->set($propertyPath, $value); - } - - /** - * Persist the modifications done on the original configuration file. - * - * @return bool - */ - public function saveConfiguration() - { - try { - $filesystem = new Filesystem(); - $filesystem->dumpFile($this->filename, 'configuration->get(), true) . ';' . "\n"); - - if (function_exists('opcache_invalidate')) { - opcache_invalidate($this->filename); - } - } catch (IOException $e) { - return false; - } - - return true; - } -} diff --git a/src/Adapter/Contact/CommandHandler/AddContactHandler.php b/src/Adapter/Contact/CommandHandler/AddContactHandler.php deleted file mode 100644 index c6b807c5..00000000 --- a/src/Adapter/Contact/CommandHandler/AddContactHandler.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Contact\CommandHandler; - -use Contact; -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CleanHtml; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\DefaultLanguage; -use PrestaShop\PrestaShop\Core\Domain\Contact\Command\AddContactCommand; -use PrestaShop\PrestaShop\Core\Domain\Contact\CommandHandler\AddContactHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\CannotAddContactException; -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\ContactConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\ContactException; -use PrestaShop\PrestaShop\Core\Domain\Contact\ValueObject\ContactId; -use PrestaShopException; -use Symfony\Component\Validator\Validator\ValidatorInterface; - -/** - * Class AddContactHandler is used for adding contact data. - * - * @internal - */ -final class AddContactHandler extends AbstractObjectModelHandler implements AddContactHandlerInterface -{ - /** - * @var ValidatorInterface - */ - private $validator; - - /** - * @param ValidatorInterface $validator - */ - public function __construct(ValidatorInterface $validator) - { - $this->validator = $validator; - } - - /** - * {@inheritdoc} - * - * @throws CannotAddContactException - * @throws ContactException - */ - public function handle(AddContactCommand $command) - { - $this->assertLocalisedTitleContainsDefaultLanguage($command->getLocalisedTitles()); - - try { - $entity = new Contact(); - $entity->name = $command->getLocalisedTitles(); - $entity->customer_service = $command->isMessageSavingEnabled(); - - if (null !== $command->getEmail()) { - $entity->email = $command->getEmail()->getValue(); - } - - if (null !== $command->getLocalisedDescription()) { - $this->assertDescriptionContainsCleanHtmlValues($command->getLocalisedDescription()); - $entity->description = $command->getLocalisedDescription(); - } - - if (false === $entity->add()) { - throw new CannotAddContactException('Unable to add contact'); - } - - if (null !== $command->getShopAssociation()) { - $this->associateWithShops($entity, $command->getShopAssociation()); - } - } catch (PrestaShopException $exception) { - throw new ContactException('An unexpected error occurred when adding contact', 0, $exception); - } - - return new ContactId((int) $entity->id); - } - - /** - * Checks if the localised titles array contains value for the default language. - * - * @param array $localisedTitle - * - * @throws ContactConstraintException - */ - private function assertLocalisedTitleContainsDefaultLanguage(array $localisedTitle) - { - $errors = $this->validator->validate($localisedTitle, new DefaultLanguage()); - - if (0 !== count($errors)) { - throw new ContactConstraintException('Title field is not found for default language', ContactConstraintException::MISSING_TITLE_FOR_DEFAULT_LANGUAGE); - } - } - - /** - * Assets that the value should not contain script tags or javascript events. - * - * @param array $localisedDescriptions - * - * @throws ContactConstraintException - */ - private function assertDescriptionContainsCleanHtmlValues(array $localisedDescriptions) - { - foreach ($localisedDescriptions as $description) { - $errors = $this->validator->validate($description, new CleanHtml()); - - if (0 !== count($errors)) { - throw new ContactConstraintException(sprintf('Given description "%s" contains javascript events or script tags', $description), ContactConstraintException::INVALID_DESCRIPTION); - } - } - } -} diff --git a/src/Adapter/Contact/CommandHandler/EditContactHandler.php b/src/Adapter/Contact/CommandHandler/EditContactHandler.php deleted file mode 100644 index 249fb903..00000000 --- a/src/Adapter/Contact/CommandHandler/EditContactHandler.php +++ /dev/null @@ -1,158 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Contact\CommandHandler; - -use Contact; -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CleanHtml; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\DefaultLanguage; -use PrestaShop\PrestaShop\Core\Domain\Contact\Command\EditContactCommand; -use PrestaShop\PrestaShop\Core\Domain\Contact\CommandHandler\EditContactHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\CannotUpdateContactException; -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\ContactConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\ContactException; -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\ContactNotFoundException; -use PrestaShopDatabaseException; -use PrestaShopException; -use Symfony\Component\Validator\Validator\ValidatorInterface; - -/** - * Class EditContactHandler is responsible for editing contact data. - * - * @internal - */ -final class EditContactHandler extends AbstractObjectModelHandler implements EditContactHandlerInterface -{ - /** - * @var ValidatorInterface - */ - private $validator; - - /** - * @param ValidatorInterface $validator - */ - public function __construct(ValidatorInterface $validator) - { - $this->validator = $validator; - } - - /** - * {@inheritdoc} - * - * @throws ContactException - */ - public function handle(EditContactCommand $command) - { - try { - $entity = $this->getContactEntityIfFound($command->getContactId()->getValue()); - - if (null !== $command->getLocalisedTitles()) { - $this->assertLocalisedTitleContainsDefaultLanguage($command->getLocalisedTitles()); - $entity->name = $command->getLocalisedTitles(); - } - - if (null !== $command->getLocalisedDescription()) { - $this->assertDescriptionContainsCleanHtmlValues($command->getLocalisedDescription()); - $entity->description = $command->getLocalisedDescription(); - } - - if (null !== $command->getEmail()) { - $entity->email = $command->getEmail()->getValue(); - } - - if (null !== $command->isMessagesSavingEnabled()) { - $entity->customer_service = $command->isMessagesSavingEnabled(); - } - - if (false === $entity->update()) { - throw new CannotUpdateContactException(sprintf('Unable to update contact object with id %s', $command->getContactId()->getValue())); - } - - if (null !== $command->getShopAssociation()) { - $this->associateWithShops($entity, $command->getShopAssociation()); - } - } catch (PrestaShopException $e) { - throw new ContactException(sprintf('An unexpected error occurred when retrieving contact with id %s', var_export($command->getContactId()->getValue(), true)), 0, $e); - } - } - - /** - * Validates that values does not contain script tags or javascript events. - * - * @param array $localisedDescriptions - * - * @throws ContactConstraintException - */ - private function assertDescriptionContainsCleanHtmlValues(array $localisedDescriptions) - { - foreach ($localisedDescriptions as $description) { - $errors = $this->validator->validate($description, new CleanHtml()); - - if (0 !== count($errors)) { - throw new ContactConstraintException(sprintf('Given description "%s" contains javascript events or script tags', $description), ContactConstraintException::INVALID_DESCRIPTION); - } - } - } - - /** - * Checks if the localised titles array contains value for the default language. - * - * @param array $localisedTitle - * - * @throws ContactConstraintException - */ - private function assertLocalisedTitleContainsDefaultLanguage(array $localisedTitle) - { - $errors = $this->validator->validate($localisedTitle, new DefaultLanguage()); - - if (0 !== count($errors)) { - throw new ContactConstraintException('Title field is not found for default language', ContactConstraintException::MISSING_TITLE_FOR_DEFAULT_LANGUAGE); - } - } - - /** - * Gets contact entity. - * - * @param int $contactId - * - * @return Contact - * - * @throws ContactNotFoundException - * @throws PrestaShopException - * @throws PrestaShopDatabaseException - */ - private function getContactEntityIfFound($contactId) - { - $entity = new Contact($contactId); - - if (0 >= $entity->id) { - throw new ContactNotFoundException(sprintf('Contact object with id %s was not found', var_export($contactId, true))); - } - - return $entity; - } -} diff --git a/src/Adapter/Contact/QueryHandler/GetContactForEditingHandler.php b/src/Adapter/Contact/QueryHandler/GetContactForEditingHandler.php deleted file mode 100644 index a9085902..00000000 --- a/src/Adapter/Contact/QueryHandler/GetContactForEditingHandler.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Contact\QueryHandler; - -use Contact; -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\ContactException; -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\ContactNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Contact\Query\GetContactForEditing; -use PrestaShop\PrestaShop\Core\Domain\Contact\QueryHandler\GetContactForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Contact\QueryResult\EditableContact; -use PrestaShopException; -use Symfony\Component\Form\DataTransformerInterface; - -/** - * Class GetContactForEditingHandler is responsible for getting the data for contact edit page. - * - * @internal - */ -final class GetContactForEditingHandler implements GetContactForEditingHandlerInterface -{ - /** - * @var DataTransformerInterface - */ - private $stringArrayToIntegerArrayDataTransformer; - - /** - * @param DataTransformerInterface $stringArrayToIntegerArrayDataTransformer - */ - public function __construct(DataTransformerInterface $stringArrayToIntegerArrayDataTransformer) - { - $this->stringArrayToIntegerArrayDataTransformer = $stringArrayToIntegerArrayDataTransformer; - } - - /** - * {@inheritdoc} - * - * @throws ContactException - */ - public function handle(GetContactForEditing $query) - { - try { - $contact = new Contact($query->getContactId()->getValue()); - - if (0 >= $contact->id) { - throw new ContactNotFoundException(sprintf('Contact object with id %s was not found', var_export($query->getContactId()->getValue(), true))); - } - $editableContact = new EditableContact( - $query->getContactId()->getValue(), - $contact->name, - $contact->email, - (bool) $contact->customer_service, - $contact->description, - $this->stringArrayToIntegerArrayDataTransformer->reverseTransform($contact->getAssociatedShops()) - ); - } catch (PrestaShopException $e) { - throw new ContactException(sprintf('An unexpected error occurred when retrieving contact with id %s', var_export($query->getContactId()->getValue(), true)), 0, $e); - } - - return $editableContact; - } -} diff --git a/src/Adapter/Container/ContainerBuilderExtensionInterface.php b/src/Adapter/Container/ContainerBuilderExtensionInterface.php deleted file mode 100644 index 1bc2504d..00000000 --- a/src/Adapter/Container/ContainerBuilderExtensionInterface.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Container; - -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * Interface ContainerBuilderExtensionInterface is used to externalize some container - * building actions from the PrestaShop\PrestaShop\Adapter\ContainerBuilder (register - * an extension, init some parameters). - * - * This builder extension system needs to be used for actions that can't be performed in a - * CompilerPassInterface due to the compilation workflow (some actions MUST be done before - * the compilation stars, this is where this system comes in handy). - */ -interface ContainerBuilderExtensionInterface -{ - /** - * This method is called by the ContainerBuilder before compiling the container. This is where you - * can add extension, compiler pass, or parameters to the container. - * - * @param ContainerBuilder $container - */ - public function build(ContainerBuilder $container); -} diff --git a/src/Adapter/Container/ContainerParametersExtension.php b/src/Adapter/Container/ContainerParametersExtension.php deleted file mode 100644 index ceef4e87..00000000 --- a/src/Adapter/Container/ContainerParametersExtension.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Container; - -use PrestaShop\PrestaShop\Core\EnvironmentInterface; -use PrestaShopBundle\Kernel\ModuleRepository; -use PrestaShopBundle\Kernel\ModuleRepositoryFactory; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * This container extension is in charge of initializing the container parameters. - * It uses the same type of init as the kernel container thanks to the set_parameters.php - * script which allows it to be as close as possible to the symfony kernel AND the script - * automatically manage env test switching. - * - * We also add a few default parameters which are expected by doctrine and some of our - * compiler pass which need the list of active modules. - * - * Note: this can't be done as a CompilerPassInterface because parameters need to be set before extensions - * are registered (especially Doctrine extension). - */ -class ContainerParametersExtension implements ContainerBuilderExtensionInterface -{ - /** - * @var EnvironmentInterface - */ - private $environment; - - /** - * @param EnvironmentInterface $environment - */ - public function __construct(EnvironmentInterface $environment) - { - $this->environment = $environment; - } - - /** - * {@inheritdoc} - */ - public function build(ContainerBuilder $container) - { - //This script is used in config.yml to init the container parameters - //It is also able to generate the parameters.php file if it does not exist - include _PS_ROOT_DIR_ . '/app/config/set_parameters.php'; - $container->addResource(new FileResource(_PS_ROOT_DIR_ . '/app/config/parameters.php')); - - //Most of these parameters are just necessary fro doctrine services definitions - $container->setParameter('kernel.bundles', []); - $container->setParameter('kernel.root_dir', _PS_ROOT_DIR_ . '/app'); - $container->setParameter('kernel.project_dir', _PS_ROOT_DIR_); - $container->setParameter('kernel.name', 'app'); - $container->setParameter('kernel.debug', $this->environment->isDebug()); - $container->setParameter('kernel.environment', $this->environment->getName()); - - //Note: this is not the same folder in test env because PS_CACHE_DIR only manages dev and prod env - //but it should! So for now let's do it the right way here and let's fix the rest later when EnvironmentInterface - //will be correctly/fully integrated. - $container->setParameter('kernel.cache_dir', $this->environment->getCacheDir()); - - //Init the active modules - $factory = new ModuleRepositoryFactory($container->getParameterBag()->all()); - /** @var ModuleRepository $moduleRepository */ - $moduleRepository = $factory->getRepository(); - $container->setParameter('kernel.active_modules', $moduleRepository->getActiveModules()); - } -} diff --git a/src/Adapter/Container/DoctrineBuilderExtension.php b/src/Adapter/Container/DoctrineBuilderExtension.php deleted file mode 100644 index 9efd20bf..00000000 --- a/src/Adapter/Container/DoctrineBuilderExtension.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Container; - -use Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension; -use PrestaShop\PrestaShop\Core\EnvironmentInterface; -use PrestaShopBundle\DependencyInjection\Compiler\ModulesDoctrineCompilerPass; -use PrestaShopBundle\DependencyInjection\Config\ConfigYamlLoader; -use Symfony\Component\Config\FileLocator; -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * Class DoctrineBuilderExtension is used to init the doctrine service in the ContainerBuilder. - * This is a manual initialisation of Doctrine because we are not in a symfony context, so we need - * add the extension manually (required parameters are managed by ContainerParametersExtension). - * - * Note: this can't be done as a CompilerPassInterface because extensions need to be registered before compilation. - */ -class DoctrineBuilderExtension implements ContainerBuilderExtensionInterface -{ - /** @var EnvironmentInterface */ - private $environment; - - /** - * @param EnvironmentInterface $environment - */ - public function __construct(EnvironmentInterface $environment) - { - $this->environment = $environment; - } - - /** - * {@inheritdoc} - */ - public function build(ContainerBuilder $container) - { - $configDirectories = [$container->getParameter('kernel.root_dir') . '/config']; - $fileLocator = new FileLocator($configDirectories); - - $configLoader = new ConfigYamlLoader($fileLocator); - $configPath = sprintf('config_legacy_%s.yml', $this->environment->getName()); - $configLoader->load($configPath); - $config = $configLoader->getConfig(); - - $container->registerExtension(new DoctrineExtension()); - $container->loadFromExtension('doctrine', $config['doctrine']); - $container->addCompilerPass(new ModulesDoctrineCompilerPass()); - } -} diff --git a/src/Adapter/Container/LegacyContainer.php b/src/Adapter/Container/LegacyContainer.php deleted file mode 100644 index 3077a58a..00000000 --- a/src/Adapter/Container/LegacyContainer.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Container; - -use Symfony\Component\DependencyInjection\Container; - -/** - * This class is only used when we build containers for legacy environment. It - * is used as a base class when dumping the container in our ContainerBuilder. - * - * It implements LegacyContainerInterface which allows to detect if the container - * was built by Symfony or by PrestaShop. - */ -class LegacyContainer extends Container implements LegacyContainerInterface -{ -} diff --git a/src/Adapter/Container/LegacyContainerBuilder.php b/src/Adapter/Container/LegacyContainerBuilder.php deleted file mode 100644 index 7fa146ae..00000000 --- a/src/Adapter/Container/LegacyContainerBuilder.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Container; - -use Symfony\Component\DependencyInjection\ContainerBuilder as SfContainerBuilder; - -/** - * This class is only used when we build containers for legacy environment. It - * is used as a base builder when we build the container in our ContainerBuilder. - * - * It is needed during the first generation of the container as it is used as a container - * during this process, next calls usually use the built container class that extends LegacyContainer. - * - * It implements LegacyContainerInterface which allows to detect if the container - * was built by Symfony or by PrestaShop. - */ -class LegacyContainerBuilder extends SfContainerBuilder implements LegacyContainerInterface -{ -} diff --git a/src/Adapter/Container/LegacyContainerInterface.php b/src/Adapter/Container/LegacyContainerInterface.php deleted file mode 100644 index 569089d2..00000000 --- a/src/Adapter/Container/LegacyContainerInterface.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Container; - -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * This interface is only used when we build containers for legacy environment. It - * is common to LegacyContainer and LegacyContainerBuilder. - * - * It allows to easily (and without losing performance) detect if the container is a - * Symfony one (generated by kernel) or a legacy one (generated by PrestaShop core). - */ -interface LegacyContainerInterface extends ContainerInterface -{ -} diff --git a/src/Adapter/ContainerBuilder.php b/src/Adapter/ContainerBuilder.php deleted file mode 100644 index 228619ff..00000000 --- a/src/Adapter/ContainerBuilder.php +++ /dev/null @@ -1,244 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use Doctrine\Common\Cache\ArrayCache; -use Doctrine\ORM\Tools\Setup; -use Exception; -use LegacyCompilerPass; -use PrestaShop\PrestaShop\Adapter\Container\ContainerBuilderExtensionInterface; -use PrestaShop\PrestaShop\Adapter\Container\ContainerParametersExtension; -use PrestaShop\PrestaShop\Adapter\Container\DoctrineBuilderExtension; -use PrestaShop\PrestaShop\Adapter\Container\LegacyContainer; -use PrestaShop\PrestaShop\Adapter\Container\LegacyContainerBuilder; -use PrestaShop\PrestaShop\Core\EnvironmentInterface; -use PrestaShopBundle\DependencyInjection\Compiler\LoadServicesFromModulesPass; -use Symfony\Component\Config\ConfigCache; -use Symfony\Component\Config\FileLocator; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\DependencyInjection\Compiler\PassConfig; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\DependencyInjection\Dumper\PhpDumper; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; - -/** - * Build the Container for PrestaShop Legacy. - */ -class ContainerBuilder -{ - /** - * @var ContainerInterface - */ - private static $containers; - - /** - * @var string - */ - private $environment; - - /** - * @var string - */ - private $containerName; - - /** - * @var string - */ - private $containerClassName; - - /** - * @var string - */ - private $dumpFile; - - /** - * @var ConfigCache - */ - private $containerConfigCache; - - /** - * @param string $containerName - * @param bool $isDebug - * - * @return LegacyContainerBuilder - * - * @throws Exception - */ - public static function getContainer($containerName, $isDebug) - { - if (!isset(self::$containers[$containerName])) { - $builder = new ContainerBuilder(new Environment($isDebug)); - self::$containers[$containerName] = $builder->buildContainer($containerName); - } - - return self::$containers[$containerName]; - } - - /** - * @param EnvironmentInterface $environment - */ - public function __construct(EnvironmentInterface $environment) - { - $this->environment = $environment; - } - - /** - * @param string $containerName - * - * @return ContainerInterface|LegacyContainerBuilder - * - * @throws Exception - */ - public function buildContainer($containerName) - { - $this->containerName = $containerName; - $this->containerClassName = ucfirst($this->containerName) . 'Container'; - $this->dumpFile = $this->environment->getCacheDir() . $this->containerClassName . '.php'; - $this->containerConfigCache = new ConfigCache($this->dumpFile, $this->environment->isDebug()); - - //These methods load required files like autoload or annotation metadata so we need to load - //them at each container creation, this can't be compiled. - $this->loadDoctrineAnnotationMetadata(); - - $container = $this->loadDumpedContainer(); - if (null === $container) { - $container = $this->compileContainer(); - } - $this->loadModulesAutoloader($container); - - return $container; - } - - /** - * @return ContainerInterface|null - */ - private function loadDumpedContainer() - { - $container = null; - if ($this->containerConfigCache->isFresh()) { - require_once $this->dumpFile; - $container = new $this->containerClassName(); - } - - return $container; - } - - /** - * @return LegacyContainerBuilder - * - * @throws Exception - */ - private function compileContainer() - { - $container = new LegacyContainerBuilder(); - //If the container builder is modified the container logically should be rebuilt - $container->addResource(new FileResource(__FILE__)); - - $container->addCompilerPass(new LoadServicesFromModulesPass($this->containerName), PassConfig::TYPE_BEFORE_OPTIMIZATION, 1); - $container->addCompilerPass(new LegacyCompilerPass()); - - //Build extensions - $builderExtensions = [ - new ContainerParametersExtension($this->environment), - new DoctrineBuilderExtension($this->environment), - ]; - /** @var ContainerBuilderExtensionInterface $builderExtension */ - foreach ($builderExtensions as $builderExtension) { - $builderExtension->build($container); - } - - $this->loadServicesFromConfig($container); - $container->compile(); - - //Dump the container file - $dumper = new PhpDumper($container); - $this->containerConfigCache->write( - $dumper->dump([ - 'class' => $this->containerClassName, - 'base_class' => LegacyContainer::class, - ]), - $container->getResources() - ); - - return $container; - } - - /** - * In symfony context doctrine classes (like Table, Entity, ...) are available thanks to - * the autoloader. In this specific context we don't have the general autoloader, so we need - * to include these classes manually. This is performed in Doctrine\ORM\Configuration::newDefaultAnnotationDriver - * which is called in Setup::createAnnotationMetadataConfiguration. - */ - private function loadDoctrineAnnotationMetadata() - { - //IMPORTANT: we need to provide a cache because doctrine tries to init a connection on redis, memcached, ... on its own - Setup::createAnnotationMetadataConfiguration([], $this->environment->isDebug(), null, new ArrayCache()); - } - - /** - * @param LegacyContainerBuilder $container - * - * @throws Exception - */ - private function loadServicesFromConfig(LegacyContainerBuilder $container) - { - $loader = new YamlFileLoader($container, new FileLocator(__DIR__)); - $servicesPath = sprintf( - '%sservices/%s/services_%s.yml', - _PS_CONFIG_DIR_, - $this->containerName, - $this->environment->getName() - ); - $loader->load($servicesPath); - } - - /** - * Loops through all active modules and automatically include their autoload (if present). - * Needs to be done as earlier as possible in application lifecycle. Unfortunately this can't - * be done in a compiler pass because they are only executed on compilation and this needs to - * be done at each container instanciation. - * - * @param ContainerInterface $container - * - * @throws Exception - */ - private function loadModulesAutoloader(ContainerInterface $container) - { - if (!$container->hasParameter('kernel.active_modules')) { - return; - } - - $activeModules = $container->getParameter('kernel.active_modules'); - foreach ($activeModules as $module) { - $autoloader = _PS_MODULE_DIR_ . $module . '/vendor/autoload.php'; - - if (file_exists($autoloader)) { - include_once $autoloader; - } - } - } -} diff --git a/src/Adapter/ContainerFinder.php b/src/Adapter/ContainerFinder.php deleted file mode 100644 index 9d80dcf0..00000000 --- a/src/Adapter/ContainerFinder.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use Context; -use Controller; -use PrestaShop\PrestaShop\Core\Exception\ContainerNotFoundException; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Find the container - */ -class ContainerFinder -{ - /** - * @var Context - */ - protected $context; - - /** - * ContainerFinder constructor. - * - * @param Context $context - */ - public function __construct(Context $context) - { - $this->context = $context; - } - - /** - * @return ContainerBuilder|ContainerInterface - * - * @throws ContainerNotFoundException - */ - public function getContainer() - { - if (isset($this->context->container)) { - return $this->context->container; - } - if (isset($this->context->controller) - && $this->context->controller instanceof Controller - && ($container = $this->context->controller->getContainer()) - && null !== $container - ) { - return $container; - } - $container = SymfonyContainer::getInstance(); - if (null !== $container) { - return $container; - } - - throw new ContainerNotFoundException('Kernel Container is not available'); - } -} diff --git a/src/Adapter/ContextStateManager.php b/src/Adapter/ContextStateManager.php deleted file mode 100644 index e7e71e3b..00000000 --- a/src/Adapter/ContextStateManager.php +++ /dev/null @@ -1,285 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter; - -use Cart; -use Context; -use Country; -use Currency; -use Customer; -use Language; -use Shop; - -/** - * Allows manipulating context state. - * This was adapted for specific broken legacy use cases when the previous state of context must be restored after some actions. - * - * e.g. order creation from back office. - * Legacy requires Context properties (currency, country etc.) instead of using cart properties - * so some context props must be changed for a while and then restored to previous state. - */ -final class ContextStateManager -{ - private const MANAGED_FIELDS = [ - 'cart', - 'country', - 'currency', - 'language', - 'customer', - 'shop', - 'shopContext', - ]; - - /** - * @var Context - */ - private $context; - - /** - * @var array - */ - private $contextFieldsStack = [[]]; - - /** - * @param Context $context - */ - public function __construct(Context $context) - { - $this->context = $context; - } - - /** - * @return Context - */ - public function getContext(): Context - { - return $this->context; - } - - /** - * Sets context cart and saves previous value - * - * @param Cart|null $cart - * - * @return $this - */ - public function setCart(?Cart $cart): self - { - $this->saveContextField('cart'); - $this->context->cart = $cart; - - return $this; - } - - /** - * Sets context country and saves previous value - * - * @param Country|null $country - * - * @return $this - */ - public function setCountry(?Country $country): self - { - $this->saveContextField('country'); - $this->context->country = $country; - - return $this; - } - - /** - * Sets context currency and saves previous value - * - * @param Currency|null $currency - * - * @return $this - */ - public function setCurrency(?Currency $currency): self - { - $this->saveContextField('currency'); - $this->context->currency = $currency; - - return $this; - } - - /** - * Sets context language and saves previous value - * - * @param Language|null $language - * - * @return $this - */ - public function setLanguage(?Language $language): self - { - $this->saveContextField('language'); - $this->context->language = $language; - - return $this; - } - - /** - * Sets context customer and saves previous value - * - * @param Customer|null $customer - * - * @return $this - */ - public function setCustomer(?Customer $customer): self - { - $this->saveContextField('customer'); - $this->context->customer = $customer; - - return $this; - } - - /** - * Sets context shop and saves previous value - * - * @param Shop $shop - * - * @return $this - * - * @throws \PrestaShopException - */ - public function setShop(Shop $shop): self - { - $this->saveContextField('shop'); - $this->context->shop = $shop; - Shop::setContext(Shop::CONTEXT_SHOP, $shop->id); - - return $this; - } - - /** - * Restores context to a state before changes - * - * @return self - */ - public function restorePreviousContext(): self - { - $currentStashIndex = array_key_last($this->contextFieldsStack); - foreach (array_keys($this->contextFieldsStack[$currentStashIndex]) as $fieldName) { - $this->restoreContextField($fieldName); - } - $this->removeLastSavedContext(); - - return $this; - } - - /** - * Saves the current overridden fields in the context, allowing you to set new values to the - * current Context. Next time you call restorePreviousContext the context will be refilled with - * the values that were saved during this call. - * - * This is useful if several services use the ContextStateManager, this way if every service - * saved the context before modifying it there is no risk of removing previous modifications - * when you restore the context, because the different states have been stacked. - * - * @return $this - */ - public function saveCurrentContext(): self - { - // Saves all the fields that have not been overridden - foreach (self::MANAGED_FIELDS as $contextField) { - $this->saveContextField($contextField); - } - - // Add a new empty layer - $this->contextFieldsStack[] = []; - - return $this; - } - - /** - * Save context field into local array - * - * @param string $fieldName - */ - private function saveContextField(string $fieldName) - { - $currentStashIndex = array_key_last($this->contextFieldsStack); - // NOTE: array_key_exists important here, isset cannot be used because it would not detect if null is stored - if (!array_key_exists($fieldName, $this->contextFieldsStack[$currentStashIndex])) { - if ('shop' === $fieldName) { - $this->contextFieldsStack[$currentStashIndex]['shop'] = $this->context->$fieldName; - $this->contextFieldsStack[$currentStashIndex]['shopContext'] = Shop::getContext(); - } else { - $this->contextFieldsStack[$currentStashIndex][$fieldName] = $this->context->$fieldName; - } - } - } - - /** - * Restores context saved value, and remove save value from local array - * - * @param string $fieldName - */ - private function restoreContextField(string $fieldName): void - { - $currentStashIndex = array_key_last($this->contextFieldsStack); - // NOTE: array_key_exists important here, isset cannot be used because it would not detect if null is stored - if (array_key_exists($fieldName, $this->contextFieldsStack[$currentStashIndex])) { - if ('shop' === $fieldName) { - $this->restoreShopContext($currentStashIndex); - } - $this->context->$fieldName = $this->contextFieldsStack[$currentStashIndex][$fieldName]; - unset($this->contextFieldsStack[$currentStashIndex][$fieldName]); - } - } - - /** - * Restore the ShopContext, this is used when Shop has been overridden, we need to - * restore context->shop of course But also the static fields in Shop class - * - * @param int $currentStashIndex - */ - private function restoreShopContext(int $currentStashIndex): void - { - $shop = $this->contextFieldsStack[$currentStashIndex]['shop']; - $shopId = $shop instanceof Shop ? $shop->id : null; - $shopContext = $this->contextFieldsStack[$currentStashIndex]['shopContext']; - if (null !== $shopContext) { - Shop::setContext($shopContext, $shopId); - } - unset($this->contextFieldsStack[$currentStashIndex]['shopContext']); - } - - /** - * Removes the last saved stashed context, in case this method is called too many times - * we always keep one layer available - */ - private function removeLastSavedContext(): void - { - array_pop($this->contextFieldsStack); - - // Always keep at least one layer (in case we remove too many) - if (empty($this->contextFieldsStack)) { - $this->contextFieldsStack[] = []; - } - } -} diff --git a/src/Adapter/Converter/ExcelToCsvFileConverter.php b/src/Adapter/Converter/ExcelToCsvFileConverter.php deleted file mode 100644 index 96e83988..00000000 --- a/src/Adapter/Converter/ExcelToCsvFileConverter.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Converter; - -use PhpOffice\PhpSpreadsheet\IOFactory; -use PrestaShop\PrestaShop\Core\File\Converter\FileConverterInterface; -use SplFileInfo; -use Symfony\Component\Filesystem\Filesystem; - -/** - * Class ExcelToCsvFileConverter converts excel files to CSV. - */ -final class ExcelToCsvFileConverter implements FileConverterInterface -{ - /** - * @var Filesystem - */ - private $filesystem; - - /** - * @var string - */ - private $csvDirectory; - - /** - * @var string - */ - private $excelDirectory; - - /** - * @param Filesystem $filesystem - * @param string $csvDirectory path to CSV files directory - * @param string $excelDirectory path to excel files directory - */ - public function __construct(Filesystem $filesystem, $csvDirectory, $excelDirectory) - { - $this->filesystem = $filesystem; - $this->csvDirectory = $csvDirectory; - $this->excelDirectory = $excelDirectory; - } - - /** - * {@inheritdoc} - */ - public function convert(SplFileInfo $sourceFile) - { - if (preg_match('#(.*?)\.(csv)#is', $sourceFile->getFilename())) { - // File is already in CSV - return $sourceFile; - } - - if (!$this->filesystem->exists($this->excelDirectory)) { - $this->filesystem->mkdir($this->excelDirectory); - } - - $destinationFilename = basename($sourceFile->getFilename(), $sourceFile->getExtension()) . '.csv'; - $destinationFilePath = $this->excelDirectory . $destinationFilename; - - if (!$this->filesystem->exists($destinationFilePath)) { - $excelReader = IOFactory::createReaderForFile($sourceFile->getFilename()); - $excelReader->setReadDataOnly(true); - $excelFile = $excelReader->load($sourceFile->getFilename() . $destinationFilename); - $csvWriter = IOFactory::createWriter($excelFile, 'Csv'); - $csvWriter->setSheetIndex(0); - $csvWriter->setDelimiter(';'); - $csvWriter->save($destinationFilePath); - } - - return new SplFileInfo($destinationFilePath); - } -} diff --git a/src/Adapter/CoreException.php b/src/Adapter/CoreException.php deleted file mode 100644 index f4f772c0..00000000 --- a/src/Adapter/CoreException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -/** - * @todo: find why this class have been created and used. - */ -class CoreException extends \Exception -{ -} diff --git a/src/Adapter/Country/CountryDataProvider.php b/src/Adapter/Country/CountryDataProvider.php deleted file mode 100644 index 8ac35d4b..00000000 --- a/src/Adapter/Country/CountryDataProvider.php +++ /dev/null @@ -1,137 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Country; - -use Configuration; -use Country; -use Db; -use DbQuery; - -/** - * This class will provide data from DB / ORM about Country - */ -class CountryDataProvider -{ - /** - * Return available countries. - * - * @param int $id_lang Language ID - * @param bool $active return only active coutries - * @param bool $contain_states return only country with states - * @param bool $list_states Include the states list with the returned list - * - * @return array Countries and corresponding zones - */ - public function getCountries($id_lang, $active = false, $contain_states = false, $list_states = true) - { - return Country::getCountries($id_lang, $active, $contain_states, $list_states); - } - - /** - * Returns list of countries IDs which need DNI - * - * @return array - */ - public function getCountriesIdWhichNeedDni() - { - $query = new DbQuery(); - $query - ->select('c.`id_country`') - ->from('country', 'c') - ->where('c.`need_identification_number` = 1') - ; - $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query); - - return array_map(function ($country) { return $country['id_country']; }, $result); - } - - /** - * Returns list of countries IDs which need Postcode - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getCountriesIdWhichNeedPostcode() - { - $query = new DbQuery(); - $query - ->select('c.`id_country`') - ->from('country', 'c') - ->where('c.`need_zip_code` = 1') - ; - $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query); - - return array_map(function ($country) { return $country['id_country']; }, $result); - } - - /** - * Returns list of countries IDS which need a state - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getCountriesIdWhichNeedState() - { - $query = new DbQuery(); - $query - ->select('c.`id_country`') - ->from('country', 'c') - ->where('c.`contains_states` = 1') - ; - $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query); - - return array_map(function ($country) { return $country['id_country']; }, $result); - } - - /** - * Get Country IsoCode by Id. - * - * @param int $id Country Id - * - * @return string the related iso code - */ - public function getIsoCodebyId($id = null) - { - $countryId = (null === $id) ? Configuration::get('PS_COUNTRY_DEFAULT') : $id; - - return Country::getIsoById($countryId); - } - - /** - * Get country Id by ISO code. - * - * @param string $isoCode Country ISO code - * - * @return int - */ - public function getIdByIsoCode($isoCode) - { - return Country::getByIso($isoCode); - } -} diff --git a/src/Adapter/Country/CountryRequiredFieldsProvider.php b/src/Adapter/Country/CountryRequiredFieldsProvider.php deleted file mode 100644 index dbad18ec..00000000 --- a/src/Adapter/Country/CountryRequiredFieldsProvider.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Country; - -use PrestaShop\PrestaShop\Core\Country\CountryRequiredFieldsProviderInterface; -use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Country\ValueObject\CountryId; - -class CountryRequiredFieldsProvider implements CountryRequiredFieldsProviderInterface -{ - /** - * @var CountryDataProvider - */ - private $countryDataProvider; - - public function __construct(CountryDataProvider $countryDataProvider) - { - $this->countryDataProvider = $countryDataProvider; - } - - /** - * {@inheritdoc} - * - * @throws CountryNotFoundException - */ - public function isStatesRequired(CountryId $countryId): bool - { - $countries = $this->countryDataProvider->getCountriesIdWhichNeedState(); - - return in_array($countryId->getValue(), $countries); - } - - /** - * {@inheritdoc} - * - * @throws CountryNotFoundException - */ - public function isDniRequired(CountryId $countryId): bool - { - $countries = $this->countryDataProvider->getCountriesIdWhichNeedDni(); - - return in_array($countryId->getValue(), $countries); - } -} diff --git a/src/Adapter/Country/CountryZipCodeRequirementsProvider.php b/src/Adapter/Country/CountryZipCodeRequirementsProvider.php deleted file mode 100644 index c32700aa..00000000 --- a/src/Adapter/Country/CountryZipCodeRequirementsProvider.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Country; - -use Country; -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use PrestaShop\PrestaShop\Core\Country\CountryZipCodeRequirements; -use PrestaShop\PrestaShop\Core\Country\CountryZipCodeRequirementsProviderInterface; -use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Country\ValueObject\CountryId; -use PrestaShop\PrestaShop\Core\Domain\Country\ZipCodePatternResolver; -use PrestaShopException; - -final class CountryZipCodeRequirementsProvider implements CountryZipCodeRequirementsProviderInterface -{ - /** - * @var int - */ - private $langId; - - /** - * @var ZipCodePatternResolver - */ - private $patternResolver; - - /** - * @param LegacyContext $context - * @param ZipCodePatternResolver $patternResolver - */ - public function __construct(LegacyContext $context, ZipCodePatternResolver $patternResolver) - { - $this->langId = (int) $context->getLanguage()->id; - $this->patternResolver = $patternResolver; - } - - /** - * {@inheritdoc} - * - * @throws CountryNotFoundException - */ - public function getCountryZipCodeRequirements(CountryId $countryId): CountryZipCodeRequirements - { - $countryIdValue = $countryId->getValue(); - - try { - $country = new Country($countryIdValue); - } catch (PrestaShopException $e) { - throw new CountryNotFoundException(sprintf('Country with id "%s" was not found.', $countryIdValue)); - } - - if ($country->id !== $countryIdValue) { - throw new CountryNotFoundException(sprintf('Country with id "%s" was not found.', $countryIdValue)); - } - - $requirements = new CountryZipCodeRequirements($country->need_zip_code); - - if (isset($country->name[$this->langId])) { - $requirements->setCountryName($country->name[$this->langId]); - } - - if ($country->need_zip_code && !empty($country->zip_code_format)) { - $pattern = $this->patternResolver->getRegexPattern($country->zip_code_format, $country->iso_code); - $humanReadablePattern = $this->patternResolver->getHumanReadablePattern( - $country->zip_code_format, - $country->iso_code - ); - - $requirements->setPatterns($pattern, $humanReadablePattern); - } - - return $requirements; - } -} diff --git a/src/Adapter/Country/QueryHandler/GetCountryRequiredFieldsHandler.php b/src/Adapter/Country/QueryHandler/GetCountryRequiredFieldsHandler.php deleted file mode 100644 index 276d12cb..00000000 --- a/src/Adapter/Country/QueryHandler/GetCountryRequiredFieldsHandler.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Country\QueryHandler; - -use PrestaShop\PrestaShop\Core\Country\CountryRequiredFieldsProviderInterface; -use PrestaShop\PrestaShop\Core\Domain\Country\Query\GetCountryRequiredFields; -use PrestaShop\PrestaShop\Core\Domain\Country\QueryHandler\GetCountryRequiredFieldsHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Country\QueryResult\CountryRequiredFields; - -/** - * Handles and provides country state requirements - */ -final class GetCountryRequiredFieldsHandler implements GetCountryRequiredFieldsHandlerInterface -{ - /** @var CountryRequiredFieldsProviderInterface */ - private $requiredFieldsProvider; - - /** - * @param CountryRequiredFieldsProviderInterface $requiredFieldsProvider - */ - public function __construct(CountryRequiredFieldsProviderInterface $requiredFieldsProvider) - { - $this->requiredFieldsProvider = $requiredFieldsProvider; - } - - /** - * {@inheritdoc} - */ - public function handle(GetCountryRequiredFields $query): CountryRequiredFields - { - return new CountryRequiredFields( - $this->requiredFieldsProvider->isStatesRequired($query->getCountryId()), - $this->requiredFieldsProvider->isDniRequired($query->getCountryId()) - ); - } -} diff --git a/src/Adapter/CreditSlip/CreditSlipTemplateTypeProvider.php b/src/Adapter/CreditSlip/CreditSlipTemplateTypeProvider.php deleted file mode 100644 index 5e07f565..00000000 --- a/src/Adapter/CreditSlip/CreditSlipTemplateTypeProvider.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CreditSlip; - -use PDF; -use PrestaShop\PrestaShop\Core\PDF\PDFTemplateTypeProviderInterface; - -/** - * Provides credit slip PDF template type. - */ -final class CreditSlipTemplateTypeProvider implements PDFTemplateTypeProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getPDFTemplateType() - { - return PDF::TEMPLATE_ORDER_SLIP; - } -} diff --git a/src/Adapter/CreditSlip/QueryHandler/GetCreditSlipIdsByDateRangeHandler.php b/src/Adapter/CreditSlip/QueryHandler/GetCreditSlipIdsByDateRangeHandler.php deleted file mode 100644 index 6af8fd76..00000000 --- a/src/Adapter/CreditSlip/QueryHandler/GetCreditSlipIdsByDateRangeHandler.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CreditSlip\QueryHandler; - -use OrderSlip; -use PrestaShop\PrestaShop\Core\Domain\CreditSlip\Exception\CreditSlipException; -use PrestaShop\PrestaShop\Core\Domain\CreditSlip\Exception\CreditSlipNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\CreditSlip\Query\GetCreditSlipIdsByDateRange; -use PrestaShop\PrestaShop\Core\Domain\CreditSlip\QueryHandler\GetCreditSlipIdsByDateRangeHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CreditSlip\ValueObject\CreditSlipId; -use PrestaShopException; - -/** - * Handles query which gets CreditSlipIds by provided date range - */ -final class GetCreditSlipIdsByDateRangeHandler implements GetCreditSlipIdsByDateRangeHandlerInterface -{ - /** - * Handles the query using legacy object model - * - * {@inheritdoc} - */ - public function handle(GetCreditSlipIdsByDateRange $query) - { - try { - $from = $query->getDateTimeFrom()->format('Y-m-d'); - $to = $query->getDateTimeTo()->format('Y-m-d'); - $ids = OrderSlip::getSlipsIdByDate($from, $to); - - if (empty($ids)) { - throw new CreditSlipNotFoundException(sprintf('No credit slips found for date range "%s - %s"', $from, $to), CreditSlipNotFoundException::BY_DATE_RANGE); - } - - $creditSlipIds = []; - foreach ($ids as $id) { - $creditSlipIds[] = new CreditSlipId($id); - } - } catch (PrestaShopException $e) { - throw new CreditSlipException('Something went wrong when trying to get OrderSlip ids by date range', 0, $e); - } - - return $creditSlipIds; - } -} diff --git a/src/Adapter/Currency/CommandHandler/AbstractCurrencyHandler.php b/src/Adapter/Currency/CommandHandler/AbstractCurrencyHandler.php deleted file mode 100644 index 1c8581a6..00000000 --- a/src/Adapter/Currency/CommandHandler/AbstractCurrencyHandler.php +++ /dev/null @@ -1,281 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Currency\CommandHandler; - -use Currency; -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\AddCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\EditCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotCreateCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotUpdateCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; -use PrestaShop\PrestaShop\Core\Language\LanguageInterface; -use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleRepository; -use PrestaShop\PrestaShop\Core\Localization\Currency\PatternTransformer; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShopDatabaseException; -use PrestaShopException; - -/** - * Class AbstractCurrencyHandler is responsible for encapsulating common behavior for legacy currency object model. - * - * @internal - */ -abstract class AbstractCurrencyHandler extends AbstractObjectModelHandler -{ - /** - * @var LocaleRepository - */ - protected $localeRepoCLDR; - - /** - * @var LanguageInterface[] - */ - protected $languages; - - /** - * @var CurrencyCommandValidator - */ - protected $validator; - - /** - * @param LocaleRepository $localeRepoCLDR - * @param LanguageInterface[] $languages - * @param CurrencyCommandValidator $validator - */ - public function __construct( - LocaleRepository $localeRepoCLDR, - array $languages, - CurrencyCommandValidator $validator - ) { - $this->localeRepoCLDR = $localeRepoCLDR; - $this->languages = $languages; - $this->validator = $validator; - } - - /** - * Associations conversion rate to given shop ids. - * - * @param Currency $entity - * @param array $shopIds - */ - protected function associateConversionRateToShops(Currency $entity, array $shopIds) - { - $columnsToUpdate = []; - foreach ($shopIds as $shopId) { - $columnsToUpdate[$shopId] = [ - 'conversion_rate' => $entity->conversion_rate, - ]; - } - - $this->updateMultiStoreColumns($entity, $columnsToUpdate); - } - - /** - * @param Currency $entity - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - * @throws \PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException - */ - protected function refreshLocalizedData(Currency $entity) - { - $languagesData = []; - foreach ($this->languages as $language) { - $languagesData[] = [ - 'id_lang' => $language->getId(), - ]; - } - - //This method will insert the missing localized names/symbols and detect if the currency has been modified - $entity->refreshLocalizedCurrencyData($languagesData, $this->localeRepoCLDR); - } - - /** - * @param Currency $entity - * @param array $localizedTransformations - * - * @throws LanguageNotFoundException - */ - protected function applyPatternTransformations(Currency $entity, array $localizedTransformations) - { - $transformer = new PatternTransformer(); - $localizedPatterns = []; - foreach ($localizedTransformations as $langId => $transformationType) { - if (empty($transformationType)) { - continue; - } - - $languageCurrencyPattern = $this->getCurrencyPatternByLanguageId($langId); - $localizedPatterns[$langId] = $transformer->transform($languageCurrencyPattern, $transformationType); - } - $entity->setLocalizedPatterns($localizedPatterns); - } - - /** - * @param Currency $entity - * @param AddCurrencyCommand $command - * - * @throws CannotCreateCurrencyException - * @throws LanguageNotFoundException - * @throws LocalizationException - * @throws PrestaShopDatabaseException - * @throws PrestaShopException - */ - protected function addEntity(Currency $entity, AddCurrencyCommand $command) - { - $entity->iso_code = $command->getIsoCode()->getValue(); - $entity->active = $command->isEnabled(); - $entity->deleted = false; - $entity->conversion_rate = $command->getExchangeRate()->getValue(); - - // When creating a currency we reset the fields even if empty (then they will be generated by refreshLocalizedData) - $entity->setLocalizedNames($command->getLocalizedNames()); - $entity->setLocalizedSymbols($command->getLocalizedSymbols()); - $this->applyPatternTransformations($entity, $command->getLocalizedTransformations()); - - $this->refreshLocalizedData($entity); - $this->validateCurrency($entity); - - //IMPORTANT: specify that we want to save null values - if (false === $entity->save(true, true)) { - throw new CannotCreateCurrencyException('Failed to create new currency'); - } - - $this->associateWithShops($entity, $command->getShopIds()); - $this->associateConversionRateToShops($entity, $command->getShopIds()); - } - - /** - * @param Currency $entity - * @param EditCurrencyCommand $command - * - * @throws CannotUpdateCurrencyException - * @throws LanguageNotFoundException - * @throws LocalizationException - * @throws PrestaShopDatabaseException - * @throws PrestaShopException - */ - protected function updateEntity(Currency $entity, EditCurrencyCommand $command) - { - if (null !== $command->getExchangeRate()) { - $entity->conversion_rate = $command->getExchangeRate()->getValue(); - } - if (null !== $command->getPrecision()) { - $entity->precision = $command->getPrecision()->getValue(); - } - $entity->active = $command->isEnabled(); - - if (!empty($command->getLocalizedNames())) { - $entity->setLocalizedNames($command->getLocalizedNames()); - } - if (!empty($command->getLocalizedSymbols())) { - $entity->setLocalizedSymbols($command->getLocalizedSymbols()); - } - if (!empty($command->getLocalizedTransformations())) { - $this->applyPatternTransformations($entity, $command->getLocalizedTransformations()); - } - - $this->refreshLocalizedData($entity); - $this->validateCurrency($entity); - - //IMPORTANT: specify that we want to save null values - if (false === $entity->update(true)) { - throw new CannotUpdateCurrencyException( - sprintf( - 'An error occurred when updating currency object with id "%s"', - $command->getCurrencyId()->getValue() - ) - ); - } - - if (!empty($command->getShopIds())) { - $this->associateWithShops($entity, $command->getShopIds()); - $this->associateConversionRateToShops($entity, $command->getShopIds()); - } - } - - /** - * @param Currency $currency - * - * @throws CurrencyConstraintException - * @throws PrestaShopException - */ - private function validateCurrency(Currency $currency): void - { - $this->validateLocalizedField($currency, 'name', CurrencyConstraintException::INVALID_NAME); - $this->validateLocalizedField($currency, 'symbol', CurrencyConstraintException::INVALID_SYMBOL); - $this->validateLocalizedField($currency, 'pattern', CurrencyConstraintException::INVALID_SYMBOL); - } - - /** - * @param Currency $currency - * @param string $propertyName - * @param int $errorCode - * - * @throws CurrencyConstraintException - * @throws PrestaShopException - */ - private function validateLocalizedField(Currency $currency, string $propertyName, int $errorCode): void - { - $localizedValues = $currency->{$propertyName}; - - foreach ($localizedValues as $langId => $value) { - if (true !== $currency->validateField($propertyName, $value, $langId)) { - throw new CurrencyConstraintException( - sprintf( - 'Invalid Currency localized property "%s" for language with id "%d"', - $propertyName, - $langId - ), - $errorCode - ); - } - } - } - - /** - * @param int $langId - * - * @return string - * - * @throws LanguageNotFoundException - */ - private function getCurrencyPatternByLanguageId(int $langId) - { - /** @var LanguageInterface $language */ - foreach ($this->languages as $language) { - if ($langId === $language->getId()) { - return $this->localeRepoCLDR->getLocale($language->getLocale())->getCurrencyPattern(); - } - } - - throw new LanguageNotFoundException(new LanguageId($langId)); - } -} diff --git a/src/Adapter/Currency/CommandHandler/AddOfficialCurrencyHandler.php b/src/Adapter/Currency/CommandHandler/AddOfficialCurrencyHandler.php deleted file mode 100644 index e2d3a5e0..00000000 --- a/src/Adapter/Currency/CommandHandler/AddOfficialCurrencyHandler.php +++ /dev/null @@ -1,156 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Currency\CommandHandler; - -use PrestaShop\PrestaShop\Core\Currency\CurrencyDataProviderInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\AddCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\CommandHandler\AddCurrencyHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotCreateCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\CurrencyId; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageNotFoundException; -use PrestaShop\PrestaShop\Core\Language\LanguageInterface; -use PrestaShop\PrestaShop\Core\Localization\CLDR\Locale; -use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleRepository; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShopException; - -/** - * Adds a new currency. - * - * @internal - */ -final class AddOfficialCurrencyHandler extends AbstractCurrencyHandler implements AddCurrencyHandlerInterface -{ - /** - * @var CurrencyDataProviderInterface - */ - private $currencyDataProvider; - - /** - * @param LocaleRepository $localeRepoCLDR - * @param LanguageInterface[] $languages - * @param CurrencyCommandValidator $validator - * @param CurrencyDataProviderInterface $currencyDataProvider - */ - public function __construct( - LocaleRepository $localeRepoCLDR, - array $languages, - CurrencyCommandValidator $validator, - CurrencyDataProviderInterface $currencyDataProvider - ) { - parent::__construct($localeRepoCLDR, $languages, $validator); - $this->currencyDataProvider = $currencyDataProvider; - } - - /** - * {@inheritdoc} - * - * @throws CannotCreateCurrencyException - * @throws CurrencyConstraintException - * @throws CurrencyException - * @throws CurrencyNotFoundException - * @throws LocalizationException - * @throws LanguageNotFoundException - */ - public function handle(AddCurrencyCommand $command) - { - $this->validator->assertCurrencyIsNotAvailableInDatabase($command->getIsoCode()->getValue()); - - try { - $entity = $this->currencyDataProvider->getCurrencyByIsoCodeOrCreate($command->getIsoCode()->getValue()); - - $entity->unofficial = false; - $entity->numeric_iso_code = $this->findNumericIsoCodeFromAlphaCode($command->getIsoCode()->getValue()); - $entity->precision = $this->getPrecision($command); - - $this->addEntity($entity, $command); - } catch (PrestaShopException $exception) { - throw new CurrencyException('Failed to create new currency', 0, $exception); - } - - return new CurrencyId((int) $entity->id); - } - - /** - * @param AddCurrencyCommand $command - * - * @return int - */ - private function getPrecision(AddCurrencyCommand $command): int - { - if (null !== $command->getPrecision()) { - return $command->getPrecision()->getValue(); - } - - // CLDR locale give us the CLDR reference specification - $cldrLocale = $this->getCLDRLocale(); - // CLDR currency gives data from CLDR reference, for the given language - $cldrCurrency = $cldrLocale->getCurrency($command->getIsoCode()->getValue()); - - return $cldrCurrency->getDecimalDigits(); - } - - /** - * @param string $isoCode - * - * @return string - * - * @throws CurrencyNotFoundException - */ - private function findNumericIsoCodeFromAlphaCode($isoCode): string - { - $cldrLocale = $this->getCLDRLocale(); - $allCurrencies = $cldrLocale->getAllCurrencies(); - - $matchingRealCurrency = null; - foreach ($allCurrencies as $currencyData) { - if ($currencyData->getIsoCode() === $isoCode) { - return $currencyData->getNumericIsoCode(); - } - } - - throw new CurrencyNotFoundException(sprintf('ISO code "%s" does not match any currency in CLDR database', $isoCode)); - } - - /** - * Returns a CLDR locale, since they all contain the same info about currencies - * it doesn't matter which one is used so we return the one matching the first - * provided language. - * - * @return Locale - */ - private function getCLDRLocale() - { - /** @var LanguageInterface $language */ - $language = $this->languages[0]; - - return $this->localeRepoCLDR->getLocale($language->getLocale()); - } -} diff --git a/src/Adapter/Currency/CommandHandler/AddUnofficialCurrencyHandler.php b/src/Adapter/Currency/CommandHandler/AddUnofficialCurrencyHandler.php deleted file mode 100644 index f43e90d4..00000000 --- a/src/Adapter/Currency/CommandHandler/AddUnofficialCurrencyHandler.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Currency\CommandHandler; - -use PrestaShop\PrestaShop\Core\Currency\CurrencyDataProviderInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\AddUnofficialCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\CommandHandler\AddUnofficialCurrencyHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotCreateCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\InvalidUnofficialCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\CurrencyId; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageNotFoundException; -use PrestaShop\PrestaShop\Core\Language\LanguageInterface; -use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleRepository; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShopException; - -/** - * Adds a new unofficial currency. - * - * @internal - */ -final class AddUnofficialCurrencyHandler extends AbstractCurrencyHandler implements AddUnofficialCurrencyHandlerInterface -{ - /** - * @var CurrencyDataProviderInterface - */ - private $currencyDataProvider; - - /** - * @param LocaleRepository $localeRepoCLDR - * @param LanguageInterface[] $languages - * @param CurrencyCommandValidator $validator - * @param CurrencyDataProviderInterface $currencyDataProvider - */ - public function __construct( - LocaleRepository $localeRepoCLDR, - array $languages, - CurrencyCommandValidator $validator, - CurrencyDataProviderInterface $currencyDataProvider - ) { - parent::__construct($localeRepoCLDR, $languages, $validator); - $this->currencyDataProvider = $currencyDataProvider; - } - - /** - * {@inheritdoc} - * - * @throws CannotCreateCurrencyException - * @throws CurrencyException - * @throws CurrencyConstraintException - * @throws InvalidUnofficialCurrencyException - * @throws LanguageNotFoundException - * @throws LocalizationException - */ - public function handle(AddUnofficialCurrencyCommand $command) - { - $this->validator->assertCurrencyIsNotInReference($command->getIsoCode()->getValue()); - $this->validator->assertCurrencyIsNotAvailableInDatabase($command->getIsoCode()->getValue()); - - try { - $entity = $this->currencyDataProvider->getCurrencyByIsoCodeOrCreate($command->getIsoCode()->getValue()); - - $entity->unofficial = true; - $entity->numeric_iso_code = null; - if (null !== $command->getPrecision()) { - $entity->precision = $command->getPrecision()->getValue(); - } - - $this->addEntity($entity, $command); - } catch (PrestaShopException $exception) { - throw new CurrencyException('Failed to create new currency', 0, $exception); - } - - return new CurrencyId((int) $entity->id); - } -} diff --git a/src/Adapter/Currency/CommandHandler/CurrencyCommandValidator.php b/src/Adapter/Currency/CommandHandler/CurrencyCommandValidator.php deleted file mode 100644 index 93658b4f..00000000 --- a/src/Adapter/Currency/CommandHandler/CurrencyCommandValidator.php +++ /dev/null @@ -1,164 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Currency\CommandHandler; - -use Configuration; -use Currency; -use PrestaShop\PrestaShop\Core\Currency\CurrencyDataProviderInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\EditCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotDisableDefaultCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\DefaultCurrencyInMultiShopException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\InvalidUnofficialCurrencyException; -use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleRepository; -use Shop; - -/** - * Validates that modifications managed via currency commands are valid and respect this domain - * specific rules (avoid duplicate currencies, remove default currency, ...). - */ -final class CurrencyCommandValidator -{ - /** - * @var LocaleRepository - */ - private $localeRepoCLDR; - - /** - * @var CurrencyDataProviderInterface - */ - private $currencyDataProvider; - - /** - * @var int - */ - private $defaultCurrencyId; - - /** - * @param LocaleRepository $localeRepoCLDR - * @param CurrencyDataProviderInterface $currencyDataProvider - * @param int $defaultCurrencyId - */ - public function __construct( - LocaleRepository $localeRepoCLDR, - CurrencyDataProviderInterface $currencyDataProvider, - int $defaultCurrencyId - ) { - $this->localeRepoCLDR = $localeRepoCLDR; - $this->currencyDataProvider = $currencyDataProvider; - $this->defaultCurrencyId = $defaultCurrencyId; - } - - /** - * @param string $isoCode - * - * @throws InvalidUnofficialCurrencyException - */ - public function assertCurrencyIsNotInReference(string $isoCode) - { - /* - * Every locale has the same list of currencies (even those defined in only one language) so it - * doesn't matter which one is used to perform this check. - */ - $locale = $this->localeRepoCLDR->getLocale('en'); - $cldrCurrency = $locale->getCurrency($isoCode); - if (null !== $cldrCurrency) { - throw new InvalidUnofficialCurrencyException(sprintf('Unofficial currency with iso code "%s" is invalid because it matches a currency from CLDR database', $isoCode), $isoCode); - } - } - - /** - * Throws an error if currency is available in the database (soft deleted currencies don't count) - * - * @param string $isoCode - * - * @throws CurrencyConstraintException - */ - public function assertCurrencyIsNotAvailableInDatabase(string $isoCode) - { - $currency = $this->currencyDataProvider->getCurrencyByIsoCode($isoCode); - - if (null !== $currency && !$currency->deleted) { - throw new CurrencyConstraintException(sprintf('Currency with iso code "%s" already exists and cannot be created', $isoCode), CurrencyConstraintException::CURRENCY_ALREADY_EXISTS); - } - } - - /** - * Prevents from default currency being disabled. - * - * @param EditCurrencyCommand $command - * - * @throws CannotDisableDefaultCurrencyException - */ - public function assertDefaultCurrencyIsNotBeingDisabled(EditCurrencyCommand $command) - { - if (!$command->isEnabled() && $command->getCurrencyId()->getValue() === $this->defaultCurrencyId) { - throw new CannotDisableDefaultCurrencyException(sprintf('Currency with id "%s" is the default currency and cannot be disabled.', $command->getCurrencyId()->getValue())); - } - } - - /** - * On each shop there might be different default currency. This function prevents from removing shop association - * from each shop and checks that the shop is not being disabled as well. - * - * @param Currency $currency - * @param EditCurrencyCommand $command - * - * @throws DefaultCurrencyInMultiShopException - */ - public function assertDefaultCurrencyIsNotBeingRemovedOrDisabledFromShop(Currency $currency, EditCurrencyCommand $command) - { - if (empty($command->getShopIds())) { - return; - } - $shopIds = $command->getShopIds(); - $allShopIds = Shop::getShops(false, null, true); - - foreach ($allShopIds as $shopId) { - $shopDefaultCurrencyId = (int) Configuration::get( - 'PS_CURRENCY_DEFAULT', - null, - null, - $shopId - ); - - if ((int) $currency->id !== $shopDefaultCurrencyId) { - continue; - } - - if (!in_array($shopId, $shopIds)) { - $shop = new Shop($shopId); - throw new DefaultCurrencyInMultiShopException($currency->getName(), $shop->name, sprintf('Currency with id %s cannot be unassigned from shop with id %s because its the default currency.', $currency->id, $shopId), DefaultCurrencyInMultiShopException::CANNOT_REMOVE_CURRENCY); - } - - if (!$command->isEnabled()) { - $shop = new Shop($shopId); - throw new DefaultCurrencyInMultiShopException($currency->getName(), $shop->name, sprintf('Currency with id %s cannot be disabled from shop with id %s because its the default currency.', $currency->id, $shopId), DefaultCurrencyInMultiShopException::CANNOT_DISABLE_CURRENCY); - } - } - } -} diff --git a/src/Adapter/Currency/CommandHandler/DeleteCurrencyHandler.php b/src/Adapter/Currency/CommandHandler/DeleteCurrencyHandler.php deleted file mode 100644 index ab406115..00000000 --- a/src/Adapter/Currency/CommandHandler/DeleteCurrencyHandler.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Currency\CommandHandler; - -use Configuration; -use Currency; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\DeleteCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\CommandHandler\DeleteCurrencyHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotDeleteCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotDeleteDefaultCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\DefaultCurrencyInMultiShopException; -use PrestaShopException; -use Shop; - -/** - * Class DeleteCurrencyHandler is responsible for handling the deletion of currency logic. - * - * @internal - */ -final class DeleteCurrencyHandler implements DeleteCurrencyHandlerInterface -{ - /** - * @var int - */ - private $defaultCurrencyId; - - /** - * @param int $defaultCurrencyId - */ - public function __construct($defaultCurrencyId) - { - $this->defaultCurrencyId = (int) $defaultCurrencyId; - } - - /** - * {@inheritdoc} - * - * @throws CurrencyException - */ - public function handle(DeleteCurrencyCommand $command) - { - $entity = new Currency($command->getCurrencyId()->getValue()); - - if (0 >= $entity->id) { - throw new CurrencyNotFoundException(sprintf('Currency object with id "%s" has not been found for deletion.', $command->getCurrencyId()->getValue())); - } - - $this->assertDefaultCurrencyIsNotBeingRemoved($command->getCurrencyId()->getValue()); - $this->assertDefaultCurrencyIsNotBeingRemovedFromAnyShop($entity); - - try { - if (false === $entity->delete()) { - throw new CannotDeleteCurrencyException(sprintf('Unable to delete currency object with id "%s"', $command->getCurrencyId()->getValue())); - } - } catch (PrestaShopException $e) { - throw new CurrencyException(sprintf('An error occurred when deleting Currency object with id "%s"', $command->getCurrencyId()->getValue()), 0, $e); - } - } - - /** - * @param int $currencyId - * - * @throws CannotDeleteDefaultCurrencyException - */ - private function assertDefaultCurrencyIsNotBeingRemoved($currencyId) - { - if ($currencyId === $this->defaultCurrencyId) { - throw new CannotDeleteDefaultCurrencyException(sprintf('Currency with id "%s" is the default currency and cannot be deleted.', $currencyId)); - } - } - - /** - * Prevents from removing the currency from any shop context. - * - * @param Currency $currency - * - * @throws DefaultCurrencyInMultiShopException - */ - private function assertDefaultCurrencyIsNotBeingRemovedFromAnyShop(Currency $currency) - { - $allShopIds = Shop::getShops(false, null, true); - - foreach ($allShopIds as $shopId) { - $shopDefaultCurrencyId = (int) Configuration::get( - 'PS_CURRENCY_DEFAULT', - null, - null, - $shopId - ); - - if ((int) $currency->id !== $shopDefaultCurrencyId) { - continue; - } - - $shop = new Shop($shopId); - throw new DefaultCurrencyInMultiShopException($currency->name, $shop->name, sprintf('Currency with id %s cannot be removed from shop with id %s because its the default currency.', $currency->id, $shopId), DefaultCurrencyInMultiShopException::CANNOT_REMOVE_CURRENCY); - } - } -} diff --git a/src/Adapter/Currency/CommandHandler/EditOfficialCurrencyHandler.php b/src/Adapter/Currency/CommandHandler/EditOfficialCurrencyHandler.php deleted file mode 100644 index ee33f9cd..00000000 --- a/src/Adapter/Currency/CommandHandler/EditOfficialCurrencyHandler.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Currency\CommandHandler; - -use Currency; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\EditCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\CommandHandler\EditCurrencyHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotDisableDefaultCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotUpdateCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\DefaultCurrencyInMultiShopException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageNotFoundException; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShopException; - -/** - * Class EditOfficialCurrencyHandler is responsible for updating currencies. - * - * @internal - */ -final class EditOfficialCurrencyHandler extends AbstractCurrencyHandler implements EditCurrencyHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CannotDisableDefaultCurrencyException - * @throws CannotUpdateCurrencyException - * @throws CurrencyException - * @throws CurrencyNotFoundException - * @throws DefaultCurrencyInMultiShopException - * @throws LocalizationException - * @throws LanguageNotFoundException - */ - public function handle(EditCurrencyCommand $command) - { - try { - $entity = new Currency($command->getCurrencyId()->getValue()); - if (0 >= $entity->id) { - throw new CurrencyNotFoundException(sprintf('Currency object with id "%s" was not found for currency update', $command->getCurrencyId()->getValue())); - } - $this->verify($entity, $command); - $this->updateEntity($entity, $command); - } catch (PrestaShopException $exception) { - throw new CurrencyException(sprintf('An error occurred when updating currency object with id "%s"', $command->getCurrencyId()->getValue()), 0, $exception); - } - } - - /** - * @param Currency $entity - * @param EditCurrencyCommand $command - * - * @throws CannotDisableDefaultCurrencyException - * @throws DefaultCurrencyInMultiShopException - */ - private function verify(Currency $entity, EditCurrencyCommand $command) - { - $this->validator->assertDefaultCurrencyIsNotBeingDisabled($command); - $this->validator->assertDefaultCurrencyIsNotBeingRemovedOrDisabledFromShop($entity, $command); - } -} diff --git a/src/Adapter/Currency/CommandHandler/EditUnofficialCurrencyHandler.php b/src/Adapter/Currency/CommandHandler/EditUnofficialCurrencyHandler.php deleted file mode 100644 index 9205c282..00000000 --- a/src/Adapter/Currency/CommandHandler/EditUnofficialCurrencyHandler.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Currency\CommandHandler; - -use Currency; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\EditUnofficialCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\CommandHandler\EditUnofficialCurrencyHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotDisableDefaultCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotUpdateCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\DefaultCurrencyInMultiShopException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\InvalidUnofficialCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageNotFoundException; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShopException; - -/** - * Class EditUnofficialCurrencyHandler is responsible for updating unofficial currencies. - * - * @internal - */ -final class EditUnofficialCurrencyHandler extends AbstractCurrencyHandler implements EditUnofficialCurrencyHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CannotDisableDefaultCurrencyException - * @throws CannotUpdateCurrencyException - * @throws CurrencyException - * @throws CurrencyNotFoundException - * @throws DefaultCurrencyInMultiShopException - * @throws LocalizationException - * @throws LanguageNotFoundException - */ - public function handle(EditUnofficialCurrencyCommand $command) - { - try { - $entity = new Currency($command->getCurrencyId()->getValue()); - if (0 >= $entity->id) { - throw new CurrencyNotFoundException(sprintf('Currency object with id "%s" was not found for currency update', $command->getCurrencyId()->getValue())); - } - $this->verify($entity, $command); - - if (null !== $command->getIsoCode()) { - $entity->iso_code = $command->getIsoCode()->getValue(); - } - $this->updateEntity($entity, $command); - } catch (PrestaShopException $exception) { - throw new CurrencyException(sprintf('An error occurred when updating currency object with id "%s"', $command->getCurrencyId()->getValue()), 0, $exception); - } - } - - /** - * @param Currency $entity - * @param EditUnofficialCurrencyCommand $command - * - * @throws CannotDisableDefaultCurrencyException - * @throws CurrencyConstraintException - * @throws DefaultCurrencyInMultiShopException - * @throws InvalidUnofficialCurrencyException - */ - private function verify(Currency $entity, EditUnofficialCurrencyCommand $command) - { - $this->validator->assertDefaultCurrencyIsNotBeingDisabled($command); - if (null !== $command->getIsoCode()) { - $this->validator->assertCurrencyIsNotInReference($command->getIsoCode()->getValue()); - if ($entity->iso_code !== $command->getIsoCode()->getValue()) { - $this->validator->assertCurrencyIsNotAvailableInDatabase($command->getIsoCode()->getValue()); - } - } - $this->validator->assertDefaultCurrencyIsNotBeingRemovedOrDisabledFromShop($entity, $command); - } -} diff --git a/src/Adapter/Currency/CommandHandler/RefreshExchangeRatesHandler.php b/src/Adapter/Currency/CommandHandler/RefreshExchangeRatesHandler.php deleted file mode 100644 index c2cad8b8..00000000 --- a/src/Adapter/Currency/CommandHandler/RefreshExchangeRatesHandler.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Currency\CommandHandler; - -use Currency; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\RefreshExchangeRatesCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\CommandHandler\RefreshExchangeRatesHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotRefreshExchangeRatesException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; - -/** - * Class RefreshExchangeRatesHandler is responsible for refreshing currency exchange rates. - * - * @internal - */ -final class RefreshExchangeRatesHandler implements RefreshExchangeRatesHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CurrencyException - */ - public function handle(RefreshExchangeRatesCommand $command) - { - $error = Currency::refreshCurrencies(); - - if ($error) { - throw new CannotRefreshExchangeRatesException($error); - } - } -} diff --git a/src/Adapter/Currency/CommandHandler/ToggleCurrencyStatusHandler.php b/src/Adapter/Currency/CommandHandler/ToggleCurrencyStatusHandler.php deleted file mode 100644 index 6b125ff2..00000000 --- a/src/Adapter/Currency/CommandHandler/ToggleCurrencyStatusHandler.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Currency\CommandHandler; - -use Configuration; -use Currency; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\ToggleCurrencyStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\CommandHandler\ToggleCurrencyStatusHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotDisableDefaultCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotToggleCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\DefaultCurrencyInMultiShopException; -use PrestaShopException; -use Shop; - -/** - * Class ToggleCurrencyStatusHandler is responsible for toggling currency status. - * - * @internal - */ -final class ToggleCurrencyStatusHandler implements ToggleCurrencyStatusHandlerInterface -{ - /** - * @var int - */ - private $defaultCurrencyId; - - /** - * @param int $defaultCurrencyId - */ - public function __construct($defaultCurrencyId) - { - $this->defaultCurrencyId = (int) $defaultCurrencyId; - } - - /** - * {@inheritdoc} - * - * @throws CurrencyException - */ - public function handle(ToggleCurrencyStatusCommand $command) - { - $entity = new Currency($command->getCurrencyId()->getValue()); - - if (0 >= $entity->id) { - throw new CurrencyNotFoundException(sprintf('Currency object with id "%s" has not been found for toggling.', $command->getCurrencyId()->getValue())); - } - - if ($entity->active) { - $this->assertDefaultCurrencyIsNotBeingDisabled($entity); - $this->assertDefaultCurrencyIsNotBeingDisabledFromAnyShop($entity); - } - - try { - if (false === $entity->toggleStatus()) { - throw new CannotToggleCurrencyException(sprintf('Unable to toggle Currency with id "%s"', $command->getCurrencyId()->getValue())); - } - } catch (PrestaShopException $e) { - throw new CurrencyException(sprintf('An error occurred when toggling status for Currency object with id "%s"', $command->getCurrencyId()->getValue()), 0, $e); - } - } - - /** - * @param Currency $currency - * - * @throws CannotDisableDefaultCurrencyException - */ - private function assertDefaultCurrencyIsNotBeingDisabled(Currency $currency) - { - if ((int) $currency->id === $this->defaultCurrencyId) { - throw new CannotDisableDefaultCurrencyException(sprintf('Currency with id "%s" is the default currency and cannot be disabled.', $currency->id)); - } - } - - /** - * @param Currency $currency - * - * @throws DefaultCurrencyInMultiShopException - */ - private function assertDefaultCurrencyIsNotBeingDisabledFromAnyShop(Currency $currency) - { - $allShopIds = Shop::getShops(false, null, true); - - foreach ($allShopIds as $shopId) { - $shopDefaultCurrencyId = (int) Configuration::get( - 'PS_CURRENCY_DEFAULT', - null, - null, - $shopId - ); - - if ((int) $currency->id !== $shopDefaultCurrencyId) { - continue; - } - - $shop = new Shop($shopId); - throw new DefaultCurrencyInMultiShopException($currency->name, $shop->name, sprintf('Currency with id %s cannot be disabled from shop with id %s because its the default currency.', $currency->id, $shopId), DefaultCurrencyInMultiShopException::CANNOT_DISABLE_CURRENCY); - } - } -} diff --git a/src/Adapter/Currency/CommandHandler/ToggleExchangeRateAutomatizationHandler.php b/src/Adapter/Currency/CommandHandler/ToggleExchangeRateAutomatizationHandler.php deleted file mode 100644 index 90d457cd..00000000 --- a/src/Adapter/Currency/CommandHandler/ToggleExchangeRateAutomatizationHandler.php +++ /dev/null @@ -1,258 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Currency\CommandHandler; - -use CronJobs; -use Db; -use Exception; -use Module; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\Entity\DbQuery; -use PrestaShop\PrestaShop\Adapter\Shop\ShopUrlDataProvider; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\ToggleExchangeRateAutomatizationCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\CommandHandler\ToggleExchangeRateAutomatizationHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\AutomateExchangeRatesUpdateException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; -use PrestaShopException; -use Shop; -use Symfony\Component\Translation\TranslatorInterface; -use Tools; - -/** - * Class ToggleExchangeRateAutomatizationHandler is responsible for turning on or off the setting - if its on then - * in CronJobs module it creates new record with url which points to the script which is being executed at certain time - * of period. If the setting is off then it removes that record. - * - * @todo: an issue with multi-store cron task scheduler. - * - * @internal - */ -final class ToggleExchangeRateAutomatizationHandler implements ToggleExchangeRateAutomatizationHandlerInterface -{ - /** - * @var Configuration - */ - private $configuration; - - /** - * @var Shop - */ - private $contextShop; - - /** - * @var bool - */ - private $isCronJobModuleInstalled; - - /** - * @var ShopUrlDataProvider - */ - private $shopUrlDataProvider; - - /** - * @var string - */ - private $adminBaseUrl; - - /** - * @var string - */ - private $dbPrefix; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param Configuration $configuration - * @param Shop $contextShop - * @param ShopUrlDataProvider $shopUrlDataProvider - * @param TranslatorInterface $translator - * @param bool $isCronJobModuleInstalled - * @param string $adminBaseUrl - * @param string $dbPrefix - */ - public function __construct( - Configuration $configuration, - Shop $contextShop, - ShopUrlDataProvider $shopUrlDataProvider, - TranslatorInterface $translator, - $isCronJobModuleInstalled, - $adminBaseUrl, - $dbPrefix - ) { - $this->configuration = $configuration; - $this->contextShop = $contextShop; - $this->isCronJobModuleInstalled = $isCronJobModuleInstalled; - $this->shopUrlDataProvider = $shopUrlDataProvider; - $this->adminBaseUrl = $adminBaseUrl; - $this->dbPrefix = $dbPrefix; - $this->translator = $translator; - } - - /** - * {@inheritdoc} - * - * @throws CurrencyException - */ - public function handle(ToggleExchangeRateAutomatizationCommand $command) - { - if (!$this->isCronJobModuleInstalled) { - throw new AutomateExchangeRatesUpdateException('Live exchange rates feature cannot be modified because "cronjob" module is not installed', AutomateExchangeRatesUpdateException::CRON_TASK_MANAGER_MODULE_NOT_INSTALLED); - } - - $this->configuration->restrictUpdatesTo($this->contextShop); - - $cronId = (int) $this->configuration->get('PS_ACTIVE_CRONJOB_EXCHANGE_RATE'); - $thereIsOneCronRunning = ($cronId !== 0); - - try { - if ($thereIsOneCronRunning && $command->exchangeRateStatus()) { - $this->removeConfigurationIfNotFoundOrIsDeactivated($cronId); - - return; - } - - if (!$thereIsOneCronRunning && $command->exchangeRateStatus()) { - $this->enableExchangeRatesScheduler(); - - return; - } - - if ($thereIsOneCronRunning && !$command->exchangeRateStatus()) { - $this->disableExchangeRatesScheduler($cronId); - - return; - } - } catch (Exception $exception) { - throw new CurrencyException('An unexpected error occurred when trying to update live exchange rates', 0, $exception); - } - } - - /** - * @return string - * - * @throws PrestaShopException - */ - private function getCronUrl() - { - $protocol = Tools::getShopProtocol(); - $shopDomain = $this->shopUrlDataProvider->getMainShopUrl()->domain; - $cronFileLink = sprintf( - 'cron_currency_rates.php?secure_key=%s', - md5($this->configuration->get('_COOKIE_KEY_') . $this->configuration->get('PS_SHOP_NAME')) - ); - - return $protocol . $shopDomain . $this->adminBaseUrl . $cronFileLink; - } - - /** - * @param string $cronUrl - * - * @return bool - * - * @throws Exception - */ - private function createCronJob($cronUrl) - { - /** @var CronJobs $cronJobsModule */ - $cronJobsModule = Module::getInstanceByName('cronjobs'); - - $isCronAdded = $cronJobsModule->addOneShotTask( - $cronUrl, - $this->translator->trans( - 'Live exchange Rate for %shop_name%', - [ - '%shop_name%' => $this->configuration->get('PS_SHOP_NAME'), - ], - 'Admin.International.Feature' - ) - ); - - $this->configuration->set('PS_ACTIVE_CRONJOB_EXCHANGE_RATE', Db::getInstance()->Insert_ID()); - - return $isCronAdded; - } - - /** - * It checks if the given cronjob exists or is active. If it does not exist or it is not active when the configura - * tion value is being reset. - * - * @param int $cronId - * - * @throws Exception - */ - private function removeConfigurationIfNotFoundOrIsDeactivated($cronId) - { - $query = new DbQuery(); - $query - ->select('*') - ->from('cronjobs') - ->where('`id_cronjob`=' . (int) $cronId) - ; - - /** @var array $row */ - $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($query); - - if (!is_array($row) || empty($row['active'])) { - $this->configuration->set('PS_ACTIVE_CRONJOB_EXCHANGE_RATE', 0); - } - } - - /** - * Creates new cronjob for exchange rates auto update. - * - * @throws PrestaShopException - * @throws AutomateExchangeRatesUpdateException - * @throws Exception - */ - private function enableExchangeRatesScheduler() - { - $cronUrl = $this->getCronUrl(); - - if (false === $this->createCronJob($cronUrl)) { - throw new AutomateExchangeRatesUpdateException('Failed to create a cron task for live exchange rate update', AutomateExchangeRatesUpdateException::CRON_TASK_CREATION_FAILED); - } - } - - /** - * Removes given cronjob from configuration and also from cronjobs table. - * - * @param int $cronId - * - * @throws Exception - */ - private function disableExchangeRatesScheduler($cronId) - { - $this->configuration->set('PS_ACTIVE_CRONJOB_EXCHANGE_RATE', 0); - - Db::getInstance()->execute( - 'DELETE FROM ' . $this->dbPrefix . 'cronjobs WHERE `id_cronjob`=' . (int) $cronId - ); - } -} diff --git a/src/Adapter/Currency/CurrencyDataProvider.php b/src/Adapter/Currency/CurrencyDataProvider.php deleted file mode 100644 index 6e7282b0..00000000 --- a/src/Adapter/Currency/CurrencyDataProvider.php +++ /dev/null @@ -1,173 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Currency; - -use Currency; -use Exception; -use Language; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Currency\CurrencyDataProviderInterface; - -/** - * This class will provide data from DB / ORM about Currency. - */ -class CurrencyDataProvider implements CurrencyDataProviderInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var int - */ - private $shopId; - - /** @var Currency */ - private $defaultCurrency; - - /** - * @param ConfigurationInterface $configuration - * @param int $shopId - */ - public function __construct(ConfigurationInterface $configuration, $shopId) - { - $this->configuration = $configuration; - $this->shopId = $shopId; - } - - /** - * {@inheritdoc} - */ - public function getCurrencies($object = false, $active = true, $group_by = false) - { - return Currency::getCurrencies($object = false, $active = true, $group_by = false); - } - - /** - * {@inheritdoc} - */ - public function findAll($currentShopOnly = true) - { - return Currency::findAll(true, false, $currentShopOnly); - } - - /** - * {@inheritdoc} - */ - public function findAllInstalled() - { - return Currency::findAllInstalled(); - } - - /** - * {@inheritdoc} - */ - public function getCurrencyByIsoCode($isoCode, $idLang = null) - { - $currencyId = Currency::getIdByIsoCode($isoCode, 0, false, true); - if (!$currencyId) { - return null; - } - - if (empty($idLang)) { - $idLang = $this->configuration->get('PS_LANG_DEFAULT'); - } - - return new Currency($currencyId, $idLang); - } - - /** - * @param string $isoCode - * @param string $locale - * - * @return Currency|null - */ - public function getCurrencyByIsoCodeAndLocale($isoCode, $locale) - { - $idLang = Language::getIdByLocale($locale, true); - - return $this->getCurrencyByIsoCode($isoCode, $idLang); - } - - /** - * {@inheritdoc} - */ - public function getCurrencyByIsoCodeOrCreate($isoCode, $idLang = null) - { - // Soft deleted currencies are not kept duplicated any more, so if one try to recreate it the one in database is reused - $currency = $this->getCurrencyByIsoCode($isoCode, $idLang); - if (null === $currency) { - if (null === $idLang) { - $idLang = $this->configuration->get('PS_LANG_DEFAULT'); - } - $currency = new Currency(null, $idLang); - } - - return $currency; - } - - /** - * {@inheritdoc} - */ - public function saveCurrency(Currency $currencyEntity) - { - if (false === $currencyEntity->save()) { - throw new Exception('Failed saving Currency entity'); - } - } - - /** - * {@inheritdoc} - */ - public function getCurrencyById($currencyId) - { - return new Currency($currencyId); - } - - /** - * {@inheritdoc} - */ - public function getDefaultCurrencyIsoCode() - { - return $this->getDefaultCurrency()->iso_code; - } - - /** - * Returns default Currency set in Configuration - * - * @return Currency - */ - public function getDefaultCurrency() - { - if (null === $this->defaultCurrency) { - $this->defaultCurrency = new Currency((int) $this->configuration->get('PS_CURRENCY_DEFAULT'), null, $this->shopId); - } - - return $this->defaultCurrency; - } -} diff --git a/src/Adapter/Currency/CurrencyManager.php b/src/Adapter/Currency/CurrencyManager.php deleted file mode 100644 index 25d6f7d8..00000000 --- a/src/Adapter/Currency/CurrencyManager.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Currency; - -use Currency; -use ObjectModel; -use Shop; - -/** - * Class CurrencyManager is responsible for dealing with currency data using legacy classes. - */ -class CurrencyManager -{ - /** - * Updates currency data after default currency has changed. - */ - public function updateDefaultCurrency() - { - /* Set conversion rate of default currency to 1 */ - ObjectModel::updateMultishopTable('Currency', ['conversion_rate' => 1], 'a.id_currency'); - - $tmpContext = Shop::getContext(); - if ($tmpContext == Shop::CONTEXT_GROUP) { - $tmpShop = Shop::getContextShopGroupID(); - } else { - $tmpShop = (int) Shop::getContextShopID(); - } - - foreach (Shop::getContextListShopID() as $shopId) { - Shop::setContext(Shop::CONTEXT_SHOP, (int) $shopId); - Currency::refreshCurrencies(); - } - - Shop::setContext($tmpContext, $tmpShop); - } -} diff --git a/src/Adapter/Currency/QueryHandler/GetCurrencyExchangeRateHandler.php b/src/Adapter/Currency/QueryHandler/GetCurrencyExchangeRateHandler.php deleted file mode 100644 index 0520b9af..00000000 --- a/src/Adapter/Currency/QueryHandler/GetCurrencyExchangeRateHandler.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Currency\QueryHandler; - -use PrestaShop\PrestaShop\Core\Currency\Exception\CurrencyFeedException; -use PrestaShop\PrestaShop\Core\Currency\ExchangeRateProvider; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\ExchangeRateNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetCurrencyExchangeRate; -use PrestaShop\PrestaShop\Core\Domain\Currency\QueryHandler\GetCurrencyExchangeRateHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\QueryResult\ExchangeRate; - -/** - * Class GetCurrencyExchangeRateHandler handles the GetCurrencyExchangeRate query - * and returns the exchange rate of a specified currency via a ExchangeRate value object. - */ -class GetCurrencyExchangeRateHandler implements GetCurrencyExchangeRateHandlerInterface -{ - /** @var ExchangeRateProvider */ - private $exchangeRateProvider; - - /** - * @param ExchangeRateProvider $exchangeRateProvider - */ - public function __construct(ExchangeRateProvider $exchangeRateProvider) - { - $this->exchangeRateProvider = $exchangeRateProvider; - } - - /** - * {@inheritdoc} - */ - public function handle(GetCurrencyExchangeRate $query) - { - try { - $currencyExchangeRate = $this->exchangeRateProvider->getExchangeRate($query->getIsoCode()->getValue()); - } catch (CurrencyFeedException $e) { - throw new ExchangeRateNotFoundException(sprintf('Exchange rate for Currency with iso code %s was not found', $query->getIsoCode()->getValue()), 0, $e); - } - - return new ExchangeRate($currencyExchangeRate); - } -} diff --git a/src/Adapter/Currency/QueryHandler/GetCurrencyForEditingHandler.php b/src/Adapter/Currency/QueryHandler/GetCurrencyForEditingHandler.php deleted file mode 100644 index 95c2c2d7..00000000 --- a/src/Adapter/Currency/QueryHandler/GetCurrencyForEditingHandler.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Currency\QueryHandler; - -use Currency; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetCurrencyForEditing; -use PrestaShop\PrestaShop\Core\Domain\Currency\QueryHandler\GetCurrencyForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\QueryResult\EditableCurrency; -use PrestaShop\PrestaShop\Core\Localization\Currency\PatternTransformer; - -/** - * Class GetCurrencyForEditingHandler is responsible for retrieving required data used in currency form. - * - * @internal - */ -final class GetCurrencyForEditingHandler implements GetCurrencyForEditingHandlerInterface -{ - /** - * @var int - */ - private $contextShopId; - - /** - * @param int $contextShopId - */ - public function __construct($contextShopId) - { - $this->contextShopId = $contextShopId; - } - - /** - * {@inheritdoc} - */ - public function handle(GetCurrencyForEditing $query) - { - $entity = new Currency( - $query->getCurrencyId()->getValue(), - null, - $this->contextShopId - ); - - if (0 >= $entity->id) { - throw new CurrencyNotFoundException(sprintf('Currency object with id "%s" was not found for editing', $query->getCurrencyId()->getValue())); - } - - $transformer = new PatternTransformer(); - $transformations = []; - foreach ($entity->getLocalizedPatterns() as $langId => $pattern) { - $transformations[$langId] = !empty($pattern) ? $transformer->getTransformationType($pattern) : ''; - } - - return new EditableCurrency( - $entity->id, - $entity->iso_code, - $entity->getLocalizedNames(), - $entity->getLocalizedSymbols(), - $transformations, - $entity->conversion_rate, - $entity->precision, - $entity->active, - $entity->unofficial, - $entity->getAssociatedShops() - ); - } -} diff --git a/src/Adapter/Currency/QueryHandler/GetReferenceCurrencyHandler.php b/src/Adapter/Currency/QueryHandler/GetReferenceCurrencyHandler.php deleted file mode 100644 index 6b301675..00000000 --- a/src/Adapter/Currency/QueryHandler/GetReferenceCurrencyHandler.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Currency\QueryHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetReferenceCurrency; -use PrestaShop\PrestaShop\Core\Domain\Currency\QueryHandler\GetReferenceCurrencyHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\QueryResult\ReferenceCurrency; -use PrestaShop\PrestaShop\Core\Language\LanguageInterface; -use PrestaShop\PrestaShop\Core\Localization\CLDR\CurrencyInterface; -use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleRepository; - -class GetReferenceCurrencyHandler implements GetReferenceCurrencyHandlerInterface -{ - /** - * @var LocaleRepository - */ - private $localeRepository; - - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @var LanguageInterface[] - */ - private $languages; - - /** - * @param LocaleRepository $localeRepository - * @param CommandBusInterface $queryBus - * @param array $languages - */ - public function __construct( - LocaleRepository $localeRepository, - CommandBusInterface $queryBus, - array $languages - ) { - $this->localeRepository = $localeRepository; - $this->queryBus = $queryBus; - $this->languages = $languages; - } - - /** - * {@inheritdoc} - */ - public function handle(GetReferenceCurrency $query): ReferenceCurrency - { - $localizedNames = []; - $localizedSymbols = []; - $localizedPatterns = []; - $currency = null; - /** @var LanguageInterface $language */ - foreach ($this->languages as $language) { - $locale = $this->localeRepository->getLocale($language->getLocale()); - $localeCurrency = $locale->getCurrency($query->getIsoCode()->getValue()); - if (null !== $localeCurrency) { - $currency = $localeCurrency; - $localizedNames[$language->getId()] = $localeCurrency->getDisplayName(); - $localizedSymbols[$language->getId()] = $localeCurrency->getSymbol(CurrencyInterface::SYMBOL_TYPE_NARROW) ?: $localeCurrency->getIsoCode(); - } else { - $localizedNames[$language->getId()] = $query->getIsoCode()->getValue(); - $localizedSymbols[$language->getId()] = $query->getIsoCode()->getValue(); - } - $localizedPatterns[$language->getId()] = $locale->getCurrencyPattern(); - } - - if (null === $currency) { - throw new CurrencyNotFoundException(sprintf('Can not find reference currency with ISO code %s', $query->getIsoCode()->getValue())); - } - - return new ReferenceCurrency( - $currency->getIsoCode(), - $currency->getNumericIsoCode(), - $localizedNames, - $localizedSymbols, - $localizedPatterns, - $currency->getDecimalDigits() - ); - } -} diff --git a/src/Adapter/Customer/CommandHandler/AbstractCustomerHandler.php b/src/Adapter/Customer/CommandHandler/AbstractCustomerHandler.php deleted file mode 100644 index 5b34ea1d..00000000 --- a/src/Adapter/Customer/CommandHandler/AbstractCustomerHandler.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\CommandHandler; - -use Customer; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\MissingCustomerRequiredFieldsException; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Provides reusable methods for customer command handlers. - * - * @internal - */ -abstract class AbstractCustomerHandler -{ - /** - * @param CustomerId $customerId - * @param Customer $customer - * - * @throws CustomerNotFoundException - */ - protected function assertCustomerWasFound(CustomerId $customerId, Customer $customer) - { - if ($customer->id !== $customerId->getValue()) { - throw new CustomerNotFoundException($customerId, sprintf('Customer with id "%s" was not found.', $customerId->getValue())); - } - } - - /** - * @param Customer $customer - * - * @throws MissingCustomerRequiredFieldsException - */ - protected function assertRequiredFieldsAreNotMissing(Customer $customer) - { - $errors = $customer->validateFieldsRequiredDatabase(); - - if (!empty($errors)) { - $missingFields = array_keys($errors); - - throw new MissingCustomerRequiredFieldsException($missingFields, sprintf('One or more required fields for customer are missing. Missing fields are: %s', implode(',', $missingFields))); - } - } -} diff --git a/src/Adapter/Customer/CommandHandler/AddCustomerHandler.php b/src/Adapter/Customer/CommandHandler/AddCustomerHandler.php deleted file mode 100644 index 7572933e..00000000 --- a/src/Adapter/Customer/CommandHandler/AddCustomerHandler.php +++ /dev/null @@ -1,153 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\CommandHandler; - -use Customer; -use PrestaShop\PrestaShop\Core\Crypto\Hashing; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\AddCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler\AddCustomerHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerDefaultGroupAccessException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\DuplicateCustomerEmailException; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\RequiredField; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -/** - * Handles command that adds new customer - * - * @internal - */ -final class AddCustomerHandler extends AbstractCustomerHandler implements AddCustomerHandlerInterface -{ - /** - * @var Hashing - */ - private $hashing; - - /** - * @var string Value of legacy _COOKIE_KEY_ - */ - private $legacyCookieKey; - - /** - * @param Hashing $hashing - * @param string $legacyCookieKey - */ - public function __construct(Hashing $hashing, $legacyCookieKey) - { - $this->hashing = $hashing; - $this->legacyCookieKey = $legacyCookieKey; - } - - /** - * {@inheritdoc} - */ - public function handle(AddCustomerCommand $command) - { - $customer = new Customer(); - - $this->fillCustomerWithCommandData($customer, $command); - - // validateFieldsRequiredDatabase() below is using $_POST - // to check if required fields are set - $_POST[RequiredField::PARTNER_OFFERS] = $command->isPartnerOffersSubscribed(); - - $this->assertRequiredFieldsAreNotMissing($customer); - - if (false === $customer->validateFields(false)) { - throw new CustomerException('Customer contains invalid field values'); - } - - $this->assertCustomerWithGivenEmailDoesNotExist($command->getEmail()); - $this->assertCustomerCanAccessDefaultGroup($command); - - $customer->add(); - - return new CustomerId((int) $customer->id); - } - - /** - * @param Email $email - */ - private function assertCustomerWithGivenEmailDoesNotExist(Email $email) - { - $customer = new Customer(); - $customer->getByEmail($email->getValue()); - - if ($customer->id) { - throw new DuplicateCustomerEmailException($email, sprintf('Customer with email "%s" already exists', $email->getValue())); - } - } - - /** - * @param Customer $customer - * @param AddCustomerCommand $command - */ - private function fillCustomerWithCommandData(Customer $customer, AddCustomerCommand $command) - { - $apeCode = null !== $command->getApeCode() ? - $command->getApeCode()->getValue() : - null; - - $hashedPassword = $this->hashing->hash( - $command->getPassword()->getValue(), - $this->legacyCookieKey - ); - - $customer->firstname = $command->getFirstName()->getValue(); - $customer->lastname = $command->getLastName()->getValue(); - $customer->email = $command->getEmail()->getValue(); - $customer->passwd = $hashedPassword; - $customer->id_default_group = $command->getDefaultGroupId(); - $customer->groupBox = $command->getGroupIds(); - $customer->id_gender = $command->getGenderId(); - $customer->active = $command->isEnabled(); - $customer->optin = $command->isPartnerOffersSubscribed(); - $customer->birthday = $command->getBirthday()->getValue(); - $customer->id_shop = $command->getShopId(); - - // fill b2b customer fields - $customer->company = $command->getCompanyName(); - $customer->siret = $command->getSiretCode(); - $customer->ape = $apeCode; - $customer->website = $command->getWebsite(); - $customer->outstanding_allow_amount = $command->getAllowedOutstandingAmount(); - $customer->max_payment_days = $command->getMaxPaymentDays(); - $customer->id_risk = $command->getRiskId(); - } - - /** - * @param AddCustomerCommand $command - */ - private function assertCustomerCanAccessDefaultGroup(AddCustomerCommand $command) - { - if (!in_array($command->getDefaultGroupId(), $command->getGroupIds())) { - throw new CustomerDefaultGroupAccessException(sprintf('Customer default group with id "%s" must be in access groups', $command->getDefaultGroupId())); - } - } -} diff --git a/src/Adapter/Customer/CommandHandler/BulkDeleteCustomerHandler.php b/src/Adapter/Customer/CommandHandler/BulkDeleteCustomerHandler.php deleted file mode 100644 index d4c92197..00000000 --- a/src/Adapter/Customer/CommandHandler/BulkDeleteCustomerHandler.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\CommandHandler; - -use Customer; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\BulkDeleteCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler\BulkDeleteCustomerHandlerInterface; - -/** - * Handles command that deletes customers in bulk action. - * - * @internal - */ -final class BulkDeleteCustomerHandler extends AbstractCustomerHandler implements BulkDeleteCustomerHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(BulkDeleteCustomerCommand $command) - { - foreach ($command->getCustomerIds() as $customerId) { - $customer = new Customer($customerId->getValue()); - - $this->assertCustomerWasFound($customerId, $customer); - - if ($command->getDeleteMethod()->isAllowedToRegisterAfterDelete()) { - $customer->delete(); - - continue; - } - - $customer->deleted = 1; - $customer->update(); - } - } -} diff --git a/src/Adapter/Customer/CommandHandler/BulkDisableCustomerHandler.php b/src/Adapter/Customer/CommandHandler/BulkDisableCustomerHandler.php deleted file mode 100644 index d69e760a..00000000 --- a/src/Adapter/Customer/CommandHandler/BulkDisableCustomerHandler.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\CommandHandler; - -use Customer; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\BulkDisableCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler\BulkDisableCustomerHandlerInterface; - -/** - * Handles command that disables customers in bulk action. - * - * @internal - */ -final class BulkDisableCustomerHandler extends AbstractCustomerHandler implements BulkDisableCustomerHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(BulkDisableCustomerCommand $command) - { - foreach ($command->getCustomerIds() as $customerId) { - $customer = new Customer($customerId->getValue()); - - $this->assertCustomerWasFound($customerId, $customer); - - $customer->active = false; - $customer->update(); - } - } -} diff --git a/src/Adapter/Customer/CommandHandler/BulkEnableCustomerHandler.php b/src/Adapter/Customer/CommandHandler/BulkEnableCustomerHandler.php deleted file mode 100644 index 444db4f0..00000000 --- a/src/Adapter/Customer/CommandHandler/BulkEnableCustomerHandler.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\CommandHandler; - -use Customer; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\BulkEnableCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler\BulkEnableCustomerHandlerInterface; - -/** - * Handles command which enables given customers. - * - * @internal - */ -final class BulkEnableCustomerHandler extends AbstractCustomerHandler implements BulkEnableCustomerHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(BulkEnableCustomerCommand $command) - { - foreach ($command->getCustomerIds() as $customerId) { - $customer = new Customer($customerId->getValue()); - - $this->assertCustomerWasFound($customerId, $customer); - - $customer->active = true; - $customer->update(); - } - } -} diff --git a/src/Adapter/Customer/CommandHandler/DeleteCustomerHandler.php b/src/Adapter/Customer/CommandHandler/DeleteCustomerHandler.php deleted file mode 100644 index 8745beed..00000000 --- a/src/Adapter/Customer/CommandHandler/DeleteCustomerHandler.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\CommandHandler; - -use Customer; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\DeleteCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler\DeleteCustomerHandlerInterface; - -/** - * Handles delete customer command. - * - * @internal - */ -final class DeleteCustomerHandler extends AbstractCustomerHandler implements DeleteCustomerHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(DeleteCustomerCommand $command) - { - $customerId = $command->getCustomerId(); - $customer = new Customer($customerId->getValue()); - - $this->assertCustomerWasFound($customerId, $customer); - - if ($command->getDeleteMethod()->isAllowedToRegisterAfterDelete()) { - $customer->delete(); - - return; - } - - // soft delete customer - // in order to forbid signing in again - $customer->deleted = 1; - $customer->update(); - } -} diff --git a/src/Adapter/Customer/CommandHandler/EditCustomerHandler.php b/src/Adapter/Customer/CommandHandler/EditCustomerHandler.php deleted file mode 100644 index f67af963..00000000 --- a/src/Adapter/Customer/CommandHandler/EditCustomerHandler.php +++ /dev/null @@ -1,254 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\CommandHandler; - -use Customer; -use PrestaShop\PrestaShop\Core\Crypto\Hashing; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\EditCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler\EditCustomerHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerDefaultGroupAccessException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\DuplicateCustomerEmailException; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\RequiredField; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -/** - * Handles commands which edits given customer with provided data. - * - * @internal - */ -final class EditCustomerHandler extends AbstractCustomerHandler implements EditCustomerHandlerInterface -{ - /** - * @var Hashing - */ - private $hashing; - - /** - * @var string Value of legacy _COOKIE_KEY_ - */ - private $legacyCookieKey; - - /** - * @param Hashing $hashing - * @param string $legacyCookieKey - */ - public function __construct(Hashing $hashing, $legacyCookieKey) - { - $this->hashing = $hashing; - $this->legacyCookieKey = $legacyCookieKey; - } - - /** - * {@inheritdoc} - */ - public function handle(EditCustomerCommand $command) - { - $customerId = $command->getCustomerId(); - $customer = new Customer($customerId->getValue()); - - $this->assertCustomerWasFound($customerId, $customer); - - $this->assertCustomerWithUpdatedEmailDoesNotExist($customer, $command); - $this->assertCustomerCanAccessDefaultGroup($customer, $command); - - $this->updateCustomerWithCommandData($customer, $command); - - // validateFieldsRequiredDatabase() below is using $_POST - // to check if required fields are set - if ($command->isPartnerOffersSubscribed() !== null) { - $_POST[RequiredField::PARTNER_OFFERS] = $command->isPartnerOffersSubscribed(); - } elseif ($command->isNewsletterSubscribed() !== null) { - $_POST[RequiredField::NEWSLETTER] = $command->isNewsletterSubscribed(); - } - - // before validation, we need to get the list of customer mandatory fields from the database - // and set their current values (only if it is not being modified: if it is not in $_POST) - $requiredFields = $customer->getFieldsRequiredDatabase(); - foreach ($requiredFields as $field) { - if (!array_key_exists($field['field_name'], $_POST)) { - $_POST[$field['field_name']] = $customer->{$field['field_name']}; - } - } - - $this->assertRequiredFieldsAreNotMissing($customer); - - if (false === $customer->validateFields(false)) { - throw new CustomerException('Customer contains invalid field values'); - } - - if (false === $customer->update()) { - throw new CustomerException('Failed to update customer'); - } - } - - /** - * @param Customer $customer - * @param EditCustomerCommand $command - */ - private function updateCustomerWithCommandData(Customer $customer, EditCustomerCommand $command) - { - if (null !== $command->getGenderId()) { - $customer->id_gender = $command->getGenderId(); - } - - if (null !== $command->getFirstName()) { - $customer->firstname = $command->getFirstName()->getValue(); - } - - if (null !== $command->getLastName()) { - $customer->lastname = $command->getLastName()->getValue(); - } - - if (null !== $command->getEmail()) { - $customer->email = $command->getEmail()->getValue(); - } - - if (null !== $command->getPassword()) { - $hashedPassword = $this->hashing->hash( - $command->getPassword()->getValue(), - $this->legacyCookieKey - ); - - $customer->passwd = $hashedPassword; - } - - if (null !== $command->getBirthday()) { - $customer->birthday = $command->getBirthday()->getValue(); - } - - if (null !== $command->isEnabled()) { - $customer->active = $command->isEnabled(); - } - - if (null !== $command->isPartnerOffersSubscribed()) { - $customer->optin = $command->isPartnerOffersSubscribed(); - } - - if (null !== $command->getGroupIds()) { - $customer->groupBox = $command->getGroupIds(); - } - - if (null !== $command->getDefaultGroupId()) { - $customer->id_default_group = $command->getDefaultGroupId(); - } - - if (null !== $command->isNewsletterSubscribed()) { - $customer->newsletter = $command->isNewsletterSubscribed(); - } - - $this->updateCustomerB2bData($customer, $command); - } - - /** - * @param Customer $customer - * @param EditCustomerCommand $command - */ - private function updateCustomerB2bData(Customer $customer, EditCustomerCommand $command) - { - if (null !== $command->getCompanyName()) { - $customer->company = $command->getCompanyName(); - } - - if (null !== $command->getSiretCode()) { - $customer->siret = $command->getSiretCode(); - } - - if (null !== $command->getApeCode()) { - $customer->ape = $command->getApeCode()->getValue(); - } - - if (null !== $command->getWebsite()) { - $customer->website = $command->getWebsite(); - } - - if (null !== $command->getAllowedOutstandingAmount()) { - $customer->outstanding_allow_amount = $command->getAllowedOutstandingAmount(); - } - - if (null !== $command->getMaxPaymentDays()) { - $customer->max_payment_days = $command->getMaxPaymentDays(); - } - - if (null !== $command->getRiskId()) { - $customer->id_risk = $command->getRiskId(); - } - } - - /** - * @param Customer $customer - * @param EditCustomerCommand $command - */ - private function assertCustomerWithUpdatedEmailDoesNotExist(Customer $customer, EditCustomerCommand $command) - { - // if email is not being updated - // then assertion is not needed - if (null === $command->getEmail()) { - return; - } - - if ($command->getEmail()->isEqualTo(new Email($customer->email))) { - return; - } - - $customerByEmail = new Customer(); - $customerByEmail->getByEmail($command->getEmail()->getValue()); - - if ($customerByEmail->id) { - throw new DuplicateCustomerEmailException($command->getEmail(), sprintf('Customer with email "%s" already exists', $command->getEmail()->getValue())); - } - } - - /** - * @param Customer $customer - * @param EditCustomerCommand $command - */ - private function assertCustomerCanAccessDefaultGroup(Customer $customer, EditCustomerCommand $command) - { - // if neither default group - // nor group ids are being edited - // then no need to assert - if (null === $command->getDefaultGroupId() - || null === $command->getGroupIds() - ) { - return; - } - - $defaultGroupId = null !== $command->getDefaultGroupId() ? - $command->getDefaultGroupId() : - $customer->id_default_group - ; - $groupIds = null !== $command->getGroupIds() ? - $command->getGroupIds() : - $customer->getGroups() - ; - - if (!in_array($defaultGroupId, $groupIds)) { - throw new CustomerDefaultGroupAccessException(sprintf('Customer default group with id "%s" must be in access groups', $command->getDefaultGroupId())); - } - } -} diff --git a/src/Adapter/Customer/CommandHandler/SetPrivateNoteAboutCustomerHandler.php b/src/Adapter/Customer/CommandHandler/SetPrivateNoteAboutCustomerHandler.php deleted file mode 100644 index 5d9e01aa..00000000 --- a/src/Adapter/Customer/CommandHandler/SetPrivateNoteAboutCustomerHandler.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\CommandHandler; - -use Customer; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\SetPrivateNoteAboutCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler\SetPrivateNoteAboutCustomerHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerNotFoundException; - -/** - * Handles command that saves private note for customer - * - * @internal - */ -final class SetPrivateNoteAboutCustomerHandler implements SetPrivateNoteAboutCustomerHandlerInterface -{ - /** - * @param SetPrivateNoteAboutCustomerCommand $command - */ - public function handle(SetPrivateNoteAboutCustomerCommand $command) - { - $customerId = $command->getCustomerId(); - $customer = new Customer($customerId->getValue()); - - if ($customer->id !== $customerId->getValue()) { - throw new CustomerNotFoundException($customerId, sprintf('Customer with id "%s" was not found.', $customerId->getValue())); - } - - $customer->note = $command->getPrivateNote(); - $customer->update(); - } -} diff --git a/src/Adapter/Customer/CommandHandler/SetRequiredFieldsForCustomerHandler.php b/src/Adapter/Customer/CommandHandler/SetRequiredFieldsForCustomerHandler.php deleted file mode 100644 index 0080481f..00000000 --- a/src/Adapter/Customer/CommandHandler/SetRequiredFieldsForCustomerHandler.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\CommandHandler; - -use Customer; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\SetRequiredFieldsForCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler\SetRequiredFieldsForCustomerHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CannotSetRequiredFieldsForCustomerException; - -/** - * Handles command which sets required fields for customer. - * - * @internal - */ -final class SetRequiredFieldsForCustomerHandler implements SetRequiredFieldsForCustomerHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(SetRequiredFieldsForCustomerCommand $command) - { - $customer = new Customer(); - - if (!$customer->addFieldsRequiredDatabase($command->getRequiredFields())) { - throw new CannotSetRequiredFieldsForCustomerException(sprintf('Cannot set "%s" required fields for customer', implode(',', $command->getRequiredFields()))); - } - } -} diff --git a/src/Adapter/Customer/CommandHandler/TransformGuestToCustomerHandler.php b/src/Adapter/Customer/CommandHandler/TransformGuestToCustomerHandler.php deleted file mode 100644 index d6c3e4f3..00000000 --- a/src/Adapter/Customer/CommandHandler/TransformGuestToCustomerHandler.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\CommandHandler; - -use Customer; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\TransformGuestToCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler\TransformGuestToCustomerHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerTransformationException; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Handles guest to customer transformation command - * - * @internal - */ -final class TransformGuestToCustomerHandler implements TransformGuestToCustomerHandlerInterface -{ - /** - * @var int - */ - private $contextLangId; - - /** - * @param int $contextLangId - */ - public function __construct($contextLangId) - { - $this->contextLangId = $contextLangId; - } - - /** - * @param TransformGuestToCustomerCommand $command - */ - public function handle(TransformGuestToCustomerCommand $command) - { - $customerId = $command->getCustomerId(); - $customer = new Customer($customerId->getValue()); - - $this->assertCustomerExists($customerId, $customer); - $this->assertCustomerIsGuest($customer); - - if (!$customer->transformToCustomer($this->contextLangId)) { - throw new CustomerTransformationException(sprintf('Failed to transform guest into customer'), CustomerTransformationException::TRANSFORMATION_FAILED); - } - } - - /** - * @param CustomerId $customerId - * @param Customer $customer - * - * @throws CustomerNotFoundException - */ - private function assertCustomerExists(CustomerId $customerId, Customer $customer) - { - if ($customer->id !== $customerId->getValue()) { - throw new CustomerNotFoundException($customerId, sprintf('Customer with id "%s" was not found', $customerId->getValue())); - } - } - - /** - * @param Customer $customer - * - * @throws CustomerTransformationException - */ - private function assertCustomerIsGuest(Customer $customer) - { - if (Customer::customerExists($customer->email)) { - throw new CustomerTransformationException(sprintf('Customer with id "%s" already exists as non-guest', $customer->id), CustomerTransformationException::CUSTOMER_IS_NOT_GUEST); - } - } -} diff --git a/src/Adapter/Customer/CustomerConfiguration.php b/src/Adapter/Customer/CustomerConfiguration.php deleted file mode 100644 index cfc08d34..00000000 --- a/src/Adapter/Customer/CustomerConfiguration.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * Class CustomerConfiguration is responsible for saving & loading customer configuration. - */ -class CustomerConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'redisplay_cart_at_login' => $this->configuration->getBoolean('PS_CART_FOLLOWING'), - 'send_email_after_registration' => $this->configuration->getBoolean('PS_CUSTOMER_CREATION_EMAIL'), - 'password_reset_delay' => $this->configuration->getInt('PS_PASSWD_TIME_FRONT'), - 'enable_b2b_mode' => $this->configuration->getBoolean('PS_B2B_ENABLE'), - 'ask_for_birthday' => $this->configuration->getBoolean('PS_CUSTOMER_BIRTHDATE'), - 'enable_offers' => $this->configuration->getBoolean('PS_CUSTOMER_OPTIN'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $config) - { - if ($this->validateConfiguration($config)) { - $this->configuration->set('PS_CART_FOLLOWING', (int) $config['redisplay_cart_at_login']); - $this->configuration->set('PS_CUSTOMER_CREATION_EMAIL', (int) $config['send_email_after_registration']); - $this->configuration->set('PS_PASSWD_TIME_FRONT', (int) $config['password_reset_delay']); - $this->configuration->set('PS_B2B_ENABLE', (int) $config['enable_b2b_mode']); - $this->configuration->set('PS_CUSTOMER_BIRTHDATE', (int) $config['ask_for_birthday']); - $this->configuration->set('PS_CUSTOMER_OPTIN', (int) $config['enable_offers']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $config) - { - return isset( - $config['redisplay_cart_at_login'], - $config['send_email_after_registration'], - $config['password_reset_delay'], - $config['enable_b2b_mode'], - $config['ask_for_birthday'], - $config['enable_offers'] - ); - } -} diff --git a/src/Adapter/Customer/CustomerDataProvider.php b/src/Adapter/Customer/CustomerDataProvider.php deleted file mode 100644 index 736ea74e..00000000 --- a/src/Adapter/Customer/CustomerDataProvider.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer; - -use Customer; -use Db; -use Symfony\Component\Process\Exception\LogicException; - -/** - * This class will provide data from DB / ORM about Customer. - */ -class CustomerDataProvider -{ - /** - * @param int $id - * - * @throws LogicException If the customer id is not set - * - * @return object customer - */ - public function getCustomer($id) - { - if (!$id) { - throw new LogicException('You need to provide a customer id', null, 5002); - } - - $customer = new Customer($id); - - return $customer; - } - - public function getIdByEmail(string $email) - { - $id = null; - $customers = Customer::getCustomersByEmail($email); - if (!empty($customers)) { - $id = current($customers)['id_customer']; - } - - return $id; - } - - /** - * @param int $customerId - * @param int $langId - * - * @return array - */ - public function getCustomerAddresses($customerId, $langId) - { - $customer = $this->getCustomer($customerId); - - return $customer->getAddresses($langId); - } - - /** - * Get Default Customer Group ID. - * - * @param int $idCustomer Customer ID - * - * @return mixed|string|null - */ - public function getDefaultGroupId($idCustomer) - { - return Customer::getDefaultGroupId($idCustomer); - } - - /** - * Provides customer messages - * - * @param int $customerId - */ - public function getCustomerMessages(int $customerId, ?int $orderId = null, ?int $limit = null) - { - $mainSql = 'SELECT cm.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, - e.`firstname` AS efirstname, e.`lastname` AS elastname - FROM ' . _DB_PREFIX_ . 'customer_thread ct - LEFT JOIN ' . _DB_PREFIX_ . 'customer_message cm - ON ct.id_customer_thread = cm.id_customer_thread - LEFT JOIN `' . _DB_PREFIX_ . 'customer` c - ON ct.`id_customer` = c.`id_customer` - LEFT OUTER JOIN `' . _DB_PREFIX_ . 'employee` e - ON e.`id_employee` = cm.`id_employee` - WHERE ct.id_customer = ' . $customerId; - - if ($orderId) { - $mainSql .= ' AND ct.`id_order` = ' . $orderId; - } - - $mainSql .= ' GROUP BY cm.id_customer_message - ORDER BY cm.date_add DESC'; - - $count = Db::getInstance()->executeS("SELECT COUNT(*) AS total FROM ($mainSql) AS messages"); - - if ($limit) { - $mainSql .= " LIMIT $limit"; - } - - return [ - 'total' => empty($count) ? 0 : (int) $count[0]['total'], - 'messages' => Db::getInstance()->executeS($mainSql), - ]; - } -} diff --git a/src/Adapter/Customer/CustomerDataSource.php b/src/Adapter/Customer/CustomerDataSource.php deleted file mode 100644 index 26a59aee..00000000 --- a/src/Adapter/Customer/CustomerDataSource.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer; - -use Customer; -use PrestaShop\PrestaShop\Core\Customer\CustomerDataSourceInterface; - -final class CustomerDataSource implements CustomerDataSourceInterface -{ - /** - * {@inheritdoc} - */ - public function hasCustomerWithEmail(string $email): bool - { - return Customer::customerExists($email, false, false); - } -} diff --git a/src/Adapter/Customer/QueryHandler/GetCustomerCartsHandler.php b/src/Adapter/Customer/QueryHandler/GetCustomerCartsHandler.php deleted file mode 100644 index 90be229f..00000000 --- a/src/Adapter/Customer/QueryHandler/GetCustomerCartsHandler.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\QueryHandler; - -use Cart; -use Currency; -use Customer; -use PrestaShop\PrestaShop\Adapter\Customer\CommandHandler\AbstractCustomerHandler; -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerCarts; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryHandler\GetCustomerCartsHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\CartSummary; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShop\PrestaShop\Core\Localization\LocaleInterface; - -/** - * Handles GetCustomerCartsQuery using legacy object models - */ -final class GetCustomerCartsHandler extends AbstractCustomerHandler implements GetCustomerCartsHandlerInterface -{ - /** - * @var LocaleInterface - */ - private $locale; - - /** - * @param LocaleInterface $locale - */ - public function __construct( - LocaleInterface $locale - ) { - $this->locale = $locale; - } - - /** - * {@inheritdoc} - */ - public function handle(GetCustomerCarts $query): array - { - $customerId = $query->getCustomerId(); - $this->assertCustomerWasFound($customerId, new Customer($customerId->getValue())); - - return $this->getCarts($customerId->getValue()); - } - - /** - * @param int $customerId - * - * @return array - * - * @throws LocalizationException - */ - private function getCarts(int $customerId): array - { - $carts = Cart::getCustomerCarts($customerId, false); - $summarizedCarts = []; - - foreach ($carts as $key => $customerCart) { - $cartId = (int) $customerCart['id_cart']; - $currency = new Currency((int) $customerCart['id_currency']); - $cart = new Cart($cartId); - - $summarizedCarts[] = new CartSummary( - $cart->id, - $cart->date_add, - $this->locale->formatPrice($cart->getOrderTotal(), $currency->iso_code) - ); - } - - return $summarizedCarts; - } -} diff --git a/src/Adapter/Customer/QueryHandler/GetCustomerForAddressCreationHandler.php b/src/Adapter/Customer/QueryHandler/GetCustomerForAddressCreationHandler.php deleted file mode 100644 index 4c0d7e7a..00000000 --- a/src/Adapter/Customer/QueryHandler/GetCustomerForAddressCreationHandler.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\QueryHandler; - -use Customer; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerByEmailNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerForAddressCreation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryHandler\GetCustomerForAddressCreationHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\AddressCreationCustomerInformation; -use PrestaShopDatabaseException; - -/** - * Handles finding customer by email - */ -final class GetCustomerForAddressCreationHandler implements GetCustomerForAddressCreationHandlerInterface -{ - /** - * {@inheritdoc} - * - * @return AddressCreationCustomerInformation - * - * @throws CustomerByEmailNotFoundException - * @throws CustomerException - */ - public function handle(GetCustomerForAddressCreation $query): AddressCreationCustomerInformation - { - $email = $query->getCustomerEmail(); - - try { - $result = Customer::searchByName($email); - } catch (PrestaShopDatabaseException $e) { - throw new CustomerException(sprintf('Failed to fetch results for customers with email %s', $email)); - } - - if (empty($result)) { - throw new CustomerByEmailNotFoundException(sprintf('Failed to find customer with email %s', $email)); - } - - $customer = reset($result); - - $customerInformation = new AddressCreationCustomerInformation( - (int) $customer['id_customer'], - $customer['firstname'], - $customer['lastname'] - ); - - if (null !== $customer['company']) { - $customerInformation->setCompany($customer['company']); - } - - return $customerInformation; - } -} diff --git a/src/Adapter/Customer/QueryHandler/GetCustomerForEditingHandler.php b/src/Adapter/Customer/QueryHandler/GetCustomerForEditingHandler.php deleted file mode 100644 index 516de51d..00000000 --- a/src/Adapter/Customer/QueryHandler/GetCustomerForEditingHandler.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\QueryHandler; - -use Customer; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerForEditing; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryHandler\GetCustomerForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\EditableCustomer; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\Birthday; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\FirstName; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\LastName; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -/** - * Handles command that gets customer for editing - * - * @internal - */ -final class GetCustomerForEditingHandler implements GetCustomerForEditingHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GetCustomerForEditing $query) - { - $customerId = $query->getCustomerId(); - $customer = new Customer($customerId->getValue()); - - if ($customer->id !== $customerId->getValue()) { - throw new CustomerNotFoundException($customerId, sprintf('Customer with id "%s" was not found', $customerId->getValue())); - } - - $birthday = null === $customer->birthday ? - Birthday::createEmpty() : - new Birthday($customer->birthday) - ; - - return new EditableCustomer( - $customerId, - (int) $customer->id_gender, - new FirstName($customer->firstname), - new LastName($customer->lastname), - new Email($customer->email), - $birthday, - (bool) $customer->active, - (bool) $customer->optin, - (bool) $customer->newsletter, - $customer->getGroups(), - (int) $customer->id_default_group, - (string) $customer->company, - (string) $customer->siret, - (string) $customer->ape, - (string) $customer->website, - (float) $customer->outstanding_allow_amount, - (int) $customer->max_payment_days, - (int) $customer->id_risk - ); - } -} diff --git a/src/Adapter/Customer/QueryHandler/GetCustomerForViewingHandler.php b/src/Adapter/Customer/QueryHandler/GetCustomerForViewingHandler.php deleted file mode 100644 index d3d8bba6..00000000 --- a/src/Adapter/Customer/QueryHandler/GetCustomerForViewingHandler.php +++ /dev/null @@ -1,601 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\QueryHandler; - -use Carrier; -use Cart; -use CartRule; -use Category; -use Context; -use Currency; -use Customer; -use CustomerThread; -use Db; -use Gender; -use Group; -use Language; -use Link; -use Order; -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerForViewing; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryHandler\GetCustomerForViewingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\AddressInformation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\BoughtProductInformation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\CartInformation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\DiscountInformation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\GeneralInformation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\GroupInformation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\LastConnectionInformation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\MessageInformation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\OrderInformation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\OrdersInformation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\PersonalInformation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\ProductsInformation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\ReferrerInformation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\SentEmailInformation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\Subscriptions; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\ViewableCustomer; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\ViewedProductInformation; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; -use PrestaShop\PrestaShop\Core\Localization\Locale; -use Product; -use Referrer; -use Shop; -use Symfony\Component\Translation\TranslatorInterface; -use Tools; -use Validate; - -/** - * Handles commands which gets customer for viewing in Back Office. - * - * @internal - */ -final class GetCustomerForViewingHandler implements GetCustomerForViewingHandlerInterface -{ - /** - * @var LegacyContext - */ - private $context; - - /** - * @var int - */ - private $contextLangId; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var Link - */ - private $link; - - /** - * @var Locale - */ - private $locale; - - /** - * @param TranslatorInterface $translator - * @param int $contextLangId - * @param Link $link - * @param Locale $locale - */ - public function __construct( - TranslatorInterface $translator, - $contextLangId, - Link $link, - Locale $locale - ) { - $this->context = new LegacyContext(); - $this->contextLangId = $contextLangId; - $this->translator = $translator; - $this->link = $link; - $this->locale = $locale; - } - - /** - * {@inheritdoc} - */ - public function handle(GetCustomerForViewing $query) - { - $customerId = $query->getCustomerId(); - $customer = new Customer($customerId->getValue()); - - $this->assertCustomerWasFound($customerId, $customer); - - Context::getContext()->customer = $customer; - - return new ViewableCustomer( - $customerId, - $this->getGeneralInformation($customer), - $this->getPersonalInformation($customer), - $this->getCustomerOrders($customer), - $this->getCustomerCarts($customer), - $this->getCustomerProducts($customer), - $this->getCustomerMessages($customer), - $this->getCustomerDiscounts($customer), - $this->getLastEmailsSentToCustomer($customer), - $this->getLastCustomerConnections($customer), - $this->getCustomerGroups($customer), - $this->getCustomerReferrers($customer), - $this->getCustomerAddresses($customer) - ); - } - - /** - * @param Customer $customer - * - * @return GeneralInformation - */ - private function getGeneralInformation(Customer $customer) - { - return new GeneralInformation( - $customer->note, - Customer::customerExists($customer->email) - ); - } - - /** - * @param Customer $customer - * - * @return PersonalInformation - */ - private function getPersonalInformation(Customer $customer) - { - $customerStats = $customer->getStats(); - - $gender = new Gender($customer->id_gender, $this->contextLangId); - $socialTitle = $gender->name ?: $this->translator->trans('Unknown', [], 'Admin.Orderscustomers.Feature'); - - if ($customer->birthday && '0000-00-00' !== $customer->birthday) { - $birthday = sprintf( - $this->translator->trans('%1$d years old (birth date: %2$s)', [], 'Admin.Orderscustomers.Feature'), - $customerStats['age'], - Tools::displayDate($customer->birthday) - ); - } else { - $birthday = $this->translator->trans('Unknown', [], 'Admin.Orderscustomers.Feature'); - } - - $registrationDate = Tools::displayDate($customer->date_add, null, true); - $lastUpdateDate = Tools::displayDate($customer->date_upd, null, true); - $lastVisitDate = $customerStats['last_visit'] ? - Tools::displayDate($customerStats['last_visit'], null, true) : - $this->translator->trans('Never', [], 'Admin.Global'); - - $customerShop = new Shop($customer->id_shop); - $customerLanguage = new Language($customer->id_lang); - - $customerSubscriptions = new Subscriptions( - (bool) $customer->newsletter, - (bool) $customer->optin - ); - - return new PersonalInformation( - $customer->firstname, - $customer->lastname, - $customer->email, - $customer->isGuest(), - $socialTitle, - $birthday, - $registrationDate, - $lastUpdateDate, - $lastVisitDate, - $this->getCustomerRankBySales($customer->id), - $customerShop->name, - $customerLanguage->name, - $customerSubscriptions, - (bool) $customer->active - ); - } - - /** - * @param int $customerId - * - * @return int|null customer rank or null if customer is not ranked - */ - private function getCustomerRankBySales($customerId) - { - $sql = 'SELECT SUM(total_paid_real) FROM ' . _DB_PREFIX_ . 'orders WHERE id_customer = ' . (int) $customerId . ' AND valid = 1'; - - if ($totalPaid = Db::getInstance()->getValue($sql)) { - $sql = ' - SELECT SQL_CALC_FOUND_ROWS COUNT(*) - FROM ' . _DB_PREFIX_ . 'orders - WHERE valid = 1 - AND id_customer != ' . (int) $customerId . ' - GROUP BY id_customer - HAVING SUM(total_paid_real) > ' . (int) $totalPaid; - - Db::getInstance()->getValue($sql); - - return (int) Db::getInstance()->getValue('SELECT FOUND_ROWS()') + 1; - } - - return null; - } - - /** - * @param Customer $customer - * - * @return OrdersInformation - */ - private function getCustomerOrders(Customer $customer) - { - $validOrders = []; - $invalidOrders = []; - - $orders = Order::getCustomerOrders($customer->id, true); - $totalSpent = 0; - - foreach ($orders as $order) { - $order['total_paid_real_not_formated'] = $order['total_paid_real']; - $order['total_paid_real'] = $this->locale->formatPrice( - $order['total_paid_real'], - Currency::getIsoCodeById((int) $order['id_currency']) - ); - - if (!isset($order['order_state'])) { - $order['order_state'] = $this->translator->trans( - 'There is no status defined for this order.', - [], - 'Admin.Orderscustomers.Notification' - ); - } - - $customerOrderInformation = new OrderInformation( - (int) $order['id_order'], - Tools::displayDate($order['date_add']), - $order['payment'], - $order['order_state'], - (int) $order['nb_products'], - $order['total_paid_real'] - ); - - if ($order['valid']) { - $validOrders[] = $customerOrderInformation; - $totalSpent += $order['total_paid_real_not_formated'] / $order['conversion_rate']; - } else { - $invalidOrders[] = $customerOrderInformation; - } - } - - return new OrdersInformation( - $this->locale->formatPrice($totalSpent, $this->context->getContext()->currency->iso_code), - $validOrders, - $invalidOrders - ); - } - - /** - * @param Customer $customer - * - * @return CartInformation[] - */ - private function getCustomerCarts(Customer $customer) - { - $carts = Cart::getCustomerCarts($customer->id); - $customerCarts = []; - - foreach ($carts as $cart) { - $cart = new Cart((int) $cart['id_cart']); - Context::getContext()->cart = $cart; - - $currency = new Currency($cart->id_currency); - Context::getContext()->currency = $currency; - - $carrier = new Carrier($cart->id_carrier); - $summary = $cart->getSummaryDetails(); - - $customerCarts[] = new CartInformation( - sprintf('%06d', $cart->id), - Tools::displayDate($cart->date_add, null, true), - $this->locale->formatPrice($summary['total_price'], $currency->iso_code), - $carrier->name - ); - } - - Context::getContext()->currency = Currency::getDefaultCurrency(); - - return $customerCarts; - } - - /** - * @param Customer $customer - * - * @return ProductsInformation - */ - private function getCustomerProducts(Customer $customer) - { - $boughtProducts = []; - $viewedProducts = []; - - $products = $customer->getBoughtProducts(); - foreach ($products as $product) { - $boughtProducts[] = new BoughtProductInformation( - (int) $product['id_order'], - Tools::displayDate($product['date_add'], null, false), - $product['product_name'], - $product['product_quantity'] - ); - } - - $sql = ' - SELECT DISTINCT cp.id_product, c.id_cart, c.id_shop, cp.id_shop AS cp_id_shop - FROM ' . _DB_PREFIX_ . 'cart_product cp - JOIN ' . _DB_PREFIX_ . 'cart c ON (c.id_cart = cp.id_cart) - JOIN ' . _DB_PREFIX_ . 'product p ON (cp.id_product = p.id_product) - WHERE c.id_customer = ' . (int) $customer->id . ' - AND NOT EXISTS ( - SELECT 1 - FROM ' . _DB_PREFIX_ . 'orders o - JOIN ' . _DB_PREFIX_ . 'order_detail od ON (o.id_order = od.id_order) - WHERE product_id = cp.id_product AND o.valid = 1 AND o.id_customer = ' . (int) $customer->id . ' - ) - '; - - $viewedProductsData = Db::getInstance()->executeS($sql); - foreach ($viewedProductsData as $productData) { - $product = new Product( - $productData['id_product'], - false, - $this->contextLangId, - $productData['id_shop'] - ); - - if (!Validate::isLoadedObject($product)) { - continue; - } - - $productUrl = $this->link->getProductLink( - $product->id, - $product->link_rewrite, - Category::getLinkRewrite($product->id_category_default, $this->contextLangId), - null, - null, - $productData['cp_id_shop'] - ); - - $viewedProducts[] = new ViewedProductInformation( - (int) $product->id, - $product->name, - $productUrl - ); - } - - return new ProductsInformation( - $boughtProducts, - $viewedProducts - ); - } - - /** - * @param Customer $customer - * - * @return MessageInformation[] - */ - private function getCustomerMessages(Customer $customer) - { - $customerMessages = []; - $messages = CustomerThread::getCustomerMessages((int) $customer->id); - - $messageStatuses = [ - 'open' => $this->translator->trans('Open', [], 'Admin.Orderscustomers.Feature'), - 'closed' => $this->translator->trans('Closed', [], 'Admin.Orderscustomers.Feature'), - 'pending1' => $this->translator->trans('Pending 1', [], 'Admin.Orderscustomers.Feature'), - 'pending2' => $this->translator->trans('Pending 2', [], 'Admin.Orderscustomers.Feature'), - ]; - - foreach ($messages as $message) { - $status = isset($messageStatuses[$message['status']]) ? - $messageStatuses[$message['status']] : - $message['status']; - - $customerMessages[] = new MessageInformation( - (int) $message['id_customer_thread'], - substr(strip_tags(html_entity_decode($message['message'], ENT_NOQUOTES, 'UTF-8')), 0, 75), - $status, - Tools::displayDate($message['date_add'], null, true) - ); - } - - return $customerMessages; - } - - /** - * @param Customer $customer - * - * @return DiscountInformation[] - */ - private function getCustomerDiscounts(Customer $customer) - { - $discounts = CartRule::getCustomerCartRules($this->contextLangId, $customer->id, false, false); - $customerDiscounts = []; - - foreach ($discounts as $discount) { - $availableQuantity = $discount['quantity'] > 0 ? (int) $discount['quantity_for_user'] : 0; - - $customerDiscounts[] = new DiscountInformation( - (int) $discount['id_cart_rule'], - $discount['code'], - $discount['name'], - (bool) $discount['active'], - $availableQuantity - ); - } - - return $customerDiscounts; - } - - /** - * @param Customer $customer - * - * @return SentEmailInformation[] - */ - private function getLastEmailsSentToCustomer(Customer $customer) - { - $emails = $customer->getLastEmails(); - $customerEmails = []; - - foreach ($emails as $email) { - $customerEmails[] = new SentEmailInformation( - Tools::displayDate($email['date_add'], null, true), - $email['language'], - $email['subject'], - $email['template'] - ); - } - - return $customerEmails; - } - - /** - * @param Customer $customer - * - * @return LastConnectionInformation[] - */ - private function getLastCustomerConnections(Customer $customer) - { - $connections = $customer->getLastConnections(); - $lastConnections = []; - - if (!is_array($connections)) { - $connections = []; - } - - foreach ($connections as $connection) { - $httpReferer = $connection['http_referer'] ? - preg_replace('/^www./', '', parse_url($connection['http_referer'], PHP_URL_HOST)) : - $this->translator->trans('Direct link', [], 'Admin.Orderscustomers.Notification'); - - $lastConnections[] = new LastConnectionInformation( - $connection['id_connections'], - Tools::displayDate($connection['date_add']), - $connection['pages'], - $connection['time'], - $httpReferer, - $connection['ipaddress'] - ); - } - - return $lastConnections; - } - - /** - * @param Customer $customer - * - * @return GroupInformation[] - */ - private function getCustomerGroups(Customer $customer) - { - $groups = $customer->getGroups(); - $customerGroups = []; - - foreach ($groups as $groupId) { - $group = new Group($groupId); - - $customerGroups[] = new GroupInformation( - (int) $group->id, - $group->name[$this->contextLangId] - ); - } - - return $customerGroups; - } - - /** - * @param Customer $customer - * - * @return ReferrerInformation[] - */ - private function getCustomerReferrers(Customer $customer) - { - $referrers = Referrer::getReferrers($customer->id); - $customerReferrers = []; - - foreach ($referrers as $referrer) { - $customerReferrers[] = new ReferrerInformation( - Tools::displayDate($referrer['date_add'], null, true), - $referrer['name'], - $referrer['shop_name'] - ); - } - - return $customerReferrers; - } - - /** - * @param Customer $customer - * - * @return AddressInformation[] - */ - private function getCustomerAddresses(Customer $customer) - { - $addresses = $customer->getAddresses($this->contextLangId); - $customerAddresses = []; - - foreach ($addresses as $address) { - $company = $address['company'] ?: '--'; - $fullAddress = sprintf( - '%s %s %s %s', - $address['address1'], - $address['address2'] ?: '', - $address['postcode'], - $address['city'] - ); - - $customerAddresses[] = new AddressInformation( - (int) $address['id_address'], - $company, - sprintf('%s %s', $address['firstname'], $address['lastname']), - $fullAddress, - $address['country'], - (string) $address['phone'], - (string) $address['phone_mobile'] - ); - } - - return $customerAddresses; - } - - /** - * @param CustomerId $customerId - * @param Customer $customer - * - * @throws CustomerNotFoundException - */ - private function assertCustomerWasFound(CustomerId $customerId, Customer $customer) - { - if (!$customer->id) { - throw new CustomerNotFoundException($customerId, sprintf('Customer with id "%s" was not found.', $customerId->getValue())); - } - } -} diff --git a/src/Adapter/Customer/QueryHandler/GetCustomerOrdersHandler.php b/src/Adapter/Customer/QueryHandler/GetCustomerOrdersHandler.php deleted file mode 100644 index 0b4fe60c..00000000 --- a/src/Adapter/Customer/QueryHandler/GetCustomerOrdersHandler.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\QueryHandler; - -use Currency; -use Customer; -use Order; -use PrestaShop\PrestaShop\Adapter\Customer\CommandHandler\AbstractCustomerHandler; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerOrders; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryHandler\GetCustomerOrdersHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\OrderSummary; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShop\PrestaShop\Core\Localization\LocaleInterface; - -/** - * Handles GetCustomerOrders query using legacy object models - */ -final class GetCustomerOrdersHandler extends AbstractCustomerHandler implements GetCustomerOrdersHandlerInterface -{ - /** - * @var LocaleInterface - */ - private $locale; - - /** - * @param LocaleInterface $locale - */ - public function __construct( - LocaleInterface $locale - ) { - $this->locale = $locale; - } - - /** - * @param GetCustomerOrders $query - * - * @return OrderSummary[] - * - * @throws CustomerNotFoundException - */ - public function handle(GetCustomerOrders $query): array - { - $customerId = $query->getCustomerId(); - - $this->assertCustomerWasFound($customerId, new Customer($customerId->getValue())); - - return $this->getOrders($customerId->getValue()); - } - - /** - * @param int $customerId - * - * @throws LocalizationException - */ - private function getOrders(int $customerId) - { - $summarizedOrders = []; - - $customerOrders = Order::getCustomerOrders($customerId); - foreach ($customerOrders as $customerOrder) { - $currency = new Currency((int) $customerOrder['id_currency']); - - $summarizedOrders[] = new OrderSummary( - (int) $customerOrder['id_order'], - $customerOrder['date_add'], - $customerOrder['payment'], - $customerOrder['order_state'] ?: '', - (int) $customerOrder['nb_products'], - $this->locale->formatPrice( - $customerOrder['total_paid_real'], - $currency->iso_code - ) - ); - } - - return $summarizedOrders; - } -} diff --git a/src/Adapter/Customer/QueryHandler/GetRequiredFieldsForCustomerHandler.php b/src/Adapter/Customer/QueryHandler/GetRequiredFieldsForCustomerHandler.php deleted file mode 100644 index 580b64a4..00000000 --- a/src/Adapter/Customer/QueryHandler/GetRequiredFieldsForCustomerHandler.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\QueryHandler; - -use Customer; -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetRequiredFieldsForCustomer; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryHandler\GetRequiredFieldsForCustomerHandlerInterface; - -/** - * Handles query which gets required fields for customer sign up - * - * @internal - */ -final class GetRequiredFieldsForCustomerHandler implements GetRequiredFieldsForCustomerHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GetRequiredFieldsForCustomer $query) - { - $requiredFields = (new Customer())->getFieldsRequiredDatabase(); - - if (empty($requiredFields)) { - return []; - } - - $fields = []; - - foreach ($requiredFields as $field) { - $fields[] = $field['field_name']; - } - - return $fields; - } -} diff --git a/src/Adapter/Customer/QueryHandler/SearchCustomersHandler.php b/src/Adapter/Customer/QueryHandler/SearchCustomersHandler.php deleted file mode 100644 index dc36f2be..00000000 --- a/src/Adapter/Customer/QueryHandler/SearchCustomersHandler.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Customer\QueryHandler; - -use Customer; -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\SearchCustomers; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryHandler\SearchCustomersHandlerInterface; - -/** - * Handles query that searches for customers by given phrases - * - * @internal - */ -final class SearchCustomersHandler implements SearchCustomersHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(SearchCustomers $query) - { - $limit = 50; - $phrases = array_unique($query->getPhrases()); - - $customers = []; - - foreach ($phrases as $searchPhrase) { - if (empty($searchPhrase)) { - continue; - } - - $customersResult = Customer::searchByName($searchPhrase, $limit); - if (!is_array($customersResult)) { - continue; - } - - foreach ($customersResult as $customerArray) { - if (!$customerArray['active']) { - continue; - } - - $customerArray['fullname_and_email'] = sprintf( - '%s %s - %s', - $customerArray['firstname'], - $customerArray['lastname'], - $customerArray['email'] - ); - - unset( - $customerArray['passwd'], - $customerArray['secure_key'], - $customerArray['last_passwd_gen'], - $customerArray['reset_password_token'], - $customerArray['reset_password_validity'] - ); - $customers[$customerArray['id_customer']] = $customerArray; - } - } - - return $customers; - } -} diff --git a/src/Adapter/CustomerService/CommandHandler/AddOrderCustomerMessageHandler.php b/src/Adapter/CustomerService/CommandHandler/AddOrderCustomerMessageHandler.php deleted file mode 100644 index 28acc869..00000000 --- a/src/Adapter/CustomerService/CommandHandler/AddOrderCustomerMessageHandler.php +++ /dev/null @@ -1,264 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CustomerService\CommandHandler; - -use Configuration; -use Customer; -use CustomerMessage; -use CustomerThread; -use Language; -use Mail; -use Order; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CleanHtml; -use PrestaShop\PrestaShop\Core\Domain\CustomerMessage\Command\AddOrderCustomerMessageCommand; -use PrestaShop\PrestaShop\Core\Domain\CustomerMessage\CommandHandler\AddOrderCustomerMessageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CustomerMessage\Exception\CannotSendEmailException; -use PrestaShop\PrestaShop\Core\Domain\CustomerMessage\Exception\CustomerMessageConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CustomerMessage\Exception\CustomerMessageException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderNotFoundException; -use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Validator\Validator\ValidatorInterface; -use Tools; - -final class AddOrderCustomerMessageHandler implements AddOrderCustomerMessageHandlerInterface -{ - /** - * @var int - */ - private $contextShopId; - - /** - * @var int - */ - private $contextLanguageId; - - /** - * @var int - */ - private $contextEmployeeId; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ValidatorInterface - */ - private $validator; - - /** - * @param TranslatorInterface $translator - * @param ValidatorInterface $validator - * @param int $contextShopId - * @param int $contextLanguageId - * @param int $contextEmployeeId - */ - public function __construct( - TranslatorInterface $translator, - ValidatorInterface $validator, - int $contextShopId, - int $contextLanguageId, - int $contextEmployeeId - ) { - $this->contextShopId = $contextShopId; - $this->contextLanguageId = $contextLanguageId; - $this->contextEmployeeId = $contextEmployeeId; - $this->translator = $translator; - $this->validator = $validator; - } - - /** - * {@inheritdoc} - * - * @throws CustomerMessageException - * @throws OrderNotFoundException - */ - public function handle(AddOrderCustomerMessageCommand $command): void - { - $this->assertIsValidMessage($command->getMessage()); - - $order = new Order($command->getOrderId()->getValue()); - - if (0 >= $order->id) { - throw new OrderNotFoundException($command->getOrderId(), "Order with id {$command->getOrderId()->getValue()} was not found"); - } - - $customer = new Customer($order->id_customer); - - if (0 >= $customer->id) { - throw new CustomerMessageException("Associated order customer with id {$command->getOrderId()->getValue()} was not found", CustomerMessageException::ORDER_CUSTOMER_NOT_FOUND); - } - - $customerServiceThreadId = CustomerThread::getIdCustomerThreadByEmailAndIdOrder( - $customer->email, - $order->id - ); - - if (!$customerServiceThreadId) { - try { - $customerServiceThreadId = $this->createCustomerMessageThread($order); - } catch (\PrestaShopException $e) { - throw new CustomerMessageException('An unexpected error occurred when creating customer message thread', 0, $e); - } - } - - try { - $this->createMessage($customerServiceThreadId, $command); - } catch (\PrestaShopException $e) { - throw new CustomerMessageException('An unexpected error occurred when creating customer message', 0, $e); - } - - $failedMailSentMessage = 'An unexpected error occurred when sending the email'; - - try { - $isSent = $this->sendMail($customer, $order, $command); - - if (!$isSent) { - throw new CannotSendEmailException($failedMailSentMessage); - } - } catch (\PrestaShopException $e) { - throw new CannotSendEmailException($failedMailSentMessage, 0, $e); - } - } - - /** - * @param string $message - * - * @throws CustomerMessageConstraintException - */ - private function assertIsValidMessage(string $message): void - { - $errors = $this->validator->validate($message, new CleanHtml()); - - if (0 !== \count($errors)) { - throw new CustomerMessageConstraintException(sprintf('Given message "%s" contains javascript events or script tags', $message), CustomerMessageConstraintException::INVALID_MESSAGE); - } - } - - /** - * Creates customer message thread which groups customer message in an order group. - * - * @param Order $order - * - * @return int - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - private function createCustomerMessageThread(Order $order): int - { - $orderCustomer = new Customer($order->id_customer); - - $customerThread = new CustomerThread(); - $customerThread->id_contact = 0; - $customerThread->id_customer = (int) $order->id_customer; - $customerThread->id_shop = $this->contextShopId; - $customerThread->id_order = $order->id; - $customerThread->id_lang = $this->contextLanguageId; - $customerThread->email = $orderCustomer->email; - $customerThread->status = 'open'; - $customerThread->token = Tools::passwdGen(12); - $customerThread->add(); - - return $customerThread->id; - } - - /** - * Creates actual message. - * - * @param int $customerServiceThreadId - * @param AddOrderCustomerMessageCommand $command - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - private function createMessage(int $customerServiceThreadId, AddOrderCustomerMessageCommand $command): void - { - $customerMessage = new CustomerMessage(); - $customerMessage->id_customer_thread = $customerServiceThreadId; - $customerMessage->id_employee = $this->contextEmployeeId; - $customerMessage->message = $command->getMessage(); - $customerMessage->private = $command->isPrivate(); - $customerMessage->add(); - } - - /** - * Sends email to customer - * - * @param Customer $customer - * @param Order $order - * @param AddOrderCustomerMessageCommand $command - * - * @return bool - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - private function sendMail(Customer $customer, Order $order, AddOrderCustomerMessageCommand $command): bool - { - if ($command->isPrivate()) { - return true; - } - - $message = $command->getMessage(); - - if (Configuration::get('PS_MAIL_TYPE', null, null, $order->id_shop) != Mail::TYPE_TEXT) { - $message = Tools::nl2br(Tools::htmlentitiesUTF8($command->getMessage())); - } - - $orderLanguage = new Language((int) $order->id_lang); - $varsTpl = [ - '{lastname}' => $customer->lastname, - '{firstname}' => $customer->firstname, - '{id_order}' => $order->id, - '{order_name}' => $order->getUniqReference(), - '{message}' => $message, - ]; - - return Mail::Send( - (int) $order->id_lang, - 'order_merchant_comment', - $this->translator->trans( - 'New message regarding your order', - [], - 'Emails.Subject', - $orderLanguage->locale - ), - $varsTpl, - $customer->email, - $customer->firstname . ' ' . $customer->lastname, - null, - null, - null, - null, - _PS_MAIL_DIR_, - true, - (int) $order->id_shop - ); - } -} diff --git a/src/Adapter/CustomerService/CommandHandler/ForwardCustomerThreadHandler.php b/src/Adapter/CustomerService/CommandHandler/ForwardCustomerThreadHandler.php deleted file mode 100644 index 151483c8..00000000 --- a/src/Adapter/CustomerService/CommandHandler/ForwardCustomerThreadHandler.php +++ /dev/null @@ -1,337 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CustomerService\CommandHandler; - -use Contact; -use Context; -use CustomerMessage; -use Db; -use Employee; -use Mail; -use Order; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Command\ForwardCustomerThreadCommand; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\CommandHandler\ForwardCustomerThreadHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Exception\CustomerServiceException; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\ValueObject\CustomerThreadId; -use Symfony\Component\Translation\TranslatorInterface; -use Tools; -use Validate; - -/** - * @internal - */ -final class ForwardCustomerThreadHandler implements ForwardCustomerThreadHandlerInterface -{ - /** - * @var Context - */ - private $context; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param Context $context - * @param ConfigurationInterface $configuration - */ - public function __construct(Context $context, ConfigurationInterface $configuration) - { - $this->context = $context; - $this->translator = $this->context->getTranslator(); - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function handle(ForwardCustomerThreadCommand $command) - { - if ($command->forwardToEmployee()) { - $this->forwardToEmployee($command); - } else { - $this->forwardToSomeoneElse($command); - } - } - - /** - * Forward customer thread to another employee - * - * @param ForwardCustomerThreadCommand $command - */ - private function forwardToEmployee(ForwardCustomerThreadCommand $command) - { - $customerThreadMessage = $this->getCustomerThreadMessage($command->getCustomerThreadId()); - - $content = $this->renderMessage( - $customerThreadMessage, - $command->getEmployeeId()->getValue() - ); - - $customerMessage = $this->createCustomerMessage($command); - $employee = new Employee($command->getEmployeeId()->getValue()); - - $params = [ - '{messages}' => stripslashes($content), - '{employee}' => $this->context->employee->firstname . ' ' . $this->context->employee->lastname, - '{comment}' => stripslashes(Tools::nl2br($command->getComment())), - '{firstname}' => $employee->firstname, - '{lastname}' => $employee->lastname, - ]; - - $forwardEmailSent = Mail::Send( - $this->context->language->id, - 'forward_msg', - $this->context->getTranslator()->trans( - 'Fwd: Customer message', - [], - 'Emails.Subject', - $this->context->language->locale - ), - $params, - $employee->email, - $employee->firstname . ' ' . $employee->lastname, - $this->context->employee->email, - $this->context->employee->firstname . ' ' . $this->context->employee->lastname, - null, - null, - _PS_MAIL_DIR_, - true - ); - - if ($forwardEmailSent) { - $customerMessage->private = 1; - $customerMessage->message = sprintf( - '%s %s %s %s %s %s', - $this->translator->trans('Message forwarded to', [], 'Admin.Catalog.Feature'), - $employee->firstname, - $employee->lastname, - PHP_EOL, - $this->translator->trans('Comment:', [], 'Admin.Catalog.Feature'), - $command->getComment() - ); - - $customerMessage->add(); - } - } - - /** - * Forward customer thread to someone else - * - * @param ForwardCustomerThreadCommand $command - */ - private function forwardToSomeoneElse(ForwardCustomerThreadCommand $command) - { - $customerThreadMessage = $this->getCustomerThreadMessage($command->getCustomerThreadId()); - - $content = $this->renderMessage($customerThreadMessage); - - $params = [ - '{messages}' => Tools::nl2br(stripslashes($content)), - '{employee}' => $this->context->employee->firstname . ' ' . $this->context->employee->lastname, - '{comment}' => stripslashes($command->getComment()), - '{firstname}' => '', - '{lastname}' => '', - ]; - - $customerMessage = $this->createCustomerMessage($command); - - $forwardEmailSent = Mail::Send( - $this->context->language->id, - 'forward_msg', - $this->translator->trans( - 'Fwd: Customer message', - [], - 'Emails.Subject', - $this->context->language->locale - ), - $params, - $command->getEmail()->getValue(), - null, - $this->context->employee->email, - $this->context->employee->firstname . ' ' . $this->context->employee->lastname, - null, - null, - _PS_MAIL_DIR_, - true - ); - - if ($forwardEmailSent) { - $customerMessage->message = sprintf( - '%s %s %s %s %s', - $this->translator->trans('Message forwarded to', [], 'Admin.Catalog.Feature'), - $command->getEmail()->getValue(), - PHP_EOL, - $this->translator->trans('Comment:', [], 'Admin.Catalog.Feature'), - $command->getComment() - ); - - $customerMessage->add(); - } - } - - /** - * @param array $message - * @param int|null $id_employee - * - * @return string - */ - protected function renderMessage(array $message, $id_employee = null) - { - $tpl = $this->context->smarty->createTemplate( - 'controllers' . DIRECTORY_SEPARATOR . 'customer_threads/message.tpl', - $this->context->smarty - ); - - $contacts = Contact::getContacts($this->context->language->id); - $contact_array = []; - - foreach ($contacts as $contact) { - $contact_array[$contact['id_contact']] = [ - 'id_contact' => $contact['id_contact'], - 'name' => $contact['name'], - ]; - } - - $contacts = $contact_array; - - if (!empty($message['id_product']) - && empty($message['employee_name']) - ) { - $id_order_product = Order::getIdOrderProduct( - (int) $message['id_customer'], - (int) $message['id_product'] - ); - } - - $message['date_add'] = Tools::displayDate($message['date_add'], null, true); - $message['user_agent'] = strip_tags($message['user_agent']); - $message['message'] = $this->replaceUrlsWithTags($message['message']); - - $isValidOrderId = true; - $order = new Order((int) $message['id_order']); - - if (!Validate::isLoadedObject($order)) { - $isValidOrderId = false; - } - - $baseAdminLink = Tools::getAdminUrl(basename(_PS_ADMIN_DIR_)); - - $threadUrl = $baseAdminLink . '/' . $this->context->link->getAdminLink('AdminCustomerThreads', true, [], [ - 'id_customer_thread' => (int) $message['id_customer_thread'], - 'viewcustomer_thread' => 1, - ]); - - $tpl->assign([ - 'thread_url' => $threadUrl, - 'link' => $this->context->link, - 'token' => Tools::getAdminToken( - 'AdminCustomerThreads' . (int) $message['id_customer_thread'] . (int) $this->context->employee->id - ), - 'message' => $message, - 'id_order_product' => isset($id_order_product) ? $id_order_product : null, - 'email' => true, - 'id_employee' => $id_employee, - 'PS_SHOP_NAME' => $this->configuration->get('PS_SHOP_NAME'), - 'file_name' => file_exists(_PS_UPLOAD_DIR_ . $message['file_name']), - 'contacts' => $contacts, - 'is_valid_order_id' => $isValidOrderId, - ]); - - return $tpl->fetch(); - } - - /** - * @param CustomerThreadId $customerThreadId - * - * @return array - */ - private function getCustomerThreadMessage(CustomerThreadId $customerThreadId) - { - return Db::getInstance()->getRow(' - SELECT ct.*, cm.*, cl.name subject, CONCAT(e.firstname, \' \', e.lastname) employee_name, - CONCAT(c.firstname, \' \', c.lastname) customer_name, c.firstname - FROM ' . _DB_PREFIX_ . 'customer_thread ct - LEFT JOIN ' . _DB_PREFIX_ . 'customer_message cm - ON (ct.id_customer_thread = cm.id_customer_thread) - LEFT JOIN ' . _DB_PREFIX_ . 'contact_lang cl - ON (cl.id_contact = ct.id_contact AND cl.id_lang = ' . (int) $this->context->language->id . ') - LEFT OUTER JOIN ' . _DB_PREFIX_ . 'employee e - ON e.id_employee = cm.id_employee - LEFT OUTER JOIN ' . _DB_PREFIX_ . 'customer c - ON (c.email = ct.email) - WHERE ct.id_customer_thread = ' . (int) $customerThreadId->getValue() . ' - ORDER BY cm.date_add DESC - '); - } - - /** - * @param ForwardCustomerThreadCommand $command - * - * @return CustomerMessage - */ - private function createCustomerMessage(ForwardCustomerThreadCommand $command) - { - $customerMessage = new CustomerMessage(); - $customerMessage->id_employee = (int) $this->context->employee->id; - $customerMessage->id_customer_thread = (int) $command->getCustomerThreadId()->getValue(); - $customerMessage->ip_address = (int) ip2long(Tools::getRemoteAddr()); - - if (false === $customerMessage->validateField('message', $command->getComment())) { - throw new CustomerServiceException(sprintf('Comment "%s" is not valid.', $command->getComment())); - } - - return $customerMessage; - } - - /** - * Replaces URLs with tags in string. - * - * @param string $text - * - * @return string - */ - private function replaceUrlsWithTags($text) - { - return preg_replace( - '/(https?:\/\/[a-z0-9#%&_=\(\)\.\? \+\-@\/]{6,1000})([\s\n<])/Uui', - '\1\2', - html_entity_decode( - $text, - ENT_QUOTES, - 'UTF-8' - ) - ); - } -} diff --git a/src/Adapter/CustomerService/CommandHandler/ReplyToCustomerThreadHandler.php b/src/Adapter/CustomerService/CommandHandler/ReplyToCustomerThreadHandler.php deleted file mode 100644 index 22db6d23..00000000 --- a/src/Adapter/CustomerService/CommandHandler/ReplyToCustomerThreadHandler.php +++ /dev/null @@ -1,174 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CustomerService\CommandHandler; - -use Contact; -use Context; -use Customer; -use CustomerMessage; -use CustomerThread; -use Language; -use Mail; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Command\ReplyToCustomerThreadCommand; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\CommandHandler\ReplyToCustomerThreadHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Exception\CustomerServiceException; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\ValueObject\CustomerThreadStatus; -use ShopUrl; -use Symfony\Component\Translation\TranslatorInterface; -use Tools; -use Validate; - -/** - * @internal - */ -final class ReplyToCustomerThreadHandler implements ReplyToCustomerThreadHandlerInterface -{ - /** - * @var Context - */ - private $context; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param Context $context - */ - public function __construct(Context $context) - { - $this->context = $context; - $this->translator = $context->getTranslator(); - } - - /** - * @param ReplyToCustomerThreadCommand $command - */ - public function handle(ReplyToCustomerThreadCommand $command) - { - $customerThread = new CustomerThread( - $command->getCustomerThreadId()->getValue() - ); - - ShopUrl::cacheMainDomainForShop((int) $customerThread->id_shop); - - $customerMessage = $this->createCustomerMessage( - $customerThread, - $command->getReplyMessage() - ); - - $replyWasSent = $this->sendReplyEmail($customerThread, $customerMessage); - - if ($replyWasSent) { - $customerThread->status = CustomerThreadStatus::CLOSED; - $customerThread->update(); - } - } - - /** - * @param CustomerThread $customerThread - * @param string $replyMessage - * - * @return CustomerMessage - */ - private function createCustomerMessage(CustomerThread $customerThread, $replyMessage) - { - $customerMessage = new CustomerMessage(); - $customerMessage->id_employee = (int) $this->context->employee->id; - $customerMessage->id_customer_thread = $customerThread->id; - $customerMessage->ip_address = (int) ip2long(Tools::getRemoteAddr()); - $customerMessage->message = $replyMessage; - - if (false === $customerMessage->validateField('message', $customerMessage->message)) { - throw new CustomerServiceException('Invalid reply message'); - } - - if (false === $customerMessage->add()) { - throw new CustomerServiceException('Failed to add customer message'); - } - - return $customerMessage; - } - - /** - * @param CustomerThread $customerThread - * @param CustomerMessage $customerMessage - * - * @return bool - */ - private function sendReplyEmail(CustomerThread $customerThread, CustomerMessage $customerMessage) - { - $customer = new Customer($customerThread->id_customer); - - $params = [ - '{reply}' => Tools::nl2br($customerMessage->message), - '{link}' => Tools::url( - $this->context->link->getPageLink('contact', true, null, null, false, $customerThread->id_shop), - 'id_customer_thread=' . (int) $customerThread->id . '&token=' . $customerThread->token - ), - '{firstname}' => $customer->firstname, - '{lastname}' => $customer->lastname, - ]; - - $contact = new Contact((int) $customerThread->id_contact, (int) $customerThread->id_lang); - - if (Validate::isLoadedObject($contact)) { - $fromName = $contact->name; - $fromEmail = $contact->email; - } else { - $fromName = null; - $fromEmail = null; - } - - $language = new Language((int) $customerThread->id_lang); - - return Mail::Send( - (int) $customerThread->id_lang, - 'reply_msg', - $this->translator->trans( - 'An answer to your message is available #ct%thread_id% #tc%thread_token%', - [ - '%thread_id%' => $customerThread->id, - '%thread_token%' => $customerThread->token, - ], - 'Emails.Subject', - $language->locale - ), - $params, - $customerThread->email, - null, - $fromEmail, - $fromName, - null, - null, - _PS_MAIL_DIR_, - true, - $customerThread->id_shop - ); - } -} diff --git a/src/Adapter/CustomerService/QueryHandler/GetCustomerThreadForViewingHandler.php b/src/Adapter/CustomerService/QueryHandler/GetCustomerThreadForViewingHandler.php deleted file mode 100644 index 0063303b..00000000 --- a/src/Adapter/CustomerService/QueryHandler/GetCustomerThreadForViewingHandler.php +++ /dev/null @@ -1,388 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\CustomerService\QueryHandler; - -use Contact; -use Context; -use Currency; -use Customer; -use CustomerThread; -use DateTime; -use Employee; -use Order; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Exception\CustomerThreadNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Query\GetCustomerThreadForViewing; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryHandler\GetCustomerThreadForViewingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryResult\CustomerInformation; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryResult\CustomerThreadMessage; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryResult\CustomerThreadTimeline; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryResult\CustomerThreadTimelineItem; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryResult\CustomerThreadView; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\ValueObject\CustomerThreadId; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\ValueObject\CustomerThreadMessageType; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\ValueObject\CustomerThreadStatus; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; -use Product; -use Symfony\Component\Translation\TranslatorInterface; -use Tools; -use Validate; - -/** - * @internal - */ -final class GetCustomerThreadForViewingHandler implements GetCustomerThreadForViewingHandlerInterface -{ - /** - * @var Context - */ - private $context; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param Context $context - */ - public function __construct(Context $context) - { - $this->context = $context; - $this->translator = $context->getTranslator(); - } - - /** - * {@inheritdoc} - */ - public function handle(GetCustomerThreadForViewing $query) - { - $customerThread = $this->getCustomerThread($query->getCustomerThreadId()); - - $messages = CustomerThread::getMessageCustomerThreads($query->getCustomerThreadId()->getValue()); - - return new CustomerThreadView( - $query->getCustomerThreadId(), - new LanguageId((int) $customerThread->id_lang), - $this->getAvailableActions($customerThread), - $this->getCustomerInformation($customerThread), - $this->getContactName($customerThread), - $this->getCustomerThreadMessages($messages), - $this->getTimeline($messages, $customerThread) - ); - } - - /** - * @param array $messages - * - * @return CustomerThreadMessage[] - */ - private function getCustomerThreadMessages(array $messages) - { - $threadMessages = []; - - foreach ($messages as $key => $message) { - $employeeImage = null; - - if ($message['id_employee']) { - $employee = new Employee($message['id_employee']); - $employeeImage = $employee->getImage(); - } - - $attachmentFile = null; - - if (!empty($message['file_name']) - && file_exists(_PS_UPLOAD_DIR_ . $message['file_name']) - ) { - $attachmentFile = _THEME_PROD_PIC_DIR_ . $message['file_name']; - } - - $productId = null; - $productName = null; - - if ($message['id_product']) { - $product = new Product((int) $message['id_product'], false, $this->context->language->id); - - if (Validate::isLoadedObject($product)) { - $productId = (int) $product->id; - $productName = $product->name; - } - } - - $type = $message['id_employee'] ? - CustomerThreadMessageType::EMPLOYEE : - CustomerThreadMessageType::CUSTOMER; - - $threadMessages[] = new CustomerThreadMessage( - $type, - $message['message'], - $message['date_add'], - $employeeImage, - $message['employee_name'], - $message['customer_name'], - $attachmentFile, - $productId, - $productName - ); - } - - return $threadMessages; - } - - /** - * @param CustomerThreadId $customerThreadId - * - * @return CustomerThread - */ - private function getCustomerThread(CustomerThreadId $customerThreadId) - { - $customerThread = new CustomerThread($customerThreadId->getValue()); - - if ($customerThread->id !== $customerThreadId->getValue()) { - throw new CustomerThreadNotFoundException(sprintf('Customer thread with id "%s" was not found', $customerThreadId->getValue())); - } - - return $customerThread; - } - - /** - * Get customer thread messages in timeline - * - * @param array $messages - * @param CustomerThread $customerThread - * - * @return CustomerThreadTimeline - */ - private function getTimeline(array $messages, CustomerThread $customerThread) - { - $timeline = []; - - foreach ($messages as $message) { - $product = new Product((int) $message['id_product'], false, $this->context->language->id); - - $content = ''; - - if (!$message['private']) { - $content .= sprintf( - '%s %s
    ', - $this->translator->trans('Message to:', [], 'Admin.Catalog.Feature'), - !$message['id_employee'] ? $message['subject'] : $message['customer_name'] - ); - } - - if (Validate::isLoadedObject($product)) { - $content .= sprintf( - '
    %s%s

    ', - $this->translator->trans('Product:', [], 'Admin.Catalog.Feature'), - $product->name - ); - } - - $content .= Tools::safeOutput($message['message']); - - $timeline[$message['date_add']][] = [ - 'arrow' => 'left', - 'background_color' => '', - 'icon' => 'email', - 'content' => $content, - 'date' => $message['date_add'], - 'related_order_id' => null, - ]; - } - - $order = new Order((int) $customerThread->id_order); - - if (Validate::isLoadedObject($order)) { - $order_history = $order->getHistory($this->context->language->id); - foreach ($order_history as $history) { - $link_order = $this->context->link->getAdminLink('AdminOrders', true, [], [ - 'vieworder' => 1, - 'id_order' => (int) $order->id, - ]); - - $content = sprintf( - '%s #%d

    ', - Tools::safeOutput($link_order), - $this->translator->trans('Order', [], 'Admin.Global'), - $order->id - ); - - $content .= sprintf( - '%s %s', - $this->translator->trans('Status:', [], 'Admin.Catalog.Feature'), - $history['ostate_name'] - ); - - $timeline[$history['date_add']][] = [ - 'arrow' => 'right', - 'alt' => true, - 'background_color' => $history['color'], - 'icon' => 'credit_card', - 'content' => $content, - 'date' => $history['date_add'], - 'see_more_link' => $link_order, - 'related_order_id' => (int) $order->id, - ]; - } - } - - krsort($timeline); - - $timelineItems = []; - - foreach ($timeline as $items) { - foreach ($items as $item) { - $timelineItems[] = new CustomerThreadTimelineItem( - $item['content'], - $item['icon'], - $item['arrow'], - $item['date'], - isset($item['background_color']) ? $item['background_color'] : null, - $item['related_order_id'] - ); - } - } - - return new CustomerThreadTimeline($timelineItems); - } - - /** - * @param CustomerThread $thread - * - * @return array - */ - private function getAvailableActions(CustomerThread $thread) - { - $actions = []; - - if ($thread->status !== CustomerThreadStatus::CLOSED) { - $actions[CustomerThreadStatus::CLOSED] = [ - 'label' => $this->translator->trans('Mark as "handled"', [], 'Admin.Catalog.Feature'), - 'value' => CustomerThreadStatus::CLOSED, - ]; - } else { - $actions[CustomerThreadStatus::OPEN] = [ - 'label' => $this->translator->trans('Re-open', [], 'Admin.Catalog.Feature'), - 'value' => CustomerThreadStatus::OPEN, - ]; - } - - if ($thread->status !== CustomerThreadStatus::PENDING_1) { - $actions[CustomerThreadStatus::PENDING_1] = [ - 'label' => $this->translator->trans( - 'Mark as "pending 1" (will be answered later)', - [], - 'Admin.Catalog.Feature' - ), - 'value' => CustomerThreadStatus::PENDING_1, - ]; - } else { - $actions[CustomerThreadStatus::PENDING_1] = [ - 'label' => $this->translator->trans('Disable pending status', [], 'Admin.Catalog.Feature'), - 'value' => CustomerThreadStatus::OPEN, - ]; - } - - if ($thread->status !== CustomerThreadStatus::PENDING_2) { - $actions[CustomerThreadStatus::PENDING_2] = [ - 'label' => $this->translator->trans( - 'Mark as "pending 2" (will be answered later)', - [], - 'Admin.Catalog.Feature' - ), - 'value' => CustomerThreadStatus::PENDING_2, - ]; - } else { - $actions[CustomerThreadStatus::PENDING_2] = [ - 'label' => $this->translator->trans('Disable pending status', [], 'Admin.Catalog.Feature'), - 'value' => CustomerThreadStatus::OPEN, - ]; - } - - return $actions; - } - - /** - * @param CustomerThread $thread - * - * @return CustomerInformation - */ - private function getCustomerInformation(CustomerThread $thread) - { - if (!$thread->id_customer) { - return CustomerInformation::withEmailOnly($thread->email); - } - - $customer = new Customer($thread->id_customer); - $orders = Order::getCustomerOrders($customer->id); - - $totalOk = 0; - $ordersOk = []; - - if ($orders && count($orders)) { - foreach ($orders as $key => $order) { - if ($order['valid']) { - $ordersOk[] = $order; - $totalOk += $order['total_paid_real'] / $order['conversion_rate']; - } - - $orders[$key]['date_add'] = Tools::displayDate($order['date_add']); - $orders[$key]['total_paid_real'] = Tools::displayPrice( - $order['total_paid_real'], - new Currency((int) $order['id_currency']) - ); - } - } - - return new CustomerInformation( - $customer->id, - $customer->firstname, - $customer->lastname, - $thread->email, - count($ordersOk), - $totalOk ? Tools::displayPrice($totalOk, $this->context->currency) : $totalOk, - (new DateTime($customer->date_add))->format($this->context->language->date_format_lite) - ); - } - - /** - * @param CustomerThread $thread - * - * @return string|null - */ - private function getContactName(CustomerThread $thread) - { - $contacts = Contact::getContacts($this->context->language->id); - - foreach ($contacts as $contact) { - if ((int) $contact['id_contact'] === (int) $thread->id_contact) { - return $contact['name']; - } - } - - return null; - } -} diff --git a/src/Adapter/Database.php b/src/Adapter/Database.php deleted file mode 100644 index ecbabac1..00000000 --- a/src/Adapter/Database.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use Db; -use DbQuery; - -/** - * Adapter for Db legacy class. - */ -class Database implements \PrestaShop\PrestaShop\Core\Foundation\Database\DatabaseInterface -{ - /** - * Perform a SELECT sql statement. - * - * @param string $sqlString - * - * @return array|false - * - * @throws \PrestaShopDatabaseException - */ - public function select($sqlString) - { - return Db::getInstance()->executeS($sqlString); - } - - /** - * Escape $unsafe to be used into a SQL statement. - * - * @param string $unsafeData - * - * @return string - */ - public function escape($unsafeData) - { - return Db::getInstance()->escape($unsafeData, true, true); - } - - /** - * Returns a value from the first row, first column of a SELECT query. - * - * @param string|DbQuery $sql - * @param bool $useMaster - * @param bool $useCache - * - * @return string|false|null - */ - public function getValue($sql, $useMaster = true, $useCache = true) - { - return Db::getInstance($useMaster)->getValue($sql, $useCache); - } - - /** - * Returns the text of the error message from previous database operation. - * - * @return string - */ - public function getErrorMessage() - { - return Db::getInstance()->getMsgError(); - } - - /** - * Enable the cache. - */ - public function enableCache() - { - Db::getInstance()->enableCache(); - } - - /** - * Disable the cache. - */ - public function disableCache() - { - Db::getInstance()->disableCache(); - } -} diff --git a/src/Adapter/Debug/DebugMode.php b/src/Adapter/Debug/DebugMode.php deleted file mode 100644 index 09249ad3..00000000 --- a/src/Adapter/Debug/DebugMode.php +++ /dev/null @@ -1,185 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Debug; - -use Tools; - -/** - * Utilitary class to manages the Debug mode legacy application. - */ -class DebugMode -{ - const DEBUG_MODE_SUCCEEDED = 0; - const DEBUG_MODE_ERROR_NO_READ_ACCESS = 1; - const DEBUG_MODE_ERROR_NO_READ_ACCESS_CUSTOM = 2; - const DEBUG_MODE_ERROR_NO_WRITE_ACCESS = 3; - const DEBUG_MODE_ERROR_NO_WRITE_ACCESS_CUSTOM = 4; - const DEBUG_MODE_ERROR_NO_DEFINITION_FOUND = 5; - - /** - * Is Debug Mode enabled? Checks on custom defines file first. - * - * @return bool Whether debug mode is enabled - */ - public function isDebugModeEnabled() - { - $definesClean = ''; - $customDefinesPath = _PS_ROOT_DIR_ . '/config/defines_custom.inc.php'; - $definesPath = _PS_ROOT_DIR_ . '/config/defines.inc.php'; - - if (is_readable($customDefinesPath)) { - $definesClean = php_strip_whitespace($customDefinesPath); - } - - if (!preg_match('/define\(\'_PS_MODE_DEV_\', ([a-zA-Z]+)\);/Ui', $definesClean, $debugModeValue)) { - $definesClean = php_strip_whitespace($definesPath); - if (!preg_match('/define\(\'_PS_MODE_DEV_\', ([a-zA-Z]+)\);/Ui', $definesClean, $debugModeValue)) { - return false; - } - } - - return 'true' === Tools::strtolower($debugModeValue[1]); - } - - /** - * Enable Debug mode. - * - * @return int Whether changing debug mode succeeded or error code - */ - public function enable() - { - return $this->changePsModeDevValue('true'); - } - - /** - * Disable debug mode. - * - * @return int Whether changing debug mode succeeded or error code - */ - public function disable() - { - return $this->changePsModeDevValue('false'); - } - - /** - * Check read permission on custom defines.inc.php. - * - * @return bool Whether the file can be read - */ - private function isCustomDefinesReadable() - { - return is_readable(_PS_ROOT_DIR_ . '/config/defines_custom.inc.php'); - } - - /** - * Check read permission on main defines.inc.php. - * - * @return bool Whether the file can be read - */ - private function isMainDefinesReadable() - { - return is_readable(_PS_ROOT_DIR_ . '/config/defines.inc.php'); - } - - /** - * Update Debug Mode value in main defines file. - * - * @param string $value should be "true" or "false" - * - * @return int the debug mode - */ - private function updateDebugModeValueInMainFile($value) - { - $filename = _PS_ROOT_DIR_ . '/config/defines.inc.php'; - $cleanedFileContent = php_strip_whitespace($filename); - $fileContent = Tools::file_get_contents($filename); - - if (!preg_match('/define\(\'_PS_MODE_DEV_\', ([a-zA-Z]+)\);/Ui', $cleanedFileContent)) { - return self::DEBUG_MODE_ERROR_NO_DEFINITION_FOUND; - } - - $fileContent = preg_replace('/define\(\'_PS_MODE_DEV_\', ([a-zA-Z]+)\);/Ui', 'define(\'_PS_MODE_DEV_\', ' . $value . ');', $fileContent); - if (!@file_put_contents($filename, $fileContent)) { - return self::DEBUG_MODE_ERROR_NO_WRITE_ACCESS; - } - - if (function_exists('opcache_invalidate')) { - opcache_invalidate($filename); - } - - return self::DEBUG_MODE_SUCCEEDED; - } - - /** - * Update Debug Mode value in custom defines file. - * - * @param string $value should be "true" or "false" - * - * @return int the debug mode - */ - private function updateDebugModeValueInCustomFile($value) - { - $customFileName = _PS_ROOT_DIR_ . '/config/defines_custom.inc.php'; - $cleanedFileContent = php_strip_whitespace($customFileName); - $fileContent = Tools::file_get_contents($customFileName); - - if (!empty($cleanedFileContent) && preg_match('/define\(\'_PS_MODE_DEV_\', ([a-zA-Z]+)\);/Ui', $cleanedFileContent)) { - $fileContent = preg_replace('/define\(\'_PS_MODE_DEV_\', ([a-zA-Z]+)\);/Ui', 'define(\'_PS_MODE_DEV_\', ' . $value . ');', $fileContent); - - if (!@file_put_contents($customFileName, $fileContent)) { - return self::DEBUG_MODE_ERROR_NO_WRITE_ACCESS_CUSTOM; - } - - if (function_exists('opcache_invalidate')) { - opcache_invalidate($customFileName); - } - - return self::DEBUG_MODE_SUCCEEDED; - } - } - - /** - * Change value of _PS_MODE_DEV_ constant. - * - * @param string $value should be "true" or "false" - * - * @return int the debug mode - */ - private function changePsModeDevValue($value) - { - // Check custom defines file first - if ($this->isCustomDefinesReadable()) { - return $this->updateDebugModeValueInCustomFile($value); - } - - if ($this->isMainDefinesReadable()) { - return $this->updateDebugModeValueInMainFile($value); - } else { - return self::DEBUG_MODE_ERROR_NO_READ_ACCESS; - } - } -} diff --git a/src/Adapter/Debug/DebugModeConfiguration.php b/src/Adapter/Debug/DebugModeConfiguration.php deleted file mode 100644 index f53931d5..00000000 --- a/src/Adapter/Debug/DebugModeConfiguration.php +++ /dev/null @@ -1,156 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Debug; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * This class manages Debug mode configuration for a Shop. - */ -class DebugModeConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - /** - * @var DebugMode Debug mode manager - */ - private $debugMode; - - /** - * @var string Path to the application defines path - */ - private $configDefinesPath; - - public function __construct(DebugMode $debugMode, Configuration $configuration, $configDefinesPath) - { - $this->debugMode = $debugMode; - $this->configuration = $configuration; - $this->configDefinesPath = $configDefinesPath; - } - - /** - * Returns configuration used to manage Debug mode in back office. - * - * @return array - */ - public function getConfiguration() - { - return [ - 'disable_non_native_modules' => $this->configuration->getBoolean('PS_DISABLE_NON_NATIVE_MODULE'), - 'disable_overrides' => $this->configuration->getBoolean('PS_DISABLE_OVERRIDES'), - 'debug_mode' => $this->debugMode->isDebugModeEnabled(), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - $errors = []; - - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_DISABLE_NON_NATIVE_MODULE', $configuration['disable_non_native_modules']); - $this->configuration->set('PS_DISABLE_OVERRIDES', $configuration['disable_overrides']); - - $status = $this->updateDebugMode((bool) $configuration['debug_mode']); - - switch ($status) { - case DebugMode::DEBUG_MODE_SUCCEEDED: - break; - case DebugMode::DEBUG_MODE_ERROR_NO_WRITE_ACCESS: - $errors[] = [ - 'key' => 'Error: Could not write to file. Make sure that the correct permissions are set on the file %s', - 'domain' => 'Admin.Advparameters.Notification', - 'parameters' => [$this->configDefinesPath], - ]; - - break; - case DebugMode::DEBUG_MODE_ERROR_NO_DEFINITION_FOUND: - $errors[] = [ - 'key' => 'Error: Could not find whether debug mode is enabled. Make sure that the correct permissions are set on the file %s', - 'domain' => 'Admin.Advparameters.Notification', - 'parameters' => [$this->configDefinesPath], - ]; - - break; - case DebugMode::DEBUG_MODE_ERROR_NO_WRITE_ACCESS_CUSTOM: - $errors[] = [ - 'key' => 'Error: Could not write to file. Make sure that the correct permissions are set on the file %s', - 'domain' => 'Admin.Advparameters.Notification', - 'parameters' => [$this->configDefinesPath], - ]; - - break; - case DebugMode::DEBUG_MODE_ERROR_NO_READ_ACCESS: - $errors[] = [ - 'key' => 'Error: Could not write to file. Make sure that the correct permissions are set on the file %s', - 'domain' => 'Admin.Advparameters.Notification', - 'parameters' => [$this->configDefinesPath], - ]; - - break; - default: - break; - } - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['disable_non_native_modules'], - $configuration['disable_overrides'], - $configuration['debug_mode'] - ); - } - - /** - * Change Debug mode value if needed. - * - * @param $enableStatus - * - * @return int the status of update - */ - private function updateDebugMode($enableStatus) - { - $currentDebugMode = $this->debugMode->isDebugModeEnabled(); - - if ($enableStatus !== $currentDebugMode) { - return (true === $enableStatus) ? $this->debugMode->enable() : $this->debugMode->disable(); - } - } -} diff --git a/src/Adapter/Domain/AbstractObjectModelHandler.php b/src/Adapter/Domain/AbstractObjectModelHandler.php deleted file mode 100644 index 51fd4f0c..00000000 --- a/src/Adapter/Domain/AbstractObjectModelHandler.php +++ /dev/null @@ -1,164 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Domain; - -use Context; -use Db; -use ImageManager; -use ObjectModel; -use PrestaShopDatabaseException; -use Shop; - -/** - * Class AbstractObjectModelHandler is responsible for executing legacy code which is common for legacy ObjectModel. - * - * @internal - */ -abstract class AbstractObjectModelHandler -{ - /** - * This function assigns stores ids to the given object. It removes previously set shop ids and adds new ids instead. - * - * @param ObjectModel $objectModel - * @param array $shopAssociation - * - * @throws PrestaShopDatabaseException - */ - protected function associateWithShops(ObjectModel $objectModel, array $shopAssociation) - { - if (empty($shopAssociation) || !Shop::isFeatureActive()) { - return; - } - - $tableName = (string) $objectModel::$definition['table']; - $primaryKeyName = (string) $objectModel::$definition['primary']; - $primaryKeyValue = (int) $objectModel->id; - - if (!Shop::isTableAssociated($tableName)) { - return; - } - - // Get list of shop id we want to exclude from asso deletion - $excludeIds = $shopAssociation; - foreach (Db::getInstance()->executeS('SELECT id_shop FROM ' . _DB_PREFIX_ . 'shop') as $row) { - if (!Context::getContext()->employee->hasAuthOnShop($row['id_shop'])) { - $excludeIds[] = $row['id_shop']; - } - } - - $excludeShopsCondtion = $excludeIds ? - ' AND id_shop NOT IN (' . implode(', ', array_map('intval', $excludeIds)) . ')' : - '' - ; - - Db::getInstance()->delete( - $tableName . '_shop', - '`' . $primaryKeyName . '` = ' . $primaryKeyValue . $excludeShopsCondtion - ); - - $insert = []; - foreach ($shopAssociation as $shopId) { - // Check if context employee has access to the shop before inserting shop association. - if (Context::getContext()->employee->hasAuthOnShop($shopId)) { - $insert[] = [ - $primaryKeyName => $primaryKeyValue, - 'id_shop' => (int) $shopId, - ]; - } - } - - Db::getInstance()->insert( - $tableName . '_shop', - $insert, - false, - true, - Db::INSERT_IGNORE - ); - } - - /** - * @param ObjectModel $objectModel - * @param array $multiStoreColumnAssociation - an array key contains shop id while values contains the mapping of - * column and its value - */ - protected function updateMultiStoreColumns(ObjectModel $objectModel, array $multiStoreColumnAssociation) - { - $tableName = (string) $objectModel::$definition['table']; - $primaryKey = (string) $objectModel::$definition['primary']; - $primaryKeyValue = (int) $objectModel->id; - - foreach ($multiStoreColumnAssociation as $shopId => $items) { - $shop = new Shop($shopId); - - if (0 >= $shop->id || !is_array($items)) { - continue; - } - - $update = []; - foreach ($items as $columnName => $columnValue) { - $update[$columnName] = pSQL($columnValue); - } - - Db::getInstance()->update( - $tableName . '_shop', - $update, - $primaryKey . '=' . $primaryKeyValue - ); - } - } - - /** - * @param string $imagePath the original image path - * @param int $imageId - * @param string $belongsTo object name to which image belongs (e.g. 'supplier', 'manufacturer') - * - * @return string - */ - protected function getTmpImageTag($imagePath, $imageId, $belongsTo) - { - return ImageManager::thumbnail( - $imagePath, - $belongsTo . '_' . $imageId . '.jpg', - 350, - 'jpg', - true, - true - ); - } - - /** - * Calculates and returns image size in kb for provided image path. Returns null if image doesn't exist - * - * @param string $imagePath - * - * @return float|null - */ - protected function getImageSize($imagePath) - { - return file_exists($imagePath) ? filesize($imagePath) / 1000 : null; - } -} diff --git a/src/Adapter/Email/EmailConfigurationTester.php b/src/Adapter/Email/EmailConfigurationTester.php deleted file mode 100644 index c42f2e70..00000000 --- a/src/Adapter/Email/EmailConfigurationTester.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Email; - -use PrestaShop\PrestaShop\Adapter\Entity\Mail; -use PrestaShop\PrestaShop\Adapter\Entity\Tools; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Email\EmailConfigurationTesterInterface; -use PrestaShop\PrestaShop\Core\Email\MailOption; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class EmailConfigurationTester is responsible for sending test email. - * - * @internal - */ -final class EmailConfigurationTester implements EmailConfigurationTesterInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param ConfigurationInterface $configuration - * @param TranslatorInterface $translator - */ - public function __construct( - ConfigurationInterface $configuration, - TranslatorInterface $translator - ) { - $this->configuration = $configuration; - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function testConfiguration(array $config) - { - $content = $this->translator->trans( - 'This is a test message. Your server is now configured to send email.', - [], - 'Admin.Advparameters.Feature' - ); - $subject = $this->translator->trans('Test message -- Prestashop', [], 'Admin.Advparameters.Feature'); - - $smtpChecked = MailOption::METHOD_SMTP === (int) $config['mail_method']; - - $password = !empty($config['smtp_password']) ? - urldecode($config['smtp_password']) : - $this->configuration->get('PS_MAIL_PASSWD'); - $password = str_replace( - ['<', '>', '"', '&'], - ['<', '>', '"', '&'], - Tools::htmlentitiesUTF8($password) - ); - - $result = Mail::sendMailTest( - Tools::htmlentitiesUTF8($smtpChecked), - Tools::htmlentitiesUTF8($config['smtp_server']), - Tools::htmlentitiesUTF8($content), - Tools::htmlentitiesUTF8($subject), - Tools::htmlentitiesUTF8('text/html'), - Tools::htmlentitiesUTF8($config['send_email_to']), - Tools::htmlentitiesUTF8($this->configuration->get('PS_SHOP_EMAIL')), - Tools::htmlentitiesUTF8($config['smtp_username']), - $password, - Tools::htmlentitiesUTF8($config['smtp_port']), - Tools::htmlentitiesUTF8($config['smtp_encryption']) - ); - - $errors = []; - - if (false === $result || is_string($result)) { - $errors[] = - $this->translator->trans('Error: Please check your configuration', [], 'Admin.Advparameters.Feature'); - } - - if (is_string($result)) { - $errors[] = $result; - } - - return $errors; - } -} diff --git a/src/Adapter/Email/EmailLogEraser.php b/src/Adapter/Email/EmailLogEraser.php deleted file mode 100644 index 792dcf62..00000000 --- a/src/Adapter/Email/EmailLogEraser.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Email; - -use PrestaShop\PrestaShop\Adapter\Entity\Mail; -use PrestaShop\PrestaShop\Adapter\Entity\PrestaShopCollection; -use PrestaShop\PrestaShop\Core\Email\EmailLogEraserInterface; - -/** - * Class EmailLogEraser provides API for erasing email logs. - * - * @internal - */ -final class EmailLogEraser implements EmailLogEraserInterface -{ - /** - * {@inheritdoc} - */ - public function erase(array $mailLogIds) - { - $errors = []; - - if (empty($mailLogIds)) { - $errors[] = [ - 'key' => 'You must select at least one element to delete.', - 'parameters' => [], - 'domain' => 'Admin.Notifications.Error', - ]; - - return $errors; - } - - $emailLogs = new PrestaShopCollection('Mail'); - $emailLogs->where('id_mail', 'in', $mailLogIds); - - /** @var Mail $emailLog */ - foreach ($emailLogs->getResults() as $emailLog) { - if (!$emailLog->delete()) { - $errors[] = [ - 'key' => 'Can\'t delete #%id%', - 'parameters' => [ - '%id%' => $emailLog->id, - ], - 'domain' => 'Admin.Notifications.Error', - ]; - - continue; - } - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function eraseAll() - { - return Mail::eraseAllLogs(); - } -} diff --git a/src/Adapter/Employee/AvatarProvider.php b/src/Adapter/Employee/AvatarProvider.php deleted file mode 100644 index 0eeea31b..00000000 --- a/src/Adapter/Employee/AvatarProvider.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Employee; - -use PrestaShop\PrestaShop\Adapter\Tools; -use PrestaShop\PrestaShop\Core\Employee\AvatarProviderInterface; - -/** - * Class AvatarProvider provides employee avatar data. - */ -final class AvatarProvider implements AvatarProviderInterface -{ - /** - * @var Tools - */ - private $tools; - - /** - * @param Tools $tools - */ - public function __construct(Tools $tools) - { - $this->tools = $tools; - } - - /** - * {@inheritdoc} - */ - public function getDefaultAvatarUrl() - { - return $this->tools->getAdminImageUrl('prestashop-avatar.png'); - } -} diff --git a/src/Adapter/Employee/ContextEmployeeProvider.php b/src/Adapter/Employee/ContextEmployeeProvider.php deleted file mode 100644 index 4ed253ba..00000000 --- a/src/Adapter/Employee/ContextEmployeeProvider.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Employee; - -use Employee; -use PrestaShop\PrestaShop\Core\Employee\ContextEmployeeProviderInterface; - -/** - * Class ContextEmployeeProvider provides context employee data. - */ -final class ContextEmployeeProvider implements ContextEmployeeProviderInterface -{ - /** - * @var Employee - */ - private $contextEmployee; - - /** - * @param Employee $contextEmployee - */ - public function __construct(Employee $contextEmployee) - { - $this->contextEmployee = $contextEmployee; - } - - /** - * {@inheritdoc} - */ - public function isSuperAdmin() - { - return $this->contextEmployee->isSuperAdmin(); - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return (int) $this->contextEmployee->id; - } - - /** - * {@inheritdoc} - */ - public function getLanguageId() - { - return (int) $this->contextEmployee->id_lang; - } - - /** - * {@inheritdoc} - */ - public function getProfileId() - { - return (int) $this->contextEmployee->id_profile; - } - - /** - * {@inheritdoc} - */ - public function getData() - { - return [ - 'id' => (int) $this->contextEmployee->id, - 'profileId' => (int) $this->contextEmployee->id_profile, - 'languageId' => (int) $this->contextEmployee->id_lang, - 'firstname' => $this->contextEmployee->firstname, - 'lastname' => $this->contextEmployee->lastname, - 'email' => $this->contextEmployee->email, - ]; - } -} diff --git a/src/Adapter/Employee/EmployeeDataProvider.php b/src/Adapter/Employee/EmployeeDataProvider.php deleted file mode 100644 index 4bf33632..00000000 --- a/src/Adapter/Employee/EmployeeDataProvider.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Employee; - -use Employee; -use PrestaShop\PrestaShop\Core\Employee\EmployeeDataProviderInterface; - -/** - * Class EmployeeDataProvider provides employee data using legacy logic. - */ -final class EmployeeDataProvider implements EmployeeDataProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getEmployeeHashedPassword($employeeId) - { - $employee = new Employee($employeeId); - - return (string) $employee->passwd; - } - - /** - * {@inheritdoc} - */ - public function isSuperAdmin($employeeId) - { - $employee = new Employee($employeeId); - - return $employee->isSuperAdmin(); - } -} diff --git a/src/Adapter/Employee/EmployeeFormAccessChecker.php b/src/Adapter/Employee/EmployeeFormAccessChecker.php deleted file mode 100644 index d5342095..00000000 --- a/src/Adapter/Employee/EmployeeFormAccessChecker.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Employee; - -use PrestaShop\PrestaShop\Core\Employee\Access\EmployeeFormAccessCheckerInterface; -use PrestaShop\PrestaShop\Core\Employee\ContextEmployeeProviderInterface; -use PrestaShop\PrestaShop\Core\Employee\EmployeeDataProviderInterface; -use PrestaShopBundle\Entity\Repository\TabRepository; -use Tab; - -/** - * Class EmployeeFormAccessChecker checks employee's access to the employee form. - */ -final class EmployeeFormAccessChecker implements EmployeeFormAccessCheckerInterface -{ - /** - * @var ContextEmployeeProviderInterface - */ - private $contextEmployeeProvider; - - /** - * @var TabRepository - */ - private $tabRepository; - - /** - * @var EmployeeDataProviderInterface - */ - private $employeeDataProvider; - - /** - * @param ContextEmployeeProviderInterface $contextEmployeeProvider - * @param EmployeeDataProviderInterface $employeeDataProvider - * @param TabRepository $tabRepository - */ - public function __construct( - ContextEmployeeProviderInterface $contextEmployeeProvider, - EmployeeDataProviderInterface $employeeDataProvider, - TabRepository $tabRepository - ) { - $this->contextEmployeeProvider = $contextEmployeeProvider; - $this->employeeDataProvider = $employeeDataProvider; - $this->tabRepository = $tabRepository; - } - - /** - * {@inheritdoc} - */ - public function isRestrictedAccess($employeeId) - { - if (!is_int($employeeId)) { - throw new \InvalidArgumentException(sprintf('Employee ID must be an integer, %s given', gettype($employeeId))); - } - - return $employeeId === $this->contextEmployeeProvider->getId(); - } - - /** - * {@inheritdoc} - */ - public function canAccessEditFormFor($employeeId) - { - // To access super admin edit form you must be a super admin. - if ($this->employeeDataProvider->isSuperAdmin($employeeId)) { - return $this->contextEmployeeProvider->isSuperAdmin(); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function canAccessAddonsConnect() - { - return Tab::checkTabRights( - $this->tabRepository->findOneIdByClassName('AdminModulesController') - ); - } -} diff --git a/src/Adapter/Employee/FormLanguageChanger.php b/src/Adapter/Employee/FormLanguageChanger.php deleted file mode 100644 index 11bf4c32..00000000 --- a/src/Adapter/Employee/FormLanguageChanger.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Employee; - -use Language; -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use PrestaShop\PrestaShop\Core\Employee\FormLanguageChangerInterface; - -/** - * Class FormLanguageChanger is responsible for changing the language, - * which is used in forms by the employee. - * It is not the language in which form texts are translated, but rather - * the language, which is selected by default in the translatable fields. - */ -final class FormLanguageChanger implements FormLanguageChangerInterface -{ - /** - * @var LegacyContext - */ - private $legacyContext; - - /** - * @param LegacyContext $legacyContext - */ - public function __construct(LegacyContext $legacyContext) - { - $this->legacyContext = $legacyContext; - } - - /** - * {@inheritdoc} - */ - public function changeLanguageInCookies($languageIsoCode) - { - $this->legacyContext->getContext()->cookie->employee_form_lang = (int) Language::getIdByIso($languageIsoCode); - $this->legacyContext->getContext()->cookie->write(); - } -} diff --git a/src/Adapter/Employee/NavigationMenuToggler.php b/src/Adapter/Employee/NavigationMenuToggler.php deleted file mode 100644 index e39f2722..00000000 --- a/src/Adapter/Employee/NavigationMenuToggler.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Employee; - -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use PrestaShop\PrestaShop\Core\Employee\NavigationMenuTogglerInterface; - -/** - * Class NavigationMenuToggler handles collapsing/expanding the navigation for context employee. - */ -final class NavigationMenuToggler implements NavigationMenuTogglerInterface -{ - /** - * @var LegacyContext - */ - private $legacyContext; - - /** - * @param LegacyContext $legacyContext - */ - public function __construct(LegacyContext $legacyContext) - { - $this->legacyContext = $legacyContext; - } - - /** - * {@inheritdoc} - */ - public function toggleNavigationMenuInCookies($shouldCollapse) - { - $this->legacyContext->getContext()->cookie->collapse_menu = (int) $shouldCollapse; - $this->legacyContext->getContext()->cookie->write(); - } -} diff --git a/src/Adapter/EntityMapper.php b/src/Adapter/EntityMapper.php deleted file mode 100644 index 36b69cb8..00000000 --- a/src/Adapter/EntityMapper.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use Cache; -use Db; -use DbQuery; -use Shop; - -/** - * Not used in PrestaShop core, only in tests. - * - * @deprecated since 1.7.5, to be removed in 1.8 - */ -class EntityMapper -{ - /** - * Load ObjectModel. - * - * @param $id - * @param $id_lang - * @param $entity \ObjectModel - * @param $entity_defs - * @param $id_shop - * @param $should_cache_objects - * - * @throws \PrestaShopDatabaseException - */ - public function load($id, $id_lang, $entity, $entity_defs, $id_shop, $should_cache_objects) - { - // Load object from database if object id is present - $cache_id = 'objectmodel_' . $entity_defs['classname'] . '_' . (int) $id . '_' . (int) $id_shop . '_' . (int) $id_lang; - if (!$should_cache_objects || !\Cache::isStored($cache_id)) { - $sql = new DbQuery(); - $sql->from($entity_defs['table'], 'a'); - $sql->where('a.`' . bqSQL($entity_defs['primary']) . '` = ' . (int) $id); - - // Get lang informations - if ($id_lang && isset($entity_defs['multilang']) && $entity_defs['multilang']) { - $sql->leftJoin($entity_defs['table'] . '_lang', 'b', 'a.`' . bqSQL($entity_defs['primary']) . '` = b.`' . bqSQL($entity_defs['primary']) . '` AND b.`id_lang` = ' . (int) $id_lang); - if ($id_shop && !empty($entity_defs['multilang_shop'])) { - $sql->where('b.`id_shop` = ' . (int) $id_shop); - } - } - - // Get shop informations - if (Shop::isTableAssociated($entity_defs['table'])) { - $sql->leftJoin($entity_defs['table'] . '_shop', 'c', 'a.`' . bqSQL($entity_defs['primary']) . '` = c.`' . bqSQL($entity_defs['primary']) . '` AND c.`id_shop` = ' . (int) $id_shop); - } - - if ($object_datas = Db::getInstance()->getRow($sql)) { - if (!$id_lang && isset($entity_defs['multilang']) && $entity_defs['multilang']) { - $sql = 'SELECT * - FROM `' . bqSQL(_DB_PREFIX_ . $entity_defs['table']) . '_lang` - WHERE `' . bqSQL($entity_defs['primary']) . '` = ' . (int) $id - . (($id_shop && $entity->isLangMultishop()) ? ' AND `id_shop` = ' . (int) $id_shop : ''); - - if ($object_datas_lang = Db::getInstance()->executeS($sql)) { - foreach ($object_datas_lang as $row) { - foreach ($row as $key => $value) { - if ($key != $entity_defs['primary'] && array_key_exists($key, $entity)) { - if (!isset($object_datas[$key]) || !is_array($object_datas[$key])) { - $object_datas[$key] = []; - } - - $object_datas[$key][$row['id_lang']] = $value; - } - } - } - } - } - $entity->id = (int) $id; - foreach ($object_datas as $key => $value) { - if (array_key_exists($key, $entity_defs['fields']) - || array_key_exists($key, $entity)) { - $entity->{$key} = $value; - } else { - unset($object_datas[$key]); - } - } - if ($should_cache_objects) { - Cache::store($cache_id, $object_datas); - } - } - } else { - $object_datas = Cache::retrieve($cache_id); - if ($object_datas) { - $entity->id = (int) $id; - foreach ($object_datas as $key => $value) { - $entity->{$key} = $value; - } - } - } - } -} diff --git a/src/Adapter/EntityMetaDataRetriever.php b/src/Adapter/EntityMetaDataRetriever.php deleted file mode 100644 index b85ea9d9..00000000 --- a/src/Adapter/EntityMetaDataRetriever.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use PrestaShop\PrestaShop\Core\Foundation\Database\EntityMetaData; - -/** - * Retrieve all meta data of an ObjectModel. - */ -class EntityMetaDataRetriever -{ - /** - * @param string $className - * - * @return EntityMetaData - * - * @throws \PrestaShop\PrestaShop\Adapter\CoreException - */ - public function getEntityMetaData($className) - { - $metaData = new EntityMetaData(); - - $metaData->setEntityClassName($className); - - if (property_exists($className, 'definition')) { - // Legacy entity - $classVars = get_class_vars($className); - $metaData->setTableName($classVars['definition']['table']); - $metaData->setPrimaryKeyFieldNames([$classVars['definition']['primary']]); - } else { - throw new CoreException(sprintf('Cannot get metadata for entity `%s`.', $className)); - } - - return $metaData; - } -} diff --git a/src/Adapter/Environment.php b/src/Adapter/Environment.php deleted file mode 100644 index 80fa4ce9..00000000 --- a/src/Adapter/Environment.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use PrestaShop\PrestaShop\Core\EnvironmentInterface; - -/** - * Class Environment is used to store/access environment information like the current - * environment name or to know if debug mode is enabled. It can be built via - * dependency injection but it also manages default fallback based on legacy PrestaShop - * const. - */ -class Environment implements EnvironmentInterface -{ - /** - * @var bool - */ - private $isDebug; - - /** - * @var string - */ - private $name; - - /** - * @param bool|null $isDebug - * @param string|null $name - */ - public function __construct($isDebug = null, $name = null) - { - if (null === $isDebug) { - $this->isDebug = defined(_PS_MODE_DEV_) ? _PS_MODE_DEV_ : true; - } else { - $this->isDebug = $isDebug; - } - - if (null !== $name) { - $this->name = $name; - } else { - if (defined(_PS_ENV_)) { - $this->name = _PS_ENV_; - } else { - $this->name = $this->isDebug ? 'dev' : 'prod'; - } - } - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function isDebug() - { - return $this->isDebug; - } - - /** - * {@inheritdoc} - */ - public function getCacheDir() - { - if (defined('_PS_CACHE_DIR_')) { - return _PS_CACHE_DIR_; - } - - return _PS_ROOT_DIR_ . '/var/cache/' . $this->getName() . '/'; - } -} diff --git a/src/Adapter/Feature/CombinationFeature.php b/src/Adapter/Feature/CombinationFeature.php deleted file mode 100644 index 58ca6a00..00000000 --- a/src/Adapter/Feature/CombinationFeature.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Feature; - -use Combination; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Feature\FeatureInterface; - -/** - * This class manages Combination feature. - */ -class CombinationFeature implements FeatureInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function isUsed() - { - return Combination::isCurrentlyUsed(); - } - - /** - * {@inheritdoc} - */ - public function isActive() - { - return Combination::isFeatureActive(); - } - - /** - * {@inheritdoc} - */ - public function enable() - { - $this->configuration->set('PS_COMBINATION_FEATURE_ACTIVE', true); - } - - /** - * {@inheritdoc} - */ - public function disable() - { - $this->configuration->set('PS_COMBINATION_FEATURE_ACTIVE', false); - } - - /** - * {@inheritdoc} - */ - public function update($status) - { - true === $status ? $this->enable() : $this->disable(); - } -} diff --git a/src/Adapter/Feature/CommandHandler/AddFeatureHandler.php b/src/Adapter/Feature/CommandHandler/AddFeatureHandler.php deleted file mode 100644 index c62172a9..00000000 --- a/src/Adapter/Feature/CommandHandler/AddFeatureHandler.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Feature\CommandHandler; - -use Feature; -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use PrestaShop\PrestaShop\Core\Domain\Feature\Command\AddFeatureCommand; -use PrestaShop\PrestaShop\Core\Domain\Feature\CommandHandler\AddFeatureHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Feature\Exception\CannotAddFeatureException; -use PrestaShop\PrestaShop\Core\Domain\Feature\Exception\FeatureConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Feature\ValueObject\FeatureId; - -/** - * Handles adding of features using legacy logic. - */ -final class AddFeatureHandler extends AbstractObjectModelHandler implements AddFeatureHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(AddFeatureCommand $command) - { - $feature = new Feature(); - - $feature->name = $command->getLocalizedNames(); - - if (false === $feature->validateFields(false)) { - throw new FeatureConstraintException('Invalid feature data'); - } - - if (false === $feature->validateFieldsLang(false)) { - throw new FeatureConstraintException('Invalid feature data', FeatureConstraintException::INVALID_NAME); - } - - if (false === $feature->add()) { - throw new CannotAddFeatureException('Unable to create new feature'); - } - - $this->associateWithShops($feature, $command->getShopAssociation()); - - return new FeatureId($feature->id); - } -} diff --git a/src/Adapter/Feature/CommandHandler/EditFeatureHandler.php b/src/Adapter/Feature/CommandHandler/EditFeatureHandler.php deleted file mode 100644 index ce8df8c1..00000000 --- a/src/Adapter/Feature/CommandHandler/EditFeatureHandler.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Feature\CommandHandler; - -use Feature; -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use PrestaShop\PrestaShop\Core\Domain\Feature\Command\EditFeatureCommand; -use PrestaShop\PrestaShop\Core\Domain\Feature\CommandHandler\EditFeatureHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Feature\Exception\CannotEditFeatureException; -use PrestaShop\PrestaShop\Core\Domain\Feature\Exception\FeatureConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Feature\Exception\FeatureNotFoundException; - -/** - * Handles feature editing. - */ -final class EditFeatureHandler extends AbstractObjectModelHandler implements EditFeatureHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(EditFeatureCommand $command) - { - $feature = new Feature($command->getFeatureId()->getValue()); - - if (empty($feature->id)) { - throw new FeatureNotFoundException('Feature could not be found.'); - } - - if (null !== $command->getLocalizedNames()) { - $feature->name = $command->getLocalizedNames(); - } - - if (null !== $command->getAssociatedShopIds()) { - $this->associateWithShops($feature, $command->getAssociatedShopIds()); - } - - if (false === $feature->validateFields(false)) { - throw new FeatureConstraintException('Invalid data when updating feature'); - } - - if (false === $feature->validateFieldsLang(false)) { - throw new FeatureConstraintException('Invalid data when updating feature', FeatureConstraintException::INVALID_NAME); - } - - if (false === $feature->update()) { - throw new CannotEditFeatureException(sprintf('Failed to edit Feature with id "%s".', $feature->id)); - } - } -} diff --git a/src/Adapter/Feature/FeatureDataProvider.php b/src/Adapter/Feature/FeatureDataProvider.php deleted file mode 100644 index 5023a3fd..00000000 --- a/src/Adapter/Feature/FeatureDataProvider.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Feature; - -use Feature; -use FeatureValue; - -/** - * This class will provide data from DB / ORM about Feature. - */ -class FeatureDataProvider -{ - /** - * Get all features for a given language. - * - * @param int $id_lang Language id - * @param bool $with_shop - * - * @return array Multiple arrays with feature's data - */ - public static function getFeatures($id_lang, $with_shop = true) - { - return Feature::getFeatures($id_lang, $with_shop); - } - - /** - * Get all values for a given feature and language. - * - * @param int $id_lang Language id - * @param int $id_feature Feature id - * @param bool $custom - * - * @return array Array with feature's values - */ - public static function getFeatureValuesWithLang($id_lang, $id_feature, $custom = false) - { - return FeatureValue::getFeatureValuesWithLang($id_lang, $id_feature, $custom); - } - - /** - * Get all language for a given value. - * - * @param bool $id_feature_value Feature value id - * - * @return array Array with value's languages - */ - public static function getFeatureValueLang($id_feature_value) - { - return FeatureValue::getFeatureValueLang($id_feature_value); - } -} diff --git a/src/Adapter/Feature/FeatureFeature.php b/src/Adapter/Feature/FeatureFeature.php deleted file mode 100644 index 3b0e3d5c..00000000 --- a/src/Adapter/Feature/FeatureFeature.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Feature; - -use Feature; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Feature\FeatureInterface; - -/** - * This class manages Feature feature. - */ -class FeatureFeature implements FeatureInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function isUsed() - { - return Feature::isCurrentlyUsed(); - } - - /** - * {@inheritdoc} - */ - public function isActive() - { - return Feature::isFeatureActive(); - } - - /** - * {@inheritdoc} - */ - public function enable() - { - $this->configuration->set('PS_FEATURE_FEATURE_ACTIVE', true); - } - - /** - * {@inheritdoc} - */ - public function disable() - { - $this->configuration->set('PS_FEATURE_FEATURE_ACTIVE', false); - } - - /** - * {@inheritdoc} - */ - public function update($status) - { - true === $status ? $this->enable() : $this->disable(); - } -} diff --git a/src/Adapter/Feature/GroupFeature.php b/src/Adapter/Feature/GroupFeature.php deleted file mode 100644 index 186bcaae..00000000 --- a/src/Adapter/Feature/GroupFeature.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Feature; - -use Group; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Feature\FeatureInterface; - -/** - * This class manages Group feature. - */ -class GroupFeature implements FeatureInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function isUsed() - { - return Group::isCurrentlyUsed(); - } - - /** - * {@inheritdoc} - */ - public function isActive() - { - return Group::isFeatureActive(); - } - - /** - * {@inheritdoc} - */ - public function enable() - { - $this->configuration->set('PS_GROUP_FEATURE_ACTIVE', true); - } - - /** - * {@inheritdoc} - */ - public function disable() - { - $this->configuration->set('PS_GROUP_FEATURE_ACTIVE', false); - } - - /** - * {@inheritdoc} - */ - public function update($status) - { - true === $status ? $this->enable() : $this->disable(); - } -} diff --git a/src/Adapter/Feature/MultistoreFeature.php b/src/Adapter/Feature/MultistoreFeature.php deleted file mode 100644 index 42c37232..00000000 --- a/src/Adapter/Feature/MultistoreFeature.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Feature; - -use PrestaShop\PrestaShop\Adapter\Entity\Shop; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Feature\FeatureInterface; -use PrestaShop\PrestaShop\Core\Multistore\MultistoreConfig; - -/** - * Class MultistoreFeature provides data about multishop feature usage. - * - * @internal - */ -final class MultistoreFeature implements FeatureInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function isUsed() - { - // internally it checks if feature is active - // and at least 2 shops exist - return Shop::isFeatureActive(); - } - - /** - * {@inheritdoc} - */ - public function isActive() - { - return (bool) $this->configuration->get(MultistoreConfig::FEATURE_STATUS); - } - - /** - * {@inheritdoc} - */ - public function enable() - { - $this->configuration->set(MultistoreConfig::FEATURE_STATUS, 1); - } - - /** - * {@inheritdoc} - */ - public function disable() - { - $this->configuration->set(MultistoreConfig::FEATURE_STATUS, 0); - } - - /** - * {@inheritdoc} - */ - public function update($status) - { - $status ? $this->enable() : $this->disable(); - } -} diff --git a/src/Adapter/Feature/QueryHandler/GetFeatureForEditingHandler.php b/src/Adapter/Feature/QueryHandler/GetFeatureForEditingHandler.php deleted file mode 100644 index da6ad252..00000000 --- a/src/Adapter/Feature/QueryHandler/GetFeatureForEditingHandler.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Feature\QueryHandler; - -use Feature; -use PrestaShop\PrestaShop\Core\Domain\Feature\Exception\FeatureNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Feature\Query\GetFeatureForEditing; -use PrestaShop\PrestaShop\Core\Domain\Feature\QueryHandler\GetFeatureForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Feature\QueryResult\EditableFeature; - -/** - * Handles get feature for editing query. - */ -final class GetFeatureForEditingHandler implements GetFeatureForEditingHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GetFeatureForEditing $query) - { - $feature = new Feature($query->getFeatureId()->getValue()); - - if (empty($feature->id)) { - throw new FeatureNotFoundException('Feature could not be found.'); - } - - return new EditableFeature( - $query->getFeatureId(), - $feature->name, - $feature->getAssociatedShops() - ); - } -} diff --git a/src/Adapter/File/HtaccessFileGenerator.php b/src/Adapter/File/HtaccessFileGenerator.php deleted file mode 100644 index e84480f5..00000000 --- a/src/Adapter/File/HtaccessFileGenerator.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\File; - -use PrestaShop\PrestaShop\Adapter\Cache\CacheClearer; -use PrestaShop\PrestaShop\Adapter\Tools; - -/** - * Class HtaccessFileGenerator is responsible for generating htaccess file with its default content. - */ -class HtaccessFileGenerator -{ - /** - * @var CacheClearer - */ - private $cacheClearer; - - /** - * @var Tools - */ - private $tools; - - /** - * @var bool - */ - private $multipleViewsConfiguration; - - /** - * HtaccessFileGenerator constructor. - * - * @param CacheClearer $cacheClearer - * @param Tools $tools - * @param bool $multipleViewsConfiguration - */ - public function __construct(CacheClearer $cacheClearer, Tools $tools, $multipleViewsConfiguration) - { - $this->cacheClearer = $cacheClearer; - $this->tools = $tools; - $this->multipleViewsConfiguration = $multipleViewsConfiguration; - } - - /** - * Generates htaccess file and its content. - * - * @param bool|null $disableMultiView if null, rely on the Shop configuration - * - * @return bool - */ - public function generateFile($disableMultiView = null) - { - if (null === $disableMultiView) { - $disableMultiView = $this->multipleViewsConfiguration; - } - - $isGenerated = $disableMultiView ? $this->tools->generateHtaccessWithMultiViews() : $this->tools->generateHtaccessWithoutMultiViews(); - - if ($isGenerated) { - $this->cacheClearer->clearAllCaches(); - } - - return $isGenerated; - } -} diff --git a/src/Adapter/File/RobotsTextFileGenerator.php b/src/Adapter/File/RobotsTextFileGenerator.php deleted file mode 100644 index c5c79e69..00000000 --- a/src/Adapter/File/RobotsTextFileGenerator.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\File; - -use Tools; - -/** - * Class RobotsTextFileGenerator is responsible for generating robots txt file. - */ -class RobotsTextFileGenerator -{ - /** - * Generates the robots.txt file. - * - * @return bool - */ - public function generateFile() - { - return Tools::generateRobotsFile(true); - } -} diff --git a/src/Adapter/File/Uploader/AttachmentFileUploader.php b/src/Adapter/File/Uploader/AttachmentFileUploader.php deleted file mode 100644 index 54cff044..00000000 --- a/src/Adapter/File/Uploader/AttachmentFileUploader.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\File\Uploader; - -use Attachment; -use ErrorException; -use PrestaShop\PrestaShop\Core\Configuration\UploadSizeConfigurationInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Attachment\AttachmentFileUploaderInterface; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentUploadFailedException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\CannotUnlinkAttachmentException; -use PrestaShopException; -use Symfony\Component\HttpFoundation\File\Exception\FileException; - -/** - * Uploads attachment file and if needed deletes old attachment file - * - * @internal - */ -final class AttachmentFileUploader implements AttachmentFileUploaderInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var UploadSizeConfigurationInterface - */ - private $uploadSizeConfiguration; - - public function __construct( - ConfigurationInterface $configuration, - UploadSizeConfigurationInterface $uploadSizeConfiguration - ) { - $this->configuration = $configuration; - $this->uploadSizeConfiguration = $uploadSizeConfiguration; - } - - /** - * {@inheritdoc} - * - * @throws AttachmentConstraintException - * @throws AttachmentNotFoundException - * @throws AttachmentUploadFailedException - */ - public function upload( - string $filePath, - string $uniqueFileName, - int $fileSize, - int $id = null, - $throwExceptionOnFailure = true - ): void { - $this->checkFileAllowedForUpload($fileSize); - $this->uploadFile($filePath, $uniqueFileName, $fileSize); - if ($id !== null) { - $this->deleteOldFile($id, $throwExceptionOnFailure); - } - } - - /** - * @param bool $throwExceptionOnFailure - * - * @throws AttachmentNotFoundException - * @throws CannotUnlinkAttachmentException - */ - private function deleteOldFile(int $attachmentId, $throwExceptionOnFailure): void - { - try { - $attachment = new Attachment($attachmentId); - $fileLink = _PS_DOWNLOAD_DIR_ . $attachment->file; - - try { - unlink($fileLink); - } catch (ErrorException $e) { - if ($throwExceptionOnFailure) { - throw new CannotUnlinkAttachmentException($e->getMessage(), 0, null, $fileLink); - } - } - } catch (PrestaShopException $e) { - throw new AttachmentNotFoundException(sprintf('Attachment with id "%s" was not found.', $attachmentId)); - } - } - - /** - * @throws AttachmentConstraintException - * @throws AttachmentUploadFailedException - */ - private function uploadFile(string $filePath, string $uniqid, int $fileSize): void - { - if ($fileSize > ($this->configuration->get('PS_ATTACHMENT_MAXIMUM_SIZE') * 1024 * 1024)) { - throw new AttachmentConstraintException( - sprintf( - 'Max file size allowed is "%s" bytes. Uploaded file size is "%s".', - (string) ($this->configuration->get('PS_ATTACHMENT_MAXIMUM_SIZE') * 1024), - number_format(($fileSize / 1024), 2, '.', '') - ), - AttachmentConstraintException::INVALID_FILE_SIZE - ); - } - - try { - move_uploaded_file($filePath, _PS_DOWNLOAD_DIR_ . $uniqid); - } catch (FileException $e) { - throw new AttachmentUploadFailedException(sprintf('Failed to copy the file %s.', $filePath)); - } - } - - /** - * @throws AttachmentConstraintException - */ - private function checkFileAllowedForUpload(int $fileSize): void - { - $maxFileSize = $this->uploadSizeConfiguration->getMaxUploadSizeInBytes(); - - if ($maxFileSize > 0 && $fileSize > $maxFileSize) { - throw new AttachmentConstraintException( - sprintf('Max file size allowed is "%s" bytes. Uploaded file size is "%s".', $maxFileSize, $fileSize), - AttachmentConstraintException::INVALID_FILE_SIZE - ); - } - } -} diff --git a/src/Adapter/Form/ChoiceProvider/CarrierForOrderChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/CarrierForOrderChoiceProvider.php deleted file mode 100644 index 997aa0e9..00000000 --- a/src/Adapter/Form/ChoiceProvider/CarrierForOrderChoiceProvider.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use Address; -use Carrier; -use Cart; -use Customer; -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * @internal - */ -final class CarrierForOrderChoiceProvider implements ConfigurableFormChoiceProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getChoices(array $options): array - { - $options = $this->resolveOptions($options); - - $cart = Cart::getCartByOrderId($options['order_id']); - $groups = Customer::getGroupsStatic((int) $cart->id_customer); - $address = new Address((int) $cart->id_address_delivery); - - $carriers = Carrier::getCarriersForOrder(Address::getZoneById((int) $address->id), $groups, $cart); - $choices = []; - - foreach ($carriers as $carrier) { - $delay = $carrier['delay'] ? sprintf(' (%s)', $carrier['delay']) : ''; - - $choices[$carrier['name'] . $delay] = (int) $carrier['id_carrier']; - } - - return $choices; - } - - /** - * @param array $options - * - * @return array - */ - private function resolveOptions(array $options): array - { - $resolver = new OptionsResolver(); - $resolver->setRequired([ - 'order_id', - ]); - $resolver->setAllowedTypes('order_id', 'int'); - - return $resolver->resolve($options); - } -} diff --git a/src/Adapter/Form/ChoiceProvider/CategoryTreeChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/CategoryTreeChoiceProvider.php deleted file mode 100644 index 1c8285af..00000000 --- a/src/Adapter/Form/ChoiceProvider/CategoryTreeChoiceProvider.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Adapter\Category\CategoryDataProvider; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class CategoryTreeChoiceProvider provides categories as tree choices. - */ -final class CategoryTreeChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var CategoryDataProvider - */ - private $categoryDataProvider; - - /** - * @var int - */ - private $contextShopRootCategoryId; - - /** - * @var bool - */ - private $enabledCategoriesOnly; - - /** - * @param CategoryDataProvider $categoryDataProvider - * @param int $contextShopRootCategoryId - * @param bool $enabledCategoriesOnly - */ - public function __construct(CategoryDataProvider $categoryDataProvider, $contextShopRootCategoryId, $enabledCategoriesOnly = false) - { - $this->categoryDataProvider = $categoryDataProvider; - $this->contextShopRootCategoryId = $contextShopRootCategoryId; - $this->enabledCategoriesOnly = $enabledCategoriesOnly; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $categories = $this->categoryDataProvider->getNestedCategories($this->contextShopRootCategoryId, false, $this->enabledCategoriesOnly); - $choices = []; - - foreach ($categories as $category) { - $choices[] = $this->buildChoiceTree($category); - } - - return $choices; - } - - /** - * @param array $category - * - * @return array - */ - private function buildChoiceTree(array $category) - { - $tree = [ - 'id_category' => $category['id_category'], - 'name' => $category['name'], - ]; - - if (isset($category['children'])) { - foreach ($category['children'] as $childCategory) { - $tree['children'][] = $this->buildChoiceTree($childCategory); - } - } - - return $tree; - } -} diff --git a/src/Adapter/Form/ChoiceProvider/CountryStateByIdChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/CountryStateByIdChoiceProvider.php deleted file mode 100644 index cae03303..00000000 --- a/src/Adapter/Form/ChoiceProvider/CountryStateByIdChoiceProvider.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use Country; -use PrestaShop\PrestaShop\Core\Exception\CoreException; -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; -use PrestaShopException; -use State; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Provides choices of country states with state name as key and id as value - */ -final class CountryStateByIdChoiceProvider implements ConfigurableFormChoiceProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getChoices(array $options) - { - $resolver = new OptionsResolver(); - $this->configureOptions($resolver); - $resolvedOptions = $resolver->resolve($options); - $choices = []; - - try { - $countryId = $resolvedOptions['id_country']; - $countryHasStates = (new Country($countryId))->contains_states; - - if (!$countryHasStates) { - return []; - } - - $states = State::getStatesByIdCountry($countryId, $resolvedOptions['only_active']); - - foreach ($states as $state) { - $choices[$state['name']] = $state['id_state']; - } - } catch (PrestaShopException $e) { - throw new CoreException(sprintf('An error occurred when getting states for country id "%s"', $countryId)); - } - - return $choices; - } - - /** - * Configures array parameters and default values - * - * @param OptionsResolver $resolver - */ - private function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults(['only_active' => false]); - $resolver->setRequired('id_country'); - $resolver->setAllowedTypes('id_country', 'int'); - $resolver->setAllowedTypes('only_active', 'bool'); - $this->allowIdCountryGreaterThanZero($resolver); - } - - /** - * @param OptionsResolver $resolver - */ - private function allowIdCountryGreaterThanZero(OptionsResolver $resolver) - { - $resolver->setAllowedValues('id_country', function ($value) { - return 0 < $value; - }); - } -} diff --git a/src/Adapter/Form/ChoiceProvider/CurrencySymbolByIdChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/CurrencySymbolByIdChoiceProvider.php deleted file mode 100644 index c7efe859..00000000 --- a/src/Adapter/Form/ChoiceProvider/CurrencySymbolByIdChoiceProvider.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use Currency; -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; - -/** - * Provides currency choices where currency is represented by symbol (e.g. € for euro) and value is currency id. - */ -final class CurrencySymbolByIdChoiceProvider implements ConfigurableFormChoiceProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getChoices(array $options): array - { - $currencies = Currency::getCurrenciesByIdShop($options['id_shop']); - $choices = []; - - foreach ($currencies as $currency) { - $choices[$currency['symbol']] = (int) $currency['id_currency']; - } - - return $choices; - } -} diff --git a/src/Adapter/Form/ChoiceProvider/EmployeeNameByIdChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/EmployeeNameByIdChoiceProvider.php deleted file mode 100644 index e348d7b6..00000000 --- a/src/Adapter/Form/ChoiceProvider/EmployeeNameByIdChoiceProvider.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use Employee; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * @internal - */ -final class EmployeeNameByIdChoiceProvider implements FormChoiceProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getChoices() - { - $employees = Employee::getEmployees(); - - $choices = []; - - foreach ($employees as $employee) { - $name = sprintf('%s. %s', substr($employee['firstname'], 0, 1), $employee['lastname']); - - $choices[$name] = (int) $employee['id_employee']; - } - - return $choices; - } -} diff --git a/src/Adapter/Form/ChoiceProvider/GenderByIdChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/GenderByIdChoiceProvider.php deleted file mode 100644 index 4309429f..00000000 --- a/src/Adapter/Form/ChoiceProvider/GenderByIdChoiceProvider.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use Gender; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class GenderByIdChoiceProvider provides gender choices with label as title and value as gender id. - */ -final class GenderByIdChoiceProvider implements FormChoiceProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getChoices() - { - $genders = Gender::getGenders(); - $choices = []; - - /** @var Gender $gender */ - foreach ($genders as $gender) { - $choices[$gender->name] = $gender->id; - } - - return $choices; - } -} diff --git a/src/Adapter/Form/ChoiceProvider/GroupByIdChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/GroupByIdChoiceProvider.php deleted file mode 100644 index 624fb5d3..00000000 --- a/src/Adapter/Form/ChoiceProvider/GroupByIdChoiceProvider.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use Group; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Provides choices for customer groups - */ -final class GroupByIdChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var int - */ - private $contextLangId; - - /** - * @param ConfigurationInterface $configuration - * @param int $contextLangId - */ - public function __construct(ConfigurationInterface $configuration, $contextLangId) - { - $this->configuration = $configuration; - $this->contextLangId = $contextLangId; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $choices = []; - $groups = Group::getGroups($this->contextLangId, true); - - $groupsToSkip = [ - (int) $this->configuration->get('PS_UNIDENTIFIED_GROUP'), - (int) $this->configuration->get('PS_GUEST_GROUP'), - ]; - - foreach ($groups as $group) { - $groupId = $group['id_group']; - - if (in_array($groups, $groupsToSkip)) { - continue; - } - - $choices[$group['name']] = (int) $groupId; - } - - return $choices; - } -} diff --git a/src/Adapter/Form/ChoiceProvider/InstalledPaymentModulesChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/InstalledPaymentModulesChoiceProvider.php deleted file mode 100644 index da0a982b..00000000 --- a/src/Adapter/Form/ChoiceProvider/InstalledPaymentModulesChoiceProvider.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use Module; -use PaymentModule; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Validate; - -final class InstalledPaymentModulesChoiceProvider implements FormChoiceProviderInterface -{ - private static $paymentModules; - - /** - * {@inheritdoc} - */ - public function getChoices(): array - { - if (!self::$paymentModules) { - self::$paymentModules = []; - - foreach (PaymentModule::getInstalledPaymentModules() as $payment) { - $module = Module::getInstanceByName($payment['name']); - if (Validate::isLoadedObject($module) && $module->active) { - self::$paymentModules[$module->name] = $module->displayName; - } - } - } - - return self::$paymentModules; - } -} diff --git a/src/Adapter/Form/ChoiceProvider/ManufacturerNameByIdChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/ManufacturerNameByIdChoiceProvider.php deleted file mode 100644 index 0c463538..00000000 --- a/src/Adapter/Form/ChoiceProvider/ManufacturerNameByIdChoiceProvider.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Provides choices of manufacturers with manufacturer name as key and id as value - */ -final class ManufacturerNameByIdChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var array - */ - private $manufacturers; - - public function __construct(array $manufacturers) - { - $this->manufacturers = $manufacturers; - } - - /** - * Get choices. - * - * @return array - */ - public function getChoices() - { - $choices = []; - - foreach ($this->manufacturers as $manufacturer) { - $choices[$manufacturer['name']] = (int) $manufacturer['id_manufacturer']; - } - - return $choices; - } -} diff --git a/src/Adapter/Form/ChoiceProvider/OrderCountriesChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/OrderCountriesChoiceProvider.php deleted file mode 100644 index 567b2822..00000000 --- a/src/Adapter/Form/ChoiceProvider/OrderCountriesChoiceProvider.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use Context; -use Country; -use Db; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Shop; - -/** - * Choices for countries in which at least one order has been placed - */ -final class OrderCountriesChoiceProvider implements FormChoiceProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getChoices() - { - if (!Country::isCurrentlyUsed('country', true)) { - return []; - } - - $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(' - SELECT DISTINCT c.id_country, cl.`name` - FROM `' . _DB_PREFIX_ . 'orders` o - ' . Shop::addSqlAssociation('orders', 'o') . ' - INNER JOIN `' . _DB_PREFIX_ . 'address` a - ON a.id_address = o.id_address_delivery - INNER JOIN `' . _DB_PREFIX_ . 'country` c - ON a.id_country = c.id_country - INNER JOIN `' . _DB_PREFIX_ . 'country_lang` cl - ON (c.`id_country` = cl.`id_country` - AND cl.`id_lang` = ' . (int) Context::getContext()->language->id . ') - ORDER BY cl.name ASC' - ); - - $choices = []; - - foreach ($result as $row) { - $choices[$row['name']] = $row['id_country']; - } - - return $choices; - } -} diff --git a/src/Adapter/Form/ChoiceProvider/OrderInvoiceByIdChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/OrderInvoiceByIdChoiceProvider.php deleted file mode 100644 index a92bcd52..00000000 --- a/src/Adapter/Form/ChoiceProvider/OrderInvoiceByIdChoiceProvider.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use Currency; -use Order; -use OrderInvoice; -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; -use PrestaShop\PrestaShop\Core\Localization\LocaleInterface; - -final class OrderInvoiceByIdChoiceProvider implements ConfigurableFormChoiceProviderInterface -{ - /** - * @var LocaleInterface - */ - private $locale; - - /** - * @param LocaleInterface $locale - */ - public function __construct(LocaleInterface $locale) - { - $this->locale = $locale; - } - - /** - * {@inheritdoc} - */ - public function getChoices(array $options): array - { - $order = new Order($options['id_order']); - $invoices = $order->getInvoicesCollection(); - $labelFormat = isset($options['display_total']) && false !== $options['display_total'] ? '%s - %s' : '%s'; - - $choices = []; - - /** @var OrderInvoice $invoice */ - foreach ($invoices as $invoice) { - $invoiceLabel = sprintf( - $labelFormat, - $invoice->getInvoiceNumberFormatted($options['id_lang'], $order->id_shop), - $this->locale->formatPrice($invoice->total_paid_tax_incl, Currency::getIsoCodeById($invoice->getOrder()->id_currency)) - ); - $choices[$invoiceLabel] = $invoice->id; - } - - return $choices; - } -} diff --git a/src/Adapter/Form/ChoiceProvider/ProfileByIdChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/ProfileByIdChoiceProvider.php deleted file mode 100644 index cf120c39..00000000 --- a/src/Adapter/Form/ChoiceProvider/ProfileByIdChoiceProvider.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Profile; - -/** - * Class ProfileByIdChoiceProvider provides employee profile choices with name as label and profile id as value. - */ -final class ProfileByIdChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var int - */ - private $contextLangId; - - /** - * @param int $contextLangId - */ - public function __construct($contextLangId) - { - $this->contextLangId = $contextLangId; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $profiles = Profile::getProfiles($this->contextLangId); - $choices = []; - - foreach ($profiles as $profile) { - $choices[$profile['name']] = $profile['id_profile']; - } - - return $choices; - } -} diff --git a/src/Adapter/Form/ChoiceProvider/ResourcesChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/ResourcesChoiceProvider.php deleted file mode 100644 index 3841fd73..00000000 --- a/src/Adapter/Form/ChoiceProvider/ResourcesChoiceProvider.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use WebserviceRequest; - -/** - * Provides resources that can be accessed by webservice request - * - * @internal - */ -final class ResourcesChoiceProvider implements FormChoiceProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getChoices() - { - $legacyResources = WebserviceRequest::getResources(); - $choices = []; - - foreach (array_keys($legacyResources) as $resource) { - $choices[$resource] = $resource; - } - - return $choices; - } -} diff --git a/src/Adapter/Form/ChoiceProvider/RiskByIdChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/RiskByIdChoiceProvider.php deleted file mode 100644 index 077b57e8..00000000 --- a/src/Adapter/Form/ChoiceProvider/RiskByIdChoiceProvider.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Risk; - -/** - * Class RiskByIdChoiceProvider - * - * @internal - */ -final class RiskByIdChoiceProvider implements FormChoiceProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getChoices() - { - $risks = Risk::getRisks(); - $choices = []; - - /** @var Risk $risk */ - foreach ($risks as $risk) { - $choices[$risk->name] = (int) $risk->id; - } - - return $choices; - } -} diff --git a/src/Adapter/Form/ChoiceProvider/ShopNameByIdChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/ShopNameByIdChoiceProvider.php deleted file mode 100644 index 0c9ec8ef..00000000 --- a/src/Adapter/Form/ChoiceProvider/ShopNameByIdChoiceProvider.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Shop; - -/** - * Provides shop names by name => id value pairs - */ -final class ShopNameByIdChoiceProvider implements FormChoiceProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getChoices() - { - $shopsById = []; - - foreach (Shop::getShops() as $shop) { - $shopsById[$shop['name']] = $shop['id_shop']; - } - - return $shopsById; - } -} diff --git a/src/Adapter/Form/ChoiceProvider/ShopTreeChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/ShopTreeChoiceProvider.php deleted file mode 100644 index dc524b2d..00000000 --- a/src/Adapter/Form/ChoiceProvider/ShopTreeChoiceProvider.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Shop; -use ShopGroup; - -/** - * Class ShopTreeChoiceProvider provides shop choices for choice tree. - * - * @internal - */ -final class ShopTreeChoiceProvider implements FormChoiceProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getChoices() - { - $shopGroups = ShopGroup::getShopGroups(); - $choices = []; - - /** @var ShopGroup $shopGroup */ - foreach ($shopGroups as $shopGroup) { - $shopGroupChoices = [ - 'name' => $shopGroup->name, - 'id_shop' => null, - 'children' => [], - ]; - - $shops = ShopGroup::getShopsFromGroup($shopGroup->id); - - foreach ($shops as $shopId) { - $shop = Shop::getShop($shopId['id_shop']); - - // If context employee doesn't have access to a shop, $shop will be false - if (false === $shop) { - continue; - } - - $shopGroupChoices['children'][] = [ - 'name' => $shop['name'], - 'id_shop' => $shop['id_shop'], - ]; - } - - $choices[] = $shopGroupChoices; - } - - return $choices; - } -} diff --git a/src/Adapter/Form/ChoiceProvider/TaxRuleGroupChoiceProvider.php b/src/Adapter/Form/ChoiceProvider/TaxRuleGroupChoiceProvider.php deleted file mode 100644 index c3bec81d..00000000 --- a/src/Adapter/Form/ChoiceProvider/TaxRuleGroupChoiceProvider.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use TaxRulesGroup; - -/** - * Provides tax rule group choices with tax rule name as key and id as value - */ -final class TaxRuleGroupChoiceProvider implements FormChoiceProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getChoices() - { - $rules = TaxRulesGroup::getTaxRulesGroupsForOptions(); - - $choices = []; - foreach ($rules as $rule) { - $choices[$rule['name']] = $rule['id_tax_rules_group']; - } - - return $choices; - } -} diff --git a/src/Adapter/GeneralConfiguration.php b/src/Adapter/GeneralConfiguration.php deleted file mode 100644 index ff544282..00000000 --- a/src/Adapter/GeneralConfiguration.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * Manages the configuration data about general options. - */ -class GeneralConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'check_modules_update' => $this->configuration->getBoolean('PRESTASTORE_LIVE'), - 'check_ip_address' => $this->configuration->getBoolean('PS_COOKIE_CHECKIP'), - 'front_cookie_lifetime' => $this->configuration->get('PS_COOKIE_LIFETIME_FO'), - 'back_cookie_lifetime' => $this->configuration->get('PS_COOKIE_LIFETIME_BO'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - $errors = []; - - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PRESTASTORE_LIVE', (bool) $configuration['check_modules_update']); - $this->configuration->set('PS_COOKIE_CHECKIP', (bool) $configuration['check_ip_address']); - $this->configuration->set('PS_COOKIE_LIFETIME_FO', (int) $configuration['front_cookie_lifetime']); - $this->configuration->set('PS_COOKIE_LIFETIME_BO', (int) $configuration['back_cookie_lifetime']); - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['check_modules_update'], - $configuration['check_ip_address'], - $configuration['front_cookie_lifetime'], - $configuration['back_cookie_lifetime'] - ); - } -} diff --git a/src/Adapter/Geolocation/GeolocationByIpAddressConfiguration.php b/src/Adapter/Geolocation/GeolocationByIpAddressConfiguration.php deleted file mode 100644 index d68289db..00000000 --- a/src/Adapter/Geolocation/GeolocationByIpAddressConfiguration.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Geolocation; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * Class GeolocationByIpAddressConfiguration is responsible for configuring geolocation configuration. - */ -final class GeolocationByIpAddressConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - /** - * @param Configuration $configuration - */ - public function __construct( - Configuration $configuration - ) { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'geolocation_enabled' => $this->configuration->getBoolean('PS_GEOLOCATION_ENABLED'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $config) - { - if ($this->validateConfiguration($config)) { - $this->configuration->set('PS_GEOLOCATION_ENABLED', $config['geolocation_enabled']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $config) - { - return isset($config['geolocation_enabled']); - } -} diff --git a/src/Adapter/Geolocation/GeolocationIpAddressWhitelistConfiguration.php b/src/Adapter/Geolocation/GeolocationIpAddressWhitelistConfiguration.php deleted file mode 100644 index 8b52b376..00000000 --- a/src/Adapter/Geolocation/GeolocationIpAddressWhitelistConfiguration.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Geolocation; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; - -/** - * Class GeolocationIpAddressWhitelistConfiguration is responsible for configuring geolocation IP address whitelist data. - */ -final class GeolocationIpAddressWhitelistConfiguration implements DataConfigurationInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'geolocation_whitelist' => $this->configuration->get('PS_GEOLOCATION_WHITELIST'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $config) - { - if ($this->validateConfiguration($config)) { - $this->configuration->set('PS_GEOLOCATION_WHITELIST', $config['geolocation_whitelist']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $config) - { - return isset( - $config['geolocation_whitelist'] - ); - } -} diff --git a/src/Adapter/Geolocation/GeolocationOptionsConfiguration.php b/src/Adapter/Geolocation/GeolocationOptionsConfiguration.php deleted file mode 100644 index 6b18610e..00000000 --- a/src/Adapter/Geolocation/GeolocationOptionsConfiguration.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Geolocation; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * Class GeolocationOptionsConfiguration is responsible for configuring geolocation options data. - */ -final class GeolocationOptionsConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - /** - * @param Configuration $configuration - */ - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'geolocation_behaviour' => $this->configuration->get('PS_GEOLOCATION_BEHAVIOR'), - 'geolocation_na_behaviour' => $this->configuration->getInt('PS_GEOLOCATION_NA_BEHAVIOR'), - 'geolocation_countries' => $this->configuration->get('PS_ALLOWED_COUNTRIES'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $config) - { - if ($this->validateConfiguration($config)) { - $this->configuration->set('PS_GEOLOCATION_BEHAVIOR', $config['geolocation_behaviour']); - $this->configuration->set('PS_GEOLOCATION_NA_BEHAVIOR', $config['geolocation_na_behaviour']); - $this->configuration->set('PS_ALLOWED_COUNTRIES', $config['geolocation_countries']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $config) - { - return isset( - $config['geolocation_behaviour'], - $config['geolocation_na_behaviour'] - ); - } -} diff --git a/src/Adapter/Grid/Action/Row/AccessibilityChecker/CategoryForViewAccessibilityChecker.php b/src/Adapter/Grid/Action/Row/AccessibilityChecker/CategoryForViewAccessibilityChecker.php deleted file mode 100644 index 27d00f93..00000000 --- a/src/Adapter/Grid/Action/Row/AccessibilityChecker/CategoryForViewAccessibilityChecker.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Grid\Action\Row\AccessibilityChecker; - -use Category; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\AccessibilityChecker\AccessibilityCheckerInterface; - -/** - * Class CategoryForViewAccessibilityChecker. - * - * @internal - */ -final class CategoryForViewAccessibilityChecker implements AccessibilityCheckerInterface -{ - /** - * @var int - */ - private $contextLangId; - - /** - * @param int $contextLangId - */ - public function __construct($contextLangId) - { - $this->contextLangId = $contextLangId; - } - - /** - * {@inheritdoc} - */ - public function isGranted(array $category) - { - return Category::hasChildren($category['id_category'], $this->contextLangId, false); - } -} diff --git a/src/Adapter/Grid/Search/Factory/SearchCriteriaWithCategoryParentIdFilterFactory.php b/src/Adapter/Grid/Search/Factory/SearchCriteriaWithCategoryParentIdFilterFactory.php deleted file mode 100644 index 53d94965..00000000 --- a/src/Adapter/Grid/Search/Factory/SearchCriteriaWithCategoryParentIdFilterFactory.php +++ /dev/null @@ -1,159 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Grid\Search\Factory; - -use Category; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\Shop\Context; -use PrestaShop\PrestaShop\Core\Feature\FeatureInterface; -use PrestaShop\PrestaShop\Core\Grid\Search\Factory\DecoratedSearchCriteriaFactory; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteria; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use PrestaShop\PrestaShop\Core\Multistore\MultistoreContextCheckerInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\RequestStack; - -/** - * Class SearchCriteriaWithCategoryParentIdFilterFactory. - * - * @internal - */ -final class SearchCriteriaWithCategoryParentIdFilterFactory implements DecoratedSearchCriteriaFactory -{ - /** - * @var Configuration - */ - private $configuration; - - /** - * @var Context - */ - private $shopContext; - - /** - * @var FeatureInterface - */ - private $multistoreFeature; - - /** - * @var MultistoreContextCheckerInterface - */ - private $multistoreContextChecker; - - /** - * @var int - */ - private $contextShopCategoryId; - - /** - * @var RequestStack - */ - private $requestStack; - - /** - * @param Configuration $configuration - * @param Context $shopContext - * @param FeatureInterface $multistoreFeature - * @param MultistoreContextCheckerInterface $multistoreContextChecker - * @param int $contextShopCategoryId - * @param RequestStack $requestStack - */ - public function __construct( - Configuration $configuration, - Context $shopContext, - FeatureInterface $multistoreFeature, - MultistoreContextCheckerInterface $multistoreContextChecker, - $contextShopCategoryId, - RequestStack $requestStack - ) { - $this->configuration = $configuration; - $this->shopContext = $shopContext; - $this->multistoreFeature = $multistoreFeature; - $this->multistoreContextChecker = $multistoreContextChecker; - $this->contextShopCategoryId = $contextShopCategoryId; - $this->requestStack = $requestStack; - } - - /** - * {@inheritdoc} - */ - public function createFrom(SearchCriteriaInterface $searchCriteria) - { - $categoryParentId = $this->resolveCategoryParentId(); - - $filters = array_merge( - $searchCriteria->getFilters(), - ['id_category_parent' => $categoryParentId] - ); - - return new SearchCriteria( - $filters, - $searchCriteria->getOrderBy(), - $searchCriteria->getOrderWay(), - $searchCriteria->getOffset(), - $searchCriteria->getLimit() - ); - } - - /** - * @return int Category parent id - */ - private function resolveCategoryParentId() - { - /** @var Request $request */ - $request = $this->requestStack->getCurrentRequest(); - if (!empty($request->attributes->get('categoryId'))) { - return (int) $request->attributes->get('categoryId'); - } - - $categoriesCountWithoutParent = count(Category::getCategoriesWithoutParent()); - $isMultistoreFeatureUsed = $this->multistoreFeature->isUsed(); - - if (!$isMultistoreFeatureUsed && $categoriesCountWithoutParent > 1) { - return $this->configuration->getInt('PS_ROOT_CATEGORY'); - } - - if ($isMultistoreFeatureUsed && 1 === $categoriesCountWithoutParent) { - return $this->configuration->getInt('PS_HOME_CATEGORY'); - } - - if ($isMultistoreFeatureUsed - && $categoriesCountWithoutParent > 1 - && !$this->multistoreContextChecker->isSingleShopContext() - ) { - if ($this->multistoreFeature->isActive() - && count($this->shopContext->getShops(true, true)) === 1 - ) { - return $this->contextShopCategoryId; - } - - return $this->configuration->getInt('PS_ROOT_CATEGORY'); - } - - return $this->contextShopCategoryId; - } -} diff --git a/src/Adapter/Group/GroupDataProvider.php b/src/Adapter/Group/GroupDataProvider.php deleted file mode 100644 index aa8bed04..00000000 --- a/src/Adapter/Group/GroupDataProvider.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Group; - -use Group; - -/** - * This class will provide data from DB / ORM about Group. - */ -class GroupDataProvider -{ - /** - * Return available groups. - * - * @param int $id_lang - * @param bool $id_shop - * - * @return array Groups - */ - public function getGroups($id_lang, $id_shop = false) - { - return Group::getGroups($id_lang, $id_shop); - } - - /** - * Return current group object - * Use context. - * - * @return Group Group object - */ - public static function getCurrent() - { - return Group::getCurrent(); - } -} diff --git a/src/Adapter/Group/Provider/DefaultGroupsProvider.php b/src/Adapter/Group/Provider/DefaultGroupsProvider.php deleted file mode 100644 index a01254c1..00000000 --- a/src/Adapter/Group/Provider/DefaultGroupsProvider.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Group\Provider; - -use Group; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Group\Provider\DefaultGroup; -use PrestaShop\PrestaShop\Core\Group\Provider\DefaultGroups; -use PrestaShop\PrestaShop\Core\Group\Provider\DefaultGroupsProviderInterface; - -/** - * Provides default customer groups - * - * @internal - */ -final class DefaultGroupsProvider implements DefaultGroupsProviderInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var int - */ - private $contextLangId; - - /** - * @param ConfigurationInterface $configuration - * @param int $contextLangId - */ - public function __construct(ConfigurationInterface $configuration, $contextLangId) - { - $this->configuration = $configuration; - $this->contextLangId = $contextLangId; - } - - /** - * {@inheritdoc} - */ - public function getGroups() - { - $visitorsGroup = new Group($this->configuration->get('PS_UNIDENTIFIED_GROUP')); - $guestsGroup = new Group($this->configuration->get('PS_GUEST_GROUP')); - $customersGroup = new Group($this->configuration->get('PS_CUSTOMER_GROUP')); - - $visitorName = isset($visitorsGroup->name[$this->contextLangId]) ? - $visitorsGroup->name[$this->contextLangId] : - reset($visitorsGroup->name) - ; - $visitorsGroupDto = new DefaultGroup((int) $visitorsGroup->id, $visitorName); - - $groupsName = isset($guestsGroup->name[$this->contextLangId]) ? - $guestsGroup->name[$this->contextLangId] : - $guestsGroup->name - ; - $guestsGroupDto = new DefaultGroup((int) $guestsGroup->id, $groupsName); - - $customersName = isset($customersGroup->name[$this->contextLangId]) ? - $customersGroup->name[$this->contextLangId] : - reset($customersGroup->name) - ; - $customersGroupDto = new DefaultGroup((int) $customersGroup->id, $customersName); - - return new DefaultGroups( - $visitorsGroupDto, - $guestsGroupDto, - $customersGroupDto - ); - } -} diff --git a/src/Adapter/Hook/HookDispatcher.php b/src/Adapter/Hook/HookDispatcher.php deleted file mode 100644 index 341c06c2..00000000 --- a/src/Adapter/Hook/HookDispatcher.php +++ /dev/null @@ -1,205 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Hook; - -use PrestaShop\PrestaShop\Core\Hook\Hook; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShop\PrestaShop\Core\Hook\HookInterface; -use PrestaShop\PrestaShop\Core\Hook\RenderedHook; -use PrestaShopBundle\Service\Hook\HookEvent; -use PrestaShopBundle\Service\Hook\RenderingHookEvent; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventDispatcher; - -/** - * This dispatcher is used to trigger hook listeners. - * - * The dispatch process cannot be stopped like a common EventDispatcher. - * - * If the event is a RenderingHookEvent, then the final result is - * an array of contents accessed from $event->getContent(). - */ -class HookDispatcher extends EventDispatcher implements HookDispatcherInterface -{ - /** - * @var array - */ - private $renderingContent = []; - - /** - * @var bool - */ - private $propagationStoppedCalledBy = false; - - /** - * {@inheritdoc} - * This override will check if $event is an instance of HookEvent. - * - * @throws \Exception if the Event is not HookEvent or a subclass - */ - public function dispatch($eventName, Event $event = null) - { - if ($event === null) { - $event = new HookEvent(); - } - - if (!$event instanceof HookEvent) { - throw new \Exception('HookDispatcher must dispatch a HookEvent subclass only. ' . get_class($event) . ' given.'); - } - - if ($listeners = $this->getListeners(strtolower($eventName))) { - $this->doDispatch($listeners, $eventName, $event); - } - - return $event; - } - - /** - * {@inheritdoc} - */ - public function dispatchHook(HookInterface $hook) - { - return $this->dispatchForParameters( - $hook->getName(), - $hook->getParameters() - ); - } - - /** - * Calls multiple hooks with the same parameter set. - * - * Each event is independent for each hook call. Parameter set is duplicated. - * - * @param array $eventNames the hooks to dispatch to - * @param array $eventParameters the parameters set to insert in each HookEvent instance - * - * @throws \Exception if the Event is not HookEvent or a subclass - */ - public function dispatchMultiple(array $eventNames, array $eventParameters) - { - foreach ($eventNames as $name) { - $this->dispatch($name, (new HookEvent())->setHookParameters($eventParameters)); - } - } - - /** - * {@inheritdoc} - * This override will avoid PropagationStopped to break the dispatching process. - * After dispatch, in case of RenderingHookEvent, the final content array will be set in event. - */ - protected function doDispatch($listeners, $eventName, Event $event) - { - $this->propagationStoppedCalledBy = false; - foreach ($listeners as $listener) { - // removes $this to parameters. Hooks should not have access to dispatcher - ob_start(); - $listener($event, $eventName, null); - $obContent = ob_get_clean(); - - if ($event instanceof RenderingHookEvent) { - $listenerName = $event->popListener() ?: $listener[1]; - - $eventContent = $event->popContent(); - $this->renderingContent[$listenerName] = (!is_string($eventContent) || strlen($eventContent) > strlen($obContent)) - ? $eventContent - : $obContent; - } - if ($event->isPropagationStopped()) { - $this->propagationStoppedCalledBy = $listener; - } - } - if ($event instanceof RenderingHookEvent) { - $event->setContent($this->renderingContent); - $this->renderingContent = []; - } - } - - /** - * Creates a HookEvent, sets its parameters, and dispatches it. - * - * @param $eventName string The hook name - * @param array $parameters Hook parameters - * - * @return Event the event that has been passed to each listener - * - * @throws \Exception - */ - public function dispatchForParameters($eventName, array $parameters = []) - { - $event = new HookEvent(); - $event->setHookParameters($parameters); - - return $this->dispatch($eventName, $event); - } - - /** - * Creates a RenderingHookEvent, sets its parameters, and dispatches it. Returns the event with the response(s). - * - * @param string $eventName the hook name - * @param array $parameters Hook parameters - * - * @return Event The event that has been passed to each listener. Contains the responses. - * - * @throws \Exception - */ - public function renderForParameters($eventName, array $parameters = []) - { - $event = new RenderingHookEvent(); - $event->setHookParameters($parameters); - - return $this->dispatch($eventName, $event); - } - - /** - * {@inheritdoc} - */ - public function dispatchWithParameters($hookName, array $hookParameters = []) - { - $this->dispatch(new Hook($hookName, $hookParameters)); - } - - /** - * {@inheritdoc} - */ - public function dispatchRendering(HookInterface $hook) - { - $event = $this->renderForParameters( - $hook->getName(), - $hook->getParameters() - ); - - return new RenderedHook($hook, $event->getContent()); - } - - /** - * {@inheritdoc} - */ - public function dispatchRenderingWithParameters($hookName, array $hookParameters = []) - { - return $this->dispatchRendering(new Hook($hookName, $hookParameters)); - } -} diff --git a/src/Adapter/Hook/HookInformationProvider.php b/src/Adapter/Hook/HookInformationProvider.php deleted file mode 100644 index e53d47d1..00000000 --- a/src/Adapter/Hook/HookInformationProvider.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Hook; - -use Hook; - -/** - * Give information about the hooks. - */ -class HookInformationProvider -{ - /** - * @param string $hookName - * - * @return bool - */ - public function isDisplayHookName($hookName) - { - return Hook::isDisplayHookName($hookName); - } - - /** - * Return Hooks List. - * - * @param bool $position Where position is active - * @param bool $onlyDisplayHooks Only hook with display hook name - * - * @return array Hooks List - */ - public function getHooks($position = false, $onlyDisplayHooks = false) - { - return Hook::getHooks($position, $onlyDisplayHooks); - } - - /** - * Return Hooks list. - * - * @param int $hookId Hook id - * @param int $moduleId Module id - * - * @return array Modules list - */ - public function getModulesFromHook($hookId, $moduleId = null) - { - return Hook::getModulesFromHook($hookId, $moduleId); - } -} diff --git a/src/Adapter/HookManager.php b/src/Adapter/HookManager.php deleted file mode 100644 index 0db8a816..00000000 --- a/src/Adapter/HookManager.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use Hook; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Bridge to execute hooks in modern pages. - */ -class HookManager -{ - /** - * Execute modules for specified hook. - * - * @param string $hook_name Hook Name - * @param array $hook_args Parameters for the functions - * @param int $id_module Execute hook for this module only - * @param bool $array_return If specified, module output will be set by name in an array - * @param bool $check_exceptions Check permission exceptions - * @param bool $use_push Force change to be refreshed on Dashboard widgets - * @param int $id_shop If specified, hook will be execute the shop with this ID - * - * @throws \PrestaShopException - * - * @return string/array modules output - */ - public function exec( - $hook_name, - $hook_args = [], - $id_module = null, - $array_return = false, - $check_exceptions = true, - $use_push = false, - $id_shop = null - ) { - $sfContainer = SymfonyContainer::getInstance(); - $request = null; - - if ($sfContainer instanceof ContainerInterface) { - $request = $sfContainer->get('request_stack')->getCurrentRequest(); - } - - if (null !== $request) { - $hook_args = array_merge(['request' => $request], $hook_args); - - // If Symfony application is booted, we use it to dispatch Hooks - $hookDispatcher = $sfContainer->get('prestashop.core.hook.dispatcher'); - - return $hookDispatcher - ->dispatchRenderingWithParameters($hook_name, $hook_args) - ->getContent(); - } else { - try { - return Hook::exec($hook_name, $hook_args, $id_module, $array_return, $check_exceptions, $use_push, $id_shop); - } catch (\Exception $e) { - $logger = ServiceLocator::get('\\PrestaShop\\PrestaShop\\Adapter\\LegacyLogger'); - $logger->error(sprintf('Exception on hook %s for module %s. %s', $hook_name, $id_module, $e->getMessage())); - } - } - } -} diff --git a/src/Adapter/Hosting/HostingInformation.php b/src/Adapter/Hosting/HostingInformation.php deleted file mode 100644 index 24fc4830..00000000 --- a/src/Adapter/Hosting/HostingInformation.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Hosting; - -use Db; -use Tools; - -/** - * Provides hosting system information. - */ -class HostingInformation -{ - /** - * @return array - */ - public function getDatabaseInformation() - { - return [ - 'version' => Db::getInstance()->getVersion(), - 'server' => _DB_SERVER_, - 'name' => _DB_NAME_, - 'user' => _DB_USER_, - 'prefix' => _DB_PREFIX_, - 'engine' => _MYSQL_ENGINE_, - 'driver' => Db::getClass(), - ]; - } - - /** - * @return array - */ - public function getServerInformation() - { - return [ - 'version' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : 'n/a', - 'php' => $this->getPhpInformation(), - ]; - } - - /** - * @return array - */ - private function getPhpInformation() - { - return [ - 'version' => PHP_VERSION, - 'memoryLimit' => ini_get('memory_limit'), - 'maxExecutionTime' => ini_get('max_execution_time'), - 'maxFileSizeUpload' => ini_get('upload_max_filesize'), - ]; - } - - /** - * @return string - */ - public function getUname() - { - return function_exists('php_uname') ? php_uname('s') . ' ' . php_uname('v') . ' ' . php_uname('m') : ''; - } - - /** - * @return bool - */ - public function isApacheInstawebModule() - { - return Tools::apacheModExists('mod_instaweb'); - } - - /** - * Check if the shop is hosted on PrestaCloud. - * - * @return bool - */ - public function isHostMode() - { - return defined('_PS_HOST_MODE_'); - } -} diff --git a/src/Adapter/Image/ImageRetriever.php b/src/Adapter/Image/ImageRetriever.php deleted file mode 100644 index 088a32f0..00000000 --- a/src/Adapter/Image/ImageRetriever.php +++ /dev/null @@ -1,297 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Image; - -use Image; -use ImageManager; -use ImageType; -use Language; -use Link; -use Product; - -/** - * This class is mainly responsible of Product images. - */ -class ImageRetriever -{ - /** - * @var Link - */ - private $link; - - public function __construct(Link $link) - { - $this->link = $link; - } - - /** - * @param array $product - * @param Language $language - * - * @return array - */ - public function getAllProductImages(array $product, Language $language) - { - $productInstance = new Product( - $product['id_product'], - false, - $language->id - ); - - $images = $productInstance->getImages($language->id); - - if (empty($images)) { - return []; - } - - $combinationImages = $productInstance->getCombinationImages($language->id); - if (!$combinationImages) { - $combinationImages = []; - } - $imageToCombinations = []; - - foreach ($combinationImages as $imgs) { - foreach ($imgs as $img) { - $imageToCombinations[$img['id_image']][] = $img['id_product_attribute']; - } - } - - $images = array_map(function (array $image) use ( - $productInstance, - $imageToCombinations - ) { - $image = array_merge($this->getImage( - $productInstance, - $image['id_image'] - ), $image); - - if (isset($imageToCombinations[$image['id_image']])) { - $image['associatedVariants'] = $imageToCombinations[$image['id_image']]; - } else { - $image['associatedVariants'] = []; - } - - return $image; - }, $images); - - return $images; - } - - /** - * @param array $product - * @param Language $language - * - * @return array - */ - public function getProductImages(array $product, Language $language) - { - $images = $this->getAllProductImages($product, $language); - - $productAttributeId = $product['id_product_attribute']; - $filteredImages = []; - - foreach ($images as $image) { - if (in_array($productAttributeId, $image['associatedVariants'])) { - $filteredImages[] = $image; - } - } - - return (0 === count($filteredImages)) ? $images : $filteredImages; - } - - /** - * @param $object - * @param int $id_image - * - * @return array|null - * - * @throws \PrestaShopDatabaseException - */ - public function getImage($object, $id_image) - { - if (!$id_image) { - return null; - } - - if (get_class($object) === 'Product') { - $type = 'products'; - $getImageURL = 'getImageLink'; - $root = _PS_PROD_IMG_DIR_; - $imageFolderPath = implode(DIRECTORY_SEPARATOR, [ - rtrim($root, DIRECTORY_SEPARATOR), - rtrim(Image::getImgFolderStatic($id_image), DIRECTORY_SEPARATOR), - ]); - } elseif (get_class($object) === 'Store') { - $type = 'stores'; - $getImageURL = 'getStoreImageLink'; - $root = _PS_STORE_IMG_DIR_; - $imageFolderPath = rtrim($root, DIRECTORY_SEPARATOR); - } else { - $type = 'categories'; - $getImageURL = 'getCatImageLink'; - $root = _PS_CAT_IMG_DIR_; - $imageFolderPath = rtrim($root, DIRECTORY_SEPARATOR); - } - - $urls = []; - $image_types = ImageType::getImagesTypes($type, true); - - $extPath = $imageFolderPath . DIRECTORY_SEPARATOR . 'fileType'; - $ext = @file_get_contents($extPath) ?: 'jpg'; - - $mainImagePath = implode(DIRECTORY_SEPARATOR, [ - $imageFolderPath, - $id_image . '.' . $ext, - ]); - - foreach ($image_types as $image_type) { - $resizedImagePath = implode(DIRECTORY_SEPARATOR, [ - $imageFolderPath, - $id_image . '-' . $image_type['name'] . '.' . $ext, - ]); - - if (!file_exists($resizedImagePath)) { - ImageManager::resize( - $mainImagePath, - $resizedImagePath, - (int) $image_type['width'], - (int) $image_type['height'] - ); - } - - $url = $this->link->$getImageURL( - isset($object->link_rewrite) ? $object->link_rewrite : $object->name, - $id_image, - $image_type['name'] - ); - - $urls[$image_type['name']] = [ - 'url' => $url, - 'width' => (int) $image_type['width'], - 'height' => (int) $image_type['height'], - ]; - } - - uasort($urls, function (array $a, array $b) { - return $a['width'] * $a['height'] > $b['width'] * $b['height'] ? 1 : -1; - }); - - $keys = array_keys($urls); - - $small = $urls[$keys[0]]; - $large = end($urls); - $medium = $urls[$keys[ceil((count($keys) - 1) / 2)]]; - - return [ - 'bySize' => $urls, - 'small' => $small, - 'medium' => $medium, - 'large' => $large, - 'legend' => isset($object->meta_title) ? $object->meta_title : $object->name, - 'id_image' => $id_image, - ]; - } - - /** - * @param string $imageHash - * - * @return array - */ - public function getCustomizationImage($imageHash) - { - $large_image_url = rtrim($this->link->getBaseLink(), '/') . '/upload/' . $imageHash; - $small_image_url = $large_image_url . '_small'; - - $small = [ - 'url' => $small_image_url, - ]; - - $large = [ - 'url' => $large_image_url, - ]; - - $medium = $large; - - return [ - 'bySize' => [ - 'small' => $small, - 'medium' => $medium, - 'large' => $large, - ], - 'small' => $small, - 'medium' => $medium, - 'large' => $large, - 'legend' => '', - ]; - } - - /** - * @param Language $language - * - * @return array - * - * @throws \PrestaShopDatabaseException - */ - public function getNoPictureImage(Language $language) - { - $urls = []; - $type = 'products'; - $image_types = ImageType::getImagesTypes($type, true); - - foreach ($image_types as $image_type) { - $url = $this->link->getImageLink( - '', - $language->iso_code . '-default', - $image_type['name'] - ); - - $urls[$image_type['name']] = [ - 'url' => $url, - 'width' => (int) $image_type['width'], - 'height' => (int) $image_type['height'], - ]; - } - - uasort($urls, function (array $a, array $b) { - return $a['width'] * $a['height'] > $b['width'] * $b['height'] ? 1 : -1; - }); - - $keys = array_keys($urls); - - $small = $urls[$keys[0]]; - $large = end($urls); - $medium = $urls[$keys[ceil((count($keys) - 1) / 2)]]; - - return [ - 'bySize' => $urls, - 'small' => $small, - 'medium' => $medium, - 'large' => $large, - 'legend' => '', - ]; - } -} diff --git a/src/Adapter/Image/Uploader/AbstractImageUploader.php b/src/Adapter/Image/Uploader/AbstractImageUploader.php deleted file mode 100644 index ef055ac7..00000000 --- a/src/Adapter/Image/Uploader/AbstractImageUploader.php +++ /dev/null @@ -1,173 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Image\Uploader; - -use Configuration; -use ImageManager; -use ImageType; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\ImageOptimizationException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\ImageUploadException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\MemoryLimitException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\UploadedImageConstraintException; -use PrestaShop\PrestaShop\Core\Image\Uploader\ImageUploaderInterface; -use PrestaShopException; -use Symfony\Component\HttpFoundation\File\UploadedFile; -use Tools; - -/** - * Class AbstractImageUploader encapsulates reusable legacy methods used for image uploading. - * - * @internal - */ -abstract class AbstractImageUploader implements ImageUploaderInterface -{ - /** - * Check if image is allowed to be uploaded. - * - * @param UploadedFile $image - * - * @throws UploadedImageConstraintException - */ - protected function checkImageIsAllowedForUpload(UploadedFile $image) - { - $maxFileSize = Tools::getMaxUploadSize(); - - if ($maxFileSize > 0 && $image->getSize() > $maxFileSize) { - throw new UploadedImageConstraintException(sprintf('Max file size allowed is "%s" bytes. Uploaded image size is "%s".', $maxFileSize, $image->getSize()), UploadedImageConstraintException::EXCEEDED_SIZE); - } - - if (!ImageManager::isRealImage($image->getPathname(), $image->getClientMimeType()) - || !ImageManager::isCorrectImageFileExt($image->getClientOriginalName()) - || preg_match('/\%00/', $image->getClientOriginalName()) // prevent null byte injection - ) { - throw new UploadedImageConstraintException(sprintf('Image format "%s", not recognized, allowed formats are: .gif, .jpg, .png', $image->getClientOriginalExtension()), UploadedImageConstraintException::UNRECOGNIZED_FORMAT); - } - } - - /** - * Creates temporary image from uploaded file - * - * @param UploadedFile $image - * - * @throws ImageUploadException - * - * @return string - */ - protected function createTemporaryImage(UploadedFile $image) - { - $temporaryImageName = tempnam(_PS_TMP_IMG_DIR_, 'PS'); - - if (!$temporaryImageName || !move_uploaded_file($image->getPathname(), $temporaryImageName)) { - throw new ImageUploadException('Failed to create temporary image file'); - } - - return $temporaryImageName; - } - - /** - * Uploads resized image from temporary folder to image destination - * - * @param $temporaryImageName - * @param $destination - * - * @throws ImageOptimizationException - * @throws MemoryLimitException - */ - protected function uploadFromTemp($temporaryImageName, $destination) - { - if (!ImageManager::checkImageMemoryLimit($temporaryImageName)) { - throw new MemoryLimitException('Cannot upload image due to memory restrictions'); - } - - if (!ImageManager::resize($temporaryImageName, $destination)) { - throw new ImageOptimizationException('An error occurred while uploading the image. Check your directory permissions.'); - } - - unlink($temporaryImageName); - } - - /** - * Generates different size images - * - * @param int $id - * @param string $imageDir - * @param string $belongsTo to whom the image belongs (for example 'suppliers' or 'categories') - * - * @return bool - * - * @throws ImageOptimizationException - */ - protected function generateDifferentSize($id, $imageDir, $belongsTo) - { - $resized = true; - - try { - $imageTypes = ImageType::getImagesTypes($belongsTo); - - foreach ($imageTypes as $imageType) { - $resized &= $this->resize($id, $imageDir, $imageType); - } - } catch (PrestaShopException $e) { - throw new ImageOptimizationException('Unable to resize one or more of your pictures.'); - } - - if (!$resized) { - throw new ImageOptimizationException('Unable to resize one or more of your pictures.'); - } - - return $resized; - } - - /** - * Resizes the image depending from its type - * - * @param int $id - * @param string $imageDir - * @param array $imageType - * - * @return bool - */ - private function resize($id, $imageDir, array $imageType) - { - $ext = '.jpg'; - $width = $imageType['width']; - $height = $imageType['height']; - - if (Configuration::get('PS_HIGHT_DPI')) { - $ext = '2x.jpg'; - $width *= 2; - $height *= 2; - } - - return ImageManager::resize( - $imageDir . $id . '.jpg', - $imageDir . $id . '-' . stripslashes($imageType['name']) . $ext, - (int) $width, - (int) $height - ); - } -} diff --git a/src/Adapter/Image/Uploader/CategoryCoverImageUploader.php b/src/Adapter/Image/Uploader/CategoryCoverImageUploader.php deleted file mode 100644 index 3d2902b7..00000000 --- a/src/Adapter/Image/Uploader/CategoryCoverImageUploader.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Image\Uploader; - -use Category; -use ImageManager; -use ImageType; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\ImageOptimizationException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\ImageUploadException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\MemoryLimitException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\UploadedImageConstraintException; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Class CategoryCoverImageUploader. - * - * @internal - */ -final class CategoryCoverImageUploader extends AbstractImageUploader -{ - /** - * {@inheritdoc} - * - * @throws MemoryLimitException - * @throws ImageOptimizationException - * @throws ImageUploadException - * @throws UploadedImageConstraintException - */ - public function upload($id, UploadedFile $uploadedImage) - { - $this->checkImageIsAllowedForUpload($uploadedImage); - $this->deleteOldImage($id); - $this->uploadImage($id, $uploadedImage); - $this->generateDifferentTypes($id); - } - - /** - * Delete old category image. - * - * @param int $id - */ - private function deleteOldImage($id) - { - $category = new Category($id); - $category->deleteImage(); - } - - /** - * @param int $id - * @param UploadedFile $image - * - * @throws ImageOptimizationException - * @throws ImageUploadException - * @throws MemoryLimitException - */ - private function uploadImage($id, UploadedFile $image) - { - $temporaryImageName = tempnam(_PS_TMP_IMG_DIR_, 'PS'); - - if (!$temporaryImageName) { - throw new ImageUploadException('Failed to create temporary image file'); - } - - if (!move_uploaded_file($image->getPathname(), $temporaryImageName)) { - throw new ImageUploadException('Failed to upload image'); - } - - if (!ImageManager::checkImageMemoryLimit($temporaryImageName)) { - throw new MemoryLimitException('Cannot upload image due to memory restrictions'); - } - - $optimizationSucceeded = ImageManager::resize( - $temporaryImageName, - _PS_IMG_DIR_ . 'c' . DIRECTORY_SEPARATOR . $id . '.jpg', - null, - null, - 'jpg' - ); - - if (!$optimizationSucceeded) { - throw new ImageOptimizationException('Failed to optimize image after uploading'); - } - - unlink($temporaryImageName); - } - - /** - * @param int $id - * - * @throws ImageUploadException - */ - private function generateDifferentTypes($id) - { - if (!file_exists(_PS_CAT_IMG_DIR_ . $id . '.jpg')) { - return; - } - - $imagesTypes = ImageType::getImagesTypes('categories'); - foreach ($imagesTypes as $k => $imageType) { - $generated = ImageManager::resize( - _PS_CAT_IMG_DIR_ . $id . '.jpg', - _PS_CAT_IMG_DIR_ . $id . '-' . stripslashes($imageType['name']) . '.jpg', - (int) $imageType['width'], - (int) $imageType['height'] - ); - - if (!$generated) { - throw new ImageUploadException('Error occurred when uploading image'); - } - } - } -} diff --git a/src/Adapter/Image/Uploader/CategoryMenuThumbnailUploader.php b/src/Adapter/Image/Uploader/CategoryMenuThumbnailUploader.php deleted file mode 100644 index cad4ebbc..00000000 --- a/src/Adapter/Image/Uploader/CategoryMenuThumbnailUploader.php +++ /dev/null @@ -1,126 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Image\Uploader; - -use HelperImageUploader; -use ImageManager; -use PrestaShop\PrestaShop\Adapter\Cache\CacheClearer; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\MenuThumbnailsLimitException; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\MenuThumbnailId; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\ImageUploadException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\MemoryLimitException; -use PrestaShop\PrestaShop\Core\Image\Uploader\ImageUploaderInterface; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Class CategoryMenuThumbnailUploader. - */ -final class CategoryMenuThumbnailUploader implements ImageUploaderInterface -{ - /** - * @var CacheClearer - */ - private $cacheClearer; - - /** - * @param CacheClearer $cacheClearer - */ - public function __construct(CacheClearer $cacheClearer) - { - $this->cacheClearer = $cacheClearer; - } - - /** - * {@inheritdoc} - * - * @throws ImageUploadException - */ - public function upload($categoryId, UploadedFile $uploadedImage) - { - //Get total of image already present in directory - $files = scandir(_PS_CAT_IMG_DIR_, SCANDIR_SORT_NONE); - $usedKeys = []; - - foreach ($files as $file) { - $matches = []; - - if (preg_match('/^' . $categoryId . '-([0-9])?_thumb.jpg/i', $file, $matches) === 1) { - $usedKeys[] = (int) $matches[1]; - } - } - - $availableKeys = array_diff(MenuThumbnailId::ALLOWED_ID_VALUES, $usedKeys); - - // HelperImageUploader::process() expects - // uploaded file to be available in $_FILES - $_FILES['thumbnail'] = [ - 'error' => [$uploadedImage->getError()], - 'name' => [$uploadedImage->getClientOriginalName()], - 'size' => [$uploadedImage->getSize()], - 'tmp_name' => [$uploadedImage->getPathname()], - 'type' => [$uploadedImage->getMimeType()], - ]; - - $helper = new HelperImageUploader('thumbnail'); - $uploadedFiles = $helper->process(); - - if (count($availableKeys) < count($uploadedFiles)) { - throw new MenuThumbnailsLimitException(sprintf('Maximum number of menu thumbnails was reached for category "%s"', $categoryId)); - } - - foreach ($uploadedFiles as &$uploadedFile) { - $key = array_shift($availableKeys); - - // Evaluate the memory required to resize the image: if it's too much, you can't resize it. - if (isset($uploadedFile['save_path']) && !ImageManager::checkImageMemoryLimit($uploadedFile['save_path'])) { - throw new MemoryLimitException(sprintf('Cannot resize menu thumbnail for category with id "%s" due to reached memory limit.', $categoryId)); - } - - // Copy new image - if (!isset($uploadedFile['save_path']) - || !ImageManager::resize($uploadedFile['save_path'], _PS_CAT_IMG_DIR_ . $categoryId . '-' . $key . '_thumb.jpg') - ) { - throw new ImageUploadException('An error occurred while uploading the image.'); - } - - if (isset($uploadedFile['save_path']) && is_file($uploadedFile['save_path'])) { - unlink($uploadedFile['save_path']); - } - - // Necessary to prevent hacking - if (isset($uploadedFile['save_path'])) { - unset($uploadedFile['save_path']); - } - - if (isset($uploadedFile['tmp_name'])) { - unset($uploadedFile['tmp_name']); - } - } - - $this->cacheClearer->clearSmartyCache(); - } -} diff --git a/src/Adapter/Image/Uploader/CategoryThumbnailImageUploader.php b/src/Adapter/Image/Uploader/CategoryThumbnailImageUploader.php deleted file mode 100644 index 01b99ca5..00000000 --- a/src/Adapter/Image/Uploader/CategoryThumbnailImageUploader.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Image\Uploader; - -use ImageManager; -use ImageType; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\ImageOptimizationException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\ImageUploadException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\UploadedImageConstraintException; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Class CategoryThumbnailImageUploader. - */ -final class CategoryThumbnailImageUploader extends AbstractImageUploader -{ - /** - * {@inheritdoc} - * - * @throws UploadedImageConstraintException - * @throws ImageUploadException - * @throws ImageOptimizationException - */ - public function upload($id, UploadedFile $uploadedImage) - { - $imagesTypes = ImageType::getImagesTypes('categories'); - $formattedName = ImageType::getFormattedName('small'); - - foreach ($imagesTypes as $k => $imagesType) { - if ($formattedName !== $imagesType['name']) { - continue; - } - - $this->checkImageIsAllowedForUpload($uploadedImage); - - $tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS'); - if (!$tmpName) { - throw new ImageUploadException('Failed to create temporary category thumbnail image file'); - } - - if (!move_uploaded_file($uploadedImage->getPathname(), $tmpName)) { - throw new ImageUploadException('Failed to upload category thumbnail image'); - } - - if (!ImageManager::resize( - $tmpName, - _PS_CAT_IMG_DIR_ . $id . '-' . stripslashes($imagesType['name']) . '.jpg', - (int) $imagesType['width'], - (int) $imagesType['height'] - )) { - throw new ImageOptimizationException('Failed to optimize category thumbnail image after uploading'); - } - - if (($imageSize = getimagesize($tmpName)) && is_array($imageSize)) { - ImageManager::resize( - $tmpName, - _PS_CAT_IMG_DIR_ . $id . '_thumb.jpg', - (int) $imageSize[0], - (int) $imageSize[1] - ); - } - - unlink($tmpName); - } - } -} diff --git a/src/Adapter/Image/Uploader/ManufacturerImageUploader.php b/src/Adapter/Image/Uploader/ManufacturerImageUploader.php deleted file mode 100644 index 72e65378..00000000 --- a/src/Adapter/Image/Uploader/ManufacturerImageUploader.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Image\Uploader; - -use Configuration; -use ImageManager; -use ImageType; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\ImageOptimizationException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\ImageUploadException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\MemoryLimitException; -use PrestaShopException; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Uploads manufacturer logo image - */ -final class ManufacturerImageUploader extends AbstractImageUploader -{ - /** - * {@inheritdoc} - */ - public function upload($manufacturerId, UploadedFile $image) - { - $this->checkImageIsAllowedForUpload($image); - $temporaryImageName = tempnam(_PS_TMP_IMG_DIR_, 'PS'); - - if (!$temporaryImageName) { - throw new ImageUploadException('An error occurred while uploading the image. Check your directory permissions.'); - } - - if (!move_uploaded_file($image->getPathname(), $temporaryImageName)) { - throw new ImageUploadException('An error occurred while uploading the image. Check your directory permissions.'); - } - - // Evaluate the memory required to resize the image: if it's too much, you can't resize it. - if (!ImageManager::checkImageMemoryLimit($temporaryImageName)) { - throw new MemoryLimitException('Due to memory limit restrictions, this image cannot be loaded. Increase your memory_limit value.'); - } - // Copy new image - if (!ImageManager::resize($temporaryImageName, _PS_MANU_IMG_DIR_ . $manufacturerId . '.jpg')) { - throw new ImageOptimizationException('An error occurred while uploading the image. Check your directory permissions.'); - } - - $this->generateDifferentSizeImages($manufacturerId); - } - - /** - * @param int $manufacturerId - * - * @return bool - */ - private function generateDifferentSizeImages($manufacturerId) - { - $resized = true; - $generateHighDpiImages = (bool) Configuration::get('PS_HIGHT_DPI'); - - try { - /* Generate images with different size */ - if (isset($_FILES) && - count($_FILES) && - file_exists(_PS_MANU_IMG_DIR_ . $manufacturerId . '.jpg') - ) { - $imageTypes = ImageType::getImagesTypes('manufacturers'); - - foreach ($imageTypes as $imageType) { - $resized &= ImageManager::resize( - _PS_MANU_IMG_DIR_ . $manufacturerId . '.jpg', - _PS_MANU_IMG_DIR_ . $manufacturerId . '-' . stripslashes($imageType['name']) . '.jpg', - (int) $imageType['width'], - (int) $imageType['height'] - ); - - if ($generateHighDpiImages) { - $resized &= ImageManager::resize( - _PS_MANU_IMG_DIR_ . $manufacturerId . '.jpg', - _PS_MANU_IMG_DIR_ . $manufacturerId . '-' . stripslashes($imageType['name']) . '2x.jpg', - (int) $imageType['width'] * 2, - (int) $imageType['height'] * 2 - ); - } - } - - $currentLogo = _PS_TMP_IMG_DIR_ . 'manufacturer_mini_' . $manufacturerId . '.jpg'; - - if ($resized && file_exists($currentLogo)) { - unlink($currentLogo); - } - } - } catch (PrestaShopException $e) { - throw new ImageOptimizationException('Unable to resize one or more of your pictures.'); - } - - if (!$resized) { - throw new ImageOptimizationException('Unable to resize one or more of your pictures.'); - } - - return $resized; - } -} diff --git a/src/Adapter/Image/Uploader/SupplierImageUploader.php b/src/Adapter/Image/Uploader/SupplierImageUploader.php deleted file mode 100644 index a52f9229..00000000 --- a/src/Adapter/Image/Uploader/SupplierImageUploader.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Image\Uploader; - -use Supplier; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Uploads supplier logo image - */ -final class SupplierImageUploader extends AbstractImageUploader -{ - /** - * {@inheritdoc} - */ - public function upload($supplierId, UploadedFile $image) - { - $this->checkImageIsAllowedForUpload($image); - $tempImageName = $this->createTemporaryImage($image); - $this->deleteOldImage($supplierId); - - $destination = _PS_SUPP_IMG_DIR_ . $supplierId . '.jpg'; - $this->uploadFromTemp($tempImageName, $destination); - - if (file_exists($destination)) { - $this->generateDifferentSize($supplierId, _PS_SUPP_IMG_DIR_, 'suppliers'); - } - } - - /** - * Deletes old image - * - * @param $id - */ - private function deleteOldImage($id) - { - $supplier = new Supplier($id); - $supplier->deleteImage(); - - $currentLogo = _PS_TMP_IMG_DIR_ . 'supplier_mini_' . $id . '.jpg'; - - if (file_exists($currentLogo)) { - unlink($currentLogo); - } - } -} diff --git a/src/Adapter/ImageManager.php b/src/Adapter/ImageManager.php deleted file mode 100644 index 1b724b5a..00000000 --- a/src/Adapter/ImageManager.php +++ /dev/null @@ -1,141 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use Image; -use ImageManager as LegacyImageManager; - -/** - * Class responsible of finding images and creating thumbnails. - */ -class ImageManager -{ - /** - * @var LegacyContext - */ - private $legacyContext; - - /** - * @param LegacyContext $legacyContext - */ - public function __construct(LegacyContext $legacyContext) - { - $this->legacyContext = $legacyContext; - } - - /** - * Old legacy way to generate a thumbnail. - * - * Use it upon a new Image management system is available. - * - * @param $imageId - * @param string $imageType - * @param string $tableName - * @param string $imageDir - * - * @return string The HTML < img > tag - */ - public function getThumbnailForListing($imageId, $imageType = 'jpg', $tableName = 'product', $imageDir = _PS_PROD_IMG_DIR_) - { - $thumbPath = $this->getThumbnailTag($imageId, $imageType, $tableName, $imageDir); - - // because legacy uses relative path to reach a directory under root directory... - $replacement = 'src="' . $this->legacyContext->getRootUrl(); - $thumbPath = preg_replace('/src="(\\.\\.\\/)+/', $replacement, $thumbPath); - - return $thumbPath; - } - - public function getThumbnailPath($imageId) - { - $imageType = 'jpg'; - $tableName = 'product'; - $imageDir = _PS_PROD_IMG_DIR_; - - $imagePath = $this->getImagePath($imageId, $imageType, $tableName, $imageDir); - $thumbnailCachedImageName = $this->makeCachedImageName($imageId, $imageType, $tableName); - LegacyImageManager::thumbnail( - $imagePath, - $thumbnailCachedImageName, - 45, - $imageType - ); - - return LegacyImageManager::getThumbnailPath($thumbnailCachedImageName, false); - } - - /** - * @param $imageId - * @param string $imageType - * @param string $tableName - * @param string $imageDir - * - * @return string - */ - private function getThumbnailTag($imageId, $imageType, $tableName, $imageDir) - { - $imagePath = $this->getImagePath($imageId, $imageType, $tableName, $imageDir); - - return LegacyImageManager::thumbnail( - $imagePath, - $this->makeCachedImageName($imageId, $imageType, $tableName), - 45, - $imageType - ); - } - - /** - * @param $imageId - * @param $imageType - * @param $tableName - * @param $imageDir - * - * @return string - */ - private function getImagePath($imageId, $imageType, $tableName, $imageDir) - { - if ($tableName == 'product') { - $image = new Image($imageId); - - return $imageDir . $image->getExistingImgPath() . '.' . $imageType; - } - - return $imageDir . $imageId . '.' . $imageType; - } - - /** - * @param $imageId - * @param $imageType - * @param $tableName - * - * @return string - */ - private function makeCachedImageName($imageId, $imageType, $tableName) - { - return $tableName . '_mini_' . $imageId . '.' . $imageType; - } -} diff --git a/src/Adapter/Import/CsvFileOpener.php b/src/Adapter/Import/CsvFileOpener.php deleted file mode 100644 index 4ee25804..00000000 --- a/src/Adapter/Import/CsvFileOpener.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Import; - -use PrestaShop\PrestaShop\Core\File\Converter\FileConverterInterface; -use PrestaShop\PrestaShop\Core\Import\Exception\UnreadableFileException; -use PrestaShop\PrestaShop\Core\Import\File\FileOpenerInterface; -use PrestaShop\PrestaShop\Core\Import\ImportDirectory; -use SplFileInfo; - -/** - * Class CsvFileOpener is responsible for opening the CSV import file. - */ -final class CsvFileOpener implements FileOpenerInterface -{ - /** - * @var FileConverterInterface - */ - private $excelToCsvConverter; - - /** - * @var ImportDirectory - */ - private $importDirectory; - - /** - * @param FileConverterInterface $excelToCsvConverter - * @param ImportDirectory $importDirectory - */ - public function __construct( - FileConverterInterface $excelToCsvConverter, - ImportDirectory $importDirectory - ) { - $this->excelToCsvConverter = $excelToCsvConverter; - $this->importDirectory = $importDirectory; - } - - /** - * {@inheritdoc} - */ - public function open(SplFileInfo $file) - { - $importFile = $this->excelToCsvConverter->convert($file); - $filePath = $importFile->getPathname(); - $isReadableFile = is_file($filePath) && is_readable($filePath); - - if (!$isReadableFile || !($handle = fopen($filePath, 'r'))) { - throw new UnreadableFileException(); - } - - $this->rewindBomAware($handle); - - return $handle; - } - - /** - * Rewind the file handle, skipping BOM signature. - * - * @param resource $handle - */ - private function rewindBomAware($handle) - { - if (!is_resource($handle)) { - return; - } - - rewind($handle); - - if (($bom = fread($handle, 3)) != "\xEF\xBB\xBF") { - rewind($handle); - } - } -} diff --git a/src/Adapter/Import/DataMatchSaver.php b/src/Adapter/Import/DataMatchSaver.php deleted file mode 100644 index 96abf4b6..00000000 --- a/src/Adapter/Import/DataMatchSaver.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Import; - -use Doctrine\DBAL\Connection; - -/** - * Class DataMatchSaver saves data configuration match. - * This class will be removed with CQRS introduction. - */ -final class DataMatchSaver -{ - /** - * @var Connection - */ - private $connection; - - /** - * @var string - */ - private $dbPrefix; - - /** - * @param Connection $connection - * @param string $dbPrefix - */ - public function __construct(Connection $connection, $dbPrefix) - { - $this->connection = $connection; - $this->dbPrefix = $dbPrefix; - } - - /** - * Save data match. - * - * @param string $name name of the match - * @param array $value value of the match - * @param int $skipRows number of rows to skip from the import file - * - * @return bool - */ - public function save($name, array $value, $skipRows) - { - return (bool) $this->connection->insert( - $this->dbPrefix . 'import_match', - [ - '`name`' => pSQL($name), - '`match`' => pSQL(implode('|', $value)), - '`skip`' => (int) $skipRows, - ] - ); - } -} diff --git a/src/Adapter/Import/Handler/AbstractImportHandler.php b/src/Adapter/Import/Handler/AbstractImportHandler.php deleted file mode 100644 index 86bb1dfa..00000000 --- a/src/Adapter/Import/Handler/AbstractImportHandler.php +++ /dev/null @@ -1,507 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Import\Handler; - -use Language; -use ObjectModel; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\Database; -use PrestaShop\PrestaShop\Adapter\Import\ImportDataFormatter; -use PrestaShop\PrestaShop\Adapter\Validate; -use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface; -use PrestaShop\PrestaShop\Core\Import\Configuration\ImportConfigInterface; -use PrestaShop\PrestaShop\Core\Import\Configuration\ImportRuntimeConfigInterface; -use PrestaShop\PrestaShop\Core\Import\Exception\EmptyDataRowException; -use PrestaShop\PrestaShop\Core\Import\File\DataRow\DataRowInterface; -use PrestaShop\PrestaShop\Core\Import\Handler\ImportHandlerInterface; -use Psr\Log\LoggerInterface; -use Symfony\Component\PropertyAccess\PropertyAccess; -use Symfony\Component\PropertyAccess\PropertyAccessor; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class AbstractImportHandler is an abstract handler for import. - */ -abstract class AbstractImportHandler implements ImportHandlerInterface -{ - /** - * @var ImportDataFormatter - */ - protected $dataFormatter; - - /** - * @var array - */ - protected $contextShopIds; - - /** - * @var bool whether the multistore feature is enabled - */ - protected $isMultistoreEnabled; - - /** - * @var int - */ - protected $currentContextShopId; - - /** - * @var TranslatorInterface - */ - protected $translator; - - /** - * @var array all shops ids - */ - protected $allShopIds; - - /** - * @var string import type label - */ - protected $importTypeLabel; - - /** - * @var Database - */ - protected $legacyDatabase; - - /** - * @var int - */ - protected $languageId; - - /** - * @var Configuration - */ - protected $configuration; - - /** - * @var Validate - */ - protected $validate; - - /** - * @var PropertyAccessor - */ - protected $propertyAccessor; - - /** - * @var int - */ - protected $defaultLanguageId; - - /** - * @var array entity default values - */ - protected $defaultValues = []; - - /** - * Callback methods with field names as keys. - * Callback methods are executed on fields during import process. - * - * @var array - */ - private $callbacks = []; - - /** - * Multilingual entity fields. - * - * @var array - */ - private $languageFields = [ - 'name', - 'description', - 'description_short', - 'meta_title', - 'meta_keywords', - 'meta_description', - 'link_rewrite', - 'available_now', - 'available_later', - 'delivery_in_stock', - 'delivery_out_stock', - ]; - - /** - * @var array - */ - private $warnings = []; - - /** - * @var array - */ - private $errors = []; - - /** - * @var array - */ - private $notices = []; - - /** - * @var int - */ - private $contextLanguageId; - - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @var int employee ID, used for logs - */ - private $employeeId; - - /** - * @var CacheClearerInterface - */ - private $cacheClearer; - - /** - * @param ImportDataFormatter $dataFormatter - * @param array $allShopIds - * @param array $contextShopIds - * @param int $currentContextShopId - * @param bool $isMultistoreEnabled - * @param int $contextLanguageId - * @param TranslatorInterface $translator - * @param LoggerInterface $logger - * @param int $employeeId - * @param Database $legacyDatabase - * @param CacheClearerInterface $cacheClearer - * @param Configuration $configuration - * @param Validate $validate - */ - public function __construct( - ImportDataFormatter $dataFormatter, - array $allShopIds, - array $contextShopIds, - $currentContextShopId, - $isMultistoreEnabled, - $contextLanguageId, - TranslatorInterface $translator, - LoggerInterface $logger, - $employeeId, - Database $legacyDatabase, - CacheClearerInterface $cacheClearer, - Configuration $configuration, - Validate $validate - ) { - $this->dataFormatter = $dataFormatter; - $this->contextShopIds = $contextShopIds; - $this->currentContextShopId = $currentContextShopId; - $this->isMultistoreEnabled = $isMultistoreEnabled; - $this->translator = $translator; - $this->allShopIds = $allShopIds; - $this->contextLanguageId = $contextLanguageId; - $this->logger = $logger; - $this->employeeId = $employeeId; - $this->legacyDatabase = $legacyDatabase; - $this->cacheClearer = $cacheClearer; - $this->configuration = $configuration; - $this->validate = $validate; - $this->propertyAccessor = PropertyAccess::createPropertyAccessor(); - $this->defaultLanguageId = $this->configuration->getInt('PS_LANG_DEFAULT'); - } - - /** - * {@inheritdoc} - */ - public function setUp(ImportConfigInterface $importConfig, ImportRuntimeConfigInterface $runtimeConfig) - { - $languageIso = trim($importConfig->getLanguageIso()); - $locale = strtolower($languageIso) . '_' . strtoupper($languageIso) . '.UTF-8'; - setlocale(LC_COLLATE, $locale); - setlocale(LC_CTYPE, $locale); - - $dataFormatter = $this->dataFormatter; - $multipleValueSeparator = $importConfig->getMultipleValueSeparator(); - - $getBoolean = function ($value) use ($dataFormatter) { - return $dataFormatter->getBoolean($value); - }; - $getPrice = function ($value) use ($dataFormatter) { - return $dataFormatter->getPrice($value); - }; - $createMultilangField = function ($value) use ($dataFormatter) { - return $dataFormatter->createMultiLangField($value); - }; - $split = function ($value) use ($dataFormatter, $multipleValueSeparator) { - return $dataFormatter->split($value, $multipleValueSeparator); - }; - $this->callbacks = [ - 'active' => $getBoolean, - 'tax_rate' => $getPrice, - 'price_tex' => $getPrice, - 'price_tin' => $getPrice, - 'reduction_price' => $getPrice, - 'reduction_percent' => $getPrice, - 'wholesale_price' => $getPrice, - 'ecotax' => $getPrice, - 'name' => $createMultilangField, - 'description' => $createMultilangField, - 'description_short' => $createMultilangField, - 'meta_title' => $createMultilangField, - 'meta_keywords' => $createMultilangField, - 'meta_description' => $createMultilangField, - 'link_rewrite' => $createMultilangField, - 'available_now' => $createMultilangField, - 'available_later' => $createMultilangField, - 'category' => $split, - 'online_only' => $getBoolean, - 'accessories' => $split, - 'image_alt' => $split, - 'delivery_in_stock' => $createMultilangField, - 'delivery_out_stock' => $createMultilangField, - ]; - - $this->legacyDatabase->disableCache(); - } - - /** - * {@inheritdoc} - */ - public function importRow( - ImportConfigInterface $importConfig, - ImportRuntimeConfigInterface $runtimeConfig, - DataRowInterface $dataRow - ) { - if ($dataRow->isEmpty()) { - $this->warning( - $this->translator->trans( - 'There is an empty row in the file that won\'t be imported.', - [], - 'Admin.Advparameters.Notification' - ) - ); - throw new EmptyDataRowException(); - } - - if (!$this->languageId) { - $this->languageId = Language::getIdByIso($importConfig->getLanguageIso()); - - if (!$this->validate->isUnsignedInt($this->languageId)) { - $this->languageId = $this->configuration->getInt('PS_LANG_DEFAULT'); - } - } - } - - /** - * {@inheritdoc} - */ - public function tearDown(ImportConfigInterface $importConfig, ImportRuntimeConfigInterface $runtimeConfig) - { - if (!$runtimeConfig->shouldValidateData()) { - $offset = $runtimeConfig->getOffset(); - - $logMessage = sprintf( - $this->translator->trans('%s import', [], 'Admin.Advparameters.Notification'), - $this->importTypeLabel - ); - $logMessage .= ' '; - $logMessage .= sprintf( - $this->translator->trans('(from %s to %s)', [], 'Admin.Advparameters.Notification'), - $offset, - $runtimeConfig->getNumberOfProcessedRows() + $offset - ); - if ($importConfig->truncate()) { - $logMessage .= ' '; - $logMessage .= $this->translator->trans('with truncate', [], 'Admin.Advparameters.Notification'); - } - $this->logger->notice( - $logMessage, - [ - 'allow_duplicate' => true, - 'object_type' => $this->importTypeLabel, - ] - ); - - if ($runtimeConfig->isFinished()) { - $this->cacheClearer->clear(); - } - } - - $this->legacyDatabase->enableCache(); - } - - /** - * {@inheritdoc} - */ - public function getWarnings() - { - return $this->warnings; - } - - /** - * Add a warning message. - * - * @param string $message - */ - public function warning($message) - { - $this->warnings[] = $message; - } - - /** - * {@inheritdoc} - */ - public function getErrors() - { - return $this->errors; - } - - /** - * Add an error message. - * - * @param string $message - */ - public function error($message) - { - $this->errors[] = $message; - } - - /** - * {@inheritdoc} - */ - public function getNotices() - { - return $this->notices; - } - - /** - * Add a notice message. - * - * @param string $message - */ - public function notice($message) - { - $this->notices[] = $message; - } - - /** - * Fetch a data value by given entity field name out of data row. - * - * @param DataRowInterface $dataRow - * @param array $entityFields required to find the data cell index in data row - * @param string $entityFieldName - * - * @return string data value - */ - protected function fetchDataValueByKey(DataRowInterface $dataRow, array $entityFields, $entityFieldName) - { - $cellIndex = array_search($entityFieldName, $entityFields); - - if (false !== $cellIndex && $dataRow->offsetExists($cellIndex)) { - $dataCell = $dataRow->offsetGet($cellIndex); - - return trim($dataCell->getValue()); - } - - return ''; - } - - /** - * Set default values for entity. - * - * @param ObjectModel $entity - */ - protected function setDefaultValues(ObjectModel $entity) - { - $members = get_object_vars($entity); - - foreach ($this->defaultValues as $field => $defaultValue) { - $fieldExists = array_key_exists($field, $members); - if (!$fieldExists || $entity->$field === null) { - $entity->$field = $defaultValue; - } - } - } - - /** - * Fill entity data out of data row. - * - * @param ObjectModel $entity - * @param array $entityFields - * @param DataRowInterface $dataRow - * @param int $languageId - */ - protected function fillEntityData( - ObjectModel $entity, - array $entityFields, - DataRowInterface $dataRow, - $languageId - ) { - foreach ($entityFields as $field) { - $value = $this->fetchDataValueByKey($dataRow, $entityFields, $field); - - if (isset($this->callbacks[$field])) { - $value = $this->callbacks[$field]($value); - } - - $canBeTranslated = in_array($field, $this->languageFields) && $languageId; - - if ($canBeTranslated) { - foreach ($value as $langId => $formattedValue) { - if (empty($entity->{$field}[$languageId]) || $langId == $languageId) { - $entity->{$field}[$langId] = $formattedValue; - } - } - } elseif (!empty($value) || $value == '0') { - $entity->{$field} = $value; - } - } - } - - /** - * Add a warning message with additional entity data. - * - * @param string $message - * @param string $entityName - * @param int|null $entityId - */ - protected function addEntityWarning($message, $entityName, $entityId = null) - { - $this->warning(sprintf( - '%s (ID %s) %s', - (string) $entityName, - null !== $entityId ? (int) $entityId : '', - $message - )); - } - - /** - * Checks if entity exists in the database. - * - * @param ObjectModel $entity - * @param string $table database table without prefix, e.g. "product". - * - * @return bool - */ - protected function entityExists(ObjectModel $entity, $table) - { - return $entity->id && ObjectModel::existsInDatabase($entity->id, $table); - } -} diff --git a/src/Adapter/Import/Handler/CategoryImportHandler.php b/src/Adapter/Import/Handler/CategoryImportHandler.php deleted file mode 100644 index 3aae58d6..00000000 --- a/src/Adapter/Import/Handler/CategoryImportHandler.php +++ /dev/null @@ -1,553 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Import\Handler; - -use Category; -use Doctrine\DBAL\Connection; -use ObjectModel; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\Database; -use PrestaShop\PrestaShop\Adapter\Import\ImageCopier; -use PrestaShop\PrestaShop\Adapter\Import\ImportDataFormatter; -use PrestaShop\PrestaShop\Adapter\Tools; -use PrestaShop\PrestaShop\Adapter\Validate; -use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface; -use PrestaShop\PrestaShop\Core\Import\Configuration\ImportConfigInterface; -use PrestaShop\PrestaShop\Core\Import\Configuration\ImportRuntimeConfigInterface; -use PrestaShop\PrestaShop\Core\Import\Entity; -use PrestaShop\PrestaShop\Core\Import\Exception\InvalidDataRowException; -use PrestaShop\PrestaShop\Core\Import\Exception\SkippedIterationException; -use PrestaShop\PrestaShop\Core\Import\File\DataRow\DataRowInterface; -use Psr\Log\LoggerInterface; -use Shop; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class CategoryImportHandler holds legacy logic of category import. - */ -final class CategoryImportHandler extends AbstractImportHandler -{ - /** - * @var array core categories IDs, such as Root and Home - */ - private $coreCategories; - - /** - * @var ImageCopier - */ - private $imageCopier; - - /** - * @var Tools - */ - private $tools; - - /** - * @var Connection - */ - private $connection; - - /** - * @var string database prefix - */ - private $dbPrefix; - - /** - * @param ImportDataFormatter $dataFormatter - * @param array $allShopIds - * @param array $contextShopIds - * @param int $currentContextShopId - * @param bool $isMultistoreEnabled - * @param int $contextLanguageId - * @param TranslatorInterface $translator - * @param LoggerInterface $logger - * @param int $employeeId - * @param Database $legacyDatabase - * @param CacheClearerInterface $cacheClearer - * @param Configuration $configuration - * @param Validate $validate - * @param ImageCopier $imageCopier - * @param Tools $tools - * @param Connection $connection - * @param string $dbPrefix - */ - public function __construct( - ImportDataFormatter $dataFormatter, - array $allShopIds, - array $contextShopIds, - $currentContextShopId, - $isMultistoreEnabled, - $contextLanguageId, - TranslatorInterface $translator, - LoggerInterface $logger, - $employeeId, - Database $legacyDatabase, - CacheClearerInterface $cacheClearer, - Configuration $configuration, - Validate $validate, - ImageCopier $imageCopier, - Tools $tools, - Connection $connection, - $dbPrefix - ) { - parent::__construct( - $dataFormatter, - $allShopIds, - $contextShopIds, - $currentContextShopId, - $isMultistoreEnabled, - $contextLanguageId, - $translator, - $logger, - $employeeId, - $legacyDatabase, - $cacheClearer, - $configuration, - $validate - ); - $this->imageCopier = $imageCopier; - $this->tools = $tools; - $this->connection = $connection; - $this->dbPrefix = $dbPrefix; - $this->importTypeLabel = $this->translator->trans('Categories', [], 'Admin.Global'); - $this->defaultValues = [ - 'active' => '1', - 'parent' => $this->configuration->getInt('PS_HOME_CATEGORY'), - 'link_rewrite' => '', - ]; - } - - /** - * {@inheritdoc} - */ - public function setUp(ImportConfigInterface $importConfig, ImportRuntimeConfigInterface $runtimeConfig) - { - parent::setUp($importConfig, $runtimeConfig); - - $this->coreCategories = [ - $this->configuration->getInt('PS_ROOT_CATEGORY'), - $this->configuration->getInt('PS_HOME_CATEGORY'), - ]; - } - - /** - * {@inheritdoc} - */ - public function importRow( - ImportConfigInterface $importConfig, - ImportRuntimeConfigInterface $runtimeConfig, - DataRowInterface $dataRow - ) { - parent::importRow($importConfig, $runtimeConfig, $dataRow); - - $entityFields = $runtimeConfig->getEntityFields(); - $categoryId = $this->fetchDataValueByKey($dataRow, $entityFields, 'id'); - - $this->checkCategoryId($categoryId); - - if ($categoryId && ($importConfig->forceIds() || ObjectModel::existsInDatabase($categoryId, 'category'))) { - $category = new Category((int) $categoryId); - } else { - $category = new Category(); - } - - $category->id_shop_default = $this->currentContextShopId; - - $this->setDefaultValues($category); - $this->fillEntityData($category, $entityFields, $dataRow, $this->languageId); - $this->findParentCategory($category, $runtimeConfig, $categoryId); - $this->fillLinkRewrite($category, $categoryId); - $this->createCategory( - $category, - $importConfig, - $runtimeConfig, - $categoryId, - $this->fetchDataValueByKey($dataRow, $entityFields, 'name'), - $this->fetchDataValueByKey($dataRow, $entityFields, 'shop') - ); - - return $category; - } - - /** - * {@inheritdoc} - */ - public function tearDown(ImportConfigInterface $importConfig, ImportRuntimeConfigInterface $runtimeConfig) - { - if (!$runtimeConfig->shouldValidateData() && $runtimeConfig->isFinished()) { - /* Import has finished, we can regenerate the categories nested tree */ - Category::regenerateEntireNtree(); - } - - parent::tearDown($importConfig, $runtimeConfig); - } - - /** - * Checks if given category ID is allowed in the import. - * - * @param int $categoryId - */ - private function checkCategoryId($categoryId) - { - if (in_array($categoryId, $this->coreCategories)) { - $this->error( - $this->translator->trans( - 'The category ID must be unique. It can\'t be the same as the one for Root or Home category.', - [], - 'Admin.Advparameters.Notification' - ) - ); - throw new InvalidDataRowException(); - } - } - - /** - * Find the parent category for category that's being imported. - * - * @param Category $category - * @param ImportRuntimeConfigInterface $runtimeConfig - * @param int $categoryId - */ - private function findParentCategory( - Category $category, - ImportRuntimeConfigInterface $runtimeConfig, - $categoryId - ) { - if (!isset($category->parent)) { - return; - } - - $isValidation = $runtimeConfig->shouldValidateData(); - - // Parent category - if (is_numeric($category->parent)) { - // Validation for parenting itself - if ($isValidation && $category->parent == $category->id) { - $this->error($this->translator->trans( - 'The category ID must be unique. It can\'t be the same as the one for the parent category (ID: %1$s).', - $categoryId ?: null, - 'Admin.Advparameters.Notification' - )); - - throw new InvalidDataRowException(); - } - - $sharedData = $runtimeConfig->getSharedData(); - $movedCategories = isset($sharedData['cat_moved']) ? $sharedData['cat_moved'] : []; - - if (isset($movedCategories[$category->parent])) { - $category->parent = $movedCategories[$category->parent]; - } - $category->id_parent = $category->parent; - } elseif (is_string($category->parent)) { - // Validation for parenting itself - if ($isValidation && isset($category->name) && ($category->parent == $category->name)) { - $this->error( - $this->translator->trans( - 'A category can\'t be its own parent. You should rename it (current name: %1$s).', - [$category->parent], - 'Admin.Advparameters.Notification' - ) - ); - - throw new InvalidDataRowException(); - } - $categoryParent = Category::searchByName($this->languageId, $category->parent, true); - if ($categoryParent['id_category']) { - $category->id_parent = (int) $categoryParent['id_category']; - $category->level_depth = (int) $categoryParent['level_depth'] + 1; - } else { - $unfriendlyError = $this->configuration->getBoolean('UNFRIENDLY_ERROR'); - $categoryToCreate = new Category(); - $categoryToCreate->name = $this->dataFormatter->createMultiLangField($category->parent); - $categoryToCreate->active = 1; - $linkRewrite = $this->dataFormatter->createFriendlyUrl( - $categoryToCreate->name[$this->languageId] - ); - $categoryToCreate->link_rewrite = $this->dataFormatter->createMultiLangField($linkRewrite); - // Default parent is home for unknown category to create - $categoryToCreate->id_parent = $this->configuration->getInt('PS_HOME_CATEGORY'); - - $fieldsError = $category->validateFields($unfriendlyError, true); - $langFieldsError = $category->validateFieldsLang($unfriendlyError, true); - $isValid = true === $fieldsError && true === $langFieldsError; - - if ($isValid && !$isValidation && $categoryToCreate->add()) { - $category->id_parent = $categoryToCreate->id; - } else { - if (!$isValidation) { - $this->error( - $this->translator->trans( - '%category_name% (ID: %id%) cannot be saved', - [ - '%category_name%' => $categoryToCreate->name[$this->languageId], - '%id%' => !empty($categoryToCreate->id) ? $categoryToCreate->id : 'null', - ], - 'Admin.Advparameters.Notification' - ) - ); - } - - if (!$isValid) { - $error = true !== $fieldsError ? $fieldsError : ''; - $error .= true !== $langFieldsError ? $langFieldsError : ''; - - $this->error($error . $this->legacyDatabase->getErrorMessage()); - } - } - } - } - } - - /** - * Fill link rewrite value for category. - * - * @param Category $category - * @param int $categoryId - */ - private function fillLinkRewrite(Category $category, $categoryId) - { - if (isset($category->link_rewrite) && !empty($category->link_rewrite[$this->defaultLanguageId])) { - $validLinkRewrite = $this->validate->isLinkRewrite($category->link_rewrite[$this->defaultLanguageId]); - $linkRewrite = $category->link_rewrite[$this->defaultLanguageId]; - } else { - $validLinkRewrite = false; - $linkRewrite = $category->link_rewrite; - } - - if (empty($linkRewrite) || !$validLinkRewrite) { - $category->link_rewrite = $this->dataFormatter->createFriendlyUrl( - $category->name[$this->defaultLanguageId] - ); - if ($category->link_rewrite == '') { - $category->link_rewrite = 'friendly-url-autogeneration-failed'; - $this->warning( - $this->translator->trans( - 'URL rewriting failed to auto-generate a friendly URL for: %category_name%', - [ - '%category_name%' => $category->name[$this->defaultLanguageId], - ], - 'Admin.Advparameters.Notification' - ) - ); - } - $category->link_rewrite = $this->dataFormatter->createMultiLangField($category->link_rewrite); - } - - if (!$validLinkRewrite) { - $this->notice( - $this->translator->trans( - 'Rewrite link for %1$s (ID %2$s): re-written as %3$s.', - [ - '%1$s' => $linkRewrite, - '%2$s' => !empty($categoryId) ? $categoryId : 'null', - '%3$s' => $category->link_rewrite[$this->defaultLanguageId], - ], - 'Admin.Advparameters.Notification' - ) - ); - } - } - - /** - * Create the category. - * - * @param Category $category - * @param ImportConfigInterface $importConfig - * @param ImportRuntimeConfigInterface $runtimeConfig - * @param int $categoryId - * @param string $categoryName - * @param string $shopData - */ - private function createCategory( - Category $category, - ImportConfigInterface $importConfig, - ImportRuntimeConfigInterface $runtimeConfig, - $categoryId, - $categoryName, - $shopData - ) { - $unfriendlyError = $this->configuration->getBoolean('UNFRIENDLY_ERROR'); - $movedCategories = []; - $result = false; - - $fieldsError = $category->validateFields($unfriendlyError, true); - $langFieldsError = $category->validateFieldsLang($unfriendlyError, true); - $isValid = true === $fieldsError && true === $langFieldsError; - - if ($isValid && empty($this->getErrors())) { - $categoryAlreadyCreated = Category::searchByNameAndParentCategoryId( - $this->languageId, - $category->name[$this->languageId], - $category->id_parent - ); - - // If category already in base, get id category back - if ($categoryAlreadyCreated['id_category']) { - $movedCategories[$category->id] = (int) $categoryAlreadyCreated['id_category']; - $category->id = (int) $categoryAlreadyCreated['id_category']; - if (Validate::isDate($categoryAlreadyCreated['date_add'])) { - $category->date_add = $categoryAlreadyCreated['date_add']; - } - } - - if ($category->id && $category->id == $category->id_parent) { - $this->error( - sprintf( - $this->translator->trans( - 'A category cannot be its own parent. The parent category ID is either missing or unknown (ID: %1$s).', - [], - 'Admin.Advparameters.Notification' - ), - !empty($categoryId) ? $categoryId : 'null' - ) - ); - - throw new InvalidDataRowException(); - } - - /* No automatic nTree regeneration for import */ - $category->doNotRegenerateNTree = true; - - // If id category AND id category already in base, trying to update - if ($category->id && - $category->categoryExists($category->id) && - !in_array($category->id, $this->coreCategories) && - !$runtimeConfig->shouldValidateData() - ) { - $result = $category->update(); - } - if ($category->id == $this->configuration->getInt('PS_ROOT_CATEGORY')) { - $this->error( - $this->translator->trans( - 'The root category cannot be modified.', - [], - 'Admin.Advparameters.Notification' - ) - ); - } - // If no id_category or update failed - $category->force_id = (bool) $importConfig->forceIds(); - if (!$result && !$runtimeConfig->shouldValidateData()) { - $result = $category->add(); - if ($categoryId && $category->id != $categoryId) { - $movedCategories[$categoryId] = $category->id; - } - } - } - - if ($movedCategories) { - $sharedData = $runtimeConfig->getSharedData(); - - if ($this->propertyAccessor->isWritable($sharedData, '[cat_moved]')) { - $sharedItem = $this->propertyAccessor->getValue($sharedData, '[cat_moved]'); - $sharedItem = is_array($sharedItem) ? $sharedItem + $movedCategories : $movedCategories; - $runtimeConfig->addSharedDataItem('cat_moved', $sharedItem); - } - } - - if ($runtimeConfig->shouldValidateData()) { - throw new SkippedIterationException(); - } - - //copying images of categories - if (!empty($category->image)) { - $copyResult = $this->imageCopier->copyImg( - $category->id, - null, - $category->image, - 'categories', - !$importConfig->skipThumbnailRegeneration() - ); - - if (!$copyResult) { - $this->warning( - $category->image . - ' ' . - $this->translator->trans('cannot be copied.', [], 'Admin.Advparameters.Notification') - ); - } - } - - // If both failed, mysql error - if (!$result) { - $this->error( - $this->translator->trans( - '%1$s (ID: %2$s) cannot be %3$s', - [ - !empty($categoryName) ? $this->tools->sanitize($categoryName) : 'No Name', - !empty($categoryId) ? $this->tools->sanitize($categoryId) : 'No ID', - $runtimeConfig->shouldValidateData() ? 'validated' : 'saved', - ], - 'Admin.Advparameters.Notification' - ) - ); - $error = $fieldsError !== true ? $fieldsError : ''; - $error .= $langFieldsError !== true ? $langFieldsError : ''; - $error .= $this->legacyDatabase->getErrorMessage(); - - if ($error) { - $this->error($error); - } - } else { - // Associate category to shop - if ($this->isMultistoreEnabled) { - $this->connection->delete( - $this->dbPrefix . 'category_shop', - [ - 'id_category' => (int) $category->id, - ] - ); - - if (empty($shopData)) { - $shopData = implode($importConfig->getMultipleValueSeparator(), $this->contextShopIds); - } - - // Get shops for each attributes - $shopData = explode($importConfig->getMultipleValueSeparator(), $shopData); - - foreach ($shopData as $shop) { - if (!empty($shop)) { - if (!is_numeric($shop)) { - $category->addShop(Shop::getIdByName($shop)); - } else { - $category->addShop($shop); - } - } - } - } - } - } - - /** - * {@inheritdoc} - */ - public function supports($importEntityType) - { - return $importEntityType === Entity::TYPE_CATEGORIES; - } -} diff --git a/src/Adapter/Import/Handler/ImportHandlerFinder.php b/src/Adapter/Import/Handler/ImportHandlerFinder.php deleted file mode 100644 index ae6fbc58..00000000 --- a/src/Adapter/Import/Handler/ImportHandlerFinder.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Import\Handler; - -use PrestaShop\PrestaShop\Core\Import\Exception\NotSupportedImportTypeException; -use PrestaShop\PrestaShop\Core\Import\Handler\ImportHandlerFinderInterface; -use PrestaShop\PrestaShop\Core\Import\Handler\ImportHandlerInterface; - -/** - * Class ImportHandlerFinder is responsible for finding a proper import handler. - */ -final class ImportHandlerFinder implements ImportHandlerFinderInterface -{ - /** - * @var ImportHandlerInterface[] - */ - private $importHandlers; - - /** - * @param ImportHandlerInterface[] $importHandlers - */ - public function __construct(ImportHandlerInterface ...$importHandlers) - { - $this->importHandlers = $importHandlers; - } - - /** - * {@inheritdoc} - */ - public function find($importEntityType) - { - foreach ($this->importHandlers as $importHandler) { - if ($importHandler->supports($importEntityType)) { - return $importHandler; - } - } - - throw new NotSupportedImportTypeException(); - } -} diff --git a/src/Adapter/Import/Handler/ProductImportHandler.php b/src/Adapter/Import/Handler/ProductImportHandler.php deleted file mode 100644 index 3801c434..00000000 --- a/src/Adapter/Import/Handler/ProductImportHandler.php +++ /dev/null @@ -1,1420 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Import\Handler; - -use Address; -use Category; -use Doctrine\DBAL\Connection; -use Feature; -use FeatureValue; -use Image; -use Manufacturer; -use Module; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\Database; -use PrestaShop\PrestaShop\Adapter\Import\ImageCopier; -use PrestaShop\PrestaShop\Adapter\Import\ImportDataFormatter; -use PrestaShop\PrestaShop\Adapter\Tools; -use PrestaShop\PrestaShop\Adapter\Validate; -use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface; -use PrestaShop\PrestaShop\Core\Import\Configuration\ImportConfigInterface; -use PrestaShop\PrestaShop\Core\Import\Configuration\ImportRuntimeConfigInterface; -use PrestaShop\PrestaShop\Core\Import\Entity; -use PrestaShop\PrestaShop\Core\Import\File\DataRow\DataRowInterface; -use Product; -use ProductDownload; -use ProductSupplier; -use Psr\Log\LoggerInterface; -use Shop; -use SpecificPrice; -use StockAvailable; -use StockManagerFactory; -use Supplier; -use Symfony\Component\Translation\TranslatorInterface; -use Tag; -use TaxManagerFactory; -use TaxRulesGroup; -use Warehouse; -use WarehouseProductLocation; - -/** - * Class ProductImportHandler is responsible for product import. - */ -final class ProductImportHandler extends AbstractImportHandler -{ - /** - * @var Connection database connection - */ - private $connection; - - /** - * @var string product database table name - */ - private $productTable; - - /** - * @var string accessory database table name - */ - private $accessoryTable; - - /** - * @var Address - */ - private $shopAddress; - - /** - * @var Tools - */ - private $tools; - - /** - * @var ImageCopier - */ - private $imageCopier; - - /** - * @param ImportDataFormatter $dataFormatter - * @param array $allShopIds - * @param array $contextShopIds - * @param int $currentContextShopId - * @param bool $isMultistoreEnabled - * @param int $contextLanguageId - * @param TranslatorInterface $translator - * @param LoggerInterface $logger - * @param int $employeeId - * @param Database $legacyDatabase - * @param CacheClearerInterface $cacheClearer - * @param Connection $connection - * @param string $dbPrefix - * @param Configuration $configuration - * @param Address $shopAddress - * @param Validate $validate - * @param Tools $tools - * @param ImageCopier $imageCopier - */ - public function __construct( - ImportDataFormatter $dataFormatter, - array $allShopIds, - array $contextShopIds, - $currentContextShopId, - $isMultistoreEnabled, - $contextLanguageId, - TranslatorInterface $translator, - LoggerInterface $logger, - $employeeId, - Database $legacyDatabase, - CacheClearerInterface $cacheClearer, - Connection $connection, - $dbPrefix, - Configuration $configuration, - Address $shopAddress, - Validate $validate, - Tools $tools, - ImageCopier $imageCopier - ) { - parent::__construct( - $dataFormatter, - $allShopIds, - $contextShopIds, - $currentContextShopId, - $isMultistoreEnabled, - $contextLanguageId, - $translator, - $logger, - $employeeId, - $legacyDatabase, - $cacheClearer, - $configuration, - $validate - ); - - $this->connection = $connection; - $this->productTable = $dbPrefix . 'product'; - $this->accessoryTable = $dbPrefix . 'accessory'; - $this->defaultValues = [ - 'id_category' => [$this->configuration->getInt('PS_HOME_CATEGORY')], - 'id_category_default' => null, - 'active' => '1', - 'width' => 0.000000, - 'height' => 0.000000, - 'depth' => 0.000000, - 'weight' => 0.000000, - 'visibility' => 'both', - 'additional_shipping_cost' => 0.00, - 'unit_price' => 0, - 'quantity' => 0, - 'minimal_quantity' => 1, - 'low_stock_threshold' => null, - 'low_stock_alert' => false, - 'price' => 0, - 'id_tax_rules_group' => 0, - 'description_short' => [$this->defaultLanguageId => ''], - 'link_rewrite' => [$this->defaultLanguageId => ''], - 'online_only' => 0, - 'condition' => 'new', - 'available_date' => date('Y-m-d'), - 'date_add' => date('Y-m-d H:i:s'), - 'date_upd' => date('Y-m-d H:i:s'), - 'customizable' => 0, - 'uploadable_files' => 0, - 'text_fields' => 0, - 'advanced_stock_management' => 0, - 'depends_on_stock' => 0, - 'is_virtual' => 0, - ]; - $this->shopAddress = $shopAddress; - $this->tools = $tools; - $this->imageCopier = $imageCopier; - $this->importTypeLabel = $this->translator->trans('Products', [], 'Admin.Global'); - } - - /** - * {@inheritdoc} - */ - public function setUp(ImportConfigInterface $importConfig, ImportRuntimeConfigInterface $runtimeConfig) - { - parent::setUp($importConfig, $runtimeConfig); - - if (!defined('PS_MASS_PRODUCT_CREATION')) { - define('PS_MASS_PRODUCT_CREATION', true); - } - - if (!$runtimeConfig->shouldValidateData()) { - Module::setBatchMode(true); - } - } - - /** - * {@inheritdoc} - */ - public function importRow( - ImportConfigInterface $importConfig, - ImportRuntimeConfigInterface $runtimeConfig, - DataRowInterface $dataRow - ) { - parent::importRow($importConfig, $runtimeConfig, $dataRow); - - $entityFields = $runtimeConfig->getEntityFields(); - $productId = $this->fetchProductId( - $dataRow, - $runtimeConfig->getEntityFields(), - $importConfig->matchReferences() - ); - $productName = $this->fetchDataValueByKey($dataRow, $entityFields, 'name'); - $product = new Product($productId); - - $this->loadStock($product); - $this->setDefaultValues($product); - $this->fillEntityData($product, $entityFields, $dataRow, $this->languageId); - $this->loadShops($product, $importConfig, $productName); - $this->loadTaxes($product); - $this->loadManufacturer($product, false); - $this->loadSupplier($product, false); - $this->loadPrice($product); - $this->loadCategory($product, false); - $this->loadMetaData($product, $importConfig); - $this->fixFloatValues($product); - - $productExistsById = $this->entityExists($product, 'product'); - $productExistsByReference = $importConfig->matchReferences() && - $product->reference && - $product->existsRefInDatabase($product->reference) - ; - - if ($productExistsByReference || $productExistsById) { - $product->date_upd = date('Y-m-d H:i:s'); - } - - $unfriendlyError = $this->configuration->getBoolean('UNFRIENDLY_ERROR'); - $fieldsError = $product->validateFields($unfriendlyError, true); - $langFieldsError = $product->validateFieldsLang($unfriendlyError, true); - $isValid = true === $fieldsError && true === $langFieldsError; - - if ($isValid) { - $productSaved = $this->loadProductData( - $product, - $importConfig, - $productExistsById, - $productExistsByReference, - $runtimeConfig->shouldValidateData(), - $dataRow, - $entityFields - ); - - if (!$productSaved) { - $productId = $this->fetchDataValueByKey($dataRow, $entityFields, 'id'); - - $this->error(sprintf( - $this->translator->trans('%1$s (ID: %2$s) cannot be saved', [], 'Admin.Advparameters.Notification'), - !empty($productName) ? $this->tools->sanitize($productName) : 'No Name', - !empty($productId) ? $this->tools->sanitize($productId) : 'No ID' - )); - - $this->error($fieldsError . $langFieldsError . $this->legacyDatabase->getErrorMessage()); - } else { - if (!$runtimeConfig->shouldValidateData()) { - $this->saveProductSupplier($product); - $this->saveProductTags($product, $importConfig, $productName); - $this->saveProductImages($product, $importConfig); - $this->saveFeatures($product, $importConfig); - } - - $this->saveSpecificPrice( - $product, - $this->fetchDataValueByKey($dataRow, $entityFields, 'reduction_price'), - $this->fetchDataValueByKey($dataRow, $entityFields, 'reduction_percent'), - $this->fetchDataValueByKey($dataRow, $entityFields, 'reduction_from'), - $this->fetchDataValueByKey($dataRow, $entityFields, 'reduction_to'), - $runtimeConfig->shouldValidateData(), - $productName - ); - $this->updateAdditionalData($product, $runtimeConfig->shouldValidateData()); - $this->saveStock( - $product, - $runtimeConfig->shouldValidateData(), - $productExistsById || $productExistsByReference - ); - - $this->linkAccessories($product, $runtimeConfig); - } - } - } - - /** - * {@inheritdoc} - */ - public function tearDown(ImportConfigInterface $importConfig, ImportRuntimeConfigInterface $runtimeConfig) - { - parent::tearDown($importConfig, $runtimeConfig); - - if ($runtimeConfig->isFinished() && !$runtimeConfig->shouldValidateData()) { - $this->importAccessories($runtimeConfig); - } - - if (!$runtimeConfig->shouldValidateData()) { - Module::processDeferedFuncCall(); - Module::processDeferedClearCache(); - Tag::updateTagCount(); - } - } - - /** - * Legacy logic to create category. - * This method is internally called by legacy Category::searchByPath(), so it has to be public. - * - * @param int $defaultLanguageId - * @param string $categoryName - * @param int|null $parentCategoryId - */ - public function createCategory($defaultLanguageId, $categoryName, $parentCategoryId = null) - { - $unfriendlyError = $this->configuration->getBoolean('UNFRIENDLY_ERROR'); - $homeCategoryId = $this->configuration->getInt('PS_HOME_CATEGORY'); - $category = new Category(); - - $category->id_shop_default = $this->isMultistoreEnabled ? (int) $this->currentContextShopId : 1; - $category->name = $this->dataFormatter->createMultiLangField(trim($categoryName)); - $category->active = 1; - $category->id_parent = (int) ($parentCategoryId ? $parentCategoryId : $homeCategoryId); - $category->link_rewrite = $this->dataFormatter->createMultiLangField( - $this->dataFormatter->createFriendlyUrl($category->name[$defaultLanguageId]) - ); - - $fieldsError = $category->validateFields($unfriendlyError, true); - $langFieldsError = $category->validateFieldsLang($unfriendlyError, true); - $isValid = true === $fieldsError && true === $langFieldsError; - - if (!$isValid || !$category->add()) { - $this->error(sprintf( - $this->translator->trans( - '%1$s (ID: %2$s) cannot be saved', - [], - 'Admin.Advparameters.Notification' - ), - $category->name[$defaultLanguageId], - !empty($category->id) ? $category->id : 'null' - )); - - if (!$isValid) { - $error = true !== $fieldsError ? $fieldsError : ''; - $error .= true !== $langFieldsError ? $langFieldsError : ''; - - $this->error($error . $this->legacyDatabase->getErrorMessage()); - } - } - } - - /** - * Fetch the product ID. - * - * @param DataRowInterface $dataRow - * @param array $entityFields - * @param bool $fetchByReference if true, will fallback to finding the product ID by reference - * - * @return int|null - */ - private function fetchProductId( - DataRowInterface $dataRow, - array $entityFields, - $fetchByReference - ) { - $productId = $this->fetchDataValueByKey($dataRow, $entityFields, 'id'); - - if (!empty($productId)) { - return (int) $productId; - } - - if ($fetchByReference) { - $productReference = $this->fetchDataValueByKey($dataRow, $entityFields, 'reference'); - - if ($productReference) { - $statement = $this->connection->query( - 'SELECT p.`id_product` - FROM `' . $this->productTable . '` p - ' . Shop::addSqlAssociation('product', 'p') . ' - WHERE p.`reference` = "' . pSQL($productReference) . '"' - ); - $row = $statement->fetch(); - - return isset($row['id_product']) ? $row['id_product'] : null; - } - } - - return null; - } - - /** - * Load stock data for the product. - * - * @param Product $product - */ - private function loadStock(Product $product) - { - if (!Validate::isLoadedObject($product)) { - return; - } - - $product->loadStockData(); - $category_data = Product::getProductCategories((int) $product->id); - - if (is_array($category_data)) { - foreach ($category_data as $tmp) { - if (!isset($product->category) || !$product->category || is_array($product->category)) { - $product->category[] = $tmp; - } - } - } - } - - /** - * Load shops data into the product object. - * - * @param Product $product - * @param ImportConfigInterface $importConfig - * @param string $productName used for error messages - */ - private function loadShops(Product $product, ImportConfigInterface $importConfig, $productName) - { - $defaultShopId = $this->configuration->getInt('PS_SHOP_DEFAULT'); - - if (!$this->isMultistoreEnabled) { - $product->shop = $defaultShopId; - $product->id_shop_default = $defaultShopId; - } elseif (!isset($product->shop) || empty($product->shop)) { - $product->shop = implode($importConfig->getMultipleValueSeparator(), $this->contextShopIds); - $product->id_shop_default = $this->currentContextShopId; - } - - // link product to shops - $product->id_shop_list = []; - $productShops = explode($importConfig->getMultipleValueSeparator(), $product->shop); - - if (is_array($productShops)) { - foreach ($productShops as $shop) { - if (!empty($shop)) { - $shop = is_numeric($shop) ? $shop : Shop::getIdByName($shop); - - if (!in_array($shop, $this->allShopIds)) { - $this->addEntityWarning( - $this->translator->trans('Shop is not valid', [], 'Admin.Advparameters.Notification'), - $productName, - $product->id - ); - } else { - $product->id_shop_list[] = $shop; - } - } - } - } - } - - /** - * Load taxes data into the product object. - * - * @param Product $product - */ - private function loadTaxes(Product $product) - { - if ($product->id_tax_rules_group) { - if (Validate::isLoadedObject(new TaxRulesGroup($product->id_tax_rules_group))) { - $taxManager = TaxManagerFactory::getManager($this->shopAddress, $product->id_tax_rules_group); - $taxCalculator = $taxManager->getTaxCalculator(); - $product->tax_rate = $taxCalculator->getTotalRate(); - } else { - $this->addEntityWarning( - $this->translator->trans( - 'Unknown tax rule group ID. You need to create a group with this ID first.', - [], - 'Admin.Advparameters.Notification' - ), - 'id_tax_rules_group', - $product->id_tax_rules_group - ); - } - } - - if (!$this->configuration->getBoolean('PS_USE_ECOTAX')) { - $product->ecotax = 0; - } - } - - /** - * Load manufacturer data into the product object. - * - * @param Product $product - * @param bool $validateOnly if true, will not create new manufacturer if not exists - */ - private function loadManufacturer(Product $product, $validateOnly) - { - if (!isset($product->manufacturer)) { - return; - } - - if (is_numeric($product->manufacturer) && Manufacturer::manufacturerExists($product->manufacturer)) { - $product->id_manufacturer = (int) $product->manufacturer; - } elseif (is_string($product->manufacturer) && !empty($product->manufacturer)) { - if ($manufacturer = Manufacturer::getIdByName($product->manufacturer)) { - $product->id_manufacturer = (int) $manufacturer; - } else { - $unfriendlyError = $this->configuration->getBoolean('UNFRIENDLY_ERROR'); - - $manufacturer = new Manufacturer(); - $manufacturer->name = $product->manufacturer; - $manufacturer->active = true; - - $fieldsError = $manufacturer->validateFields($unfriendlyError, true); - $langFieldsError = $manufacturer->validateFieldsLang($unfriendlyError, true); - $isValid = true === $fieldsError && true === $langFieldsError; - - // Creating the manufacturer if it's not validation step - if ($isValid && !$validateOnly && $manufacturer->add()) { - $product->id_manufacturer = (int) $manufacturer->id; - $manufacturer->associateTo($product->id_shop_list); - } else { - if (!$validateOnly) { - $this->error(sprintf( - $this->translator->trans( - '%1$s (ID: %2$s) cannot be saved', - [], - 'Admin.Advparameters.Notification' - ), - $manufacturer->name, - !empty($manufacturer->id) ? $manufacturer->id : 'null' - )); - } - - if (!$isValid) { - $error = true !== $fieldsError ? $fieldsError : ''; - $error .= true !== $langFieldsError ? $langFieldsError : ''; - - $this->error($error . $this->legacyDatabase->getErrorMessage()); - } - } - } - } - } - - /** - * Load supplier data into the product object. - * - * @param Product $product - * @param bool $validateOnly if true, will not create new supplier if not exists - */ - private function loadSupplier(Product $product, $validateOnly) - { - if (!isset($product->supplier)) { - return; - } - - if (is_numeric($product->supplier) && Supplier::supplierExists($product->supplier)) { - $product->id_supplier = (int) $product->supplier; - } elseif (is_string($product->supplier) && !empty($product->supplier)) { - if ($supplier = Supplier::getIdByName($product->supplier)) { - $product->id_supplier = (int) $supplier; - } else { - $unfriendlyError = $this->configuration->getBoolean('UNFRIENDLY_ERROR'); - - $supplier = new Supplier(); - $supplier->name = $product->supplier; - $supplier->active = true; - - $fieldsError = $supplier->validateFields($unfriendlyError, true); - $langFieldsError = $supplier->validateFieldsLang($unfriendlyError, true); - $isValid = true === $fieldsError && true === $langFieldsError; - - // Creating the supplier if it's not validation step - if ($isValid && !$validateOnly && $supplier->add()) { - $product->id_supplier = (int) $supplier->id; - $supplier->associateTo($product->id_shop_list); - } else { - if (!$validateOnly) { - $this->error(sprintf( - $this->translator->trans( - '%1$s (ID: %2$s) cannot be saved', - [], - 'Admin.Advparameters.Notification' - ), - $supplier->name, - !empty($supplier->id) ? $supplier->id : 'null' - )); - } - - if (!$isValid) { - $error = true !== $fieldsError ? $fieldsError : ''; - $error .= true !== $langFieldsError ? $langFieldsError : ''; - - $this->error($error . $this->legacyDatabase->getErrorMessage()); - } - } - } - } - } - - /** - * Load prices into product object. - * - * @param Product $product - */ - private function loadPrice(Product $product) - { - if (isset($product->price_tex) && !isset($product->price_tin)) { - $product->price = $product->price_tex; - } elseif (isset($product->price_tin) && !isset($product->price_tex)) { - $product->price = $product->price_tin; - // If a tax is already included in price, withdraw it from price - if ($product->tax_rate) { - $product->price = (float) number_format($product->price / (1 + $product->tax_rate / 100), 6, '.', ''); - } - } elseif (isset($product->price_tin, $product->price_tex)) { - $product->price = $product->price_tex; - } - } - - /** - * Load category data into product object. - * - * @param Product $product - * @param $validateOnly - */ - private function loadCategory(Product $product, $validateOnly) - { - if (isset($product->category) && is_array($product->category) && count($product->category)) { - $unfriendlyError = $this->configuration->getBoolean('UNFRIENDLY_ERROR'); - $defaultLanguageId = $this->configuration->getInt('PS_LANG_DEFAULT'); - $homeCategoryId = $this->configuration->getInt('PS_HOME_CATEGORY'); - $product->id_category = []; // Reset default values array - - foreach ($product->category as $value) { - if (is_numeric($value)) { - if (Category::categoryExists($value)) { - $product->id_category[] = (int) $value; - } else { - $category = new Category(); - $category->id = (int) $value; - $category->name = $this->dataFormatter->createMultiLangField($value); - $category->active = 1; - $category->id_parent = $homeCategoryId; - $category->link_rewrite = $this->dataFormatter->createMultiLangField( - $this->dataFormatter->createFriendlyUrl($category->name[$defaultLanguageId]) - ); - - $fieldsError = $category->validateFields($unfriendlyError, true); - $langFieldsError = $category->validateFieldsLang($unfriendlyError, true); - $isValid = true === $fieldsError && true === $langFieldsError; - - if ($isValid && !$validateOnly && $category->add()) { - $product->id_category[] = (int) $category->id; - } else { - if (!$validateOnly) { - $this->error(sprintf( - $this->translator->trans( - '%1$s (ID: %2$s) cannot be saved', - [], - 'Admin.Advparameters.Notification' - ), - $category->name[$defaultLanguageId], - !empty($category->id) ? $category->id : 'null' - )); - } - - if (!$isValid) { - $error = true !== $fieldsError ? $fieldsError : ''; - $error .= true !== $langFieldsError ? $langFieldsError : ''; - - $this->error($error . $this->legacyDatabase->getErrorMessage()); - } - } - } - } elseif (!$validateOnly && is_string($value) && !empty($value)) { - $category = Category::searchByPath( - $defaultLanguageId, - trim($value), - $this, - 'createCategory' - ); - if ($category['id_category']) { - $product->id_category[] = (int) $category['id_category']; - } else { - $this->error( - $this->translator->trans( - '%data% cannot be saved', - [ - '%data%' => trim($value), - ], - 'Admin.Advparameters.Notification' - ) - ); - } - } - } - - $product->id_category = array_values(array_unique($product->id_category)); - } - - // Category default now takes the value of the first new category during import - if (isset($product->id_category[0])) { - $product->id_category_default = (int) $product->id_category[0]; - } elseif (!empty($product->id_category_default)) { - $defaultProductShop = new Shop($product->id_shop_default); - $product->id_category_default = Category::getRootCategory( - null, - Validate::isLoadedObject($defaultProductShop) ? $defaultProductShop : null - )->id; - } - } - - /** - * Load meta data into the product object. - * - * @param Product $product - * @param ImportConfigInterface $importConfig - */ - private function loadMetaData(Product $product, ImportConfigInterface $importConfig) - { - $linkRewrite = ''; - - $linkRewriteExists = is_array($product->link_rewrite) && isset($product->link_rewrite[$this->languageId]); - - if ($linkRewriteExists) { - $linkRewrite = trim($product->link_rewrite[$this->languageId]); - } - - $validLink = $this->validate->isLinkRewrite($linkRewrite); - - if (($linkRewriteExists && empty($product->link_rewrite[$this->languageId])) || !$validLink) { - $linkRewrite = $this->dataFormatter->createFriendlyUrl($product->name[$this->languageId]); - - if ($linkRewrite == '') { - $linkRewrite = 'friendly-url-autogeneration-failed'; - } - } - - if (!$validLink) { - $this->notice($this->translator->trans( - 'Rewrite link for %1$s (ID %2$s): re-written as %3$s.', - [ - '%1$s' => $product->name[$this->languageId], - '%2$s' => !empty($info['id']) ? $info['id'] : 'null', - '%3$s' => $linkRewrite, - ], - 'Admin.Advparameters.Notification' - )); - } - - if (!$validLink || !(is_array($product->link_rewrite) && count($product->link_rewrite))) { - $product->link_rewrite = $this->dataFormatter->createMultiLangField($linkRewrite); - } else { - $product->link_rewrite[(int) $this->languageId] = $linkRewrite; - } - - $multipleValueSeparator = $importConfig->getMultipleValueSeparator(); - - // replace the value of separator by coma - if ($multipleValueSeparator != ',') { - if (is_array($product->meta_keywords)) { - foreach ($product->meta_keywords as &$metaKeyword) { - if (!empty($metaKeyword)) { - $metaKeyword = str_replace($multipleValueSeparator, ',', $metaKeyword); - } - } - } - } - } - - /** - * Fix float values. - * - * @param Product $product - */ - private function fixFloatValues(Product $product) - { - // Convert comma into dot for all floating values - foreach (Product::$definition['fields'] as $key => $array) { - if ($array['type'] == Product::TYPE_FLOAT) { - $product->{$key} = str_replace(',', '.', $product->{$key}); - } - } - } - - /** - * Load other product data. - * - * @param Product $product - * @param ImportConfigInterface $importConfig - * @param bool $productExistsById - * @param bool $productExistsByReference - * @param bool $validateOnly - * @param DataRowInterface $dataRow - * @param array $entityFields - * - * @return bool - */ - private function loadProductData( - Product $product, - ImportConfigInterface $importConfig, - $productExistsById, - $productExistsByReference, - $validateOnly, - DataRowInterface $dataRow, - array $entityFields - ) { - if (!$product->quantity) { - $product->quantity = 0; - } - - $product->force_id = (bool) $importConfig->forceIds(); - $result = true; - - if ($productExistsById || $productExistsByReference) { - $sqlPart = 'SELECT product_shop.`date_add`, p.`id_product` - FROM `' . _DB_PREFIX_ . 'product` p - ' . Shop::addSqlAssociation('product', 'p') . ' - WHERE '; - - if ($productExistsByReference) { - $sqlPart .= 'p.`reference` = "' . pSQL($product->reference) . '"'; - } elseif ($productExistsById) { - $sqlPart .= 'p.`id_product` = ' . (int) $product->id; - } - - $statement = $this->connection->query($sqlPart); - $row = $statement->fetch(); - - if ($productExistsByReference) { - $product->id = (int) $row['id_product']; - } - - $product->date_add = $row['date_add']; - - if (!$validateOnly) { - $result = $product->update(); - } - } else { - $result = $product->add($product->date_add == ''); - } - - if (!$validateOnly) { - if ($product->getType() == Product::PTYPE_VIRTUAL) { - StockAvailable::setProductOutOfStock((int) $product->id, 1); - } else { - StockAvailable::setProductOutOfStock((int) $product->id, (int) $product->out_of_stock); - } - - if ($productDownload_id = ProductDownload::getIdFromIdProduct((int) $product->id)) { - $productDownload = new ProductDownload($productDownload_id); - $productDownload->delete(true); - } - - if ($product->getType() == Product::PTYPE_VIRTUAL) { - $downloadDir = $this->configuration->get('_PS_DOWNLOAD_DIR_'); - - $productDownload = new ProductDownload(); - $productDownload->filename = ProductDownload::getNewFilename(); - $virtualProductFileUrl = $this->fetchDataValueByKey( - $dataRow, - $entityFields, - 'file_url' - ); - $this->tools->copy($virtualProductFileUrl, $downloadDir . $productDownload->filename); - $productDownload->id_product = (int) $product->id; - $productDownload->nb_downloadable = (int) $this->fetchDataValueByKey( - $dataRow, - $entityFields, - 'nb_downloadable' - ); - $productDownload->date_expiration = $this->fetchDataValueByKey( - $dataRow, - $entityFields, - 'date_expiration' - ); - $productDownload->nb_days_accessible = (int) $this->fetchDataValueByKey( - $dataRow, - $entityFields, - 'nb_days_accessible' - ); - $productDownload->display_filename = basename($virtualProductFileUrl); - $productDownload->add(); - } - } - - return $result; - } - - /** - * Save product supplier data. - * - * @param Product $product - */ - private function saveProductSupplier(Product $product) - { - if ($product->id && isset($product->id_supplier) && property_exists($product, 'supplier_reference')) { - $productSupplierId = (int) ProductSupplier::getIdByProductAndSupplier( - (int) $product->id, - 0, - (int) $product->id_supplier - ); - - $productSupplier = new ProductSupplier($productSupplierId); - $productSupplier->id_product = (int) $product->id; - $productSupplier->id_product_attribute = 0; - $productSupplier->id_supplier = (int) $product->id_supplier; - $productSupplier->product_supplier_price_te = $product->wholesale_price; - $productSupplier->product_supplier_reference = $product->supplier_reference; - $productSupplier->save(); - } - } - - /** - * Save specific price for a product. - * - * @param Product $product - * @param $reductionPrice - * @param $reductionPercent - * @param $reductionFrom - * @param $reductionTo - * @param $validateOnly - * @param $productName - */ - private function saveSpecificPrice( - Product $product, - $reductionPrice, - $reductionPercent, - $reductionFrom, - $reductionTo, - $validateOnly, - $productName - ) { - $reductionPercent = (float) $reductionPercent; - $reductionPrice = (float) $reductionPrice; - - if (!$reductionPrice <= 0 && $reductionPercent <= 0) { - return; - } - - foreach ($product->id_shop_list as $shopId) { - $specificPrice = SpecificPrice::getSpecificPrice($product->id, $shopId, 0, 0, 0, 1, 0, 0, 0, 0); - - if (is_array($specificPrice) && isset($specificPrice['id_specific_price'])) { - $specificPrice = new SpecificPrice((int) $specificPrice['id_specific_price']); - } else { - $specificPrice = new SpecificPrice(); - } - $specificPrice->id_product = (int) $product->id; - $specificPrice->id_specific_price_rule = 0; - $specificPrice->id_shop = $shopId; - $specificPrice->id_currency = 0; - $specificPrice->id_country = 0; - $specificPrice->id_group = 0; - $specificPrice->price = -1; - $specificPrice->id_customer = 0; - $specificPrice->from_quantity = 1; - $specificPrice->reduction = $reductionPrice ? $reductionPrice : $reductionPercent / 100; - $specificPrice->reduction_type = $reductionPrice ? 'amount' : 'percentage'; - $specificPrice->from = Validate::isDate($reductionFrom) ? $reductionFrom : '0000-00-00 00:00:00'; - $specificPrice->to = Validate::isDate($reductionTo) ? $reductionTo : '0000-00-00 00:00:00'; - - if (!$validateOnly && !$specificPrice->save()) { - $this->addEntityWarning( - $this->translator->trans('Discount is invalid', [], 'Admin.Advparameters.Notification'), - $this->tools->sanitize($productName), - $product->id - ); - } - } - } - - /** - * Save product tags data. - * - * @param Product $product - * @param ImportConfigInterface $importConfig - * @param string $productName product name, used for error messages - */ - private function saveProductTags(Product $product, ImportConfigInterface $importConfig, $productName) - { - if (empty($product->tags)) { - return; - } - - $multipleValueSeparator = $importConfig->getMultipleValueSeparator(); - - if (isset($product->id) && $product->id) { - $tags = Tag::getProductTags($product->id); - if (is_array($tags) && count($tags)) { - if (!empty($product->tags)) { - $product->tags = explode($multipleValueSeparator, $product->tags); - } - if (is_array($product->tags) && count($product->tags)) { - foreach ($product->tags as $key => $tag) { - if (!empty($tag)) { - $product->tags[$key] = trim($tag); - } - } - $tags[$this->languageId] = $product->tags; - $product->tags = $tags; - } - } - } - // Delete tags for this id product, for no duplicating error - Tag::deleteTagsForProduct($product->id); - - if (!is_array($product->tags) && !empty($product->tags)) { - $product->tags = $this->dataFormatter->createMultiLangField($product->tags); - foreach ($product->tags as $key => $tags) { - $isTagAdded = Tag::addTags($key, $product->id, $tags, $multipleValueSeparator); - if (!$isTagAdded) { - $this->addEntityWarning( - $this->tools->sanitize($productName), - $product->id, - $this->translator->trans('Tags list is invalid', [], 'Admin.Advparameters.Notification') - ); - break; - } - } - } else { - foreach ($product->tags as $key => $tags) { - $str = ''; - - foreach ($tags as $one_tag) { - $str .= $one_tag . $multipleValueSeparator; - } - - $str = rtrim($str, $multipleValueSeparator); - $isTagAdded = Tag::addTags($key, $product->id, $str, $multipleValueSeparator); - - if (!$isTagAdded) { - $this->addEntityWarning( - $this->tools->sanitize($productName), - (int) $product->id, - $this->translator->trans( - 'Invalid tag(s) (%s)', - [ - $str, - ], - 'Admin.Notifications.Error' - ) - ); - break; - } - } - } - } - - /** - * Save product images. - * - * @param Product $product - * @param ImportConfigInterface $importConfig - */ - private function saveProductImages(Product $product, ImportConfigInterface $importConfig) - { - //delete existing images if "delete_existing_images" is set to 1 - if (isset($product->delete_existing_images)) { - if ((bool) $product->delete_existing_images) { - $product->deleteImages(); - } - } - - if (isset($product->image) && is_array($product->image) && count($product->image)) { - $unfriendlyError = $this->configuration->getBoolean('UNFRIENDLY_ERROR'); - $product_has_images = (bool) Image::getImages($this->languageId, (int) $product->id); - - foreach ($product->image as $key => $url) { - $url = trim($url); - $error = false; - if (!empty($url)) { - $url = str_replace(' ', '%20', $url); - - $image = new Image(); - $image->id_product = (int) $product->id; - $image->position = Image::getHighestPosition($product->id) + 1; - $image->cover = (!$key && !$product_has_images) ? true : false; - $alt = $product->image_alt[$key]; - if (strlen($alt) > 0) { - $image->legend = $this->dataFormatter->createMultiLangField($alt); - } - - $fieldsError = $image->validateFields($unfriendlyError, true); - $langFieldsError = $image->validateFieldsLang($unfriendlyError, true); - $isValid = true === $fieldsError && true === $langFieldsError; - - if ($isValid && $image->add()) { - // associate image to selected shops - $image->associateTo($product->id_shop_list); - $copySucceeded = $this->imageCopier->copyImg( - $product->id, - $image->id, - $url, - 'products', - !$importConfig->skipThumbnailRegeneration() - ); - - if (!$copySucceeded) { - $image->delete(); - $this->warning( - $this->translator->trans( - 'Error copying image: %url%', - [ - '%url%' => $url, - ], - 'Admin.Advparameters.Notification' - ) - ); - } - } else { - $error = true; - } - } else { - $error = true; - } - - if ($error) { - $this->warning( - $this->translator->trans( - 'Product #%id%: the picture (%url%) cannot be saved.', - [ - '%id%' => $image->id_product, - '%url%' => $url, - ], - 'Admin.Advparameters.Notification' - ) - ); - } - } - } - } - - /** - * Update additional product data. - * - * @param Product $product - * @param bool $validateOnly - */ - private function updateAdditionalData(Product $product, $validateOnly) - { - if (!$validateOnly && isset($product->id_category) && is_array($product->id_category)) { - $product->updateCategories(array_map('intval', $product->id_category)); - } - - $product->checkDefaultAttributes(); - if (!$validateOnly && !$product->cache_default_attribute) { - Product::updateDefaultAttribute($product->id); - } - } - - /** - * Save product features. - * - * @param Product $product - * @param ImportConfigInterface $importConfig - */ - private function saveFeatures(Product $product, ImportConfigInterface $importConfig) - { - // Features import - $features = get_object_vars($product); - $multipleValueSeparator = $importConfig->getMultipleValueSeparator(); - - if (empty($features['features'])) { - return; - } - - foreach (explode($multipleValueSeparator, $features['features']) as $singleFeature) { - if (empty($singleFeature)) { - continue; - } - $feature = explode(':', $singleFeature); - $featureName = isset($feature[0]) ? trim($feature[0]) : ''; - $featureValue = isset($feature[1]) ? trim($feature[1]) : ''; - $position = isset($feature[2]) ? (int) $feature[2] - 1 : false; - $custom = isset($feature[3]) ? (int) $feature[3] : false; - - if (!empty($featureName) && !empty($featureValue)) { - $featureId = (int) Feature::addFeatureImport($featureName, $position); - $productId = null; - if ($importConfig->forceIds() || $importConfig->matchReferences()) { - $productId = (int) $product->id; - } - $featureValueId = (int) FeatureValue::addFeatureValueImport( - $featureId, - $featureValue, - $productId, - $this->languageId, - $custom - ); - Product::addFeatureProductImport($product->id, $featureId, $featureValueId); - } - } - - // clean feature positions to avoid conflict - Feature::cleanPositions(); - } - - /** - * Save stock data for the product. - * - * @param Product $product - * @param bool $validateOnly - * @param bool $productExists - */ - private function saveStock(Product $product, $validateOnly, $productExists) - { - $asmEnabled = $this->configuration->getBoolean('PS_ADVANCED_STOCK_MANAGEMENT'); - - // set advanced stock managment - if (!$validateOnly && isset($product->advanced_stock_management)) { - if ($product->advanced_stock_management != 1 && $product->advanced_stock_management != 0) { - $this->warning( - $this->translator->trans( - 'Advanced stock management has incorrect value. Not set for product %name%', - ['%name%' => $product->name[$this->languageId]], - 'Admin.Advparameters.Notification' - ) - ); - } elseif (!$asmEnabled && $product->advanced_stock_management == 1) { - $this->warning( - $this->translator->trans( - 'Advanced stock management is not enabled, cannot enable on product %name%', - ['%name%' => $product->name[$this->languageId]], - 'Admin.Advparameters.Notification' - ) - ); - } elseif ($productExists) { - $product->setAdvancedStockManagement($product->advanced_stock_management); - } - // automaticly disable depends on stock, if a_s_m set to disabled - if (StockAvailable::dependsOnStock($product->id) == 1 && $product->advanced_stock_management == 0) { - StockAvailable::setProductDependsOnStock($product->id, 0); - } - } - - // Check if warehouse exists - if (isset($product->warehouse) && $product->warehouse) { - if (!$asmEnabled) { - $this->warning( - $this->translator->trans( - 'Advanced stock management is not enabled, warehouse not set on product %name%', - ['%name%' => $product->name[$this->languageId]], - 'Admin.Advparameters.Notification' - ) - ); - } elseif (!$validateOnly) { - if (Warehouse::exists($product->warehouse)) { - // Get already associated warehouses - $associatedWarehousesCollection = WarehouseProductLocation::getCollection($product->id); - // Delete any entry in warehouse for this product - foreach ($associatedWarehousesCollection as $awc) { - $awc->delete(); - } - $warehouseLocationEntity = new WarehouseProductLocation(); - $warehouseLocationEntity->id_product = $product->id; - $warehouseLocationEntity->id_product_attribute = 0; - $warehouseLocationEntity->id_warehouse = $product->warehouse; - $warehouseLocationEntity->save(); - StockAvailable::synchronize($product->id); - } else { - $this->warning( - $this->translator->trans( - 'Warehouse did not exist, cannot set on product %name%', - ['%name%' => $product->name[$this->languageId]], - 'Admin.Advparameters.Notification' - ) - ); - } - } - } - - if ($this->isMultistoreEnabled) { - $shopIds = $product->id_shop_list; - } else { - $shopIds = [ - $this->currentContextShopId, - ]; - } - - // stock available - if (isset($product->depends_on_stock)) { - if ($product->depends_on_stock != 0 && $product->depends_on_stock != 1) { - $this->warning( - $this->translator->trans( - 'Incorrect value for "Depends on stock" for product %name%', - ['%name%' => $product->name[$this->languageId]], - 'Admin.Advparameters.Notification' - ) - ); - } elseif ((!$product->advanced_stock_management || $product->advanced_stock_management == 0) && $product->depends_on_stock == 1) { - $this->warning( - $this->translator->trans( - 'Advanced stock management is not enabled, cannot set "Depends on stock" for product %name%', - ['%name%' => $product->name[$this->languageId]], - 'Admin.Advparameters.Notification' - ) - ); - } elseif (!$validateOnly) { - StockAvailable::setProductDependsOnStock($product->id, $product->depends_on_stock); - } - - // This code allows us to set qty and disable depends on stock - if (!$validateOnly && isset($product->quantity)) { - // if depends on stock and quantity, add quantity to stock - if ($product->depends_on_stock == 1) { - $stockManager = StockManagerFactory::getManager(); - $price = str_replace(',', '.', $product->wholesale_price); - if ($price == 0) { - $price = 0.000001; - } - $price = round(floatval($price), 6); - $warehouse = new Warehouse($product->warehouse); - $productAdded = $stockManager->addProduct( - (int) $product->id, - 0, - $warehouse, - (int) $product->quantity, - 1, - $price, - true - ); - - if ($productAdded) { - StockAvailable::synchronize((int) $product->id); - } - } else { - foreach ($shopIds as $shop) { - StockAvailable::setQuantity((int) $product->id, 0, (int) $product->quantity, (int) $shop); - } - } - } - } elseif (!$validateOnly) { - // if not depends_on_stock set, use normal qty - foreach ($shopIds as $shop) { - StockAvailable::setQuantity((int) $product->id, 0, (int) $product->quantity, (int) $shop); - } - } - } - - /** - * Link product accessories. - * - * @param Product $product - * @param ImportRuntimeConfigInterface $runtimeConfig - */ - private function linkAccessories(Product $product, ImportRuntimeConfigInterface $runtimeConfig) - { - // Accessories linkage - if ($runtimeConfig->shouldValidateData()) { - return; - } - - $hasAccessories = - isset($product->accessories) && - is_array($product->accessories) && - count($product->accessories) - ; - - if ($hasAccessories) { - $sharedData = $runtimeConfig->getSharedData(); - $accessories = isset($sharedData['accessories']) ? $sharedData['accessories'] : []; - $accessories[$product->id] = $product->accessories; - $runtimeConfig->addSharedDataItem('accessories', $accessories); - } - } - - /** - * Import accessories. - * - * @param ImportRuntimeConfigInterface $runtimeConfig - */ - private function importAccessories(ImportRuntimeConfigInterface $runtimeConfig) - { - $sharedData = $runtimeConfig->getSharedData(); - - if (!isset($sharedData['accessories'])) { - return; - } - - foreach ($sharedData['accessories'] as $productId => $links) { - if (count($links) > 0) { // We delete and relink only if there is accessories to link... - // Bulk jobs: for performances, we need to do a minimum amount of SQL queries. No product inflation. - $uniqueIds = Product::getExistingIdsFromIdsOrRefs($links); - $this->connection->delete( - $this->accessoryTable, - [ - 'id_product_1' => (int) $productId, - ] - ); - Product::changeAccessoriesForProduct($uniqueIds, $productId); - } - } - } - - /** - * {@inheritdoc} - */ - public function supports($importEntityType) - { - return $importEntityType === Entity::TYPE_PRODUCTS; - } -} diff --git a/src/Adapter/Import/ImageCopier.php b/src/Adapter/Import/ImageCopier.php deleted file mode 100644 index c0c0c719..00000000 --- a/src/Adapter/Import/ImageCopier.php +++ /dev/null @@ -1,250 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Import; - -use Image; -use ImageManager; -use ImageType; -use PrestaShop\PrestaShop\Adapter\Tools; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; - -/** - * Class ImageCopier copies images during import process. - */ -final class ImageCopier -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var Tools - */ - private $tools; - - /** - * @var int - */ - private $contextShopId; - - /** - * @var HookDispatcherInterface - */ - private $hookDispatcher; - - /** - * @param ConfigurationInterface $configuration - * @param Tools $tools - * @param int $contextShopId - * @param HookDispatcherInterface $hookDispatcher - */ - public function __construct( - ConfigurationInterface $configuration, - Tools $tools, - $contextShopId, - HookDispatcherInterface $hookDispatcher - ) { - $this->configuration = $configuration; - $this->tools = $tools; - $this->contextShopId = $contextShopId; - $this->hookDispatcher = $hookDispatcher; - } - - /** - * Copy an image located in $url and save it in a path. - * - * @param int $entityId id of product or category (set in entity) - * @param int $imageId id of the image if watermark enabled - * @param string $url path or url to use - * @param string $entity 'products' or 'categories' - * @param bool $regenerate - * - * @return bool - */ - public function copyImg($entityId, $imageId = null, $url = '', $entity = 'products', $regenerate = true) - { - $tmpDir = $this->configuration->get('_PS_TMP_IMG_DIR_'); - $tmpFile = tempnam($tmpDir, 'ps_import'); - $watermarkTypes = explode(',', $this->configuration->get('WATERMARK_TYPES')); - - switch ($entity) { - default: - case 'products': - $image_obj = new Image($imageId); - $path = $image_obj->getPathForCreation(); - break; - case 'categories': - $path = $this->configuration->get('_PS_CAT_IMG_DIR_') . (int) $entityId; - break; - case 'manufacturers': - $path = $this->configuration->get('_PS_MANU_IMG_DIR_') . (int) $entityId; - break; - case 'suppliers': - $path = $this->configuration->get('_PS_SUPP_IMG_DIR_') . (int) $entityId; - break; - case 'stores': - $path = $this->configuration->get('_PS_STORE_IMG_DIR_') . (int) $entityId; - break; - } - - $url = urldecode(trim($url)); - $parsedUrl = parse_url($url); - - if (isset($parsedUrl['path'])) { - $uri = ltrim($parsedUrl['path'], '/'); - $parts = explode('/', $uri); - foreach ($parts as &$part) { - $part = rawurlencode($part); - } - unset($part); - $parsedUrl['path'] = '/' . implode('/', $parts); - } - - if (isset($parsedUrl['query'])) { - $query_parts = []; - parse_str($parsedUrl['query'], $query_parts); - $parsedUrl['query'] = http_build_query($query_parts); - } - - if (!function_exists('http_build_url')) { - require_once $this->configuration->get('_PS_TOOL_DIR_') . 'http_build_url/http_build_url.php'; - } - - $url = http_build_url('', $parsedUrl); - - $origTmpfile = $tmpFile; - - if ($this->tools->copy($url, $tmpFile)) { - // Evaluate the memory required to resize the image: if it's too much, you can't resize it. - if (!ImageManager::checkImageMemoryLimit($tmpFile)) { - @unlink($tmpFile); - - return false; - } - - $targetWidth = $targetHeight = 0; - $sourceWidth = $sourceHeight = 0; - $error = 0; - ImageManager::resize( - $tmpFile, - $path . '.jpg', - null, - null, - 'jpg', - false, - $error, - $targetWidth, - $targetHeight, - 5, - $sourceWidth, - $sourceHeight - ); - $imagesTypes = ImageType::getImagesTypes($entity, true); - - if ($regenerate) { - $previous_path = null; - $pathInfos = []; - $pathInfos[] = [$targetWidth, $targetHeight, $path . '.jpg']; - foreach ($imagesTypes as $imageType) { - $tmpFile = $this->getBestPath($imageType['width'], $imageType['height'], $pathInfos); - - if (ImageManager::resize( - $tmpFile, - $path . '-' . stripslashes($imageType['name']) . '.jpg', - $imageType['width'], - $imageType['height'], - 'jpg', - false, - $error, - $targetWidth, - $targetHeight, - 5, - $sourceWidth, - $sourceHeight - )) { - // the last image should not be added in the candidate list if it's bigger than the original image - if ($targetWidth <= $sourceWidth && $targetHeight <= $sourceHeight) { - $pathInfos[] = [$targetWidth, $targetHeight, $path . '-' . stripslashes($imageType['name']) . '.jpg']; - } - if ($entity == 'products') { - $file = $tmpDir . 'product_mini_' . (int) $entityId . '.jpg'; - if (is_file($file)) { - unlink($file); - } - - $file = $tmpDir . 'product_mini_' . (int) $entityId . '_' . (int) $this->contextShopId . '.jpg'; - if (is_file($file)) { - unlink($file); - } - } - } - if (in_array($imageType['id_image_type'], $watermarkTypes)) { - $this->hookDispatcher->dispatchWithParameters( - 'actionWatermark', - [ - 'id_image' => $imageId, - 'id_product' => $entityId, - ] - ); - } - } - } - } else { - @unlink($origTmpfile); - - return false; - } - unlink($origTmpfile); - - return true; - } - - /** - * Find the best path, compared to given dimensions. - * - * @param int $targetWidth - * @param int $targetHeight - * @param array $pathInfos - * - * @return string - */ - private function getBestPath($targetWidth, $targetHeight, $pathInfos) - { - $pathInfos = array_reverse($pathInfos); - $path = ''; - foreach ($pathInfos as $pathInfo) { - list($width, $height, $path) = $pathInfo; - if ($width >= $targetWidth && $height >= $targetHeight) { - return $path; - } - } - - return $path; - } -} diff --git a/src/Adapter/Import/ImportDataFormatter.php b/src/Adapter/Import/ImportDataFormatter.php deleted file mode 100644 index 7c608323..00000000 --- a/src/Adapter/Import/ImportDataFormatter.php +++ /dev/null @@ -1,155 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Import; - -use Language; -use PrestaShop\PrestaShop\Adapter\Tools; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; - -/** - * Class ImportDataFormatter is an adapter with data formatting methods for import. - */ -final class ImportDataFormatter -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var Tools - */ - private $tools; - - public function __construct( - ConfigurationInterface $configuration, - Tools $tools - ) { - $this->configuration = $configuration; - $this->tools = $tools; - } - - /** - * @param $value - * - * @return bool - */ - public function getBoolean($value) - { - return (bool) $value; - } - - /** - * @param string $field - * - * @return float - */ - public function getPrice($field) - { - $field = (float) str_replace(',', '.', $field); - $field = (float) str_replace('%', '', $field); - - return $field; - } - - /** - * Create a multilang field. - * - * @param string $field - * - * @return array - */ - public function createMultiLangField($field) - { - $result = []; - - foreach (Language::getIDs(false) as $languageId) { - $result[$languageId] = $field; - } - - return $result; - } - - /** - * Split the field by separator. - * - * @param string $field - * @param string $separator - * - * @return array - */ - public function split($field, $separator) - { - if (empty($field)) { - return []; - } - - if (is_null($separator) || trim($separator) == '') { - $separator = ','; - } - - $uniqidPath = false; - - // try data:// protocol. If failed, old school file on filesystem. - if (false === ($fd = @fopen('data://text/plain;base64,' . base64_encode($field), 'rb'))) { - do { - $uniqidPath = $this->configuration->get('_PS_UPLOAD_DIR_') . uniqid(); - } while (file_exists($uniqidPath)); - file_put_contents($uniqidPath, $field); - $fd = fopen($uniqidPath, 'r'); - } - - if ($fd === false) { - return []; - } - - $content = fgetcsv($fd, 0, $separator); - fclose($fd); - - if ($uniqidPath !== false && file_exists($uniqidPath)) { - @unlink($uniqidPath); - } - - if (empty($content) || !is_array($content)) { - return []; - } - - return $content; - } - - /** - * Transform given value into a friendly url string. - * - * @param string $value - * - * @return string - */ - public function createFriendlyUrl($value) - { - return $this->tools->linkRewrite($value); - } -} diff --git a/src/Adapter/Import/ImportEntityDeleter.php b/src/Adapter/Import/ImportEntityDeleter.php deleted file mode 100644 index 7456806b..00000000 --- a/src/Adapter/Import/ImportEntityDeleter.php +++ /dev/null @@ -1,311 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Import; - -use Doctrine\DBAL\Connection; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Image\Deleter\ImageFileDeleterInterface; -use PrestaShop\PrestaShop\Core\Import\Entity; -use PrestaShop\PrestaShop\Core\Import\Entity\ImportEntityDeleterInterface; -use PrestaShop\PrestaShop\Core\Import\Exception\NotSupportedImportEntityException; - -/** - * Class ImportEntityDeleter is responsible for deleting import entities. - */ -final class ImportEntityDeleter implements ImportEntityDeleterInterface -{ - /** - * @var Connection - */ - private $connection; - - /** - * @var string database prefix - */ - private $dbPrefix; - - /** - * @var Configuration - */ - private $configuration; - - /** - * @var ImageFileDeleterInterface - */ - private $imageFileDeleter; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param Configuration $configuration - * @param ImageFileDeleterInterface $imageFileDeleter - */ - public function __construct( - Connection $connection, - $dbPrefix, - Configuration $configuration, - ImageFileDeleterInterface $imageFileDeleter - ) { - $this->connection = $connection; - $this->dbPrefix = $dbPrefix; - $this->configuration = $configuration; - $this->imageFileDeleter = $imageFileDeleter; - } - - /** - * {@inheritdoc} - */ - public function deleteAll($importEntity) - { - switch ($importEntity) { - case Entity::TYPE_CATEGORIES: - $this->deleteCategories(); - - break; - - case Entity::TYPE_PRODUCTS: - $this->deleteProducts(); - - break; - - case Entity::TYPE_COMBINATIONS: - $this->deleteCombinations(); - - break; - - case Entity::TYPE_CUSTOMERS: - $this->truncateTables([ - 'customer', - ]); - - break; - - case Entity::TYPE_ADDRESSES: - $this->truncateTables([ - 'address', - ]); - - break; - - case Entity::TYPE_MANUFACTURERS: - $this->deleteManufacturers(); - - break; - - case Entity::TYPE_SUPPLIERS: - $this->deleteSuppliers(); - - break; - - case Entity::TYPE_ALIAS: - $this->truncateTables([ - 'alias', - ]); - - break; - - default: - throw new NotSupportedImportEntityException("Import entity \"{$importEntity}\" is not supported"); - } - - $this->imageFileDeleter->deleteAllImages($this->configuration->get('_PS_TMP_IMG_DIR_')); - } - - /** - * Delete all suppliers data and images. - */ - private function deleteSuppliers() - { - $this->truncateTables([ - 'supplier', - 'supplier_lang', - 'supplier_shop', - ]); - - $this->imageFileDeleter->deleteFromPath($this->configuration->get('_PS_SUPP_IMG_DIR_')); - } - - /** - * Delete all manufacturers images and data. - */ - private function deleteManufacturers() - { - $this->truncateTables([ - 'manufacturer', - 'manufacturer_lang', - 'manufacturer_shop', - ]); - - $this->imageFileDeleter->deleteFromPath($this->configuration->get('_PS_MANU_IMG_DIR_')); - } - - /** - * Delete all categories images and data, except Root and Home. - */ - private function deleteCategories() - { - $protectedCategoriesIds = [ - $this->configuration->getInt('PS_HOME_CATEGORY'), - $this->configuration->getInt('PS_ROOT_CATEGORY'), - ]; - - $this->connection->executeQuery( - "DELETE FROM {$this->dbPrefix}category WHERE id_category NOT IN (?)", - [$protectedCategoriesIds], - [Connection::PARAM_INT_ARRAY] - ); - - $this->connection->executeQuery( - "DELETE FROM {$this->dbPrefix}category_lang WHERE id_category NOT IN (?)", - [$protectedCategoriesIds], - [Connection::PARAM_INT_ARRAY] - ); - - $this->connection->executeQuery( - "DELETE FROM {$this->dbPrefix}category_shop WHERE id_category NOT IN (?)", - [$protectedCategoriesIds], - [Connection::PARAM_INT_ARRAY] - ); - - $this->connection->executeQuery("ALTER TABLE {$this->dbPrefix}category AUTO_INCREMENT = 3"); - - $this->imageFileDeleter->deleteFromPath($this->configuration->get('_PS_CAT_IMG_DIR_')); - } - - /** - * Delete all products images and data. - */ - private function deleteProducts() - { - $truncateTables = [ - 'product', - 'product_shop', - 'feature_product', - 'product_lang', - 'category_product', - 'product_tag', - 'image', - 'image_lang', - 'image_shop', - 'specific_price', - 'specific_price_priority', - 'product_carrier', - 'cart_product', - 'product_attachment', - 'product_country_tax', - 'product_download', - 'product_group_reduction_cache', - 'product_sale', - 'product_supplier', - 'warehouse_product_location', - 'stock', - 'stock_available', - 'stock_mvt', - 'customization', - 'customization_field', - 'supply_order_detail', - 'attribute_impact', - 'product_attribute', - 'product_attribute_shop', - 'product_attribute_combination', - 'product_attribute_image', - 'pack', - ]; - - $this->truncateTables($truncateTables); - - $truncateIfExists = [ - 'favorite_product', - ]; - - $this->truncateTablesIfExist($truncateIfExists); - - $imgDir = $this->configuration->get('_PS_PROD_IMG_DIR_'); - $this->imageFileDeleter->deleteFromPath($imgDir, true, true); - } - - /** - * Delete all combinations data. - */ - private function deleteCombinations() - { - $truncateTables = [ - 'attribute', - 'attribute_impact', - 'attribute_lang', - 'attribute_group', - 'attribute_group_lang', - 'attribute_group_shop', - 'attribute_shop', - 'product_attribute', - 'product_attribute_shop', - 'product_attribute_combination', - 'product_attribute_image', - ]; - - $this->truncateTables($truncateTables); - $this->connection->executeQuery( - "DELETE FROM `{$this->dbPrefix}stock_available` WHERE id_product_attribute != 0" - ); - } - - /** - * Truncate multiple tables. - * - * @param array $tables - * - * @throws \Doctrine\DBAL\DBALException - */ - private function truncateTables(array $tables) - { - foreach ($tables as $table) { - $this->connection->executeQuery("TRUNCATE TABLE `{$this->dbPrefix}{$table}`"); - } - } - - /** - * Truncate tables if they exist. Truncates them one by one. - * - * @param array $tables - * - * @throws \Doctrine\DBAL\DBALException - */ - private function truncateTablesIfExist(array $tables) - { - foreach ($tables as $table) { - $tableExists = $this->connection->getSchemaManager()->tablesExist( - [ - "{$this->dbPrefix}{$table}", - ] - ); - - if ($tableExists) { - $this->connection->executeQuery("TRUNCATE TABLE `{$this->dbPrefix}{$table}`"); - } - } - } -} diff --git a/src/Adapter/Invoice/InvoiceOptionsConfiguration.php b/src/Adapter/Invoice/InvoiceOptionsConfiguration.php deleted file mode 100644 index b398553f..00000000 --- a/src/Adapter/Invoice/InvoiceOptionsConfiguration.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Invoice; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * Class InvoiceOptionsConfiguration is responsible for saving & loading invoice configuration. - */ -final class InvoiceOptionsConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - /** - * @param Configuration $configuration - */ - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'enable_invoices' => $this->configuration->getBoolean('PS_INVOICE'), - 'enable_tax_breakdown' => $this->configuration->getBoolean('PS_INVOICE_TAXES_BREAKDOWN'), - 'enable_product_images' => $this->configuration->getBoolean('PS_PDF_IMG_INVOICE'), - 'invoice_prefix' => $this->configuration->get('PS_INVOICE_PREFIX'), - 'add_current_year' => $this->configuration->getBoolean('PS_INVOICE_USE_YEAR'), - 'reset_number_annually' => $this->configuration->getBoolean('PS_INVOICE_RESET'), - 'year_position' => $this->configuration->getInt('PS_INVOICE_YEAR_POS'), - 'invoice_number' => $this->configuration->getInt('PS_INVOICE_START_NUMBER'), - 'legal_free_text' => $this->configuration->get('PS_INVOICE_LEGAL_FREE_TEXT'), - 'footer_text' => $this->configuration->get('PS_INVOICE_FREE_TEXT'), - 'invoice_model' => $this->configuration->get('PS_INVOICE_MODEL'), - 'use_disk_cache' => $this->configuration->getBoolean('PS_PDF_USE_CACHE'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_INVOICE', $configuration['enable_invoices']); - $this->configuration->set('PS_INVOICE_TAXES_BREAKDOWN', $configuration['enable_tax_breakdown']); - $this->configuration->set('PS_PDF_IMG_INVOICE', $configuration['enable_product_images']); - $this->configuration->set('PS_INVOICE_PREFIX', $configuration['invoice_prefix']); - $this->configuration->set('PS_INVOICE_USE_YEAR', $configuration['add_current_year']); - $this->configuration->set('PS_INVOICE_RESET', $configuration['reset_number_annually']); - $this->configuration->set('PS_INVOICE_YEAR_POS', $configuration['year_position']); - $this->configuration->set('PS_INVOICE_START_NUMBER', $configuration['invoice_number']); - $this->configuration->set('PS_INVOICE_LEGAL_FREE_TEXT', $configuration['legal_free_text']); - $this->configuration->set('PS_INVOICE_FREE_TEXT', $configuration['footer_text']); - $this->configuration->set('PS_INVOICE_MODEL', $configuration['invoice_model']); - $this->configuration->set('PS_PDF_USE_CACHE', $configuration['use_disk_cache']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['enable_invoices'], - $configuration['enable_tax_breakdown'], - $configuration['enable_product_images'], - $configuration['invoice_prefix'], - $configuration['add_current_year'], - $configuration['reset_number_annually'], - $configuration['year_position'], - $configuration['invoice_number'], - $configuration['legal_free_text'], - $configuration['footer_text'], - $configuration['invoice_model'], - $configuration['use_disk_cache'] - ); - } -} diff --git a/src/Adapter/Invoice/InvoiceTemplateTypeProvider.php b/src/Adapter/Invoice/InvoiceTemplateTypeProvider.php deleted file mode 100644 index f1ae13ed..00000000 --- a/src/Adapter/Invoice/InvoiceTemplateTypeProvider.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Invoice; - -use PrestaShop\PrestaShop\Adapter\Entity\PDF; -use PrestaShop\PrestaShop\Core\PDF\PDFTemplateTypeProviderInterface; - -/** - * Class InvoiceTemplateTypeProvider provides invoice PDF template type. - */ -final class InvoiceTemplateTypeProvider implements PDFTemplateTypeProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getPDFTemplateType() - { - return PDF::TEMPLATE_INVOICE; - } -} diff --git a/src/Adapter/Invoice/OrderInvoiceDataProvider.php b/src/Adapter/Invoice/OrderInvoiceDataProvider.php deleted file mode 100644 index 5083ec5c..00000000 --- a/src/Adapter/Invoice/OrderInvoiceDataProvider.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Invoice; - -use DateTimeInterface; -use PrestaShop\PrestaShop\Adapter\Entity\Order; -use PrestaShop\PrestaShop\Adapter\Entity\OrderInvoice; -use PrestaShop\PrestaShop\Core\Order\OrderInvoiceDataProviderInterface; - -/** - * Class OrderInvoiceDataProvider provides OrderInvoice data using legacy code. - */ -final class OrderInvoiceDataProvider implements OrderInvoiceDataProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getByDateInterval(DateTimeInterface $dateFrom, DateTimeInterface $dateTo) - { - return OrderInvoice::getByDateInterval( - $dateFrom->format('Y-m-d'), - $dateTo->format('Y-m-d') - ); - } - - /** - * {@inheritdoc} - */ - public function getByStatus($orderStateId) - { - return OrderInvoice::getByStatus($orderStateId); - } - - /** - * {@inheritdoc} - */ - public function getNextInvoiceNumber() - { - return Order::getLastInvoiceNumber() + 1; - } -} diff --git a/src/Adapter/Kpi/AbandonedCartKpi.php b/src/Adapter/Kpi/AbandonedCartKpi.php deleted file mode 100644 index a7c66001..00000000 --- a/src/Adapter/Kpi/AbandonedCartKpi.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Kpi; - -use ConfigurationKPI; -use Context; -use HelperKpi; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; - -/** - * @internal - */ -final class AbandonedCartKpi implements KpiInterface -{ - /** - * {@inheritdoc} - */ - public function render() - { - $translator = Context::getContext()->getTranslator(); - - $helper = new HelperKpi(); - $helper->id = 'box-carts'; - $helper->icon = 'remove_shopping_cart'; - $helper->color = 'color1'; - $helper->title = $translator->trans('Abandoned Carts', [], 'Admin.Global'); - $helper->subtitle = $translator->trans('Today', [], 'Admin.Global'); - $helper->href = Context::getContext()->link->getAdminLink('AdminCarts') . '&action=filterOnlyAbandonedCarts'; - - if (ConfigurationKPI::get('ABANDONED_CARTS') !== false) { - $helper->value = ConfigurationKPI::get('ABANDONED_CARTS'); - } - - $helper->source = Context::getContext()->link->getAdminLink('AdminStats') - . '&ajax=1&action=getKpi&kpi=abandoned_cart'; - $helper->refresh = (bool) (ConfigurationKPI::get('ABANDONED_CARTS_EXPIRE') < time()); - - return $helper->generate(); - } -} diff --git a/src/Adapter/Kpi/AverageCustomerAgeKpi.php b/src/Adapter/Kpi/AverageCustomerAgeKpi.php deleted file mode 100644 index 70e6941c..00000000 --- a/src/Adapter/Kpi/AverageCustomerAgeKpi.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Kpi; - -use HelperKpi; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Renders average age of all customers. - */ -final class AverageCustomerAgeKpi implements KpiInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ConfigurationInterface - */ - private $kpiConfiguration; - - /** - * @var string - */ - private $sourceUrl; - - public function __construct( - TranslatorInterface $translator, - ConfigurationInterface $kpiConfiguration, - $sourceUrl - ) { - $this->translator = $translator; - $this->kpiConfiguration = $kpiConfiguration; - $this->sourceUrl = $sourceUrl; - } - - /** - * {@inheritdoc} - */ - public function render() - { - $helper = new HelperKpi(); - $helper->id = 'box-age'; - $helper->icon = 'calendar_today'; - $helper->color = 'color2'; - - $helper->title = $this->translator->trans('Average Age', [], 'Admin.Orderscustomers.Feature'); - $helper->subtitle = $this->translator->trans('All Time', [], 'Admin.Global'); - - if (false !== $this->kpiConfiguration->get('AVG_CUSTOMER_AGE')) { - $helper->value = $this->kpiConfiguration->get('AVG_CUSTOMER_AGE'); - } - - $helper->source = $this->sourceUrl; - $helper->refresh = $this->kpiConfiguration->get('AVG_CUSTOMER_AGE_EXPIRE') < time(); - - return $helper->generate(); - } -} diff --git a/src/Adapter/Kpi/AverageOrderValueKpi.php b/src/Adapter/Kpi/AverageOrderValueKpi.php deleted file mode 100644 index 30b244e5..00000000 --- a/src/Adapter/Kpi/AverageOrderValueKpi.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Kpi; - -use ConfigurationKPI; -use Context; -use HelperKpi; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; - -/** - * @internal - */ -final class AverageOrderValueKpi implements KpiInterface -{ - /** - * {@inheritdoc} - */ - public function render() - { - $translator = Context::getContext()->getTranslator(); - - $helper = new HelperKpi(); - $helper->id = 'box-average-order'; - $helper->icon = 'account_balance_wallet'; - $helper->color = 'color1'; - $helper->title = $translator->trans('Average Order Value', [], 'Admin.Global'); - $helper->subtitle = $translator->trans('30 days', [], 'Admin.Global'); - - if (ConfigurationKPI::get('AVG_ORDER_VALUE') !== false) { - $helper->value = $translator->trans( - '%amount% tax excl.', - ['%amount%' => ConfigurationKPI::get('AVG_ORDER_VALUE')], - 'Admin.Orderscustomers.Feature' - ); - } - - $helper->source = Context::getContext()->link->getAdminLink('AdminStats') - . '&ajax=1&action=getKpi&kpi=average_order_value'; - $helper->refresh = (bool) (ConfigurationKPI::get('AVG_ORDER_VALUE_EXPIRE') < time()); - - return $helper->generate(); - } -} diff --git a/src/Adapter/Kpi/AverageProductsInCategoryKpi.php b/src/Adapter/Kpi/AverageProductsInCategoryKpi.php deleted file mode 100644 index ea21310d..00000000 --- a/src/Adapter/Kpi/AverageProductsInCategoryKpi.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Kpi; - -use HelperKpi; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class AverageProductsInCategoryKpi. - * - * @internal - */ -final class AverageProductsInCategoryKpi implements KpiInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ConfigurationInterface - */ - private $kpiConfiguration; - - /** - * @var string - */ - private $sourceUrl; - - /** - * @param TranslatorInterface $translator - * @param ConfigurationInterface $kpiConfiguration - * @param string $sourceUrl - */ - public function __construct( - TranslatorInterface $translator, - ConfigurationInterface $kpiConfiguration, - $sourceUrl - ) { - $this->translator = $translator; - $this->kpiConfiguration = $kpiConfiguration; - $this->sourceUrl = $sourceUrl; - } - - /** - * {@inheritdoc} - */ - public function render() - { - $helper = new HelperKpi(); - $helper->id = 'box-products-per-category'; - $helper->icon = 'search'; - $helper->color = 'color4'; - $helper->title = - $this->translator->trans('Average number of products per category', [], 'Admin.Catalog.Feature'); - - if (false !== $this->kpiConfiguration->get('PRODUCTS_PER_CATEGORY')) { - $helper->value = $this->kpiConfiguration->get('PRODUCTS_PER_CATEGORY'); - } - - $helper->source = $this->sourceUrl; - $helper->refresh = $this->kpiConfiguration->get('PRODUCTS_PER_CATEGORY_EXPIRE') < time(); - - return $helper->generate(); - } -} diff --git a/src/Adapter/Kpi/ConversionRateKpi.php b/src/Adapter/Kpi/ConversionRateKpi.php deleted file mode 100644 index 0ae68eaa..00000000 --- a/src/Adapter/Kpi/ConversionRateKpi.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Kpi; - -use ConfigurationKPI; -use Context; -use HelperKpi; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; - -/** - * @internal - */ -final class ConversionRateKpi implements KpiInterface -{ - /** - * {@inheritdoc} - */ - public function render() - { - $translator = Context::getContext()->getTranslator(); - - $helper = new HelperKpi(); - $helper->id = 'box-conversion-rate'; - $helper->icon = 'assessment'; - $helper->color = 'color1'; - $helper->title = $translator->trans('Conversion Rate', [], 'Admin.Global'); - $helper->subtitle = $translator->trans('30 days', [], 'Admin.Global'); - - if (ConfigurationKPI::get('CONVERSION_RATE') !== false) { - $helper->value = ConfigurationKPI::get('CONVERSION_RATE'); - } - - if (ConfigurationKPI::get('CONVERSION_RATE_CHART') !== false) { - $helper->data = ConfigurationKPI::get('CONVERSION_RATE_CHART'); - } - - $helper->source = Context::getContext()->link->getAdminLink('AdminStats') - . '&ajax=1&action=getKpi&kpi=conversion_rate'; - $helper->refresh = (bool) (ConfigurationKPI::get('CONVERSION_RATE_EXPIRE') < time()); - - return $helper->generate(); - } -} diff --git a/src/Adapter/Kpi/DisabledCategoriesKpi.php b/src/Adapter/Kpi/DisabledCategoriesKpi.php deleted file mode 100644 index 14a672f5..00000000 --- a/src/Adapter/Kpi/DisabledCategoriesKpi.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Kpi; - -use HelperKpi; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class DisabledCategoriesKpi. - * - * @internal - */ -final class DisabledCategoriesKpi implements KpiInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ConfigurationInterface - */ - private $kpiConfiguration; - - /** - * @var string - */ - private $sourceUrl; - - /** - * @param TranslatorInterface $translator - * @param ConfigurationInterface $kpiConfiguration - * @param string $sourceUrl - */ - public function __construct( - TranslatorInterface $translator, - ConfigurationInterface $kpiConfiguration, - $sourceUrl - ) { - $this->translator = $translator; - $this->kpiConfiguration = $kpiConfiguration; - $this->sourceUrl = $sourceUrl; - } - - /** - * {@inheritdoc} - */ - public function render() - { - $helper = new HelperKpi(); - $helper->id = 'box-disabled-categories'; - $helper->icon = 'toggle_off'; - $helper->color = 'color1'; - $helper->title = $this->translator->trans('Disabled Categories', [], 'Admin.Catalog.Feature'); - - if (false !== $this->kpiConfiguration->get('DISABLED_CATEGORIES')) { - $helper->value = $this->kpiConfiguration->get('DISABLED_CATEGORIES'); - } - - $helper->source = $this->sourceUrl; - $helper->refresh = $this->kpiConfiguration->get('DISABLED_CATEGORIES_EXPIRE') < time(); - - return $helper->generate(); - } -} diff --git a/src/Adapter/Kpi/EmptyCategoriesKpi.php b/src/Adapter/Kpi/EmptyCategoriesKpi.php deleted file mode 100644 index a491253c..00000000 --- a/src/Adapter/Kpi/EmptyCategoriesKpi.php +++ /dev/null @@ -1,100 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Kpi; - -use HelperKpi; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class EmptyCategoriesKpi. - * - * @internal - */ -final class EmptyCategoriesKpi implements KpiInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var string - */ - private $sourceUrl; - - /** - * @var string - */ - private $hrefUrl; - - /** - * @param TranslatorInterface $translator - * @param ConfigurationInterface $configuration - * @param string $sourceUrl - * @param string $hrefUrl - */ - public function __construct( - TranslatorInterface $translator, - ConfigurationInterface $configuration, - $sourceUrl, - $hrefUrl - ) { - $this->translator = $translator; - $this->configuration = $configuration; - $this->sourceUrl = $sourceUrl; - $this->hrefUrl = $hrefUrl; - } - - /** - * {@inheritdoc} - */ - public function render() - { - $helper = new HelperKpi(); - $helper->id = 'box-empty-categories'; - $helper->icon = 'bookmark'; - $helper->color = 'color2'; - $helper->href = $this->hrefUrl; - $helper->title = $this->translator->trans('Empty Categories', [], 'Admin.Catalog.Feature'); - - if (false !== $this->configuration->get('EMPTY_CATEGORIES')) { - $helper->value = $this->configuration->get('EMPTY_CATEGORIES'); - } - - $helper->source = $this->sourceUrl; - $helper->refresh = $this->configuration->get('EMPTY_CATEGORIES_EXPIRE') < time(); - - return $helper->generate(); - } -} diff --git a/src/Adapter/Kpi/EnabledLanguagesKpi.php b/src/Adapter/Kpi/EnabledLanguagesKpi.php deleted file mode 100644 index 9f128c85..00000000 --- a/src/Adapter/Kpi/EnabledLanguagesKpi.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Kpi; - -use HelperKpi; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class EnabledLanguagesKpi is an implementation for enabled languages KPI. - */ -final class EnabledLanguagesKpi implements KpiInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var string - */ - private $clickLink; - - /** - * @var string - */ - private $sourceLink; - - /** - * @param TranslatorInterface $translator - * @param ConfigurationInterface $configuration - * @param string $clickLink a link for clicking on the KPI - * @param string $sourceLink a link to refresh KPI - */ - public function __construct( - TranslatorInterface $translator, - ConfigurationInterface $configuration, - $clickLink, - $sourceLink - ) { - $this->translator = $translator; - $this->configuration = $configuration; - $this->clickLink = $clickLink; - $this->sourceLink = $sourceLink; - } - - /** - * {@inheritdoc} - */ - public function render() - { - $enabledLanguages = $this->configuration->get('ENABLED_LANGUAGES'); - - $kpi = new HelperKpi(); - $kpi->context->smarty->setTemplateDir(_PS_BO_ALL_THEMES_DIR_ . 'new-theme/template/'); - $kpi->id = 'box-languages'; - $kpi->icon = 'mic'; - $kpi->color = 'color1'; - $kpi->href = $this->clickLink; - $kpi->title = $this->translator->trans('Enabled Languages', [], 'Admin.International.Feature'); - - if (false !== $enabledLanguages) { - $kpi->value = $enabledLanguages; - } - - $kpi->source = $this->sourceLink; - $kpi->refresh = $this->configuration->get('ENABLED_LANGUAGES_EXPIRE') < time(); - - return $kpi->generate(); - } -} diff --git a/src/Adapter/Kpi/MainCountryKpi.php b/src/Adapter/Kpi/MainCountryKpi.php deleted file mode 100644 index 603b0503..00000000 --- a/src/Adapter/Kpi/MainCountryKpi.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Kpi; - -use HelperKpi; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class MainCountryKpi is an implementation for main countries KPI. - */ -final class MainCountryKpi implements KpiInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var string - */ - private $sourceLink; - - /** - * @param TranslatorInterface $translator - * @param ConfigurationInterface $configuration - * @param string $sourceLink a link to refresh KPI - */ - public function __construct( - TranslatorInterface $translator, - ConfigurationInterface $configuration, - $sourceLink - ) { - $this->translator = $translator; - $this->configuration = $configuration; - $this->sourceLink = $sourceLink; - } - - /** - * {@inheritdoc} - */ - public function render() - { - $mainCountry = $this->configuration->get('MAIN_COUNTRY'); - - $kpi = new HelperKpi(); - $kpi->context->smarty->setTemplateDir(_PS_BO_ALL_THEMES_DIR_ . 'new-theme/template/'); - $kpi->id = 'box-country'; - $kpi->icon = 'home'; - $kpi->color = 'color2'; - $kpi->title = $this->translator->trans('Main Country', [], 'Admin.International.Feature'); - $kpi->subtitle = $this->translator->trans('30 Days', [], 'Admin.Global'); - - if (false !== $mainCountry) { - $kpi->value = $mainCountry; - } - - $kpi->source = $this->sourceLink; - $kpi->refresh = $this->configuration->get('MAIN_COUNTRY_EXPIRE') < time(); - - return $kpi->generate(); - } -} diff --git a/src/Adapter/Kpi/MostCommonCustomersGenderKpi.php b/src/Adapter/Kpi/MostCommonCustomersGenderKpi.php deleted file mode 100644 index de6e95b5..00000000 --- a/src/Adapter/Kpi/MostCommonCustomersGenderKpi.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Kpi; - -use HelperKpi; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Renders percent of most common customers gender. - */ -final class MostCommonCustomersGenderKpi implements KpiInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ConfigurationInterface - */ - private $kpiConfiguration; - - /** - * @var string - */ - private $sourceUrl; - - /** - * @param TranslatorInterface $translator - * @param ConfigurationInterface $kpiConfiguration - * @param string $sourceUrl - */ - public function __construct( - TranslatorInterface $translator, - ConfigurationInterface $kpiConfiguration, - $sourceUrl - ) { - $this->translator = $translator; - $this->kpiConfiguration = $kpiConfiguration; - $this->sourceUrl = $sourceUrl; - } - - /** - * {@inheritdoc} - */ - public function render() - { - $helper = new HelperKpi(); - $helper->id = 'box-gender'; - $helper->icon = 'person'; - $helper->color = 'color1'; - $helper->title = $this->translator->trans('Customers', [], 'Admin.Global'); - $helper->subtitle = $this->translator->trans('All Time', [], 'Admin.Global'); - - if (false !== $this->kpiConfiguration->get('CUSTOMER_MAIN_GENDER')) { - $helper->value = $this->kpiConfiguration->get('CUSTOMER_MAIN_GENDER'); - } - - $helper->source = $this->sourceUrl; - $helper->refresh = $this->kpiConfiguration->get('CUSTOMER_MAIN_GENDER_EXPIRE') < time(); - - return $helper->generate(); - } -} diff --git a/src/Adapter/Kpi/NetProfitPerVisitKpi.php b/src/Adapter/Kpi/NetProfitPerVisitKpi.php deleted file mode 100644 index 301eef75..00000000 --- a/src/Adapter/Kpi/NetProfitPerVisitKpi.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Kpi; - -use ConfigurationKPI; -use Context; -use HelperKpi; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; - -/** - * @internal - */ -final class NetProfitPerVisitKpi implements KpiInterface -{ - /** - * {@inheritdoc} - */ - public function render() - { - $translator = Context::getContext()->getTranslator(); - - $helper = new HelperKpi(); - $helper->id = 'box-net-profit-visit'; - $helper->icon = 'account_box'; - $helper->color = 'color1'; - $helper->title = $translator->trans('Net Profit per Visit', [], 'Admin.Orderscustomers.Feature'); - $helper->subtitle = $translator->trans('30 days', [], 'Admin.Orderscustomers.Feature'); - - if (ConfigurationKPI::get('NETPROFIT_VISIT') !== false) { - $helper->value = ConfigurationKPI::get('NETPROFIT_VISIT'); - } - - $helper->source = Context::getContext()->link->getAdminLink('AdminStats') - . '&ajax=1&action=getKpi&kpi=netprofit_visit'; - $helper->refresh = (bool) (ConfigurationKPI::get('NETPROFIT_VISIT_EXPIRE') < time()); - - return $helper->generate(); - } -} diff --git a/src/Adapter/Kpi/NewsletterRegistrationsKpi.php b/src/Adapter/Kpi/NewsletterRegistrationsKpi.php deleted file mode 100644 index 576bf8eb..00000000 --- a/src/Adapter/Kpi/NewsletterRegistrationsKpi.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Kpi; - -use HelperKpi; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Renders number of how many customers have registered for newsletter. - */ -final class NewsletterRegistrationsKpi implements KpiInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ConfigurationInterface - */ - private $kpiConfiguration; - - /** - * @var string - */ - private $sourceUrl; - - /** - * @param TranslatorInterface $translator - * @param ConfigurationInterface $kpiConfiguration - * @param string $sourceUrl - */ - public function __construct( - TranslatorInterface $translator, - ConfigurationInterface $kpiConfiguration, - $sourceUrl - ) { - $this->translator = $translator; - $this->kpiConfiguration = $kpiConfiguration; - $this->sourceUrl = $sourceUrl; - } - - /** - * {@inheritdoc} - */ - public function render() - { - $helper = new HelperKpi(); - $helper->id = 'box-newsletter'; - $helper->icon = 'mail_outline'; - $helper->color = 'color3'; - - $helper->title = $this->translator->trans('Newsletter Registrations', [], 'Admin.Orderscustomers.Feature'); - $helper->subtitle = $this->translator->trans('All Time', [], 'Admin.Global'); - - if (false !== $this->kpiConfiguration->get('NEWSLETTER_REGISTRATIONS')) { - $helper->value = $this->kpiConfiguration->get('NEWSLETTER_REGISTRATIONS'); - } - - $helper->source = $this->sourceUrl; - $helper->refresh = $this->kpiConfiguration->get('NEWSLETTER_REGISTRATIONS_EXPIRE') < time(); - - return $helper->generate(); - } -} diff --git a/src/Adapter/Kpi/OrdersPerCustomerKpi.php b/src/Adapter/Kpi/OrdersPerCustomerKpi.php deleted file mode 100644 index 78abd99c..00000000 --- a/src/Adapter/Kpi/OrdersPerCustomerKpi.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Kpi; - -use HelperKpi; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Renders amount of orders per customer. - */ -final class OrdersPerCustomerKpi implements KpiInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ConfigurationInterface - */ - private $kpiConfiguration; - - /** - * @var string - */ - private $sourceUrl; - - public function __construct( - TranslatorInterface $translator, - ConfigurationInterface $kpiConfiguration, - $sourceUrl - ) { - $this->translator = $translator; - $this->kpiConfiguration = $kpiConfiguration; - $this->sourceUrl = $sourceUrl; - } - - /** - * {@inheritdoc} - */ - public function render() - { - $helper = new HelperKpi(); - $helper->id = 'box-orders'; - $helper->icon = 'shopping_basket'; - $helper->color = 'color4'; - - $helper->title = $this->translator->trans('Orders per Customer', [], 'Admin.Orderscustomers.Feature'); - $helper->subtitle = $this->translator->trans('All Time', [], 'Admin.Global'); - - if (false !== $this->kpiConfiguration->get('ORDERS_PER_CUSTOMER')) { - $helper->value = $this->kpiConfiguration->get('ORDERS_PER_CUSTOMER'); - } - - $helper->source = $this->sourceUrl; - $helper->refresh = $this->kpiConfiguration->get('ORDERS_PER_CUSTOMER_EXPIRE') < time(); - - return $helper->generate(); - } -} diff --git a/src/Adapter/Kpi/ShoppingCartTotalKpi.php b/src/Adapter/Kpi/ShoppingCartTotalKpi.php deleted file mode 100644 index 82ca1d60..00000000 --- a/src/Adapter/Kpi/ShoppingCartTotalKpi.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Kpi; - -use Cart; -use Context; -use Currency; -use Group; -use HelperKpi; -use Order; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; -use PrestaShop\PrestaShop\Core\Localization\Locale; -use Validate; - -/** - * {@inheritdoc} - */ -final class ShoppingCartTotalKpi implements KpiInterface -{ - /** - * @var Locale - */ - private $locale; - - /** - * @var array - */ - private $options; - - /** - * @param Locale $locale - */ - public function __construct(Locale $locale) - { - $this->locale = $locale; - } - - /** - * {@inheritdoc} - */ - public function render() - { - $translator = Context::getContext()->getTranslator(); - $cart = new Cart($this->options['cart_id']); - - $helper = new HelperKpi(); - $helper->id = 'box-kpi-cart'; - $helper->icon = 'shopping_cart'; - $helper->color = 'color1'; - $helper->title = $translator->trans('Total Cart', [], 'Admin.Orderscustomers.Feature'); - $helper->subtitle = $translator->trans('Cart #%ID%', ['%ID%' => $cart->id], 'Admin.Orderscustomers.Feature'); - $helper->value = $this->locale->formatPrice( - $this->getCartTotalPrice($cart), - Currency::getIsoCodeById((int) $cart->id_currency) - ); - - return $helper->generate(); - } - - /** - * Sets options for Kpi - * - * @param array $options - */ - public function setOptions(array $options) - { - $this->options = $options; - } - - /** - * @param Cart $cart - * - * @return float - */ - private function getCartTotalPrice(Cart $cart) - { - $summary = $cart->getSummaryDetails(); - - $id_order = (int) Order::getIdByCartId($cart->id); - $order = new Order($id_order); - - if (Validate::isLoadedObject($order)) { - $taxCalculationMethod = $order->getTaxCalculationMethod(); - } else { - $taxCalculationMethod = Group::getPriceDisplayMethod(Group::getCurrent()->id); - } - - $totalPrice = $taxCalculationMethod == PS_TAX_EXC ? - $summary['total_price_without_tax'] : - $summary['total_price']; - - return $totalPrice; - } -} diff --git a/src/Adapter/Kpi/TopCategoryKpi.php b/src/Adapter/Kpi/TopCategoryKpi.php deleted file mode 100644 index 6218b460..00000000 --- a/src/Adapter/Kpi/TopCategoryKpi.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Kpi; - -use HelperKpi; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class TopCategoryKpi. - * - * @internal - */ -final class TopCategoryKpi implements KpiInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ConfigurationInterface - */ - private $kpiConfiguration; - - /** - * @var string - */ - private $sourceUrl; - - /** - * @var int - */ - private $employeeIdLang; - - /** - * @param TranslatorInterface $translator - * @param ConfigurationInterface $kpiConfiguration - * @param string $sourceUrl - * @param int $employeeIdLang - */ - public function __construct( - TranslatorInterface $translator, - ConfigurationInterface $kpiConfiguration, - $sourceUrl, - $employeeIdLang - ) { - $this->translator = $translator; - $this->kpiConfiguration = $kpiConfiguration; - $this->sourceUrl = $sourceUrl; - $this->employeeIdLang = $employeeIdLang; - } - - /** - * {@inheritdoc} - */ - public function render() - { - $helper = new HelperKpi(); - $helper->id = 'box-top-category'; - $helper->icon = 'money'; - $helper->color = 'color3'; - $helper->title = $this->translator->trans('Top Category', [], 'Admin.Catalog.Feature'); - $helper->subtitle = $this->translator->trans('30 days', [], 'Admin.Global'); - - $topCategory = $this->kpiConfiguration->get('TOP_CATEGORY'); - - if (isset($topCategory[$this->employeeIdLang])) { - $helper->value = $topCategory[$this->employeeIdLang]; - } - - $topCategoryExpire = $this->kpiConfiguration->get('TOP_CATEGORY_EXPIRE'); - if (isset($topCategoryExpire[$this->employeeIdLang])) { - $topCategoryExpire = $topCategoryExpire[$this->employeeIdLang]; - } else { - $topCategoryExpire = false; - } - - $helper->source = $this->sourceUrl; - $helper->refresh = $topCategoryExpire < time(); - - return $helper->generate(); - } -} diff --git a/src/Adapter/Kpi/TranslationsKpi.php b/src/Adapter/Kpi/TranslationsKpi.php deleted file mode 100644 index 8eb63bb1..00000000 --- a/src/Adapter/Kpi/TranslationsKpi.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Kpi; - -use HelperKpi; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class TranslationsKpi is an implementation for translations KPI. - */ -final class TranslationsKpi implements KpiInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var string - */ - private $sourceLink; - - /** - * @param TranslatorInterface $translator - * @param ConfigurationInterface $configuration - * @param string $sourceLink a link to refresh KPI - */ - public function __construct( - TranslatorInterface $translator, - ConfigurationInterface $configuration, - $sourceLink - ) { - $this->translator = $translator; - $this->configuration = $configuration; - $this->sourceLink = $sourceLink; - } - - /** - * {@inheritdoc} - */ - public function render() - { - $frontOfficeTranslations = $this->configuration->get('FRONTOFFICE_TRANSLATIONS'); - - $kpi = new HelperKpi(); - $kpi->context->smarty->setTemplateDir(_PS_BO_ALL_THEMES_DIR_ . 'new-theme/template/'); - $kpi->id = 'box-translations'; - $kpi->icon = 'list'; - $kpi->color = 'color3'; - $kpi->title = $this->translator->trans('Front office Translations', [], 'Admin.International.Feature'); - - if (false !== $frontOfficeTranslations) { - $kpi->value = $frontOfficeTranslations; - } - - $kpi->source = $this->sourceLink; - $kpi->refresh = $this->configuration->get('FRONTOFFICE_TRANSLATIONS_EXPIRE') < time(); - - return $kpi->generate(); - } -} diff --git a/src/Adapter/Language/CommandHandler/AbstractLanguageHandler.php b/src/Adapter/Language/CommandHandler/AbstractLanguageHandler.php deleted file mode 100644 index b5c8b7bb..00000000 --- a/src/Adapter/Language/CommandHandler/AbstractLanguageHandler.php +++ /dev/null @@ -1,147 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language\CommandHandler; - -use Context; -use ImageManager; -use ImageType; -use Language; -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\CopyingNoPictureException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageImageUploadingException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\IsoCode; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; - -/** - * Encapsulates common legacy behavior for adding/editing language - */ -abstract class AbstractLanguageHandler extends AbstractObjectModelHandler -{ - /** - * Copies "No picture" image for specific language - * - * @param IsoCode $isoCode - * @param string $noPictureImagePath - */ - protected function copyNoPictureImage(IsoCode $isoCode, $noPictureImagePath) - { - if (!($temporaryImage = tempnam(_PS_TMP_IMG_DIR_, 'PS')) - || !move_uploaded_file($noPictureImagePath, $temporaryImage) - ) { - return; - } - - if (!ImageManager::resize($temporaryImage, _PS_IMG_DIR_ . 'p/' . $isoCode->getValue() . '.jpg')) { - throw new CopyingNoPictureException(sprintf('An error occurred while copying "No Picture" image to product directory'), CopyingNoPictureException::PRODUCT_IMAGE_COPY_ERROR); - } - - if (!ImageManager::resize($temporaryImage, _PS_IMG_DIR_ . 'c/' . $isoCode->getValue() . '.jpg')) { - throw new CopyingNoPictureException(sprintf('An error occurred while copying "No Picture" image to category directory'), CopyingNoPictureException::CATEGORY_IMAGE_COPY_ERROR); - } - - if (!ImageManager::resize($temporaryImage, _PS_IMG_DIR_ . 'm/' . $isoCode->getValue() . '.jpg')) { - throw new CopyingNoPictureException(sprintf('An error occurred while copying "No Picture" image to brand directory'), CopyingNoPictureException::BRAND_IMAGE_COPY_ERROR); - } - - $imagesTypes = ImageType::getImagesTypes('products'); - - foreach ($imagesTypes as $imagesType) { - $imageName = $isoCode->getValue() . '-default-' . stripslashes($imagesType['name']) . '.jpg'; - $imageWidth = $imagesType['width']; - $imageHeight = $imagesType['height']; - - if (!ImageManager::resize($temporaryImage, _PS_IMG_DIR_ . 'p/' . $imageName, $imageWidth, $imageHeight)) { - throw new CopyingNoPictureException(sprintf('An error occurred while copying "No Picture" image to product directory'), CopyingNoPictureException::PRODUCT_IMAGE_COPY_ERROR); - } - - if (!ImageManager::resize($temporaryImage, _PS_IMG_DIR_ . 'c/' . $imageName, $imageWidth, $imageHeight)) { - throw new CopyingNoPictureException(sprintf('An error occurred while copying "No Picture" image to category directory'), CopyingNoPictureException::CATEGORY_IMAGE_COPY_ERROR); - } - - if (!ImageManager::resize($temporaryImage, _PS_IMG_DIR_ . 'm/' . $imageName, $imageWidth, $imageHeight)) { - throw new CopyingNoPictureException(sprintf('An error occurred while copying "No Picture" image to brand directory'), CopyingNoPictureException::BRAND_IMAGE_COPY_ERROR); - } - } - - unlink($temporaryImage); - } - - /** - * @param int $languageId - * @param string $newImagePath - * @param string $imageDir - */ - protected function uploadImage($languageId, $newImagePath, $imageDir) - { - $temporaryImage = tempnam(_PS_TMP_IMG_DIR_, 'PS'); - if (!$temporaryImage) { - return; - } - - if (!move_uploaded_file($newImagePath, $temporaryImage)) { - return; - } - - // Evaluate the memory required to resize the image: if it's too much, you can't resize it. - if (!ImageManager::checkImageMemoryLimit($temporaryImage)) { - throw new LanguageImageUploadingException('Due to memory limit restrictions, this image cannot be loaded. Increase your memory_limit value.', LanguageImageUploadingException::MEMORY_LIMIT_RESTRICTION); - } - - // Copy new image - if (!ImageManager::resize($temporaryImage, _PS_IMG_DIR_ . $imageDir . $languageId . '.jpg')) { - throw new LanguageImageUploadingException('An error occurred while uploading the image. Check your directory permissions.', LanguageImageUploadingException::UNEXPECTED_ERROR); - } - - if (file_exists(_PS_LANG_IMG_DIR_ . $languageId . '.jpg')) { - $shopId = Context::getContext()->shop->id; - $currentFile = _PS_TMP_IMG_DIR_ . 'lang_mini_' . $languageId . '_' . $shopId . '.jpg'; - - if (file_exists($currentFile)) { - unlink($currentFile); - } - } - - unlink($temporaryImage); - } - - /** - * @param LanguageId $languageId - * - * @return Language - */ - protected function getLegacyLanguageObject(LanguageId $languageId) - { - $language = new Language($languageId->getValue()); - - if ($languageId->getValue() !== $language->id) { - throw new LanguageNotFoundException($languageId, sprintf('Language with id "%s" was not found', $languageId->getValue())); - } - - return $language; - } -} diff --git a/src/Adapter/Language/CommandHandler/AddLanguageHandler.php b/src/Adapter/Language/CommandHandler/AddLanguageHandler.php deleted file mode 100644 index c31febdb..00000000 --- a/src/Adapter/Language/CommandHandler/AddLanguageHandler.php +++ /dev/null @@ -1,132 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language\CommandHandler; - -use Language; -use PrestaShop\PrestaShop\Core\Domain\Language\Command\AddLanguageCommand; -use PrestaShop\PrestaShop\Core\Domain\Language\CommandHandler\AddLanguageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageException; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\IsoCode; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; - -/** - * Handles command which adds new language using legacy object model - * - * @internal - */ -final class AddLanguageHandler extends AbstractLanguageHandler implements AddLanguageHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(AddLanguageCommand $command) - { - $this->assertLanguageWithIsoCodeDoesNotExist($command->getIsoCode()); - - $this->copyNoPictureImage( - $command->getIsoCode(), - $command->getNoPictureImagePath() - ); - - $language = $this->createLegacyLanguageObjectFromCommand($command); - - $this->uploadFlagImage($language, $command); - $this->addShopAssociation($language, $command); - - return new LanguageId((int) $language->id); - } - - /** - * @param IsoCode $isoCode - * - * @throws LanguageConstraintException - */ - private function assertLanguageWithIsoCodeDoesNotExist(IsoCode $isoCode) - { - if (Language::getIdByIso($isoCode->getValue())) { - throw new LanguageConstraintException(sprintf('Language with ISO code "%s" already exists', $isoCode->getValue()), LanguageConstraintException::DUPLICATE_ISO_CODE); - } - } - - /** - * Add language and shop association - * - * @param Language $language - * @param AddLanguageCommand $command - */ - private function addShopAssociation(Language $language, AddLanguageCommand $command) - { - $this->associateWithShops( - $language, - $command->getShopAssociation() - ); - } - - /** - * @param AddLanguageCommand $command - * - * @return Language - */ - private function createLegacyLanguageObjectFromCommand(AddLanguageCommand $command) - { - $language = new Language(); - $language->name = $command->getName(); - $language->iso_code = $command->getIsoCode()->getValue(); - if (false !== ($languageDetails = Language::getLangDetails($command->getIsoCode()->getValue()))) { - $language->locale = $languageDetails['locale']; - } - $language->language_code = $command->getTagIETF()->getValue(); - $language->date_format_lite = $command->getShortDateFormat(); - $language->date_format_full = $command->getFullDateFormat(); - $language->is_rtl = $command->isRtl(); - $language->active = $command->isActive(); - - if (false === $language->validateFields(false)) { - throw new LanguageException('Cannot add language with invalid data'); - } - - if (false === $language->add()) { - throw new LanguageException(sprintf('Failed to add new language "%s"', $command->getName())); - } - - return $language; - } - - /** - * @param Language $language - * @param AddLanguageCommand $command - */ - private function uploadFlagImage(Language $language, AddLanguageCommand $command) - { - $this->uploadImage( - $language->id, - $command->getFlagImagePath(), - 'l' . DIRECTORY_SEPARATOR - ); - } -} diff --git a/src/Adapter/Language/CommandHandler/BulkDeleteLanguagesHandler.php b/src/Adapter/Language/CommandHandler/BulkDeleteLanguagesHandler.php deleted file mode 100644 index 61db163e..00000000 --- a/src/Adapter/Language/CommandHandler/BulkDeleteLanguagesHandler.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language\CommandHandler; - -use Configuration; -use Context; -use Language; -use PrestaShop\PrestaShop\Core\Domain\Language\Command\BulkDeleteLanguagesCommand; -use PrestaShop\PrestaShop\Core\Domain\Language\CommandHandler\BulkDeleteLanguagesHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\DefaultLanguageException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageException; -use Shop; - -/** - * Deletes languages using legacy Language object model - * - * @internal - */ -final class BulkDeleteLanguagesHandler extends AbstractLanguageHandler implements BulkDeleteLanguagesHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(BulkDeleteLanguagesCommand $command) - { - // language can only be modified in "ALL SHOPS" context - Shop::setContext(Shop::CONTEXT_ALL); - - foreach ($command->getLanguageIds() as $languageId) { - $language = $this->getLegacyLanguageObject($languageId); - - $this->assertLanguageIsNotDefault($language); - $this->assertLanguageIsNotInUse($language); - - if (false === $language->delete()) { - throw new LanguageException(sprintf('Failed to delele language "%s"', $language->iso_code)); - } - } - } - - /** - * @param Language $language - */ - private function assertLanguageIsNotDefault(Language $language) - { - if ($language->id === (int) Configuration::get('PS_LANG_DEFAULT')) { - throw new DefaultLanguageException(sprintf('Default language "%s" cannot be deleted', $language->iso_code), DefaultLanguageException::CANNOT_DELETE_ERROR); - } - } - - /** - * @param Language $language - */ - private function assertLanguageIsNotInUse(Language $language) - { - if ($language->id === (int) Context::getContext()->language->id) { - throw new DefaultLanguageException(sprintf('Used language "%s" cannot be deleted', $language->iso_code), DefaultLanguageException::CANNOT_DELETE_IN_USE_ERROR); - } - } -} diff --git a/src/Adapter/Language/CommandHandler/BulkToggleLanguagesStatusHandler.php b/src/Adapter/Language/CommandHandler/BulkToggleLanguagesStatusHandler.php deleted file mode 100644 index 5bd86efe..00000000 --- a/src/Adapter/Language/CommandHandler/BulkToggleLanguagesStatusHandler.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language\CommandHandler; - -use Configuration; -use Language; -use PrestaShop\PrestaShop\Core\Domain\Language\Command\BulkToggleLanguagesStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Language\CommandHandler\BulkToggleLanguagesStatusHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\DefaultLanguageException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageException; - -/** - * Toggles multiple languages status using legacy Language object model - * - * @internal - */ -final class BulkToggleLanguagesStatusHandler extends AbstractLanguageHandler implements BulkToggleLanguagesStatusHandlerInterface -{ - /** - * @param BulkToggleLanguagesStatusCommand $command - */ - public function handle(BulkToggleLanguagesStatusCommand $command) - { - foreach ($command->getLanguageIds() as $languageId) { - $language = $this->getLegacyLanguageObject($languageId); - - $this->assertLanguageIsNotDefault($language, $command); - - $language->active = $command->getStatus(); - - if (false === $language->update()) { - throw new LanguageException(sprintf('Failed to toggle language "%s" to status %s', $language->id, var_export($command->getStatus(), true))); - } - } - } - - /** - * @param Language $language - * @param BulkToggleLanguagesStatusCommand $command - */ - private function assertLanguageIsNotDefault(Language $language, BulkToggleLanguagesStatusCommand $command) - { - if (true === $command->getStatus()) { - return; - } - - if ($language->id === (int) Configuration::get('PS_LANG_DEFAULT')) { - throw new DefaultLanguageException(sprintf('Default language "%s" cannot be disabled', $language->iso_code), DefaultLanguageException::CANNOT_DISABLE_ERROR); - } - } -} diff --git a/src/Adapter/Language/CommandHandler/DeleteLanguageHandler.php b/src/Adapter/Language/CommandHandler/DeleteLanguageHandler.php deleted file mode 100644 index d66f6336..00000000 --- a/src/Adapter/Language/CommandHandler/DeleteLanguageHandler.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language\CommandHandler; - -use Configuration; -use Context; -use Language; -use PrestaShop\PrestaShop\Core\Domain\Language\Command\DeleteLanguageCommand; -use PrestaShop\PrestaShop\Core\Domain\Language\CommandHandler\DeleteLanguageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\DefaultLanguageException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageException; -use Shop; - -/** - * Deletes language using legacy object model - * - * @internal - */ -final class DeleteLanguageHandler extends AbstractLanguageHandler implements DeleteLanguageHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(DeleteLanguageCommand $command) - { - $language = $this->getLegacyLanguageObject($command->getLanguageId()); - - $this->assertLanguageIsNotDefault($language); - $this->assertLanguageIsNotInUse($language); - - // language must be deleted in "ALL SHOPS" context - Shop::setContext(Shop::CONTEXT_ALL); - - if (false === $language->delete()) { - throw new LanguageException(sprintf('Failed to delele language "%s"', $language->iso_code)); - } - } - - /** - * @param Language $language - */ - private function assertLanguageIsNotDefault(Language $language) - { - if ($language->id === (int) Configuration::get('PS_LANG_DEFAULT')) { - throw new DefaultLanguageException(sprintf('Default language "%s" cannot be deleted', $language->iso_code), DefaultLanguageException::CANNOT_DELETE_ERROR); - } - } - - /** - * @param Language $language - */ - private function assertLanguageIsNotInUse(Language $language) - { - if ($language->id === (int) Context::getContext()->language->id) { - throw new DefaultLanguageException(sprintf('Used language "%s" cannot be deleted', $language->iso_code), DefaultLanguageException::CANNOT_DELETE_IN_USE_ERROR); - } - } -} diff --git a/src/Adapter/Language/CommandHandler/EditLanguageHandler.php b/src/Adapter/Language/CommandHandler/EditLanguageHandler.php deleted file mode 100644 index 22dd5946..00000000 --- a/src/Adapter/Language/CommandHandler/EditLanguageHandler.php +++ /dev/null @@ -1,239 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language\CommandHandler; - -use Configuration; -use Db; -use Language; -use PrestaShop\PrestaShop\Core\Domain\Language\Command\EditLanguageCommand; -use PrestaShop\PrestaShop\Core\Domain\Language\CommandHandler\EditLanguageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\CannotDisableDefaultLanguageException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageException; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\IsoCode; - -/** - * Handles command which edits language using legacy object model - * - * @internal - */ -final class EditLanguageHandler extends AbstractLanguageHandler implements EditLanguageHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(EditLanguageCommand $command) - { - $language = $this->getLegacyLanguageObject($command->getLanguageId()); - - $this->assertLanguageWithIsoCodeDoesNotExist($language, $command); - $this->assertDefaultLanguageIsNotDisabled($command); - - $this->copyNoPictureIfChanged($language, $command); - $this->updateEmployeeLanguage($command); - $this->moveTranslationsIfIsoChanged($language, $command); - - $this->updateLanguageWithCommandData($language, $command); - $this->updateShopAssociationIfChanged($language, $command); - $this->uploadFlagImageIfChanged($language, $command); - } - - /** - * Update legacy language only with data that is set - * - * @param Language $language - * @param EditLanguageCommand $command - */ - private function updateLanguageWithCommandData(Language $language, EditLanguageCommand $command) - { - if (null !== $command->getName()) { - $language->name = $command->getName(); - } - - if (null !== $command->getIsoCode()) { - $language->iso_code = $command->getIsoCode()->getValue(); - if (false !== ($languageDetails = Language::getLangDetails($command->getIsoCode()->getValue()))) { - $language->locale = $languageDetails['locale']; - } - } - - if (null !== $command->getTagIETF()) { - $language->language_code = $command->getTagIETF()->getValue(); - } - - if (null !== $command->getShortDateFormat()) { - $language->date_format_lite = $command->getShortDateFormat(); - } - - if (null !== $command->getFullDateFormat()) { - $language->date_format_full = $command->getFullDateFormat(); - } - - if (null !== $command->isRtl()) { - $language->is_rtl = $command->isRtl(); - } - - if (null !== $command->isActive()) { - $language->active = $command->isActive(); - } - - if (false === $language->validateFields(false)) { - throw new LanguageException('Cannot add language with invalid data'); - } - - if (false === $language->update()) { - throw new LanguageException(sprintf('Cannot update language with id "%s"', $language->id)); - } - } - - /** - * Only copy new "No picture" if it's being updated - * - * @param Language $language - * @param EditLanguageCommand $command - */ - private function copyNoPictureIfChanged(Language $language, EditLanguageCommand $command) - { - if (null === $command->getNoPictureImagePath()) { - return; - } - - $isoCode = $command->getIsoCode(); - - if (!$isoCode instanceof IsoCode) { - $isoCode = new IsoCode($language->iso_code); - } - - $this->copyNoPictureImage( - $isoCode, - $command->getNoPictureImagePath() - ); - } - - /** - * Default language cannot be disabled - * - * @param EditLanguageCommand $command - */ - private function assertDefaultLanguageIsNotDisabled(EditLanguageCommand $command) - { - if (false === $command->isActive() - && $command->getLanguageId()->getValue() === (int) Configuration::get('PS_LANG_DEFAULT') - ) { - throw new CannotDisableDefaultLanguageException(sprintf('Language with id "%s" is default language and thus it cannot be disabled', $command->getLanguageId()->getValue())); - } - } - - /** - * If language that is being updated is disabled - * and there are employees that use this language - * then their language has to be updated to default - * - * @param EditLanguageCommand $command - */ - private function updateEmployeeLanguage(EditLanguageCommand $command) - { - if (false === $command->isActive()) { - Db::getInstance()->execute( - 'UPDATE `' . _DB_PREFIX_ . 'employee` - SET `id_lang`=' . (int) Configuration::get('PS_LANG_DEFAULT') . ' - WHERE `id_lang`=' . (int) $command->getLanguageId()->getValue() - ); - } - } - - /** - * Move translation files if language's ISO code has changed - * - * @param Language $language - * @param EditLanguageCommand $command - */ - private function moveTranslationsIfIsoChanged(Language $language, EditLanguageCommand $command) - { - if (null !== $command->getIsoCode() - && $language->iso_code !== $command->getIsoCode()->getValue() - ) { - $language->moveToIso($command->getLanguageId()->getValue()); - } - } - - /** - * @param Language $language - * @param EditLanguageCommand $command - */ - private function updateShopAssociationIfChanged(Language $language, EditLanguageCommand $command) - { - if (null === $command->getShopAssociation()) { - return; - } - - $this->associateWithShops( - $language, - $command->getShopAssociation() - ); - } - - /** - * Update language's flag image if it has changed - * - * @param Language $language - * @param EditLanguageCommand $command - */ - private function uploadFlagImageIfChanged(Language $language, EditLanguageCommand $command) - { - if (null === $command->getFlagImagePath()) { - return; - } - - $language->deleteImage(); - - $this->uploadImage( - $command->getLanguageId()->getValue(), - $command->getFlagImagePath(), - 'l' . DIRECTORY_SEPARATOR - ); - } - - /** - * Assert that language with updated ISO code does not exist - * - * @param Language $language - * @param EditLanguageCommand $command - */ - private function assertLanguageWithIsoCodeDoesNotExist(Language $language, EditLanguageCommand $command) - { - if (null !== $command->getIsoCode()) { - return; - } - - if ($language->iso_code === $command->getIsoCode()->getValue() - && Language::getIdByIso($command->getIsoCode()->getValue()) - ) { - throw new LanguageConstraintException(sprintf('Language with ISO code "%s" already exists', $command->getIsoCode()->getValue()), LanguageConstraintException::INVALID_ISO_CODE); - } - } -} diff --git a/src/Adapter/Language/CommandHandler/ToggleLanguageStatusHandler.php b/src/Adapter/Language/CommandHandler/ToggleLanguageStatusHandler.php deleted file mode 100644 index 0aaa4252..00000000 --- a/src/Adapter/Language/CommandHandler/ToggleLanguageStatusHandler.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language\CommandHandler; - -use Configuration; -use Language; -use PrestaShop\PrestaShop\Core\Domain\Language\Command\ToggleLanguageStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Language\CommandHandler\ToggleLanguageStatusHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\DefaultLanguageException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageException; - -/** - * Enables/disables language using legacy Language object model - * - * @internal - */ -final class ToggleLanguageStatusHandler extends AbstractLanguageHandler implements ToggleLanguageStatusHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(ToggleLanguageStatusCommand $command) - { - $language = $this->getLegacyLanguageObject($command->getLanguageId()); - - $this->assertLanguageIsNotDefault($language, $command); - - $language->active = $command->getStatus(); - - if (false === $language->update()) { - throw new LanguageException(sprintf('Failed to toggle language "%s" to status %s', $language->id, var_export($command->getStatus(), true))); - } - } - - /** - * @param Language $language - * @param ToggleLanguageStatusCommand $command - */ - private function assertLanguageIsNotDefault(Language $language, ToggleLanguageStatusCommand $command) - { - if (true === $command->getStatus()) { - return; - } - - if ($language->id === (int) Configuration::get('PS_LANG_DEFAULT')) { - throw new DefaultLanguageException(sprintf('Default language "%s" cannot be disabled', $language->iso_code), DefaultLanguageException::CANNOT_DISABLE_ERROR); - } - } -} diff --git a/src/Adapter/Language/LanguageActivator.php b/src/Adapter/Language/LanguageActivator.php deleted file mode 100644 index 0947318d..00000000 --- a/src/Adapter/Language/LanguageActivator.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language; - -use Language; -use PrestaShop\PrestaShop\Core\Language\LanguageActivatorInterface; - -/** - * Class LanguageActivator is responsible for activating/deactivating language. - */ -final class LanguageActivator implements LanguageActivatorInterface -{ - /** - * {@inheritdoc} - */ - public function enable($langId) - { - $this->setActive($langId, true); - } - - /** - * {@inheritdoc} - */ - public function disable($langId) - { - $this->setActive($langId, false); - } - - /** - * Enable/disable language. - * - * @param int $langId - * @param bool $status - */ - private function setActive($langId, $status) - { - $lang = new Language((int) $langId); - - if ((int) $lang->active !== (int) $status) { - $lang->active = (int) $status; - $lang->save(); - } - } -} diff --git a/src/Adapter/Language/LanguageCopier.php b/src/Adapter/Language/LanguageCopier.php deleted file mode 100644 index a86af838..00000000 --- a/src/Adapter/Language/LanguageCopier.php +++ /dev/null @@ -1,265 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language; - -use PrestaShop\PrestaShop\Core\Addon\Theme\Theme; -use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeCollection; -use PrestaShop\PrestaShop\Core\Language\Copier\LanguageCopierConfigInterface; -use PrestaShop\PrestaShop\Core\Language\Copier\LanguageCopierInterface; -use Symfony\Component\Filesystem\Exception\IOExceptionInterface; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class LanguageCopier responsible for copying a language into another language. - */ -final class LanguageCopier implements LanguageCopierInterface -{ - /** - * @var LanguageDataProvider - */ - private $languageDataProvider; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var Filesystem - */ - private $filesystem; - - /** - * @var ThemeCollection - */ - private $themeCollection; - - /** - * @param LanguageDataProvider $languageDataProvider - * @param TranslatorInterface $translator - * @param Filesystem $filesystem - * @param ThemeCollection $themeCollection - */ - public function __construct( - LanguageDataProvider $languageDataProvider, - TranslatorInterface $translator, - Filesystem $filesystem, - ThemeCollection $themeCollection - ) { - $this->languageDataProvider = $languageDataProvider; - $this->translator = $translator; - $this->filesystem = $filesystem; - $this->themeCollection = $themeCollection; - } - - /** - * {@inheritdoc} - */ - public function copy(LanguageCopierConfigInterface $config) - { - $errors = $this->validateConfig($config); - - if (!empty($errors)) { - return $errors; - } - - $languageFiles = $this->languageDataProvider->getFilesList( - $config->getLanguageFrom(), - $config->getThemeFrom(), - $config->getLanguageTo(), - $config->getThemeTo() - ); - - foreach ($languageFiles as $source => $destination) { - try { - $this->filesystem->mkdir(dirname($destination)); - } catch (IOExceptionInterface $exception) { - $errors[] = [ - 'key' => 'Cannot create the folder "%folder%". Please check your directory writing permissions.', - 'domain' => 'Admin.International.Notification', - 'parameters' => [ - '%folder%' => $destination, - ], - ]; - - continue; - } - - try { - $this->filesystem->copy($source, $destination); - } catch (IOExceptionInterface $exception) { - $errors[] = [ - 'key' => 'Impossible to copy "%source%" to "%dest%".', - 'domain' => 'Admin.International.Notification', - 'parameters' => [ - '%source%' => $source, - '%dest%' => $destination, - ], - ]; - - continue; - } - - if ($this->isModuleContext($source, $destination, $config->getLanguageFrom())) { - $changedModuleTranslationKeys = $this->changeModulesTranslationKeys( - $destination, - $config->getThemeFrom(), - $config->getThemeTo() - ); - - if (!$changedModuleTranslationKeys) { - $errors[] = [ - 'key' => 'Impossible to translate "%dest%".', - 'domain' => 'Admin.International.Notification', - 'parameters' => [ - '%dest%' => $destination, - ], - ]; - } - } - } - - if (!empty($errors)) { - $errors[] = [ - 'key' => 'A part of the data has been copied but some of the language files could not be found.', - 'domain' => 'Admin.International.Notification', - 'parameters' => [], - ]; - } - - return $errors; - } - - /** - * Validates given configuration. - * - * @param LanguageCopierConfigInterface $config - * - * @return array of errors - */ - private function validateConfig(LanguageCopierConfigInterface $config) - { - $errors = []; - - $languageFrom = $config->getLanguageFrom(); - $languageTo = $config->getLanguageTo(); - $themeFrom = $config->getThemeFrom(); - $themeTo = $config->getThemeTo(); - - if (empty($languageFrom) || empty($languageTo)) { - $errors[] = [ - 'key' => 'You must select two languages in order to copy data from one to another.', - 'domain' => 'Admin.International.Notification', - 'parameters' => [], - ]; - } elseif (empty($themeFrom) || empty($themeTo)) { - $errors[] = [ - 'key' => 'You must select two themes in order to copy data from one to another.', - 'domain' => 'Admin.International.Notification', - 'parameters' => [], - ]; - } elseif ( - $themeFrom === $themeTo && - $languageFrom === $languageTo - ) { - $errors[] = [ - 'key' => 'There is nothing to copy (same language and theme).', - 'domain' => 'Admin.International.Notification', - 'parameters' => [], - ]; - } else { - $fromThemeFound = false; - $toThemeFound = false; - - /** @var Theme $theme */ - foreach ($this->themeCollection as $theme) { - // Checking if "From" theme exists by name - if ($theme->getName() === $themeFrom) { - $fromThemeFound = true; - } - - // Checking if "To" theme exists by name - if ($theme->getName() === $themeTo) { - $toThemeFound = true; - } - } - - if (!$fromThemeFound || !$toThemeFound) { - $errors[] = [ - 'key' => 'Theme(s) not found', - 'domain' => 'Admin.International.Notification', - 'parameters' => [], - ]; - } - } - - return $errors; - } - - /** - * Checks if the source and destination paths are related to modules. - * - * @param string $source - * @param string $destination - * @param string $language - * - * @return bool - */ - private function isModuleContext($source, $destination, $language) - { - // Legacy condition - return false !== strpos($destination, 'modules') && basename($source) === $language . '.php'; - } - - /** - * A legacy method to change modules translation keys. - * - * @param string $path - * @param string $themeFrom - * @param string $themeTo - * - * @return bool result - */ - private function changeModulesTranslationKeys($path, $themeFrom, $themeTo) - { - $content = file_get_contents($path); - $arrayReplace = []; - $result = true; - - if (preg_match_all('#\$_MODULE\[\'([^\']+)\'\]#Ui', $content, $matches)) { - foreach ($matches[1] as $value) { - $arrayReplace[$value] = str_replace($themeFrom, $themeTo, $value); - } - - $content = str_replace(array_keys($arrayReplace), array_values($arrayReplace), $content); - $result = file_put_contents($path, $content) === false ? false : true; - } - - return $result; - } -} diff --git a/src/Adapter/Language/LanguageDataProvider.php b/src/Adapter/Language/LanguageDataProvider.php deleted file mode 100644 index e5a866a5..00000000 --- a/src/Adapter/Language/LanguageDataProvider.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language; - -use Exception; -use Language; - -/** - * Class LanguageDataProvider is responsible for providing language data from legacy part. - */ -class LanguageDataProvider -{ - /** - * Returns languages data. - * - * @param bool $active - * @param bool $shopId - * @param bool $onlyIds - * - * @return array - */ - public function getLanguages($active = true, $shopId = false, $onlyIds = false) - { - return Language::getLanguages($active, $shopId, $onlyIds); - } - - /** - * Returns language code by iso code. - * - * @param string $isoCode - ISO 3166-2 alpha-2 format code - * - * @return false|string|null - */ - public function getLanguageCodeByIso($isoCode) - { - return Language::getLanguageCodeByIso($isoCode); - } - - /** - * Gets language details from json file. - * - * @param string $locale - * - * @return array - * - * @throws Exception - */ - public function getLanguageDetails($locale) - { - $result = Language::getJsonLanguageDetails($locale); - - if (false === $result) { - return []; - } - - return $result; - } - - /** - * Gets the files list for given language, including files from modules. - * - * @param string $isoFrom - * @param string $themeFrom - * @param string $isoTo - * @param string $themeTo - * - * @return array - */ - public function getFilesList( - $isoFrom, - $themeFrom, - $isoTo, - $themeTo - ) { - return Language::getFilesList($isoFrom, $themeFrom, $isoTo, $themeTo, false, false, true); - } -} diff --git a/src/Adapter/Language/LanguageFlagThumbnailProvider.php b/src/Adapter/Language/LanguageFlagThumbnailProvider.php deleted file mode 100644 index 07730584..00000000 --- a/src/Adapter/Language/LanguageFlagThumbnailProvider.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language; - -use HelperList; -use ImageManager; -use PrestaShop\PrestaShop\Core\Image\ImageProviderInterface; -use PrestaShop\PrestaShop\Core\Image\Parser\ImageTagSourceParserInterface; - -/** - * Class LanguageThumbnailProvider provides path to language's flag thumbnail. - */ -final class LanguageFlagThumbnailProvider implements ImageProviderInterface -{ - /** - * @var ImageTagSourceParserInterface - */ - private $imageTagSourceParser; - - /** - * @var int - */ - private $contextShopId; - - /** - * @param ImageTagSourceParserInterface $imageTagSourceParser - * @param $contextShopId - */ - public function __construct( - ImageTagSourceParserInterface $imageTagSourceParser, - $contextShopId - ) { - $this->imageTagSourceParser = $imageTagSourceParser; - $this->contextShopId = $contextShopId; - } - - /** - * {@inheritdoc} - */ - public function getPath($languageId) - { - $pathToImage = _PS_IMG_DIR_ . 'l' . DIRECTORY_SEPARATOR . $languageId . '.jpg'; - - $imageTag = ImageManager::thumbnail( - $pathToImage, - 'lang_mini_' . $languageId . '_' . $this->contextShopId . '.jpg', - HelperList::LIST_THUMBNAIL_SIZE, - 'jpg' - ); - - return $this->imageTagSourceParser->parse($imageTag); - } -} diff --git a/src/Adapter/Language/LanguageImageManager.php b/src/Adapter/Language/LanguageImageManager.php deleted file mode 100644 index a8cfb696..00000000 --- a/src/Adapter/Language/LanguageImageManager.php +++ /dev/null @@ -1,203 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language; - -use ImageType; - -/** - * Handles language images (flag, "no image" placeholders) - */ -class LanguageImageManager -{ - /** - * Path where images are saved to - */ - const IMG_PATH = _PS_IMG_DIR_ . '/l/'; - - /** - * Path where flags are stored - */ - const FLAGS_SOURCE = _PS_IMG_DIR_ . 'flags/%s.jpg'; - - /** - * Path where flags are copied to - */ - const FLAGS_DESTINATION = self::IMG_PATH . '%d.jpg'; - - /** - * Default flag - */ - const FALLBACK_FLAG_SOURCE = self::IMG_PATH . 'none.jpg'; - - const IMAGE_DIRECTORIES = [ - _PS_CAT_IMG_DIR_, - _PS_MANU_IMG_DIR_, - _PS_PROD_IMG_DIR_, - _PS_SUPP_IMG_DIR_, - ]; - - const PLACEHOLDER_IMAGE_NAME_PATTERNS = [ - '%s.jpg', - '%s-default-%s.jpg', - ]; - - const DEFAULT_LANGUAGE_CODE = 'en'; - - /** - * Sets up the language flag image for the given language - * - * @param string $localeCode IETF language tag - * @param int $langId Language id - * @param string|null $flagCode If provided, use this flag code. By default, auto-detect using locale code. - */ - public function setupLanguageFlag(string $localeCode, int $langId, ?string $flagCode = null): void - { - $flagCode = $flagCode ?? $this->getFlagCountryCodeFromLocale($localeCode); - - $flagPath = $this->getFlagPath($flagCode); - - if (!file_exists($flagPath)) { - $flagPath = static::FALLBACK_FLAG_SOURCE; - } - - $destinationPath = $this->getFlagDestination($langId); - - $this->unlinkIfExists($destinationPath); - - copy($flagPath, $destinationPath); - } - - /** - * Creates default copies for the "no image" image - * - * @param string $isoCode 2-letter ISO code - */ - public function setupDefaultImagePlaceholder(string $isoCode): void - { - $filesToCopy = [ - $this->getPlaceholderImageFilename(static::DEFAULT_LANGUAGE_CODE) => $this->getPlaceholderImageFilename($isoCode), - ]; - - $imageTypes = ImageType::getAll(); - if (!empty($imageTypes)) { - foreach (array_keys($imageTypes) as $alias) { - $formattedImageType = ImageType::getFormattedName($alias); - $from = $this->getPlaceholderImageFilename(static::DEFAULT_LANGUAGE_CODE, $formattedImageType); - $to = $this->getPlaceholderImageFilename($isoCode, $formattedImageType); - $filesToCopy[$from] = $to; - } - } - - foreach (static::IMAGE_DIRECTORIES as $destinationDir) { - foreach ($filesToCopy as $sourceFile => $newFile) { - @copy(static::IMG_PATH . $sourceFile, $destinationDir . $newFile); - } - } - } - - /** - * Deletes images associated with the language - * - * @param int $langId - * @param string $isoCode 2-letter ISO code - */ - public function deleteImages(int $langId, string $isoCode): void - { - $images = [ - $this->getPlaceholderImageFilename($isoCode), - $this->getPlaceholderImageFilename($isoCode, ImageType::getFormattedName('thickbox')), - $this->getPlaceholderImageFilename($isoCode, ImageType::getFormattedName('home')), - $this->getPlaceholderImageFilename($isoCode, ImageType::getFormattedName('large')), - $this->getPlaceholderImageFilename($isoCode, ImageType::getFormattedName('medium')), - $this->getPlaceholderImageFilename($isoCode, ImageType::getFormattedName('small')), - ]; - foreach (static::IMAGE_DIRECTORIES as $directory) { - foreach ($images as $image) { - $this->unlinkIfExists($directory . $image); - $this->unlinkIfExists(static::IMG_PATH . $langId . '.jpg'); - } - } - } - - /** - * @param string $locale IETF language tag - * - * @return string - */ - private function getFlagCountryCodeFromLocale(string $locale): string - { - return strtolower(explode('-', $locale)[1]); - } - - /** - * @param string $countryCode - * - * @return string - */ - private function getFlagPath(string $countryCode): string - { - return sprintf(static::FLAGS_SOURCE, $countryCode); - } - - /** - * @param int $langId - * - * @return string - */ - private function getFlagDestination(int $langId): string - { - return sprintf(static::FLAGS_DESTINATION, $langId); - } - - /** - * Removes a file if it exists - * - * @param string $file - */ - private function unlinkIfExists(string $file): void - { - if (file_exists($file)) { - unlink($file); - } - } - - /** - * @param string $isoCode - * @param string|null $imageTypeName - * - * @return string - */ - private function getPlaceholderImageFilename(string $isoCode, string $imageTypeName = null): string - { - if (null !== $imageTypeName) { - return sprintf(static::PLACEHOLDER_IMAGE_NAME_PATTERNS[1], $isoCode, $imageTypeName); - } - - return sprintf(static::PLACEHOLDER_IMAGE_NAME_PATTERNS[0], $isoCode); - } -} diff --git a/src/Adapter/Language/LanguagePackInstaller.php b/src/Adapter/Language/LanguagePackInstaller.php deleted file mode 100644 index 16d65f76..00000000 --- a/src/Adapter/Language/LanguagePackInstaller.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language; - -use Language; -use PrestaShop\PrestaShop\Core\Foundation\Version; -use PrestaShop\PrestaShop\Core\Language\Pack\LanguagePackInstallerInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class LanguagePack is responsible for the language pack actions regarding installation. - */ -final class LanguagePackInstaller implements LanguagePackInstallerInterface -{ - /** - * @var Version - */ - private $version; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * LanguagePackInstaller constructor. - * - * @param TranslatorInterface $translator - * @param Version $version - */ - public function __construct(TranslatorInterface $translator, Version $version) - { - $this->version = $version; - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function downloadAndInstallLanguagePack($iso) - { - $freshInstall = empty(Language::getIdByIso($iso)); - $result = Language::downloadAndInstallLanguagePack($iso, $this->version->getVersion(), null, $freshInstall); - - if (false === $result) { - return [ - $this->translator->trans( - 'Fatal error: ISO code is not correct', - [], - 'Admin.International.Notification' - ), - ]; - } - - if (is_array($result) && !empty($result)) { - return $result; - } - - return []; - } -} diff --git a/src/Adapter/Language/LanguageValidator.php b/src/Adapter/Language/LanguageValidator.php deleted file mode 100644 index e038404d..00000000 --- a/src/Adapter/Language/LanguageValidator.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language; - -use Language; -use PrestaShop\PrestaShop\Core\Language\LanguageValidatorInterface; - -/** - * Class LanguageValidator is responsible for supporting validations from legacy Language class part. - */ -final class LanguageValidator implements LanguageValidatorInterface -{ - /** - * {@inheritdoc} - */ - public function isInstalledByLocale($locale) - { - return Language::isInstalledByLocale($locale); - } -} diff --git a/src/Adapter/Language/Pack/LanguagePackImporter.php b/src/Adapter/Language/Pack/LanguagePackImporter.php deleted file mode 100644 index dcac8387..00000000 --- a/src/Adapter/Language/Pack/LanguagePackImporter.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language\Pack; - -use PrestaShop\PrestaShop\Adapter\Language\LanguageDataProvider; -use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface; -use PrestaShop\PrestaShop\Core\Language\Pack\Import\LanguagePackImporterInterface; -use PrestaShop\PrestaShop\Core\Language\Pack\LanguagePackInstallerInterface; - -/** - * Class LanguagePackImporter is responsible for importing language pack. - */ -final class LanguagePackImporter implements LanguagePackImporterInterface -{ - /** - * @var LanguagePackInstallerInterface - */ - private $languagePack; - - /** - * @var LanguageDataProvider - */ - private $languageProvider; - - /** - * @var CacheClearerInterface - */ - private $entireCacheClearer; - - /** - * @var string - */ - private $translationsDir; - - /** - * @param LanguagePackInstallerInterface $languagePack - * @param LanguageDataProvider $languageProvider - * @param CacheClearerInterface $entireCacheClearer - * @param string $translationsDir - */ - public function __construct( - LanguagePackInstallerInterface $languagePack, - LanguageDataProvider $languageProvider, - CacheClearerInterface $entireCacheClearer, - $translationsDir - ) { - $this->languagePack = $languagePack; - $this->languageProvider = $languageProvider; - $this->entireCacheClearer = $entireCacheClearer; - $this->translationsDir = $translationsDir; - } - - /** - * {@inheritdoc} - */ - public function import($isoCode) - { - $result = $this->languagePack->downloadAndInstallLanguagePack($isoCode); - - if (!empty($result)) { - return $result; - } - - $this->entireCacheClearer->clear(); - - return []; - } - - /** - * Gets language code in format of ISO 639-1. - * - * @param string $languageCode - language code to format - * - * @return string - */ - private function getFormattedLanguageCode($languageCode) - { - $explodedLangCode = explode('-', $languageCode); - - return sprintf( - '%s-%s', - isset($explodedLangCode[0]) ? $explodedLangCode[0] : '', - isset($explodedLangCode[1]) ? strtoupper($explodedLangCode[1]) : '' - ); - } -} diff --git a/src/Adapter/Language/QueryHandler/GetLanguageForEditingHandler.php b/src/Adapter/Language/QueryHandler/GetLanguageForEditingHandler.php deleted file mode 100644 index 4ced0853..00000000 --- a/src/Adapter/Language/QueryHandler/GetLanguageForEditingHandler.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language\QueryHandler; - -use Language; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Language\Query\GetLanguageForEditing; -use PrestaShop\PrestaShop\Core\Domain\Language\QueryHandler\GetLanguageForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Language\QueryResult\EditableLanguage; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\IsoCode; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\TagIETF; - -/** - * Gets language for editing - * - * @internal - */ -final class GetLanguageForEditingHandler implements GetLanguageForEditingHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GetLanguageForEditing $query) - { - $language = $this->getLegacyLanguageObject($query->getLanguageId()); - - return new EditableLanguage( - $query->getLanguageId(), - $language->name, - new IsoCode($language->iso_code), - new TagIETF($language->language_code), - $language->date_format_lite, - $language->date_format_full, - (bool) $language->is_rtl, - (bool) $language->active, - array_map(function ($shopId) { return (int) $shopId; }, $language->getAssociatedShops()) - ); - } - - /** - * @param LanguageId $languageId - * - * @return Language - */ - private function getLegacyLanguageObject(LanguageId $languageId) - { - $language = new Language($languageId->getValue()); - - if ($languageId->getValue() !== (int) $language->id) { - throw new LanguageNotFoundException($languageId, sprintf('Language with id "%s" was not found', $languageId->getValue())); - } - - return $language; - } -} diff --git a/src/Adapter/Language/RTL/InstalledLanguageChecker.php b/src/Adapter/Language/RTL/InstalledLanguageChecker.php deleted file mode 100644 index 64b166e2..00000000 --- a/src/Adapter/Language/RTL/InstalledLanguageChecker.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Language\RTL; - -use PrestaShop\PrestaShop\Adapter\Language\LanguageDataProvider; -use PrestaShop\PrestaShop\Core\Language\RTL\InstalledLanguageCheckerInterface; - -/** - * Class InstalledLanguageChecker - */ -final class InstalledLanguageChecker implements InstalledLanguageCheckerInterface -{ - /** - * @var LanguageDataProvider - */ - private $languageDataProvider; - - /** - * @param LanguageDataProvider $languageDataProvider - */ - public function __construct(LanguageDataProvider $languageDataProvider) - { - $this->languageDataProvider = $languageDataProvider; - } - - /** - * {@inheritdoc} - */ - public function isInstalledRtlLanguage() - { - $languages = $this->languageDataProvider->getLanguages(false); - - return in_array('1', array_column($languages, 'is_rtl')); - } -} diff --git a/src/Adapter/LegacyContext.php b/src/Adapter/LegacyContext.php deleted file mode 100644 index 82179dc5..00000000 --- a/src/Adapter/LegacyContext.php +++ /dev/null @@ -1,346 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use AdminController; -use AdminLegacyLayoutControllerCore; -use Context; -use Currency; -use Employee; -use Language; -use RuntimeException; -use Smarty; -use Symfony\Component\Process\Exception\LogicException; -use Tab; - -/** - * This adapter will complete the new architecture Context with legacy values. - * A merge is done, but the legacy values will be transferred to the new Context - * during legacy refactoring. - */ -class LegacyContext -{ - /** @var Currency */ - private $employeeCurrency; - - /** @var string Contains the base uri for mail themes (by default https://domain.com/mails/themes/). Used for mails assets. */ - private $mailThemesUri; - - /** @var Tools */ - private $tools; - - /** - * @param string|null $mailThemesUri - * @param Tools|null $tools - */ - public function __construct( - $mailThemesUri = null, - Tools $tools = null - ) { - $this->mailThemesUri = $mailThemesUri; - $this->tools = null !== $tools ? $tools : new Tools(); - } - - /** - * To be used only in Adapters. Should not been called by Core classes. Prefer to use Core\context class, - * that will contains all you need in the Core architecture. - * - * @throws LogicException If legacy context is not set properly - * - * @return Context the Legacy context, for Adapter use only - */ - public function getContext() - { - static $legacyContext = null; - - if (null === $legacyContext) { - $legacyContext = Context::getContext(); - - if ($legacyContext && !empty($legacyContext->shop) && !isset($legacyContext->controller) && isset($legacyContext->employee)) { - //init real legacy shop context - $adminController = new AdminController(); - $adminController->initShopContext(); - } - } - - return $legacyContext; - } - - /** - * Get smarty instance from legacy context. - * - * @return Smarty - */ - public function getSmarty() - { - return $this->getContext()->smarty; - } - - /** - * Gets the Admin base url (actually random directory name). - * - * @return string - */ - public function getAdminBaseUrl() - { - return __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_) . '/'; - } - - /** - * Adapter to get Admin HTTP link. - * - * @param string $controller the controller name - * @param bool $withToken - * @param array[string] $extraParams - * - * @return string - */ - public function getAdminLink($controller, $withToken = true, $extraParams = []) - { - return $this->getContext()->link->getAdminLink($controller, $withToken, $extraParams, $extraParams); - } - - /** - * Returns the controller link in its legacy form, without trying to convert it in symfony url. - * - * @param string $controller - * @param bool $withToken - * @param array $extraParams - * - * @return string - */ - public function getLegacyAdminLink($controller, $withToken = true, $extraParams = []) - { - return $this->getContext()->link->getLegacyAdminLink($controller, $withToken, $extraParams); - } - - /** - * Adapter to get Front controller HTTP link. - * - * @param string $controller the controller name - * - * @return string - */ - public function getFrontUrl($controller) - { - $legacyContext = $this->getContext(); - - return $legacyContext->link->getPageLink($controller); - } - - /** - * Adapter to get Root Url. - * - * @return string The lagacy root URL - */ - public function getRootUrl() - { - return __PS_BASE_URI__; - } - - /** - * Adapter to get upload directory - * - * @return string - */ - public function getUploadDirectory() - { - return _PS_UPLOAD_DIR_; - } - - /** - * Url to the mail themes folder - * - * @return string - */ - public function getMailThemesUrl() - { - return $this->tools->getShopDomainSsl(true) . __PS_BASE_URI__ . $this->mailThemesUri; - } - - /** - * This fix is used to have a ready translation in the smarty 'l' function. - * Called by AutoResponseFormatTrait in beforeActionSuggestResponseFormat(). - * So if you do not use this Trait, you must call this method by yourself in the action. - * - * @param string $legacyController - */ - public function setupLegacyTranslationContext($legacyController = 'AdminTab') - { - Context::getContext()->override_controller_name_for_translations = $legacyController; - } - - /** - * Adapter to get admin legacy layout into legacy controller context. - * - * @param string $controllerName The legacy controller name - * @param string $title The page title to override default one - * @param array $headerToolbarBtn The header toolbar to override - * @param string $displayType The legacy display type variable - * @param bool $showContentHeader can force header toolbar (buttons and title) to be hidden with false value - * @param string $headerTabContent - * @param bool $enableSidebar Allow to use right sidebar to display docs for instance - * @param string $helpLink If specified, will be used instead of legacy one - * @param string[] $jsRouterMetadata array to provide base_url and security token for JS Router - * @param string $metaTitle - * @param bool $useRegularH1Structure allows complex

    structure if set to false - * - * @return string The html layout - */ - public function getLegacyLayout( - $controllerName, - $title, - $headerToolbarBtn, - $displayType, - $showContentHeader, - $headerTabContent, - $enableSidebar, - $helpLink = '', - $jsRouterMetadata = [], - $metaTitle = '', - $useRegularH1Structure = true - ) { - $originCtrl = new AdminLegacyLayoutControllerCore( - $controllerName, - $title, - $headerToolbarBtn, - $displayType, - $showContentHeader, - $headerTabContent, - $enableSidebar, - $helpLink, - $jsRouterMetadata, - $metaTitle, - $useRegularH1Structure - ); - $originCtrl->run(); - - return $originCtrl->outPutHtml; - } - - /** - * Returns available languages. The first one is the employee default one. - * - * @param bool $active Select only active languages - * @param int|bool $id_shop Shop ID - * @param bool $ids_only If true, returns an array of language IDs - * - * @return array Languages - */ - public function getLanguages($active = true, $id_shop = false, $ids_only = false) - { - $languages = Language::getLanguages($active, $id_shop, $ids_only); - $defaultLanguageFirst = $this->getLanguage(); - usort($languages, function ($a, $b) use ($defaultLanguageFirst) { - if ($a['id_lang'] == $defaultLanguageFirst->id) { - return -1; // $a is the default one. - } - if ($b['id_lang'] == $defaultLanguageFirst->id) { - return 1; // $b is the default one. - } - - return 0; - }); - - return $languages; - } - - /** - * Returns language ISO code set for the current employee. - * - * @return string Languages - */ - public function getEmployeeLanguageIso() - { - return Language::getIsoById($this->getContext()->employee->id_lang); - } - - /** - * Returns Currency set for the current employee. - * - * @return Currency - */ - public function getEmployeeCurrency() - { - if (null === $this->employeeCurrency && $this->getContext()->currency) { - $this->employeeCurrency = $this->getContext()->currency->sign; - } - - return $this->employeeCurrency; - } - - /** - * @return Language - */ - public function getLanguage() - { - $context = $this->getContext(); - - if ($context->language instanceof Language) { - return $context->language; - } - - return new Language(); - } - - /** - * Get employee's default tab name. - * - * @return string Default tab name for employee - * - * @throws RuntimeException Throws exception if employee does not exist in context - */ - public function getDefaultEmployeeTab() - { - $employee = $this->getContext()->employee; - - if (!$employee instanceof Employee) { - throw new RuntimeException('Cannot retrieve default employee tab. Employee does not exist in context!'); - } - - $idTab = $employee->default_tab; - $tab = new Tab($idTab); - - return $tab->class_name; - } - - /** - * @return string - */ - public function getMailThemesUri() - { - return $this->mailThemesUri; - } - - /** - * @return array Returns both enabled and disabled languages - */ - public function getAvailableLanguages() - { - return $this->getLanguages(false); - } -} diff --git a/src/Adapter/LegacyHookSubscriber.php b/src/Adapter/LegacyHookSubscriber.php deleted file mode 100644 index 38502eb5..00000000 --- a/src/Adapter/LegacyHookSubscriber.php +++ /dev/null @@ -1,302 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use Context; -use Hook; -use PrestaShopBundle\Service\Hook\HookEvent; -use PrestaShopBundle\Service\Hook\RenderingHookEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * The subscriber for HookDispatcher that triggers legacy Hooks. - * - * This subscriber is registered into the HookDispatcher service via services.yml. - * The legacy hooks are registered one by one in the dispatcher, but each corresponding - * function is a magic method catched by __call(). - * This ensure the listeners' count is real. - * - * - *

    COVERED HOOKS FROM PrestaShop v1.7

    - * - *
    - *

    ProductController

    - *
      - *
    • actionProductAdd
      - *
        - *
      • Legacy code (for legacy Admin controller, Product pages) is not modified
      • - *
      • Since 1.7 (refactored Admin Product pages), triggered by an adapter from legacy code: not modified
      • - *
      • Parameters: - *
          - *
        1. product: [object] Product (unchanged)
        2. - *
        3. cookie: [object] Cookie (unchanged)
        4. - *
        5. cart: [object] Cart (unchanged)
        6. - *
        7. altern: ???
        8. - *
        - *
      • - *
      • Returns: void
      • - *
      - *
    • - *
    • actionProductDelete
      - *
        - *
      • Legacy code (for legacy Admin controller, Product pages) is not modified
      • - *
      • Since 1.7 (refactored Admin Product pages), triggered by an adapter from legacy code: not modified
      • - *
      • Parameters: - *
          - *
        1. id_product: [int] Product ID to be deleted (unchanged)
        2. - *
        3. product: [object] Product (unchanged)
        4. - *
        5. cookie: [object] Cookie (unchanged)
        6. - *
        7. cart: [object] Cart (unchanged)
        8. - *
        9. altern: ???
        10. - *
        - *
      • - *
      • Returns: void
      • - *
      - *
    • - *
    • actionProductUpdate
      - *
        - *
      • Legacy code (for legacy Admin controller, Product pages) is not modified
      • - *
      • Since 1.7 (refactored Admin Product pages), triggered by an adapter from legacy code or directly from an adapter: duplicated behavior.
      • - *
      • Parameters: - *
          - *
        1. id_product: [int] Product ID to be deleted (unchanged)
        2. - *
        3. product: [object] Product (unchanged)
        4. - *
        5. cookie: [object] Cookie (unchanged)
        6. - *
        7. cart: [object] Cart (unchanged)
        8. - *
        9. altern: ???
        10. - *
        - *
      • - *
      • Returns: void
      • - *
      - *
    • - *
    • actionAdminProductsListingFieldsModifier
      - *
        - *
      • Legacy code (for legacy Admin controller, Product pages) is not modified
      • - *
      • Since 1.7 (refactored Admin Product pages), triggered by an adapter with a DIFFERENT BEHAVIOR.
      • - *
      • Parameters for the new 1.7 behavior (if _ps_version present and >=1.7.0): - *
          - *
        1. _ps_version: [int] value of _PS_VERSION_ is present only if triggered on new Product catalog page (>=1.7)
        2. - *
        3. sql_select: [&array] SELECT fields (to modify directly if needed)
        4. - *
        5. sql_table: [&array] TABLES to join (to modify directly if needed)
        6. - *
        7. sql_where: [&array] WHERE clauses (to modify directly if needed)
        8. - *
        9. sql_order: [&array] ORDER BY clauses (to modify directly if needed)
        10. - *
        11. sql_limit: [&string] LIMIT clause (to modify directly if needed)
        12. - *
        13. cookie: [object] Cookie (unchanged)
        14. - *
        15. cart: [object] Cart (unchanged)
        16. - *
        17. altern: ???
        18. - *
        - *
      • - *
      • {@see AbstractAdminQueryBuilder::compileSqlQuery()} for more details about how to build these arrays.
      • - *
      • {@see AdminProductDataProvider::getCatalogProductList()} for an example.
      • - *
      • Returns: void (but you can modify input parameters passed by reference)
      • - *
      - *
    • - *
    • actionAdminProductsListingResultsModifier
      - *
        - *
      • Legacy code (for legacy Admin controller, Product pages) is not modified
      • - *
      • Since 1.7 (refactored Admin Product pages), triggered by an adapter with a DIFFERENT BEHAVIOR.
      • - *
      • Parameters for the new 1.7 behavior (if _ps_version present and >=1.7.0): - *
          - *
        1. _ps_version: [int] value of _PS_VERSION_ is present only if triggered on new Product catalog page (>=1.7)
        2. - *
        3. products: [&array] List of the products on the requested page, after sql query (modified by actionAdminProductsListingFieldsModifier hook)
        4. - *
        5. total: [integer] total count of products (without pagination) that matches with the requested filters
        6. - *
        7. cookie: [object] Cookie (unchanged)
        8. - *
        9. cart: [object] Cart (unchanged)
        10. - *
        11. altern: ???
        12. - *
        - *
      • - *
      • {@see AdminProductDataProvider::getCatalogProductList()} for an example.
      • - *
      • Returns: void (but you can modify input parameters passed by reference)
      • - *
      - *
    • - *
    • displayAdminProductsExtra
      - *
        - *
      • Legacy code (for legacy Admin controller, Product pages) is not modified
      • - *
      • Since 1.7 (refactored Admin Product pages), triggered by the new architecture in Twig template.
      • - *
      • Parameters for the new 1.7 behavior (if _ps_version present and >=1.7.0): - *
          - *
        1. _ps_version: [int] value of _PS_VERSION_ is present only if triggered on new Product details page (>=1.7)
        2. - *
        3. id_product: [int] Product ID to be detailed in the form
        4. - *
        5. cookie: [object] Cookie (unchanged)
        6. - *
        7. cart: [object] Cart (unchanged)
        8. - *
        9. altern: ???
        10. - *
        - *
      • - *
      • Returns: HTML code, all embedded. While the page has been refactored, JS and legacy HTML/CSS classes are all changed.
      • - *
      - *
    • - *
    • actionUpdateQuantity
      - *
        - *
      • Legacy code (for legacy Admin controller, Product pages) is not modified
      • - *
      • Since 1.7 (refactored Admin Product pages), triggered by an adapter from legacy code or directly from an adapter: duplicated behavior.
      • - *
      • Parameters: - *
          - *
        1. id_product: [int] Product ID to be updated (unchanged)
        2. - *
        3. id_product_attribute: [int] Product attribute ID to be updated (unchanged, 0 if the product has no attribute)
        4. - *
        5. quantity: [int] Quantity to set (unchanged)
        6. - *
        7. cookie: [object] Cookie (unchanged)
        8. - *
        9. cart: [object] Cart (unchanged)
        10. - *
        11. altern: ???
        12. - *
        - *
      • - *
      • Returns: void
      • - *
      - *
    • - *
    • action{Admin|AdminProductsController}{Duplicate|Delete|Sort|Activate|Deactivate}{Before|After}
      - *
        - *
      • Since 1.7, triggered from the Controller
      • - *
      • Parameter, one of these: - *
          - *
        1. product_list_id: [array] A list of product IDs concerning the action
        2. - *
        3. product_id: [int] The product ID concerning the action
        4. - *
        5. product_list_position: [array] The positions of products in the product_list_id parameter, to sort
        6. - *
        - *
      • - *
      • Returns: void
      • - *
      - *
    • - *
    • shouldUseLegacyPage
      - *
        - *
      • Since 1.7, triggered from the Controller. This is a transitional behavior and can be removed in the future.
      • - *
      • Parameters: - *
          - *
        1. page: [string] The page name concerning the parameter change ('product', etc...)
        2. - *
        3. use_legacy: [boolean] True if the user ask to use legacy page instead of the new one.
        4. - *
        - *
      • - *
      • Returns: void
      • - *
      - *
    • - *
    • actionProductActivation
      - *
        - *
      • Since 1.7, triggered from the AdminProductDataUpdater via sf ProductController.
      • - *
      • Parameters: - *
          - *
        1. id_product: [int] Product ID to be updated
        2. - *
        3. product: [object] Product
        4. - *
        5. activated: [boolean] True if activation, False if deactivation.
        6. - *
        - *
      • - *
      • Returns: void
      • - *
      - *
    • - *
    - *
    - *
    - */ -class LegacyHookSubscriber implements EventSubscriberInterface -{ - /** - * Returns an array of event names this subscriber wants to listen to. - * - * The array keys are event names and the value are a function name - * that will be solved by magic __call(). The function contains data to extract: hookId, moduleId - * - * TODO: add cache layer on $listeners - * - * @return array The listeners array - */ - public static function getSubscribedEvents() - { - $listeners = []; - - //Hack SF2 cache clear : if context not mounted, bypass legacy call - $legacyContext = Context::getContext(); - if (!$legacyContext || empty($legacyContext->shop) || empty($legacyContext->employee)) { - return $listeners; - } - - $hooks = Hook::getHooks(); - - if (is_array($hooks)) { - foreach ($hooks as $hook) { - $name = strtolower($hook['name']); - $id = $hook['id_hook']; - - $moduleListeners = []; - $modules = []; - //SF2 cache clear bug fix : call bqSQL alias function - if (function_exists('bqSQL')) { - $modules = Hook::getHookModuleExecList($name); - } - - if (is_array($modules)) { - foreach ($modules as $order => $module) { - $moduleId = $module['id_module']; - $functionName = 'call_' . $id . '_' . $moduleId; - $moduleListeners[] = [$functionName, 2000 - $order]; - } - } else { - $moduleListeners[] = ['call_' . $id . '_0', 2000]; - } - - $listeners[$name] = $moduleListeners; - } - } - - return $listeners; - } - - /** - * This will handle magic methods registered as listeners. - * - * These methods are built with the following syntax: - * "call__(HookEvent $event, $hookName)" - * - * @param string $name The method called - * @param array $args The HookEvent, and then the hook name (eventName) - * - * @throws \BadMethodCallException - */ - public function __call($name, $args) - { - if (strpos($name, 'call_') !== 0) { - throw new \BadMethodCallException('The call to \'' . $name . '\' is not recognized.'); - } - - $ids = explode('_', $name); - array_shift($ids); // remove 'call' - - if (count($ids) !== 2) { - throw new \BadMethodCallException('The call to \'' . $name . '\' is not recognized.'); - } - - $moduleId = (int) $ids[1]; - list($event, $hookName) = $args; - - /** @var $event HookEvent */ - $content = Hook::exec($hookName, $event->getHookParameters(), $moduleId, ($event instanceof RenderingHookEvent)); - - if ( - $event instanceof RenderingHookEvent - && 0 !== $moduleId - && !empty($content) - ) { - $event->setContent([array_values($content)[0]], array_keys($content)[0]); - } - } -} diff --git a/src/Adapter/LegacyLogger.php b/src/Adapter/LegacyLogger.php deleted file mode 100644 index dfc8a1f1..00000000 --- a/src/Adapter/LegacyLogger.php +++ /dev/null @@ -1,170 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use Monolog\Logger; -use PrestaShopLogger; -use Psr\Log\LoggerInterface; - -/** - * Class that bridge the legacy implementation of Logger with Psr Logger interface. - */ -class LegacyLogger implements LoggerInterface -{ - public function emergency($message, array $context = []) - { - $this->log(Logger::EMERGENCY, $message, $context); - } - - /** - * Action must be taken immediately. - * - * Example: Entire website down, database unavailable, etc. This should - * trigger the SMS alerts and wake you up. - * - * @param string $message - * @param array $context - */ - public function alert($message, array $context = []) - { - $this->log(Logger::ALERT, $message, $context); - } - - /** - * Critical conditions. - * - * Example: Application component unavailable, unexpected exception. - * - * @param string $message - * @param array $context - */ - public function critical($message, array $context = []) - { - $this->log(Logger::CRITICAL, $message, $context); - } - - /** - * Runtime errors that do not require immediate action but should typically - * be logged and monitored. - * - * @param string $message - * @param array $context - */ - public function error($message, array $context = []) - { - $this->log(Logger::ERROR, $message, $context); - } - - /** - * Exceptional occurrences that are not errors. - * - * Example: Use of deprecated APIs, poor use of an API, undesirable things - * that are not necessarily wrong. - * - * @param string $message - * @param array $context - */ - public function warning($message, array $context = []) - { - $this->log(Logger::WARNING, $message, $context); - } - - /** - * Normal but significant events. - * - * @param string $message - * @param array $context - */ - public function notice($message, array $context = []) - { - $this->log(Logger::NOTICE, $message, $context); - } - - /** - * Interesting events. - * - * Example: User logs in, SQL logs. - * - * @param string $message - * @param array $context - */ - public function info($message, array $context = []) - { - $this->log(Logger::INFO, $message, $context); - } - - /** - * Detailed debug information. - * - * @param string $message - * @param array $context - */ - public function debug($message, array $context = []) - { - $this->log(Logger::DEBUG, $message, $context); - } - - /** - * Logs with an arbitrary level. - * - * @param mixed $level - * @param string $message - * @param array $context - */ - public function log($level, $message, array $context = []) - { - switch ($level) { - case Logger::EMERGENCY: - case Logger::ALERT: - case Logger::CRITICAL: - $pslevel = 4; - - break; - case Logger::ERROR: - $pslevel = 3; - - break; - case Logger::WARNING: - $pslevel = 2; - - break; - case Logger::NOTICE: - case Logger::INFO: - case Logger::DEBUG: - $pslevel = 1; - - break; - } - - $error_code = !empty($context['error_code']) ? $context['error_code'] : null; - $object_type = !empty($context['object_type']) ? $context['object_type'] : null; - $object_id = !empty($context['object_id']) ? $context['object_id'] : null; - $allow_duplicate = !empty($context['allow_duplicate']) ? $context['allow_duplicate'] : null; - - PrestaShopLogger::addLog($message, $pslevel, $error_code, $object_type, $object_id, $allow_duplicate); - } -} diff --git a/src/Adapter/Localization/AdvancedConfiguration.php b/src/Adapter/Localization/AdvancedConfiguration.php deleted file mode 100644 index 304933b3..00000000 --- a/src/Adapter/Localization/AdvancedConfiguration.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Localization; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * Class AdvancedConfiguration is responsible for 'Improve > International > Localization' page - * 'Advanced' form data. - */ -class AdvancedConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - /** - * @param Configuration $configuration - */ - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'language_identifier' => $this->configuration->get('PS_LOCALE_LANGUAGE'), - 'country_identifier' => $this->configuration->get('PS_LOCALE_COUNTRY'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $config) - { - $errors = []; - - if ($this->validateConfiguration($config)) { - $this->configuration->set('PS_LOCALE_LANGUAGE', $config['language_identifier']); - $this->configuration->set('PS_LOCALE_COUNTRY', $config['country_identifier']); - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $config) - { - return isset( - $config['language_identifier'], - $config['country_identifier'] - ); - } -} diff --git a/src/Adapter/Localization/LegacyTranslator.php b/src/Adapter/Localization/LegacyTranslator.php deleted file mode 100644 index a2ac79ca..00000000 --- a/src/Adapter/Localization/LegacyTranslator.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Localization; - -use Translate; - -/** - * Wraps the Legacy translation system - * - * @deprecated The legacy translation system will be removed in the next major version - */ -class LegacyTranslator -{ - /** - * @param string $moduleName Module name - * @param string $originalString String to translate - * @param string|false $source - * @param null $sprintf - * @param bool $js - * @param string|null $locale - * @param bool $fallback [default=true] If true, this method falls back to the new translation system if no translation is found - * - * @return mixed|string - * - * @throws \Exception - */ - public function translate( - $moduleName, - $originalString, - $source, - $sprintf = null, - $js = false, - $locale = null, - $fallback = true, - $escape = true - ) { - return Translate::getModuleTranslation( - $moduleName, - $originalString, - $source, - $sprintf, - $js, - $locale, - $fallback, - $escape - ); - } -} diff --git a/src/Adapter/Localization/LocalUnitsConfiguration.php b/src/Adapter/Localization/LocalUnitsConfiguration.php deleted file mode 100644 index a41a001c..00000000 --- a/src/Adapter/Localization/LocalUnitsConfiguration.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Localization; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * Class LocalUnitsConfiguration is responsible for 'Improve > International > Localization' page - * 'Local units' form data. - */ -class LocalUnitsConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - /** - * @param Configuration $configuration - */ - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'weight_unit' => $this->configuration->get('PS_WEIGHT_UNIT'), - 'distance_unit' => $this->configuration->get('PS_DISTANCE_UNIT'), - 'volume_unit' => $this->configuration->get('PS_VOLUME_UNIT'), - 'dimension_unit' => $this->configuration->get('PS_DIMENSION_UNIT'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $config) - { - $errors = []; - - if ($this->validateConfiguration($config)) { - $this->configuration->set('PS_WEIGHT_UNIT', $config['weight_unit']); - $this->configuration->set('PS_DISTANCE_UNIT', $config['distance_unit']); - $this->configuration->set('PS_VOLUME_UNIT', $config['volume_unit']); - $this->configuration->set('PS_DIMENSION_UNIT', $config['dimension_unit']); - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $config) - { - return isset( - $config['weight_unit'], - $config['distance_unit'], - $config['volume_unit'], - $config['dimension_unit'] - ); - } -} diff --git a/src/Adapter/Localization/LocalizationConfiguration.php b/src/Adapter/Localization/LocalizationConfiguration.php deleted file mode 100644 index 5708ca70..00000000 --- a/src/Adapter/Localization/LocalizationConfiguration.php +++ /dev/null @@ -1,141 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Localization; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\Currency\CurrencyManager; -use PrestaShop\PrestaShop\Adapter\Language\LanguageActivator; -use PrestaShop\PrestaShop\Adapter\Module\AdminModuleDataProvider; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\Language\LanguageActivatorInterface; - -/** - * Class LocalizationConfiguration is responsible for 'Improve > International > Localization' page - * 'Configuration' form data. - */ -class LocalizationConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - /** - * @var LanguageActivator - */ - private $languageActivator; - - /** - * @var CurrencyManager - */ - private $currencyManager; - - /** - * @var AdminModuleDataProvider - */ - private $adminModuleDataProvider; - - /** - * @param Configuration $configuration - * @param LanguageActivatorInterface $languageActivator - * @param CurrencyManager $currencyManager - * @param AdminModuleDataProvider $adminModuleDataProvider - */ - public function __construct( - Configuration $configuration, - LanguageActivatorInterface $languageActivator, - CurrencyManager $currencyManager, - AdminModuleDataProvider $adminModuleDataProvider - ) { - $this->configuration = $configuration; - $this->languageActivator = $languageActivator; - $this->currencyManager = $currencyManager; - $this->adminModuleDataProvider = $adminModuleDataProvider; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'default_language' => $this->configuration->getInt('PS_LANG_DEFAULT'), - 'detect_language_from_browser' => $this->configuration->getBoolean('PS_DETECT_LANG'), - 'default_country' => $this->configuration->getInt('PS_COUNTRY_DEFAULT'), - 'detect_country_from_browser' => $this->configuration->getBoolean('PS_DETECT_COUNTRY'), - 'default_currency' => $this->configuration->getInt('PS_CURRENCY_DEFAULT'), - 'timezone' => $this->configuration->get('PS_TIMEZONE'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $config) - { - $errors = []; - - if ($this->validateConfiguration($config)) { - $this->languageActivator->enable((int) $config['default_language']); - - // only update currency related data if it has changed - $currentConfig = $this->getConfiguration(); - if ($currentConfig['default_currency'] != $config['default_currency']) { - $this->configuration->set('PS_CURRENCY_DEFAULT', (int) $config['default_currency']); - $this->currencyManager->updateDefaultCurrency(); - } - - // remove module list cache if the default country changed - if ($currentConfig['default_country'] != $config['default_country']) { - $this->adminModuleDataProvider->clearModuleListCache(); - } - - $this->configuration->set('PS_LANG_DEFAULT', (int) $config['default_language']); - $this->configuration->set('PS_DETECT_LANG', (int) $config['detect_language_from_browser']); - $this->configuration->set('PS_COUNTRY_DEFAULT', (int) $config['default_country']); - $this->configuration->set('PS_DETECT_COUNTRY', (int) $config['detect_country_from_browser']); - $this->configuration->set('PS_TIMEZONE', $config['timezone']); - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $config) - { - return isset( - $config['default_language'], - $config['detect_language_from_browser'], - $config['default_country'], - $config['detect_country_from_browser'], - $config['default_currency'], - $config['timezone'] - ); - } -} diff --git a/src/Adapter/Mail/MailingInformation.php b/src/Adapter/Mail/MailingInformation.php deleted file mode 100644 index a4532927..00000000 --- a/src/Adapter/Mail/MailingInformation.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Mail; - -use Configuration; - -/** - * Retrieve mailing information. - */ -class MailingInformation -{ - /** - * @return bool - */ - public function isNativeMailUsed() - { - return Configuration::get('PS_MAIL_METHOD') == 1; - } - - /** - * @return array - */ - public function getSmtpInformation() - { - return [ - 'server' => Configuration::get('PS_MAIL_SERVER'), - 'user' => Configuration::get('PS_MAIL_USER'), - 'password' => Configuration::get('PS_MAIL_PASSWD'), - 'encryption' => Configuration::get('PS_MAIL_SMTP_ENCRYPTION'), - 'port' => Configuration::get('PS_MAIL_SMTP_PORT'), - ]; - } -} diff --git a/src/Adapter/MailTemplate/MailPartialTemplateRenderer.php b/src/Adapter/MailTemplate/MailPartialTemplateRenderer.php deleted file mode 100644 index af155196..00000000 --- a/src/Adapter/MailTemplate/MailPartialTemplateRenderer.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\MailTemplate; - -use PrestaShop\PrestaShop\Core\Language\LanguageInterface; -use Smarty; -use Tools; - -/** - * Class MailPartialTemplateRenderer renders partial mail templates (especially for order). This - * feature was moved in this service so that it can be shared between PaymentModule and MailPreviewVariablesBuilder. - */ -class MailPartialTemplateRenderer -{ - /** @var Smarty */ - private $smarty; - - /** - * @param Smarty $smarty - */ - public function __construct(Smarty $smarty) - { - $this->smarty = $smarty; - } - - /** - * Fetch the content of $partialTemplateName inside the folder - * current_theme/mails/current_iso_lang/ if found, otherwise in - * mails/current_iso_lang. - * - * @param string $partialTemplateName template name with extension - * @param LanguageInterface $language - * @param array $variables sent to smarty as 'list' - * @param bool $cleanComments - * - * @return string - */ - public function render($partialTemplateName, LanguageInterface $language, array $variables = [], $cleanComments = false) - { - $potentialPaths = [ - _PS_THEME_DIR_ . 'mails' . DIRECTORY_SEPARATOR . $language->getIsoCode() . DIRECTORY_SEPARATOR . $partialTemplateName, - _PS_MAIL_DIR_ . $language->getIsoCode() . DIRECTORY_SEPARATOR . $partialTemplateName, - _PS_THEME_DIR_ . 'mails' . DIRECTORY_SEPARATOR . 'en' . DIRECTORY_SEPARATOR . $partialTemplateName, - _PS_MAIL_DIR_ . 'en' . DIRECTORY_SEPARATOR . $partialTemplateName, - _PS_MAIL_DIR_ . '_partials' . DIRECTORY_SEPARATOR . $partialTemplateName, - ]; - - foreach ($potentialPaths as $path) { - if (Tools::file_exists_cache($path)) { - $this->smarty->assign('list', $variables); - $content = $this->smarty->fetch($path); - if ($cleanComments) { - $content = preg_replace('/\s?\s?/s', '', $content); - } - - return $content; - } - } - - return ''; - } -} diff --git a/src/Adapter/MailTemplate/MailPreviewVariablesBuilder.php b/src/Adapter/MailTemplate/MailPreviewVariablesBuilder.php deleted file mode 100644 index a4d176ba..00000000 --- a/src/Adapter/MailTemplate/MailPreviewVariablesBuilder.php +++ /dev/null @@ -1,440 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\MailTemplate; - -use Address; -use AddressFormat; -use Carrier; -use Cart; -use Context; -use Order; -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Employee\ContextEmployeeProviderInterface; -use PrestaShop\PrestaShop\Core\Localization\Locale; -use PrestaShop\PrestaShop\Core\MailTemplate\Layout\LayoutInterface; -use Product; -use Symfony\Component\Translation\TranslatorInterface; -use Tools; - -/** - * Class MailPreviewVariablesBuilder is used to build fake (but realistic) template variables to preview email templates. - */ -final class MailPreviewVariablesBuilder -{ - const ORDER_CONFIRMATION = 'order_conf'; - - const DOWNLOAD_PRODUCT = 'download_product'; - - const EMAIL_ALERTS_MODULE = 'ps_emailalerts'; - const NEW_ORDER = 'new_order'; - const RETURN_SLIP = 'return_slip'; - - /** @var ConfigurationInterface */ - private $configuration; - - /** @var LegacyContext */ - private $legacyContext; - - /** - * @var Locale - */ - private $locale; - - /** @var ContextEmployeeProviderInterface */ - private $employeeProvider; - - /** @var Context */ - private $context; - - /** @var MailPartialTemplateRenderer */ - private $mailPartialTemplateRenderer; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * MailPreviewVariablesBuilder constructor. - * - * @param ConfigurationInterface $configuration - * @param LegacyContext $legacyContext - * @param ContextEmployeeProviderInterface $employeeProvider - * @param MailPartialTemplateRenderer $mailPartialTemplateRenderer - * @param Locale $locale - * @param TranslatorInterface $translatorComponent - */ - public function __construct( - ConfigurationInterface $configuration, - LegacyContext $legacyContext, - ContextEmployeeProviderInterface $employeeProvider, - MailPartialTemplateRenderer $mailPartialTemplateRenderer, - Locale $locale, - TranslatorInterface $translatorComponent - ) { - $this->configuration = $configuration; - $this->legacyContext = $legacyContext; - $this->context = $this->legacyContext->getContext(); - $this->employeeProvider = $employeeProvider; - $this->mailPartialTemplateRenderer = $mailPartialTemplateRenderer; - $this->locale = $locale; - $this->translator = $translatorComponent; - } - - /** - * @param LayoutInterface $mailLayout - * - * @return array - * - * @throws \SmartyException - */ - public function buildTemplateVariables(LayoutInterface $mailLayout) - { - $imageDir = $this->configuration->get('_PS_IMG_DIR_'); - $baseUrl = $this->context->link->getBaseLink(); - - //Logo url - $logoMail = $this->configuration->get('PS_LOGO_MAIL'); - $logo = $this->configuration->get('PS_LOGO'); - if (!empty($logoMail) && file_exists($imageDir . $logoMail)) { - $templateVars['{shop_logo}'] = $baseUrl . 'img/' . $logoMail; - } else { - if (!empty($logo) && file_exists($imageDir . $logo)) { - $templateVars['{shop_logo}'] = $baseUrl . 'img/' . $logo; - } else { - $templateVars['{shop_logo}'] = ''; - } - } - - $employeeData = $this->employeeProvider->getData(); - - $templateVars['{firstname}'] = $employeeData['firstname']; - $templateVars['{lastname}'] = $employeeData['lastname']; - $templateVars['{email}'] = $employeeData['email']; - $templateVars['{shop_name}'] = $this->context->shop->name; - $templateVars['{shop_url}'] = $this->context->link->getPageLink('index', true); - $templateVars['{my_account_url}'] = $this->context->link->getPageLink('my-account', true); - $templateVars['{guest_tracking_url}'] = $this->context->link->getPageLink('guest-tracking', true); - $templateVars['{history_url}'] = $this->context->link->getPageLink('history', true); - $templateVars['{color}'] = $this->configuration->get('PS_MAIL_COLOR'); - $templateVars = array_merge($templateVars, $this->buildOrderVariables($mailLayout)); - - return $templateVars; - } - - /** - * @param $id - * @param array $parameters - * @param null $domain - * @param null $local - * - * @return string - */ - protected function trans($id, $parameters = [], $domain = null, $local = null) - { - return $this->translator->trans($id, $parameters, $domain, $local); - } - - /** - * @return array - * - * @throws \PrestaShopException - * @throws \PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException - * @throws \SmartyException - */ - private function buildOrderVariables(LayoutInterface $mailLayout) - { - $orders = Order::getOrdersWithInformations(1); - $order = new Order($orders[0]['id_order']); - - if (self::ORDER_CONFIRMATION == $mailLayout->getName()) { - $productTemplateList = $this->getProductList($order); - $productListTxt = $this->mailPartialTemplateRenderer->render('order_conf_product_list.txt', $this->context->language, $productTemplateList); - $productListHtml = $this->mailPartialTemplateRenderer->render('order_conf_product_list.tpl', $this->context->language, $productTemplateList); - - $cartRulesList[] = [ - 'voucher_name' => 'Promo code', - 'voucher_reduction' => '-' . $this->locale->formatPrice(5, $this->context->currency->iso_code), - ]; - $cartRulesListTxt = $this->mailPartialTemplateRenderer->render('order_conf_cart_rules.txt', $this->context->language, $cartRulesList); - $cartRulesListHtml = $this->mailPartialTemplateRenderer->render('order_conf_cart_rules.tpl', $this->context->language, $cartRulesList); - - $productVariables = [ - '{products}' => $productListHtml, - '{products_txt}' => $productListTxt, - '{discounts}' => $cartRulesListHtml, - '{discounts_txt}' => $cartRulesListTxt, - ]; - } elseif (self::DOWNLOAD_PRODUCT == $mailLayout->getName()) { - $virtualProductTemplateList = $this->getFakeVirtualProductList(); - $virtualProductListTxt = $this->mailPartialTemplateRenderer->render('download_product_virtual_products.txt', $this->context->language, $virtualProductTemplateList); - $virtualProductListHtml = $this->mailPartialTemplateRenderer->render('download_product_virtual_products.tpl', $this->context->language, $virtualProductTemplateList); - $productVariables = [ - '{nbProducts}' => count($virtualProductTemplateList), - '{virtualProducts}' => $virtualProductListHtml, - '{virtualProductsTxt}' => $virtualProductListTxt, - ]; - } elseif (self::EMAIL_ALERTS_MODULE == $mailLayout->getModuleName() && self::NEW_ORDER == $mailLayout->getName()) { - $productVariables = [ - '{items}' => $this->getNewOrderItems($order), - ]; - } elseif (self::EMAIL_ALERTS_MODULE == $mailLayout->getModuleName() && self::RETURN_SLIP == $mailLayout->getName()) { - $productVariables = [ - '{items}' => $this->getReturnSlipItems($order), - ]; - } else { - return []; - } - - $carrier = new Carrier($order->id_carrier); - $delivery = new Address($order->id_address_delivery); - $invoice = new Address($order->id_address_invoice); - - return array_merge($productVariables, [ - '{carrier}' => $carrier->name, - '{delivery_block_txt}' => $this->getFormatedAddress($delivery, "\n"), - '{invoice_block_txt}' => $this->getFormatedAddress($invoice, "\n"), - '{delivery_block_html}' => $this->getFormatedAddress($delivery, '
    ', [ - 'firstname' => '%s', - 'lastname' => '%s', - ]), - '{invoice_block_html}' => $this->getFormatedAddress($invoice, '
    ', [ - 'firstname' => '%s', - 'lastname' => '%s', - ]), - '{date}' => Tools::displayDate($order->date_add, null, 1), - '{order_name}' => $order->getUniqReference(), - '{id_order}' => $order->id, - '{payment}' => Tools::substr($order->payment, 0, 255), - '{total_products}' => count($order->getProducts()), - '{total_discounts}' => $this->locale->formatPrice($order->total_discounts, $this->context->currency->iso_code), - '{total_wrapping}' => $this->locale->formatPrice($order->total_wrapping, $this->context->currency->iso_code), - '{total_shipping}' => $this->locale->formatPrice($order->total_shipping, $this->context->currency->iso_code), - '{total_shipping_tax_excl}' => $this->locale->formatPrice($order->total_shipping_tax_excl, $this->context->currency->iso_code), - '{total_shipping_tax_incl}' => $this->locale->formatPrice($order->total_shipping_tax_incl, $this->context->currency->iso_code), - '{total_tax_paid}' => $this->locale->formatPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency->iso_code), - '{total_paid}' => $this->locale->formatPrice($order->total_paid, $this->context->currency->iso_code), - ]); - } - - /** - * @param Order $order - * - * @return string - * - * @throws \PrestaShopException - * @throws \PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException - */ - private function getNewOrderItems(Order $order) - { - $itemsTable = ''; - - $products = $order->getProducts(); - $customizedDatas = Product::getAllCustomizedDatas($order->id_cart); - Product::addCustomizationPrice($products, $customizedDatas); - foreach ($products as $key => $product) { - $unitPrice = $product['product_price_wt']; - - $customizationText = ''; - if (isset($customizedDatas[$product['product_id']][$product['product_attribute_id']])) { - foreach ($customizedDatas[$product['product_id']][$product['product_attribute_id']][$order->id_address_delivery] as $customization) { - if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) { - foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) { - $customizationText .= $text['name'] . ': ' . $text['value'] . '
    '; - } - } - - if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) { - $customizationText .= count($customization['datas'][Product::CUSTOMIZE_FILE]) . ' ' . $this->trans('image(s)', [], 'Modules.Mailalerts.Admin') . '
    '; - } - - $customizationText .= '---
    '; - } - if (method_exists('Tools', 'rtrimString')) { - $customizationText = Tools::rtrimString($customizationText, '---
    '); - } else { - $customizationText = preg_replace('/---
    $/', '', $customizationText); - } - } - - $url = $this->context->link->getProductLink($product['product_id']); - $itemsTable .= - ' - ' . $product['product_reference'] . ' - - ' . $product['product_name'] . '' - . (isset($product['attributes_small']) ? ' ' . $product['attributes_small'] : '') - . (!empty($customizationText) ? '
    ' . $customizationText : '') - . '
    - - ' . $this->locale->formatPrice($unitPrice, $this->context->currency->iso_code) . ' - ' . (int) $product['product_quantity'] . ' - ' - . $this->locale->formatPrice(($unitPrice * $product['product_quantity']), $this->context->currency->iso_code) - . ' - '; - } - foreach ($order->getCartRules() as $discount) { - $itemsTable .= - ' - ' . $this->trans('Voucher code:', [], 'Modules.Mailalerts.Admin') . ' ' . $discount['name'] . ' - -' . $this->locale->formatPrice($discount['value'], $this->context->currency->iso_code) . ' - '; - } - - return $itemsTable; - } - - /** - * @param Order $order - * - * @return string - * - * @throws \PrestaShopException - */ - private function getReturnSlipItems(Order $order) - { - $itemsTable = ''; - foreach ($order->getCartProducts() as $key => $product) { - $url = $this->context->link->getProductLink($product['product_id']); - $itemsTable .= - ' - ' . $product['product_reference'] . ' - - ' . $product['product_name'] . ' - - - ' . (int) $product['product_quantity'] . ' - '; - } - - return $itemsTable; - } - - /** - * @param Order $order - * - * @return array - * - * @throws \PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException - */ - private function getProductList(Order $order) - { - $cart = new Cart($order->id_cart); - $packageList = $cart->getPackageList(); - $package = current(current($packageList)); - $productList = $package['product_list']; - - $productTemplateList = []; - foreach ($productList as $product) { - $price = Product::getPriceStatic((int) $product['id_product'], false, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 6, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{$this->configuration->get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']); - $priceWithTax = Product::getPriceStatic((int) $product['id_product'], true, ($product['id_product_attribute'] ? (int) $product['id_product_attribute'] : null), 2, null, false, true, $product['cart_quantity'], false, (int) $order->id_customer, (int) $order->id_cart, (int) $order->{$this->configuration->get('PS_TAX_ADDRESS_TYPE')}, $specific_price, true, true, null, true, $product['id_customization']); - - $productPrice = Product::getTaxCalculationMethod() == PS_TAX_EXC ? Tools::ps_round($price, 2) : $priceWithTax; - - $productTemplate = [ - 'id_product' => $product['id_product'], - 'reference' => $product['reference'], - 'name' => $product['name'] . (isset($product['attributes']) ? ' - ' . $product['attributes'] : ''), - 'price' => $this->locale->formatPrice($productPrice * $product['quantity'], $this->context->currency->iso_code), - 'quantity' => $product['quantity'], - 'customization' => [], - ]; - - if (isset($product['price']) && $product['price']) { - $productTemplate['unit_price'] = $this->locale->formatPrice($productPrice, $this->context->currency->iso_code); - $productTemplate['unit_price_full'] = $this->locale->formatPrice($productPrice, $this->context->currency->iso_code) - . ' ' . $product['unity']; - } else { - $productTemplate['unit_price'] = $productTemplate['unit_price_full'] = ''; - } - - $customizedDatas = Product::getAllCustomizedDatas((int) $order->id_cart, null, true, null, (int) $product['id_customization']); - if (isset($customizedDatas[$product['id_product']][$product['id_product_attribute']])) { - $productTemplate['customization'] = []; - foreach ($customizedDatas[$product['id_product']][$product['id_product_attribute']][$order->id_address_delivery] as $customization) { - $customizationText = ''; - if (isset($customization['datas'][Product::CUSTOMIZE_TEXTFIELD])) { - foreach ($customization['datas'][Product::CUSTOMIZE_TEXTFIELD] as $text) { - $customizationText .= '' . $text['name'] . ': ' . $text['value'] . '
    '; - } - } - - if (isset($customization['datas'][Product::CUSTOMIZE_FILE])) { - $customizationText .= $this->trans('%d image(s)', [count($customization['datas'][Product::CUSTOMIZE_FILE])], 'Admin.Payment.Notification') . '
    '; - } - - $customizationQuantity = (int) $customization['quantity']; - - $productTemplate['customization'][] = [ - 'customization_text' => $customizationText, - 'customization_quantity' => $customizationQuantity, - 'quantity' => $this->locale->formatPrice($customizationQuantity * $productPrice, $this->context->currency->iso_code), - ]; - } - } - $productTemplateList[] = $productTemplate; - } - - return $productTemplateList; - } - - /** - * @return array - */ - private function getFakeVirtualProductList() - { - $products = Product::getProducts($this->context->language->getId(), 0, 2, 'id_product', 'ASC'); - $results = []; - - foreach ($products as $productData) { - $product = new Product($productData['id_product']); - $results[] = [ - 'text' => Product::getProductName($productData['id_product']), - 'url' => $product->getLink(), - 'complementary_text' => '', - ]; - } - $results[1]['complementary_text'] = ' ' . $this->trans('expires on %s.', [date('Y-m-d')], 'Admin.Orderscustomers.Notification'); - $results[1]['complementary_text'] .= ' ' . $this->trans('downloadable %d time(s)', [10], 'Admin.Orderscustomers.Notification'); - - return $results; - } - - /** - * @param Address $address Address $the_address that needs to be txt formated - * @param string $lineSeparator Line separator - * @param array $fieldsStyle Associative array to replace styled fields - * - * @return string - */ - private function getFormatedAddress(Address $address, $lineSeparator, $fieldsStyle = []) - { - return AddressFormat::generateAddress($address, ['avoid' => []], $lineSeparator, ' ', $fieldsStyle); - } -} diff --git a/src/Adapter/MailTemplate/MailTemplateTwigRenderer.php b/src/Adapter/MailTemplate/MailTemplateTwigRenderer.php deleted file mode 100644 index 28a4c8b4..00000000 --- a/src/Adapter/MailTemplate/MailTemplateTwigRenderer.php +++ /dev/null @@ -1,188 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\MailTemplate; - -use PrestaShop\PrestaShop\Core\Exception\FileNotFoundException; -use PrestaShop\PrestaShop\Core\Exception\TypeException; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShop\PrestaShop\Core\Language\LanguageInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\Layout\LayoutInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\Layout\LayoutVariablesBuilderInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\MailTemplateInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\MailTemplateRendererInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\Transformation\TransformationCollection; -use PrestaShop\PrestaShop\Core\MailTemplate\Transformation\TransformationInterface; -use Symfony\Component\Templating\EngineInterface; - -/** - * MailTemplateTwigRenderer is a basic implementation of MailTemplateRendererInterface - * using the twig engine. - */ -class MailTemplateTwigRenderer implements MailTemplateRendererInterface -{ - /** @var EngineInterface */ - private $engine; - - /** @var LayoutVariablesBuilderInterface */ - private $variablesBuilder; - - /** @var HookDispatcherInterface */ - private $hookDispatcher; - - /** @var TransformationInterface[] */ - private $transformations; - - /** - * @param EngineInterface $engine - * @param LayoutVariablesBuilderInterface $variablesBuilder - * @param HookDispatcherInterface $hookDispatcher - * - * @throws TypeException - */ - public function __construct( - EngineInterface $engine, - LayoutVariablesBuilderInterface $variablesBuilder, - HookDispatcherInterface $hookDispatcher - ) { - $this->engine = $engine; - $this->variablesBuilder = $variablesBuilder; - $this->hookDispatcher = $hookDispatcher; - $this->transformations = new TransformationCollection(); - } - - /** - * @param LayoutInterface $layout - * @param LanguageInterface $language - * - * @throws TypeException - * - * @return string - * - * @throws FileNotFoundException - * @throws TypeException - */ - public function renderHtml(LayoutInterface $layout, LanguageInterface $language) - { - return $this->render($layout, $language, MailTemplateInterface::HTML_TYPE); - } - - /** - * @param LayoutInterface $layout - * @param LanguageInterface $language - * - * @throws FileNotFoundException - * @throws TypeException - * - * @return string - */ - public function renderTxt(LayoutInterface $layout, LanguageInterface $language) - { - return $this->render($layout, $language, MailTemplateInterface::TXT_TYPE); - } - - /** - * @param LayoutInterface $layout - * @param LanguageInterface $language - * @param string $templateType - * - * @return string - * - * @throws FileNotFoundException - * @throws TypeException - */ - private function render( - LayoutInterface $layout, - LanguageInterface $language, - $templateType - ) { - $layoutVariables = $this->variablesBuilder->buildVariables($layout, $language); - $layoutVariables['templateType'] = $templateType; - if (MailTemplateInterface::HTML_TYPE === $templateType) { - $layoutPath = !empty($layout->getHtmlPath()) ? $layout->getHtmlPath() : $layout->getTxtPath(); - } else { - $layoutPath = !empty($layout->getTxtPath()) ? $layout->getTxtPath() : $layout->getHtmlPath(); - } - if (!file_exists($layoutPath)) { - throw new FileNotFoundException(sprintf('Could not find layout file: %s', $layoutPath)); - } - - $renderedTemplate = $this->engine->render($layoutPath, $layoutVariables); - $templateTransformations = $this->getMailLayoutTransformations($layout, $templateType); - /** @var TransformationInterface $transformation */ - foreach ($templateTransformations as $transformation) { - $renderedTemplate = $transformation - ->setLanguage($language) - ->apply($renderedTemplate, $layoutVariables) - ; - } - - return $renderedTemplate; - } - - /** - * @param LayoutInterface $mailLayout - * @param string $templateType - * - * @return TransformationCollection - * - * @throws TypeException - */ - private function getMailLayoutTransformations(LayoutInterface $mailLayout, $templateType) - { - $templateTransformations = new TransformationCollection(); - /** @var TransformationInterface $transformation */ - foreach ($this->transformations as $transformation) { - if ($templateType !== $transformation->getType()) { - continue; - } - - $templateTransformations->add($transformation); - } - - //This hook allows to add/remove transformations during a layout rendering - $this->hookDispatcher->dispatchWithParameters( - MailTemplateRendererInterface::GET_MAIL_LAYOUT_TRANSFORMATIONS, - [ - 'mailLayout' => $mailLayout, - 'templateType' => $templateType, - 'layoutTransformations' => $templateTransformations, - ] - ); - - return $templateTransformations; - } - - /** - * {@inheritdoc} - */ - public function addTransformation(TransformationInterface $transformation) - { - $this->transformations[] = $transformation; - - return $this; - } -} diff --git a/src/Adapter/Manufacturer/AbstractManufacturerHandler.php b/src/Adapter/Manufacturer/AbstractManufacturerHandler.php deleted file mode 100644 index 3ef2f93a..00000000 --- a/src/Adapter/Manufacturer/AbstractManufacturerHandler.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Manufacturer; - -use Manufacturer; -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\ManufacturerException; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\ManufacturerNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\ValueObject\ManufacturerId; -use PrestaShopException; - -/** - * Provides reusable methods for manufacturer command/query handlers - */ -abstract class AbstractManufacturerHandler extends AbstractObjectModelHandler -{ - /** - * Gets legacy Manufacturer - * - * @param ManufacturerId $manufacturerId - * - * @return Manufacturer - * - * @throws ManufacturerException - */ - protected function getManufacturer(ManufacturerId $manufacturerId) - { - try { - $manufacturer = new Manufacturer($manufacturerId->getValue()); - } catch (PrestaShopException $e) { - throw new ManufacturerException('Failed to create new manufacturer', 0, $e); - } - - if ($manufacturer->id !== $manufacturerId->getValue()) { - throw new ManufacturerNotFoundException(sprintf('Manufacturer with id "%s" was not found.', $manufacturerId->getValue())); - } - - return $manufacturer; - } -} diff --git a/src/Adapter/Manufacturer/CommandHandler/AbstractManufacturerCommandHandler.php b/src/Adapter/Manufacturer/CommandHandler/AbstractManufacturerCommandHandler.php deleted file mode 100644 index ff68a6bb..00000000 --- a/src/Adapter/Manufacturer/CommandHandler/AbstractManufacturerCommandHandler.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Manufacturer\CommandHandler; - -use Manufacturer; -use PrestaShop\PrestaShop\Adapter\Manufacturer\AbstractManufacturerHandler; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\ManufacturerException; -use PrestaShopException; - -/** - * Provides reusable methods for manufacturer command handlers - */ -abstract class AbstractManufacturerCommandHandler extends AbstractManufacturerHandler -{ - /** - * Deletes legacy Manufacturer - * - * @param Manufacturer $manufacturer - * - * @return bool - * - * @throws ManufacturerException - */ - protected function deleteManufacturer(Manufacturer $manufacturer) - { - try { - return $manufacturer->delete(); - } catch (PrestaShopException $e) { - throw new ManufacturerException(sprintf('An error occurred when deleting Manufacturer object with id "%s".', $manufacturer->id)); - } - } - - /** - * Toggles legacy manufacturer status - * - * @param Manufacturer $manufacturer - * @param bool $newStatus - * - * @return bool - * - * @throws ManufacturerException - */ - protected function toggleManufacturerStatus(Manufacturer $manufacturer, $newStatus) - { - $manufacturer->active = $newStatus; - - try { - return $manufacturer->save(); - } catch (PrestaShopException $e) { - throw new ManufacturerException(sprintf('An error occurred when updating manufacturer status with id "%s"', $manufacturer->id)); - } - } -} diff --git a/src/Adapter/Manufacturer/CommandHandler/AddManufacturerHandler.php b/src/Adapter/Manufacturer/CommandHandler/AddManufacturerHandler.php deleted file mode 100644 index f247cc0d..00000000 --- a/src/Adapter/Manufacturer/CommandHandler/AddManufacturerHandler.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Manufacturer\CommandHandler; - -use Manufacturer; -use PrestaShop\PrestaShop\Adapter\Manufacturer\AbstractManufacturerHandler; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\AddManufacturerCommand; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\CommandHandler\AddManufacturerHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\ManufacturerException; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\ValueObject\ManufacturerId; - -/** - * Handles command which adds new manufacturer using legacy object model - */ -final class AddManufacturerHandler extends AbstractManufacturerHandler implements AddManufacturerHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(AddManufacturerCommand $command) - { - $manufacturer = new Manufacturer(); - $this->fillLegacyManufacturerWithData($manufacturer, $command); - - try { - if (false === $manufacturer->validateFields(false)) { - throw new ManufacturerException('Manufacturer contains invalid field values'); - } - - if (!$manufacturer->add()) { - throw new ManufacturerException(sprintf('Failed to add new manufacturer "%s"', $command->getName())); - } - $this->addShopAssociation($manufacturer, $command); - } catch (\PrestaShopException $e) { - throw new ManufacturerException(sprintf('Failed to add new manufacturer "%s"', $command->getName())); - } - - return new ManufacturerId((int) $manufacturer->id); - } - - /** - * Add manufacturer and shop association - * - * @param Manufacturer $manufacturer - * @param AddManufacturerCommand $command - * - * @throws \PrestaShopDatabaseException - */ - private function addShopAssociation(Manufacturer $manufacturer, AddManufacturerCommand $command) - { - $this->associateWithShops( - $manufacturer, - $command->getShopAssociation() - ); - } - - /** - * @param Manufacturer $manufacturer - * @param AddManufacturerCommand $command - */ - private function fillLegacyManufacturerWithData(Manufacturer $manufacturer, AddManufacturerCommand $command) - { - $manufacturer->name = $command->getName(); - $manufacturer->short_description = $command->getLocalizedShortDescriptions(); - $manufacturer->description = $command->getLocalizedDescriptions(); - $manufacturer->meta_title = $command->getLocalizedMetaTitles(); - $manufacturer->meta_description = $command->getLocalizedMetaDescriptions(); - $manufacturer->meta_keywords = $command->getLocalizedMetaKeywords(); - $manufacturer->active = $command->isEnabled(); - } -} diff --git a/src/Adapter/Manufacturer/CommandHandler/BulkDeleteManufacturerHandler.php b/src/Adapter/Manufacturer/CommandHandler/BulkDeleteManufacturerHandler.php deleted file mode 100644 index 561d7c10..00000000 --- a/src/Adapter/Manufacturer/CommandHandler/BulkDeleteManufacturerHandler.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Manufacturer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\BulkDeleteManufacturerCommand; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\CommandHandler\BulkDeleteManufacturerHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\DeleteManufacturerException; - -/** - * Handles command which deletes manufacturers in bulk action - */ -final class BulkDeleteManufacturerHandler extends AbstractManufacturerCommandHandler implements BulkDeleteManufacturerHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(BulkDeleteManufacturerCommand $command) - { - foreach ($command->getManufacturerIds() as $manufacturerId) { - $manufacturer = $this->getManufacturer($manufacturerId); - - if (!$this->deleteManufacturer($manufacturer)) { - throw new DeleteManufacturerException(sprintf('Cannot delete Manufacturer object with id "%s".', $manufacturer->id), DeleteManufacturerException::FAILED_BULK_DELETE); - } - } - } -} diff --git a/src/Adapter/Manufacturer/CommandHandler/BulkToggleManufacturerStatusHandler.php b/src/Adapter/Manufacturer/CommandHandler/BulkToggleManufacturerStatusHandler.php deleted file mode 100644 index 59b510fc..00000000 --- a/src/Adapter/Manufacturer/CommandHandler/BulkToggleManufacturerStatusHandler.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Manufacturer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\BulkToggleManufacturerStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\CommandHandler\BulkToggleManufacturerStatusHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\UpdateManufacturerException; - -/** - * Handles command which toggles manufacturer status in bulk action - */ -final class BulkToggleManufacturerStatusHandler extends AbstractManufacturerCommandHandler implements BulkToggleManufacturerStatusHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(BulkToggleManufacturerStatusCommand $command) - { - foreach ($command->getManufacturerIds() as $manufacturerId) { - $manufacturer = $this->getManufacturer($manufacturerId); - - if (!$this->toggleManufacturerStatus($manufacturer, $command->getExpectedStatus())) { - throw new UpdateManufacturerException(sprintf('Unable to toggle manufacturer status with id "%s"', $manufacturer->id), UpdateManufacturerException::FAILED_BULK_UPDATE_STATUS); - } - } - } -} diff --git a/src/Adapter/Manufacturer/CommandHandler/DeleteManufacturerHandler.php b/src/Adapter/Manufacturer/CommandHandler/DeleteManufacturerHandler.php deleted file mode 100644 index 45d621b7..00000000 --- a/src/Adapter/Manufacturer/CommandHandler/DeleteManufacturerHandler.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Manufacturer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\DeleteManufacturerCommand; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\CommandHandler\DeleteManufacturerHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\DeleteManufacturerException; - -/** - * Handles command which deletes manufacturer using legacy object model - */ -final class DeleteManufacturerHandler extends AbstractManufacturerCommandHandler implements DeleteManufacturerHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(DeleteManufacturerCommand $command) - { - $manufacturer = $this->getManufacturer($command->getManufacturerId()); - - if (!$this->deleteManufacturer($manufacturer)) { - throw new DeleteManufacturerException(sprintf('Cannot delete Manufacturer object with id "%s".', $manufacturer->id), DeleteManufacturerException::FAILED_DELETE); - } - } -} diff --git a/src/Adapter/Manufacturer/CommandHandler/EditManufacturerHandler.php b/src/Adapter/Manufacturer/CommandHandler/EditManufacturerHandler.php deleted file mode 100644 index a44ca3d1..00000000 --- a/src/Adapter/Manufacturer/CommandHandler/EditManufacturerHandler.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Manufacturer\CommandHandler; - -use Manufacturer; -use PrestaShop\PrestaShop\Adapter\Manufacturer\AbstractManufacturerHandler; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\EditManufacturerCommand; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\CommandHandler\EditManufacturerHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\ManufacturerException; -use PrestaShopException; - -/** - * Handles command which edits manufacturer using legacy object model - */ -final class EditManufacturerHandler extends AbstractManufacturerHandler implements EditManufacturerHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws ManufacturerException - */ - public function handle(EditManufacturerCommand $command) - { - $manufacturerId = $command->getManufacturerId(); - $manufacturer = $this->getManufacturer($manufacturerId); - $this->populateManufacturerWithData($manufacturer, $command); - - try { - if (false === $manufacturer->validateFields(false)) { - throw new ManufacturerException('Manufacturer contains invalid field values'); - } - - if (!$manufacturer->update()) { - throw new ManufacturerException(sprintf('Cannot update manufacturer with id "%s"', $manufacturer->id)); - } - - if (null !== $command->getAssociatedShops()) { - $this->associateWithShops($manufacturer, $command->getAssociatedShops()); - } - } catch (PrestaShopException $e) { - throw new ManufacturerException(sprintf('Cannot update manufacturer with id "%s"', $manufacturer->id)); - } - } - - /** - * Populates Manufacturer object with given data - * - * @param Manufacturer $manufacturer - * @param EditManufacturerCommand $command - */ - private function populateManufacturerWithData(Manufacturer $manufacturer, EditManufacturerCommand $command) - { - if (null !== $command->getName()) { - $manufacturer->name = $command->getName(); - } - if (null !== $command->getLocalizedShortDescriptions()) { - $manufacturer->short_description = $command->getLocalizedShortDescriptions(); - } - if (null !== $command->getLocalizedDescriptions()) { - $manufacturer->description = $command->getLocalizedDescriptions(); - } - if (null !== $command->getLocalizedMetaDescriptions()) { - $manufacturer->meta_description = $command->getLocalizedMetaDescriptions(); - } - if (null !== $command->getLocalizedMetaKeywords()) { - $manufacturer->meta_keywords = $command->getLocalizedMetaKeywords(); - } - if (null !== $command->getLocalizedMetaTitles()) { - $manufacturer->meta_title = $command->getLocalizedMetaTitles(); - } - if (null !== $command->isEnabled()) { - $manufacturer->active = $command->isEnabled(); - } - } -} diff --git a/src/Adapter/Manufacturer/CommandHandler/ToggleManufacturerStatusHandler.php b/src/Adapter/Manufacturer/CommandHandler/ToggleManufacturerStatusHandler.php deleted file mode 100644 index d8f19099..00000000 --- a/src/Adapter/Manufacturer/CommandHandler/ToggleManufacturerStatusHandler.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Manufacturer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\ToggleManufacturerStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\CommandHandler\ToggleManufacturerStatusHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\UpdateManufacturerException; - -/** - * Handles command which toggles manufacturer status - */ -final class ToggleManufacturerStatusHandler extends AbstractManufacturerCommandHandler implements ToggleManufacturerStatusHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(ToggleManufacturerStatusCommand $command) - { - $manufacturer = $this->getManufacturer($command->getManufacturerId()); - - if (!$this->toggleManufacturerStatus($manufacturer, $command->getExpectedStatus())) { - throw new UpdateManufacturerException(sprintf('Unable to toggle manufacturer status with id "%s"', $manufacturer->id), UpdateManufacturerException::FAILED_UPDATE_STATUS); - } - } -} diff --git a/src/Adapter/Manufacturer/ManufacturerDataProvider.php b/src/Adapter/Manufacturer/ManufacturerDataProvider.php deleted file mode 100644 index a48c8dbf..00000000 --- a/src/Adapter/Manufacturer/ManufacturerDataProvider.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Manufacturer; - -use Manufacturer; - -/** - * This class will provide data from DB / ORM about Manufacturer. - */ -class ManufacturerDataProvider -{ - /** - * Get all Manufacturer. - * - * @param bool $get_nb_products - * @param int $id_lang - * @param bool $active - * @param bool $p - * @param bool $n - * @param bool $all_group - * @param bool $group_by - * - * @return array Manufacturer - */ - public function getManufacturers($get_nb_products = false, $id_lang = 0, $active = true, $p = false, $n = false, $all_group = false, $group_by = false) - { - return Manufacturer::getManufacturers($get_nb_products, $id_lang, $active, $p, $n, $all_group, $group_by); - } -} diff --git a/src/Adapter/Manufacturer/ManufacturerLogoThumbnailProvider.php b/src/Adapter/Manufacturer/ManufacturerLogoThumbnailProvider.php deleted file mode 100644 index a02b4a94..00000000 --- a/src/Adapter/Manufacturer/ManufacturerLogoThumbnailProvider.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Manufacturer; - -use HelperList; -use ImageManager; -use PrestaShop\PrestaShop\Core\Image\ImageProviderInterface; -use PrestaShop\PrestaShop\Core\Image\Parser\ImageTagSourceParserInterface; - -/** - * Provides path for manufacturer logo thumbnail - */ -final class ManufacturerLogoThumbnailProvider implements ImageProviderInterface -{ - /** - * @var ImageTagSourceParserInterface - */ - private $imageTagSourceParser; - - /** - * @param ImageTagSourceParserInterface $imageTagSourceParser - */ - public function __construct( - ImageTagSourceParserInterface $imageTagSourceParser - ) { - $this->imageTagSourceParser = $imageTagSourceParser; - } - - /** - * {@inheritdoc} - */ - public function getPath($manufacturerId) - { - $pathToImage = _PS_MANU_IMG_DIR_ . $manufacturerId . '.jpg'; - - $imageTag = ImageManager::thumbnail( - $pathToImage, - 'manufacturer_mini_' . $manufacturerId . '.jpg', - HelperList::LIST_THUMBNAIL_SIZE - ); - - return $this->imageTagSourceParser->parse($imageTag); - } -} diff --git a/src/Adapter/Manufacturer/ManufacturerProductSearchProvider.php b/src/Adapter/Manufacturer/ManufacturerProductSearchProvider.php deleted file mode 100644 index 1a2ff749..00000000 --- a/src/Adapter/Manufacturer/ManufacturerProductSearchProvider.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Manufacturer; - -use Manufacturer; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchProviderInterface; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchResult; -use PrestaShop\PrestaShop\Core\Product\Search\SortOrderFactory; -use Symfony\Component\Translation\TranslatorInterface; - -class ManufacturerProductSearchProvider implements ProductSearchProviderInterface -{ - private $translator; - private $manufacturer; - private $sortOrderFactory; - - public function __construct( - TranslatorInterface $translator, - Manufacturer $manufacturer - ) { - $this->translator = $translator; - $this->manufacturer = $manufacturer; - $this->sortOrderFactory = new SortOrderFactory($this->translator); - } - - /** - * @param ProductSearchContext $context - * @param ProductSearchQuery $query - * @param string $type - * - * @return array|bool - */ - private function getProductsOrCount( - ProductSearchContext $context, - ProductSearchQuery $query, - $type = 'products' - ) { - return $this->manufacturer->getProducts( - $this->manufacturer->id, - $context->getIdLang(), - $query->getPage(), - $query->getResultsPerPage(), - $query->getSortOrder()->toLegacyOrderBy(), - $query->getSortOrder()->toLegacyOrderWay(), - $type !== 'products' - ); - } - - /** - * @param ProductSearchContext $context - * @param ProductSearchQuery $query - * - * @return ProductSearchResult - */ - public function runQuery( - ProductSearchContext $context, - ProductSearchQuery $query - ) { - $products = $this->getProductsOrCount($context, $query, 'products'); - $count = $this->getProductsOrCount($context, $query, 'count'); - - $result = new ProductSearchResult(); - - if (!empty($products)) { - $result - ->setProducts($products) - ->setTotalProductsCount($count); - - $result->setAvailableSortOrders( - $this->sortOrderFactory->getDefaultSortOrders() - ); - } - - return $result; - } -} diff --git a/src/Adapter/Manufacturer/QueryHandler/GetManufacturerForEditingHandler.php b/src/Adapter/Manufacturer/QueryHandler/GetManufacturerForEditingHandler.php deleted file mode 100644 index 1adb4725..00000000 --- a/src/Adapter/Manufacturer/QueryHandler/GetManufacturerForEditingHandler.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Manufacturer\QueryHandler; - -use ImageManager; -use PrestaShop\PrestaShop\Adapter\Manufacturer\AbstractManufacturerHandler; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Query\GetManufacturerForEditing; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\QueryHandler\GetManufacturerForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\QueryResult\EditableManufacturer; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\ValueObject\ManufacturerId; -use PrestaShop\PrestaShop\Core\Image\Parser\ImageTagSourceParserInterface; - -/** - * Handles query which gets manufacturer for editing - */ -final class GetManufacturerForEditingHandler extends AbstractManufacturerHandler implements GetManufacturerForEditingHandlerInterface -{ - /** - * @var ImageTagSourceParserInterface - */ - private $imageTagSourceParser; - - public function __construct( - ImageTagSourceParserInterface $imageTagSourceParser - ) { - $this->imageTagSourceParser = $imageTagSourceParser; - } - - /** - * {@inheritdoc} - */ - public function handle(GetManufacturerForEditing $query) - { - $manufacturerId = $query->getManufacturerId(); - $manufacturer = $this->getManufacturer($manufacturerId); - - return new EditableManufacturer( - $manufacturerId, - $manufacturer->name, - (bool) $manufacturer->active, - $manufacturer->short_description, - $manufacturer->description, - $manufacturer->meta_title, - $manufacturer->meta_description, - $manufacturer->meta_keywords, - $this->getLogoImage($manufacturerId), - $manufacturer->getAssociatedShops() - ); - } - - /** - * @param ManufacturerId $manufacturerId - * - * @return array|null - */ - private function getLogoImage(ManufacturerId $manufacturerId) - { - $pathToImage = _PS_MANU_IMG_DIR_ . $manufacturerId->getValue() . '.jpg'; - $imageTag = ImageManager::thumbnail( - $pathToImage, - 'manufacturer_' . $manufacturerId->getValue() . '.jpg', - 350, - 'jpg', - true, - true - ); - - $imageSize = file_exists($pathToImage) ? filesize($pathToImage) / 1000 : ''; - - if (empty($imageTag) || empty($imageSize)) { - return null; - } - - return [ - 'size' => sprintf('%skB', $imageSize), - 'path' => $this->imageTagSourceParser->parse($imageTag), - ]; - } -} diff --git a/src/Adapter/Manufacturer/QueryHandler/GetManufacturerForViewingHandler.php b/src/Adapter/Manufacturer/QueryHandler/GetManufacturerForViewingHandler.php deleted file mode 100644 index 9d36539c..00000000 --- a/src/Adapter/Manufacturer/QueryHandler/GetManufacturerForViewingHandler.php +++ /dev/null @@ -1,163 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Manufacturer\QueryHandler; - -use Manufacturer; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\ManufacturerNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Query\GetManufacturerForViewing; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\QueryHandler\GetManufacturerForViewingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\QueryResult\ViewableManufacturer; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\ValueObject\ManufacturerId; -use Product; - -/** - * Handles getting manufacturer for viewing query using legacy object model - */ -final class GetManufacturerForViewingHandler implements GetManufacturerForViewingHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GetManufacturerForViewing $query) - { - $manufacturer = $this->getManufacturer($query->getManufacturerId()); - - return new ViewableManufacturer( - $manufacturer->name, - $this->getManufacturerAddresses($manufacturer, $query->getLanguageId()), - $this->getManufacturerProducts($manufacturer, $query->getLanguageId()) - ); - } - - /** - * @param ManufacturerId $manufacturerId - * - * @return Manufacturer - */ - private function getManufacturer(ManufacturerId $manufacturerId) - { - $manufacturer = new Manufacturer($manufacturerId->getValue()); - - if ($manufacturer->id !== $manufacturerId->getValue()) { - throw new ManufacturerNotFoundException(sprintf('Manufacturer with id "%s" was not found.', $manufacturerId->getValue())); - } - - return $manufacturer; - } - - /** - * @param Manufacturer $manufacturer - * @param LanguageId $languageId - * - * @return array - */ - private function getManufacturerProducts(Manufacturer $manufacturer, LanguageId $languageId) - { - $products = []; - $manufacturerProducts = $manufacturer->getProductsLite($languageId->getValue()); - - foreach ($manufacturerProducts as $productData) { - $product = new Product($productData['id_product'], false, $languageId->getValue()); - $product->loadStockData(); - - $productCombinations = $product->getAttributeCombinations($languageId->getValue()); - $combinations = []; - - foreach ($productCombinations as $combination) { - $attributeId = $combination['id_product_attribute']; - - if (!isset($combinations[$attributeId])) { - $combinations[$attributeId] = [ - 'reference' => $combination['reference'], - 'ean13' => $combination['ean13'], - 'upc' => $combination['upc'], - 'mpn' => $combination['mpn'], - 'quantity' => $combination['quantity'], - 'attributes' => '', - ]; - } - - $attribute = sprintf( - '%s - %s', - $combination['group_name'], - $combination['attribute_name'] - ); - - if (!empty($combinations[$attributeId]['attributes'])) { - $attribute = sprintf(', %s', $attribute); - } - - $combinations[$attributeId]['attributes'] .= $attribute; - } - - $products[] = [ - 'id' => $product->id, - 'name' => $product->name, - 'reference' => $product->reference, - 'ean13' => $product->ean13, - 'upc' => $product->upc, - 'mpn' => $product->mpn, - 'quantity' => $product->quantity, - 'combinations' => $combinations, - ]; - } - - return $products; - } - - /** - * @param Manufacturer $manufacturer - * @param LanguageId $languageId - * - * @return array - */ - private function getManufacturerAddresses(Manufacturer $manufacturer, LanguageId $languageId) - { - $addresses = []; - $manufacturerAddresses = $manufacturer->getAddresses($languageId->getValue()); - - foreach ($manufacturerAddresses as $address) { - $addresses[] = [ - 'id' => $address['id_address'], - 'first_name' => $address['firstname'], - 'last_name' => $address['lastname'], - 'address1' => $address['address1'], - 'address2' => $address['address2'], - 'postcode' => $address['postcode'], - 'city' => $address['city'], - 'state' => $address['state'], - 'country' => $address['country'], - 'phone' => $address['phone'], - 'phone_mobile' => $address['phone_mobile'], - 'other' => $address['other'], - ]; - } - - return $addresses; - } -} diff --git a/src/Adapter/Media/MediaServerConfiguration.php b/src/Adapter/Media/MediaServerConfiguration.php deleted file mode 100644 index 87e187c3..00000000 --- a/src/Adapter/Media/MediaServerConfiguration.php +++ /dev/null @@ -1,143 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Media; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * This class will provide Media servers configuration for a Shop. - */ -class MediaServerConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'media_server_one' => $this->configuration->get('PS_MEDIA_SERVER_1'), - 'media_server_two' => $this->configuration->get('PS_MEDIA_SERVER_2'), - 'media_server_three' => $this->configuration->get('PS_MEDIA_SERVER_3'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - $errors = []; - $isValid = $this->validateConfiguration($configuration); - if (true === $isValid) { - $serverOne = $configuration['media_server_one']; - $serverTwo = $configuration['media_server_two']; - $serverThree = $configuration['media_server_three']; - - $this->configuration->set('PS_MEDIA_SERVER_1', $serverOne); - $this->configuration->set('PS_MEDIA_SERVER_2', $serverTwo); - $this->configuration->set('PS_MEDIA_SERVER_3', $serverThree); - - if (!empty($serverOne) || !empty($serverTwo) || !empty($serverThree)) { - $this->configuration->set('PS_MEDIA_SERVERS', 1); - } else { - $this->configuration->set('PS_MEDIA_SERVERS', 0); - } - } else { - $errors = $isValid; - } - - return $errors; - } - - /** - * {@inheritdoc} - * - * @todo: when PHP minimum version will be 7.1, use "FILTER_VALIDATE_DOMAIN" constraint. - */ - public function validateConfiguration(array $configuration) - { - $errors = []; - $serverOne = $configuration['media_server_one']; - $serverTwo = $configuration['media_server_two']; - $serverThree = $configuration['media_server_three']; - - if (!empty($serverOne) && !$this->isValidDomain($serverOne)) { - $errors[] = [ - 'key' => 'Media server #1 is invalid', - 'domain' => 'Admin.Advparameters.Notification', - 'parameters' => [], - ]; - } - - if (!empty($serverTwo) && !$this->isValidDomain($serverTwo)) { - $errors[] = [ - 'key' => 'Media server #2 is invalid', - 'domain' => 'Admin.Advparameters.Notification', - 'parameters' => [], - ]; - } - - if (!empty($serverThree) && !$this->isValidDomain($serverThree)) { - $errors[] = [ - 'key' => 'Media server #3 is invalid', - 'domain' => 'Admin.Advparameters.Notification', - 'parameters' => [], - ]; - } - - if (count($errors) > 0) { - return $errors; - } - - return true; - } - - /** - * To be removed once the minimum version is PHP 7.1. - * - * @param $domainName - * - * @return bool - */ - private function isValidDomain($domainName) - { - $ip = gethostbyname($domainName); - - return false !== filter_var($ip, FILTER_VALIDATE_IP); - } -} diff --git a/src/Adapter/Meta/CommandHandler/AddMetaHandler.php b/src/Adapter/Meta/CommandHandler/AddMetaHandler.php deleted file mode 100644 index 7cf16394..00000000 --- a/src/Adapter/Meta/CommandHandler/AddMetaHandler.php +++ /dev/null @@ -1,174 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Meta\CommandHandler; - -use Meta; -use PrestaShop\PrestaShop\Adapter\Meta\MetaDataProvider; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\DefaultLanguage; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\IsUrlRewrite; -use PrestaShop\PrestaShop\Core\Domain\Meta\Command\AddMetaCommand; -use PrestaShop\PrestaShop\Core\Domain\Meta\CommandHandler\AddMetaHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\CannotAddMetaException; -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaException; -use PrestaShop\PrestaShop\Core\Domain\Meta\ValueObject\MetaId; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopException; -use Symfony\Component\Validator\Validator\ValidatorInterface; - -/** - * Class SaveMetaHandler is responsible for saving meta data. - * - * @internal - */ -final class AddMetaHandler implements AddMetaHandlerInterface -{ - /** - * @var HookDispatcherInterface - */ - private $hookDispatcher; - - /** - * @var int - */ - private $defaultLanguageId; - - /** - * @var ValidatorInterface - */ - private $validator; - - /** - * @var MetaDataProvider - */ - private $metaDataProvider; - - /** - * @param HookDispatcherInterface $hookDispatcher - * @param ValidatorInterface $validator - * @param int $defaultLanguageId - * @param MetaDataProvider $metaDataProvider - */ - public function __construct( - HookDispatcherInterface $hookDispatcher, - ValidatorInterface $validator, - $defaultLanguageId, - MetaDataProvider $metaDataProvider - ) { - $this->hookDispatcher = $hookDispatcher; - $this->defaultLanguageId = $defaultLanguageId; - $this->validator = $validator; - $this->metaDataProvider = $metaDataProvider; - } - - /** - * {@inheritdoc} - * - * @throws CannotAddMetaException - * @throws MetaException - */ - public function handle(AddMetaCommand $command) - { - $this->assertUrlRewriteHasDefaultLanguage($command); - $this->assertIsUrlRewriteValid($command); - $this->assertIsValidPageName($command); - - try { - $entity = new Meta(); - $entity->page = $command->getPageName()->getValue(); - $entity->title = $command->getLocalisedPageTitles(); - $entity->description = $command->getLocalisedMetaDescription(); - $entity->keywords = $command->getLocalisedMetaKeywords(); - - $rewriteUrls = $command->getLocalisedRewriteUrls(); - foreach ($rewriteUrls as $idLang => $rewriteUrl) { - if (!$rewriteUrl) { - $rewriteUrls[$idLang] = $rewriteUrls[$this->defaultLanguageId]; - } - } - - $entity->url_rewrite = $rewriteUrls; - $entity->add(); - - if (0 >= $entity->id) { - throw new CannotAddMetaException(sprintf('Invalid entity id after creation: %s', $entity->id)); - } - } catch (PrestaShopException $exception) { - throw new MetaException('Failed to create meta entity', 0, $exception); - } - - $this->hookDispatcher->dispatchWithParameters('actionAdminMetaSave'); - - return new MetaId((int) $entity->id); - } - - /** - * @param AddMetaCommand $command - * - * @throws MetaConstraintException - */ - private function assertUrlRewriteHasDefaultLanguage(AddMetaCommand $command) - { - $urlRewriteErrors = $this->validator->validate( - $command->getLocalisedRewriteUrls(), - new DefaultLanguage() - ); - - if (0 !== count($urlRewriteErrors) && 'index' !== $command->getPageName()->getValue()) { - throw new MetaConstraintException('The url rewrite is missing for the default language when creating new meta record', MetaConstraintException::INVALID_URL_REWRITE); - } - } - - /** - * @param AddMetaCommand $command - * - * @throws MetaConstraintException - */ - private function assertIsUrlRewriteValid(AddMetaCommand $command) - { - foreach ($command->getLocalisedRewriteUrls() as $idLang => $rewriteUrl) { - $errors = $this->validator->validate($rewriteUrl, new IsUrlRewrite()); - - if (0 !== count($errors)) { - throw new MetaConstraintException(sprintf('Url rewrite %s for language with id %s is not valid', $rewriteUrl, $idLang), MetaConstraintException::INVALID_URL_REWRITE); - } - } - } - - /** - * @param AddMetaCommand $command - * - * @throws MetaConstraintException - */ - private function assertIsValidPageName(AddMetaCommand $command) - { - $availablePages = $this->metaDataProvider->getAvailablePages(); - if (!in_array($command->getPageName()->getValue(), $availablePages, true)) { - throw new MetaConstraintException(sprintf('Given page name %s is not available. Available values are %s', $command->getPageName()->getValue(), var_export($availablePages, true)), MetaConstraintException::INVALID_PAGE_NAME); - } - } -} diff --git a/src/Adapter/Meta/CommandHandler/EditMetaHandler.php b/src/Adapter/Meta/CommandHandler/EditMetaHandler.php deleted file mode 100644 index 8fb5c9d7..00000000 --- a/src/Adapter/Meta/CommandHandler/EditMetaHandler.php +++ /dev/null @@ -1,168 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Meta\CommandHandler; - -use Meta; -use PrestaShop\PrestaShop\Adapter\Meta\MetaDataProvider; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\DefaultLanguage; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\IsUrlRewrite; -use PrestaShop\PrestaShop\Core\Domain\Meta\Command\EditMetaCommand; -use PrestaShop\PrestaShop\Core\Domain\Meta\CommandHandler\EditMetaHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\CannotEditMetaException; -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaException; -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaNotFoundException; -use PrestaShopException; -use Symfony\Component\Validator\Validator\ValidatorInterface; - -/** - * Class EditMetaHandler is responsible for editing meta data. - * - * @internal - */ -final class EditMetaHandler implements EditMetaHandlerInterface -{ - /** - * @var ValidatorInterface - */ - private $validator; - - /** - * @var MetaDataProvider - */ - private $metaDataProvider; - - /** - * @param ValidatorInterface $validator - * @param MetaDataProvider $metaDataProvider - */ - public function __construct( - ValidatorInterface $validator, - MetaDataProvider $metaDataProvider - ) { - $this->validator = $validator; - $this->metaDataProvider = $metaDataProvider; - } - - /** - * {@inheritdoc} - * - * @throws MetaException - */ - public function handle(EditMetaCommand $command) - { - try { - $entity = new Meta($command->getMetaId()->getValue()); - - if (0 >= $entity->id) { - throw new MetaNotFoundException(sprintf('Meta with id "%s" was not found for edit', $command->getMetaId()->getValue())); - } - - if (null !== $command->getPageName()) { - $this->assertIsValidPageName($entity->page, $command); - $entity->page = $command->getPageName()->getValue(); - } - - if (null !== $command->getLocalisedRewriteUrls()) { - $entity->url_rewrite = $command->getLocalisedRewriteUrls(); - } - - if (null !== $command->getLocalisedPageTitles()) { - $entity->title = $command->getLocalisedPageTitles(); - } - - if (null !== $command->getLocalisedMetaDescriptions()) { - $entity->description = $command->getLocalisedMetaDescriptions(); - } - - if (null !== $command->getLocalisedMetaKeywords()) { - $entity->keywords = $command->getLocalisedMetaKeywords(); - } - - $this->assertUrlRewriteHasDefaultLanguage($entity); - $this->assertIsUrlRewriteValid($entity); - - if (false === $entity->update()) { - throw new CannotEditMetaException(sprintf('Error occurred when updating Meta with id "%s"', $command->getMetaId()->getValue())); - } - } catch (PrestaShopException $exception) { - throw new CannotEditMetaException(sprintf('Error occurred when updating Meta with id "%s"', $command->getMetaId()->getValue()), 0, $exception); - } - } - - /** - * @param Meta $entity - * - * @throws MetaConstraintException - */ - private function assertUrlRewriteHasDefaultLanguage(Meta $entity) - { - $urlRewriteErrors = $this->validator->validate( - $entity->url_rewrite, - new DefaultLanguage() - ); - - if ('index' !== $entity->page && 0 !== count($urlRewriteErrors)) { - throw new MetaConstraintException('The url rewrite is missing for the default language when editing meta record', MetaConstraintException::INVALID_URL_REWRITE); - } - } - - /** - * @param Meta $entity - * - * @throws MetaConstraintException - */ - private function assertIsUrlRewriteValid(Meta $entity) - { - foreach ($entity->url_rewrite as $idLang => $rewriteUrl) { - $errors = $this->validator->validate($rewriteUrl, new IsUrlRewrite()); - - if (0 !== count($errors)) { - throw new MetaConstraintException(sprintf('Url rewrite %s for language with id %s is not valid', $rewriteUrl, $idLang), MetaConstraintException::INVALID_URL_REWRITE); - } - } - } - - /** - * @param $alreadyExistingPage - * @param EditMetaCommand $command - * - * @throws MetaConstraintException - */ - private function assertIsValidPageName($alreadyExistingPage, EditMetaCommand $command) - { - if ($command->getPageName()->getValue() === $alreadyExistingPage) { - return; - } - - $availablePages = $this->metaDataProvider->getAvailablePages(); - - if (!in_array($command->getPageName()->getValue(), $availablePages, true)) { - throw new MetaConstraintException(sprintf('Given page name %s is not available. Available values are %s', $command->getPageName()->getValue(), var_export($availablePages, true)), MetaConstraintException::INVALID_PAGE_NAME); - } - } -} diff --git a/src/Adapter/Meta/MetaDataProvider.php b/src/Adapter/Meta/MetaDataProvider.php deleted file mode 100644 index 8cf2d562..00000000 --- a/src/Adapter/Meta/MetaDataProvider.php +++ /dev/null @@ -1,143 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Meta; - -use Db; -use DbQuery; -use Meta; -use PrestaShop\PrestaShop\Core\Meta\MetaDataProviderInterface; - -/** - * Class MetaDataProvider is responsible for providing data related with meta entity. - */ -class MetaDataProvider implements MetaDataProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getIdByPage($pageName) - { - $query = new DbQuery(); - $query->select('`id_meta`'); - $query->from('meta'); - $query->where('`page`= "' . pSQL($pageName) . '"'); - - $idMeta = 0; - $result = Db::getInstance()->getValue($query); - - if ($result) { - $idMeta = $result; - } - - return $idMeta; - } - - /** - * @return array - */ - public function getAvailablePages() - { - return Meta::getPages(true); - } - - /** - * {@inheritdoc} - */ - public function getDefaultMetaPageNameById($metaId) - { - $query = new DbQuery(); - $query->select('`page`'); - $query->from('meta'); - $query->where('`id_meta`=' . (int) $metaId); - $query->where('`page` NOT LIKE "module-%"'); - $result = Db::getInstance()->getValue($query); - - return is_string($result) ? $result : null; - } - - /** - * {@inheritdoc} - */ - public function getModuleMetaPageNameById($metaId) - { - $query = new DbQuery(); - $query->select('`page`'); - $query->from('meta'); - $query->where('`id_meta`=' . (int) $metaId); - $query->where('`page` LIKE "module-%"'); - - $result = Db::getInstance()->getValue($query); - - return is_string($result) ? $result : null; - } - - /** - * {@inheritdoc} - */ - public function getDefaultMetaPageNamesExcludingFilled() - { - $pages = Meta::getPages(true); - - $result = []; - foreach ($pages as $pageName => $fileName) { - if (!$this->isModuleFile($fileName)) { - $result[$pageName] = $fileName; - } - } - - return $result; - } - - /** - * {@inheritdoc} - */ - public function getNotConfiguredModuleMetaPageNames() - { - $pages = Meta::getPages(true); - - $result = []; - foreach ($pages as $pageName => $fileName) { - if ($this->isModuleFile($fileName)) { - $result[$pageName] = $fileName; - } - } - - return $result; - } - - /** - * Checks whenever the file contains module file pattern. - * - * @param string $fileName - * - * @return bool - */ - private function isModuleFile($fileName) - { - return 0 === strncmp($fileName, 'module-', 7); - } -} diff --git a/src/Adapter/Meta/MetaEraser.php b/src/Adapter/Meta/MetaEraser.php deleted file mode 100644 index b3e27e16..00000000 --- a/src/Adapter/Meta/MetaEraser.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Meta; - -use Meta; -use PrestaShopCollection; -use PrestaShopException; - -/** - * Class MetaEraser is responsible for removing data from meta entity. - */ -final class MetaEraser -{ - /** - * Erases data from meta entity. - * - * @param array $metaIds - * - * @return array - * - * @throws PrestaShopException - */ - public function erase(array $metaIds) - { - $errors = []; - - if (empty($metaIds)) { - $errors[] = [ - 'key' => 'You must select at least one element to delete.', - 'parameters' => [], - 'domain' => 'Admin.Notifications.Error', - ]; - - return $errors; - } - - $metaData = new PrestaShopCollection(Meta::class); - $metaData->where('id_meta', 'in', $metaIds); - - /** @var Meta $item */ - foreach ($metaData->getResults() as $item) { - if (!$item->delete()) { - $errors[] = [ - 'key' => 'Can\'t delete #%id%', - 'parameters' => [ - '%id%' => $item->id, - ], - 'domain' => 'Admin.Notifications.Error', - ]; - - continue; - } - } - - return $errors; - } -} diff --git a/src/Adapter/Meta/QueryHandler/GetMetaForEditingHandler.php b/src/Adapter/Meta/QueryHandler/GetMetaForEditingHandler.php deleted file mode 100644 index 6d47a77d..00000000 --- a/src/Adapter/Meta/QueryHandler/GetMetaForEditingHandler.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Meta\QueryHandler; - -use Meta; -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Meta\Query\GetMetaForEditing; -use PrestaShop\PrestaShop\Core\Domain\Meta\QueryHandler\GetMetaForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Meta\QueryResult\EditableMeta; - -/** - * Class GetMetaForEditingHandler is responsible for retrieving meta data. - * - * @internal - */ -final class GetMetaForEditingHandler implements GetMetaForEditingHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws MetaNotFoundException - */ - public function handle(GetMetaForEditing $query) - { - $metaId = $query->getMetaId(); - - $entity = new Meta($metaId->getValue()); - - if (0 >= $entity->id) { - throw new MetaNotFoundException(sprintf('Meta with id "%s" cannot be found', $metaId->getValue())); - } - - if ((int) $entity->id !== $metaId->getValue()) { - throw new MetaNotFoundException(sprintf('The retrieved id "%s" does not match requested Meta id "%s"', $entity->id, $metaId->getValue())); - } - - return new EditableMeta( - $metaId->getValue(), - $entity->page, - $entity->title, - $entity->description, - $entity->keywords, - $entity->url_rewrite - ); - } -} diff --git a/src/Adapter/Meta/QueryHandler/GetPagesForLayoutCustomizationHandler.php b/src/Adapter/Meta/QueryHandler/GetPagesForLayoutCustomizationHandler.php deleted file mode 100644 index 78cd3adb..00000000 --- a/src/Adapter/Meta/QueryHandler/GetPagesForLayoutCustomizationHandler.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Meta\QueryHandler; - -use Meta; -use PrestaShop\PrestaShop\Core\Domain\Meta\Query\GetPagesForLayoutCustomization; -use PrestaShop\PrestaShop\Core\Domain\Meta\QueryHandler\GetPagesForLayoutCustomizationHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Meta\QueryResult\LayoutCustomizationPage; - -/** - * Class GetMetaPagesListHandler. - */ -final class GetPagesForLayoutCustomizationHandler implements GetPagesForLayoutCustomizationHandlerInterface -{ - /** - * @var int - */ - private $contextLangId; - - /** - * @param int $contextLangId - */ - public function __construct($contextLangId) - { - $this->contextLangId = $contextLangId; - } - - /** - * {@inheritdoc} - */ - public function handle(GetPagesForLayoutCustomization $query) - { - $metas = Meta::getAllMeta($this->contextLangId); - $pages = []; - - foreach ($metas as $meta) { - $pages[] = new LayoutCustomizationPage( - $meta['page'], - $meta['title'], - $meta['description'] - ); - } - - return $pages; - } -} diff --git a/src/Adapter/Meta/SEOOptionsDataConfiguration.php b/src/Adapter/Meta/SEOOptionsDataConfiguration.php deleted file mode 100644 index 395e8448..00000000 --- a/src/Adapter/Meta/SEOOptionsDataConfiguration.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Meta; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -class SEOOptionsDataConfiguration implements DataConfigurationInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'product_attributes_in_title' => $this->configuration->get('PS_PRODUCT_ATTRIBUTES_IN_TITLE'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - $errors = []; - try { - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_PRODUCT_ATTRIBUTES_IN_TITLE', $configuration['product_attributes_in_title']); - } - } catch (CoreException $exception) { - $errors[] = $exception->getMessage(); - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['product_attributes_in_title'] - ); - } -} diff --git a/src/Adapter/Meta/SetUpUrlsDataConfiguration.php b/src/Adapter/Meta/SetUpUrlsDataConfiguration.php deleted file mode 100644 index 44f9750e..00000000 --- a/src/Adapter/Meta/SetUpUrlsDataConfiguration.php +++ /dev/null @@ -1,145 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Meta; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\File\HtaccessFileGenerator; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class SetUpUrlsDataConfiguration is responsible for saving, validating and getting configurations related with urls - * configuration located in Shop parameters -> Traffic & Seo -> Seo & Urls. - */ -final class SetUpUrlsDataConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - /** - * @var HtaccessFileGenerator - */ - private $htaccessFileGenerator; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * SetUpUrlsDataConfiguration constructor. - * - * @param Configuration $configuration - * @param HtaccessFileGenerator $htaccessFileGenerator - * @param TranslatorInterface $translator - */ - public function __construct( - Configuration $configuration, - HtaccessFileGenerator $htaccessFileGenerator, - TranslatorInterface $translator - ) { - $this->configuration = $configuration; - $this->htaccessFileGenerator = $htaccessFileGenerator; - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'friendly_url' => $this->configuration->getBoolean('PS_REWRITING_SETTINGS'), - 'accented_url' => $this->configuration->getBoolean('PS_ALLOW_ACCENTED_CHARS_URL'), - 'canonical_url_redirection' => $this->configuration->get('PS_CANONICAL_REDIRECT'), - 'disable_apache_multiview' => $this->configuration->getBoolean('PS_HTACCESS_DISABLE_MULTIVIEWS'), - 'disable_apache_mod_security' => $this->configuration->getBoolean('PS_HTACCESS_DISABLE_MODSEC'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - $errors = []; - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_REWRITING_SETTINGS', $configuration['friendly_url']); - $this->configuration->set('PS_ALLOW_ACCENTED_CHARS_URL', $configuration['accented_url']); - $this->configuration->set('PS_CANONICAL_REDIRECT', $configuration['canonical_url_redirection']); - $this->configuration->set('PS_HTACCESS_DISABLE_MULTIVIEWS', $configuration['disable_apache_multiview']); - $this->configuration->set('PS_HTACCESS_DISABLE_MODSEC', $configuration['disable_apache_mod_security']); - - if (!$this->htaccessFileGenerator->generateFile($configuration['disable_apache_multiview'])) { - $this->configuration->set('PS_REWRITING_SETTINGS', 0); - - $errorMessage = $this->translator - ->trans( - 'Before being able to use this tool, you need to:', - [], - 'Admin.Shopparameters.Notification' - ); - - $errorMessage .= ' '; - $errorMessage .= $this->translator - ->trans( - 'Create a blank .htaccess in your root directory.', - [], - 'Admin.Shopparameters.Notification' - ); - - $errorMessage .= ' '; - $errorMessage .= $this->translator - ->trans( - 'Give it write permissions (CHMOD 666 on Unix system).', - [], - 'Admin.Shopparameters.Notification' - ); - - $errors[] = $errorMessage; - } - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['friendly_url'], - $configuration['accented_url'], - $configuration['canonical_url_redirection'], - $configuration['disable_apache_multiview'], - $configuration['disable_apache_mod_security'] - ); - } -} diff --git a/src/Adapter/Meta/ShopUrlDataConfiguration.php b/src/Adapter/Meta/ShopUrlDataConfiguration.php deleted file mode 100644 index 64c9d0d3..00000000 --- a/src/Adapter/Meta/ShopUrlDataConfiguration.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Meta; - -use PrestaShop\PrestaShop\Adapter\File\HtaccessFileGenerator; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShopException; -use ShopUrl; - -/** - * Class ShopUrlDataConfiguration is responsible for updating and getting data from shop_url table. - */ -final class ShopUrlDataConfiguration implements DataConfigurationInterface -{ - /** - * @var ShopUrl - */ - private $mainShopUrl; - - /** - * @var HtaccessFileGenerator - */ - private $htaccessFileGenerator; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * ShopUrlDataConfiguration constructor. - * - * @param ShopUrl $mainShopUrl - * @param ConfigurationInterface $configuration - */ - public function __construct( - ShopUrl $mainShopUrl, - ConfigurationInterface $configuration, - HtaccessFileGenerator $htaccessFileGenerator - ) { - $this->mainShopUrl = $mainShopUrl; - $this->configuration = $configuration; - $this->htaccessFileGenerator = $htaccessFileGenerator; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'domain' => $this->mainShopUrl->domain, - 'domain_ssl' => $this->mainShopUrl->domain_ssl, - 'physical_uri' => $this->mainShopUrl->physical_uri, - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - $errors = []; - - try { - if ($this->validateConfiguration($configuration)) { - $this->mainShopUrl->domain = $configuration['domain']; - $this->mainShopUrl->domain_ssl = $configuration['domain_ssl']; - - if (is_string($configuration['physical_uri'])) { - $this->mainShopUrl->physical_uri = $configuration['physical_uri']; - } - - $this->mainShopUrl->update(); - - $this->configuration->set('PS_SHOP_DOMAIN', $configuration['domain']); - $this->configuration->set('PS_SHOP_DOMAIN_SSL', $configuration['domain_ssl']); - $this->htaccessFileGenerator->generateFile(); - } - } catch (PrestaShopException $exception) { - $errors[] = $exception->getMessage(); - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['domain'], - $configuration['domain_ssl'] - ) && $this->isValidUri($configuration['physical_uri']); - } - - /** - * Check if it's a valid URI. - * - * @param string $uri - * - * @return bool - */ - private function isValidUri($uri) - { - return preg_match('#^(?:[~\-_\/&\.]|\w|%\d+|\s)+$#', $uri); - } -} diff --git a/src/Adapter/Meta/UrlSchemaDataConfiguration.php b/src/Adapter/Meta/UrlSchemaDataConfiguration.php deleted file mode 100644 index 78722fb2..00000000 --- a/src/Adapter/Meta/UrlSchemaDataConfiguration.php +++ /dev/null @@ -1,137 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Meta; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; - -/** - * Class UrlSchemaDataConfiguration is responsible for validating, updating and retrieving data used in - * Shop parameters -> Traffix & Seo -> Seo & Urls -> Set Shop URL form field. - */ -final class UrlSchemaDataConfiguration implements DataConfigurationInterface -{ - /** - * @var array - */ - private $rules; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * UrlSchemaDataConfiguration constructor. - * - * @param ConfigurationInterface $configuration - * @param array $rules - */ - public function __construct(ConfigurationInterface $configuration, array $rules) - { - $this->rules = $rules; - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - $configResult = []; - foreach ($this->rules as $routeId => $defaultRule) { - $result = $this->getConfigurationValue($routeId) ?: $defaultRule; - $configResult[$routeId] = $result; - } - - return $configResult; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - if ($this->validateConfiguration($configuration)) { - foreach ($configuration as $routeId => $value) { - $this->updateConfigurationValue($routeId, $value); - } - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - $configurationExists = true; - foreach (array_keys($configuration) as $routeId) { - $configurationExists &= isset($this->rules[$routeId]); - } - - return $configurationExists; - } - - /** - * Gets configuration from configuration table. - * - * @param string $routeId - * - * @return string - */ - private function getConfigurationValue($routeId) - { - return $this->configuration->get($this->getConfigurationKey($routeId)); - } - - /** - * Updates configuration data. - * - * @param string $routeId - * @param string $rule - * - * @return mixed - */ - private function updateConfigurationValue($routeId, $rule) - { - return $this->configuration->set($this->getConfigurationKey($routeId), $rule); - } - - /** - * Gets key which is used to retrieve data from configuration table. - * - * @param string $routeId - * - * @return string - */ - private function getConfigurationKey($routeId) - { - return sprintf('PS_ROUTE_%s', $routeId); - } -} diff --git a/src/Adapter/Module/AdminModuleDataProvider.php b/src/Adapter/Module/AdminModuleDataProvider.php deleted file mode 100644 index 58053b93..00000000 --- a/src/Adapter/Module/AdminModuleDataProvider.php +++ /dev/null @@ -1,520 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module; - -use Context; -use Doctrine\Common\Cache\CacheProvider; -use Employee; -use Module as LegacyModule; -use PrestaShop\PrestaShop\Core\Addon\AddonListFilterOrigin; -use PrestaShop\PrestaShop\Core\Addon\AddonsCollection; -use PrestaShopBundle\Service\DataProvider\Admin\AddonsInterface; -use PrestaShopBundle\Service\DataProvider\Admin\CategoriesProvider; -use PrestaShopBundle\Service\DataProvider\Admin\ModuleInterface; -use Psr\Log\LoggerInterface; -use Symfony\Component\Routing\Router; -use Symfony\Component\Translation\TranslatorInterface; -use Tools; - -/** - * Data provider for new Architecture, about Module object model. - * - * This class will provide data from DB / ORM about Modules for the Admin interface. - * This is an Adapter that works with the Legacy code and persistence behaviors. - */ -class AdminModuleDataProvider implements ModuleInterface -{ - const _CACHEKEY_MODULES_ = '_addons_modules'; - - const _DAY_IN_SECONDS_ = 86400; /* Cache for One Day */ - - /** - * @const array giving a translation domain key for each module action - */ - const _ACTIONS_TRANSLATION_DOMAINS_ = [ - 'install' => 'Admin.Actions', - 'uninstall' => 'Admin.Actions', - 'enable' => 'Admin.Actions', - 'disable' => 'Admin.Actions', - 'enable_mobile' => 'Admin.Modules.Feature', - 'disable_mobile' => 'Admin.Modules.Feature', - 'reset' => 'Admin.Actions', - 'upgrade' => 'Admin.Actions', - 'configure' => 'Admin.Actions', - ]; - - /** - * @var array of defined and callable module actions - */ - protected $moduleActions = ['install', 'uninstall', 'enable', 'disable', 'enable_mobile', 'disable_mobile', 'reset', 'upgrade']; - - /** - * @var int - */ - private $languageISO; - - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @var Router|null - */ - private $router = null; - - /** - * @var AddonsInterface - */ - private $addonsDataProvider; - - /** - * @var CategoriesProvider - */ - private $categoriesProvider; - - /** - * @var ModuleDataProvider - */ - private $moduleProvider; - - /** - * @var CacheProvider - */ - private $cacheProvider; - - /** - * @var Employee - */ - private $employee; - - /** - * @var array - */ - protected $catalog_modules = []; - - /** - * @var array - */ - protected $catalog_modules_names; - - /** - * @var bool - */ - public $failed = false; - - public function __construct( - TranslatorInterface $translator, - LoggerInterface $logger, - AddonsInterface $addonsDataProvider, - CategoriesProvider $categoriesProvider, - ModuleDataProvider $modulesProvider, - CacheProvider $cacheProvider = null, - Employee $employee = null - ) { - list($this->languageISO) = explode('-', $translator->getLocale()); - - $this->logger = $logger; - $this->addonsDataProvider = $addonsDataProvider; - $this->categoriesProvider = $categoriesProvider; - $this->moduleProvider = $modulesProvider; - $this->cacheProvider = $cacheProvider; - $this->employee = $employee; - } - - /** - * @param Router $router - */ - public function setRouter(Router $router) - { - $this->router = $router; - } - - /** - * Clear the modules information from Addons cache. - */ - public function clearCatalogCache() - { - if ($this->cacheProvider) { - $this->cacheProvider->delete($this->languageISO . self::_CACHEKEY_MODULES_); - } - $this->catalog_modules = []; - } - - /** - * Clears module list cache. - */ - public function clearModuleListCache() - { - if (file_exists(LegacyModule::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST)) { - @unlink(LegacyModule::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST); - } - } - - /** - * @deprecated since version 1.7.3.0 - * - * @return array - */ - public function getAllModules() - { - return LegacyModule::getModulesOnDisk( - true, - $this->addonsDataProvider->isAddonsAuthenticated(), - (int) Context::getContext()->employee->id - ); - } - - /** - * @param array $filters - * - * @return array - */ - public function getCatalogModules(array $filters = []) - { - if (count($this->catalog_modules) === 0 && !$this->failed) { - $this->loadCatalogData(); - } - - return $this->applyModuleFilters( - $this->catalog_modules, - $filters - ); - } - - /** - * @param array $filter - * - * @return array - */ - public function getCatalogModulesNames(array $filter = []) - { - return array_keys($this->getCatalogModules($filter)); - } - - /** - * Check the permissions of the current context (CLI or employee) for a module. - * - * @param array $actions Actions to check - * @param string $name The module name - * - * @return array of allowed actions - */ - protected function filterAllowedActions(array $actions, $name = '') - { - $allowedActions = []; - foreach (array_keys($actions) as $actionName) { - if ($this->isAllowedAccess($actionName, $name)) { - $allowedActions[$actionName] = $actions[$actionName]; - } - } - - return $allowedActions; - } - - /** - * Check the permissions of the current context (CLI or employee) for a specified action. - * - * @param string $action The action called in the module - * @param string $name (Optionnal for 'install') The module name to check - * - * @return bool - */ - public function isAllowedAccess($action, $name = '') - { - if (Tools::isPHPCLI()) { - return true; - } - - if (in_array($action, ['install', 'upgrade'])) { - return $this->employee->can('add', 'AdminModulessf'); - } - - if ('uninstall' === $action) { - return $this->employee->can('delete', 'AdminModulessf') && $this->moduleProvider->can('uninstall', $name); - } - - return $this->employee->can('edit', 'AdminModulessf') && $this->moduleProvider->can('configure', $name); - } - - /** - * @param AddonsCollection $addons - * @param string|null $specific_action - * - * @return AddonsCollection - */ - public function generateAddonsUrls(AddonsCollection $addons, $specific_action = null) - { - foreach ($addons as $addon) { - $urls = []; - foreach ($this->moduleActions as $action) { - $urls[$action] = $this->router->generate('admin_module_manage_action', [ - 'action' => $action, - 'module_name' => $addon->attributes->get('name'), - ]); - } - $urls['configure'] = $this->router->generate('admin_module_configure_action', [ - 'module_name' => $addon->attributes->get('name'), - ]); - - if ($addon->database->has('installed') && $addon->database->getBoolean('installed')) { - if (!$addon->database->getBoolean('active')) { - $url_active = 'enable'; - unset( - $urls['install'], - $urls['disable'] - ); - } elseif ($addon->attributes->getBoolean('is_configurable')) { - $url_active = 'configure'; - unset( - $urls['enable'], - $urls['install'] - ); - } else { - $url_active = 'disable'; - unset( - $urls['install'], - $urls['enable'], - $urls['configure'] - ); - } - - if (!$addon->attributes->getBoolean('is_configurable')) { - unset($urls['configure']); - } - - if ($addon->canBeUpgraded()) { - $url_active = 'upgrade'; - } else { - unset( - $urls['upgrade'] - ); - } - if (!$addon->database->getBoolean('active_on_mobile')) { - unset($urls['disable_mobile']); - } else { - unset($urls['enable_mobile']); - } - if (!$addon->canBeUpgraded()) { - unset( - $urls['upgrade'] - ); - } - } elseif ( - !$addon->attributes->has('origin') || - $addon->disk->getBoolean('is_present') || - in_array($addon->attributes->get('origin'), ['native', 'native_all', 'partner', 'customer'], true) - ) { - $url_active = 'install'; - unset( - $urls['uninstall'], - $urls['enable'], - $urls['disable'], - $urls['enable_mobile'], - $urls['disable_mobile'], - $urls['reset'], - $urls['upgrade'], - $urls['configure'] - ); - } else { - $url_active = 'buy'; - } - - $urls = $this->filterAllowedActions($urls, $addon->attributes->get('name')); - $addon->attributes->set('urls', $urls); - $addon->attributes->set('actionTranslationDomains', self::_ACTIONS_TRANSLATION_DOMAINS_); - if ($specific_action && array_key_exists($specific_action, $urls)) { - $addon->attributes->set('url_active', $specific_action); - } elseif ($url_active === 'buy' || array_key_exists($url_active, $urls)) { - $addon->attributes->set('url_active', $url_active); - } else { - $addon->attributes->set('url_active', key($urls)); - } - - $categoryParent = $this->categoriesProvider->getParentCategory($addon->attributes->get('categoryName')); - $addon->attributes->set('categoryParent', $categoryParent); - } - - return $addons; - } - - /** - * @param $moduleId - * - * @return array - */ - public function getModuleAttributesById($moduleId) - { - return (array) $this->addonsDataProvider->request('module', ['id_module' => $moduleId]); - } - - /** - * @param array $modules - * @param array $filters - * - * @return array - */ - protected function applyModuleFilters(array $modules, array $filters) - { - if (!count($filters)) { - return $modules; - } - - // We get our module IDs to keep - foreach ($filters as $filter_name => $value) { - $search_result = []; - - switch ($filter_name) { - case 'search': - // We build our results array. - // We could remove directly the non-matching modules, but we will give that for the final loop of this function - - foreach (explode(' ', $value) as $keyword) { - if (empty($keyword)) { - continue; - } - - // Instead of looping on the whole module list, we use $module_ids which can already be reduced - // thanks to the previous array_intersect(...) - foreach ($modules as $key => $module) { - if (strpos($module->displayName, $keyword) !== false - || strpos($module->name, $keyword) !== false - || strpos($module->description, $keyword) !== false) { - $search_result[] = $key; - } - } - } - - break; - case 'name': - // exact given name (should return 0 or 1 result) - $search_result[] = $value; - - break; - default: - // "the switch statement is considered a looping structure for the purposes of continue." - continue 2; - } - - $modules = array_intersect_key($modules, array_flip($search_result)); - } - - return $modules; - } - - /** - * Load module catalogue. If not in cache, query Addons API. - */ - protected function loadCatalogData() - { - if ($this->cacheProvider && $this->cacheProvider->contains($this->languageISO . self::_CACHEKEY_MODULES_)) { - $this->catalog_modules = $this->cacheProvider->fetch($this->languageISO . self::_CACHEKEY_MODULES_); - } - - if (!$this->catalog_modules) { - $params = ['format' => 'json']; - $requests = [ - AddonListFilterOrigin::ADDONS_MUST_HAVE => 'must-have', - AddonListFilterOrigin::ADDONS_SERVICE => 'service', - AddonListFilterOrigin::ADDONS_NATIVE => 'native', - AddonListFilterOrigin::ADDONS_NATIVE_ALL => 'native_all', - ]; - if ($this->addonsDataProvider->isAddonsAuthenticated()) { - $requests[AddonListFilterOrigin::ADDONS_CUSTOMER] = 'customer'; - } - - try { - $listAddons = []; - // We execute each addons request - foreach ($requests as $action_filter_value => $action) { - if (!$this->addonsDataProvider->isAddonsUp()) { - continue; - } - // We add the request name in each product returned by Addons, - // so we know whether is bought - - $addons = $this->addonsDataProvider->request($action, $params); - foreach ($addons as $addonsType => $addon) { - if (empty($addon->name)) { - $this->logger->error(sprintf('The addon with id %s does not have name.', $addon->id)); - - continue; - } - - $addon->origin = $action; - $addon->origin_filter_value = $action_filter_value; - $addon->categoryParent = $this->categoriesProvider - ->getParentCategory($addon->categoryName); - if (isset($addon->version)) { - $addon->version_available = $addon->version; - } - if (!isset($addon->product_type)) { - $addon->productType = isset($addonsType) ? rtrim($addonsType, 's') : 'module'; - } else { - $addon->productType = $addon->product_type; - } - $listAddons[$addon->name] = $addon; - } - } - - if (!empty($listAddons)) { - $this->catalog_modules = $listAddons; - if ($this->cacheProvider) { - $this->cacheProvider->save($this->languageISO . self::_CACHEKEY_MODULES_, $this->catalog_modules, self::_DAY_IN_SECONDS_); - } - } else { - $this->fallbackOnCatalogCache(); - } - } catch (\Exception $e) { - if (!$this->fallbackOnCatalogCache()) { - $this->logger->error('Data from PrestaShop Addons is invalid, and cannot fallback on cache. ', ['exception' => $e->getMessage()]); - } - } - } - } - - /** - * If cache exists, get the Catalogue from the cache. - * - * @return array Module loaded from the cache - */ - protected function fallbackOnCatalogCache() - { - // Fallback on data from cache if exists - if ($this->cacheProvider) { - $this->catalog_modules = $this->cacheProvider->fetch($this->languageISO . self::_CACHEKEY_MODULES_); - } - - if (!$this->catalog_modules) { - $this->catalog_modules = []; - } - - $this->failed = true; - - return $this->catalog_modules; - } -} diff --git a/src/Adapter/Module/Configuration/ModuleComplexConfigurationInterface.php b/src/Adapter/Module/Configuration/ModuleComplexConfigurationInterface.php deleted file mode 100644 index 3c779ef5..00000000 --- a/src/Adapter/Module/Configuration/ModuleComplexConfigurationInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module\Configuration; - -use PrestaShop\PrestaShop\Adapter\Module\Module; - -/** - * @todo: document what is the contract of this interface. - */ -interface ModuleComplexConfigurationInterface -{ - /** - * @param Module $module - * @param array $params - * - * @return mixed - */ - public function run(Module $module, array $params); -} diff --git a/src/Adapter/Module/Configuration/ModuleSelfConfigurator.php b/src/Adapter/Module/Configuration/ModuleSelfConfigurator.php deleted file mode 100644 index e3097799..00000000 --- a/src/Adapter/Module/Configuration/ModuleSelfConfigurator.php +++ /dev/null @@ -1,506 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module\Configuration; - -use Doctrine\DBAL\Connection; -use Exception; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Addon\Module\ModuleRepository; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Process\Exception\InvalidArgumentException; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; -use Symfony\Component\Yaml\Exception\ParseException; -use Symfony\Component\Yaml\Yaml; - -/** - * This class allow system users and developers to configure their module - * with a single config file. - * - * Use validate() to check everything is ready to run. - * Use configure() to run the configuration with the provided parameters. - */ -class ModuleSelfConfigurator -{ - /** - * @var string|null the module name - */ - protected $module; - - /** - * @var string|null - */ - protected $configFile; - - /** - * @var array - */ - protected $configs = []; - - /** - * @var string - */ - protected $defaultConfigFile = 'self_config.yml'; - - /** - * @var ModuleRepository - */ - protected $moduleRepository; - - /** - * @var Configuration - */ - protected $configuration; - - /** - * @var Connection - */ - protected $connection; - - /** - * @var Filesystem - */ - protected $filesystem; - - public function __construct( - ModuleRepository $moduleRepository, - Configuration $configuration, - Connection $connection, - Filesystem $filesystem - ) { - $this->module = null; - $this->configFile = null; - - $this->moduleRepository = $moduleRepository; - $this->configuration = $configuration; - $this->connection = $connection; - $this->filesystem = $filesystem; - } - - /** - * Alias for $module setter. - * - * @param string $name - * - * @return $this - */ - public function module($name) - { - return $this->setModule($name); - } - - /** - * Set the module to be updated with its name. - * - * @param string $name - * - * @return $this - * - * @throws UnexpectedTypeException - */ - public function setModule($name) - { - if (!is_string($name)) { - throw new UnexpectedTypeException($name, 'string'); - } - $this->module = $name; - - return $this; - } - - /** - * If defined, get the config file path or if possible, guess it. - * - * @return string|null - * - * @throws InvalidArgumentException - */ - public function getFile() - { - // If set, return it - if ($this->configFile) { - return $this->configFile; - } - - // If we do not know in which module to search, we cannot go further - if (!$this->module) { - return null; - } - - // Find and store the first config file we find - $files = Finder::create() - ->files() - ->in(_PS_MODULE_DIR_ . $this->module) - ->name($this->defaultConfigFile, null, true); - - foreach ($files as $file) { - $this->configFile = $file->getRealPath(); - - return $this->configFile; - } - - return null; - } - - /** - * Alias for config file setter. - * - * @param string $filepath - * - * @return $this - */ - public function file($filepath) - { - return $this->setFile($filepath); - } - - /** - * Set the config file to parse. - * - * @param string $filepath - * - * @return $this - * - * @throws UnexpectedTypeException - */ - public function setFile($filepath) - { - if (!is_string($filepath)) { - throw new UnexpectedTypeException($filepath, 'string'); - } - - $this->configFile = $filepath; - - return $this; - } - - /** - * In order to prevent some failure, we can check all pre-requesites are respected. - * Any error will be reported in the array. - * - * @return array - */ - public function validate() - { - $errors = []; - if ($this->module === null) { - $errors[] = 'Module name not specified'; - } - - try { - $file = $this->getFile(); - } catch (InvalidArgumentException $e) { - $errors[] = $e->getMessage(); - $file = null; - } - - if ($file === null) { - $errors[] = 'No config file to apply'; - } elseif (!file_exists($file)) { - $errors[] = 'Specified config file is not found'; - } else { - try { - $config = $this->loadYmlFile($file); - } catch (ParseException $e) { - $errors[] = $e->getMessage(); - } - - if (empty($config)) { - $errors[] = 'Parsed config file is empty'; - } - } - - if (!$this->module || !$this->moduleRepository->getModule($this->module)->hasValidInstance()) { - $errors[] = 'The module specified is invalid'; - } - - return $errors; - } - - /** - * Launch the self configuration with all the context previously set! - * - * @return bool - */ - public function configure() - { - if (count($this->validate())) { - return false; - } - $config = $this->loadYmlFile($this->getFile()); - - $this->runConfigurationStep($config); - $this->runFilesStep($config); - $this->runSqlStep($config); - $this->runPhpStep($config); - - return true; - } - - // PROTECTED ZONE - - /** - * Helper function which adds the relative path from the YML config file. - * Do not alter URLs. - * - * @param string $file - * - * @return string - */ - protected function convertRelativeToAbsolutePaths($file) - { - // If we do not deal with any kind of URL, add the path to the YML config file - if (!filter_var($file, FILTER_VALIDATE_URL)) { - $file = dirname($this->getFile()) . '/' . $file; - } - - return $file; - } - - /** - * Finds and returns filepath from a config key in the YML config file. - * Can be a string of a value of "file" key. - * - * @param array $data - * - * @return string - * - * @throws Exception if file data not provided - */ - protected function extractFilePath($data) - { - if (is_scalar($data)) { - $file = $data; - } elseif (is_array($data) && !empty($data['file'])) { - $file = $data['file']; - } else { - throw new Exception('Missing file path'); - } - - return $this->convertRelativeToAbsolutePaths($file); - } - - /** - * Require a PHP file and instanciate the class of the same name in it. - * - * @param string $file - * - * @return stdClass - */ - protected function loadPhpFile($file) - { - // Load file - require_once $file; - - // Load class of same name as the file - $className = pathinfo($file, PATHINFO_FILENAME); - - return new $className(); - } - - /** - * Parse and return the YML content. - * - * @param string $file - * - * @return array - */ - protected function loadYmlFile($file) - { - if (array_key_exists($file, $this->configs)) { - return $this->configs[$file]; - } - $this->configs[$file] = Yaml::parse(file_get_contents($file)); - - return $this->configs[$file]; - } - - /** - * Run configuration for "configuration" step. - * - * @param array $config - */ - protected function runConfigurationStep($config) - { - if (empty($config['configuration'])) { - return; - } - - if (array_key_exists('update', $config['configuration'])) { - $this->runConfigurationUpdate($config['configuration']['update']); - } - - if (array_key_exists('delete', $config['configuration'])) { - $this->runConfigurationDelete($config['configuration']['delete']); - } - } - - /** - * Run configuration for "file" step. - * - * @param array $config - */ - protected function runFilesStep($config) - { - if (empty($config['files'])) { - return; - } - - foreach ($config['files'] as $copy) { - if (empty($copy['source'])) { - throw new Exception('Missing source file'); - } - if (empty($copy['dest'])) { - throw new Exception('Missing destination file'); - } - - // If we get a relative path from the yml, add the original path - foreach (['source', 'dest'] as $prop) { - $copy[$prop] = $this->convertRelativeToAbsolutePaths($copy[$prop]); - } - - $this->filesystem->copy( - $copy['source'], - $copy['dest'] - ); - } - } - - /** - * Run configuration for "php" step. - * - * @param array $config - */ - protected function runPhpStep($config) - { - if (empty($config['php'])) { - return; - } - - foreach ($config['php'] as $data) { - $file = $this->extractFilePath($data); - - $module = $this->moduleRepository->getModule($this->module); - $params = !empty($data['params']) ? $data['params'] : []; - - $this->loadPhpFile($file)->run($module, $params); - } - } - - /** - * Run configuration for "sql" step. - * - * @param array $config - */ - protected function runSqlStep($config) - { - if (empty($config['sql'])) { - return; - } - - // Avoid unconsistant state with transactions - $this->connection->beginTransaction(); - - try { - foreach ($config['sql'] as $data) { - $this->runSqlFile($data); - } - $this->connection->commit(); - } catch (Exception $e) { - $this->connection->rollBack(); - - throw $e; - } - } - - /** - * Subtask of Sql step. Get and prepare all SQL requests from a file. - * - * @param array $data - */ - protected function runSqlFile($data) - { - $content = file_get_contents($this->extractFilePath($data)); - - foreach (explode(';', $content) as $sql) { - $sql = trim($sql); - if (empty($sql)) { - continue; - } - - // Set _DB_PREFIX_ - $sql = str_replace( - [ - 'PREFIX_', - 'DB_NAME', - ], - [ - $this->configuration->get('_DB_PREFIX_'), - $this->configuration->get('_DB_NAME_'), - ], - $sql - ); - - $stmt = $this->connection->prepare($sql); - $stmt->execute(); - } - } - - /** - * Subtask of configuration step, for all configuration key to update. - * - * @param array $config - * - * @throws Exception - */ - protected function runConfigurationUpdate($config) - { - foreach ($config as $key => $data) { - if (is_array($data) && isset($data['value'])) { - $value = $data['value']; - } elseif (is_scalar($data)) { - // string / integer / decimal / bool - $value = $data; - } else { - throw new Exception(sprintf('No value given for key %s', $key)); - } - $this->configuration->set($key, $value); - } - } - - /** - * Subtask of configuration step, for all configuration keys to delete. - * - * @param array $config - */ - protected function runConfigurationDelete($config) - { - foreach ($config as $key) { - $this->configuration->delete($key); - } - } -} diff --git a/src/Adapter/Module/Module.php b/src/Adapter/Module/Module.php deleted file mode 100644 index 54ecd62f..00000000 --- a/src/Adapter/Module/Module.php +++ /dev/null @@ -1,483 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module; - -use Module as LegacyModule; -use PrestaShop\PrestaShop\Core\Addon\AddonListFilterOrigin; -use PrestaShop\PrestaShop\Core\Addon\Module\AddonListFilterDeviceStatus; -use PrestaShop\PrestaShop\Core\Addon\Module\ModuleInterface; -use Symfony\Component\HttpFoundation\ParameterBag; - -/** - * This class is the interface to the legacy Module class. - * - * It will allow current modules to work even with the new ModuleManager - */ -class Module implements ModuleInterface -{ - const ACTION_INSTALL = 'install'; - const ACTION_UNINSTALL = 'uninstall'; - const ACTION_ENABLE = 'enable'; - const ACTION_DISABLE = 'disable'; - const ACTION_ENABLE_MOBILE = 'enable_mobile'; - const ACTION_DISABLE_MOBILE = 'disable_mobile'; - const ACTION_RESET = 'reset'; - const ACTION_UPGRADE = 'upgrade'; - - /** @var LegacyModule Module The instance of the legacy module */ - public $instance = null; - - /** - * Module attributes (name, displayName etc.). - * - * @var \Symfony\Component\HttpFoundation\ParameterBag - */ - public $attributes; - - /** - * Module attributes from disk. - * - * @var \Symfony\Component\HttpFoundation\ParameterBag - */ - public $disk; - - /** - * Module attributes from database. - * - * @var \Symfony\Component\HttpFoundation\ParameterBag - */ - public $database; - - /** - * Default values for ParameterBag attributes. - * - * @var array - */ - private $attributes_default = [ - 'id' => 0, - 'name' => '', - 'categoryName' => '', - 'displayName' => '', - 'version' => null, - 'description' => '', - 'author' => '', - 'author_uri' => false, - 'tab' => 'others', - 'is_configurable' => 0, - 'need_instance' => 0, - 'limited_countries' => [], - 'parent_class' => 'Module', - 'is_paymentModule' => false, - 'productType' => 'module', - 'warning' => '', - 'img' => '', - 'badges' => [], - 'cover' => [], - 'screenshotsUrls' => [], - 'videoUrl' => null, - 'refs' => ['unknown'], - 'price' => [ - 'EUR' => 0, - 'USD' => 0, - 'GBP' => 0, - ], - 'type' => '', - // From the marketplace - 'url' => null, - 'avgRate' => 0, - 'nbRates' => 0, - 'fullDescription' => '', - 'confirmUninstall' => '', - ]; - - /** - * Default values for ParameterBag disk. - * - * @var array - */ - private $disk_default = [ - 'filemtype' => 0, - 'is_present' => 0, - 'is_valid' => 0, - 'version' => null, - 'path' => '', - ]; - - /** - * Default values for ParameterBag database. - * - * @var array - */ - private $database_default = [ - 'installed' => 0, - 'active' => 0, - 'active_on_mobile' => true, - 'version' => null, - 'last_access_date' => '0000-00-00 00:00:00', - 'date_add' => null, - 'date_upd' => null, - ]; - - /** - * @param array $attributes - * @param array $disk - * @param array $database - */ - public function __construct(array $attributes = [], array $disk = [], array $database = []) - { - $this->attributes = new ParameterBag($this->attributes_default); - $this->disk = new ParameterBag($this->disk_default); - $this->database = new ParameterBag($this->database_default); - // Set all attributes - $this->attributes->add($attributes); - $this->disk->add($disk); - $this->database->add($database); - - if ($this->database->get('installed')) { - $version = $this->database->get('version'); - } elseif (null === $this->attributes->get('version') && $this->disk->get('is_valid')) { - $version = $this->disk->get('version'); - } else { - $version = $this->attributes->get('version'); - } - - if (!$this->attributes->has('version_available')) { - $this->attributes->set('version_available', $this->disk->get('version')); - } - - $this->fillLogo(); - - $this->attributes->set('version', $version); - $this->attributes->set('type', $this->convertType($this->get('origin_filter_value'))); - - // Unfortunately, we can sometime have an array, and sometimes an object. - // This is the first place where this value *always* exists - $this->attributes->set('price', (array) $this->attributes->get('price')); - } - - /** - * @return legacyInstance|void - * - * @throws \Exception - */ - public function getInstance() - { - if (!$this->hasValidInstance()) { - return; - } - - return $this->instance; - } - - /** - * @return bool True if valid Module instance - */ - public function hasValidInstance() - { - if (($this->disk->has('is_present') && $this->disk->getBoolean('is_present') === false) - || ($this->disk->has('is_valid') && $this->disk->getBoolean('is_valid') === false) - ) { - return false; - } - - if ($this->instance === null) { - // We try to instantiate the legacy class if not done yet - try { - $this->instanciateLegacyModule($this->attributes->get('name')); - } catch (\Exception $e) { - $this->disk->set('is_valid', false); - - return false; - } - } - - $this->disk->set('is_valid', $this->instance instanceof LegacyModule); - - return $this->disk->get('is_valid'); - } - - /** - * @return bool - */ - public function isActive() - { - return (bool) $this->database->get('active'); - } - - /** - * {@inheritdoc} - */ - public function onInstall() - { - if (!$this->hasValidInstance()) { - return false; - } - - // If not modified, code used in installer is executed: - // "Notice: Use of undefined constant _PS_INSTALL_LANGS_PATH_ - assumed '_PS_INSTALL_LANGS_PATH_'" - LegacyModule::updateTranslationsAfterInstall(false); - - // Casted to Boolean, because some modules returns 1 instead true and 0 instead false. - // Other value types are not expected. See also: https://github.com/PrestaShop/PrestaShop/pull/11442#issuecomment-440485268 - // The best way is to check for non Boolean type and `throw \UnexpectedValueException`, - // but it's need much refactoring and testing. - // TODO: refactoring. - $result = (bool) $this->instance->install(); - - $this->database->set('installed', $result); - $this->database->set('active', $result); - $this->database->set('version', $this->attributes->get('version')); - - return $result; - } - - /** - * {@inheritdoc} - */ - public function onUninstall() - { - if (!$this->hasValidInstance()) { - return false; - } - - $result = $this->instance->uninstall(); - $this->database->set('installed', !$result); - - return $result; - } - - /** - * {@inheritdoc} - */ - public function onUpgrade($version) - { - $this->database->set('version', $this->attributes->get('version_available')); - - return true; - } - - /** - * {@inheritdoc} - */ - public function onEnable() - { - if (!$this->hasValidInstance()) { - return false; - } - - $result = $this->instance->enable(); - $this->database->set('active', $result); - - return $result; - } - - /** - * {@inheritdoc} - */ - public function onDisable() - { - if (!$this->hasValidInstance()) { - return false; - } - - $result = $this->instance->disable(); - $this->database->set('active', !$result); - - return $result; - } - - /** - * {@inheritdoc} - */ - public function onMobileEnable() - { - if (!$this->hasValidInstance()) { - return false; - } - - $result = $this->instance->enableDevice(AddonListFilterDeviceStatus::DEVICE_MOBILE); - $this->database->set('active_on_mobile', $result); - - return $result; - } - - /** - * {@inheritdoc} - */ - public function onMobileDisable() - { - if (!$this->hasValidInstance()) { - return false; - } - - $result = $this->instance->disableDevice(AddonListFilterDeviceStatus::DEVICE_MOBILE); - $this->database->set('active_on_mobile', !$result); - - return $result; - } - - /** - * {@inheritdoc} - */ - public function onReset() - { - if (!$this->hasValidInstance()) { - return false; - } - - return $this->instance->reset(); - } - - /** - * Retrieve an instance of Legacy Module Object model from data. - */ - protected function instanciateLegacyModule() - { - /** - * @TODO Temporary: This test prevents an error when switching branches with the cache. - * Can be removed at the next release (when we will be sure that it is defined) - */ - $path = $this->disk->get('path', ''); // Variable needed for empty() test - if (empty($path)) { - $this->disk->set('path', _PS_MODULE_DIR_ . DIRECTORY_SEPARATOR . $this->attributes->get('name')); - } - // End of temporary content - require_once $this->disk->get('path') . DIRECTORY_SEPARATOR . $this->attributes->get('name') . '.php'; - $this->instance = LegacyModule::getInstanceByName($this->attributes->get('name')); - } - - /** - * @param $attribute - * - * @return mixed - */ - public function get($attribute) - { - return $this->attributes->get($attribute, null); - } - - /** - * @param $attribute - * @param $value - */ - public function set($attribute, $value) - { - $this->attributes->set($attribute, $value); - } - - /** - * @param $value - * - * @return mixed|string - */ - private function convertType($value) - { - $conversionTable = [ - AddonListFilterOrigin::ADDONS_CUSTOMER => 'addonsBought', - AddonListFilterOrigin::ADDONS_MUST_HAVE => 'addonsMustHave', - ]; - - return isset($conversionTable[$value]) ? $conversionTable[$value] : ''; - } - - /** - * Set the module logo. - */ - public function fillLogo() - { - $img = $this->attributes->get('img'); - if (empty($img)) { - $this->attributes->set('img', __PS_BASE_URI__ . 'img/questionmark.png'); - } - $this->attributes->set('logo', __PS_BASE_URI__ . 'img/questionmark.png'); - - foreach (['logo.png', 'logo.gif'] as $logo) { - $logo_path = _PS_MODULE_DIR_ . $this->get('name') . DIRECTORY_SEPARATOR . $logo; - if (file_exists($logo_path)) { - $this->attributes->set('img', __PS_BASE_URI__ . basename(_PS_MODULE_DIR_) . '/' . $this->get('name') . '/' . $logo); - $this->attributes->set('logo', $logo); - - break; - } - } - } - - /** - * Inform the merchant an upgrade is wating to be applied from the disk or the marketplace. - * - * @return bool - */ - public function canBeUpgraded() - { - if ($this->database->get('installed') == 0) { - return false; - } - - // Potential update from API - if ($this->canBeUpgradedFromAddons()) { - return true; - } - - // Potential update from disk - return version_compare($this->database->get('version'), $this->disk->get('version'), '<'); - } - - /** - * Only check if an upgrade is available on the marketplace. - * - * @return bool - */ - public function canBeUpgradedFromAddons() - { - return $this->attributes->get('version_available') !== 0 - && version_compare($this->database->get('version'), $this->attributes->get('version_available'), '<'); - } - - /** - * Return installed modules. - * - * @param int $position Take only positionnables modules - * - * @return array Modules - */ - public function getModulesInstalled($position = 0) - { - return LegacyModule::getModulesInstalled((int) $position); - } - - /** - * Return an instance of the specified module. - * - * @param int $moduleId Module id - * - * @return Module instance - */ - public function getInstanceById($moduleId) - { - return LegacyModule::getInstanceById((int) $moduleId); - } -} diff --git a/src/Adapter/Module/ModuleDataProvider.php b/src/Adapter/Module/ModuleDataProvider.php deleted file mode 100644 index 97ac2179..00000000 --- a/src/Adapter/Module/ModuleDataProvider.php +++ /dev/null @@ -1,306 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module; - -use Db; -use Doctrine\ORM\EntityManager; -use Module as LegacyModule; -use PhpParser; -use PrestaShop\PrestaShop\Adapter\Shop\Context; -use PrestaShop\PrestaShop\Core\Addon\Module\AddonListFilterDeviceStatus; -use Psr\Log\LoggerInterface; -use Symfony\Component\Translation\TranslatorInterface; -use Tools; -use Validate; - -/** - * This class will provide data from DB / ORM about Module. - */ -class ModuleDataProvider -{ - /** - * Logger. - * - * @var LoggerInterface - */ - private $logger; - - /** - * Translator. - * - * @var \Symfony\Component\Translation\TranslatorInterface - */ - private $translator; - - /** - * EntityManager for module history. - * - * @var EntityManager - */ - private $entityManager; - - /** - * @var int - */ - private $employeeID; - - public function __construct(LoggerInterface $logger, TranslatorInterface $translator, EntityManager $entityManager = null) - { - $this->logger = $logger; - $this->translator = $translator; - $this->entityManager = $entityManager; - $this->employeeID = 0; - } - - /** - * @param $employeeID - */ - public function setEmployeeId($employeeID) - { - $this->employeeID = (int) $employeeID; - } - - /** - * Return all module information from database. - * - * @param string $name The technical module name to search - * - * @return array - */ - public function findByName($name) - { - $result = Db::getInstance()->getRow('SELECT `id_module` as `id`, `active`, `version` FROM `' . _DB_PREFIX_ . 'module` WHERE `name` = "' . pSQL($name) . '"'); - if ($result) { - $result['installed'] = 1; - $result['active'] = $this->isEnabled($name); - $result['active_on_mobile'] = (bool) ($this->getDeviceStatus($name) & AddonListFilterDeviceStatus::DEVICE_MOBILE); - $lastAccessDate = '0000-00-00 00:00:00'; - - if (!Tools::isPHPCLI() && null !== $this->entityManager && $this->employeeID) { - $moduleID = (int) $result['id']; - - $qb = $this->entityManager->createQueryBuilder(); - $qb->select('mh') - ->from('PrestaShopBundle:ModuleHistory', 'mh', 'mh.idModule') - ->where('mh.idEmployee = ?1') - ->setParameter(1, $this->employeeID); - $query = $qb->getQuery(); - $query->useResultCache(true); - $modulesHistory = $query->getResult(); - - if (array_key_exists($moduleID, $modulesHistory)) { - $lastAccessDate = $modulesHistory[$moduleID]->getDateUpd()->format('Y-m-d H:i:s'); - } - } - $result['last_access_date'] = $lastAccessDate; - - return $result; - } - - return ['installed' => 0]; - } - - /** - * Return translated module *Display Name*. - * - * @param string $module The technical module name - * - * @return string The translated Module displayName - */ - public function getModuleName($module) - { - return LegacyModule::getModuleName($module); - } - - /** - * Check current employee permission on a given module. - * - * @param string $action - * @param string $name - * - * @return bool True if allowed - */ - public function can($action, $name) - { - $module_id = LegacyModule::getModuleIdByName($name); - - if (empty($module_id)) { - return false; - } - - return LegacyModule::getPermissionStatic($module_id, $action); - } - - /** - * Check if a module is enabled in the current shop context. - * - * @param bool $name The technical module name - * - * @return bool True if enable - */ - public function isEnabled($name) - { - $id_shops = (new Context())->getContextListShopID(); - // ToDo: Load list of all installed modules ? - - $result = Db::getInstance()->getRow('SELECT m.`id_module` as `active`, ms.`id_module` as `shop_active` - FROM `' . _DB_PREFIX_ . 'module` m - LEFT JOIN `' . _DB_PREFIX_ . 'module_shop` ms ON m.`id_module` = ms.`id_module` - WHERE `name` = "' . pSQL($name) . '" - AND ms.`id_shop` IN (' . implode(',', array_map('intval', $id_shops)) . ')'); - if ($result) { - return (bool) ($result['active'] && $result['shop_active']); - } else { - return false; - } - } - - public function isInstalled($name) - { - // ToDo: Load list of all installed modules ? - return (bool) $this->getModuleIdByName($name); - } - - /** - * Returns the Module Id - * - * @param string $name The technical module name - * - * @return int the Module Id, or 0 if not found - */ - public function getModuleIdByName($name) - { - return (int) Db::getInstance()->getValue( - 'SELECT `id_module` FROM `' . _DB_PREFIX_ . 'module` WHERE `name` = "' . pSQL($name) . '"' - ); - } - - /** - * We won't load an invalid class. This function will check any potential parse error. - * - * @param string $name The technical module name to check - * - * @return bool true if valid - */ - public function isModuleMainClassValid($name) - { - if (!Validate::isModuleName($name)) { - return false; - } - - $file_path = _PS_MODULE_DIR_ . $name . '/' . $name . '.php'; - // Check if file exists (slightly faster than file_exists) - if (!(int) @filemtime($file_path)) { - return false; - } - - $parser = (new PhpParser\ParserFactory())->create(PhpParser\ParserFactory::PREFER_PHP7); - - try { - $parser->parse(file_get_contents($file_path)); - } catch (PhpParser\Error $exception) { - $this->logger->critical( - $this->translator->trans( - 'Parse error detected in main class of module %module%: %parse_error%', - [ - '%module%' => $name, - '%parse_error%' => $exception->getMessage(), - ], - 'Admin.Modules.Notification' - ) - ); - - return false; - } - - $logger = $this->logger; - // -> Even if we do not detect any parse error in the file, we may have issues - // when trying to load the file. (i.e with additional require_once). - // -> We use an anonymous function here because if a test is made twice - // on the same module, the test on require_once would immediately return true - // (as the file would have already been evaluated). - $require_correct = function ($name) use ($file_path, $logger) { - try { - require_once $file_path; - } catch (\Exception $e) { - $logger->error( - $this->translator->trans( - 'Error while loading file of module %module%. %error_message%', - [ - '%module%' => $name, - '%error_message%' => $e->getMessage(), ], - 'Admin.Modules.Notification' - ) - ); - - return false; - } - - return true; - }; - - return $require_correct($name); - } - - /** - * Check if the module is in the modules folder, with a valid class. - * - * @param string $name The technical module name to find - * - * @return bool True if found - */ - public function isOnDisk($name) - { - $path = _PS_MODULE_DIR_ . $name . '/' . $name . '.php'; - - return file_exists($path); - } - - /** - * Check if the module has been enabled on mobile. - * - * @param string $name The technical module name to check - * - * @return int The devices enabled for this module - */ - private function getDeviceStatus($name) - { - $id_shops = (new Context())->getContextListShopID(); - // ToDo: Load list of all installed modules ? - - $result = Db::getInstance()->getRow('SELECT m.`id_module` as `active`, ms.`id_module` as `shop_active`, ms.`enable_device` as `enable_device` - FROM `' . _DB_PREFIX_ . 'module` m - LEFT JOIN `' . _DB_PREFIX_ . 'module_shop` ms ON m.`id_module` = ms.`id_module` - WHERE `name` = "' . pSQL($name) . '" - AND ms.`id_shop` IN (' . implode(',', array_map('intval', $id_shops)) . ')'); - if ($result) { - return (int) $result['enable_device']; - } - - return false; - } -} diff --git a/src/Adapter/Module/ModuleDataUpdater.php b/src/Adapter/Module/ModuleDataUpdater.php deleted file mode 100644 index 5b4e0dbe..00000000 --- a/src/Adapter/Module/ModuleDataUpdater.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module; - -use Module as LegacyModule; -use PrestaShopBundle\Service\DataProvider\Admin\AddonsInterface; -use Symfony\Component\Filesystem\Exception\IOException; -use Symfony\Component\Filesystem\Filesystem; - -/** - * Responsible of managing updates of modules. - */ -class ModuleDataUpdater -{ - /** - * @var AddonsInterface - */ - private $addonsDataProvider; - - /** - * @var AdminModuleDataProvider - */ - private $adminModuleDataProvider; - - public function __construct(AddonsInterface $addonsDataProvider, AdminModuleDataProvider $adminModuleDataProvider) - { - $this->addonsDataProvider = $addonsDataProvider; - $this->adminModuleDataProvider = $adminModuleDataProvider; - } - - /** - * @param $name - * - * @return bool - */ - public function setModuleOnDiskFromAddons($name) - { - // Note : Data caching should be handled by the addons data provider - // Check if the module can be downloaded from addons - foreach ($this->adminModuleDataProvider->getCatalogModules(['name' => $name]) as $catalog_module) { - if ($catalog_module->name == $name && in_array($catalog_module->origin, ['native', 'native_all', 'must-have', 'customer'])) { - return $this->addonsDataProvider->downloadModule($catalog_module->id); - } - } - - return false; - } - - /** - * @param $name - * - * @return bool - */ - public function removeModuleFromDisk($name) - { - $fs = new FileSystem(); - - try { - $fs->remove(_PS_MODULE_DIR_ . '/' . $name); - - return true; - } catch (IOException $e) { - return false; - } - } - - /** - * @param $name - * - * @return bool - */ - public function upgrade($name) - { - // Calling this function will init legacy module data - $module_list = LegacyModule::getModulesOnDisk(); - - foreach ($module_list as $module) { - if ($module->name != $name) { - continue; - } - - if (LegacyModule::initUpgradeModule($module)) { - $legacy_instance = LegacyModule::getInstanceByName($name); - $legacy_instance->runUpgradeModule(); - - LegacyModule::upgradeModuleVersion($name, $module->version); - - return !count($legacy_instance->getErrors()); - } elseif (LegacyModule::getUpgradeStatus($name)) { - return true; - } - - return true; - } - - return false; - } -} diff --git a/src/Adapter/Module/ModulePresenter.php b/src/Adapter/Module/ModulePresenter.php deleted file mode 100644 index 3bd872b3..00000000 --- a/src/Adapter/Module/ModulePresenter.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module; - -/** - * @deprecated since 1.7.4.0 - * @see \PrestaShop\PrestaShop\Adapter\Presenter\Module\ModulePresenter - */ -class ModulePresenter extends \PrestaShop\PrestaShop\Adapter\Presenter\Module\ModulePresenter -{ -} diff --git a/src/Adapter/Module/ModuleZip.php b/src/Adapter/Module/ModuleZip.php deleted file mode 100644 index 2b7b8851..00000000 --- a/src/Adapter/Module/ModuleZip.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module; - -/** - * Value object used to represent a partial Module object during unzipping - * of a module archive. - */ -class ModuleZip -{ - /** - * @var string Module technical name, guessed from the path [module name]/[module name].php - */ - private $name; - - /** - * @var string Temporary path to extract the module files before going into the modules folder - */ - private $sandboxPath; - - /** - * @var string Complete path to the source file (Zip) - */ - private $source; - - public function __construct($source) - { - $this->name = null; - $this->sandboxPath = null; - $this->source = $source; - } - - /** - * @return string|null - */ - public function getName() - { - return $this->name; - } - - /** - * @return string - */ - public function getSource() - { - return $this->source; - } - - /** - * @return string|null - */ - public function getSandboxPath() - { - return $this->sandboxPath; - } - - /** - * @param $name - * - * @return $this - */ - public function setName($name) - { - $this->name = $name; - - return $this; - } - - /** - * @param $sandboxPath - * - * @return $this - */ - public function setSandboxPath($sandboxPath) - { - $this->sandboxPath = $sandboxPath; - - return $this; - } -} diff --git a/src/Adapter/Module/ModuleZipManager.php b/src/Adapter/Module/ModuleZipManager.php deleted file mode 100644 index 97dc698b..00000000 --- a/src/Adapter/Module/ModuleZipManager.php +++ /dev/null @@ -1,221 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module; - -use Exception; -use PrestaShopBundle\Event\ModuleZipManagementEvent; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Translation\TranslatorInterface; -use Tools; -use ZipArchive; - -/** - * Responsible of unzipping of Module Zip archives. - */ -class ModuleZipManager -{ - /* - * Data - */ - private static $sources = []; - - /* - * Services - */ - /** - * @var \Symfony\Component\Filesystem\Filesystem - */ - private $filesystem; - - /** - * Translator. - * - * @var TranslatorInterface - */ - private $translator; - - /** - * @var EventDispatcherInterface - */ - private $eventDispatcher; - - public function __construct( - Filesystem $filesystem, - TranslatorInterface $translator, - EventDispatcherInterface $eventDispatcher - ) { - $this->filesystem = $filesystem; - $this->translator = $translator; - $this->eventDispatcher = $eventDispatcher; - } - - /** - * Detect module name from zipball. - * - * @param string $source - * - * @return string - * - * @throws Exception If unable to find the module name - */ - public function getName($source) - { - $this->initSource($source); - - if ($this->getSource($source)->getName($source) !== null) { - return $this->getSource($source)->getName($source); - } - - if (!file_exists($source)) { - throw new Exception($this->translator->trans('Unable to find uploaded module at the following path: %file%', ['%file%' => $source], 'Admin.Modules.Notification')); - } - - $sandboxPath = $this->getSandboxPath($source); - $zip = new ZipArchive(); - if ($zip->open($source) === false || !$zip->extractTo($sandboxPath) || !$zip->close()) { - throw new Exception($this->translator->trans('Cannot extract module in %path% to get its name. %error%', ['%path%' => $sandboxPath, '%error%' => $zip->getStatusString()], 'Admin.Modules.Notification')); - } - - // Check the structure and get the module name - $directories = Finder::create() - ->directories() - ->in($sandboxPath) - ->depth('== 0') - ->exclude(['__MACOSX']) - ->ignoreVCS(true); - - $validModuleStructure = false; - // We must have only one folder in the zip, which contains the module files - if (iterator_count($directories->directories()) == 1) { - $directories = iterator_to_array($directories); - $moduleName = basename(current($directories)->getFileName()); - - // Inside of this folder, we MUST have a file called .php - $moduleFolder = Finder::create() - ->files() - ->in($sandboxPath . $moduleName) - ->depth('== 0') - ->exclude(['__MACOSX']) - ->ignoreVCS(true); - foreach (iterator_to_array($moduleFolder) as $file) { - if ($file->getFileName() === $moduleName . '.php') { - $validModuleStructure = true; - - break; - } - } - } - - if (!$validModuleStructure) { - $this->filesystem->remove($sandboxPath); - - throw new Exception($this->translator->trans('This file does not seem to be a valid module zip', [], 'Admin.Modules.Notification')); - } - - $this->getSource($source)->setName($moduleName); - - return $moduleName; - } - - /** - * When ready, send the module Zip in the modules folder. - * - * @param string $source - */ - public function storeInModulesFolder($source) - { - $name = $this->getName($source); - $sandboxPath = $this->getSandboxPath($source); - // Now we are sure to have a valid module, we copy it to the modules folder - $modulePath = _PS_MODULE_DIR_ . $name; - $this->filesystem->mkdir($modulePath); - $this->filesystem->mirror( - $sandboxPath . $name, - $modulePath, - null, - ['override' => true] - ); - $this->eventDispatcher - ->dispatch( - ModuleZipManagementEvent::DOWNLOAD, - new ModuleZipManagementEvent($this->getSource($source)) - ); - - $this->filesystem->remove($sandboxPath); - } - - /** - * @param $source - * - * @return string|null - */ - private function getSandboxPath($source) - { - $sandboxPath = $this->getSource($source)->getSandboxPath(); - if ($sandboxPath === null) { - $sandboxPath = _PS_CACHE_DIR_ . 'sandbox/' . uniqid() . '/'; - $this->filesystem->mkdir($sandboxPath); - $this->getSource($source)->setSandboxPath($sandboxPath); - } - - return $sandboxPath; - } - - /** - * Get a ModuleZip instance from a given source (= zip filepath). - * - * @param string $source - * - * @return ModuleZip|null - */ - private function getSource($source) - { - if (!array_key_exists($source, self::$sources)) { - return null; - } - - return self::$sources[$source]; - } - - /** - * Init all data regarding a source before proceeding it. - * - * @param string $source - */ - private function initSource($source) - { - if ((filter_var($source, FILTER_VALIDATE_URL))) { - $source = Tools::createFileFromUrl($source); - } - - if ($this->getSource($source) === null) { - self::$sources[$source] = new ModuleZip($source); - } - } -} diff --git a/src/Adapter/Module/PaymentModuleListProvider.php b/src/Adapter/Module/PaymentModuleListProvider.php deleted file mode 100644 index 7f74fb57..00000000 --- a/src/Adapter/Module/PaymentModuleListProvider.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module; - -use PrestaShop\PrestaShop\Core\Addon\AddonListFilter; -use PrestaShop\PrestaShop\Core\Addon\AddonListFilterStatus; -use PrestaShop\PrestaShop\Core\Addon\AddonListFilterType; -use PrestaShop\PrestaShop\Core\Addon\AddonRepositoryInterface; -use PrestaShop\PrestaShop\Core\Module\DataProvider\PaymentModuleListProviderInterface; -use PrestaShopBundle\Entity\Repository\ModuleRepository; - -/** - * Class PaymentModuleListProvider is responsible for providing payment module list. - */ -final class PaymentModuleListProvider implements PaymentModuleListProviderInterface -{ - /** - * @var AddonRepositoryInterface - */ - private $addonRepository; - - /** - * @var ModuleRepository - */ - private $moduleRepository; - - /** - * @var int - */ - private $shopId; - - /** - * @param AddonRepositoryInterface $addonRepository - * @param ModuleRepository $moduleRepository - * @param int $shopId - */ - public function __construct( - AddonRepositoryInterface $addonRepository, - ModuleRepository $moduleRepository, - $shopId - ) { - $this->addonRepository = $addonRepository; - $this->moduleRepository = $moduleRepository; - $this->shopId = $shopId; - } - - /** - * {@inheritdoc} - */ - public function getPaymentModuleList() - { - $filters = (new AddonListFilter()) - ->setType(AddonListFilterType::MODULE) - ->setStatus(AddonListFilterStatus::INSTALLED); - - $modules = $this->addonRepository->getFilteredList($filters); - $paymentModules = []; - - /** @var Module $module */ - foreach ($modules as $module) { - if ($module->attributes->get('is_paymentModule')) { - $restrictedCountries = $this->moduleRepository->findRestrictedCountryIds( - $module->database->get('id'), - $this->shopId - ); - $restrictedCurrencies = $this->moduleRepository->findRestrictedCurrencyIds( - $module->database->get('id'), - $this->shopId - ); - $restrictedGroups = $this->moduleRepository->findRestrictedGroupIds( - $module->database->get('id'), - $this->shopId - ); - $restrictedCarriers = $this->moduleRepository->findRestrictedCarrierReferenceIds( - $module->database->get('id'), - $this->shopId - ); - - $module->attributes->set('countries', $restrictedCountries); - $module->attributes->set('currencies', $restrictedCurrencies); - $module->attributes->set('groups', $restrictedGroups); - $module->attributes->set('carriers', $restrictedCarriers); - - $paymentModules[$module->attributes->get('name')] = $module; - } - } - - return $paymentModules; - } -} diff --git a/src/Adapter/Module/Presenter/PaymentModulesPresenter.php b/src/Adapter/Module/Presenter/PaymentModulesPresenter.php deleted file mode 100644 index c2059c05..00000000 --- a/src/Adapter/Module/Presenter/PaymentModulesPresenter.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module\Presenter; - -use PrestaShop\PrestaShop\Adapter\Module\ModuleDataProvider; -use PrestaShop\PrestaShop\Adapter\Presenter\PresenterInterface; -use PrestaShop\PrestaShop\Core\Addon\Module\ModuleRepository; -use PrestaShop\PrestaShop\Core\Module\DataProvider\TabModuleListProviderInterface; - -/** - * Class PaymentModulesPresenter is responsible for presenting payment modules. - */ -class PaymentModulesPresenter -{ - /** - * @var string It will use legacy controller name to get payment modules for controller - */ - const PAYMENT_METHODS_CONTROLLER = 'AdminPayment'; - - /** - * @var TabModuleListProviderInterface - */ - private $tabModuleListProvider; - - /** - * @var ModuleDataProvider - */ - private $moduleDataProvider; - - /** - * @var PresenterInterface - */ - private $modulePresenter; - - /** - * @var ModuleRepository - */ - private $moduleRepository; - - /** - * @param TabModuleListProviderInterface $tabModuleListProvider - * @param ModuleDataProvider $moduleDataProvider - * @param PresenterInterface $modulePresenter - * @param ModuleRepository $moduleRepository - */ - public function __construct( - TabModuleListProviderInterface $tabModuleListProvider, - ModuleDataProvider $moduleDataProvider, - PresenterInterface $modulePresenter, - ModuleRepository $moduleRepository - ) { - $this->tabModuleListProvider = $tabModuleListProvider; - $this->moduleDataProvider = $moduleDataProvider; - $this->modulePresenter = $modulePresenter; - $this->moduleRepository = $moduleRepository; - } - - /** - * Get presented payment modules. - * - * @return array - */ - public function present() - { - $tabModuleNames = $this->tabModuleListProvider->getTabModules(self::PAYMENT_METHODS_CONTROLLER); - - $installedModules = $this->moduleRepository->getInstalledModules(); - $installedModuleNames = array_keys($installedModules); - - $paymentModulesToDisplay = []; - foreach ($tabModuleNames as $moduleName) { - if (!in_array($moduleName, $installedModuleNames) || - !$this->moduleDataProvider->can('configure', $moduleName) - ) { - continue; - } - - $installedModule = $installedModules[$moduleName]; - if ($installedModule->database->get('active')) { - $paymentModulesToDisplay[] = $this->modulePresenter->present($installedModule); - } - } - - return $paymentModulesToDisplay; - } -} diff --git a/src/Adapter/Module/PrestaTrust/ModuleEventSubscriber.php b/src/Adapter/Module/PrestaTrust/ModuleEventSubscriber.php deleted file mode 100644 index 99bd1be7..00000000 --- a/src/Adapter/Module/PrestaTrust/ModuleEventSubscriber.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module\PrestaTrust; - -use PrestaShopBundle\Event\ModuleZipManagementEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * This class subscribes to the events module installation / uninstallation - * in order to install or remove its tabs as well. - */ -class ModuleEventSubscriber implements EventSubscriberInterface -{ - /** - * @var PrestaTrustChecker - */ - private $checker; - - /** - * These events can be enabled/disabled via the config file. - * - * @var bool - */ - private $enabled; - - public function __construct(PrestaTrustChecker $checker) - { - $this->checker = $checker; - } - - /** - * {@inheritdoc} - */ - public static function getSubscribedEvents() - { - return [ - ModuleZipManagementEvent::DOWNLOAD => 'onNewModule', - ]; - } - - /** - * Event executed on module download (coming from the marketplace or the employee disk) - * If the feature is enabled in the project configuration, we will trigger our class PrestaTrustChecker to verify - * if the module is compliant. - * - * @param ModuleZipManagementEvent $event - */ - public function onNewModule(ModuleZipManagementEvent $event) - { - if (!$this->enabled) { - return; - } - - $this->checker->checkModuleZip($event->getModuleZip()); - } - - /** - * Check if the feature is enabled. - * - * @return bool - */ - public function isEnabled() - { - return $this->enabled; - } - - /** - * Enable / disable the PrestaTrust feature. - * - * @param bool $enabled - * - * @return $this - */ - public function setEnabled($enabled) - { - $this->enabled = (bool) $enabled; - - return $this; - } -} diff --git a/src/Adapter/Module/PrestaTrust/PrestaTrustChecker.php b/src/Adapter/Module/PrestaTrust/PrestaTrustChecker.php deleted file mode 100644 index 238f715e..00000000 --- a/src/Adapter/Module/PrestaTrust/PrestaTrustChecker.php +++ /dev/null @@ -1,273 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module\PrestaTrust; - -use Doctrine\Common\Cache\Cache; -use Exception; -use PrestaShop\PrestaShop\Adapter\Module\Module; -use PrestaShop\PrestaShop\Adapter\Module\ModuleZip; -use PrestaShopBundle\Service\DataProvider\Marketplace\ApiClient; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Translation\TranslatorInterface; -use ZipArchive; - -/** - * Responsible of Module verification by PrestaTrust system. - */ -class PrestaTrustChecker -{ - /** - * @var array - */ - protected $checked_extensions = ['php', 'js', 'css', 'tpl']; - - const SMART_CONTRACT_PATTERN = 'prestatrust-license-verification: '; - const CHECKS_ALL_OK = 'Module is authenticated.'; - const CHECKS_INTEGRITY_NOK = 'Warning, the module has been modified since its purchase from the Addons Marketplace.'; - const CHECKS_PROPERTY_NOK = 'Warning, the purchase proof is invalid. This license has already been used on another shop.'; - const CHECKS_ALL_NOK = 'Warning, the module has been modified and its purchase proof is invalid.'; - - /** - * @var Cache - */ - protected $cache; - - /** - * Addons marketplace API client. - * - * @var ApiClient - */ - protected $apiClient; - - /** - * @var TranslatorInterface - */ - protected $translator; - - /** - * @param Cache $cache Cache provider to keep data between two requests - * @param ApiClient $apiClient Addons Marketplace API client (Guzzle) - * @param TranslatorInterface $translator Translator for explanation messages - */ - public function __construct(Cache $cache, ApiClient $apiClient, TranslatorInterface $translator) - { - $this->cache = $cache; - $this->apiClient = $apiClient; - $this->translator = $translator; - } - - /** - * If the module is compliant, this class generates and adds all PrestaTrust related details. - * If not, the module remains untouched. We do not execute checks to avoid slow performances. - * - * @param Module $module - */ - public function loadDetailsIntoModule(Module $module) - { - if (!$this->isCompliant($module)) { - return; - } - - if (!$this->cache->contains($module->get('name'))) { - return; - } - - // Merge 2 existing sources of data - $details = (object) array_merge((array) $module->get('prestatrust', new \stdClass()), (array) $this->cache->fetch($module->get('name'))); - - $details->check_list = $this->requestCheck($details->hash, $this->findSmartContrat($module->disk->get('path'))); - $details->status = array_sum($details->check_list) == count($details->check_list); // True if all content is True - $details->message = $this->translator->trans($this->getMessage($details->check_list), [], 'Admin.Modules.Notification'); - - $module->set('prestatrust', $details); - } - - /** - * This function, called by the "module download" event, will look at the uploaded zip before its deletion. - * Looking at the original content (before unzipping) allows us to make sure we do not have altered content - * or remaining one from another zip. - * Any module copy pasted in the module folder won't go through this function. - * - * @param string $name Module technical name - * @param string $zipFile Module Zip location - */ - public function checkModuleZip(ModuleZip $zipFile) - { - // Do we need to check something in order to validate only PrestaTrust related modules? - - $details = new \stdClass(); - $details->hash = $this->calculateHash($zipFile->getSource()); - - $this->cache->save($zipFile->getName(), $details); - } - - /** - * Find all files with defined extensions, and calculate md5 from their content. - * - * @param string $zipFile Path to the module Zip file - * - * @return string Hash of the module - */ - protected function calculateHash($zipFile) - { - $preparehash = ''; - $zip = new ZipArchive(); - if (true !== $zip->open($zipFile)) { - return $preparehash; - } - - for ($i = 0; $i < $zip->numFiles; ++$i) { - $stat = $zip->statIndex($i); - $file_info = pathinfo($stat['name']); - - if (empty($file_info['filename']) || empty($file_info['extension'])) { - continue; - } - - if (in_array(trim($file_info['extension']), $this->checked_extensions)) { - $preparehash .= $zip->getFromName($file_info['dirname'] . '/' . $file_info['basename']); - } - } - $zip->close(); - - return hash('sha256', $preparehash); - } - - /** - * Find and return the smart contract address to be checked with the API. - * To find the address, we must find a file which matches the pattern "'prestatrust-license-verification:". - * The address will be found right after it, and must also match the file name. - * - * @param string $path Module root path - * - * @return string|null smart contract address, if found - */ - public function findSmartContrat($path) - { - $finder = Finder::create(); - $finder->files()->contains(self::SMART_CONTRACT_PATTERN)->in($path); - - // Get the first file in the results - foreach ($finder as $file) { - $sc = trim(str_replace(self::SMART_CONTRACT_PATTERN, '', $file->getContents())); - if ($sc === $file->getFilename()) { - return $sc; - } - } - - return null; - } - - /** - * Get message to display at the employee. It is used to explain briefly what is PrestaTrust and what - * went right (or wrong). - * - * @param array $check_list - * - * @return string Message displayed for confirmation - */ - protected function getMessage(array $check_list) - { - if ($check_list['integrity'] && $check_list['property']) { - return self::CHECKS_ALL_OK; - } - if (!$check_list['integrity'] && $check_list['property']) { - return self::CHECKS_INTEGRITY_NOK; - } - if ($check_list['integrity'] && !$check_list['property']) { - return self::CHECKS_PROPERTY_NOK; - } - - return self::CHECKS_ALL_NOK; - } - - /** - * Check if a module can be checked with PrestaTrust. To make it compliant, an attribute "author_address" - * must exist, start with "0x" and be 42 characters long. - * - * @param Module $module - * - * @return bool Module compliancy - */ - protected function isCompliant(Module $module) - { - if (!$module->attributes->has('author_address')) { - return false; - } - - $address = $module->attributes->get('author_address'); - - // Always ensure 0x prefix. - // Address should be 20bytes=40 HEX-chars + prefix. - if (!self::hasHexPrefix($address) || strlen($address) !== 42) { - return false; - } - - if (!function_exists('ctype_xdigit') || !ctype_xdigit(substr($address, strlen('0x')))) { - return false; - } - - return true; - } - - /** - * Check that the string starts with '0x'. - * - * @param string $str Author address - * - * @return bool True if starts with '0x' - */ - protected function hasHexPrefix($str) - { - $prefix = '0x'; - - return substr($str, 0, strlen($prefix)) === $prefix; - } - - /** - * Send to the Marketplace API our details about the module, and get results - * about its integrity and property. - * - * @param string $hash Calculted hash from the modules files - * @param string $contract Smart contract address from module - * - * @return array of check list results - */ - protected function requestCheck($hash, $contract) - { - try { - $result = $this->apiClient->getPrestaTrustCheck($hash, $contract); - - return [ - 'integrity' => (bool) ($result->hash_trusted), - 'property' => (bool) ($result->property_trusted), - ]; - } catch (Exception $e) { - return ['integrity' => false, 'property' => false]; - } - } -} diff --git a/src/Adapter/Module/Tab/ModuleTabManagementSubscriber.php b/src/Adapter/Module/Tab/ModuleTabManagementSubscriber.php deleted file mode 100644 index c0e8e4eb..00000000 --- a/src/Adapter/Module/Tab/ModuleTabManagementSubscriber.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module\Tab; - -use PrestaShopBundle\Event\ModuleManagementEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * This class subscribes to the events module installation / uninstallation - * in order to install or remove its tabs as well. - */ -class ModuleTabManagementSubscriber implements EventSubscriberInterface -{ - /** - * @var ModuleTabRegister - */ - private $moduleTabRegister; - /** - * @var ModuleTabUnregister - */ - private $moduleTabUnregister; - - public function __construct(ModuleTabRegister $moduleTabRegister, ModuleTabUnregister $moduleTabUnregister) - { - $this->moduleTabRegister = $moduleTabRegister; - $this->moduleTabUnregister = $moduleTabUnregister; - } - - /** - * {@inheritdoc} - */ - public static function getSubscribedEvents() - { - return [ - ModuleManagementEvent::INSTALL => 'onModuleInstall', - ModuleManagementEvent::UNINSTALL => 'onModuleUninstall', - ModuleManagementEvent::ENABLE => 'onModuleEnable', - ModuleManagementEvent::DISABLE => 'onModuleDisable', - ]; - } - - /** - * @param ModuleManagementEvent $event - */ - public function onModuleInstall(ModuleManagementEvent $event) - { - $this->moduleTabRegister->registerTabs($event->getModule()); - } - - /** - * @param ModuleManagementEvent $event - */ - public function onModuleUninstall(ModuleManagementEvent $event) - { - $this->moduleTabUnregister->unregisterTabs($event->getModule()); - } - - /** - * @param ModuleManagementEvent $event - */ - public function onModuleEnable(ModuleManagementEvent $event) - { - $this->moduleTabRegister->enableTabs($event->getModule()); - } - - /** - * @param ModuleManagementEvent $event - */ - public function onModuleDisable(ModuleManagementEvent $event) - { - $this->moduleTabUnregister->disableTabs($event->getModule()); - } -} diff --git a/src/Adapter/Module/Tab/ModuleTabRegister.php b/src/Adapter/Module/Tab/ModuleTabRegister.php deleted file mode 100644 index e90b4f06..00000000 --- a/src/Adapter/Module/Tab/ModuleTabRegister.php +++ /dev/null @@ -1,434 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module\Tab; - -use Exception; -use PrestaShop\PrestaShop\Adapter\Module\Module; -use PrestaShopBundle\Entity\Repository\LangRepository; -use PrestaShopBundle\Entity\Repository\TabRepository; -use Psr\Log\LoggerInterface; -use Symfony\Component\Config\Loader\LoaderInterface; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Finder\SplFileInfo; -use Symfony\Component\HttpFoundation\ParameterBag; -use Symfony\Component\Translation\TranslatorInterface; -use TabCore as Tab; - -/** - * Class responsible of register new tab in Back Office's menu. - */ -class ModuleTabRegister -{ - const SUFFIX = '_MTR'; - - /** - * @var string - */ - private $defaultParent = 'DEFAULT'; - - /** - * @var LangRepository - */ - protected $langRepository; - - /** - * @var TabRepository - */ - protected $tabRepository; - - /** - * @var \Psr\Log\LoggerInterface - */ - private $logger; - - /** - * @var \Symfony\Component\Translation\TranslatorInterface - */ - private $translator; - - /** - * @var Filesystem - */ - private $filesystem; - - /** - * @var array List all active languages on the shop - */ - private $languages; - - /** - * @var LoaderInterface - */ - private $routingConfigLoader; - - /** - * @param TabRepository $tabRepository - * @param LangRepository $langRepository - * @param LoggerInterface $logger - * @param TranslatorInterface $translator - * @param Filesystem $filesystem - * @param array $languages - * @param LoaderInterface $routingConfigLoader - */ - public function __construct( - TabRepository $tabRepository, - LangRepository $langRepository, - LoggerInterface $logger, - TranslatorInterface $translator, - Filesystem $filesystem, - array $languages, - LoaderInterface $routingConfigLoader - ) { - $this->langRepository = $langRepository; - $this->tabRepository = $tabRepository; - $this->logger = $logger; - $this->translator = $translator; - $this->filesystem = $filesystem; - $this->languages = $languages; - $this->routingConfigLoader = $routingConfigLoader; - } - - /** - * Fetch module-defined tabs and find undeclared ModuleAdminControllers. - * - * This is done automatically as part of the module installation. - * - * @param Module $module - */ - public function registerTabs(Module $module) - { - if (!$module->getInstance()) { - return; - } - - $tabs = $this->addUndeclaredTabs($module->get('name'), $module->getInstance()->getTabs()); - foreach ($tabs as $tab) { - try { - $this->registerTab($module, new ParameterBag($tab)); - } catch (Exception $e) { - $this->logger->error($e->getMessage()); - } - } - } - - /** - * @param Module $module - */ - public function enableTabs(Module $module) - { - $this->tabRepository->changeEnabledByModuleName($module->get('name'), true); - } - - /** - * Looks for ModuleAdminControllers not declared as Tab and - * add them to the list to register. - * - * @param string $moduleName - * @param array $tabs - * - * @return array - */ - protected function addUndeclaredTabs($moduleName, array $tabs) - { - // Function to get only class name from tabs already declared - $tabsNames = array_map(function ($tab) { - if (array_key_exists('class_name', $tab)) { - return $tab['class_name']; - } - }, $tabs); - - $detectedControllers = $this->getDetectedModuleControllers($moduleName); - foreach ($detectedControllers as $adminControllerName) { - if (in_array($adminControllerName, $tabsNames)) { - continue; - } - - if ($this->tabRepository->findOneIdByClassName($adminControllerName)) { - continue; - } - - $tabs[] = [ - 'class_name' => $adminControllerName, - 'visible' => false, - ]; - } - - return $tabs; - } - - /** - * Returns a list of all detected controllers, either from admin/controllers folder - * or from the routing file. - * - * @param string $moduleName - * - * @return array - * - * @throws Exception - */ - protected function getDetectedModuleControllers(string $moduleName): array - { - $legacyControllersFilenames = $this->getModuleAdminControllersFilename($moduleName); - $legacyControllers = array_map(function ($legacyControllersFilename) { - return str_replace('Controller.php', '', $legacyControllersFilename); - }, $legacyControllersFilenames); - $legacyControllers = $legacyControllers ?? []; - - $routingControllers = $this->getModuleControllersFromRouting($moduleName); - $routingControllers = $routingControllers ?? []; - - return array_merge($legacyControllers, $routingControllers); - } - - /** - * Check mandatory data for tab registration, such as class name and class exists. - * - * @param string $moduleName - * @param ParameterBag $data - * - * @return bool (= true) when no issue detected - * - * @throws Exception in case of invalid data - */ - protected function checkIsValid($moduleName, ParameterBag $data) - { - $className = $data->get('class_name', null); - if (null === $className) { - throw new Exception('Missing class name of tab'); - } - - // Check controller exists - $detectedControllers = $this->getDetectedModuleControllers($moduleName); - if (empty($data->get('route_name')) && !in_array($className, $detectedControllers)) { - throw new Exception(sprintf('Class "%sController" not found in controllers/admin nor routing file', $className)); - } - - // Deprecation check - if ($data->has('ParentClassName') && !$data->has('parent_class_name')) { - $this->logger->warning('Tab attribute "ParentClassName" is deprecated. You must use "parent_class_name" instead.'); - } - //Check if the tab was already added manually - if (!empty($this->tabRepository->findOneIdByClassName($className))) { - throw new Exception(sprintf('Cannot register tab "%s" because it already exists', $className)); - } - - return true; - } - - /** - * Find all ModuleAdminController classes from module. - * This allow to check a class exists for a registered tab and to register automatically all the classes - * not explicitely declared by the module developer. - * - * @param string $moduleName - * - * @return array of Symfony\Component\Finder\SplFileInfo, listing all the ModuleAdminControllers found - */ - protected function getModuleAdminControllers($moduleName) - { - $modulePath = _PS_ROOT_DIR_ . '/' . basename(_PS_MODULE_DIR_) . - '/' . $moduleName . '/controllers/admin/'; - - if (!$this->filesystem->exists($modulePath)) { - return []; - } - - $moduleFolder = Finder::create()->files() - ->in($modulePath) - ->depth('== 0') - ->name('*Controller.php') - ->exclude(['index.php']) - ->contains('/Controller\s+extends\s+/i'); - - return iterator_to_array($moduleFolder); - } - - /** - * Parses the routes file from the module and return the list of associated controller - * via the _legacy_controller routing option. - * - * @param string $moduleName - * - * @return string[] - * - * @throws Exception - */ - protected function getModuleControllersFromRouting(string $moduleName): array - { - $routingFile = _PS_ROOT_DIR_ . '/' . basename(_PS_MODULE_DIR_) . - '/' . $moduleName . '/config/routes.yml'; - - if (!$this->filesystem->exists($routingFile)) { - return []; - } - - $routingControllers = []; - $moduleRoutes = $this->routingConfigLoader->import($routingFile, 'yaml'); - foreach ($moduleRoutes->getIterator() as $route) { - $legacyController = $route->getDefault('_legacy_controller'); - if (!empty($legacyController)) { - $routingControllers[] = $legacyController; - } - } - - return $routingControllers; - } - - /** - * Convert SPLFileInfo array to file names. Better & easier to check if a class to register exists. - * - * @param string $moduleName - * - * @return array of strings - */ - protected function getModuleAdminControllersFilename($moduleName) - { - return array_map(function (SplFileInfo $file) { - return $file->getFilename(); - }, $this->getModuleAdminControllers($moduleName)); - } - - /** - * From the name given by the module maintainer, associate a value per language - * installed on the shop. - * - * @param mixed $names - * - * @return array Name to use for each installed language - */ - protected function getTabNames($names) - { - $translatedNames = []; - - foreach ($this->languages as $lang) { - // In case we just receive a string, we apply it to all languages - if (!is_array($names)) { - $translatedNames[$lang['id_lang']] = $names; - } elseif (array_key_exists($lang['locale'], $names)) { - $translatedNames[$lang['id_lang']] = $names[$lang['locale']]; - } elseif (array_key_exists($lang['language_code'], $names)) { - $translatedNames[$lang['id_lang']] = $names[$lang['language_code']]; - } elseif (array_key_exists($lang['iso_code'], $names)) { - $translatedNames[$lang['id_lang']] = $names[$lang['iso_code']]; - } else { - $translatedNames[$lang['id_lang']] = reset($names); // Get the first name available in the array - } - } - - return $translatedNames; - } - - /** - * Install a tab according to its defined structure. - * - * @param Module $module - * @param ParameterBag $tabDetails the structure of the tab - * - * @throws Exception in case of error from validation or save - */ - protected function registerTab(Module $module, ParameterBag $tabDetails) - { - $this->checkIsValid($module->get('name'), $tabDetails); - - /** - * Legacy Tab, to be replaced with Doctrine entity when right management - * won't be directly linked to the tab creation - * - * @ToDo - */ - $tab = new Tab(); - $tab->active = $tabDetails->getBoolean('visible', true); - $tab->enabled = true; - $tab->class_name = $tabDetails->get('class_name'); - $tab->route_name = $tabDetails->get('route_name'); - $tab->module = $module->get('name'); - $tab->name = $this->getTabNames($tabDetails->get('name', $tab->class_name)); - $tab->icon = $tabDetails->get('icon'); - $tab->id_parent = $this->findParentId($tabDetails); - - if (!$tab->save()) { - throw new Exception($this->translator->trans('Failed to install admin tab "%name%".', ['%name%' => $tab->name], 'Admin.Modules.Notification')); - } - } - - /** - * Find the parent ID from the given tab context. - * - * @param ParameterBag $tabDetails the structure of the tab - * - * @return int ID of the parent, 0 if none - */ - protected function findParentId(ParameterBag $tabDetails) - { - $idParent = 0; - $parentClassName = $tabDetails->get('parent_class_name', $tabDetails->get('ParentClassName')); - if (!empty($parentClassName)) { - // Could be a previously duplicated tab - $idParent = $this->tabRepository->findOneIdByClassName($parentClassName . self::SUFFIX); - if (!$idParent) { - $idParent = $this->tabRepository->findOneIdByClassName($parentClassName); - } - } elseif (true === $tabDetails->getBoolean('visible', true)) { - $idParent = $this->tabRepository->findOneIdByClassName($this->defaultParent); - } - - return $this->duplicateParentIfAlone((int) $idParent); - } - - /** - * When the tab you add is the first child of a parent tab, we must duplicate it in the children - * or its link will be overriden. - * - * @param int $idParent - * - * @return int new parent ID - */ - protected function duplicateParentIfAlone($idParent) - { - // If the given parent has already children, don't touch anything - if ($idParent === 0 || count($this->tabRepository->findByParentId($idParent))) { - return $idParent; - } - - $currentTab = new Tab($idParent); - $newTab = clone $currentTab; - $newTab->id = 0; - $newTab->id_parent = $currentTab->id_parent; - $newTab->class_name = $currentTab->class_name . self::SUFFIX; - $newTab->save(); - - // Second save in order to get the proper position (add() resets it) - $newTab->position = $currentTab->position; - $newTab->save(); - - $currentTab->id_parent = $newTab->id; - $currentTab->save(); - - return $newTab->id; - } -} diff --git a/src/Adapter/Module/Tab/ModuleTabUnregister.php b/src/Adapter/Module/Tab/ModuleTabUnregister.php deleted file mode 100644 index bc07c573..00000000 --- a/src/Adapter/Module/Tab/ModuleTabUnregister.php +++ /dev/null @@ -1,153 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module\Tab; - -use PrestaShop\PrestaShop\Adapter\Module\Module; -use PrestaShopBundle\Entity\Repository\LangRepository; -use PrestaShopBundle\Entity\Repository\TabRepository; -use PrestaShopBundle\Entity\Tab; -use Psr\Log\LoggerInterface; -use Symfony\Component\Translation\TranslatorInterface; -use Tab as TabClass; - -/** - * Class responsible of unregister existing tabs of Back Office's menu. - */ -class ModuleTabUnregister -{ - /** - * @var LangRepository - */ - protected $langRepository; - - /** - * @var TabRepository - */ - protected $tabRepository; - - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @var TranslatorInterface - */ - private $translator; - - public function __construct(TabRepository $tabRepository, LangRepository $langRepository, LoggerInterface $logger, TranslatorInterface $translator) - { - $this->langRepository = $langRepository; - $this->tabRepository = $tabRepository; - $this->logger = $logger; - $this->translator = $translator; - } - - /** - * Uninstall all module-defined tabs. - * - * This is done automatically as part of the module uninstallation. - * - * @return bool returns true if the module tabs were successfully uninstalled, false if any of them failed to do so - */ - public function unregisterTabs(Module $module) - { - // We use the Tab repository to have only - // installed tabs related to the module - $tabs = $this->tabRepository->findByModule($module->get('name')); - - foreach ($tabs as $tab) { - $this->unregisterTab($tab); - $this->removeDuplicatedParent($tab); - } - } - - /** - * @param Module $module - */ - public function disableTabs(Module $module) - { - $this->tabRepository->changeEnabledByModuleName($module->get('name'), false); - } - - /** - * Uninstalls a tab given its defined structure. - * - * @param Tab $tab the instance of entity tab - */ - private function unregisterTab(Tab $tab) - { - // We need to use the legacy class because of the right management - $tab_legacy = new TabClass($tab->getId()); - - if (!$tab_legacy->delete()) { - $this->logger->warning( - $this->translator->trans( - 'Failed to uninstall admin tab "%name%".', - [ - '%name%' => $tab->getClassName(), - ], - 'Admin.Modules.Notification' - ) - ); - } - } - - /** - * When we add a level of children in the menu tabs, we created a dummy parent. - * We must delete it when it has no more children than the original tab. - * - * @param Tab $tab - */ - private function removeDuplicatedParent(Tab $tab) - { - $remainingChildren = $this->tabRepository->findByParentId($tab->getIdParent()); - // Or more than one children, the parent tab is still used. - // If there is no children, the deletion is likely to be done manually by the module. - if (count($remainingChildren) !== 1) { - return; - } - - $parent = $this->tabRepository->find($tab->getIdParent()); - $child = end($remainingChildren); - - // We know we have a tab to delete if the parent name is the remaining child name+_MTR - if ($parent->getClassName() === $child->getClassName() . ModuleTabRegister::SUFFIX) { - $legacyTabParent = new TabClass($parent->getId()); - // Setting a wrong id_parent will prevent the children to move - $legacyTabParent->id_parent = -1; - $legacyTabParent->delete(); - - $legacyTab = new TabClass($child->getId()); - $legacyTab->id_parent = $parent->getIdParent(); - $legacyTab->save(); - // Updating the id_parent will override the position, that's why we save 2 times - $legacyTab->position = $parent->getPosition(); - $legacyTab->save(); - } - } -} diff --git a/src/Adapter/Module/TabModuleListProvider.php b/src/Adapter/Module/TabModuleListProvider.php deleted file mode 100644 index 4f81748c..00000000 --- a/src/Adapter/Module/TabModuleListProvider.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Module; - -use PrestaShop\PrestaShop\Adapter\Entity\Tab; -use PrestaShop\PrestaShop\Core\Module\DataProvider\TabModuleListProviderInterface; - -/** - * Class TabModuleListProvider is responsible for providing tab modules. - */ -final class TabModuleListProvider implements TabModuleListProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getTabModules($tabClassName) - { - $tabId = Tab::getIdFromClassName($tabClassName); - $modules = Tab::getTabModulesList($tabId); - - return $modules['default_list']; - } -} diff --git a/src/Adapter/NewProducts/NewProductsProductSearchProvider.php b/src/Adapter/NewProducts/NewProductsProductSearchProvider.php deleted file mode 100644 index d1d2caf2..00000000 --- a/src/Adapter/NewProducts/NewProductsProductSearchProvider.php +++ /dev/null @@ -1,127 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\NewProducts; - -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchProviderInterface; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchResult; -use PrestaShop\PrestaShop\Core\Product\Search\SortOrder; -use PrestaShop\PrestaShop\Core\Product\Search\SortOrderFactory; -use Product; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Used to query the latest products, see NewProductsController in Front Office. - */ -class NewProductsProductSearchProvider implements ProductSearchProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var SortOrderFactory - */ - private $sortOrderFactory; - - public function __construct( - TranslatorInterface $translator - ) { - $this->translator = $translator; - $this->sortOrderFactory = new SortOrderFactory($this->translator); - } - - /** - * @param ProductSearchContext $context - * @param ProductSearchQuery $query - * @param string $type - * - * @return array - */ - private function getProductsOrCount( - ProductSearchContext $context, - ProductSearchQuery $query, - $type = 'products' - ) { - return Product::getNewProducts( - $context->getIdLang(), - $query->getPage(), - $query->getResultsPerPage(), - $type !== 'products', - $query->getSortOrder()->toLegacyOrderBy(), - $query->getSortOrder()->toLegacyOrderWay() - ); - } - - /** - * {@inheritdoc} - */ - public function runQuery( - ProductSearchContext $context, - ProductSearchQuery $query - ) { - if (!$products = $this->getProductsOrCount($context, $query, 'products')) { - $products = []; - } - $count = $this->getProductsOrCount($context, $query, 'count'); - - $result = new ProductSearchResult(); - - if (!empty($products)) { - $result - ->setProducts($products) - ->setTotalProductsCount($count); - - $result->setAvailableSortOrders( - [ - (new SortOrder('product', 'date_add', 'desc'))->setLabel( - $this->translator->trans('Date added, newest to oldest', [], 'Shop.Theme.Catalog') - ), - (new SortOrder('product', 'date_add', 'asc'))->setLabel( - $this->translator->trans('Date added, oldest to newest', [], 'Shop.Theme.Catalog') - ), - (new SortOrder('product', 'name', 'asc'))->setLabel( - $this->translator->trans('Name, A to Z', [], 'Shop.Theme.Catalog') - ), - (new SortOrder('product', 'name', 'desc'))->setLabel( - $this->translator->trans('Name, Z to A', [], 'Shop.Theme.Catalog') - ), - (new SortOrder('product', 'price', 'asc'))->setLabel( - $this->translator->trans('Price, low to high', [], 'Shop.Theme.Catalog') - ), - (new SortOrder('product', 'price', 'desc'))->setLabel( - $this->translator->trans('Price, high to low', [], 'Shop.Theme.Catalog') - ), - ] - ); - } - - return $result; - } -} diff --git a/src/Adapter/News/NewsDataProvider.php b/src/Adapter/News/NewsDataProvider.php deleted file mode 100644 index 89670123..00000000 --- a/src/Adapter/News/NewsDataProvider.php +++ /dev/null @@ -1,175 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\News; - -use Context; -use PrestaShop\CircuitBreaker\Contract\CircuitBreakerInterface; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\Country\CountryDataProvider; -use PrestaShop\PrestaShop\Adapter\Tools; -use PrestaShop\PrestaShop\Adapter\Validate; - -/** - * Provide the news from https://www.prestashop.com/blog/ - */ -class NewsDataProvider -{ - const NUM_ARTICLES = 2; - - const CLOSED_ALLOWED_FAILURES = 3; - const CLOSED_TIMEOUT_SECONDS = 3; - - const OPEN_ALLOWED_FAILURES = 3; - const OPEN_TIMEOUT_SECONDS = 3; - const OPEN_THRESHOLD_SECONDS = 86400; // 24 hours - - /** - * @var CircuitBreakerInterface - */ - private $circuitBreaker; - - /** - * @var Configuration - */ - private $configuration; - - /** - * @var int - */ - private $contextMode; - - /** - * @var CountryDataProvider - */ - private $countryDataProvider; - - /** - * @var Tools - */ - private $tools; - - /** - * @var Validate - */ - private $validate; - - /** - * NewsDataProvider constructor. - * - * @param CircuitBreakerInterface $circuitBreaker - * @param CountryDataProvider $countryDataProvider - * @param Tools $tools - * @param Configuration $configuration - * @param Validate $validate - * @param int $contextMode - */ - public function __construct( - CircuitBreakerInterface $circuitBreaker, - CountryDataProvider $countryDataProvider, - Tools $tools, - Configuration $configuration, - Validate $validate, - $contextMode - ) { - $this->circuitBreaker = $circuitBreaker; - $this->configuration = $configuration; - $this->contextMode = $contextMode; - $this->countryDataProvider = $countryDataProvider; - $this->tools = $tools; - $this->validate = $validate; - } - - /** - * @param string $isoCode - * - * @return array - * - * @throws \PrestaShopException - */ - public function getData($isoCode) - { - $data = ['has_errors' => true, 'rss' => []]; - $apiUrl = $this->configuration->get('_PS_API_URL_'); - - $blogXMLResponse = $this->circuitBreaker->call($apiUrl . '/rss/blog/blog-' . $isoCode . '.xml'); - - if (empty($blogXMLResponse)) { - $data['has_errors'] = false; - - return $data; - } - - $rss = @simplexml_load_string($blogXMLResponse); - if (!$rss) { - return $data; - } - - $articles_limit = self::NUM_ARTICLES; - - $shop_default_country_id = (int) $this->configuration->get('PS_COUNTRY_DEFAULT'); - $shop_default_iso_country = mb_strtoupper($this->countryDataProvider->getIsoCodebyId($shop_default_country_id), 'utf-8'); - $analytics_params = [ - 'utm_source' => 'back-office', - 'utm_medium' => 'rss', - 'utm_campaign' => 'back-office-' . $shop_default_iso_country, - ]; - - foreach ($rss->channel->item as $item) { - if ($articles_limit == 0) { - break; - } - if (!$this->validate->isCleanHtml((string) $item->title) - || !$this->validate->isCleanHtml((string) $item->description) - || empty($item->link) - || empty($item->title)) { - continue; - } - $analytics_params['utm_content'] = 'download'; - if (in_array($this->contextMode, [Context::MODE_HOST, Context::MODE_HOST_CONTRIB])) { - $analytics_params['utm_content'] = 'cloud'; - } - - $url_query = parse_url($item->link, PHP_URL_QUERY); - parse_str($url_query, $link_query_params); - $full_url_params = array_merge($link_query_params, $analytics_params); - $base_url = explode('?', (string) $item->link); - $base_url = (string) $base_url[0]; - $article_link = $base_url . '?' . http_build_query($full_url_params); - $date = strtotime($item->pubDate); - $data['rss'][] = [ - 'date' => $this->tools->displayDate(date('Y-m-d H:i:s', $date), null, false), - 'title' => htmlentities($item->title, ENT_QUOTES, 'utf-8'), - 'short_desc' => $this->tools->truncateString(strip_tags((string) $item->description), 150), - 'link' => (string) $article_link, - ]; - --$articles_limit; - } - $data['has_errors'] = false; - - return $data; - } -} diff --git a/src/Adapter/Notification/CommandHandler/UpdateEmployeeNotificationLastElementHandler.php b/src/Adapter/Notification/CommandHandler/UpdateEmployeeNotificationLastElementHandler.php deleted file mode 100644 index 9f554cb7..00000000 --- a/src/Adapter/Notification/CommandHandler/UpdateEmployeeNotificationLastElementHandler.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Notification\CommandHandler; - -use Notification; -use PrestaShop\PrestaShop\Core\Domain\Notification\Command\UpdateEmployeeNotificationLastElementCommand; -use PrestaShop\PrestaShop\Core\Domain\Notification\CommandHandler\UpdateEmployeeNotificationLastElementCommandHandlerInterface; - -/** - * Handle update employee's last notification element of a given type - * - * @internal - */ -final class UpdateEmployeeNotificationLastElementHandler implements UpdateEmployeeNotificationLastElementCommandHandlerInterface -{ - /** - * @param UpdateEmployeeNotificationLastElementCommand $command - */ - public function handle(UpdateEmployeeNotificationLastElementCommand $command) - { - (new Notification())->updateEmployeeLastElement($command->getType()->getValue()); - } -} diff --git a/src/Adapter/Notification/QueryHandler/GetNotificationLastElementsHandler.php b/src/Adapter/Notification/QueryHandler/GetNotificationLastElementsHandler.php deleted file mode 100644 index 4220d074..00000000 --- a/src/Adapter/Notification/QueryHandler/GetNotificationLastElementsHandler.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Notification\QueryHandler; - -use Notification; -use PrestaShop\PrestaShop\Core\Domain\Notification\Query\GetNotificationLastElements; -use PrestaShop\PrestaShop\Core\Domain\Notification\QueryHandler\GetNotificationLastElementsHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Notification\QueryResult\NotificationResult; -use PrestaShop\PrestaShop\Core\Domain\Notification\QueryResult\NotificationsResult; -use PrestaShop\PrestaShop\Core\Domain\Notification\QueryResult\NotificationsResults; - -/** - * Get employee last notification elements - * - * @internal - */ -final class GetNotificationLastElementsHandler implements GetNotificationLastElementsHandlerInterface -{ - /** - * @param GetNotificationLastElements $query - * - * @return NotificationsResults - * - * {@inheritdoc} - */ - public function handle(GetNotificationLastElements $query): NotificationsResults - { - $elements = (new Notification())->getLastElements(); - $results = []; - foreach ($elements as $type => $notifications) { - $notificationsResult = []; - foreach ($notifications['results'] as $notification) { - $notificationsResult[] = new NotificationResult( - $notification['id_order'], - $notification['id_customer'], - $notification['customer_name'], - $notification['id_customer_message'], - $notification['id_customer_thread'], - $notification['customer_view_url'], - $notification['total_paid'], - $notification['carrier'], - $notification['iso_code'], - $notification['company'], - $notification['status'], - $notification['date_add'] - ); - } - $results[] = new NotificationsResult($type, $notifications['total'], $notificationsResult); - } - - return new NotificationsResults($results); - } -} diff --git a/src/Adapter/Number/RoundModeConverter.php b/src/Adapter/Number/RoundModeConverter.php deleted file mode 100644 index 8f0469e1..00000000 --- a/src/Adapter/Number/RoundModeConverter.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Number; - -use PrestaShop\Decimal\Operation\Rounding; -use PrestaShop\PrestaShop\Adapter\CoreException; - -class RoundModeConverter -{ - const MODE_MAP = [ - PS_ROUND_UP => Rounding::ROUND_CEIL, - PS_ROUND_DOWN => Rounding::ROUND_FLOOR, - PS_ROUND_HALF_UP => Rounding::ROUND_HALF_UP, - PS_ROUND_HALF_DOWN => Rounding::ROUND_HALF_DOWN, - PS_ROUND_HALF_EVEN => Rounding::ROUND_HALF_EVEN, - ]; - - /** - * @param int $legacyRoundMode - * - * @return string - * - * @throws CoreException - */ - public static function getNumberRoundMode(int $legacyRoundMode): string - { - if (!isset(static::MODE_MAP[$legacyRoundMode])) { - throw new CoreException(sprintf('Cannot map round mode %d', $legacyRoundMode)); - } - - return static::MODE_MAP[$legacyRoundMode]; - } -} diff --git a/src/Adapter/ObjectPresenter.php b/src/Adapter/ObjectPresenter.php deleted file mode 100644 index e1bd8c61..00000000 --- a/src/Adapter/ObjectPresenter.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -/** - * @deprecated since 1.7.4.0 - * @see \PrestaShop\PrestaShop\Adapter\Presenter\Object\ObjectPresenter - */ -class ObjectPresenter extends \PrestaShop\PrestaShop\Adapter\Presenter\Object\ObjectPresenter -{ -} diff --git a/src/Adapter/OptionalFeatures/OptionalFeaturesConfiguration.php b/src/Adapter/OptionalFeatures/OptionalFeaturesConfiguration.php deleted file mode 100644 index db432699..00000000 --- a/src/Adapter/OptionalFeatures/OptionalFeaturesConfiguration.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\OptionalFeatures; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\Feature\CombinationFeature; -use PrestaShop\PrestaShop\Adapter\Feature\FeatureFeature; -use PrestaShop\PrestaShop\Adapter\Feature\GroupFeature; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * This class will provide Optional features configuration for a Shop. - */ -class OptionalFeaturesConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - /** - * @var CombinationFeature - */ - private $combinationFeature; - - /** - * @var FeatureFeature - */ - private $featureFeature; - - /** - * @var GroupFeature - */ - private $groupFeature; - - public function __construct( - Configuration $configuration, - CombinationFeature $combinationFeature, - FeatureFeature $featureFeature, - GroupFeature $groupFeature - ) { - $this->configuration = $configuration; - $this->combinationFeature = $combinationFeature; - $this->featureFeature = $featureFeature; - $this->groupFeature = $groupFeature; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'combinations' => $this->combinationFeature->isActive(), - 'features' => $this->featureFeature->isActive(), - 'customer_groups' => $this->groupFeature->isActive(), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - if ($this->validateConfiguration($configuration)) { - $this->combinationFeature->update((bool) $configuration['combinations']); - $this->featureFeature->update((bool) $configuration['features']); - $this->groupFeature->update((bool) $configuration['customer_groups']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['combinations'], - $configuration['features'], - $configuration['customer_groups'] - ); - } -} diff --git a/src/Adapter/Order/AbstractOrderHandler.php b/src/Adapter/Order/AbstractOrderHandler.php deleted file mode 100644 index 71f99073..00000000 --- a/src/Adapter/Order/AbstractOrderHandler.php +++ /dev/null @@ -1,176 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order; - -use Address; -use Cart; -use Combination; -use Configuration; -use Currency; -use Customer; -use Group; -use Order; -use PrestaShop\PrestaShop\Adapter\Number\RoundModeConverter; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; -use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; -use PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision; -use PrestaShopException; -use Product; -use Validate; - -/** - * Reusable methods for Order subdomain command/query handlers. - */ -abstract class AbstractOrderHandler -{ - /** - * @param OrderId $orderId - * - * @return Order - */ - protected function getOrder(OrderId $orderId) - { - try { - $order = new Order($orderId->getValue()); - } catch (PrestaShopException $e) { - throw new OrderException( - sprintf( - 'Error occured when trying to get order object #%s', - $orderId->getValue() - ), - 0, - $e - ); - } - - if ($order->id !== $orderId->getValue()) { - throw new OrderNotFoundException($orderId, sprintf('Order with id "%d" was not found.', $orderId->getValue())); - } - - return $order; - } - - /** - * @param Order $order - * - * @return bool - */ - protected function isTaxIncludedInOrder(Order $order): bool - { - return $this->getOrderTaxCalculationMethod($order) === PS_TAX_INC; - } - - /** - * @param Order $order - * - * @return int - */ - protected function getOrderTaxCalculationMethod(Order $order): int - { - $customer = new Customer($order->id_customer); - - return Group::getPriceDisplayMethod((int) $customer->id_default_group); - } - - /** - * @param Cart $cart - * - * @return int - */ - protected function getPrecisionFromCart(Cart $cart): int - { - $computingPrecision = new ComputingPrecision(); - $currency = new Currency((int) $cart->id_currency); - - return $computingPrecision->getPrecision($currency->precision); - } - - /** - * @param int $combinationId - * - * @return Combination|null - */ - protected function getCombination(int $combinationId) - { - $combination = null; - - if (0 !== $combinationId) { - $combination = new Combination($combinationId); - - if (!Validate::isLoadedObject($combination)) { - throw new OrderException('Product combination not found.'); - } - } - - return $combination; - } - - /** - * @param ProductId $productId - * @param int $langId - * - * @return Product - */ - protected function getProduct(ProductId $productId, $langId) - { - $product = new Product($productId->getValue(), false, $langId); - - if ($product->id !== $productId->getValue()) { - throw new OrderException(sprintf('Product with id "%d" is invalid.', $productId->getValue())); - } - - return $product; - } - - /** - * @return string - */ - protected function getNumberRoundMode(): string - { - return RoundModeConverter::getNumberRoundMode((int) Configuration::get('PS_PRICE_ROUND_MODE')); - } - - /** - * Delivery option consists of deliveryAddress and carrierId. - * - * Legacy multishipping feature used comma separated carriers in delivery option (e.g. {'1':'6,7'} - * Now that multishipping is gone - delivery option should consist of one carrier and one address. - * - * However the structure of deliveryOptions is still used with comma in legacy, so - * this method provides assurance for deliveryOption structure until major refactoring - * - * @param int $carrierId - * - * @return string - */ - protected function formatLegacyDeliveryOptionFromCarrierId(int $carrierId): string - { - return sprintf('%d,', $carrierId); - } -} diff --git a/src/Adapter/Order/CommandHandler/AbstractOrderCommandHandler.php b/src/Adapter/Order/CommandHandler/AbstractOrderCommandHandler.php deleted file mode 100644 index fe53852f..00000000 --- a/src/Adapter/Order/CommandHandler/AbstractOrderCommandHandler.php +++ /dev/null @@ -1,224 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Address; -use Cart; -use Configuration; -use Context; -use Country; -use Currency; -use Customer; -use Language; -use Order; -use OrderDetail; -use Pack; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Adapter\Order\AbstractOrderHandler; -use PrestaShop\PrestaShop\Adapter\StockManager; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use Product; -use Shop; -use StockAvailable; -use StockManagerFactory; -use StockMvt; -use Warehouse; - -/** - * Abstracts reusable functionality for Order subdomain handlers. - * - * @internal - */ -abstract class AbstractOrderCommandHandler extends AbstractOrderHandler -{ - /** - * @param OrderDetail $orderDetail - * @param int $productQuantity - * @param bool $delete - */ - protected function reinjectQuantity(OrderDetail $orderDetail, $productQuantity, $delete = false) - { - // Reinject product - $reinjectableQuantity = (int) $orderDetail->product_quantity - (int) $orderDetail->product_quantity_reinjected; - $quantityToReinject = $productQuantity > $reinjectableQuantity ? $reinjectableQuantity : $productQuantity; - - $product = new Product( - $orderDetail->product_id, - false, - (int) Context::getContext()->language->id, - (int) $orderDetail->id_shop - ); - - if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') - && $product->advanced_stock_management - && $orderDetail->id_warehouse != 0 - ) { - $manager = StockManagerFactory::getManager(); - $movements = StockMvt::getNegativeStockMvts( - $orderDetail->id_order, - $orderDetail->product_id, - $orderDetail->product_attribute_id, - $quantityToReinject - ); - - foreach ($movements as $movement) { - if ($quantityToReinject > $movement['physical_quantity']) { - $quantityToReinject = $movement['physical_quantity']; - } - - if (Pack::isPack((int) $product->id)) { - // Gets items - if ($product->pack_stock_type == Pack::STOCK_TYPE_PRODUCTS_ONLY - || $product->pack_stock_type == Pack::STOCK_TYPE_PACK_BOTH - || ($product->pack_stock_type == Pack::STOCK_TYPE_DEFAULT - && Configuration::get('PS_PACK_STOCK_TYPE') > 0) - ) { - $products_pack = Pack::getItems((int) $product->id, (int) Configuration::get('PS_LANG_DEFAULT')); - // Foreach item - foreach ($products_pack as $product_pack) { - if ($product_pack->advanced_stock_management == 1) { - $manager->addProduct( - $product_pack->id, - $product_pack->id_pack_product_attribute, - new Warehouse($movement['id_warehouse']), - $product_pack->pack_quantity * $quantityToReinject, - null, - $movement['price_te'] - ); - } - } - } - - if ($product->pack_stock_type == Pack::STOCK_TYPE_PACK_ONLY - || $product->pack_stock_type == Pack::STOCK_TYPE_PACK_BOTH - || ( - $product->pack_stock_type == Pack::STOCK_TYPE_DEFAULT - && (Configuration::get('PS_PACK_STOCK_TYPE') == Pack::STOCK_TYPE_PACK_ONLY - || Configuration::get('PS_PACK_STOCK_TYPE') == Pack::STOCK_TYPE_PACK_BOTH) - ) - ) { - $manager->addProduct( - $orderDetail->product_id, - $orderDetail->product_attribute_id, - new Warehouse($movement['id_warehouse']), - $quantityToReinject, - null, - $movement['price_te'] - ); - } - } else { - $manager->addProduct( - $orderDetail->product_id, - $orderDetail->product_attribute_id, - new Warehouse($movement['id_warehouse']), - $quantityToReinject, - null, - $movement['price_te'] - ); - } - } - - $productId = $orderDetail->product_id; - - if ($delete) { - $orderDetail->delete(); - } - - StockAvailable::synchronize($productId); - } elseif ($orderDetail->id_warehouse == 0) { - StockAvailable::updateQuantity( - $orderDetail->product_id, - $orderDetail->product_attribute_id, - $quantityToReinject, - $orderDetail->id_shop, - true, - [ - 'id_order' => $orderDetail->id_order, - 'id_stock_mvt_reason' => Configuration::get('PS_STOCK_CUSTOMER_RETURN_REASON'), - ] - ); - - // sync all stock - (new StockManager())->updatePhysicalProductQuantity( - (int) $orderDetail->id_shop, - (int) Configuration::get('PS_OS_ERROR'), - (int) Configuration::get('PS_OS_CANCELED'), - null, - (int) $orderDetail->id_order - ); - - if ($delete) { - $orderDetail->delete(); - } - } else { - throw new OrderException('This product cannot be re-stocked.'); - } - } - - /** - * @param ContextStateManager $contextStateManager - * @param Cart $cart - */ - protected function setCartContext(ContextStateManager $contextStateManager, Cart $cart): void - { - $contextStateManager - ->setCart($cart) - ->setCustomer(new Customer($cart->id_customer)) - ->setCurrency(new Currency($cart->id_currency)) - ->setLanguage(new Language($cart->id_lang)) - ->setCountry($this->getCartTaxCountry($cart)) - ->setShop(new Shop($cart->id_shop)) - ; - } - - /** - * @param ContextStateManager $contextStateManager - * @param Order $order - */ - protected function setOrderContext(ContextStateManager $contextStateManager, Order $order): void - { - $cart = new Cart($order->id_cart); - $this->setCartContext($contextStateManager, $cart); - } - - /** - * @param Cart $cart - * - * @return Country - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - protected function getCartTaxCountry(Cart $cart): Country - { - $taxAddressType = Configuration::get('PS_TAX_ADDRESS_TYPE'); - $taxAddressId = property_exists($cart, $taxAddressType) ? $cart->{$taxAddressType} : $cart->id_address_delivery; - $taxAddress = new Address($taxAddressId); - - return new Country($taxAddress->id_country); - } -} diff --git a/src/Adapter/Order/CommandHandler/AddCartRuleToOrderHandler.php b/src/Adapter/Order/CommandHandler/AddCartRuleToOrderHandler.php deleted file mode 100644 index 2521a647..00000000 --- a/src/Adapter/Order/CommandHandler/AddCartRuleToOrderHandler.php +++ /dev/null @@ -1,266 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Cart; -use CartRule; -use Configuration; -use Currency; -use Customer; -use Order; -use OrderInvoice; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Adapter\Order\AbstractOrderHandler; -use PrestaShop\PrestaShop\Adapter\Order\OrderAmountUpdater; -use PrestaShop\PrestaShop\Core\Domain\CartRule\Exception\InvalidCartRuleDiscountValueException; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\AddCartRuleToOrderCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\AddCartRuleToOrderHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\OrderDiscountType; -use PrestaShopException; -use Shop; -use Validate; - -/** - * @internal - */ -final class AddCartRuleToOrderHandler extends AbstractOrderHandler implements AddCartRuleToOrderHandlerInterface -{ - /** - * @var OrderAmountUpdater - */ - private $orderAmountUpdater; - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @param OrderAmountUpdater $orderAmountUpdater - * @param ContextStateManager $contextStateManager - */ - public function __construct(OrderAmountUpdater $orderAmountUpdater, ContextStateManager $contextStateManager) - { - $this->orderAmountUpdater = $orderAmountUpdater; - $this->contextStateManager = $contextStateManager; - } - - /** - * {@inheritdoc} - */ - public function handle(AddCartRuleToOrderCommand $command): void - { - $this->assertPercentCartRule($command); - $order = $this->getOrder($command->getOrderId()); - - $this->contextStateManager - ->setCurrency(new Currency($order->id_currency)) - ->setCustomer(new Customer($order->id_customer)) - ->setShop(new Shop($order->id_shop)) - ; - - try { - $this->addCartRuleAndUpdateOrder($command, $order); - } finally { - $this->contextStateManager->restorePreviousContext(); - } - } - - /** - * @param AddCartRuleToOrderCommand $command - * @param Order $order - * - * @return void - * - * @throws InvalidCartRuleDiscountValueException - * @throws OrderException - * @throws PrestaShopException - * @throws \PrestaShopDatabaseException - */ - private function addCartRuleAndUpdateOrder(AddCartRuleToOrderCommand $command, Order $order): void - { - // If the discount is for only one invoice - $orderInvoice = null; - if ($order->hasInvoice() && null !== $command->getOrderInvoiceId()) { - $orderInvoice = new OrderInvoice($command->getOrderInvoiceId()->getValue()); - if (!Validate::isLoadedObject($orderInvoice)) { - throw new OrderException('Can\'t load Order Invoice object'); - } - } - $this->assertAmountCartRule($command, $order, $orderInvoice); - $this->assertFreeShippingCartRule($command, $order, $orderInvoice); - - $cart = Cart::getCartByOrderId($order->id); - $cartRuleObj = new CartRule(); - $cartRuleObj->date_from = date('Y-m-d H:i:s', strtotime('-1 hour', strtotime($order->date_add))); - $cartRuleObj->date_to = date('Y-m-d H:i:s', strtotime('+1 hour')); - $cartRuleObj->name[Configuration::get('PS_LANG_DEFAULT')] = $command->getCartRuleName(); - // This a one time cart rule, for a specific user that can only be used once - $cartRuleObj->id_customer = $cart->id_customer; - $cartRuleObj->quantity = 1; - $cartRuleObj->quantity_per_user = 1; - $cartRuleObj->active = 0; - $cartRuleObj->highlight = 0; - $cartRuleObj->reduction_currency = (int) $order->id_currency; - - if ($command->getCartRuleType() === OrderDiscountType::DISCOUNT_PERCENT) { - $cartRuleObj->reduction_percent = (float) (string) $command->getDiscountValue(); - } elseif ($command->getCartRuleType() === OrderDiscountType::DISCOUNT_AMOUNT) { - $discountValueTaxIncluded = (float) (string) $command->getDiscountValue(); - $cartRuleObj->reduction_amount = $discountValueTaxIncluded; - $cartRuleObj->reduction_tax = 1; - } elseif ($command->getCartRuleType() === OrderDiscountType::FREE_SHIPPING) { - $cartRuleObj->free_shipping = 1; - } - - try { - if (!$cartRuleObj->add()) { - throw new OrderException('An error occurred during the CartRule creation'); - } - } catch (PrestaShopException $e) { - throw new OrderException('An error occurred during the CartRule creation', 0, $e); - } - - try { - // It's important to add the cart rule to the cart Or it will be ignored when cart performs AutoRemove AddAdd - if (!$cart->addCartRule($cartRuleObj->id)) { - throw new OrderException('An error occurred while adding CartRule to cart'); - } - } catch (PrestaShopException $e) { - throw new OrderException('An error occurred while adding CartRule to cart', 0, $e); - } - - $this->orderAmountUpdater->update($order, $cart, null !== $orderInvoice ? (int) $orderInvoice->id : null); - } - - /** - * @param AddCartRuleToOrderCommand $command - * - * @throws InvalidCartRuleDiscountValueException - */ - private function assertPercentCartRule(AddCartRuleToOrderCommand $command): void - { - if (OrderDiscountType::DISCOUNT_PERCENT !== $command->getCartRuleType()) { - return; - } - - $discountValue = (float) (string) $command->getDiscountValue(); - if ($discountValue <= 0) { - throw new InvalidCartRuleDiscountValueException( - 'Percent value must be greater than 0', - InvalidCartRuleDiscountValueException::INVALID_MIN_PERCENT - ); - } elseif ($discountValue > 100) { - throw new InvalidCartRuleDiscountValueException( - 'Percent value must be less than 100', - InvalidCartRuleDiscountValueException::INVALID_MAX_PERCENT - ); - } - } - - /** - * @param AddCartRuleToOrderCommand $command - * @param Order $order - * @param OrderInvoice|null $orderInvoice - * - * @throws InvalidCartRuleDiscountValueException - */ - private function assertAmountCartRule(AddCartRuleToOrderCommand $command, Order $order, ?OrderInvoice $orderInvoice): void - { - if (OrderDiscountType::DISCOUNT_AMOUNT !== $command->getCartRuleType()) { - return; - } - - if (null === $command->getDiscountValue() || $command->getDiscountValue()->isLowerOrEqualThanZero()) { - throw new InvalidCartRuleDiscountValueException( - 'Discount amount specified is not positive', - InvalidCartRuleDiscountValueException::INVALID_MIN_AMOUNT - ); - } - - $discountValue = (float) (string) $command->getDiscountValue(); - if (null !== $orderInvoice) { - $orderInvoices = [$orderInvoice]; - } elseif ($order->hasInvoice()) { - $orderInvoices = $order->getInvoicesCollection()->getResults(); - } - if (!empty($orderInvoices)) { - foreach ($orderInvoices as $invoice) { - if ($discountValue > $invoice->total_paid_tax_incl) { - throw new InvalidCartRuleDiscountValueException( - 'Discount amount specified is too high', - InvalidCartRuleDiscountValueException::INVALID_MAX_AMOUNT - ); - } - } - } else { - if ($discountValue > $order->total_paid_tax_incl) { - throw new InvalidCartRuleDiscountValueException( - 'Discount amount specified is too high', - InvalidCartRuleDiscountValueException::INVALID_MAX_AMOUNT - ); - } - } - } - - /** - * @param AddCartRuleToOrderCommand $command - * @param Order $order - * @param OrderInvoice|null $orderInvoice - * - * @throws InvalidCartRuleDiscountValueException - */ - private function assertFreeShippingCartRule(AddCartRuleToOrderCommand $command, Order $order, ?OrderInvoice $orderInvoice): void - { - if (OrderDiscountType::FREE_SHIPPING !== $command->getCartRuleType()) { - return; - } - - if (null !== $orderInvoice) { - $orderInvoices = [$orderInvoice]; - } elseif ($order->hasInvoice()) { - $orderInvoices = $order->getInvoicesCollection()->getResults(); - } - if (!empty($orderInvoices)) { - foreach ($orderInvoices as $invoice) { - if ($invoice->total_paid_tax_incl <= $invoice->total_shipping_tax_incl) { - throw new InvalidCartRuleDiscountValueException( - 'Discount amount specified is too high', - InvalidCartRuleDiscountValueException::INVALID_FREE_SHIPPING - ); - } - } - } else { - if ($order->total_paid_tax_incl <= $order->total_shipping_tax_incl) { - throw new InvalidCartRuleDiscountValueException( - 'Discount amount specified is too high', - InvalidCartRuleDiscountValueException::INVALID_FREE_SHIPPING - ); - } - } - } -} diff --git a/src/Adapter/Order/CommandHandler/AddOrderFromBackOfficeHandler.php b/src/Adapter/Order/CommandHandler/AddOrderFromBackOfficeHandler.php deleted file mode 100644 index 72e4066c..00000000 --- a/src/Adapter/Order/CommandHandler/AddOrderFromBackOfficeHandler.php +++ /dev/null @@ -1,195 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Address; -use BoOrderCore; -use Cart; -use Configuration; -use Context; -use Country; -use Currency; -use Customer; -use Employee; -use Exception; -use Language; -use Message; -use Module; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\AddOrderFromBackOfficeCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\AddOrderFromBackOfficeHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; -use Shop; -use Validate; - -/** - * @internal - */ -final class AddOrderFromBackOfficeHandler implements AddOrderFromBackOfficeHandlerInterface -{ - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @param ContextStateManager $contextStateManager - */ - public function __construct(ContextStateManager $contextStateManager) - { - $this->contextStateManager = $contextStateManager; - } - - /** - * {@inheritdoc} - */ - public function handle(AddOrderFromBackOfficeCommand $command) - { - $paymentModule = !Configuration::get('PS_CATALOG_MODE') ? - Module::getInstanceByName($command->getPaymentModuleName()) : - new BoOrderCore(); - - if (false === $paymentModule) { - throw new OrderException(sprintf('Payment method "%s" does not exist.', $paymentModule)); - } - - $cart = new Cart($command->getCartId()->getValue()); - - $this->assertAddressesAreNotDisabled($cart); - - //Context country, language and currency is used in PaymentModule::validateOrder (it should rely on cart address country instead) - $this->contextStateManager - ->setCart($cart) - ->setCurrency(new Currency($cart->id_currency)) - ->setCustomer(new Customer($cart->id_customer)) - ->setLanguage(new Language($cart->id_lang)) - ->setCountry($this->getTaxCountry($cart)) - ->setShop(new Shop($cart->id_shop)) - ; - - $translator = Context::getContext()->getTranslator(); - $employee = new Employee($command->getEmployeeId()->getValue()); - $message = sprintf( - '%s %s. %s', - $translator->trans('Manual order -- Employee:', [], 'Admin.Orderscustomers.Feature'), - $employee->firstname[0], - $employee->lastname - ); - - try { - $orderMessage = $command->getOrderMessage(); - if (!empty($orderMessage)) { - $this->addOrderMessage($cart, $orderMessage); - } - - $paymentModule->validateOrder( - (int) $cart->id, - $command->getOrderStateId(), - $cart->getOrderTotal(), - $paymentModule->displayName, - $message, - [], - null, - false, - $cart->secure_key - ); - } catch (Exception $e) { - throw new OrderException('Failed to add order. ' . $e->getMessage(), 0, $e); - } finally { - $this->contextStateManager->restorePreviousContext(); - } - - if (!$paymentModule->currentOrder) { - throw new OrderException('Failed to add order.'); - } - - return new OrderId((int) $paymentModule->currentOrder); - } - - /** - * Saves customer message and link it to the cart. - * - * @param Cart $cart - * @param string $orderMessage - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - * @throws OrderConstraintException - */ - private function addOrderMessage(Cart $cart, string $orderMessage): void - { - if (!Validate::isMessage($orderMessage)) { - throw new OrderConstraintException('The order message is invalid', OrderConstraintException::INVALID_CUSTOMER_MESSAGE); - } - - $messageId = null; - if ($oldMessage = Message::getMessageByCartId((int) $cart->id)) { - $messageId = $oldMessage['id_message']; - } - $message = new Message((int) $messageId); - $message->message = $orderMessage; - $message->id_cart = (int) $cart->id; - $message->id_customer = (int) $cart->id_customer; - $message->save(); - } - - /** - * @param Cart $cart - */ - private function assertAddressesAreNotDisabled(Cart $cart) - { - $isDeliveryCountryDisabled = !Address::isCountryActiveById((int) $cart->id_address_delivery); - $isInvoiceCountryDisabled = !Address::isCountryActiveById((int) $cart->id_address_invoice); - - if ($isDeliveryCountryDisabled) { - throw new OrderException(sprintf('Delivery country for cart with id "%d" is disabled.', $cart->id)); - } - - if ($isInvoiceCountryDisabled) { - throw new OrderException(sprintf('Invoice country for cart with id "%d" is disabled.', $cart->id)); - } - } - - /** - * @param Cart $cart - * - * @return Country - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - private function getTaxCountry(Cart $cart) - { - $taxAddressType = Configuration::get('PS_TAX_ADDRESS_TYPE'); - $taxAddressId = property_exists($cart, $taxAddressType) ? $cart->{$taxAddressType} : $cart->id_address_delivery; - $taxAddress = new Address($taxAddressId); - - return new Country($taxAddress->id_country); - } -} diff --git a/src/Adapter/Order/CommandHandler/AddPaymentHandler.php b/src/Adapter/Order/CommandHandler/AddPaymentHandler.php deleted file mode 100644 index 11583ed2..00000000 --- a/src/Adapter/Order/CommandHandler/AddPaymentHandler.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Currency; -use OrderInvoice; -use PrestaShop\PrestaShop\Adapter\Order\AbstractOrderHandler; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\Payment\Command\AddPaymentCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\Payment\CommandHandler\AddPaymentHandlerInterface; -use Validate; - -/** - * @internal - */ -final class AddPaymentHandler extends AbstractOrderHandler implements AddPaymentHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(AddPaymentCommand $command) - { - $order = $this->getOrder($command->getOrderId()); - - $currency = new Currency($command->getPaymentCurrencyId()->getValue()); - $orderHasInvoice = $order->hasInvoice(); - - if ($orderHasInvoice) { - $orderInvoice = new OrderInvoice($command->getOrderInvoiceId()); - } else { - $orderInvoice = null; - } - - if (!Validate::isLoadedObject($currency)) { - throw new OrderException('The selected currency is invalid.'); - } - - if ($orderHasInvoice && !Validate::isLoadedObject($orderInvoice)) { - throw new OrderException('The invoice is invalid.'); - } - - $paymentAdded = $order->addOrderPayment( - (string) $command->getPaymentAmount(), - $command->getPaymentMethod(), - $command->getPaymentTransactionId(), - $currency, - $command->getPaymentDate()->format('Y-m-d H:i:s'), - $orderInvoice - ); - - if (!$paymentAdded) { - throw new OrderException('An error occurred during payment.'); - } - } -} diff --git a/src/Adapter/Order/CommandHandler/AddProductToOrderHandler.php b/src/Adapter/Order/CommandHandler/AddProductToOrderHandler.php deleted file mode 100644 index 8a2b5e2b..00000000 --- a/src/Adapter/Order/CommandHandler/AddProductToOrderHandler.php +++ /dev/null @@ -1,608 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Address; -use Attribute; -use Carrier; -use Cart; -use CartRule; -use Combination; -use Configuration; -use Context; -use Currency; -use Customer; -use Hook; -use Order; -use OrderCarrier; -use OrderDetail; -use OrderInvoice; -use PrestaShop\PrestaShop\Adapter\Cart\Comparator\CartProductsComparator; -use PrestaShop\PrestaShop\Adapter\Cart\Comparator\CartProductUpdate; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Adapter\Order\AbstractOrderHandler; -use PrestaShop\PrestaShop\Adapter\Order\OrderAmountUpdater; -use PrestaShop\PrestaShop\Adapter\Order\OrderDetailUpdater; -use PrestaShop\PrestaShop\Adapter\Order\OrderProductQuantityUpdater; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\DuplicateProductInOrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\DuplicateProductInOrderInvoiceException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\Product\Command\AddProductToOrderCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\Product\CommandHandler\AddProductToOrderHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductOutOfStockException; -use Product; -use Shop; -use StockAvailable; -use Symfony\Component\Translation\TranslatorInterface; -use Tools; - -/** - * Handles adding product to an existing order using legacy object model classes. - * - * @internal - */ -final class AddProductToOrderHandler extends AbstractOrderHandler implements AddProductToOrderHandlerInterface -{ - /** - * @var Context - */ - private $context; - - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @var OrderAmountUpdater - */ - private $orderAmountUpdater; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var int - */ - private $computingPrecision; - - /** - * @var OrderProductQuantityUpdater - */ - private $orderProductQuantityUpdater; - - /** - * @var OrderDetailUpdater - */ - private $orderDetailUpdater; - - /** - * @param TranslatorInterface $translator - * @param ContextStateManager $contextStateManager - * @param OrderAmountUpdater $orderAmountUpdater - * @param OrderProductQuantityUpdater $orderProductQuantityUpdater - * @param OrderDetailUpdater $orderDetailUpdater - */ - public function __construct( - TranslatorInterface $translator, - ContextStateManager $contextStateManager, - OrderAmountUpdater $orderAmountUpdater, - OrderProductQuantityUpdater $orderProductQuantityUpdater, - OrderDetailUpdater $orderDetailUpdater - ) { - $this->context = Context::getContext(); - $this->translator = $translator; - $this->contextStateManager = $contextStateManager; - $this->orderAmountUpdater = $orderAmountUpdater; - $this->orderProductQuantityUpdater = $orderProductQuantityUpdater; - $this->orderDetailUpdater = $orderDetailUpdater; - } - - /** - * {@inheritdoc} - */ - public function handle(AddProductToOrderCommand $command) - { - $order = $this->getOrder($command->getOrderId()); - - $this->assertOrderWasNotShipped($order); - $this->assertProductNotDuplicate($order, $command); - - $cart = Cart::getCartByOrderId($order->id); - if (!($cart instanceof Cart)) { - throw new OrderException('Cart linked to the order cannot be found.'); - } - - $product = $this->getProduct($command->getProductId(), (int) $order->id_lang); - $combination = null !== $command->getCombinationId() ? $this->getCombination($command->getCombinationId()->getValue()) : null; - $combinationId = null !== $combination ? (int) $combination->id : 0; - - $this->checkProductInStock($product, $command); - - $this->contextStateManager - ->setCurrency(new Currency($order->id_currency)) - ->setCustomer(new Customer($order->id_customer)) - ->setCart($cart) - ->setShop(new Shop($order->id_shop)) - ; - - $this->computingPrecision = $this->getPrecisionFromCart($cart); - try { - $cartComparator = new CartProductsComparator($cart); - $this->addProductToCart($cart, $product, $combination, $command->getProductQuantity()); - $updatedCartProducts = $cart->getProducts(true); - - // We get all the modification (creation AND updates) and then filter them - $productModifications = $cartComparator->getModifiedProducts(); - $creationModifications = []; - $updateModifications = []; - foreach ($productModifications as $cartProductUpdate) { - // Real creation is naturally a creation update - if ($cartProductUpdate->isCreated()) { - $creationModifications[] = $cartProductUpdate; - continue; - } - - // Now we check if the update is about the currently added product This is important for multi invoice orders, in case - // the added product was already in previous invoices - $cartCombinationId = null !== $cartProductUpdate->getCombinationId() ? $cartProductUpdate->getCombinationId()->getValue() : 0; - if ($cartProductUpdate->getProductId()->getValue() === (int) $product->id && $cartCombinationId === $combinationId) { - $creationModifications[] = $cartProductUpdate; - } else { - $updateModifications[] = $cartProductUpdate; - } - } - - $createdProducts = $this->getCreatedCartProducts( - $creationModifications, - $updatedCartProducts - ); - - $invoice = $this->createNewOrEditExistingInvoice( - $command, - $order, - $cart, - $createdProducts - ); - - // Create Order detail information - $this->createOrderDetails( - $order, - $invoice, - $cart, - $createdProducts - ); - - // Once OrderDetail has been created we update it (and identical ones) with the correct price - $this->orderDetailUpdater->updateOrderDetailsForProduct( - $order, - $command->getProductId()->getValue(), - null !== $command->getCombinationId() ? $command->getCombinationId()->getValue() : 0, - $command->getProductPriceTaxExcluded(), - $command->getProductPriceTaxIncluded() - ); - StockAvailable::synchronize($product->id); - - $this->updateAffectedOrderDetails( - $order, - $updateModifications - ); - - // Update totals amount of order - $this->orderAmountUpdater->update($order, $cart, null !== $invoice ? (int) $invoice->id : null); - Hook::exec('actionOrderEdited', ['order' => $order]); - } finally { - $this->contextStateManager->restorePreviousContext(); - } - } - - /** - * @param Order $order - * - * @throws OrderException - */ - private function assertOrderWasNotShipped(Order $order) - { - if ($order->hasBeenShipped()) { - throw new OrderException('Cannot add product to shipped order.'); - } - } - - /** - * @param Order $order - * @param OrderInvoice|null $invoice - * @param Cart $cart - * @param array $cartProducts - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - private function createOrderDetails(Order $order, ?OrderInvoice $invoice, Cart $cart, array $cartProducts): void - { - $orderDetail = new OrderDetail(); - $orderDetail->createList( - $order, - $cart, - $order->getCurrentOrderState(), - $cartProducts, - !empty($invoice->id) ? $invoice->id : 0 - ); - } - - /** - * When a product is added some other products may be affected (because of CartRule that would - * add some gift for example) So we update products which have been modified in the cart and - * update the related OrderDetail - * - * @param Order $order - * @param CartProductUpdate[] $updatedProducts - * - * @throws OrderException - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - private function updateAffectedOrderDetails( - Order $order, - array $updatedProducts - ): void { - $orderDetails = $order->getOrderDetailList(); - foreach ($updatedProducts as $updatedProduct) { - $updatedCombinationId = null !== $updatedProduct->getCombinationId() ? $updatedProduct->getCombinationId()->getValue() : 0; - $affectedOrderDetail = null; - foreach ($orderDetails as $orderDetailData) { - if ((int) $orderDetailData['product_id'] === $updatedProduct->getProductId()->getValue() - && (int) $orderDetailData['product_attribute_id'] === $updatedCombinationId) { - $affectedOrderDetail = new OrderDetail($orderDetailData['id_order_detail']); - break; - } - } - - $newUpdatedQuantity = (int) $affectedOrderDetail->product_quantity + $updatedProduct->getDeltaQuantity(); - $orderInvoice = (int) $affectedOrderDetail->id_order_invoice !== 0 ? new OrderInvoice($affectedOrderDetail->id_order_invoice) : null; - $this->orderProductQuantityUpdater->update( - $order, - $affectedOrderDetail, - $newUpdatedQuantity, - $orderInvoice, - false - ); - } - } - - /** - * @param CartProductUpdate[] $creationUpdates - * @param CartProductUpdate[] $cartProducts - * - * @return array - */ - private function getCreatedCartProducts( - array $creationUpdates, - array $cartProducts - ): array { - $additionalProducts = []; - foreach ($creationUpdates as $additionalUpdate) { - $updateProductId = $additionalUpdate->getProductId()->getValue(); - $updateCombinationId = null !== $additionalUpdate->getCombinationId() ? $additionalUpdate->getCombinationId()->getValue() : 0; - $cartProduct = $this->getMatchingProduct($cartProducts, [ - 'id_product' => $updateProductId, - 'id_product_attribute' => $updateCombinationId, - ]); - $cartProduct['cart_quantity'] = $additionalUpdate->getDeltaQuantity(); - $additionalProducts[] = $cartProduct; - } - - return $additionalProducts; - } - - /** - * Find a specific product among the product array - * - * @param array $productList - * @param array $searchedProduct - * - * @return array|null - */ - private function getMatchingProduct(array $productList, array $searchedProduct): ?array - { - return array_reduce($productList, function ($carry, $item) use ($searchedProduct) { - if (null !== $carry) { - return $carry; - } - - $productMatch = $item['id_product'] == $searchedProduct['id_product']; - $combinationMatch = $item['id_product_attribute'] == $searchedProduct['id_product_attribute']; - - return $productMatch && $combinationMatch ? $item : null; - }); - } - - /** - * @param Cart $cart - * @param Product $product - * @param Combination|null $combination - * @param int $quantity - */ - private function addProductToCart(Cart $cart, Product $product, $combination, $quantity): void - { - /** - * Here we update product and customization in the cart. - * - * The last argument "skip quantity check" is set to true because - * 1) the quantity has already been checked, - * 2) (main reason) when the cart checks the availability ; it substracts - * its own quantity from available stock. - * - * This is because a product in a cart is not really out of the stock, because it is not checked out yet. - * - * Here we are editing an order, not a cart, so what has been ordered - * has already been substracted from the stock. - */ - $result = $cart->updateQty( - $quantity, - $product->id, - $combination ? $combination->id : null, - false, - 'up', - 0, - new Shop($cart->id_shop), - true, - true - ); - - if ($result < 0) { - // If product has attribute, minimal quantity is set with minimal quantity of attribute - $minimalQuantity = $combination - ? Attribute::getAttributeMinimalQty($combination->id) : - $product->minimal_quantity - ; - - throw new OrderException(sprintf('Minimum quantity of "%d" must be added', $minimalQuantity)); - } - - if (!$result) { - throw new OrderException(sprintf('Product with id "%s" is out of stock.', $product->id)); - } - } - - /** - * @param AddProductToOrderCommand $command - * @param Order $order - * @param Cart $cart - * @param array $products - * - * @return OrderInvoice|null - */ - private function createNewOrEditExistingInvoice( - AddProductToOrderCommand $command, - Order $order, - Cart $cart, - array $products - ) { - if ($order->hasInvoice()) { - return $command->getOrderInvoiceId() ? - $this->updateExistingInvoice($command->getOrderInvoiceId(), $cart, $products) : - $this->createNewInvoice($order, $cart, $command->hasFreeShipping(), $products); - } - - return null; - } - - /** - * @todo: Most of this method can be simplified, since OrderAmountUpdater computes everything - * the invoice computation here should be removable, as well as $order->addCartRule - * - * @param Order $order - * @param Cart $cart - * @param bool $isFreeShipping - * @param array $newProducts - */ - private function createNewInvoice(Order $order, Cart $cart, $isFreeShipping, array $newProducts) - { - $invoice = new OrderInvoice(); - - // If we create a new invoice, we calculate shipping cost - $totalMethod = Cart::BOTH; - - // Create Cart rule in order to make free shipping - if ($isFreeShipping) { - // @todo: use private method to create cart rule - $freeShippingCartRule = new CartRule(); - $freeShippingCartRule->id_customer = $order->id_customer; - $freeShippingCartRule->name = [ - Configuration::get('PS_LANG_DEFAULT') => $this->translator->trans( - '[Generated] CartRule for Free Shipping', - [], - 'Admin.Orderscustomers.Notification' - ), - ]; - $freeShippingCartRule->date_from = date('Y-m-d H:i:s'); - $freeShippingCartRule->date_to = date('Y-m-d H:i:s', time() + 24 * 3600); - $freeShippingCartRule->quantity = 1; - $freeShippingCartRule->quantity_per_user = 1; - $freeShippingCartRule->minimum_amount_currency = $order->id_currency; - $freeShippingCartRule->reduction_currency = $order->id_currency; - $freeShippingCartRule->free_shipping = true; - $freeShippingCartRule->active = 1; - $freeShippingCartRule->add(); - - // Add cart rule to cart and in order - $cart->addCartRule($freeShippingCartRule->id); - $values = [ - 'tax_incl' => $freeShippingCartRule->getContextualValue(true), - 'tax_excl' => $freeShippingCartRule->getContextualValue(false), - ]; - - $order->addCartRule( - $freeShippingCartRule->id, - $freeShippingCartRule->name[Configuration::get('PS_LANG_DEFAULT')], - $values - ); - } - - $invoice->id_order = $order->id; - if ($invoice->number) { - Configuration::updateValue('PS_INVOICE_START_NUMBER', false, false, null, $order->id_shop); - } else { - $invoice->number = Order::getLastInvoiceNumber() + 1; - } - - $invoice_address = new Address( - (int) $order->{Configuration::get('PS_TAX_ADDRESS_TYPE', null, null, $order->id_shop)} - ); - $carrier = new Carrier((int) $order->id_carrier); - $taxCalculator = $carrier->getTaxCalculator($invoice_address); - - $invoice->total_paid_tax_excl = Tools::ps_round( - (float) $cart->getOrderTotal(false, $totalMethod, $newProducts), - $this->computingPrecision - ); - $invoice->total_paid_tax_incl = Tools::ps_round( - (float) $cart->getOrderTotal(true, $totalMethod, $newProducts), - $this->computingPrecision - ); - $invoice->total_products = (float) $cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $newProducts); - $invoice->total_products_wt = (float) $cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $newProducts); - $invoice->total_shipping_tax_excl = (float) $cart->getTotalShippingCost(null, false); - $invoice->total_shipping_tax_incl = (float) $cart->getTotalShippingCost(); - - $invoice->total_wrapping_tax_excl = abs($cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $newProducts)); - $invoice->total_wrapping_tax_incl = abs($cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $newProducts)); - $invoice->shipping_tax_computation_method = (int) $taxCalculator->computation_method; - $invoice->add(); - - $invoice->saveCarrierTaxCalculator($taxCalculator->getTaxesAmount($invoice->total_shipping_tax_excl)); - - $orderCarrier = new OrderCarrier(); - $orderCarrier->id_order = (int) $order->id; - $orderCarrier->id_carrier = (int) $order->id_carrier; - $orderCarrier->id_order_invoice = (int) $invoice->id; - $orderCarrier->weight = (float) $cart->getTotalWeight(); - $orderCarrier->shipping_cost_tax_excl = (float) $invoice->total_shipping_tax_excl; - $orderCarrier->shipping_cost_tax_incl = (float) $invoice->total_shipping_tax_incl; - $orderCarrier->add(); - - return $invoice; - } - - /** - * @todo: this whole method should be removable as well since ALL invoices are updated by OrderAmountUpdater - * - * @param int $orderInvoiceId - * @param Cart $cart - * @param array $newProducts - * - * @return OrderInvoice - */ - private function updateExistingInvoice($orderInvoiceId, Cart $cart, array $newProducts) - { - $invoice = new OrderInvoice($orderInvoiceId); - - $invoice->total_paid_tax_excl += Tools::ps_round( - (float) $cart->getOrderTotal(false, Cart::BOTH_WITHOUT_SHIPPING, $newProducts), - $this->computingPrecision - ); - $invoice->total_paid_tax_incl += Tools::ps_round( - (float) $cart->getOrderTotal(true, Cart::BOTH_WITHOUT_SHIPPING, $newProducts), - $this->computingPrecision - ); - $invoice->total_products += (float) $cart->getOrderTotal( - false, - Cart::ONLY_PRODUCTS, - $newProducts - ); - $invoice->total_products_wt += (float) $cart->getOrderTotal( - true, - Cart::ONLY_PRODUCTS, - $newProducts - ); - - $invoice->update(); - - return $invoice; - } - - /** - * @param Product $product - * @param AddProductToOrderCommand $command - * - * @throws ProductOutOfStockException - */ - private function checkProductInStock(Product $product, AddProductToOrderCommand $command): void - { - //check if product is available in stock - if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock($command->getProductId()->getValue()))) { - $combinationId = null !== $command->getCombinationId() ? $command->getCombinationId()->getValue() : 0; - $availableQuantity = StockAvailable::getQuantityAvailableByProduct($command->getProductId()->getValue(), $combinationId); - - if ($availableQuantity < $command->getProductQuantity()) { - throw new ProductOutOfStockException(sprintf('Product with id "%s" is out of stock, thus cannot be added to cart', $product->id)); - } - } - } - - /** - * @param Order $order - * @param AddProductToOrderCommand $command - * - * @throws DuplicateProductInOrderException - * @throws DuplicateProductInOrderInvoiceException - */ - private function assertProductNotDuplicate(Order $order, AddProductToOrderCommand $command): void - { - $invoicesContainingProduct = []; - foreach ($order->getOrderDetailList() as $orderDetail) { - if ($command->getProductId()->getValue() !== (int) $orderDetail['product_id']) { - continue; - } - if (!empty($command->getCombinationId()) && $command->getCombinationId()->getValue() !== (int) $orderDetail['product_attribute_id']) { - continue; - } - $invoicesContainingProduct[] = (int) $orderDetail['id_order_invoice']; - } - - if (empty($invoicesContainingProduct)) { - return; - } - - // If it's a new invoice (or no invoice), the ID is null, so we check if the Order has invoice (in which case - // a new one is going to be created) If it doesn't have invoices we don't allow adding duplicate OrderDetail - if (empty($command->getOrderInvoiceId()) && !$order->hasInvoice()) { - throw new DuplicateProductInOrderException('You cannot add this product in the order as it is already present'); - } - - // If we are targeting a specific invoice check that the ID has not been found in the OrderDetail list - if (!empty($command->getOrderInvoiceId()) && in_array((int) $command->getOrderInvoiceId(), $invoicesContainingProduct)) { - $orderInvoice = new OrderInvoice($command->getOrderInvoiceId()); - $invoiceNumber = $orderInvoice->getInvoiceNumberFormatted((int) Configuration::get('PS_LANG_DEFAULT'), $order->id_shop); - throw new DuplicateProductInOrderInvoiceException($invoiceNumber, 'You cannot add this product in this invoice as it is already present'); - } - } -} diff --git a/src/Adapter/Order/CommandHandler/BulkChangeOrderStatusHandler.php b/src/Adapter/Order/CommandHandler/BulkChangeOrderStatusHandler.php deleted file mode 100644 index f320ff06..00000000 --- a/src/Adapter/Order/CommandHandler/BulkChangeOrderStatusHandler.php +++ /dev/null @@ -1,131 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Carrier; -use Configuration; -use Context; -use Order; -use OrderHistory; -use OrderState; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\BulkChangeOrderStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\BulkChangeOrderStatusHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\ChangeOrderStatusException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; -use StockAvailable; - -/** - * @internal - */ -final class BulkChangeOrderStatusHandler implements BulkChangeOrderStatusHandlerInterface -{ - /** - * @param BulkChangeOrderStatusCommand $command - */ - public function handle(BulkChangeOrderStatusCommand $command) - { - $orderState = new OrderState($command->getNewOrderStatusId()); - - if ($orderState->id !== $command->getNewOrderStatusId()) { - throw new OrderException(sprintf('Order state with ID "%s" was not found.', $command->getNewOrderStatusId())); - } - - $ordersWithFailedToUpdateStatus = []; - $ordersWithFailedToSendEmail = []; - $ordersWithAssignedStatus = []; - - foreach ($command->getOrderIds() as $orderId) { - $order = $this->getOrderObject($orderId); - $currentOrderState = $order->getCurrentOrderState(); - - if ($currentOrderState->id === $orderState->id) { - $ordersWithAssignedStatus[] = $orderId; - - continue; - } - - $history = new OrderHistory(); - $history->id_order = $order->id; - $history->id_employee = (int) Context::getContext()->employee->id; - - $useExistingPayment = !$order->hasInvoice(); - $history->changeIdOrderState((int) $orderState->id, $order, $useExistingPayment); - - $carrier = new Carrier($order->id_carrier, $order->id_lang); - $templateVars = []; - - if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') && $order->shipping_number) { - $templateVars['{followup}'] = str_replace('@', $order->shipping_number, $carrier->url); - } - - if (!$history->add()) { - $ordersWithFailedToUpdateStatus[] = $orderId; - - continue; - } - - if (!$history->sendEmail($order, $templateVars)) { - $ordersWithFailedToSendEmail[] = $orderId; - - continue; - } - - if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) { - foreach ($order->getProducts() as $product) { - if (StockAvailable::dependsOnStock($product['product_id'])) { - StockAvailable::synchronize($product['product_id'], (int) $product['id_shop']); - } - } - } - } - - if (!empty($ordersWithFailedToUpdateStatus) - || !empty($ordersWithFailedToSendEmail) - || !empty($ordersWithAssignedStatus) - ) { - throw new ChangeOrderStatusException($ordersWithFailedToUpdateStatus, $ordersWithFailedToSendEmail, $ordersWithAssignedStatus, 'Failed to update status or sent email when changing order status.'); - } - } - - /** - * @param OrderId $orderId - * - * @return Order - */ - private function getOrderObject(OrderId $orderId) - { - $order = new Order($orderId->getValue()); - - if ($order->id !== $orderId->getValue()) { - throw new OrderNotFoundException($orderId); - } - - return $order; - } -} diff --git a/src/Adapter/Order/CommandHandler/CancelOrderProductHandler.php b/src/Adapter/Order/CommandHandler/CancelOrderProductHandler.php deleted file mode 100644 index 3d68c265..00000000 --- a/src/Adapter/Order/CommandHandler/CancelOrderProductHandler.php +++ /dev/null @@ -1,248 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Cart; -use Configuration; -use Customization; -use Hook; -use Order; -use OrderDetail; -use OrderHistory; -use OrderInvoice; -use PrestaShop\PrestaShop\Adapter\Order\OrderProductQuantityUpdater; -use PrestaShop\PrestaShop\Core\Domain\Order\CancellationActionType; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\CancelOrderProductCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\CancelOrderProductHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidCancelProductException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidOrderStateException; -use Psr\Log\LoggerInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * @internal - */ -final class CancelOrderProductHandler extends AbstractOrderCommandHandler implements CancelOrderProductHandlerInterface -{ - /** - * @var OrderProductQuantityUpdater - */ - private $orderProductQuantityUpdater; - - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * CancelOrderProductHandler constructor. - * - * @param OrderProductQuantityUpdater $orderProductQuantityUpdater - * @param LoggerInterface $logger - * @param TranslatorInterface $translator - */ - public function __construct( - OrderProductQuantityUpdater $orderProductQuantityUpdater, - LoggerInterface $logger, - TranslatorInterface $translator - ) { - $this->orderProductQuantityUpdater = $orderProductQuantityUpdater; - $this->logger = $logger; - $this->translator = $translator; - } - - /** - * Legacy code for product cancellation handling in order page - */ - public function handle(CancelOrderProductCommand $command) - { - $order = new Order($command->getOrderId()->getValue()); - $this->checkInput($command); - $this->checkOrderState($order); - - $cartId = Cart::getCartIdByOrderId($command->getOrderId()->getValue()); - $customizationQuantities = Customization::countQuantityByCart($cartId); - $orderDetails = $this->getOrderDetails($command); - - $this->assertCancelableProductQuantities($orderDetails, $customizationQuantities); - - $this->cancelProducts($order, $orderDetails); - - if (empty($order->getOrderDetailList())) { - $this->cancelOrder($order); - } - } - - private function getOrderDetails(CancelOrderProductCommand $command) - { - $productList = []; - $customizedCancelQuantity = []; - $productCancelQuantity = []; - - foreach ($command->getCancelledProducts() as $orderDetailId => $cancelQuantity) { - $orderDetail = new OrderDetail($orderDetailId); - $productList[] = $orderDetail; - if ((int) $orderDetail->id_customization > 0) { - $customizedCancelQuantity[$orderDetail->id_customization] = $cancelQuantity; - } else { - $productCancelQuantity[$orderDetail->id_order_detail] = $cancelQuantity; - } - } - - return [ - 'productsOrderDetails' => $productList, - 'productCancelQuantity' => $productCancelQuantity, - 'customizedCancelQuantity' => $customizedCancelQuantity, - ]; - } - - private function checkInput(CancelOrderProductCommand $command) - { - if (empty($command->getCancelledProducts())) { - throw new InvalidCancelProductException(InvalidCancelProductException::NO_REFUNDS); - } - - foreach ($command->getCancelledProducts() as $orderDetailId => $quantity) { - if ((int) $quantity <= 0) { - throw new InvalidCancelProductException(InvalidCancelProductException::INVALID_QUANTITY); - } - } - } - - /** - * @param Order $order* - */ - private function checkOrderState(Order $order) - { - if ($order->hasBeenPaid() || $order->hasPayments()) { - throw new InvalidOrderStateException( - InvalidOrderStateException::ALREADY_PAID, - 'Can not cancel product on an order which is already paid' - ); - } - } - - /** - * @param Order $order - */ - private function cancelOrder(Order $order) - { - $history = new OrderHistory(); - $history->id_order = (int) $order->id; - $history->changeIdOrderState(Configuration::get('PS_OS_CANCELED'), $order); - if (!$history->addWithemail()) { - // email failure must not block order update process - $this->logger->warning( - $this->translator->trans( - 'Order history email could not be sent, test your email configuration in the Advanced Parameters > E-mail section of your back office.', - [], - 'Admin.Orderscustomers.Notification' - ) - ); - } - } - - /** - * @param array $orderDetails - * - * @throws InvalidCancelProductException - */ - private function assertCancelableProductQuantities(array $orderDetails, array $customizationQuantities) - { - if (empty($orderDetails['productsOrderDetails'])) { - throw new InvalidCancelProductException(InvalidCancelProductException::INVALID_QUANTITY, 0); - } - $customizationList = []; - foreach ($orderDetails['productsOrderDetails'] as $orderDetail) { - // check non customized product quantities - if ((int) $orderDetail->id_customization <= 0) { - $customizationQuantity = 0; - $cancelQuantity = $orderDetails['productCancelQuantity'][$orderDetail->id_order_detail]; - if (array_key_exists($orderDetail->product_id, $customizationQuantities) && array_key_exists($orderDetail->product_attribute_id, $customizationQuantities[$orderDetail->product_id])) { - $customizationQuantity = (int) $customizationQuantities[$orderDetail->product_id][$orderDetail->product_attribute_id]; - } - $cancellableQuantity = $orderDetail->product_quantity - $customizationQuantity - $orderDetail->product_quantity_refunded - $orderDetail->product_quantity_return; - if ($cancellableQuantity < $cancelQuantity) { - throw new InvalidCancelProductException(InvalidCancelProductException::QUANTITY_TOO_HIGH, $cancellableQuantity); - } - continue; - } - // get list of customizations - $customizationList[$orderDetail->id_customization] = $orderDetail->id_order_detail; - } - - if (empty($customizationList)) { - return; - } - - $customization_quantities = Customization::retrieveQuantitiesFromIds(array_keys($customizationList)); - - // check customized products quantities - foreach ($customizationList as $id_customization => $id_order_detail) { - $qtyCancelProduct = abs($orderDetails['customizedCancelQuantity'][$id_customization]); - $customization_quantity = $customization_quantities[$id_customization]; - if (!$qtyCancelProduct) { - throw new InvalidCancelProductException(InvalidCancelProductException::INVALID_QUANTITY); - } - $cancellableQuantity = $customization_quantity['quantity'] - ($customization_quantity['quantity_refunded'] + $customization_quantity['quantity_returned']); - - if ($qtyCancelProduct > $cancellableQuantity) { - throw new InvalidCancelProductException(InvalidCancelProductException::QUANTITY_TOO_HIGH, $cancellableQuantity); - } - } - } - - /** - * @param Order $order - * @param array $orderDetails - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - * @throws \PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException - */ - private function cancelProducts(Order $order, array $orderDetails) - { - if (!empty($orderDetails['productsOrderDetails'])) { - foreach ($orderDetails['productsOrderDetails'] as $orderDetail) { - if ((int) $orderDetail->id_customization > 0) { - $qty_cancel_product = abs($orderDetails['customizedCancelQuantity'][$orderDetail->id_customization]); - } else { - $qty_cancel_product = $orderDetails['productCancelQuantity'][$orderDetail->id_order_detail]; - } - $newQuantity = max((int) $orderDetail->product_quantity - (int) $qty_cancel_product, 0); - $orderInvoice = $orderDetail->id_order_invoice != 0 ? new OrderInvoice($orderDetail->id_order_invoice) : null; - $this->orderProductQuantityUpdater->update($order, $orderDetail, $newQuantity, $orderInvoice); - Hook::exec('actionProductCancel', ['order' => $order, 'id_order_detail' => (int) $orderDetail->id_order_detail, 'action' => CancellationActionType::CANCEL_PRODUCT], null, false, true, false, $order->id_shop); - } - } - } -} diff --git a/src/Adapter/Order/CommandHandler/ChangeOrderCurrencyHandler.php b/src/Adapter/Order/CommandHandler/ChangeOrderCurrencyHandler.php deleted file mode 100644 index d3caae4c..00000000 --- a/src/Adapter/Order/CommandHandler/ChangeOrderCurrencyHandler.php +++ /dev/null @@ -1,234 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Cart; -use Currency; -use ObjectModel; -use Order; -use OrderCarrier; -use OrderDetail; -use OrderInvoice; -use PrestaShop\PrestaShop\Adapter\Order\AbstractOrderHandler; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\ChangeOrderCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\ChangeOrderCurrencyHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShopCollection; -use PrestaShopException; -use Tools; -use Validate; - -/** - * @internal - */ -final class ChangeOrderCurrencyHandler extends AbstractOrderHandler implements ChangeOrderCurrencyHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(ChangeOrderCurrencyCommand $command) - { - $order = $this->getOrder($command->getOrderId()); - - if ($command->getNewCurrencyId()->getValue() === (int) $order->id_currency || $order->valid) { - throw new OrderException('You cannot change the currency.'); - } - - try { - $oldCurrency = new Currency($order->id_currency); - $newCurrency = new Currency($command->getNewCurrencyId()->getValue()); - - if (!Validate::isLoadedObject($oldCurrency) || !Validate::isLoadedObject($newCurrency)) { - throw new OrderException('Can\'t load Currency object'); - } - - $this->updateOrderDetail($order, $oldCurrency, $newCurrency); - $this->updateOrderCarrier((int) $order->getIdOrderCarrier(), $oldCurrency, $newCurrency); - $this->updateInvoices($order->getInvoicesCollection(), $oldCurrency, $newCurrency); - $this->updateCart($order->id_cart, $newCurrency); - $this->updateOrder($order, $oldCurrency, $newCurrency); - } catch (PrestaShopException $e) { - throw new OrderException( - sprintf( - 'Error occurred when trying to change currency for order #%s', - $order->id - ), - 0, - $e - ); - } - } - - /** - * @param int $orderCarrierId - * @param Currency $oldCurrency - * @param Currency $newCurrency - */ - private function updateOrderCarrier(int $orderCarrierId, Currency $oldCurrency, Currency $newCurrency): void - { - if (!$orderCarrierId) { - return; - } - - $order_carrier = new OrderCarrier($orderCarrierId); - $order_carrier->shipping_cost_tax_excl = (float) Tools::convertPriceFull( - $order_carrier->shipping_cost_tax_excl, - $oldCurrency, - $newCurrency - ); - $order_carrier->shipping_cost_tax_incl = (float) Tools::convertPriceFull( - $order_carrier->shipping_cost_tax_incl, - $oldCurrency, - $newCurrency - ); - $order_carrier->update(); - } - - /** - * @param Order $order - * @param Currency $oldCurrency - * @param Currency $newCurrency - */ - private function updateOrderDetail(Order $order, Currency $oldCurrency, Currency $newCurrency): void - { - foreach ($order->getOrderDetailList() as $orderDetailItem) { - $orderDetail = new OrderDetail($orderDetailItem['id_order_detail']); - $fields = [ - 'ecotax', - 'product_price', - 'reduction_amount', - 'total_shipping_price_tax_excl', - 'total_shipping_price_tax_incl', - 'total_price_tax_incl', - 'total_price_tax_excl', - 'product_quantity_discount', - 'purchase_supplier_price', - 'reduction_amount', - 'reduction_amount_tax_incl', - 'reduction_amount_tax_excl', - 'unit_price_tax_incl', - 'unit_price_tax_excl', - 'original_product_price', - ]; - - $this->convertPriceFields($orderDetail, $fields, $oldCurrency, $newCurrency); - - $orderDetail->update(); - $orderDetail->updateTaxAmount($order); - } - } - - /** - * @param PrestaShopCollection $invoices - * @param Currency $oldCurrency - * @param Currency $newCurrency - */ - private function updateInvoices(PrestaShopCollection $invoices, Currency $oldCurrency, Currency $newCurrency): void - { - if (!$invoices->count()) { - return; - } - - foreach ($invoices as $invoice) { - $this->convertPriceFields($invoice, $this->getSharedAmountFields(), $oldCurrency, $newCurrency); - $invoice->save(); - } - } - - /** - * @param Order $order - * @param Currency $oldCurrency - * @param Currency $newCurrency - */ - private function updateOrder(Order $order, Currency $oldCurrency, Currency $newCurrency): void - { - $this->convertPriceFields($order, $this->getSharedAmountFields(), $oldCurrency, $newCurrency); - - $order->id_currency = $newCurrency->id; - $order->conversion_rate = (float) $newCurrency->conversion_rate; - $order->update(); - } - - /** - * @param int $cartId - * @param Currency $newCurrency - */ - private function updateCart(int $cartId, Currency $newCurrency): void - { - $cart = new Cart($cartId); - - $cart->id_currency = $newCurrency->id; - $cart->update(); - } - - /** - * Provides fields for Order and OrderInvoice amounts update - * - * @return array - */ - private function getSharedAmountFields(): array - { - return [ - 'total_discounts', - 'total_discounts_tax_incl', - 'total_discounts_tax_excl', - 'total_discount_tax_excl', - 'total_discount_tax_incl', - 'total_paid', - 'total_paid_tax_incl', - 'total_paid_tax_excl', - 'total_paid_real', - 'total_products', - 'total_products_wt', - 'total_shipping', - 'total_shipping_tax_incl', - 'total_shipping_tax_excl', - 'total_wrapping', - 'total_wrapping_tax_incl', - 'total_wrapping_tax_excl', - ]; - } - - /** - * @param Order|OrderDetail|OrderInvoice $object - * @param array $fields - * @param Currency $oldCurrency - * @param Currency $newCurrency - */ - private function convertPriceFields( - ObjectModel $object, - array $fields, - Currency $oldCurrency, - Currency $newCurrency - ) { - foreach ($fields as $field) { - if (isset($object->$field)) { - $object->{$field} = Tools::convertPriceFull($object->{$field}, $oldCurrency, $newCurrency); - } - } - } -} diff --git a/src/Adapter/Order/CommandHandler/ChangeOrderDeliveryAddressHandler.php b/src/Adapter/Order/CommandHandler/ChangeOrderDeliveryAddressHandler.php deleted file mode 100644 index e0e55549..00000000 --- a/src/Adapter/Order/CommandHandler/ChangeOrderDeliveryAddressHandler.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Address; -use Cart; -use PrestaShop\PrestaShop\Adapter\Order\AbstractOrderHandler; -use PrestaShop\PrestaShop\Adapter\Order\OrderAmountUpdater; -use PrestaShop\PrestaShop\Adapter\Order\OrderDetailUpdater; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\ChangeOrderDeliveryAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\ChangeOrderDeliveryAddressHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use Validate; - -/** - * @internal - */ -final class ChangeOrderDeliveryAddressHandler extends AbstractOrderHandler implements ChangeOrderDeliveryAddressHandlerInterface -{ - /** - * @var OrderAmountUpdater - */ - private $orderAmountUpdater; - - /** - * @var OrderDetailUpdater - */ - private $orderDetailTaxUpdater; - - /** - * @param OrderAmountUpdater $orderAmountUpdater - * @param OrderDetailUpdater $orderDetailTaxUpdater - */ - public function __construct( - OrderAmountUpdater $orderAmountUpdater, - OrderDetailUpdater $orderDetailTaxUpdater - ) { - $this->orderAmountUpdater = $orderAmountUpdater; - $this->orderDetailTaxUpdater = $orderDetailTaxUpdater; - } - - /** - * {@inheritdoc} - */ - public function handle(ChangeOrderDeliveryAddressCommand $command) - { - $order = $this->getOrder($command->getOrderId()); - $address = new Address($command->getNewDeliveryAddressId()->getValue()); - - $cart = Cart::getCartByOrderId($order->id); - - if (!Validate::isLoadedObject($address)) { - throw new OrderException('New delivery address is not valid'); - } - - $cart->updateDeliveryAddressId((int) $cart->id_address_delivery, (int) $address->id); - $cart->setDeliveryOption([ - (int) $cart->id_address_delivery => $this->formatLegacyDeliveryOptionFromCarrierId($order->id_carrier), - ]); - $cart->update(); - - $order->id_address_delivery = $address->id; - $this->orderDetailTaxUpdater->updateOrderDetailsTaxes($order); - $this->orderAmountUpdater->update($order, $cart); - } -} diff --git a/src/Adapter/Order/CommandHandler/ChangeOrderInvoiceAddressHandler.php b/src/Adapter/Order/CommandHandler/ChangeOrderInvoiceAddressHandler.php deleted file mode 100644 index f916fdb4..00000000 --- a/src/Adapter/Order/CommandHandler/ChangeOrderInvoiceAddressHandler.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Address; -use Cart; -use PrestaShop\PrestaShop\Adapter\Order\AbstractOrderHandler; -use PrestaShop\PrestaShop\Adapter\Order\OrderAmountUpdater; -use PrestaShop\PrestaShop\Adapter\Order\OrderDetailUpdater; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\ChangeOrderInvoiceAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\ChangeOrderInvoiceAddressHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use Validate; - -/** - * @internal - */ -final class ChangeOrderInvoiceAddressHandler extends AbstractOrderHandler implements ChangeOrderInvoiceAddressHandlerInterface -{ - /** - * @var OrderAmountUpdater - */ - private $orderAmountUpdater; - - /** - * @var OrderDetailUpdater - */ - private $orderDetailTaxUpdater; - - /** - * @param OrderAmountUpdater $orderAmountUpdater - * @param OrderDetailUpdater $orderDetailTaxUpdater - */ - public function __construct( - OrderAmountUpdater $orderAmountUpdater, - OrderDetailUpdater $orderDetailTaxUpdater - ) { - $this->orderAmountUpdater = $orderAmountUpdater; - $this->orderDetailTaxUpdater = $orderDetailTaxUpdater; - } - - /** - * {@inheritdoc} - */ - public function handle(ChangeOrderInvoiceAddressCommand $command) - { - $order = $this->getOrder($command->getOrderId()); - $address = new Address($command->getNewInvoiceAddressId()->getValue()); - - $cart = Cart::getCartByOrderId($order->id); - - if (!Validate::isLoadedObject($address)) { - throw new OrderException('New invoice address is not valid'); - } - - $cart->id_address_invoice = $address->id; - $cart->update(); - - $order->id_address_invoice = $address->id; - $this->orderDetailTaxUpdater->updateOrderDetailsTaxes($order); - $this->orderAmountUpdater->update($order, $cart); - } -} diff --git a/src/Adapter/Order/CommandHandler/DeleteCartRuleFromOrderHandler.php b/src/Adapter/Order/CommandHandler/DeleteCartRuleFromOrderHandler.php deleted file mode 100644 index 6174bed8..00000000 --- a/src/Adapter/Order/CommandHandler/DeleteCartRuleFromOrderHandler.php +++ /dev/null @@ -1,166 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Cart; -use CartRule; -use Currency; -use Customer; -use Order; -use OrderCartRule; -use OrderDetail; -use OrderInvoice; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Adapter\Order\AbstractOrderHandler; -use PrestaShop\PrestaShop\Adapter\Order\OrderAmountUpdater; -use PrestaShop\PrestaShop\Adapter\Order\OrderProductQuantityUpdater; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\DeleteCartRuleFromOrderCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\DeleteCartRuleFromOrderHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use Shop; -use Validate; - -/** - * @internal - */ -final class DeleteCartRuleFromOrderHandler extends AbstractOrderHandler implements DeleteCartRuleFromOrderHandlerInterface -{ - /** - * @var OrderAmountUpdater - */ - private $orderAmountUpdater; - - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @var OrderProductQuantityUpdater - */ - private $orderProductQuantityUpdater; - - /** - * @param OrderAmountUpdater $orderAmountUpdater - * @param ContextStateManager $contextStateManager - * @param OrderProductQuantityUpdater $orderProductQuantityUpdater - */ - public function __construct( - OrderAmountUpdater $orderAmountUpdater, - OrderProductQuantityUpdater $orderProductQuantityUpdater, - ContextStateManager $contextStateManager - ) { - $this->orderAmountUpdater = $orderAmountUpdater; - $this->orderProductQuantityUpdater = $orderProductQuantityUpdater; - $this->contextStateManager = $contextStateManager; - } - - /** - * {@inheritdoc} - */ - public function handle(DeleteCartRuleFromOrderCommand $command) - { - $order = $this->getOrder($command->getOrderId()); - $orderCartRule = new OrderCartRule($command->getOrderCartRuleId()); - if (!Validate::isLoadedObject($orderCartRule) || $orderCartRule->id_order != $order->id) { - throw new OrderException('Invalid order cart rule provided.'); - } - - $cart = Cart::getCartByOrderId($order->id); - if (!Validate::isLoadedObject($cart) || $order->id_cart != $cart->id) { - throw new OrderException('Invalid cart provided.'); - } - - $this->contextStateManager - ->setCurrency(new Currency($order->id_currency)) - ->setCustomer(new Customer($order->id_customer)) - ->setShop(new Shop($order->id_shop)) - ; - - try { - // Delete Order Cart Rule and update Order - $cartRule = new CartRule($orderCartRule->id_cart_rule); - $orderCartRule->softDelete(); - $cart->removeCartRule($orderCartRule->id_cart_rule); - - // If cart rule was a gift product we must update an OrderDetail manually - $giftOrderDetail = $this->getGiftOrderDetail($order, $cartRule); - if ($giftOrderDetail instanceof OrderDetail) { - $newQuantity = ((int) $giftOrderDetail->product_quantity) - 1; - - /* - * Note: we are lucky the stock updates happens smoothly, it was not re-injected by removing the CartRule - * because Cart doesn't update the stock but it will while we update the OrderDetail Lucky - * for us it's the same difference of 1 so it's all accurate in the end - */ - // This calls the OrderAmountUpdater internally so no need to perform both calls - $this->orderProductQuantityUpdater->update( - $order, - $giftOrderDetail, - $newQuantity, - (int) $giftOrderDetail->id_order_invoice !== 0 ? new OrderInvoice((int) $giftOrderDetail->id_order_invoice) : null, - false - ); - } else { - $this->orderAmountUpdater->update($order, $cart, $orderCartRule->id_order_invoice); - } - } finally { - $this->contextStateManager->restorePreviousContext(); - } - } - - /** - * @param Order $order - * @param CartRule $cartRule - * - * @return OrderDetail|null - */ - private function getGiftOrderDetail(Order $order, CartRule $cartRule): ?OrderDetail - { - $productId = (int) $cartRule->gift_product; - $productAttributeId = (int) $cartRule->gift_product_attribute; - - $fallbackOrderDetailId = null; - $giftOrderDetailId = null; - foreach ($order->getOrderDetailList() as $orderDetail) { - if ((int) $orderDetail['product_id'] !== $productId || (int) $orderDetail['product_attribute_id'] !== $productAttributeId) { - continue; - } - - // We try to find a row with at least 2 items - if ($orderDetail['product_quantity'] > 1) { - $giftOrderDetailId = $orderDetail['id_order_detail']; - - return new OrderDetail($giftOrderDetailId); - } - // keep the first one for fallback - $fallbackOrderDetailId = $fallbackOrderDetailId ?? $orderDetail['id_order_detail']; - } - - return (null === $fallbackOrderDetailId) ? null : new OrderDetail($fallbackOrderDetailId); - } -} diff --git a/src/Adapter/Order/CommandHandler/DeleteProductFromOrderHandler.php b/src/Adapter/Order/CommandHandler/DeleteProductFromOrderHandler.php deleted file mode 100644 index 665e061a..00000000 --- a/src/Adapter/Order/CommandHandler/DeleteProductFromOrderHandler.php +++ /dev/null @@ -1,137 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Cart; -use Currency; -use Customer; -use Hook; -use Order; -use OrderDetail; -use OrderInvoice; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Adapter\Order\OrderAmountUpdater; -use PrestaShop\PrestaShop\Adapter\Order\OrderProductQuantityUpdater; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Order\Product\Command\DeleteProductFromOrderCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\Product\CommandHandler\DeleteProductFromOrderHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; -use Shop; -use Validate; - -/** - * @internal - */ -final class DeleteProductFromOrderHandler extends AbstractOrderCommandHandler implements DeleteProductFromOrderHandlerInterface -{ - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @var OrderAmountUpdater - */ - private $orderAmountUpdater; - /** - * @var OrderProductQuantityUpdater - */ - private $orderProductQuantityUpdater; - - /** - * @param ContextStateManager $contextStateManager - * @param OrderAmountUpdater $orderAmountUpdater - * @param OrderProductQuantityUpdater $orderProductQuantityUpdater - */ - public function __construct( - ContextStateManager $contextStateManager, - OrderAmountUpdater $orderAmountUpdater, - OrderProductQuantityUpdater $orderProductQuantityUpdater - ) { - $this->contextStateManager = $contextStateManager; - $this->orderAmountUpdater = $orderAmountUpdater; - $this->orderProductQuantityUpdater = $orderProductQuantityUpdater; - } - - /** - * {@inheritdoc} - */ - public function handle(DeleteProductFromOrderCommand $command) - { - $orderDetail = new OrderDetail($command->getOrderDetailId()); - $order = new Order($command->getOrderId()->getValue()); - - $this->assertProductCanBeDeleted($order, $orderDetail); - - $cart = new Cart($order->id_cart); - - $this->contextStateManager - ->setCart($cart) - ->setCurrency(new Currency($order->id_currency)) - ->setCustomer(new Customer($order->id_customer)) - ->setShop(new Shop($order->id_shop)) - ; - - try { - $order = $this->orderProductQuantityUpdater->update( - $order, - $orderDetail, - 0, - $orderDetail->id_order_invoice != 0 ? new OrderInvoice($orderDetail->id_order_invoice) : null - ); - - Hook::exec('actionOrderEdited', ['order' => $order]); - } finally { - $this->contextStateManager->restorePreviousContext(); - } - } - - /** - * @param Order $order - * @param OrderDetail $orderDetail - */ - private function assertProductCanBeDeleted(Order $order, OrderDetail $orderDetail) - { - if (!Validate::isLoadedObject($orderDetail)) { - throw new OrderException('Order detail could not be found.'); - } - - if (!Validate::isLoadedObject($order)) { - throw new OrderNotFoundException(new OrderId((int) $order->id), 'Order could not be found.'); - } - - if ($orderDetail->id_order != $order->id) { - throw new OrderException('Order detail does not belong to order.'); - } - - // We can't edit a delivered order - if ($order->hasBeenDelivered()) { - throw new OrderException('Delivered order cannot be modified.'); - } - } -} diff --git a/src/Adapter/Order/CommandHandler/DuplicateOrderCartHandler.php b/src/Adapter/Order/CommandHandler/DuplicateOrderCartHandler.php deleted file mode 100644 index ac48f996..00000000 --- a/src/Adapter/Order/CommandHandler/DuplicateOrderCartHandler.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Cart; -use Currency; -use Customer; -use Language; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\DuplicateOrderCartCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\DuplicateOrderCartHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\DuplicateOrderCartException; -use Shop; - -/** - * @internal - */ -final class DuplicateOrderCartHandler implements DuplicateOrderCartHandlerInterface -{ - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @param ContextStateManager $contextStateManager - */ - public function __construct(ContextStateManager $contextStateManager) - { - $this->contextStateManager = $contextStateManager; - } - - /** - * {@inheritdoc} - */ - public function handle(DuplicateOrderCartCommand $command) - { - // IMPORTANT: context customer must be set in order to correctly fill the address - $cart = Cart::getCartByOrderId($command->getOrderId()->getValue()); - $this->contextStateManager - ->setCart($cart) - ->setCustomer(new Customer($cart->id_customer)) - ->setCurrency(new Currency($cart->id_currency)) - ->setLanguage(new Language($cart->id_lang)) - ->setShop(new Shop($cart->id_shop)) - ; - $result = $cart->duplicate(); - - if (false === $result || !isset($result['cart'])) { - $this->contextStateManager->restorePreviousContext(); - throw new DuplicateOrderCartException(sprintf('Cannot duplicate cart from order "%s"', $command->getOrderId()->getValue())); - } - - $this->contextStateManager->restorePreviousContext(); - - return new CartId((int) $result['cart']->id); - } -} diff --git a/src/Adapter/Order/CommandHandler/GenerateInvoiceHandler.php b/src/Adapter/Order/CommandHandler/GenerateInvoiceHandler.php deleted file mode 100644 index b230a051..00000000 --- a/src/Adapter/Order/CommandHandler/GenerateInvoiceHandler.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Configuration; -use PrestaShop\PrestaShop\Adapter\Order\AbstractOrderHandler; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\Invoice\Command\GenerateInvoiceCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\Invoice\CommandHandler\GenerateOrderInvoiceHandlerInterface; - -/** - * @internal - */ -final class GenerateInvoiceHandler extends AbstractOrderHandler implements GenerateOrderInvoiceHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GenerateInvoiceCommand $command) - { - $order = $this->getOrder($command->getOrderId()); - - if (!Configuration::get('PS_INVOICE', null, null, $order->id_shop)) { - throw new OrderException('Invoice management has been disabled.'); - } - - if ($order->hasInvoice()) { - throw new OrderException('This order already has an invoice.'); - } - - $order->setInvoice(true); - } -} diff --git a/src/Adapter/Order/CommandHandler/IssuePartialRefundHandler.php b/src/Adapter/Order/CommandHandler/IssuePartialRefundHandler.php deleted file mode 100644 index 2f0a2a3f..00000000 --- a/src/Adapter/Order/CommandHandler/IssuePartialRefundHandler.php +++ /dev/null @@ -1,184 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Context; -use Hook; -use Order; -use OrderCarrier; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Adapter\Order\Refund\OrderRefundCalculator; -use PrestaShop\PrestaShop\Adapter\Order\Refund\OrderRefundUpdater; -use PrestaShop\PrestaShop\Adapter\Order\Refund\OrderSlipCreator; -use PrestaShop\PrestaShop\Adapter\Order\Refund\VoucherGenerator; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\CancellationActionType; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\IssuePartialRefundCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\IssuePartialRefundHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidOrderStateException; -use Validate; - -/** - * @internal - */ -final class IssuePartialRefundHandler extends AbstractOrderCommandHandler implements IssuePartialRefundHandlerInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var OrderRefundCalculator - */ - private $orderRefundCalculator; - - /** - * @var OrderSlipCreator - */ - private $orderSlipCreator; - - /** - * @var VoucherGenerator - */ - private $voucherGenerator; - - /** - * @var OrderRefundUpdater - */ - private $refundUpdater; - - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @param ConfigurationInterface $configuration - * @param OrderRefundCalculator $orderRefundCalculator - * @param OrderSlipCreator $orderSlipCreator - * @param VoucherGenerator $voucherGenerator - * @param OrderRefundUpdater $refundUpdater - * @param ContextStateManager $contextStateManager - */ - public function __construct( - ConfigurationInterface $configuration, - OrderRefundCalculator $orderRefundCalculator, - OrderSlipCreator $orderSlipCreator, - VoucherGenerator $voucherGenerator, - OrderRefundUpdater $refundUpdater, - ContextStateManager $contextStateManager - ) { - $this->configuration = $configuration; - $this->orderRefundCalculator = $orderRefundCalculator; - $this->orderSlipCreator = $orderSlipCreator; - $this->voucherGenerator = $voucherGenerator; - $this->refundUpdater = $refundUpdater; - $this->contextStateManager = $contextStateManager; - } - - /** - * {@inheritdoc} - */ - public function handle(IssuePartialRefundCommand $command): void - { - /** @var Order $order */ - $order = $this->getOrder($command->getOrderId()); - if (!$order->hasBeenPaid() && !$order->hasPayments()) { - throw new InvalidOrderStateException( - InvalidOrderStateException::NOT_PAID, - 'Can not perform partial refund on an order which is not paid' - ); - } - - $this->setOrderContext($this->contextStateManager, $order); - - try { - $this->issuePartialRefund($command, $order); - } finally { - $this->contextStateManager->restorePreviousContext(); - } - } - - /** - * @param IssuePartialRefundCommand $command - * @param Order $order - */ - private function issuePartialRefund(IssuePartialRefundCommand $command, Order $order): void - { - $orderRefundSummary = $this->orderRefundCalculator->computeOrderRefund( - $order, - $command->getOrderDetailRefunds(), - $command->getShippingCostRefundAmount(), - $command->getVoucherRefundType(), - $command->getVoucherRefundAmount() - ); - - // @todo This part should probably be in a share abstract class as it will probably be common with other handlers - // Update order details and reinject quantities - $shouldReinjectProducts = !$order->hasBeenDelivered() || $command->restockRefundedProducts(); - foreach ($orderRefundSummary->getProductRefunds() as $orderDetailId => $productRefund) { - $orderDetail = $orderRefundSummary->getOrderDetailById($orderDetailId); - if ($shouldReinjectProducts) { - $this->reinjectQuantity($orderDetail, $productRefund['quantity']); - } - Hook::exec('actionProductCancel', ['order' => $order, 'id_order_detail' => (int) $orderDetailId, 'action' => CancellationActionType::PARTIAL_REFUND], null, false, true, false, $order->id_shop); - } - - // Update order carrier weight - $orderCarrier = new OrderCarrier((int) $order->getIdOrderCarrier()); - if (Validate::isLoadedObject($orderCarrier)) { - $orderCarrier->weight = (float) $order->getTotalWeight(); - if ($orderCarrier->update()) { - $order->weight = sprintf('%.3f %s', $orderCarrier->weight, $this->configuration->get('PS_WEIGHT_UNIT')); - } - } - - // Create order slip - if ($command->generateCreditSlip()) { - $this->orderSlipCreator->create($order, $orderRefundSummary); - } - - // Update refund details - $productsReturned = (int) $this->configuration->get('PS_ORDER_RETURN') === 1 && $order->hasBeenDelivered(); - $this->refundUpdater->updateRefundData( - $orderRefundSummary, - $productsReturned, - $shouldReinjectProducts - ); - - // Generate voucher if needed - if ($command->generateVoucher() && $orderRefundSummary->getRefundedAmount() > 0) { - $this->voucherGenerator->generateVoucher( - $order, - $orderRefundSummary->getRefundedAmount(), - Context::getContext()->currency->iso_code, - $orderRefundSummary->isTaxIncluded() - ); - } - } -} diff --git a/src/Adapter/Order/CommandHandler/IssueReturnProductHandler.php b/src/Adapter/Order/CommandHandler/IssueReturnProductHandler.php deleted file mode 100644 index b4ee9845..00000000 --- a/src/Adapter/Order/CommandHandler/IssueReturnProductHandler.php +++ /dev/null @@ -1,184 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Context; -use Hook; -use Order; -use OrderCarrier; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Adapter\Order\Refund\OrderRefundCalculator; -use PrestaShop\PrestaShop\Adapter\Order\Refund\OrderRefundSummary; -use PrestaShop\PrestaShop\Adapter\Order\Refund\OrderRefundUpdater; -use PrestaShop\PrestaShop\Adapter\Order\Refund\OrderSlipCreator; -use PrestaShop\PrestaShop\Adapter\Order\Refund\VoucherGenerator; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\CancellationActionType; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\IssueReturnProductCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\IssueReturnProductHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidOrderStateException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\ReturnProductDisabledException; -use Validate; - -/** - * @internal - */ -class IssueReturnProductHandler extends AbstractOrderCommandHandler implements IssueReturnProductHandlerInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var OrderRefundCalculator - */ - private $orderRefundCalculator; - - /** - * @var OrderSlipCreator - */ - private $orderSlipCreator; - - /** - * @var VoucherGenerator - */ - private $voucherGenerator; - - /** - * @var OrderRefundUpdater - */ - private $refundUpdater; - - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @param ConfigurationInterface $configuration - * @param OrderRefundCalculator $orderRefundCalculator - * @param OrderSlipCreator $orderSlipCreator - * @param VoucherGenerator $voucherGenerator - * @param OrderRefundUpdater $refundUpdater - * @param ContextStateManager $contextStateManager - */ - public function __construct( - ConfigurationInterface $configuration, - OrderRefundCalculator $orderRefundCalculator, - OrderSlipCreator $orderSlipCreator, - VoucherGenerator $voucherGenerator, - OrderRefundUpdater $refundUpdater, - ContextStateManager $contextStateManager - ) { - $this->configuration = $configuration; - $this->orderRefundCalculator = $orderRefundCalculator; - $this->orderSlipCreator = $orderSlipCreator; - $this->voucherGenerator = $voucherGenerator; - $this->refundUpdater = $refundUpdater; - $this->contextStateManager = $contextStateManager; - } - - /** - * {@inheritdoc} - */ - public function handle(IssueReturnProductCommand $command): void - { - if ((int) $this->configuration->get('PS_ORDER_RETURN') <= 0) { - throw new ReturnProductDisabledException(); - } - - $order = $this->getOrder($command->getOrderId()); - if (!$order->hasBeenDelivered()) { - throw new InvalidOrderStateException( - InvalidOrderStateException::DELIVERY_NOT_FOUND, - 'Can not perform return product on order with not delivered yet' - ); - } - $this->setOrderContext($this->contextStateManager, $order); - - try { - $this->issueReturn($command, $order); - } finally { - $this->contextStateManager->restorePreviousContext(); - } - } - - private function issueReturn(IssueReturnProductCommand $command, Order $order): void - { - $shippingRefundAmount = new Number((string) ($command->refundShippingCost() ? $order->total_shipping_tax_incl : 0)); - /** @var OrderRefundSummary $orderRefundSummary */ - $orderRefundSummary = $this->orderRefundCalculator->computeOrderRefund( - $order, - $command->getOrderDetailRefunds(), - $shippingRefundAmount, - $command->getVoucherRefundType(), - $command->getVoucherRefundAmount() - ); - - // Update order details and reinject quantities - foreach ($orderRefundSummary->getProductRefunds() as $orderDetailId => $productRefund) { - $orderDetail = $orderRefundSummary->getOrderDetailById($orderDetailId); - if ($command->restockRefundedProducts()) { - $this->reinjectQuantity($orderDetail, $productRefund['quantity']); - } - Hook::exec('actionProductCancel', ['order' => $order, 'id_order_detail' => (int) $orderDetailId, 'action' => CancellationActionType::RETURN_PRODUCT], null, false, true, false, $order->id_shop); - } - - // Update order carrier weight - $orderCarrier = new OrderCarrier((int) $order->getIdOrderCarrier()); - if (Validate::isLoadedObject($orderCarrier)) { - $orderCarrier->weight = (float) $order->getTotalWeight(); - if ($orderCarrier->update()) { - $order->weight = sprintf('%.3f %s', $orderCarrier->weight, $this->configuration->get('PS_WEIGHT_UNIT')); - } - } - - // Create order slip - if ($command->generateCreditSlip()) { - $this->orderSlipCreator->create($order, $orderRefundSummary); - } - - // Update refund details (by definition it returns products) - $this->refundUpdater->updateRefundData( - $orderRefundSummary, - true, - $command->restockRefundedProducts() - ); - - // Generate voucher if needed - if ($command->generateVoucher() && $orderRefundSummary->getRefundedAmount() > 0) { - $this->voucherGenerator->generateVoucher( - $order, - $orderRefundSummary->getRefundedAmount(), - Context::getContext()->currency->iso_code, - $orderRefundSummary->isTaxIncluded() - ); - } - } -} diff --git a/src/Adapter/Order/CommandHandler/IssueStandardRefundHandler.php b/src/Adapter/Order/CommandHandler/IssueStandardRefundHandler.php deleted file mode 100644 index 703d5e91..00000000 --- a/src/Adapter/Order/CommandHandler/IssueStandardRefundHandler.php +++ /dev/null @@ -1,193 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Context; -use Hook; -use Order; -use OrderCarrier; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Adapter\Order\Refund\OrderRefundCalculator; -use PrestaShop\PrestaShop\Adapter\Order\Refund\OrderRefundUpdater; -use PrestaShop\PrestaShop\Adapter\Order\Refund\OrderSlipCreator; -use PrestaShop\PrestaShop\Adapter\Order\Refund\VoucherGenerator; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\CancellationActionType; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\IssueStandardRefundCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\IssueStandardRefundHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidOrderStateException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\ReturnProductDisabledException; -use Validate; - -/** - * @internal - */ -class IssueStandardRefundHandler extends AbstractOrderCommandHandler implements IssueStandardRefundHandlerInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var OrderRefundCalculator - */ - private $orderRefundCalculator; - - /** - * @var OrderSlipCreator - */ - private $orderSlipCreator; - - /** - * @var VoucherGenerator - */ - private $voucherGenerator; - - /** - * @var OrderRefundUpdater - */ - private $refundUpdater; - - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @param ConfigurationInterface $configuration - * @param OrderRefundCalculator $orderRefundCalculator - * @param OrderSlipCreator $orderSlipCreator - * @param VoucherGenerator $voucherGenerator - * @param OrderRefundUpdater $refundUpdater - * @param ContextStateManager $contextStateManager - */ - public function __construct( - ConfigurationInterface $configuration, - OrderRefundCalculator $orderRefundCalculator, - OrderSlipCreator $orderSlipCreator, - VoucherGenerator $voucherGenerator, - OrderRefundUpdater $refundUpdater, - ContextStateManager $contextStateManager - ) { - $this->configuration = $configuration; - $this->orderRefundCalculator = $orderRefundCalculator; - $this->orderSlipCreator = $orderSlipCreator; - $this->voucherGenerator = $voucherGenerator; - $this->refundUpdater = $refundUpdater; - $this->contextStateManager = $contextStateManager; - } - - /** - * {@inheritdoc} - */ - public function handle(IssueStandardRefundCommand $command): void - { - if ((int) $this->configuration->get('PS_ORDER_RETURN') <= 0) { - throw new ReturnProductDisabledException(); - } - - /** @var Order $order */ - $order = $this->getOrder($command->getOrderId()); - if (!$order->hasBeenPaid() && !$order->hasPayments()) { - throw new InvalidOrderStateException( - InvalidOrderStateException::NOT_PAID, - 'Can not perform standard refund on an order which is not paid' - ); - } - if ($order->hasBeenDelivered()) { - throw new InvalidOrderStateException( - InvalidOrderStateException::UNEXPECTED_DELIVERY, - 'Can not perform standard refund on order already delivered' - ); - } - - $this->setOrderContext($this->contextStateManager, $order); - - try { - $this->issueStandardRefund($command, $order); - } finally { - $this->contextStateManager->restorePreviousContext(); - } - } - - /** - * @param IssueStandardRefundCommand $command - * @param Order $order - */ - private function issueStandardRefund(IssueStandardRefundCommand $command, Order $order): void - { - $shippingRefundAmount = new Number((string) ($command->refundShippingCost() ? $order->total_shipping_tax_incl : 0)); - $orderRefundSummary = $this->orderRefundCalculator->computeOrderRefund( - $order, - $command->getOrderDetailRefunds(), - $shippingRefundAmount, - $command->getVoucherRefundType(), - $command->getVoucherRefundAmount() - ); - - // Update order details and reinject quantities - foreach ($orderRefundSummary->getProductRefunds() as $orderDetailId => $productRefund) { - $orderDetail = $orderRefundSummary->getOrderDetailById($orderDetailId); - // For standard refund the order is necessarily NOT delivered yet, so reinjection is automatic - $this->reinjectQuantity($orderDetail, $productRefund['quantity']); - Hook::exec('actionProductCancel', ['order' => $order, 'id_order_detail' => (int) $orderDetailId, 'action' => CancellationActionType::STANDARD_REFUND], null, false, true, false, $order->id_shop); - } - - // Update order carrier weight - $orderCarrier = new OrderCarrier((int) $order->getIdOrderCarrier()); - if (Validate::isLoadedObject($orderCarrier)) { - $orderCarrier->weight = (float) $order->getTotalWeight(); - if ($orderCarrier->update()) { - $order->weight = sprintf('%.3f %s', $orderCarrier->weight, $this->configuration->get('PS_WEIGHT_UNIT')); - } - } - - // Create order slip - if ($command->generateCreditSlip()) { - $this->orderSlipCreator->create($order, $orderRefundSummary); - } - - // Update refund details (standard refund only happen for an order not delivered, so it can't return products) - $this->refundUpdater->updateRefundData( - $orderRefundSummary, - false, - true - ); - - // Generate voucher if needed - if ($command->generateVoucher() && $orderRefundSummary->getRefundedAmount() > 0) { - $this->voucherGenerator->generateVoucher( - $order, - $orderRefundSummary->getRefundedAmount(), - Context::getContext()->currency->iso_code, - $orderRefundSummary->isTaxIncluded() - ); - } - } -} diff --git a/src/Adapter/Order/CommandHandler/ResendOrderEmailHandler.php b/src/Adapter/Order/CommandHandler/ResendOrderEmailHandler.php deleted file mode 100644 index 675684db..00000000 --- a/src/Adapter/Order/CommandHandler/ResendOrderEmailHandler.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Carrier; -use Configuration; -use OrderHistory; -use OrderState; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\ResendOrderEmailCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\ResendOrderEmailHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderEmailSendException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use Validate; - -/** - * @internal - */ -final class ResendOrderEmailHandler extends AbstractOrderCommandHandler implements ResendOrderEmailHandlerInterface -{ - /** - * @param ResendOrderEmailCommand $command - */ - public function handle(ResendOrderEmailCommand $command): void - { - $order = $this->getOrder($command->getOrderId()); - $orderState = new OrderState($command->getOrderStatusId()); - - if (!Validate::isLoadedObject($orderState)) { - throw new OrderException(sprintf('An error occurred while loading order status. Order status with "%s" was not found.', $command->getOrderId()->getValue())); - } - - $history = new OrderHistory($command->getOrderHistoryId()); - - $carrier = new Carrier($order->id_carrier, $order->id_lang); - $templateVars = []; - - if ($orderState->id == Configuration::get('PS_OS_SHIPPING') && $order->shipping_number) { - $templateVars = ['{followup}' => str_replace('@', $order->shipping_number, $carrier->url)]; - } - - if (!$history->sendEmail($order, $templateVars)) { - throw new OrderEmailSendException('Failed to resend order email.', OrderEmailSendException::FAILED_RESEND); - } - } -} diff --git a/src/Adapter/Order/CommandHandler/SendProcessOrderEmailHandler.php b/src/Adapter/Order/CommandHandler/SendProcessOrderEmailHandler.php deleted file mode 100644 index 74721f56..00000000 --- a/src/Adapter/Order/CommandHandler/SendProcessOrderEmailHandler.php +++ /dev/null @@ -1,190 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Cart; -use Customer; -use Language; -use Link; -use Mail; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\SendProcessOrderEmailCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\SendProcessOrderEmailHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderEmailSendException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShopException; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Handles SendProcessOrderEmail command using legacy object model - */ -class SendProcessOrderEmailHandler implements SendProcessOrderEmailHandlerInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var Link - */ - private $contextLink; - - public function __construct( - TranslatorInterface $translator, - Link $contextLink - ) { - $this->translator = $translator; - $this->contextLink = $contextLink; - } - - /** - * {@inheritdoc} - */ - public function handle(SendProcessOrderEmailCommand $command): void - { - $cartId = $command->getCartId(); - - try { - $cart = $this->getCart($cartId); - $customer = $this->getCustomer(new CustomerId((int) $cart->id_customer)); - $langId = (int) $cart->id_lang; - $cartLanguage = new Language($langId); - - if (!Mail::send( - $langId, - 'backoffice_order', - $this->getSubject($cartLanguage), - $this->getEmailTemplateVars($cartId->getValue(), $cartLanguage, $customer), - $customer->email, - $customer->firstname . ' ' . $customer->lastname, - null, - null, - null, - null, - _PS_MAIL_DIR_, - true, - $cart->id_shop - )) { - throw new OrderEmailSendException('Failed to send order process email to customer', OrderEmailSendException::FAILED_SEND_PROCESS_ORDER); - } - } catch (PrestaShopException $e) { - throw new OrderException('An error occurred when trying to get info for order processing'); - } - } - - /** - * Provides legacy cart object - * - * @param CartId $cartId - * - * @return Cart - * - * @throws CartNotFoundException - */ - private function getCart(CartId $cartId) - { - $cartIdValue = $cartId->getValue(); - $cart = new Cart($cartIdValue); - - if ($cart->id !== $cartIdValue) { - throw new CartNotFoundException(sprintf('Cart #%s not found', $cartIdValue)); - } - - return $cart; - } - - /** - * Provides legacy customer object - * - * @param CustomerId $customerId - * - * @return Customer - * - * @throws CustomerNotFoundException - */ - private function getCustomer(CustomerId $customerId) - { - $customerIdValue = $customerId->getValue(); - $customer = new Customer($customerIdValue); - - if ($customer->id !== $customerIdValue) { - throw new CustomerNotFoundException(new CustomerId($customerIdValue), sprintf('Customer #%s not found', $customerIdValue)); - } - - return $customer; - } - - /** - * Provides translated subject for email - * - * @param Language $cartLanguage - * - * @return string - */ - private function getSubject(Language $cartLanguage): string - { - return $this->translator->trans( - 'Process the payment of your order', - [], - 'Emails.Subject', - $cartLanguage->locale - ); - } - - /** - * Provides email template variables - * - * @param int $cartId - * @param Language $cartLanguage - * @param Customer $customer - * - * @return array - */ - private function getEmailTemplateVars(int $cartId, Language $cartLanguage, Customer $customer): array - { - $orderLink = $this->contextLink->getPageLink( - 'order', - false, - $cartLanguage->id, - http_build_query([ - 'step' => 3, - 'recover_cart' => $cartId, - 'token_cart' => md5(_COOKIE_KEY_ . 'recover_cart_' . $cartId), - ]) - ); - - return [ - '{order_link}' => $orderLink, - '{firstname}' => $customer->firstname, - '{lastname}' => $customer->lastname, - ]; - } -} diff --git a/src/Adapter/Order/CommandHandler/UpdateInvoiceNoteHandler.php b/src/Adapter/Order/CommandHandler/UpdateInvoiceNoteHandler.php deleted file mode 100644 index bfb2d682..00000000 --- a/src/Adapter/Order/CommandHandler/UpdateInvoiceNoteHandler.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use OrderInvoice; -use PrestaShop\PrestaShop\Core\Domain\Order\Invoice\Command\UpdateInvoiceNoteCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\Invoice\CommandHandler\UpdateInvoiceNoteHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Invoice\Exception\InvoiceException; -use PrestaShop\PrestaShop\Core\Domain\Order\Invoice\Exception\InvoiceNotFoundException; -use Validate; - -/** - * @internal - */ -final class UpdateInvoiceNoteHandler implements UpdateInvoiceNoteHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(UpdateInvoiceNoteCommand $command): void - { - $note = $command->getNote(); - $orderInvoice = new OrderInvoice($command->getOrderInvoiceId()->getValue()); - - if (!Validate::isLoadedObject($orderInvoice) && Validate::isCleanHtml($note)) { - throw new InvoiceNotFoundException(sprintf('Order invoice with id "%d" was not found', $command->getOrderInvoiceId()->getValue())); - } - - $orderInvoice->note = $note; - - if (!$orderInvoice->save()) { - throw new InvoiceException('The invoice note was not saved.'); - } - } -} diff --git a/src/Adapter/Order/CommandHandler/UpdateOrderShippingDetailsHandler.php b/src/Adapter/Order/CommandHandler/UpdateOrderShippingDetailsHandler.php deleted file mode 100644 index 06d58f86..00000000 --- a/src/Adapter/Order/CommandHandler/UpdateOrderShippingDetailsHandler.php +++ /dev/null @@ -1,126 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Carrier; -use Cart; -use Customer; -use Hook; -use OrderCarrier; -use PrestaShop\PrestaShop\Adapter\Order\AbstractOrderHandler; -use PrestaShop\PrestaShop\Adapter\Order\OrderAmountUpdater; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\UpdateOrderShippingDetailsCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\UpdateOrderShippingDetailsHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\TransistEmailSendingException; -use Validate; - -/** - * @internal - */ -final class UpdateOrderShippingDetailsHandler extends AbstractOrderHandler implements UpdateOrderShippingDetailsHandlerInterface -{ - /** - * @var OrderAmountUpdater - */ - private $orderAmountUpdater; - - /** - * @param OrderAmountUpdater $orderAmountUpdater - */ - public function __construct(OrderAmountUpdater $orderAmountUpdater) - { - $this->orderAmountUpdater = $orderAmountUpdater; - } - - /** - * {@inheritdoc} - */ - public function handle(UpdateOrderShippingDetailsCommand $command) - { - $order = $this->getOrder($command->getOrderId()); - - $trackingNumber = $command->getShippingTrackingNumber(); - $carrierId = $command->getNewCarrierId(); - $oldTrackingNumber = $order->shipping_number; - - $orderCarrier = new OrderCarrier($command->getCurrentOrderCarrierId()); - if (!Validate::isLoadedObject($orderCarrier)) { - throw new OrderException('The order carrier ID is invalid.'); - } - - if (!empty($trackingNumber) && !Validate::isTrackingNumber($trackingNumber)) { - throw new OrderException('The tracking number is incorrect.'); - } - - //update carrier - ONLY if changed - then refresh shipping cost - $oldCarrierId = (int) $orderCarrier->id_carrier; - if ($oldCarrierId !== $carrierId) { - $cart = Cart::getCartByOrderId($order->id); - $cart->setDeliveryOption([ - (int) $cart->id_address_delivery => $this->formatLegacyDeliveryOptionFromCarrierId($carrierId), - ]); - $cart->save(); - - $orderCarrier->id_carrier = $carrierId; - $orderCarrier->update(); - - $order->id_carrier = $carrierId; - $this->orderAmountUpdater->update($order, $cart); - } - - //load fresh order carrier because updated just before - $orderCarrier = new OrderCarrier((int) $order->getIdOrderCarrier()); - - // update shipping number - // Keep these two following lines for backward compatibility, remove on 1.6 version - $order->shipping_number = $trackingNumber; - $order->update(); - - // Update order_carrier - $orderCarrier->tracking_number = pSQL($trackingNumber); - if (!$orderCarrier->update()) { - throw new OrderException('The order carrier cannot be updated.'); - } - - //send mail only if tracking number is different AND not empty - if (!empty($trackingNumber) && $oldTrackingNumber != $trackingNumber) { - if (!$orderCarrier->sendInTransitEmail($order)) { - throw new TransistEmailSendingException('An error occurred while sending an email to the customer.'); - } - - $customer = new Customer((int) $order->id_customer); - $carrier = new Carrier((int) $order->id_carrier, $order->id_lang); - - Hook::exec('actionAdminOrdersTrackingNumberUpdate', [ - 'order' => $order, - 'customer' => $customer, - 'carrier' => $carrier, - ], null, false, true, false, $order->id_shop); - } - } -} diff --git a/src/Adapter/Order/CommandHandler/UpdateOrderStatusHandler.php b/src/Adapter/Order/CommandHandler/UpdateOrderStatusHandler.php deleted file mode 100644 index 5b3f669e..00000000 --- a/src/Adapter/Order/CommandHandler/UpdateOrderStatusHandler.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Carrier; -use Configuration; -use Context; -use OrderHistory; -use OrderState; -use PrestaShop\PrestaShop\Adapter\Order\AbstractOrderHandler; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\UpdateOrderStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler\UpdateOrderStatusHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\ChangeOrderStatusException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use StockAvailable; - -/** - * @internal - */ -final class UpdateOrderStatusHandler extends AbstractOrderHandler implements UpdateOrderStatusHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(UpdateOrderStatusCommand $command) - { - $order = $this->getOrder($command->getOrderId()); - $orderState = $this->getOrderStateObject($command->getNewOrderStatusId()); - - $currentOrderState = $order->getCurrentOrderState(); - - if ($currentOrderState->id == $orderState->id) { - throw new OrderException('The order has already been assigned this status.'); - } - - // Create new OrderHistory - $history = new OrderHistory(); - $history->id_order = $order->id; - $history->id_employee = (int) Context::getContext()->employee->id; - - $useExistingPayments = false; - if (!$order->hasInvoice()) { - $useExistingPayments = true; - } - - $history->changeIdOrderState((int) $orderState->id, $order, $useExistingPayments); - - $carrier = new Carrier($order->id_carrier, $order->id_lang); - $templateVars = []; - - if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') && $order->shipping_number) { - $templateVars = [ - '{followup}' => str_replace('@', $order->shipping_number, $carrier->url), - ]; - } - - // Save all changes - $historyAdded = $history->addWithemail(true, $templateVars); - - if ($historyAdded) { - // synchronizes quantities if needed.. - if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) { - foreach ($order->getProducts() as $product) { - if (StockAvailable::dependsOnStock($product['product_id'])) { - StockAvailable::synchronize($product['product_id'], (int) $product['id_shop']); - } - } - } - - return; - } - - throw new ChangeOrderStatusException([], [$command->getOrderId()], [], 'Failed to update status or sent email when changing order status.'); - } - - /** - * @param int $orderStatusId - * - * @return OrderState - */ - private function getOrderStateObject($orderStatusId) - { - $orderState = new OrderState($orderStatusId); - - if ($orderState->id !== $orderStatusId) { - throw new OrderException(sprintf('Order status with id "%s" was not found.', $orderStatusId)); - } - - return $orderState; - } -} diff --git a/src/Adapter/Order/CommandHandler/UpdateProductInOrderHandler.php b/src/Adapter/Order/CommandHandler/UpdateProductInOrderHandler.php deleted file mode 100644 index 627197bd..00000000 --- a/src/Adapter/Order/CommandHandler/UpdateProductInOrderHandler.php +++ /dev/null @@ -1,232 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Order\CommandHandler; - -use Configuration; -use Exception; -use Hook; -use Order; -use OrderDetail; -use OrderInvoice; -use PrestaShop\PrestaShop\Adapter\Order\AbstractOrderHandler; -use PrestaShop\PrestaShop\Adapter\Order\OrderDetailUpdater; -use PrestaShop\PrestaShop\Adapter\Order\OrderProductQuantityUpdater; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\CannotEditDeliveredOrderProductException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\CannotFindProductInOrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\DuplicateProductInOrderInvoiceException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\Product\Command\UpdateProductInOrderCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\Product\CommandHandler\UpdateProductInOrderHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductOutOfStockException; -use Product; -use StockAvailable; -use Validate; - -/** - * @internal - */ -final class UpdateProductInOrderHandler extends AbstractOrderHandler implements UpdateProductInOrderHandlerInterface -{ - /** - * @var OrderProductQuantityUpdater - */ - private $orderProductQuantityUpdater; - - /** - * @var OrderDetailUpdater - */ - private $orderDetailUpdater; - - /** - * UpdateProductInOrderHandler constructor. - * - * @param OrderProductQuantityUpdater $orderProductQuantityUpdater - * @param OrderDetailUpdater $orderDetailUpdater - */ - public function __construct( - OrderProductQuantityUpdater $orderProductQuantityUpdater, - OrderDetailUpdater $orderDetailUpdater - ) { - $this->orderProductQuantityUpdater = $orderProductQuantityUpdater; - $this->orderDetailUpdater = $orderDetailUpdater; - } - - /** - * {@inheritdoc} - */ - public function handle(UpdateProductInOrderCommand $command) - { - try { - $order = $this->getOrder($command->getOrderId()); - - $orderDetail = new OrderDetail($command->getOrderDetailId()); - $orderInvoice = null; - if (!empty($command->getOrderInvoiceId())) { - $orderInvoice = new OrderInvoice($command->getOrderInvoiceId()); - } - - // Check fields validity - $this->assertProductCanBeUpdated($command, $orderDetail, $order, $orderInvoice); - $this->assertProductNotDuplicate($order, $orderDetail, $orderInvoice); - - // Update current OrderDetail with new price (the object will be updated by reference) - $this->orderDetailUpdater->updateOrderDetail( - $orderDetail, - $order, - $command->getPriceTaxExcluded(), - $command->getPriceTaxIncluded() - ); - - // We also need to update all identical OrderDetails to be sure that Cart will get the correct price - $this->orderDetailUpdater->updateOrderDetailsForProduct( - $order, - (int) $orderDetail->product_id, - (int) $orderDetail->product_attribute_id, - $command->getPriceTaxExcluded(), - $command->getPriceTaxIncluded() - ); - - // Update invoice, quantity and amounts - $order = $this->orderProductQuantityUpdater->update($order, $orderDetail, $command->getQuantity(), $orderInvoice); - - Hook::exec('actionOrderEdited', ['order' => $order]); - } catch (Exception $e) { - throw $e; - } - } - - /** - * @param UpdateProductInOrderCommand $command - * @param OrderDetail $orderDetail - * @param Order $order - * @param OrderInvoice|null $orderInvoice - * - * @throws OrderException - */ - private function assertProductCanBeUpdated( - UpdateProductInOrderCommand $command, - OrderDetail $orderDetail, - Order $order, - OrderInvoice $orderInvoice = null - ) { - // assert product exists - $product = new Product($orderDetail->product_id); - if ($product->id !== (int) $orderDetail->product_id) { - throw new CannotFindProductInOrderException('You cannot edit the price of a product that no longer exists in your catalog.'); - } - - if (!Validate::isLoadedObject($orderDetail)) { - throw new OrderException('The Order Detail object could not be loaded.'); - } - - if (null !== $orderInvoice && !Validate::isLoadedObject($orderInvoice)) { - throw new OrderException('The invoice object cannot be loaded.'); - } - - if (!Validate::isLoadedObject($order)) { - throw new OrderException('The order object cannot be loaded.'); - } - - if ($orderDetail->id_order != $order->id) { - throw new OrderException('You cannot edit the order detail for this order.'); - } - - // We can't edit a delivered order - if ($order->hasBeenDelivered()) { - throw new CannotEditDeliveredOrderProductException('You cannot edit a delivered order.'); - } - - if (null !== $orderInvoice && $orderInvoice->id_order != $order->id) { - throw new OrderException('You cannot use this invoice for the order'); - } - - if ($command->getPriceTaxIncluded()->isNegative() || $command->getPriceTaxExcluded()->isNegative()) { - throw new OrderException('Invalid price'); - } - - if (!Validate::isUnsignedInt($command->getQuantity())) { - throw new OrderException('Invalid quantity'); - } - - //check if product is available in stock - if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock($orderDetail->product_id))) { - $availableQuantity = StockAvailable::getQuantityAvailableByProduct($orderDetail->product_id, $orderDetail->product_attribute_id); - $quantityDiff = $command->getQuantity() - (int) $orderDetail->product_quantity; - - if ($quantityDiff > $availableQuantity) { - throw new ProductOutOfStockException('Not enough products in stock'); - } - } - } - - /** - * @param Order $order - * @param OrderDetail $orderDetail - * @param OrderInvoice|null $orderInvoice - * - * @throws DuplicateProductInOrderInvoiceException - */ - private function assertProductNotDuplicate(Order $order, OrderDetail $orderDetail, ?OrderInvoice $orderInvoice = null): void - { - // If the OrderDetail's invoice is not changed no reason to check - if (null === $orderInvoice || (int) $orderInvoice->id === (int) $orderDetail->id_order_invoice) { - return; - } - - // If no multi invoice possible no reason to check - if (!$order->hasInvoice()) { - return; - } - - $invoicesContainingProduct = []; - foreach ($order->getOrderDetailList() as $orderDetailData) { - if ((int) $orderDetail->id === (int) $orderDetailData['id_order_detail']) { - continue; - } - if ((int) $orderDetail->product_id !== (int) $orderDetailData['product_id']) { - continue; - } - if ((int) $orderDetail->product_attribute_id !== (int) $orderDetailData['product_attribute_id']) { - continue; - } - $invoicesContainingProduct[] = (int) $orderDetailData['id_order_invoice']; - } - - // No invoices contain the product it's fine - if (empty($invoicesContainingProduct)) { - return; - } - - // The newly assigned invoice already contains this product, this it not possible - if (in_array((int) $orderInvoice->id, $invoicesContainingProduct)) { - $invoiceNumber = $orderInvoice->getInvoiceNumberFormatted((int) Configuration::get('PS_LANG_DEFAULT'), $order->id_shop); - throw new DuplicateProductInOrderInvoiceException($invoiceNumber, 'You cannot add this product in this invoice as it is already present'); - } - } -} diff --git a/src/Adapter/Order/Delivery/SlipOptionsConfiguration.php b/src/Adapter/Order/Delivery/SlipOptionsConfiguration.php deleted file mode 100644 index 30160d3b..00000000 --- a/src/Adapter/Order/Delivery/SlipOptionsConfiguration.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\Delivery; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * This class manages Order delivery slip options configuration. - */ -final class SlipOptionsConfiguration implements DataConfigurationInterface -{ - const PREFIX = 'PS_DELIVERY_PREFIX'; - const NUMBER = 'PS_DELIVERY_NUMBER'; - const ENABLE_PRODUCT_IMAGE = 'PS_PDF_IMG_DELIVERY'; - - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * Returns configuration used to manage slip options in back office. - * - * @return array - */ - public function getConfiguration() - { - return [ - 'prefix' => $this->configuration->get(self::PREFIX), - 'number' => $this->configuration->getInt(self::NUMBER), - 'enable_product_image' => $this->configuration->getBoolean(self::ENABLE_PRODUCT_IMAGE), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - if ($this->validateConfiguration($configuration)) { - $this->configuration->set(self::PREFIX, $configuration['prefix']); - $this->configuration->set(self::NUMBER, $configuration['number']); - $this->configuration->set(self::ENABLE_PRODUCT_IMAGE, $configuration['enable_product_image']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['prefix'], - $configuration['number'], - $configuration['enable_product_image'] - ); - } -} diff --git a/src/Adapter/Order/Delivery/SlipPdfConfiguration.php b/src/Adapter/Order/Delivery/SlipPdfConfiguration.php deleted file mode 100644 index 1428fdff..00000000 --- a/src/Adapter/Order/Delivery/SlipPdfConfiguration.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\Delivery; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\Order\Invoice; -use PrestaShop\PrestaShop\Adapter\Validate; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * This class manages Order delivery slip pdf configuration. - */ -final class SlipPdfConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * Returns configuration used to manage Slip pdf in back office. - * - * @return array - */ - public function getConfiguration() - { - return []; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - if ($this->validateConfiguration($configuration)) { - if (!Validate::isDate($configuration['date_to'])) { - $errors[] = [ - 'key' => "Invalid 'to' date", - 'domain' => 'Admin.Catalog.Notification', - 'parameters' => [], - ]; - } - - if (!Validate::isDate($configuration['date_from'])) { - $errors[] = [ - 'key' => "Invalid 'from' date", - 'domain' => 'Admin.Catalog.Notification', - 'parameters' => [], - ]; - } - - if (empty(Invoice::getByDeliveryDateInterval($configuration['date_from'], $configuration['date_to']))) { - $errors[] = [ - 'key' => 'No delivery slip was found for this period.', - 'domain' => 'Admin.Orderscustomers.Notification', - 'parameters' => [], - ]; - } - } - - return !empty($errors) ? $errors : []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['date_from'], - $configuration['date_to'] - ); - } -} diff --git a/src/Adapter/Order/GeneralConfiguration.php b/src/Adapter/Order/GeneralConfiguration.php deleted file mode 100644 index 3a9bb21d..00000000 --- a/src/Adapter/Order/GeneralConfiguration.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * General Settings configuration available in ShopParameters > Order Preferences. - */ -class GeneralConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'enable_final_summary' => $this->configuration->getBoolean('PS_FINAL_SUMMARY_ENABLED'), - 'enable_guest_checkout' => $this->configuration->getBoolean('PS_GUEST_CHECKOUT_ENABLED'), - 'disable_reordering_option' => $this->configuration->getBoolean('PS_DISALLOW_HISTORY_REORDERING'), - 'purchase_minimum_value' => $this->configuration->get('PS_PURCHASE_MINIMUM'), - 'recalculate_shipping_cost' => $this->configuration->getBoolean('PS_ORDER_RECALCULATE_SHIPPING'), - 'allow_multishipping' => $this->configuration->getBoolean('PS_ALLOW_MULTISHIPPING'), - 'allow_delayed_shipping' => $this->configuration->getBoolean('PS_SHIP_WHEN_AVAILABLE'), - 'enable_tos' => $this->configuration->getBoolean('PS_CONDITIONS'), - 'tos_cms_id' => $this->configuration->get('PS_CONDITIONS_CMS_ID'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_FINAL_SUMMARY_ENABLED', $configuration['enable_final_summary']); - $this->configuration->set('PS_GUEST_CHECKOUT_ENABLED', $configuration['enable_guest_checkout']); - $this->configuration->set('PS_DISALLOW_HISTORY_REORDERING', $configuration['disable_reordering_option']); - $this->configuration->set('PS_PURCHASE_MINIMUM', $configuration['purchase_minimum_value']); - $this->configuration->set('PS_ORDER_RECALCULATE_SHIPPING', $configuration['recalculate_shipping_cost']); - $this->configuration->set('PS_ALLOW_MULTISHIPPING', $configuration['allow_multishipping']); - $this->configuration->set('PS_SHIP_WHEN_AVAILABLE', $configuration['allow_delayed_shipping']); - $this->configuration->set('PS_CONDITIONS', $configuration['enable_tos']); - $this->configuration->set('PS_CONDITIONS_CMS_ID', $configuration['tos_cms_id']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['enable_final_summary'], - $configuration['enable_guest_checkout'], - $configuration['disable_reordering_option'], - $configuration['purchase_minimum_value'], - $configuration['recalculate_shipping_cost'], - $configuration['allow_multishipping'], - $configuration['allow_delayed_shipping'], - $configuration['enable_tos'], - $configuration['tos_cms_id'] - ); - } -} diff --git a/src/Adapter/Order/GiftOptionsConfiguration.php b/src/Adapter/Order/GiftOptionsConfiguration.php deleted file mode 100644 index 50a2311a..00000000 --- a/src/Adapter/Order/GiftOptionsConfiguration.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * Gift Settings configuration available in ShopParameters > Order Preferences. - */ -class GiftOptionsConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'enable_gift_wrapping' => $this->configuration->getBoolean('PS_GIFT_WRAPPING'), - 'gift_wrapping_price' => $this->configuration->get('PS_GIFT_WRAPPING_PRICE'), - 'gift_wrapping_tax_rules_group' => $this->configuration->get('PS_GIFT_WRAPPING_TAX_RULES_GROUP'), - 'offer_recyclable_pack' => $this->configuration->getBoolean('PS_RECYCLABLE_PACK'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_GIFT_WRAPPING', $configuration['enable_gift_wrapping']); - $this->configuration->set('PS_GIFT_WRAPPING_PRICE', $configuration['gift_wrapping_price']); - $this->configuration->set('PS_GIFT_WRAPPING_TAX_RULES_GROUP', $configuration['gift_wrapping_tax_rules_group']); - $this->configuration->set('PS_RECYCLABLE_PACK', $configuration['offer_recyclable_pack']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['enable_gift_wrapping'], - $configuration['gift_wrapping_price'], - $configuration['gift_wrapping_tax_rules_group'], - $configuration['offer_recyclable_pack'] - ); - } -} diff --git a/src/Adapter/Order/Invoice.php b/src/Adapter/Order/Invoice.php deleted file mode 100644 index 19852862..00000000 --- a/src/Adapter/Order/Invoice.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order; - -use OrderInvoice as InvoiceLegacy; -use PrestaShop\PrestaShop\Core\Order\InvoiceInterface; - -/** - * Invoice Helper. - */ -final class Invoice implements InvoiceInterface -{ - /** - * {@inheritdoc} - */ - public static function getByDeliveryDateInterval($dateFrom, $dateTo) - { - return InvoiceLegacy::getByDeliveryDateInterval($dateFrom, $dateTo); - } -} diff --git a/src/Adapter/Order/OrderAmountUpdater.php b/src/Adapter/Order/OrderAmountUpdater.php deleted file mode 100644 index 2744e68d..00000000 --- a/src/Adapter/Order/OrderAmountUpdater.php +++ /dev/null @@ -1,512 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Order; - -use Address; -use Cache; -use Carrier; -use Cart; -use CartRule; -use Currency; -use Customer; -use Language; -use Order; -use OrderCarrier; -use OrderCartRule; -use OrderDetail; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Core\Cart\CartRuleData; -use PrestaShop\PrestaShop\Core\Domain\Configuration\ShopConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Shop\ValueObject\ShopConstraint; -use PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision; -use PrestaShopDatabaseException; -use PrestaShopException; -use Product; -use Shop; -use Tools; -use Validate; - -class OrderAmountUpdater -{ - /** - * @var ShopConfigurationInterface - */ - private $shopConfiguration; - - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @var OrderDetailUpdater - */ - private $orderDetailUpdater; - - /** - * @var array - */ - private $orderConstraints = []; - - /** - * @var bool - */ - private $keepOrderPrices = true; - - /** - * @param ShopConfigurationInterface $shopConfiguration - * @param ContextStateManager $contextStateManager - * @param OrderDetailUpdater $orderDetailUpdater - */ - public function __construct( - ShopConfigurationInterface $shopConfiguration, - ContextStateManager $contextStateManager, - OrderDetailUpdater $orderDetailUpdater - ) { - $this->shopConfiguration = $shopConfiguration; - $this->contextStateManager = $contextStateManager; - $this->orderDetailUpdater = $orderDetailUpdater; - } - - /** - * @param Order $order - * @param Cart $cart - * @param int|null $orderInvoiceId - * - * @throws OrderException - * @throws PrestaShopDatabaseException - * @throws PrestaShopException - */ - public function update( - Order $order, - Cart $cart, - ?int $orderInvoiceId = null - ): void { - $this->cleanCaches(); - - $this->contextStateManager - ->saveCurrentContext() - ->setCart($cart) - ->setCurrency(new Currency($cart->id_currency)) - ->setCustomer(new Customer($cart->id_customer)) - ->setLanguage(new Language($cart->id_lang)) - ->setCountry($cart->getTaxCountry()) - ->setShop(new Shop($cart->id_shop)) - ; - - try { - // @todo: use https://github.com/PrestaShop/decimal for price computations - $computingPrecision = $this->getPrecisionFromCart($cart); - - // Update order details (if quantity or product price have been modified) - $this->updateOrderDetails($order, $cart); - - // Recalculate cart rules and Fix differences between cart's cartRules and order's cartRules - $this->updateOrderCartRules($order, $cart, $computingPrecision, $orderInvoiceId); - - // Update order totals - $this->updateOrderTotals($order, $cart, $computingPrecision); - - // Update carrier weight for shipping cost - $this->updateOrderCarrier($order, $cart); - - // Order::update is called after previous functions so that we only call it once - if (!$order->update()) { - throw new OrderException('Could not update order invoice in database.'); - } - - $this->updateOrderInvoices($order, $cart, $computingPrecision); - } finally { - $this->contextStateManager->restorePreviousContext(); - } - } - - /** - * There are many caches among legacy classes that can store previous prices - * we need to clean them to make sure the price is completely up to date - */ - private function cleanCaches(): void - { - // For many intermediate computations - Cart::resetStaticCache(); - - // For discount computation - CartRule::resetStaticCache(); - Cache::clean('getContextualValue_*'); - - // For shipping costs - Carrier::resetStaticCache(); - Cache::clean('getPackageShippingCost_*'); - } - - /** - * @param Order $order - * @param Cart $cart - * @param int $computingPrecision - */ - private function updateOrderTotals(Order $order, Cart $cart, int $computingPrecision): void - { - $orderProducts = $order->getCartProducts(); - - $carrierId = $order->id_carrier; - $order->total_discounts = (float) abs($cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $orderProducts, $carrierId, false, $this->keepOrderPrices)); - $order->total_discounts_tax_excl = (float) abs($cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $orderProducts, $carrierId, false, $this->keepOrderPrices)); - $order->total_discounts_tax_incl = (float) abs($cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $orderProducts, $carrierId, false, $this->keepOrderPrices)); - - // We should always use Cart::BOTH for the order total since it contains all products, shipping fees and cart rules - $order->total_paid = Tools::ps_round( - (float) $cart->getOrderTotal(true, Cart::BOTH, $orderProducts, $carrierId, false, $this->keepOrderPrices), - $computingPrecision - ); - $order->total_paid_tax_excl = Tools::ps_round( - (float) $cart->getOrderTotal(false, Cart::BOTH, $orderProducts, $carrierId, false, $this->keepOrderPrices), - $computingPrecision - ); - $order->total_paid_tax_incl = Tools::ps_round( - (float) $cart->getOrderTotal(true, Cart::BOTH, $orderProducts, $carrierId, false, $this->keepOrderPrices), - $computingPrecision - ); - - $order->total_products = (float) $cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $orderProducts, $carrierId, false, $this->keepOrderPrices); - $order->total_products_wt = (float) $cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $orderProducts, $carrierId, false, $this->keepOrderPrices); - - $order->total_wrapping = abs($cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $orderProducts, $carrierId, false, $this->keepOrderPrices)); - $order->total_wrapping_tax_excl = abs($cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $orderProducts, $carrierId, false, $this->keepOrderPrices)); - $order->total_wrapping_tax_incl = abs($cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $orderProducts, $carrierId, false, $this->keepOrderPrices)); - - $totalShippingTaxIncluded = $order->total_shipping_tax_incl; - $totalShippingTaxExcluded = $order->total_shipping_tax_excl; - - $order->total_shipping = $cart->getOrderTotal(true, Cart::ONLY_SHIPPING, $orderProducts, $carrierId, false, $this->keepOrderPrices); - $order->total_shipping_tax_excl = $cart->getOrderTotal(false, Cart::ONLY_SHIPPING, $orderProducts, $carrierId, false, $this->keepOrderPrices); - $order->total_shipping_tax_incl = $cart->getOrderTotal(true, Cart::ONLY_SHIPPING, $orderProducts, $carrierId, false, $this->keepOrderPrices); - - if (!$this->getOrderConfiguration('PS_ORDER_RECALCULATE_SHIPPING', $order)) { - $shippingDiffTaxIncluded = $order->total_shipping_tax_incl - $totalShippingTaxIncluded; - $shippingDiffTaxExcluded = $order->total_shipping_tax_excl - $totalShippingTaxExcluded; - - $order->total_shipping = $totalShippingTaxIncluded; - $order->total_shipping_tax_incl = $totalShippingTaxIncluded; - $order->total_shipping_tax_excl = $totalShippingTaxExcluded; - - $order->total_paid -= $shippingDiffTaxIncluded; - $order->total_paid_tax_incl -= $shippingDiffTaxIncluded; - $order->total_paid_tax_excl -= $shippingDiffTaxExcluded; - } - } - - /** - * @param Order $order - * @param Cart $cart - * - * @throws PrestaShopDatabaseException - * @throws PrestaShopException - */ - private function updateOrderCarrier(Order $order, Cart $cart): void - { - $orderCarrier = new OrderCarrier((int) $order->getIdOrderCarrier()); - - if (Validate::isLoadedObject($orderCarrier)) { - $orderCarrier->weight = (float) $order->getTotalWeight(); - $orderCarrier->shipping_cost_tax_incl = (float) $order->total_shipping_tax_incl; - $orderCarrier->shipping_cost_tax_excl = (float) $order->total_shipping_tax_excl; - - if ($orderCarrier->update()) { - $order->weight = sprintf('%.3f ' . $this->getOrderConfiguration('PS_WEIGHT_UNIT', $order), $orderCarrier->weight); - } - } - - if (!$cart->isVirtualCart() && isset($order->id_carrier)) { - $carrier = new Carrier((int) $order->id_carrier, (int) $cart->id_lang); - if (null !== $carrier && Validate::isLoadedObject($carrier)) { - $taxAddressId = (int) $order->{$this->getOrderConfiguration('PS_TAX_ADDRESS_TYPE', $order)}; - $order->carrier_tax_rate = $carrier->getTaxesRate(new Address($taxAddressId)); - } - } - } - - /** - * @param Order $order - * @param Cart $cart - * - * @throws OrderException - * @throws PrestaShopDatabaseException - * @throws PrestaShopException - */ - private function updateOrderDetails(Order $order, Cart $cart): void - { - // Get cart products with prices kept from order - $cartProducts = $cart->getProducts(true, false, null, true, $this->keepOrderPrices); - foreach ($order->getCartProducts() as $orderProduct) { - $orderDetail = new OrderDetail($orderProduct['id_order_detail'], null, $this->contextStateManager->getContext()); - $cartProduct = $this->getProductFromCart($cartProducts, (int) $orderDetail->product_id, (int) $orderDetail->product_attribute_id); - - $this->orderDetailUpdater->updateOrderDetail( - $orderDetail, - $order, - new Number((string) $cartProduct['price_with_reduction_without_tax']), - new Number((string) $cartProduct['price_with_reduction']) - ); - } - } - - /** - * @param array $cartProducts - * @param int $productId - * @param int $productAttributeId - * - * @return array - */ - private function getProductFromCart(array $cartProducts, int $productId, int $productAttributeId): array - { - $cartProduct = array_reduce($cartProducts, function ($carry, $item) use ($productId, $productAttributeId) { - if (null !== $carry) { - return $carry; - } - - $productMatch = $item['id_product'] == $productId; - $combinationMatch = $item['id_product_attribute'] == $productAttributeId; - - return $productMatch && $combinationMatch ? $item : null; - }); - - // This shouldn't happen, if it does something was not done before updating the Order (removing an OrderDetail maybe) - if (null === $cartProduct) { - throw new OrderException('Could not find the product in cart, meaning Order and Cart are out of sync'); - } - - return $cartProduct; - } - - /** - * Update cart rules to be synced with current cart: - * - cart rules attached to new product may be added/removed - * - global shop cart rules may be added/removed - * - cart rules amount may vary because other cart rules have been added/removed - * - * @param Order $order - * @param Cart $cart - * @param int $computingPrecision - * @param int|null $orderInvoiceId - * - * @throws OrderException - * @throws PrestaShopDatabaseException - * @throws PrestaShopException - */ - private function updateOrderCartRules( - Order $order, - Cart $cart, - int $computingPrecision, - ?int $orderInvoiceId - ): void { - CartRule::autoAddToCart(); - CartRule::autoRemoveFromCart(); - $carrierId = $order->id_carrier; - - $newCartRules = $cart->getCartRules(); - // We need the calculator to compute the discount on the whole products because they can interact with each - // other so they can't be computed independently, it needs to keep order prices - $calculator = $cart->newCalculator($order->getCartProducts(), $newCartRules, $carrierId, $computingPrecision, $this->keepOrderPrices); - $calculator->processCalculation(); - - foreach ($order->getCartRules() as $orderCartRuleData) { - /** @var CartRuleData $cartRuleData */ - foreach ($calculator->getCartRulesData() as $cartRuleData) { - $cartRule = $cartRuleData->getCartRule(); - if ($cartRule->id == $orderCartRuleData['id_cart_rule']) { - // Cart rule is still in the cart no need to remove it, but we update it as the amount may have changed - $orderCartRule = new OrderCartRule($orderCartRuleData['id_order_cart_rule']); - $orderCartRule->id_order = $order->id; - $orderCartRule->name = $cartRule->name; - $orderCartRule->free_shipping = $cartRule->free_shipping; - $orderCartRule->value = Tools::ps_round($cartRuleData->getDiscountApplied()->getTaxIncluded(), $computingPrecision); - $orderCartRule->value_tax_excl = Tools::ps_round($cartRuleData->getDiscountApplied()->getTaxExcluded(), $computingPrecision); - $orderCartRule->save(); - continue 2; - } - } - - // This one is no longer in the new cart rules so we delete it - $orderCartRule = new OrderCartRule($orderCartRuleData['id_order_cart_rule']); - // This one really needs to be deleted because it doesn't match the applied cart rules any more - // we don't use soft deleted here (unlike in the handler) but hard delete - if (!$orderCartRule->delete()) { - throw new OrderException('Could not delete order cart rule from database.'); - } - } - - // Finally add the new cart rules that are not in the Order - foreach ($calculator->getCartRulesData() as $cartRuleData) { - $cartRule = $cartRuleData->getCartRule(); - foreach ($order->getCartRules() as $orderCartRuleData) { - if ($cartRule->id == $orderCartRuleData['id_cart_rule']) { - // This cart rule is already present no need to add it - continue 2; - } - } - - // Add missing order cart rule - $orderCartRule = new OrderCartRule(); - $orderCartRule->id_order = $order->id; - $orderCartRule->id_cart_rule = $cartRule->id; - $orderCartRule->id_order_invoice = $orderInvoiceId ?? 0; - $orderCartRule->name = $cartRule->name; - $orderCartRule->free_shipping = $cartRule->free_shipping; - $orderCartRule->value = Tools::ps_round($cartRuleData->getDiscountApplied()->getTaxIncluded(), $computingPrecision); - $orderCartRule->value_tax_excl = Tools::ps_round($cartRuleData->getDiscountApplied()->getTaxExcluded(), $computingPrecision); - $orderCartRule->save(); - } - } - - /** - * @param Order $order - * @param Cart $cart - * @param int $computingPrecision - * - * @throws OrderException - * @throws PrestaShopDatabaseException - * @throws PrestaShopException - */ - private function updateOrderInvoices(Order $order, Cart $cart, int $computingPrecision): void - { - $invoiceProducts = []; - foreach ($order->getCartProducts() as $orderProduct) { - if (!empty($orderProduct['id_order_invoice'])) { - $invoiceProducts[$orderProduct['id_order_invoice']][] = $orderProduct; - } - } - - $invoiceCollection = $order->getInvoicesCollection(); - $firstInvoice = $invoiceCollection->getFirst(); - - foreach ($invoiceCollection as $invoice) { - // If all the invoice's products have been removed the offset won't exist - $currentInvoiceProducts = isset($invoiceProducts[$invoice->id]) ? $invoiceProducts[$invoice->id] : []; - - // Shipping are computed on first invoice only - $carrierId = $order->id_carrier; - $totalMethod = ($firstInvoice === null || $firstInvoice->id == $invoice->id) ? Cart::BOTH : Cart::BOTH_WITHOUT_SHIPPING; - $invoice->total_paid_tax_excl = Tools::ps_round( - (float) $cart->getOrderTotal(false, $totalMethod, $currentInvoiceProducts, $carrierId, false, $this->keepOrderPrices), - $computingPrecision - ); - $invoice->total_paid_tax_incl = Tools::ps_round( - (float) $cart->getOrderTotal(true, $totalMethod, $currentInvoiceProducts, $carrierId, false, $this->keepOrderPrices), - $computingPrecision - ); - - $invoice->total_products = Tools::ps_round( - (float) $cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $currentInvoiceProducts, $carrierId, false, $this->keepOrderPrices), - $computingPrecision - ); - $invoice->total_products_wt = Tools::ps_round( - (float) $cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $currentInvoiceProducts, $carrierId, false, $this->keepOrderPrices), - $computingPrecision - ); - - $invoice->total_discount_tax_excl = Tools::ps_round( - (float) $cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $currentInvoiceProducts, $carrierId, false, $this->keepOrderPrices), - $computingPrecision - ); - - $invoice->total_discount_tax_incl = Tools::ps_round( - (float) $cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $currentInvoiceProducts, $carrierId, false, $this->keepOrderPrices), - $computingPrecision - ); - - $totalShippingTaxIncluded = $invoice->total_shipping_tax_incl; - $totalShippingTaxExcluded = $invoice->total_shipping_tax_excl; - - $invoice->total_shipping = $cart->getOrderTotal(true, Cart::ONLY_SHIPPING, $currentInvoiceProducts, $carrierId, false, $this->keepOrderPrices); - $invoice->total_shipping_tax_excl = $cart->getOrderTotal(false, Cart::ONLY_SHIPPING, $currentInvoiceProducts, $carrierId, false, $this->keepOrderPrices); - $invoice->total_shipping_tax_incl = $cart->getOrderTotal(true, Cart::ONLY_SHIPPING, $currentInvoiceProducts, $carrierId, false, $this->keepOrderPrices); - - if (!$this->getOrderConfiguration('PS_ORDER_RECALCULATE_SHIPPING', $order)) { - $shippingDiffTaxIncluded = $invoice->total_shipping_tax_incl - $totalShippingTaxIncluded; - $shippingDiffTaxExcluded = $invoice->total_shipping_tax_excl - $totalShippingTaxExcluded; - - $invoice->total_shipping = $totalShippingTaxIncluded; - $invoice->total_shipping_tax_incl = $totalShippingTaxIncluded; - $invoice->total_shipping_tax_excl = $totalShippingTaxExcluded; - - $invoice->total_paid -= $shippingDiffTaxIncluded; - $invoice->total_paid_tax_incl -= $shippingDiffTaxIncluded; - $invoice->total_paid_tax_excl -= $shippingDiffTaxExcluded; - } - - if (!$invoice->update()) { - throw new OrderException('Could not update order invoice in database.'); - } - } - } - - /** - * @param Cart $cart - * - * @return int - */ - private function getPrecisionFromCart(Cart $cart): int - { - $computingPrecision = new ComputingPrecision(); - $currency = new Currency((int) $cart->id_currency); - - return $computingPrecision->getPrecision((int) $currency->precision); - } - - /** - * @param string $key - * @param Order $order - * - * @return mixed - */ - private function getOrderConfiguration(string $key, Order $order) - { - return $this->shopConfiguration->get($key, null, $this->getOrderShopConstraint($order)); - } - - /** - * @param Order $order - * - * @return ShopConstraint - */ - private function getOrderShopConstraint(Order $order): ShopConstraint - { - $constraintKey = $order->id_shop . '-' . $order->id_shop_group; - if (!isset($this->orderConstraints[$constraintKey])) { - $this->orderConstraints[$constraintKey] = new ShopConstraint( - (int) $order->id_shop, - (int) $order->id_shop_group - ); - } - - return $this->orderConstraints[$constraintKey]; - } -} diff --git a/src/Adapter/Order/OrderDetailUpdater.php b/src/Adapter/Order/OrderDetailUpdater.php deleted file mode 100644 index a6ef317e..00000000 --- a/src/Adapter/Order/OrderDetailUpdater.php +++ /dev/null @@ -1,471 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Order; - -use Address; -use Cart; -use Country; -use Currency; -use Customer; -use Db; -use Language; -use Order; -use OrderDetail; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Core\Domain\Configuration\ShopConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Shop\ValueObject\ShopConstraint; -use PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision; -use Product; -use Shop; -use TaxCalculator; -use TaxManagerFactory; -use Tools; - -class OrderDetailUpdater -{ - private const COMPARISON_PRECISION = 6; - - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @var ShopConfigurationInterface - */ - private $shopConfiguration; - - /** - * @param ContextStateManager $contextStateManager - * @param ShopConfigurationInterface $shopConfiguration - */ - public function __construct( - ContextStateManager $contextStateManager, - ShopConfigurationInterface $shopConfiguration - ) { - $this->contextStateManager = $contextStateManager; - $this->shopConfiguration = $shopConfiguration; - } - - /** - * @param OrderDetail $orderDetail - * @param Order $order - * @param Number $priceTaxExcluded - * @param Number $priceTaxIncluded - * - * @throws OrderException - */ - public function updateOrderDetail( - OrderDetail $orderDetail, - Order $order, - Number $priceTaxExcluded, - Number $priceTaxIncluded - ): void { - list($roundType, $computingPrecision, $taxAddress) = $this->prepareOrderContext($order); - - try { - $precisePriceTaxExcluded = $this->getPrecisePriceTaxExcluded($priceTaxIncluded, $priceTaxExcluded, $order, $orderDetail, $taxAddress); - $precisePriceTaxIncluded = $this->getPrecisePriceTaxIncluded($priceTaxIncluded, $priceTaxExcluded, $order, $orderDetail, $taxAddress); - - $this->applyOrderDetailPriceUpdate( - $orderDetail, - $precisePriceTaxExcluded, - $precisePriceTaxIncluded, - $roundType, - $computingPrecision - ); - } finally { - $this->contextStateManager->restorePreviousContext(); - } - } - - /** - * @param Order $order - * @param int $productId - * @param int $combinationId - * @param Number $priceTaxExcluded - * @param Number $priceTaxIncluded - * - * @throws OrderException - */ - public function updateOrderDetailsForProduct( - Order $order, - int $productId, - int $combinationId, - Number $priceTaxExcluded, - Number $priceTaxIncluded - ): void { - list($roundType, $computingPrecision, $taxAddress) = $this->prepareOrderContext($order); - - try { - $this->applyUpdatesForProduct( - $order, - $productId, - $combinationId, - $priceTaxExcluded, - $priceTaxIncluded, - $roundType, - $computingPrecision, - $taxAddress - ); - } finally { - $this->contextStateManager->restorePreviousContext(); - } - } - - /** - * @param Order $order - */ - public function updateOrderDetailsTaxes(Order $order): void - { - list($roundType, $computingPrecision, $taxAddress) = $this->prepareOrderContext($order); - - try { - $orderDetailsData = $order->getProducts(); - foreach ($orderDetailsData as $orderDetailData) { - $orderDetail = new OrderDetail($orderDetailData['id_order_detail']); - - // Clean existing order_detail_tax - Db::getInstance()->delete('order_detail_tax', 'id_order_detail = ' . (int) $orderDetail->id); - - $taxCalculator = $this->getTaxCalculatorByAddress($taxAddress, $orderDetail); - $taxesAmount = $taxCalculator->getTaxesAmount($orderDetail->unit_price_tax_excl); - $unitAmount = $totalAmount = 0; - if (!empty($taxesAmount)) { - $orderDetailTaxes = []; - foreach ($taxesAmount as $taxId => $amount) { - switch ($roundType) { - case Order::ROUND_ITEM: - $unitAmount = (float) Tools::ps_round($amount, $computingPrecision); - $totalAmount = $unitAmount * $orderDetail->product_quantity; - - break; - case Order::ROUND_LINE: - $unitAmount = $amount; - $totalAmount = Tools::ps_round($unitAmount * $orderDetail->product_quantity, $computingPrecision); - - break; - case Order::ROUND_TOTAL: - $unitAmount = $amount; - $totalAmount = $unitAmount * $orderDetail->product_quantity; - - break; - } - $orderDetailTaxes[] = [ - 'id_order_detail' => $orderDetail->id, - 'id_tax' => $taxId, - 'unit_amount' => (float) $unitAmount, - 'total_amount' => (float) $totalAmount, - ]; - $orderDetail->unit_price_tax_incl = (float) $orderDetail->unit_price_tax_excl + $unitAmount; - $orderDetail->total_price_tax_incl = (float) $orderDetail->total_price_tax_incl + $totalAmount; - } - - Db::getInstance()->insert('order_detail_tax', $orderDetailTaxes, false); - } - - // Update OrderDetail values - $orderDetail->unit_price_tax_incl = (float) $orderDetail->unit_price_tax_excl + $unitAmount; - $orderDetail->total_price_tax_incl = (float) $orderDetail->total_price_tax_incl + $totalAmount; - if (!$orderDetail->update()) { - throw new OrderException('An error occurred while editing the product line.'); - } - } - } finally { - $this->contextStateManager->restorePreviousContext(); - } - } - - /** - * @param Order $order - * - * @return array - */ - private function prepareOrderContext(Order $order): array - { - $shopConstraint = new ShopConstraint( - (int) $order->id_shop, - (int) $order->id_shop_group - ); - $roundType = (int) $this->shopConfiguration->get('PS_ROUND_TYPE', null, $shopConstraint); - $taxAddressType = $this->shopConfiguration->get('PS_TAX_ADDRESS_TYPE', null, $shopConstraint); - $taxAddress = new Address($order->{$taxAddressType}); - $country = new Country($taxAddress->id_country); - $currency = new Currency($order->id_currency); - $shop = new Shop($order->id_shop); - $computingPrecision = (new ComputingPrecision())->getPrecision((int) $currency->precision); - - $this->contextStateManager - ->saveCurrentContext() - ->setCart(new Cart($order->id_cart)) - ->setCustomer(new Customer($order->id_customer)) - ->setLanguage(new Language($order->id_lang)) - ->setCurrency($currency) - ->setCountry($country) - ->setShop($shop) - ; - - return [$roundType, $computingPrecision, $taxAddress]; - } - - /** - * @param OrderDetail $orderDetail - * @param Number $priceTaxExcluded - * @param Number $priceTaxIncluded - * @param int $roundType - * @param int $computingPrecision - * - * @throws OrderException - */ - private function applyOrderDetailPriceUpdate( - OrderDetail $orderDetail, - Number $priceTaxExcluded, - Number $priceTaxIncluded, - int $roundType, - int $computingPrecision - ): void { - $floatPriceTaxExcluded = (float) (string) $priceTaxExcluded; - $floatPriceTaxIncluded = (float) (string) $priceTaxIncluded; - - $orderDetail->product_price = $orderDetail->unit_price_tax_excl = $floatPriceTaxExcluded; - $orderDetail->unit_price_tax_incl = $floatPriceTaxIncluded; - switch ($roundType) { - case Order::ROUND_TOTAL: - $orderDetail->total_price_tax_excl = $floatPriceTaxExcluded * $orderDetail->product_quantity; - $orderDetail->total_price_tax_incl = $floatPriceTaxIncluded * $orderDetail->product_quantity; - - break; - case Order::ROUND_LINE: - $orderDetail->total_price_tax_excl = Tools::ps_round($floatPriceTaxExcluded * $orderDetail->product_quantity, $computingPrecision); - $orderDetail->total_price_tax_incl = Tools::ps_round($floatPriceTaxIncluded * $orderDetail->product_quantity, $computingPrecision); - - break; - - case Order::ROUND_ITEM: - default: - $orderDetail->product_price = $orderDetail->unit_price_tax_excl = Tools::ps_round($floatPriceTaxExcluded, $computingPrecision); - $orderDetail->unit_price_tax_incl = Tools::ps_round($floatPriceTaxIncluded, $computingPrecision); - $orderDetail->total_price_tax_excl = $orderDetail->unit_price_tax_excl * $orderDetail->product_quantity; - $orderDetail->total_price_tax_incl = $orderDetail->unit_price_tax_incl * $orderDetail->product_quantity; - - break; - } - - if (!$orderDetail->update()) { - throw new OrderException('An error occurred while editing the product line.'); - } - } - - /** - * @param Order $order - * @param int $productId - * @param int $combinationId - * @param Number $priceTaxExcluded - * @param Number $priceTaxIncluded - * @param int $roundType - * @param int $computingPrecision - * @param Address $taxAddress - * - * @throws OrderException - */ - private function applyUpdatesForProduct( - Order $order, - int $productId, - int $combinationId, - Number $priceTaxExcluded, - Number $priceTaxIncluded, - int $roundType, - int $computingPrecision, - Address $taxAddress - ): void { - $identicalOrderDetails = $this->getOrderDetailsForProduct($order, $productId, $combinationId); - if (empty($identicalOrderDetails)) { - return; - } - - // Get precise prices thanks to first OrderDetail (they all have the same price anyway) - $orderDetail = $identicalOrderDetails[0]; - $precisePriceTaxExcluded = $this->getPrecisePriceTaxExcluded($priceTaxIncluded, $priceTaxExcluded, $order, $orderDetail, $taxAddress); - $precisePriceTaxIncluded = $this->getPrecisePriceTaxIncluded($priceTaxIncluded, $priceTaxExcluded, $order, $orderDetail, $taxAddress); - - foreach ($identicalOrderDetails as $identicalOrderDetail) { - $this->applyOrderDetailPriceUpdate( - $identicalOrderDetail, - $precisePriceTaxExcluded, - $precisePriceTaxIncluded, - $roundType, - $computingPrecision - ); - } - } - - /** - * @param Order $order - * @param int $productId - * @param int $combinationId - * - * @return array - */ - private function getOrderDetailsForProduct( - Order $order, - int $productId, - int $combinationId - ): array { - $identicalOrderDetails = []; - $orderDetails = $order->getOrderDetailList(); - foreach ($orderDetails as $orderDetail) { - if ((int) $orderDetail['product_id'] === $productId - && (int) $orderDetail['product_attribute_id'] === $combinationId) { - $identicalOrderDetails[] = new OrderDetail($orderDetail['id_order_detail']); - } - } - - return $identicalOrderDetails; - } - - /** - * Since prices in input are sometimes rounded they don't precisely match, so in this case - * if the price is different from catalog we use price included as a base and recompute the - * price tax excluded with additional precision. - * - * @param Number $priceTaxIncluded - * @param Number $priceTaxExcluded - * @param Order $order - * @param OrderDetail $orderDetail - * @param Address $taxAddress - * - * @return Number - */ - private function getPrecisePriceTaxExcluded( - Number $priceTaxIncluded, - Number $priceTaxExcluded, - Order $order, - OrderDetail $orderDetail, - Address $taxAddress - ): Number { - $productOriginalPrice = $this->getProductRegularPrice($order, $orderDetail, $taxAddress); - - // If provided price is equal to catalog price no need to recompute - if ($productOriginalPrice->equals($priceTaxExcluded)) { - return $priceTaxExcluded; - } - - $productTaxCalculator = $this->getTaxCalculatorByAddress($taxAddress, $orderDetail); - $taxFactor = new Number((string) (1 + ($productTaxCalculator->getTotalRate() / 100))); - - $computedPriceTaxIncluded = $priceTaxExcluded->times($taxFactor); - if ($computedPriceTaxIncluded->equals($priceTaxIncluded)) { - return $priceTaxExcluded; - } - - // When price tax included is computed based on price tax excluded there is a difference - // so we recompute the price tax excluded based on the tax rate to have more precision - return $priceTaxIncluded->dividedBy($taxFactor); - } - - /** - * Since prices in input are sometimes rounded they don't precisely match, so in this case - * if the price is the same as the catalog we use price excluded as a base and recompute the - * price tax included with additional precision. - * - * @param Number $priceTaxIncluded - * @param Number $priceTaxExcluded - * @param Order $order - * @param OrderDetail $orderDetail - * @param Address $taxAddress - * - * @return Number - */ - private function getPrecisePriceTaxIncluded( - Number $priceTaxIncluded, - Number $priceTaxExcluded, - Order $order, - OrderDetail $orderDetail, - Address $taxAddress - ): Number { - $productOriginalPrice = $this->getProductRegularPrice($order, $orderDetail, $taxAddress); - - // If provided price is different from the catalog price we use the input price tax included as a base - if (!$productOriginalPrice->equals($priceTaxExcluded)) { - return $priceTaxIncluded; - } - - $productTaxCalculator = $this->getTaxCalculatorByAddress($taxAddress, $orderDetail); - $taxFactor = new Number((string) (1 + ($productTaxCalculator->getTotalRate() / 100))); - - return $priceTaxExcluded->times($taxFactor); - } - - /** - * @param Order $order - * @param OrderDetail $orderDetail - * @param Address $taxAddress - * - * @return Number - */ - private function getProductRegularPrice( - Order $order, - OrderDetail $orderDetail, - Address $taxAddress - ): Number { - // Get price via getPriceStatic so that the catalog price rules are applied - - return new Number((string) Product::getPriceStatic( - (int) $orderDetail->product_id, - false, - (int) $orderDetail->product_attribute_id, - self::COMPARISON_PRECISION, - null, - false, - true, - 1, - false, - $order->id_customer, // We still use the customer ID in case this customer has some special prices - null, // But we keep the cart null as we don't want this order overridden price - $taxAddress->id - )); - } - - /** - * Get a TaxCalculator adapted for the OrderDetail's product and the specified address - * - * @param Address $address - * @param OrderDetail $orderDetail - * - * @return TaxCalculator - */ - private function getTaxCalculatorByAddress(Address $address, OrderDetail $orderDetail): TaxCalculator - { - $tax_manager = TaxManagerFactory::getManager($address, $orderDetail->getTaxRulesGroupId()); - - return $tax_manager->getTaxCalculator(); - } -} diff --git a/src/Adapter/Order/OrderPresenter.php b/src/Adapter/Order/OrderPresenter.php deleted file mode 100644 index fa555c42..00000000 --- a/src/Adapter/Order/OrderPresenter.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order; - -/** - * @deprecated since 1.7.4.0 - * @see \PrestaShop\PrestaShop\Adapter\Presenter\Order\OrderPresenter - */ -class OrderPresenter extends \PrestaShop\PrestaShop\Adapter\Presenter\Order\OrderPresenter -{ -} diff --git a/src/Adapter/Order/OrderProductQuantityUpdater.php b/src/Adapter/Order/OrderProductQuantityUpdater.php deleted file mode 100644 index 674d8c91..00000000 --- a/src/Adapter/Order/OrderProductQuantityUpdater.php +++ /dev/null @@ -1,507 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Order; - -use Cart; -use Configuration; -use Context; -use Currency; -use Customer; -use Customization; -use Db; -use Language; -use Order; -use OrderDetail; -use OrderInvoice; -use Pack; -use PrestaShop\PrestaShop\Adapter\Cart\Comparator\CartProductsComparator; -use PrestaShop\PrestaShop\Adapter\Cart\Comparator\CartProductUpdate; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Adapter\Order\Refund\OrderProductRemover; -use PrestaShop\PrestaShop\Adapter\StockManager; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductOutOfStockException; -use Product; -use Shop; -use StockAvailable; -use StockManagerFactory; -use StockMvt; -use Warehouse; - -/** - * Increase or decrease quantity of an order's product. - * Recalculate cart rules, order's prices and shipping infos. - */ -class OrderProductQuantityUpdater -{ - /** - * @var OrderAmountUpdater - */ - private $orderAmountUpdater; - - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @var OrderProductRemover - */ - private $orderProductRemover; - - public function __construct( - OrderAmountUpdater $orderAmountUpdater, - OrderProductRemover $orderProductRemover, - ContextStateManager $contextStateManager - ) { - $this->orderAmountUpdater = $orderAmountUpdater; - $this->orderProductRemover = $orderProductRemover; - $this->contextStateManager = $contextStateManager; - } - - /** - * @param Order $order - * @param OrderDetail $orderDetail - * @param int $newQuantity - * @param OrderInvoice|null $orderInvoice - * @param bool $updateCart Used when you don't want to update the cart (CartRule removal for example) - * - * @return Order - * - * @throws OrderException - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - public function update( - Order $order, - OrderDetail $orderDetail, - int $newQuantity, - ?OrderInvoice $orderInvoice, - bool $updateCart = true - ): Order { - $cart = new Cart($order->id_cart); - - $this->contextStateManager - ->saveCurrentContext() - ->setCart($cart) - ->setCurrency(new Currency($cart->id_currency)) - ->setCustomer(new Customer($cart->id_customer)) - ->setLanguage(new Language($cart->id_lang)) - ->setCountry($cart->getTaxCountry()) - ->setShop(new Shop($cart->id_shop)) - ; - - try { - $this->updateOrderDetail($order, $cart, $orderDetail, $newQuantity, $orderInvoice, $updateCart); - - // Update prices on the order after cart rules are recomputed - $this->orderAmountUpdater->update($order, $cart, null !== $orderInvoice ? (int) $orderInvoice->id : null); - } finally { - $this->contextStateManager->restorePreviousContext(); - } - - return $order; - } - - /** - * @param Order $order - * @param Cart $cart - * @param OrderDetail $orderDetail - * @param int $newQuantity - * @param OrderInvoice|null $orderInvoice - * @param bool $updateCart - * - * @throws OrderException - * @throws ProductOutOfStockException - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - private function updateOrderDetail( - Order $order, - Cart $cart, - OrderDetail $orderDetail, - int $newQuantity, - ?OrderInvoice $orderInvoice, - bool $updateCart - ): void { - $oldQuantity = (int) $orderDetail->product_quantity; - - // Perform deletion first, we don't want the OrderDetail to be saved with a quantity 0, this could lead to bugs - if (0 === $newQuantity) { - // Product deletion - $updatedProducts = $this->orderProductRemover->deleteProductFromOrder($order, $orderDetail, $updateCart); - $this->updateCustomizationOnProductDelete($order, $orderDetail, $oldQuantity); - $this->applyOtherProductUpdates($order, $cart, $orderInvoice, $updatedProducts); - } else { - $this->assertValidProductQuantity($orderDetail, $newQuantity); - // It's important to override the invoice, this is what allows to switch an OrderDetail from an invoice to another - if (null !== $orderInvoice) { - $orderDetail->id_order_invoice = $orderInvoice->id; - } - - $orderDetail->product_quantity = $newQuantity; - $orderDetail->reduction_percent = 0; - $orderDetail->update(); - - if ($orderDetail->id_customization > 0) { - $customization = new Customization($orderDetail->id_customization); - $customization->quantity = $newQuantity; - $customization->save(); - } - - // Update quantity on the cart and stock - if ($updateCart) { - $updatedProducts = $this->updateProductQuantity($cart, $orderDetail, $oldQuantity, $newQuantity); - $this->applyOtherProductUpdates($order, $cart, $orderInvoice, $updatedProducts); - } - } - - // Update product stocks - $this->updateStocks($cart, $orderDetail, $oldQuantity, $newQuantity); - } - - /** - * @param Order $order - * @param Cart $cart - * @param OrderInvoice|null $orderInvoice - * @param CartProductUpdate[] $updatedProducts - */ - private function applyOtherProductUpdates( - Order $order, - Cart $cart, - ?OrderInvoice $orderInvoice, - array $updatedProducts - ) { - // Some products have been affected by the removal of the initial product (probably related to a CartRule) - // So we detect the changes that happened in the cart and apply them on the OrderDetail - $orderDetails = $order->getOrderDetailList(); - foreach ($updatedProducts as $updatedProduct) { - $updatedCombinationId = $updatedProduct->getCombinationId() !== null ? $updatedProduct->getCombinationId()->getValue() : 0; - $updatedOrderDetail = null; - foreach ($orderDetails as $orderDetailData) { - if ((int) $orderDetailData['product_id'] === $updatedProduct->getProductId()->getValue() - && (int) $orderDetailData['product_attribute_id'] === $updatedCombinationId) { - $updatedOrderDetail = new OrderDetail($orderDetailData['id_order_detail']); - break; - } - } - - if (null !== $updatedOrderDetail) { - $newUpdatedQuantity = (int) $updatedOrderDetail->product_quantity + $updatedProduct->getDeltaQuantity(); - // Important: we update the OrderDetail but not the cart (it is already updated) to avoid infinite loop - $this->updateOrderDetail( - $order, - $cart, - $updatedOrderDetail, - $newUpdatedQuantity, - $orderInvoice, - false - ); - } - } - } - - /** - * @param Cart $cart - * @param OrderDetail $orderDetail - * @param int $oldQuantity - * @param int $newQuantity - * - * @return array - */ - private function updateProductQuantity( - Cart $cart, - OrderDetail $orderDetail, - int $oldQuantity, - int $newQuantity - ): array { - $deltaQuantity = $newQuantity - $oldQuantity; - - if (0 === $deltaQuantity) { - return []; - } - - $cartComparator = new CartProductsComparator($cart); - $knownUpdates = [ - new CartProductUpdate( - (int) $orderDetail->product_id, - (int) $orderDetail->product_attribute_id, - $deltaQuantity, - false - ), - ]; - - /** - * Here we update product and customization in the cart. - * - * The last argument "skip quantity check" is set to true because - * 1) the quantity has already been checked, - * 2) (main reason) when the cart checks the availability ; it substracts - * its own quantity from available stock. - * - * This is because a product in a cart is not really out of the stock, because it is not checked out yet. - * - * Here we are editing an order, not a cart, so what has been ordered - * has already been substracted from the stock. - */ - $updateQuantityResult = $cart->updateQty( - abs($deltaQuantity), - $orderDetail->product_id, - $orderDetail->product_attribute_id, - false, - $deltaQuantity < 0 ? 'down' : 'up', - 0, - new Shop($cart->id_shop), - true, - true - ); - - if (-1 === $updateQuantityResult) { - throw new \LogicException('Minimum quantity is not respected'); - } elseif (true !== $updateQuantityResult) { - throw new \LogicException('Something went wrong'); - } - - return $cartComparator->getUpdatedProducts($knownUpdates); - } - - /** - * @param Cart $cart - * @param OrderDetail $orderDetail - * @param int $oldQuantity - * @param int $newQuantity - * - * @throws OrderException - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - private function updateStocks(Cart $cart, OrderDetail $orderDetail, int $oldQuantity, int $newQuantity): void - { - $deltaQuantity = $oldQuantity - $newQuantity; - - if (0 === $deltaQuantity) { - return; - } - - if (0 === $newQuantity) { - // Product deletion. Reinject quantity in stock - $this->reinjectQuantity($orderDetail, $oldQuantity, $newQuantity, true); - } elseif ($deltaQuantity > 0) { - // Increase product quantity - StockAvailable::updateQuantity( - $orderDetail->product_id, - $orderDetail->product_attribute_id, - $deltaQuantity, - $cart->id_shop, - true, - [ - 'id_order' => $orderDetail->id_order, - 'id_stock_mvt_reason' => Configuration::get('PS_STOCK_CUSTOMER_RETURN_REASON'), - ] - ); - } else { - // Decrease product quantity. Reinject quantity in stock - $this->reinjectQuantity($orderDetail, $oldQuantity, $newQuantity, false); - } - } - - /** - * @param OrderDetail $orderDetail - * @param int $oldQuantity - * @param int $newQuantity - * @param bool $delete - * - * @throws OrderException - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - protected function reinjectQuantity( - OrderDetail $orderDetail, - int $oldQuantity, - int $newQuantity, - $delete = false - ) { - // Reinject product - $reinjectableQuantity = $oldQuantity - $newQuantity; - $quantityToReinject = $oldQuantity > $reinjectableQuantity ? $reinjectableQuantity : $oldQuantity; - - $product = new Product( - $orderDetail->product_id, - false, - (int) Context::getContext()->language->id, - (int) $orderDetail->id_shop - ); - - if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') - && $product->advanced_stock_management - && $orderDetail->id_warehouse != 0 - ) { - $manager = StockManagerFactory::getManager(); - $movements = StockMvt::getNegativeStockMvts( - $orderDetail->id_order, - $orderDetail->product_id, - $orderDetail->product_attribute_id, - $quantityToReinject - ); - - foreach ($movements as $movement) { - if ($quantityToReinject > $movement['physical_quantity']) { - $quantityToReinject = $movement['physical_quantity']; - } - - if (Pack::isPack((int) $product->id)) { - // Gets items - if ($product->pack_stock_type == Pack::STOCK_TYPE_PRODUCTS_ONLY - || $product->pack_stock_type == Pack::STOCK_TYPE_PACK_BOTH - || ($product->pack_stock_type == Pack::STOCK_TYPE_DEFAULT - && Configuration::get('PS_PACK_STOCK_TYPE') > 0) - ) { - $products_pack = Pack::getItems((int) $product->id, (int) Configuration::get('PS_LANG_DEFAULT')); - // Foreach item - foreach ($products_pack as $product_pack) { - if ($product_pack->advanced_stock_management == 1) { - $manager->addProduct( - $product_pack->id, - $product_pack->id_pack_product_attribute, - new Warehouse($movement['id_warehouse']), - $product_pack->pack_quantity * $quantityToReinject, - null, - $movement['price_te'] - ); - } - } - } - - if ($product->pack_stock_type == Pack::STOCK_TYPE_PACK_ONLY - || $product->pack_stock_type == Pack::STOCK_TYPE_PACK_BOTH - || ( - $product->pack_stock_type == Pack::STOCK_TYPE_DEFAULT - && (Configuration::get('PS_PACK_STOCK_TYPE') == Pack::STOCK_TYPE_PACK_ONLY - || Configuration::get('PS_PACK_STOCK_TYPE') == Pack::STOCK_TYPE_PACK_BOTH) - ) - ) { - $manager->addProduct( - $orderDetail->product_id, - $orderDetail->product_attribute_id, - new Warehouse($movement['id_warehouse']), - $quantityToReinject, - null, - $movement['price_te'] - ); - } - } else { - $manager->addProduct( - $orderDetail->product_id, - $orderDetail->product_attribute_id, - new Warehouse($movement['id_warehouse']), - $quantityToReinject, - null, - $movement['price_te'] - ); - } - } - - $productId = $orderDetail->product_id; - - if ($delete) { - $orderDetail->delete(); - } - - StockAvailable::synchronize($productId); - } elseif ($orderDetail->id_warehouse == 0) { - StockAvailable::updateQuantity( - $orderDetail->product_id, - $orderDetail->product_attribute_id, - $quantityToReinject, - $orderDetail->id_shop, - true, - [ - 'id_order' => $orderDetail->id_order, - 'id_stock_mvt_reason' => Configuration::get('PS_STOCK_CUSTOMER_RETURN_REASON'), - ] - ); - - // sync all stock - (new StockManager())->updatePhysicalProductQuantity( - (int) $orderDetail->id_shop, - (int) Configuration::get('PS_OS_ERROR'), - (int) Configuration::get('PS_OS_CANCELED'), - null, - (int) $orderDetail->id_order - ); - - if ($delete) { - $orderDetail->delete(); - } - } else { - throw new OrderException('This product cannot be re-stocked.'); - } - } - - /** - * @param Order $order - * @param OrderDetail $orderDetail - * @param int $oldQuantity - * - * @throws OrderException - */ - private function updateCustomizationOnProductDelete(Order $order, OrderDetail $orderDetail, int $oldQuantity): void - { - if (!(int) $order->getCurrentState()) { - throw new OrderException('Could not get a valid Order state before deletion'); - } - - if ($order->hasBeenPaid()) { - Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'customization` SET `quantity_refunded` = `quantity_refunded` + ' . (int) $oldQuantity . ' WHERE `id_customization` = ' . (int) $orderDetail->id_customization . ' AND `id_cart` = ' . (int) $order->id_cart . ' AND `id_product` = ' . (int) $orderDetail->product_id); - } - - if (!Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'customization` WHERE `quantity` = 0')) { - throw new OrderException('Could not delete customization from database.'); - } - } - - /** - * @param OrderDetail $orderDetail - * @param int $newQuantity - * - * @throws ProductOutOfStockException - */ - private function assertValidProductQuantity(OrderDetail $orderDetail, int $newQuantity) - { - //check if product is available in stock - if (!Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock($orderDetail->product_id))) { - $availableQuantity = StockAvailable::getQuantityAvailableByProduct($orderDetail->product_id, $orderDetail->product_attribute_id); - $quantityDiff = $newQuantity - (int) $orderDetail->product_quantity; - - if ($quantityDiff > $availableQuantity) { - throw new ProductOutOfStockException('Not enough products in stock'); - } - } - } -} diff --git a/src/Adapter/Order/OrderReturnPresenter.php b/src/Adapter/Order/OrderReturnPresenter.php deleted file mode 100644 index 46dacd75..00000000 --- a/src/Adapter/Order/OrderReturnPresenter.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Order; - -/** - * @deprecated since 1.7.4.0 - * @see \PrestaShop\PrestaShop\Adapter\Presenter\Order\OrderReturnPresenter - */ -class OrderReturnPresenter extends \PrestaShop\PrestaShop\Adapter\Presenter\Order\OrderReturnPresenter -{ -} diff --git a/src/Adapter/Order/OrderSiblingProvider.php b/src/Adapter/Order/OrderSiblingProvider.php deleted file mode 100644 index 7f95fbdc..00000000 --- a/src/Adapter/Order/OrderSiblingProvider.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Order; - -use Order; -use PrestaShop\PrestaShop\Core\Order\OrderSiblingProviderInterface; - -class OrderSiblingProvider implements OrderSiblingProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getNextOrderId(int $orderId): int - { - $order = new Order($orderId); - - return (int) $order->getNextOrderId(); - } - - /** - * {@inheritdoc} - */ - public function getPreviousOrderId(int $orderId): int - { - $order = new Order($orderId); - - return (int) $order->getPreviousOrderId(); - } -} diff --git a/src/Adapter/Order/QueryHandler/GetOrderForViewingHandler.php b/src/Adapter/Order/QueryHandler/GetOrderForViewingHandler.php deleted file mode 100644 index f35b2b14..00000000 --- a/src/Adapter/Order/QueryHandler/GetOrderForViewingHandler.php +++ /dev/null @@ -1,808 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\QueryHandler; - -use Address; -use Carrier; -use Configuration; -use ConnectionsSource; -use Context; -use Country; -use Currency; -use Customer; -use DateTimeImmutable; -use Gender; -use Module; -use Order; -use OrderInvoice; -use OrderPayment; -use OrderSlip; -use OrderState; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Adapter\Customer\CustomerDataProvider; -use PrestaShop\PrestaShop\Adapter\Order\AbstractOrderHandler; -use PrestaShop\PrestaShop\Core\Domain\Exception\InvalidSortingException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\OrderDocumentType; -use PrestaShop\PrestaShop\Core\Domain\Order\Query\GetOrderForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\Query\GetOrderProductsForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryHandler\GetOrderForViewingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryHandler\GetOrderProductsForViewingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\LinkedOrderForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\LinkedOrdersForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderCarrierForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderCustomerForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderDiscountForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderDiscountsForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderDocumentForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderDocumentsForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderHistoryForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderInvoiceAddressForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderMessageDateForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderMessageForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderMessagesForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderPaymentForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderPaymentsForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderPricesForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderProductsForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderReturnForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderReturnsForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderShippingAddressForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderShippingForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderSourceForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderSourcesForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderStatusForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; -use PrestaShop\PrestaShop\Core\Image\Parser\ImageTagSourceParserInterface; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShop\PrestaShop\Core\Localization\Locale; -use State; -use Symfony\Component\Translation\TranslatorInterface; -use Tools; -use Validate; - -/** - * Handle getting order for viewing - * - * @internal - */ -final class GetOrderForViewingHandler extends AbstractOrderHandler implements GetOrderForViewingHandlerInterface -{ - /** - * @var Locale - */ - private $locale; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var int - */ - private $contextLanguageId; - - /** - * @var CustomerDataProvider - */ - private $customerDataProvider; - - /** - * @var Context - */ - private $context; - - /** - * @var GetOrderProductsForViewingHandlerInterface - */ - private $getOrderProductsForViewingHandler; - - /** - * @param ImageTagSourceParserInterface $imageTagSourceParser - * @param TranslatorInterface $translator - * @param int $contextLanguageId - * @param Locale $locale - * @param Context $context - * @param CustomerDataProvider $customerDataProvider - * @param GetOrderProductsForViewingHandlerInterface $getOrderProductsForViewingHandler - */ - public function __construct( - TranslatorInterface $translator, - int $contextLanguageId, - Locale $locale, - Context $context, - CustomerDataProvider $customerDataProvider, - GetOrderProductsForViewingHandlerInterface $getOrderProductsForViewingHandler - ) { - $this->translator = $translator; - $this->contextLanguageId = $contextLanguageId; - $this->locale = $locale; - $this->translator = $translator; - $this->context = $context; - $this->customerDataProvider = $customerDataProvider; - $this->getOrderProductsForViewingHandler = $getOrderProductsForViewingHandler; - } - - /** - * {@inheritdoc} - */ - public function handle(GetOrderForViewing $query): OrderForViewing - { - $order = $this->getOrder($query->getOrderId()); - $orderCarrier = new Carrier($order->id_carrier); - $taxCalculationMethod = $this->getOrderTaxCalculationMethod($order); - - $isTaxIncluded = ($taxCalculationMethod == PS_TAX_INC); - - $taxMethod = $isTaxIncluded ? - $this->translator->trans('Tax included', [], 'Admin.Global') : - $this->translator->trans('Tax excluded', [], 'Admin.Global'); - - $invoiceManagementIsEnabled = (bool) Configuration::get('PS_INVOICE', null, null, $order->id_shop); - - return new OrderForViewing( - (int) $order->id, - (int) $order->id_currency, - (int) $order->id_carrier, - (string) $orderCarrier->name, - (int) $order->id_shop, - $order->reference, - (bool) $order->isVirtual(), - $taxMethod, - $isTaxIncluded, - (bool) $order->valid, - $order->hasBeenPaid(), - $order->hasInvoice(), - $order->hasBeenDelivered(), - $order->hasBeenShipped(), - $invoiceManagementIsEnabled, - new DateTimeImmutable($order->date_add), - $this->getOrderCustomer($order), - $this->getOrderShippingAddress($order), - $this->getOrderInvoiceAddress($order), - $this->getOrderProducts($query->getOrderId(), $query->getProductsSorting()->getValue()), - $this->getOrderHistory($order), - $this->getOrderDocuments($order), - $this->getOrderShipping($order), - $this->getOrderReturns($order), - $this->getOrderPayments($order), - $this->getOrderMessages($order), - $this->getOrderPrices($order), - $this->getOrderDiscounts($order), - $this->getOrderSources($order), - $this->getLinkedOrders($order) - ); - } - - /** - * @param Order $order - * - * @return OrderCustomerForViewing|null - */ - private function getOrderCustomer(Order $order): ?OrderCustomerForViewing - { - $currency = new Currency($order->id_currency); - $customer = new Customer($order->id_customer); - - if (!Validate::isLoadedObject($customer)) { - return null; - } - - $gender = new Gender($customer->id_gender); - $genderName = ''; - - if (Validate::isLoadedObject($gender)) { - $genderName = $gender->name[$order->id_lang]; - } - - $customerStats = $customer->getStats(); - $totalSpentSinceRegistration = Tools::convertPrice($customerStats['total_orders'], $order->id_currency); - - return new OrderCustomerForViewing( - $customer->id, - $customer->firstname, - $customer->lastname, - $genderName, - $customer->email, - new DateTimeImmutable($customer->date_add), - $totalSpentSinceRegistration !== null ? $this->locale->formatPrice($totalSpentSinceRegistration, $currency->iso_code) : '', - $customerStats['nb_orders'], - $customer->note, - (bool) $customer->is_guest - ); - } - - /** - * @param Order $order - * - * @return OrderShippingAddressForViewing - */ - public function getOrderShippingAddress(Order $order): OrderShippingAddressForViewing - { - $address = new Address($order->id_address_delivery); - $country = new Country($address->id_country); - $stateName = ''; - - if ($address->id_state) { - $state = new State($address->id_state); - - $stateName = $state->name; - } - - return new OrderShippingAddressForViewing( - $address->id, - $address->firstname, - $address->lastname, - $address->company, - $address->address1, - $address->address2, - $stateName, - $address->city, - $country->name[$order->id_lang], - $address->postcode, - $address->phone, - $address->phone_mobile - ); - } - - /** - * @param Order $order - * - * @return OrderInvoiceAddressForViewing - */ - private function getOrderInvoiceAddress(Order $order): OrderInvoiceAddressForViewing - { - $address = new Address($order->id_address_invoice); - $country = new Country($address->id_country); - $stateName = ''; - - if ($address->id_state) { - $state = new State($address->id_state); - - $stateName = $state->name; - } - - return new OrderInvoiceAddressForViewing( - $address->id, - $address->firstname, - $address->lastname, - $address->company, - $address->address1, - $address->address2, - $stateName, - $address->city, - $country->name[$order->id_lang], - $address->postcode, - $address->phone, - $address->phone_mobile - ); - } - - /** - * @param Order $order - * - * @return OrderHistoryForViewing - */ - private function getOrderHistory(Order $order): OrderHistoryForViewing - { - $history = $order->getHistory($this->contextLanguageId); - - $statuses = []; - - foreach ($history as $item) { - $statuses[] = new OrderStatusForViewing( - (int) $item['id_order_history'], - (int) $item['id_order_state'], - $item['ostate_name'], - $item['color'], - new DateTimeImmutable($item['date_add']), - (bool) $item['send_email'], - $item['employee_firstname'], - $item['employee_lastname'] - ); - } - - return new OrderHistoryForViewing( - $order->current_state, - $statuses - ); - } - - /** - * @param Order $order - * - * @return OrderDocumentsForViewing - * - * @throws LocalizationException - */ - private function getOrderDocuments(Order $order): OrderDocumentsForViewing - { - $currency = new Currency($order->id_currency); - $documents = $order->getDocuments(); - - $documentsForViewing = []; - - /** @var OrderInvoice|OrderSlip $document */ - foreach ($documents as $document) { - $type = null; - $number = null; - $amount = null; - $numericAmount = null; - $amountMismatch = null; - $availableAction = null; - $isAddPaymentAllowed = false; - - if ($document instanceof OrderInvoice) { - $type = isset($document->is_delivery) ? OrderDocumentType::DELIVERY_SLIP : OrderDocumentType::INVOICE; - } elseif ($document instanceof OrderSlip) { - $type = OrderDocumentType::CREDIT_SLIP; - } - - if (OrderDocumentType::INVOICE === $type) { - $number = $document->getInvoiceNumberFormatted( - $this->contextLanguageId, - $order->id_shop - ); - - if ($document->getRestPaid()) { - $isAddPaymentAllowed = true; - } - $amount = $this->locale->formatPrice($document->total_paid_tax_incl, $currency->iso_code); - $numericAmount = $document->total_paid_tax_incl; - - if ($document->getTotalPaid()) { - if ($document->getRestPaid() > 0) { - $amountMismatch = sprintf( - '%s %s', - $this->locale->formatPrice($document->getRestPaid(), $currency->iso_code), - $this->translator->trans('not paid', [], 'Admin.Orderscustomers.Feature') - ); - } elseif ($document->getRestPaid() < 0) { - $amountMismatch = sprintf( - '%s %s', - $this->locale->formatPrice($document->getRestPaid(), $currency->iso_code), - $this->translator->trans('overpaid', [], 'Admin.Orderscustomers.Feature') - ); - } - } - } elseif (OrderDocumentType::DELIVERY_SLIP === $type) { - $number = sprintf( - '%s%06d', - Configuration::get('PS_DELIVERY_PREFIX', $this->contextLanguageId, null, $order->id_shop), - $document->delivery_number - ); - $amount = $this->locale->formatPrice( - $document->total_shipping_tax_incl, - $currency->iso_code - ); - $numericAmount = $document->total_shipping_tax_incl; - } elseif (OrderDocumentType::CREDIT_SLIP) { - $number = sprintf( - '%s%06d', - Configuration::get('PS_CREDIT_SLIP_PREFIX', $this->contextLanguageId), - $document->id - ); - $amount = $this->locale->formatPrice( - $document->total_products_tax_incl + $document->total_shipping_tax_incl, - $currency->iso_code - ); - $numericAmount = $document->total_products_tax_incl + $document->total_shipping_tax_incl; - } - - $documentsForViewing[] = new OrderDocumentForViewing( - $document->id, - $type, - new DateTimeImmutable($document->date_add), - $number, - $numericAmount, - $amount, - $amountMismatch, - $document instanceof OrderInvoice ? $document->note : null, - $isAddPaymentAllowed - ); - } - - $canGenerateInvoice = Configuration::get('PS_INVOICE') && - count($order->getInvoicesCollection()) && - $order->invoice_number; - - $canGenerateDeliverySlip = (bool) $order->delivery_number; - - return new OrderDocumentsForViewing( - $canGenerateInvoice, - $canGenerateDeliverySlip, - $documentsForViewing - ); - } - - /** - * @param Order $order - * - * @return OrderShippingForViewing - * - * @throws LocalizationException - */ - private function getOrderShipping(Order $order): OrderShippingForViewing - { - $taxCalculationMethod = $this->getOrderTaxCalculationMethod($order); - - $shipping = $order->getShipping(); - $carriers = []; - $carrierModuleInfo = null; - - $currency = new Currency($order->id_currency); - $carrier = new Carrier($order->id_carrier); - $carrierModuleInfo = null; - - if ($carrier->is_module) { - $module = Module::getInstanceByName($carrier->external_module_name); - if (method_exists($module, 'displayInfoByCart')) { - $carrierModuleInfo = $module->displayInfoByCart($order->id_cart); - } - } - - if (!$order->isVirtual()) { - foreach ($shipping as $item) { - if ($taxCalculationMethod == PS_TAX_INC) { - $price = Tools::displayPrice($item['shipping_cost_tax_incl'], $currency); - } else { - $price = Tools::displayPrice($item['shipping_cost_tax_excl'], $currency); - } - - $trackingUrl = null; - $trackingNumber = $item['tracking_number']; - - if ($item['url'] && $item['tracking_number']) { - $trackingUrl = str_replace('@', $item['tracking_number'], $item['url']); - } - - $weight = sprintf('%.3f %s', $item['weight'], Configuration::get('PS_WEIGHT_UNIT')); - - $carriers[] = new OrderCarrierForViewing( - (int) $item['id_order_carrier'], - new DateTimeImmutable($item['date_add']), - $item['carrier_name'], - $weight, - (int) $item['id_carrier'], - $price, - $trackingUrl, - $trackingNumber, - $item['can_edit'] - ); - } - } - - return new OrderShippingForViewing( - $carriers, - (bool) $order->recyclable, - (bool) $order->gift, - $order->gift_message, - $carrierModuleInfo - ); - } - - /** - * @param Order $order - * - * @return OrderReturnsForViewing - */ - private function getOrderReturns(Order $order): OrderReturnsForViewing - { - $returns = $order->getReturn(); - - if ($order->isVirtual()) { - return new OrderReturnsForViewing(); - } - - $orderReturns = []; - - foreach ($returns as $orderReturn) { - $trackingUrl = null; - $trackingNumber = null; - - if (isset($orderReturn['url'], $orderReturn['tracking_number'])) { - $trackingUrl = $orderReturn['url']; - $trackingNumber = $orderReturn['tracking_number']; - } elseif (isset($orderReturn['tracking_number'])) { - $trackingNumber = $orderReturn['tracking_number']; - } - - $orderReturns[] = new OrderReturnForViewing( - (int) $orderReturn['id_order_return'], - isset($orderReturn['id_order_invoice']) ? (int) $orderReturn['id_order_invoice'] : 0, - isset($orderReturn['id_carrier']) ? (int) $orderReturn['id_carrier'] : 0, - new DateTimeImmutable($orderReturn['date_add']), - $orderReturn['type'], - $orderReturn['state_name'], - $trackingUrl, - $trackingNumber - ); - } - - return new OrderReturnsForViewing($orderReturns); - } - - /** - * @param Order $order - * - * @return OrderPaymentsForViewing - * - * @throws LocalizationException - */ - private function getOrderPayments(Order $order): OrderPaymentsForViewing - { - $currency = new Currency($order->id_currency); - $payments = $order->getOrderPayments(); - - $currentState = $order->getCurrentOrderState(); - - $orderAmountToPay = null; - $orderAmountPaid = null; - $paymentMismatchOrders = []; - - if (count($payments) > 0) { - $noPaymentMismatch = round($order->getOrdersTotalPaid(), 2) == round($order->getTotalPaid(), 2) - || ($currentState && $currentState->id == 6); - - if (!$noPaymentMismatch) { - $orderAmountToPay = $this->locale->formatPrice($order->getOrdersTotalPaid(), $currency->iso_code); - $orderAmountPaid = $this->locale->formatPrice($order->getTotalPaid(), $currency->iso_code); - - foreach ($order->getBrother() as $relatedOrder) { - $paymentMismatchOrders[] = $relatedOrder->id; - } - } - } - - $orderPayments = []; - - /** @var OrderPayment $payment */ - foreach ($order->getOrderPaymentCollection() as $payment) { - $currency = new Currency($payment->id_currency); - $invoice = $payment->getOrderInvoice($order->id); - $invoiceNumber = $invoice ? - $invoice->getInvoiceNumberFormatted($this->contextLanguageId, $order->id_shop) : - null; - - $orderPayments[] = new OrderPaymentForViewing( - $payment->id, - new DateTimeImmutable($payment->date_add), - $payment->payment_method, - $payment->transaction_id, - $this->locale->formatPrice($payment->amount, $currency->iso_code), - $invoiceNumber, - $payment->card_number, - $payment->card_brand, - $payment->card_expiration, - $payment->card_holder - ); - } - - return new OrderPaymentsForViewing( - $orderPayments, - $orderAmountToPay, - $orderAmountPaid, - $paymentMismatchOrders - ); - } - - /** - * @param Order $order - * - * @return OrderMessagesForViewing - */ - private function getOrderMessages(Order $order): OrderMessagesForViewing - { - $orderMessagesForOrderPage = $this->customerDataProvider->getCustomerMessages( - (int) $order->id_customer, - (int) $order->id - ); - - $messages = []; - - foreach ($orderMessagesForOrderPage['messages'] as $orderMessage) { - $messageEmployeeId = (int) $orderMessage['id_employee']; - $isCurrentEmployeesMessage = (int) $this->context->employee->id === $messageEmployeeId; - - $messages[] = new OrderMessageForViewing( - (int) $orderMessage['id_customer_message'], - $orderMessage['message'], - new OrderMessageDateForViewing( - new DateTimeImmutable($orderMessage['date_add']), - $this->context->language->date_format_full - ), - $messageEmployeeId, - $isCurrentEmployeesMessage, - $orderMessage['efirstname'], - $orderMessage['elastname'], - $orderMessage['cfirstname'], - $orderMessage['clastname'], - (bool) $orderMessage['private'] - ); - } - - return new OrderMessagesForViewing($messages, $orderMessagesForOrderPage['total']); - } - - /** - * @param Order $order - * - * @return OrderPricesForViewing - * - * @throws LocalizationException - */ - private function getOrderPrices(Order $order): OrderPricesForViewing - { - $currency = new Currency($order->id_currency); - $customer = $order->getCustomer(); - - $isTaxExcluded = !$this->isTaxIncludedInOrder($order); - - $shipping_refundable_tax_excl = $order->total_shipping_tax_excl; - $shipping_refundable_tax_incl = $order->total_shipping_tax_incl; - - $slips = OrderSlip::getOrdersSlip($customer->id, $order->id); - foreach ($slips as $slip) { - $shipping_refundable_tax_excl -= $slip['total_shipping_tax_excl']; - $shipping_refundable_tax_incl -= $slip['total_shipping_tax_incl']; - } - - if ($isTaxExcluded) { - $productsPrice = (float) $order->total_products; - $discountsAmount = (float) $order->total_discounts_tax_excl; - $wrappingPrice = (float) $order->total_wrapping_tax_excl; - $shippingPrice = (float) $order->total_shipping_tax_excl; - $shippingRefundable = max(0, $shipping_refundable_tax_excl); - $totalAmount = (float) $order->total_paid_tax_excl; - } else { - $productsPrice = (float) $order->total_products_wt; - $discountsAmount = (float) $order->total_discounts_tax_incl; - $wrappingPrice = (float) $order->total_wrapping_tax_incl; - $shippingPrice = (float) $order->total_shipping_tax_incl; - $shippingRefundable = max(0, $shipping_refundable_tax_incl); - $totalAmount = (float) $order->total_paid_tax_incl; - } - - $taxesAmount = $order->total_paid_tax_incl - $order->total_paid_tax_excl; - - return new OrderPricesForViewing( - new Number((string) $productsPrice), - new Number((string) $discountsAmount), - new Number((string) $wrappingPrice), - new Number((string) $shippingPrice), - new Number((string) $shippingRefundable), - new Number((string) $taxesAmount), - new Number((string) $totalAmount), - Tools::displayPrice($productsPrice, $currency), - Tools::displayPrice($discountsAmount, $currency), - Tools::displayPrice($wrappingPrice, $currency), - Tools::displayPrice($shippingPrice, $currency), - Tools::displayPrice($shippingRefundable, $currency), - Tools::displayPrice($taxesAmount, $currency), - Tools::displayPrice($totalAmount, $currency) - ); - } - - /** - * @param Order $order - * - * @return OrderDiscountsForViewing - * - * @throws LocalizationException - */ - private function getOrderDiscounts(Order $order): OrderDiscountsForViewing - { - $isTaxIncluded = $this->isTaxIncludedInOrder($order); - $currency = new Currency($order->id_currency); - $discounts = $order->getCartRules(); - $discountsForViewing = []; - - foreach ($discounts as $discount) { - $discountAmount = $isTaxIncluded ? $discount['value'] : $discount['value_tax_excl']; - $discountsForViewing[] = new OrderDiscountForViewing( - (int) $discount['id_order_cart_rule'], - $discount['name'], - new Number((string) $discountAmount), - Tools::displayPrice($discountAmount, $currency) - ); - } - - return new OrderDiscountsForViewing($discountsForViewing); - } - - /** - * @param Order $order - * - * @return OrderSourcesForViewing - */ - private function getOrderSources(Order $order): OrderSourcesForViewing - { - $sourcesData = ConnectionsSource::getOrderSources($order->id); - $sources = []; - - if ( $sourcesData ) - foreach ($sourcesData as $sourceItem) { - $sources[] = new OrderSourceForViewing( - $sourceItem['http_referer'], - $sourceItem['request_uri'], - new DateTimeImmutable($sourceItem['date_add']), - $sourceItem['keywords'] - ); - } - - return new OrderSourcesForViewing($sources); - } - - /** - * @return LinkedOrdersForViewing - */ - private function getLinkedOrders(Order $order): LinkedOrdersForViewing - { - $brothersData = $order->getBrother(); - $brothers = []; - /** @var Order $brotherItem */ - foreach ($brothersData as $brotherItem) { - $isTaxExcluded = !$this->isTaxIncludedInOrder($brotherItem); - - $currency = new Currency($brotherItem->id_currency); - - if ($isTaxExcluded) { - $totalAmount = $this->locale->formatPrice($brotherItem->total_paid_tax_excl, $currency->iso_code); - } else { - $totalAmount = $this->locale->formatPrice($brotherItem->total_paid_tax_incl, $currency->iso_code); - } - - $orderState = new OrderState($brotherItem->current_state); - - $brothers[] = new LinkedOrderForViewing( - $brotherItem->id, - $orderState->name[$this->context->language->getId()], - $totalAmount - ); - } - - return new LinkedOrdersForViewing($brothers); - } - - /** - * @param OrderId $orderId - * @param string $productsOrder - * - * @return OrderProductsForViewing - * - * @throws OrderException - * @throws InvalidSortingException - */ - private function getOrderProducts(OrderId $orderId, string $productsOrder): OrderProductsForViewing - { - return $this->getOrderProductsForViewingHandler->handle( - GetOrderProductsForViewing::all($orderId->getValue(), $productsOrder) - ); - } -} diff --git a/src/Adapter/Order/QueryHandler/GetOrderPreviewHandler.php b/src/Adapter/Order/QueryHandler/GetOrderPreviewHandler.php deleted file mode 100644 index 5569e3bb..00000000 --- a/src/Adapter/Order/QueryHandler/GetOrderPreviewHandler.php +++ /dev/null @@ -1,234 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\QueryHandler; - -use Carrier; -use Country; -use Currency; -use Customer; -use Group; -use Order; -use OrderCarrier; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Adapter\Entity\Address; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Order\Query\GetOrderPreview; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryHandler\GetOrderPreviewHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderPreview; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderPreviewInvoiceDetails; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderPreviewProductDetail; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderPreviewShippingDetails; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; -use PrestaShop\PrestaShop\Core\Localization\Locale\Repository as LocaleRepository; -use State; -use StockAvailable; -use Validate; - -/** - * Handles GetOrderPreview query using legacy object model - */ -final class GetOrderPreviewHandler implements GetOrderPreviewHandlerInterface -{ - /** - * @var LocaleRepository - */ - private $localeRepository; - - /** - * @var string - */ - private $locale; - - /** - * @param LocaleRepository $localeRepository - * @param string $locale - */ - public function __construct( - LocaleRepository $localeRepository, - string $locale - ) { - $this->localeRepository = $localeRepository; - $this->locale = $locale; - } - - /** - * {@inheritdoc} - */ - public function handle(GetOrderPreview $query): OrderPreview - { - $order = $this->getOrder($query->getOrderId()); - $priceDisplayMethod = $this->getOrderTaxCalculationMethod($order); - - return new OrderPreview( - $this->getInvoiceDetails($order), - $this->getShippingDetails($order), - $this->getProductDetails($order), - $order->isVirtual(), - $priceDisplayMethod == PS_TAX_INC - ); - } - - /** - * @param OrderId $orderId - * - * @return Order - * - * @throws OrderNotFoundException - */ - private function getOrder(OrderId $orderId): Order - { - $order = new Order($orderId->getValue()); - if ($order->id !== $orderId->getValue()) { - throw new OrderNotFoundException($orderId, sprintf('Order with id "%s" was not found.', $orderId->getValue())); - } - - return $order; - } - - /** - * @param Order $order - * - * @return OrderPreviewInvoiceDetails - */ - private function getInvoiceDetails(Order $order): OrderPreviewInvoiceDetails - { - $customer = new Customer($order->id_customer); - $address = new Address($order->id_address_invoice); - $country = new Country($address->id_country); - $state = new State($address->id_state); - $stateName = Validate::isLoadedObject($state) ? $state->name : null; - - return new OrderPreviewInvoiceDetails( - $address->firstname, - $address->lastname, - $address->company, - $address->vat_number, - $address->address1, - $address->address2, - $address->city, - $address->postcode, - $stateName, - $country->name[$order->id_lang], - $customer ? $customer->email : null, - $address->phone - ); - } - - /** - * {@inheritdoc} - */ - private function getShippingDetails(Order $order): OrderPreviewShippingDetails - { - $address = new Address($order->id_address_delivery); - $country = new Country($address->id_country); - $carrier = new Carrier($order->id_carrier); - $state = new State($address->id_state); - - $carrierName = null; - $stateName = Validate::isLoadedObject($state) ? $state->name : null; - - if (Validate::isLoadedObject($carrier)) { - $carrierName = $carrier->name; - } - - $orderCarrierId = $order->getIdOrderCarrier(); - $orderCarrier = new OrderCarrier($orderCarrierId); - - return new OrderPreviewShippingDetails( - $address->firstname, - $address->lastname, - $address->company, - $address->vat_number, - $address->address1, - $address->address2, - $address->city, - $address->postcode, - $stateName, - $country->name[$order->id_lang], - $address->phone, - $carrierName, - $orderCarrier->tracking_number ?: null - ); - } - - /** - * @param Order $order - * - * @return OrderPreviewProductDetail[] - */ - private function getProductDetails(Order $order): array - { - $productDetails = []; - $currency = new Currency($order->id_currency); - $locale = $this->localeRepository->getLocale($this->locale); - - $taxCalculationMethod = $this->getOrderTaxCalculationMethod($order); - - foreach ($order->getProductsDetail() as $detail) { - $unitPrice = $detail['unit_price_tax_excl']; - $totalPrice = $detail['total_price_tax_excl']; - - $totalPriceTaxIncl = new Number($detail['total_price_tax_incl']); - $totalPriceTaxExcl = new Number($detail['total_price_tax_excl']); - - $totalTaxAmount = $totalPriceTaxIncl->minus($totalPriceTaxExcl); - - if (PS_TAX_INC === $taxCalculationMethod) { - $unitPrice = $detail['unit_price_tax_incl']; - $totalPrice = $detail['total_price_tax_incl']; - } - - $productDetails[] = new OrderPreviewProductDetail( - $detail['product_name'], - $detail['product_reference'], - StockAvailable::getLocation( - $detail['product_id'], - $detail['product_attribute_id'], - $detail['id_shop'] - ), - (int) $detail['product_quantity'], - $locale->formatPrice($unitPrice, $currency->iso_code), - $locale->formatPrice($totalPrice, $currency->iso_code), - $locale->formatPrice((string) $totalTaxAmount, $currency->iso_code) - ); - } - - return $productDetails; - } - - /** - * @param Order $order - * - * @return int - */ - private function getOrderTaxCalculationMethod(Order $order): int - { - $customer = new Customer($order->id_customer); - - return Group::getPriceDisplayMethod((int) $customer->id_default_group); - } -} diff --git a/src/Adapter/Order/QueryHandler/GetOrderProductsForViewingHandler.php b/src/Adapter/Order/QueryHandler/GetOrderProductsForViewingHandler.php deleted file mode 100644 index 1a7d4a1c..00000000 --- a/src/Adapter/Order/QueryHandler/GetOrderProductsForViewingHandler.php +++ /dev/null @@ -1,317 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\QueryHandler; - -use Currency; -use Db; -use Image; -use ImageManager; -use Order; -use OrderInvoice; -use OrderReturn; -use OrderSlip; -use Pack; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Adapter\Order\AbstractOrderHandler; -use PrestaShop\PrestaShop\Core\Domain\Order\Query\GetOrderProductsForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryHandler\GetOrderProductsForViewingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderProductCustomizationForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderProductCustomizationsForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderProductForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderProductsForViewing; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\QuerySorting; -use PrestaShop\PrestaShop\Core\Image\Parser\ImageTagSourceParserInterface; -use PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision; -use PrestaShop\PrestaShop\Core\Localization\Locale; -use Product; -use Shop; -use StockAvailable; -use Warehouse; -use WarehouseProductLocation; - -/** - * Handles GetOrderProductsForViewing query using legacy object models - */ -final class GetOrderProductsForViewingHandler extends AbstractOrderHandler implements GetOrderProductsForViewingHandlerInterface -{ - /** - * @var ImageTagSourceParserInterface - */ - private $imageTagSourceParser; - - /** - * @var int - */ - private $contextLanguageId; - - /** - * @var Locale - */ - private $locale; - - public function __construct( - ImageTagSourceParserInterface $imageTagSourceParser, - int $contextLanguageId, - Locale $locale - ) { - $this->imageTagSourceParser = $imageTagSourceParser; - $this->contextLanguageId = $contextLanguageId; - $this->locale = $locale; - } - - public function handle(GetOrderProductsForViewing $query): OrderProductsForViewing - { - $order = $this->getOrder($query->getOrderId()); - $taxCalculationMethod = $this->getOrderTaxCalculationMethod($order); - - $products = $order->getProducts(); - $currency = new Currency((int) $order->id_currency); - $computingPrecision = new ComputingPrecision(); - $precision = $computingPrecision->getPrecision($currency->precision); - - foreach ($products as &$product) { - if ($product['image'] instanceof Image) { - $name = 'product_mini_' . (int) $product['product_id'] . (isset($product['product_attribute_id']) ? '_' . (int) $product['product_attribute_id'] : '') . '.jpg'; - // generate image cache, only for back office - $product['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $product['image']->getExistingImgPath() . '.jpg', $name, 45, 'jpg'); - if (file_exists(_PS_TMP_IMG_DIR_ . $name)) { - $product['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name); - } else { - $product['image_size'] = false; - } - } - - // Get total customized quantity for current product - $customized_product_quantity = 0; - - $customizations = []; - if (is_array($product['customizedDatas'])) { - foreach ($product['customizedDatas'] as $customizationPerAddress) { - foreach ($customizationPerAddress as $customizationId => $customization) { - $customized_product_quantity += (int) $customization['quantity']; - foreach ($customization['datas'] as $datas) { - foreach ($datas as $data) { - $customizations[] = new OrderProductCustomizationForViewing((int) $data['type'], $data['name'], $data['value']); - } - } - } - } - } - - $product['customizations'] = !empty($customizations) ? new OrderProductCustomizationsForViewing($customizations) : null; - $product['customized_product_quantity'] = $customized_product_quantity; - $product['current_stock'] = StockAvailable::getQuantityAvailableByProduct($product['product_id'], $product['product_attribute_id'], $product['id_shop']); - $product['quantity_refundable'] = $product['product_quantity'] - $product['product_quantity_return'] - $product['product_quantity_refunded']; - $product['amount_refundable'] = $product['total_price_tax_excl'] - $product['total_refunded_tax_excl']; - $product['amount_refundable_tax_incl'] = $product['total_price_tax_incl'] - $product['total_refunded_tax_incl']; - $product['displayed_max_refundable'] = $taxCalculationMethod === PS_TAX_EXC ? $product['amount_refundable'] : $product['amount_refundable_tax_incl']; - $resumeAmountKey = $taxCalculationMethod === PS_TAX_EXC ? 'total_refunded_tax_excl' : 'total_refunded_tax_incl'; - $product['amount_refunded'] = $product[$resumeAmountKey] ?? 0; - $product['refund_history'] = OrderSlip::getProductSlipDetail($product['id_order_detail']); - $product['return_history'] = OrderReturn::getProductReturnDetail($product['id_order_detail']); - - if ($product['id_warehouse'] != 0) { - $warehouse = new Warehouse((int) $product['id_warehouse']); - $product['warehouse_name'] = $warehouse->name; - $warehouse_location = WarehouseProductLocation::getProductLocation($product['product_id'], $product['product_attribute_id'], $product['id_warehouse']); - if (!empty($warehouse_location)) { - $product['warehouse_location'] = $warehouse_location; - } else { - $product['warehouse_location'] = false; - } - } else { - $product['warehouse_name'] = '--'; - $product['warehouse_location'] = false; - } - - $pack_items = $product['cache_is_pack'] ? Pack::getItemTable($product['id_product'], $this->contextLanguageId, true) : []; - foreach ($pack_items as &$pack_item) { - $pack_item['current_stock'] = StockAvailable::getQuantityAvailableByProduct($pack_item['id_product'], $pack_item['id_product_attribute'], $pack_item['id_shop']); - $this->setProductImageInformation($pack_item); - if ($pack_item['image'] instanceof Image) { - $name = 'product_mini_' . (int) $pack_item['id_product'] . (isset($pack_item['id_product_attribute']) ? '_' . (int) $pack_item['id_product_attribute'] : '') . '.jpg'; - // generate image cache, only for back office - $pack_item['image_tag'] = ImageManager::thumbnail(_PS_IMG_DIR_ . 'p/' . $pack_item['image']->getExistingImgPath() . '.jpg', $name, 45, 'jpg'); - if (file_exists(_PS_TMP_IMG_DIR_ . $name)) { - $pack_item['image_size'] = getimagesize(_PS_TMP_IMG_DIR_ . $name); - } else { - $pack_item['image_size'] = false; - } - } - } - - unset($pack_item); - - $product['pack_items'] = $pack_items; - } - - unset($product); - - if (QuerySorting::DESC === $query->getProductsSorting()->getValue()) { - // reorder products by order_detail_id DESC - krsort($products); - } else { - // reorder products by order_detail_id ASC - ksort($products); - } - - $productsForViewing = []; - - $isOrderTaxExcluded = ($taxCalculationMethod == PS_TAX_EXC); - foreach ($products as $product) { - $unitPrice = $isOrderTaxExcluded ? - $product['unit_price_tax_excl'] : - $product['unit_price_tax_incl'] - ; - - // if rounding type is set to "per item" we must round the unit price now, otherwise values won't match - // the totals in the order summary - if ((int) $order->round_type === Order::ROUND_ITEM) { - $unitPrice = (new Number((string) $unitPrice))->round($precision, $this->getNumberRoundMode()); - } - - $totalPrice = $unitPrice * - (!empty($product['customizedDatas']) ? $product['customizationQuantityTotal'] : $product['product_quantity']); - - $unitPriceFormatted = $this->locale->formatPrice($unitPrice, $currency->iso_code); - $totalPriceFormatted = $this->locale->formatPrice($totalPrice, $currency->iso_code); - - $imagePath = isset($product['image_tag']) ? - $this->imageTagSourceParser->parse($product['image_tag']) : - null; - $product['product_quantity_refunded'] = $product['product_quantity_refunded'] ?: false; - - $productType = !empty($product['pack_items']) ? OrderProductForViewing::TYPE_PACK : - OrderProductForViewing::TYPE_PRODUCT_WITHOUT_COMBINATIONS; - - $orderInvoice = new OrderInvoice($product['id_order_invoice']); - - $packItems = []; - foreach ($product['pack_items'] as $pack_item) { - $packItemType = !empty($pack_item['pack_items']) ? OrderProductForViewing::TYPE_PACK : - OrderProductForViewing::TYPE_PRODUCT_WITHOUT_COMBINATIONS; - $packItemImagePath = isset($pack_item['image_tag']) ? - $this->imageTagSourceParser->parse($pack_item['image_tag']) : - null; - $packItems[] = new OrderProductForViewing( - null, - $pack_item['id_product'], - 0, - $pack_item['name'], - $pack_item['reference'], - $pack_item['supplier_reference'], - $pack_item['pack_quantity'], - 0, - 0, - $pack_item['current_stock'], - $packItemImagePath, - '0', - '0', - '0', - $this->locale->formatPrice(0, $currency->iso_code), - 0, - $this->locale->formatPrice(0, $currency->iso_code), - '0', - $pack_item['location'], - null, - '', - $packItemType, - (bool) Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock($pack_item['id_product'])) - ); - } - - $productsForViewing[] = new OrderProductForViewing( - $product['id_order_detail'], - $product['product_id'], - $product['product_attribute_id'], - $product['product_name'], - $product['product_reference'], - $product['product_supplier_reference'], - $product['product_quantity'], - $unitPriceFormatted, - $totalPriceFormatted, - $product['current_stock'], - $imagePath, - (new Number((string) $product['unit_price_tax_excl']))->round($precision, $this->getNumberRoundMode()), - (new Number((string) $product['unit_price_tax_incl']))->round($precision, $this->getNumberRoundMode()), - (string) $product['tax_rate'], - $this->locale->formatPrice($product['amount_refunded'], $currency->iso_code), - $product['product_quantity_refunded'] + $product['product_quantity_return'], - $this->locale->formatPrice($product['displayed_max_refundable'], $currency->iso_code), - (string) $product['displayed_max_refundable'], - $product['location'], - !empty($product['id_order_invoice']) ? $product['id_order_invoice'] : null, - !empty($product['id_order_invoice']) ? $orderInvoice->getInvoiceNumberFormatted($order->id_lang) : '', - $productType, - (bool) Product::isAvailableWhenOutOfStock(StockAvailable::outOfStock($product['product_id'])), - $packItems, - $product['customizations'] - ); - } - - $offset = $query->getOffset(); - $limit = $query->getLimit(); - - //@todo: its not really paginated, as all products are retrieved from legacy Order::getProducts(). But could be improved in future. - if (null !== $offset && $limit) { - $productsForViewing = array_slice($products, (int) $offset, (int) $limit); - } - - return new OrderProductsForViewing($productsForViewing); - } - - /** - * @param $pack_item - */ - private function setProductImageInformation(&$pack_item): void - { - if (isset($pack_item['id_product_attribute']) && $pack_item['id_product_attribute']) { - $id_image = Db::getInstance()->getValue(' - SELECT `image_shop`.id_image - FROM `' . _DB_PREFIX_ . 'product_attribute_image` pai' . - Shop::addSqlAssociation('image', 'pai', true) . ' - WHERE id_product_attribute = ' . (int) $pack_item['id_product_attribute']); - } - - if (!isset($id_image) || !$id_image) { - $id_image = Db::getInstance()->getValue( - ' - SELECT `image_shop`.id_image - FROM `' . _DB_PREFIX_ . 'image` i' . - Shop::addSqlAssociation('image', 'i', true, 'image_shop.cover=1') . ' - WHERE i.id_product = ' . (int) $pack_item['id_product'] - ); - } - - $pack_item['image'] = null; - $pack_item['image_size'] = null; - - if ($id_image) { - $pack_item['image'] = new Image($id_image); - } - } -} diff --git a/src/Adapter/Order/Refund/OrderProductRemover.php b/src/Adapter/Order/Refund/OrderProductRemover.php deleted file mode 100644 index 25d7f218..00000000 --- a/src/Adapter/Order/Refund/OrderProductRemover.php +++ /dev/null @@ -1,243 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Order\Refund; - -use Cart; -use CartRule; -use Db; -use Order; -use OrderCartRule; -use OrderDetail; -use PrestaShop\PrestaShop\Adapter\Cart\Comparator\CartProductsComparator; -use PrestaShop\PrestaShop\Adapter\Cart\Comparator\CartProductUpdate; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\DeleteCustomizedProductFromOrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\DeleteProductFromOrderException; -use Psr\Log\LoggerInterface; -use SpecificPrice; -use Symfony\Component\Translation\TranslatorInterface; - -class OrderProductRemover -{ - /** - * @var LoggerInterface - */ - private $logger; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * OrderProductRemover constructor. - * - * @param LoggerInterface $logger - */ - public function __construct(LoggerInterface $logger, TranslatorInterface $translator) - { - $this->logger = $logger; - $this->translator = $translator; - } - - /** - * @param Order $order - * @param OrderDetail $orderDetail - * @param bool $updateCart Used when you don't want to update the cart (CartRule removal for example) - * - * @return array - */ - public function deleteProductFromOrder(Order $order, OrderDetail $orderDetail, bool $updateCart = true): array - { - $cart = new Cart($order->id_cart); - - // Important to remove order cart rule before the product is removed, so that cart rule can detect if it's applied on it - $this->deleteOrderCartRule($order, $orderDetail, $cart); - - if ((int) $orderDetail->id_customization > 0) { - $this->deleteCustomization($order, $orderDetail); - } - - $updatedProducts = []; - if ($updateCart) { - $updatedProducts = $this->updateCart($cart, $orderDetail); - } - - $this->deleteSpecificPrice($order, $orderDetail, $cart); - - $this->deleteOrderDetail( - $order, - $orderDetail - ); - - return $updatedProducts; - } - - /** - * @param Cart $cart - * @param OrderDetail $orderDetail - * - * @return CartProductUpdate[] - */ - private function updateCart(Cart $cart, OrderDetail $orderDetail): array - { - $cartComparator = new CartProductsComparator($cart); - $knownUpdates = [ - new CartProductUpdate( - (int) $orderDetail->product_id, - (int) $orderDetail->product_attribute_id, - -$orderDetail->product_quantity, - false - ), - ]; - - $cart->updateQty( - $orderDetail->product_quantity, - $orderDetail->product_id, - $orderDetail->product_attribute_id, - false, - 'down', - 0, - null, - true, - false, - false // Do not preserve gift removal - ); - - return $cartComparator->getUpdatedProducts($knownUpdates); - } - - /** - * @param Order $order - * @param OrderDetail $orderDetail - * - * @throws DeleteProductFromOrderException - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - private function deleteOrderDetail( - Order $order, - OrderDetail $orderDetail - ) { - if (!$orderDetail->delete()) { - throw new DeleteProductFromOrderException('Could not delete order detail'); - } - - $order->update(); - } - - /** - * @param Order $order - * @param OrderDetail $orderDetail - */ - private function deleteCustomization(Order $order, OrderDetail $orderDetail) - { - if (!(int) $order->getCurrentState()) { - throw new DeleteCustomizedProductFromOrderException('Could not get a valid Order state before deletion'); - } - if (!Db::getInstance()->execute('DELETE FROM `' . _DB_PREFIX_ . 'customization` WHERE `id_customization` = ' . (int) $orderDetail->id_customization . ' AND `id_cart` = ' . (int) $order->id_cart . ' AND `id_product` = ' . (int) $orderDetail->product_id)) { - throw new DeleteCustomizedProductFromOrderException('Could not delete customization from database.'); - } - } - - /** - * The deleted OrderCartRule are ignored by CartRule:autoAdd and CartRule:autoRemove so it is not able to clean - * them when the product is removed, hence the discount could never be re applied. So we manually check and remove - * them. - * - * @param Order $order - * @param OrderDetail $orderDetail - * @param Cart $cart - */ - private function deleteOrderCartRule( - Order $order, - OrderDetail $orderDetail, - Cart $cart - ): void { - $orderCartRules = $order->getDeletedCartRules(); - if (empty($orderCartRules)) { - return; - } - - $removedOrderCartRules = []; - foreach ($orderCartRules as $orderCartRule) { - $cartRule = new CartRule($orderCartRule['id_cart_rule']); - $discountedProducts = $cartRule->checkProductRestrictionsFromCart($cart, true, true, true); - foreach ($discountedProducts as $discountedProduct) { - // The return value is the concatenation of productId and attributeId, but the attributeId is always replaced by 0 - if ($discountedProduct === $orderDetail->product_id . '-0') { - if (!in_array($orderCartRule['id_order_cart_rule'], $removedOrderCartRules)) { - $removedOrderCartRules[] = $orderCartRule['id_order_cart_rule']; - } - } - } - } - - foreach ($removedOrderCartRules as $removedOrderCartRuleId) { - $orderCartRule = new OrderCartRule($removedOrderCartRuleId); - $orderCartRule->delete(); - } - } - - /** - * @param Order $order - * @param OrderDetail $orderDetail - * @param Cart $cart - */ - private function deleteSpecificPrice( - Order $order, - OrderDetail $orderDetail, - Cart $cart - ): void { - $productQuantity = $cart->getProductQuantity($orderDetail->product_id, $orderDetail->product_attribute_id); - if (!isset($productQuantity['quantity']) || (int) $productQuantity['quantity'] > 0) { - return; - } - - // WARNING: DO NOT use SpecificPrice::getSpecificPrice as it filters out fields that are not in database - // hence it ignores the customer or cart restriction and results are biased - $existingSpecificPriceId = SpecificPrice::exists( - (int) $orderDetail->product_id, - (int) $orderDetail->product_attribute_id, - 0, - 0, - 0, - $order->id_currency, - $order->id_customer, - SpecificPrice::ORDER_DEFAULT_FROM_QUANTITY, - SpecificPrice::ORDER_DEFAULT_DATE, - SpecificPrice::ORDER_DEFAULT_DATE, - false, - $order->id_cart - ); - if (!empty($existingSpecificPriceId)) { - $specificPrice = new SpecificPrice($existingSpecificPriceId); - $specificPrice->delete(); - } - } -} diff --git a/src/Adapter/Order/Refund/OrderRefundCalculator.php b/src/Adapter/Order/Refund/OrderRefundCalculator.php deleted file mode 100644 index cd518e5b..00000000 --- a/src/Adapter/Order/Refund/OrderRefundCalculator.php +++ /dev/null @@ -1,277 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\Refund; - -use Address; -use Carrier; -use Currency; -use Customer; -use Customization; -use Group; -use Order; -use OrderDetail; -use OrderSlip; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidCancelProductException; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderDetailRefund; -use PrestaShop\PrestaShop\Core\Domain\Order\VoucherRefundType; -use PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision; -use PrestaShopDatabaseException; -use PrestaShopException; -use TaxCalculator; -use Tools; - -/** - * Performs all computation for a refund on an Order, returns a OrderRefundDetail - * object which contains all the refund detail. - */ -class OrderRefundCalculator -{ - /** - * @param Order $order - * @param array $orderDetailRefunds - * @param Number $shippingRefund - * @param int $voucherRefundType - * @param Number|null $chosenVoucherAmount - * - * @return OrderRefundSummary - * - * @throws InvalidCancelProductException - * @throws PrestaShopDatabaseException - * @throws PrestaShopException - */ - public function computeOrderRefund( - Order $order, - array $orderDetailRefunds, - Number $shippingRefund, - int $voucherRefundType, - ?Number $chosenVoucherAmount - ): OrderRefundSummary { - $isTaxIncluded = $this->isTaxIncludedInOrder($order); - $precision = $this->getPrecision($order); - - $orderDetailList = $this->getOrderDetailList($orderDetailRefunds); - $productRefunds = $this->flattenCheckedProductRefunds( - $orderDetailRefunds, - $isTaxIncluded, - $orderDetailList, - $precision - ); - - $numberZero = new Number('0'); - - $refundedAmount = $numberZero; - foreach ($productRefunds as $orderDetailId => $productRefund) { - $refundedAmount = $refundedAmount->plus(new Number((string) $productRefund['amount'])); - } - - $voucherChosen = false; - $voucherAmount = $numberZero; - if ($voucherRefundType === VoucherRefundType::PRODUCT_PRICES_EXCLUDING_VOUCHER_REFUND) { - $voucherAmount = new Number((string) $order->total_discounts); - $refundedAmount = $refundedAmount->minus($voucherAmount); - } elseif ($voucherRefundType === VoucherRefundType::SPECIFIC_AMOUNT_REFUND) { - $voucherChosen = true; - $refundedAmount = $voucherAmount = $chosenVoucherAmount; - } - - $shippingCostAmount = $shippingRefund ?? $numberZero; - if ($shippingCostAmount->isPositive()) { - $shippingMaxRefund = new Number( - $isTaxIncluded ? - (string) $order->total_shipping_tax_incl : - (string) $order->total_shipping_tax_excl - ); - - $shippingSlipResume = OrderSlip::getShippingSlipResume($order->id); - $shippingSlipTotalTaxIncl = new Number((string) ($shippingSlipResume['total_shipping_tax_incl'] ?? 0)); - $shippingMaxRefund = $shippingMaxRefund->minus($shippingSlipTotalTaxIncl); - - if ($shippingCostAmount->isGreaterThan($shippingMaxRefund)) { - $shippingCostAmount = $shippingMaxRefund; - } - // Previously taxes were computed but then some values are mixed with and without taxes - // They all should be in the same state since OrderRefundSummary contains $isTaxIncluded - $refundedAmount = $refundedAmount->plus($shippingCostAmount); - } - - // Something has to be refunded (check refunds count instead of the sum in case a voucher is implied) - if (count($productRefunds) <= 0 && $refundedAmount->isLowerOrEqualThanZero()) { - throw new InvalidCancelProductException(InvalidCancelProductException::NO_REFUNDS); - } - - return new OrderRefundSummary( - $orderDetailList, - $productRefunds, - (float) (string) $refundedAmount, - (float) (string) $shippingCostAmount, - (float) (string) $voucherAmount, - $voucherChosen, - $isTaxIncluded, - $precision - ); - } - - /** - * @param array $orderDetailRefunds - * - * @return OrderDetail[] - * - * @throws PrestaShopDatabaseException - * @throws PrestaShopException - */ - private function getOrderDetailList(array $orderDetailRefunds) - { - $orderDetailList = []; - /** @var OrderDetailRefund $orderDetailRefund */ - foreach ($orderDetailRefunds as $orderDetailRefund) { - $orderDetailList[$orderDetailRefund->getOrderDetailId()] = new OrderDetail($orderDetailRefund->getOrderDetailId()); - } - - return $orderDetailList; - } - - /** - * @param array $orderDetailRefunds - * @param bool $isTaxIncluded - * @param array $orderDetails - * @param TaxCalculator $taxCalculator - * @param int $precision - * - * @return array - * - * @throws InvalidCancelProductException - */ - private function flattenCheckedProductRefunds( - array $orderDetailRefunds, - bool $isTaxIncluded, - array $orderDetails, - int $precision - ) { - $productRefunds = []; - /** @var OrderDetailRefund $orderDetailRefund */ - foreach ($orderDetailRefunds as $orderDetailRefund) { - $orderDetailId = $orderDetailRefund->getOrderDetailId(); - /** @var OrderDetail $orderDetail */ - $orderDetail = $orderDetails[$orderDetailId]; - $quantity = $orderDetailRefund->getProductQuantity(); - if ($orderDetail->id_customization) { - $customization = new Customization($orderDetail->id_customization); - $quantityLeft = (int) $customization->quantity - (int) $customization->quantity_refunded - $customization->quantity_returned; - } else { - $quantityLeft = (int) $orderDetail->product_quantity - (int) $orderDetail->product_quantity_refunded - (int) $orderDetail->product_quantity_return; - } - if ($quantity > $quantityLeft) { - throw new InvalidCancelProductException(InvalidCancelProductException::QUANTITY_TOO_HIGH, $quantityLeft); - } - - $productRefunds[$orderDetailId] = [ - 'quantity' => $quantity, - 'id_order_detail' => $orderDetailId, - ]; - - // Compute max refund by product (based on quantity left and already refunded amount) - $productUnitPrice = $isTaxIncluded ? (float) $orderDetail->unit_price_tax_incl : (float) $orderDetail->unit_price_tax_excl; - $productMaxRefund = (int) $quantity * $productUnitPrice; - - // If refunded amount is null it means the whole product is refunded (used for standard refund, and return product) - if (null === $orderDetailRefund->getRefundedAmount()) { - $productRefundAmount = (float) (string) $productMaxRefund; - } else { - $productRefundAmount = (float) (string) $orderDetailRefund->getRefundedAmount() <= $productMaxRefund ? - (float) (string) $orderDetailRefund->getRefundedAmount() : $productMaxRefund; - } - - $productRefunds[$orderDetailId]['amount'] = $productRefundAmount; - $productRefunds[$orderDetailId]['unit_price'] = - $productRefunds[$orderDetailId]['amount'] / $productRefunds[$orderDetailId]['quantity']; - - // We get the tax calculator from the OrderDetail which will make it use the tax rate at the moment the order was placed - $taxCalculator = $orderDetail->getTaxCalculator(); - - // Add data for OrderDetail updates, it's important to round because too many decimals will fail in Validate::isPrice - if ($isTaxIncluded) { - $productRefunds[$orderDetailId]['total_refunded_tax_incl'] = Tools::ps_round($productRefundAmount, $precision); - $productRefunds[$orderDetailId]['total_refunded_tax_excl'] = Tools::ps_round($taxCalculator->removeTaxes($productRefundAmount), $precision); - } else { - $productRefunds[$orderDetailId]['total_refunded_tax_excl'] = Tools::ps_round($productRefundAmount, $precision); - $productRefunds[$orderDetailId]['total_refunded_tax_incl'] = Tools::ps_round($taxCalculator->addTaxes($productRefundAmount), $precision); - } - - // Add missing fields - $productRefunds[$orderDetailId]['unit_price_tax_excl'] = (float) $orderDetail->unit_price_tax_excl; - $productRefunds[$orderDetailId]['unit_price_tax_incl'] = (float) $orderDetail->unit_price_tax_incl; - $productRefunds[$orderDetailId]['total_price_tax_excl'] = (float) $orderDetail->unit_price_tax_excl * $productRefunds[$orderDetailId]['quantity']; - $productRefunds[$orderDetailId]['total_price_tax_incl'] = (float) $orderDetail->unit_price_tax_incl * $productRefunds[$orderDetailId]['quantity']; - } - - return $productRefunds; - } - - /** - * @param Order $order - * - * @return bool - */ - private function isTaxIncludedInOrder(Order $order): bool - { - $customer = new Customer($order->id_customer); - - $taxCalculationMethod = Group::getPriceDisplayMethod((int) $customer->id_default_group); - - return $taxCalculationMethod === PS_TAX_INC; - } - - /** - * @param Order $order - * - * @return TaxCalculator - * - * @throws PrestaShopException - */ - private function getCarrierTaxCalculatorFromOrder(Order $order): TaxCalculator - { - $carrier = new Carrier((int) $order->id_carrier); - // @todo: define if we use invoice or delivery address, or we use configuration PS_TAX_ADDRESS_TYPE - $address = Address::initialize($order->id_address_delivery, false); - - return $carrier->getTaxCalculator($address); - } - - /** - * @param Order $order - * - * @return int - */ - private function getPrecision(Order $order): int - { - $currency = new Currency($order->id_currency); - $computingPrecision = new ComputingPrecision(); - - return $computingPrecision->getPrecision($currency->precision); - } -} diff --git a/src/Adapter/Order/Refund/OrderRefundSummary.php b/src/Adapter/Order/Refund/OrderRefundSummary.php deleted file mode 100644 index 688731e4..00000000 --- a/src/Adapter/Order/Refund/OrderRefundSummary.php +++ /dev/null @@ -1,179 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\Refund; - -use OrderDetail; - -/** - * Container of all the necessary information for an order refund - */ -class OrderRefundSummary -{ - /** - * @var OrderDetail[] - */ - private $orderDetails; - - /** - * @var array - */ - private $productRefunds; - - /** - * @var float - */ - private $refundedAmount; - - /** - * @var float - */ - private $refundedShipping; - - /** - * @var float - */ - private $voucherAmount; - - /** - * @var bool - */ - private $voucherChosen; - - /** - * @var bool - */ - private $isTaxIncluded; - - /** - * @var int - */ - private $precision; - - /** - * @param array $orderDetails - * @param array $productRefunds - * @param float $refundedAmount - * @param float $refundedShipping - * @param float $voucherAmount - * @param bool $voucherChosen - * @param bool $isTaxIncluded - * @param int $precision - */ - public function __construct( - array $orderDetails, - array $productRefunds, - float $refundedAmount, - float $refundedShipping, - float $voucherAmount, - bool $voucherChosen, - bool $isTaxIncluded, - int $precision - ) { - $this->orderDetails = $orderDetails; - $this->productRefunds = $productRefunds; - $this->refundedAmount = $refundedAmount; - $this->refundedShipping = $refundedShipping; - $this->voucherAmount = $voucherAmount; - $this->voucherChosen = $voucherChosen; - $this->isTaxIncluded = $isTaxIncluded; - $this->precision = $precision; - } - - /** - * @return OrderDetail[] - */ - public function getOrderDetails(): array - { - return $this->orderDetails; - } - - /** - * @return array - */ - public function getProductRefunds(): array - { - return $this->productRefunds; - } - - /** - * @return float - */ - public function getRefundedAmount(): float - { - return $this->refundedAmount; - } - - /** - * @return float - */ - public function getRefundedShipping(): float - { - return $this->refundedShipping; - } - - /** - * @return float - */ - public function getVoucherAmount(): float - { - return $this->voucherAmount; - } - - /** - * @return bool - */ - public function isVoucherChosen(): bool - { - return $this->voucherChosen; - } - - /** - * @return bool - */ - public function isTaxIncluded(): bool - { - return $this->isTaxIncluded; - } - - /** - * @return int - */ - public function getPrecision(): int - { - return $this->precision; - } - - /** - * @param int $orderDetailId - * - * @return OrderDetail|null - */ - public function getOrderDetailById(int $orderDetailId): ?OrderDetail - { - return isset($this->orderDetails[$orderDetailId]) ? $this->orderDetails[$orderDetailId] : null; - } -} diff --git a/src/Adapter/Order/Refund/OrderRefundUpdater.php b/src/Adapter/Order/Refund/OrderRefundUpdater.php deleted file mode 100644 index 376a5749..00000000 --- a/src/Adapter/Order/Refund/OrderRefundUpdater.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\Refund; - -use Customization; -use Order; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\CancelProductFromOrderException; -use PrestaShopDatabaseException; -use PrestaShopException; - -class OrderRefundUpdater -{ - /** - * @param OrderRefundSummary $orderRefundSummary - * @param bool $returnedProducts - * @param bool $restock - * - * @throws CancelProductFromOrderException - * @throws PrestaShopDatabaseException - * @throws PrestaShopException - */ - public function updateRefundData( - OrderRefundSummary $orderRefundSummary, - bool $returnedProducts, - bool $restock - ) { - // Update order details (after credit slip to avoid updating refunded quantities while the credit slip fails) - foreach ($orderRefundSummary->getProductRefunds() as $orderDetailId => $productRefund) { - $orderDetail = $orderRefundSummary->getOrderDetailById($orderDetailId); - // There is a distinction between a product returned and refunded (depending if the order was delivered or not) - if ($returnedProducts) { - $orderDetail->product_quantity_return += $productRefund['quantity']; - } else { - $orderDetail->product_quantity_refunded += $productRefund['quantity']; - } - - // This was previously done in OrderSlip::create, but it was not consistent and too complicated - // Besides this now allows to track refunded products even when credit slip is not generated - $orderDetail->total_refunded_tax_excl += $productRefund['total_refunded_tax_excl']; - $orderDetail->total_refunded_tax_incl += $productRefund['total_refunded_tax_incl']; - - if ($restock) { - $reinjectableQuantity = (int) $orderDetail->product_quantity - (int) $orderDetail->product_quantity_reinjected; - $quantityToReinject = $productRefund['quantity'] > $reinjectableQuantity ? $reinjectableQuantity : $productRefund['quantity']; - $orderDetail->product_quantity_reinjected += $quantityToReinject; - } - - if (!$orderDetail->update()) { - throw new CancelProductFromOrderException('Cannot update order detail'); - } - - // Update customization - if ($orderDetail->id_customization) { - $customization = new Customization($orderDetail->id_customization); - if ($returnedProducts) { - $customization->quantity_returned += $productRefund['quantity']; - } else { - $customization->quantity_refunded += $productRefund['quantity']; - } - - if (!$customization->update()) { - throw new CancelProductFromOrderException('Cannot update customization'); - } - } - } - } -} diff --git a/src/Adapter/Order/Refund/OrderSlipCreator.php b/src/Adapter/Order/Refund/OrderSlipCreator.php deleted file mode 100644 index 1dbf27fb..00000000 --- a/src/Adapter/Order/Refund/OrderSlipCreator.php +++ /dev/null @@ -1,337 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\Refund; - -use Address; -use Carrier; -use Currency; -use Customer; -use Db; -use Hook; -use Language; -use Mail; -use Order; -use OrderDetail; -use OrderSlip; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidCancelProductException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\VoucherRefundType; -use PrestaShopDatabaseException; -use PrestaShopException; -use StockAvailable; -use Symfony\Component\Translation\TranslatorInterface; -use TaxCalculator; -use TaxManagerFactory; -use Tools; - -/** - * Class OrderSlipCreator is responsible of creating an OrderSlip for a refund - */ -class OrderSlipCreator -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param ConfigurationInterface $configuration - * @param TranslatorInterface $translator - */ - public function __construct( - ConfigurationInterface $configuration, - TranslatorInterface $translator - ) { - $this->configuration = $configuration; - $this->translator = $translator; - } - - /** - * @param Order $order - * @param OrderRefundSummary $orderRefundSummary - * - * @throws InvalidCancelProductException - * @throws OrderException - * @throws PrestaShopDatabaseException - * @throws PrestaShopException - */ - public function create( - Order $order, - OrderRefundSummary $orderRefundSummary - ) { - if ($orderRefundSummary->getRefundedAmount() > 0) { - $orderSlipCreated = $this->createOrderSlip( - $order, - $orderRefundSummary->getProductRefunds(), - $orderRefundSummary->getRefundedShipping(), - $orderRefundSummary->getVoucherAmount(), - $orderRefundSummary->isVoucherChosen(), - !$orderRefundSummary->isTaxIncluded(), - $orderRefundSummary->getPrecision() - ); - - if (!$orderSlipCreated) { - throw new OrderException('You cannot generate a partial credit slip.'); - } - - $fullQuantityList = array_map(function ($orderDetail) { return $orderDetail['quantity']; }, $orderRefundSummary->getProductRefunds()); - Hook::exec('actionOrderSlipAdd', [ - 'order' => $order, - 'productList' => $orderRefundSummary->getProductRefunds(), - 'qtyList' => $fullQuantityList, - ], null, false, true, false, $order->id_shop); - - $customer = new Customer((int) $order->id_customer); - - // @todo: use private method to send mail - $params = [ - '{lastname}' => $customer->lastname, - '{firstname}' => $customer->firstname, - '{id_order}' => $order->id, - '{order_name}' => $order->getUniqReference(), - ]; - - $orderLanguage = new Language((int) $order->id_lang); - - // @todo: use a dedicated Mail class (see #13945) - // @todo: remove this @and have a proper error handling - @Mail::Send( - (int) $order->id_lang, - 'credit_slip', - $this->translator->trans( - 'New credit slip regarding your order', - [], - 'Emails.Subject', - $orderLanguage->locale - ), - $params, - $customer->email, - $customer->firstname . ' ' . $customer->lastname, - null, - null, - null, - null, - _PS_MAIL_DIR_, - true, - (int) $order->id_shop - ); - - /** @var OrderDetail $orderDetail */ - foreach ($orderRefundSummary->getOrderDetails() as $orderDetail) { - if ($this->configuration->get('PS_ADVANCED_STOCK_MANAGEMENT')) { - StockAvailable::synchronize($orderDetail->product_id); - } - } - } else { - throw new InvalidCancelProductException(InvalidCancelProductException::INVALID_AMOUNT); - } - } - - /** - * This is a copy of OrderSlip::create except the OrderDetail modification has been removed - * since it's now managed in the handler, this allows to update order details even without - * generating a credit slip - * - * @todo this copy uses array data but could probably be refactored to use OrderDetailRefund objects - * - * @param Order $order - * @param array $product_list - * @param float $shipping_cost - * @param float $amount - * @param bool $amount_choosen - * @param bool $add_tax - * @param int $precision - * - * @return bool - * - * @throws PrestaShopDatabaseException - * @throws PrestaShopException - */ - private function createOrderSlip( - Order $order, - array $product_list, - float $shipping_cost = 0, - float $amount = 0, - bool $amount_choosen = false, - bool $add_tax = true, - int $precision = 6 - ) { - $currency = new Currency((int) $order->id_currency); - $orderSlip = new OrderSlip(); - $orderSlip->id_customer = (int) $order->id_customer; - $orderSlip->id_order = (int) $order->id; - $orderSlip->conversion_rate = $currency->conversion_rate; - - if ($add_tax) { - $add_or_remove = 'add'; - $inc_or_ex_1 = 'excl'; - $inc_or_ex_2 = 'incl'; - } else { - $add_or_remove = 'remove'; - $inc_or_ex_1 = 'incl'; - $inc_or_ex_2 = 'excl'; - } - - $orderSlip->total_shipping_tax_excl = 0; - $orderSlip->total_shipping_tax_incl = 0; - $orderSlip->partial = 0; - - if ($shipping_cost > 0) { - $orderSlip->shipping_cost = true; - $carrier = new Carrier((int) $order->id_carrier); - // @todo: define if we use invoice or delivery address, or we use configuration PS_TAX_ADDRESS_TYPE - $address = Address::initialize($order->id_address_delivery, false); - $tax_calculator = $carrier->getTaxCalculator($address); - $orderSlip->{'total_shipping_tax_' . $inc_or_ex_1} = $shipping_cost; - - if ($tax_calculator instanceof TaxCalculator) { - $orderSlip->{'total_shipping_tax_' . $inc_or_ex_2} = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($orderSlip->{'total_shipping_tax_' . $inc_or_ex_1}), $precision); - } else { - $orderSlip->{'total_shipping_tax_' . $inc_or_ex_2} = $orderSlip->{'total_shipping_tax_' . $inc_or_ex_1}; - } - } else { - $orderSlip->shipping_cost = false; - } - - $orderSlip->amount = 0; - $orderSlip->total_products_tax_excl = 0; - $orderSlip->total_products_tax_incl = 0; - $total_products = []; - foreach ($product_list as &$product) { - $order_detail = new OrderDetail((int) $product['id_order_detail']); - $price = (float) $product['unit_price']; - $quantity = (int) $product['quantity']; - - // @todo: define if we use invoice or delivery address, or we use configuration PS_TAX_ADDRESS_TYPE - $address = Address::initialize($order->id_address_invoice, false); - $id_address = (int) $address->id; - $id_tax_rules_group = (int) $order_detail->id_tax_rules_group; - $tax_calculator = $order_detail->getTaxCalculator(); - - $orderSlip->{'total_products_tax_' . $inc_or_ex_1} += $price * $quantity; - - if (in_array($this->configuration->get('PS_ROUND_TYPE'), [Order::ROUND_ITEM, Order::ROUND_LINE])) { - if (!isset($total_products[$id_tax_rules_group])) { - $total_products[$id_tax_rules_group] = 0; - } - } else { - if (!isset($total_products[$id_tax_rules_group . '_' . $id_address])) { - $total_products[$id_tax_rules_group . '_' . $id_address] = 0; - } - } - - $product_tax_incl_line = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price) * $quantity, $precision); - - switch ($this->configuration->get('PS_ROUND_TYPE')) { - case Order::ROUND_ITEM: - $product_tax_incl = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price), $precision) * $quantity; - $total_products[$id_tax_rules_group] += $product_tax_incl; - - break; - case Order::ROUND_LINE: - $product_tax_incl = $product_tax_incl_line; - $total_products[$id_tax_rules_group] += $product_tax_incl; - - break; - case Order::ROUND_TOTAL: - $product_tax_incl = $product_tax_incl_line; - $total_products[$id_tax_rules_group . '_' . $id_address] += $price * $quantity; - - break; - } - - $product['unit_price_tax_' . $inc_or_ex_1] = $price; - $product['unit_price_tax_' . $inc_or_ex_2] = Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price), $precision); - $product['total_price_tax_' . $inc_or_ex_1] = Tools::ps_round($price * $quantity, $precision); - $product['total_price_tax_' . $inc_or_ex_2] = Tools::ps_round($product_tax_incl, $precision); - } - - unset($product); - - foreach ($total_products as $key => $price) { - if ($this->configuration->get('PS_ROUND_TYPE') == Order::ROUND_TOTAL) { - $tmp = explode('_', $key); - $address = Address::initialize((int) $tmp[1], true); - $tax_calculator = TaxManagerFactory::getManager($address, $tmp[0])->getTaxCalculator(); - $orderSlip->{'total_products_tax_' . $inc_or_ex_2} += Tools::ps_round($tax_calculator->{$add_or_remove . 'Taxes'}($price), $precision); - } else { - $orderSlip->{'total_products_tax_' . $inc_or_ex_2} += $price; - } - } - - $orderSlip->{'total_products_tax_' . $inc_or_ex_2} -= $amount && !$amount_choosen ? $amount : 0; - $orderSlip->amount = $amount_choosen ? $amount : $orderSlip->{'total_products_tax_' . $inc_or_ex_1}; - $orderSlip->shipping_cost_amount = $orderSlip->total_shipping_tax_incl; - - if ((float) $amount && !$amount_choosen) { - $orderSlip->order_slip_type = VoucherRefundType::PRODUCT_PRICES_EXCLUDING_VOUCHER_REFUND; - } - if (((float) $amount && $amount_choosen) || $orderSlip->shipping_cost_amount > 0) { - $orderSlip->order_slip_type = VoucherRefundType::SPECIFIC_AMOUNT_REFUND; - } - - if (!$orderSlip->add()) { - return false; - } - - $res = true; - - foreach ($product_list as $product) { - $res &= $this->addProductOrderSlip((int) $orderSlip->id, $product); - } - - return (bool) $res; - } - - /** - * @param array $product - * - * @return bool - * - * @throws PrestaShopDatabaseException - */ - private function addProductOrderSlip(int $orderSlipId, array $product): bool - { - return (bool) Db::getInstance()->insert('order_slip_detail', [ - 'id_order_slip' => $orderSlipId, - 'id_order_detail' => (int) $product['id_order_detail'], - 'product_quantity' => $product['quantity'], - 'unit_price_tax_excl' => $product['unit_price_tax_excl'], - 'unit_price_tax_incl' => $product['unit_price_tax_incl'], - 'total_price_tax_excl' => $product['total_price_tax_excl'], - 'total_price_tax_incl' => $product['total_price_tax_incl'], - 'amount_tax_excl' => $product['total_price_tax_excl'], - 'amount_tax_incl' => $product['total_price_tax_incl'], - ]); - } -} diff --git a/src/Adapter/Order/Refund/VoucherGenerator.php b/src/Adapter/Order/Refund/VoucherGenerator.php deleted file mode 100644 index 6c5a99fe..00000000 --- a/src/Adapter/Order/Refund/VoucherGenerator.php +++ /dev/null @@ -1,167 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Order\Refund; - -use CartRule; -use Customer; -use Language; -use Mail; -use Order; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShop\PrestaShop\Core\Localization\Locale; -use PrestaShopDatabaseException; -use PrestaShopException; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class VoucherGenerator is responsible of generating a voucher for a customer - * for an order refund. - */ -class VoucherGenerator -{ - /** - * @var Locale - */ - private $locale; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param Locale $locale - * @param TranslatorInterface $translator - */ - public function __construct( - Locale $locale, - TranslatorInterface $translator - ) { - $this->locale = $locale; - $this->translator = $translator; - } - - /** - * @param Order $order - * @param float $voucherAmount - * @param string $currencyIsoCode - * @param bool $isTaxIncluded - * - * @throws OrderException - * @throws PrestaShopDatabaseException - * @throws PrestaShopException - * @throws LocalizationException - */ - public function generateVoucher( - Order $order, - float $voucherAmount, - string $currencyIsoCode, - bool $isTaxIncluded - ) { - $cartRule = new CartRule(); - $cartRule->description = $this->translator->trans( - 'Credit slip for order #%d', - ['#%d' => $order->id], - 'Admin.Orderscustomers.Feature' - ); - - $langIds = Language::getIDs(false); - foreach ($langIds as $langId) { - // Define a temporary name - $cartRule->name[$langId] = sprintf('V0C%1$dO%2$d', $order->id_customer, $order->id); - } - - // Define a temporary code - $cartRule->code = sprintf('V0C%1$dO%2$d', $order->id_customer, $order->id); - $cartRule->quantity = 1; - $cartRule->quantity_per_user = 1; - - // Specific to the customer - $cartRule->id_customer = $order->id_customer; - $now = time(); - $cartRule->date_from = date('Y-m-d H:i:s', $now); - $cartRule->date_to = date('Y-m-d H:i:s', strtotime('+1 year')); - $cartRule->partial_use = 1; - $cartRule->active = 1; - - $cartRule->reduction_amount = $voucherAmount; - $cartRule->reduction_tax = $isTaxIncluded; - $cartRule->minimum_amount_currency = $order->id_currency; - $cartRule->reduction_currency = $order->id_currency; - - if (!$cartRule->add()) { - throw new OrderException('You cannot generate a voucher.'); - } - - // Update the voucher code and name - foreach ($langIds as $langId) { - $cartRule->name[$langId] = sprintf('V%1$dC%2$dO%3$d', $cartRule->id, $order->id_customer, $order->id); - } - - $cartRule->code = sprintf('V%1$dC%2$dO%3$d', $cartRule->id, $order->id_customer, $order->id); - - if (!$cartRule->update()) { - throw new OrderException('You cannot generate a voucher.'); - } - - $customer = new Customer((int) ($order->id_customer)); - - $params = [ - '{lastname}' => $customer->lastname, - '{firstname}' => $customer->firstname, - '{id_order}' => $order->id, - '{order_name}' => $order->getUniqReference(), - '{voucher_amount}' => $this->locale->formatPrice($cartRule->reduction_amount, $currencyIsoCode), - '{voucher_num}' => $cartRule->code, - ]; - - // @todo: use private method to send mail and later a decoupled mail sender - $orderLanguage = new Language((int) $order->id_lang); - - @Mail::Send( - (int) $order->id_lang, - 'voucher', - $this->translator->trans( - 'New voucher for your order #%s', - [$order->reference], - 'Emails.Subject', - $orderLanguage->locale - ), - $params, - $customer->email, - $customer->firstname . ' ' . $customer->lastname, - null, - null, - null, - null, - _PS_MAIL_DIR_, - true, - (int) $order->id_shop - ); - } -} diff --git a/src/Adapter/OrderMessage/AbstractOrderMessageHandler.php b/src/Adapter/OrderMessage/AbstractOrderMessageHandler.php deleted file mode 100644 index 2699f039..00000000 --- a/src/Adapter/OrderMessage/AbstractOrderMessageHandler.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\OrderMessage; - -use OrderMessage; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Exception\OrderMessageNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\ValueObject\OrderMessageId; - -/** - * Provides common methods for OrderMessage command/query handlers that uses object model - * - * @internal - */ -abstract class AbstractOrderMessageHandler -{ - /** - * @param OrderMessageId $orderMessageId - * - * @return OrderMessage - */ - protected function getOrderMessage(OrderMessageId $orderMessageId): OrderMessage - { - $orderMessage = new OrderMessage($orderMessageId->getValue()); - - if ($orderMessage->id !== $orderMessageId->getValue()) { - throw new OrderMessageNotFoundException($orderMessageId, sprintf('Order message with id "%s" was not found', $orderMessageId->getValue())); - } - - return $orderMessage; - } -} diff --git a/src/Adapter/OrderMessage/CommandHandler/AddOrderMessageHandler.php b/src/Adapter/OrderMessage/CommandHandler/AddOrderMessageHandler.php deleted file mode 100644 index 9ca28504..00000000 --- a/src/Adapter/OrderMessage/CommandHandler/AddOrderMessageHandler.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\OrderMessage\CommandHandler; - -use OrderMessage; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command\AddOrderMessageCommand; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\CommandHandler\AddOrderMessageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Exception\OrderMessageException; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\ValueObject\OrderMessageId; -use PrestaShopException; - -/** - * Handles adding new order message using legacy object model - * - * @internal - */ -final class AddOrderMessageHandler implements AddOrderMessageHandlerInterface -{ - /** - * @param AddOrderMessageCommand $command - * - * @return OrderMessageId - */ - public function handle(AddOrderMessageCommand $command): OrderMessageId - { - $orderMessage = new OrderMessage(); - - $orderMessage->name = $command->getLocalizedName(); - $orderMessage->message = $command->getLocalizedMessage(); - - try { - $orderMessage->validateFields(); - $orderMessage->validateFieldsLang(); - } catch (PrestaShopException $e) { - throw new OrderMessageException('Order message contains invalid fields', 0, $e); - } - - try { - if (false === $orderMessage->add()) { - throw new OrderMessageException('Failed to add order message'); - } - } catch (PrestaShopException $e) { - throw new OrderMessageException('Failed to add order message', 0, $e); - } - - return new OrderMessageId((int) $orderMessage->id); - } -} diff --git a/src/Adapter/OrderMessage/CommandHandler/BulkDeleteOrderMessageHandler.php b/src/Adapter/OrderMessage/CommandHandler/BulkDeleteOrderMessageHandler.php deleted file mode 100644 index cd9b22a6..00000000 --- a/src/Adapter/OrderMessage/CommandHandler/BulkDeleteOrderMessageHandler.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\OrderMessage\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\OrderMessage\AbstractOrderMessageHandler; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command\BulkDeleteOrderMessageCommand; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\CommandHandler\BulkDeleteOrderMessageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Exception\OrderMessageException; -use PrestaShopException; - -/** - * Deletes Order messages in bulk action using object model - * - * @internal - */ -final class BulkDeleteOrderMessageHandler extends AbstractOrderMessageHandler implements BulkDeleteOrderMessageHandlerInterface -{ - /** - * @param BulkDeleteOrderMessageCommand $command - */ - public function handle(BulkDeleteOrderMessageCommand $command): void - { - foreach ($command->getOrderMessageIds() as $orderMessageId) { - $orderMessage = $this->getOrderMessage($orderMessageId); - - try { - if (false === $orderMessage->delete()) { - throw new OrderMessageException(sprintf('Failed to delete Order message with id "%d" during bulk delete', $orderMessage->id), OrderMessageException::FAILED_BULK_DELETE); - } - } catch (PrestaShopException $e) { - throw new OrderMessageException(sprintf('Failed to delete Order message with id "%s"', $orderMessage->id)); - } - } - } -} diff --git a/src/Adapter/OrderMessage/CommandHandler/DeleteOrderMessageHandler.php b/src/Adapter/OrderMessage/CommandHandler/DeleteOrderMessageHandler.php deleted file mode 100644 index 2ed4e538..00000000 --- a/src/Adapter/OrderMessage/CommandHandler/DeleteOrderMessageHandler.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\OrderMessage\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\OrderMessage\AbstractOrderMessageHandler; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command\DeleteOrderMessageCommand; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\CommandHandler\DeleteOrderMessageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Exception\OrderMessageException; -use PrestaShopException; - -/** - * Handles deleting order message using object model - * - * @internal - */ -final class DeleteOrderMessageHandler extends AbstractOrderMessageHandler implements DeleteOrderMessageHandlerInterface -{ - /** - * @param DeleteOrderMessageCommand $command - */ - public function handle(DeleteOrderMessageCommand $command): void - { - $orderMessage = $this->getOrderMessage($command->getOrderMessageId()); - - try { - if (false === $orderMessage->delete()) { - throw new OrderMessageException(sprintf('Failed to delete Order message with id "%d"', $orderMessage->id), OrderMessageException::FAILED_DELETE); - } - } catch (PrestaShopException $e) { - throw new OrderMessageException(sprintf('Failed to delete Order message with id "%s"', $orderMessage->id)); - } - } -} diff --git a/src/Adapter/OrderMessage/CommandHandler/EditOrderMessageHandler.php b/src/Adapter/OrderMessage/CommandHandler/EditOrderMessageHandler.php deleted file mode 100644 index 88080e02..00000000 --- a/src/Adapter/OrderMessage/CommandHandler/EditOrderMessageHandler.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\OrderMessage\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\OrderMessage\AbstractOrderMessageHandler; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command\EditOrderMessageCommand; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\CommandHandler\EditOrderMessageHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Exception\OrderMessageException; -use PrestaShopException; - -/** - * Handles editing order message using legacy object model - * - * @internal - */ -final class EditOrderMessageHandler extends AbstractOrderMessageHandler implements EditOrderMessageHandlerInterface -{ - /** - * @param EditOrderMessageCommand $command - */ - public function handle(EditOrderMessageCommand $command): void - { - $orderMessage = $this->getOrderMessage($command->getOrderMessageId()); - - if (null !== $command->getLocalizedName()) { - $orderMessage->name = $command->getLocalizedName(); - } - - if (null !== $command->getLocalizedMessage()) { - $orderMessage->message = $command->getLocalizedMessage(); - } - - try { - $orderMessage->validateFields(); - $orderMessage->validateFieldsLang(); - } catch (PrestaShopException $e) { - throw new OrderMessageException('Order message contains invalid fields', 0, $e); - } - - try { - if (false === $orderMessage->update()) { - throw new OrderMessageException(sprintf('Failed to update order message with id "%s"', $command->getOrderMessageId()->getValue())); - } - } catch (PrestaShopException $e) { - throw new OrderMessageException(sprintf('Failed to update order message with id "%s"', $command->getOrderMessageId()->getValue()), 0, $e); - } - } -} diff --git a/src/Adapter/OrderMessage/OrderMessageProvider.php b/src/Adapter/OrderMessage/OrderMessageProvider.php deleted file mode 100644 index 99619d54..00000000 --- a/src/Adapter/OrderMessage/OrderMessageProvider.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\OrderMessage; - -use OrderMessage; - -/** - * Gets order messages. - */ -class OrderMessageProvider -{ - /** - * @var int - */ - private $contextLanguageId; - - /** - * @param int $contextLanguageId - */ - public function __construct(int $contextLanguageId) - { - $this->contextLanguageId = $contextLanguageId; - } - - public function getMessages(): array - { - $result = OrderMessage::getOrderMessages($this->contextLanguageId); - - return \is_array($result) ? $result : []; - } -} diff --git a/src/Adapter/OrderMessage/QueryHandler/GetOrderMessageForEditingHandler.php b/src/Adapter/OrderMessage/QueryHandler/GetOrderMessageForEditingHandler.php deleted file mode 100644 index 99936fff..00000000 --- a/src/Adapter/OrderMessage/QueryHandler/GetOrderMessageForEditingHandler.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\OrderMessage\QueryHandler; - -use PrestaShop\PrestaShop\Adapter\OrderMessage\AbstractOrderMessageHandler; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Query\GetOrderMessageForEditing; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\QueryHandler\GetOrderMessageForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\QueryResult\EditableOrderMessage; - -/** - * Get order message for editing using object model - * - * @internal - */ -final class GetOrderMessageForEditingHandler extends AbstractOrderMessageHandler implements GetOrderMessageForEditingHandlerInterface -{ - /** - * @param GetOrderMessageForEditing $query - * - * @return EditableOrderMessage - */ - public function handle(GetOrderMessageForEditing $query): EditableOrderMessage - { - $orderMessage = $this->getOrderMessage($query->getOrderMessageId()); - - return new EditableOrderMessage( - $query->getOrderMessageId(), - $orderMessage->name, - $orderMessage->message - ); - } -} diff --git a/src/Adapter/OrderState/OrderStateDataProvider.php b/src/Adapter/OrderState/OrderStateDataProvider.php deleted file mode 100644 index ee2f5674..00000000 --- a/src/Adapter/OrderState/OrderStateDataProvider.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\OrderState; - -use OrderState; -use PrestaShop\PrestaShop\Core\Order\OrderStateDataProviderInterface; - -/** - * Class OrderStateDataProvider provides OrderState data using legacy code. - */ -final class OrderStateDataProvider implements OrderStateDataProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getOrderStates($languageId) - { - return OrderState::getOrderStates($languageId, false); - } -} diff --git a/src/Adapter/PDF/CreditSlipPdfGenerator.php b/src/Adapter/PDF/CreditSlipPdfGenerator.php deleted file mode 100644 index 47d3d724..00000000 --- a/src/Adapter/PDF/CreditSlipPdfGenerator.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\PDF; - -use Context; -use Doctrine\DBAL\Connection; -use ObjectModel; -use OrderSlip; -use PDF; -use PrestaShop\PrestaShop\Core\Domain\CreditSlip\ValueObject\CreditSlipId; -use PrestaShop\PrestaShop\Core\PDF\Exception\MissingDataException; -use PrestaShop\PrestaShop\Core\PDF\Exception\PdfException; -use PrestaShop\PrestaShop\Core\PDF\PDFGeneratorInterface; -use PrestaShopException; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Responsible for generating CreditSlip PDF - */ -final class CreditSlipPdfGenerator implements PDFGeneratorInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var string - */ - private $dbPrefix; - - /** - * @var Connection - */ - private $connection; - - /** - * @param TranslatorInterface $translator - * @param string $dbPrefix - * @param Connection $connection - */ - public function __construct( - TranslatorInterface $translator, - $dbPrefix, - Connection $connection - ) { - $this->translator = $translator; - $this->dbPrefix = $dbPrefix; - $this->connection = $connection; - } - - /** - * Generates PDF from given data using legacy object models - * - * @param CreditSlipId[] $creditSlipIds - * - * @throws PdfException - */ - public function generatePDF(array $creditSlipIds) - { - $ids = []; - foreach ($creditSlipIds as $creditSlipId) { - $ids[] = $creditSlipId->getValue(); - } - - try { - $slipsList = $this->getCreditSlipsList($ids); - $slipsCollection = ObjectModel::hydrateCollection('OrderSlip', $slipsList); - - $pdf = new PDF($slipsCollection, PDF::TEMPLATE_ORDER_SLIP, Context::getContext()->smarty); - $pdf->render(); - } catch (PrestaShopException $e) { - throw new PdfException('Something went wrong when trying to generate pdf', 0, $e); - } - } - - /** - * Gets credit slips array from sql - * - * @param int[] $creditSlipIds - * - * @return OrderSlip[] - * - * @throws MissingDataException - */ - private function getCreditSlipsList($creditSlipIds) - { - if (!empty($creditSlipIds)) { - $qb = $this->connection->createQueryBuilder() - ->select('*') - ->from($this->dbPrefix . 'order_slip', 'os') - ->where('id_order_slip IN (:creditSlipIds)') - ->setParameter('creditSlipIds', $creditSlipIds, Connection::PARAM_INT_ARRAY) - ; - - $slipsList = $qb->execute()->fetchAll(); - } - - if (!empty($slipsList)) { - return $slipsList; - } - - throw new MissingDataException('Missing data required to generate PDF'); - } -} diff --git a/src/Adapter/PDF/DeliverySlipPdfGenerator.php b/src/Adapter/PDF/DeliverySlipPdfGenerator.php deleted file mode 100644 index dc0e97f2..00000000 --- a/src/Adapter/PDF/DeliverySlipPdfGenerator.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\PDF; - -use Context; -use Order; -use PDF; -use PrestaShop\PrestaShop\Core\Exception\CoreException; -use PrestaShop\PrestaShop\Core\PDF\PDFGeneratorInterface; -use RuntimeException; -use Symfony\Component\Translation\TranslatorInterface; -use Validate; - -/** - * Generates delivery slip for given order - * - * @internal - */ -final class DeliverySlipPdfGenerator implements PDFGeneratorInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function generatePDF(array $orderId) - { - if (count($orderId) !== 1) { - throw new CoreException(sprintf('"%s" supports generating delivery slip for single order only.', get_class($this))); - } - - $orderId = reset($orderId); - $order = new Order((int) $orderId); - - if (!Validate::isLoadedObject($order)) { - throw new RuntimeException($this->translator->trans('The order cannot be found within your database.', [], 'Admin.Orderscustomers.Notification')); - } - - $order_invoice_collection = $order->getInvoicesCollection(); - - $pdf = new PDF($order_invoice_collection, PDF::TEMPLATE_DELIVERY_SLIP, Context::getContext()->smarty); - $pdf->render(); - } -} diff --git a/src/Adapter/PDF/OrderInvoicePdfGenerator.php b/src/Adapter/PDF/OrderInvoicePdfGenerator.php deleted file mode 100644 index a036e9ac..00000000 --- a/src/Adapter/PDF/OrderInvoicePdfGenerator.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\PDF; - -use Context; -use Hook; -use Order; -use PDF; -use PrestaShop\PrestaShop\Core\Exception\CoreException; -use PrestaShop\PrestaShop\Core\PDF\PDFGeneratorInterface; -use RuntimeException; -use Symfony\Component\Translation\TranslatorInterface; -use Validate; - -/** - * Generates invoice for given order. - */ -final class OrderInvoicePdfGenerator implements PDFGeneratorInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function generatePDF(array $orderId) - { - if (count($orderId) !== 1) { - throw new CoreException(sprintf('"%s" supports generating invoice for single order only.', get_class($this))); - } - - $orderId = reset($orderId); - $order = new Order((int) $orderId); - if (!Validate::isLoadedObject($order)) { - throw new RuntimeException($this->translator->trans('The order cannot be found within your database.', [], 'Admin.Orderscustomers.Notification')); - } - - $order_invoice_list = $order->getInvoicesCollection(); - - Hook::exec('actionPDFInvoiceRender', ['order_invoice_list' => $order_invoice_list]); - - $pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, Context::getContext()->smarty); - $pdf->render(); - } -} diff --git a/src/Adapter/PDF/PDFGenerator.php b/src/Adapter/PDF/PDFGenerator.php deleted file mode 100644 index 4874ed7a..00000000 --- a/src/Adapter/PDF/PDFGenerator.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\PDF; - -use PrestaShop\PrestaShop\Adapter\Entity\PDF; -use PrestaShop\PrestaShop\Core\PDF\PDFGeneratorInterface; -use PrestaShop\PrestaShop\Core\PDF\PDFTemplateTypeProviderInterface; -use Smarty; - -/** - * Class PDFManager responsible for PDF generation using legacy code. - */ -final class PDFGenerator implements PDFGeneratorInterface -{ - /** - * @var Smarty - */ - private $smarty; - - /** - * @var PDFTemplateTypeProviderInterface - */ - private $templateTypeProvider; - - /** - * @param Smarty $smarty - * @param PDFTemplateTypeProviderInterface $templateTypeProvider - */ - public function __construct( - Smarty $smarty, - PDFTemplateTypeProviderInterface $templateTypeProvider - ) { - $this->smarty = $smarty; - $this->templateTypeProvider = $templateTypeProvider; - } - - /** - * {@inheritdoc} - */ - public function generatePDF(array $objectCollection) - { - $pdf = new PDF($objectCollection, $this->templateTypeProvider->getPDFTemplateType(), $this->smarty); - $pdf->render(); - } -} diff --git a/src/Adapter/Pack/PackDataProvider.php b/src/Adapter/Pack/PackDataProvider.php deleted file mode 100644 index 9a79ef2a..00000000 --- a/src/Adapter/Pack/PackDataProvider.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Pack; - -use Context; -use Pack; -use Product; - -/** - * This class will provide data from DB / ORM about product pack. - */ -class PackDataProvider -{ - /** - * Get product pack items. - * - * @param int $id_product - * @param int $id_lang - */ - public function getItems($id_product, $id_lang) - { - $packItems = Pack::getItems($id_product, $id_lang); - - foreach ($packItems as $packItem) { - $cover = $packItem->id_pack_product_attribute ? Product::getCombinationImageById($packItem->id_pack_product_attribute, $id_lang) : Product::getCover($packItem->id); - $packItem->image = Context::getContext()->link->getImageLink($packItem->link_rewrite, $cover ? $cover['id_image'] : '', 'home_default'); - } - - return $packItems; - } -} diff --git a/src/Adapter/Preferences/PreferencesConfiguration.php b/src/Adapter/Preferences/PreferencesConfiguration.php deleted file mode 100644 index 0e63094c..00000000 --- a/src/Adapter/Preferences/PreferencesConfiguration.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Preferences; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * This class will provide Shop Preferences configuration. - */ -class PreferencesConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'enable_ssl' => $this->configuration->getBoolean('PS_SSL_ENABLED'), - 'enable_ssl_everywhere' => $this->configuration->getBoolean('PS_SSL_ENABLED_EVERYWHERE'), - 'enable_token' => $this->configuration->getBoolean('PS_TOKEN_ENABLE'), - 'allow_html_iframes' => $this->configuration->getBoolean('PS_ALLOW_HTML_IFRAME'), - 'use_htmlpurifier' => $this->configuration->getBoolean('PS_USE_HTMLPURIFIER'), - 'price_round_mode' => $this->configuration->get('PS_PRICE_ROUND_MODE'), - 'price_round_type' => $this->configuration->get('PS_ROUND_TYPE'), - 'display_suppliers' => $this->configuration->getBoolean('PS_DISPLAY_SUPPLIERS'), - 'display_manufacturers' => $this->configuration->getBoolean('PS_DISPLAY_MANUFACTURERS'), - 'display_best_sellers' => $this->configuration->getBoolean('PS_DISPLAY_BEST_SELLERS'), - 'multishop_feature_active' => $this->configuration->getBoolean('PS_MULTISHOP_FEATURE_ACTIVE'), - 'shop_activity' => $this->configuration->get('PS_SHOP_ACTIVITY'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_SSL_ENABLED', $configuration['enable_ssl']); - $this->configuration->set('PS_SSL_ENABLED_EVERYWHERE', $configuration['enable_ssl_everywhere']); - $this->configuration->set('PS_TOKEN_ENABLE', $configuration['enable_token']); - $this->configuration->set('PS_ALLOW_HTML_IFRAME', $configuration['allow_html_iframes']); - $this->configuration->set('PS_USE_HTMLPURIFIER', $configuration['use_htmlpurifier']); - $this->configuration->set('PS_PRICE_ROUND_MODE', $configuration['price_round_mode']); - $this->configuration->set('PS_ROUND_TYPE', $configuration['price_round_type']); - $this->configuration->set('PS_DISPLAY_SUPPLIERS', $configuration['display_suppliers']); - $this->configuration->set('PS_DISPLAY_MANUFACTURERS', $configuration['display_manufacturers']); - $this->configuration->set('PS_DISPLAY_BEST_SELLERS', $configuration['display_best_sellers']); - $this->configuration->set('PS_MULTISHOP_FEATURE_ACTIVE', $configuration['multishop_feature_active']); - $this->configuration->set('PS_SHOP_ACTIVITY', $configuration['shop_activity']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['enable_ssl'], - $configuration['enable_ssl_everywhere'], - $configuration['enable_token'], - $configuration['allow_html_iframes'], - $configuration['use_htmlpurifier'], - $configuration['price_round_mode'], - $configuration['price_round_type'], - $configuration['display_suppliers'], - $configuration['display_manufacturers'], - $configuration['display_best_sellers'], - $configuration['multishop_feature_active'] - ); - } -} diff --git a/src/Adapter/Presenter/AbstractLazyArray.php b/src/Adapter/Presenter/AbstractLazyArray.php deleted file mode 100644 index e92a569d..00000000 --- a/src/Adapter/Presenter/AbstractLazyArray.php +++ /dev/null @@ -1,392 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Presenter; - -use ArrayAccess; -use ArrayIterator; -use ArrayObject; -use Countable; -use Doctrine\Common\Util\Inflector; -use Iterator; -use JsonSerializable; -use ReflectionClass; -use ReflectionException; -use ReflectionMethod; -use RuntimeException; - -/** - * This class is useful to provide the same behaviour than an array, but which load the result of each key on demand - * (LazyLoading). - * - * Example: - * - * If your want to define the ['addresses'] array access in your lazyArray object, just define the public method - * getAddresses() and add the annotation arrayAccess to it. e.g: - * - * @arrayAccess - * - * @return array - * - * public function getAddresses() - * - * The method name should always be the index name converted to camelCase and prefixed with get. e.g: - * - * ['add_to_cart'] => getAddToCart() - * - * You can also add an array with already defined key to the lazyArray be calling the appendArray function. - * e.g.: you have a $product array containing $product['id'] = 10; $product['url'] = 'foo'; - * If you call ->appendArray($product) on the lazyArray, it will define the key ['id'] and ['url'] as well - * for the lazyArray. - * Note if the key already exists as a method, it will be skip. In our example, if getUrl() is defined with the - * annotation @arrayAccess, the $product['url'] = 'foo'; will be ignored - */ -abstract class AbstractLazyArray implements Iterator, ArrayAccess, Countable, JsonSerializable -{ - /** - * @var ArrayObject - */ - private $arrayAccessList; - - /** - * @var ArrayIterator - */ - private $arrayAccessIterator; - - /** - * @var array - */ - private $methodCacheResults = []; - - /** - * AbstractLazyArray constructor. - * - * @throws ReflectionException - */ - public function __construct() - { - $this->arrayAccessList = new ArrayObject(); - $reflectionClass = new ReflectionClass(get_class($this)); - $methods = $reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC); - foreach ($methods as $method) { - $methodDoc = $method->getDocComment(); - if (strpos($methodDoc, '@arrayAccess') !== false) { - $this->arrayAccessList[$this->convertMethodNameToIndex($method->getName())] = - [ - 'type' => 'method', - 'value' => $method->getName(), - ]; - } - } - $this->arrayAccessIterator = $this->arrayAccessList->getIterator(); - } - - /** - * Make the lazyArray serializable like an array. - * - * @return array - * - * @throws RuntimeException - */ - public function jsonSerialize() - { - $arrayResult = []; - foreach ($this->arrayAccessList as $key => $value) { - $arrayResult[$key] = $this->offsetGet($key); - } - - return $arrayResult; - } - - /** - * Set array key and values from $array into the LazyArray. - * - * @param array $array - */ - public function appendArray($array) - { - foreach ($array as $key => $value) { - // do not override any existing method - if (!$this->arrayAccessList->offsetExists($key)) { - $this->arrayAccessList->offsetSet( - $key, - [ - 'type' => 'variable', - 'value' => $value, - ] - ); - } - } - } - - /** - * The number of keys defined into the lazyArray. - * - * @return int - */ - public function count() - { - return $this->arrayAccessList->count(); - } - - /** - * The properties are provided as an array. But callers checking the type of this class (is_object === true) - * think they must use the object syntax. - * - * Check if the index exists inside the lazyArray. - * - * @param string $index - * - * @return bool - */ - public function __isset($index) - { - return $this->offsetExists($index); - } - - /** - * The properties are provided as an array. But callers checking the type of this class (is_object === true) - * think they must use the object syntax. - * - * Get the value associated with the $index from the lazyArray. - * - * @param mixed $index - * - * @return mixed - * - * @throws RuntimeException - */ - public function __get($index) - { - return $this->offsetGet($index); - } - - /** - * The properties are provided as an array. But callers checking the type of this class (is_object === true) - * think they must use the object syntax. - * - * @param mixed $offset - * @param mixed $value - * @param bool $force if set, allow override of an existing method - * - * @throws RuntimeException - */ - public function __set($name, $value) - { - $this->offsetSet($name, $value); - } - - /** - * The properties are provided as an array. But callers checking the type of this class (is_object === true) - * think they must use the object syntax. - * - * @param mixed $offset - * @param bool $force if set, allow unset of an existing method - * - * @throws RuntimeException - */ - public function __unset($name) - { - $this->offsetUnset($name); - } - - /** - * Needed to ensure that any changes to this object won't bleed to other instances - */ - public function __clone() - { - $this->arrayAccessList = clone $this->arrayAccessList; - $this->arrayAccessIterator = clone $this->arrayAccessIterator; - } - - /** - * Get the value associated with the $index from the lazyArray. - * - * @param mixed $index - * - * @return mixed - * - * @throws RuntimeException - */ - public function offsetGet($index) - { - if (isset($this->arrayAccessList[$index])) { - // if the index is associated with a method, execute the method an cache the result - if ($this->arrayAccessList[$index]['type'] === 'method') { - if (!isset($this->methodCacheResults[$index])) { - $methodName = $this->arrayAccessList[$index]['value']; - $this->methodCacheResults[$index] = $this->{$methodName}(); - } - $result = $this->methodCacheResults[$index]; - } else { // if the index is associated with a value, just return the value - $result = $this->arrayAccessList[$index]['value']; - } - - return $result; - } - - return []; - } - - /** - * Check if the index exists inside the lazyArray. - * - * @param mixed $index - * - * @return bool - */ - public function offsetExists($index) - { - return isset($this->arrayAccessList[$index]); - } - - /** - * Copy the lazyArray. - * - * @return AbstractLazyArray - */ - public function getArrayCopy() - { - return clone $this; - } - - /** - * Get the result associated with the current index. - * - * @return mixed - * - * @throws RuntimeException - */ - public function current() - { - $key = $this->arrayAccessIterator->key(); - - return $this->offsetGet($key); - } - - /** - * Go to the next result inside the lazyArray. - */ - public function next() - { - $this->arrayAccessIterator->next(); - } - - /** - * Get the key associated with the current index. - * - * @return mixed|string - */ - public function key() - { - return $this->arrayAccessIterator->key(); - } - - /** - * Check if we are at the end of the lazyArray. - * - * @return bool - */ - public function valid() - { - return $this->arrayAccessIterator->valid(); - } - - /** - * Go back to the first element of the lazyArray. - */ - public function rewind() - { - $this->arrayAccessIterator->rewind(); - } - - /** - * Set the keys not present in the given $array to null. - * - * @param array $array - * - * @throws RuntimeException - */ - public function intersectKey($array) - { - $arrayCopy = $this->arrayAccessList->getArrayCopy(); - foreach ($arrayCopy as $key => $value) { - if (!array_key_exists($key, $array)) { - $this->offsetUnset($key, true); - } - } - } - - /** - * @param mixed $offset - * @param mixed $value - * @param bool $force if set, allow override of an existing method - * - * @throws RuntimeException - */ - public function offsetSet($offset, $value, $force = false) - { - if (!$force && $this->arrayAccessList->offsetExists($offset)) { - $result = $this->arrayAccessList->offsetGet($offset); - if ($result['type'] !== 'variable') { - throw new RuntimeException('Trying to set the index ' . print_r($offset, true) . ' of the LazyArray ' . get_class($this) . ' already defined by a method is not allowed'); - } - } - $this->arrayAccessList->offsetSet($offset, [ - 'type' => 'variable', - 'value' => $value, - ]); - } - - /** - * @param mixed $offset - * @param bool $force if set, allow unset of an existing method - * - * @throws RuntimeException - */ - public function offsetUnset($offset, $force = false) - { - $result = $this->arrayAccessList->offsetGet($offset); - if ($force || $result['type'] === 'variable') { - $this->arrayAccessList->offsetUnset($offset); - } else { - throw new RuntimeException('Trying to unset the index ' . print_r($offset, true) . ' of the LazyArray ' . get_class($this) . ' already defined by a method is not allowed'); - } - } - - /** - * @param string $methodName - * - * @return string - */ - private function convertMethodNameToIndex($methodName) - { - // remove "get" prefix from the function name - $strippedMethodName = substr($methodName, 3); - - return Inflector::tableize($strippedMethodName); - } -} diff --git a/src/Adapter/Presenter/Cart/CartPresenter.php b/src/Adapter/Presenter/Cart/CartPresenter.php deleted file mode 100644 index 44a7abe3..00000000 --- a/src/Adapter/Presenter/Cart/CartPresenter.php +++ /dev/null @@ -1,669 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Presenter\Cart; - -use Cart; -use CartRule; -use Configuration; -use Context; -use Country; -use Hook; -use PrestaShop\PrestaShop\Adapter\Image\ImageRetriever; -use PrestaShop\PrestaShop\Adapter\Presenter\PresenterInterface; -use PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductListingPresenter; -use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter; -use PrestaShop\PrestaShop\Adapter\Product\ProductColorsRetriever; -use PrestaShop\PrestaShop\Core\Product\ProductPresentationSettings; -use Product; -use Symfony\Component\Translation\TranslatorInterface; -use TaxConfiguration; -use Tools; - -class CartPresenter implements PresenterInterface -{ - /** - * @var PriceFormatter - */ - private $priceFormatter; - - /** - * @var \Link - */ - private $link; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ImageRetriever - */ - private $imageRetriever; - - /** - * @var TaxConfiguration - */ - private $taxConfiguration; - - public function __construct() - { - $context = Context::getContext(); - $this->priceFormatter = new PriceFormatter(); - $this->link = $context->link; - $this->translator = $context->getTranslator(); - $this->imageRetriever = new ImageRetriever($this->link); - $this->taxConfiguration = new TaxConfiguration(); - } - - /** - * @return bool - */ - private function includeTaxes() - { - return $this->taxConfiguration->includeTaxes(); - } - - /** - * @param array $rawProduct - * - * @return \PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductLazyArray|\PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductListingLazyArray - */ - private function presentProduct(array $rawProduct) - { - $settings = new ProductPresentationSettings(); - - $settings->catalog_mode = Configuration::isCatalogMode(); - $settings->catalog_mode_with_prices = (int) Configuration::get('PS_CATALOG_MODE_WITH_PRICES'); - $settings->include_taxes = $this->includeTaxes(); - $settings->allow_add_variant_to_cart_from_listing = (int) Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'); - $settings->stock_management_enabled = Configuration::get('PS_STOCK_MANAGEMENT'); - $settings->showPrices = Configuration::showPrices(); - - if (isset($rawProduct['attributes']) && is_string($rawProduct['attributes'])) { - $rawProduct['attributes'] = $this->getAttributesArrayFromString($rawProduct['attributes']); - } - $rawProduct['remove_from_cart_url'] = $this->link->getRemoveFromCartURL( - $rawProduct['id_product'], - $rawProduct['id_product_attribute'] - ); - - $rawProduct['up_quantity_url'] = $this->link->getUpQuantityCartURL( - $rawProduct['id_product'], - $rawProduct['id_product_attribute'] - ); - - $rawProduct['down_quantity_url'] = $this->link->getDownQuantityCartURL( - $rawProduct['id_product'], - $rawProduct['id_product_attribute'] - ); - - $rawProduct['update_quantity_url'] = $this->link->getUpdateQuantityCartURL( - $rawProduct['id_product'], - $rawProduct['id_product_attribute'] - ); - - $resetFields = [ - 'ecotax_rate', - 'specific_prices', - 'customizable', - 'online_only', - 'reduction', - 'reduction_without_tax', - 'new', - 'condition', - 'pack', - ]; - foreach ($resetFields as $field) { - if (!array_key_exists($field, $rawProduct)) { - $rawProduct[$field] = ''; - } - } - - if ($this->includeTaxes()) { - $rawProduct['price_amount'] = $rawProduct['price_wt']; - $rawProduct['price'] = $this->priceFormatter->format($rawProduct['price_wt']); - } else { - $rawProduct['price_amount'] = $rawProduct['price']; - $rawProduct['price'] = $rawProduct['price_tax_exc'] = $this->priceFormatter->format($rawProduct['price']); - } - - if ($rawProduct['price_amount'] && $rawProduct['unit_price_ratio'] > 0) { - $rawProduct['unit_price'] = $rawProduct['price_amount'] / $rawProduct['unit_price_ratio']; - } - - $rawProduct['total'] = $this->priceFormatter->format( - $this->includeTaxes() ? - $rawProduct['total_wt'] : - $rawProduct['total'] - ); - - $rawProduct['quantity_wanted'] = $rawProduct['cart_quantity']; - - $presenter = new ProductListingPresenter( - $this->imageRetriever, - $this->link, - $this->priceFormatter, - new ProductColorsRetriever(), - $this->translator - ); - - return $presenter->present( - $settings, - $rawProduct, - Context::getContext()->language - ); - } - - /** - * @param array $products - * @param Cart $cart - * - * @return array - */ - public function addCustomizedData(array $products, Cart $cart) - { - return array_map(function ($product) use ($cart) { - $customizations = []; - - $data = Product::getAllCustomizedDatas($cart->id, null, true, null, (int) $product['id_customization']); - - if (!$data) { - $data = []; - } - $id_product = (int) $product['id_product']; - $id_product_attribute = (int) $product['id_product_attribute']; - if (array_key_exists($id_product, $data)) { - if (array_key_exists($id_product_attribute, $data[$id_product])) { - foreach ($data[$id_product] as $byAddress) { - foreach ($byAddress as $byAddressCustomizations) { - foreach ($byAddressCustomizations as $customization) { - $presentedCustomization = [ - 'quantity' => $customization['quantity'], - 'fields' => [], - 'id_customization' => null, - ]; - - foreach ($customization['datas'] as $byType) { - foreach ($byType as $data) { - $field = []; - switch ($data['type']) { - case Product::CUSTOMIZE_FILE: - $field['type'] = 'image'; - $field['image'] = $this->imageRetriever->getCustomizationImage( - $data['value'] - ); - - break; - case Product::CUSTOMIZE_TEXTFIELD: - $field['type'] = 'text'; - $field['text'] = $data['value']; - - break; - default: - $field['type'] = null; - } - $field['label'] = $data['name']; - $field['id_module'] = $data['id_module']; - $presentedCustomization['id_customization'] = $data['id_customization']; - $presentedCustomization['fields'][] = $field; - } - } - - $product['up_quantity_url'] = $this->link->getUpQuantityCartURL( - $product['id_product'], - $product['id_product_attribute'], - $presentedCustomization['id_customization'] - ); - $product['down_quantity_url'] = $this->link->getDownQuantityCartURL( - $product['id_product'], - $product['id_product_attribute'], - $presentedCustomization['id_customization'] - ); - $product['remove_from_cart_url'] = $this->link->getRemoveFromCartURL( - $product['id_product'], - $product['id_product_attribute'], - $presentedCustomization['id_customization'] - ); - $product['update_quantity_url'] = $this->link->getUpdateQuantityCartURL( - $product['id_product'], - $product['id_product_attribute'], - $presentedCustomization['id_customization'] - ); - - $presentedCustomization['up_quantity_url'] = $this->link->getUpQuantityCartURL( - $product['id_product'], - $product['id_product_attribute'], - $presentedCustomization['id_customization'] - ); - - $presentedCustomization['down_quantity_url'] = $this->link->getDownQuantityCartURL( - $product['id_product'], - $product['id_product_attribute'], - $presentedCustomization['id_customization'] - ); - - $presentedCustomization['remove_from_cart_url'] = $this->link->getRemoveFromCartURL( - $product['id_product'], - $product['id_product_attribute'], - $presentedCustomization['id_customization'] - ); - - $presentedCustomization['update_quantity_url'] = $product['update_quantity_url']; - - $customizations[] = $presentedCustomization; - } - } - } - } - } - - usort($customizations, function (array $a, array $b) { - if ( - $a['quantity'] > $b['quantity'] - || count($a['fields']) > count($b['fields']) - || $a['id_customization'] > $b['id_customization'] - ) { - return -1; - } else { - return 1; - } - }); - - $product['customizations'] = $customizations; - - return $product; - }, $products); - } - - /** - * @param Cart $cart - * @param bool $shouldSeparateGifts - * - * @return array - * - * @throws \Exception - */ - public function present($cart, $shouldSeparateGifts = false) - { - if (!is_a($cart, 'Cart')) { - throw new \Exception('CartPresenter can only present instance of Cart'); - } - - if ($shouldSeparateGifts) { - $rawProducts = $cart->getProductsWithSeparatedGifts(); - } else { - $rawProducts = $cart->getProducts(true); - } - - $products = array_map([$this, 'presentProduct'], $rawProducts); - $products = $this->addCustomizedData($products, $cart); - $subtotals = []; - - $productsTotalExcludingTax = $cart->getOrderTotal(false, Cart::ONLY_PRODUCTS); - $total_excluding_tax = $cart->getOrderTotal(false); - $total_including_tax = $cart->getOrderTotal(true); - $total_discount = $cart->getDiscountSubtotalWithoutGifts($this->includeTaxes()); - $totalCartAmount = $cart->getOrderTotal($this->includeTaxes(), Cart::ONLY_PRODUCTS); - - $subtotals['products'] = [ - 'type' => 'products', - 'label' => $this->translator->trans('Subtotal', [], 'Shop.Theme.Checkout'), - 'amount' => $totalCartAmount, - 'value' => $this->priceFormatter->format($totalCartAmount), - ]; - - if ($total_discount) { - $subtotals['discounts'] = [ - 'type' => 'discount', - 'label' => $this->translator->trans('Discount(s)', [], 'Shop.Theme.Checkout'), - 'amount' => $total_discount, - 'value' => $this->priceFormatter->format($total_discount), - ]; - } else { - $subtotals['discounts'] = null; - } - - if ($cart->gift) { - $giftWrappingPrice = ($cart->getGiftWrappingPrice($this->includeTaxes()) != 0) - ? $cart->getGiftWrappingPrice($this->includeTaxes()) - : 0; - - $subtotals['gift_wrapping'] = [ - 'type' => 'gift_wrapping', - 'label' => $this->translator->trans('Gift wrapping', [], 'Shop.Theme.Checkout'), - 'amount' => $giftWrappingPrice, - 'value' => ($giftWrappingPrice > 0) - ? $this->priceFormatter->convertAndFormat($giftWrappingPrice) - : $this->translator->trans('Free', [], 'Shop.Theme.Checkout'), - ]; - } - - if (!$cart->isVirtualCart()) { - $shippingCost = $cart->getTotalShippingCost(null, $this->includeTaxes()); - } else { - $shippingCost = 0; - } - $subtotals['shipping'] = [ - 'type' => 'shipping', - 'label' => $this->translator->trans('Shipping', [], 'Shop.Theme.Checkout'), - 'amount' => $shippingCost, - 'value' => $this->getShippingDisplayValue($cart, $shippingCost), - ]; - - $subtotals['tax'] = null; - if (Configuration::get('PS_TAX_DISPLAY')) { - $taxAmount = $total_including_tax - $total_excluding_tax; - $subtotals['tax'] = [ - 'type' => 'tax', - 'label' => ($this->includeTaxes()) - ? $this->translator->trans('Included taxes', [], 'Shop.Theme.Checkout') - : $this->translator->trans('Taxes', [], 'Shop.Theme.Checkout'), - 'amount' => $taxAmount, - 'value' => $this->priceFormatter->format($taxAmount), - ]; - } - - $totals = [ - 'total' => [ - 'type' => 'total', - 'label' => $this->translator->trans('Total', [], 'Shop.Theme.Checkout'), - 'amount' => $this->includeTaxes() ? $total_including_tax : $total_excluding_tax, - 'value' => $this->priceFormatter->format( - $this->includeTaxes() ? $total_including_tax : $total_excluding_tax - ), - ], - 'total_including_tax' => [ - 'type' => 'total', - 'label' => $this->translator->trans('Total (tax incl.)', [], 'Shop.Theme.Checkout'), - 'amount' => $total_including_tax, - 'value' => $this->priceFormatter->format($total_including_tax), - ], - 'total_excluding_tax' => [ - 'type' => 'total', - 'label' => $this->translator->trans('Total (tax excl.)', [], 'Shop.Theme.Checkout'), - 'amount' => $total_excluding_tax, - 'value' => $this->priceFormatter->format($total_excluding_tax), - ], - ]; - - $products_count = array_reduce($products, function ($count, $product) { - return $count + $product['quantity']; - }, 0); - - $summary_string = $products_count === 1 ? - $this->translator->trans('1 item', [], 'Shop.Theme.Checkout') : - $this->translator->trans('%count% items', ['%count%' => $products_count], 'Shop.Theme.Checkout'); - - $minimalPurchase = $this->priceFormatter->convertAmount((float) Configuration::get('PS_PURCHASE_MINIMUM')); - - Hook::exec('overrideMinimalPurchasePrice', [ - 'minimalPurchase' => &$minimalPurchase, - ]); - - // TODO: move it to a common parent, since it's copied in OrderPresenter and ProductPresenter - $labels = [ - 'tax_short' => ($this->includeTaxes()) - ? $this->translator->trans('(tax incl.)', [], 'Shop.Theme.Global') - : $this->translator->trans('(tax excl.)', [], 'Shop.Theme.Global'), - 'tax_long' => ($this->includeTaxes()) - ? $this->translator->trans('(tax included)', [], 'Shop.Theme.Global') - : $this->translator->trans('(tax excluded)', [], 'Shop.Theme.Global'), - ]; - - $discounts = $cart->getDiscounts(); - $vouchers = $this->getTemplateVarVouchers($cart); - - $cartRulesIds = array_flip(array_map( - function ($voucher) { - return $voucher['id_cart_rule']; - }, - $vouchers['added'] - )); - - $discounts = array_filter($discounts, function ($discount) use ($cartRulesIds, $cart) { - $voucherCustomerId = (int) $discount['id_customer']; - $voucherIsRestrictedToASingleCustomer = ($voucherCustomerId !== 0); - $voucherIsEmptyCode = empty($discount['code']); - if ($voucherIsRestrictedToASingleCustomer && $cart->id_customer !== $voucherCustomerId && $voucherIsEmptyCode) { - return false; - } - - return !array_key_exists($discount['id_cart_rule'], $cartRulesIds); - }); - - return [ - 'products' => $products, - 'totals' => $totals, - 'subtotals' => $subtotals, - 'products_count' => $products_count, - 'summary_string' => $summary_string, - 'labels' => $labels, - 'id_address_delivery' => $cart->id_address_delivery, - 'id_address_invoice' => $cart->id_address_invoice, - 'is_virtual' => $cart->isVirtualCart(), - 'vouchers' => $vouchers, - 'discounts' => $discounts, - 'minimalPurchase' => $minimalPurchase, - 'minimalPurchaseRequired' => ($productsTotalExcludingTax < $minimalPurchase) ? - $this->translator->trans( - 'A minimum shopping cart total of %amount% (tax excl.) is required to validate your order. Current cart total is %total% (tax excl.).', - [ - '%amount%' => $this->priceFormatter->format($minimalPurchase), - '%total%' => $this->priceFormatter->format($productsTotalExcludingTax), - ], - 'Shop.Theme.Checkout' - ) : - '', - ]; - } - - /** - * Accepts a cart object with the shipping cost amount and formats the shipping cost display value accordingly. - * If the shipping cost is 0, then we must check if this is because of a free carrier and thus display 'Free' or - * simply because the system was unable to determine shipping cost at this point and thus send an empty string to hide the shipping line. - * - * @param Cart $cart - * @param float $shippingCost - * - * @return string - */ - private function getShippingDisplayValue($cart, $shippingCost) - { - $shippingDisplayValue = ''; - - // if one of the applied cart rules have free shipping, then the shipping display value is 'Free' - foreach ($cart->getCartRules() as $rule) { - if ($rule['free_shipping'] && !$rule['carrier_restriction']) { - return $this->translator->trans('Free', [], 'Shop.Theme.Checkout'); - } - } - - if ($shippingCost != 0) { - $shippingDisplayValue = $this->priceFormatter->format($shippingCost); - } else { - $defaultCountry = null; - - if (isset(Context::getContext()->cookie->id_country)) { - $defaultCountry = new Country(Context::getContext()->cookie->id_country); - } - - $deliveryOptionList = $cart->getDeliveryOptionList($defaultCountry); - - if (isset($deliveryOptionList) && count($deliveryOptionList) > 0) { - foreach ($deliveryOptionList as $option) { - foreach ($option as $currentCarrier) { - if (isset($currentCarrier['is_free']) && $currentCarrier['is_free'] > 0) { - $shippingDisplayValue = $this->translator->trans('Free', [], 'Shop.Theme.Checkout'); - break 2; - } - } - } - } - } - - return $shippingDisplayValue; - } - - private function getTemplateVarVouchers(Cart $cart) - { - $cartVouchers = $cart->getCartRules(); - $vouchers = []; - - $cartHasTax = null === $cart->id ? false : $cart::getTaxesAverageUsed($cart); - $freeShippingAlreadySet = false; - foreach ($cartVouchers as $cartVoucher) { - $vouchers[$cartVoucher['id_cart_rule']]['id_cart_rule'] = $cartVoucher['id_cart_rule']; - $vouchers[$cartVoucher['id_cart_rule']]['name'] = $cartVoucher['name']; - $vouchers[$cartVoucher['id_cart_rule']]['code'] = $cartVoucher['code']; - $vouchers[$cartVoucher['id_cart_rule']]['reduction_percent'] = $cartVoucher['reduction_percent']; - $vouchers[$cartVoucher['id_cart_rule']]['reduction_currency'] = $cartVoucher['reduction_currency']; - - // Voucher reduction depending of the cart tax rule - // if $cartHasTax & voucher is tax excluded, set amount voucher to tax included - if ($cartHasTax && $cartVoucher['reduction_tax'] == '0') { - $cartVoucher['reduction_amount'] = $cartVoucher['reduction_amount'] * (1 + $cartHasTax / 100); - } - - $vouchers[$cartVoucher['id_cart_rule']]['reduction_amount'] = $cartVoucher['reduction_amount']; - - if ($this->cartVoucherHasGiftProductReduction($cartVoucher)) { - $cartVoucher['reduction_amount'] = $cartVoucher['value_real']; - } - - $totalCartVoucherReduction = 0; - - if (!$this->cartVoucherHasPercentReduction($cartVoucher) - && !$this->cartVoucherHasAmountReduction($cartVoucher) - && !$this->cartVoucherHasGiftProductReduction($cartVoucher)) { - $freeShippingOnly = true; - if ($freeShippingAlreadySet) { - unset($vouchers[$cartVoucher['id_cart_rule']]); - continue; - } else { - $freeShippingAlreadySet = true; - } - } else { - $freeShippingOnly = false; - $totalCartVoucherReduction = $this->includeTaxes() ? $cartVoucher['value_real'] : $cartVoucher['value_tax_exc']; - } - - // when a voucher has only a shipping reduction, the value displayed must be "Free Shipping" - if ($freeShippingOnly) { - $cartVoucher['reduction_formatted'] = $this->translator->trans( - 'Free shipping', - [], - 'Admin.Shipping.Feature' - ); - } else { - $cartVoucher['reduction_formatted'] = '-' . $this->priceFormatter->format($totalCartVoucherReduction); - } - $vouchers[$cartVoucher['id_cart_rule']]['reduction_formatted'] = $cartVoucher['reduction_formatted']; - $vouchers[$cartVoucher['id_cart_rule']]['delete_url'] = $this->link->getPageLink( - 'cart', - true, - null, - [ - 'deleteDiscount' => $cartVoucher['id_cart_rule'], - 'token' => Tools::getToken(false), - ] - ); - } - - return [ - 'allowed' => (int) CartRule::isFeatureActive(), - 'added' => $vouchers, - ]; - } - - /** - * @param array $cartVoucher - * - * @return bool - */ - private function cartVoucherHasFreeShipping($cartVoucher) - { - return !empty($cartVoucher['free_shipping']); - } - - /** - * @param array $cartVoucher - * - * @return bool - */ - private function cartVoucherHasPercentReduction($cartVoucher) - { - return isset($cartVoucher['reduction_percent']) - && $cartVoucher['reduction_percent'] > 0 - && $cartVoucher['reduction_amount'] == '0.00'; - } - - /** - * @param array $cartVoucher - * - * @return bool - */ - private function cartVoucherHasAmountReduction($cartVoucher) - { - return isset($cartVoucher['reduction_amount']) && $cartVoucher['reduction_amount'] > 0; - } - - /** - * @param array $cartVoucher - * - * @return bool - */ - private function cartVoucherHasGiftProductReduction($cartVoucher) - { - return !empty($cartVoucher['gift_product']); - } - - /** - * Receives a string containing a list of attributes affected to the product and returns them as an array. - * - * @param string $attributes - * - * @return array Converted attributes in an array - */ - protected function getAttributesArrayFromString($attributes) - { - $separator = Configuration::get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'); - $pattern = '/(?>(?P[^:]+:[^:]+)' . $separator . '+(?!' . $separator . '([^:' . $separator . '])+:))/'; - $attributesArray = []; - $matches = []; - if (!preg_match_all($pattern, $attributes . $separator, $matches)) { - return $attributesArray; - } - - foreach ($matches['attribute'] as $attribute) { - list($key, $value) = explode(':', $attribute); - $attributesArray[trim($key)] = ltrim($value); - } - - return $attributesArray; - } -} diff --git a/src/Adapter/Presenter/Module/ModulePresenter.php b/src/Adapter/Presenter/Module/ModulePresenter.php deleted file mode 100644 index f59ac848..00000000 --- a/src/Adapter/Presenter/Module/ModulePresenter.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Presenter\Module; - -use Currency; -use Exception; -use PrestaShop\PrestaShop\Adapter\Module\Module; -use PrestaShop\PrestaShop\Adapter\Presenter\PresenterInterface; -use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter; -use PrestaShop\PrestaShop\Core\Addon\AddonsCollection; - -class ModulePresenter implements PresenterInterface -{ - /** - * @var Currency - */ - private $currency; - - /** @var PriceFormatter */ - private $priceFormatter; - - public function __construct(Currency $currency, PriceFormatter $priceFormatter) - { - $this->currency = $currency; - $this->priceFormatter = $priceFormatter; - } - - /** - * @param Module $module - * - * @return array - */ - public function present($module) - { - if (!($module instanceof Module)) { - throw new Exception('ModulePresenter can only present instance of Module'); - } - - $attributes = $module->attributes->all(); - $attributes['picos'] = $this->addPicos($attributes); - $attributes['price'] = $this->getModulePrice($attributes['price']); - $attributes['starsRate'] = str_replace('.', '', round($attributes['avgRate'] * 2) / 2); // Round to the nearest 0.5 - - return [ - 'attributes' => $attributes, - 'disk' => $module->disk->all(), - 'database' => $module->database->all(), - ]; - } - - private function getModulePrice($prices) - { - $iso_code = $this->currency->iso_code; - if (array_key_exists($iso_code, $prices)) { - $prices['displayPrice'] = $this->priceFormatter->convertAndFormat($prices[$iso_code]); - $prices['raw'] = $prices[$iso_code]; - } else { - $prices['displayPrice'] = '$' . $prices['USD']; - $prices['raw'] = $prices['USD']; - } - - return $prices; - } - - /** - * Transform a collection of addons as a simple array of data. - * - * @param AddonsCollection|array $modules - * - * @return array - */ - public function presentCollection($modules) - { - $presentedProducts = []; - foreach ($modules as $name => $product) { - $presentedProducts[$name] = $this->present($product); - } - - return $presentedProducts; - } - - /** - * Generate the list of small icons to be displayed near the module name. - * - * @param array $attributes Attributes of presented module - * - * @return array - */ - private function addPicos(array $attributes) - { - $picos = []; - - // PrestaTrust display - if (!empty($attributes['prestatrust']) && !empty($attributes['prestatrust']->pico)) { - $text = ''; - $class = ''; - if (isset($attributes['prestatrust']->status)) { - $text = $attributes['prestatrust']->status ? 'OK' : 'KO'; - $class = $attributes['prestatrust']->status ? 'text-success' : 'text-warning'; - } - $picos['prestatrust'] = [ - 'img' => $attributes['prestatrust']->pico, - 'label' => 'prestatrust', - 'text' => $text, - 'class' => $class, - ]; - } - - return $picos; - } -} diff --git a/src/Adapter/Presenter/Object/ObjectPresenter.php b/src/Adapter/Presenter/Object/ObjectPresenter.php deleted file mode 100644 index ccbf27c3..00000000 --- a/src/Adapter/Presenter/Object/ObjectPresenter.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Presenter\Object; - -use Exception; -use Hook; -use ObjectModel; -use PrestaShop\PrestaShop\Adapter\Presenter\PresenterInterface; - -class ObjectPresenter implements PresenterInterface -{ - /** - * @param ObjectModel $object - * - * @return array - * - * @throws Exception - */ - public function present($object) - { - if (!($object instanceof ObjectModel)) { - throw new Exception('ObjectPresenter can only present ObjectModel classes'); - } - - $presentedObject = []; - - $fields = $object::$definition['fields']; - foreach ($fields as $fieldName => $null) { - $presentedObject[$fieldName] = $object->{$fieldName}; - } - $presentedObject['id'] = $object->id; - - $mustRemove = ['deleted', 'active']; - foreach ($mustRemove as $fieldName) { - if (isset($presentedObject[$fieldName])) { - unset($presentedObject[$fieldName]); - } - } - - $this->filterHtmlContent($object::$definition['table'], $presentedObject, $object->getHtmlFields()); - - return $presentedObject; - } - - /** - * Execute filterHtml hook for html Content for objectPresenter. - * - * @param $type - * @param $presentedObject - * @param $htmlFields - */ - private function filterHtmlContent($type, &$presentedObject, $htmlFields) - { - if (!empty($htmlFields) && is_array($htmlFields)) { - $filteredHtml = Hook::exec( - 'filterHtmlContent', - [ - 'type' => $type, - 'htmlFields' => $htmlFields, - 'object' => $presentedObject, - ], - null, - false, - true, - false, - null, - true - ); - - if (!empty($filteredHtml['object'])) { - $presentedObject = $filteredHtml['object']; - } - } - } -} diff --git a/src/Adapter/Presenter/Order/OrderDetailLazyArray.php b/src/Adapter/Presenter/Order/OrderDetailLazyArray.php deleted file mode 100644 index 04704be1..00000000 --- a/src/Adapter/Presenter/Order/OrderDetailLazyArray.php +++ /dev/null @@ -1,257 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Presenter\Order; - -use Cart; -use Configuration; -use Context; -use Currency; -use HistoryController; -use Order; -use PrestaShop\PrestaShop\Adapter\Presenter\AbstractLazyArray; -use PrestaShop\PrestaShop\Core\Localization\Locale; -use PrestaShopBundle\Translation\TranslatorComponent; -use PrestaShopException; -use Tools; - -class OrderDetailLazyArray extends AbstractLazyArray -{ - /** - * @var Locale - */ - private $locale; - - /** - * @var Order - */ - private $order; - - /** - * @var Context - */ - private $context; - - /** - * @var TranslatorComponent - */ - private $translator; - - /** - * OrderDetailLazyArray constructor. - * - * @param Order $order - */ - public function __construct(Order $order) - { - $this->order = $order; - $this->context = Context::getContext(); - $this->translator = Context::getContext()->getTranslator(); - $this->locale = $this->context->getCurrentLocale(); - parent::__construct(); - } - - /** - * @arrayAccess - * - * @return int - */ - public function getId() - { - return $this->order->id; - } - - /** - * @arrayAccess - * - * @return string - */ - public function getReference() - { - return $this->order->reference; - } - - /** - * @arrayAccess - * - * @return string - * - * @throws PrestaShopException - */ - public function getOrderDate() - { - return Tools::displayDate($this->order->date_add, null, false); - } - - /** - * @arrayAccess - * - * @return string - */ - public function getDetailsUrl() - { - return $this->context->link->getPageLink('order-detail', true, null, 'id_order=' . $this->order->id); - } - - /** - * @arrayAccess - * - * @return mixed - */ - public function getReorderUrl() - { - return HistoryController::getUrlToReorder((int) $this->order->id, $this->context); - } - - /** - * @arrayAccess - * - * @return mixed - */ - public function getInvoiceUrl() - { - return HistoryController::getUrlToInvoice($this->order, $this->context); - } - - /** - * @arrayAccess - * - * @return string - */ - public function getGiftMessage() - { - return nl2br($this->order->gift_message); - } - - /** - * @arrayAccess - * - * @return int - */ - public function getIsReturnable() - { - return (int) $this->order->isReturnable(); - } - - /** - * @arrayAccess - * - * @return string - */ - public function getPayment() - { - return $this->order->payment; - } - - /** - * @arrayAccess - * - * @return string - */ - public function getModule() - { - return $this->order->module; - } - - /** - * @arrayAccess - * - * @return bool - */ - public function getRecyclable() - { - return (bool) $this->order->recyclable; - } - - /** - * @arrayAccess - * - * @return bool - */ - public function getIsValid() - { - return $this->order->valid; - } - - /** - * @arrayAccess - * - * @return bool - */ - public function getIsVirtual() - { - $cart = new Cart($this->order->id_cart); - - return $cart->isVirtualCart(); - } - - /** - * @arrayAccess - * - * @return array - */ - public function getShipping() - { - $order = $this->order; - - $shippingList = $order->getShipping(); - $orderShipping = []; - - foreach ($shippingList as $shippingId => $shipping) { - if (isset($shipping['carrier_name']) && $shipping['carrier_name']) { - $orderShipping[$shippingId] = $shipping; - $orderShipping[$shippingId]['shipping_date'] = - Tools::displayDate($shipping['date_add'], null, false); - $orderShipping[$shippingId]['shipping_weight'] = - ($shipping['weight'] > 0) ? sprintf('%.3f', $shipping['weight']) . ' ' . - Configuration::get('PS_WEIGHT_UNIT') : '-'; - $shippingCost = - (!$order->getTaxCalculationMethod()) ? $shipping['shipping_cost_tax_excl'] - : $shipping['shipping_cost_tax_incl']; - $orderShipping[$shippingId]['shipping_cost'] = - ($shippingCost > 0) ? $this->locale->formatPrice($shippingCost, (Currency::getIsoCodeById((int) $order->id_currency))) - : $this->translator->trans('Free', [], 'Shop.Theme.Checkout'); - - $tracking_line = '-'; - if ($shipping['tracking_number']) { - if ($shipping['url'] && $shipping['tracking_number']) { - $tracking_line = '' . $shipping['tracking_number'] . ''; - } else { - $tracking_line = $shipping['tracking_number']; - } - } - - $orderShipping[$shippingId]['tracking'] = $tracking_line; - } - } - - return $orderShipping; - } -} diff --git a/src/Adapter/Presenter/Order/OrderLazyArray.php b/src/Adapter/Presenter/Order/OrderLazyArray.php deleted file mode 100644 index 85c54e19..00000000 --- a/src/Adapter/Presenter/Order/OrderLazyArray.php +++ /dev/null @@ -1,463 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Presenter\Order; - -use Address; -use AddressFormat; -use Carrier; -use Cart; -use Configuration; -use Context; -use Currency; -use CustomerMessage; -use Doctrine\Common\Annotations\AnnotationException; -use Order; -use OrderReturn; -use PrestaShop\PrestaShop\Adapter\Presenter\AbstractLazyArray; -use PrestaShop\PrestaShop\Adapter\Presenter\Cart\CartPresenter; -use PrestaShop\PrestaShop\Adapter\Presenter\Object\ObjectPresenter; -use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter; -use PrestaShopBundle\Translation\TranslatorComponent; -use PrestaShopException; -use ProductDownload; -use ReflectionException; -use TaxConfiguration; -use Tools; - -class OrderLazyArray extends AbstractLazyArray -{ - /** @var CartPresenter */ - private $cartPresenter; - - /** @var ObjectPresenter */ - private $objectPresenter; - - /** @var PriceFormatter */ - private $priceFormatter; - - /** @var TranslatorComponent */ - private $translator; - - /** @var TaxConfiguration */ - private $taxConfiguration; - - /** @var Order */ - private $order; - - /** @var OrderSubtotalLazyArray */ - private $subTotals; - - /** - * OrderArray constructor. - * - * @throws AnnotationException - * @throws ReflectionException - */ - public function __construct(Order $order) - { - $this->order = $order; - $this->cartPresenter = new CartPresenter(); - $this->objectPresenter = new ObjectPresenter(); - $this->priceFormatter = new PriceFormatter(); - $this->translator = Context::getContext()->getTranslator(); - $this->taxConfiguration = new TaxConfiguration(); - $this->subTotals = new OrderSubtotalLazyArray($this->order); - parent::__construct(); - } - - /** - * @arrayAccess - * - * @return mixed - */ - public function getTotals() - { - $amounts = $this->getAmounts(); - - return $amounts['totals']; - } - - /** - * @arrayAccess - * - * @return int - */ - public function getIdAddressInvoice() - { - return $this->order->id_address_invoice; - } - - /** - * @arrayAccess - * - * @return int - */ - public function getIdAddressDelivery() - { - return $this->order->id_address_delivery; - } - - /** - * @arrayAccess - * - * @return mixed - */ - public function getSubtotals() - { - return $this->subTotals; - } - - /** - * @arrayAccess - * - * @return int - */ - public function getProductsCount() - { - return count($this->getProducts()); - } - - /** - * @arrayAccess - * - * @return mixed - * - * @throws PrestaShopException - */ - public function getShipping() - { - $details = $this->getDetails(); - - return $details['shipping']; - } - - /** - * @arrayAccess - * - * @return array - */ - public function getProducts() - { - $order = $this->order; - $cart = new Cart($order->id_cart); - - $orderProducts = $order->getProducts(); - $cartProducts = $this->cartPresenter->present($cart); - $orderPaid = $order->getCurrentOrderState() && $order->getCurrentOrderState()->paid; - - $includeTaxes = $this->includeTaxes(); - foreach ($orderProducts as &$orderProduct) { - // Use data from OrderDetail in case that the Product has been deleted - $orderProduct['name'] = $orderProduct['product_name']; - $orderProduct['quantity'] = $orderProduct['product_quantity']; - $orderProduct['id_product'] = $orderProduct['product_id']; - $orderProduct['id_product_attribute'] = $orderProduct['product_attribute_id']; - - $productPrice = $includeTaxes ? 'product_price_wt' : 'product_price'; - $totalPrice = $includeTaxes ? 'total_wt' : 'total_price'; - - $orderProduct['price'] = $this->priceFormatter->format( - $orderProduct[$productPrice], - Currency::getCurrencyInstance((int) $order->id_currency) - ); - $orderProduct['total'] = $this->priceFormatter->format( - $orderProduct[$totalPrice], - Currency::getCurrencyInstance((int) $order->id_currency) - ); - - if ($orderPaid && $orderProduct['is_virtual']) { - $id_product_download = ProductDownload::getIdFromIdProduct($orderProduct['product_id']); - $product_download = new ProductDownload($id_product_download); - if ($product_download->display_filename != '') { - $orderProduct['download_link'] = - $product_download->getTextLink(false, $orderProduct['download_hash']) - . '&id_order=' . (int) $order->id - . '&secure_key=' . $order->secure_key; - } - } - - foreach ($cartProducts['products'] as $cartProduct) { - if (($cartProduct['id_product'] === $orderProduct['id_product']) - && ($cartProduct['id_product_attribute'] === $orderProduct['id_product_attribute'])) { - if (isset($cartProduct['attributes'])) { - $orderProduct['attributes'] = $cartProduct['attributes']; - } else { - $orderProduct['attributes'] = []; - } - $orderProduct['cover'] = $cartProduct['cover']; - $orderProduct['unit_price_full'] = $cartProduct['unit_price_full']; - } - } - - OrderReturn::addReturnedQuantity($orderProducts, $order->id); - } - - $orderProducts = $this->cartPresenter->addCustomizedData($orderProducts, $cart); - - return $orderProducts; - } - - /** - * @arrayAccess - * - * @return array - */ - public function getAmounts() - { - $order = $this->order; - - $amounts['subtotals'] = $this->subTotals; - - $amounts['totals'] = []; - $amount = $this->includeTaxes() ? $order->total_paid : $order->total_paid_tax_excl; - $amounts['totals']['total'] = [ - 'type' => 'total', - 'label' => $this->translator->trans('Total', [], 'Shop.Theme.Checkout'), - 'amount' => $amount, - 'value' => $this->priceFormatter->format($amount, Currency::getCurrencyInstance((int) $order->id_currency)), - ]; - - $amounts['totals']['total_paid'] = [ - 'type' => 'total_paid', - 'label' => $this->translator->trans('Total paid', [], 'Shop.Theme.Checkout'), - 'amount' => $order->total_paid_real, - 'value' => $this->priceFormatter->format( - $order->total_paid_real, - Currency::getCurrencyInstance((int) $order->id_currency) - ), - ]; - - $amounts['totals']['total_including_tax'] = [ - 'type' => 'total_including_tax', - 'label' => $this->translator->trans('Total (tax incl.)', [], 'Shop.Theme.Checkout'), - 'amount' => $order->total_paid_tax_incl, - 'value' => $this->priceFormatter->format( - $order->total_paid_tax_incl, - Currency::getCurrencyInstance((int) $order->id_currency) - ), - ]; - - $amounts['totals']['total_excluding_tax'] = [ - 'type' => 'total_excluding_tax', - 'label' => $this->translator->trans('Total (tax excl.)', [], 'Shop.Theme.Checkout'), - 'amount' => $order->total_paid_tax_excl, - 'value' => $this->priceFormatter->format( - $order->total_paid_tax_excl, - Currency::getCurrencyInstance((int) $order->id_currency) - ), - ]; - - return $amounts; - } - - /** - * @arrayAccess - * - * @return OrderDetailLazyArray - */ - public function getDetails() - { - return new OrderDetailLazyArray($this->order); - } - - /** - * @arrayAccess - * - * @return array - */ - public function getHistory() - { - $order = $this->order; - - $orderHistory = []; - $context = Context::getContext(); - $historyList = $order->getHistory($context->language->id, false, true); - - foreach ($historyList as $historyId => $history) { - if ($history['id_order_state'] == $order->current_state) { - $historyId = 'current'; - } - $orderHistory[$historyId] = $history; - $orderHistory[$historyId]['history_date'] = Tools::displayDate($history['date_add'], null, false); - $orderHistory[$historyId]['contrast'] = (Tools::getBrightness($history['color']) > 128) ? 'dark' : 'bright'; - } - - if (!isset($orderHistory['current'])) { - $orderHistory['current'] = $this->getDefaultHistory(); - } - - return $orderHistory; - } - - /** - * @arrayAccess - * - * @return array - */ - public function getMessages() - { - $order = $this->order; - - $messages = []; - $customerMessages = CustomerMessage::getMessagesByOrderId((int) $order->id, false); - - foreach ($customerMessages as $cmId => $customerMessage) { - $messages[$cmId] = $customerMessage; - $messages[$cmId]['message'] = nl2br($customerMessage['message']); - $messages[$cmId]['message_date'] = Tools::displayDate($customerMessage['date_add'], null, true); - if (isset($customerMessage['elastname']) && $customerMessage['elastname']) { - $messages[$cmId]['name'] = $customerMessage['efirstname'] . ' ' . $customerMessage['elastname']; - } elseif ($customerMessage['clastname']) { - $messages[$cmId]['name'] = $customerMessage['cfirstname'] . ' ' . $customerMessage['clastname']; - } else { - $messages[$cmId]['name'] = Configuration::get('PS_SHOP_NAME'); - } - } - - return $messages; - } - - /** - * @arrayAccess - * - * @return array - */ - public function getCarrier() - { - $order = $this->order; - - $carrier = new Carrier((int) $order->id_carrier, (int) $order->id_lang); - $orderCarrier = $this->objectPresenter->present($carrier); - $orderCarrier['name'] = ($carrier->name == '0') ? Configuration::get('PS_SHOP_NAME') : $carrier->name; - $orderCarrier['delay'] = $carrier->delay; - - return $orderCarrier; - } - - /** - * @arrayAccess - * - * @return array - */ - public function getAddresses() - { - $order = $this->order; - - $orderAddresses = [ - 'delivery' => [], - 'invoice' => [], - ]; - - $addressDelivery = new Address((int) $order->id_address_delivery); - $addressInvoice = new Address((int) $order->id_address_invoice); - - if (!$order->isVirtual()) { - $orderAddresses['delivery'] = $this->objectPresenter->present($addressDelivery); - $orderAddresses['delivery']['formatted'] = - AddressFormat::generateAddress($addressDelivery, [], '
    '); - } - - $orderAddresses['invoice'] = $this->objectPresenter->present($addressInvoice); - $orderAddresses['invoice']['formatted'] = AddressFormat::generateAddress($addressInvoice, [], '
    '); - - return $orderAddresses; - } - - /** - * @arrayAccess - * - * @return string - */ - public function getFollowUp() - { - $order = $this->order; - - $carrier = $this->getCarrier(); - if (!empty($carrier['url']) && !empty($order->shipping_number)) { - return str_replace('@', $order->shipping_number, $carrier['url']); - } - - return ''; - } - - /** - * @arrayAccess - * - * @return array - */ - public function getLabels() - { - return [ - 'tax_short' => ($this->includeTaxes()) - ? $this->translator->trans('(tax incl.)', [], 'Shop.Theme.Global') - : $this->translator->trans('(tax excl.)', [], 'Shop.Theme.Global'), - 'tax_long' => ($this->includeTaxes()) - ? $this->translator->trans('(tax included)', [], 'Shop.Theme.Global') - : $this->translator->trans('(tax excluded)', [], 'Shop.Theme.Global'), - ]; - } - - /** - * @return bool|mixed - */ - private function includeTaxes() - { - return $this->taxConfiguration->includeTaxes(); - } - - /** - * @return array - */ - private function getDefaultHistory() - { - return [ - 'id_order_state' => '', - 'invoice' => '', - 'send_email' => '', - 'module_name' => '', - 'color' => '', - 'unremovable' => '', - 'hidden' => '', - 'logable' => '', - 'delivery' => '', - 'shipped' => '', - 'paid' => '', - 'pdf_invoice' => '', - 'pdf_delivery' => '', - 'deleted' => '', - 'id_order_history' => '', - 'id_employee' => '', - 'id_order' => '', - 'date_add' => '', - 'employee_firstname' => '', - 'employee_lastname' => '', - 'ostate_name' => '', - 'history_date' => '', - 'contrast' => '', - ]; - } -} diff --git a/src/Adapter/Presenter/Order/OrderPresenter.php b/src/Adapter/Presenter/Order/OrderPresenter.php deleted file mode 100644 index 1c2c49bd..00000000 --- a/src/Adapter/Presenter/Order/OrderPresenter.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Presenter\Order; - -use Exception; -use Order; -use PrestaShop\PrestaShop\Adapter\Presenter\PresenterInterface; - -class OrderPresenter implements PresenterInterface -{ - /** - * @param Order $order - * - * @return OrderLazyArray - * - * @throws Exception - */ - public function present($order) - { - if (!($order instanceof Order)) { - throw new Exception('OrderPresenter can only present instance of Order'); - } - - return new OrderLazyArray($order); - } -} diff --git a/src/Adapter/Presenter/Order/OrderReturnLazyArray.php b/src/Adapter/Presenter/Order/OrderReturnLazyArray.php deleted file mode 100644 index e92d966f..00000000 --- a/src/Adapter/Presenter/Order/OrderReturnLazyArray.php +++ /dev/null @@ -1,145 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Presenter\Order; - -use Link; -use PrestaShop\PrestaShop\Adapter\Presenter\AbstractLazyArray; -use PrestaShopException; -use Tools; - -class OrderReturnLazyArray extends AbstractLazyArray -{ - /** - * @var string - */ - private $prefix; - - /** - * @var Link - */ - private $link; - - /** @var array */ - private $orderReturn; - - /** - * OrderReturnLazyArray constructor. - * - * @param string $prefix - * @param Link $link - * @param array $orderReturn - * - * @throws \ReflectionException - */ - public function __construct($prefix, Link $link, array $orderReturn) - { - $this->prefix = $prefix; - $this->link = $link; - $this->orderReturn = $orderReturn; - parent::__construct(); - $this->appendArray($orderReturn); - } - - /** - * @arrayAccess - * - * @return mixed - */ - public function getId() - { - return $this->orderReturn['id_order_return']; - } - - /** - * @arrayAccess - * - * @return string - */ - public function getDetailsUrl() - { - return $this->link->getPageLink( - 'order-detail', - true, - null, - 'id_order=' . (int) $this->orderReturn['id_order'] - ); - } - - /** - * @arrayAccess - * - * @return string - */ - public function getReturnUrl() - { - return $this->link->getPageLink( - 'order-return', - true, - null, - 'id_order_return=' . (int) $this->orderReturn['id_order_return'] - ); - } - - /** - * @arrayAccess - * - * @return string - */ - public function getReturnNumber() - { - return $this->prefix . sprintf('%06d', $this->orderReturn['id_order_return']); - } - - /** - * @arrayAccess - * - * @return string - * - * @throws PrestaShopException - */ - public function getReturnDate() - { - return Tools::displayDate($this->orderReturn['date_add'], null, false); - } - - /** - * @arrayAccess - * - * @return string - */ - public function getPrintUrl() - { - return ($this->orderReturn['state'] == 2) - ? $this->link->getPageLink( - 'pdf-order-return', - true, - null, - 'id_order_return=' . (int) $this->orderReturn['id_order_return'] - ) - : ''; - } -} diff --git a/src/Adapter/Presenter/Order/OrderReturnPresenter.php b/src/Adapter/Presenter/Order/OrderReturnPresenter.php deleted file mode 100644 index f036f886..00000000 --- a/src/Adapter/Presenter/Order/OrderReturnPresenter.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Presenter\Order; - -use Exception; -use Link; -use PrestaShop\PrestaShop\Adapter\Presenter\PresenterInterface; - -class OrderReturnPresenter implements PresenterInterface -{ - /** - * @var string - */ - private $prefix; - - /** - * @var Link - */ - private $link; - - /** - * OrderReturnPresenter constructor. - * - * @param $prefix - * @param Link $link - */ - public function __construct($prefix, Link $link) - { - $this->prefix = $prefix; - $this->link = $link; - } - - /** - * @param $orderReturn - * - * @return OrderReturnLazyArray - * - * @throws \ReflectionException - */ - public function present($orderReturn) - { - if (!is_array($orderReturn)) { - throw new Exception('orderReturnPresenter can only present order_return passed as array'); - } - - return new OrderReturnLazyArray($this->prefix, $this->link, $orderReturn); - } -} diff --git a/src/Adapter/Presenter/Order/OrderSubtotalLazyArray.php b/src/Adapter/Presenter/Order/OrderSubtotalLazyArray.php deleted file mode 100644 index 4e033b4e..00000000 --- a/src/Adapter/Presenter/Order/OrderSubtotalLazyArray.php +++ /dev/null @@ -1,224 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Presenter\Order; - -use Cart; -use Configuration; -use Context; -use Currency; -use Order; -use PrestaShop\PrestaShop\Adapter\Presenter\AbstractLazyArray; -use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter; -use PrestaShopBundle\Translation\TranslatorComponent; -use TaxConfiguration; - -class OrderSubtotalLazyArray extends AbstractLazyArray -{ - /** @var Order */ - private $order; - - /** @var Context */ - private $context; - - /** @var TaxConfiguration */ - private $taxConfiguration; - - /** @var PriceFormatter */ - private $priceFormatter; - - /** @var bool */ - private $includeTaxes; - - /** @var TranslatorComponent */ - private $translator; - - /** - * OrderSubtotalLazyArray constructor. - * - * @param Order $order - */ - public function __construct(Order $order) - { - $this->context = Context::getContext(); - $this->taxConfiguration = new TaxConfiguration(); - $this->includeTaxes = $this->includeTaxes(); - $this->priceFormatter = new PriceFormatter(); - $this->translator = Context::getContext()->getTranslator(); - $this->order = $order; - parent::__construct(); - } - - /** - * @arrayAccess - * - * @return array - */ - public function getProducts() - { - $totalProducts = ($this->includeTaxes) ? $this->order->total_products_wt : $this->order->total_products; - - return [ - 'type' => 'products', - 'label' => $this->translator->trans('Subtotal', [], 'Shop.Theme.Checkout'), - 'amount' => $totalProducts, - 'value' => $this->priceFormatter->format( - $totalProducts, - Currency::getCurrencyInstance((int) $this->order->id_currency) - ), - ]; - } - - /** - * @arrayAccess - * - * @return array - */ - public function getDiscounts() - { - $discountAmount = ($this->includeTaxes) - ? $this->order->total_discounts_tax_incl - : $this->order->total_discounts_tax_excl; - if ((float) $discountAmount) { - return [ - 'type' => 'discount', - 'label' => $this->translator->trans('Discount', [], 'Shop.Theme.Checkout'), - 'amount' => $discountAmount, - 'value' => $this->priceFormatter->format( - $discountAmount, - Currency::getCurrencyInstance((int) $this->order->id_currency) - ), - ]; - } - - return [ - 'type' => 'discount', - 'label' => null, - 'amount' => null, - 'value' => '', - ]; - } - - /** - * @arrayAccess - * - * @return array - */ - public function getShipping() - { - $cart = new Cart($this->order->id_cart); - if (!$cart->isVirtualCart()) { - $shippingCost = ($this->includeTaxes) - ? $this->order->total_shipping_tax_incl : $this->order->total_shipping_tax_excl; - - return [ - 'type' => 'shipping', - 'label' => $this->translator->trans('Shipping and handling', [], 'Shop.Theme.Checkout'), - 'amount' => $shippingCost, - 'value' => $shippingCost != 0 ? $this->priceFormatter->format( - $shippingCost, - Currency::getCurrencyInstance((int) $this->order->id_currency) - ) - : $this->translator->trans('Free', [], 'Shop.Theme.Checkout'), - ]; - } - - return [ - 'type' => 'shipping', - 'label' => null, - 'amount' => null, - 'value' => '', - ]; - } - - /** - * @arrayAccess - * - * @return array - */ - public function getTax() - { - if (!Configuration::get('PS_TAX_DISPLAY')) { - return [ - 'type' => 'tax', - 'label' => null, - 'amount' => null, - 'value' => '', - ]; - } - - $tax = $this->order->total_paid_tax_incl - $this->order->total_paid_tax_excl; - - return [ - 'type' => 'tax', - 'label' => $this->translator->trans('Tax', [], 'Shop.Theme.Checkout'), - 'amount' => $tax, - 'value' => $this->priceFormatter->format( - $tax, - Currency::getCurrencyInstance((int) $this->order->id_currency) - ), - ]; - } - - /** - * @arrayAccess - * - * @return array - */ - public function getGiftWrapping() - { - if ($this->order->gift) { - $giftWrapping = ($this->includeTaxes) - ? $this->order->total_wrapping_tax_incl - : $this->order->total_wrapping_tax_excl; - - return [ - 'type' => 'gift_wrapping', - 'label' => $this->translator->trans('Gift wrapping', [], 'Shop.Theme.Checkout'), - 'amount' => $giftWrapping, - 'value' => $this->priceFormatter->format( - $giftWrapping, - Currency::getCurrencyInstance((int) $this->order->id_currency) - ), - ]; - } - - return [ - 'type' => 'gift_wrapping', - 'label' => null, - 'amount' => null, - 'value' => '', - ]; - } - - /** - * @return bool - */ - private function includeTaxes() - { - return $this->taxConfiguration->includeTaxes(); - } -} diff --git a/src/Adapter/Presenter/PresenterInterface.php b/src/Adapter/Presenter/PresenterInterface.php deleted file mode 100644 index db13d403..00000000 --- a/src/Adapter/Presenter/PresenterInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Presenter; - -interface PresenterInterface -{ - /** - * @param mixed $object - * - * @return array|AbstractLazyArray - */ - public function present($object); -} diff --git a/src/Adapter/Presenter/Product/ProductLazyArray.php b/src/Adapter/Presenter/Product/ProductLazyArray.php deleted file mode 100644 index 3038bd16..00000000 --- a/src/Adapter/Presenter/Product/ProductLazyArray.php +++ /dev/null @@ -1,1050 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Presenter\Product; - -use Configuration; -use Hook; -use Language; -use Link; -use PrestaShop\Decimal\Number; -use PrestaShop\Decimal\Operation\Rounding; -use PrestaShop\PrestaShop\Adapter\Image\ImageRetriever; -use PrestaShop\PrestaShop\Adapter\Presenter\AbstractLazyArray; -use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter; -use PrestaShop\PrestaShop\Adapter\Product\ProductColorsRetriever; -use PrestaShop\PrestaShop\Core\Product\ProductPresentationSettings; -use Product; -use Symfony\Component\Translation\Exception\InvalidArgumentException; -use Symfony\Component\Translation\TranslatorInterface; -use Tools; - -class ProductLazyArray extends AbstractLazyArray -{ - /** - * @var ImageRetriever - */ - private $imageRetriever; - - /** - * @var Link - */ - private $link; - - /** - * @var PriceFormatter - */ - private $priceFormatter; - - /** - * @var ProductColorsRetriever - */ - private $productColorsRetriever; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ProductPresentationSettings - */ - protected $settings; - - /** - * @var array - */ - protected $product; - - /** - * @var Language - */ - private $language; - - public function __construct( - ProductPresentationSettings $settings, - array $product, - Language $language, - ImageRetriever $imageRetriever, - Link $link, - PriceFormatter $priceFormatter, - ProductColorsRetriever $productColorsRetriever, - TranslatorInterface $translator - ) { - $this->settings = $settings; - $this->product = $product; - $this->language = $language; - $this->imageRetriever = $imageRetriever; - $this->link = $link; - $this->priceFormatter = $priceFormatter; - $this->productColorsRetriever = $productColorsRetriever; - $this->translator = $translator; - - $this->fillImages( - $settings, - $product, - $language - ); - - $this->addPriceInformation( - $settings, - $product, - $language - ); - - $this->addQuantityInformation( - $settings, - $product, - $language - ); - - parent::__construct(); - $this->appendArray($this->product); - } - - /** - * @arrayAccess - * - * @return mixed - */ - public function getId() - { - return $this->product['id_product']; - } - - /** - * @arrayAccess - * - * @return array|mixed - */ - public function getAttributes() - { - if (isset($this->product['attributes'])) { - return $this->product['attributes']; - } - - return []; - } - - /** - * @arrayAccess - * - * @return bool - */ - public function getShowPrice() - { - return $this->shouldShowPrice($this->settings, $this->product); - } - - /** - * @arrayAccess - * - * @return string - */ - public function getWeightUnit() - { - return Configuration::get('PS_WEIGHT_UNIT'); - } - - /** - * @arrayAccess - * - * @return string - */ - public function getUrl() - { - return $this->getProductURL($this->product, $this->language); - } - - /** - * @arrayAccess - * - * @return string - */ - public function getCanonicalUrl() - { - return $this->getProductURL($this->product, $this->language, true); - } - - /** - * @arrayAccess - * - * @return string|null - */ - public function getAddToCartUrl() - { - if ($this->shouldEnableAddToCartButton($this->product, $this->settings)) { - return $this->link->getAddToCartURL( - $this->product['id_product'], - $this->product['id_product_attribute'] - ); - } - - return null; - } - - /** - * @arrayAccess - * - * @return array|bool - * - * @throws InvalidArgumentException - */ - public function getCondition() - { - if (empty($this->product['show_condition'])) { - return false; - } - - switch ($this->product['condition']) { - case 'new': - return [ - 'type' => 'new', - 'label' => $this->translator->trans('New product', [], 'Shop.Theme.Catalog'), - 'schema_url' => 'https://schema.org/NewCondition', - ]; - case 'used': - return [ - 'type' => 'used', - 'label' => $this->translator->trans('Used', [], 'Shop.Theme.Catalog'), - 'schema_url' => 'https://schema.org/UsedCondition', - ]; - - break; - case 'refurbished': - return [ - 'type' => 'refurbished', - 'label' => $this->translator->trans('Refurbished', [], 'Shop.Theme.Catalog'), - 'schema_url' => 'https://schema.org/RefurbishedCondition', - ]; - - break; - default: - return false; - } - } - - /** - * @arrayAccess - * - * @return string|null - */ - public function getDeliveryInformation() - { - if ($this->product['quantity'] > 0) { - return Configuration::get('PS_LABEL_DELIVERY_TIME_AVAILABLE', $this->language->id); - } elseif ($this->product['allow_oosp']) { - return Configuration::get('PS_LABEL_DELIVERY_TIME_OOSBOA', $this->language->id); - } - - return null; - } - - /** - * @arrayAccess - * - * @return array - */ - public function getEmbeddedAttributes() - { - $whitelist = $this->getProductAttributeWhitelist(); - $embeddedProductAttributes = []; - foreach ($this->product as $attribute => $value) { - if (in_array($attribute, $whitelist)) { - $embeddedProductAttributes[$attribute] = $value; - } - } - - return $embeddedProductAttributes; - } - - /** - * @arrayAccess - * - * @return string|null - */ - public function getFileSizeFormatted() - { - if (!isset($this->product['attachments'])) { - return null; - } - foreach ($this->product['attachments'] as &$attachment) { - return Tools::formatBytes($attachment['file_size'], 2); - } - - return null; - } - - /** - * @arrayAccess - * - * @return array - * - * @throws \ReflectionException - */ - public function getAttachments() - { - foreach ($this->product['attachments'] as &$attachment) { - if (!isset($attachment['file_size_formatted'])) { - $attachment['file_size_formatted'] = Tools::formatBytes($attachment['file_size'], 2); - } - } - - return $this->product['attachments']; - } - - /** - * @arrayAccess - * - * @return array|mixed - */ - public function getQuantityDiscounts() - { - return (isset($this->product['quantity_discounts'])) ? $this->product['quantity_discounts'] : []; - } - - /** - * @arrayAccess - * - * @return mixed|null - */ - public function getReferenceToDisplay() - { - if (isset($this->product['attributes'])) { - foreach ($this->product['attributes'] as $attribute) { - if (isset($attribute['reference']) && $attribute['reference'] != null) { - return $attribute['reference']; - } - } - } - - if ('' !== $this->product['reference']) { - return $this->product['reference']; - } - - return null; - } - - /** - * @arrayAccess - * - * @return array|null - */ - public function getGroupedFeatures() - { - if ($this->product['features']) { - return $this->buildGroupedFeatures($this->product['features']); - } - - return null; - } - - /** - * @arrayAccess - * - * @return string - */ - public function getSeoAvailability() - { - $seoAvailability = 'https://schema.org/'; - if ($this->product['quantity'] > 0) { - $seoAvailability .= 'InStock'; - } elseif ($this->product['quantity'] <= 0 && $this->product['allow_oosp']) { - $seoAvailability .= 'PreOrder'; - } else { - $seoAvailability .= 'OutOfStock'; - } - - return $seoAvailability; - } - - /** - * @arrayAccess - * - * @return array - * - * @throws InvalidArgumentException - */ - public function getLabels() - { - return [ - 'tax_short' => ($this->settings->include_taxes) - ? $this->translator->trans('(tax incl.)', [], 'Shop.Theme.Global') - : $this->translator->trans('(tax excl.)', [], 'Shop.Theme.Global'), - 'tax_long' => ($this->settings->include_taxes) - ? $this->translator->trans('Tax included', [], 'Shop.Theme.Global') - : $this->translator->trans('Tax excluded', [], 'Shop.Theme.Global'), - ]; - } - - /** - * @arrayAccess - * - * @return array|null - */ - public function getEcotax() - { - if (isset($this->product['ecotax'])) { - return [ - 'value' => $this->priceFormatter->format($this->product['ecotax']), - 'amount' => $this->product['ecotax'], - 'rate' => $this->product['ecotax_rate'], - ]; - } - - return null; - } - - /** - * @arrayAccess - * - * @return array - * - * @throws InvalidArgumentException - */ - public function getFlags() - { - $flags = []; - - $show_price = $this->shouldShowPrice($this->settings, $this->product); - - if ($show_price && $this->product['online_only']) { - $flags['online-only'] = [ - 'type' => 'online-only', - 'label' => $this->translator->trans('Online only', [], 'Shop.Theme.Catalog'), - ]; - } - - if ($show_price && $this->product['on_sale'] && !$this->settings->catalog_mode) { - $flags['on-sale'] = [ - 'type' => 'on-sale', - 'label' => $this->translator->trans('On sale!', [], 'Shop.Theme.Catalog'), - ]; - } - - if ($show_price && $this->product['reduction']) { - if ($this->product['discount_type'] === 'percentage') { - $flags['discount'] = [ - 'type' => 'discount', - 'label' => $this->product['discount_percentage'], - ]; - } elseif ($this->product['discount_type'] === 'amount') { - $flags['discount'] = [ - 'type' => 'discount', - 'label' => $this->product['discount_amount_to_display'], - ]; - } else { - $flags['discount'] = [ - 'type' => 'discount', - 'label' => $this->translator->trans('Reduced price', [], 'Shop.Theme.Catalog'), - ]; - } - } - - if ($this->product['new']) { - $flags['new'] = [ - 'type' => 'new', - 'label' => $this->translator->trans('New', [], 'Shop.Theme.Catalog'), - ]; - } - - if ($this->product['pack']) { - $flags['pack'] = [ - 'type' => 'pack', - 'label' => $this->translator->trans('Pack', [], 'Shop.Theme.Catalog'), - ]; - } - - Hook::exec('actionProductFlagsModifier', [ - 'flags' => &$flags, - 'product' => $this->product, - ]); - - return $flags; - } - - /** - * @arrayAccess - * - * @return array - */ - public function getMainVariants() - { - $colors = $this->productColorsRetriever->getColoredVariants($this->product['id_product']); - - if (!is_array($colors)) { - return []; - } - - return array_map(function (array $color) { - $color['add_to_cart_url'] = $this->link->getAddToCartURL( - $color['id_product'], - $color['id_product_attribute'] - ); - $color['url'] = $this->getProductURL($color, $this->language); - $color['type'] = 'color'; - $color['html_color_code'] = $color['color']; - unset($color['color']); - - return $color; - }, $colors); - } - - /** - * @arrayAccess - * - * @return 0|null - */ - public function getSpecificReferences() - { - if (isset($this->product['attributes']) && !isset($this->product['cart_quantity'])) { - $specificReferences = array_slice($this->product['attributes'], 0)[0]; - //this attributes should not be displayed in FO - unset( - $specificReferences['id_attribute'], - $specificReferences['id_attribute_group'], - $specificReferences['name'], - $specificReferences['group'], - $specificReferences['reference'] - ); - - //if the attribute's references doesn't exist then get the product's references or unset it - foreach ($specificReferences as $key => $value) { - if (empty($value)) { - $translatedKey = $this->getTranslatedKey($key); - unset($specificReferences[$key]); - if (!empty($this->product[$key])) { - $specificReferences[$translatedKey] = $this->product[$key]; - } - } - } - - if (empty($specificReferences)) { - $specificReferences = null; - } - - return $specificReferences; - } - - return null; - } - - /** - * Prices should be shown for products with active "Show price" option - * and customer groups with active "Show price" option. - * - * @param ProductPresentationSettings $settings - * @param array $product - * - * @return bool - */ - private function shouldShowPrice( - ProductPresentationSettings $settings, - array $product - ) { - return $settings->shouldShowPrice() && (bool) $product['show_price']; - } - - /** - * The "Add to cart" button should be shown for products available for order. - * - * @param $product - * - * @return mixed - */ - private function shouldShowAddToCartButton($product) - { - return (bool) $product['available_for_order']; - } - - private function fillImages( - ProductPresentationSettings $settings, - array $product, - Language $language - ) { - // Get all product images, including potential cover - $productImages = $this->imageRetriever->getAllProductImages( - $product, - $language - ); - - // Get filtered product images matching the specified id_product_attribute - $this->product['images'] = $this->filterImagesForCombination($productImages, $product['id_product_attribute']); - - // Get default image for selected combination (used for product page, cart details, ...) - $this->product['default_image'] = reset($this->product['images']); - foreach ($this->product['images'] as $image) { - // If one of the image is a cover it is used as such - if (isset($image['cover']) && null !== $image['cover']) { - $this->product['default_image'] = $image; - - break; - } - } - - // Get generic product image, used for product listing - if (isset($product['cover_image_id'])) { - // First try to find cover in product images - foreach ($productImages as $productImage) { - if ($productImage['id_image'] == $product['cover_image_id']) { - $this->product['cover'] = $productImage; - break; - } - } - - // If the cover is not associated to the product images it is fetched manually - if (!isset($this->product['cover'])) { - $coverImage = $this->imageRetriever->getImage(new Product($product['id_product'], false, $language->getId()), $product['cover_image_id']); - $this->product['cover'] = array_merge($coverImage, [ - 'legend' => $coverImage['legend'], - ]); - } - } - - // If no cover fallback on default image - if (!isset($this->product['cover'])) { - $this->product['cover'] = $this->product['default_image']; - } - } - - /** - * @param array $images - * @param int $productAttributeId - * - * @return array - */ - private function filterImagesForCombination(array $images, int $productAttributeId) - { - $filteredImages = []; - - foreach ($images as $image) { - if (in_array($productAttributeId, $image['associatedVariants'])) { - $filteredImages[] = $image; - } - } - - return (0 === count($filteredImages)) ? $images : $filteredImages; - } - - private function addPriceInformation( - ProductPresentationSettings $settings, - array $product, - Language $language - ) { - $this->product['has_discount'] = false; - $this->product['discount_type'] = null; - $this->product['discount_percentage'] = null; - $this->product['discount_percentage_absolute'] = null; - $this->product['discount_amount'] = null; - $this->product['discount_amount_to_display'] = null; - - if ($settings->include_taxes) { - $price = $regular_price = $product['price']; - } else { - $price = $regular_price = $product['price_tax_exc']; - } - - if ($product['specific_prices']) { - $this->product['has_discount'] = (0 != $product['reduction']); - $this->product['discount_type'] = $product['specific_prices']['reduction_type']; - - $absoluteReduction = new Number($product['specific_prices']['reduction']); - $absoluteReduction = $absoluteReduction->times(new Number('100')); - $negativeReduction = $absoluteReduction->toNegative(); - $presAbsoluteReduction = $absoluteReduction->round(2, Rounding::ROUND_HALF_UP); - $presNegativeReduction = $negativeReduction->round(2, Rounding::ROUND_HALF_UP); - - // TODO: add percent sign according to locale preferences - $this->product['discount_percentage'] = Tools::displayNumber($presNegativeReduction) . '%'; - $this->product['discount_percentage_absolute'] = Tools::displayNumber($presAbsoluteReduction) . '%'; - if ($settings->include_taxes) { - $regular_price = $product['price_without_reduction']; - $this->product['discount_amount'] = $this->priceFormatter->format( - $product['reduction'] - ); - } else { - $regular_price = $product['price_without_reduction_without_tax']; - $this->product['discount_amount'] = $this->priceFormatter->format( - $product['reduction_without_tax'] - ); - } - $this->product['discount_amount_to_display'] = '-' . $this->product['discount_amount']; - } - - $this->product['price_amount'] = $price; - $this->product['price'] = $this->priceFormatter->format($price); - $this->product['regular_price_amount'] = $regular_price; - $this->product['regular_price'] = $this->priceFormatter->format($regular_price); - - if ($product['reduction'] < $product['price_without_reduction']) { - $this->product['discount_to_display'] = $this->product['discount_amount']; - } else { - $this->product['discount_to_display'] = $this->product['regular_price']; - } - - if (isset($product['unit_price']) && $product['unit_price']) { - $this->product['unit_price'] = $this->priceFormatter->format($product['unit_price']); - $this->product['unit_price_full'] = $this->priceFormatter->format($product['unit_price']) - . ' ' . $product['unity']; - } else { - $this->product['unit_price'] = $this->product['unit_price_full'] = ''; - } - } - - /** - * @param array $product - * @param ProductPresentationSettings $settings - * - * @return bool - */ - protected function shouldEnableAddToCartButton(array $product, ProductPresentationSettings $settings) - { - if (($product['customizable'] == 2 || !empty($product['customization_required']))) { - $shouldEnable = false; - - if (isset($product['customizations'])) { - $shouldEnable = true; - foreach ($product['customizations']['fields'] as $field) { - if ($field['required'] && !$field['is_customized']) { - $shouldEnable = false; - } - } - } - } else { - $shouldEnable = true; - } - - $shouldEnable = $shouldEnable && $this->shouldShowAddToCartButton($product); - - if ($settings->stock_management_enabled - && !$product['allow_oosp'] - && ($product['quantity'] <= 0 - || $product['quantity'] - $this->getQuantityWanted() < 0 - || $product['quantity'] - $this->getMinimalQuantity() < 0) - ) { - $shouldEnable = false; - } - - return $shouldEnable; - } - - /** - * @return int Quantity of product requested by the customer - */ - private function getQuantityWanted() - { - return (int) Tools::getValue('quantity_wanted', 1); - } - - /** - * @return int Minimal quantity of product requested by the customer - */ - private function getMinimalQuantity() - { - return (int) $this->product['minimal_quantity']; - } - - /** - * {@inheritdoc} - * - * @param array $product - * @param Language $language - * @param bool $canonical - * - * @return string - */ - private function getProductURL( - array $product, - Language $language, - $canonical = false - ) { - $linkRewrite = isset($product['link_rewrite']) ? $product['link_rewrite'] : null; - $category = isset($product['category']) ? $product['category'] : null; - $ean13 = isset($product['ean13']) ? $product['ean13'] : null; - - return $this->link->getProductLink( - $product['id_product'], - $linkRewrite, - $category, - $ean13, - $language->id, - null, - !$canonical && $product['id_product_attribute'] > 0 ? $product['id_product_attribute'] : null, - false, - false, - true - ); - } - - /** - * @param ProductPresentationSettings $settings - * @param array $product - * @param Language $language - */ - public function addQuantityInformation( - ProductPresentationSettings $settings, - array $product, - Language $language - ) { - $show_price = $this->shouldShowPrice($settings, $product); - $show_availability = $show_price && $settings->stock_management_enabled; - $this->product['show_availability'] = $show_availability; - $product['quantity_wanted'] = $this->getQuantityWanted(); - - if (isset($product['available_date']) && '0000-00-00' == $product['available_date']) { - $product['available_date'] = null; - } - - if ($show_availability) { - if ($product['quantity'] - $product['quantity_wanted'] >= 0) { - $this->product['availability_date'] = $product['available_date']; - - if ($product['quantity'] < $settings->lastRemainingItems) { - $this->applyLastItemsInStockDisplayRule(); - } else { - $this->product['availability_message'] = $product['available_now'] ? $product['available_now'] - : Configuration::get('PS_LABEL_IN_STOCK_PRODUCTS', $language->id); - $this->product['availability'] = 'available'; - } - } elseif ($product['allow_oosp']) { - $this->product['availability_message'] = $product['available_later'] ? $product['available_later'] - : Configuration::get('PS_LABEL_OOS_PRODUCTS_BOA', $language->id); - $this->product['availability_date'] = $product['available_date']; - $this->product['availability'] = 'available'; - } elseif ($product['quantity_wanted'] > 0 && $product['quantity'] > 0) { - $this->product['availability_message'] = $this->translator->trans( - 'There are not enough products in stock', - [], - 'Shop.Notifications.Error' - ); - $this->product['availability'] = 'unavailable'; - $this->product['availability_date'] = null; - } elseif (!empty($product['quantity_all_versions']) && $product['quantity_all_versions'] > 0) { - $this->product['availability_message'] = $this->translator->trans( - 'Product available with different options', - [], - 'Shop.Theme.Catalog' - ); - $this->product['availability_date'] = $product['available_date']; - $this->product['availability'] = 'unavailable'; - } else { - $this->product['availability_message'] = - Configuration::get('PS_LABEL_OOS_PRODUCTS_BOD', $language->id); - $this->product['availability_date'] = $product['available_date']; - $this->product['availability'] = 'unavailable'; - } - } else { - $this->product['availability_message'] = null; - $this->product['availability_date'] = null; - $this->product['availability'] = null; - } - } - - /** - * Override availability message. - */ - protected function applyLastItemsInStockDisplayRule() - { - $this->product['availability_message'] = $this->translator->trans( - 'Last items in stock', - [], - 'Shop.Theme.Catalog' - ); - $this->product['availability'] = 'last_remaining_items'; - } - - /** - * @param string $key - * - * @return string - */ - private function getTranslatedKey($key) - { - switch ($key) { - case 'ean13': - return $this->translator->trans('ean13', [], 'Shop.Theme.Catalog'); - case 'isbn': - return $this->translator->trans('isbn', [], 'Shop.Theme.Catalog'); - case 'upc': - return $this->translator->trans('upc', [], 'Shop.Theme.Catalog'); - case 'mpn': - return $this->translator->trans('MPN', [], 'Shop.Theme.Catalog'); - } - - return $key; - } - - /** - * @return array - */ - protected function getProductAttributeWhitelist() - { - return [ - 'add_to_cart_url', - 'additional_shipping_cost', - 'advanced_stock_management', - 'allow_oosp', - 'attachments', - 'attribute_price', - 'attributes', - 'availability', - 'availability_date', - 'availability_message', - 'available_date', - 'available_for_order', - 'available_later', - 'available_now', - 'cache_default_attribute', - 'canonical_url', - 'category', - 'category_name', - 'condition', - 'cover', - 'customer_group_discount', - 'customizable', - 'customization_required', - 'customizations', - 'date_add', - 'date_upd', - 'delivery_in_stock', - 'delivery_out_stock', - 'description', - 'description_short', - 'discount_amount', - 'discount_amount_to_display', - 'discount_percentage', - 'discount_percentage_absolute', - 'discount_type', - 'ecotax', - 'ecotax_rate', - 'extraContent', - 'features', - 'flags', - 'has_discount', - 'id', - 'id_category_default', - 'id_customization', - 'id_image', - 'id_manufacturer', - 'id_product', - 'id_product_attribute', - 'id_shop_default', - 'id_supplier', - 'id_type_redirected', - 'images', - 'indexed', - 'is_customizable', - 'is_virtual', - 'labels', - 'link', - 'link_rewrite', - 'low_stock_alert', - 'low_stock_threshold', - 'main_variants', - 'meta_description', - 'meta_keywords', - 'meta_title', - 'minimal_quantity', - 'name', - 'new', - 'nopackprice', - 'on_sale', - 'online_only', - 'out_of_stock', - 'pack', - 'pack_stock_type', - 'packItems', - 'price', - 'price_amount', - 'price_tax_exc', - 'price_without_reduction', - 'quantity', - 'quantity_all_versions', - 'quantity_discounts', - 'quantity_label', - 'quantity_wanted', - 'rate', - 'redirect_type', - 'reduction', - 'reference', - 'reference_to_display', - 'show_availability', - 'show_condition', - 'show_price', - 'show_quantities', - 'specific_prices', - 'tax_name', - 'text_fields', - 'unit_price', - 'unit_price_full', - 'unit_price_ratio', - 'unity', - 'uploadable_files', - 'url', - 'virtual', - 'visibility', - 'weight_unit', - ]; - } - - /** - * Assemble the same features in one array. - * - * @param array $productFeatures - * - * @return array - */ - protected function buildGroupedFeatures(array $productFeatures) - { - $valuesByFeatureName = []; - $groupedFeatures = []; - - // features can either be "raw" (id_feature, id_product_id_feature_value) - // or "full" (id_feature, name, value) - // grouping can only be performed if they are "full" - if (empty($productFeatures) || !array_key_exists('name', reset($productFeatures))) { - return []; - } - - foreach ($productFeatures as $feature) { - $featureName = $feature['name']; - // build an array of unique features - $groupedFeatures[$featureName] = $feature; - // aggregate feature values separately - $valuesByFeatureName[$featureName][] = $feature['value']; - } - - // replace value from features that have multiple values with the ones we aggregated earlier - foreach ($valuesByFeatureName as $featureName => $values) { - if (count($values) > 1) { - sort($values, SORT_NATURAL); - $groupedFeatures[$featureName]['value'] = implode("\n", $values); - } - } - - return $groupedFeatures; - } -} diff --git a/src/Adapter/Presenter/Product/ProductListingLazyArray.php b/src/Adapter/Presenter/Product/ProductListingLazyArray.php deleted file mode 100644 index f9bcd5fc..00000000 --- a/src/Adapter/Presenter/Product/ProductListingLazyArray.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Presenter\Product; - -use PrestaShop\PrestaShop\Core\Product\ProductPresentationSettings; - -class ProductListingLazyArray extends ProductLazyArray -{ - /** - * @arrayAccess - * - * @return string|null - */ - public function getAddToCartUrl() - { - if ($this->product['id_product_attribute'] != 0 && !$this->settings->allow_add_variant_to_cart_from_listing) { - return null; - } - - if ($this->product['customizable'] == 2 || !empty($this->product['customization_required'])) { - return null; - } - - return parent::getAddToCartUrl(); - } - - /** - * @param array $product - * @param ProductPresentationSettings $settings - * - * @return bool - */ - protected function shouldEnableAddToCartButton(array $product, ProductPresentationSettings $settings) - { - if (isset($product['attributes']) - && count($product['attributes']) > 0 - && !$settings->allow_add_variant_to_cart_from_listing) { - return false; - } - - return parent::shouldEnableAddToCartButton($product, $settings); - } -} diff --git a/src/Adapter/Presenter/Product/ProductListingPresenter.php b/src/Adapter/Presenter/Product/ProductListingPresenter.php deleted file mode 100644 index dfaa7516..00000000 --- a/src/Adapter/Presenter/Product/ProductListingPresenter.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Presenter\Product; - -use Language; -use PrestaShop\PrestaShop\Core\Product\ProductPresentationSettings; - -class ProductListingPresenter extends ProductPresenter -{ - /** - * @param ProductPresentationSettings $settings - * @param array $product - * @param Language $language - * - * @return ProductLazyArray|ProductListingLazyArray - * - * @throws \ReflectionException - */ - public function present( - ProductPresentationSettings $settings, - array $product, - Language $language - ) { - return new ProductListingLazyArray( - $settings, - $product, - $language, - $this->imageRetriever, - $this->link, - $this->priceFormatter, - $this->productColorsRetriever, - $this->translator - ); - } -} diff --git a/src/Adapter/Presenter/Product/ProductPresenter.php b/src/Adapter/Presenter/Product/ProductPresenter.php deleted file mode 100644 index 866152d9..00000000 --- a/src/Adapter/Presenter/Product/ProductPresenter.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Presenter\Product; - -use Language; -use Link; -use PrestaShop\PrestaShop\Adapter\Image\ImageRetriever; -use PrestaShop\PrestaShop\Adapter\Product\PriceFormatter; -use PrestaShop\PrestaShop\Adapter\Product\ProductColorsRetriever; -use PrestaShop\PrestaShop\Core\Product\ProductPresentationSettings; -use Symfony\Component\Translation\TranslatorInterface; - -class ProductPresenter -{ - /** - * @var ImageRetriever - */ - protected $imageRetriever; - - /** - * @var Link - */ - protected $link; - - /** - * @var PriceFormatter - */ - protected $priceFormatter; - - /** - * @var ProductColorsRetriever - */ - protected $productColorsRetriever; - - /** - * @var TranslatorInterface - */ - protected $translator; - - public function __construct( - ImageRetriever $imageRetriever, - Link $link, - PriceFormatter $priceFormatter, - ProductColorsRetriever $productColorsRetriever, - TranslatorInterface $translator - ) { - $this->imageRetriever = $imageRetriever; - $this->link = $link; - $this->priceFormatter = $priceFormatter; - $this->productColorsRetriever = $productColorsRetriever; - $this->translator = $translator; - } - - public function present( - ProductPresentationSettings $settings, - array $product, - Language $language - ) { - return new ProductLazyArray( - $settings, - $product, - $language, - $this->imageRetriever, - $this->link, - $this->priceFormatter, - $this->productColorsRetriever, - $this->translator - ); - } -} diff --git a/src/Adapter/PricesDrop/PricesDropProductSearchProvider.php b/src/Adapter/PricesDrop/PricesDropProductSearchProvider.php deleted file mode 100644 index 1b99fda0..00000000 --- a/src/Adapter/PricesDrop/PricesDropProductSearchProvider.php +++ /dev/null @@ -1,121 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\PricesDrop; - -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchProviderInterface; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchResult; -use PrestaShop\PrestaShop\Core\Product\Search\SortOrder; -use PrestaShop\PrestaShop\Core\Product\Search\SortOrderFactory; -use Product; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Used to query the Prices Drop, see PricesDropController in Front Office. - */ -class PricesDropProductSearchProvider implements ProductSearchProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var SortOrderFactory - */ - private $sortOrderFactory; - - public function __construct( - TranslatorInterface $translator - ) { - $this->translator = $translator; - $this->sortOrderFactory = new SortOrderFactory($this->translator); - } - - /** - * @param ProductSearchContext $context - * @param ProductSearchQuery $query - * @param string $type - * - * @return array - */ - private function getProductsOrCount( - ProductSearchContext $context, - ProductSearchQuery $query, - $type = 'products' - ) { - return Product::getPricesDrop( - $context->getIdLang(), - $query->getPage(), - $query->getResultsPerPage(), - $type !== 'products', - $query->getSortOrder()->toLegacyOrderBy(), - $query->getSortOrder()->toLegacyOrderWay() - ); - } - - /** - * {@inheritdoc} - */ - public function runQuery( - ProductSearchContext $context, - ProductSearchQuery $query - ) { - if (!$products = $this->getProductsOrCount($context, $query, 'products')) { - $products = []; - } - $count = $this->getProductsOrCount($context, $query, 'count'); - - $result = new ProductSearchResult(); - - if (!empty($products)) { - $result - ->setProducts($products) - ->setTotalProductsCount($count); - - $result->setAvailableSortOrders( - [ - (new SortOrder('product', 'name', 'asc'))->setLabel( - $this->translator->trans('Name, A to Z', [], 'Shop.Theme.Catalog') - ), - (new SortOrder('product', 'name', 'desc'))->setLabel( - $this->translator->trans('Name, Z to A', [], 'Shop.Theme.Catalog') - ), - (new SortOrder('product', 'price', 'asc'))->setLabel( - $this->translator->trans('Price, low to high', [], 'Shop.Theme.Catalog') - ), - (new SortOrder('product', 'price', 'desc'))->setLabel( - $this->translator->trans('Price, high to low', [], 'Shop.Theme.Catalog') - ), - ] - ); - } - - return $result; - } -} diff --git a/src/Adapter/Product/AdminProductDataProvider.php b/src/Adapter/Product/AdminProductDataProvider.php deleted file mode 100644 index de200287..00000000 --- a/src/Adapter/Product/AdminProductDataProvider.php +++ /dev/null @@ -1,472 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product; - -use AppKernel; -use Configuration; -use Context; -use Currency; -use Db; -use DbQuery; -use Doctrine\ORM\EntityManager; -use Hook; -use PrestaShop\PrestaShop\Adapter\Admin\AbstractAdminQueryBuilder; -use PrestaShop\PrestaShop\Adapter\ImageManager; -use PrestaShop\PrestaShop\Adapter\Validate; -use PrestaShopBundle\Entity\AdminFilter; -use PrestaShopBundle\Service\DataProvider\Admin\ProductInterface; -use Product; -use Psr\Cache\CacheItemPoolInterface; -use StockAvailable; -use Tools; - -/** - * Data provider for new Architecture, about Product object model. - * - * This class will provide data from DB / ORM about Products for the Admin interface. - * This is an Adapter that works with the Legacy code and persistence behaviors. - */ -class AdminProductDataProvider extends AbstractAdminQueryBuilder implements ProductInterface -{ - /** - * @var EntityManager - */ - private $entityManager; - - /** - * @var ImageManager - */ - private $imageManager; - - /** - * @var CacheItemPoolInterface - */ - private $cache; - - public function __construct( - EntityManager $entityManager, - ImageManager $imageManager, - CacheItemPoolInterface $cache - ) { - $this->entityManager = $entityManager; - $this->imageManager = $imageManager; - $this->cache = $cache; - } - - /** - * {@inheritdoc} - */ - public function getPersistedFilterParameters() - { - $employee = Context::getContext()->employee; - $employeeId = $employee->id ?: 0; - - $cachedFilters = $this->cache->getItem("app.product_filters_${employeeId}"); - - if (!$cachedFilters->isHit()) { - $shop = Context::getContext()->shop; - $filter = $this->entityManager->getRepository('PrestaShopBundle:AdminFilter')->findOneBy([ - 'employee' => $employeeId, - 'shop' => $shop->id ?: 0, - 'controller' => 'ProductController', - 'action' => 'catalogAction', - ]); - - /** @var $filter AdminFilter */ - if (null === $filter) { - $filters = AdminFilter::getProductCatalogEmptyFilter(); - } else { - $filters = $filter->getProductCatalogFilter(); - } - - $cachedFilters->set($filters); - $this->cache->save($cachedFilters); - } - - return $cachedFilters->get(); - } - - /** - * {@inheritdoc} - */ - public function isCategoryFiltered() - { - $filters = $this->getPersistedFilterParameters(); - - return !empty($filters['filter_category']) && $filters['filter_category'] > 0; - } - - /** - * {@inheritdoc} - */ - public function isColumnFiltered() - { - $filters = $this->getPersistedFilterParameters(); - foreach ($filters as $filterKey => $filterValue) { - if (strpos($filterKey, 'filter_column_') === 0 && $filterValue !== '') { - return true; // break at first column filter found - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function persistFilterParameters(array $parameters) - { - $employee = Context::getContext()->employee; - $shop = Context::getContext()->shop; - $filter = $this->entityManager->getRepository('PrestaShopBundle:AdminFilter')->findOneBy([ - 'employee' => $employee->id ?: 0, - 'shop' => $shop->id ?: 0, - 'controller' => 'ProductController', - 'action' => 'catalogAction', - ]); - - if (!$filter) { - $filter = new AdminFilter(); - $filter->setEmployee($employee->id ?: 0)->setShop($shop->id ?: 0)->setController('ProductController')->setAction('catalogAction'); - } - - $filter->setProductCatalogFilter($parameters); - $this->entityManager->persist($filter); - - // if each filter is == '', then remove item from DB :) - if (count(array_diff($filter->getProductCatalogFilter(), [''])) == 0) { - $this->entityManager->remove($filter); - } - - $this->entityManager->flush(); - - //Flush cache - $employee = Context::getContext()->employee; - $employeeId = $employee->id ?: 0; - - $this->cache->deleteItem("app.product_filters_${employeeId}"); - } - - /** - * {@inheritdoc} - */ - public function combinePersistentCatalogProductFilter($paramsIn = [], $avoidPersistence = false) - { - // retrieve persisted filter parameters - $persistedParams = $this->getPersistedFilterParameters(); - // merge with new values - $paramsOut = array_merge($persistedParams, (array) $paramsIn); - // persist new values - if (!$avoidPersistence) { - $this->persistFilterParameters($paramsOut); - } - - // return new values - return $paramsOut; - } - - /** - * {@inheritdoc} - */ - public function getCatalogProductList( - $offset, - $limit, - $orderBy, - $sortOrder, - $post = [], - $avoidPersistence = false, - $formatCldr = true - ) { - $offset = (int) $offset; - $limit = (int) $limit; - $orderBy = Validate::isOrderBy($orderBy) ? $orderBy : 'id_product'; - $sortOrder = Validate::isOrderWay($sortOrder) ? $sortOrder : 'desc'; - - $filterParams = $this->combinePersistentCatalogProductFilter(array_merge( - $post, - ['last_offset' => $offset, 'last_limit' => $limit, 'last_orderBy' => $orderBy, 'last_sortOrder' => $sortOrder] - ), $avoidPersistence); - $filterParams = AdminFilter::sanitizeFilterParameters($filterParams); - - $showPositionColumn = $this->isCategoryFiltered(); - if ($orderBy == 'position_ordering' && $showPositionColumn) { - foreach ($filterParams as $key => $param) { - if (strpos($key, 'filter_column_') === 0) { - $filterParams[$key] = ''; - } - } - } - if ($orderBy == 'position_ordering') { - $orderBy = 'position'; - } - - $idShop = Context::getContext()->shop->id; - $idLang = Context::getContext()->language->id; - - $sqlSelect = [ - 'id_product' => ['table' => 'p', 'field' => 'id_product', 'filtering' => ' %s '], - 'reference' => ['table' => 'p', 'field' => 'reference', 'filtering' => self::FILTERING_LIKE_BOTH], - 'price' => ['table' => 'sa', 'field' => 'price', 'filtering' => ' %s '], - 'id_shop_default' => ['table' => 'p', 'field' => 'id_shop_default'], - 'is_virtual' => ['table' => 'p', 'field' => 'is_virtual'], - 'name' => ['table' => 'pl', 'field' => 'name', 'filtering' => self::FILTERING_LIKE_BOTH], - 'link_rewrite' => ['table' => 'pl', 'field' => 'link_rewrite', 'filtering' => self::FILTERING_LIKE_BOTH], - 'active' => ['table' => 'sa', 'field' => 'active', 'filtering' => self::FILTERING_EQUAL_NUMERIC], - 'shopname' => ['table' => 'shop', 'field' => 'name'], - 'id_image' => ['table' => 'image_shop', 'field' => 'id_image'], - 'name_category' => ['table' => 'cl', 'field' => 'name', 'filtering' => self::FILTERING_LIKE_BOTH], - 'price_final' => '0', - 'nb_downloadable' => ['table' => 'pd', 'field' => 'nb_downloadable'], - 'sav_quantity' => ['table' => 'sav', 'field' => 'quantity', 'filtering' => ' %s '], - 'badge_danger' => ['select' => 'IF(sav.`quantity`<=0, 1, 0)', 'filtering' => 'IF(sav.`quantity`<=0, 1, 0) = %s'], - ]; - $sqlTable = [ - 'p' => 'product', - 'pl' => [ - 'table' => 'product_lang', - 'join' => 'LEFT JOIN', - 'on' => 'pl.`id_product` = p.`id_product` AND pl.`id_lang` = ' . $idLang . ' AND pl.`id_shop` = ' . $idShop, - ], - 'sav' => [ - 'table' => 'stock_available', - 'join' => 'LEFT JOIN', - 'on' => 'sav.`id_product` = p.`id_product` AND sav.`id_product_attribute` = 0' . - StockAvailable::addSqlShopRestriction(null, $idShop, 'sav'), - ], - 'sa' => [ - 'table' => 'product_shop', - 'join' => 'JOIN', - 'on' => 'p.`id_product` = sa.`id_product` AND sa.id_shop = ' . $idShop, - ], - 'cl' => [ - 'table' => 'category_lang', - 'join' => 'LEFT JOIN', - 'on' => 'sa.`id_category_default` = cl.`id_category` AND cl.`id_lang` = ' . $idLang . ' AND cl.id_shop = ' . $idShop, - ], - 'c' => [ - 'table' => 'category', - 'join' => 'LEFT JOIN', - 'on' => 'c.`id_category` = cl.`id_category`', - ], - 'shop' => [ - 'table' => 'shop', - 'join' => 'LEFT JOIN', - 'on' => 'shop.id_shop = ' . $idShop, - ], - 'image_shop' => [ - 'table' => 'image_shop', - 'join' => 'LEFT JOIN', - 'on' => 'image_shop.`id_product` = p.`id_product` AND image_shop.`cover` = 1 AND image_shop.id_shop = ' . $idShop, - ], - 'i' => [ - 'table' => 'image', - 'join' => 'LEFT JOIN', - 'on' => 'i.`id_image` = image_shop.`id_image`', - ], - 'pd' => [ - 'table' => 'product_download', - 'join' => 'LEFT JOIN', - 'on' => 'pd.`id_product` = p.`id_product`', - ], - ]; - $sqlWhere = ['AND', 1]; - $sqlOrder = [$orderBy . ' ' . $sortOrder]; - if ($orderBy != 'id_product') { - $sqlOrder[] = 'id_product asc'; // secondary order by (useful when ordering by active, quantity, price, etc...) - } - $sqlLimit = $offset . ', ' . $limit; - - // Column 'position' added if filtering by category - if ($showPositionColumn) { - $filteredCategoryId = (int) $filterParams['filter_category']; - $sqlSelect['position'] = ['table' => 'cp', 'field' => 'position']; - $sqlTable['cp'] = [ - 'table' => 'category_product', - 'join' => 'INNER JOIN', - 'on' => 'cp.`id_product` = p.`id_product` AND cp.`id_category` = ' . $filteredCategoryId, - ]; - } elseif ($orderBy == 'position') { - // We do not show position column, so we do not join the table, so we do not order by position! - $sqlOrder = ['id_product ASC']; - } - - $sqlGroupBy = []; - - // exec legacy hook but with different parameters (retro-compat < 1.7 is broken here) - Hook::exec('actionAdminProductsListingFieldsModifier', [ - '_ps_version' => AppKernel::VERSION, - 'sql_select' => &$sqlSelect, - 'sql_table' => &$sqlTable, - 'sql_where' => &$sqlWhere, - 'sql_group_by' => &$sqlGroupBy, - 'sql_order' => &$sqlOrder, - 'sql_limit' => &$sqlLimit, - ]); - foreach ($filterParams as $filterParam => $filterValue) { - if (!$filterValue && $filterValue !== '0') { - continue; - } - if (strpos($filterParam, 'filter_column_') === 0) { - $filterValue = Db::getInstance()->escape($filterValue, in_array($filterParam, [ - 'filter_column_id_product', - 'filter_column_sav_quantity', - 'filter_column_price', - ]), true); - $field = substr($filterParam, 14); // 'filter_column_' takes 14 chars - if (isset($sqlSelect[$field]['table'])) { - $sqlWhere[] = $sqlSelect[$field]['table'] . '.`' . $sqlSelect[$field]['field'] . '` ' . sprintf($sqlSelect[$field]['filtering'], $filterValue); - } else { - $sqlWhere[] = '(' . sprintf($sqlSelect[$field]['filtering'], $filterValue) . ')'; - } - } - // for 'filter_category', see next if($showPositionColumn) block. - } - $sqlWhere[] = 'state = ' . Product::STATE_SAVED; - - // exec legacy hook but with different parameters (retro-compat < 1.7 is broken here) - Hook::exec('actionAdminProductsListingFieldsModifier', [ - '_ps_version' => AppKernel::VERSION, - 'sql_select' => &$sqlSelect, - 'sql_table' => &$sqlTable, - 'sql_where' => &$sqlWhere, - 'sql_group_by' => &$sqlGroupBy, - 'sql_order' => &$sqlOrder, - 'sql_limit' => &$sqlLimit, - ]); - - $sql = $this->compileSqlQuery($sqlSelect, $sqlTable, $sqlWhere, $sqlGroupBy, $sqlOrder, $sqlLimit); - $products = Db::getInstance()->executeS($sql, true, false); - $total = Db::getInstance()->executeS('SELECT FOUND_ROWS();', true, false); - $total = $total[0]['FOUND_ROWS()']; - - // post treatment - $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT')); - $localeCldr = Tools::getContextLocale(Context::getContext()); - - foreach ($products as &$product) { - $product['total'] = $total; // total product count (filtered) - $product['price_final'] = Product::getPriceStatic( - $product['id_product'], - true, - null, - Context::getContext()->getComputingPrecision(), - null, - false, - false, - 1, - true, - null, - null, - null, - $nothing, - true, - true - ); - - if ($formatCldr) { - $product['price'] = $localeCldr->formatPrice($product['price'], $currency->iso_code); - $product['price_final'] = $localeCldr->formatPrice($product['price_final'], $currency->iso_code); - } - $product['image'] = $this->imageManager->getThumbnailForListing($product['id_image']); - $product['image_link'] = Context::getContext()->link->getImageLink($product['link_rewrite'], $product['id_image']); - } - - // post treatment by hooks - // exec legacy hook but with different parameters (retro-compat < 1.7 is broken here) - Hook::exec('actionAdminProductsListingResultsModifier', [ - '_ps_version' => AppKernel::VERSION, - 'products' => &$products, - 'total' => $total, - ]); - - return $products; - } - - /** - * {@inheritdoc} - */ - public function countAllProducts() - { - $idShop = Context::getContext()->shop->id; - - $query = new DbQuery(); - $query->select('COUNT(ps.id_product)'); - $query->from('product_shop', 'ps'); - $query->where('ps.id_shop = ' . (int) $idShop); - - $total = Db::getInstance()->getValue($query); - - return (int) $total; - } - - /** - * Translates new Core route parameters into their Legacy equivalent. - * - * @param string[] $coreParameters The new Core route parameters - * - * @return string[] The URL parameters for Legacy URL (GETs) - */ - public function mapLegacyParametersProductForm($coreParameters = []) - { - $params = []; - if ($coreParameters['id'] == '0') { - $params['addproduct'] = 1; - } else { - $params['updateproduct'] = 1; - $params['id_product'] = $coreParameters['id']; - } - - return $params; - } - - /** - * {@inheritdoc} - */ - public function getPaginationLimitChoices() - { - $paginationLimitChoices = [20, 50, 100]; - - $memory = Tools::getMemoryLimit(); - - if ($memory >= 512 * 1024 * 1024) { - $paginationLimitChoices[] = 300; - } - if ($memory >= 1536 * 1024 * 1024) { - $paginationLimitChoices[] = 1000; - } - - return $paginationLimitChoices; - } - - /** - * {@inheritdoc} - */ - public function isNewProductDefaultActivated() - { - return (bool) Configuration::get('PS_PRODUCT_ACTIVATION_DEFAULT'); - } -} diff --git a/src/Adapter/Product/AdminProductDataUpdater.php b/src/Adapter/Product/AdminProductDataUpdater.php deleted file mode 100644 index 39599511..00000000 --- a/src/Adapter/Product/AdminProductDataUpdater.php +++ /dev/null @@ -1,299 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product; - -use Category; -use Configuration; -use Db; -use GroupReduction; -use Image; -use Pack; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Exception\UpdateProductException; -use PrestaShopBundle\Service\DataUpdater\Admin\ProductInterface; -use Product; -use Search; -use Shop; -use ShopGroup; -use Validate; - -/** - * This class will update/insert/delete data from DB / ORM about Product, for both Front and Admin interfaces. - */ -class AdminProductDataUpdater implements ProductInterface -{ - /** - * @var HookDispatcherInterface - */ - private $hookDispatcher; - - /** - * Constructor. HookDispatcher is injected by Sf container. - * - * @param HookDispatcher $hookDispatcher - */ - public function __construct(HookDispatcherInterface $hookDispatcher) - { - $this->hookDispatcher = $hookDispatcher; - } - - /** - * {@inheritdoc} - */ - public function activateProductIdList(array $productListId, $activate = true) - { - if (count($productListId) < 1) { - throw new \Exception('AdminProductDataUpdater->activateProductIdList() should always receive at least one ID. Zero given.', 5003); - } - - $failedIdList = []; - foreach ($productListId as $productId) { - $product = new Product($productId); - if (!Validate::isLoadedObject($product) - || $product->validateFields(false, true) !== true - || $product->validateFieldsLang(false, true) !== true) { - $failedIdList[] = $productId; - - continue; - } - $product->active = ($activate ? 1 : 0); - $product->update(); - if (in_array($product->visibility, ['both', 'search']) && Configuration::get('PS_SEARCH_INDEXATION')) { - Search::indexation(false, $product->id); - } - $this->hookDispatcher->dispatchWithParameters('actionProductActivation', ['id_product' => (int) $product->id, 'product' => $product, 'activated' => $activate]); - } - - if (count($failedIdList) > 0) { - throw new UpdateProductException('Cannot change activation state on many requested products', 5004); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function deleteProductIdList(array $productIdList) - { - if (count($productIdList) < 1) { - throw new \Exception('AdminProductDataUpdater->deleteProductIdList() should always receive at least one ID. Zero given.', 5005); - } - - $failedIdList = $productIdList; // Since we have just one call to delete all, cannot have distinctive fails. - // Hooks: will trigger actionProductDelete multiple times - $result = (new Product())->deleteSelection($productIdList); - - if ($result === 0) { - throw new UpdateProductException('Cannot delete many requested products.', 5006); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function duplicateProductIdList(array $productIdList) - { - if (count($productIdList) < 1) { - throw new \Exception('AdminProductDataUpdater->duplicateProductIdList() should always receive at least one ID. Zero given.', 5005); - } - - $failedIdList = []; - foreach ($productIdList as $productId) { - try { - $this->duplicateProduct($productId); - } catch (\Exception $e) { - $failedIdList[] = $productId; - - continue; - } - } - - if (count($failedIdList) > 0) { - throw new UpdateProductException('Cannot duplicate many requested products', 5004); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function deleteProduct($productId) - { - $product = new Product($productId); - if (!Validate::isLoadedObject($product)) { - throw new \Exception('AdminProductDataUpdater->deleteProduct() received an unknown ID.', 5005); - } - - // dumb? no: delete() makes a lot of things, and can reject deletion in specific cases. - // Hooks: will trigger actionProductDelete - $result = $product->delete(); - - if ($result === 0) { - throw new UpdateProductException('Cannot delete the requested product.', 5007); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function duplicateProduct($productId, $namePattern = 'copy of %s') - { - //TODO : use the $namePattern var to input translated version of 'copy of %s', if translation requested. - $product = new Product($productId); - if (!Validate::isLoadedObject($product)) { - throw new \Exception('AdminProductDataUpdater->duplicateProduct() received an unknown ID.', 5005); - } - - if (($error = $product->validateFields(false, true)) !== true - || ($error = $product->validateFieldsLang(false, true)) !== true) { - throw new UpdateProductException(sprintf('Cannot duplicate this product: %s', $error)); - } - - $id_product_old = $product->id; - if (empty($product->price) && Shop::getContext() == Shop::CONTEXT_GROUP) { - $shops = ShopGroup::getShopsFromGroup(Shop::getContextShopGroupID()); - foreach ($shops as $shop) { - if ($product->isAssociatedToShop($shop['id_shop'])) { - $product_price = new Product($id_product_old, false, null, $shop['id_shop']); - $product->price = $product_price->price; - } - } - } - - unset( - $product->id, - $product->id_product - ); - - $product->indexed = 0; - $product->active = 0; - - // change product name to prefix it - foreach ($product->name as $langKey => $oldName) { - if (!preg_match('/^' . str_replace('%s', '.*', preg_quote($namePattern, '/') . '$/'), $oldName)) { - $newName = sprintf($namePattern, $oldName); - if (mb_strlen($newName, 'UTF-8') <= 127) { - $product->name[$langKey] = $newName; - } - } - } - - if ($product->add() - && Category::duplicateProductCategories($id_product_old, $product->id) - && Product::duplicateSuppliers($id_product_old, $product->id) - && ($combination_images = Product::duplicateAttributes($id_product_old, $product->id)) !== false - && GroupReduction::duplicateReduction($id_product_old, $product->id) - && Product::duplicateAccessories($id_product_old, $product->id) - && Product::duplicateFeatures($id_product_old, $product->id) - && Product::duplicateSpecificPrices($id_product_old, $product->id) - && Pack::duplicate($id_product_old, $product->id) - && Product::duplicateCustomizationFields($id_product_old, $product->id) - && Product::duplicatePrices($id_product_old, $product->id) - && Product::duplicateTags($id_product_old, $product->id) - && Product::duplicateTaxes($id_product_old, $product->id) - && Product::duplicateDownload($id_product_old, $product->id)) { - if ($product->hasAttributes()) { - Product::updateDefaultAttribute($product->id); - } - - if (!Image::duplicateProductImages($id_product_old, $product->id, $combination_images)) { - throw new UpdateProductException('An error occurred while copying images.', 5008); - } else { - $this->hookDispatcher->dispatchWithParameters('actionProductAdd', ['id_product_old' => $id_product_old, 'id_product' => (int) $product->id, 'product' => $product]); - if (in_array($product->visibility, ['both', 'search']) && Configuration::get('PS_SEARCH_INDEXATION')) { - Search::indexation(false, $product->id); - } - - return $product->id; - } - } else { - if ($product->id !== null) { - $product->delete(); - } - throw new \Exception('An error occurred while creating an object.', 5009); - } - } - - /** - * {@inheritdoc} - */ - public function sortProductIdList(array $productList, $filterParams) - { - if (count($productList) < 2) { - return false; - } - - if (!isset($filterParams['filter_category'])) { - throw new \Exception('Cannot sort when filterParams does not contains \'filter_category\'.', 5010); - } - - foreach ($filterParams as $k => $v) { - if ($v == '' || strpos($k, 'filter_') !== 0) { - continue; - } - if ($k == 'filter_category') { - continue; - } - - throw new \Exception('Cannot sort when filterParams contains other filter than \'filter_category\'.', 5010); - } - - $categoryId = $filterParams['filter_category']; - $minPosition = min(array_values($productList)); - $productsIds = implode(',', array_map('intval', array_keys($productList))); - - /* - * First request to update position on category_product - */ - Db::getInstance()->query('SET @i := ' . (((int) $minPosition) - 1)); - $updatePositions = 'UPDATE `' . _DB_PREFIX_ . 'category_product` cp ' . - 'SET cp.`position` = (SELECT @i := @i + 1) ' . - 'WHERE cp.`id_category` = ' . (int) $categoryId . ' AND cp.`id_product` IN (' . $productsIds . ') ' . - 'ORDER BY FIELD(cp.`id_product`, ' . $productsIds . ')'; - Db::getInstance()->query($updatePositions); - - /** - * Second request to update date_upd because - * ORDER BY is not working on multi-tables update - */ - $updateProducts = 'UPDATE `' . _DB_PREFIX_ . 'product` p ' . - '' . Shop::addSqlAssociation('product', 'p') . ' ' . - 'SET ' . - ' p.`date_upd` = "' . date('Y-m-d H:i:s') . '", ' . - ' product_shop.`date_upd` = "' . date('Y-m-d H:i:s') . '" ' . - 'WHERE p.`id_product` IN (' . $productsIds . ') '; - Db::getInstance()->query($updateProducts); - - return true; - } -} diff --git a/src/Adapter/Product/AdminProductWrapper.php b/src/Adapter/Product/AdminProductWrapper.php deleted file mode 100644 index 3f748700..00000000 --- a/src/Adapter/Product/AdminProductWrapper.php +++ /dev/null @@ -1,951 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product; - -use AdminProductsController; -use Attachment; -use Category; -use Combination; -use Configuration; -use Context; -use Customer; -use Db; -use Hook; -use Image; -use Language; -use ObjectModel; -use PrestaShop\PrestaShop\Adapter\Entity\Customization; -use PrestaShop\PrestaShop\Core\Foundation\Database\EntityNotFoundException; -use PrestaShop\PrestaShop\Core\Localization\Locale; -use PrestaShopBundle\Utils\FloatParser; -use Product; -use ProductDownload; -use Shop; -use ShopUrl; -use SpecificPrice; -use SpecificPriceRule; -use StockAvailable; -use Symfony\Component\Translation\TranslatorInterface; -use Tools; -use Validate; - -/** - * Admin controller wrapper for new Architecture, about Product admin controller. - */ -class AdminProductWrapper -{ - /** - * @var array - */ - private $errors = []; - - /** - * @var Locale - */ - private $locale; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var array - */ - private $employeeAssociatedShops; - - /** - * @var FloatParser - */ - private $floatParser; - - /** - * Constructor : Inject Symfony\Component\Translation Translator. - * - * @param object $translator - * @param array $employeeAssociatedShops - * @param Locale $locale - * @param FloatParser|null $floatParser - */ - public function __construct($translator, array $employeeAssociatedShops, Locale $locale, FloatParser $floatParser = null) - { - $this->translator = $translator; - $this->employeeAssociatedShops = $employeeAssociatedShops; - $this->locale = $locale; - $this->floatParser = $floatParser ?? new FloatParser(); - } - - /** - * getInstance - * Get the legacy AdminProductsControllerCore instance. - * - * @return AdminProductsController instance - */ - public function getInstance() - { - return new AdminProductsController(); - } - - /** - * processProductAttribute - * Update a combination. - * - * @param object $product - * @param array $combinationValues the posted values - * - * @return AdminProductsController instance - */ - public function processProductAttribute($product, $combinationValues) - { - $id_product_attribute = (int) $combinationValues['id_product_attribute']; - $images = []; - - if (!Combination::isFeatureActive() || $id_product_attribute == 0) { - return; - } - - if (!isset($combinationValues['attribute_wholesale_price'])) { - $combinationValues['attribute_wholesale_price'] = 0; - } - if (!isset($combinationValues['attribute_price_impact'])) { - $combinationValues['attribute_price_impact'] = 0; - } - if (!isset($combinationValues['attribute_weight_impact'])) { - $combinationValues['attribute_weight_impact'] = 0; - } - if (!isset($combinationValues['attribute_ecotax'])) { - $combinationValues['attribute_ecotax'] = 0; - } - if ((isset($combinationValues['attribute_default']) && $combinationValues['attribute_default'] == 1)) { - $product->deleteDefaultAttributes(); - } - if (!empty($combinationValues['id_image_attr'])) { - $images = $combinationValues['id_image_attr']; - } else { - $combination = new Combination($id_product_attribute); - $combination->setImages([]); - } - if (!isset($combinationValues['attribute_low_stock_threshold'])) { - $combinationValues['attribute_low_stock_threshold'] = null; - } - if (!isset($combinationValues['attribute_low_stock_alert'])) { - $combinationValues['attribute_low_stock_alert'] = false; - } - - $product->updateAttribute( - $id_product_attribute, - $combinationValues['attribute_wholesale_price'], - $combinationValues['attribute_price'] * $combinationValues['attribute_price_impact'], - $combinationValues['attribute_weight'] * $combinationValues['attribute_weight_impact'], - $combinationValues['attribute_unity'] * $combinationValues['attribute_unit_impact'], - $combinationValues['attribute_ecotax'], - $images, - $combinationValues['attribute_reference'], - $combinationValues['attribute_ean13'], - (isset($combinationValues['attribute_default']) && $combinationValues['attribute_default'] == 1), - isset($combinationValues['attribute_location']) ? $combinationValues['attribute_location'] : null, - $combinationValues['attribute_upc'], - $combinationValues['attribute_minimal_quantity'], - $combinationValues['available_date_attribute'], - false, - [], - $combinationValues['attribute_isbn'], - $combinationValues['attribute_low_stock_threshold'], - $combinationValues['attribute_low_stock_alert'], - $combinationValues['attribute_mpn'] - ); - - StockAvailable::setProductDependsOnStock((int) $product->id, $product->depends_on_stock, null, $id_product_attribute); - StockAvailable::setProductOutOfStock((int) $product->id, $product->out_of_stock, null, $id_product_attribute); - StockAvailable::setLocation((int) $product->id, $combinationValues['attribute_location'], null, $id_product_attribute); - - $product->checkDefaultAttributes(); - - if ((isset($combinationValues['attribute_default']) && $combinationValues['attribute_default'] == 1)) { - Product::updateDefaultAttribute((int) $product->id); - if (isset($id_product_attribute)) { - $product->cache_default_attribute = (int) $id_product_attribute; - } - - // We need to reload the product because some other calls have modified the database - // It's done just for the setAvailableDate to avoid side effects - Product::disableCache(); - $consistentProduct = new Product($product->id); - if ($available_date = $combinationValues['available_date_attribute']) { - $consistentProduct->setAvailableDate($available_date); - } else { - $consistentProduct->setAvailableDate(); - } - Product::enableCache(); - } - - if (isset($combinationValues['attribute_quantity'])) { - $this->processQuantityUpdate($product, $combinationValues['attribute_quantity'], $id_product_attribute); - } - } - - /** - * Update a quantity for a product or a combination. - * - * Does not work in Advanced stock management. - * - * @param Product $product - * @param int $quantity - * @param int $forAttributeId - */ - public function processQuantityUpdate(Product $product, $quantity, $forAttributeId = 0) - { - // Hook triggered by legacy code below: actionUpdateQuantity('id_product', 'id_product_attribute', 'quantity') - StockAvailable::setQuantity((int) $product->id, $forAttributeId, $quantity); - Hook::exec('actionProductUpdate', ['id_product' => (int) $product->id, 'product' => $product]); - } - - /** - * Update the out of stock strategy. - * - * @param Product $product - * @param int $out_of_stock - */ - public function processProductOutOfStock(Product $product, $out_of_stock) - { - StockAvailable::setProductOutOfStock((int) $product->id, (int) $out_of_stock); - } - - /** - * @param Product $product - * @param string $location - */ - public function processLocation(Product $product, $location) - { - StockAvailable::setLocation($product->id, $location); - } - - /** - * Set if a product depends on stock (ASM). For a product or a combination. - * - * Does work only in Advanced stock management. - * - * @param Product $product - * @param bool $dependsOnStock - * @param int $forAttributeId - */ - public function processDependsOnStock(Product $product, $dependsOnStock, $forAttributeId = 0) - { - StockAvailable::setProductDependsOnStock((int) $product->id, $dependsOnStock, null, $forAttributeId); - } - - /** - * Add/Update a SpecificPrice object. - * - * @param int $id_product - * @param array $specificPriceValues the posted values - * @param int (optional) $id_specific_price if this is an update of an existing specific price, null else - * - * @return AdminProductsController instance - */ - public function processProductSpecificPrice($id_product, $specificPriceValues, $idSpecificPrice = null) - { - // ---- data formatting ---- - $id_product_attribute = $specificPriceValues['sp_id_product_attribute']; - $id_shop = $specificPriceValues['sp_id_shop'] ? $specificPriceValues['sp_id_shop'] : 0; - $id_currency = $specificPriceValues['sp_id_currency'] ? $specificPriceValues['sp_id_currency'] : 0; - $id_country = $specificPriceValues['sp_id_country'] ? $specificPriceValues['sp_id_country'] : 0; - $id_group = $specificPriceValues['sp_id_group'] ? $specificPriceValues['sp_id_group'] : 0; - $id_customer = !empty($specificPriceValues['sp_id_customer']['data']) ? $specificPriceValues['sp_id_customer']['data'][0] : 0; - $price = isset($specificPriceValues['leave_bprice']) ? '-1' : $this->floatParser->fromString($specificPriceValues['sp_price']); - $from_quantity = $specificPriceValues['sp_from_quantity']; - $reduction = $this->floatParser->fromString($specificPriceValues['sp_reduction']); - $reduction_tax = $specificPriceValues['sp_reduction_tax']; - $reduction_type = !$reduction ? 'amount' : $specificPriceValues['sp_reduction_type']; - $reduction_type = $reduction_type == '-' ? 'amount' : $reduction_type; - $from = $specificPriceValues['sp_from']; - if (!$from) { - $from = '0000-00-00 00:00:00'; - } - $to = $specificPriceValues['sp_to']; - if (!$to) { - $to = '0000-00-00 00:00:00'; - } - $isThisAnUpdate = (null !== $idSpecificPrice); - - // ---- validation ---- - if (($price == '-1') && ((float) $reduction == '0')) { - $this->errors[] = $this->translator->trans('No reduction value has been submitted', [], 'Admin.Catalog.Notification'); - } elseif ($to != '0000-00-00 00:00:00' && strtotime($to) < strtotime($from)) { - $this->errors[] = $this->translator->trans('Invalid date range', [], 'Admin.Catalog.Notification'); - } elseif ($reduction_type == 'percentage' && ((float) $reduction <= 0 || (float) $reduction > 100)) { - $this->errors[] = $this->translator->trans('Submitted reduction value (0-100) is out-of-range', [], 'Admin.Catalog.Notification'); - } - $validationResult = $this->validateSpecificPrice( - $id_product, - $id_shop, - $id_currency, - $id_country, - $id_group, - $id_customer, - $price, - $from_quantity, - $reduction, - $reduction_type, - $from, - $to, - $id_product_attribute, - $isThisAnUpdate - ); - - if (false === $validationResult || count($this->errors)) { - return $this->errors; - } - - // ---- data modification ---- - if ($isThisAnUpdate) { - $specificPrice = new SpecificPrice($idSpecificPrice); - } else { - $specificPrice = new SpecificPrice(); - } - - $specificPrice->id_product = (int) $id_product; - $specificPrice->id_product_attribute = (int) $id_product_attribute; - $specificPrice->id_shop = (int) $id_shop; - $specificPrice->id_currency = (int) ($id_currency); - $specificPrice->id_country = (int) ($id_country); - $specificPrice->id_group = (int) ($id_group); - $specificPrice->id_customer = (int) $id_customer; - $specificPrice->price = (float) ($price); - $specificPrice->from_quantity = (int) ($from_quantity); - $specificPrice->reduction = (float) ($reduction_type == 'percentage' ? $reduction / 100 : $reduction); - $specificPrice->reduction_tax = $reduction_tax; - $specificPrice->reduction_type = $reduction_type; - $specificPrice->from = $from; - $specificPrice->to = $to; - - if ($isThisAnUpdate) { - $dataSavingResult = $specificPrice->save(); - } else { - $dataSavingResult = $specificPrice->add(); - } - - if (false === $dataSavingResult) { - $this->errors[] = $this->translator->trans('An error occurred while updating the specific price.', [], 'Admin.Catalog.Notification'); - } - - return $this->errors; - } - - /** - * Validate a specific price. - */ - private function validateSpecificPrice( - $id_product, - $id_shop, - $id_currency, - $id_country, - $id_group, - $id_customer, - $price, - $from_quantity, - $reduction, - $reduction_type, - $from, - $to, - $id_combination = 0, - $isThisAnUpdate = false - ) { - if (!Validate::isUnsignedId($id_shop) || !Validate::isUnsignedId($id_currency) || !Validate::isUnsignedId($id_country) || !Validate::isUnsignedId($id_group) || !Validate::isUnsignedId($id_customer)) { - $this->errors[] = 'Wrong IDs'; - } elseif ((!isset($price) && !isset($reduction)) || (isset($price) && !Validate::isNegativePrice($price)) || (isset($reduction) && !Validate::isPrice($reduction))) { - $this->errors[] = 'Invalid price/discount amount'; - } elseif (!Validate::isUnsignedInt($from_quantity)) { - $this->errors[] = 'Invalid quantity'; - } elseif ($reduction && !Validate::isReductionType($reduction_type)) { - $this->errors[] = 'Please select a discount type (amount or percentage).'; - } elseif ($from && $to && (!Validate::isDateFormat($from) || !Validate::isDateFormat($to))) { - $this->errors[] = 'The from/to date is invalid.'; - } elseif (!$isThisAnUpdate && SpecificPrice::exists((int) $id_product, $id_combination, $id_shop, $id_group, $id_country, $id_currency, $id_customer, $from_quantity, $from, $to, false)) { - $this->errors[] = 'A specific price already exists for these parameters.'; - } else { - return true; - } - - return false; - } - - /** - * Get specific prices list for a product. - * - * @param object $product - * @param object $defaultCurrency - * @param array $shops Available shops - * @param array $currencies Available currencies - * @param array $countries Available countries - * @param array $groups Available users groups - * - * @return array - */ - public function getSpecificPricesList($product, $defaultCurrency, $shops, $currencies, $countries, $groups) - { - $content = []; - $specific_prices = SpecificPrice::getByProductId((int) $product->id); - - $tmp = []; - foreach ($shops as $shop) { - $tmp[$shop['id_shop']] = $shop; - } - $shops = $tmp; - $tmp = []; - foreach ($currencies as $currency) { - $tmp[$currency['id_currency']] = $currency; - } - $currencies = $tmp; - - $tmp = []; - foreach ($countries as $country) { - $tmp[$country['id_country']] = $country; - } - $countries = $tmp; - - $tmp = []; - foreach ($groups as $group) { - $tmp[$group['id_group']] = $group; - } - $groups = $tmp; - - if (is_array($specific_prices) && count($specific_prices)) { - foreach ($specific_prices as $specific_price) { - $id_currency = $specific_price['id_currency'] ? $specific_price['id_currency'] : $defaultCurrency->id; - if (!isset($currencies[$id_currency])) { - continue; - } - - $current_specific_currency = $currencies[$id_currency]; - if ($specific_price['reduction_type'] == 'percentage') { - $impact = '- ' . ($specific_price['reduction'] * 100) . ' %'; - } elseif ($specific_price['reduction'] > 0) { - $impact = '- ' . $this->locale->formatPrice($specific_price['reduction'], $current_specific_currency['iso_code']) . ' '; - if ($specific_price['reduction_tax']) { - $impact .= '(' . $this->translator->trans('Tax incl.', [], 'Admin.Global') . ')'; - } else { - $impact .= '(' . $this->translator->trans('Tax excl.', [], 'Admin.Global') . ')'; - } - } else { - $impact = '--'; - } - - if ($specific_price['from'] == '0000-00-00 00:00:00' && $specific_price['to'] == '0000-00-00 00:00:00') { - $period = $this->translator->trans('Unlimited', [], 'Admin.Global'); - } else { - $period = $this->translator->trans('From', [], 'Admin.Global') . ' ' . ($specific_price['from'] != '0000-00-00 00:00:00' ? $specific_price['from'] : '0000-00-00 00:00:00') . '
    ' . $this->translator->trans('to', [], 'Admin.Global') . ' ' . ($specific_price['to'] != '0000-00-00 00:00:00' ? $specific_price['to'] : '0000-00-00 00:00:00'); - } - if ($specific_price['id_product_attribute']) { - $combination = new Combination((int) $specific_price['id_product_attribute']); - $attributes = $combination->getAttributesName(1); - $attributes_name = ''; - foreach ($attributes as $attribute) { - $attributes_name .= $attribute['name'] . ' - '; - } - $attributes_name = rtrim($attributes_name, ' - '); - } else { - $attributes_name = $this->translator->trans('All combinations', [], 'Admin.Catalog.Feature'); - } - - $rule = new SpecificPriceRule((int) $specific_price['id_specific_price_rule']); - $rule_name = ($rule->id ? $rule->name : '--'); - - if ($specific_price['id_customer']) { - $customer = new Customer((int) $specific_price['id_customer']); - if (Validate::isLoadedObject($customer)) { - $customer_full_name = $customer->firstname . ' ' . $customer->lastname; - } - unset($customer); - } - - if (!$specific_price['id_shop'] || in_array($specific_price['id_shop'], Shop::getContextListShopID())) { - $can_delete_specific_prices = true; - if (Shop::isFeatureActive()) { - $can_delete_specific_prices = (count($this->employeeAssociatedShops) > 1 && !$specific_price['id_shop']) || $specific_price['id_shop']; - } - - $price = Tools::ps_round($specific_price['price'], 2); - $fixed_price = (($price == Tools::ps_round($product->price, 2) && $current_specific_currency['id_currency'] == $defaultCurrency->id) || $specific_price['price'] == -1) ? '--' : $this->locale->formatPrice($price, $current_specific_currency['iso_code']); - - $content[] = [ - 'id_specific_price' => $specific_price['id_specific_price'], - 'id_product' => $product->id, - 'rule_name' => $rule_name, - 'attributes_name' => $attributes_name, - 'shop' => ($specific_price['id_shop'] ? $shops[$specific_price['id_shop']]['name'] : $this->translator->trans('All shops', [], 'Admin.Global')), - 'currency' => ($specific_price['id_currency'] ? $currencies[$specific_price['id_currency']]['name'] : $this->translator->trans('All currencies', [], 'Admin.Global')), - 'country' => ($specific_price['id_country'] ? $countries[$specific_price['id_country']]['name'] : $this->translator->trans('All countries', [], 'Admin.Global')), - 'group' => ($specific_price['id_group'] ? $groups[$specific_price['id_group']]['name'] : $this->translator->trans('All groups', [], 'Admin.Global')), - 'customer' => (isset($customer_full_name) ? $customer_full_name : $this->translator->trans('All customers', [], 'Admin.Global')), - 'fixed_price' => $fixed_price, - 'impact' => $impact, - 'period' => $period, - 'from_quantity' => $specific_price['from_quantity'], - 'can_delete' => (!$rule->id && $can_delete_specific_prices) ? true : false, - 'can_edit' => (!$rule->id && $can_delete_specific_prices) ? true : false, - ]; - - unset($customer_full_name); - } - } - } - - return $content; - } - - /** - * @param int $id - * - * @return SpecificPrice - * - * @throws PrestaShopObjectNotFoundException - */ - public function getSpecificPriceDataById($id) - { - $price = new SpecificPrice($id); - if (null === $price->id) { - throw new EntityNotFoundException(sprintf('Cannot find specific price with id %d', $id)); - } - - return $price; - } - - /** - * Delete a specific price. - * - * @param int $id_specific_price - * - * @return array error & status - */ - public function deleteSpecificPrice($id_specific_price) - { - if (!$id_specific_price || !Validate::isUnsignedId($id_specific_price)) { - $error = $this->translator->trans('The specific price ID is invalid.', [], 'Admin.Catalog.Notification'); - } else { - $specificPrice = new SpecificPrice((int) $id_specific_price); - if (!$specificPrice->delete()) { - $error = $this->translator->trans('An error occurred while attempting to delete the specific price.', [], 'Admin.Catalog.Notification'); - } - } - - if (isset($error)) { - return [ - 'status' => 'error', - 'message' => $error, - ]; - } - - return [ - 'status' => 'ok', - 'message' => $this->translator->trans('Successful deletion', [], 'Admin.Notifications.Success'), - ]; - } - - /** - * Get price priority. - * - * @param int|null $idProduct - * - * @return array - */ - public function getPricePriority($idProduct = null) - { - if (!$idProduct) { - return [ - 0 => 'id_shop', - 1 => 'id_currency', - 2 => 'id_country', - 3 => 'id_group', - ]; - } - - $specific_price_priorities = SpecificPrice::getPriority((int) $idProduct); - - // Not use id_customer - if ($specific_price_priorities[0] == 'id_customer') { - unset($specific_price_priorities[0]); - } - - return array_values($specific_price_priorities); - } - - /** - * Process customization collection. - * - * @param object $product - * @param array $data - * - * @return bool - */ - public function processProductCustomization($product, $data) - { - $customization_ids = []; - if ($data) { - foreach ($data as $customization) { - $customization_ids[] = (int) $customization['id_customization_field']; - } - } - - $shopList = Shop::getContextListShopID(); - - /* Update the customization fields to be deleted in the next step if not used */ - $product->softDeleteCustomizationFields($customization_ids); - - $usedCustomizationIds = $product->getUsedCustomizationFieldsIds(); - $usedCustomizationIds = array_column($usedCustomizationIds, 'index'); - $usedCustomizationIds = array_map('intval', $usedCustomizationIds); - $usedCustomizationIds = array_unique(array_merge($usedCustomizationIds, $customization_ids), SORT_REGULAR); - - //remove customization field langs for current context shops - $productCustomization = $product->getCustomizationFieldIds(); - $toDeleteCustomizationIds = []; - foreach ($productCustomization as $customizationFiled) { - if (!in_array((int) $customizationFiled['id_customization_field'], $usedCustomizationIds)) { - $toDeleteCustomizationIds[] = (int) $customizationFiled['id_customization_field']; - } - //if the customization_field is still in use, only delete the current context shops langs, - if (in_array((int) $customizationFiled['id_customization_field'], $customization_ids)) { - Customization::deleteCustomizationFieldLangByShop($customizationFiled['id_customization_field'], $shopList); - } - } - - //remove unused customization for the product - $product->deleteUnusedCustomizationFields($toDeleteCustomizationIds); - - //create new customizations - $countFieldText = 0; - $countFieldFile = 0; - $productCustomizableValue = 0; - $hasRequiredField = false; - - $new_customization_fields_ids = []; - - if ($data) { - foreach ($data as $key => $customization) { - if ($customization['require']) { - $hasRequiredField = true; - } - - //create label - if (isset($customization['id_customization_field'])) { - $id_customization_field = (int) $customization['id_customization_field']; - Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'customization_field` - SET `required` = ' . ($customization['require'] ? 1 : 0) . ', `type` = ' . (int) $customization['type'] . ' - WHERE `id_customization_field` = ' . $id_customization_field); - } else { - Db::getInstance()->execute( - 'INSERT INTO `' . _DB_PREFIX_ . 'customization_field` (`id_product`, `type`, `required`) - VALUES (' - . (int) $product->id . ', ' - . (int) $customization['type'] . ', ' - . ($customization['require'] ? 1 : 0) - . ')' - ); - $id_customization_field = (int) Db::getInstance()->Insert_ID(); - } - - $new_customization_fields_ids[$key] = $id_customization_field; - - // Create multilingual label name - $langValues = ''; - foreach (Language::getLanguages() as $language) { - $name = $customization['label'][$language['id_lang']]; - foreach ($shopList as $id_shop) { - $langValues .= '(' - . (int) $id_customization_field . ', ' - . (int) $language['id_lang'] . ', ' - . (int) $id_shop . ',\'' - . pSQL($name) - . '\'), '; - } - } - Db::getInstance()->execute( - 'INSERT INTO `' . _DB_PREFIX_ . 'customization_field_lang` (`id_customization_field`, `id_lang`, `id_shop`, `name`) VALUES ' - . rtrim( - $langValues, - ', ' - ) - ); - - if ($customization['type'] == Product::CUSTOMIZE_FILE) { - ++$countFieldFile; - } else { - ++$countFieldText; - } - } - - $productCustomizableValue = $hasRequiredField ? 2 : 1; - } - - //update product count fields labels - Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'product` SET `customizable` = ' . $productCustomizableValue . ', `uploadable_files` = ' . (int) $countFieldFile . ', `text_fields` = ' . (int) $countFieldText . ' WHERE `id_product` = ' . (int) $product->id); - - //update product_shop count fields labels - ObjectModel::updateMultishopTable('product', [ - 'customizable' => $productCustomizableValue, - 'uploadable_files' => (int) $countFieldFile, - 'text_fields' => (int) $countFieldText, - ], 'a.id_product = ' . (int) $product->id); - - Configuration::updateGlobalValue('PS_CUSTOMIZATION_FEATURE_ACTIVE', '1'); - - return $new_customization_fields_ids; - } - - /** - * Update product download. - * - * @param object $product - * @param array $data - * - * @return bool - */ - public function updateDownloadProduct($product, $data) - { - $id_product_download = ProductDownload::getIdFromIdProduct((int) $product->id, false); - $download = new ProductDownload($id_product_download ? $id_product_download : null); - - if ((int) $data['is_virtual_file'] == 1) { - $fileName = null; - $file = $data['file']; - - if (!empty($file)) { - $fileName = ProductDownload::getNewFilename(); - $file->move(_PS_DOWNLOAD_DIR_, $fileName); - } - - $product->setDefaultAttribute(0); //reset cache_default_attribute - - $download->id_product = (int) $product->id; - $download->display_filename = $data['name']; - $download->filename = $fileName ? $fileName : $download->filename; - $download->date_add = date('Y-m-d H:i:s'); - $download->date_expiration = $data['expiration_date'] ? $data['expiration_date'] . ' 23:59:59' : ''; - $download->nb_days_accessible = (int) $data['nb_days']; - $download->nb_downloadable = (int) $data['nb_downloadable']; - $download->active = 1; - $download->is_shareable = 0; - - if (!$id_product_download) { - $download->save(); - } else { - $download->update(); - } - } else { - if (!empty($id_product_download)) { - $download->date_expiration = date('Y-m-d H:i:s', time() - 1); - $download->active = 0; - $download->update(); - } - } - - return $download; - } - - /** - * Delete file from a virtual product. - * - * @param object $product - */ - public function processDeleteVirtualProductFile($product) - { - $id_product_download = ProductDownload::getIdFromIdProduct((int) $product->id, false); - $download = new ProductDownload($id_product_download ? $id_product_download : null); - - if ($download && !empty($download->filename)) { - unlink(_PS_DOWNLOAD_DIR_ . $download->filename); - Db::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'product_download` SET filename = "" WHERE `id_product_download` = ' . (int) $download->id); - } - } - - /** - * Delete a virtual product. - * - * @param object $product - */ - public function processDeleteVirtualProduct($product) - { - $id_product_download = ProductDownload::getIdFromIdProduct((int) $product->id, false); - $download = new ProductDownload($id_product_download ? $id_product_download : null); - - if ($download) { - $download->delete(true); - } - } - - /** - * Add attachement file. - * - * @param object $product - * @param array $data - * @param array $locales - * - * @return object|null Attachement - */ - public function processAddAttachment($product, $data, $locales) - { - $attachment = null; - $file = $data['file']; - if (!empty($file)) { - $fileName = sha1(microtime()); - $attachment = new Attachment(); - - foreach ($locales as $locale) { - $attachment->name[(int) $locale['id_lang']] = $data['name']; - $attachment->description[(int) $locale['id_lang']] = $data['description']; - } - - $attachment->file = $fileName; - $attachment->mime = $file->getMimeType(); - $attachment->file_name = $file->getClientOriginalName(); - - $file->move(_PS_DOWNLOAD_DIR_, $fileName); - - if ($attachment->add()) { - $attachment->attachProduct($product->id); - } - } - - return $attachment; - } - - /** - * Process product attachments. - * - * @param object $product - * @param array $data - */ - public function processAttachments($product, $data) - { - Attachment::attachToProduct($product->id, $data); - } - - /** - * Update images positions. - * - * @param array $data Indexed array with id product/position - */ - public function ajaxProcessUpdateImagePosition($data) - { - foreach ($data as $id => $position) { - $img = new Image((int) $id); - $img->position = (int) $position; - $img->update(); - } - } - - /** - * Update image legend and cover. - * - * @param int $idImage - * @param array $data - * - * @return object image - */ - public function ajaxProcessUpdateImage($idImage, $data) - { - $img = new Image((int) $idImage); - if ($data['cover']) { - Image::deleteCover((int) $img->id_product); - $img->cover = 1; - } - $img->legend = $data['legend']; - $img->update(); - - return $img; - } - - /** - * Generate preview URL. - * - * @param object $product - * @param bool $preview - * - * @return string preview url - */ - public function getPreviewUrl($product, $preview = true) - { - $context = Context::getContext(); - $id_lang = Configuration::get('PS_LANG_DEFAULT', null, null, $context->shop->id); - - if (!ShopUrl::getMainShopDomain()) { - return false; - } - - $is_rewrite_active = (bool) Configuration::get('PS_REWRITING_SETTINGS'); - $preview_url = $context->link->getProductLink( - $product, - $product->link_rewrite[$context->language->id], - Category::getLinkRewrite($product->id_category_default, $context->language->id), - null, - $id_lang, - (int) $context->shop->id, - 0, - $is_rewrite_active - ); - - if (!$product->active && $preview) { - $preview_url = $this->getPreviewUrlDeactivate($preview_url); - } - - return $preview_url; - } - - /** - * Generate preview URL deactivate. - * - * @param string $preview_url - * - * @return string preview url deactivate - */ - public function getPreviewUrlDeactivate($preview_url) - { - $context = Context::getContext(); - $token = Tools::getAdminTokenLite('AdminProducts'); - - $admin_dir = dirname($_SERVER['PHP_SELF']); - $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1); - $preview_url_deactivate = $preview_url . ((strpos($preview_url, '?') === false) ? '?' : '&') . 'adtoken=' . $token . '&ad=' . $admin_dir . '&id_employee=' . (int) $context->employee->id . '&preview=1'; - - return $preview_url_deactivate; - } - - /** - * Generate preview URL. - * - * @param int $productId - * - * @return string preview url - */ - public function getPreviewUrlFromId($productId) - { - $product = new Product($productId, false); - - return $this->getPreviewUrl($product); - } -} diff --git a/src/Adapter/Product/AttachmentDataProvider.php b/src/Adapter/Product/AttachmentDataProvider.php deleted file mode 100644 index 1df06665..00000000 --- a/src/Adapter/Product/AttachmentDataProvider.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product; - -use Db; - -/** - * This class will provide data from DB / ORM about attachment. - */ -class AttachmentDataProvider -{ - /** - * Get all attachments. - * - * @param int $id_lang - * - * @return array Attachment - */ - public function getAllAttachments($id_lang) - { - return Db::getInstance()->executeS(' - SELECT * - FROM ' . _DB_PREFIX_ . 'attachment a - LEFT JOIN ' . _DB_PREFIX_ . 'attachment_lang al - ON (a.id_attachment = al.id_attachment AND al.id_lang = ' . (int) $id_lang . ') - '); - } -} diff --git a/src/Adapter/Product/CommandHandler/AssignProductToCategoryHandler.php b/src/Adapter/Product/CommandHandler/AssignProductToCategoryHandler.php deleted file mode 100644 index 27d84b7d..00000000 --- a/src/Adapter/Product/CommandHandler/AssignProductToCategoryHandler.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use PrestaShop\PrestaShop\Adapter\Product\ProductDataProvider; -use PrestaShop\PrestaShop\Core\Domain\Product\Command\AssignProductToCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\Product\CommandHandler\AssignProductToCategoryHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\CannotAssignProductToCategoryException; - -/** - * Adds a category to a product - * - * @internal - */ -final class AssignProductToCategoryHandler extends AbstractObjectModelHandler implements AssignProductToCategoryHandlerInterface -{ - /** - * @param AssignProductToCategoryCommand $command - */ - public function handle(AssignProductToCategoryCommand $command) - { - $this->assignProductToCategory($command); - } - - /** - * @param AssignProductToCategoryCommand $command - * - * @throws CannotAssignProductToCategoryException - */ - private function assignProductToCategory(AssignProductToCategoryCommand $command) - { - $productDataProvider = new ProductDataProvider(); - $product = $productDataProvider->getProductInstance($command->getProductId()->getValue()); - $product->addToCategories($command->getCategoryId()->getValue()); - if (false === $product->save()) { - throw new CannotAssignProductToCategoryException(sprintf('Failed to add category to product %d', $command->getProductId()->getValue())); - } - } -} diff --git a/src/Adapter/Product/CommandHandler/UpdateProductStatusCommandHandler.php b/src/Adapter/Product/CommandHandler/UpdateProductStatusCommandHandler.php deleted file mode 100644 index 1db83e6a..00000000 --- a/src/Adapter/Product/CommandHandler/UpdateProductStatusCommandHandler.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Entity\Product; -use PrestaShop\PrestaShop\Core\Domain\Product\Command\UpdateProductStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Product\CommandHandler\UpdateProductStatusCommandHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\CannotUpdateProductException; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductNotFoundException; - -/** - * @internal - */ -class UpdateProductStatusCommandHandler implements UpdateProductStatusCommandHandlerInterface -{ - /** - * @param UpdateProductStatusCommand $command - */ - public function handle(UpdateProductStatusCommand $command) - { - $productId = $command->getProductId()->getValue(); - $product = new Product($productId); - - if ($product->id !== $productId) { - throw new ProductNotFoundException(sprintf('Product with id "%s" was not found', $productId)); - } - if ($product->active != $command->getEnable()) { - if (!$product->toggleStatus()) { - throw new CannotUpdateProductException(sprintf('Cannot update status for product with id "%s"', $productId)); - } - } - } -} diff --git a/src/Adapter/Product/FilterCategoriesRequestPurifier.php b/src/Adapter/Product/FilterCategoriesRequestPurifier.php deleted file mode 100644 index bba3183d..00000000 --- a/src/Adapter/Product/FilterCategoriesRequestPurifier.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product; - -use Symfony\Component\HttpFoundation\Request; - -/** - * Extracted from Product Controller, used to cleanup the request. - * For internal use only. - */ -final class FilterCategoriesRequestPurifier -{ - const CATEGORY = 'filter_category'; - - /** - * Changes the filter category values in case it is not numeric or signed. - * - * @param Request $request - * - * @return Request - */ - public function purify(Request $request) - { - if ($request->isMethod('POST')) { - $value = $request->request->get(self::CATEGORY); - if (null !== $value && (!is_numeric($value) || $value < 0)) { - $request->request->set(self::CATEGORY, ''); - } - } - - return $request; - } -} diff --git a/src/Adapter/Product/GeneralConfiguration.php b/src/Adapter/Product/GeneralConfiguration.php deleted file mode 100644 index 90897e4c..00000000 --- a/src/Adapter/Product/GeneralConfiguration.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * This class loads and saves general configuration for product. - */ -class GeneralConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'catalog_mode' => $this->configuration->getBoolean('PS_CATALOG_MODE'), - 'catalog_mode_with_prices' => $this->configuration->getBoolean('PS_CATALOG_MODE_WITH_PRICES'), - 'new_days_number' => $this->configuration->get('PS_NB_DAYS_NEW_PRODUCT'), - 'short_description_limit' => $this->configuration->get('PS_PRODUCT_SHORT_DESC_LIMIT'), - 'quantity_discount' => $this->configuration->get('PS_QTY_DISCOUNT_ON_COMBINATION'), - 'force_friendly_url' => $this->configuration->getBoolean('PS_FORCE_FRIENDLY_PRODUCT'), - 'default_status' => $this->configuration->getBoolean('PS_PRODUCT_ACTIVATION_DEFAULT'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $config) - { - $errors = []; - - if ($this->validateConfiguration($config)) { - $catalogMode = (int) $config['catalog_mode']; - $this->configuration->set('PS_CATALOG_MODE', $catalogMode); - $this->configuration->set('PS_CATALOG_MODE_WITH_PRICES', $catalogMode ? (int) $config['catalog_mode_with_prices'] : 0); - $this->configuration->set('PS_NB_DAYS_NEW_PRODUCT', (int) $config['new_days_number']); - $this->configuration->set('PS_PRODUCT_SHORT_DESC_LIMIT', (int) $config['short_description_limit']); - $this->configuration->set('PS_QTY_DISCOUNT_ON_COMBINATION', (int) $config['quantity_discount']); - $this->configuration->set('PS_FORCE_FRIENDLY_PRODUCT', (int) $config['force_friendly_url']); - $this->configuration->set('PS_PRODUCT_ACTIVATION_DEFAULT', (int) $config['default_status']); - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - $resolver = new OptionsResolver(); - $resolver->setRequired([ - 'catalog_mode', - 'catalog_mode_with_prices', - 'new_days_number', - 'short_description_limit', - 'quantity_discount', - 'force_friendly_url', - 'default_status', - ]); - - $resolver->resolve($configuration); - - return true; - } -} diff --git a/src/Adapter/Product/ListParametersUpdater.php b/src/Adapter/Product/ListParametersUpdater.php deleted file mode 100644 index e1aca8d8..00000000 --- a/src/Adapter/Product/ListParametersUpdater.php +++ /dev/null @@ -1,143 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product; - -use PrestaShop\PrestaShop\Core\Exception\ProductException; - -/** - * Can manage filter parameters from request in Product Catalogue Page. - * For internal use only. - */ -final class ListParametersUpdater -{ - /** - * In case of position ordering all the filters should be reset. - * - * @param array $filterParameters - * @param string $orderBy - * @param bool $hasCategoryFilter - * - * @return array $filterParameters - */ - public function cleanFiltersForPositionOrdering($filterParameters, $orderBy, $hasCategoryFilter) - { - if ($orderBy == 'position_ordering' && $hasCategoryFilter) { - foreach (array_keys($filterParameters) as $key) { - if (strpos($key, 'filter_column_') === 0) { - $filterParameters[$key] = ''; - } - } - } - - return $filterParameters; - } - - /** - * @param array $queryFilterParameters - * @param array $persistedFilterParameters - * @param array $defaultFilterParameters - * - * @return array - * - * @throws ProductException - */ - public function buildListParameters( - array $queryFilterParameters, - array $persistedFilterParameters, - array $defaultFilterParameters - ) { - $filters = [ - 'offset' => (int) $this->getParameter( - 'offset', - $queryFilterParameters, - $persistedFilterParameters, - $defaultFilterParameters - ), - 'limit' => (int) $this->getParameter( - 'limit', - $queryFilterParameters, - $persistedFilterParameters, - $defaultFilterParameters - ), - 'orderBy' => (string) $this->getParameter( - 'orderBy', - $queryFilterParameters, - $persistedFilterParameters, - $defaultFilterParameters - ), - 'sortOrder' => (string) $this->getParameter( - 'sortOrder', - $queryFilterParameters, - $persistedFilterParameters, - $defaultFilterParameters - ), - ]; - - /* - * We need to force the sort order when the order by - * is set to position_ordering - */ - if ('position_ordering' === $filters['orderBy']) { - $filters['sortOrder'] = 'asc'; - } - - return $filters; - } - - /** - * @param string $parameterName - * @param array $queryFilterParameters - * @param array $persistedFilterParameters - * @param array $defaultFilterParameters - * - * @return string|int - * - * @throws ProductException - */ - private function getParameter( - $parameterName, - array $queryFilterParameters, - array $persistedFilterParameters, - array $defaultFilterParameters - ) { - if (isset($queryFilterParameters[$parameterName])) { - $value = $queryFilterParameters[$parameterName]; - } elseif (isset($persistedFilterParameters[$parameterName])) { - $value = $persistedFilterParameters[$parameterName]; - } elseif (isset($defaultFilterParameters[$parameterName])) { - $value = $defaultFilterParameters[$parameterName]; - } else { - throw new ProductException('Could not find the parameter %s', 'Admin.Notifications.Error', [$parameterName]); - } - - if ($value === 'last' && isset($persistedFilterParameters['last_' . $parameterName])) { - $value = $persistedFilterParameters['last_' . $parameterName]; - } - - return $value; - } -} diff --git a/src/Adapter/Product/PackItemsManager.php b/src/Adapter/Product/PackItemsManager.php deleted file mode 100644 index 19ace581..00000000 --- a/src/Adapter/Product/PackItemsManager.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product; - -use Pack; -use PrestaShop\PrestaShop\Adapter\ServiceLocator; -use Product; - -/** - * Class responsible of getting information about Pack Items. - */ -class PackItemsManager -{ - /** - * Get the Products contained in the given Pack. - * - * @param \Pack $pack - * @param int $id_lang Optional - * - * @return array(Product) The products contained in this Pack, with special dynamic attributes [pack_quantity, id_pack_product_attribute] - */ - public function getPackItems($pack, $id_lang = false) - { - if ($id_lang === false) { - $configuration = ServiceLocator::get('\\PrestaShop\\PrestaShop\\Core\\ConfigurationInterface'); - $id_lang = (int) $configuration->get('PS_LANG_DEFAULT'); - } - - return Pack::getItems($pack->id, $id_lang); - } - - /** - * Get all Packs that contains the given item in the corresponding declination. - * - * @param Product $item - * @param int $item_attribute_id - * @param bool|int $id_lang Optional - * - * @return array(Pack) The packs that contains the given item, with special dynamic attribute [pack_item_quantity] - */ - public function getPacksContainingItem($item, $item_attribute_id, $id_lang = false) - { - if ($id_lang === false) { - $configuration = ServiceLocator::get('\\PrestaShop\\PrestaShop\\Core\\ConfigurationInterface'); - $id_lang = (int) $configuration->get('PS_LANG_DEFAULT'); - } - - return Pack::getPacksContainingItem($item->id, $item_attribute_id, $id_lang); - } - - /** - * Is this product a pack? - * - * @param Product $product - * - * @return bool - */ - public function isPack($product) - { - return Pack::isPack($product->id); - } - - /** - * Is this product in a pack? - * If $id_product_attribute specified, then will restrict search on the given combination, - * else this method will match a product if at least one of all its combination is in a pack. - * - * @param Product $product - * @param int $id_product_attribute Optional combination of the product - * - * @return bool - */ - public function isPacked($product, $id_product_attribute = false) - { - return Pack::isPacked($product->id, $id_product_attribute); - } -} diff --git a/src/Adapter/Product/PageConfiguration.php b/src/Adapter/Product/PageConfiguration.php deleted file mode 100644 index 0781a9c3..00000000 --- a/src/Adapter/Product/PageConfiguration.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class PageConfiguration is responsible for saving & loading product page configuration. - */ -class PageConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'display_quantities' => $this->configuration->getBoolean('PS_DISPLAY_QTIES'), - 'display_last_quantities' => $this->configuration->get('PS_LAST_QTIES'), - 'display_unavailable_attributes' => $this->configuration->getBoolean('PS_DISP_UNAVAILABLE_ATTR'), - 'allow_add_variant_to_cart_from_listing' => $this->configuration->getBoolean('PS_ATTRIBUTE_CATEGORY_DISPLAY'), - 'attribute_anchor_separator' => $this->configuration->get('PS_ATTRIBUTE_ANCHOR_SEPARATOR'), - 'display_discount_price' => $this->configuration->getBoolean('PS_DISPLAY_DISCOUNT_PRICE'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $config) - { - $errors = []; - - if ($this->validateConfiguration($config)) { - $this->configuration->set('PS_DISPLAY_QTIES', (int) $config['display_quantities']); - $this->configuration->set('PS_LAST_QTIES', (int) $config['display_last_quantities']); - $this->configuration->set('PS_DISP_UNAVAILABLE_ATTR', (int) $config['display_unavailable_attributes']); - $this->configuration->set('PS_ATTRIBUTE_CATEGORY_DISPLAY', (int) $config['allow_add_variant_to_cart_from_listing']); - $this->configuration->set('PS_ATTRIBUTE_ANCHOR_SEPARATOR', $config['attribute_anchor_separator']); - $this->configuration->set('PS_DISPLAY_DISCOUNT_PRICE', (int) $config['display_discount_price']); - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $config) - { - $resolver = new OptionsResolver(); - $resolver->setRequired([ - 'display_quantities', - 'display_last_quantities', - 'display_unavailable_attributes', - 'allow_add_variant_to_cart_from_listing', - 'attribute_anchor_separator', - 'display_discount_price', - ]); - - $resolver->resolve($config); - - return true; - } -} diff --git a/src/Adapter/Product/PaginationConfiguration.php b/src/Adapter/Product/PaginationConfiguration.php deleted file mode 100644 index 75df1752..00000000 --- a/src/Adapter/Product/PaginationConfiguration.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class PaginationConfiguration is responsible for saving & loading pagination configuration for products. - */ -class PaginationConfiguration implements DataConfigurationInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'products_per_page' => $this->configuration->get('PS_PRODUCTS_PER_PAGE'), - 'default_order_by' => $this->configuration->get('PS_PRODUCTS_ORDER_BY'), - 'default_order_way' => $this->configuration->get('PS_PRODUCTS_ORDER_WAY'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $config) - { - $errors = []; - - if ($this->validateConfiguration($config)) { - $this->configuration->set('PS_PRODUCTS_PER_PAGE', (int) $config['products_per_page']); - $this->configuration->set('PS_PRODUCTS_ORDER_BY', (int) $config['default_order_by']); - $this->configuration->set('PS_PRODUCTS_ORDER_WAY', (int) $config['default_order_way']); - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - $resolver = new OptionsResolver(); - $resolver->setRequired([ - 'products_per_page', - 'default_order_by', - 'default_order_way', - ]); - - $resolver->resolve($configuration); - - return true; - } -} diff --git a/src/Adapter/Product/PriceCalculator.php b/src/Adapter/Product/PriceCalculator.php deleted file mode 100644 index b05e4f0b..00000000 --- a/src/Adapter/Product/PriceCalculator.php +++ /dev/null @@ -1,212 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product; - -use Context; -use Product; - -/** - * Access Product price depending on taxes, eco tax, reductions. - */ -class PriceCalculator -{ - /** - * @param int $idProduct Product id - * @param bool $useTax With taxes or not (optional) - * @param int|null $idProductAttribute product attribute id (optional). - * If set to false, do not apply the combination price impact. - * NULL does apply the default combination price impact - * @param int $decimals Number of decimals (optional) - * @param int|null $divisor Useful when paying many time without fees (optional) - * @param bool $onlyReduc Returns only the reduction amount - * @param bool $useReduc Set if the returned amount will include reduction - * @param int $quantity Required for quantity discount application (default value: 1) - * @param bool $forceAssociatedTax DEPRECATED - NOT USED Force to apply the associated tax. - * Only works when the parameter $usetax is true - * @param int|null $idCustomer Customer ID (for customer group reduction) - * @param int|null $idCart Cart ID. Required when the cookie is not accessible - * (e.g., inside a payment module, a cron task...) - * @param int|null $idAddress Customer address ID. Required for price (tax included) - * calculation regarding the guest localization - * @param null $specificPriceOutput If a specific price applies regarding the previous parameters, - * this variable is filled with the corresponding SpecificPrice object - * @param bool $withEcotax insert ecotax in price output - * @param bool $useGroupReduction - * @param Context|null $context - * @param bool $useCustomerPrice - * @param int|null $idCustomization - * - * @return float Product price - */ - public function getProductPrice( - $idProduct, - $useTax = true, - $idProductAttribute = null, - $decimals = 6, - $divisor = null, - $onlyReduc = false, - $useReduc = true, - $quantity = 1, - $forceAssociatedTax = false, - $idCustomer = null, - $idCart = null, - $idAddress = null, - &$specificPriceOutput = null, - $withEcotax = true, - $useGroupReduction = true, - Context $context = null, - $useCustomerPrice = true, - $idCustomization = null - ) { - return Product::getPriceStatic( - $idProduct, - $useTax, - $idProductAttribute, - $decimals, - $divisor, - $onlyReduc, - $useReduc, - $quantity, - $forceAssociatedTax, - $idCustomer, - $idCart, - $idAddress, - $specificPriceOutput, - $withEcotax, - $useGroupReduction, - $context, - $useCustomerPrice, - $idCustomization - ); - } - - /** - * Price calculation / Get product price. - * - * @param int $idShop Shop id - * @param int $idProduct Product id - * @param int $idProductAttribute Product attribute id - * @param int $idCountry Country id - * @param int $idState State id - * @param string $zipCode - * @param int $idCurrency Currency id - * @param int $idGroup Group id - * @param int $quantity Quantity Required for Specific prices : quantity discount application - * @param bool $useTax with (1) or without (0) tax - * @param int $decimals Number of decimals returned - * @param bool $onlyReduc Returns only the reduction amount - * @param bool $useReduc Set if the returned amount will include reduction - * @param bool $withEcotax insert ecotax in price output - * @param null $specificPrice If a specific price applies regarding the previous parameters, - * this variable is filled with the corresponding SpecificPrice object - * @param bool $useGroupReduction - * @param int $idCustomer - * @param bool $useCustomerPrice - * @param int $idCart - * @param int $realQuantity - * @param int $idCustomization - * - * @return float Product price - **/ - public function priceCalculation( - $idShop, - $idProduct, - $idProductAttribute, - $idCountry, - $idState, - $zipCode, - $idCurrency, - $idGroup, - $quantity, - $useTax, - $decimals, - $onlyReduc, - $useReduc, - $withEcotax, - &$specificPrice, - $useGroupReduction, - $idCustomer = 0, - $useCustomerPrice = true, - $idCart = 0, - $realQuantity = 0, - $idCustomization = 0 - ) { - return Product::priceCalculation( - $idShop, - $idProduct, - $idProductAttribute, - $idCountry, - $idState, - $zipCode, - $idCurrency, - $idGroup, - $quantity, - $useTax, - $decimals, - $onlyReduc, - $useReduc, - $withEcotax, - $specificPrice, - $useGroupReduction, - $idCustomer, - $useCustomerPrice, - $idCart, - $realQuantity, - $idCustomization - ); - } - - /** - * @param int $orderId Order id - * @param int $productId Product id - * @param int $combinationId Combination (Product attribute) id - * @param bool $withTaxes With or without taxes - * @param bool $useReduction With or without reduction - * @param bool $withEcoTax With or without ecto tax - * - * @return float|null - * - * @throws \PrestaShopDatabaseException - */ - public function getOrderPrice( - int $orderId, - int $productId, - int $combinationId, - bool $withTaxes, - bool $useReduction, - bool $withEcoTax - ): ?float { - return Product::getPriceFromOrder( - $orderId, - $productId, - $combinationId, - $withTaxes, - $useReduction, - $withEcoTax - ); - } -} diff --git a/src/Adapter/Product/PriceFormatter.php b/src/Adapter/Product/PriceFormatter.php deleted file mode 100644 index b0aeae7d..00000000 --- a/src/Adapter/Product/PriceFormatter.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product; - -use Tools; - -/** - * Format a price depending on locale and currency. - */ -class PriceFormatter -{ - /** - * @param float $price - * @param string|null $currency - * - * @return float - */ - public function convertAmount($price, $currency = null) - { - return (float) Tools::convertPrice($price, $currency); - } - - /** - * @param float $price - * @param string|null $currency - * - * @return string - */ - public function format($price, $currency = null) - { - return Tools::displayPrice($price, $currency); - } - - /** - * @param float $price - * - * @return string - */ - public function convertAndFormat($price) - { - return $this->format($this->convertAmount($price)); - } -} diff --git a/src/Adapter/Product/ProductColorsRetriever.php b/src/Adapter/Product/ProductColorsRetriever.php deleted file mode 100644 index 8f8ea2ca..00000000 --- a/src/Adapter/Product/ProductColorsRetriever.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product; - -use Product; - -/** - * Retrieve colors of a Product, if any. - */ -class ProductColorsRetriever -{ - /** - * @param int $id_product - * - * @return mixed|null - */ - public function getColoredVariants($id_product) - { - $attributesColorList = Product::getAttributesColorList([$id_product]); - - return (is_array($attributesColorList)) ? current($attributesColorList) : null; - } -} diff --git a/src/Adapter/Product/ProductDataProvider.php b/src/Adapter/Product/ProductDataProvider.php deleted file mode 100644 index 59783c1e..00000000 --- a/src/Adapter/Product/ProductDataProvider.php +++ /dev/null @@ -1,166 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product; - -use Context; -use Image; -use Product; -use StockAvailable; - -/** - * This class will provide data from DB / ORM about Product, for both Front and Admin interfaces. - */ -class ProductDataProvider -{ - /** - * Get a new ProductCore instance. - * - * @param null $idProduct - * - * @return Product - */ - public function getProductInstance($idProduct = null) - { - if ($idProduct) { - return new Product($idProduct); - } - - return new Product(); - } - - /** - * Get a product. - * - * @param int $id_product - * @param bool $full - * @param int|null $id_lang - * @param int|null $id_shop - * @param object|null $context - * - * @throws \LogicException If the product id is not set - * - * @return Product $product - */ - public function getProduct($id_product, $full = false, $id_lang = null, $id_shop = null, $context = null) - { - if (!$id_product) { - throw new \LogicException('You need to provide a product id', 5002); - } - - $product = new Product($id_product, $full, $id_lang, $id_shop, $context); - if ($product) { - if (!is_array($product->link_rewrite)) { - $linkRewrite = $product->link_rewrite; - } else { - $linkRewrite = $product->link_rewrite[$id_lang ? $id_lang : key($product->link_rewrite)]; - } - - $cover = Product::getCover($product->id); - $product->image = Context::getContext()->link->getImageLink($linkRewrite, $cover ? $cover['id_image'] : '', 'home_default'); - } - - return $product; - } - - /** - * Get default taxe rate product. - * - * @return int id tax rule group - */ - public function getIdTaxRulesGroup() - { - $product = new Product(); - - return $product->getIdTaxRulesGroup(); - } - - /** - * Get product quantity. - * - * @param int $id_product - * @param int|null $id_product_attribute - * @param bool|null $cache_is_pack - * - * @return int stock - */ - public function getQuantity($id_product, $id_product_attribute = null, $cache_is_pack = null) - { - return Product::getQuantity($id_product, $id_product_attribute, $cache_is_pack); - } - - /** - * @param int $id_product - * @param int $id_product_attribute Optional - * - * @return string - */ - public function getLocation($id_product, $id_product_attribute = 0) - { - return StockAvailable::getLocation($id_product, $id_product_attribute); - } - - /** - * Get associated images to product. - * - * @param int $id_product - * @param int $id_lang - * - * @return array - */ - public function getImages($id_product, $id_lang) - { - $id_shop = (int) Context::getContext()->shop->id; - $data = []; - foreach (Image::getImages($id_lang, $id_product, null, $id_shop) as $image) { - $data[] = $this->getImage($image['id_image']); - } - - return $data; - } - - /** - * Get an image. - * - * @param int $id_image - * - * @return array() - */ - public function getImage($id_image) - { - $imageData = new Image((int) $id_image); - - return [ - 'id' => $imageData->id, - 'id_product' => $imageData->id_product, - 'position' => $imageData->position, - 'cover' => $imageData->cover ? true : false, - 'legend' => $imageData->legend, - 'format' => $imageData->image_format, - 'base_image_url' => _THEME_PROD_DIR_ . $imageData->getImgPath(), - ]; - } -} diff --git a/src/Adapter/Product/QueryHandler/GetProductIsEnabledHandler.php b/src/Adapter/Product/QueryHandler/GetProductIsEnabledHandler.php deleted file mode 100644 index daf477e3..00000000 --- a/src/Adapter/Product/QueryHandler/GetProductIsEnabledHandler.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product\QueryHandler; - -use PrestaShop\PrestaShop\Adapter\Entity\Product; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Product\Query\GetProductIsEnabled; -use PrestaShop\PrestaShop\Core\Domain\Product\QueryHandler\GetProductIsEnabledHandlerInterface; - -/** - * @internal - */ -final class GetProductIsEnabledHandler implements GetProductIsEnabledHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GetProductIsEnabled $query) - { - $productId = $query->getProductId()->getValue(); - $product = new Product($productId); - - if ($product->id !== $productId) { - throw new ProductNotFoundException(sprintf('Product with id "%s" was not found.', $productId)); - } - - return (bool) $product->active; - } -} diff --git a/src/Adapter/Product/QueryHandler/SearchProductsHandler.php b/src/Adapter/Product/QueryHandler/SearchProductsHandler.php deleted file mode 100644 index 58b34773..00000000 --- a/src/Adapter/Product/QueryHandler/SearchProductsHandler.php +++ /dev/null @@ -1,318 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Product\QueryHandler; - -use Address; -use Configuration; -use Currency; -use Order; -use PrestaShop\PrestaShop\Adapter\ContextStateManager; -use PrestaShop\PrestaShop\Adapter\Currency\CurrencyDataProvider; -use PrestaShop\PrestaShop\Adapter\Order\AbstractOrderHandler; -use PrestaShop\PrestaShop\Adapter\Tools; -use PrestaShop\PrestaShop\Core\Domain\Product\Query\SearchProducts; -use PrestaShop\PrestaShop\Core\Domain\Product\QueryHandler\SearchProductsHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Product\QueryResult\FoundProduct; -use PrestaShop\PrestaShop\Core\Domain\Product\QueryResult\ProductCombination; -use PrestaShop\PrestaShop\Core\Domain\Product\QueryResult\ProductCustomizationField; -use PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision; -use PrestaShop\PrestaShop\Core\Localization\LocaleInterface; -use Product; -use Shop; - -/** - * Handles products search using legacy object model - */ -final class SearchProductsHandler extends AbstractOrderHandler implements SearchProductsHandlerInterface -{ - /** - * @var int - */ - private $contextLangId; - - /** - * @var LocaleInterface - */ - private $contextLocale; - - /** - * @var ContextStateManager - */ - private $contextStateManager; - - /** - * @var CurrencyDataProvider - */ - private $currencyDataProvider; - - /** - * @var Tools - */ - private $tools; - - /** - * @param int $contextLangId - * @param LocaleInterface $contextLocale - * @param Tools $tools - * @param CurrencyDataProvider $currencyDataProvider - * @param ContextStateManager $contextStateManager - */ - public function __construct( - int $contextLangId, - LocaleInterface $contextLocale, - Tools $tools, - CurrencyDataProvider $currencyDataProvider, - ContextStateManager $contextStateManager - ) { - $this->contextLangId = $contextLangId; - $this->contextLocale = $contextLocale; - $this->currencyDataProvider = $currencyDataProvider; - $this->tools = $tools; - $this->contextStateManager = $contextStateManager; - } - - /** - * {@inheritdoc} - * - * @param SearchProducts $query - * - * @return array - */ - public function handle(SearchProducts $query): array - { - $currency = $this->currencyDataProvider->getCurrencyByIsoCode($query->getAlphaIsoCode()->getValue()); - $this->contextStateManager - ->setCurrency($currency) - ; - if (null !== $query->getOrderId()) { - $order = $this->getOrder($query->getOrderId()); - $this->contextStateManager - ->setShop(new Shop($order->id_shop)) - ; - } - - try { - $foundProducts = $this->searchProducts($query, $currency); - } finally { - $this->contextStateManager->restorePreviousContext(); - } - - return $foundProducts; - } - - /** - * @param SearchProducts $query - * @param Currency $currency - * - * @return array - */ - private function searchProducts(SearchProducts $query, Currency $currency): array - { - $computingPrecision = new ComputingPrecision(); - $currencyPrecision = $computingPrecision->getPrecision((int) $currency->precision); - - $order = $address = null; - if (null !== $query->getOrderId()) { - $order = $this->getOrder($query->getOrderId()); - $orderAddressId = $order->{Configuration::get('PS_TAX_ADDRESS_TYPE', null, null, $order->id_shop)}; - $address = new Address($orderAddressId); - } - - $products = Product::searchByName( - $this->contextLangId, - $query->getPhrase(), - null, - $query->getResultsLimit() - ); - - $foundProducts = []; - if ($products) { - foreach ($products as $product) { - $foundProduct = $this->createFoundProductFromLegacy( - new Product($product['id_product']), - $query->getAlphaIsoCode()->getValue(), - $currencyPrecision, - $order, - $address - ); - $foundProducts[] = $foundProduct; - } - } - - return $foundProducts; - } - - /** - * @param Product $product - * @param string $isoCodeCurrency - * @param int $computingPrecision - * @param Order|null $order - * @param Address|null $address - * - * @return FoundProduct - */ - private function createFoundProductFromLegacy( - Product $product, - string $isoCodeCurrency, - int $computingPrecision, - ?Order $order = null, - ?Address $address = null - ): FoundProduct { - // It's important to use null (not 0) as attribute ID so that Product::priceCalculation can fallback to default combination - $priceTaxExcluded = $this->getProductPriceForOrder((int) $product->id, null, false, $computingPrecision, $order); - $priceTaxIncluded = $this->getProductPriceForOrder((int) $product->id, null, true, $computingPrecision, $order); - $product->loadStockData(); - - return new FoundProduct( - $product->id, - $product->name[$this->contextLangId], - $this->contextLocale->formatPrice($priceTaxExcluded, $isoCodeCurrency), - $this->tools->round($priceTaxIncluded, $computingPrecision), - $this->tools->round($priceTaxExcluded, $computingPrecision), - $product->getTaxesRate($address), - Product::getQuantity($product->id), - $product->location, - (bool) Product::isAvailableWhenOutOfStock($product->out_of_stock), - $this->getProductCombinations($product, $isoCodeCurrency, $computingPrecision, $order), - $this->getProductCustomizationFields($product) - ); - } - - /** - * @param Product $product - * - * @return ProductCustomizationField[] - */ - private function getProductCustomizationFields(Product $product): array - { - $fields = $product->getCustomizationFields(); - $customizationFields = []; - - if (false !== $fields) { - foreach ($fields as $typeId => $typeFields) { - foreach ($typeFields as $field) { - $customizationField = new ProductCustomizationField( - (int) $field[$this->contextLangId]['id_customization_field'], - (int) $typeId, - $field[$this->contextLangId]['name'], - (bool) $field[$this->contextLangId]['required'] - ); - - $customizationFields[$customizationField->getCustomizationFieldId()] = $customizationField; - } - } - } - - return $customizationFields; - } - - /** - * @param Product $product - * @param string $currencyIsoCode - * @param int $computingPrecision - * @param Order|null $order - * - * @return array - */ - private function getProductCombinations( - Product $product, - string $currencyIsoCode, - int $computingPrecision, - ?Order $order = null - ): array { - $productCombinations = []; - $combinations = $product->getAttributeCombinations(); - - if (false !== $combinations) { - foreach ($combinations as $combination) { - $productAttributeId = (int) $combination['id_product_attribute']; - $attribute = $combination['attribute_name']; - - if (isset($productCombinations[$productAttributeId])) { - $existingAttribute = $productCombinations[$productAttributeId]->getAttribute(); - $attribute = $existingAttribute . ' - ' . $attribute; - } - - $priceTaxExcluded = $this->getProductPriceForOrder((int) $product->id, $productAttributeId, false, $computingPrecision, $order); - $priceTaxIncluded = $this->getProductPriceForOrder((int) $product->id, $productAttributeId, true, $computingPrecision, $order); - - $productCombination = new ProductCombination( - $productAttributeId, - $attribute, - $combination['quantity'], - $this->contextLocale->formatPrice($priceTaxExcluded, $currencyIsoCode), - $priceTaxExcluded, - $priceTaxIncluded, - $combination['location'], - $combination['reference'] - ); - - $productCombinations[$productCombination->getAttributeCombinationId()] = $productCombination; - } - } - - return $productCombinations; - } - - /** - * @param int $productId - * @param int|null $productAttributeId - * @param bool $withTaxes - * @param int $computingPrecision - * @param Order|null $order - * - * @return float - */ - private function getProductPriceForOrder( - int $productId, - ?int $productAttributeId, - bool $withTaxes, - int $computingPrecision, - ?Order $order) - { - if (null === $order) { - return Product::getPriceStatic($productId, $withTaxes, $productAttributeId, $computingPrecision); - } - - return Product::getPriceStatic( - $productId, - $withTaxes, - $productAttributeId, - $computingPrecision, - null, - false, - true, - 1, - false, - $order->id_customer, - $order->id_cart, - $order->{Configuration::get('PS_TAX_ADDRESS_TYPE', null, null, $order->id_shop)} - ); - } -} diff --git a/src/Adapter/Product/StockConfiguration.php b/src/Adapter/Product/StockConfiguration.php deleted file mode 100644 index aa362c74..00000000 --- a/src/Adapter/Product/StockConfiguration.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Product; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class StockConfiguration is responsible for saving & loading products stock configuration. - */ -class StockConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'allow_ordering_oos' => $this->configuration->getBoolean('PS_ORDER_OUT_OF_STOCK'), - 'stock_management' => $this->configuration->getBoolean('PS_STOCK_MANAGEMENT'), - 'in_stock_label' => $this->configuration->get('PS_LABEL_IN_STOCK_PRODUCTS'), - 'oos_allowed_backorders' => $this->configuration->get('PS_LABEL_OOS_PRODUCTS_BOA'), - 'oos_denied_backorders' => $this->configuration->get('PS_LABEL_OOS_PRODUCTS_BOD'), - 'delivery_time' => (array) $this->configuration->get('PS_LABEL_DELIVERY_TIME_AVAILABLE'), - 'oos_delivery_time' => (array) $this->configuration->get('PS_LABEL_DELIVERY_TIME_OOSBOA'), - 'pack_stock_management' => $this->configuration->get('PS_PACK_STOCK_TYPE'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $config) - { - $errors = []; - - if ($this->validateConfiguration($config)) { - $this->configuration->set('PS_ORDER_OUT_OF_STOCK', (int) $config['allow_ordering_oos']); - $this->configuration->set('PS_STOCK_MANAGEMENT', (int) $config['stock_management']); - $this->configuration->set('PS_LABEL_IN_STOCK_PRODUCTS', $config['in_stock_label']); - $this->configuration->set('PS_LABEL_OOS_PRODUCTS_BOA', $config['oos_allowed_backorders']); - $this->configuration->set('PS_LABEL_OOS_PRODUCTS_BOD', $config['oos_denied_backorders']); - $this->configuration->set('PS_LABEL_DELIVERY_TIME_AVAILABLE', $config['delivery_time']); - $this->configuration->set('PS_LABEL_DELIVERY_TIME_OOSBOA', $config['oos_delivery_time']); - $this->configuration->set('PS_PACK_STOCK_TYPE', $config['pack_stock_management']); - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - $resolver = new OptionsResolver(); - $resolver->setRequired([ - 'allow_ordering_oos', - 'stock_management', - 'in_stock_label', - 'delivery_time', - 'oos_allowed_backorders', - 'oos_delivery_time', - 'oos_denied_backorders', - 'pack_stock_management', - ]); - - $resolver->resolve($configuration); - - return true; - } -} diff --git a/src/Adapter/Profile/CommandHandler/AbstractProfileHandler.php b/src/Adapter/Profile/CommandHandler/AbstractProfileHandler.php deleted file mode 100644 index f6d4922d..00000000 --- a/src/Adapter/Profile/CommandHandler/AbstractProfileHandler.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile\CommandHandler; - -use Employee; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\FailedToDeleteProfileException; -use Profile; - -/** - * @internal - */ -abstract class AbstractProfileHandler -{ - /** - * Checks if given profile is not assigned to any employee. - * - * @param Profile $profile - * - * @throws FailedToDeleteProfileException - */ - protected function assertProfileIsNotAssignedToEmployee(Profile $profile) - { - $profileEmployees = Employee::getEmployeesByProfile($profile->id); - - if (!empty($profileEmployees)) { - throw new FailedToDeleteProfileException(sprintf('Failed to delete profile with id "%d", because it is assigned to employee.', $profile->id), FailedToDeleteProfileException::PROFILE_IS_ASSIGNED_TO_EMPLOYEE); - } - } -} diff --git a/src/Adapter/Profile/CommandHandler/AddProfileHandler.php b/src/Adapter/Profile/CommandHandler/AddProfileHandler.php deleted file mode 100644 index f0bd4d88..00000000 --- a/src/Adapter/Profile/CommandHandler/AddProfileHandler.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Profile\Command\AddProfileCommand; -use PrestaShop\PrestaShop\Core\Domain\Profile\CommandHandler\AddProfileHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\ProfileException; -use PrestaShop\PrestaShop\Core\Domain\Profile\ValueObject\ProfileId; -use Profile; - -/** - * Adds new employee profile using legacy object model - */ -final class AddProfileHandler implements AddProfileHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(AddProfileCommand $command) - { - $profile = new Profile(); - $profile->name = $command->getLocalizedNames(); - - if (false === $profile->validateFieldsLang(false)) { - throw new ProfileException('Cannot create Profile because it contains invalid data'); - } - - if (false === $profile->add()) { - throw new ProfileException('Failed to create Profile'); - } - - return new ProfileId((int) $profile->id); - } -} diff --git a/src/Adapter/Profile/CommandHandler/BulkDeleteProfileHandler.php b/src/Adapter/Profile/CommandHandler/BulkDeleteProfileHandler.php deleted file mode 100644 index 7d569204..00000000 --- a/src/Adapter/Profile/CommandHandler/BulkDeleteProfileHandler.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Profile\Command\BulkDeleteProfileCommand; -use PrestaShop\PrestaShop\Core\Domain\Profile\CommandHandler\BulkDeleteProfileHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\CannotDeleteSuperAdminProfileException; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\FailedToDeleteProfileException; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\ProfileException; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\ProfileNotFoundException; -use PrestaShop\PrestaShop\Core\Employee\ContextEmployeeProviderInterface; -use PrestaShopException; -use Profile; - -/** - * Class BulkDeleteProfileHandler - * - * @internal - */ -final class BulkDeleteProfileHandler extends AbstractProfileHandler implements BulkDeleteProfileHandlerInterface -{ - /** - * @var int - */ - private $superAdminProfileId; - - /** - * @var ContextEmployeeProviderInterface - */ - private $contextEmployeeProvider; - - /** - * @param int $superAdminProfileId - * @param ContextEmployeeProviderInterface $contextEmployeeProvider - */ - public function __construct($superAdminProfileId, ContextEmployeeProviderInterface $contextEmployeeProvider) - { - $this->superAdminProfileId = $superAdminProfileId; - $this->contextEmployeeProvider = $contextEmployeeProvider; - } - - /** - * {@inheritdoc} - */ - public function handle(BulkDeleteProfileCommand $command) - { - $entityIds = $command->getProfileIds(); - - foreach ($entityIds as $entityId) { - $entityIdValue = $entityId->getValue(); - - try { - $entity = new Profile($entityIdValue); - - if ($entity->id != $entityIdValue) { - throw new ProfileNotFoundException(sprintf('Profile with id %s cannot be found.', var_export($entityIdValue, true))); - } - - if ($this->contextEmployeeProvider->getProfileId() === $entity->id) { - throw new FailedToDeleteProfileException(sprintf('Failed to delete Profile with id %s', var_export($entityIdValue, true)), FailedToDeleteProfileException::PROFILE_IS_ASSIGNED_TO_CONTEXT_EMPLOYEE); - } - - if ($entity->id == $this->superAdminProfileId) { - throw new CannotDeleteSuperAdminProfileException(sprintf('Cannot delete Profile with id %s', var_export($entityIdValue, true))); - } - - $this->assertProfileIsNotAssignedToEmployee($entity); - - if (false === $entity->delete()) { - throw new FailedToDeleteProfileException(sprintf('Failed to delete Profile with id %s', var_export($entityIdValue, true)), FailedToDeleteProfileException::UNEXPECTED_ERROR); - } - } catch (PrestaShopException $e) { - throw new ProfileException(sprintf('Unexpected error occurred when deleting Profile with id %s', var_export($entityIdValue, true)), 0, $e); - } - } - } -} diff --git a/src/Adapter/Profile/CommandHandler/DeleteProfileHandler.php b/src/Adapter/Profile/CommandHandler/DeleteProfileHandler.php deleted file mode 100644 index e2e87a2e..00000000 --- a/src/Adapter/Profile/CommandHandler/DeleteProfileHandler.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Profile\Command\DeleteProfileCommand; -use PrestaShop\PrestaShop\Core\Domain\Profile\CommandHandler\DeleteProfileHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\CannotDeleteSuperAdminProfileException; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\FailedToDeleteProfileException; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\ProfileException; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\ProfileNotFoundException; -use PrestaShop\PrestaShop\Core\Employee\ContextEmployeeProviderInterface; -use PrestaShopException; -use Profile; - -/** - * Class DeleteProfileHandler - * - * @internal - */ -final class DeleteProfileHandler extends AbstractProfileHandler implements DeleteProfileHandlerInterface -{ - /** - * @var int - */ - private $superAdminProfileId; - - /** - * @var ContextEmployeeProviderInterface - */ - private $contextEmployeeProvider; - - /** - * @param int $superAdminProfileId - * @param ContextEmployeeProviderInterface $contextEmployeeProvider - */ - public function __construct($superAdminProfileId, ContextEmployeeProviderInterface $contextEmployeeProvider) - { - $this->superAdminProfileId = $superAdminProfileId; - $this->contextEmployeeProvider = $contextEmployeeProvider; - } - - /** - * {@inheritdoc} - */ - public function handle(DeleteProfileCommand $command) - { - $entityId = $command->getProfileId()->getValue(); - - try { - $entity = new Profile($entityId); - - if ($entity->id != $entityId) { - throw new ProfileNotFoundException(sprintf('Profile with id %s cannot be found.', var_export($entityId, true))); - } - - if ($this->contextEmployeeProvider->getProfileId() === $entity->id) { - throw new FailedToDeleteProfileException(sprintf('Failed to delete Profile with id %s', var_export($entityId, true)), FailedToDeleteProfileException::PROFILE_IS_ASSIGNED_TO_CONTEXT_EMPLOYEE); - } - - $this->assertProfileIsNotAssignedToEmployee($entity); - - if ($entity->id == $this->superAdminProfileId) { - throw new CannotDeleteSuperAdminProfileException(sprintf('Cannot delete Profile with id %s', var_export($entityId, true))); - } - - if (false === $entity->delete()) { - throw new FailedToDeleteProfileException(sprintf('Failed to delete Profile with id %s', var_export($entityId, true))); - } - } catch (PrestaShopException $e) { - throw new ProfileException(sprintf('Unexpected error occurred when deleting Profile with id %s', var_export($entityId, true)), 0, $e); - } - } -} diff --git a/src/Adapter/Profile/CommandHandler/EditProfileHandler.php b/src/Adapter/Profile/CommandHandler/EditProfileHandler.php deleted file mode 100644 index 9d147e2f..00000000 --- a/src/Adapter/Profile/CommandHandler/EditProfileHandler.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Profile\Command\EditProfileCommand; -use PrestaShop\PrestaShop\Core\Domain\Profile\CommandHandler\EditProfileHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\ProfileException; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\ProfileNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Profile\ValueObject\ProfileId; -use Profile; - -/** - * Edits Profile using legacy object model - */ -final class EditProfileHandler implements EditProfileHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(EditProfileCommand $command) - { - $profile = $this->getProfile($command->getProfileId()); - $profile->name = $command->getLocalizedNames(); - - if (false === $profile->validateFieldsLang(false)) { - throw new ProfileException('Cannot edit Profile because it contains invalid data'); - } - - if (false === $profile->update()) { - throw new ProfileException('Failed to edit Profile'); - } - } - - /** - * @param ProfileId $profileId - * - * @return Profile - * - * @throws ProfileNotFoundException - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - private function getProfile(ProfileId $profileId) - { - $profile = new Profile($profileId->getValue()); - - if ($profile->id !== $profileId->getValue()) { - throw new ProfileNotFoundException(sprintf('Profile with id "%s" was not found', $profileId->getValue())); - } - - return $profile; - } -} diff --git a/src/Adapter/Profile/Employee/AbstractEmployeeHandler.php b/src/Adapter/Profile/Employee/AbstractEmployeeHandler.php deleted file mode 100644 index cb03b9bc..00000000 --- a/src/Adapter/Profile/Employee/AbstractEmployeeHandler.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile\Employee; - -use Employee; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; - -abstract class AbstractEmployeeHandler -{ - /** - * @param EmployeeId $employeeId - * - * @return Employee - * - * @throws EmployeeNotFoundException - */ - protected function getEmployee(EmployeeId $employeeId): Employee - { - $employee = new Employee($employeeId->getValue()); - - if ($employee->id !== $employeeId->getValue()) { - throw new EmployeeNotFoundException($employeeId, sprintf('Employee with id "%s" was not found', $employeeId->getValue())); - } - - return $employee; - } -} diff --git a/src/Adapter/Profile/Employee/CommandHandler/AbstractEmployeeHandler.php b/src/Adapter/Profile/Employee/CommandHandler/AbstractEmployeeHandler.php deleted file mode 100644 index b5130ca1..00000000 --- a/src/Adapter/Profile/Employee/CommandHandler/AbstractEmployeeHandler.php +++ /dev/null @@ -1,98 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile\Employee\CommandHandler; - -use Context; -use Employee; -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\AdminEmployeeException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\CannotDeleteWarehouseManagerException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeCannotChangeItselfException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; -use Warehouse; - -/** - * Class AbstractEmployeeStatusHandler. - */ -abstract class AbstractEmployeeHandler extends AbstractObjectModelHandler -{ - /** - * @param EmployeeId $employeeId - * @param Employee $employee - * - * @throws EmployeeNotFoundException - */ - protected function assertEmployeeWasFoundById(EmployeeId $employeeId, Employee $employee) - { - if (!$employee->id) { - throw new EmployeeNotFoundException($employeeId, sprintf('Employee with id "%s" cannot be found.', $employeeId->getValue())); - } - } - - /** - * If employee is admin and no other admins exists, then terminate command execution. - * - * @param Employee $employee - */ - protected function assertEmployeeIsNotTheOnlyAdminInShop(Employee $employee) - { - if ($employee->isLastAdmin()) { - throw new AdminEmployeeException(sprintf('Employee with id %s is the only admin in shop and status cannot be changed.', $employee->id), AdminEmployeeException::CANNOT_CHANGE_LAST_ADMIN); - } - } - - /** - * If logged in employee is trying to toggle itself, then terminate execution. - * - * @param Employee $employee - */ - protected function assertLoggedInEmployeeIsNotTheSameAsBeingUpdatedEmployee(Employee $employee) - { - if (Context::getContext()->employee->id === $employee->id) { - throw new EmployeeCannotChangeItselfException('Employee cannot change status of itself.', EmployeeCannotChangeItselfException::CANNOT_CHANGE_STATUS); - } - } - - /** - * Make sure that given employee does not manage any warehouse. - * - * Even though Warehouse feature was removed in 1.7 - * but the code related to it still exists - * thus assertion is kept for BC i guess. - * - * @param Employee $employee - */ - protected function assertEmployeeDoesNotManageWarehouse(Employee $employee) - { - $warehouses = Warehouse::getWarehousesByEmployee($employee->id); - - if (count($warehouses) > 0) { - throw new CannotDeleteWarehouseManagerException(sprintf('Employee with id %s is warehouse manager and cannot be deleted.', $employee->id)); - } - } -} diff --git a/src/Adapter/Profile/Employee/CommandHandler/AddEmployeeHandler.php b/src/Adapter/Profile/Employee/CommandHandler/AddEmployeeHandler.php deleted file mode 100644 index 7efec336..00000000 --- a/src/Adapter/Profile/Employee/CommandHandler/AddEmployeeHandler.php +++ /dev/null @@ -1,140 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile\Employee\CommandHandler; - -use Employee; -use PrestaShop\PrestaShop\Core\Crypto\Hashing; -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\AddEmployeeCommand; -use PrestaShop\PrestaShop\Core\Domain\Employee\CommandHandler\AddEmployeeHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmailAlreadyUsedException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\InvalidProfileException; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; -use PrestaShop\PrestaShop\Core\Employee\Access\ProfileAccessCheckerInterface; -use PrestaShop\PrestaShop\Core\Employee\ContextEmployeeProviderInterface; - -/** - * Handles command which adds new employee using legacy object model - * - * @internal - */ -final class AddEmployeeHandler extends AbstractEmployeeHandler implements AddEmployeeHandlerInterface -{ - /** - * @var Hashing - */ - private $hashing; - - /** - * @var ProfileAccessCheckerInterface - */ - private $profileAccessChecker; - - /** - * @var ContextEmployeeProviderInterface - */ - private $contextEmployeeProvider; - - /** - * @param Hashing $hashing - * @param ProfileAccessCheckerInterface $profileAccessChecker - * @param ContextEmployeeProviderInterface $contextEmployeeProvider - */ - public function __construct( - Hashing $hashing, - ProfileAccessCheckerInterface $profileAccessChecker, - ContextEmployeeProviderInterface $contextEmployeeProvider - ) { - $this->hashing = $hashing; - $this->profileAccessChecker = $profileAccessChecker; - $this->contextEmployeeProvider = $contextEmployeeProvider; - } - - /** - * {@inheritdoc} - */ - public function handle(AddEmployeeCommand $command) - { - $canAccessProfile = $this->profileAccessChecker->canEmployeeAccessProfile( - $this->contextEmployeeProvider->getId(), - (int) $command->getProfileId() - ); - - if (!$canAccessProfile) { - throw new InvalidProfileException('You cannot access the provided profile.'); - } - - $this->assertEmailIsNotAlreadyUsed($command->getEmail()->getValue()); - - $employee = $this->createLegacyEmployeeObjectFromCommand($command); - - $this->associateWithShops($employee, $command->getShopAssociation()); - - return new EmployeeId((int) $employee->id); - } - - /** - * Create legacy employee object. - * - * @param AddEmployeeCommand $command - * - * @return Employee - */ - private function createLegacyEmployeeObjectFromCommand(AddEmployeeCommand $command) - { - $employee = new Employee(); - $employee->firstname = $command->getFirstName()->getValue(); - $employee->lastname = $command->getLastName()->getValue(); - $employee->email = $command->getEmail()->getValue(); - $employee->id_lang = $command->getLanguageId(); - $employee->id_profile = $command->getProfileId(); - $employee->default_tab = $command->getDefaultPageId(); - $employee->active = $command->isActive(); - $employee->passwd = $this->hashing->hash($command->getPlainPassword()->getValue()); - $employee->id_last_order = $employee->getLastElementsForNotify('order'); - $employee->id_last_customer_message = $employee->getLastElementsForNotify('customer_message'); - $employee->id_last_customer = $employee->getLastElementsForNotify('customer'); - - if (false === $employee->add()) { - throw new EmployeeException(sprintf('Failed to add new employee with email "%s"', $command->getEmail()->getValue())); - } - - return $employee; - } - - /** - * @param string $email - * - * @throws EmailAlreadyUsedException - */ - private function assertEmailIsNotAlreadyUsed($email) - { - if (Employee::employeeExists($email)) { - throw new EmailAlreadyUsedException($email, 'An account already exists for this email address'); - } - } -} diff --git a/src/Adapter/Profile/Employee/CommandHandler/BulkDeleteEmployeeHandler.php b/src/Adapter/Profile/Employee/CommandHandler/BulkDeleteEmployeeHandler.php deleted file mode 100644 index 0374ebed..00000000 --- a/src/Adapter/Profile/Employee/CommandHandler/BulkDeleteEmployeeHandler.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile\Employee\CommandHandler; - -use Employee; -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\BulkDeleteEmployeeCommand; -use PrestaShop\PrestaShop\Core\Domain\Employee\CommandHandler\BulkDeleteEmployeeHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\CannotDeleteEmployeeException; - -/** - * Class BulkDeleteEmployeeHandler. - */ -final class BulkDeleteEmployeeHandler extends AbstractEmployeeHandler implements BulkDeleteEmployeeHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(BulkDeleteEmployeeCommand $command) - { - foreach ($command->getEmployeeIds() as $employeeId) { - $employee = new Employee($employeeId->getValue()); - - $this->assertEmployeeWasFoundById($employeeId, $employee); - $this->assertLoggedInEmployeeIsNotTheSameAsBeingUpdatedEmployee($employee); - $this->assertEmployeeIsNotTheOnlyAdminInShop($employee); - $this->assertEmployeeDoesNotManageWarehouse($employee); - - if (!$employee->delete()) { - throw new CannotDeleteEmployeeException($employeeId, sprintf('Cannot delete employee with id "%s".', $employeeId->getValue())); - } - } - } -} diff --git a/src/Adapter/Profile/Employee/CommandHandler/BulkUpdateEmployeeStatusHandler.php b/src/Adapter/Profile/Employee/CommandHandler/BulkUpdateEmployeeStatusHandler.php deleted file mode 100644 index ed3cbcd9..00000000 --- a/src/Adapter/Profile/Employee/CommandHandler/BulkUpdateEmployeeStatusHandler.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile\Employee\CommandHandler; - -use Employee; -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\BulkUpdateEmployeeStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Employee\CommandHandler\BulkUpdateEmployeeStatusHandlerInterface; - -/** - * Class BulkUpdateEmployeeStatusHandler. - */ -final class BulkUpdateEmployeeStatusHandler extends AbstractEmployeeHandler implements BulkUpdateEmployeeStatusHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(BulkUpdateEmployeeStatusCommand $command) - { - foreach ($command->getEmployeeIds() as $employeeId) { - $employee = new Employee($employeeId->getValue()); - - $this->assertEmployeeWasFoundById($employeeId, $employee); - $this->assertLoggedInEmployeeIsNotTheSameAsBeingUpdatedEmployee($employee); - $this->assertEmployeeIsNotTheOnlyAdminInShop($employee); - - $employee->active = $command->getStatus(); - $employee->save(); - } - } -} diff --git a/src/Adapter/Profile/Employee/CommandHandler/DeleteEmployeeHandler.php b/src/Adapter/Profile/Employee/CommandHandler/DeleteEmployeeHandler.php deleted file mode 100644 index d26cd017..00000000 --- a/src/Adapter/Profile/Employee/CommandHandler/DeleteEmployeeHandler.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile\Employee\CommandHandler; - -use Employee; -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\DeleteEmployeeCommand; -use PrestaShop\PrestaShop\Core\Domain\Employee\CommandHandler\DeleteEmployeeHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\CannotDeleteEmployeeException; - -/** - * Class DeleteEmployeeHandler. - */ -final class DeleteEmployeeHandler extends AbstractEmployeeHandler implements DeleteEmployeeHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(DeleteEmployeeCommand $command) - { - $employeeId = $command->getEmployeeId(); - $employee = new Employee($employeeId->getValue()); - - $this->assertEmployeeWasFoundById($employeeId, $employee); - $this->assertLoggedInEmployeeIsNotTheSameAsBeingUpdatedEmployee($employee); - $this->assertEmployeeIsNotTheOnlyAdminInShop($employee); - $this->assertEmployeeDoesNotManageWarehouse($employee); - - if (!$employee->delete()) { - throw new CannotDeleteEmployeeException($employeeId, sprintf('Cannot delete employee with id "%s".', $employeeId->getValue())); - } - } -} diff --git a/src/Adapter/Profile/Employee/CommandHandler/EditEmployeeHandler.php b/src/Adapter/Profile/Employee/CommandHandler/EditEmployeeHandler.php deleted file mode 100644 index dbd7f35a..00000000 --- a/src/Adapter/Profile/Employee/CommandHandler/EditEmployeeHandler.php +++ /dev/null @@ -1,190 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile\Employee\CommandHandler; - -use Employee; -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use PrestaShop\PrestaShop\Core\Crypto\Hashing; -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\EditEmployeeCommand; -use PrestaShop\PrestaShop\Core\Domain\Employee\CommandHandler\EditEmployeeHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmailAlreadyUsedException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\InvalidProfileException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\MissingShopAssociationException; -use PrestaShop\PrestaShop\Core\Employee\Access\ProfileAccessCheckerInterface; -use PrestaShop\PrestaShop\Core\Employee\ContextEmployeeProviderInterface; -use Shop; - -/** - * Handles command which edits employee using legacy object model - * - * @internal - */ -final class EditEmployeeHandler extends AbstractEmployeeHandler implements EditEmployeeHandlerInterface -{ - /** - * @var Hashing - */ - private $hashing; - - /** - * @var ProfileAccessCheckerInterface - */ - private $profileAccessChecker; - - /** - * @var ContextEmployeeProviderInterface - */ - private $contextEmployeeProvider; - - /** - * @var LegacyContext - */ - private $legacyContext; - - /** - * @param Hashing $hashing - * @param ProfileAccessCheckerInterface $profileAccessChecker - * @param ContextEmployeeProviderInterface $contextEmployeeProvider - * @param LegacyContext $legacyContext - */ - public function __construct( - Hashing $hashing, - ProfileAccessCheckerInterface $profileAccessChecker, - ContextEmployeeProviderInterface $contextEmployeeProvider, - LegacyContext $legacyContext - ) { - $this->hashing = $hashing; - $this->profileAccessChecker = $profileAccessChecker; - $this->contextEmployeeProvider = $contextEmployeeProvider; - $this->legacyContext = $legacyContext; - } - - /** - * {@inheritdoc} - */ - public function handle(EditEmployeeCommand $command) - { - $canAccessProfile = $this->profileAccessChecker->canEmployeeAccessProfile( - $this->contextEmployeeProvider->getId(), - (int) $command->getProfileId() - ); - - if (!$canAccessProfile) { - throw new InvalidProfileException('You cannot access the provided profile.'); - } - - $employee = new Employee($command->getEmployeeId()->getValue()); - - $this->assertEmailIsNotAlreadyUsed($employee, $command->getEmail()->getValue()); - - $this->updateEmployeeWithCommandData($employee, $command); - - if (null !== $command->getPlainPassword() && $employee->id == $this->contextEmployeeProvider->getId()) { - $this->updatePasswordInCookie($employee); - } - } - - /** - * Update employee object model with data from employee edit command. - * - * @param Employee $employee - * @param EditEmployeeCommand $command - * - * @throws EmployeeException - */ - private function updateEmployeeWithCommandData(Employee $employee, EditEmployeeCommand $command) - { - $employee->firstname = $command->getFirstName()->getValue(); - $employee->lastname = $command->getLastName()->getValue(); - $employee->email = $command->getEmail()->getValue(); - $employee->default_tab = $command->getDefaultPageId(); - $employee->id_lang = $command->getLanguageId(); - $employee->id_last_order = $employee->getLastElementsForNotify('order'); - $employee->id_last_customer_message = $employee->getLastElementsForNotify('customer_message'); - $employee->id_last_customer = $employee->getLastElementsForNotify('customer'); - - // Allow changing profile and active status only when editing not own account. - if ($employee->id != $this->contextEmployeeProvider->getId()) { - $employee->id_profile = $command->getProfileId(); - $employee->active = $command->isActive(); - } - - $shopAssociation = $command->getShopAssociation(); - - if (!$employee->isSuperAdmin() && empty($shopAssociation)) { - throw new MissingShopAssociationException('Employee must be associated to at least one shop.'); - } - - if (null !== $command->getPlainPassword()) { - $employee->passwd = $this->hashing->hash($command->getPlainPassword()->getValue()); - } - - if (false === $employee->update()) { - throw new EmployeeException(sprintf('Cannot update employee with id "%s"', $employee->id)); - } - - if ($employee->isSuperAdmin()) { - $shopAssociation = array_values(Shop::getShops(false, null, true)); - } - - // Allow changing shop association only when editing not own account. - if (null !== $shopAssociation && $employee->id != $this->contextEmployeeProvider->getId()) { - $this->associateWithShops($employee, $shopAssociation); - } - } - - /** - * @param Employee $employee - * @param string $email - * - * @throws EmailAlreadyUsedException - */ - private function assertEmailIsNotAlreadyUsed(Employee $employee, $email) - { - // Don't count own email as usage. - if ($employee->email === $email) { - return; - } - - if (Employee::employeeExists($email)) { - throw new EmailAlreadyUsedException($email, 'An account already exists for this email address'); - } - } - - /** - * Update employee password in cookie. - * - * @param Employee $employee - */ - private function updatePasswordInCookie(Employee $employee) - { - $this->legacyContext->getContext()->cookie->passwd = $employee->passwd; - $this->legacyContext->getContext()->employee->passwd = $employee->passwd; - $this->legacyContext->getContext()->cookie->write(); - } -} diff --git a/src/Adapter/Profile/Employee/CommandHandler/ToggleEmployeeStatusHandler.php b/src/Adapter/Profile/Employee/CommandHandler/ToggleEmployeeStatusHandler.php deleted file mode 100644 index 90307344..00000000 --- a/src/Adapter/Profile/Employee/CommandHandler/ToggleEmployeeStatusHandler.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile\Employee\CommandHandler; - -use Employee; -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\ToggleEmployeeStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Employee\CommandHandler\ToggleEmployeeStatusHandlerInterface; - -/** - * Class ToggleEmployeeStatusHandler encapsulates Employee status toggling using legacy Employee object model. - */ -final class ToggleEmployeeStatusHandler extends AbstractEmployeeHandler implements ToggleEmployeeStatusHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(ToggleEmployeeStatusCommand $command) - { - $employeeId = $command->getEmployeeId(); - $employee = new Employee($employeeId->getValue()); - - $this->assertEmployeeWasFoundById($employeeId, $employee); - $this->assertLoggedInEmployeeIsNotTheSameAsBeingUpdatedEmployee($employee); - $this->assertEmployeeIsNotTheOnlyAdminInShop($employee); - - $employee->toggleStatus(); - } -} diff --git a/src/Adapter/Profile/Employee/QueryHandler/GetEmployeeEmailByIdHandler.php b/src/Adapter/Profile/Employee/QueryHandler/GetEmployeeEmailByIdHandler.php deleted file mode 100644 index 3ab59077..00000000 --- a/src/Adapter/Profile/Employee/QueryHandler/GetEmployeeEmailByIdHandler.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile\Employee\QueryHandler; - -use PrestaShop\PrestaShop\Adapter\Profile\Employee\AbstractEmployeeHandler; -use PrestaShop\PrestaShop\Core\Domain\Employee\Query\GetEmployeeEmailById; -use PrestaShop\PrestaShop\Core\Domain\Employee\QueryHandler\GetEmployeeEmailByIdHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -final class GetEmployeeEmailByIdHandler extends AbstractEmployeeHandler implements GetEmployeeEmailByIdHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GetEmployeeEmailById $query): Email - { - $employee = $this->getEmployee($query->getEmployeeId()); - - return new Email($employee->email); - } -} diff --git a/src/Adapter/Profile/Employee/QueryHandler/GetEmployeeForEditingHandler.php b/src/Adapter/Profile/Employee/QueryHandler/GetEmployeeForEditingHandler.php deleted file mode 100644 index d394962c..00000000 --- a/src/Adapter/Profile/Employee/QueryHandler/GetEmployeeForEditingHandler.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile\Employee\QueryHandler; - -use Employee; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Query\GetEmployeeForEditing; -use PrestaShop\PrestaShop\Core\Domain\Employee\QueryHandler\GetEmployeeForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Employee\QueryResult\EditableEmployee; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\FirstName; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\LastName; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -/** - * Handles command that gets employee for editing. - */ -final class GetEmployeeForEditingHandler implements GetEmployeeForEditingHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GetEmployeeForEditing $query) - { - $employeeId = $query->getEmployeeId(); - $employee = new Employee($employeeId->getValue()); - - if ($employee->id !== $employeeId->getValue()) { - throw new EmployeeNotFoundException($employeeId, sprintf('Employee with id "%s" was not found', $employeeId->getValue())); - } - - return new EditableEmployee( - $employeeId, - new FirstName($employee->firstname), - new LastName($employee->lastname), - new Email($employee->email), - $employee->getImage(), - (int) $employee->default_tab, - (int) $employee->id_lang, - (bool) $employee->active, - (int) $employee->id_profile, - $employee->getAssociatedShops() - ); - } -} diff --git a/src/Adapter/Profile/ProfileDataProvider.php b/src/Adapter/Profile/ProfileDataProvider.php deleted file mode 100644 index 0f2f3e39..00000000 --- a/src/Adapter/Profile/ProfileDataProvider.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile; - -use PrestaShop\PrestaShop\Core\Employee\ContextEmployeeProviderInterface; -use Profile; - -/** - * Class ProfileDataProvider provides employee profile data using legacy logic. - */ -class ProfileDataProvider -{ - /** - * @var ContextEmployeeProviderInterface - */ - private $contextEmployeeProvider; - - /** - * @var int - */ - private $superAdminProfileId; - - /** - * @param ContextEmployeeProviderInterface $contextEmployeeProvider - * @param int $superAdminProfileId - */ - public function __construct( - ContextEmployeeProviderInterface $contextEmployeeProvider, - $superAdminProfileId - ) { - $this->contextEmployeeProvider = $contextEmployeeProvider; - $this->superAdminProfileId = $superAdminProfileId; - } - - /** - * Get employee profiles. - * - * @param int $languageId - * - * @return array - */ - public function getProfiles($languageId) - { - $profiles = Profile::getProfiles($languageId); - - if ($profiles && !$this->contextEmployeeProvider->isSuperAdmin()) { - foreach ($profiles as $key => $profile) { - if ($profile['id_profile'] == $this->superAdminProfileId) { - unset($profiles[$key]); - break; - } - } - } - - return $profiles ?: []; - } -} diff --git a/src/Adapter/Profile/QueryHandler/GetProfileForEditingHandler.php b/src/Adapter/Profile/QueryHandler/GetProfileForEditingHandler.php deleted file mode 100644 index b8dfc975..00000000 --- a/src/Adapter/Profile/QueryHandler/GetProfileForEditingHandler.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Profile\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\ProfileNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Profile\Query\GetProfileForEditing; -use PrestaShop\PrestaShop\Core\Domain\Profile\QueryHandler\GetProfileForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Profile\QueryResult\EditableProfile; -use PrestaShop\PrestaShop\Core\Domain\Profile\ValueObject\ProfileId; -use Profile; - -/** - * Gets Profile for editing using legacy object model - */ -final class GetProfileForEditingHandler implements GetProfileForEditingHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GetProfileForEditing $query) - { - $profile = $this->getProfile($query->getProfileId()); - - return new EditableProfile( - $query->getProfileId(), - $profile->name - ); - } - - /** - * @param ProfileId $profileId - * - * @return Profile - * - * @throws ProfileNotFoundException - */ - private function getProfile(ProfileId $profileId) - { - $profile = new Profile($profileId->getValue()); - - if ($profile->id !== $profileId->getValue()) { - throw new ProfileNotFoundException(sprintf('Profile with id "%s" was not found', $profileId->getValue())); - } - - return $profile; - } -} diff --git a/src/Adapter/Requirement/CheckMissingOrUpdatedFiles.php b/src/Adapter/Requirement/CheckMissingOrUpdatedFiles.php deleted file mode 100644 index 60b62079..00000000 --- a/src/Adapter/Requirement/CheckMissingOrUpdatedFiles.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Requirement; - -use AppKernel; - -/** - * Part of requirements for a PrestaShop website - * Check if all required files exists. - */ -class CheckMissingOrUpdatedFiles -{ - /** - * @param string|null $dir - * @param string $path - * - * @return array - */ - public function getListOfUpdatedFiles($dir = null, $path = '') - { - $fileList = [ - 'missing' => [], - 'updated' => [], - ]; - - if (null === $dir) { - $xml = @simplexml_load_file(_PS_API_URL_ . '/xml/md5-' . AppKernel::MAJOR_VERSION . '/' . AppKernel::VERSION . '.xml'); - if (!$xml) { - return $fileList; - } - - $dir = $xml->ps_root_dir[0]; - } - - $excludeRegexp = '(install(-dev|-new)?|themes|tools|cache|docs|download|img|localization|log|mails|translations|upload|modules|override/(:?.*)index.php$)'; - $adminDir = basename(_PS_ADMIN_DIR_); - - foreach ($dir->md5file as $file) { - $filename = preg_replace('#^admin/#', $adminDir . '/', $path . $file['name']); - if (preg_match('#^' . $excludeRegexp . '#', $filename)) { - continue; - } - - if (!file_exists(_PS_ROOT_DIR_ . '/' . $filename)) { - $fileList['missing'][] = $filename; - } elseif (md5_file(_PS_ROOT_DIR_ . '/' . $filename) !== (string) $file) { - $fileList['updated'][] = $filename; - } - } - - foreach ($dir->dir as $subdir) { - $fileList = array_merge_recursive($fileList, $this->getListOfUpdatedFiles($subdir, $path . $subdir['name'] . '/')); - } - - return $fileList; - } -} diff --git a/src/Adapter/Requirement/CheckRequirements.php b/src/Adapter/Requirement/CheckRequirements.php deleted file mode 100644 index e6005e07..00000000 --- a/src/Adapter/Requirement/CheckRequirements.php +++ /dev/null @@ -1,154 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Requirement; - -use ConfigurationTest; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Check system requirements of a PrestaShop website. - */ -class CheckRequirements -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * Returns a summary of all system requirements. - * - * @return array - */ - public function getSummary() - { - $paramsRequiredResults = ConfigurationTest::check(ConfigurationTest::getDefaultTests()); - - $isHostMode = defined('_PS_HOST_MODE_'); - - if (!$isHostMode) { - $paramsOptionalResults = ConfigurationTest::check(ConfigurationTest::getDefaultTestsOp()); - } - - $failRequired = in_array('fail', $paramsRequiredResults); - - $testsErrors = $this->getErrorMessages(); - - if ($failRequired && 'ok' !== $paramsRequiredResults['files']) { - $tmp = ConfigurationTest::test_files(true); - if (is_array($tmp) && count($tmp)) { - $testsErrors['files'] = $testsErrors['files'] . '
    (' . implode(', ', $tmp) . ')'; - } - } - - $testsErrors = $this->fillMissingDescriptions($testsErrors, $paramsRequiredResults); - - $results = [ - 'failRequired' => $failRequired, - 'testsErrors' => $testsErrors, - 'testsRequired' => $paramsRequiredResults, - ]; - - if (!$isHostMode) { - $results = array_merge($results, [ - 'testsErrors' => $this->fillMissingDescriptions($testsErrors, $paramsOptionalResults), - 'failOptional' => in_array('fail', $paramsOptionalResults), - 'testsOptional' => $paramsOptionalResults, - ]); - } - - return $results; - } - - /** - * @return array - */ - private function getErrorMessages() - { - return [ - 'phpversion' => $this->translator->trans('Update your PHP version.', [], 'Admin.Advparameters.Notification'), - 'upload' => $this->translator->trans('Configure your server to allow file uploads.', [], 'Admin.Advparameters.Notification'), - 'system' => $this->translator->trans('Configure your server to allow the creation of directories and files with write permissions.', [], 'Admin.Advparameters.Notification'), - 'curl' => $this->translator->trans('Enable the CURL extension on your server.', [], 'Admin.Advparameters.Notification'), - 'dom' => $this->translator->trans('Enable the DOM extension on your server.', [], 'Admin.Advparameters.Notification'), - 'fileinfo' => $this->translator->trans('Enable the Fileinfo extension on your server.', [], 'Admin.Advparameters.Notification'), - 'gd' => $this->translator->trans('Enable the GD library on your server.', [], 'Admin.Advparameters.Notification'), - 'json' => $this->translator->trans('Enable the JSON extension on your server.', [], 'Admin.Advparameters.Notification'), - 'mbstring' => $this->translator->trans('Enable the Mbstring extension on your server.', [], 'Admin.Advparameters.Notification'), - 'openssl' => $this->translator->trans('Enable the OpenSSL extension on your server.', [], 'Admin.Advparameters.Notification'), - 'pdo_mysql' => $this->translator->trans('Enable the PDO Mysql extension on your server.', [], 'Admin.Advparameters.Notification'), - 'simplexml' => $this->translator->trans('Enable the XML extension on your server.', [], 'Admin.Advparameters.Notification'), - 'zip' => $this->translator->trans('Enable the ZIP extension on your server.', [], 'Admin.Advparameters.Notification'), - 'mysql_support' => $this->translator->trans('Enable the MySQL support on your server.', [], 'Admin.Advparameters.Notification'), - 'config_dir' => $this->translator->trans('Set write permissions for the "config" folder.', [], 'Admin.Advparameters.Notification'), - 'cache_dir' => $this->translator->trans('Set write permissions for the "cache" folder.', [], 'Admin.Advparameters.Notification'), - 'sitemap' => $this->translator->trans('Set write permissions for the "sitemap.xml" file.', [], 'Admin.Advparameters.Notification'), - 'img_dir' => $this->translator->trans('Set write permissions for the "img" folder and subfolders.', [], 'Admin.Advparameters.Notification'), - 'log_dir' => $this->translator->trans('Set write permissions for the "log" folder and subfolders.', [], 'Admin.Advparameters.Notification'), - 'mails_dir' => $this->translator->trans('Set write permissions for the "mails" folder and subfolders.', [], 'Admin.Advparameters.Notification'), - 'module_dir' => $this->translator->trans('Set write permissions for the "modules" folder and subfolders.', [], 'Admin.Advparameters.Notification'), - 'theme_cache_dir' => $this->translator->trans('Set write permissions for the "themes/%s/cache/" folder and subfolders, recursively.', ['%s' => _THEME_NAME_], 'Admin.Advparameters.Notification'), - 'theme_lang_dir' => $this->translator->trans('Set write permissions for the "themes/%s/lang/" folder and subfolders, recursively.', ['%s' => _THEME_NAME_], 'Admin.Advparameters.Notification'), - 'theme_pdf_lang_dir' => $this->translator->trans('Set write permissions for the "themes/%s/pdf/lang/" folder and subfolders, recursively.', ['%s' => _THEME_NAME_], 'Admin.Advparameters.Notification'), - 'config_sf2_dir' => $this->translator->trans('Set write permissions for the "app/config/" folder and subfolders, recursively.', [], 'Admin.Advparameters.Notification'), - 'translations_sf2' => $this->translator->trans('Set write permissions for the "app/Resources/translations/" folder and subfolders, recursively.', [], 'Admin.Advparameters.Notification'), - 'translations_dir' => $this->translator->trans('Set write permissions for the "translations" folder and subfolders.', [], 'Admin.Advparameters.Notification'), - 'customizable_products_dir' => $this->translator->trans('Set write permissions for the "upload" folder and subfolders.', [], 'Admin.Advparameters.Notification'), - 'virtual_products_dir' => $this->translator->trans('Set write permissions for the "download" folder and subfolders.', [], 'Admin.Advparameters.Notification'), - 'fopen' => $this->translator->trans('Allow the PHP fopen() function on your server.', [], 'Admin.Advparameters.Notification'), - 'gz' => $this->translator->trans('Enable GZIP compression on your server.', [], 'Admin.Advparameters.Notification'), - 'files' => $this->translator->trans('Some PrestaShop files are missing from your server.', [], 'Admin.Advparameters.Notification'), - 'new_phpversion' => $this->translator->trans('You are using PHP %s version. Soon, the latest PHP version supported by PrestaShop will be PHP 5.6. To make sure you’re ready for the future, we recommend you to upgrade to PHP 5.6 now!', ['%s' => PHP_VERSION], 'Admin.Advparameters.Notification'), - 'apache_mod_rewrite' => $this->translator->trans('Enable the Apache mod_rewrite module', [], 'Admin.Advparameters.Notification'), - ]; - } - - /** - * Add default message on missing check descriptions. - * - * @param array $errorMessages - * @param array $checks - * - * @return array Error messages with fallback for missing entries - */ - private function fillMissingDescriptions($errorMessages, $checks) - { - foreach (array_keys(array_diff_key($checks, $errorMessages)) as $key) { - $errorMessages[$key] = $this->translator->trans('%key% (missing description)', ['%key%' => $key], 'Admin.Advparameters.Feature'); - } - - return $errorMessages; - } -} diff --git a/src/Adapter/RoundingMapper.php b/src/Adapter/RoundingMapper.php deleted file mode 100644 index 9e1f6c76..00000000 --- a/src/Adapter/RoundingMapper.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use PrestaShop\Decimal\Operation\Rounding; - -/** - * Maps rounding modes from legacy rounding modes values to the new PrestaShop/Decimal's Rounding constant values. - */ -final class RoundingMapper -{ - /** - * Maps rounding modes from legacy rounding modes values to the new PrestaShop/Decimal's Rounding constant values. - * eg. : asking mapping for PS_ROUND_UP (value : 0) would return Rounding::ROUND_CEIL (value : 'ceil'). - * - * @param int $legacyRoundingMode - * The legacy rounding mode value - * - * @return string - * The corresponding Rounding class' constant value - */ - public static function mapRounding($legacyRoundingMode) - { - $roundModes = [ - PS_ROUND_UP => Rounding::ROUND_CEIL, - PS_ROUND_DOWN => Rounding::ROUND_FLOOR, - PS_ROUND_HALF_UP => Rounding::ROUND_HALF_UP, - PS_ROUND_HALF_DOWN => Rounding::ROUND_HALF_DOWN, - PS_ROUND_HALF_EVEN => Rounding::ROUND_HALF_EVEN, - PS_ROUND_HALF_ODD => Rounding::ROUND_HALF_EVEN, // Rounding::ROUND_HALF_ODD does not exist (never used) - ]; - if (!array_key_exists((int) $legacyRoundingMode, $roundModes)) { - throw new \InvalidArgumentException('Unknown legacy rounding mode : ' . (int) $legacyRoundingMode); - } - - return $roundModes[$legacyRoundingMode]; - } -} diff --git a/src/Adapter/Routes/DefaultRouteProvider.php b/src/Adapter/Routes/DefaultRouteProvider.php deleted file mode 100644 index cdf9bbcd..00000000 --- a/src/Adapter/Routes/DefaultRouteProvider.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Routes; - -use Dispatcher; -use PrestaShopException; - -/** - * Class DefaultRouteProvider is responsible for retrieving data from dispatcher entity. - */ -class DefaultRouteProvider -{ - /** - * Gets keywords used in generating different routes. - * - * @return array - the key is the route id - product_rule, category_rule etc... and the values are keyword array - * used to generate the route. If param field exists in keywords array then it is mandatory field to use. - * - * @throws PrestaShopException - */ - public function getKeywords() - { - $routes = $this->getDefaultRoutes(); - - $result = []; - foreach ($routes as $routeId => $value) { - $result[$routeId] = $value['keywords']; - } - - return $result; - } - - /** - * Gets rules which are used for routes generation. - * - * @return array - he key is the route id - product_rule, category_rule etc... and the value is rule itself. - * - * @throws PrestaShopException - */ - public function getRules() - { - $routes = $this->getDefaultRoutes(); - - $result = []; - foreach ($routes as $routeId => $value) { - $result[$routeId] = $value['rule']; - } - - return $result; - } - - /** - * Gets default routes which contains data such as keywords, rule etc. - * - * @return array - * - * @throws PrestaShopException - */ - private function getDefaultRoutes() - { - return Dispatcher::getInstance()->default_routes; - } -} diff --git a/src/Adapter/Routes/RouteValidator.php b/src/Adapter/Routes/RouteValidator.php deleted file mode 100644 index 8d178d02..00000000 --- a/src/Adapter/Routes/RouteValidator.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Routes; - -use Dispatcher; -use PrestaShopException; -use Validate; - -/** - * Class RouteValidator is responsible for validating routes. - */ -class RouteValidator -{ - /** - * Check for a route pattern validity. - * - * @param string $pattern to validate - * - * @return bool Validity is ok or not - */ - public function isRoutePattern($pattern) - { - return Validate::isRoutePattern($pattern); - } - - /** - * Check if a route rule contain all required keywords of default route definition. - * - * @param string $routeId - * @param string $rule Rule to verify - * - * @return array - returns list of missing keywords - * - * @throws PrestaShopException - */ - public function doesRouteContainsRequiredKeywords($routeId, $rule) - { - $missingKeywords = []; - $validationResult = Dispatcher::getInstance()->validateRoute($routeId, $rule, $missingKeywords); - - return $validationResult ? [] : $missingKeywords; - } -} diff --git a/src/Adapter/Routing/AdminLinkBuilder.php b/src/Adapter/Routing/AdminLinkBuilder.php deleted file mode 100644 index 0fd2f44c..00000000 --- a/src/Adapter/Routing/AdminLinkBuilder.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Routing; - -use Link; -use PrestaShop\PrestaShop\Core\Routing\EntityLinkBuilderInterface; - -/** - * Class AdminLinkBuilder is able to build entity links based on the Link::getAdminLink - * method (which indirectly allows it to build symfony url as well). - */ -class AdminLinkBuilder implements EntityLinkBuilderInterface -{ - /** @var Link */ - private $link; - - /** @var array */ - private $entityControllers; - - /** - * This class can manage entities based on the $entityControllers parameter, - * you need to specify an array map with then entity/table short name and its - * associated legacy controller: - * e.g. $entityControllers = [ - * 'product' => 'AdminProducts', - * 'customer' => 'AdminCustomers', - * ]; - * - * @param Link $link Link class that generates links - * @param array $entityControllers List of entities with appropriate controller - */ - public function __construct(Link $link, array $entityControllers) - { - $this->link = $link; - $this->entityControllers = $entityControllers; - } - - /** - * {@inheritdoc} - */ - public function getViewLink($entity, array $parameters) - { - $controller = $this->entityControllers[$entity]; - $parameters = $this->buildActionParameters('view', $entity, $parameters); - - return $this->link->getAdminLink($controller, true, $parameters); - } - - /** - * {@inheritdoc} - */ - public function getEditLink($entity, array $parameters) - { - $controller = $this->entityControllers[$entity]; - $parameters = $this->buildActionParameters('update', $entity, $parameters); - - return $this->link->getAdminLink($controller, true, $parameters); - } - - /** - * @param string $action - * @param string $entity - * @param array $parameters - * - * @return array - */ - private function buildActionParameters($action, $entity, array $parameters) - { - unset($parameters['current_index']); - unset($parameters['token']); - $editAction = $action . $entity; - - return array_merge( - $parameters, - [$editAction => 1] - ); - } - - /** - * {@inheritdoc} - */ - public function canBuild($entity) - { - return !empty($this->entityControllers[$entity]); - } -} diff --git a/src/Adapter/Routing/LegacyHelperLinkBuilder.php b/src/Adapter/Routing/LegacyHelperLinkBuilder.php deleted file mode 100644 index 4ad09b11..00000000 --- a/src/Adapter/Routing/LegacyHelperLinkBuilder.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Routing; - -use PrestaShop\PrestaShop\Core\Exception\InvalidArgumentException; -use PrestaShop\PrestaShop\Core\Routing\EntityLinkBuilderInterface; - -/** - * Class LegacyHelperLinkBuilder is able to build entity links "manually" by concatenating - * the parameters to the current index. This way of building links is deprecated and should - * be replaced with Symfony router or Link::getAdminLink - */ -class LegacyHelperLinkBuilder implements EntityLinkBuilderInterface -{ - /** - * @param string $entity - * @param array $parameters - * - * @return string - * - * @throws InvalidArgumentException - */ - public function getViewLink($entity, array $parameters) - { - if (!isset($parameters['current_index'])) { - throw new InvalidArgumentException('Missing parameter current_index to build legacy link'); - } - - $currentIndex = $parameters['current_index']; - $parameters = $this->buildActionParameters('view', $entity, $parameters); - - return $currentIndex . '&' . http_build_query($parameters); - } - - /** - * @param string $entity - * @param array $parameters - * - * @return string - * - * @throws InvalidArgumentException - */ - public function getEditLink($entity, array $parameters) - { - if (!isset($parameters['current_index'])) { - throw new InvalidArgumentException('Missing parameter current_index to build legacy link'); - } - - $currentIndex = $parameters['current_index']; - $parameters = $this->buildActionParameters('update', $entity, $parameters); - - return $currentIndex . '&' . http_build_query($parameters); - } - - /** - * @param string $action - * @param string $entity - * @param array $parameters - * - * @return array - */ - private function buildActionParameters($action, $entity, array $parameters) - { - unset($parameters['current_index']); - $actionParameter = $action . $entity; - - /** - * Legacy actions are displayed with empty value (e.g ?controller=ProductAdminController&updateproduct&id_product=1) - * Some modules don't just check that the parameter is set but also that it is empty... - * The closest thing we have with http_build_query is controller=ProductAdminController&updateproduct=&id_product=1 - */ - $parameters = array_merge( - [$actionParameter => ''], - $parameters - ); - - return $parameters; - } - - /** - * {@inheritdoc} - */ - public function canBuild($entity) - { - return true; - } -} diff --git a/src/Adapter/Search/SearchProductSearchProvider.php b/src/Adapter/Search/SearchProductSearchProvider.php deleted file mode 100644 index 920f658f..00000000 --- a/src/Adapter/Search/SearchProductSearchProvider.php +++ /dev/null @@ -1,147 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Search; - -use Hook; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchProviderInterface; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchResult; -use PrestaShop\PrestaShop\Core\Product\Search\SortOrderFactory; -use Search; -use Symfony\Component\Translation\TranslatorInterface; -use Tools; - -/** - * Class responsible of retrieving products in Search page of Front Office. - * - * @see SearchController - */ -class SearchProductSearchProvider implements ProductSearchProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var SortOrderFactory - */ - private $sortOrderFactory; - - public function __construct( - TranslatorInterface $translator - ) { - $this->translator = $translator; - $this->sortOrderFactory = new SortOrderFactory($this->translator); - } - - /** - * {@inheritdoc} - */ - public function runQuery( - ProductSearchContext $context, - ProductSearchQuery $query - ) { - $products = []; - $count = 0; - - if (($string = $query->getSearchString())) { - $queryString = Tools::replaceAccentedChars(urldecode($string)); - - $result = Search::find( - $context->getIdLang(), - $queryString, - $query->getPage(), - $query->getResultsPerPage(), - $query->getSortOrder()->toLegacyOrderBy(), - $query->getSortOrder()->toLegacyOrderWay(), - false, // ajax, what's the link? - false, // $use_cookie, ignored anyway - null - ); - $products = $result['result']; - $count = $result['total']; - - Hook::exec('actionSearch', [ - 'searched_query' => $queryString, - 'total' => $count, - - // deprecated since 1.7.x - 'expr' => $queryString, - ]); - } elseif (($tag = $query->getSearchTag())) { - $queryString = urldecode($tag); - - $products = Search::searchTag( - $context->getIdLang(), - $queryString, - false, - $query->getPage(), - $query->getResultsPerPage(), - $query->getSortOrder()->toLegacyOrderBy(true), - $query->getSortOrder()->toLegacyOrderWay(), - false, - null - ); - - $count = Search::searchTag( - $context->getIdLang(), - $queryString, - true, - $query->getPage(), - $query->getResultsPerPage(), - $query->getSortOrder()->toLegacyOrderBy(true), - $query->getSortOrder()->toLegacyOrderWay(), - false, - null - ); - - Hook::exec('actionSearch', [ - 'searched_query' => $queryString, - 'total' => $count, - - // deprecated since 1.7.x - 'expr' => $queryString, - ]); - } - - $result = new ProductSearchResult(); - - if (!empty($products)) { - $result - ->setProducts($products) - ->setTotalProductsCount($count); - - $result->setAvailableSortOrders( - $this->sortOrderFactory->getDefaultSortOrders() - ); - } - - return $result; - } -} diff --git a/src/Adapter/Security/Admin.php b/src/Adapter/Security/Admin.php deleted file mode 100644 index dfcada1c..00000000 --- a/src/Adapter/Security/Admin.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Security; - -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\HttpKernelInterface; -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; -use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; -use Symfony\Component\Security\Core\User\UserProviderInterface; - -/** - * Admin Middleware security. - */ -class Admin -{ - /** - * @var LegacyContext - */ - private $context; - - /** - * @var \Context - */ - private $legacyContext; - - /** - * @var TokenStorage - */ - private $securityTokenStorage; - - /** - * @var UserProviderInterface - */ - private $userProvider; - - public function __construct(LegacyContext $context, TokenStorage $securityTokenStorage, UserProviderInterface $userProvider) - { - $this->context = $context; - $this->legacyContext = $context->getContext(); - $this->securityTokenStorage = $securityTokenStorage; - $this->userProvider = $userProvider; - } - - /** - * Check if employee is logged in - * If not logged in, redirect to admin home page. - * - * @param GetResponseEvent $event - * - * @return bool or redirect - */ - public function onKernelRequest(GetResponseEvent $event) - { - //if employee loggdin in legacy context, authenticate him into sf2 security context - if (isset($this->legacyContext->employee) && $this->legacyContext->employee->isLoggedBack()) { - $user = $this->userProvider->loadUserByUsername($this->legacyContext->employee->email); - $token = new UsernamePasswordToken($user, null, 'admin', $user->getRoles()); - $this->securityTokenStorage->setToken($token); - - return true; - } - - // in case of exception handler sub request, avoid infinite redirection - if ($event->getRequestType() === HttpKernelInterface::SUB_REQUEST - && $event->getRequest()->attributes->has('exception') - ) { - return true; - } - - //employee not logged in - $event->stopPropagation(); - - //if http request - add 403 error - $request = Request::createFromGlobals(); - if ($request->isXmlHttpRequest()) { - header('HTTP/1.1 403 Forbidden'); - exit(); - } - - //redirect to admin home page - header('Location: ' . $this->context->getAdminLink('', false)); - exit(); - } -} diff --git a/src/Adapter/Security/SslMiddleware.php b/src/Adapter/Security/SslMiddleware.php deleted file mode 100644 index b561281b..00000000 --- a/src/Adapter/Security/SslMiddleware.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Security; - -use Configuration; -use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Tools; - -/** - * Middleware that is triggered during kernel.request event on Symfony routing process, to redirect to HTTPS in some cases. - * - * If PS_SSL_ENABLED & (PS_SSL_ENABLED_EVERYWHERE | REFERER is HTTPS) - * Then redirect to the equivalent URL to HTTPS. - * Warning : will lost post data, - */ -class SslMiddleware -{ - /** - * Registered as kernel.request event listener. - * - * If the condition needs a redirection to HTTPS, then the current process is interrupted, the headers are sent directly. - * - * @param GetResponseEvent $event - */ - public function onKernelRequest(GetResponseEvent $event) - { - // already SSL, do nothing more - if (Tools::usingSecureMode()) { - return; - } - - $enabled = (1 == Configuration::get('PS_SSL_ENABLED')); - $forced = (1 == Configuration::get('PS_SSL_ENABLED_EVERYWHERE')); - $serverParams = $event->getRequest()->server; - $refererSsl = ($serverParams->has('HTTP_REFERER') && strpos($serverParams->get('HTTP_REFERER'), 'https') === 0); - - if ($enabled && ($forced || $refererSsl)) { - $this->redirectToSsl($event); - } - } - - private function redirectToSsl(GetResponseEvent $event) - { - $event->stopPropagation(); - $redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; - header('HTTP/1.1 302 Found'); - header("Location: $redirect"); - exit(); - } -} diff --git a/src/Adapter/ServiceLocator.php b/src/Adapter/ServiceLocator.php deleted file mode 100644 index 7100e5f0..00000000 --- a/src/Adapter/ServiceLocator.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use PrestaShop\PrestaShop\Core\Foundation\IoC\Container; - -/** - * @internal - * - * To be removed in 1.7.1. - */ -class ServiceLocator -{ - /** - * Set a service container Instance. - * - * @var Container - */ - private static $service_container; - - public static function setServiceContainerInstance(Container $container) - { - self::$service_container = $container; - } - - /** - * Get a service depending on its given $serviceName. - * - * @param $serviceName - * - * @return mixed|object - * - * @throws CoreException - */ - public static function get($serviceName) - { - if (empty(self::$service_container) || null === self::$service_container) { - throw new CoreException('Service container is not set.'); - } - - return self::$service_container->make($serviceName); - } -} diff --git a/src/Adapter/Shop/CommandHandler/UploadLogosHandler.php b/src/Adapter/Shop/CommandHandler/UploadLogosHandler.php deleted file mode 100644 index 0e23e392..00000000 --- a/src/Adapter/Shop/CommandHandler/UploadLogosHandler.php +++ /dev/null @@ -1,166 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Shop\CommandHandler; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Exception\FileUploadException; -use PrestaShop\PrestaShop\Core\Domain\Shop\Command\UploadLogosCommand; -use PrestaShop\PrestaShop\Core\Domain\Shop\CommandHandler\UploadLogosHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Shop\DTO\ShopLogoSettings; -use PrestaShop\PrestaShop\Core\Domain\Shop\Exception\ShopException; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShop\PrestaShop\Core\Shop\LogoUploader; -use PrestaShopException; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Class UploadLogosHandler - */ -final class UploadLogosHandler implements UploadLogosHandlerInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var LogoUploader - */ - private $logoUploader; - - /** - * @var HookDispatcherInterface - */ - private $hookDispatcher; - - /** - * @param ConfigurationInterface $configuration - * @param LogoUploader $logoUploader - * @param HookDispatcherInterface $hookDispatcher - */ - public function __construct( - ConfigurationInterface $configuration, - LogoUploader $logoUploader, - HookDispatcherInterface $hookDispatcher - ) { - $this->configuration = $configuration; - $this->logoUploader = $logoUploader; - $this->hookDispatcher = $hookDispatcher; - } - - /** - * {@inheritdoc} - * - * @throws ShopException - * @throws FileUploadException - */ - public function handle(UploadLogosCommand $command) - { - $this->configuration->set('PS_IMG_UPDATE_TIME', time()); - - try { - if (null !== $command->getUploadedHeaderLogo()) { - $this->uploadHeaderLogo($command->getUploadedHeaderLogo()); - } - - if (null !== $command->getUploadedMailLogo()) { - $this->uploadMailLogo($command->getUploadedMailLogo()); - } - - if (null !== $command->getUploadedInvoiceLogo()) { - $this->uploadInvoiceLogo($command->getUploadedInvoiceLogo()); - } - - if (null !== $command->getUploadedFavicon()) { - $this->uploadFavicon($command->getUploadedFavicon()); - } - } catch (PrestaShopException $exception) { - throw new ShopException('An unexpected error occurred when uploading image', 0, $exception); - } - - $this->hookDispatcher->dispatchWithParameters('actionAdminThemesControllerUpdate_optionsAfter'); - } - - /** - * @param UploadedFile $uploadedFile - */ - private function uploadHeaderLogo(UploadedFile $uploadedFile) - { - $this->setUploadedFileToBeCompatibleWithLegacyUploader(ShopLogoSettings::HEADER_LOGO_FILE_NAME, $uploadedFile); - - $this->logoUploader->updateHeader(); - } - - /** - * @param UploadedFile $uploadedFile - */ - private function uploadMailLogo(UploadedFile $uploadedFile) - { - $this->setUploadedFileToBeCompatibleWithLegacyUploader(ShopLogoSettings::MAIL_LOGO_FILE_NAME, $uploadedFile); - - $this->logoUploader->updateMail(); - } - - /** - * @param UploadedFile $uploadedHeaderLogo - */ - private function uploadInvoiceLogo(UploadedFile $uploadedHeaderLogo) - { - $this->setUploadedFileToBeCompatibleWithLegacyUploader(ShopLogoSettings::INVOICE_LOGO_FILE_NAME, $uploadedHeaderLogo); - - $this->logoUploader->updateInvoice(); - } - - /** - * @param UploadedFile $uploadedHeaderLogo - */ - private function uploadFavicon(UploadedFile $uploadedHeaderLogo) - { - $this->setUploadedFileToBeCompatibleWithLegacyUploader(ShopLogoSettings::FAVICON_FILE_NAME, $uploadedHeaderLogo); - - $this->logoUploader->updateFavicon(); - } - - /** - * @param string $legacyFileName - * @param UploadedFile $uploadedFile - * - * @return array - */ - private function setUploadedFileToBeCompatibleWithLegacyUploader($legacyFileName, UploadedFile $uploadedFile) - { - $_FILES[$legacyFileName] = [ - 'name' => $uploadedFile->getClientOriginalName(), - 'type' => $uploadedFile->getMimeType(), - 'tmp_name' => $uploadedFile->getPathname(), - 'error' => $uploadedFile->getError(), - 'size' => $uploadedFile->getSize(), - ]; - - return $_FILES; - } -} diff --git a/src/Adapter/Shop/Context.php b/src/Adapter/Shop/Context.php deleted file mode 100644 index a53fb813..00000000 --- a/src/Adapter/Shop/Context.php +++ /dev/null @@ -1,231 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Shop; - -use Context as LegacyContext; -use PrestaShop\PrestaShop\Core\Multistore\MultistoreContextCheckerInterface; -use PrestaShop\PrestaShop\Core\Shop\ShopContextInterface; -use Shop; -use ShopGroup; - -/** - * This class will provide legacy shop context. - */ -class Context implements MultistoreContextCheckerInterface, ShopContextInterface -{ - /** - * Get shops list. - * - * @param bool $active - * @param bool $get_as_list_id - * - * @return array - */ - public function getShops($active = true, $get_as_list_id = false) - { - return Shop::getShops($active, Shop::getContextShopGroupID(), $get_as_list_id); - } - - /** - * Get current ID of shop if context is CONTEXT_SHOP. - * - * @return int - */ - public function getContextShopID($null_value_without_multishop = false) - { - return Shop::getContextShopID($null_value_without_multishop); - } - - /** - * Get a list of ID concerned by the shop context (E.g. if context is shop group, get list of children shop ID). - * - * @param bool|string $share If false, dont check share datas from group. Else can take a Shop::SHARE_* constant value - * - * @return array - */ - public function getContextListShopID($share = false) - { - return Shop::getContextListShopID($share); - } - - /** - * Return the result of getContextListShopID() for customers usecase - * This handles the "multishop sharing customer" feature setting - * - * @return array - */ - public function getContextListShopIDUsingCustomerSharingSettings() - { - $groupSettings = Shop::getGroupFromShop(Shop::getContextShopID(), false); - - if ($groupSettings['share_customer']) { - return Shop::getContextListShopID(Shop::SHARE_CUSTOMER); - } else { - return Shop::getContextListShopID(); - } - } - - /** - * Get if it's a GroupShop context. - * - * @return bool - * - * @deprecated since 1.7.6.0, to be removed in 1.8. Use $this->isGroupShopContext() instead. - */ - public function isShopGroupContext() - { - return $this->isGroupShopContext(); - } - - /** - * Get if it's a Shop context. - * - * @return bool - */ - public function isShopContext() - { - return Shop::getContext() === Shop::CONTEXT_SHOP; - } - - /** - * Get if it's a All context. - * - * @return bool - * - * @deprecated since 1.7.6.0, to be removed in 1.8. Use $this->isAllShopContext() instead. - */ - public function isAllContext() - { - return $this->isAllShopContext(); - } - - /** - * Check if shop context is Shop. - * - * @return bool - */ - public function isSingleShopContext() - { - if (!Shop::isFeatureActive()) { - return true; - } - - return $this->isShopContext(); - } - - /** - * Update Multishop context for only one shop. - * - * @param int $id Shop id to set in the current context - */ - public function setShopContext($id) - { - Shop::setContext(Shop::CONTEXT_SHOP, $id); - } - - /** - * Update Multishop context for only one shop group. - * - * @param int $id Shop id to set in the current context - */ - public function setShopGroupContext($id) - { - Shop::setContext(Shop::CONTEXT_GROUP, $id); - } - - /** - * Update Multishop context for only one shop group. - * - * @param int $id Shop id to set in the current context - */ - public function setAllContext($id) - { - Shop::setContext(Shop::CONTEXT_ALL, $id); - } - - public function getContextShopGroup() - { - return Shop::getContextShopGroup(); - } - - /** - * Retrieve group ID of a shop. - * - * @param $shopId - * @param bool $asId - * - * @return int - */ - public function getGroupFromShop($shopId, $asId = true) - { - return Shop::getGroupFromShop($shopId, $asId); - } - - /** - * @param $shopGroupId - * - * @return ShopGroup - */ - public function ShopGroup($shopGroupId) - { - return new ShopGroup($shopGroupId); - } - - /** - * {@inheritdoc} - */ - public function isAllShopContext() - { - return Shop::getContext() === Shop::CONTEXT_ALL; - } - - /** - * {@inheritdoc} - */ - public function isGroupShopContext() - { - return Shop::getContext() === Shop::CONTEXT_GROUP; - } - - /** - * Get list of all shop IDs. - * - * @return array - */ - public function getAllShopIds() - { - return Shop::getCompleteListOfShopsID(); - } - - /** - * {@inheritdoc} - */ - public function getShopName() - { - return LegacyContext::getContext()->shop->name; - } -} diff --git a/src/Adapter/Shop/MaintenanceConfiguration.php b/src/Adapter/Shop/MaintenanceConfiguration.php deleted file mode 100644 index d7d904b5..00000000 --- a/src/Adapter/Shop/MaintenanceConfiguration.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Shop; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * This class loads and saves data configuration for the Maintenance page. - */ -class MaintenanceConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'enable_shop' => $this->configuration->getBoolean('PS_SHOP_ENABLE'), - 'maintenance_ip' => $this->configuration->get('PS_MAINTENANCE_IP'), - 'maintenance_text' => $this->configuration->get('PS_MAINTENANCE_TEXT'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_SHOP_ENABLE', $configuration['enable_shop']); - $this->configuration->set('PS_MAINTENANCE_IP', $configuration['maintenance_ip']); - $this->configuration->set('PS_MAINTENANCE_TEXT', $configuration['maintenance_text'], null, ['html' => true]); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['enable_shop'], - $configuration['maintenance_ip'], - $configuration['maintenance_text'] - ); - } -} diff --git a/src/Adapter/Shop/QueryHandler/GetLogosPathsHandler.php b/src/Adapter/Shop/QueryHandler/GetLogosPathsHandler.php deleted file mode 100644 index 95d79639..00000000 --- a/src/Adapter/Shop/QueryHandler/GetLogosPathsHandler.php +++ /dev/null @@ -1,131 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Shop\QueryHandler; - -use Configuration; -use PrestaShop\PrestaShop\Core\Domain\Shop\Query\GetLogosPaths; -use PrestaShop\PrestaShop\Core\Domain\Shop\QueryHandler\GetLogosPathsHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Shop\QueryResult\LogosPaths; - -/** - * Responsible for providing header, email, invoice and favicon logo paths for specific shop context. - */ -final class GetLogosPathsHandler implements GetLogosPathsHandlerInterface -{ - /** - * @var string - */ - private $imageBaseUrl; - - /** - * @var string - */ - private $imageDirectory; - - /** - * @param string $imageBaseUrl - * @param string $imageDirectory - */ - public function __construct($imageBaseUrl, $imageDirectory) - { - $this->imageBaseUrl = $imageBaseUrl; - $this->imageDirectory = $imageDirectory; - } - - /** - * {@inheritdoc} - */ - public function handle(GetLogosPaths $query) - { - return new LogosPaths( - $this->getHeaderLogoPath(), - $this->getMailLogoPath(), - $this->getInvoiceLogoPath(), - $this->getFaviconPath() - ); - } - - /** - * Get path to context's shop logo. - * - * @return string - */ - private function getHeaderLogoPath() - { - return $this->imageBaseUrl . Configuration::get('PS_LOGO'); - } - - /** - * Get path to context's shop mail logo. - * - * @return string - */ - private function getMailLogoPath() - { - if (!$mailLogo = Configuration::get('PS_LOGO_MAIL')) { - return $this->getHeaderLogoPath(); - } - - $mailLogoPath = $this->imageDirectory . $mailLogo; - - if (!file_exists($mailLogoPath)) { - return $this->getHeaderLogoPath(); - } - - return $this->imageBaseUrl . $mailLogo; - } - - /** - * Get path to context's shop invoice logo. - * - * @return string - */ - private function getInvoiceLogoPath() - { - if (!$invoiceLogo = Configuration::get('PS_LOGO_INVOICE')) { - return $this->getHeaderLogoPath(); - } - - $invoiceLogoPath = $this->imageDirectory . $invoiceLogo; - - if (!file_exists($invoiceLogoPath)) { - return $this->getHeaderLogoPath(); - } - - return $this->imageBaseUrl . $invoiceLogo; - } - - /** - * Get path to context's shop favicon. - * - * @return string - */ - private function getFaviconPath() - { - return $this->imageBaseUrl . Configuration::get('PS_FAVICON'); - } -} diff --git a/src/Adapter/Shop/ShopInformation.php b/src/Adapter/Shop/ShopInformation.php deleted file mode 100644 index 57960ba5..00000000 --- a/src/Adapter/Shop/ShopInformation.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Shop; - -use AppKernel; -use PrestaShop\PrestaShop\Adapter\LegacyContext; - -/** - * Retrieve common information from a the actual Shop. - * - * Depends on Context, avoid re-use of this class - */ -class ShopInformation -{ - /** - * @var \Context - */ - private $context; - - /** - * @param LegacyContext $legacyContext - */ - public function __construct(LegacyContext $legacyContext) - { - $this->context = $legacyContext->getContext(); - } - - /** - * @return array - */ - public function getShopInformation() - { - return [ - 'version' => AppKernel::VERSION, - 'url' => $this->context->shop->getBaseURL(), - 'path' => _PS_ROOT_DIR_, - 'theme' => $this->context->shop->theme->getName(), - ]; - } -} diff --git a/src/Adapter/Shop/ShopUrlDataProvider.php b/src/Adapter/Shop/ShopUrlDataProvider.php deleted file mode 100644 index 09c970cf..00000000 --- a/src/Adapter/Shop/ShopUrlDataProvider.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Shop; - -use PrestaShopException; -use ShopUrl; -use Validate; - -/** - * Class ShopUrlDataProvider is responsible for providing data from shop_url table. - */ -class ShopUrlDataProvider -{ - /** - * @var int - */ - private $contextShopId; - - /** - * ShopUrlDataProvider constructor. - * - * @param int $contextShopId - */ - public function __construct($contextShopId) - { - $this->contextShopId = $contextShopId; - } - - /** - * Gets main shop url data. - * - * @return ShopUrl - * - * @throws PrestaShopException - */ - public function getMainShopUrl() - { - /** @var ShopUrl $result */ - $result = ShopUrl::getShopUrls($this->contextShopId)->where('main', '=', 1)->getFirst(); - - if (!Validate::isLoadedObject($result)) { - return new ShopUrl(); - } - - return $result; - } - - /** - * Checks whenever the main shop url exists for current shop context. - * - * @return bool - * - * @throws PrestaShopException - */ - public function doesMainShopUrlExist() - { - $shopUrl = ShopUrl::getShopUrls($this->contextShopId)->where('main', '=', 1)->getFirst(); - - return Validate::isLoadedObject($shopUrl); - } -} diff --git a/src/Adapter/Shop/Url/BaseUrlProvider.php b/src/Adapter/Shop/Url/BaseUrlProvider.php deleted file mode 100644 index b58d558f..00000000 --- a/src/Adapter/Shop/Url/BaseUrlProvider.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Shop\Url; - -use Link; -use PrestaShop\PrestaShop\Core\Shop\Url\UrlProviderInterface; - -/** - * Class BaseUrlProvider provides base Front Office URL for context shop. - */ -final class BaseUrlProvider implements UrlProviderInterface -{ - /** - * @var Link - */ - private $link; - - /** - * @param Link $link - */ - public function __construct(Link $link) - { - $this->link = $link; - } - - /** - * {@inheritdoc} - */ - public function getUrl() - { - return $this->link->getBaseLink(); - } -} diff --git a/src/Adapter/Shop/Url/CategoryProvider.php b/src/Adapter/Shop/Url/CategoryProvider.php deleted file mode 100644 index 75d52ca1..00000000 --- a/src/Adapter/Shop/Url/CategoryProvider.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Shop\Url; - -use Link; -use PrestaShop\PrestaShop\Core\Shop\Url\UrlProviderInterface; - -/** - * Class CategoryProvider provides base Front Office URL for context shop. - */ -final class CategoryProvider implements UrlProviderInterface -{ - /** - * @var Link - */ - private $link; - - /** - * @param Link $link - */ - public function __construct(Link $link) - { - $this->link = $link; - } - - /** - * Create a link to a category. - * - * @param int $categoryId - * @param string $rewrite - * - * @return string - */ - public function getUrl($categoryId = null, $rewrite = null) - { - return $this->link->getCategoryLink((int) $categoryId, $rewrite); - } -} diff --git a/src/Adapter/Shop/Url/CmsProvider.php b/src/Adapter/Shop/Url/CmsProvider.php deleted file mode 100644 index b39f0008..00000000 --- a/src/Adapter/Shop/Url/CmsProvider.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Shop\Url; - -use Link; -use PrestaShop\PrestaShop\Core\Shop\Url\UrlProviderInterface; - -/** - * Class CmsProvider provides base Front Office URL for context shop. - */ -final class CmsProvider implements UrlProviderInterface -{ - /** - * @var Link - */ - private $link; - - /** - * @param Link $link - */ - public function __construct(Link $link) - { - $this->link = $link; - } - - /** - * Create a link to a cms. - * - * @param int $cmsId - * @param string $rewrite - * - * @return string - */ - public function getUrl($cmsId = null, $rewrite = null) - { - return $this->link->getCmsLink((int) $cmsId, $rewrite); - } -} diff --git a/src/Adapter/Smarty/SmartyCacheConfiguration.php b/src/Adapter/Smarty/SmartyCacheConfiguration.php deleted file mode 100644 index d8e00a62..00000000 --- a/src/Adapter/Smarty/SmartyCacheConfiguration.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Smarty; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * This class will manage Smarty configuration for a Shop. - */ -class SmartyCacheConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'template_compilation' => $this->configuration->get('PS_SMARTY_FORCE_COMPILE'), - 'cache' => $this->configuration->getBoolean('PS_SMARTY_CACHE'), - 'multi_front_optimization' => $this->configuration->getBoolean('PS_SMARTY_LOCAL'), - 'caching_type' => $this->configuration->get('PS_SMARTY_CACHING_TYPE'), - 'clear_cache' => $this->configuration->get('PS_SMARTY_CLEAR_CACHE'), - 'smarty_console' => $this->configuration->get('PS_SMARTY_CONSOLE'), - 'smarty_console_key' => $this->configuration->get('PS_SMARTY_CONSOLE_KEY'), - ]; - } - - /** - * {@inheritdoc} - * - * Note: 'smarty_console' and 'smarty_console_key' keys are not allowed for update. - */ - public function updateConfiguration(array $configuration) - { - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_SMARTY_FORCE_COMPILE', $configuration['template_compilation']); - $this->configuration->set('PS_SMARTY_CACHE', $configuration['cache']); - $this->configuration->set('PS_SMARTY_LOCAL', $configuration['multi_front_optimization']); - $this->configuration->set('PS_SMARTY_CACHING_TYPE', $configuration['caching_type']); - $this->configuration->set('PS_SMARTY_CLEAR_CACHE', $configuration['clear_cache']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['template_compilation'], - $configuration['cache'], - $configuration['multi_front_optimization'], - $configuration['caching_type'], - $configuration['clear_cache'], - $configuration['smarty_console'], - $configuration['smarty_console_key'] - ); - } -} diff --git a/src/Adapter/SpecificPrice/AbstractSpecificPriceHandler.php b/src/Adapter/SpecificPrice/AbstractSpecificPriceHandler.php deleted file mode 100644 index 794875bb..00000000 --- a/src/Adapter/SpecificPrice/AbstractSpecificPriceHandler.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\SpecificPrice; - -use DateTime; -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Exception\SpecificPriceConstraintException; -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Exception\SpecificPriceException; -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Exception\SpecificPriceNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\ValueObject\SpecificPriceId; -use PrestaShopException; -use SpecificPrice; - -/** - * Provides reusable methods for specific price handlers - */ -abstract class AbstractSpecificPriceHandler -{ - /** - * Gets legacy SpecificPrice object - * - * @param SpecificPriceId $specificPriceId - * - * @return SpecificPrice - * - * @throws SpecificPriceException - * @throws SpecificPriceNotFoundException - */ - protected function getSpecificPrice(SpecificPriceId $specificPriceId): SpecificPrice - { - $specificPriceIdValue = $specificPriceId->getValue(); - - try { - $specificPrice = new SpecificPrice($specificPriceIdValue); - } catch (PrestaShopException $e) { - throw new SpecificPriceException('Failed to fetch new specific price', 0, $e); - } - - if ($specificPrice->id !== $specificPriceIdValue) { - throw new SpecificPriceNotFoundException(sprintf('Specific price with id "%s" was not found.', $specificPriceIdValue)); - } - - return $specificPrice; - } - - /** - * Checks if date range values are not inverse. (range from not bigger than range to) - * - * @param DateTime $from - * @param DateTime $to - * - * @throws SpecificPriceConstraintException - */ - protected function assertDateRangeIsNotInverse(DateTime $from, DateTime $to) - { - if ($from->diff($to)->invert) { - throw new SpecificPriceConstraintException('The date time for specific price cannot be inverse', SpecificPriceConstraintException::INVALID_DATE_RANGE); - } - } -} diff --git a/src/Adapter/SpecificPrice/CommandHandler/AddSpecificPriceHandler.php b/src/Adapter/SpecificPrice/CommandHandler/AddSpecificPriceHandler.php deleted file mode 100644 index 96c9398a..00000000 --- a/src/Adapter/SpecificPrice/CommandHandler/AddSpecificPriceHandler.php +++ /dev/null @@ -1,120 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\SpecificPrice\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\SpecificPrice\AbstractSpecificPriceHandler; -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Command\AddSpecificPriceCommand; -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\CommandHandler\AddSpecificPriceHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Exception\SpecificPriceConstraintException; -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Exception\SpecificPriceException; -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\ValueObject\SpecificPriceId; -use PrestaShop\PrestaShop\Core\Util\DateTime\DateTime; -use PrestaShopException; -use SpecificPrice; - -/** - * Handles AddSpecificPriceCommand using legacy object model - */ -final class AddSpecificPriceHandler extends AbstractSpecificPriceHandler implements AddSpecificPriceHandlerInterface -{ - /** - * @param AddSpecificPriceCommand $command - * - * @return SpecificPriceId - * - * @throws SpecificPriceConstraintException - * @throws SpecificPriceException - */ - public function handle(AddSpecificPriceCommand $command): SpecificPriceId - { - try { - $specificPrice = $this->createSpecificPriceFromCommand($command); - - if (false === $specificPrice->validateFields(false)) { - throw new SpecificPriceConstraintException('Specific price contains invalid field values'); - } - - if (!$specificPrice->add()) { - throw new SpecificPriceException('Failed to add new specific price'); - } - } catch (PrestaShopException $e) { - throw new SpecificPriceException('An error occurred when trying to add new specific price'); - } - - return new SpecificPriceId($specificPrice->id); - } - - /** - * Creates legacy SpecificPrice object from command - * - * @param AddSpecificPriceCommand $command - * - * @return SpecificPrice - * - * @throws PrestaShopException - * @throws SpecificPriceConstraintException - */ - private function createSpecificPriceFromCommand(AddSpecificPriceCommand $command): SpecificPrice - { - $specificPrice = new SpecificPrice(); - - $specificPrice->id_product = $command->getProductId()->getValue(); - $specificPrice->reduction_type = $command->getReduction()->getType(); - $specificPrice->reduction = $command->getReduction()->getValue(); - $specificPrice->reduction_tax = $command->isIncludeTax(); - $specificPrice->price = $command->getPrice(); - $specificPrice->from_quantity = $command->getFromQuantity(); - $specificPrice->id_shop_group = $command->getShopGroupId() ?? 0; - $specificPrice->id_shop = $command->getShopId() ?? 0; - $specificPrice->id_cart = $command->getCartId() ?? 0; - $specificPrice->id_product_attribute = $command->getProductAttributeId() ?? 0; - $specificPrice->id_currency = $command->getCurrencyId() ?? 0; - $specificPrice->id_specific_price_rule = $command->getCartRuleId() ?? 0; - $specificPrice->id_country = $command->getCountryId() ?? 0; - $specificPrice->id_group = $command->getGroupId() ?? 0; - $specificPrice->id_customer = $command->getCustomerId() ?? 0; - $specificPrice->from = DateTime::NULL_VALUE; - $specificPrice->to = DateTime::NULL_VALUE; - - $from = $command->getDateTimeFrom(); - $to = $command->getDateTimeTo(); - - if ($from && $to) { - $this->assertDateRangeIsNotInverse($from, $to); - } - - if ($from) { - $specificPrice->from = $from->format('Y-m-d H:i:s'); - } - - if ($to) { - $specificPrice->to = $to->format('Y-m-d H:i:s'); - } - - return $specificPrice; - } -} diff --git a/src/Adapter/SpecificPrice/CommandHandler/DeleteSpecificPriceByCartProductHandler.php b/src/Adapter/SpecificPrice/CommandHandler/DeleteSpecificPriceByCartProductHandler.php deleted file mode 100644 index a52d4a79..00000000 --- a/src/Adapter/SpecificPrice/CommandHandler/DeleteSpecificPriceByCartProductHandler.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\SpecificPrice\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Command\DeleteSpecificPriceByCartProductCommand; -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\CommandHandler\DeleteSpecificPriceByCartProductHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Exception\SpecificPriceException; -use PrestaShopException; -use SpecificPrice; - -/** - * Handles DeleteSpecificPriceByCartProduct command using legacy object model - */ -final class DeleteSpecificPriceByCartProductHandler implements DeleteSpecificPriceByCartProductHandlerInterface -{ - /** - * @param DeleteSpecificPriceByCartProductCommand $command - * - * @throws SpecificPriceException - */ - public function handle(DeleteSpecificPriceByCartProductCommand $command): void - { - $productAttributeId = $command->getProductAttributeId() ?? false; - $cartIdValue = $command->getCartId()->getValue(); - $productIdValue = $command->getProductId()->getValue(); - - try { - if (false === SpecificPrice::deleteByIdCart($cartIdValue, $productIdValue, $productAttributeId)) { - throw new SpecificPriceException(sprintf('Failed to delete specific price for cart #%s product #%s', $cartIdValue, $productIdValue)); - } - } catch (PrestaShopException $e) { - throw new SpecificPriceException(sprintf('An error occurred when trying to delete specific price for cart #%s product #%s', $cartIdValue, $productIdValue)); - } - } -} diff --git a/src/Adapter/SqlManager/CommandHandler/AddSqlRequestHandler.php b/src/Adapter/SqlManager/CommandHandler/AddSqlRequestHandler.php deleted file mode 100644 index bccd7ad3..00000000 --- a/src/Adapter/SqlManager/CommandHandler/AddSqlRequestHandler.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\SqlManager\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\AddSqlRequestCommand; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\CommandHandler\AddSqlRequestHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\CannotAddSqlRequestException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\ValueObject\SqlRequestId; -use PrestaShopException; -use RequestSql; - -/** - * Class AddSqlRequestHandler handles SqlRequest creation command. - * - * @internal - */ -final class AddSqlRequestHandler implements AddSqlRequestHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CannotAddSqlRequestException - * @throws SqlRequestException - */ - public function handle(AddSqlRequestCommand $command) - { - try { - $entity = new RequestSql(); - $entity->name = $command->getName(); - $entity->sql = $command->getSql(); - - $entity->add(); - - if (0 >= $entity->id) { - throw new CannotAddSqlRequestException(sprintf('Invalid entity id after creation: %s', $entity->id)); - } - - return new SqlRequestId($entity->id); - } catch (PrestaShopException $e) { - throw new SqlRequestException('Failed to create SqlRequest', 0, $e); - } - } -} diff --git a/src/Adapter/SqlManager/CommandHandler/BulkDeleteSqlRequestHandler.php b/src/Adapter/SqlManager/CommandHandler/BulkDeleteSqlRequestHandler.php deleted file mode 100644 index 5b2a0415..00000000 --- a/src/Adapter/SqlManager/CommandHandler/BulkDeleteSqlRequestHandler.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\SqlManager\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\BulkDeleteSqlRequestCommand; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\CommandHandler\BulkDeleteSqlRequestHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\CannotDeleteSqlRequestException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestException; -use PrestaShopException; -use RequestSql; - -/** - * Class BulkDeleteSqlRequestHandler handles bulk delete of SqlRequest command. - */ -final class BulkDeleteSqlRequestHandler implements BulkDeleteSqlRequestHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws SqlRequestException - */ - public function handle(BulkDeleteSqlRequestCommand $command) - { - try { - foreach ($command->getSqlRequestIds() as $sqlRequestId) { - $entity = new RequestSql($sqlRequestId->getValue()); - - if (false === $entity->delete()) { - throw new CannotDeleteSqlRequestException(sprintf('Failed to delete SqlRequest with id %s', $sqlRequestId), CannotDeleteSqlRequestException::CANNOT_BULK_DELETE); - } - } - } catch (PrestaShopException $e) { - throw new SqlRequestException('Unexpected error occurred when handling bulk delete SqlRequest', 0, $e); - } - } -} diff --git a/src/Adapter/SqlManager/CommandHandler/DeleteSqlRequestHandler.php b/src/Adapter/SqlManager/CommandHandler/DeleteSqlRequestHandler.php deleted file mode 100644 index ccc5d4ea..00000000 --- a/src/Adapter/SqlManager/CommandHandler/DeleteSqlRequestHandler.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\SqlManager\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\DeleteSqlRequestCommand; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\CommandHandler\DeleteSqlRequestHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\CannotDeleteSqlRequestException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestNotFoundException; -use PrestaShopException; -use RequestSql; - -/** - * Class DeleteSqlRequestHandler. - * - * @internal - */ -final class DeleteSqlRequestHandler implements DeleteSqlRequestHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CannotDeleteSqlRequestException - * @throws SqlRequestNotFoundException - * @throws SqlRequestException - */ - public function handle(DeleteSqlRequestCommand $command) - { - $entityId = $command->getSqlRequestId()->getValue(); - - try { - $entity = new RequestSql($entityId); - - if (0 >= $entity->id) { - throw new SqlRequestNotFoundException(sprintf('SqlRequest with id "%s" was not found for edit', var_export($entityId, true))); - } - - if (false === $entity->delete()) { - throw new CannotDeleteSqlRequestException(sprintf('Could not delete SqlRequest with id %s', var_export($entityId)), CannotDeleteSqlRequestException::CANNOT_SINGLE_DELETE); - } - } catch (PrestaShopException $e) { - throw new SqlRequestException(sprintf('Unexpected error occurred when deleting SqlRequest with id %s', var_export($entityId, true)), 0, $e); - } - } -} diff --git a/src/Adapter/SqlManager/CommandHandler/EditSqlRequestHandler.php b/src/Adapter/SqlManager/CommandHandler/EditSqlRequestHandler.php deleted file mode 100644 index edbdc9a1..00000000 --- a/src/Adapter/SqlManager/CommandHandler/EditSqlRequestHandler.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\SqlManager\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\EditSqlRequestCommand; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\CommandHandler\EditSqlRequestHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\CannotEditSqlRequestException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestNotFoundException; -use PrestaShopException; -use RequestSql; - -/** - * Class EditSqlRequestHandler is responsible for updating SqlRequest. - * - * @internal - */ -final class EditSqlRequestHandler implements EditSqlRequestHandlerInterface -{ - /** - * {@inheritdoc} - * - * @param EditSqlRequestCommand $command - * - * @throws CannotEditSqlRequestException - * @throws SqlRequestException - * @throws SqlRequestNotFoundException - */ - public function handle(EditSqlRequestCommand $command) - { - try { - $entity = new RequestSql($command->getSqlRequestId()->getValue()); - - if (0 >= $entity->id) { - throw new SqlRequestNotFoundException(sprintf('SqlRequest with id "%s" was not found for edit', $command->getSqlRequestId()->getValue())); - } - - if (null !== $command->getName()) { - $entity->name = $command->getName(); - } - - if (null !== $command->getSql()) { - $entity->sql = $command->getSql(); - } - - if (false === $entity->update()) { - throw new CannotEditSqlRequestException(sprintf('Error occurred when updating SqlRequest with id "%s"', $command->getSqlRequestId()->getValue())); - } - } catch (PrestaShopException $e) { - throw new SqlRequestException(sprintf('Error occurred when updating SqlRequest with id "%s"', $command->getSqlRequestId()->getValue())); - } - } -} diff --git a/src/Adapter/SqlManager/QueryHandler/GetDatabaseTableFieldsListHandler.php b/src/Adapter/SqlManager/QueryHandler/GetDatabaseTableFieldsListHandler.php deleted file mode 100644 index f1cdb1f3..00000000 --- a/src/Adapter/SqlManager/QueryHandler/GetDatabaseTableFieldsListHandler.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\SqlManager\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\DatabaseTableFields; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetDatabaseTableFieldsList; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\QueryHandler\GetDatabaseTableFieldsListHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\ValueObject\DatabaseTableField; -use RequestSql; - -/** - * Class GetDatabaseTableFieldsListHandler. - * - * @internal - */ -final class GetDatabaseTableFieldsListHandler implements GetDatabaseTableFieldsListHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GetDatabaseTableFieldsList $query) - { - $attributes = (new RequestSql())->getAttributesByTable($query->getTableName()); - $fields = []; - - foreach ($attributes as $attribute) { - $fields[] = new DatabaseTableField( - $attribute['Field'], - $attribute['Type'] - ); - } - - return new DatabaseTableFields($fields); - } -} diff --git a/src/Adapter/SqlManager/QueryHandler/GetDatabaseTablesListHandler.php b/src/Adapter/SqlManager/QueryHandler/GetDatabaseTablesListHandler.php deleted file mode 100644 index 5653832f..00000000 --- a/src/Adapter/SqlManager/QueryHandler/GetDatabaseTablesListHandler.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\SqlManager\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\DatabaseTablesList; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetDatabaseTablesList; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\QueryHandler\GetDatabaseTablesListHandlerInterface; -use RequestSql; - -/** - * Class GetDatabaseTablesListHandler. - * - * @internal - */ -final class GetDatabaseTablesListHandler implements GetDatabaseTablesListHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GetDatabaseTablesList $query) - { - $dbTables = (new RequestSql())->getTables(); - - return new DatabaseTablesList($dbTables); - } -} diff --git a/src/Adapter/SqlManager/QueryHandler/GetSqlRequestExecutionResultHandler.php b/src/Adapter/SqlManager/QueryHandler/GetSqlRequestExecutionResultHandler.php deleted file mode 100644 index 780cc641..00000000 --- a/src/Adapter/SqlManager/QueryHandler/GetSqlRequestExecutionResultHandler.php +++ /dev/null @@ -1,100 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\SqlManager\QueryHandler; - -use Db; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetSqlRequestExecutionResult; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\QueryHandler\GetSqlRequestExecutionResultHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\SqlRequestExecutionResult; -use PrestaShopException; -use RequestSql; - -/** - * Class GetSqlRequestExecutionResultHandler. - * - * @internal - */ -final class GetSqlRequestExecutionResultHandler implements GetSqlRequestExecutionResultHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws SqlRequestNotFoundException - * @throws SqlRequestException - */ - public function handle(GetSqlRequestExecutionResult $query) - { - try { - $id = $query->getSqlRequestId()->getValue(); - $entity = new RequestSql($id); - - if (0 >= $entity->id) { - throw new SqlRequestNotFoundException(sprintf('SqlRequest with id %s was not found', $id)); - } - - $rows = Db::getInstance()->executeS($entity->sql); - - if (empty($rows)) { - return new SqlRequestExecutionResult([], []); - } - - $columns = array_keys(reset($rows)); - $rows = $this->hideSensitiveData($rows); - - return new SqlRequestExecutionResult( - $columns, - $rows - ); - } catch (PrestaShopException $e) { - throw new SqlRequestException('Unexpected error occurred', 0, $e); - } - } - - /** - * Replaces sensitive data with placeholder values. - * - * @param array $records - * - * @return array Records with hidden sensitive data - * - * @throws PrestaShopException - */ - private function hideSensitiveData(array $records) - { - foreach ($records as $key => $record) { - foreach ((new RequestSql())->attributes as $sensitiveAttribute => $placeholder) { - if (isset($record[$sensitiveAttribute])) { - $records[$key][$sensitiveAttribute] = $placeholder; - } - } - } - - return $records; - } -} diff --git a/src/Adapter/SqlManager/QueryHandler/GetSqlRequestForEditingHandler.php b/src/Adapter/SqlManager/QueryHandler/GetSqlRequestForEditingHandler.php deleted file mode 100644 index 10a65ae9..00000000 --- a/src/Adapter/SqlManager/QueryHandler/GetSqlRequestForEditingHandler.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\SqlManager\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\EditableSqlRequest; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetSqlRequestForEditing; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\QueryHandler\GetSqlRequestForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\ValueObject\SqlRequestId; -use RequestSql; - -/** - * Class GetSqlRequestForEditingHandler. - * - * @internal - */ -final class GetSqlRequestForEditingHandler implements GetSqlRequestForEditingHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws SqlRequestException - * @throws SqlRequestNotFoundException - */ - public function handle(GetSqlRequestForEditing $query) - { - $entity = $this->loadById($query->getRequestSqlId()); - - return $this->buildEditableSqlRequest($entity); - } - - /** - * @param SqlRequestId $requestSqlId - * - * @return RequestSql - * - * @throws SqlRequestNotFoundException - */ - private function loadById(SqlRequestId $requestSqlId) - { - $entity = new RequestSql($requestSqlId->getValue()); - - if (0 >= $entity->id) { - throw new SqlRequestNotFoundException(sprintf('SqlRequest with id "%s" cannot be found', $requestSqlId->getValue())); - } - - if ((int) $entity->id !== $requestSqlId->getValue()) { - throw new SqlRequestNotFoundException(sprintf('The retrieved id "%s" does not match requested SqlRequest id "%s"', $entity->id, $requestSqlId->getValue())); - } - - return $entity; - } - - /** - * @param RequestSql $entity - * - * @return EditableSqlRequest - * - * @throws SqlRequestException - */ - private function buildEditableSqlRequest(RequestSql $entity) - { - return new EditableSqlRequest( - new SqlRequestId($entity->id), - $entity->name, - $entity->sql - ); - } -} diff --git a/src/Adapter/SqlManager/SqlQueryValidator.php b/src/Adapter/SqlManager/SqlQueryValidator.php deleted file mode 100644 index 0d990648..00000000 --- a/src/Adapter/SqlManager/SqlQueryValidator.php +++ /dev/null @@ -1,415 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\SqlManager; - -use ErrorException; -use PrestaShop\PrestaShop\Adapter\Entity\RequestSql; -use PrestaShopDatabaseException; - -/** - * Class SqlQueryValidator is responsible for validating Request SQL model data. - */ -class SqlQueryValidator -{ - /** - * Check if SQL is valid for Reqest SQL model. - * Only "Select" sqls should be valid. - * - * @param string $sql - * - * @return array Array of errors if any - */ - public function validate($sql) - { - $errors = []; - - try { - $requestSql = new RequestSql(); - $parser = $requestSql->parsingSql($sql); - $validate = $requestSql->validateParser($parser, false, $sql); - - if (!$validate || count($requestSql->error_sql)) { - $errors = $this->getErrors($requestSql->error_sql); - } - } catch (ErrorException $e) { - $errors[] = [ - 'key' => 'Bad SQL query', - 'parameters' => [], - 'domain' => 'Admin.Notifications.Error', - ]; - } catch (PrestaShopDatabaseException $e) { - $errors[] = [ - 'key' => 'Bad SQL query', - 'parameters' => [], - 'domain' => 'Admin.Notifications.Error', - ]; - } - - return $errors; - } - - /** - * Get request sql errors. - * - * @param array $sqlErrors - * - * @return array - */ - private function getErrors(array $sqlErrors) - { - $errors = []; - - foreach ($sqlErrors as $key => $sqlError) { - if (false === is_array($sqlError)) { - $sqlError = []; - } - - if ('checkedFrom' === $key) { - $errors[] = $this->getFromKeywordError($sqlError); - } elseif ('checkedSelect' === $key) { - $errors[] = $this->getSelectKeywordError($sqlError); - } elseif ('checkedWhere' === $key) { - $errors[] = $this->getWhereKeywordError($sqlError); - } elseif ('checkedHaving' === $key) { - $errors[] = $this->getHavingKeywordError($sqlError); - } elseif ('checkedOrder' === $key) { - $errors[] = $this->getOrderKeywordError($sqlError); - } elseif ('checkedGroupBy' === $key) { - $errors[] = $this->getGroupKeywordError($sqlError); - } elseif ('checkedLimit' === $key) { - $errors[] = $this->getLimitKeywordError(); - } elseif ('returnNameTable' === $key) { - $errors[] = $this->getReferenceError($sqlError); - } elseif ('testedRequired' === $key) { - $errors[] = $this->getRequiredKeyError($sqlError); - } elseif ('testedUnauthorized' === $key) { - $errors[] = $this->getUnauthorizedKeyError($sqlError); - } - } - - return $errors; - } - - /** - * Get SQL error for "FROM" keyword validation. - * - * @param array $legacyError - * - * @return array - */ - private function getFromKeywordError(array $legacyError) - { - if (isset($legacyError['table'])) { - return [ - 'key' => 'The "%tablename%" table does not exist.', - 'parameters' => [ - '%tablename%' => $legacyError['table'], - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - if (isset($legacyError['attribut'])) { - return [ - 'key' => 'The "%attribute%" attribute does not exist in the "%table%" table.', - 'parameters' => [ - '%attribute%' => $legacyError['attribut'][0], - '%table%' => $legacyError['attribut'][1], - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - return [ - 'key' => 'Undefined "%s" error', - 'parameters' => [ - 'checkedForm', - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - /** - * Get SQL error for "SELECT" keyword validation. - * - * @param array $legacyError - * - * @return array - */ - private function getSelectKeywordError(array $legacyError) - { - if (isset($legacyError['table'])) { - return [ - 'key' => 'The "%tablename%" table does not exist.', - 'parameters' => [ - '%tablename%' => $legacyError['table'], - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - if (isset($legacyError['attribut'])) { - return [ - 'key' => 'The "%attribute%" attribute does not exist in the "%table%" table.', - 'parameters' => [ - '%attribute%' => $legacyError['attribut'][0], - '%table%' => $legacyError['attribut'][1], - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - if (isset($legacyError['*'])) { - return [ - 'key' => 'The "*" operator cannot be used in a nested query.', - 'parameters' => [], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - return [ - 'key' => 'Undefined "%s" error', - 'parameters' => [ - 'checkedSelect', - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - /** - * Get SQL error for "WHERE" keyword validation. - * - * @param array $legacyError - * - * @return array - */ - private function getWhereKeywordError(array $legacyError) - { - if (isset($legacyError['operator'])) { - return [ - 'key' => 'The operator "%s" is incorrect.', - 'parameters' => [ - '%operator%' => $legacyError['operator'], - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - if (isset($legacyError['attribut'])) { - return [ - 'key' => 'The "%attribute%" attribute does not exist in the "%table%" table.', - 'parameters' => [ - '%attribute%' => $legacyError['attribut'][0], - '%table%' => $legacyError['attribut'][1], - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - return [ - 'key' => 'Undefined "%s" error', - 'parameters' => [ - 'checkedWhere', - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - /** - * Get SQL error for "HAVING" keyword validation. - * - * @param array $legacyError - * - * @return array - */ - private function getHavingKeywordError(array $legacyError) - { - if (isset($legacyError['operator'])) { - return [ - 'key' => 'The "%operator%" operator is incorrect.', - 'parameters' => [ - '%operator%' => $legacyError['operator'], - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - if (isset($legacyError['attribut'])) { - return [ - 'key' => 'The "%attribute%" attribute does not exist in the "%table%" table.', - 'parameters' => [ - '%attribute%' => $legacyError['attribut'][0], - '%table%' => $legacyError['attribut'][1], - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - return [ - 'key' => 'Undefined "%s" error', - 'parameters' => [ - 'checkedHaving', - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - /** - * Get SQL error for "ORDER" keyword validation. - * - * @param array $legacyError - * - * @return array - */ - private function getOrderKeywordError(array $legacyError) - { - if (isset($legacyError['attribut'])) { - return [ - 'key' => 'The "%attribute%" attribute does not exist in the "%table%" table.', - 'parameters' => [ - '%attribute%' => $legacyError['attribut'][0], - '%table%' => $legacyError['attribut'][1], - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - return [ - 'key' => 'Undefined "%s" error', - 'parameters' => [ - 'checkedOrder', - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - /** - * Get SQL error for "GROUP" keyword validation. - * - * @param array $legacyError - * - * @return array - */ - private function getGroupKeywordError(array $legacyError) - { - if (isset($legacyError['attribut'])) { - return [ - 'key' => 'The "%attribute%" attribute does not exist in the "%table%" table.', - 'parameters' => [ - '%attribute%' => $legacyError['attribut'][0], - '%table%' => $legacyError['attribut'][1], - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - return [ - 'key' => 'Undefined "%s" error', - 'parameters' => [ - 'checkedGroupBy', - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - /** - * Get SQL error for "LIMIT" keyword validation. - * - * @return array - */ - private function getLimitKeywordError() - { - return [ - 'key' => 'The LIMIT clause must contain numeric arguments.', - 'parameters' => [], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - /** - * Get reference related SQL error. - * - * @param array $legacyError - * - * @return array - */ - private function getReferenceError(array $legacyError) - { - if (isset($legacyError['reference'])) { - return [ - 'key' => 'The "%reference%" reference does not exist in the "%table%" table.', - 'parameters' => [ - '%reference%' => $legacyError['reference'][0], - '%table%' => $legacyError['attribut'][1], - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - return [ - 'key' => 'When multiple tables are used, each attribute must refer back to a table.', - 'parameters' => [], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } - - /** - * Get required key error. - * - * @param string $legacyError - * - * @return array - */ - private function getRequiredKeyError($legacyError) - { - return [ - 'key' => '"%key%" does not exist.', - 'parameters' => [ - '%key%' => $legacyError, - ], - 'domain' => 'Admin.Notifications.Error', - ]; - } - - /** - * Get unauthorized key error. - * - * @param string $legacyError - * - * @return array - */ - private function getUnauthorizedKeyError($legacyError) - { - return [ - 'key' => '"%key%" is an unauthorized keyword.', - 'parameters' => [ - '%key%' => $legacyError, - ], - 'domain' => 'Admin.Advparameters.Notification', - ]; - } -} diff --git a/src/Adapter/SqlManager/SqlRequestFormDataValidator.php b/src/Adapter/SqlManager/SqlRequestFormDataValidator.php deleted file mode 100644 index 817d9c00..00000000 --- a/src/Adapter/SqlManager/SqlRequestFormDataValidator.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\SqlManager; - -use RequestSql; - -/** - * Class SqlRequestFormDataValidator validates SqlRequest data that is submitted via from. - * - * @internal - */ -class SqlRequestFormDataValidator -{ - /** - * @var SqlQueryValidator - */ - private $sqlQueryValidator; - - /** - * @param SqlQueryValidator $sqlQueryValidator - */ - public function __construct(SqlQueryValidator $sqlQueryValidator) - { - $this->sqlQueryValidator = $sqlQueryValidator; - } - - /** - * Validate SqlRequest form data. - * - * @param array $data - * - * @return array Errors if any - */ - public function validate(array $data) - { - if ($errors = $this->sqlQueryValidator->validate($data['sql'])) { - return $errors; - } - - $requestSql = new RequestSql(); - $requestSql->name = $data['name']; - $requestSql->sql = $data['sql']; - - if (true !== $error = $requestSql->validateFields(false, true)) { - return [$error]; - } - - return []; - } -} diff --git a/src/Adapter/StockManager.php b/src/Adapter/StockManager.php deleted file mode 100644 index 2249a6ee..00000000 --- a/src/Adapter/StockManager.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use Db; -use PrestaShop\PrestaShop\Adapter\Configuration as ConfigurationAdapter; -use PrestaShop\PrestaShop\Adapter\Shop\Context as ShopAdapter; -use PrestaShopBundle\Service\DataProvider\StockInterface; -use StockAvailable; - -/** - * Data provider for new Architecture, about Product stocks. - * - * This class will provide data from DB / ORM about Product stocks. - */ -class StockManager implements StockInterface -{ - /** - * Gets available stock for a given product / combination / shop. - * - * @param object $product - * @param null $id_product_attribute - * @param null $id_shop - * - * @return StockAvailable - */ - public function getStockAvailableByProduct($product, $id_product_attribute = null, $id_shop = null) - { - $stockAvailable = $this->newStockAvailable($this->getStockAvailableIdByProductId($product->id, $id_product_attribute, $id_shop)); - - if (!$stockAvailable->id) { - $shopAdapter = new ShopAdapter(); - $stockAvailable->id_product = (int) $product->id; - $stockAvailable->id_product_attribute = (int) $id_product_attribute; - - $outOfStock = $this->outOfStock((int) $product->id, $id_shop); - $stockAvailable->out_of_stock = (int) $outOfStock; - - if ($id_shop === null) { - $shop_group = $shopAdapter->getContextShopGroup(); - } else { - $shop_group = $shopAdapter->ShopGroup((int) $shopAdapter->getGroupFromShop((int) $id_shop)); - } - - // if quantities are shared between shops of the group - if ($shop_group->share_stock) { - $stockAvailable->id_shop = 0; - $stockAvailable->id_shop_group = (int) $shop_group->id; - } else { - $stockAvailable->id_shop = (int) $id_shop; - $stockAvailable->id_shop_group = 0; - } - $stockAvailable->add(); - } - - return $stockAvailable; - } - - /** - * Returns True if Stocks are managed by a module (or by legacy ASM). - * - * @return bool True if Stocks are managed by a module (or by legacy ASM) - */ - public function isAsmGloballyActivated() - { - return (bool) (new ConfigurationAdapter())->get('PS_ADVANCED_STOCK_MANAGEMENT'); - } - - /** - * @param $shopId - * @param $errorState - * @param $cancellationState - * @param int|null $idProduct - * @param int|null $idOrder - * - * @return bool - */ - public function updatePhysicalProductQuantity($shopId, $errorState, $cancellationState, $idProduct = null, $idOrder = null) - { - $this->updateReservedProductQuantity($shopId, $errorState, $cancellationState, $idProduct, $idOrder); - - $updatePhysicalQuantityQuery = ' - UPDATE {table_prefix}stock_available sa - SET sa.physical_quantity = sa.quantity + sa.reserved_quantity - WHERE sa.id_shop = ' . (int) $shopId . ' - '; - - if ($idProduct) { - $updatePhysicalQuantityQuery .= ' AND sa.id_product = ' . (int) $idProduct; - } - - if ($idOrder) { - $updatePhysicalQuantityQuery .= ' AND sa.id_product IN (SELECT product_id FROM {table_prefix}order_detail WHERE id_order = ' . (int) $idOrder . ')'; - } - - $updatePhysicalQuantityQuery = str_replace('{table_prefix}', _DB_PREFIX_, $updatePhysicalQuantityQuery); - - return Db::getInstance()->execute($updatePhysicalQuantityQuery); - } - - /** - * @param $shopId - * @param $errorState - * @param $cancellationState - * @param int|null $idProduct - * @param int|null $idOrder - * - * @return bool - */ - private function updateReservedProductQuantity($shopId, $errorState, $cancellationState, $idProduct = null, $idOrder = null) - { - $updateReservedQuantityQuery = ' - UPDATE {table_prefix}stock_available sa - SET sa.reserved_quantity = ( - SELECT SUM(od.product_quantity - od.product_quantity_refunded) - FROM {table_prefix}orders o - INNER JOIN {table_prefix}order_detail od ON od.id_order = o.id_order - INNER JOIN {table_prefix}order_state os ON os.id_order_state = o.current_state - WHERE o.id_shop = :shop_id AND - os.shipped != 1 AND ( - o.valid = 1 OR ( - os.id_order_state != :error_state AND - os.id_order_state != :cancellation_state - ) - ) AND sa.id_product = od.product_id AND - sa.id_product_attribute = od.product_attribute_id - GROUP BY od.product_id, od.product_attribute_id - ) - WHERE sa.id_shop = :shop_id - '; - - $strParams = [ - '{table_prefix}' => _DB_PREFIX_, - ':shop_id' => (int) $shopId, - ':error_state' => (int) $errorState, - ':cancellation_state' => (int) $cancellationState, - ]; - - if ($idProduct) { - $updateReservedQuantityQuery .= ' AND sa.id_product = :product_id'; - $strParams[':product_id'] = (int) $idProduct; - } - - if ($idOrder) { - $updateReservedQuantityQuery .= ' AND sa.id_product IN (SELECT product_id FROM {table_prefix}order_detail WHERE id_order = :order_id)'; - $strParams[':order_id'] = (int) $idOrder; - } - - $updateReservedQuantityQuery = strtr($updateReservedQuantityQuery, $strParams); - - return Db::getInstance()->execute($updateReservedQuantityQuery); - } - - /** - * Instance a new StockAvailable. - * - * @param null $stockAvailableId - * - * @return StockAvailable - */ - public function newStockAvailable($stockAvailableId = null) - { - if (is_int($stockAvailableId)) { - return new StockAvailable($stockAvailableId); - } - - return new StockAvailable(); - } - - /** - * Use legacy getStockAvailableIdByProductId. - * - * @param $productId - * @param null $productAttributeId - * @param null $shopId - * - * @return bool|int - */ - public function getStockAvailableIdByProductId($productId, $productAttributeId = null, $shopId = null) - { - return StockAvailable::getStockAvailableIdByProductId($productId, $productAttributeId, $shopId); - } - - /** - * For a given product, get its "out of stock" flag. - * - * @param int $productId - * @param int $shopId Optional : gets context if null @see Context::getContext() - * - * @return bool : depends on stock @see $depends_on_stock - */ - public function outOfStock($productId, $shopId = null) - { - return StockAvailable::outOfStock($productId, $shopId); - } -} diff --git a/src/Adapter/Supplier/AbstractSupplierHandler.php b/src/Adapter/Supplier/AbstractSupplierHandler.php deleted file mode 100644 index d4f13ba8..00000000 --- a/src/Adapter/Supplier/AbstractSupplierHandler.php +++ /dev/null @@ -1,120 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Supplier; - -use Address; -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\ValueObject\SupplierId; -use PrestaShopException; -use Supplier; - -/** - * Provides reusable methods for supplier command/query handlers - */ -abstract class AbstractSupplierHandler extends AbstractObjectModelHandler -{ - /** - * Gets legacy Supplier - * - * @param SupplierId $supplierId - * - * @return Supplier - * - * @throws SupplierException - */ - protected function getSupplier(SupplierId $supplierId) - { - try { - $supplier = new Supplier($supplierId->getValue()); - } catch (PrestaShopException $e) { - throw new SupplierException('Failed to create new supplier', 0, $e); - } - - if ($supplier->id !== $supplierId->getValue()) { - throw new SupplierNotFoundException(sprintf('Supplier with id "%s" was not found.', $supplierId->getValue())); - } - - return $supplier; - } - - /** - * @param SupplierId $supplierId - * - * @return Address - * - * @throws SupplierException - */ - protected function getSupplierAddress(SupplierId $supplierId) - { - $supplierIdValue = $supplierId->getValue(); - try { - $addressId = Address::getAddressIdBySupplierId($supplierIdValue); - - $address = new Address($addressId); - - if (null === $address->id_supplier) { - throw new AddressNotFoundException(sprintf('Address for supplier with id "%s" was not found', $supplierIdValue)); - } - } catch (PrestaShopException $e) { - throw new SupplierException('Failed to get supplier address', 0, $e); - } - - return $address; - } - - protected function removeSupplier(SupplierId $supplierId) - { - $supplier = $this->getSupplier($supplierId); - - try { - return $supplier->delete(); - } catch (PrestaShopException $e) { - throw new SupplierException(sprintf('An error occurred when deleting Supplier object with id "%s".', $supplier->id)); - } - } - - /** - * @param Supplier $supplier - * @param Address $address - * - * @throws PrestaShopException - * @throws SupplierException - */ - protected function validateFields(Supplier $supplier, Address $address) - { - if (false === $supplier->validateFields(false) || false === $supplier->validateFieldsLang(false)) { - throw new SupplierException('Supplier contains invalid field values'); - } - - if (false === $address->validateFields(false) || false === $address->validateFieldsLang(false)) { - throw new SupplierException('Supplier address contains invalid field values'); - } - } -} diff --git a/src/Adapter/Supplier/CommandHandler/AbstractDeleteSupplierHandler.php b/src/Adapter/Supplier/CommandHandler/AbstractDeleteSupplierHandler.php deleted file mode 100644 index d73c9c42..00000000 --- a/src/Adapter/Supplier/CommandHandler/AbstractDeleteSupplierHandler.php +++ /dev/null @@ -1,162 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Supplier\CommandHandler; - -use Address; -use Db; -use PrestaShop\PrestaShop\Adapter\Supplier\SupplierAddressProvider; -use PrestaShop\PrestaShop\Adapter\Supplier\SupplierOrderValidator; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\CannotDeleteSupplierAddressException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\CannotDeleteSupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\CannotDeleteSupplierProductRelationException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\ValueObject\SupplierId; -use PrestaShopException; -use Supplier; - -/** - * Class AbstractDeleteSupplierHandler defines common actions required for - * both BulkDeleteSupplierHandler and DeleteSupplierHandler. - */ -abstract class AbstractDeleteSupplierHandler -{ - /** - * @var SupplierOrderValidator - */ - private $supplierOrderValidator; - - /** - * @var string - */ - private $dbPrefix; - - /** - * @var SupplierAddressProvider - */ - private $supplierAddressProvider; - - /** - * @param SupplierOrderValidator $supplierOrderValidator - * @param SupplierAddressProvider $supplierAddressProvider - * @param string $dbPrefix - */ - public function __construct( - SupplierOrderValidator $supplierOrderValidator, - SupplierAddressProvider $supplierAddressProvider, - $dbPrefix - ) { - $this->supplierOrderValidator = $supplierOrderValidator; - $this->dbPrefix = $dbPrefix; - $this->supplierAddressProvider = $supplierAddressProvider; - } - - /** - * Removes supplier and all related content with it such as image, supplier and product relation - * and supplier address. - * - * @param SupplierId $supplierId - * - * @throws SupplierException - */ - protected function removeSupplier(SupplierId $supplierId) - { - try { - $entity = new Supplier($supplierId->getValue()); - - if (0 >= $entity->id) { - throw new SupplierNotFoundException(sprintf('Supplier object with id "%s" was not found for deletion.', $supplierId->getValue())); - } - - if ($this->hasPendingOrders($supplierId)) { - throw new CannotDeleteSupplierException($supplierId->getValue(), sprintf('Supplier with id %s cannot be deleted due to it has pending orders', $supplierId->getValue()), CannotDeleteSupplierException::HAS_PENDING_ORDERS); - } - - if (false === $this->deleteProductSupplierRelation($supplierId)) { - throw new CannotDeleteSupplierProductRelationException(sprintf('Unable to delete suppliers with id "%s" product relation from product_supplier table', $supplierId->getValue())); - } - - if (1 >= count($entity->getAssociatedShops()) && false === $this->deleteSupplierAddress($supplierId)) { - throw new CannotDeleteSupplierAddressException(sprintf('Unable to set deleted flag for supplier with id "%s" address', $supplierId->getValue())); - } - - if (false === $entity->delete()) { - throw new SupplierException(sprintf('Unable to delete supplier object with id "%s"', $supplierId->getValue())); - } - } catch (PrestaShopException $exception) { - throw new SupplierException(sprintf('An error occurred when deleting the supplier object with id "%s"', $supplierId->getValue()), 0, $exception); - } - } - - /** - * Deletes product supplier relation. - * - * @param SupplierId $supplierId - * - * @return bool - */ - private function deleteProductSupplierRelation(SupplierId $supplierId) - { - $sql = 'DELETE FROM `' . $this->dbPrefix . 'product_supplier` WHERE `id_supplier`=' . $supplierId->getValue(); - - return Db::getInstance()->execute($sql); - } - - /** - * Deletes supplier address. - * - * @param SupplierId $supplierId - * - * @return bool - */ - private function deleteSupplierAddress(SupplierId $supplierId) - { - $supplierAddressId = $this->supplierAddressProvider->getIdBySupplier($supplierId->getValue()); - - $address = new Address($supplierAddressId); - - if ($address->id) { - $address->deleted = true; - - return $address->update(); - } - - return true; - } - - /** - * Checks if the given supplier has pending orders. - * - * @param SupplierId $supplierId - * - * @return bool - */ - private function hasPendingOrders(SupplierId $supplierId) - { - return $this->supplierOrderValidator->hasPendingOrders($supplierId->getValue()); - } -} diff --git a/src/Adapter/Supplier/CommandHandler/AddSupplierHandler.php b/src/Adapter/Supplier/CommandHandler/AddSupplierHandler.php deleted file mode 100644 index 9976b04d..00000000 --- a/src/Adapter/Supplier/CommandHandler/AddSupplierHandler.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Supplier\CommandHandler; - -use Address; -use PrestaShop\PrestaShop\Adapter\Supplier\AbstractSupplierHandler; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\AddSupplierCommand; -use PrestaShop\PrestaShop\Core\Domain\Supplier\CommandHandler\AddSupplierHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\ValueObject\SupplierId; -use PrestaShopDatabaseException; -use PrestaShopException; -use Supplier; - -/** - * Handles command which adds new supplier using legacy object model - */ -final class AddSupplierHandler extends AbstractSupplierHandler implements AddSupplierHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws SupplierException - */ - public function handle(AddSupplierCommand $command) - { - $supplier = new Supplier(); - $this->fillSupplierWithData($supplier, $command); - $address = $this->fetchSupplierAddressFromCommand($command); - - try { - $this->validateFields($supplier, $address); - - if (!$address->add()) { - throw new SupplierException(sprintf('Failed to add new supplier address "%s"', $address->address1)); - } - - if (!$supplier->add()) { - throw new SupplierException(sprintf('Failed to add new supplier "%s"', $command->getName())); - } - - $this->addShopAssociation($supplier, $command); - $address->id_supplier = $supplier->id; - $address->update(); - } catch (PrestaShopException $e) { - throw new SupplierException(sprintf('Failed to add new supplier "%s"', $command->getName())); - } - - return new SupplierId((int) $supplier->id); - } - - /** - * Add supplier and shop association - * - * @param Supplier $supplier - * @param AddSupplierCommand $command - * - * @throws PrestaShopDatabaseException - */ - private function addShopAssociation(Supplier $supplier, AddSupplierCommand $command) - { - $this->associateWithShops( - $supplier, - $command->getShopAssociation() - ); - } - - /** - * @param Supplier $supplier - * @param AddSupplierCommand $command - */ - private function fillSupplierWithData(Supplier $supplier, AddSupplierCommand $command) - { - $currentDateTime = date('Y-m-d H:i:s'); - - $supplier->name = $command->getName(); - $supplier->description = $command->getLocalizedDescriptions(); - $supplier->meta_description = $command->getLocalizedMetaDescriptions(); - $supplier->meta_title = $command->getLocalizedMetaTitles(); - $supplier->meta_keywords = $command->getLocalizedMetaKeywords(); - $supplier->date_add = $currentDateTime; - $supplier->date_upd = $currentDateTime; - $supplier->active = $command->isEnabled(); - } - - /** - * Creates legacy address from given command data - * - * @param AddSupplierCommand $command - * - * @return Address - */ - private function fetchSupplierAddressFromCommand(AddSupplierCommand $command) - { - $address = new Address(); - $address->alias = 'supplier'; - $address->firstname = 'supplier'; - $address->lastname = 'supplier'; - $address->address1 = $command->getAddress(); - $address->address2 = $command->getAddress2(); - $address->id_country = $command->getCountryId(); - $address->city = $command->getCity(); - $address->id_state = $command->getStateId(); - $address->phone = $command->getPhone(); - $address->phone_mobile = $command->getMobilePhone(); - $address->postcode = $command->getPostCode(); - $address->dni = $command->getDni(); - - return $address; - } -} diff --git a/src/Adapter/Supplier/CommandHandler/BulkDeleteSupplierHandler.php b/src/Adapter/Supplier/CommandHandler/BulkDeleteSupplierHandler.php deleted file mode 100644 index ff665f9d..00000000 --- a/src/Adapter/Supplier/CommandHandler/BulkDeleteSupplierHandler.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Supplier\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\BulkDeleteSupplierCommand; -use PrestaShop\PrestaShop\Core\Domain\Supplier\CommandHandler\BulkDeleteSupplierHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\CannotDeleteSupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; - -/** - * Class BulkDeleteSupplierHandler is responsible for deleting multiple suppliers. - */ -final class BulkDeleteSupplierHandler extends AbstractDeleteSupplierHandler implements BulkDeleteSupplierHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws SupplierException - */ - public function handle(BulkDeleteSupplierCommand $command) - { - foreach ($command->getSupplierIds() as $supplierId) { - try { - $this->removeSupplier($supplierId); - } catch (SupplierException $e) { - if (SupplierException::class === get_class($e)) { - throw new CannotDeleteSupplierException(sprintf('Cannot delete Supplier object with id "%s".', $supplierId->getValue()), CannotDeleteSupplierException::FAILED_BULK_DELETE); - } - - throw $e; - } - } - } -} diff --git a/src/Adapter/Supplier/CommandHandler/BulkDisableSupplierHandler.php b/src/Adapter/Supplier/CommandHandler/BulkDisableSupplierHandler.php deleted file mode 100644 index 0cbc86f5..00000000 --- a/src/Adapter/Supplier/CommandHandler/BulkDisableSupplierHandler.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Supplier\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\BulkDisableSupplierCommand; -use PrestaShop\PrestaShop\Core\Domain\Supplier\CommandHandler\BulkDisableSupplierHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\CannotUpdateSupplierStatusException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierNotFoundException; -use PrestaShopException; -use Supplier; - -/** - * Class BulkDisableSupplierHandler is responsible for disabling multiple suppliers. - */ -final class BulkDisableSupplierHandler implements BulkDisableSupplierHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws SupplierException - */ - public function handle(BulkDisableSupplierCommand $command) - { - try { - foreach ($command->getSupplierIds() as $supplierId) { - $entity = new Supplier($supplierId->getValue()); - - if (0 >= $entity->id) { - throw new SupplierNotFoundException(sprintf('Supplier object with id "%s" has not been found for disabling status.', $supplierId->getValue())); - } - - $entity->active = false; - - if (false === $entity->update()) { - throw new CannotUpdateSupplierStatusException(sprintf('Unable to disable supplier object with id "%s"', $supplierId->getValue())); - } - } - } catch (PrestaShopException $e) { - throw new SupplierException('Unexpected error occurred when handling bulk disable supplier', 0, $e); - } - } -} diff --git a/src/Adapter/Supplier/CommandHandler/BulkEnableSupplierHandler.php b/src/Adapter/Supplier/CommandHandler/BulkEnableSupplierHandler.php deleted file mode 100644 index 47524f48..00000000 --- a/src/Adapter/Supplier/CommandHandler/BulkEnableSupplierHandler.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Supplier\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\BulkEnableSupplierCommand; -use PrestaShop\PrestaShop\Core\Domain\Supplier\CommandHandler\BulkEnableSupplierHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\CannotUpdateSupplierStatusException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierNotFoundException; -use PrestaShopException; -use Supplier; - -/** - * Class BulkEnableSupplierHandler is responsible for enabling multiple suppliers. - */ -final class BulkEnableSupplierHandler implements BulkEnableSupplierHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws SupplierException - */ - public function handle(BulkEnableSupplierCommand $command) - { - try { - foreach ($command->getSupplierIds() as $supplierId) { - $entity = new Supplier($supplierId->getValue()); - - if (0 >= $entity->id) { - throw new SupplierNotFoundException(sprintf('Supplier object with id "%s" has not been found for enabling status.', $supplierId->getValue())); - } - - $entity->active = true; - - if (false === $entity->update()) { - throw new CannotUpdateSupplierStatusException(sprintf('Unable to enable supplier object with id "%s"', $supplierId->getValue())); - } - } - } catch (PrestaShopException $e) { - throw new SupplierException('Unexpected error occurred when handling bulk enable supplier', 0, $e); - } - } -} diff --git a/src/Adapter/Supplier/CommandHandler/DeleteSupplierHandler.php b/src/Adapter/Supplier/CommandHandler/DeleteSupplierHandler.php deleted file mode 100644 index 91f7d9f5..00000000 --- a/src/Adapter/Supplier/CommandHandler/DeleteSupplierHandler.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Supplier\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\DeleteSupplierCommand; -use PrestaShop\PrestaShop\Core\Domain\Supplier\CommandHandler\DeleteSupplierHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\CannotDeleteSupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; - -/** - * Class DeleteSupplierHandler is responsible for deleting the supplier. - */ -final class DeleteSupplierHandler extends AbstractDeleteSupplierHandler implements DeleteSupplierHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws SupplierException - */ - public function handle(DeleteSupplierCommand $command) - { - $supplierId = $command->getSupplierId(); - try { - $this->removeSupplier($supplierId); - } catch (SupplierException $e) { - if (SupplierException::class === get_class($e)) { - throw new CannotDeleteSupplierException(sprintf('Cannot delete Supplier object with id "%s".', $supplierId->getValue()), CannotDeleteSupplierException::FAILED_DELETE); - } - - throw $e; - } - } -} diff --git a/src/Adapter/Supplier/CommandHandler/EditSupplierHandler.php b/src/Adapter/Supplier/CommandHandler/EditSupplierHandler.php deleted file mode 100644 index 93c051d3..00000000 --- a/src/Adapter/Supplier/CommandHandler/EditSupplierHandler.php +++ /dev/null @@ -1,139 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Adapter\Supplier\CommandHandler; - -use Address; -use PrestaShop\PrestaShop\Adapter\Supplier\AbstractSupplierHandler; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\EditSupplierCommand; -use PrestaShop\PrestaShop\Core\Domain\Supplier\CommandHandler\EditSupplierHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShopException; -use Supplier; - -/** - * Handles command which edits supplier using legacy object model - */ -final class EditSupplierHandler extends AbstractSupplierHandler implements EditSupplierHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws SupplierException - */ - public function handle(EditSupplierCommand $command) - { - $supplierId = $command->getSupplierId(); - $supplier = $this->getSupplier($supplierId); - $address = $this->getSupplierAddress($supplierId); - - $this->populateSupplierWithData($supplier, $command); - $this->populateAddressWithData($address, $command); - - try { - $this->validateFields($supplier, $address); - - if (false === $supplier->update()) { - throw new SupplierException(sprintf('Cannot update supplier with id "%s"', $supplier->id)); - } - if (false === $address->update()) { - throw new SupplierException(sprintf('Cannot update supplier address with id "%s"', $address->id)); - } - if (null !== $command->getAssociatedShops()) { - $this->associateWithShops($supplier, $command->getAssociatedShops()); - } - } catch (PrestaShopException $e) { - throw new SupplierException(sprintf('Cannot update supplier with id "%s"', $supplier->id)); - } - } - - /** - * Populates Supplier object with given data - * - * @param Supplier $supplier - * @param EditSupplierCommand $command - */ - private function populateSupplierWithData(Supplier $supplier, EditSupplierCommand $command) - { - if (null !== $command->getName()) { - $supplier->name = $command->getName(); - } - if (null !== $command->getLocalizedDescriptions()) { - $supplier->description = $command->getLocalizedDescriptions(); - } - if (null !== $command->getLocalizedMetaDescriptions()) { - $supplier->meta_description = $command->getLocalizedMetaDescriptions(); - } - if (null !== $command->getLocalizedMetaKeywords()) { - $supplier->meta_keywords = $command->getLocalizedMetaKeywords(); - } - if (null !== $command->getLocalizedMetaTitles()) { - $supplier->meta_title = $command->getLocalizedMetaTitles(); - } - if (null !== $command->isEnabled()) { - $supplier->active = $command->isEnabled(); - } - $supplier->date_upd = date('Y-m-d H:i:s'); - } - - /** - * Populates Supplier address with given data - * - * @param Address $address - * @param EditSupplierCommand $command - */ - private function populateAddressWithData(Address $address, EditSupplierCommand $command) - { - if (null !== $command->getAddress()) { - $address->address1 = $command->getAddress(); - } - if (null !== $command->getAddress2()) { - $address->address2 = $command->getAddress2(); - } - if (null !== $command->getPostCode()) { - $address->postcode = $command->getPostCode(); - } - if (null !== $command->getPhone()) { - $address->phone = $command->getPhone(); - } - if (null !== $command->getMobilePhone()) { - $address->phone_mobile = $command->getMobilePhone(); - } - if (null !== $command->getCity()) { - $address->city = $command->getCity(); - } - if (null !== $command->getCountryId()) { - $address->id_country = $command->getCountryId(); - } - if (null !== $command->getStateId()) { - $address->id_state = $command->getStateId(); - } - if (null !== $command->getDni()) { - $address->dni = $command->getDni(); - } - } -} diff --git a/src/Adapter/Supplier/CommandHandler/ToggleSupplierStatusHandler.php b/src/Adapter/Supplier/CommandHandler/ToggleSupplierStatusHandler.php deleted file mode 100644 index fc6de9d7..00000000 --- a/src/Adapter/Supplier/CommandHandler/ToggleSupplierStatusHandler.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Supplier\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\ToggleSupplierStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Supplier\CommandHandler\ToggleSupplierStatusHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\CannotToggleSupplierStatusException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierNotFoundException; -use PrestaShopException; -use Supplier; - -/** - * Class ToggleSupplierStatusHandler is responsible for toggling supplier status. - */ -final class ToggleSupplierStatusHandler implements ToggleSupplierStatusHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws SupplierException - */ - public function handle(ToggleSupplierStatusCommand $command) - { - try { - $entity = new Supplier($command->getSupplierId()->getValue()); - - if (0 >= $entity->id) { - throw new SupplierNotFoundException(sprintf('Supplier object with id "%s" has not been found for status changing.', $command->getSupplierId()->getValue())); - } - - if (false === $entity->toggleStatus()) { - throw new CannotToggleSupplierStatusException(sprintf('Unable to toggle supplier with id "%s"', $command->getSupplierId()->getValue())); - } - } catch (PrestaShopException $exception) { - throw new SupplierException(sprintf('An error occurred when toggling status for supplier object with id "%s"', $command->getSupplierId()->getValue()), 0, $exception); - } - } -} diff --git a/src/Adapter/Supplier/QueryHandler/GetSupplierForEditingHandler.php b/src/Adapter/Supplier/QueryHandler/GetSupplierForEditingHandler.php deleted file mode 100644 index 887dbe46..00000000 --- a/src/Adapter/Supplier/QueryHandler/GetSupplierForEditingHandler.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Supplier\QueryHandler; - -use PrestaShop\PrestaShop\Adapter\Supplier\AbstractSupplierHandler; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Query\GetSupplierForEditing; -use PrestaShop\PrestaShop\Core\Domain\Supplier\QueryHandler\GetSupplierForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Supplier\QueryResult\EditableSupplier; -use PrestaShop\PrestaShop\Core\Image\Parser\ImageTagSourceParserInterface; - -/** - * Handles query which gets supplier for editing - */ -final class GetSupplierForEditingHandler extends AbstractSupplierHandler implements GetSupplierForEditingHandlerInterface -{ - /** - * @var ImageTagSourceParserInterface - */ - private $imageTagSourceParser; - - /** - * @var int - */ - private $contextShopId; - - public function __construct( - ImageTagSourceParserInterface $imageTagSourceParser, - $contextShopId - ) { - $this->imageTagSourceParser = $imageTagSourceParser; - $this->contextShopId = $contextShopId; - } - - /** - * {@inheritdoc} - */ - public function handle(GetSupplierForEditing $query) - { - $supplierId = $query->getSupplierId(); - $supplier = $this->getSupplier($supplierId); - $address = $this->getSupplierAddress($supplierId); - - return new EditableSupplier( - $supplierId, - $supplier->name, - $supplier->description, - $address->address1, - $address->city, - $address->address2, - (int) $address->id_country, - $address->postcode, - (int) $address->id_state, - $address->phone, - $address->phone_mobile, - $supplier->meta_title, - $supplier->meta_description, - $supplier->meta_keywords, - (bool) $supplier->active, - $supplier->getAssociatedShops(), - $address->dni, - $this->getLogoImage($supplierId->getValue()) - ); - } - - /** - * @param int $imageId - * - * @return array|null - */ - private function getLogoImage(int $imageId): ?array - { - $imagePath = _PS_SUPP_IMG_DIR_ . $imageId . '.jpg'; - $imageTag = $this->getTmpImageTag($imagePath, $imageId, 'supplier'); - $imageSize = $this->getImageSize($imagePath); - - if (empty($imageTag) || null === $imageSize) { - return null; - } - - return [ - 'size' => sprintf('%skB', $imageSize), - 'path' => $this->imageTagSourceParser->parse($imageTag), - ]; - } -} diff --git a/src/Adapter/Supplier/QueryHandler/GetSupplierForViewingHandler.php b/src/Adapter/Supplier/QueryHandler/GetSupplierForViewingHandler.php deleted file mode 100644 index f5190d13..00000000 --- a/src/Adapter/Supplier/QueryHandler/GetSupplierForViewingHandler.php +++ /dev/null @@ -1,177 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Supplier\QueryHandler; - -use Currency; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Query\GetSupplierForViewing; -use PrestaShop\PrestaShop\Core\Domain\Supplier\QueryHandler\GetSupplierForViewingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Supplier\QueryResult\ViewableSupplier; -use PrestaShop\PrestaShop\Core\Domain\Supplier\ValueObject\SupplierId; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShop\PrestaShop\Core\Localization\Locale; -use PrestaShopException; -use Product; -use Supplier; - -/** - * Handles query which gets supplier for viewing - */ -final class GetSupplierForViewingHandler implements GetSupplierForViewingHandlerInterface -{ - /** - * @var Locale - */ - private $locale; - - /** - * @param Locale $locale - */ - public function __construct( - Locale $locale - ) { - $this->locale = $locale; - } - - /** - * {@inheritdoc} - * - * @throws SupplierException - * @throws LocalizationException - */ - public function handle(GetSupplierForViewing $query) - { - $supplier = $this->getSupplier($query->getSupplierId()); - - return new ViewableSupplier( - $supplier->name, - $this->getSupplierProducts($supplier, $query->getLanguageId()) - ); - } - - /** - * @param SupplierId $supplierId - * - * @return Supplier - * - * @throws SupplierNotFoundException - */ - private function getSupplier(SupplierId $supplierId) - { - $supplier = new Supplier($supplierId->getValue()); - - if ($supplier->id !== $supplierId->getValue()) { - throw new SupplierNotFoundException(sprintf('Supplier with id "%s" was not found.', $supplierId->getValue())); - } - - return $supplier; - } - - /** - * @param Supplier $supplier - * @param LanguageId $languageId - * - * @return array - * - * @throws LocalizationException - * @throws SupplierException - */ - private function getSupplierProducts(Supplier $supplier, LanguageId $languageId) - { - $products = []; - $supplierProducts = $supplier->getProductsLite($languageId->getValue()); - - try { - foreach ($supplierProducts as $productData) { - $product = new Product($productData['id_product'], false, $languageId->getValue()); - $product->loadStockData(); - - $productCombinations = $product->getAttributeCombinations($languageId->getValue()); - $combinations = []; - - foreach ($productCombinations as $combination) { - $attributeId = $combination['id_product_attribute']; - if (!isset($combinations[$attributeId])) { - $productInfo = Supplier::getProductInformationsBySupplier( - $supplier->id, - $product->id, - $combination['id_product_attribute'] - ); - $combinations[$attributeId] = [ - 'reference' => $combination['reference'], - 'supplier_reference' => $combination['supplier_reference'], - 'wholesale_price' => $this->locale->formatPrice( - $productInfo['product_supplier_price_te'], - Currency::getIsoCodeById((int) $productInfo['id_currency']) - ), - 'ean13' => $combination['ean13'], - 'upc' => $combination['upc'], - 'quantity' => $combination['quantity'], - 'attributes' => '', - ]; - } - $attribute = sprintf( - '%s - %s', - $combination['group_name'], - $combination['attribute_name'] - ); - - if (!empty($combinations[$attributeId]['attributes'])) { - $attribute = sprintf(', %s', $attribute); - } - - $combinations[$attributeId]['attributes'] = $attribute; - } - - $productInfo = Supplier::getProductInformationsBySupplier( - $supplier->id, - $product->id, - 0 - ); - $product->wholesale_price = $productInfo['product_supplier_price_te']; - $product->supplier_reference = $productInfo['product_supplier_reference']; - $products[] = [ - 'id' => $product->id, - 'name' => $product->name, - 'reference' => $product->reference, - 'supplier_reference' => $product->supplier_reference, - 'wholesale_price' => $this->locale->formatPrice($product->wholesale_price, Currency::getIsoCodeById((int) $productInfo['id_currency'])), - 'ean13' => $product->ean13, - 'upc' => $product->upc, - 'quantity' => $product->quantity, - 'combinations' => $combinations, - ]; - } - } catch (PrestaShopException $e) { - throw new SupplierException(sprintf('Failed to get products for supplier with id "%s".', $supplier->id)); - } - - return $products; - } -} diff --git a/src/Adapter/Supplier/SupplierAddressProvider.php b/src/Adapter/Supplier/SupplierAddressProvider.php deleted file mode 100644 index e1b1eeaa..00000000 --- a/src/Adapter/Supplier/SupplierAddressProvider.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Supplier; - -use Address; - -/** - * Class SupplierAddressProvider is responsible for supplier address data retrieval. - */ -class SupplierAddressProvider -{ - /** - * Gets address id by supplier - * - * @param int $supplierId - * - * @return int - */ - public function getIdBySupplier($supplierId) - { - return Address::getAddressIdBySupplierId($supplierId); - } -} diff --git a/src/Adapter/Supplier/SupplierDataProvider.php b/src/Adapter/Supplier/SupplierDataProvider.php deleted file mode 100644 index 84ed87fc..00000000 --- a/src/Adapter/Supplier/SupplierDataProvider.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Supplier; - -use ProductSupplier; -use Supplier; - -/** - * This class will provide data from DB / ORM about Supplier. - */ -class SupplierDataProvider -{ - /** - * Get all suppliers. - * - * @param bool $get_nb_products - * @param int $id_lang - * @param bool $active - * @param bool $p - * @param bool $n - * @param bool $all_groups - * - * @return array Suppliers - */ - public function getSuppliers($get_nb_products = false, $id_lang = 0, $active = true, $p = false, $n = false, $all_groups = false) - { - return Supplier::getSuppliers($get_nb_products, $id_lang, $active, $p, $n, $all_groups); - } - - /** - * Get product suppliers. - * - * @param int $id_product - * @param bool $group_by_supplier - * - * @return array Suppliers - */ - public function getProductSuppliers($id_product, $group_by_supplier = true) - { - $suppliersCollection = ProductSupplier::getSupplierCollection($id_product, $group_by_supplier); - - return $suppliersCollection->getResults(); - } - - /** - * For a given product and supplier, gets the product supplier data. - * - * @param int $id_product - * @param int $id_product_attribute - * @param int $id_supplier - * - * @return array - */ - public function getProductSupplierData($id_product, $id_product_attribute, $id_supplier) - { - return ProductSupplier::getProductSupplierData($id_product, $id_product_attribute, $id_supplier); - } - - /** - * Get supplier name by id. - * - * @param int $id_supplier - * - * @return string - */ - public function getNameById($id_supplier) - { - return Supplier::getNameById($id_supplier); - } -} diff --git a/src/Adapter/Supplier/SupplierLogoThumbnailProvider.php b/src/Adapter/Supplier/SupplierLogoThumbnailProvider.php deleted file mode 100644 index dec20078..00000000 --- a/src/Adapter/Supplier/SupplierLogoThumbnailProvider.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Supplier; - -use PrestaShop\PrestaShop\Adapter\ImageManager; -use PrestaShop\PrestaShop\Core\Image\ImageProviderInterface; -use PrestaShop\PrestaShop\Core\Image\Parser\ImageTagSourceParserInterface; - -/** - * Class SupplierLogoThumbnailProvider is responsible for providing thumbnail path for supplier logo image. - */ -final class SupplierLogoThumbnailProvider implements ImageProviderInterface -{ - /** - * @var ImageTagSourceParserInterface - */ - private $imageTagSourceParser; - - /** - * @var ImageManager - */ - private $imageManager; - - /** - * @param ImageTagSourceParserInterface $imageTagSourceParser - * @param ImageManager $imageManager - */ - public function __construct( - ImageTagSourceParserInterface $imageTagSourceParser, - ImageManager $imageManager - ) { - $this->imageTagSourceParser = $imageTagSourceParser; - $this->imageManager = $imageManager; - } - - /** - * {@inheritdoc} - */ - public function getPath($supplierId) - { - $imageTag = $this->imageManager->getThumbnailForListing( - $supplierId, - 'jpg', - 'supplier', - _PS_SUPP_IMG_DIR_ - ); - - return $this->imageTagSourceParser->parse($imageTag); - } -} diff --git a/src/Adapter/Supplier/SupplierOrderValidator.php b/src/Adapter/Supplier/SupplierOrderValidator.php deleted file mode 100644 index 2bc4198d..00000000 --- a/src/Adapter/Supplier/SupplierOrderValidator.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Supplier; - -use SupplyOrder; - -/** - * Class SupplierOrderValidator is responsible for handling supplier and its corresponding order validity. - */ -class SupplierOrderValidator -{ - /** - * Checks if the given supplier has pending orders. - * - * @param int $supplierId - * - * @return bool - */ - public function hasPendingOrders($supplierId) - { - return SupplyOrder::supplierHasPendingOrders($supplierId); - } -} diff --git a/src/Adapter/Supplier/SupplierProductSearchProvider.php b/src/Adapter/Supplier/SupplierProductSearchProvider.php deleted file mode 100644 index 09ca6e50..00000000 --- a/src/Adapter/Supplier/SupplierProductSearchProvider.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Supplier; - -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchContext; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchProviderInterface; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchQuery; -use PrestaShop\PrestaShop\Core\Product\Search\ProductSearchResult; -use PrestaShop\PrestaShop\Core\Product\Search\SortOrderFactory; -use Supplier; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class responsible of retrieving products in Suppliers page of Front Office. - * - * @see SupplierController - */ -class SupplierProductSearchProvider implements ProductSearchProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var Supplier - */ - private $supplier; - - /** - * @var SortOrderFactory - */ - private $sortOrderFactory; - - public function __construct( - TranslatorInterface $translator, - Supplier $supplier - ) { - $this->translator = $translator; - $this->supplier = $supplier; - $this->sortOrderFactory = new SortOrderFactory($this->translator); - } - - /** - * @param ProductSearchContext $context - * @param ProductSearchQuery $query - * @param string $type - * - * @return array|bool - */ - private function getProductsOrCount( - ProductSearchContext $context, - ProductSearchQuery $query, - $type = 'products' - ) { - return $this->supplier->getProducts( - $this->supplier->id, - $context->getIdLang(), - $query->getPage(), - $query->getResultsPerPage(), - $query->getSortOrder()->toLegacyOrderBy(), - $query->getSortOrder()->toLegacyOrderWay(), - $type !== 'products' - ); - } - - /** - * {@inheritdoc} - */ - public function runQuery( - ProductSearchContext $context, - ProductSearchQuery $query - ) { - $products = $this->getProductsOrCount($context, $query, 'products'); - $count = $this->getProductsOrCount($context, $query, 'count'); - - $result = new ProductSearchResult(); - - if (!empty($products)) { - $result - ->setProducts($products) - ->setTotalProductsCount($count); - - $result->setAvailableSortOrders( - $this->sortOrderFactory->getDefaultSortOrders() - ); - } - - return $result; - } -} diff --git a/src/Adapter/Support/ContactDeleter.php b/src/Adapter/Support/ContactDeleter.php deleted file mode 100644 index 88637da0..00000000 --- a/src/Adapter/Support/ContactDeleter.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Support; - -use Contact; -use PrestaShopCollection; - -/** - * Class ContactDeleter deletes contact records, using legacy code. - */ -final class ContactDeleter -{ - /** - * Delete contacts by given IDs. - * - * @param array $contactIds - * - * @return array of errors - */ - public function delete(array $contactIds) - { - $errors = []; - - if (empty($contactIds)) { - $errors[] = [ - 'key' => 'You must select at least one element to delete.', - 'parameters' => [], - 'domain' => 'Admin.Notifications.Error', - ]; - - return $errors; - } - - $contactCollection = new PrestaShopCollection(Contact::class); - $contactCollection->where('id_contact', 'in', $contactIds); - - foreach ($contactCollection as $contact) { - if (!$contact->delete()) { - $errors[] = [ - 'key' => 'Can\'t delete #%id%', - 'parameters' => [ - '%id%' => $contact->id, - ], - 'domain' => 'Admin.Notifications.Error', - ]; - - continue; - } - } - - return $errors; - } -} diff --git a/src/Adapter/Support/ContactRepository.php b/src/Adapter/Support/ContactRepository.php deleted file mode 100644 index 6204e347..00000000 --- a/src/Adapter/Support/ContactRepository.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Support; - -use PrestaShop\PrestaShop\Adapter\Entity\Contact; -use PrestaShop\PrestaShop\Core\Support\ContactRepositoryInterface; - -/** - * Class ContactRepository is responsible for retrieving contact data from database. - * - * @internal - */ -final class ContactRepository implements ContactRepositoryInterface -{ - /** - * {@inheritdoc} - */ - public function findAllByLangId($langId) - { - return Contact::getContacts($langId); - } -} diff --git a/src/Adapter/SymfonyContainer.php b/src/Adapter/SymfonyContainer.php deleted file mode 100644 index d816be1e..00000000 --- a/src/Adapter/SymfonyContainer.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use Symfony\Component\HttpKernel\KernelInterface; - -/** - * Class SymfonyContainer. - * - * This is a TEMPORARY class for quick access to the Symfony Container - */ -final class SymfonyContainer -{ - /** @var self */ - private static $instance = null; - - /** - * Get a singleton instance of SymfonyContainer. - * - * @return \Symfony\Component\DependencyInjection\ContainerInterface; - */ - public static function getInstance() - { - if (!isset(self::$instance)) { - global $kernel; - - if (null !== $kernel && $kernel instanceof KernelInterface) { - self::$instance = $kernel->getContainer(); - } - } - - return self::$instance; - } - - public static function resetStaticCache() - { - self::$instance = null; - } -} diff --git a/src/Adapter/System/SystemInformation.php b/src/Adapter/System/SystemInformation.php deleted file mode 100644 index a287a5de..00000000 --- a/src/Adapter/System/SystemInformation.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\System; - -use PrestaShop\PrestaShop\Adapter\Hosting\HostingInformation; -use PrestaShop\PrestaShop\Adapter\Mail\MailingInformation; -use PrestaShop\PrestaShop\Adapter\Shop\ShopInformation; - -/** - * Provides a summary of system information. - */ -class SystemInformation -{ - /** - * @var HostingInformation - */ - private $hostingInformation; - - /** - * @var MailingInformation - */ - private $mailingInformation; - - /** - * @var ShopInformation - */ - private $shopInformation; - - public function __construct( - HostingInformation $hostingInformation, - MailingInformation $mailingInformation, - ShopInformation $shopInformation - ) { - $this->hostingInformation = $hostingInformation; - $this->mailingInformation = $mailingInformation; - $this->shopInformation = $shopInformation; - } - - /** - * @return array - */ - public function getSummary() - { - return [ - 'notHostMode' => !$this->hostingInformation->isHostMode(), - 'server' => $this->hostingInformation->getServerInformation(), - 'instaWebInstalled' => $this->hostingInformation->isApacheInstawebModule(), - 'uname' => $this->hostingInformation->getUname(), - 'database' => $this->hostingInformation->getDatabaseInformation(), - 'shop' => $this->shopInformation->getShopInformation(), - 'isNativePHPmail' => $this->mailingInformation->isNativeMailUsed(), - 'smtp' => $this->mailingInformation->getSmtpInformation(), - ]; - } -} diff --git a/src/Adapter/Tab/TabDataProvider.php b/src/Adapter/Tab/TabDataProvider.php deleted file mode 100644 index bf312982..00000000 --- a/src/Adapter/Tab/TabDataProvider.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Tab; - -use Profile; -use Tab; - -/** - * Class TabDataProvider provides Tabs data using legacy logic. - */ -class TabDataProvider -{ - /** - * @var int - */ - private $superAdminProfileId; - - /** - * @var int - */ - private $contextEmployeeProfileId; - - /** - * @param int $contextEmployeeProfileId - * @param int $superAdminProfileId - */ - public function __construct($contextEmployeeProfileId, $superAdminProfileId) - { - $this->superAdminProfileId = $superAdminProfileId; - $this->contextEmployeeProfileId = $contextEmployeeProfileId; - } - - /** - * Gets viewable tabs for current context employee. - * - * @param int $languageId - * - * @return array - */ - public function getViewableTabsForContextEmployee($languageId) - { - return $this->getViewableTabs($this->contextEmployeeProfileId, $languageId); - } - - /** - * Gets tabs that given employee profile can view. - * - * @param int $profileId - * @param int $languageId - * - * @return array - */ - public function getViewableTabs($profileId, $languageId) - { - $viewableTabs = []; - - foreach (Tab::getTabs($languageId, 0) as $tab) { - if ($this->canAccessTab($profileId, $tab['id_tab'])) { - $viewableTabs[$tab['id_tab']] = [ - 'id_tab' => $tab['id_tab'], - 'name' => $tab['name'], - 'children' => [], - ]; - - foreach (Tab::getTabs($languageId, $tab['id_tab']) as $children) { - if ($this->canAccessTab($profileId, $children['id_tab'])) { - foreach (Tab::getTabs($languageId, $children['id_tab']) as $subchild) { - if ($this->canAccessTab($profileId, $subchild['id_tab'])) { - $viewableTabs[$tab['id_tab']]['children'][] = [ - 'id_tab' => $subchild['id_tab'], - 'name' => $subchild['name'], - ]; - } - } - } - } - } - } - - return $viewableTabs; - } - - /** - * Check if given profile can access a tab. - * - * @param int $profileId - * @param int $tabId - * @param string $accessLevel view, add, edit or delete - * - * @return bool - */ - private function canAccessTab($profileId, $tabId, $accessLevel = 'view') - { - if (!in_array($accessLevel, ['view', 'add', 'edit', 'delete'])) { - return false; - } - - if ($profileId == $this->superAdminProfileId) { - return true; - } - - $tabAccess = Profile::getProfileAccesses($profileId); - - if (isset($tabAccess[$tabId][$accessLevel])) { - return $tabAccess[$tabId][$accessLevel] === '1'; - } - - return false; - } -} diff --git a/src/Adapter/Tax/AbstractTaxHandler.php b/src/Adapter/Tax/AbstractTaxHandler.php deleted file mode 100644 index db4c17e4..00000000 --- a/src/Adapter/Tax/AbstractTaxHandler.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Tax; - -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxException; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Tax\ValueObject\TaxId; -use PrestaShopException; -use Tax; - -/** - * Provides reusable methods for tax command/query handlers. - */ -abstract class AbstractTaxHandler -{ - /** - * Gets legacy Tax - * - * @param TaxId $taxId - * - * @return Tax - */ - protected function getTax(TaxId $taxId) - { - try { - $tax = new Tax($taxId->getValue()); - } catch (PrestaShopException $e) { - throw new TaxException('Failed to create new tax', 0, $e); - } - - if ($tax->id !== $taxId->getValue()) { - throw new TaxNotFoundException(sprintf('Tax with id "%s" was not found.', $taxId->getValue())); - } - - return $tax; - } -} diff --git a/src/Adapter/Tax/CommandHandler/AddTaxHandler.php b/src/Adapter/Tax/CommandHandler/AddTaxHandler.php deleted file mode 100644 index 45177706..00000000 --- a/src/Adapter/Tax/CommandHandler/AddTaxHandler.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Tax\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Tax\AbstractTaxHandler; -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\AddTaxCommand; -use PrestaShop\PrestaShop\Core\Domain\Tax\CommandHandler\AddTaxHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxException; -use PrestaShop\PrestaShop\Core\Domain\Tax\ValueObject\TaxId; -use PrestaShopException; -use Tax; - -/** - * Handles command which is responsible for tax editing - */ -final class AddTaxHandler extends AbstractTaxHandler implements AddTaxHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws TaxException - */ - public function handle(AddTaxCommand $command) - { - $tax = new Tax(); - - $tax->name = $command->getLocalizedNames(); - $tax->rate = $command->getRate(); - $tax->active = $command->isEnabled(); - - try { - if (false === $tax->validateFields(false) || false === $tax->validateFieldsLang(false)) { - throw new TaxException('Tax contains invalid field values'); - } - - if (!$tax->save()) { - throw new TaxException(sprintf('Cannot create tax with id "%s"', $tax->id)); - } - } catch (PrestaShopException $e) { - throw new TaxException(sprintf('Cannot create tax with id "%s"', $tax->id)); - } - - return new TaxId((int) $tax->id); - } -} diff --git a/src/Adapter/Tax/CommandHandler/BulkDeleteTaxHandler.php b/src/Adapter/Tax/CommandHandler/BulkDeleteTaxHandler.php deleted file mode 100644 index d41f4679..00000000 --- a/src/Adapter/Tax/CommandHandler/BulkDeleteTaxHandler.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Tax\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Tax\AbstractTaxHandler; -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\BulkDeleteTaxCommand; -use PrestaShop\PrestaShop\Core\Domain\Tax\CommandHandler\BulkDeleteTaxHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\DeleteTaxException; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxException; -use PrestaShopException; - -/** - * Handles command which deletes Taxes on bulk action using legacy object model - */ -final class BulkDeleteTaxHandler extends AbstractTaxHandler implements BulkDeleteTaxHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(BulkDeleteTaxCommand $command) - { - foreach ($command->getTaxIds() as $taxId) { - $taxIdValue = $taxId->getValue(); - $tax = $this->getTax($taxId); - - try { - if (!$tax->delete()) { - throw new DeleteTaxException(sprintf('Cannot delete Tax object with id "%s"', $taxIdValue), DeleteTaxException::FAILED_BULK_DELETE); - } - } catch (PrestaShopException $e) { - throw new TaxException(sprintf('An error occurred when deleting Tax object with id "%s"', $taxIdValue)); - } - } - } -} diff --git a/src/Adapter/Tax/CommandHandler/BulkToggleTaxStatusHandler.php b/src/Adapter/Tax/CommandHandler/BulkToggleTaxStatusHandler.php deleted file mode 100644 index c4ece470..00000000 --- a/src/Adapter/Tax/CommandHandler/BulkToggleTaxStatusHandler.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Tax\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Tax\AbstractTaxHandler; -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\BulkToggleTaxStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Tax\CommandHandler\BulkToggleTaxStatusHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxException; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\UpdateTaxException; -use PrestaShopException; - -/** - * Handles command which toggles taxes status on bulk action using legacy object model - */ -final class BulkToggleTaxStatusHandler extends AbstractTaxHandler implements BulkToggleTaxStatusHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(BulkToggleTaxStatusCommand $command) - { - foreach ($command->getTaxIds() as $taxId) { - $tax = $this->getTax($taxId); - $tax->active = $command->getExpectedStatus(); - - try { - if (!$tax->save()) { - throw new UpdateTaxException(sprintf('Unable to toggle Tax with id "%s"', $taxId->getValue()), UpdateTaxException::FAILED_BULK_UPDATE_STATUS); - } - } catch (PrestaShopException $e) { - throw new TaxException(sprintf('An error occurred when updating Tax status with id "%s"', $taxId->getValue())); - } - } - } -} diff --git a/src/Adapter/Tax/CommandHandler/DeleteTaxHandler.php b/src/Adapter/Tax/CommandHandler/DeleteTaxHandler.php deleted file mode 100644 index e67e358a..00000000 --- a/src/Adapter/Tax/CommandHandler/DeleteTaxHandler.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Tax\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Tax\AbstractTaxHandler; -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\DeleteTaxCommand; -use PrestaShop\PrestaShop\Core\Domain\Tax\CommandHandler\DeleteTaxHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\DeleteTaxException; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxException; -use PrestaShopException; - -/** - * Handles command which deletes Tax using legacy object model - */ -final class DeleteTaxHandler extends AbstractTaxHandler implements DeleteTaxHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(DeleteTaxCommand $command) - { - $tax = $this->getTax($command->getTaxId()); - $taxIdValue = $command->getTaxId()->getValue(); - - try { - if (!$tax->delete()) { - throw new DeleteTaxException(sprintf('Cannot delete Tax object with id "%s"', $taxIdValue), DeleteTaxException::FAILED_DELETE); - } - } catch (PrestaShopException $e) { - throw new TaxException(sprintf('An error occurred when deleting Tax object with id "%s"', $taxIdValue)); - } - } -} diff --git a/src/Adapter/Tax/CommandHandler/EditTaxHandler.php b/src/Adapter/Tax/CommandHandler/EditTaxHandler.php deleted file mode 100644 index a55f3dba..00000000 --- a/src/Adapter/Tax/CommandHandler/EditTaxHandler.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Tax\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Tax\AbstractTaxHandler; -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\EditTaxCommand; -use PrestaShop\PrestaShop\Core\Domain\Tax\CommandHandler\EditTaxHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxException; -use PrestaShopException; -use Tax; - -/** - * Handles command which is responsible for tax editing - */ -final class EditTaxHandler extends AbstractTaxHandler implements EditTaxHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws TaxException - */ - public function handle(EditTaxCommand $command) - { - $tax = $this->getTax($command->getTaxId()); - - if (null !== $command->getLocalizedNames()) { - $tax->name = $command->getLocalizedNames(); - } - if (null !== $command->getRate()) { - $tax->rate = $command->getRate(); - } - if (null !== $command->isEnabled()) { - $tax->active = $command->isEnabled(); - } - - try { - if (false === $tax->validateFields(false) || false === $tax->validateFieldsLang(false)) { - throw new TaxException('Tax contains invalid field values'); - } - - if (!$tax->update()) { - throw new TaxException(sprintf('Cannot update tax with id "%s"', $tax->id)); - } - } catch (PrestaShopException $e) { - throw new TaxException(sprintf('Cannot update tax with id "%s"', $tax->id)); - } - } -} diff --git a/src/Adapter/Tax/CommandHandler/ToggleTaxStatusHandler.php b/src/Adapter/Tax/CommandHandler/ToggleTaxStatusHandler.php deleted file mode 100644 index 22f94124..00000000 --- a/src/Adapter/Tax/CommandHandler/ToggleTaxStatusHandler.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Tax\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Tax\AbstractTaxHandler; -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\ToggleTaxStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Tax\CommandHandler\ToggleTaxStatusHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxException; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\UpdateTaxException; -use PrestaShopException; - -/** - * Handles command which toggles Tax status using legacy object model - */ -final class ToggleTaxStatusHandler extends AbstractTaxHandler implements ToggleTaxStatusHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(ToggleTaxStatusCommand $command) - { - $tax = $this->getTax($command->getTaxId()); - $taxIdValue = $command->getTaxId()->getValue(); - $tax->active = $command->getExpectedStatus(); - - try { - if (!$tax->save()) { - throw new UpdateTaxException(sprintf('Unable to toggle Tax with id "%s"', $taxIdValue), UpdateTaxException::FAILED_UPDATE_STATUS); - } - } catch (PrestaShopException $e) { - throw new TaxException(sprintf('An error occurred when enabling ETax with id "%s"', $taxIdValue)); - } - } -} diff --git a/src/Adapter/Tax/Ecotax/ProductEcotaxResetter.php b/src/Adapter/Tax/Ecotax/ProductEcotaxResetter.php deleted file mode 100644 index 2a2e8526..00000000 --- a/src/Adapter/Tax/Ecotax/ProductEcotaxResetter.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Tax\Ecotax; - -use PrestaShop\PrestaShop\Core\Tax\Ecotax\ProductEcotaxResetterInterface; -use Product; - -/** - * Resets ecotax for products using legacy object model - */ -final class ProductEcotaxResetter implements ProductEcotaxResetterInterface -{ - /** - * {@inheritdoc} - */ - public function reset() - { - Product::resetEcoTax(); - } -} diff --git a/src/Adapter/Tax/QueryHandler/GetTaxForEditingHandler.php b/src/Adapter/Tax/QueryHandler/GetTaxForEditingHandler.php deleted file mode 100644 index 0e19942f..00000000 --- a/src/Adapter/Tax/QueryHandler/GetTaxForEditingHandler.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Tax\QueryHandler; - -use PrestaShop\PrestaShop\Adapter\Tax\AbstractTaxHandler; -use PrestaShop\PrestaShop\Core\Domain\Tax\Query\GetTaxForEditing; -use PrestaShop\PrestaShop\Core\Domain\Tax\QueryHandler\GetTaxForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Tax\QueryResult\EditableTax; - -/** - * Handles query which gets tax for editing - */ -final class GetTaxForEditingHandler extends AbstractTaxHandler implements GetTaxForEditingHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GetTaxForEditing $query) - { - $tax = $this->getTax($query->getTaxId()); - - return new EditableTax( - $query->getTaxId(), - $tax->name, - (float) $tax->rate, - (bool) $tax->active - ); - } -} diff --git a/src/Adapter/Tax/TaxRuleDataProvider.php b/src/Adapter/Tax/TaxRuleDataProvider.php deleted file mode 100644 index df9d5959..00000000 --- a/src/Adapter/Tax/TaxRuleDataProvider.php +++ /dev/null @@ -1,130 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Tax; - -use Address; -use Context; -use Product; -use Tax; -use TaxManagerFactory; -use TaxRulesGroup; - -/** - * This class will provide data from DB / ORM about tax rules. - */ -class TaxRuleDataProvider -{ - /** - * Get all Tax Rules Groups. - * - * @param bool $only_active - * - * @return array TaxRulesGroup - */ - public function getTaxRulesGroups($only_active = true) - { - return TaxRulesGroup::getTaxRulesGroups($only_active); - } - - /** - * Get most used Tax. - * - * @return int - */ - public function getIdTaxRulesGroupMostUsed() - { - return Product::getIdTaxRulesGroupMostUsed(); - } - - /** - * Get all Tax Rules Groups with rates. - * - * @return array TaxRulesGroup - */ - public function getTaxRulesGroupWithRates() - { - $address = new Address(); - $address->id_country = (int) Context::getContext()->country->id; - $tax_rules_groups = $this->getTaxRulesGroups(); - $tax_rates = [ - 0 => [ - 'id_tax_rules_group' => 0, - 'rates' => [0], - 'computation_method' => 0, - ], - ]; - - foreach ($tax_rules_groups as $tax_rules_group) { - $id_tax_rules_group = (int) $tax_rules_group['id_tax_rules_group']; - $tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator(); - $tax_rates[$id_tax_rules_group] = [ - 'id_tax_rules_group' => $id_tax_rules_group, - 'rates' => [], - 'computation_method' => (int) $tax_calculator->computation_method, - ]; - - if (isset($tax_calculator->taxes) && count($tax_calculator->taxes)) { - foreach ($tax_calculator->taxes as $tax) { - $tax_rates[$id_tax_rules_group]['rates'][] = (float) $tax->rate; - } - } else { - $tax_rates[$id_tax_rules_group]['rates'][] = 0; - } - } - - return $tax_rates; - } - - /** - * Get product eco taxe rate. - * - * @return float tax - */ - public function getProductEcotaxRate() - { - return Tax::getProductEcotaxRate(); - } - - /** - * Gets a list of tax rules groups for choice type. - * - * @param bool $onlyActive if true, returns only active tax rules groups - * - * @return array - */ - public function getTaxRulesGroupChoices($onlyActive = true) - { - $taxRulesGroups = $this->getTaxRulesGroups($onlyActive); - $choices = []; - - foreach ($taxRulesGroups as $taxRulesGroup) { - $choices[$taxRulesGroup['name']] = $taxRulesGroup['id_tax_rules_group']; - } - - return $choices; - } -} diff --git a/src/Adapter/TaxRulesGroup/AbstractTaxRulesGroupHandler.php b/src/Adapter/TaxRulesGroup/AbstractTaxRulesGroupHandler.php deleted file mode 100644 index 0c39d236..00000000 --- a/src/Adapter/TaxRulesGroup/AbstractTaxRulesGroupHandler.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\TaxRulesGroup; - -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\CannotDeleteTaxRulesGroupException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\ValueObject\TaxRulesGroupId; -use PrestaShopException; -use TaxRulesGroup; - -/** - * Provides common methods for tax rules group handlers - */ -abstract class AbstractTaxRulesGroupHandler -{ - /** - * Gets legacy TaxRuleGroup object - * - * @param TaxRulesGroupId $taxRulesGroupId - * - * @return TaxRulesGroup - * - * @throws TaxRulesGroupNotFoundException - */ - protected function getTaxRulesGroup(TaxRulesGroupId $taxRulesGroupId): TaxRulesGroup - { - $taxRulesGroupIdValue = $taxRulesGroupId->getValue(); - - try { - $taxRulesGroup = new TaxRulesGroup($taxRulesGroupIdValue); - } catch (PrestaShopException $e) { - throw new TaxRulesGroupNotFoundException(sprintf('Tax rules group with id "%s" was not found.', $taxRulesGroupIdValue)); - } - - if ($taxRulesGroup->id !== $taxRulesGroupIdValue) { - throw new TaxRulesGroupNotFoundException(sprintf('Tax rules group with id "%s" was not found.', $taxRulesGroupIdValue)); - } - - return $taxRulesGroup; - } - - /** - * Deletes legacy TaxRulesGroup - * - * @param TaxRulesGroup $taxRulesGroup - * - * @return bool - * - * @throws CannotDeleteTaxRulesGroupException - */ - protected function deleteTaxRulesGroup(TaxRulesGroup $taxRulesGroup): bool - { - try { - return $taxRulesGroup->delete(); - } catch (PrestaShopException $e) { - throw new CannotDeleteTaxRulesGroupException(sprintf('An error occurred when deleting tax rules group object with id "%s".', $taxRulesGroup->id)); - } - } - - /** - * Set legacy tax rules group status - * - * @param TaxRulesGroup $taxRulesGroup - * @param bool $newStatus - * - * @return bool - * - * @throws TaxRulesGroupException - */ - protected function setTaxRulesGroupStatus(TaxRulesGroup $taxRulesGroup, bool $newStatus) - { - $taxRulesGroup->active = $newStatus; - - try { - return $taxRulesGroup->save(); - } catch (PrestaShopException $e) { - throw new TaxRulesGroupException(sprintf('An error occurred when updating tax rules group status with id "%s"', $taxRulesGroup->id)); - } - } -} diff --git a/src/Adapter/TaxRulesGroup/CommandHandler/BulkDeleteTaxRulesGroupHandler.php b/src/Adapter/TaxRulesGroup/CommandHandler/BulkDeleteTaxRulesGroupHandler.php deleted file mode 100644 index 3a13d923..00000000 --- a/src/Adapter/TaxRulesGroup/CommandHandler/BulkDeleteTaxRulesGroupHandler.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\TaxRulesGroup\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\TaxRulesGroup\AbstractTaxRulesGroupHandler; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command\BulkDeleteTaxRulesGroupCommand; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\CommandHandler\BulkDeleteTaxRulesGroupHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\CannotBulkDeleteTaxRulesGroupException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupException; - -/** - * Handles multiple tax rules group deletion - */ -final class BulkDeleteTaxRulesGroupHandler extends AbstractTaxRulesGroupHandler implements BulkDeleteTaxRulesGroupHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CannotBulkDeleteTaxRulesGroupException - */ - public function handle(BulkDeleteTaxRulesGroupCommand $command): void - { - $errors = []; - - foreach ($command->getTaxRulesGroupIds() as $taxRulesGroupId) { - try { - $taxRulesGroup = $this->getTaxRulesGroup($taxRulesGroupId); - - if (!$this->deleteTaxRulesGroup($taxRulesGroup)) { - $errors[] = $taxRulesGroup->id; - } - } catch (TaxRulesGroupException $e) { - $errors[] = $taxRulesGroupId->getValue(); - } - } - - if (!empty($errors)) { - throw new CannotBulkDeleteTaxRulesGroupException($errors, 'Failed to delete all tax rules groups without errors'); - } - } -} diff --git a/src/Adapter/TaxRulesGroup/CommandHandler/BulkSetTaxRulesGroupStatusHandler.php b/src/Adapter/TaxRulesGroup/CommandHandler/BulkSetTaxRulesGroupStatusHandler.php deleted file mode 100644 index 9a27e228..00000000 --- a/src/Adapter/TaxRulesGroup/CommandHandler/BulkSetTaxRulesGroupStatusHandler.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\TaxRulesGroup\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\TaxRulesGroup\AbstractTaxRulesGroupHandler; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command\BulkSetTaxRulesGroupStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\CommandHandler\BulkToggleTaxRulesGroupStatusHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\CannotBulkUpdateTaxRulesGroupException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupException; - -/** - * Handles toggling of multiple tax rules groups statuses - */ -final class BulkSetTaxRulesGroupStatusHandler extends AbstractTaxRulesGroupHandler implements BulkToggleTaxRulesGroupStatusHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CannotBulkUpdateTaxRulesGroupException - */ - public function handle(BulkSetTaxRulesGroupStatusCommand $command): void - { - $errors = []; - - foreach ($command->getTaxRulesGroupIds() as $taxRuleGroupId) { - try { - $taxRuleGroup = $this->getTaxRulesGroup($taxRuleGroupId); - - if (!$this->setTaxRulesGroupStatus($taxRuleGroup, $command->getExpectedStatus())) { - $errors[] = $taxRuleGroup->id; - } - } catch (TaxRulesGroupException $e) { - $errors[] = $taxRuleGroupId->getValue(); - } - } - - if (!empty($errors)) { - throw new CannotBulkUpdateTaxRulesGroupException($errors, 'Failed to set all tax rules groups statuses without errors'); - } - } -} diff --git a/src/Adapter/TaxRulesGroup/CommandHandler/DeleteTaxRulesGroupHandler.php b/src/Adapter/TaxRulesGroup/CommandHandler/DeleteTaxRulesGroupHandler.php deleted file mode 100644 index af80ae7f..00000000 --- a/src/Adapter/TaxRulesGroup/CommandHandler/DeleteTaxRulesGroupHandler.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\TaxRulesGroup\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\TaxRulesGroup\AbstractTaxRulesGroupHandler; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command\DeleteTaxRulesGroupCommand; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\CommandHandler\DeleteTaxRulesGroupHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\CannotDeleteTaxRulesGroupException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupNotFoundException; - -/** - * Handles deletion of single tax rules group - */ -final class DeleteTaxRulesGroupHandler extends AbstractTaxRulesGroupHandler implements DeleteTaxRulesGroupHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CannotDeleteTaxRulesGroupException - * @throws TaxRulesGroupNotFoundException - */ - public function handle(DeleteTaxRulesGroupCommand $command): void - { - $taxRulesGroup = $this->getTaxRulesGroup($command->getTaxRulesGroupId()); - - if (!$this->deleteTaxRulesGroup($taxRulesGroup)) { - throw new CannotDeleteTaxRulesGroupException(sprintf('Cannot delete tax rules group object with id "%s".', $taxRulesGroup->id)); - } - } -} diff --git a/src/Adapter/TaxRulesGroup/CommandHandler/SetTaxRulesGroupStatusHandler.php b/src/Adapter/TaxRulesGroup/CommandHandler/SetTaxRulesGroupStatusHandler.php deleted file mode 100644 index 2fb82ace..00000000 --- a/src/Adapter/TaxRulesGroup/CommandHandler/SetTaxRulesGroupStatusHandler.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\TaxRulesGroup\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\TaxRulesGroup\AbstractTaxRulesGroupHandler; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command\SetTaxRulesGroupStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\CommandHandler\ToggleTaxRulesGroupStatusHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\CannotUpdateTaxRulesGroupException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupNotFoundException; - -/** - * Handles tax rules group status toggling - */ -final class SetTaxRulesGroupStatusHandler extends AbstractTaxRulesGroupHandler implements ToggleTaxRulesGroupStatusHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws CannotUpdateTaxRulesGroupException - * @throws TaxRulesGroupException - * @throws TaxRulesGroupNotFoundException - */ - public function handle(SetTaxRulesGroupStatusCommand $command): void - { - $taxRulesGroup = $this->getTaxRulesGroup($command->getTaxRulesGroupId()); - - if (!$this->setTaxRulesGroupStatus($taxRulesGroup, $command->getExpectedStatus())) { - throw new CannotUpdateTaxRulesGroupException(sprintf('Unable to toggle tax rules group status with id "%s"', $taxRulesGroup->id), CannotUpdateTaxRulesGroupException::FAILED_TOGGLE_STATUS); - } - } -} diff --git a/src/Adapter/TaxRulesGroup/QueryHandler/GetTaxRulesGroupForEditingHandler.php b/src/Adapter/TaxRulesGroup/QueryHandler/GetTaxRulesGroupForEditingHandler.php deleted file mode 100644 index 2795e5c4..00000000 --- a/src/Adapter/TaxRulesGroup/QueryHandler/GetTaxRulesGroupForEditingHandler.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\TaxRulesGroup\QueryHandler; - -use PrestaShop\PrestaShop\Adapter\TaxRulesGroup\AbstractTaxRulesGroupHandler; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Query\GetTaxRulesGroupForEditing; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\QueryHandler\GetTaxRulesGroupForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\QueryResult\EditableTaxRulesGroup; - -/** - * Handles query which gets tax rules group for editing - */ -final class GetTaxRulesGroupForEditingHandler extends AbstractTaxRulesGroupHandler implements GetTaxRulesGroupForEditingHandlerInterface -{ - /** - * {@inheritdoc} - * - * @throws TaxRulesGroupNotFoundException - */ - public function handle(GetTaxRulesGroupForEditing $query): EditableTaxRulesGroup - { - $taxRulesGroupId = $query->getTaxRulesGroupId(); - $taxRulesGroup = $this->getTaxRulesGroup($taxRulesGroupId); - - return new EditableTaxRulesGroup($taxRulesGroupId, (bool) $taxRulesGroup->active); - } -} diff --git a/src/Adapter/Theme/ThemeMultiStoreSettingsFormDataProvider.php b/src/Adapter/Theme/ThemeMultiStoreSettingsFormDataProvider.php deleted file mode 100644 index 4af534e5..00000000 --- a/src/Adapter/Theme/ThemeMultiStoreSettingsFormDataProvider.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Theme; - -use Configuration; -use PrestaShop\PrestaShop\Core\Form\MultiStoreSettingsFormDataProviderInterface; - -/** - * This class is used to retrieve data which is used in settings form to render multi store fields - its used in - * Theme & logo page. - * - * @internal - */ -final class ThemeMultiStoreSettingsFormDataProvider implements MultiStoreSettingsFormDataProviderInterface -{ - /** - * @var bool - */ - private $isShopFeatureUsed; - - /** - * @var bool - */ - private $isSingleShopContext; - - /** - * @param bool $isShopFeatureUsed - * @param bool $isSingleShopContext - */ - public function __construct( - $isShopFeatureUsed, - $isSingleShopContext - ) { - $this->isShopFeatureUsed = $isShopFeatureUsed; - $this->isSingleShopContext = $isSingleShopContext; - } - - /** - * {@inheritdoc} - */ - public function getData() - { - $isValidShopRestriction = $this->isShopFeatureUsed && $this->isSingleShopContext; - - $isHeaderLogoRestricted = $this->doesConfigurationExistInSingleShopContext('PS_LOGO'); - $isMailRestricted = $this->doesConfigurationExistInSingleShopContext('PS_LOGO_MAIL'); - $isInvoiceLogoRestricted = $this->doesConfigurationExistInSingleShopContext('PS_LOGO_INVOICE'); - $isFaviconRestricted = $this->doesConfigurationExistInSingleShopContext('PS_FAVICON'); - - return [ - 'header_logo_is_restricted_to_shop' => $isValidShopRestriction && $isHeaderLogoRestricted, - 'mail_logo_is_restricted_to_shop' => $isValidShopRestriction && $isMailRestricted, - 'invoice_logo_is_restricted_to_shop' => $isValidShopRestriction && $isInvoiceLogoRestricted, - 'favicon_is_restricted_to_shop' => $isValidShopRestriction && $isFaviconRestricted, - ]; - } - - /** - * Checks if the configuration exists for specific shop context. - * - * @param $configurationKey - * - * @return bool - */ - private function doesConfigurationExistInSingleShopContext($configurationKey) - { - return Configuration::isOverridenByCurrentContext($configurationKey); - } -} diff --git a/src/Adapter/Tools.php b/src/Adapter/Tools.php deleted file mode 100644 index 544e1ce3..00000000 --- a/src/Adapter/Tools.php +++ /dev/null @@ -1,281 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Adapter\File\HtaccessFileGenerator; -use Tools as LegacyTools; - -/** - * This adapter will complete the new architecture Tools. - * - * Please put only wrappers and equivalents from Legacy \Tools class. - * (only for this purpose, this is not here to put new utils functions). - */ -class Tools -{ - /** - * Return the friendly url from the provided string. - * - * @deprecated use linkRewrite - * - * @param string $str - * @param bool $utf8Decode (deprecated) - * - * @return string - */ - public function link_rewrite($str, $utf8Decode = null) - { - return $this->linkRewrite($str, $utf8Decode); - } - - /** - * Return the friendly url from the provided string. - * - * @param string $str - * @param bool $utf8Decode (deprecated) - * - * @return string - */ - public function linkRewrite($str, $utf8Decode = null) - { - if ($utf8Decode !== null) { - LegacyTools::displayParameterAsDeprecated('utf8_decode'); - } - - return LegacyTools::str2url($str); - } - - /** - * Polyfill for bcadd if BC Math extension is not installed. - * - * @deprecated since 1.7.2.2 - Use PrestaShop\Decimal\Number instead - */ - public function bcadd($left_operand, $right_operand, $scale = null) - { - $result = (new Number((string) $left_operand)) - ->plus(new Number((string) $right_operand)); - - if (null === $scale) { - return (string) $result; - } - - return (string) $result->toPrecision($scale); - } - - /** - * @param string $html - * @param string|null $uri_unescape - * @param bool $allow_style - * - * @return string - */ - public function purifyHTML($html, $uri_unescape = null, $allow_style = false) - { - return LegacyTools::purifyHTML($html, $uri_unescape, $allow_style); - } - - /** - * @see LegacyTools::refreshCACertFile() - */ - public function refreshCaCertFile() - { - LegacyTools::refreshCACertFile(); - } - - /** - * @see LegacyTools::generateRobotsFile() - * - * @return bool - */ - public function generateHtaccess() - { - return LegacyTools::generateHtaccess(); - } - - /** - * @see HtaccessFileGenerator::generateFile() - * - * @param bool $disableMultiView enable/disable Multiviews option - * - * @return bool - */ - private function generateHtaccessOnMultiViews($disableMultiView = false) - { - return LegacyTools::generateHtaccess( - null, - null, - null, - '', - $disableMultiView - ); - } - - /** - * @see HtaccessFileGenerator::generateFile() - * - * @return bool - */ - public function generateHtaccessWithMultiViews() - { - return LegacyTools::generateHtaccess( - null, - null, - null, - '', - true - ); - } - - /** - * @see HtaccessFileGenerator::generateFile() - * - * @return bool - */ - public function generateHtaccessWithoutMultiViews() - { - return LegacyTools::generateHtaccess( - null, - null, - null, - '', - false - ); - } - - /** - * returns the rounded value of $value to specified precision, according to your configuration;. - * - * @note : PHP 5.3.0 introduce a 3rd parameter mode in round function - * - * @param float $value - * @param int $precision - * - * @return float - */ - public function round($value, $precision = 0, $round_mode = null) - { - return LegacyTools::ps_round($value, $precision, $round_mode); - } - - /** - * Return domain name according to configuration and depending on ssl activation. - * - * @param bool $http if true, return domain name with protocol - * @param bool $entities if true, convert special chars to HTML entities - * - * @return string domain - */ - public function getShopDomainSsl($http = false, $entities = false) - { - return LegacyTools::getShopDomainSsl($http, $entities); - } - - /** - * Checks if apache mod exists for mod_rewrite or the server has HTTP_MOD_REWRITE enabled. - * - * @return bool - */ - public function isModRewriteActive() - { - return LegacyTools::modRewriteActive(); - } - - /** - * Copy content. - * - * @param string $source - * @param string $destination - * @param resource|null $streamContext - * - * @return bool|int - */ - public function copy($source, $destination, $streamContext = null) - { - return LegacyTools::copy($source, $destination, $streamContext); - } - - /** - * Sanitize a string. - * - * @param string $value - * @param bool $allowHtml - * - * @return string - */ - public function sanitize($value, $allowHtml = false) - { - return LegacyTools::safeOutput($value, $allowHtml); - } - - /** - * Get a valid image URL to use from BackOffice. - * - * @param string $fileName image file name - * @param bool $escapeHtmlEntities if true - escape html entities on file name argument - * - * @return string image URL - */ - public function getAdminImageUrl($fileName, $escapeHtmlEntities = false) - { - return LegacyTools::getAdminImageUrl($fileName, $escapeHtmlEntities); - } - - /** - * Delete unicode class from regular expression patterns. - * - * @param string $pattern - * - * @return string pattern - */ - public function cleanNonUnicodeSupport($pattern) - { - return LegacyTools::cleanNonUnicodeSupport($pattern); - } - - /** - * @see LegacyTools::displayDate() - * - * @return string - * - * @throws \PrestaShopException - */ - public function displayDate($date, $id_lang = null, $full = false, $separator = null) - { - return LegacyTools::displayDate($date, $id_lang, $full, $separator); - } - - /** - * @see LegacyTools::truncateString() - * - * @return bool|string - */ - public function truncateString($text, $length = 120, $options = []) - { - return LegacyTools::truncateString($text, $length, $options); - } -} diff --git a/src/Adapter/Translations/TranslationRouteFinder.php b/src/Adapter/Translations/TranslationRouteFinder.php deleted file mode 100644 index b75f803d..00000000 --- a/src/Adapter/Translations/TranslationRouteFinder.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Translations; - -use Link; -use Module; -use PrestaShop\PrestaShop\Core\Addon\Module\ModuleRepositoryInterface; -use PrestaShopBundle\Exception\InvalidModuleException; -use PrestaShopBundle\Service\TranslationService; -use Symfony\Component\HttpFoundation\ParameterBag; -use Symfony\Component\PropertyAccess\PropertyAccess; - -/** - * Class TranslationRouteFinder finds the correct route for translations. - */ -class TranslationRouteFinder -{ - /** - * Mails translations type. - */ - const MAILS = 'mails'; - - /** - * Modules translations type. - */ - const MODULES = 'modules'; - - /** - * Email body translations type. - */ - const BODY = 'body'; - - /** - * Themes translations type. - */ - const THEMES = 'themes'; - - /** - * @var TranslationService - */ - private $translationService; - - /** - * @var Link - */ - private $link; - - /** - * @var ModuleRepositoryInterface - */ - private $moduleRepository; - - /** - * @param TranslationService $translationService - * @param Link $link - * @param ModuleRepositoryInterface $moduleRepository - */ - public function __construct( - TranslationService $translationService, - Link $link, - ModuleRepositoryInterface $moduleRepository - ) { - $this->translationService = $translationService; - $this->link = $link; - $this->moduleRepository = $moduleRepository; - } - - /** - * Finds the correct translation route out of given query. - * - * @param ParameterBag $query - * - * @return string - */ - public function findRoute(ParameterBag $query) - { - $routeProperties = $query->get('form'); - $propertyAccessor = PropertyAccess::createPropertyAccessor(); - $route = 'admin_international_translation_overview'; - - switch ($propertyAccessor->getValue($routeProperties, '[translation_type]')) { - case self::MAILS: - if (self::BODY === $propertyAccessor->getValue($routeProperties, '[email_content_type]')) { - $language = $propertyAccessor->getValue($routeProperties, '[language]'); - $route = $this->link->getAdminLink( - 'AdminTranslations', - true, - [], - [ - 'lang' => $language, - 'type' => self::MAILS, - 'selected-emails' => self::BODY, - 'selected-theme' => $propertyAccessor->getValue($routeProperties, '[theme]'), - 'locale' => $this->translationService->langToLocale($language), - ] - ); - } - - break; - - case self::MODULES: - $moduleName = $propertyAccessor->getValue($routeProperties, '[module]'); - - // If module is not using the new translation system - - // generate a legacy link for it - if (!$this->isModuleUsingNewTranslationSystem($moduleName)) { - $language = $propertyAccessor->getValue($routeProperties, '[language]'); - $route = $this->link->getAdminLink( - 'AdminTranslations', - true, - [], - [ - 'type' => self::MODULES, - 'module' => $moduleName, - 'lang' => $language, - ] - ); - } - - break; - } - - return $route; - } - - /** - * Finds parameters for translation route out of given query. - * - * @param ParameterBag $query - * - * @return array of route parameters - */ - public function findRouteParameters(ParameterBag $query) - { - $routeProperties = $query->get('form'); - $propertyAccessor = PropertyAccess::createPropertyAccessor(); - $language = $propertyAccessor->getValue($routeProperties, '[language]'); - - $parameters = [ - 'lang' => $language, - 'type' => $propertyAccessor->getValue($routeProperties, '[translation_type]'), - 'locale' => $this->translationService->langToLocale($language), - ]; - - switch ($propertyAccessor->getValue($routeProperties, '[translation_type]')) { - case self::THEMES: - $parameters['selected'] = $propertyAccessor->getValue($routeProperties, '[theme]'); - - break; - - case self::MAILS: - $emailContentType = $propertyAccessor->getValue($routeProperties, '[email_content_type]'); - - if (self::BODY === $emailContentType) { - $parameters = []; - } - - break; - - case self::MODULES: - $moduleName = $propertyAccessor->getValue($routeProperties, '[module]'); - $parameters['selected'] = $moduleName; - - if (!$this->isModuleUsingNewTranslationSystem($moduleName)) { - $parameters = []; - } - - break; - } - - return $parameters; - } - - /** - * Checks if module is using the new translation system. - * - * @param string $moduleName - * - * @return bool - */ - private function isModuleUsingNewTranslationSystem($moduleName) - { - $module = $this->moduleRepository->getInstanceByName($moduleName); - - if (!($module instanceof Module)) { - throw new InvalidModuleException($moduleName); - } - - return $module->isUsingNewTranslationSystem(); - } -} diff --git a/src/Adapter/Twig/LocaleExtension.php b/src/Adapter/Twig/LocaleExtension.php deleted file mode 100644 index 67f4d8e0..00000000 --- a/src/Adapter/Twig/LocaleExtension.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Twig; - -use DateTime; -use Twig\Extension\AbstractExtension; -use Twig_SimpleFunction; - -/** - * Provides helper functions in Twig for formatting data using context locale - */ -final class LocaleExtension extends AbstractExtension -{ - /** - * @var string - */ - private $contextDateFormatLite; - - /** - * @param string $contextDateFormatLite - */ - public function __construct($contextDateFormatLite) - { - $this->contextDateFormatLite = $contextDateFormatLite; - } - - /** - * {@inheritdoc} - */ - public function getFunctions() - { - return [ - new Twig_SimpleFunction( - 'format_date', - function ($date) { - return (new DateTime($date))->format($this->contextDateFormatLite); - } - ), - ]; - } -} diff --git a/src/Adapter/Upload/UploadQuotaConfiguration.php b/src/Adapter/Upload/UploadQuotaConfiguration.php deleted file mode 100644 index a0411c8f..00000000 --- a/src/Adapter/Upload/UploadQuotaConfiguration.php +++ /dev/null @@ -1,140 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Upload; - -use Exception; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * Manages the configuration data about upload quota options. - */ -class UploadQuotaConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'max_size_attached_files' => $this->configuration->get('PS_ATTACHMENT_MAXIMUM_SIZE'), - 'max_size_downloadable_product' => $this->configuration->get('PS_LIMIT_UPLOAD_FILE_VALUE'), - 'max_size_product_image' => $this->configuration->get('PS_LIMIT_UPLOAD_IMAGE_VALUE'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - $errors = []; - - if ($this->validateConfiguration($configuration)) { - $errors = $this->updateFileUploadConfiguration($configuration); - } - - return $errors; - } - - /** - * Update the file upload limit if possible. - * - * @return array the errors list during the update operation - * - * @throws Exception - */ - private function updateFileUploadConfiguration(array $configuration) - { - $uploadMaxSize = (int) str_replace('M', '', ini_get('upload_max_filesize')); - $sizes = [ - 'max_size_attached_files' => $uploadMaxSize, - 'max_size_downloadable_product' => (int) str_replace('M', '', ini_get('post_max_size')), - 'max_size_product_image' => $uploadMaxSize, - ]; - - $errors = []; - foreach ($configuration as $configurationKey => $configurationValue) { - if (array_key_exists($configurationKey, $this->getConfiguration())) { - if ((int) $configurationValue > $sizes[$configurationKey]) { - $errors[] = [ - 'key' => 'The limit chosen is larger than the server\'s maximum upload limit. Please increase the limits of your server.', - 'domain' => 'Admin.Advparameters.Notification', - 'parameters' => [], - ]; - } - - $this->configuration->set( - $this->getConfigurationKey($configurationKey), - max((int) $configurationValue, 1) - ); - } - } - - return $errors; - } - - /** - * Map array key to the related configuration property. - * - * @param string the array key - * - * @return string the related configuration key - */ - private function getConfigurationKey($key) - { - $properties = [ - 'max_size_attached_files' => 'PS_ATTACHMENT_MAXIMUM_SIZE', - 'max_size_downloadable_product' => 'PS_LIMIT_UPLOAD_FILE_VALUE', - 'max_size_product_image' => 'PS_LIMIT_UPLOAD_IMAGE_VALUE', - ]; - - return $properties[$key]; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['max_size_attached_files'], - $configuration['max_size_downloadable_product'], - $configuration['max_size_product_image'] - ); - } -} diff --git a/src/Adapter/Validate.php b/src/Adapter/Validate.php deleted file mode 100644 index c4c51427..00000000 --- a/src/Adapter/Validate.php +++ /dev/null @@ -1,138 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter; - -use Validate as ValidateLegacy; - -/** - * Adapter for Validate Legacy class. - */ -class Validate -{ - /** - * @param mixed $way - * - * @return bool - */ - public static function isOrderWay($way) - { - return ValidateLegacy::isOrderWay($way); - } - - /** - * @param mixed $order - * - * @return bool - */ - public static function isOrderBy($order) - { - return ValidateLegacy::isOrderBy($order); - } - - /** - * @param mixed $date - * - * @return bool - */ - public static function isDate($date) - { - return ValidateLegacy::isDate($date); - } - - /** - * Check if HTML content is clean. - * - * @param string $html - * @param bool $allowIframe - * - * @return bool - */ - public function isCleanHtml($html, $allowIframe = false) - { - return ValidateLegacy::isCleanHtml($html, $allowIframe); - } - - /** - * Check for module name validity. - * - * @param string $name Module name to validate - * - * @return bool - */ - public function isModuleName($name) - { - return ValidateLegacy::isModuleName($name); - } - - /** - * Check if object has been correctly loaded. - * - * @param object $object Object to validate - * - * @return bool Validity is ok or not - */ - public static function isLoadedObject($object) - { - return ValidateLegacy::isLoadedObject($object); - } - - /** - * Check for Language Iso Code. - * - * @param string $isoCode - * - * @return bool - */ - public function isLangIsoCode($isoCode) - { - return ValidateLegacy::isLangIsoCode($isoCode); - } - - /** - * Check for an integer validity (unsigned). - * - * @param int $value Integer to validate - * - * @return bool - */ - public function isUnsignedInt($value) - { - return ValidateLegacy::isUnsignedInt($value); - } - - /** - * Check for a rewritten url validity. - * - * @param string $value - * - * @return bool - */ - public function isLinkRewrite($value) - { - return ValidateLegacy::isLinkRewrite($value); - } -} diff --git a/src/Adapter/Warehouse/WarehouseDataProvider.php b/src/Adapter/Warehouse/WarehouseDataProvider.php deleted file mode 100644 index 8086f372..00000000 --- a/src/Adapter/Warehouse/WarehouseDataProvider.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Warehouse; - -use Warehouse; -use WarehouseProductLocation; - -/** - * This class will provide data from DB / ORM about Warehouse. - */ -class WarehouseDataProvider -{ - /** - * Get product warehouses. - * - * @param int $id_product - * - * @return array Warehouses - */ - public function getWarehouseProductLocations($id_product) - { - $collection = WarehouseProductLocation::getCollection($id_product); - - return $collection->getResults(); - } - - /** - * Get all warehouses. - * - * @param bool $ignore_shop Optional, false by default - Allows to get only the warehouses that are associated to one/some shops (@see $id_shop) - * @param int $id_shop optional, Context::shop::Id by default - Allows to define a specific shop to filter - * - * @return array Warehouses (ID, reference/name concatenated) - */ - public function getWarehouses($ignore_shop = false, $id_shop = null) - { - return Warehouse::getWarehouses($ignore_shop, $id_shop); - } - - /** - * For a given product and warehouse, gets the product warehouse data. - * - * @param int $id_product - * @param int $id_product_attribute - * @param int $id_warehouse - * - * @return array - */ - public function getWarehouseProductLocationData($id_product, $id_product_attribute, $id_warehouse) - { - $location = WarehouseProductLocation::getProductLocation($id_product, $id_product_attribute, $id_warehouse); - // for 'activated', we test if $location is ===false or ==="", that's the only difference to know it... - return ['location' => $location, 'activated' => ($location !== false), 'product_id' => $id_product]; - } -} diff --git a/src/Adapter/Webservice/CommandHandler/AbstractWebserviceKeyHandler.php b/src/Adapter/Webservice/CommandHandler/AbstractWebserviceKeyHandler.php deleted file mode 100644 index 486468ed..00000000 --- a/src/Adapter/Webservice/CommandHandler/AbstractWebserviceKeyHandler.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Webservice\CommandHandler; - -use PrestaShop\PrestaShop\Adapter\Domain\AbstractObjectModelHandler; -use Tools; -use WebserviceKey; - -/** - * Encapsulates common legacy behavior for adding/editing WebserviceKey - * - * @internal - */ -abstract class AbstractWebserviceKeyHandler extends AbstractObjectModelHandler -{ - /** - * @param WebserviceKey $webserviceKey - * @param array $permissions - */ - protected function setPermissionsForWebserviceKey(WebserviceKey $webserviceKey, array $permissions) - { - Tools::generateHtaccess(); - - $legacyPermissionsStructure = []; - - foreach ($permissions as $permission => $resources) { - foreach ($resources as $resource) { - $legacyPermissionsStructure[$resource][$permission] = 'on'; - } - } - - WebserviceKey::setPermissionForAccount($webserviceKey->id, $legacyPermissionsStructure); - } -} diff --git a/src/Adapter/Webservice/CommandHandler/AddWebserviceKeyHandler.php b/src/Adapter/Webservice/CommandHandler/AddWebserviceKeyHandler.php deleted file mode 100644 index 69dcc28b..00000000 --- a/src/Adapter/Webservice/CommandHandler/AddWebserviceKeyHandler.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Webservice\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Webservice\Command\AddWebserviceKeyCommand; -use PrestaShop\PrestaShop\Core\Domain\Webservice\CommandHandler\AddWebserviceKeyHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Webservice\Exception\DuplicateWebserviceKeyException; -use PrestaShop\PrestaShop\Core\Domain\Webservice\Exception\WebserviceConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Webservice\Exception\WebserviceException; -use PrestaShop\PrestaShop\Core\Domain\Webservice\ValueObject\Key; -use PrestaShop\PrestaShop\Core\Domain\Webservice\ValueObject\WebserviceKeyId; -use WebserviceKey; - -/** - * Handles command that adds new webservice key for PrestaShop's API - * - * @internal - */ -final class AddWebserviceKeyHandler extends AbstractWebserviceKeyHandler implements AddWebserviceKeyHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(AddWebserviceKeyCommand $command) - { - $this->assertWebserviceKeyIsNotDuplicate($command->getKey()); - - $webserviceKey = $this->createLegacyWebserviceKeyFromCommand($command); - - $this->associateWithShops($webserviceKey, $command->getAssociatedShops()); - $this->setPermissionsForWebserviceKey($webserviceKey, $command->getPermissions()); - - return new WebserviceKeyId((int) $webserviceKey->id); - } - - /** - * Asserts that new webservice key does not duplicate already existing keys - * - * @param Key $key - */ - private function assertWebserviceKeyIsNotDuplicate(Key $key) - { - if (WebserviceKey::keyExists($key->getValue())) { - throw new DuplicateWebserviceKeyException(sprintf('Webservice key "%s" already exists', $key->getValue())); - } - } - - /** - * @param AddWebserviceKeyCommand $command - * - * @return WebserviceKey - */ - private function createLegacyWebserviceKeyFromCommand(AddWebserviceKeyCommand $command) - { - $webserviceKey = new WebserviceKey(); - $webserviceKey->key = $command->getKey()->getValue(); - $webserviceKey->description = $command->getDescription(); - $webserviceKey->active = $command->getStatus(); - - if (false === $webserviceKey->validateFields(false)) { - throw new WebserviceConstraintException('One or more fields are invalid in WebserviceKey'); - } - - if (false === $webserviceKey->add()) { - throw new WebserviceException('Failed to add WebserviceKey'); - } - - return $webserviceKey; - } -} diff --git a/src/Adapter/Webservice/CommandHandler/EditWebserviceKeyHandler.php b/src/Adapter/Webservice/CommandHandler/EditWebserviceKeyHandler.php deleted file mode 100644 index fc21d49b..00000000 --- a/src/Adapter/Webservice/CommandHandler/EditWebserviceKeyHandler.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Webservice\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Webservice\Command\EditWebserviceKeyCommand; -use PrestaShop\PrestaShop\Core\Domain\Webservice\CommandHandler\EditWebserviceKeyHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Webservice\Exception\WebserviceConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Webservice\Exception\WebserviceException; -use PrestaShop\PrestaShop\Core\Domain\Webservice\Exception\WebserviceKeyNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Webservice\ValueObject\WebserviceKeyId; -use WebserviceKey; - -/** - * Handles command that edits legacy WebserviceKey - * - * @internal - */ -final class EditWebserviceKeyHandler extends AbstractWebserviceKeyHandler implements EditWebserviceKeyHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(EditWebserviceKeyCommand $command) - { - $webserviceKey = $this->getLegacyWebserviceKey($command->getWebserviceKeyId()); - - $this->updateLegacyWebserviceKeyWithCommandData($webserviceKey, $command); - } - - /** - * @param WebserviceKeyId $webserviceKeyId - * - * @return WebserviceKey - */ - private function getLegacyWebserviceKey(WebserviceKeyId $webserviceKeyId) - { - $webserviceKey = new WebserviceKey($webserviceKeyId->getValue()); - - if ($webserviceKeyId->getValue() !== $webserviceKey->id) { - throw new WebserviceKeyNotFoundException(sprintf('Webservice key with id "%s was not found', $webserviceKeyId->getValue())); - } - - return $webserviceKey; - } - - /** - * @param WebserviceKey $webserviceKey - * @param EditWebserviceKeyCommand $command - */ - private function updateLegacyWebserviceKeyWithCommandData( - WebserviceKey $webserviceKey, - EditWebserviceKeyCommand $command - ) { - if (null !== $command->getKey()) { - $webserviceKey->key = $command->getKey()->getValue(); - } - - if (null !== $command->getDescription()) { - $webserviceKey->description = $command->getDescription(); - } - - if (null !== $command->getStatus()) { - $webserviceKey->active = $command->getStatus(); - } - - if (false === $webserviceKey->validateFields(false)) { - throw new WebserviceConstraintException('One or more fields are invalid in WebserviceKey'); - } - - if (false === $webserviceKey->update()) { - throw new WebserviceException(sprintf('Failed to update WebserviceKey with id "%s"', $webserviceKey->id)); - } - - if (null !== $command->getShopAssociation()) { - $this->associateWithShops($webserviceKey, $command->getShopAssociation()); - } - - if (null !== $command->getPermissions()) { - $this->setPermissionsForWebserviceKey($webserviceKey, $command->getPermissions()); - } - } -} diff --git a/src/Adapter/Webservice/QueryHandler/GetWebserviceKeyForEditingHandler.php b/src/Adapter/Webservice/QueryHandler/GetWebserviceKeyForEditingHandler.php deleted file mode 100644 index 807d7ce4..00000000 --- a/src/Adapter/Webservice/QueryHandler/GetWebserviceKeyForEditingHandler.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Webservice\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Webservice\Exception\WebserviceKeyNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Webservice\Query\GetWebserviceKeyForEditing; -use PrestaShop\PrestaShop\Core\Domain\Webservice\QueryHandler\GetWebserviceKeyForEditingHandlerInterface; -use PrestaShop\PrestaShop\Core\Domain\Webservice\QueryResult\EditableWebserviceKey; -use PrestaShop\PrestaShop\Core\Domain\Webservice\ValueObject\WebserviceKeyId; -use WebserviceKey; - -/** - * Handles command that gets webservice key data for editing - * - * @internal - */ -final class GetWebserviceKeyForEditingHandler implements GetWebserviceKeyForEditingHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(GetWebserviceKeyForEditing $query) - { - $webserviceKey = $this->getLegacyWebserviceKeyObject($query->getWebserviceKeyId()); - - return new EditableWebserviceKey( - $query->getWebserviceKeyId(), - $webserviceKey->key, - $webserviceKey->description, - $webserviceKey->active, - WebserviceKey::getPermissionForAccount($webserviceKey->key), - $webserviceKey->getAssociatedShops() - ); - } - - /** - * @param WebserviceKeyId $webserviceKeyId - * - * @return WebserviceKey - */ - private function getLegacyWebserviceKeyObject(WebserviceKeyId $webserviceKeyId) - { - $webserviceKey = new WebserviceKey($webserviceKeyId->getValue()); - - if ($webserviceKey->id !== $webserviceKeyId->getValue()) { - throw new WebserviceKeyNotFoundException(sprintf('Webservice key with id "%s" was not found', $webserviceKeyId)); - } - - return $webserviceKey; - } -} diff --git a/src/Adapter/Webservice/WebserviceConfiguration.php b/src/Adapter/Webservice/WebserviceConfiguration.php deleted file mode 100644 index 33f53336..00000000 --- a/src/Adapter/Webservice/WebserviceConfiguration.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Webservice; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; - -/** - * Manages the configuration data about upload quota options. - */ -final class WebserviceConfiguration implements DataConfigurationInterface -{ - /** - * @var Configuration - */ - private $configuration; - - /** - * @param Configuration $configuration - */ - public function __construct(Configuration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'enable_webservice' => $this->configuration->getBoolean('PS_WEBSERVICE'), - 'enable_cgi' => $this->configuration->getBoolean('PS_WEBSERVICE_CGI_HOST'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_WEBSERVICE', $configuration['enable_webservice']); - $this->configuration->set('PS_WEBSERVICE_CGI_HOST', $configuration['enable_cgi']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - $enableWebserviceisValid = (isset($configuration['enable_webservice']) && (is_bool($configuration['enable_webservice']))); - $enableCGI = (isset($configuration['enable_webservice']) && (is_bool($configuration['enable_webservice']))); - - return $enableWebserviceisValid && $enableCGI; - } -} diff --git a/src/Adapter/Webservice/WebserviceKeyEraser.php b/src/Adapter/Webservice/WebserviceKeyEraser.php deleted file mode 100644 index c5e1e504..00000000 --- a/src/Adapter/Webservice/WebserviceKeyEraser.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Webservice; - -use PrestaShopCollection; -use WebserviceKey; - -/** - * Class WebserviceKeyEraser is responsible for deleting the records from webservice account table. - */ -final class WebserviceKeyEraser -{ - /** - * Erase given webservice accounts. - * - * @param int[] $webServiceKeyIds - * - * @return string[] - array of errors. If array is empty then erase operation succeeded. - * - * @throws \PrestaShopException - */ - public function erase(array $webServiceKeyIds) - { - $errors = []; - - if (empty($webServiceKeyIds)) { - $errors[] = [ - 'key' => 'You must select at least one element to delete.', - 'parameters' => [], - 'domain' => 'Admin.Notifications.Error', - ]; - - return $errors; - } - - $webserviceKeys = new PrestaShopCollection(WebserviceKey::class); - $webserviceKeys->where('id_webservice_account', 'in', $webServiceKeyIds); - - /** @var WebserviceKey $webserviceKey */ - foreach ($webserviceKeys->getResults() as $webserviceKey) { - if (!$webserviceKey->delete()) { - $errors[] = [ - 'key' => 'Can\'t delete #%id%', - 'parameters' => [ - '%id%' => $webserviceKey->id, - ], - 'domain' => 'Admin.Notifications.Error', - ]; - - continue; - } - } - - return $errors; - } -} diff --git a/src/Adapter/Webservice/WebserviceKeyStatusModifier.php b/src/Adapter/Webservice/WebserviceKeyStatusModifier.php deleted file mode 100644 index 880c59e3..00000000 --- a/src/Adapter/Webservice/WebserviceKeyStatusModifier.php +++ /dev/null @@ -1,112 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Adapter\Webservice; - -use Symfony\Component\Translation\TranslatorInterface; -use Validate; -use WebserviceKey; - -/** - * Class WebserviceKeyStatusModifier is responsible for modifying webservice account status. - */ -final class WebserviceKeyStatusModifier -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * WebserviceKeyStatusModifier constructor. - * - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * Toggles status for webservice key entity. - * - * @param int $columnId - an id which identifies the required entity to be modified - * - * @return string[] - if empty when process of status change was successful - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - public function toggleStatus($columnId) - { - $webserviceKey = new WebserviceKey($columnId); - - if (!Validate::isLoadedObject($webserviceKey)) { - $error = $this->translator - ->trans( - 'An error occurred while updating the status for an object.', - [], - 'Admin.Notifications.Error' - ) . - WebserviceKey::$definition['table'] . - $this->translator->trans('(cannot load object)', [], 'Admin.Notifications.Error'); - - return [$error]; - } - - if (!$webserviceKey->toggleStatus()) { - $error = $this->translator - ->trans('An error occurred while updating the status.', [], 'Admin.Notifications.Error'); - - return [$error]; - } - - return []; - } - - /** - * Updates status for multiple fields. - * - * @param array $columnIds - * @param int $status - * - * @return bool - * - * @throws \PrestaShopDatabaseException - * @throws \PrestaShopException - */ - public function setStatus(array $columnIds, $status) - { - $result = true; - foreach ($columnIds as $columnId) { - $webserviceKey = new WebserviceKey($columnId); - $webserviceKey->active = $status; - $result &= $webserviceKey->update(); - } - - return $result; - } -} diff --git a/src/Core/Addon/AddonInterface.php b/src/Core/Addon/AddonInterface.php deleted file mode 100644 index 76482128..00000000 --- a/src/Core/Addon/AddonInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon; - -interface AddonInterface -{ - public function onInstall(); - - public function onUninstall(); - - public function onEnable(); - - public function onDisable(); - - public function onReset(); - - public function onUpgrade($version); -} diff --git a/src/Core/Addon/AddonListFilter.php b/src/Core/Addon/AddonListFilter.php deleted file mode 100644 index ce6bf34c..00000000 --- a/src/Core/Addon/AddonListFilter.php +++ /dev/null @@ -1,189 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon; - -class AddonListFilter -{ - /** - * @var int AddonListFilterType Specify the addon type like theme only or module only or all - */ - public $type = AddonListFilterType::ALL; - - /** - * @var int AddonListFilterStatus Specify if you want enabled only, disabled only or all addons - */ - public $status = AddonListFilterStatus::ALL; - - /** - * @var int AddonListFilterOrigin Specify if you want an addon from a specific source - */ - public $origin = AddonListFilterOrigin::ALL; - - /** - * @var array Names of all the addons to exclude from result - */ - public $exclude = []; - - /** - * @param int $origin - * - * @return \PrestaShop\PrestaShop\Core\Addon\AddonListFilter - */ - public function addOrigin($origin) - { - $this->origin &= $origin; - - return $this; - } - - /** - * @param int $status - * - * @return \PrestaShop\PrestaShop\Core\Addon\AddonListFilter - */ - public function addStatus($status) - { - $this->status &= $status; - - return $this; - } - - /** - * @param int $type - * - * @return \PrestaShop\PrestaShop\Core\Addon\AddonListFilter - */ - public function addType($type) - { - $this->type &= $type; - - return $this; - } - - /** - * @param int $origin - * - * @return bool - */ - public function hasOrigin($origin) - { - return $this->origin & $origin; - } - - /** - * @param int $status - * - * @return bool - */ - public function hasStatus($status) - { - return $this->status & $status; - } - - /** - * @param int $type - * - * @return bool - */ - public function hasType($type) - { - return $this->type & $type; - } - - /** - * @param int $origin - * - * @return \PrestaShop\PrestaShop\Core\Addon\AddonListFilter - */ - public function removeOrigin($origin) - { - return $this->addOrigin(~$origin); - } - - /** - * @param int $status - * - * @return \PrestaShop\PrestaShop\Core\Addon\AddonListFilter - */ - public function removeStatus($status) - { - return $this->addStatus(~$status); - } - - /** - * @param int $type - * - * @return \PrestaShop\PrestaShop\Core\Addon\AddonListFilter - */ - public function removeType($type) - { - return $this->addType(~$type); - } - - /** - * @param int $origin - * - * @return \PrestaShop\PrestaShop\Core\Addon\AddonListFilter - */ - public function setOrigin($origin) - { - $this->origin = $origin; - - return $this; - } - - /** - * @param int $type - * - * @return \PrestaShop\PrestaShop\Core\Addon\AddonListFilter - */ - public function setType($type) - { - $this->type = $type; - - return $this; - } - - /** - * @param int $status - * - * @return \PrestaShop\PrestaShop\Core\Addon\AddonListFilter - */ - public function setStatus($status) - { - $this->status = $status; - - return $this; - } - - public function setExclude(array $exclude) - { - $this->exclude = $exclude; - - return $this; - } -} diff --git a/src/Core/Addon/AddonListFilterOrigin.php b/src/Core/Addon/AddonListFilterOrigin.php deleted file mode 100644 index 4eb26138..00000000 --- a/src/Core/Addon/AddonListFilterOrigin.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon; - -class AddonListFilterOrigin -{ - /* Bitwise operators */ - const DISK = 1; - const ADDONS_MUST_HAVE = 2; - const ADDONS_SERVICE = 4; - const ADDONS_NATIVE = 8; - const ADDONS_NATIVE_ALL = 16; - const ADDONS_CUSTOMER = 32; - const ADDONS_ALL = 62; - - const ALL = 63; -} diff --git a/src/Core/Addon/AddonListFilterStatus.php b/src/Core/Addon/AddonListFilterStatus.php deleted file mode 100644 index 8651a383..00000000 --- a/src/Core/Addon/AddonListFilterStatus.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon; - -class AddonListFilterStatus -{ - const NOT_ON_DISK = 1; - const ON_DISK = 2; // = Present on disk but not installed - const UNINSTALLED = 4; - const INSTALLED = 8; // = Installed - const DISABLED = 16; - const ENABLED = 32; - - const ALL = 63; -} diff --git a/src/Core/Addon/AddonListFilterType.php b/src/Core/Addon/AddonListFilterType.php deleted file mode 100644 index a1d337fe..00000000 --- a/src/Core/Addon/AddonListFilterType.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon; - -class AddonListFilterType -{ - /* Bitwise operator */ - const THEME = 1; - const MODULE = 2; - const SERVICE = 4; - - const ALL = 7; /* = 1 | 2 | 4 */ -} diff --git a/src/Core/Addon/AddonListItem.php b/src/Core/Addon/AddonListItem.php deleted file mode 100644 index d47108aa..00000000 --- a/src/Core/Addon/AddonListItem.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon; - -class AddonListItem -{ - public $name; - public $displayName; - public $type; - public $author; - public $version; - public $isEnabled; -} diff --git a/src/Core/Addon/AddonManagerInterface.php b/src/Core/Addon/AddonManagerInterface.php deleted file mode 100644 index b3dbe445..00000000 --- a/src/Core/Addon/AddonManagerInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon; - -interface AddonManagerInterface -{ - public function install($source); - - public function uninstall($name); - - public function upgrade($name, $version, $source = null); - - public function enable($name); - - public function disable($name); - - public function reset($name); - - public function getError($name); -} diff --git a/src/Core/Addon/AddonRepositoryInterface.php b/src/Core/Addon/AddonRepositoryInterface.php deleted file mode 100644 index eb880d27..00000000 --- a/src/Core/Addon/AddonRepositoryInterface.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon; - -interface AddonRepositoryInterface -{ - /** - * @param string $name theme name - * - * @return AddonInterface the theme or module - */ - public function getInstanceByName($name); - - /** - * @param AddonListFilter $filter - * - * @return AddonInterface[] retrieve a list of addons, regarding the $filter used - */ - public function getFilteredList(AddonListFilter $filter); - - /** - * @return AddonInterface[] retrieve a list of addons, regardless any $filter - */ - public function getList(); -} diff --git a/src/Core/Addon/AddonsCollection.php b/src/Core/Addon/AddonsCollection.php deleted file mode 100644 index 75181b5f..00000000 --- a/src/Core/Addon/AddonsCollection.php +++ /dev/null @@ -1,269 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon; - -use ArrayAccess; -use ArrayIterator; -use Countable; -use IteratorAggregate; -use PrestaShop\PrestaShop\Adapter\Module\Module as Addon; - -/** - * An ArrayCollection is a Collection implementation that wraps a regular PHP array. - */ -class AddonsCollection implements ArrayAccess, Countable, IteratorAggregate -{ - /** - * An array containing the addons of this collection. - * - * @var array - */ - private $addons; - - /** - * Initializes a new AddonsCollection. - * - * @param array $addons - */ - public function __construct(array $addons = []) - { - $this->addons = $addons; - } - - /** - * Creates a new instance from the specified elements. - * - * This method is provided for derived classes to specify how a new - * instance should be created when constructor semantics have changed. - * - * @param array $addons elements - * - * @return static - */ - public static function createFrom(array $addons) - { - return new static($addons); - } - - /** - * Gets a native PHP array representation of the collection. - * - * @return array - */ - public function toArray() - { - return $this->addons; - } - - /** - * @return ArrayIterator|\Traversable - */ - public function getIterator() - { - return new ArrayIterator($this->addons); - } - - /** - * {@inheritdoc} - */ - public function offsetExists($offset) - { - return $this->containsKey($offset); - } - - /** - * {@inheritdoc} - */ - public function offsetGet($offset) - { - return $this->get($offset); - } - - /** - * Required by ArrayAccess interface. - * - * {@inheritdoc} - */ - public function offsetSet($offset, $addon) - { - if (!isset($offset)) { - $this->add($addon); - - return; - } - - $this->set($offset, $addon); - } - - /** - * Required by interface ArrayAccess. - * - * {@inheritdoc} - */ - public function offsetUnset($offset) - { - $this->remove($offset); - } - - /** - * Returns true if the key is found in the collection. - * - * @param mixed $key the key, can be integer or string - * - * @return bool - */ - public function containsKey($key) - { - return isset($this->addons[$key]) || array_key_exists($key, $this->addons); - } - - /** - * Returns true if the addon is found in the collection. - * - * @param Addon $addon the addon - * - * @return bool - */ - public function contains(Addon $addon) - { - return in_array($addon, $this->addons, true); - } - - /** - * {@inheritdoc} - */ - public function indexOf(Addon $addon) - { - return array_search($addon, $this->addons, true); - } - - /** - * {@inheritdoc} - */ - public function get($key) - { - return $this->addons[$key] ? $this->addons[$key] : null; - } - - /** - * {@inheritdoc} - */ - public function getKeys() - { - return array_keys($this->addons); - } - - /** - * {@inheritdoc} - */ - public function getValues() - { - return array_values($this->addons); - } - - /** - * Add an Addon with a specified key in the collection. - * - * @param mixed $key the key - * @param Addon $addon the specified addon - */ - public function set($key, Addon $addon) - { - $this->addons[$key] = $addon; - } - - /** - * Add an Addon in the collection. - * - * @param Addon $addon the specified addon - * - * @return bool - */ - public function add(Addon $addon) - { - $this->addons[] = $addon; - - return true; - } - - /** - * Remove an addon from the collection by key. - * - * @param mixed the key (can be int or string) - * - * @return bool true if the addon has been found and removed - */ - public function removeByKey($key) - { - if (!isset($this->addons[$key]) && !array_key_exists($key, $this->addons)) { - return null; - } - - $removed = $this->addons[$key]; - unset($this->addons[$key]); - - return $removed; - } - - /** - * Remove an addon from the collection by key. - * - * @param Addon $addon the addon to be removed - * - * @return bool true if the addon has been found and removed - */ - public function remove(Addon $addon) - { - $key = array_search($addon, $this->addons, true); - - if ($key === false) { - return false; - } - - unset($this->addons[$key]); - - return true; - } - - /** - * {@inheritdoc} - */ - public function isEmpty() - { - return empty($this->addons); - } - - /** - * Gets the sum of addons of the collection. - * - * @return int - */ - public function count() - { - return count($this->addons); - } -} diff --git a/src/Core/Addon/Module/AddonListFilterDeviceStatus.php b/src/Core/Addon/Module/AddonListFilterDeviceStatus.php deleted file mode 100644 index 4f172362..00000000 --- a/src/Core/Addon/Module/AddonListFilterDeviceStatus.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Module; - -class AddonListFilterDeviceStatus -{ - const DEVICE_COMPUTER = 1; - const DEVICE_TABLET = 2; - const DEVICE_MOBILE = 4; - - const ALL = 7; -} diff --git a/src/Core/Addon/Module/Exception/UnconfirmedModuleActionException.php b/src/Core/Addon/Module/Exception/UnconfirmedModuleActionException.php deleted file mode 100644 index 69544e1d..00000000 --- a/src/Core/Addon/Module/Exception/UnconfirmedModuleActionException.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Module\Exception; - -use PrestaShop\PrestaShop\Adapter\Module\Module; -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * This class is used for the module page, which allows to ask for a confirmation from the employee. - */ -class UnconfirmedModuleActionException extends CoreException -{ - /** - * Concerned module by the exception. - * - * @var Module - */ - protected $module; - - /** - * Action requested by the employee. - * - * @var string - */ - protected $action; - - /** - * Subject to send in order to confirm. - * - * @var string - */ - protected $subject; - - /** - * Module getter. - * - * @return Module - */ - public function getModule() - { - return $this->module; - } - - /** - * Action getter (install, uninstall, reset ...). - * - * @return string - */ - public function getAction() - { - return $this->action; - } - - /** - * Subject getter (PrestaTrust...). - * - * @return string - */ - public function getSubject() - { - return $this->subject; - } - - /** - * Module setter. - * - * @param Module $module - * - * @return $this - */ - public function setModule(Module $module) - { - $this->module = $module; - - return $this; - } - - /** - * Action setter. - * - * @param string $action - * - * @return $this - */ - public function setAction($action) - { - $this->action = $action; - - return $this; - } - - /** - * Subject setter. - * - * @param string $subject - * - * @return $this - */ - public function setSubject($subject) - { - $this->subject = $subject; - - return $this; - } -} diff --git a/src/Core/Addon/Module/ModuleInterface.php b/src/Core/Addon/Module/ModuleInterface.php deleted file mode 100644 index bbf211e5..00000000 --- a/src/Core/Addon/Module/ModuleInterface.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Module; - -use PrestaShop\PrestaShop\Core\Addon\AddonInterface; - -interface ModuleInterface extends AddonInterface -{ - public function onInstall(); - - public function onUninstall(); - - /** - * Called when switching the current theme of the selected shop. - * You can update configuration, enable/disable modules... - * - * @return bool true for success - */ - public function onEnable(); - - /** - * Not necessarily the opposite of enable. Use this method if - * something must be done when switching to another theme (like uninstall - * very specific modules for example). - * - * @return bool true for success - */ - public function onDisable(); - - /** - * @return bool - */ - public function onMobileEnable(); - - /** - * @return bool - */ - public function onMobileDisable(); - - /** - * @return bool - */ - public function onReset(); - - /** - * Execute up files. You can update configuration, update sql schema. - * No file modification. - * - * @return bool true for success - */ - public function onUpgrade($version); -} diff --git a/src/Core/Addon/Module/ModuleManager.php b/src/Core/Addon/Module/ModuleManager.php deleted file mode 100644 index b1265756..00000000 --- a/src/Core/Addon/Module/ModuleManager.php +++ /dev/null @@ -1,701 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Module; - -use Exception; -use PrestaShop\PrestaShop\Adapter\Module\AdminModuleDataProvider; -use PrestaShop\PrestaShop\Adapter\Module\Module; -use PrestaShop\PrestaShop\Adapter\Module\ModuleDataProvider; -use PrestaShop\PrestaShop\Adapter\Module\ModuleDataUpdater; -use PrestaShop\PrestaShop\Adapter\Module\ModuleZipManager; -use PrestaShop\PrestaShop\Core\Addon\AddonManagerInterface; -use PrestaShop\PrestaShop\Core\Addon\AddonsCollection; -use PrestaShop\PrestaShop\Core\Addon\Module\Exception\UnconfirmedModuleActionException; -use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface; -use PrestaShopBundle\Event\ModuleManagementEvent; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\HttpFoundation\ParameterBag; -use Symfony\Component\Translation\TranslatorInterface; - -class ModuleManager implements AddonManagerInterface -{ - /** - * Admin Module Data Provider. - * - * @var \PrestaShop\PrestaShop\Adapter\Module\AdminModuleDataProvider - */ - private $adminModuleProvider; - /** - * Module Data Provider. - * - * @var \PrestaShop\PrestaShop\Adapter\Module\ModuleDataProvider - */ - private $moduleProvider; - /** - * Module Data Provider. - * - * @var \PrestaShop\PrestaShop\Adapter\Module\ModuleDataUpdater - */ - private $moduleUpdater; - - /** - * Module Repository. - * - * @var \PrestaShop\PrestaShop\Core\Addon\Module\ModuleRepository - */ - private $moduleRepository; - - /** - * Module Zip Manager. - * - * @var \PrestaShop\PrestaShop\Adapter\Module\ModuleZipManager - */ - private $moduleZipManager; - - /** - * Translator. - * - * @var \Symfony\Component\Translation\TranslatorInterface - */ - private $translator; - - /** - * @var EventDispatcherInterface - */ - private $eventDispatcher; - - /** - * Additionnal data used for module actions. - * - * @var ParameterBag - */ - private $actionParams; - - /** - * @var CacheClearerInterface - */ - private $symfonyCacheClearer; - - /** - * Used to check if the cache has already been cleaned. - * - * @var bool - */ - private $cacheCleared = false; - - /** - * @param AdminModuleDataProvider $adminModuleProvider - * @param ModuleDataProvider $modulesProvider - * @param ModuleDataUpdater $modulesUpdater - * @param ModuleRepository $moduleRepository - * @param ModuleZipManager $moduleZipManager - * @param TranslatorInterface $translator - * @param EventDispatcherInterface $eventDispatcher - * @param CacheClearerInterface $symfonyCacheClearer - */ - public function __construct( - AdminModuleDataProvider $adminModuleProvider, - ModuleDataProvider $modulesProvider, - ModuleDataUpdater $modulesUpdater, - ModuleRepository $moduleRepository, - ModuleZipManager $moduleZipManager, - TranslatorInterface $translator, - EventDispatcherInterface $eventDispatcher, - CacheClearerInterface $symfonyCacheClearer - ) { - $this->adminModuleProvider = $adminModuleProvider; - $this->moduleProvider = $modulesProvider; - $this->moduleUpdater = $modulesUpdater; - $this->moduleRepository = $moduleRepository; - $this->moduleZipManager = $moduleZipManager; - $this->translator = $translator; - $this->eventDispatcher = $eventDispatcher; - $this->symfonyCacheClearer = $symfonyCacheClearer; - $this->actionParams = new ParameterBag(); - } - - /** - * For some actions, you may need to add params like confirmation details. - * This setter is the way to register them in the manager. - * - * @param array $actionParams - * - * @return $this - */ - public function setActionParams(array $actionParams) - { - $this->actionParams->replace($actionParams); - - return $this; - } - - /** - * @param callable $modulesPresenter - * - * @return object - */ - public function getModulesWithNotifications(callable $modulesPresenter) - { - $modules = $this->groupModulesByInstallationProgress(); - - $modulesProvider = $this->adminModuleProvider; - foreach ($modules as $moduleLabel => $modulesPart) { - $collection = AddonsCollection::createFrom($modulesPart); - $modulesProvider->generateAddonsUrls($collection, str_replace('to_', '', $moduleLabel)); - $modules->{$moduleLabel} = $modulesPresenter($collection); - } - - return $modules; - } - - /** - * Returns the total of module notifications - * Not used anymore, but kept for backward compatibility. - * - * @return int - * - * @deprecated since 1.7.5.0 - */ - public function countModulesWithNotifications() - { - $modules = (array) $this->groupModulesByInstallationProgress(); - - return array_reduce($modules, function ($carry, $item) { - return $carry + count($item); - }, 0); - } - - /** - * Detailed array of number of modules per notification type. - * - * @return array - */ - public function countModulesWithNotificationsDetailed() - { - $notificationCounts = [ - 'count' => 0, - ]; - - foreach ((array) $this->groupModulesByInstallationProgress() as $key => $modules) { - $count = count($modules); - $notificationCounts[$key] = $count; - $notificationCounts['count'] += $count; - } - - return $notificationCounts; - } - - /** - * @return object - */ - protected function groupModulesByInstallationProgress() - { - $installedProducts = $this->moduleRepository->getInstalledModules(); - - $modules = (object) [ - 'to_configure' => [], - 'to_update' => [], - ]; - - /* - * @var \PrestaShop\PrestaShop\Adapter\Module\Module - */ - foreach ($installedProducts as $installedProduct) { - if ($this->shouldRecommendConfigurationForModule($installedProduct)) { - $modules->to_configure[] = (object) $installedProduct; - } - - if ($installedProduct->canBeUpgraded()) { - $modules->to_update[] = (object) $installedProduct; - } - } - - return $modules; - } - - /** - * @param Module $installedProduct - * - * @return bool - */ - protected function shouldRecommendConfigurationForModule(Module $installedProduct) - { - $warnings = $this->getModuleInstallationWarnings($installedProduct); - - return !empty($warnings); - } - - /** - * @param Module $installedProduct - * - * @return array - */ - protected function getModuleInstallationWarnings(Module $installedProduct) - { - if ($installedProduct->hasValidInstance()) { - return $installedProduct->getInstance()->warning; - } - - return []; - } - - /** - * Add new module from zipball. This will unzip the file and move the content - * to the right locations. - * A theme can bundle modules, resources, documentation, email templates and so on. - * - * @param string $source The source can be a module name (installed from either local disk or addons.prestashop.com). - * or a location (url or path to the zip file) - * - * @return bool true for success - */ - public function install($source) - { - // in CLI mode, there is no employee set up - if (!$this->adminModuleProvider->isAllowedAccess(__FUNCTION__)) { - throw new Exception($this->translator->trans('You are not allowed to install modules.', [], 'Admin.Modules.Notification')); - } - - if (is_file($source)) { - $name = $this->moduleZipManager->getName($source); - } else { - $name = $source; - $source = null; - } - - if ($this->moduleProvider->isInstalled($name)) { - return $this->upgrade($name, 'latest', $source); - } - - if (!empty($source)) { - $this->moduleZipManager->storeInModulesFolder($source); - } elseif (!$this->moduleProvider->isOnDisk($name)) { - $this->moduleUpdater->setModuleOnDiskFromAddons($name); - } - - $module = $this->moduleRepository->getModule($name); - $this->checkConfirmationGiven(__FUNCTION__, $module); - $result = $module->onInstall(); - - $this->checkAndClearCache($result); - $this->dispatch(ModuleManagementEvent::INSTALL, $module); - - return $result; - } - - /** - * Remove all theme files, resources, documentation and specific modules. - * - * @param string $name The source can be a module name (installed from either local disk or addons.prestashop.com). - * or a location (url or path to the zip file) - * - * @return bool true for success - */ - public function uninstall($name) - { - // Check permissions: - // * Employee can delete - // * Employee can delete this specific module - if (!$this->adminModuleProvider->isAllowedAccess(__FUNCTION__, $name)) { - throw new Exception($this->translator->trans('You are not allowed to uninstall the module %module%.', ['%module%' => $name], 'Admin.Modules.Notification')); - } - - $this->checkIsInstalled($name); - - // Get module instance and uninstall it - $module = $this->moduleRepository->getModule($name); - $result = $module->onUninstall(); - - if ($result && $this->actionParams->get('deletion', false)) { - $result = $result && $this->removeModuleFromDisk($name); - } - - $this->checkAndClearCache($result); - $this->dispatch(ModuleManagementEvent::UNINSTALL, $module); - - return $result; - } - - /** - * Download new files from source, backup old files, replace files with new ones - * and execute all necessary migration scripts form current version to the new one. - * - * @param Addon $name the theme you want to upgrade - * @param string $version the version you want to up upgrade to - * @param string $source if the upgrade is not coming from addons, you need to specify the path to the zipball - * - * @return bool true for success - */ - public function upgrade($name, $version = 'latest', $source = null) - { - if (!$this->adminModuleProvider->isAllowedAccess(__FUNCTION__, $name)) { - throw new Exception($this->translator->trans('You are not allowed to upgrade the module %module%.', ['%module%' => $name], 'Admin.Modules.Notification')); - } - - $this->checkIsInstalled($name); - $module = $this->moduleRepository->getModule($name); - - // Get new module - // 1- From source - if ($source != null) { - $this->moduleZipManager->storeInModulesFolder($source); - } elseif ($module->canBeUpgradedFromAddons()) { - // 2- From Addons - // This step is not mandatory (in case of local module), - // we do not check the result - $this->moduleUpdater->setModuleOnDiskFromAddons($name); - } - - // Load and execute upgrade files - $result = $this->moduleUpdater->upgrade($name) && $module->onUpgrade($version); - - $this->checkAndClearCache($result); - $this->dispatch(ModuleManagementEvent::UPGRADE, $module); - - return $result; - } - - /** - * Disable a module without uninstalling it. - * Allows the merchant to temporarly remove a module without uninstalling it. - * - * @param string $name The module name to disable - * - * @return bool True for success - */ - public function disable($name) - { - if (!$this->adminModuleProvider->isAllowedAccess(__FUNCTION__, $name)) { - throw new Exception($this->translator->trans('You are not allowed to disable the module %module%.', ['%module%' => $name], 'Admin.Modules.Notification')); - } - - $this->checkIsInstalled($name); - - $module = $this->moduleRepository->getModule($name); - - try { - $result = $module->onDisable(); - } catch (Exception $e) { - throw new Exception($this->translator->trans('Error when disabling module %module%. %error_details%.', ['%module%' => $name, '%error_details%' => $e->getMessage()], 'Admin.Modules.Notification'), 0, $e); - } - - $this->checkAndClearCache($result); - $this->dispatch(ModuleManagementEvent::DISABLE, $module); - - return $result; - } - - /** - * Enable a module previously disabled. - * - * @param string $name The module name to enable - * - * @return bool True for success - */ - public function enable($name) - { - if (!$this->adminModuleProvider->isAllowedAccess(__FUNCTION__, $name)) { - throw new Exception($this->translator->trans('You are not allowed to enable the module %module%.', ['%module%' => $name], 'Admin.Modules.Notification')); - } - - $this->checkIsInstalled($name); - - $module = $this->moduleRepository->getModule($name); - - try { - $result = $module->onEnable(); - } catch (Exception $e) { - throw new Exception($this->translator->trans('Error when enabling module %module%. %error_details%.', ['%module%' => $name, '%error_details%' => $e->getMessage()], 'Admin.Modules.Notification'), 0, $e); - } - - $this->checkAndClearCache($result); - $this->dispatch(ModuleManagementEvent::ENABLE, $module); - - return $result; - } - - /** - * Disable a module specifically on mobile. - * Not written in camel case because the route and the displayed action in the template - * are related to this function name. - * - * @deprecated use disableMobile() - * - * @param string $name The module name to disable - * - * @return bool True for success - */ - public function disable_mobile($name) - { - return $this->disableMobile($name); - } - - /** - * Disable a module specifically on mobile. - * - * @param string $name The module name to disable - * - * @return bool True for success - */ - public function disableMobile($name) - { - if (!$this->adminModuleProvider->isAllowedAccess(__FUNCTION__, $name)) { - throw new Exception($this->translator->trans('You are not allowed to disable the module %module% on mobile.', ['%module%' => $name], 'Admin.Modules.Notification')); - } - - $this->checkIsInstalled($name); - - $module = $this->moduleRepository->getModule($name); - - try { - $result = $module->onMobileDisable(); - } catch (Exception $e) { - throw new Exception($this->translator->trans('Error when disabling module %module% on mobile. %error_details%', ['%module%' => $name, '%error_details%' => $e->getMessage()], 'Admin.Modules.Notification'), 0, $e); - } - - $this->checkAndClearCache($result); - - return $result; - } - - /** - * Enable a module previously disabled on mobile - * Not written in camel case because the route and the displayed action in the template - * are related to this function name. - * - * @deprecated use enableMobile - * - * @param string $name The module name to enable - * - * @return bool True for success - */ - public function enable_mobile($name) - { - return $this->enableMobile($name); - } - - /** - * Enable a module previously disabled on mobile. - * - * @param string $name The module name to enable - * - * @return bool True for success - */ - public function enableMobile($name) - { - if (!$this->adminModuleProvider->isAllowedAccess(__FUNCTION__, $name)) { - throw new Exception($this->translator->trans('You are not allowed to enable the module %module% on mobile.', ['%module%' => $name], 'Admin.Modules.Notification')); - } - - $this->checkIsInstalled($name); - - $module = $this->moduleRepository->getModule($name); - - try { - $result = $module->onMobileEnable(); - } catch (Exception $e) { - throw new Exception($this->translator->trans('Error when enabling module %module% on mobile. %error_details%', ['%module%' => $name, '%error_details%' => $e->getMessage()], 'Admin.Modules.Notification'), 0, $e); - } - - $this->checkAndClearCache($result); - - return $result; - } - - /** - * Actions to perform to restaure default settings. - * - * @param string $name The theme name to reset - * - * @return bool True for success - */ - public function reset($name, $keep_data = false) - { - if (!$this->adminModuleProvider->isAllowedAccess('install') || !$this->adminModuleProvider->isAllowedAccess('uninstall', $name)) { - throw new Exception($this->translator->trans('You are not allowed to reset the module %module%.', ['%module%' => $name], 'Admin.Modules.Notification')); - } - - $this->checkIsInstalled($name); - - $module = $this->moduleRepository->getModule($name); - - try { - if ((bool) $keep_data && method_exists($module->getInstance(), 'reset')) { - $this->dispatch(ModuleManagementEvent::UNINSTALL, $module); - $status = $module->onReset(); - $this->dispatch(ModuleManagementEvent::INSTALL, $module); - } else { - $status = ($this->uninstall($name) && $this->install($name)); - } - } catch (Exception $e) { - throw new Exception($this->translator->trans('Error when resetting module %module%. %error_details%', ['%module%' => $name, '%error_details%' => $e->getMessage()], 'Admin.Modules.Notification'), 0, $e); - } - - return $status; - } - - /** - * Shortcut to the module data provider in order to know if a module is enabled. - * - * @param string $name The technical module name - * - * @return bool - */ - public function isEnabled($name) - { - return $this->moduleProvider->isEnabled($name); - } - - /** - * Shortcut to the module data provider in order to know if a module is installed. - * - * @param string $name The technical module name - * - * @return bool True is installed - */ - public function isInstalled($name) - { - return $this->moduleProvider->isInstalled($name); - } - - /** - * Shortcut to the module data provider in order to know the module id depends - * on its name. - * - * @param string $name The technical module name - * - * @return int the Module Id, or 0 if not found - */ - public function getModuleIdByName($name) - { - return $this->moduleProvider->getModuleIdByName($name); - } - - /** - * Shortcut to the module data updater to remove the module from the disk. - * - * @param string $name The technical module name - * - * @return bool True if files were properly removed - */ - public function removeModuleFromDisk($name) - { - return $this->moduleUpdater->removeModuleFromDisk($name); - } - - /** - * Returns the last error, if found. - * - * @param string $name The technical module name - * - * @return string|null The last error added to the module if found - */ - public function getError($name) - { - $message = null; - $module = $this->moduleRepository->getModule($name); - if ($module->hasValidInstance()) { - $errors = $module->getInstance()->getErrors(); - $message = array_pop($errors); - } else { - // Invalid instance: Missing or with syntax error - $message = $this->translator->trans( - 'The module is invalid and cannot be loaded.', - [], - 'Admin.Modules.Notification' - ); - } - - if (empty($message)) { - $message = $this->translator->trans( - 'Unfortunately, the module did not return additional details.', - [], - 'Admin.Modules.Notification' - ); - } - - return $message; - } - - /** - * This function is a refacto of the event dispatching. - * - * @param string $event - * @param \PrestaShop\PrestaShop\Core\Addon\Module\Module $module - */ - private function dispatch($event, $module) - { - $this->eventDispatcher->dispatch($event, new ModuleManagementEvent($module)); - } - - private function checkIsInstalled($name) - { - if (!$this->moduleProvider->isInstalled($name)) { - throw new Exception($this->translator->trans('The module %module% must be installed first', ['%module%' => $name], 'Admin.Modules.Notification')); - } - } - - /** - * We check the module does not ask for pre-requisites to be respected prior the action being executed. - * - * @param string $action - * @param Module $module - * - * @throws UnconfirmedModuleActionException - */ - private function checkConfirmationGiven($action, Module $module) - { - if ($action === 'install') { - if ($module->attributes->has('prestatrust') && !$this->actionParams->has('confirmPrestaTrust')) { - throw (new UnconfirmedModuleActionException())->setModule($module)->setAction($action)->setSubject('PrestaTrust'); - } - } - } - - /** - * @param bool $result - */ - private function checkAndClearCache($result) - { - if ($result && $this->actionParams->get('cacheClearEnabled', true)) { - $this->clearCache(); - } - } - - /** - * Clear smarty and Symfony cache (the sf2 cache is remove on the process shutdown). - */ - private function clearCache() - { - if ($this->cacheCleared) { - return; - } - - $this->symfonyCacheClearer->clear(); - $this->cacheCleared = true; - } -} diff --git a/src/Core/Addon/Module/ModuleManagerBuilder.php b/src/Core/Addon/Module/ModuleManagerBuilder.php deleted file mode 100644 index 8f267264..00000000 --- a/src/Core/Addon/Module/ModuleManagerBuilder.php +++ /dev/null @@ -1,256 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Module; - -use Context; -use Db; -use Doctrine\Common\Cache\FilesystemCache; -use GuzzleHttp\Client; -use PrestaShop\PrestaShop\Adapter\Addons\AddonsDataProvider; -use PrestaShop\PrestaShop\Adapter\Cache\Clearer; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use PrestaShop\PrestaShop\Adapter\LegacyLogger; -use PrestaShop\PrestaShop\Adapter\Module\AdminModuleDataProvider; -use PrestaShop\PrestaShop\Adapter\Module\ModuleDataProvider; -use PrestaShop\PrestaShop\Adapter\Module\ModuleDataUpdater; -use PrestaShop\PrestaShop\Adapter\Module\ModuleZipManager; -use PrestaShop\PrestaShop\Adapter\SymfonyContainer; -use PrestaShop\PrestaShop\Adapter\Tools; -use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeManagerBuilder; -use PrestaShop\PrestaShop\Core\Util\File\YamlParser; -use PrestaShopBundle\Event\Dispatcher\NullDispatcher; -use PrestaShopBundle\Service\DataProvider\Admin\CategoriesProvider; -use PrestaShopBundle\Service\DataProvider\Marketplace\ApiClient; -use Symfony\Component\Config\FileLocator; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Routing\Loader\YamlFileLoader; -use Symfony\Component\Routing\Router; - -class ModuleManagerBuilder -{ - /** - * Singleton of ModuleRepository. - * - * @var ModuleRepository - */ - public static $modulesRepository = null; - /** - * Singleton of ModuleManager. - * - * @var ModuleManager - */ - public static $moduleManager = null; - public static $adminModuleDataProvider = null; - public static $lecacyContext; - public static $legacyLogger = null; - public static $moduleDataProvider = null; - public static $moduleDataUpdater = null; - public static $moduleZipManager = null; - public static $translator = null; - public static $addonsDataProvider = null; - public static $categoriesProvider = null; - public static $instance = null; - public static $cacheProvider = null; - - /** - * @return ModuleManagerBuilder|null - */ - public static function getInstance() - { - if (self::$instance == null) { - self::$instance = new self(); - } - - return self::$instance; - } - - /** - * Returns an instance of ModuleManager. - * - * @return ModuleManager - */ - public function build() - { - if (null === self::$moduleManager) { - $sfContainer = SymfonyContainer::getInstance(); - if (null !== $sfContainer) { - self::$moduleManager = $sfContainer->get('prestashop.module.manager'); - } else { - self::$moduleManager = new ModuleManager( - self::$adminModuleDataProvider, - self::$moduleDataProvider, - self::$moduleDataUpdater, - $this->buildRepository(), - self::$moduleZipManager, - self::$translator, - new NullDispatcher(), - new Clearer\SymfonyCacheClearer() - ); - } - } - - return self::$moduleManager; - } - - /** - * Returns an instance of ModuleRepository. - * - * @return ModuleRepository - */ - public function buildRepository() - { - if (null === self::$modulesRepository) { - $sfContainer = SymfonyContainer::getInstance(); - if (null !== $sfContainer) { - self::$modulesRepository = $sfContainer->get('prestashop.core.admin.module.repository'); - } else { - self::$modulesRepository = new ModuleRepository( - self::$adminModuleDataProvider, - self::$moduleDataProvider, - self::$moduleDataUpdater, - self::$legacyLogger, - self::$translator, - _PS_MODULE_DIR_, - self::$cacheProvider - ); - } - } - - return self::$modulesRepository; - } - - private function __construct() - { - /** - * If the Symfony container is available, it will be used for the other methods - * build & buildRepository. No need to init manually all the dependancies. - */ - $sfContainer = SymfonyContainer::getInstance(); - if (null !== $sfContainer) { - return; - } - - $yamlParser = new YamlParser((new Configuration())->get('_PS_CACHE_DIR_')); - - $config = $yamlParser->parse($this->getConfigDir() . '/config.yml'); - $prestashopAddonsConfig = - $yamlParser->parse($this->getConfigDir() . '/addons/categories.yml'); - - $clientConfig = $config['csa_guzzle']['clients']['addons_api']['config']; - - self::$translator = Context::getContext()->getTranslator(); - - $marketPlaceClient = new ApiClient( - new Client($clientConfig), - self::$translator->getLocale(), - $this->getCountryIso(), - new Tools(), - (new Configuration())->get('_PS_BASE_URL_'), - \AppKernel::VERSION - ); - - $marketPlaceClient->setSslVerification(_PS_CACHE_CA_CERT_FILE_); - if (file_exists($this->getConfigDir() . '/parameters.php')) { - $parameters = require $this->getConfigDir() . '/parameters.php'; - if (array_key_exists('addons.api_client.verify_ssl', $parameters['parameters'])) { - $marketPlaceClient->setSslVerification($parameters['parameters']['addons.api_client.verify_ssl']); - } - } - - self::$moduleZipManager = new ModuleZipManager(new Filesystem(), self::$translator, new NullDispatcher()); - self::$addonsDataProvider = new AddonsDataProvider($marketPlaceClient, self::$moduleZipManager); - - $kernelDir = realpath($this->getConfigDir() . '/../../var'); - self::$addonsDataProvider->cacheDir = $kernelDir . '/cache/prod'; - if (_PS_MODE_DEV_) { - self::$addonsDataProvider->cacheDir = $kernelDir . '/cache/dev'; - } - - self::$cacheProvider = new FilesystemCache(self::$addonsDataProvider->cacheDir . '/doctrine'); - - $themeManagerBuilder = new ThemeManagerBuilder(Context::getContext(), Db::getInstance()); - $themeName = Context::getContext()->shop->theme_name; - $themeModules = $themeName ? - $themeManagerBuilder->buildRepository()->getInstanceByName($themeName)->getModulesToEnable() : - []; - - self::$legacyLogger = new LegacyLogger(); - self::$categoriesProvider = new CategoriesProvider( - $prestashopAddonsConfig['prestashop']['addons']['categories'], - $themeModules - ); - self::$lecacyContext = new LegacyContext(); - - if (null === self::$adminModuleDataProvider) { - self::$moduleDataProvider = new ModuleDataProvider(self::$legacyLogger, self::$translator); - self::$adminModuleDataProvider = new AdminModuleDataProvider( - self::$translator, - self::$legacyLogger, - self::$addonsDataProvider, - self::$categoriesProvider, - self::$moduleDataProvider, - self::$cacheProvider, - Context::getContext()->employee - ); - self::$adminModuleDataProvider->setRouter($this->getSymfonyRouter()); - - self::$translator = Context::getContext()->getTranslator(); - self::$moduleDataUpdater = new ModuleDataUpdater(self::$addonsDataProvider, self::$adminModuleDataProvider); - } - } - - /** - * Returns an instance of \Symfony\Component\Routing\Router from Symfony scope into Legacy. - * - * @return \Symfony\Component\Routing\Router - */ - private function getSymfonyRouter() - { - // get the environment to load the good routing file - $routeFileName = _PS_MODE_DEV_ === true ? 'routing_dev.yml' : 'routing.yml'; - $routesDirectory = $this->getConfigDir(); - $locator = new FileLocator([$routesDirectory]); - $loader = new YamlFileLoader($locator); - - return new Router($loader, $routeFileName); - } - - protected function getConfigDir() - { - return _PS_ROOT_DIR_ . '/app/config'; - } - - /** - * Returns country iso from context. - */ - private function getCountryIso() - { - return \CountryCore::getIsoById(\Configuration::get('PS_COUNTRY_DEFAULT')); - } -} diff --git a/src/Core/Addon/Module/ModuleRepository.php b/src/Core/Addon/Module/ModuleRepository.php deleted file mode 100644 index 3de308f7..00000000 --- a/src/Core/Addon/Module/ModuleRepository.php +++ /dev/null @@ -1,645 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Module; - -use Doctrine\Common\Cache\ArrayCache; -use Doctrine\Common\Cache\CacheProvider; -use Exception; -use Module as LegacyModule; -use PrestaShop\PrestaShop\Adapter\Module\AdminModuleDataProvider; -use PrestaShop\PrestaShop\Adapter\Module\Module; -use PrestaShop\PrestaShop\Adapter\Module\ModuleDataProvider; -use PrestaShop\PrestaShop\Adapter\Module\ModuleDataUpdater; -use PrestaShop\PrestaShop\Adapter\Module\PrestaTrust\PrestaTrustChecker; -use PrestaShop\PrestaShop\Core\Addon\AddonListFilter; -use PrestaShop\PrestaShop\Core\Addon\AddonListFilterOrigin; -use PrestaShop\PrestaShop\Core\Addon\AddonListFilterStatus; -use PrestaShop\PrestaShop\Core\Addon\AddonListFilterType; -use PrestaShop\PrestaShop\Core\Addon\AddonsCollection; -use Psr\Log\LoggerInterface; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Translation\TranslatorInterface; - -class ModuleRepository implements ModuleRepositoryInterface -{ - const NATIVE_AUTHOR = 'PrestaShop'; - - const PARTNER_AUTHOR = 'PrestaShop Partners'; - - /** - * Admin Module Data Provider. - * - * @var \PrestaShop\PrestaShop\Adapter\Module\AdminModuleDataProvider - */ - private $adminModuleProvider; - - /** - * Logger. - * - * @var \Psr\Log\LoggerInterface - */ - private $logger; - - /** - * Module Data Provider. - * - * @var \PrestaShop\PrestaShop\Adapter\Module\ModuleDataProvider - */ - private $moduleProvider; - - /** - * Module Data Updater. - * - * @var \PrestaShop\PrestaShop\Adapter\Module\ModuleDataUpdater - */ - private $moduleUpdater; - - /** - * Translator. - * - * @var \Symfony\Component\Translation\TranslatorInterface - */ - private $translator; - - /** - * Path to the module directory, coming from Confiuration class. - * - * @var string - */ - private $modulePath; - - /** - * @var PrestaTrustChecker - */ - private $prestaTrustChecker = null; - - //### CACHE PROPERTIES #### - - /** - * Key of the cache content. - * - * @var string - */ - private $cacheFilePath; - - /** - * Contains data from cache file about modules on disk. - * - * @var array - */ - private $cache = []; - - /** - * Optionnal Doctrine cache provider. - * - * @var \Doctrine\Common\Cache\CacheProvider - */ - private $cacheProvider; - - /** - * Keep loaded modules in cache. - * - * @var ArrayCache - */ - private $loadedModules; - - //### END OF CACHE PROPERTIES #### - - public function __construct( - AdminModuleDataProvider $adminModulesProvider, - ModuleDataProvider $modulesProvider, - ModuleDataUpdater $modulesUpdater, - LoggerInterface $logger, - TranslatorInterface $translator, - $modulePath, - CacheProvider $cacheProvider = null - ) { - $this->adminModuleProvider = $adminModulesProvider; - $this->logger = $logger; - $this->moduleProvider = $modulesProvider; - $this->moduleUpdater = $modulesUpdater; - $this->translator = $translator; - $this->finder = new Finder(); - $this->modulePath = $modulePath; - - list($isoLang) = explode('-', $translator->getLocale()); - - // Cache related variables - $this->cacheFilePath = $isoLang . '_local_modules'; - $this->cacheProvider = $cacheProvider; - $this->loadedModules = new ArrayCache(); - - if ($this->cacheProvider && $this->cacheProvider->contains($this->cacheFilePath)) { - $this->cache = $this->cacheProvider->fetch($this->cacheFilePath); - } - } - - /** - * Setter for the optional PrestaTrust checker. - * - * @param PrestaTrustChecker $checker - * - * @return $this - */ - public function setPrestaTrustChecker(PrestaTrustChecker $checker) - { - $this->prestaTrustChecker = $checker; - - return $this; - } - - public function __destruct() - { - if ($this->cacheProvider) { - $this->cacheProvider->save($this->cacheFilePath, $this->cache); - } - } - - public function clearCache() - { - if ($this->cacheProvider) { - $this->cacheProvider->delete($this->cacheFilePath); - } - $this->cache = []; - } - - /** - * Get the **Legacy** Module object from its name. - * - * @param string $name The technical module name to instanciate - * - * @return \Module|null Instance of legacy Module, if valid - */ - public function getInstanceByName($name) - { - // Return legacy instance ! - return $this->getModule($name)->getInstance(); - } - - /** - * @param AddonListFilter $filter - * @param bool $skip_main_class_attributes - * - * @return AddonInterface[] retrieve a list of addons, regarding the $filter used - */ - public function getFilteredList(AddonListFilter $filter, $skip_main_class_attributes = false) - { - if ($filter->status >= AddonListFilterStatus::ON_DISK - && $filter->status != AddonListFilterStatus::ALL) { - $modules = $this->getModulesOnDisk($skip_main_class_attributes); - } else { - $modules = $this->getList(); - } - - foreach ($modules as $key => &$module) { - // Part One : Removing addons not related to the selected product type - if ($filter->type != AddonListFilterType::ALL) { - if ($module->attributes->get('productType') == 'module') { - $productType = AddonListFilterType::MODULE; - } - if ($module->attributes->get('productType') == 'service') { - $productType = AddonListFilterType::SERVICE; - } - if (!isset($productType) || $productType & ~$filter->type) { - unset($modules[$key]); - - continue; - } - } - - // Part Two : Remove module not installed if specified - if ($filter->status != AddonListFilterStatus::ALL) { - if ($module->database->get('installed') == 1 - && ($filter->hasStatus(AddonListFilterStatus::UNINSTALLED) - || !$filter->hasStatus(AddonListFilterStatus::INSTALLED))) { - unset($modules[$key]); - - continue; - } - - if ($module->database->get('installed') == 0 - && (!$filter->hasStatus(AddonListFilterStatus::UNINSTALLED) - || $filter->hasStatus(AddonListFilterStatus::INSTALLED))) { - unset($modules[$key]); - - continue; - } - - if ($module->database->get('installed') == 1 - && $module->database->get('active') == 1 - && !$filter->hasStatus(AddonListFilterStatus::DISABLED) - && $filter->hasStatus(AddonListFilterStatus::ENABLED)) { - unset($modules[$key]); - - continue; - } - - if ($module->database->get('installed') == 1 - && $module->database->get('active') == 0 - && !$filter->hasStatus(AddonListFilterStatus::ENABLED) - && $filter->hasStatus(AddonListFilterStatus::DISABLED)) { - unset($modules[$key]); - - continue; - } - } - - // Part Three : Remove addons not related to the proper source (ex Addons) - if ($filter->origin != AddonListFilterOrigin::ALL) { - if (!$module->attributes->has('origin_filter_value') && - !$filter->hasOrigin(AddonListFilterOrigin::DISK) - ) { - unset($modules[$key]); - - continue; - } - if ($module->attributes->has('origin_filter_value') && - !$filter->hasOrigin($module->attributes->get('origin_filter_value')) - ) { - unset($modules[$key]); - - continue; - } - } - } - - return $modules; - } - - /** - * @return AddonInterface[] retrieve the universe of Modules - */ - public function getList() - { - return array_merge( - $this->getAddonsCatalogModules(), - $this->getModulesOnDisk() - ); - } - - /** - * @return AddonInterface[] retrieve the list of native modules - */ - public function getNativeModules() - { - static $nativeModules = null; - - if (null === $nativeModules) { - $filter = new AddonListFilter(); - $filter->setOrigin(AddonListFilterOrigin::ADDONS_NATIVE); - - $nativeModules = $this->getFilteredList($filter); - - foreach ($nativeModules as $key => $module) { - $moduleAuthor = $module->attributes->get('author'); - if (self::NATIVE_AUTHOR !== $moduleAuthor) { - unset($nativeModules[$key]); - } - } - } - - return $nativeModules; - } - - /** - * @return AddonInterface[] retrieve the list of partners modules - */ - public function getPartnersModules() - { - $filter = new AddonListFilter(); - $filter->setOrigin(AddonListFilterOrigin::ADDONS_NATIVE); - - $partnersModules = $this->getFilteredList($filter); - - foreach ($partnersModules as $key => $module) { - $moduleAuthor = $module->attributes->get('author'); - if (self::PARTNER_AUTHOR !== $moduleAuthor) { - unset($partnersModules[$key]); - } - } - - return $partnersModules; - } - - /** - * @return AddonInterface[] get the list of installed partners modules - */ - public function getInstalledPartnersModules() - { - $partnersModules = $this->getPartnersModules(); - - foreach ($partnersModules as $key => $module) { - if (1 !== $module->database->get('installed')) { - unset($partnersModules[$key]); - } - } - - return $partnersModules; - } - - /** - * @return AddonInterface[] get the list of not installed partners modules - */ - public function getNotInstalledPartnersModules() - { - $partnersModules = $this->getPartnersModules(); - - foreach ($partnersModules as $key => $module) { - if (0 !== $module->database->get('installed')) { - unset($partnersModules[$key]); - } - } - - return $partnersModules; - } - - private function getAddonsCatalogModules() - { - $modules = []; - foreach ($this->adminModuleProvider->getCatalogModulesNames() as $name) { - try { - $module = $this->getModule($name); - if ($module instanceof Module) { - $modules[$name] = $module; - } - } catch (\ParseError $e) { - $this->logger->critical( - $this->translator->trans( - 'Parse error on module %module%. %error_details%', - [ - '%module%' => $name, - '%error_details%' => $e->getMessage(), - ], - 'Admin.Modules.Notification' - ) - ); - } catch (Exception $e) { - $this->logger->critical( - $this->translator->trans( - 'Unexpected exception on module %module%. %error_details%', - [ - '%module%' => $name, - '%error_details%' => $e->getMessage(), - ], - 'Admin.Modules.Notification' - ) - ); - } - } - - return $modules; - } - - /** - * Get the new module presenter class of the specified name provided. - * It contains data from its instance, the disk, the database and from the marketplace if exists. - * - * @param string $name The technical name of the module - * @param bool $skip_main_class_attributes - * - * @return Module - */ - public function getModule($name, $skip_main_class_attributes = false) - { - if ($this->loadedModules->contains($name)) { - return $this->loadedModules->fetch($name); - } - - $path = $this->modulePath . $name; - $php_file_path = $path . '/' . $name . '.php'; - - /* Data which design the module class */ - $attributes = ['name' => $name]; - - // Get filemtime of module main class (We do this directly with an error suppressor to go faster) - $current_filemtime = (int) @filemtime($php_file_path); - - // We check that we have data from the marketplace - try { - $module_catalog_data = $this->adminModuleProvider->getCatalogModules(['name' => $name]); - $attributes = array_merge( - $attributes, - (array) array_shift($module_catalog_data) - ); - } catch (Exception $e) { - $this->logger->alert( - $this->translator->trans( - 'Loading data from Addons failed. %error_details%', - ['%error_details%' => $e->getMessage()], - 'Admin.Modules.Notification' - ) - ); - } - - // Now, we check that cache is up to date - if (isset($this->cache[$name]['disk']['filemtime']) && - $this->cache[$name]['disk']['filemtime'] === $current_filemtime - ) { - // OK, cache can be loaded and used directly - - $attributes = array_merge($attributes, $this->cache[$name]['attributes']); - $disk = $this->cache[$name]['disk']; - } else { - // NOPE, we have to fulfil the cache with the module data - - $disk = [ - 'filemtime' => $current_filemtime, - 'is_present' => (int) $this->moduleProvider->isOnDisk($name), - 'is_valid' => 0, - 'version' => null, - 'path' => $path, - ]; - $main_class_attributes = []; - - if (!$skip_main_class_attributes && $this->moduleProvider->isModuleMainClassValid($name)) { - // We load the main class of the module, and get its properties - $tmp_module = LegacyModule::getInstanceByName($name); - foreach (['warning', 'name', 'tab', 'displayName', 'description', 'author', 'author_address', - 'limited_countries', 'need_instance', 'confirmUninstall', ] as $data_to_get) { - if (isset($tmp_module->{$data_to_get})) { - $main_class_attributes[$data_to_get] = $tmp_module->{$data_to_get}; - } - } - - $main_class_attributes['parent_class'] = get_parent_class($name); - $main_class_attributes['is_paymentModule'] = is_subclass_of($name, 'PaymentModule'); - $main_class_attributes['is_configurable'] = (int) method_exists($tmp_module, 'getContent'); - - $disk['is_valid'] = 1; - $disk['version'] = $tmp_module->version; - - $attributes = array_merge($attributes, $main_class_attributes); - } elseif (!$skip_main_class_attributes) { - $main_class_attributes['warning'] = 'Invalid module class'; - } else { - $disk['is_valid'] = 1; - } - - $this->cache[$name]['attributes'] = $main_class_attributes; - $this->cache[$name]['disk'] = $disk; - } - - // Get data from database - $database = $this->moduleProvider->findByName($name); - - $module = new Module($attributes, $disk, $database); - $this->loadedModules->save($name, $module); - if ($this->prestaTrustChecker) { - $this->prestaTrustChecker->loadDetailsIntoModule($module); - } - - return $module; - } - - public function getModuleAttributes($name) - { - $module = $this->getModule($name); - - return $module->attributes; - } - - /** - * Send request to get module details on the marketplace, then merge the data received in Module instance. - * - * @param $moduleId - * - * @return Module - */ - public function getModuleById($moduleId) - { - $moduleAttributes = $this->adminModuleProvider->getModuleAttributesById($moduleId); - - $module = $this->getModule($moduleAttributes['name']); - - foreach ($moduleAttributes as $name => $value) { - if (!$module->attributes->has($name)) { - $module->attributes->set($name, $value); - } - } - - return $module; - } - - /** - * Instanciate every module present in the modules folder. - * - * @param bool $skip_main_class_attributes - * - * @return \PrestaShop\PrestaShop\Adapter\Module\Module[] - */ - private function getModulesOnDisk($skip_main_class_attributes = false) - { - $modules = []; - $modulesDirsList = $this->finder->directories() - ->in($this->modulePath) - ->depth('== 0') - ->exclude(['__MACOSX']) - ->ignoreVCS(true); - - foreach ($modulesDirsList as $moduleDir) { - $moduleName = $moduleDir->getFilename(); - if (!file_exists($this->modulePath . $moduleName . '/' . $moduleName . '.php')) { - continue; - } - - try { - $module = $this->getModule($moduleName, $skip_main_class_attributes); - if ($module instanceof Module) { - $modules[$moduleName] = $module; - } - } catch (\ParseError $e) { - $this->logger->critical( - $this->translator->trans( - 'Parse error detected in module %module%. %error_details%.', - [ - '%module%' => $moduleName, - '%error_details%' => $e->getMessage(), ], - 'Admin.Modules.Notification' - ) - ); - } catch (Exception $e) { - $this->logger->critical( - $this->translator->trans( - 'Exception detected while loading module %module%. %error_details%.', - [ - '%module%' => $moduleName, - '%error_details%' => $e->getMessage(), ], - 'Admin.Modules.Notification' - ) - ); - } - } - - return $modules; - } - - /** - * Function loading all installed modules on the shop. Can be used as example for AddonListFilter use. - * - * @return array - */ - public function getInstalledModules() - { - $filters = new AddonListFilter(); - $filters->setType(AddonListFilterType::MODULE | AddonListFilterType::SERVICE) - ->setStatus(AddonListFilterStatus::INSTALLED); - - return $this->getFilteredList($filters); - } - - /** - * Gets all installed modules as a collection. - * - * @return AddonsCollection - */ - public function getInstalledModulesCollection() - { - $installedModules = $this->getInstalledModules(); - - return AddonsCollection::createFrom($installedModules); - } - - /** - * Returns installed module filepaths. - * - * @return array - */ - public function getInstalledModulesPaths() - { - $paths = []; - $modulesFiles = Finder::create()->directories()->in(__DIR__ . '/../../../../modules')->depth(0); - $installedModules = array_keys($this->getInstalledModules()); - - foreach ($modulesFiles as $moduleFile) { - if (in_array($moduleFile->getFilename(), $installedModules)) { - $paths[] = $moduleFile->getPathname(); - } - } - - return $paths; - } -} diff --git a/src/Core/Addon/Module/ModuleRepositoryInterface.php b/src/Core/Addon/Module/ModuleRepositoryInterface.php deleted file mode 100644 index 3712c2fa..00000000 --- a/src/Core/Addon/Module/ModuleRepositoryInterface.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Module; - -use PrestaShop\PrestaShop\Core\Addon\AddonListFilter; -use PrestaShop\PrestaShop\Core\Addon\AddonRepositoryInterface; - -interface ModuleRepositoryInterface extends AddonRepositoryInterface -{ - /** - * Get the **Legacy** Module object from its name - * Used for retrocompatibility. - * - * @param string $name The technical module name to instanciate - * - * @return \Module|null Instance of legacy Module, if valid - */ - public function getInstanceByName($name); - - /** - * @param AddonListFilter $filter - * - * @return AddonInterface[] retrieve a list of addons, regarding the $filter used - */ - public function getFilteredList(AddonListFilter $filter); - - /** - * @return AddonInterface[] retrieve a list of addons, regardless any $filter - */ - public function getList(); - - /** - * Get the new module presenter class of the specified name provided. - * It contains data from its instance, the disk, the database and from the marketplace if exists. - * - * @param string $name The technical name of the module - * - * @return \PrestaShop\PrestaShop\Adapter\Module\Module - */ - public function getModule($name); -} diff --git a/src/Core/Addon/Theme/Exception/ThemeAlreadyExistsException.php b/src/Core/Addon/Theme/Exception/ThemeAlreadyExistsException.php deleted file mode 100644 index 59c52d64..00000000 --- a/src/Core/Addon/Theme/Exception/ThemeAlreadyExistsException.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Theme\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Class ThemeAlreadyExistsException - */ -class ThemeAlreadyExistsException extends CoreException -{ - /** - * @var string - */ - private $themeName; - - /** - * @param string $themeName - * @param string $message - * @param int $code - * @param null $previous - */ - public function __construct($themeName, $message = '', $code = 0, $previous = null) - { - parent::__construct($message, $code, $previous); - - $this->themeName = $themeName; - } - - /** - * @return string - */ - public function getThemeName() - { - return $this->themeName; - } -} diff --git a/src/Core/Addon/Theme/Exception/ThemeUploadException.php b/src/Core/Addon/Theme/Exception/ThemeUploadException.php deleted file mode 100644 index 1c4fedda..00000000 --- a/src/Core/Addon/Theme/Exception/ThemeUploadException.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Theme\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Class ThemeUploadException - */ -class ThemeUploadException extends CoreException -{ - const FILE_SIZE_EXCEEDED_ERROR = 1; - const UNKNOWN_ERROR = 2; - const INVALID_MIME_TYPE = 3; - const FAILED_TO_MOVE_FILE = 4; -} diff --git a/src/Core/Addon/Theme/Theme.php b/src/Core/Addon/Theme/Theme.php deleted file mode 100644 index bc8e1c54..00000000 --- a/src/Core/Addon/Theme/Theme.php +++ /dev/null @@ -1,257 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Theme; - -use AbstractAssetManager; -use PrestaShop\PrestaShop\Core\Addon\AddonInterface; -use Shudrum\Component\ArrayFinder\ArrayFinder; -use Symfony\Component\Yaml\Yaml; - -class Theme implements AddonInterface -{ - private $attributes; - - public function __construct(array $attributes) - { - if (isset($attributes['parent'])) { - $parentAttributes = Yaml::parse(file_get_contents(_PS_ALL_THEMES_DIR_ . '/' . $attributes['parent'] . '/config/theme.yml')); - $parentAttributes['preview'] = 'themes/' . $attributes['parent'] . '/preview.png'; - $parentAttributes['parent_directory'] = rtrim($attributes['directory'], '/') . '/'; - $attributes = array_merge($parentAttributes, $attributes); - } - - $attributes['directory'] = rtrim($attributes['directory'], '/') . '/'; - - if (file_exists(_PS_ALL_THEMES_DIR_ . $attributes['name'] . '/preview.png')) { - $attributes['preview'] = 'themes/' . $attributes['name'] . '/preview.png'; - } - - $this->attributes = new ArrayFinder($attributes); - } - - public function get($attr = null, $default = null) - { - return $this->attributes->get($attr, $default); - } - - public function has($attr) - { - return $this->attributes->offsetExists($attr); - } - - public function getName() - { - return $this->attributes->get('name'); - } - - public function getDirectory() - { - return $this->attributes->get('directory'); - } - - public function getModulesToEnable() - { - $modulesToEnable = $this->get('global_settings.modules.to_enable', []); - $modulesToHook = $this->get('global_settings.hooks.modules_to_hook', []); - - foreach ($modulesToHook as $hookName => $modules) { - if (is_array($modules)) { - foreach (array_values($modules) as $module) { - if (is_array($module)) { - $module = key($module); - } - if (null !== $module && !in_array($module, $modulesToEnable)) { - $modulesToEnable[] = $module; - } - } - } - } - - return $modulesToEnable; - } - - public function getModulesToDisable() - { - return $this->get('dependencies.modules', []); - } - - public function getPageSpecificAssets($pageId) - { - return [ - 'css' => $this->getPageSpecificCss($pageId), - 'js' => $this->getPageSpecificJs($pageId), - ]; - } - - public function onInstall() - { - return true; - } - - public function onUninstall() - { - return true; - } - - /** - * Execute up files. You can update configuration, update sql schema. - * No file modification. - * - * @return bool true for success - */ - public function onUpgrade($version) - { - return true; - } - - /** - * Called when switching the current theme of the selected shop. - * You can update configuration, enable/disable modules... - * - * @return bool true for success - */ - public function onEnable() - { - return true; - } - - /** - * Not necessarily the opposite of enable. Use this method if - * something must be done when switching to another theme (like uninstall - * very specific modules for example). - * - * @return bool true for success - */ - public function onDisable() - { - return true; - } - - public function onReset() - { - return true; - } - - public function setPageLayouts(array $layouts) - { - $this->attributes->set('theme_settings.layouts', $layouts); - } - - public function getDefaultLayout() - { - $availableLayouts = $this->getAvailableLayouts(); - $defaultLayoutIdentifier = $this->attributes->get('theme_settings.default_layout'); - $defaultLayout = $availableLayouts[$defaultLayoutIdentifier]; - - $defaultLayout['key'] = $defaultLayoutIdentifier; - - return $defaultLayout; - } - - public function getPageLayouts() - { - return $this->attributes->get('theme_settings.layouts'); - } - - public function getAvailableLayouts() - { - return $this->attributes->get('meta.available_layouts'); - } - - public function getLayoutNameForPage($page) - { - $layout_name = $this->get('theme_settings.default_layout'); - if (isset($this->attributes['theme_settings']['layouts'][$page]) - && $this->attributes['theme_settings']['layouts'][$page]) { - $layout_name = $this->attributes['theme_settings']['layouts'][$page]; - } - - return $layout_name; - } - - public function getLayoutRelativePathForPage($page) - { - return 'layouts/' . $this->getLayoutNameForPage($page) . '.tpl'; - } - - private function getPageSpecificCss($pageId) - { - $css = array_merge( - (array) $this->get('assets.css.all'), - (array) $this->get('assets.css.' . $pageId) - ); - foreach ($css as $key => &$entry) { - // Required parameters - if (!isset($entry['id']) || !isset($entry['path'])) { - unset($css[$key]); - - continue; - } - if (!isset($entry['media'])) { - $entry['media'] = AbstractAssetManager::DEFAULT_MEDIA; - } - if (!isset($entry['priority'])) { - $entry['priority'] = AbstractAssetManager::DEFAULT_PRIORITY; - } - if (!isset($entry['inline'])) { - $entry['inline'] = false; - } - } - - return $css; - } - - private function getPageSpecificJs($pageId) - { - $js = array_merge( - (array) $this->get('assets.js.all'), - (array) $this->get('assets.js.' . $pageId) - ); - foreach ($js as $key => &$entry) { - // Required parameters - if (!isset($entry['id']) || !isset($entry['path'])) { - unset($js[$key]); - - continue; - } - if (!isset($entry['position'])) { - $entry['position'] = AbstractAssetManager::DEFAULT_JS_POSITION; - } - if (!isset($entry['priority'])) { - $entry['priority'] = AbstractAssetManager::DEFAULT_PRIORITY; - } - if (!isset($entry['inline'])) { - $entry['inline'] = false; - } - if (!isset($entry['attribute'])) { - $entry['attribute'] = false; - } - } - - return $js; - } -} diff --git a/src/Core/Addon/Theme/ThemeCollection.php b/src/Core/Addon/Theme/ThemeCollection.php deleted file mode 100644 index ae969796..00000000 --- a/src/Core/Addon/Theme/ThemeCollection.php +++ /dev/null @@ -1,269 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Theme; - -use ArrayAccess; -use ArrayIterator; -use Countable; -use IteratorAggregate; -use PrestaShop\PrestaShop\Core\Addon\Theme as Addon; - -/** - * An ArrayCollection is a Collection implementation that wraps a regular PHP array. - */ -class ThemeCollection implements ArrayAccess, Countable, IteratorAggregate -{ - /** - * An array containing the addons of this collection. - * - * @var array - */ - private $addons; - - /** - * Initializes a new AddonsCollection. - * - * @param array $addons - */ - public function __construct(array $addons = []) - { - $this->addons = $addons; - } - - /** - * Creates a new instance from the specified elements. - * - * This method is provided for derived classes to specify how a new - * instance should be created when constructor semantics have changed. - * - * @param array $addons elements - * - * @return static - */ - public static function createFrom(array $addons) - { - return new static($addons); - } - - /** - * Gets a native PHP array representation of the collection. - * - * @return array - */ - public function toArray() - { - return $this->addons; - } - - /** - * @return ArrayIterator|\Traversable - */ - public function getIterator() - { - return new ArrayIterator($this->addons); - } - - /** - * {@inheritdoc} - */ - public function offsetExists($offset) - { - return $this->containsKey($offset); - } - - /** - * {@inheritdoc} - */ - public function offsetGet($offset) - { - return $this->get($offset); - } - - /** - * Required by ArrayAccess interface. - * - * {@inheritdoc} - */ - public function offsetSet($offset, $addon) - { - if (!isset($offset)) { - $this->add($addon); - - return; - } - - $this->set($offset, $addon); - } - - /** - * Required by interface ArrayAccess. - * - * {@inheritdoc} - */ - public function offsetUnset($offset) - { - $this->remove($offset); - } - - /** - * Returns true if the key is found in the collection. - * - * @param mixed $key the key, can be integer or string - * - * @return bool - */ - public function containsKey($key) - { - return isset($this->addons[$key]) || array_key_exists($key, $this->addons); - } - - /** - * Returns true if the addon is found in the collection. - * - * @param Addon $addon the addon - * - * @return bool - */ - public function contains(Addon $addon) - { - return in_array($addon, $this->addons, true); - } - - /** - * {@inheritdoc} - */ - public function indexOf(Addon $addon) - { - return array_search($addon, $this->addons, true); - } - - /** - * {@inheritdoc} - */ - public function get($key) - { - return $this->addons[$key] ? $this->addons[$key] : null; - } - - /** - * {@inheritdoc} - */ - public function getKeys() - { - return array_keys($this->addons); - } - - /** - * {@inheritdoc} - */ - public function getValues() - { - return array_values($this->addons); - } - - /** - * Add an Addon with a specified key in the collection. - * - * @param mixed $key the key - * @param Addon $addon the specified addon - */ - public function set($key, Addon $addon) - { - $this->addons[$key] = $addon; - } - - /** - * Add an Addon in the collection. - * - * @param Addon $addon the specified addon - * - * @return bool - */ - public function add(Addon $addon) - { - $this->addons[] = $addon; - - return true; - } - - /** - * Remove an addon from the collection by key. - * - * @param mixed the key (can be int or string) - * - * @return bool true if the addon has been found and removed - */ - public function removeByKey($key) - { - if (!isset($this->addons[$key]) && !array_key_exists($key, $this->addons)) { - return null; - } - - $removed = $this->addons[$key]; - unset($this->addons[$key]); - - return $removed; - } - - /** - * Remove an addon from the collection by key. - * - * @param Addon $addon the addon to be removed - * - * @return bool true if the addon has been found and removed - */ - public function remove(Addon $addon) - { - $key = array_search($addon, $this->addons, true); - - if ($key === false) { - return false; - } - - unset($this->addons[$key]); - - return true; - } - - /** - * {@inheritdoc} - */ - public function isEmpty() - { - return empty($this->addons); - } - - /** - * Gets the sum of addons of the collection. - * - * @return int - */ - public function count() - { - return count($this->addons); - } -} diff --git a/src/Core/Addon/Theme/ThemeExporter.php b/src/Core/Addon/Theme/ThemeExporter.php deleted file mode 100644 index cc14c122..00000000 --- a/src/Core/Addon/Theme/ThemeExporter.php +++ /dev/null @@ -1,141 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Theme; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShopBundle\Entity\Repository\LangRepository; -use PrestaShopBundle\Translation\Exporter\ThemeExporter as TranslationsExporter; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Finder\Finder; -use ZipArchive; - -class ThemeExporter -{ - protected $configuration; - protected $fileSystem; - protected $langRepository; - protected $translationsExporter; - - public function __construct( - ConfigurationInterface $configuration, - Filesystem $fileSystem, - LangRepository $langRepository, - TranslationsExporter $translationsExporter - ) { - $this->configuration = $configuration; - $this->fileSystem = $fileSystem; - $this->langRepository = $langRepository; - $this->translationsExporter = $translationsExporter; - } - - public function export(Theme $theme) - { - $cacheDir = $this->configuration->get('_PS_CACHE_DIR_') . 'export-' . $theme->getName() . '-' . time() . DIRECTORY_SEPARATOR; - - $this->copyTheme($theme->getDirectory(), $cacheDir); - $this->copyModuleDependencies((array) $theme->get('dependencies.modules'), $cacheDir); - $this->copyTranslations($theme, $cacheDir); - - $finalFile = $this->configuration->get('_PS_ALL_THEMES_DIR_') . DIRECTORY_SEPARATOR . $theme->getName() . '.zip'; - $this->createZip($cacheDir, $finalFile); - - $this->fileSystem->remove($cacheDir); - - return realpath($finalFile); - } - - private function copyTheme($themeDir, $cacheDir) - { - $fileList = Finder::create() - ->files() - ->in($themeDir) - ->exclude(['node_modules']); - - $this->fileSystem->mirror($themeDir, $cacheDir, $fileList); - } - - private function copyModuleDependencies(array $moduleList, $cacheDir) - { - if (empty($moduleList)) { - return; - } - - $dependencyDir = $cacheDir . '/dependencies/modules/'; - $this->fileSystem->mkdir($dependencyDir); - $moduleDir = $this->configuration->get('_PS_MODULE_DIR_'); - - foreach ($moduleList as $moduleName) { - $this->fileSystem->mirror($moduleDir . $moduleName, $dependencyDir . $moduleName); - } - } - - /** - * @param Theme $theme - * @param $cacheDir - */ - protected function copyTranslations(Theme $theme, $cacheDir) - { - $translationsDir = $cacheDir . 'translations'; - - $this->fileSystem->remove($translationsDir); - $this->fileSystem->mkdir($translationsDir); - - $languages = $this->langRepository->findAll(); - if (count($languages) > 0) { - /* - * @var \PrestaShopBundle\Entity\Lang - */ - foreach ($languages as $lang) { - $locale = $lang->getLocale(); - $catalogueDir = $this->translationsExporter->exportCatalogues($theme->getName(), $locale); - } - - $catalogueDirParts = explode(DIRECTORY_SEPARATOR, $catalogueDir); - array_pop($catalogueDirParts); // Remove locale - - $cataloguesDir = implode(DIRECTORY_SEPARATOR, $catalogueDirParts); - $this->fileSystem->mirror($cataloguesDir, $translationsDir); - } - } - - private function createZip($sourceDir, $destinationFileName) - { - $zip = new ZipArchive(); - $zip->open($destinationFileName, ZipArchive::CREATE); - - $files = Finder::create() - ->files() - ->in($sourceDir) - ->exclude(['node_modules']); - - foreach ($files as $file) { - $zip->addFile($file->getRealpath(), $file->getRelativePathName()); - } - - return $zip->close(); - } -} diff --git a/src/Core/Addon/Theme/ThemeManager.php b/src/Core/Addon/Theme/ThemeManager.php deleted file mode 100644 index 2bc9a12c..00000000 --- a/src/Core/Addon/Theme/ThemeManager.php +++ /dev/null @@ -1,603 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Theme; - -use Employee; -use ErrorException; -use Exception; -use Language; -use PrestaShop\PrestaShop\Core\Addon\AddonManagerInterface; -use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder; -use PrestaShop\PrestaShop\Core\Addon\Theme\Exception\ThemeAlreadyExistsException; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\FailedToEnableThemeModuleException; -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\ThemeConstraintException; -use PrestaShop\PrestaShop\Core\Exception\FileNotFoundException; -use PrestaShop\PrestaShop\Core\Foundation\Filesystem\FileSystem as PsFileSystem; -use PrestaShop\PrestaShop\Core\Image\ImageTypeRepository; -use PrestaShop\PrestaShop\Core\Module\HookConfigurator; -use PrestaShopBundle\Service\TranslationService; -use PrestaShopBundle\Translation\Provider\TranslationFinder; -use PrestaShopLogger; -use Shop; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Finder\SplFileInfo; -use Symfony\Component\Translation\MessageCatalogue; -use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Yaml\Parser; -use Tools; - -class ThemeManager implements AddonManagerInterface -{ - /** - * @var HookConfigurator - */ - private $hookConfigurator; - - /** - * @var Shop - */ - private $shop; - - /** - * @var Employee - */ - private $employee; - - /** - * @var ThemeValidator - */ - private $themeValidator; - - /** - * @var ConfigurationInterface - */ - private $appConfiguration; - - /** - * @var Filesystem - */ - private $filesystem; - - /** - * @var Finder - */ - private $finder; - - /** - * @var ThemeRepository - */ - private $themeRepository; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ImageTypeRepository - */ - private $imageTypeRepository; - - /** - * @var TranslationFinder - */ - private $translationFinder; - - public function __construct( - Shop $shop, - ConfigurationInterface $configuration, - ThemeValidator $themeValidator, - TranslatorInterface $translator, - Employee $employee, - Filesystem $filesystem, - Finder $finder, - HookConfigurator $hookConfigurator, - ThemeRepository $themeRepository, - ImageTypeRepository $imageTypeRepository - ) { - $this->translationFinder = new TranslationFinder(); - $this->shop = $shop; - $this->appConfiguration = $configuration; - $this->themeValidator = $themeValidator; - $this->translator = $translator; - $this->employee = $employee; - $this->filesystem = $filesystem; - $this->finder = $finder; - $this->hookConfigurator = $hookConfigurator; - $this->themeRepository = $themeRepository; - $this->imageTypeRepository = $imageTypeRepository; - } - - /** - * Add new theme from zipball. This will unzip the file and move the content - * to the right locations. - * A theme can bundle modules, resources, documentation, email templates and so on. - * - * @param string $source The source can be a module name (installed from either local disk or addons.prestashop.com). - * or a location (url or path to the zip file) - * - * @return bool true for success - */ - public function install($source) - { - if ((filter_var($source, FILTER_VALIDATE_URL))) { - $source = Tools::createFileFromUrl($source); - } - if (preg_match('/\.zip$/', $source)) { - $this->installFromZip($source); - } - - return true; - } - - /** - * Remove all theme files, resources, documentation and specific modules. - * - * @param $name The source can be a module name (installed from either local disk or addons.prestashop.com). - * or a location (url or path to the zip file) - * - * @return bool true for success - */ - public function uninstall($name) - { - if (!$this->employee->can('delete', 'AdminThemes')) { - return false; - } - - $theme = $this->themeRepository->getInstanceByName($name); - $theme->onUninstall(); - - $this->filesystem->remove($theme->getDirectory()); - - return true; - } - - /** - * Download new files from source, backup old files, replace files with new ones - * and execute all necessary migration scripts form current version to the new one. - * - * @param string $name - * @param string $version the version you want to up upgrade to - * @param string $source if the upgrade is not coming from addons, you need to specify the path to the zipball - * - * @return bool true for success - */ - public function upgrade($name, $version, $source = null) - { - return true; - } - - /** - * Actions to perform when switching from another theme to this one. - * Example: - * - update configuration - * - enable/disable modules. - * - * @param string $name The theme name to enable - * @param bool $force bypass user privilege checks - * - * @return bool True for success - */ - public function enable($name, $force = false) - { - if (!$force && !$this->employee->can('edit', 'AdminThemes')) { - return false; - } - - /* if file exits, remove it and use YAML configuration file instead */ - @unlink($this->appConfiguration->get('_PS_CONFIG_DIR_') . 'themes/' . $name . '/shop' . $this->shop->id . '.json'); - - $theme = $this->themeRepository->getInstanceByName($name); - if (!$this->themeValidator->isValid($theme)) { - return false; - } - - $this->disable($this->shop->theme_name); - - $this->doCreateCustomHooks($theme->get('global_settings.hooks.custom_hooks', [])) - ->doApplyConfiguration($theme->get('global_settings.configuration', [])) - ->doDisableModules($theme->get('global_settings.modules.to_disable', [])) - ->doEnableModules($theme->getModulesToEnable()) - ->doResetModules($theme->get('global_settings.modules.to_reset', [])) - ->doApplyImageTypes($theme->get('global_settings.image_types')) - ->doHookModules($theme->get('global_settings.hooks.modules_to_hook')); - - $theme->onEnable(); - - $this->shop->theme_name = $theme->getName(); - $this->shop->update(); - - $this->saveTheme($theme); - - return $this; - } - - /** - * Actions to perform when switching from this theme to another one. - * - * @param string $name The theme name to enable - * - * @return bool True for success - */ - public function disable($name) - { - $theme = $this->themeRepository->getInstanceByName($name); - $theme->getModulesToDisable(); - - $this->doDisableModules($theme->getModulesToDisable()); - - @unlink($this->appConfiguration->get('_PS_CONFIG_DIR_') . 'themes/' . $name . '/shop' . $this->shop->id . '.json'); - - return true; - } - - /** - * Actions to perform to restore default settings. - * - * @param string $themeName The theme name to reset - * - * @return bool True for success - */ - public function reset($themeName) - { - return $this->disable($themeName) && $this->enable($themeName); - } - - /** - * Returns the last error, if found. - * - * @param string $themeName The technical theme name - * - * @return string|null The last error if found - */ - public function getError($themeName) - { - } - - /** - * Get all errors of theme install. - * - * @param string $themeName The technical theme name - * - * @return array|string|bool - */ - public function getErrors($themeName) - { - return $this->themeValidator->getErrors($themeName); - } - - private function doCreateCustomHooks(array $hooks) - { - foreach ($hooks as $hook) { - $this->hookConfigurator->addHook( - $hook['name'], - $hook['title'], - $hook['description'] - ); - } - - return $this; - } - - private function doApplyConfiguration(array $configuration) - { - foreach ($configuration as $key => $value) { - $this->appConfiguration->set($key, $value); - } - - return $this; - } - - private function doDisableModules(array $modules) - { - $moduleManagerBuilder = ModuleManagerBuilder::getInstance(); - $moduleManager = $moduleManagerBuilder->build(); - - foreach ($modules as $key => $moduleName) { - if ($moduleManager->isInstalled($moduleName) && $moduleManager->isEnabled($moduleName)) { - $moduleManager->disable($moduleName); - } - } - - return $this; - } - - /** - * @param array $modules - * - * @return $this - * - * @throws FailedToEnableThemeModuleException - */ - private function doEnableModules(array $modules) - { - $moduleManagerBuilder = ModuleManagerBuilder::getInstance(); - $moduleManager = $moduleManagerBuilder->build()->setActionParams(['confirmPrestaTrust' => true]); - - foreach ($modules as $key => $moduleName) { - if (!$moduleManager->isInstalled($moduleName) - && !$moduleManager->install($moduleName) - ) { - throw new FailedToEnableThemeModuleException($moduleName, $moduleManager->getError($moduleName)); - } - if (!$moduleManager->isEnabled($moduleName)) { - $moduleManager->enable($moduleName); - } - } - - return $this; - } - - /** - * Reset the modules received in parameters if they are installed and enabled. - * - * @param string[] $modules - * - * @return $this - */ - private function doResetModules(array $modules) - { - $moduleManagerBuilder = ModuleManagerBuilder::getInstance(); - $moduleManager = $moduleManagerBuilder->build(); - - foreach ($modules as $moduleName) { - if ($moduleManager->isInstalled($moduleName)) { - $moduleManager->reset($moduleName); - } - } - - return $this; - } - - private function doHookModules(array $hooks) - { - $this->hookConfigurator->setHooksConfiguration($hooks); - - return $this; - } - - private function doApplyImageTypes(array $types) - { - $this->imageTypeRepository->setTypes($types); - - return $this; - } - - /** - * @param $source - * - * @throws ThemeAlreadyExistsException - * @throws ThemeConstraintException - */ - private function installFromZip($source) - { - /** @var Finder $finderClass */ - $finderClass = get_class($this->finder); - $this->finder = $finderClass::create(); - - $sandboxPath = $this->getSandboxPath(); - Tools::ZipExtract($source, $sandboxPath); - - $themeConfigurationFile = $sandboxPath . '/config/theme.yml'; - - if (!file_exists($themeConfigurationFile)) { - throw new ThemeConstraintException('Missing theme configuration file which should be in located in /config/theme.yml', ThemeConstraintException::MISSING_CONFIGURATION_FILE); - } - - $theme_data = (new Parser())->parse(file_get_contents($themeConfigurationFile)); - - $theme_data['directory'] = $sandboxPath; - - try { - $theme = new Theme($theme_data); - } catch (ErrorException $exception) { - throw new ThemeConstraintException(sprintf('Theme data %s is not valid', var_export($theme_data, true)), ThemeConstraintException::INVALID_DATA, $exception); - } - - if (!$this->themeValidator->isValid($theme)) { - $this->filesystem->remove($sandboxPath); - - $this->themeValidator->getErrors($theme->getName()); - - throw new ThemeConstraintException(sprintf('Theme configuration file is not valid - %s', var_export($this->themeValidator->getErrors($theme->getName()), true)), ThemeConstraintException::INVALID_CONFIGURATION); - } - - $module_root_dir = $this->appConfiguration->get('_PS_MODULE_DIR_'); - $modules_parent_dir = $sandboxPath . '/dependencies/modules'; - if ($this->filesystem->exists($modules_parent_dir)) { - $module_dirs = $this->finder->directories() - ->in($modules_parent_dir) - ->depth('== 0'); - /** @var SplFileInfo $dir */ - foreach (iterator_to_array($module_dirs) as $dir) { - $destination = $module_root_dir . basename($dir->getFileName()); - if (!$this->filesystem->exists($destination)) { - $this->filesystem->mkdir($destination); - } - $this->filesystem->mirror($dir->getPathName(), $destination); - } - $this->filesystem->remove($modules_parent_dir); - } - - $themePath = $this->appConfiguration->get('_PS_ALL_THEMES_DIR_') . $theme->getName(); - if ($this->filesystem->exists($themePath)) { - throw new ThemeAlreadyExistsException($theme->getName(), $this->translator->trans('There is already a theme named ' . $theme->getName() . ' in your themes/ folder. Remove it if you want to continue.', [], 'Admin.Design.Notification')); - } - - $this->filesystem->mkdir($themePath); - $this->filesystem->mirror($sandboxPath, $themePath); - - $this->importTranslationToDatabase($theme); - - $this->filesystem->remove($sandboxPath); - } - - private function getSandboxPath() - { - if (!isset($this->sandbox)) { - $this->sandbox = $this->appConfiguration->get('_PS_CACHE_DIR_') . 'sandbox/' . uniqid() . '/'; - $this->filesystem->mkdir($this->sandbox, PsFileSystem::DEFAULT_MODE_FOLDER); - } - - return $this->sandbox; - } - - /** - * @param Theme $theme - */ - public function saveTheme($theme) - { - $jsonConfigFolder = $this->appConfiguration->get('_PS_CONFIG_DIR_') . 'themes/' . $theme->getName(); - if (!$this->filesystem->exists($jsonConfigFolder) && !is_dir($jsonConfigFolder)) { - mkdir($jsonConfigFolder, PsFileSystem::DEFAULT_MODE_FOLDER, true); - } - - file_put_contents( - $jsonConfigFolder . '/shop' . $this->shop->id . '.json', - json_encode($theme->get(null)) - ); - } - - /** - * Import translation from Theme to Database. - * - * @param Theme $theme - */ - private function importTranslationToDatabase(Theme $theme) - { - global $kernel; // sf kernel - - if (!(null !== $kernel && $kernel instanceof \Symfony\Component\HttpKernel\KernelInterface)) { - return; - } - - $translationService = $kernel->getContainer()->get('prestashop.service.translation'); - $themeProvider = $kernel->getContainer()->get('prestashop.translation.theme_provider'); - - $themeName = $theme->getName(); - $themePath = $this->appConfiguration->get('_PS_ALL_THEMES_DIR_') . $themeName; - $translationFolder = $themePath . DIRECTORY_SEPARATOR . 'translations' . DIRECTORY_SEPARATOR; - - $languages = Language::getLanguages(); - foreach ($languages as $language) { - $locale = $language['locale']; - - // retrieve Lang doctrine entity - try { - $lang = $translationService->findLanguageByLocale($locale); - } catch (Exception $exception) { - PrestaShopLogger::addLog('ThemeManager->importTranslationToDatabase() - Locale ' . $locale . ' does not exists'); - - continue; - } - - // check if translation dir for this lang exists - if (!is_dir($translationFolder . $locale)) { - continue; - } - - try { - // construct a new catalog for this lang and import in database if key and message are different - $messageCatalog = $this->translationFinder->getCatalogueFromPaths( - $translationFolder . $locale, - $locale - ); - - // get all default domain from catalog - $allDomains = $this->getDefaultDomains($locale, $themeProvider); - - // do the import - $this->handleImport($translationService, $messageCatalog, $allDomains, $lang, $locale, $themeName); - } catch (FileNotFoundException $e) { - // if the directory is there but there are no files, do nothing - } - } - } - - /** - * Get all default domain from catalog. - * - * @param string $locale - * @param \PrestaShopBundle\Translation\Provider\ThemeProvider $themeProvider - * - * @return array - */ - private function getDefaultDomains($locale, $themeProvider) - { - $allDomains = []; - - $defaultCatalogue = $themeProvider - ->setLocale($locale) - ->getDefaultCatalogue(); - - if (empty($defaultCatalogue)) { - return $allDomains; - } - - $defaultCatalogue = $defaultCatalogue->all(); - - if (empty($defaultCatalogue)) { - return $allDomains; - } - - foreach (array_keys($defaultCatalogue) as $domain) { - // AdminCatalogFeature.fr-FR to AdminCatalogFeature - $domain = str_replace('.' . $locale, '', $domain); - - $allDomains[] = $domain; - } - - return $allDomains; - } - - /** - * @param TranslationService $translationService - * @param MessageCatalogue $messageCatalog - * @param array $allDomains - * @param \PrestaShopBundle\Entity\Lang $lang - * @param string $locale - * @param string $themeName - */ - private function handleImport(TranslationService $translationService, MessageCatalogue $messageCatalog, $allDomains, $lang, $locale, $themeName) - { - foreach ($messageCatalog->all() as $domain => $messages) { - $domain = str_replace('.' . $locale, '', $domain); - - if (in_array($domain, $allDomains)) { - continue; - } - - foreach ($messages as $key => $message) { - if ($key !== $message) { - $translationService->saveTranslationMessage($lang, $domain, $key, $message, $themeName); - } - } - } - } -} diff --git a/src/Core/Addon/Theme/ThemeManagerBuilder.php b/src/Core/Addon/Theme/ThemeManagerBuilder.php deleted file mode 100644 index c5a9e99c..00000000 --- a/src/Core/Addon/Theme/ThemeManagerBuilder.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Theme; - -use Context; -use Db; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\Hook\HookInformationProvider; -use PrestaShop\PrestaShop\Core\Image\ImageTypeRepository; -use PrestaShop\PrestaShop\Core\Module\HookConfigurator; -use PrestaShop\PrestaShop\Core\Module\HookRepository; -use Shop; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Finder\Finder; - -class ThemeManagerBuilder -{ - private $context; - private $db; - - public function __construct(Context $context, Db $db) - { - $this->context = $context; - $this->db = $db; - } - - public function build() - { - $configuration = new Configuration(); - $configuration->restrictUpdatesTo($this->context->shop); - - return new ThemeManager( - $this->context->shop, - $configuration, - new ThemeValidator($this->context->getTranslator(), new Configuration()), - $this->context->getTranslator(), - $this->context->employee, - new Filesystem(), - new Finder(), - new HookConfigurator( - new HookRepository( - new HookInformationProvider(), - $this->context->shop, - $this->db - ) - ), - $this->buildRepository($this->context->shop), - new ImageTypeRepository( - $this->context->shop, - $this->db - ) - ); - } - - public function buildRepository(Shop $shop = null) - { - if (!$shop instanceof Shop) { - $shop = $this->context->shop; - } - - $configuration = new Configuration(); - $configuration->restrictUpdatesTo($shop); - - return new ThemeRepository( - $configuration, - new Filesystem(), - $shop - ); - } -} diff --git a/src/Core/Addon/Theme/ThemePageLayoutsCustomizer.php b/src/Core/Addon/Theme/ThemePageLayoutsCustomizer.php deleted file mode 100644 index 27f8a0fa..00000000 --- a/src/Core/Addon/Theme/ThemePageLayoutsCustomizer.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Theme; - -use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface; - -/** - * Class PagesLayoutCustomizer customizes pages layout for shop's Front Office theme. - */ -final class ThemePageLayoutsCustomizer implements ThemePageLayoutsCustomizerInterface -{ - /** - * @var Theme - */ - private $theme; - - /** - * @var ThemeManager - */ - private $themeManager; - - /** - * @var CacheClearerInterface - */ - private $smartyCacheClearer; - - /** - * @param Theme $theme - * @param ThemeManager $themeManager - * @param CacheClearerInterface $smartyCacheClearer - */ - public function __construct(Theme $theme, ThemeManager $themeManager, CacheClearerInterface $smartyCacheClearer) - { - $this->theme = $theme; - $this->themeManager = $themeManager; - $this->smartyCacheClearer = $smartyCacheClearer; - } - - /** - * {@inheritdoc} - */ - public function customize(array $pageLayouts) - { - $this->theme->setPageLayouts($pageLayouts); - $this->themeManager->saveTheme($this->theme); - - $this->smartyCacheClearer->clear(); - } -} diff --git a/src/Core/Addon/Theme/ThemePageLayoutsCustomizerInterface.php b/src/Core/Addon/Theme/ThemePageLayoutsCustomizerInterface.php deleted file mode 100644 index 891d9c15..00000000 --- a/src/Core/Addon/Theme/ThemePageLayoutsCustomizerInterface.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Theme; - -/** - * Interface PageLayoutCustomizerInterface. - */ -interface ThemePageLayoutsCustomizerInterface -{ - /** - * @param array $pageLayouts Customized layouts for pages - */ - public function customize(array $pageLayouts); -} diff --git a/src/Core/Addon/Theme/ThemeProvider.php b/src/Core/Addon/Theme/ThemeProvider.php deleted file mode 100644 index 453333c9..00000000 --- a/src/Core/Addon/Theme/ThemeProvider.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Theme; - -/** - * Class ThemeProvider - */ -final class ThemeProvider implements ThemeProviderInterface -{ - /** - * @var ThemeRepository - */ - private $themeRepository; - - /** - * @var Theme - */ - private $theme; - - /** - * @param ThemeRepository $themeRepository - * @param Theme $theme - */ - public function __construct(ThemeRepository $themeRepository, Theme $theme) - { - $this->themeRepository = $themeRepository; - $this->theme = $theme; - } - - /** - * {@inheritdoc} - */ - public function getCurrentlyUsedTheme() - { - return $this->theme; - } - - /** - * {@inheritdoc} - */ - public function getNotUsedThemes() - { - return $this->themeRepository->getListExcluding([ - $this->getCurrentlyUsedTheme()->getName(), - ]); - } -} diff --git a/src/Core/Addon/Theme/ThemeProviderInterface.php b/src/Core/Addon/Theme/ThemeProviderInterface.php deleted file mode 100644 index 1696ad43..00000000 --- a/src/Core/Addon/Theme/ThemeProviderInterface.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Theme; - -/** - * Interface ThemeProviderInterface - */ -interface ThemeProviderInterface -{ - /** - * Get currently used theme for context shop. - * - * @return Theme - */ - public function getCurrentlyUsedTheme(); - - /** - * Get not used themes for context shop. - * - * @return Theme[] - */ - public function getNotUsedThemes(); -} diff --git a/src/Core/Addon/Theme/ThemeRepository.php b/src/Core/Addon/Theme/ThemeRepository.php deleted file mode 100644 index 22c278c7..00000000 --- a/src/Core/Addon/Theme/ThemeRepository.php +++ /dev/null @@ -1,156 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Theme; - -use PrestaShop\PrestaShop\Core\Addon\AddonListFilter; -use PrestaShop\PrestaShop\Core\Addon\AddonListFilterStatus; -use PrestaShop\PrestaShop\Core\Addon\AddonListFilterType; -use PrestaShop\PrestaShop\Core\Addon\AddonRepositoryInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Foundation\Filesystem\FileSystem as PsFileSystem; -use PrestaShopException; -use Shop; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Yaml\Parser; - -class ThemeRepository implements AddonRepositoryInterface -{ - private $appConfiguration; - private $filesystem; - private $shop; - - public function __construct(ConfigurationInterface $configuration, Filesystem $filesystem, Shop $shop = null) - { - $this->appConfiguration = $configuration; - $this->filesystem = $filesystem; - $this->shop = $shop; - } - - public function getInstanceByName($name) - { - $dir = $this->appConfiguration->get('_PS_ALL_THEMES_DIR_') . $name; - - $confDir = $this->appConfiguration->get('_PS_CONFIG_DIR_') . 'themes/' . $name; - $jsonConf = $confDir . '/theme.json'; - if ($this->shop) { - $jsonConf = $confDir . '/shop' . $this->shop->id . '.json'; - } - - if ($this->filesystem->exists($jsonConf)) { - $data = $this->getConfigFromFile($jsonConf); - } else { - $data = $this->getConfigFromFile($dir . '/config/theme.yml'); - - // Write parsed yml data into json conf (faster parsing next time) - $this->filesystem->dumpFile($jsonConf, json_encode($data), PsFileSystem::DEFAULT_MODE_FILE); - } - - $data['directory'] = $dir; - - return new Theme($data); - } - - public function getList() - { - if (!isset($this->themes)) { - $this->themes = $this->getFilteredList(new AddonListFilter()); - } - - return $this->themes; - } - - /** - * Gets list of themes as a collection. - * - * @return ThemeCollection - */ - public function getListAsCollection() - { - $list = $this->getList(); - - return ThemeCollection::createFrom($list); - } - - public function getListExcluding(array $exclude) - { - $filter = (new AddonListFilter()) - ->setExclude($exclude); - - return $this->getFilteredList($filter); - } - - public function getFilteredList(AddonListFilter $filter) - { - $filter->setType(AddonListFilterType::THEME); - - if (!isset($filter->status)) { - $filter->setStatus(AddonListFilterStatus::ALL); - } - - $themes = $this->getThemesOnDisk(); - - if (count($filter->exclude) > 0) { - foreach ($filter->exclude as $name) { - unset($themes[$name]); - } - } - - return $themes; - } - - private function getThemesOnDisk() - { - $suffix = 'config/theme.yml'; - $themeDirectories = glob($this->appConfiguration->get('_PS_ALL_THEMES_DIR_') . '*/' . $suffix, GLOB_NOSORT); - - $themes = []; - foreach ($themeDirectories as $directory) { - $name = basename(substr($directory, 0, -strlen($suffix))); - $theme = $this->getInstanceByName($name); - if (isset($theme)) { - $themes[$name] = $theme; - } - } - - return $themes; - } - - private function getConfigFromFile($file) - { - if (!$this->filesystem->exists($file)) { - throw new PrestaShopException(sprintf('[ThemeRepository] Theme configuration file not found for theme at `%s`.', $file)); - } - - $content = file_get_contents($file); - - if (preg_match('/.\.(yml|yaml)$/', $file)) { - return (new Parser())->parse($content); - } elseif (preg_match('/.\.json$/', $file)) { - return json_decode($content, true); - } - } -} diff --git a/src/Core/Addon/Theme/ThemeUploaderInterface.php b/src/Core/Addon/Theme/ThemeUploaderInterface.php deleted file mode 100644 index 64694ced..00000000 --- a/src/Core/Addon/Theme/ThemeUploaderInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Theme; - -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Interface ThemeUploaderInterface - */ -interface ThemeUploaderInterface -{ - /** - * @param UploadedFile $uploadedTheme - * - * @return string Path to uploaded theme - */ - public function upload(UploadedFile $uploadedTheme); -} diff --git a/src/Core/Addon/Theme/ThemeValidator.php b/src/Core/Addon/Theme/ThemeValidator.php deleted file mode 100644 index be15933f..00000000 --- a/src/Core/Addon/Theme/ThemeValidator.php +++ /dev/null @@ -1,163 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Theme; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use Symfony\Component\Translation\TranslatorInterface; - -class ThemeValidator -{ - /** - * Translator. - * - * @var \Symfony\Component\Translation\TranslatorInterface - */ - private $translator; - private $appConfiguration; - - private $errors = []; - - public function __construct(TranslatorInterface $translator, ConfigurationInterface $configuration) - { - $this->translator = $translator; - $this->appConfiguration = $configuration; - } - - public function getErrors($themeName) - { - return array_key_exists($themeName, $this->errors) ? $this->errors[$themeName] : false; - } - - public function isValid(Theme $theme) - { - return $this->hasRequiredFiles($theme) - && $this->hasRequiredProperties($theme); - } - - private function hasRequiredProperties(Theme $theme) - { - $themeName = $theme->getName(); - - foreach ($this->getRequiredProperties() as $prop) { - if (!$theme->has($prop)) { - if (!array_key_exists($themeName, $this->errors)) { - $this->errors[$themeName] = []; - } - - $this->errors[$themeName] = $this->translator->trans( - 'An error occurred. The information "%s" is missing.', - [$prop], - 'Admin.Design.Notification' - ); - } - } - - return !array_key_exists($themeName, $this->errors); - } - - public function getRequiredProperties() - { - return [ - 'name', - 'display_name', - 'version', - 'author.name', - 'meta.compatibility.from', - 'meta.available_layouts', - 'global_settings.image_types.cart_default', - 'global_settings.image_types.small_default', - 'global_settings.image_types.medium_default', - 'global_settings.image_types.large_default', - 'global_settings.image_types.home_default', - 'global_settings.image_types.category_default', - 'theme_settings.default_layout', - ]; - } - - private function hasRequiredFiles(Theme $theme) - { - $themeName = $theme->getName(); - $parentDir = realpath($this->appConfiguration->get('_PS_ALL_THEMES_DIR_') . $theme->get('parent')) . '/'; - $parentFile = false; - - foreach ($this->getRequiredFiles() as $file) { - $childFile = $theme->getDirectory() . $file; - if ($theme->get('parent')) { - $parentFile = $parentDir . $file; - } - - if (!file_exists($childFile) && !file_exists($parentFile)) { - if (!array_key_exists($themeName, $this->errors)) { - $this->errors[$themeName] = []; - } - - $this->errors[$themeName] = $this->translator->trans('An error occurred. The template "%s" is missing.', [$file], 'Admin.Design.Notification'); - } - } - - return !array_key_exists($themeName, $this->errors); - } - - public function getRequiredFiles() - { - return [ - 'preview.png', - 'config/theme.yml', - 'assets/js/theme.js', - 'assets/css/theme.css', - // Templates - 'templates/_partials/form-fields.tpl', - 'templates/catalog/product.tpl', - 'templates/catalog/listing/product-list.tpl', - 'templates/checkout/cart.tpl', - 'templates/checkout/checkout.tpl', - 'templates/cms/category.tpl', - 'templates/cms/page.tpl', - 'templates/customer/address.tpl', - 'templates/customer/addresses.tpl', - 'templates/customer/guest-tracking.tpl', - 'templates/customer/guest-login.tpl', - 'templates/customer/history.tpl', - 'templates/customer/identity.tpl', - 'templates/index.tpl', - 'templates/customer/my-account.tpl', - 'templates/checkout/order-confirmation.tpl', - 'templates/customer/order-detail.tpl', - 'templates/customer/order-follow.tpl', - 'templates/customer/order-return.tpl', - 'templates/customer/order-slip.tpl', - 'templates/errors/404.tpl', - 'templates/errors/forbidden.tpl', - 'templates/checkout/cart-empty.tpl', - 'templates/cms/sitemap.tpl', - 'templates/cms/stores.tpl', - 'templates/customer/authentication.tpl', - 'templates/customer/registration.tpl', - 'templates/contact.tpl', - ]; - } -} diff --git a/src/Core/Addon/Theme/ThemeZipUploader.php b/src/Core/Addon/Theme/ThemeZipUploader.php deleted file mode 100644 index dfae9b04..00000000 --- a/src/Core/Addon/Theme/ThemeZipUploader.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Addon\Theme; - -use PrestaShop\PrestaShop\Core\Addon\Theme\Exception\ThemeUploadException; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Class ThemeZipUploader uploads theme to local filesystem. - */ -final class ThemeZipUploader implements ThemeUploaderInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function upload(UploadedFile $uploadedTheme) - { - $this->assertThemeWasUploadedWithoutErrors($uploadedTheme); - $this->assertUploadedFileIsZip($uploadedTheme); - - $themesDir = $this->configuration->get('_PS_ALL_THEMES_DIR_'); - $destination = $themesDir . $uploadedTheme->getClientOriginalName(); - - if (!preg_match('/^[a-zA-Z0-9_.-]+$/', $uploadedTheme->getClientOriginalName())) { - $destination = $themesDir . sha1_file($uploadedTheme->getPathname()) . '.zip'; - } - - move_uploaded_file( - $uploadedTheme->getPathname(), - $destination - ); - - return $destination; - } - - /** - * @param UploadedFile $uploadedTheme - * - * @throws ThemeUploadException - */ - private function assertThemeWasUploadedWithoutErrors(UploadedFile $uploadedTheme) - { - if (UPLOAD_ERR_OK === $uploadedTheme->getError()) { - return; - } - - if (in_array($uploadedTheme->getError(), [UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_FORM_SIZE])) { - throw new ThemeUploadException('Allowed file size exceeded for uploaded theme.', ThemeUploadException::FILE_SIZE_EXCEEDED_ERROR); - } - - throw new ThemeUploadException(sprintf('Unknown error "%s" occurred while uploading theme.', $uploadedTheme->getError()), ThemeUploadException::UNKNOWN_ERROR); - } - - /** - * @param UploadedFile $uploadedTheme - * - * @throws ThemeUploadException - */ - private function assertUploadedFileIsZip(UploadedFile $uploadedTheme) - { - preg_match('#application/zip#', $uploadedTheme->getMimeType(), $matches); - - if (empty($matches)) { - throw new ThemeUploadException('Invalid mime type of theme zip. Allowed mime type is application/zip.', ThemeUploadException::INVALID_MIME_TYPE); - } - } -} diff --git a/src/Core/AttributeGroup/AttributeGroupViewDataProviderInterface.php b/src/Core/AttributeGroup/AttributeGroupViewDataProviderInterface.php deleted file mode 100644 index d00e3152..00000000 --- a/src/Core/AttributeGroup/AttributeGroupViewDataProviderInterface.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\AttributeGroup; - -/** - * Defines contract for services that provides attribute group view action data - */ -interface AttributeGroupViewDataProviderInterface -{ - /** - * @param int $attributeGroupId - * - * @return bool - */ - public function isColorGroup($attributeGroupId); - - /** - * Provides the name of attribute group by its id - * - * @param int $attributeGroupId - * - * @return string - */ - public function getAttributeGroupNameById($attributeGroupId); -} diff --git a/src/Core/B2b/B2bFeature.php b/src/Core/B2b/B2bFeature.php deleted file mode 100644 index 7b8b7f3c..00000000 --- a/src/Core/B2b/B2bFeature.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\B2b; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Feature\FeatureInterface; - -/** - * Class B2bFeature checks manages B2B status. - */ -final class B2bFeature implements FeatureInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function isUsed() - { - return $this->isActive(); - } - - /** - * {@inheritdoc} - */ - public function isActive() - { - return (bool) $this->configuration->get('PS_B2B_ENABLE'); - } - - /** - * {@inheritdoc} - */ - public function enable() - { - $this->configuration->set('PS_B2B_ENABLE', 1); - } - - /** - * {@inheritdoc} - */ - public function disable() - { - $this->configuration->set('PS_B2B_ENABLE', 0); - } - - /** - * {@inheritdoc} - */ - public function update($status) - { - $status ? $this->enable() : $this->disable(); - } -} diff --git a/src/Core/Backup/BackupCollection.php b/src/Core/Backup/BackupCollection.php deleted file mode 100644 index 0f93c955..00000000 --- a/src/Core/Backup/BackupCollection.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Backup; - -final class BackupCollection implements BackupCollectionInterface -{ - /** - * @var BackupInterface[] - */ - private $backups = []; - - /** - * {@inheritdoc} - */ - public function add(BackupInterface $backup) - { - $this->backups[] = $backup; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function all() - { - return $this->backups; - } -} diff --git a/src/Core/Backup/BackupCollectionInterface.php b/src/Core/Backup/BackupCollectionInterface.php deleted file mode 100644 index 493d4ea0..00000000 --- a/src/Core/Backup/BackupCollectionInterface.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Backup; - -/** - * Interface BackupCollectionInterface defines contract for backup collection. - */ -interface BackupCollectionInterface -{ - /** - * Add backup to collection. - * - * @param BackupInterface $backup - * - * @return self - */ - public function add(BackupInterface $backup); - - /** - * Get all backups. - * - * @return BackupInterface[] - */ - public function all(); -} diff --git a/src/Core/Backup/BackupInterface.php b/src/Core/Backup/BackupInterface.php deleted file mode 100644 index 113f406c..00000000 --- a/src/Core/Backup/BackupInterface.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Backup; - -use DateTimeInterface; - -/** - * Interface BackupInterface defines contract for backup. - */ -interface BackupInterface -{ - /** - * Get backup filename. - * - * @return string - */ - public function getFileName(); - - /** - * Get complete path to the backup file. - * - * @return string - */ - public function getFilePath(); - - /** - * Get URL to backup. - * - * @return string - */ - public function getUrl(); - - /** - * Get backup file size in bytes. - * - * @return string - */ - public function getSize(); - - /** - * Get backup age in seconds. - * - * @return int - */ - public function getAge(); - - /** - * Get backup creation date. - * - * @return DateTimeInterface - */ - public function getDate(); -} diff --git a/src/Core/Backup/Comparator/BackupByDateComparator.php b/src/Core/Backup/Comparator/BackupByDateComparator.php deleted file mode 100644 index b5d143c5..00000000 --- a/src/Core/Backup/Comparator/BackupByDateComparator.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Backup\Comparator; - -use PrestaShop\PrestaShop\Core\Backup\BackupInterface; - -/** - * Class BackupByDateComparator compares 2 backups by creation date. - */ -final class BackupByDateComparator implements BackupComparatorInterface -{ - /** - * {@inheritdoc} - */ - public function compare(BackupInterface $backup1, BackupInterface $backup2) - { - return $backup2->getDate()->getTimestamp() - $backup1->getDate()->getTimestamp(); - } -} diff --git a/src/Core/Backup/Comparator/BackupComparatorInterface.php b/src/Core/Backup/Comparator/BackupComparatorInterface.php deleted file mode 100644 index 44568223..00000000 --- a/src/Core/Backup/Comparator/BackupComparatorInterface.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Backup\Comparator; - -use PrestaShop\PrestaShop\Core\Backup\BackupInterface; - -/** - * Interface BackupComparatorInterface defines contract for backups comparator. - */ -interface BackupComparatorInterface -{ - /** - * Compare 2 backups. - * - * @param BackupInterface $backup1 - * @param BackupInterface $backup2 - * - * @return int - */ - public function compare(BackupInterface $backup1, BackupInterface $backup2); -} diff --git a/src/Core/Backup/Configuration/BackupOptionsConfiguration.php b/src/Core/Backup/Configuration/BackupOptionsConfiguration.php deleted file mode 100644 index 7ee27aff..00000000 --- a/src/Core/Backup/Configuration/BackupOptionsConfiguration.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Backup\Configuration; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; - -/** - * Class BackupOptionsConfigurator configures backup options. - */ -final class BackupOptionsConfiguration implements DataConfigurationInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'backup_all' => (bool) $this->configuration->get('PS_BACKUP_ALL'), - 'backup_drop_tables' => (bool) $this->configuration->get('PS_BACKUP_DROP_TABLE'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $config) - { - if ($this->validateConfiguration($config)) { - $this->configuration->set('PS_BACKUP_ALL', $config['backup_all']); - $this->configuration->set('PS_BACKUP_DROP_TABLE', $config['backup_drop_tables']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $config) - { - return isset( - $config['backup_all'], - $config['backup_drop_tables'] - ); - } -} diff --git a/src/Core/Backup/Exception/BackupException.php b/src/Core/Backup/Exception/BackupException.php deleted file mode 100644 index b613e352..00000000 --- a/src/Core/Backup/Exception/BackupException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Backup\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Class BackupException is thrown whenever backup fails. - */ -class BackupException extends CoreException -{ -} diff --git a/src/Core/Backup/Exception/DirectoryIsNotWritableException.php b/src/Core/Backup/Exception/DirectoryIsNotWritableException.php deleted file mode 100644 index 182b44f1..00000000 --- a/src/Core/Backup/Exception/DirectoryIsNotWritableException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Backup\Exception; - -/** - * Class DirectoryIsNotWritableException is thrown when backup directory is not writable. - */ -class DirectoryIsNotWritableException extends BackupException -{ -} diff --git a/src/Core/Backup/Listing/BackupGridDataFactory.php b/src/Core/Backup/Listing/BackupGridDataFactory.php deleted file mode 100644 index eb546c5c..00000000 --- a/src/Core/Backup/Listing/BackupGridDataFactory.php +++ /dev/null @@ -1,157 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Backup\Listing; - -use PrestaShop\PrestaShop\Core\Backup\BackupInterface; -use PrestaShop\PrestaShop\Core\Backup\Comparator\BackupComparatorInterface; -use PrestaShop\PrestaShop\Core\Backup\Repository\BackupRepositoryInterface; -use PrestaShop\PrestaShop\Core\Grid\Data\Factory\GridDataFactoryInterface; -use PrestaShop\PrestaShop\Core\Grid\Data\GridData; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use PrestaShop\PrestaShop\Core\Util\DateTime\TimeDefinition; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * This class provides backups for listing in grid. - */ -final class BackupGridDataFactory implements GridDataFactoryInterface -{ - /** - * @var BackupRepositoryInterface - */ - private $backupRepository; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var string - */ - private $languageDateTimeFormat; - - /** - * @var BackupComparatorInterface - */ - private $backupByDateComparator; - - /** - * @param BackupRepositoryInterface $backupRepository - * @param BackupComparatorInterface $backupByDateComparator - * @param TranslatorInterface $translator - * @param string $languageDateTimeFormat - */ - public function __construct( - BackupRepositoryInterface $backupRepository, - BackupComparatorInterface $backupByDateComparator, - TranslatorInterface $translator, - $languageDateTimeFormat - ) { - $this->backupRepository = $backupRepository; - $this->translator = $translator; - $this->languageDateTimeFormat = $languageDateTimeFormat; - $this->backupByDateComparator = $backupByDateComparator; - } - - /** - * {@inheritdoc} - */ - public function getData(SearchCriteriaInterface $searchCriteria) - { - $backups = $this->backupRepository->retrieveBackups()->all(); - usort($backups, [$this->backupByDateComparator, 'compare']); - - $paginatedBackups = null !== $searchCriteria->getOffset() && null !== $searchCriteria->getLimit() ? - array_slice($backups, $searchCriteria->getOffset(), $searchCriteria->getLimit()) : - $backups; - - $backupsArray = []; - - foreach ($paginatedBackups as $backup) { - $backupsArray[] = [ - 'file_name' => $backup->getFileName(), - 'file_size' => $backup->getSize(), - 'date' => $backup->getDate(), - 'age' => $backup->getAge(), - 'age_formatted' => $this->getFormattedAge($backup), - 'date_formatted' => date($this->languageDateTimeFormat, $backup->getDate()->getTimestamp()), - 'file_size_formatted' => $this->getFormattedSize($backup), - ]; - } - - $backupCollection = new RecordCollection($backupsArray); - - return new GridData( - $backupCollection, - count($backups) - ); - } - - /** - * Get formatted age. - * - * @param BackupInterface $backup - * - * @return string - */ - private function getFormattedAge(BackupInterface $backup) - { - if (TimeDefinition::HOUR_IN_SECONDS > $backup->getAge()) { - return sprintf('< 1 %s', $this->translator->trans('Hour', [], 'Admin.Global')); - } - - if (TimeDefinition::DAY_IN_SECONDS > $backup->getAge()) { - $hours = (int) floor($backup->getAge() / TimeDefinition::HOUR_IN_SECONDS); - $label = 1 === $hours ? - $this->translator->trans('Hour', [], 'Admin.Global') : - $this->translator->trans('Hours', [], 'Admin.Global'); - - return sprintf('%s %s', $hours, $label); - } - - $days = (int) floor($backup->getAge() / TimeDefinition::DAY_IN_SECONDS); - $label = 1 === $days ? - $this->translator->trans('Day', [], 'Admin.Global') : - $this->translator->trans('Days', [], 'Admin.Global'); - - return sprintf('%s %s', $days, $label); - } - - /** - * Get formatted backup size. - * - * @param BackupInterface $backup - * - * @return string - */ - private function getFormattedSize(BackupInterface $backup) - { - return sprintf('%s Kb', number_format($backup->getSize() / 1000, 2)); - } -} diff --git a/src/Core/Backup/Manager/BackupCreatorInterface.php b/src/Core/Backup/Manager/BackupCreatorInterface.php deleted file mode 100644 index 61d12630..00000000 --- a/src/Core/Backup/Manager/BackupCreatorInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Backup\Manager; - -use PrestaShop\PrestaShop\Core\Backup\BackupInterface; - -/** - * Interface BackupCreatorInterface defines contract for backup creator. - */ -interface BackupCreatorInterface -{ - /** - * Create new backup. - * - * @return BackupInterface - */ - public function createBackup(); -} diff --git a/src/Core/Backup/Manager/BackupRemoverInterface.php b/src/Core/Backup/Manager/BackupRemoverInterface.php deleted file mode 100644 index aaa83976..00000000 --- a/src/Core/Backup/Manager/BackupRemoverInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Backup\Manager; - -use PrestaShop\PrestaShop\Core\Backup\BackupInterface; - -/** - * Interface BackupRemoverInterface defines contract for backup remover. - */ -interface BackupRemoverInterface -{ - /** - * @param BackupInterface $backup - * - * @return bool True if backup were removed successfully or False otherwise - */ - public function remove(BackupInterface $backup); -} diff --git a/src/Core/Backup/Repository/BackupRepositoryInterface.php b/src/Core/Backup/Repository/BackupRepositoryInterface.php deleted file mode 100644 index 4ff66287..00000000 --- a/src/Core/Backup/Repository/BackupRepositoryInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Backup\Repository; - -use PrestaShop\PrestaShop\Core\Backup\BackupCollectionInterface; - -/** - * Interface BackupRepositoryInterface defines contract for backup repository. - */ -interface BackupRepositoryInterface -{ - /** - * Get available backups. - * - * @return BackupCollectionInterface - */ - public function retrieveBackups(); -} diff --git a/src/Core/CMS/CMSRepository.php b/src/Core/CMS/CMSRepository.php deleted file mode 100644 index cd0b6ef1..00000000 --- a/src/Core/CMS/CMSRepository.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\CMS; - -class CMSRepository extends \PrestaShop\PrestaShop\Core\Foundation\Database\EntityRepository -{ - /** - * Return all CMSRepositories depending on $id_lang/$id_shop tuple. - * - * @param $id_lang - * @param $id_shop - * - * @return array|null - */ - public function i10nFindAll($id_lang, $id_shop) - { - $sql = ' - SELECT * - FROM `' . $this->getTableNameWithPrefix() . '` c - JOIN `' . $this->getPrefix() . 'cms_lang` cl ON c.`id_cms`= cl.`id_cms` - WHERE cl.`id_lang` = ' . (int) $id_lang . ' - AND cl.`id_shop` = ' . (int) $id_shop . ' - - '; - - return $this->hydrateMany($this->db->select($sql)); - } - - /** - * Return all CMSRepositories depending on $id_lang/$id_shop tuple. - * - * @param $id_cms - * @param $id_lang - * @param $id_shop - * - * @return CMS|null - * - * @throws \PrestaShop\PrestaShop\Core\Foundation\Database\Exception - */ - public function i10nFindOneById($id_cms, $id_lang, $id_shop) - { - $sql = ' - SELECT * - FROM `' . $this->getTableNameWithPrefix() . '` c - JOIN `' . $this->getPrefix() . 'cms_lang` cl ON c.`id_cms`= cl.`id_cms` - WHERE c.`id_cms` = ' . (int) $id_cms . ' - AND cl.`id_lang` = ' . (int) $id_lang . ' - AND cl.`id_shop` = ' . (int) $id_shop . ' - LIMIT 0 , 1 - '; - - return $this->hydrateOne($this->db->select($sql)); - } -} diff --git a/src/Core/CMS/CMSRoleRepository.php b/src/Core/CMS/CMSRoleRepository.php deleted file mode 100644 index 29f166ea..00000000 --- a/src/Core/CMS/CMSRoleRepository.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\CMS; - -class CMSRoleRepository extends \PrestaShop\PrestaShop\Core\Foundation\Database\EntityRepository -{ - /** - * Return all CMSRoles which are already associated. - * - * @return array|null - */ - public function getCMSRolesAssociated() - { - $sql = ' - SELECT * - FROM `' . $this->getTableNameWithPrefix() . '` - WHERE `id_cms` != 0'; - - return $this->hydrateMany($this->db->select($sql)); - } -} diff --git a/src/Core/CMS/CmsPageViewDataProvider.php b/src/Core/CMS/CmsPageViewDataProvider.php deleted file mode 100644 index 8e380a8d..00000000 --- a/src/Core/CMS/CmsPageViewDataProvider.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\CMS; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query\GetCmsPageCategoriesForBreadcrumb; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryResult\Breadcrumb; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Class CmsPageViewDataProvider provides cms page view data for cms listing page. - */ -final class CmsPageViewDataProvider implements CmsPageViewDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @param CommandBusInterface $queryBus - */ - public function __construct(CommandBusInterface $queryBus) - { - $this->queryBus = $queryBus; - } - - /** - * {@inheritdoc} - * - * @throws CmsPageCategoryException - */ - public function getView($cmsCategoryParentId) - { - return [ - 'root_category_id' => CmsPageCategoryId::ROOT_CMS_PAGE_CATEGORY_ID, - 'breadcrumb_tree' => $this->getBreadcrumbTree($cmsCategoryParentId), - ]; - } - - /** - * Gets breadcrumb tree which contains cms page categories. If the exception is raised when it returns empty array. - * - * @param int $cmsCategoryParentId - * - * @return Breadcrumb|array - * - * @throws CmsPageCategoryException - */ - private function getBreadcrumbTree($cmsCategoryParentId) - { - return $this->queryBus->handle(new GetCmsPageCategoriesForBreadcrumb($cmsCategoryParentId)); - } -} diff --git a/src/Core/CMS/CmsPageViewDataProviderInterface.php b/src/Core/CMS/CmsPageViewDataProviderInterface.php deleted file mode 100644 index 0383be58..00000000 --- a/src/Core/CMS/CmsPageViewDataProviderInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\CMS; - -/** - * Interface CmsPageViewDataProviderInterface defines contract for CmsPageViewDataProvider. - */ -interface CmsPageViewDataProviderInterface -{ - /** - * Gets data required for rendering the view. - * - * @param int $cmsCategoryParentId - * - * @return array - */ - public function getView($cmsCategoryParentId); -} diff --git a/src/Core/Cache/Clearer/CacheClearerChain.php b/src/Core/Cache/Clearer/CacheClearerChain.php deleted file mode 100644 index fbba8a55..00000000 --- a/src/Core/Cache/Clearer/CacheClearerChain.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Cache\Clearer; - -/** - * Class CacheClearerChain clears entire PrestaShop cache. - */ -final class CacheClearerChain implements CacheClearerInterface -{ - /** - * @var CacheClearerInterface[] - */ - private $cacheClearers; - - /** - * @param CacheClearerInterface ...$cacheClearers - */ - public function __construct(CacheClearerInterface ...$cacheClearers) - { - $this->cacheClearers = $cacheClearers; - } - - /** - * {@inheritdoc} - */ - public function clear() - { - foreach ($this->cacheClearers as $cacheClearer) { - $cacheClearer->clear(); - } - } -} diff --git a/src/Core/Cache/Clearer/CacheClearerInterface.php b/src/Core/Cache/Clearer/CacheClearerInterface.php deleted file mode 100644 index c06c509a..00000000 --- a/src/Core/Cache/Clearer/CacheClearerInterface.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Cache\Clearer; - -/** - * Interface CacheClearerInterface. - */ -interface CacheClearerInterface -{ - /** - * Clear cache. - */ - public function clear(); -} diff --git a/src/Core/Cart/AmountImmutable.php b/src/Core/Cart/AmountImmutable.php deleted file mode 100644 index 594dc45c..00000000 --- a/src/Core/Cart/AmountImmutable.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Cart; - -/** - * provide objects dealing with tax ex/in-cluded amounts - * aims to avoid using multiple values into calculation processes. - * - * this class is IMMUTABLE - */ -class AmountImmutable -{ - /** - * @var float - */ - protected $taxIncluded = 0.0; - - /** - * @var float - */ - protected $taxExcluded = 0.0; - - public function __construct($taxIncluded = 0.0, $taxExcluded = 0.0) - { - $this->setTaxIncluded($taxIncluded); - $this->setTaxExcluded($taxExcluded); - } - - /** - * @return float - */ - public function getTaxIncluded() - { - return $this->taxIncluded; - } - - /** - * @param float $taxIncluded - * - * @return AmountImmutable - */ - protected function setTaxIncluded($taxIncluded) - { - $this->taxIncluded = (float) $taxIncluded; - - return $this; - } - - /** - * @return float - */ - public function getTaxExcluded() - { - return $this->taxExcluded; - } - - /** - * @param float $taxExcluded - * - * @return AmountImmutable - */ - protected function setTaxExcluded($taxExcluded) - { - $this->taxExcluded = (float) $taxExcluded; - - return $this; - } - - /** - * sums another amount object. - * - * @param \PrestaShop\PrestaShop\Core\Cart\AmountImmutable $amount - * - * @return \PrestaShop\PrestaShop\Core\Cart\AmountImmutable - */ - public function add(AmountImmutable $amount) - { - return new static( - $this->getTaxIncluded() + $amount->getTaxIncluded(), - $this->getTaxExcluded() + $amount->getTaxExcluded() - ); - } - - /** - * substract another amount object. - * - * @param \PrestaShop\PrestaShop\Core\Cart\AmountImmutable $amount - * - * @return \PrestaShop\PrestaShop\Core\Cart\AmountImmutable - */ - public function sub(AmountImmutable $amount) - { - return new static( - $this->getTaxIncluded() - $amount->getTaxIncluded(), - $this->getTaxExcluded() - $amount->getTaxExcluded() - ); - } -} diff --git a/src/Core/Cart/Calculator.php b/src/Core/Cart/Calculator.php deleted file mode 100644 index 4155036e..00000000 --- a/src/Core/Cart/Calculator.php +++ /dev/null @@ -1,378 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Cart; - -use Cart; -use Currency; -use PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision; -use Tools; - -/** - * provides methods to process cart calculation. - */ -class Calculator -{ - /** - * @var \Cart - */ - protected $cart; - - /** - * @var int - */ - protected $id_carrier; - - /** - * @var int|null - */ - protected $orderId; - - /** - * @var CartRowCollection collection of cart content row (product+qty) - */ - protected $cartRows; - - /** - * @var CartRuleCollection - */ - protected $cartRules; - - /** - * @var Fees - */ - protected $fees; - - /** - * @var CartRuleCalculator - */ - protected $cartRuleCalculator; - - /** - * indicates if cart was already processed. - * - * @var bool - */ - protected $isProcessed = false; - - /** - * @var int|null - */ - protected $computePrecision; - - /** - * @param Cart $cart - * @param $carrierId - * @param int|null $computePrecision - * @param int|null $orderId - */ - public function __construct(Cart $cart, $carrierId, ?int $computePrecision = null, ?int $orderId = null) - { - $this->setCart($cart); - $this->setCarrierId($carrierId); - $this->orderId = $orderId; - $this->cartRows = new CartRowCollection(); - $this->fees = new Fees($this->orderId); - $this->cartRules = new CartRuleCollection(); - $this->cartRuleCalculator = new CartRuleCalculator(); - - if (null === $computePrecision) { - $currency = new Currency((int) $cart->id_currency); - $computePrecision = (new ComputingPrecision())->getPrecision($currency->precision); - } - $this->computePrecision = $computePrecision; - } - - /** - * insert a new cart row in the calculator. - * - * @param CartRow $cartRow cart item row (product+qty informations) - * - * @return $this - */ - public function addCartRow(CartRow $cartRow) - { - // reset state - $this->isProcessed = false; - - $this->cartRows->addCartRow($cartRow); - - return $this; - } - - /** - * insert a new cart rule in the calculator. - * - * @param \PrestaShop\PrestaShop\Core\Cart\CartRuleData $cartRule - * - * @return $this - */ - public function addCartRule(CartRuleData $cartRule) - { - // reset state - $this->isProcessed = false; - - $this->cartRules->addCartRule($cartRule); - - return $this; - } - - /** - * run the whole calculation process: calculate rows, discounts, fees. - * - * @param int $computePrecision Not used since 1.7.7.0, kept for backward compatibility - * - * @return $this - */ - public function processCalculation($computePrecision = null) - { - // calculate product rows - $this->calculateRows(); - // calculate fees - $this->calculateFees(); - // calculate discounts - $this->calculateCartRules(); - // store state - $this->isProcessed = true; - - return $this; - } - - /** - * @param bool $ignoreProcessedFlag force getting total even if calculation was not made internaly - * - * @return AmountImmutable - * - * @throws \Exception - */ - public function getTotal($ignoreProcessedFlag = false) - { - if (!$this->isProcessed && !$ignoreProcessedFlag) { - throw new \Exception('Cart must be processed before getting its total'); - } - - $amount = $this->getRowTotalWithoutDiscount(); - $amount = $amount->sub($this->rounded($this->getDiscountTotal(), $this->computePrecision)); - $shippingFees = $this->fees->getInitialShippingFees(); - if (null !== $shippingFees) { - $amount = $amount->add($this->rounded($shippingFees, $this->computePrecision)); - } - $wrappingFees = $this->fees->getFinalWrappingFees(); - if (null !== $wrappingFees) { - $amount = $amount->add($this->rounded($wrappingFees, $this->computePrecision)); - } - - return $amount; - } - - /** - * @return AmountImmutable - * - * @throws \Exception - */ - public function getRowTotal() - { - $amount = new AmountImmutable(); - foreach ($this->cartRows as $cartRow) { - $amount = $amount->add($cartRow->getFinalTotalPrice()); - } - - return $amount; - } - - /** - * @return AmountImmutable - * - * @throws \Exception - */ - public function getRowTotalWithoutDiscount() - { - $amount = new AmountImmutable(); - foreach ($this->cartRows as $cartRow) { - $amount = $amount->add($cartRow->getInitialTotalPrice()); - } - - return $amount; - } - - /** - * @return AmountImmutable - * - * @throws \Exception - */ - public function getDiscountTotal() - { - $amount = new AmountImmutable(); - $isFreeShippingAppliedToAmount = false; - foreach ($this->cartRules as $cartRule) { - if ((bool) $cartRule->getRuleData()['free_shipping']) { - if ($isFreeShippingAppliedToAmount) { - $initialShippingFees = $this->getFees()->getInitialShippingFees(); - $amount = $amount->sub($initialShippingFees); - } - $isFreeShippingAppliedToAmount = true; - } - $amount = $amount->add($cartRule->getDiscountApplied()); - } - - $allowedMaxDiscount = $this->getRowTotalWithoutDiscount(); - - if (null !== $this->getFees()->getInitialShippingFees() && null !== $this->getFees()->getFinalShippingFees()) { - $shippingDiscount = (new AmountImmutable()) - ->add($this->getFees()->getInitialShippingFees()) - ->sub($this->getFees()->getFinalShippingFees()) - ; - $allowedMaxDiscount = $allowedMaxDiscount->add($shippingDiscount); - } - // discount cannot be above total cart price - if ($amount > $allowedMaxDiscount) { - $amount = $allowedMaxDiscount; - } - - return $amount; - } - - /** - * @param \CartCore $cart - * - * @return Calculator - */ - protected function setCart($cart) - { - // reset state - $this->isProcessed = false; - - $this->cart = $cart; - - return $this; - } - - /** - * @param mixed $id_carrier - * - * @return Calculator - */ - protected function setCarrierId($id_carrier) - { - // reset state - $this->isProcessed = false; - - $this->id_carrier = $id_carrier; - - return $this; - } - - /** - * @return \PrestaShop\PrestaShop\Core\Cart\Fees - */ - public function getFees() - { - return $this->fees; - } - - /** - * @return \Cart - */ - public function getCart() - { - return $this->cart; - } - - /** - * Calculate row total. - * - * @param CartRow $cartRow - */ - protected function calculateRowTotal(CartRow $cartRow) - { - $cartRow->processCalculation($this->cart); - } - - /** - * calculate only product rows. - */ - public function calculateRows() - { - foreach ($this->cartRows as $cartRow) { - $this->calculateRowTotal($cartRow); - } - } - - /** - * calculate only cart rules (rows and fees have to be calculated first). - */ - public function calculateCartRules() - { - $this->cartRuleCalculator->setCartRules($this->cartRules) - ->setCartRows($this->cartRows) - ->setCalculator($this) - ->applyCartRules(); - } - - /** - * calculate only cart rules (rows and fees have to be calculated first), but don't process free-shipping discount - * (avoid loop on shipping calculation) - */ - public function calculateCartRulesWithoutFreeShipping() - { - $this->cartRuleCalculator->setCartRules($this->cartRules) - ->setCartRows($this->cartRows) - ->setCalculator($this) - ->applyCartRulesWithoutFreeShipping(); - } - - /** - * calculate wrapping and shipping fees (rows have to be calculated first). - * - * @param int|null $computePrecision Not used since 1.7.7.0, kept for backward compatibility - */ - public function calculateFees($computePrecision = null) - { - $this->fees->processCalculation($this->cart, $this->cartRows, $this->computePrecision, $this->id_carrier); - } - - /** - * @return CartRuleCollection - */ - public function getCartRulesData() - { - return $this->cartRuleCalculator->getCartRulesData(); - } - - /** - * @param AmountImmutable $amount - * @param int $computePrecision - * - * @return AmountImmutable - */ - private function rounded(AmountImmutable $amount, int $computePrecision) - { - return new AmountImmutable( - Tools::ps_round($amount->getTaxIncluded(), $computePrecision), - Tools::ps_round($amount->getTaxExcluded(), $computePrecision) - ); - } -} diff --git a/src/Core/Cart/CartRow.php b/src/Core/Cart/CartRow.php deleted file mode 100644 index 39bca200..00000000 --- a/src/Core/Cart/CartRow.php +++ /dev/null @@ -1,514 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Cart; - -use Cart; -use PrestaShop\PrestaShop\Adapter\AddressFactory; -use PrestaShop\PrestaShop\Adapter\Cache\CacheAdapter; -use PrestaShop\PrestaShop\Adapter\CoreException; -use PrestaShop\PrestaShop\Adapter\Customer\CustomerDataProvider; -use PrestaShop\PrestaShop\Adapter\Database; -use PrestaShop\PrestaShop\Adapter\Group\GroupDataProvider; -use PrestaShop\PrestaShop\Adapter\Product\PriceCalculator; -use PrestaShop\PrestaShop\Adapter\Tools; - -/** - * represent a cart row, ie a product and a quantity, and some post-process data like cart rule applied. - */ -class CartRow -{ - /** - * row round mode by item. - */ - const ROUND_MODE_ITEM = 'item'; - - /** - * row round mode by line. - */ - const ROUND_MODE_LINE = 'line'; - - /** - * row round mode by all lines. - */ - const ROUND_MODE_TOTAL = 'total'; - - /** - * static cache key pattern. - */ - const PRODUCT_PRICE_CACHE_ID_PATTERN = 'Product::getPriceStatic_%d-%d'; - - /** - * @var PriceCalculator adapter to calculate price - */ - protected $priceCalculator; - - /** - * @var AddressFactory adapter to get address informations - */ - protected $addressFactory; - - /** - * @var CustomerDataProvider adapter to get customer informations - */ - protected $customerDataProvider; - - /** - * @var GroupDataProvider adapter to get group informations - */ - protected $groupDataProvider; - - /** - * @var Database adapter to get database - */ - protected $databaseAdapter; - - /** - * @var CacheAdapter adapter to get cache - */ - protected $cacheAdapter; - - /** - * @var bool calculation will use ecotax - */ - protected $useEcotax; - - /** - * @var int calculation precision (decimals count) - */ - protected $precision; - - /** - * @var string round mode : see self::ROUND_MODE_xxx - */ - protected $roundType; - - /** - * @var int|null - */ - protected $orderId; - - /** - * @var array previous data for product: array given by Cart::getProducts() - */ - protected $rowData = []; - - /** - * @var AmountImmutable - */ - protected $initialUnitPrice; - - /** - * @var AmountImmutable - */ - protected $initialTotalPrice; - - /** - * @var AmountImmutable - */ - protected $finalUnitPrice; - - /** - * @var AmountImmutable - */ - protected $finalTotalPrice; - - /** - * @var bool indicates if the calculation was triggered (reset on data changes) - */ - protected $isProcessed = false; - - /** - * @param array $rowData array item given by Cart::getProducts() - * @param PriceCalculator $priceCalculator - * @param AddressFactory $addressFactory - * @param CustomerDataProvider $customerDataProvider - * @param CacheAdapter $cacheAdapter - * @param GroupDataProvider $groupDataProvider - * @param Database $databaseAdapter - * @param bool $useEcotax - * @param int $precision - * @param string $roundType see self::ROUND_MODE_* - * @param int|null $orderId If order ID is specified the product price is fetched from associated OrderDetail value - */ - public function __construct( - $rowData, - PriceCalculator $priceCalculator, - AddressFactory $addressFactory, - CustomerDataProvider $customerDataProvider, - CacheAdapter $cacheAdapter, - GroupDataProvider $groupDataProvider, - Database $databaseAdapter, - $useEcotax, - $precision, - $roundType, - $orderId = null - ) { - $this->setRowData($rowData); - $this->priceCalculator = $priceCalculator; - $this->addressFactory = $addressFactory; - $this->customerDataProvider = $customerDataProvider; - $this->cacheAdapter = $cacheAdapter; - $this->groupDataProvider = $groupDataProvider; - $this->databaseAdapter = $databaseAdapter; - $this->useEcotax = $useEcotax; - $this->precision = $precision; - $this->roundType = $roundType; - $this->orderId = $orderId; - } - - /** - * @param array $rowData - * - * @return CartRow - */ - public function setRowData($rowData) - { - $this->rowData = $rowData; - - return $this; - } - - /** - * @return array - */ - public function getRowData() - { - return $this->rowData; - } - - /** - * Returns the initial unit price (ie without applying cart rules). - * - * @return AmountImmutable - * - * @throws \Exception - */ - public function getInitialUnitPrice() - { - if (!$this->isProcessed) { - throw new \Exception('Row must be processed before getting its total'); - } - - return $this->initialUnitPrice; - } - - /** - * Returns the initial total price (ie without applying cart rules). - * - * @return AmountImmutable - * - * @throws \Exception - */ - public function getInitialTotalPrice() - { - if (!$this->isProcessed) { - throw new \Exception('Row must be processed before getting its total'); - } - - return $this->initialTotalPrice; - } - - /** - * return final price: initial minus the cart rule discounts. - * - * @return AmountImmutable - * - * @throws \Exception - */ - public function getFinalUnitPrice() - { - if (!$this->isProcessed) { - throw new \Exception('Row must be processed before getting its total'); - } - - return $this->finalUnitPrice; - } - - /** - * return final price: initial minus the cart rule discounts. - * - * @return AmountImmutable - * - * @throws \Exception - */ - public function getFinalTotalPrice() - { - if (!$this->isProcessed) { - throw new \Exception('Row must be processed before getting its total'); - } - - return $this->finalTotalPrice; - } - - /** - * run initial row calculation. - * - * @param Cart $cart - * - * @throws CoreException - */ - public function processCalculation(Cart $cart) - { - $rowData = $this->getRowData(); - $quantity = (int) $rowData['cart_quantity']; - $this->initialUnitPrice = $this->getProductPrice($cart, $rowData); - - // store not rounded values, except in round_mode_item, we still need to round individual items - if ($this->roundType == self::ROUND_MODE_ITEM) { - $tools = new Tools(); - $this->initialTotalPrice = new AmountImmutable( - $tools->round($this->initialUnitPrice->getTaxIncluded(), $this->precision) * $quantity, - $tools->round($this->initialUnitPrice->getTaxExcluded(), $this->precision) * $quantity - ); - } else { - $this->initialTotalPrice = new AmountImmutable( - $this->initialUnitPrice->getTaxIncluded() * $quantity, - $this->initialUnitPrice->getTaxExcluded() * $quantity - ); - } - - $this->finalTotalPrice = clone $this->initialTotalPrice; - $this->applyRound(); - // store state - $this->isProcessed = true; - } - - protected function getProductPrice(Cart $cart, $rowData) - { - $productId = (int) $rowData['id_product']; - $quantity = (int) $rowData['cart_quantity']; - - $addressId = $cart->getProductAddressId($rowData); - if (!$addressId) { - $addressId = $cart->getTaxAddressId(); - } - $address = $this->addressFactory->findOrCreate($addressId, true); - $countryId = (int) $address->id_country; - $stateId = (int) $address->id_state; - $zipCode = $address->postcode; - - $shopId = (int) $rowData['id_shop']; - $currencyId = (int) $cart->id_currency; - - $groupId = null; - if ($cart->id_customer) { - $groupId = $this->customerDataProvider->getDefaultGroupId((int) $cart->id_customer); - } - if (!$groupId) { - $groupId = (int) $this->groupDataProvider->getCurrent()->id; - } - - $cartQuantity = 0; - if ((int) $cart->id) { - $cacheId = sprintf(self::PRODUCT_PRICE_CACHE_ID_PATTERN, (int) $productId, (int) $cart->id); - if (!$this->cacheAdapter->isStored($cacheId) - || ($cartQuantity = $this->cacheAdapter->retrieve($cacheId) - != (int) $quantity)) { - $sql = 'SELECT SUM(`quantity`) - FROM `' . _DB_PREFIX_ . 'cart_product` - WHERE `id_product` = ' . (int) $productId . ' - AND `id_cart` = ' . (int) $cart->id; - $cartQuantity = (int) $this->databaseAdapter->getValue($sql, _PS_USE_SQL_SLAVE_); - $this->cacheAdapter->store($cacheId, $cartQuantity); - } else { - $cartQuantity = $this->cacheAdapter->retrieve($cacheId); - } - } - - // The $null variable below is not used, - // but it is necessary to pass it to getProductPrice because - // it expects a reference. - $specificPriceOutput = null; - - $productPrices = [ - 'price_tax_included' => [ - 'withTaxes' => true, - ], - 'price_tax_excluded' => [ - 'withTaxes' => false, - ], - ]; - foreach ($productPrices as $productPrice => $computationParameters) { - $productPrices[$productPrice]['value'] = null; - if (null !== $this->orderId) { - $productPrices[$productPrice]['value'] = $this->priceCalculator->getOrderPrice( - $this->orderId, - (int) $productId, - (int) $rowData['id_product_attribute'], - $computationParameters['withTaxes'], - true, - $this->useEcotax - ); - } - if (null === $productPrices[$productPrice]['value']) { - $productPrices[$productPrice]['value'] = $this->priceCalculator->priceCalculation( - $shopId, - (int) $productId, - (int) $rowData['id_product_attribute'], - $countryId, - $stateId, - $zipCode, - $currencyId, - $groupId, - $quantity, - $computationParameters['withTaxes'], - 6, - false, - true, - $this->useEcotax, - $specificPriceOutput, - true, - (int) $cart->id_customer ? (int) $cart->id_customer : null, - true, - (int) $cart->id, - $cartQuantity, - (int) $rowData['id_customization'] - ); - } - } - - return new AmountImmutable( - $productPrices['price_tax_included']['value'], - $productPrices['price_tax_excluded']['value'] - ); - } - - /** - * depending on attribute roundType, rounds the item/line value. - */ - protected function applyRound() - { - // ROUNDING MODE - $this->finalUnitPrice = clone $this->initialUnitPrice; - - $rowData = $this->getRowData(); - $quantity = (int) $rowData['cart_quantity']; - $tools = new Tools(); - switch ($this->roundType) { - case self::ROUND_MODE_TOTAL: - // do not round the line - $this->finalTotalPrice = new AmountImmutable( - $this->initialUnitPrice->getTaxIncluded() * $quantity, - $this->initialUnitPrice->getTaxExcluded() * $quantity - ); - - break; - case self::ROUND_MODE_LINE: - // round line result - $this->finalTotalPrice = new AmountImmutable( - $tools->round($this->initialUnitPrice->getTaxIncluded() * $quantity, $this->precision), - $tools->round($this->initialUnitPrice->getTaxExcluded() * $quantity, $this->precision) - ); - - break; - - case self::ROUND_MODE_ITEM: - default: - // round each item - $this->initialUnitPrice = new AmountImmutable( - $tools->round($this->initialUnitPrice->getTaxIncluded(), $this->precision), - $tools->round($this->initialUnitPrice->getTaxExcluded(), $this->precision) - ); - $this->finalTotalPrice = new AmountImmutable( - $this->initialUnitPrice->getTaxIncluded() * $quantity, - $this->initialUnitPrice->getTaxExcluded() * $quantity - ); - break; - } - } - - /** - * substract discount from the row - * if discount exceeds amount, we keep 0 (no use of negative amounts). - * - * @param AmountImmutable $amount - */ - public function applyFlatDiscount(AmountImmutable $amount) - { - $taxIncluded = $this->finalTotalPrice->getTaxIncluded() - $amount->getTaxIncluded(); - $taxExcluded = $this->finalTotalPrice->getTaxExcluded() - $amount->getTaxExcluded(); - if ($taxIncluded < 0) { - $taxIncluded = 0; - } - if ($taxExcluded < 0) { - $taxExcluded = 0; - } - $this->finalTotalPrice = new AmountImmutable( - $taxIncluded, - $taxExcluded - ); - - $this->updateFinalUnitPrice(); - } - - /** - * @param float $percent 0-100 - * - * @return AmountImmutable - */ - public function applyPercentageDiscount($percent) - { - $percent = (float) $percent; - if ($percent < 0 || $percent > 100) { - throw new \Exception('Invalid percentage discount given: ' . $percent); - } - $discountTaxIncluded = $this->finalTotalPrice->getTaxIncluded() * $percent / 100; - $discountTaxExcluded = $this->finalTotalPrice->getTaxExcluded() * $percent / 100; - $amount = new AmountImmutable($discountTaxIncluded, $discountTaxExcluded); - $this->applyFlatDiscount($amount); - - return $amount; - } - - /** - * when final row price is calculated, we need to update unit price. - */ - protected function updateFinalUnitPrice() - { - $rowData = $this->getRowData(); - $quantity = (int) $rowData['cart_quantity']; - $taxIncluded = $this->finalTotalPrice->getTaxIncluded(); - $taxExcluded = $this->finalTotalPrice->getTaxExcluded(); - // Avoid division by zero - if (0 === $quantity) { - $this->finalUnitPrice = new AmountImmutable(0, 0); - } else { - $this->finalUnitPrice = new AmountImmutable( - $taxIncluded / $quantity, - $taxExcluded / $quantity - ); - } - } - - /** - * @return string - */ - public function getRoundType() - { - return $this->roundType; - } -} diff --git a/src/Core/Cart/CartRowCollection.php b/src/Core/Cart/CartRowCollection.php deleted file mode 100644 index 45e6d98d..00000000 --- a/src/Core/Cart/CartRowCollection.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Cart; - -class CartRowCollection implements \Iterator, \Countable -{ - /** - * @var CartRow[] - */ - protected $cartRows = []; - protected $iteratorPosition = 0; - - public function addCartRow(CartRow $cartRow) - { - $this->cartRows[] = $cartRow; - } - - public function rewind() - { - $this->iteratorPosition = 0; - } - - /** - * @return CartRow - */ - public function current() - { - return $this->cartRows[$this->getKey($this->iteratorPosition)]; - } - - public function key() - { - return $this->getKey($this->iteratorPosition); - } - - public function next() - { - ++$this->iteratorPosition; - } - - public function valid() - { - return $this->getKey($this->iteratorPosition) !== null - && array_key_exists( - $this->getKey($this->iteratorPosition), - $this->cartRows - ); - } - - protected function getKey($iteratorPosition) - { - $keys = array_keys($this->cartRows); - if (!isset($keys[$iteratorPosition])) { - return null; - } else { - return $keys[$iteratorPosition]; - } - } - - public function count() - { - return count($this->cartRows); - } - - /** - * return product data as array. - * - * @return array - */ - public function getProducts() - { - $products = []; - foreach ($this->cartRows as $cartRow) { - $products[] = $cartRow->getRowData(); - } - - return $products; - } -} diff --git a/src/Core/Cart/CartRuleCalculator.php b/src/Core/Cart/CartRuleCalculator.php deleted file mode 100644 index a1e74653..00000000 --- a/src/Core/Cart/CartRuleCalculator.php +++ /dev/null @@ -1,312 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Cart; - -use Cart; - -class CartRuleCalculator -{ - /** - * @var Calculator - */ - protected $calculator; - - /** - * @var CartRowCollection - */ - protected $cartRows; - - /** - * @var CartRuleCollection - */ - protected $cartRules; - - /** - * @var Fees - */ - protected $fees; - - /** - * process cartrules calculation - */ - public function applyCartRules() - { - foreach ($this->cartRules as $cartRule) { - $this->applyCartRule($cartRule); - } - } - - /** - * process cartrules calculation, excluding free-shipping processing - */ - public function applyCartRulesWithoutFreeShipping() - { - foreach ($this->cartRules as $cartRule) { - $this->applyCartRule($cartRule, false); - } - } - - /** - * @param \PrestaShop\PrestaShop\Core\Cart\CartRuleCollection $cartRules - * - * @return CartRuleCalculator - */ - public function setCartRules($cartRules) - { - $this->cartRules = $cartRules; - - return $this; - } - - /** - * @param CartRuleData $cartRuleData - * @param bool $withFreeShipping used to calculate free shipping discount (avoid loop on shipping calculation) - * - * @throws \PrestaShopDatabaseException - */ - protected function applyCartRule(CartRuleData $cartRuleData, $withFreeShipping = true) - { - $cartRule = $cartRuleData->getCartRule(); - $cart = $this->calculator->getCart(); - - if (!\CartRule::isFeatureActive()) { - return; - } - - // Free shipping on selected carriers - if ($cartRule->free_shipping && $withFreeShipping) { - $initialShippingFees = $this->calculator->getFees()->getInitialShippingFees(); - $this->calculator->getFees()->subDiscountValueShipping($initialShippingFees); - $cartRuleData->addDiscountApplied($initialShippingFees); - } - - // Free gift - if ((int) $cartRule->gift_product) { - foreach ($this->cartRows as $cartRow) { - $product = $cartRow->getRowData(); - if ($product['id_product'] == $cartRule->gift_product - && ($product['id_product_attribute'] == $cartRule->gift_product_attribute - || !(int) $cartRule->gift_product_attribute) - ) { - $cartRuleData->addDiscountApplied($cartRow->getInitialUnitPrice()); - $cartRow->applyFlatDiscount($cartRow->getInitialUnitPrice()); - } - } - } - - // Discount (%) on the whole order - if ((float) $cartRule->reduction_percent > 0) { - if ($cartRule->reduction_product == 0) { - foreach ($this->cartRows as $cartRow) { - $product = $cartRow->getRowData(); - if ( - array_key_exists('product_quantity', $product) && - 0 === (int) $product['product_quantity'] - ) { - $cartRuleData->addDiscountApplied(new AmountImmutable(0.0, 0.0)); - } elseif ((($cartRule->reduction_exclude_special && !$product['reduction_applies']) - || !$cartRule->reduction_exclude_special)) { - $amount = $cartRow->applyPercentageDiscount($cartRule->reduction_percent); - $cartRuleData->addDiscountApplied($amount); - } - } - } - - // Discount (%) on a specific product - if ($cartRule->reduction_product > 0) { - foreach ($this->cartRows as $cartRow) { - if ($cartRow->getRowData()['id_product'] == $cartRule->reduction_product) { - $amount = $cartRow->applyPercentageDiscount($cartRule->reduction_percent); - $cartRuleData->addDiscountApplied($amount); - } - } - } - - // Discount (%) on the cheapest product - if ($cartRule->reduction_product == -1) { - /** @var CartRow|null $cartRowCheapest */ - $cartRowCheapest = null; - foreach ($this->cartRows as $cartRow) { - $product = $cartRow->getRowData(); - if (((($cartRule->reduction_exclude_special && !$product['reduction_applies']) - || !$cartRule->reduction_exclude_special)) && ($cartRowCheapest === null - || $cartRowCheapest->getInitialUnitPrice()->getTaxIncluded() > $cartRow->getInitialUnitPrice() - ->getTaxIncluded()) - ) { - $cartRowCheapest = $cartRow; - } - } - if ($cartRowCheapest !== null) { - // apply only on one product of the cheapest row - $discountTaxIncluded = $cartRowCheapest->getInitialUnitPrice()->getTaxIncluded() - * $cartRule->reduction_percent / 100; - $discountTaxExcluded = $cartRowCheapest->getInitialUnitPrice()->getTaxExcluded() - * $cartRule->reduction_percent / 100; - $amount = new AmountImmutable($discountTaxIncluded, $discountTaxExcluded); - $cartRowCheapest->applyFlatDiscount($amount); - $cartRuleData->addDiscountApplied($amount); - } - } - - // Discount (%) on the selection of products - if ($cartRule->reduction_product == -2) { - $selected_products = $cartRule->checkProductRestrictionsFromCart($cart, true); - if (is_array($selected_products)) { - foreach ($this->cartRows as $cartRow) { - $product = $cartRow->getRowData(); - if ((in_array($product['id_product'] . '-' . $product['id_product_attribute'], $selected_products) - || in_array($product['id_product'] . '-0', $selected_products)) - && (($cartRule->reduction_exclude_special && !$product['reduction_applies']) - || !$cartRule->reduction_exclude_special)) { - $amount = $cartRow->applyPercentageDiscount($cartRule->reduction_percent); - $cartRuleData->addDiscountApplied($amount); - } - } - } - } - } - - // Discount (¤) : weighted calculation on all concerned rows - // weight factor got from price with same tax (incl/excl) as voucher - if ((float) $cartRule->reduction_amount > 0) { - $concernedRows = new CartRowCollection(); - if ($cartRule->reduction_product > 0) { - // discount on single product - foreach ($this->cartRows as $cartRow) { - if ($cartRow->getRowData()['id_product'] == $cartRule->reduction_product) { - $concernedRows->addCartRow($cartRow); - } - } - } elseif ($cartRule->reduction_product == 0) { - // Discount (¤) on the whole order - $concernedRows = $this->cartRows; - } - /* - * Reduction on the cheapest or on the selection is not really meaningful and has been disabled in the backend - * Please keep this code, so it won't be considered as a bug - * elseif ($this->reduction_product == -1) - * elseif ($this->reduction_product == -2) - */ - - // currency conversion - $discountConverted = $this->convertAmountBetweenCurrencies( - $cartRule->reduction_amount, - new \Currency($cartRule->reduction_currency), - new \Currency($cart->id_currency) - ); - - // get total of concerned rows - $totalTaxIncl = $totalTaxExcl = 0; - foreach ($concernedRows as $concernedRow) { - $totalTaxIncl += $concernedRow->getFinalTotalPrice()->getTaxIncluded(); - $totalTaxExcl += $concernedRow->getFinalTotalPrice()->getTaxExcluded(); - } - - // The reduction cannot exceed the products total, except when we do not want it to be limited (for the partial use calculation) - $discountConverted = min($discountConverted, $cartRule->reduction_tax ? $totalTaxIncl : $totalTaxExcl); - - // apply weighted discount : - // on each line we apply a part of the discount corresponding to discount*rowWeight/total - foreach ($concernedRows as $concernedRow) { - // get current line tax rate - $taxRate = 0; - if ($concernedRow->getFinalTotalPrice()->getTaxExcluded() != 0) { - $taxRate = ($concernedRow->getFinalTotalPrice()->getTaxIncluded() - - $concernedRow->getFinalTotalPrice()->getTaxExcluded()) - / $concernedRow->getFinalTotalPrice()->getTaxExcluded(); - } - $weightFactor = 0; - if ($cartRule->reduction_tax) { - // if cart rule amount is set tax included : calculate weight tax included - if ($totalTaxIncl != 0) { - $weightFactor = $concernedRow->getFinalTotalPrice()->getTaxIncluded() / $totalTaxIncl; - } - $discountAmountTaxIncl = $discountConverted * $weightFactor; - // recalculate tax included - $discountAmountTaxExcl = $discountAmountTaxIncl / (1 + $taxRate); - } else { - // if cart rule amount is set tax excluded : calculate weight tax excluded - if ($totalTaxExcl != 0) { - $weightFactor = $concernedRow->getFinalTotalPrice()->getTaxExcluded() / $totalTaxExcl; - } - $discountAmountTaxExcl = $discountConverted * $weightFactor; - // recalculate tax excluded - $discountAmountTaxIncl = $discountAmountTaxExcl * (1 + $taxRate); - } - $amount = new AmountImmutable($discountAmountTaxIncl, $discountAmountTaxExcl); - $concernedRow->applyFlatDiscount($amount); - $cartRuleData->addDiscountApplied($amount); - } - } - } - - /** - * @param \PrestaShop\PrestaShop\Core\Cart\Calculator $calculator - * - * @return CartRuleCalculator - */ - public function setCalculator($calculator) - { - $this->calculator = $calculator; - - return $this; - } - - protected function convertAmountBetweenCurrencies($amount, \Currency $currencyFrom, \Currency $currencyTo) - { - if ($amount == 0 || $currencyFrom->conversion_rate == 0) { - return 0; - } - - // convert to default currency - $amount /= $currencyFrom->conversion_rate; - // convert to destination currency - $amount *= $currencyTo->conversion_rate; - - return $amount; - } - - /** - * @param \PrestaShop\PrestaShop\Core\Cart\CartRowCollection $cartRows - * - * @return CartRuleCalculator - */ - public function setCartRows($cartRows) - { - $this->cartRows = $cartRows; - - return $this; - } - - /** - * @return CartRuleCollection - */ - public function getCartRulesData() - { - return $this->cartRules; - } -} diff --git a/src/Core/Cart/CartRuleCollection.php b/src/Core/Cart/CartRuleCollection.php deleted file mode 100644 index 6c6f0c96..00000000 --- a/src/Core/Cart/CartRuleCollection.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Cart; - -class CartRuleCollection implements \Iterator -{ - /** - * @var CartRuleData[] - */ - protected $cartRules = []; - protected $iteratorPosition = 0; - - public function addCartRule(CartRuleData $cartRule) - { - $this->cartRules[] = $cartRule; - } - - public function rewind() - { - $this->iteratorPosition = 0; - } - - /** - * @return CartRuleData - */ - public function current() - { - return $this->cartRules[$this->getKey($this->iteratorPosition)]; - } - - public function key() - { - return $this->getKey($this->iteratorPosition); - } - - public function next() - { - ++$this->iteratorPosition; - } - - public function valid() - { - return $this->getKey($this->iteratorPosition) !== null - && array_key_exists( - $this->getKey($this->iteratorPosition), - $this->cartRules - ); - } - - protected function getKey($iteratorPosition) - { - $keys = array_keys($this->cartRules); - if (!isset($keys[$iteratorPosition])) { - return null; - } else { - return $keys[$iteratorPosition]; - } - } -} diff --git a/src/Core/Cart/CartRuleData.php b/src/Core/Cart/CartRuleData.php deleted file mode 100644 index 0502087f..00000000 --- a/src/Core/Cart/CartRuleData.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Cart; - -class CartRuleData -{ - protected $ruleData = []; - - /** - * @var AmountImmutable - */ - protected $discountApplied; - - public function __construct($rowData) - { - $this->setRuleData($rowData); - $this->discountApplied = new AmountImmutable(); - } - - /** - * @param array $ruleData - * - * @return static - */ - public function setRuleData($ruleData) - { - $this->ruleData = $ruleData; - - return $this; - } - - /** - * @return array - */ - public function getRuleData() - { - return $this->ruleData; - } - - /** - * @return \CartRule - */ - public function getCartRule() - { - $cartRuleData = $this->getRuleData(); - - return $cartRuleData['obj']; - } - - public function addDiscountApplied(AmountImmutable $amount) - { - $this->discountApplied = $this->discountApplied->add($amount); - } - - /** - * @return AmountImmutable - */ - public function getDiscountApplied() - { - return $this->discountApplied; - } -} diff --git a/src/Core/Cart/Fees.php b/src/Core/Cart/Fees.php deleted file mode 100644 index 41562d85..00000000 --- a/src/Core/Cart/Fees.php +++ /dev/null @@ -1,205 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Cart; - -use Cart; -use Currency; -use Tools; - -class Fees -{ - /** - * @var Cart - */ - protected $cart; - - /** - * @var AmountImmutable - */ - protected $shippingFees; - - /** - * @var AmountImmutable - */ - protected $finalShippingFees; - - /** - * @var AmountImmutable - */ - protected $wrappingFees; - - /** - * @var AmountImmutable - */ - protected $finalWrappingFees; - - /** - * indicates if cart was already processed. - * - * @var bool - */ - protected $isProcessed = false; - - /** - * @var int|null - */ - protected $orderId; - - /** - * @param int|null $orderId - */ - public function __construct(?int $orderId = null) - { - $this->shippingFees = new AmountImmutable(); - $this->orderId = $orderId; - } - - /** - * @param Cart $cart - * @param CartRowCollection $cartRowCollection - * @param int $computePrecision - * @param int $id_carrier - */ - public function processCalculation( - Cart $cart, - CartRowCollection $cartRowCollection, - $computePrecision, - $id_carrier = null - ) { - if ($id_carrier === null) { - $this->shippingFees = new AmountImmutable( - $cart->getTotalShippingCost(null, true), - $cart->getTotalShippingCost(null, false) - ); - } else { - $products = $cartRowCollection->getProducts(); - $this->shippingFees = new AmountImmutable( - $cart->getPackageShippingCost( - (int) $id_carrier, - true, - null, - $products, - null, - null !== $this->orderId - ), - $cart->getPackageShippingCost( - (int) $id_carrier, - false, - null, - $products, - null, - null !== $this->orderId - ) - ); - } - $this->finalShippingFees = clone $this->shippingFees; - - // wrapping fees - if ($cart->gift) { - $this->wrappingFees = new AmountImmutable( - Tools::convertPrice( - Tools::ps_round( - $cart->getGiftWrappingPrice(true), - $computePrecision - ), - Currency::getCurrencyInstance((int) $cart->id_currency) - ), - Tools::convertPrice( - Tools::ps_round( - $cart->getGiftWrappingPrice(false), - $computePrecision - ), - Currency::getCurrencyInstance((int) $cart->id_currency) - ) - ); - } else { - $this->wrappingFees = new AmountImmutable(); - } - $this->finalWrappingFees = clone $this->wrappingFees; - $this->isProcessed = true; - } - - /** - * @param Cart $cart - * - * @return Fees - */ - public function setCart($cart) - { - $this->cart = $cart; - - return $this; - } - - /** - * @return AmountImmutable - */ - public function getInitialShippingFees() - { - return $this->shippingFees; - } - - /** - * @return AmountImmutable - */ - public function getFinalShippingFees() - { - return $this->finalShippingFees; - } - - /** - * @return AmountImmutable - */ - public function getFinalWrappingFees() - { - return $this->finalWrappingFees; - } - - /** - * @return AmountImmutable - */ - public function getInitialWrappingFees() - { - return $this->wrappingFees; - } - - public function subDiscountValueShipping(AmountImmutable $amount) - { - $taxIncluded = $this->finalShippingFees->getTaxIncluded() - $amount->getTaxIncluded(); - $taxExcluded = $this->finalShippingFees->getTaxExcluded() - $amount->getTaxExcluded(); - if ($taxIncluded < 0) { - $taxIncluded = 0; - } - if ($taxExcluded < 0) { - $taxExcluded = 0; - } - $this->finalShippingFees = new AmountImmutable( - $taxIncluded, - $taxExcluded - ); - } -} diff --git a/src/Core/Checkout/TermsAndConditions.php b/src/Core/Checkout/TermsAndConditions.php deleted file mode 100644 index f79293f5..00000000 --- a/src/Core/Checkout/TermsAndConditions.php +++ /dev/null @@ -1,138 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Checkout; - -/** - * TermsAndConditions object is used to render "terms and conditions" text sections with links in it - * - * @todo: refactor this class to make it stateless - */ -class TermsAndConditions -{ - /** - * CSS identifier used to build the tag ID - * - * @var string - */ - private $identifier; - - /** - * List of URLs to use, following a numerical index - * - * @var string[] - */ - private $links; - - /** - * @var string - */ - private $rawText; - - /** - * @param string $identifier - * - * @return $this - */ - public function setIdentifier($identifier) - { - $this->identifier = $identifier; - - return $this; - } - - /** - * This function expects more than 1 argument: additionnal arguments - * are used as links - * - * Exemple : $terms->setText('hello [world] [new]', 'http://www.world.com', 'http://new.com'); - * - * @param string $rawText - * - * @return $this - */ - public function setText($rawText) - { - $links = func_get_args(); - array_shift($links); - - $this->links = $links; - $this->rawText = $rawText; - - return $this; - } - - /** - * Parses given raw text, replacing all [something] statements with tags, - * using URLs from $this->links - * - * @return string formatted text, which now contains HTML tags - */ - public function format() - { - $index = 0; - - $formattedText = preg_replace_callback('/\[(.*?)\]/', function (array $match) use (&$index) { - $textToReplace = $match[1]; - - $thereIsAMatchingLink = isset($this->links[$index]); - if ($thereIsAMatchingLink === false) { - return $textToReplace; - } - - $replacement = sprintf( - '%s', - $this->links[$index], - $this->createLinkId($index), - $textToReplace - ); - - ++$index; - - return $replacement; - }, $this->rawText); - - return $formattedText; - } - - /** - * @return string - */ - public function getIdentifier() - { - return $this->identifier; - } - - /** - * @param int $index - * - * @return string - */ - protected function createLinkId($index) - { - return 'cta-' . $this->getIdentifier() . '-' . $index; - } -} diff --git a/src/Core/CommandBus/CommandBusInterface.php b/src/Core/CommandBus/CommandBusInterface.php deleted file mode 100644 index a88e4c82..00000000 --- a/src/Core/CommandBus/CommandBusInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\CommandBus; - -/** - * Interface CommandBusInterface defines contract for Commands bus. - */ -interface CommandBusInterface -{ - /** - * Handle command. - * - * @param object $command - */ - public function handle($command); -} diff --git a/src/Core/CommandBus/ExecutedCommandRegistry.php b/src/Core/CommandBus/ExecutedCommandRegistry.php deleted file mode 100644 index 7e86d1a8..00000000 --- a/src/Core/CommandBus/ExecutedCommandRegistry.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\CommandBus; - -use PrestaShop\PrestaShop\Core\CommandBus\Parser\CommandTypeParser; - -/** - * Stores information about executed commands/queries - */ -final class ExecutedCommandRegistry -{ - private const BACKTRACE_LIMIT = 10; - - /** - * @var array - */ - private $registry = [ - 'commands' => [], - 'queries' => [], - ]; - - /** - * @var CommandTypeParser - */ - private $commandTypeParser; - - /** - * @param CommandTypeParser $commandTypeParser - */ - public function __construct(CommandTypeParser $commandTypeParser) - { - $this->commandTypeParser = $commandTypeParser; - } - - /** - * @param object $command - * @param object $handler - */ - public function register($command, $handler): void - { - $commandClass = get_class($command); - $handlerClass = get_class($handler); - - $type = $this->commandTypeParser->parse($commandClass); - - $trace = $this->getTrace(); - - switch ($type) { - case 'Command': - $this->registry['commands'][] = [ - 'command' => $commandClass, - 'command_handler' => $handlerClass, - 'trace' => $trace, - ]; - break; - case 'Query': - $this->registry['queries'][] = [ - 'query' => $commandClass, - 'query_handler' => $handlerClass, - 'trace' => $trace, - ]; - break; - } - } - - /** - * @return array - */ - public function getExecutedCommands(): array - { - return $this->registry['commands']; - } - - /** - * @return array - */ - public function getExecutedQueries(): array - { - return $this->registry['queries']; - } - - /** - * Returns the file and line that invoked the handle method - * - * @return array - */ - private function getTrace(): array - { - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, self::BACKTRACE_LIMIT); - - foreach ($trace as $step) { - if ($step['class'] === TacticianCommandBusAdapter::class - && $step['function'] === 'handle' - ) { - return [ - 'file' => $step['file'], - 'line' => $step['line'], - ]; - } - } - - return [ - 'file' => 'Unknown', - 'line' => 0, - ]; - } -} diff --git a/src/Core/CommandBus/Middleware/CommandRegisterMiddleware.php b/src/Core/CommandBus/Middleware/CommandRegisterMiddleware.php deleted file mode 100644 index 476af167..00000000 --- a/src/Core/CommandBus/Middleware/CommandRegisterMiddleware.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\CommandBus\Middleware; - -use League\Tactician\Handler\CommandNameExtractor\CommandNameExtractor; -use League\Tactician\Handler\Locator\HandlerLocator; -use League\Tactician\Middleware; -use PrestaShop\PrestaShop\Core\CommandBus\ExecutedCommandRegistry; - -/** - * Registers every command that was executed in system - */ -final class CommandRegisterMiddleware implements Middleware -{ - /** - * @var HandlerLocator - */ - private $handlerLocator; - - /** - * @var CommandNameExtractor - */ - private $commandNameExtractor; - - /** - * @var ExecutedCommandRegistry - */ - private $executedCommandRegistry; - - /** - * @param HandlerLocator $handlerLocator - * @param CommandNameExtractor $commandNameExtractor - * @param ExecutedCommandRegistry $executedCommandRegistry - */ - public function __construct( - HandlerLocator $handlerLocator, - CommandNameExtractor $commandNameExtractor, - ExecutedCommandRegistry $executedCommandRegistry - ) { - $this->handlerLocator = $handlerLocator; - $this->commandNameExtractor = $commandNameExtractor; - $this->executedCommandRegistry = $executedCommandRegistry; - } - - /** - * {@inheritdoc} - */ - public function execute($command, callable $next) - { - $commandName = $this->commandNameExtractor->extract($command); - $handler = $this->handlerLocator->getHandlerForCommand($commandName); - - $this->executedCommandRegistry->register($command, $handler); - - return $next($command); - } -} diff --git a/src/Core/CommandBus/Parser/CommandDefinition.php b/src/Core/CommandBus/Parser/CommandDefinition.php deleted file mode 100644 index da99249d..00000000 --- a/src/Core/CommandBus/Parser/CommandDefinition.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\CommandBus\Parser; - -/** - * Transfers commands and queries definition data - */ -class CommandDefinition -{ - /** - * @var string - */ - private $className; - - /** - * @var string - */ - private $commandType; - - /** - * @var string - */ - private $description; - - /** - * @param string $className - * @param string $commandType - * @param string $description - */ - public function __construct($className, $commandType, $description) - { - $this->className = $className; - $this->commandType = $commandType; - $this->description = $description; - } - - /** - * @return string - */ - public function getClassName() - { - return $this->className; - } - - /** - * @return string - */ - public function getCommandType() - { - return $this->commandType; - } - - /** - * @return string - */ - public function getDescription() - { - return $this->description; - } -} diff --git a/src/Core/CommandBus/Parser/CommandDefinitionParser.php b/src/Core/CommandBus/Parser/CommandDefinitionParser.php deleted file mode 100644 index 8e4a5d9b..00000000 --- a/src/Core/CommandBus/Parser/CommandDefinitionParser.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\CommandBus\Parser; - -use ReflectionClass; -use ReflectionException; - -/** - * Parses commands and queries definitions - */ -final class CommandDefinitionParser -{ - /** - * @param string $commandName - * - * @return CommandDefinition - * - * @throws ReflectionException - */ - public function parseDefinition($commandName) - { - return new CommandDefinition( - $commandName, - $this->parseType($commandName), - $this->parseDescription($commandName) - ); - } - - /** - * Checks whether the command is of type Query or Command by provided name - * - * @param string $commandName - * - * @return string - */ - private function parseType($commandName) - { - if (strpos($commandName, '\Command\\')) { - return 'Command'; - } - - return 'Query'; - } - - /** - * @param string $commandName - * - * @return string - * - * @throws ReflectionException - */ - private function parseDescription($commandName) - { - /** - * Removes comment symbols, annotations, and line breaks. - */ - $commandName = preg_replace("/\/+\*\*|\*+\/|\*|@(\w+)\b(.*)|\n/", - '', - (new ReflectionClass($commandName))->getDocComment() - ); - - /** - * Replaces multiple spaces to single space - */ - $commandName = preg_replace('/ +/', ' ', $commandName); - - /* - * Strips whitespace from the beginning and end - */ - return trim($commandName); - } -} diff --git a/src/Core/CommandBus/Parser/CommandTypeParser.php b/src/Core/CommandBus/Parser/CommandTypeParser.php deleted file mode 100644 index 42c9a094..00000000 --- a/src/Core/CommandBus/Parser/CommandTypeParser.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\CommandBus\Parser; - -final class CommandTypeParser -{ - /** - * @param string $commandName Fully-qualified class name of command - * - * @return string - */ - public function parse($commandName) - { - if (strpos($commandName, '\Command\\')) { - return 'Command'; - } - - return 'Query'; - } -} diff --git a/src/Core/CommandBus/TacticianCommandBusAdapter.php b/src/Core/CommandBus/TacticianCommandBusAdapter.php deleted file mode 100644 index 275b0cfa..00000000 --- a/src/Core/CommandBus/TacticianCommandBusAdapter.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\CommandBus; - -use League\Tactician\CommandBus; - -/** - * Class TacticianCommandBusAdapter is Tactician's CommandsBus implementation for PrestaShop's contract. - */ -final class TacticianCommandBusAdapter implements CommandBusInterface -{ - /** - * @var CommandBus - */ - private $bus; - - /** - * @param CommandBus $bus - */ - public function __construct(CommandBus $bus) - { - $this->bus = $bus; - } - - /** - * {@inheritdoc} - */ - public function handle($command) - { - return $this->bus->handle($command); - } -} diff --git a/src/Core/Configuration/DataConfigurationInterface.php b/src/Core/Configuration/DataConfigurationInterface.php deleted file mode 100644 index 19a14bd2..00000000 --- a/src/Core/Configuration/DataConfigurationInterface.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Configuration; - -/** - * Retrieve and Manage configuration (used to manage forms in "Configure" section of back office). - */ -interface DataConfigurationInterface -{ - /** - * @return array - */ - public function getConfiguration(); - - /** - * @param array $configuration - * - * @return array if not empty, populated by validation errors - */ - public function updateConfiguration(array $configuration); - - /** - * Ensure the parameters passed are valid. - * - * @param array $configuration - * - * @return bool Returns true if no exception are thrown - */ - public function validateConfiguration(array $configuration); -} diff --git a/src/Core/Configuration/IniConfiguration.php b/src/Core/Configuration/IniConfiguration.php deleted file mode 100644 index 26ce1e6f..00000000 --- a/src/Core/Configuration/IniConfiguration.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Configuration; - -/** - * Gets ini configuration. - */ -class IniConfiguration -{ - /** - * Get max post max size from ini configuration in bytes. - * - * @return int - */ - public function getPostMaxSizeInBytes() - { - return $this->convertToBytes(ini_get('post_max_size')); - } - - /** - * Get maximum upload size allowed by the server in bytes. - * - * @return int - */ - public function getUploadMaxSizeInBytes() - { - return min( - $this->convertToBytes(ini_get('upload_max_filesize')), - $this->getPostMaxSizeInBytes() - ); - } - - /** - * Convert a numeric value to bytes. - * - * @param int $value - * - * @return int - */ - private function convertToBytes($value) - { - $bytes = (int) trim($value); - $last = strtolower($value[strlen($value) - 1]); - - switch ($last) { - case 'g': - $bytes *= 1024; - // no break to fall-through - case 'm': - $bytes *= 1024; - // no break to fall-through - case 'k': - $bytes *= 1024; - } - - return $bytes; - } -} diff --git a/src/Core/Configuration/PhpExtensionChecker.php b/src/Core/Configuration/PhpExtensionChecker.php deleted file mode 100644 index ef6632aa..00000000 --- a/src/Core/Configuration/PhpExtensionChecker.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Configuration; - -/** - * Class PhpExtensionChecker provides object-oriented way to check if PHP extensions are loaded. - */ -final class PhpExtensionChecker implements PhpExtensionCheckerInterface -{ - /** - * {@inheritdoc} - */ - public function loaded($extension) - { - return extension_loaded($extension); - } -} diff --git a/src/Core/Configuration/PhpExtensionCheckerInterface.php b/src/Core/Configuration/PhpExtensionCheckerInterface.php deleted file mode 100644 index 11ee4692..00000000 --- a/src/Core/Configuration/PhpExtensionCheckerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Configuration; - -/** - * Interface PhpExtensionCheckerInterface. - */ -interface PhpExtensionCheckerInterface -{ - /** - * Check if PHP extension is loaded or not. - * - * @param string $extension - * - * @return bool - */ - public function loaded($extension); -} diff --git a/src/Core/Configuration/UploadSizeConfiguration.php b/src/Core/Configuration/UploadSizeConfiguration.php deleted file mode 100644 index 606db134..00000000 --- a/src/Core/Configuration/UploadSizeConfiguration.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Configuration; - -class UploadSizeConfiguration implements UploadSizeConfigurationInterface -{ - /** - * @var IniConfiguration - */ - private $iniConfiguration; - - /** - * @param IniConfiguration $iniConfiguration - */ - public function __construct(IniConfiguration $iniConfiguration) - { - $this->iniConfiguration = $iniConfiguration; - } - - /** - * {@inheritdoc} - */ - public function getMaxUploadSizeInBytes(): int - { - return $this->iniConfiguration->getUploadMaxSizeInBytes(); - } - - /** - * {@inheritdoc} - */ - public function getPostMaxSizeInBytes(): int - { - return $this->iniConfiguration->getPostMaxSizeInBytes(); - } -} diff --git a/src/Core/Configuration/UploadSizeConfigurationInterface.php b/src/Core/Configuration/UploadSizeConfigurationInterface.php deleted file mode 100644 index e55e269f..00000000 --- a/src/Core/Configuration/UploadSizeConfigurationInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Configuration; - -interface UploadSizeConfigurationInterface -{ - /** - * @return int - */ - public function getMaxUploadSizeInBytes(): int; - - /** - * @return int - */ - public function getPostMaxSizeInBytes(): int; -} diff --git a/src/Core/ConfigurationInterface.php b/src/Core/ConfigurationInterface.php deleted file mode 100644 index 415d7453..00000000 --- a/src/Core/ConfigurationInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core; - -interface ConfigurationInterface -{ - public function get($key); - - public function set($key, $value); -} diff --git a/src/Core/ConstraintValidator/AddressDniRequiredValidator.php b/src/Core/ConstraintValidator/AddressDniRequiredValidator.php deleted file mode 100644 index 83ddb89c..00000000 --- a/src/Core/ConstraintValidator/AddressDniRequiredValidator.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator; - -use PrestaShop\PrestaShop\Core\Country\CountryRequiredFieldsProviderInterface; -use PrestaShop\PrestaShop\Core\Domain\Country\ValueObject\CountryId; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\Constraints\NotBlank; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\ConstraintViolationInterface; - -/** - * Validates address DNI according to the country value and fields requirement - */ -class AddressDniRequiredValidator extends ConstraintValidator -{ - /** - * @var CountryRequiredFieldsProviderInterface - */ - private $countryRequiredFieldsProvider; - - /** - * @param CountryRequiredFieldsProviderInterface $countryRequiredFieldsProvider - */ - public function __construct(CountryRequiredFieldsProviderInterface $countryRequiredFieldsProvider) - { - $this->countryRequiredFieldsProvider = $countryRequiredFieldsProvider; - } - - /** - * {@inheritdoc} - */ - public function validate($value, Constraint $constraint) - { - $countryId = new CountryId((int) $constraint->id_country); - - if ($this->countryRequiredFieldsProvider->isDniRequired($countryId) || $constraint->required) { - $constraints = [new NotBlank([ - 'message' => $constraint->message, - ])]; - - /** @var ConstraintViolationInterface[] $violations */ - $violations = $this->context->getValidator()->validate($value, $constraints); - foreach ($violations as $violation) { - $this->context->buildViolation($violation->getMessage()) - ->setTranslationDomain('Admin.Notifications.Error') - ->addViolation(); - } - } - } -} diff --git a/src/Core/ConstraintValidator/AddressStateRequiredValidator.php b/src/Core/ConstraintValidator/AddressStateRequiredValidator.php deleted file mode 100644 index 282fdf6d..00000000 --- a/src/Core/ConstraintValidator/AddressStateRequiredValidator.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator; - -use PrestaShop\PrestaShop\Core\Country\CountryRequiredFieldsProviderInterface; -use PrestaShop\PrestaShop\Core\Domain\Country\ValueObject\CountryId; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\Constraints\NotBlank; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\ConstraintViolationInterface; - -/** - * Validates address state choice by selected country value - */ -class AddressStateRequiredValidator extends ConstraintValidator -{ - /** - * @var CountryRequiredFieldsProviderInterface - */ - private $countryRequiredFieldsProvider; - - /** - * @param CountryRequiredFieldsProviderInterface $countryRequiredFieldsProvider - */ - public function __construct(CountryRequiredFieldsProviderInterface $countryRequiredFieldsProvider) - { - $this->countryRequiredFieldsProvider = $countryRequiredFieldsProvider; - } - - /** - * {@inheritdoc} - * - * @throws CountryConstraintException - */ - public function validate($value, Constraint $constraint) - { - $countryId = new CountryId((int) $constraint->id_country); - - if ($this->countryRequiredFieldsProvider->isStatesRequired($countryId)) { - $constraints = [new NotBlank([ - 'message' => $constraint->message, - ])]; - - /** @var ConstraintViolationInterface[] $violations */ - $violations = $this->context->getValidator()->validate($value, $constraints); - foreach ($violations as $violation) { - $this->context->buildViolation($violation->getMessage()) - ->setTranslationDomain('Admin.Notifications.Error') - ->addViolation(); - } - } - } -} diff --git a/src/Core/ConstraintValidator/AddressZipCodeValidator.php b/src/Core/ConstraintValidator/AddressZipCodeValidator.php deleted file mode 100644 index 4b63b6de..00000000 --- a/src/Core/ConstraintValidator/AddressZipCodeValidator.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator; - -use PrestaShop\PrestaShop\Core\Country\CountryZipCodeRequirements; -use PrestaShop\PrestaShop\Core\Country\CountryZipCodeRequirementsProviderInterface; -use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Country\ValueObject\CountryId; -use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\Constraints\NotBlank; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\ConstraintViolationInterface; - -/** - * Validator for address zip code value - */ -final class AddressZipCodeValidator extends ConstraintValidator -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var CountryZipCodeRequirementsProviderInterface - */ - private $requirementsProvider; - - /** - * @param TranslatorInterface $translator - * @param CountryZipCodeRequirementsProviderInterface $requirementsProvider - */ - public function __construct( - TranslatorInterface $translator, - CountryZipCodeRequirementsProviderInterface $requirementsProvider - ) { - $this->translator = $translator; - $this->requirementsProvider = $requirementsProvider; - } - - /** - * {@inheritdoc} - * - * @throws CountryConstraintException - */ - public function validate($value, Constraint $constraint) - { - $countryId = (int) $constraint->id_country; - - /** @var CountryZipCodeRequirements $requirements */ - $requirements = $this->requirementsProvider->getCountryZipCodeRequirements(new CountryId($countryId)); - - if ($requirements->isRequired() || $constraint->required) { - $constraints = [new NotBlank([ - 'message' => $constraint->requiredMessage, - ])]; - - /** @var ConstraintViolationInterface[] $violations */ - $violations = $this->context->getValidator()->validate($value, $constraints); - foreach ($violations as $violation) { - $this->context->buildViolation($violation->getMessage()) - ->setTranslationDomain('Admin.Notifications.Error') - ->addViolation(); - } - } - - if (null !== $requirements->getPattern() && !(bool) preg_match($requirements->getPattern(), $value)) { - $message = $this->translator->trans('Your Zip/postal code is incorrect.', [], 'Admin.Notifications.Error') . - ' ' . - $this->translator->trans('It must be entered as follows:', [], 'Admin.Notifications.Error') . ' ' . - $requirements->getHumanReadablePattern() - ; - - $this->context->buildViolation($message)->addViolation(); - } - } -} diff --git a/src/Core/ConstraintValidator/CleanHtmlValidator.php b/src/Core/ConstraintValidator/CleanHtmlValidator.php deleted file mode 100644 index d9f4f339..00000000 --- a/src/Core/ConstraintValidator/CleanHtmlValidator.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CleanHtml; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; - -/** - * Class CleanHtmlValidator is responsible for validating the html content to prevent from having javascript events - * or script tags. - */ -final class CleanHtmlValidator extends ConstraintValidator -{ - /** - * {@inheritdoc} - */ - public function validate($value, Constraint $constraint) - { - if (!$constraint instanceof CleanHtml) { - throw new UnexpectedTypeException($constraint, CleanHtml::class); - } - - if (!$value) { - return; - } - - if (!is_string($value)) { - throw new UnexpectedTypeException($value, 'string'); - } - - $containsScriptTags = preg_match('/<[\s]*script/ims', $value) || preg_match('/.*script\:/ims', $value); - $containsJavascriptEvents = preg_match('/(' . $this->getJavascriptEvents() . ')[\s]*=/ims', $value); - - if ($containsScriptTags || $containsJavascriptEvents) { - $this->context->buildViolation($constraint->message) - ->setTranslationDomain('Admin.Notifications.Error') - ->setParameter('%s', $this->formatValue($value)) - ->addViolation() - ; - } - } - - /** - * Gets javascript events separated by pipeline which are used in preg match pattern to determine if string - * contains a javascript event. E.g onchange= is valid call for js event. - * - * @return string - */ - private function getJavascriptEvents() - { - $events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange'; - $events .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend'; - $events .= '|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onmove'; - $events .= '|onbounce|oncellchange|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondeactivate|ondrag|ondragend|ondragenter|onmousewheel'; - $events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart'; - $events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange'; - $events .= '|onselectstart|onstart|onstop'; - - return $events; - } -} diff --git a/src/Core/ConstraintValidator/Constraints/AddressDniRequired.php b/src/Core/ConstraintValidator/Constraints/AddressDniRequired.php deleted file mode 100644 index 2f491287..00000000 --- a/src/Core/ConstraintValidator/Constraints/AddressDniRequired.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\AddressDniRequiredValidator; -use Symfony\Component\Validator\Constraint; - -/** - * Validation constraint for address DNI according to the country value and fields requirement - */ -class AddressDniRequired extends Constraint -{ - public $message = 'This field cannot be empty'; - - public $id_country; - - public $required; - - /** - * {@inheritdoc} - */ - public function validatedBy() - { - return AddressDniRequiredValidator::class; - } - - public function getRequiredOptions() - { - return ['id_country', 'required']; - } -} diff --git a/src/Core/ConstraintValidator/Constraints/AddressStateRequired.php b/src/Core/ConstraintValidator/Constraints/AddressStateRequired.php deleted file mode 100644 index d289ac34..00000000 --- a/src/Core/ConstraintValidator/Constraints/AddressStateRequired.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\AddressStateRequiredValidator; -use Symfony\Component\Validator\Constraint; - -/** - * Validation constraint for address state choice by selected country value - */ -class AddressStateRequired extends Constraint -{ - public $message = 'An address located in a country containing states must have a state selected.'; - - public $id_country; - - /** - * {@inheritdoc} - */ - public function validatedBy() - { - return AddressStateRequiredValidator::class; - } - - public function getRequiredOptions() - { - return ['id_country']; - } -} diff --git a/src/Core/ConstraintValidator/Constraints/AddressZipCode.php b/src/Core/ConstraintValidator/Constraints/AddressZipCode.php deleted file mode 100644 index 552af23a..00000000 --- a/src/Core/ConstraintValidator/Constraints/AddressZipCode.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\AddressZipCodeValidator; -use Symfony\Component\Validator\Constraint; - -/** - * Address zip code validation constraint - */ -class AddressZipCode extends Constraint -{ - public $requiredMessage = 'A Zip/postal code is required.'; - - public $id_country; - - public $required; - - /** - * {@inheritdoc} - */ - public function validatedBy() - { - return AddressZipCodeValidator::class; - } - - public function getRequiredOptions() - { - return ['id_country', 'required']; - } -} diff --git a/src/Core/ConstraintValidator/Constraints/CleanHtml.php b/src/Core/ConstraintValidator/Constraints/CleanHtml.php deleted file mode 100644 index d9eb6da1..00000000 --- a/src/Core/ConstraintValidator/Constraints/CleanHtml.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\CleanHtmlValidator; -use Symfony\Component\Validator\Constraint; - -/** - * Class CleanHtml is responsible for validating the html content to prevent from having javascript events - * or script tags. - */ -final class CleanHtml extends Constraint -{ - public $message = '%s is invalid.'; - - /** - * {@inheritdoc} - */ - public function validatedBy() - { - return CleanHtmlValidator::class; - } -} diff --git a/src/Core/ConstraintValidator/Constraints/CustomerName.php b/src/Core/ConstraintValidator/Constraints/CustomerName.php deleted file mode 100644 index dd83c812..00000000 --- a/src/Core/ConstraintValidator/Constraints/CustomerName.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\CustomerNameValidator; -use Symfony\Component\Validator\Constraint; - -/** - * Class CustomerName is responsible of validating customer name according to several patterns. - */ -final class CustomerName extends Constraint -{ - public $message = 'The %s field is invalid.'; - - /** - * {@inheritdoc} - */ - public function validatedBy() - { - return CustomerNameValidator::class; - } -} diff --git a/src/Core/ConstraintValidator/Constraints/DateRange.php b/src/Core/ConstraintValidator/Constraints/DateRange.php deleted file mode 100644 index 798eec64..00000000 --- a/src/Core/ConstraintValidator/Constraints/DateRange.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\DateRangeValidator; -use Symfony\Component\Validator\Constraint; - -/** - * Provides date range validation - */ -class DateRange extends Constraint -{ - public $message = 'The selected date range is not valid.'; - - /** - * {@inheritdoc} - */ - public function validatedBy() - { - return DateRangeValidator::class; - } -} diff --git a/src/Core/ConstraintValidator/Constraints/DefaultLanguage.php b/src/Core/ConstraintValidator/Constraints/DefaultLanguage.php deleted file mode 100644 index 06bb13e1..00000000 --- a/src/Core/ConstraintValidator/Constraints/DefaultLanguage.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\DefaultLanguageValidator; -use Symfony\Component\Validator\Constraint; - -/** - * Class DefaultLanguage is responsible for checking if the array contains default language id - its common to require - * default language to be presented when saving required multi-language fields. - */ -class DefaultLanguage extends Constraint -{ - public $message = 'The field %field_name% is required at least in your default language.'; - - /** - * {@inheritdoc} - */ - public function validatedBy() - { - return DefaultLanguageValidator::class; - } -} diff --git a/src/Core/ConstraintValidator/Constraints/ExistingCustomerEmail.php b/src/Core/ConstraintValidator/Constraints/ExistingCustomerEmail.php deleted file mode 100644 index 317e43af..00000000 --- a/src/Core/ConstraintValidator/Constraints/ExistingCustomerEmail.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\ExistingCustomerEmailValidator; -use Symfony\Component\Validator\Constraint; - -/** - * Validation constraint for checking if customer with given email exists in current shop context - */ -class ExistingCustomerEmail extends Constraint -{ - public $message = 'This email address is not registered.'; - - /** - * {@inheritdoc} - */ - public function validatedBy() - { - return ExistingCustomerEmailValidator::class; - } -} diff --git a/src/Core/ConstraintValidator/Constraints/IsUrlRewrite.php b/src/Core/ConstraintValidator/Constraints/IsUrlRewrite.php deleted file mode 100644 index e5e2cbfb..00000000 --- a/src/Core/ConstraintValidator/Constraints/IsUrlRewrite.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\IsUrlRewriteValidator; -use Symfony\Component\Validator\Constraint; - -/** - * Class IsUrlRewrite is responsible of validating url rewrites according to several patterns - * which differ when ascending urls are enabled or not. - * - * @Annotation - */ -class IsUrlRewrite extends Constraint -{ - public $message = '%s is invalid.'; - - /** - * {@inheritdoc} - */ - public function validatedBy() - { - return IsUrlRewriteValidator::class; - } -} diff --git a/src/Core/ConstraintValidator/Constraints/NotBlankWhenRequired.php b/src/Core/ConstraintValidator/Constraints/NotBlankWhenRequired.php deleted file mode 100644 index c47708fb..00000000 --- a/src/Core/ConstraintValidator/Constraints/NotBlankWhenRequired.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\NotBlankWhenRequiredValidator; -use Symfony\Component\Validator\Constraints\NotBlank; - -class NotBlankWhenRequired extends NotBlank -{ - public $required; - - public function validatedBy() - { - return NotBlankWhenRequiredValidator::class; - } - - public function getRequiredOptions() - { - return ['required']; - } -} diff --git a/src/Core/ConstraintValidator/Constraints/Reduction.php b/src/Core/ConstraintValidator/Constraints/Reduction.php deleted file mode 100644 index c1031af3..00000000 --- a/src/Core/ConstraintValidator/Constraints/Reduction.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\ReductionValidator; -use Symfony\Component\Validator\Constraint; - -/** - * Constraint for validating reduction - */ -final class Reduction extends Constraint -{ - public $invalidTypeMessage = 'Reduction type "%type%" is invalid. Allowed types are: %types%.'; - - public $invalidAmountValueMessage = 'Reduction value "%value%" is invalid. Value cannot be negative'; - - public $invalidPercentageValueMessage = 'Reduction value "%value%" is invalid. Allowed values from 0 to %max%'; - - /** - * {@inheritdoc} - */ - public function validatedBy() - { - return ReductionValidator::class; - } -} diff --git a/src/Core/ConstraintValidator/Constraints/TypedRegex.php b/src/Core/ConstraintValidator/Constraints/TypedRegex.php deleted file mode 100644 index e9b0cc12..00000000 --- a/src/Core/ConstraintValidator/Constraints/TypedRegex.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\TypedRegexValidator; -use Symfony\Component\Validator\Constraint; - -/** - * Provides regex validation by type - */ -class TypedRegex extends Constraint -{ - /** - * Available types - */ - const TYPE_NAME = 'name'; - const TYPE_CATALOG_NAME = 'catalog_name'; - const TYPE_GENERIC_NAME = 'generic_name'; - const TYPE_CITY_NAME = 'city_name'; - const TYPE_ADDRESS = 'address'; - const TYPE_POST_CODE = 'post_code'; - const TYPE_PHONE_NUMBER = 'phone_number'; - const TYPE_MESSAGE = 'message'; - const TYPE_LANGUAGE_ISO_CODE = 'language_iso_code'; - const TYPE_LANGUAGE_CODE = 'language_code'; - const TYPE_CURRENCY_ISO_CODE = 'currency_iso_code'; - const TYPE_FILE_NAME = 'file_name'; - const TYPE_DNI_LITE = 'dni_lite'; - - /** - * @var string - */ - public $message = '%s is invalid'; - - /** - * @var string - */ - public $type; - - /** - * {@inheritdoc} - */ - public function getRequiredOptions() - { - return ['type']; - } - - /** - * {@inheritdoc} - */ - public function validatedBy() - { - return TypedRegexValidator::class; - } -} diff --git a/src/Core/ConstraintValidator/CustomerNameValidator.php b/src/Core/ConstraintValidator/CustomerNameValidator.php deleted file mode 100644 index 80bd6948..00000000 --- a/src/Core/ConstraintValidator/CustomerNameValidator.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CustomerName; -use PrestaShop\PrestaShop\Core\String\CharacterCleaner; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; - -/** - * Class CustomerNameValidator is responsilbe for doing the actual validation under CustomerName constraint. - */ -class CustomerNameValidator extends ConstraintValidator -{ - const PATTERN_NAME = '/^(?!\s*$)(?:[^0-9!<>,;?=+()\/\\\\@#"°*`{}_^$%:¤\[\]|\.。]|[。\.](?:\s|$))*$/u'; - const PATTERN_DOT_SPACED = '/[\.。](\s{1}[^\ ]|$)/'; - - /** - * @var CharacterCleaner - */ - private $characterCleaner; - - /** - * @param CharacterCleaner $characterCleaner - */ - public function __construct(CharacterCleaner $characterCleaner) - { - $this->characterCleaner = $characterCleaner; - } - - /** - * {@inheritdoc} - */ - public function validate($value, Constraint $constraint) - { - if (!$constraint instanceof CustomerName) { - throw new UnexpectedTypeException($constraint, CustomerName::class); - } - - if (!is_string($value)) { - throw new UnexpectedTypeException($value, 'string'); - } - - if (!$this->isNameValid($value) || !$this->isPointSpacedValid($value)) { - $this->context->buildViolation($constraint->message) - ->addViolation() - ; - } - } - - /** - * Validates url rewrite according a specific pattern. - * - * @param string $name - * - * @return bool - */ - private function isNameValid($name) - { - $pattern = $this->characterCleaner->cleanNonUnicodeSupport(self::PATTERN_NAME); - - return (bool) preg_match($pattern, $name); - } - - /** - * Check if there is not more one space after point - * - * @param string $name - * - * @return bool - */ - private function isPointSpacedValid($name) - { - if (mb_strpos($name, '.') === false && mb_strpos($name, '。') === false) { - return true; - } - $pattern = $this->characterCleaner->cleanNonUnicodeSupport(self::PATTERN_DOT_SPACED); - - return (bool) preg_match($pattern, $name); - } -} diff --git a/src/Core/ConstraintValidator/DateRangeValidator.php b/src/Core/ConstraintValidator/DateRangeValidator.php deleted file mode 100644 index 475709b5..00000000 --- a/src/Core/ConstraintValidator/DateRangeValidator.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator; - -use DateTime; -use Exception; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\DateRange; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; - -/** - * Validates ranges of date range - */ -class DateRangeValidator extends ConstraintValidator -{ - /** - * {@inheritdoc} - * - * @throws Exception - */ - public function validate($value, Constraint $constraint) - { - if (!$constraint instanceof DateRange) { - throw new UnexpectedTypeException($constraint, DateRange::class); - } - - if (!is_array($value)) { - throw new UnexpectedTypeException($value, 'array'); - } - - if (!empty($value['from']) && !empty($value['to'])) { - $this->validateRange(new DateTime($value['from']), new DateTime($value['to']), $constraint->message); - } - } - - /** - * Validate that date range is not inverted. (the 'from' value is not higher than 'to') - * - * @param DateTime $from - * @param DateTime $to - * @param $message - */ - private function validateRange(DateTime $from, DateTime $to, $message) - { - if ($from->diff($to)->invert) { - $this->context->buildViolation($message) - ->atPath('[to]') - ->setTranslationDomain('Admin.Notifications.Error') - ->addViolation() - ; - } - } -} diff --git a/src/Core/ConstraintValidator/DefaultLanguageValidator.php b/src/Core/ConstraintValidator/DefaultLanguageValidator.php deleted file mode 100644 index 984417e2..00000000 --- a/src/Core/ConstraintValidator/DefaultLanguageValidator.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\DefaultLanguage; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; - -/** - * Class DefaultLanguageValidator is responsilbe for doing the actual validation under DefaultLanguage constraint. - */ -class DefaultLanguageValidator extends ConstraintValidator -{ - /** - * @var int - */ - private $defaultLanguageId; - - /** - * @param int $defaultLanguageId - */ - public function __construct($defaultLanguageId) - { - $this->defaultLanguageId = $defaultLanguageId; - } - - /** - * {@inheritdoc} - */ - public function validate($value, Constraint $constraint) - { - if (!$constraint instanceof DefaultLanguage) { - throw new UnexpectedTypeException($constraint, DefaultLanguage::class); - } - - if (!is_array($value)) { - throw new UnexpectedTypeException($value, 'array'); - } - - if (empty($value[$this->defaultLanguageId])) { - $this->context->buildViolation($constraint->message) - ->setTranslationDomain('Admin.Notifications.Error') - ->setParameter( - '%field_name%', - $this->context->getObject() ? $this->context->getObject()->getName() : '' - ) - ->addViolation() - ; - } - } -} diff --git a/src/Core/ConstraintValidator/ExistingCustomerEmailValidator.php b/src/Core/ConstraintValidator/ExistingCustomerEmailValidator.php deleted file mode 100644 index b205e056..00000000 --- a/src/Core/ConstraintValidator/ExistingCustomerEmailValidator.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\ExistingCustomerEmail; -use PrestaShop\PrestaShop\Core\Customer\CustomerDataSourceInterface; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; - -/** - * Validator for checking if customer with given email exists in current shop context - */ -final class ExistingCustomerEmailValidator extends ConstraintValidator -{ - /** - * @var CustomerDataSourceInterface - */ - private $customerDataSource; - - /** - * @param CustomerDataSourceInterface $customerDataSource - */ - public function __construct(CustomerDataSourceInterface $customerDataSource) - { - $this->customerDataSource = $customerDataSource; - } - - /** - * {@inheritdoc} - */ - public function validate($value, Constraint $constraint) - { - if (!$constraint instanceof ExistingCustomerEmail) { - throw new UnexpectedTypeException($constraint, ExistingCustomerEmail::class); - } - - if (!$this->customerDataSource->hasCustomerWithEmail($value)) { - $this->context->buildViolation($constraint->message) - ->setTranslationDomain('Admin.Orderscustomers.Notification') - ->addViolation() - ; - } - } -} diff --git a/src/Core/ConstraintValidator/Factory/CustomerNameValidatorFactory.php b/src/Core/ConstraintValidator/Factory/CustomerNameValidatorFactory.php deleted file mode 100644 index b9516194..00000000 --- a/src/Core/ConstraintValidator/Factory/CustomerNameValidatorFactory.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator\Factory; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\CustomerNameValidator; -use PrestaShop\PrestaShop\Core\String\CharacterCleaner; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidatorFactoryInterface; -use Symfony\Component\Validator\ConstraintValidatorInterface; - -class CustomerNameValidatorFactory implements ConstraintValidatorFactoryInterface -{ - /** - * @var CharacterCleaner - */ - private $characterCleaner; - - /** - * CustomerNameValidatorFactory constructor. - * - * @param CharacterCleaner $characterCleaner - */ - public function __construct(CharacterCleaner $characterCleaner) - { - $this->characterCleaner = $characterCleaner; - } - - /** - * @param Constraint $constraint - * - * @return ConstraintValidatorInterface - */ - public function getInstance(Constraint $constraint) - { - return new CustomerNameValidator($this->characterCleaner); - } -} diff --git a/src/Core/ConstraintValidator/IsUrlRewriteValidator.php b/src/Core/ConstraintValidator/IsUrlRewriteValidator.php deleted file mode 100644 index fdec4721..00000000 --- a/src/Core/ConstraintValidator/IsUrlRewriteValidator.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\IsUrlRewrite; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; - -/** - * Class IsUrlRewriteValidator is responsible of validating url rewrites according to several patterns - * which differ when ascending urls are enabled or not. - */ -class IsUrlRewriteValidator extends ConstraintValidator -{ - /** - * @var ConfigurationInterface|bool - */ - private $accentedCharsConfiguration; - - /** - * this constructor can accept boolean value of already predefined accented chars allowance configuration to not - * introduce BC break. The recommended approach is to pass - * PrestaShop\PrestaShop\Adapter\Configuration as a service instead to avoid keeping cached scalar value. - * - * @param ConfigurationInterface|bool $accentedCharsConfiguration - */ - public function __construct($accentedCharsConfiguration) - { - $this->accentedCharsConfiguration = $accentedCharsConfiguration; - } - - /** - * {@inheritdoc} - */ - public function validate($value, Constraint $constraint) - { - if (!$constraint instanceof IsUrlRewrite) { - throw new UnexpectedTypeException($constraint, IsUrlRewrite::class); - } - - if (null === $value || '' === $value) { - return; - } - - if (!is_string($value)) { - throw new UnexpectedTypeException($value, 'string'); - } - - if (!$this->isUrlRewriteValid($value)) { - $this->context->buildViolation($constraint->message) - ->setTranslationDomain('Admin.Notifications.Error') - ->setParameter('%s', $this->formatValue($value)) - ->addViolation() - ; - } - } - - /** - * Validates url rewrite according the patterns which vary based on ascented chars allowed setting. - * - * @param string $urlRewrite - * - * @return false|int - */ - private function isUrlRewriteValid($urlRewrite) - { - $pattern = '/^[_a-zA-Z0-9\-]+$/'; - - if ($this->getAllowAccentedCharsSetting()) { - $pattern = '/^[_a-zA-Z0-9\pL\pS-]+$/u'; - } - - return preg_match($pattern, $urlRewrite); - } - - /** - * Gets the accented chars url setting. - * - * @return bool - */ - private function getAllowAccentedCharsSetting() - { - if ($this->accentedCharsConfiguration instanceof ConfigurationInterface) { - return $this->accentedCharsConfiguration->get('PS_ALLOW_ACCENTED_CHARS_URL'); - } - - return $this->accentedCharsConfiguration; - } -} diff --git a/src/Core/ConstraintValidator/NotBlankWhenRequiredValidator.php b/src/Core/ConstraintValidator/NotBlankWhenRequiredValidator.php deleted file mode 100644 index 7e2a5e35..00000000 --- a/src/Core/ConstraintValidator/NotBlankWhenRequiredValidator.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator; - -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\Constraints\NotBlankValidator; - -class NotBlankWhenRequiredValidator extends NotBlankValidator -{ - public function validate($value, Constraint $constraint) - { - if (true === $constraint->required) { - parent::validate($value, $constraint); - } - } -} diff --git a/src/Core/ConstraintValidator/ReductionValidator.php b/src/Core/ConstraintValidator/ReductionValidator.php deleted file mode 100644 index e353fac7..00000000 --- a/src/Core/ConstraintValidator/ReductionValidator.php +++ /dev/null @@ -1,142 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\Reduction as ReductionConstraint; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Reduction; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; - -/** - * Validates reduction type and value - */ -final class ReductionValidator extends ConstraintValidator -{ - /** - * {@inheritdoc} - */ - public function validate($value, Constraint $constraint) - { - if (!$constraint instanceof ReductionConstraint) { - throw new UnexpectedTypeException($constraint, ReductionConstraint::class); - } - - if (null === $value || '' === $value) { - return; - } - - if (!is_array($value)) { - throw new UnexpectedTypeException($value, 'array'); - } - - if (!$this->isAllowedType($value['type'])) { - $this->buildViolation( - $constraint->invalidTypeMessage, - [ - '%type%' => $value['type'], - '%types%' => implode(', ', [Reduction::TYPE_PERCENTAGE, Reduction::TYPE_AMOUNT]), - ], - '[type]' - ); - } - - if (Reduction::TYPE_AMOUNT === $value['type']) { - if (!$this->assertIsValidAmount($value['value'])) { - $this->buildViolation( - $constraint->invalidAmountValueMessage, - ['%value%' => $value['value']], - '[value]' - ); - } - } elseif (Reduction::TYPE_PERCENTAGE === $value['type']) { - if (!$this->assertIsValidPercentage($value['value'])) { - $this->buildViolation( - $constraint->invalidPercentageValueMessage, - [ - '%value%' => $value['value'], - '%max%' => Reduction::MAX_ALLOWED_PERCENTAGE, - ], - '[value]' - ); - } - } - } - - /** - * Returns true if type is defined in allowed types, false otherwise - * - * @param string $type - * - * @return bool - */ - private function isAllowedType(string $type): bool - { - return in_array($type, Reduction::ALLOWED_TYPES, true); - } - - /** - * Returns true is percentage is considered valid - * - * @param float $value - * - * @return bool - */ - private function assertIsValidPercentage(float $value) - { - return 0 <= $value && Reduction::MAX_ALLOWED_PERCENTAGE >= $value; - } - - /** - * Returns true if amount value is considered valid - * - * @param float $value - * - * @return bool - */ - private function assertIsValidAmount(float $value) - { - return 0 <= $value; - } - - /** - * Builds violation dependent from exception code - * - * @param string $message - * @param array $params - * @param string $errorPath - */ - private function buildViolation(string $message, array $params, string $errorPath) - { - $this->context->buildViolation($message, $params) - ->setTranslationDomain('Admin.Notifications.Error') - ->atPath($errorPath) - ->setParameters($params) - ->addViolation() - ; - } -} diff --git a/src/Core/ConstraintValidator/TypedRegexValidator.php b/src/Core/ConstraintValidator/TypedRegexValidator.php deleted file mode 100644 index a5b34fb3..00000000 --- a/src/Core/ConstraintValidator/TypedRegexValidator.php +++ /dev/null @@ -1,157 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\ConstraintValidator; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\TypedRegex; -use PrestaShop\PrestaShop\Core\Domain\Address\Configuration\AddressConstraint; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\AlphaIsoCode; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\IsoCode; -use PrestaShop\PrestaShop\Core\String\CharacterCleaner; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\InvalidArgumentException; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; - -/** - * Validates specific regex pattern for provided type - */ -class TypedRegexValidator extends ConstraintValidator -{ - /** - * @var CharacterCleaner - */ - private $characterCleaner; - - /** - * @param CharacterCleaner $characterCleaner - */ - public function __construct(CharacterCleaner $characterCleaner) - { - $this->characterCleaner = $characterCleaner; - } - - /** - * {@inheritdoc} - */ - public function validate($value, Constraint $constraint) - { - if (!$constraint instanceof TypedRegex) { - throw new UnexpectedTypeException($constraint, TypedRegex::class); - } - - if (null === $value || '' === $value) { - return; - } - - if (!is_string($value)) { - throw new UnexpectedTypeException($value, 'string'); - } - - $pattern = $this->getPattern($constraint->type); - $value = $this->sanitize($value, $constraint->type); - - if (!$this->match($pattern, $constraint->type, $value)) { - $this->context->buildViolation($constraint->message) - ->setTranslationDomain('Admin.Notifications.Error') - ->setParameter('%s', $this->formatValue($value)) - ->addViolation() - ; - } - } - - /** - * Returns regex pattern that depends on type - * - * @param string $type - * - * @return string - */ - private function getPattern($type) - { - $typePatterns = [ - TypedRegex::TYPE_NAME => $this->characterCleaner->cleanNonUnicodeSupport('/^[^0-9!<>,;?=+()@#"°{}_$%:¤|]*$/u'), - TypedRegex::TYPE_CATALOG_NAME => $this->characterCleaner->cleanNonUnicodeSupport('/^[^<>;=#{}]*$/u'), - TypedRegex::TYPE_GENERIC_NAME => $this->characterCleaner->cleanNonUnicodeSupport('/^[^<>={}]*$/u'), - TypedRegex::TYPE_CITY_NAME => $this->characterCleaner->cleanNonUnicodeSupport('/^[^!<>;?=+@#"°{}_$%]*$/u'), - TypedRegex::TYPE_ADDRESS => $this->characterCleaner->cleanNonUnicodeSupport('/^[^!<>?=+@{}_$%]*$/u'), - TypedRegex::TYPE_POST_CODE => '/^[a-zA-Z 0-9-]+$/', - TypedRegex::TYPE_PHONE_NUMBER => '/^[+0-9. ()\/-]*$/', - TypedRegex::TYPE_MESSAGE => '/[<>{}]/i', - TypedRegex::TYPE_LANGUAGE_ISO_CODE => IsoCode::PATTERN, - TypedRegex::TYPE_LANGUAGE_CODE => '/^[a-zA-Z]{2}(-[a-zA-Z]{2})?$/', - TypedRegex::TYPE_CURRENCY_ISO_CODE => AlphaIsoCode::PATTERN, - TypedRegex::TYPE_FILE_NAME => '/^[a-zA-Z0-9_.-]+$/', - TypedRegex::TYPE_DNI_LITE => AddressConstraint::DNI_LITE_PATTERN, - ]; - - if (isset($typePatterns[$type])) { - return $typePatterns[$type]; - } - - throw new InvalidArgumentException(sprintf('Type "%s" is not defined. Defined types are: %s', $type, implode(',', array_keys($typePatterns)))); - } - - /** - * Responsible for sanitizing the string depending on type. (eg. applying stripslashes()) - * - * @param string $value - * @param string $type - * - * @return string - */ - private function sanitize($value, $type) - { - if ($type === 'name') { - $value = stripslashes($value); - } - - return $value; - } - - /** - * Responsible for applying preg_match depending on type. - * preg_match returns 1 if the pattern - * matches given subject, 0 if it does not, or FALSE - * if an error occurred. - * - * @param $pattern - * @param $type - * @param $value - * - * @return false|int - */ - private function match($pattern, $type, $value) - { - $typesToInverseMatching = ['message']; - - if (in_array($type, $typesToInverseMatching, true)) { - return !preg_match($pattern, $value); - } - - return preg_match($pattern, $value); - } -} diff --git a/src/Core/ContainerBuilder.php b/src/Core/ContainerBuilder.php deleted file mode 100644 index 7c1d88d0..00000000 --- a/src/Core/ContainerBuilder.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core; - -use PrestaShop\PrestaShop\Core\Foundation\IoC\Container; - -class ContainerBuilder -{ - /** - * Construct PrestaShop Core Service container. - * - * @return \PrestaShop\PrestaShop\Core\Foundation\IoC\Container - * - * @throws \PrestaShop\PrestaShop\Core\Foundation\IoC\Exception - */ - public function build() - { - $container = new Container(); - - $container->bind('\\PrestaShop\\PrestaShop\\Core\\ConfigurationInterface', '\\PrestaShop\\PrestaShop\\Adapter\\Configuration', true); - $container->bind('PrestaShop\\PrestaShop\\Core\\ConfigurationInterface', '\\PrestaShop\\PrestaShop\\Adapter\\Configuration', true); - $container->bind('\\PrestaShop\\PrestaShop\\Core\\Foundation\\Database\\DatabaseInterface', '\\PrestaShop\\PrestaShop\\Adapter\\Database', true); - $container->bind('PrestaShop\\PrestaShop\\Core\\Foundation\\Database\\DatabaseInterface', '\\PrestaShop\\PrestaShop\\Adapter\\Database', true); - - return $container; - } -} diff --git a/src/Core/Country/CountryRequiredFieldsProviderInterface.php b/src/Core/Country/CountryRequiredFieldsProviderInterface.php deleted file mode 100644 index ad737e36..00000000 --- a/src/Core/Country/CountryRequiredFieldsProviderInterface.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Country; - -use PrestaShop\PrestaShop\Core\Domain\Country\ValueObject\CountryId; - -interface CountryRequiredFieldsProviderInterface -{ - /** - * @param CountryId $countryId - * - * @return bool - */ - public function isStatesRequired(CountryId $countryId): bool; - - /** - * @param CountryId $countryId - * - * @return bool - */ - public function isDniRequired(CountryId $countryId): bool; -} diff --git a/src/Core/Country/CountryZipCodeRequirements.php b/src/Core/Country/CountryZipCodeRequirements.php deleted file mode 100644 index 2f335da7..00000000 --- a/src/Core/Country/CountryZipCodeRequirements.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Country; - -/** - * Holds information about country zip code requirements - */ -class CountryZipCodeRequirements -{ - /** - * @var bool - */ - private $isRequired; - - /** - * @var string|null - */ - private $pattern; - - /** - * @var string|null - */ - private $humanReadablePattern; - - /** - * @var string|null - */ - private $countryName; - - /** - * @param bool $isRequired - */ - public function __construct(bool $isRequired) - { - $this->isRequired = $isRequired; - } - - /** - * @return bool - */ - public function isRequired(): bool - { - return $this->isRequired; - } - - /** - * @return string|null - */ - public function getPattern(): ?string - { - return $this->pattern; - } - - /** - * @param string $pattern - * @param string $humanReadablePattern - * - * @return CountryZipCodeRequirements - */ - public function setPatterns(string $pattern, string $humanReadablePattern): CountryZipCodeRequirements - { - $this->pattern = $pattern; - $this->humanReadablePattern = $humanReadablePattern; - - return $this; - } - - /** - * @return string|null - */ - public function getHumanReadablePattern(): ?string - { - return $this->humanReadablePattern; - } - - /** - * @return string|null - */ - public function getCountryName(): ?string - { - return $this->countryName; - } - - /** - * @param string $countryName - * - * @return CountryZipCodeRequirements - */ - public function setCountryName(string $countryName): CountryZipCodeRequirements - { - $this->countryName = $countryName; - - return $this; - } -} diff --git a/src/Core/Country/CountryZipCodeRequirementsProviderInterface.php b/src/Core/Country/CountryZipCodeRequirementsProviderInterface.php deleted file mode 100644 index b8567354..00000000 --- a/src/Core/Country/CountryZipCodeRequirementsProviderInterface.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Country; - -use PrestaShop\PrestaShop\Core\Domain\Country\ValueObject\CountryId; - -interface CountryZipCodeRequirementsProviderInterface -{ - /** - * @param CountryId $countryId - * - * @return CountryZipCodeRequirements - */ - public function getCountryZipCodeRequirements(CountryId $countryId): CountryZipCodeRequirements; -} diff --git a/src/Core/CreditSlip/CreditSlipOptionsConfiguration.php b/src/Core/CreditSlip/CreditSlipOptionsConfiguration.php deleted file mode 100644 index 0d98b9bd..00000000 --- a/src/Core/CreditSlip/CreditSlipOptionsConfiguration.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\CreditSlip; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; - -/** - * Responsible for saving configuration options for credit slip - */ -final class CreditSlipOptionsConfiguration implements DataConfigurationInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'slip_prefix' => $this->configuration->get('PS_CREDIT_SLIP_PREFIX'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_CREDIT_SLIP_PREFIX', $configuration['slip_prefix']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset($configuration['slip_prefix']); - } -} diff --git a/src/Core/Crypto/Hashing.php b/src/Core/Crypto/Hashing.php deleted file mode 100644 index 3a324d3d..00000000 --- a/src/Core/Crypto/Hashing.php +++ /dev/null @@ -1,139 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Crypto; - -/** - * Class Hashing to manage hash and crypto of user (clients/merchants) passwords. - */ -class Hashing -{ - /** @var array should contain hashing methods */ - private $hashMethods = []; - - /** - * Check if it's the first function of the array that was used for hashing. - * - * @param string $passwd The password you want to check - * @param string $hash The hash you want to check - * @param string $staticSalt A static salt - * - * @return bool Result of the verify function - */ - public function isFirstHash($passwd, $hash, $staticSalt = _COOKIE_KEY_) - { - if (!count($this->hashMethods)) { - $this->initHashMethods(); - } - - $closure = reset($this->hashMethods); - - return $closure['verify']($passwd, $hash, $staticSalt); - } - - /** - * Iterate on hash_methods array and return true if it matches. - * - * @param string $passwd The password you want to check - * @param string $hash The hash you want to check - * @param string $staticSalt A static salt - * - * @return bool `true` is returned if the function find a match else false - */ - public function checkHash($passwd, $hash, $staticSalt = _COOKIE_KEY_) - { - if (!count($this->hashMethods)) { - $this->initHashMethods(); - } - - foreach ($this->hashMethods as $closure) { - if ($closure['verify']($passwd, $hash, $staticSalt)) { - return true; - } - } - - return false; - } - - /** - * Hash the `$plaintextPassword` string and return the result of the 1st hashing method - * contained in PrestaShop\PrestaShop\Core\Crypto\Hashing::hash_methods. - * - * @param string $plaintextPassword The password you want to hash - * @param string $staticSalt The static salt - * - * @return string - */ - public function hash($plaintextPassword, $staticSalt = _COOKIE_KEY_) - { - if (!count($this->hashMethods)) { - $this->initHashMethods(); - } - - $closure = reset($this->hashMethods); - - return $closure['hash']($plaintextPassword, $staticSalt, $closure['option']); - } - - /** - * Init $hash_methods. - */ - private function initHashMethods() - { - $this->hashMethods = [ - 'bcrypt' => [ - 'option' => [], - 'hash' => function ($passwd, $staticSalt, $option) { - return password_hash($passwd, PASSWORD_BCRYPT); - }, - 'verify' => function ($passwd, $hash, $staticSalt) { - /* - * Prevent enumeration because nothing happens - * when there is no, or an invalid hash. - * Also, change the password to be sure it's not maching - * the new hash. - * The new hash is equal to 'test' in BCRYPT context. - */ - if (empty($hash)) { - $hash = '$2y$10$azRqq.pN0OlWjeVfVMZXOOwqYAx1hMfme6ZnDV.27grGOEZvG.uAO'; - $passwd = 'wrongPassword'; - } - - return password_verify($passwd, $hash); - }, - ], - 'md5' => [ - 'option' => [], - 'hash' => function ($passwd, $staticSalt, $option) { - return md5($staticSalt . $passwd); - }, - 'verify' => function ($passwd, $hash, $staticSalt) { - return md5($staticSalt . $passwd) === $hash; - }, - ], - ]; - } -} diff --git a/src/Core/Currency/CurrencyDataProviderInterface.php b/src/Core/Currency/CurrencyDataProviderInterface.php deleted file mode 100644 index a9aab1d4..00000000 --- a/src/Core/Currency/CurrencyDataProviderInterface.php +++ /dev/null @@ -1,121 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Currency; - -use Currency; -use Exception; -use PrestaShopException; - -/** - * This class will provide data from DB / ORM about Currency. - */ -interface CurrencyDataProviderInterface -{ - /** - * Return available currencies. - * - * @param bool $object - * @param bool $active - * @param bool $group_by - * - * @return array Currencies - */ - public function getCurrencies($object = false, $active = true, $group_by = false); - - /** - * Return raw currencies data from the database (not deleted + active currencies). - * - * @param bool $currentShopOnly If true returns only currencies associated to current shop - * - * @return array[] Available currencies - */ - public function findAll($currentShopOnly = true); - - /** - * Return raw data of all installed currencies in the database (regardless of their active or soft deleted status). - * - * @return array[] Currencies installed in database - */ - public function findAllInstalled(); - - /** - * Get a Currency entity instance by ISO code. - * - * @param string $isoCode - * An ISO 4217 currency code - * @param int|null $idLang - * Set this parameter if you want the currency in a specific language. - * If null, default language will be used - * - * @return currency|null - * The asked Currency object, or null if not found - */ - public function getCurrencyByIsoCode($isoCode, $idLang = null); - - /** - * Get a Currency entity instance. - * If the passed ISO code is known, this Currency entity will be loaded with known data. - * - * @param string $isoCode - * An ISO 4217 currency code - * @param int|null $idLang - * Set this parameter if you want the currency in a specific language. - * If null, default language will be used - * - * @return currency - * The asked Currency object, loaded with relevant data if passed ISO code is known - */ - public function getCurrencyByIsoCodeOrCreate($isoCode, $idLang = null); - - /** - * Persists a Currency entity into DB. - * If this entity already exists in DB (has a known currency_id), it will be updated. - * - * @param Currency $currencyEntity - * Currency object model to save - * - * @throws PrestaShopException - * If something wrong happened with DB when saving $currencyEntity - * @throws Exception - * If an unexpected result is retrieved when saving $currencyEntity - */ - public function saveCurrency(Currency $currencyEntity); - - /** - * Gets a legacy Currency instance by ID. - * - * @param int $currencyId - * - * @return Currency - */ - public function getCurrencyById($currencyId); - - /** - * Get Default currency Iso code. - */ - public function getDefaultCurrencyIsoCode(); -} diff --git a/src/Core/Currency/CurrencyGridDataFactory.php b/src/Core/Currency/CurrencyGridDataFactory.php deleted file mode 100644 index 998b7cb3..00000000 --- a/src/Core/Currency/CurrencyGridDataFactory.php +++ /dev/null @@ -1,126 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Currency; - -use PrestaShop\PrestaShop\Core\Grid\Data\Factory\GridDataFactoryInterface; -use PrestaShop\PrestaShop\Core\Grid\Data\GridData; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollectionInterface; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class CurrencyGridDataFactory is responsible for providing modified currency list grid data. - */ -final class CurrencyGridDataFactory implements GridDataFactoryInterface -{ - /** - * @var GridDataFactoryInterface - */ - private $gridDataFactory; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * CurrencyGridDataFactory constructor. - * - * @param GridDataFactoryInterface $gridDataFactory - * @param TranslatorInterface $translator - */ - public function __construct( - GridDataFactoryInterface $gridDataFactory, - TranslatorInterface $translator - ) { - $this->gridDataFactory = $gridDataFactory; - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getData(SearchCriteriaInterface $searchCriteria) - { - $gridData = $this->gridDataFactory->getData($searchCriteria); - - $records = $gridData->getRecords(); - - return new GridData( - $this->getModifiedRecords($records), - $gridData->getRecordsTotal(), - $gridData->getQuery() - ); - } - - /** - * Gets record collection with extra and modified rows. - * - * @param RecordCollectionInterface $records - * - * @return RecordCollection - */ - private function getModifiedRecords(RecordCollectionInterface $records) - { - $result = []; - foreach ($records as $key => $record) { - $result[$key] = $record; - $result[$key]['currency'] = $this->buildCurrencyName($result[$key]); - } - - return new RecordCollection($result); - } - - /** - * @param array $currency - * - * @return string - */ - private function buildCurrencyName(array $currency) - { - $currencyName = mb_ucfirst($currency['name']); - - if (!empty($currency['unofficial'])) { - return sprintf( - '%s %s', - $currencyName, - 'person' - ); - } - - if (!empty($currency['modified'])) { - return sprintf( - '%s (%s)', - $currencyName, - $this->translator->trans('Edited', [], 'Admin.International.Feature') - ); - } - - return $currencyName; - } -} diff --git a/src/Core/Currency/Exception/CurrencyFeedException.php b/src/Core/Currency/Exception/CurrencyFeedException.php deleted file mode 100644 index a3cfa22f..00000000 --- a/src/Core/Currency/Exception/CurrencyFeedException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Currency\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Thrown when an error occurred while fetching a currency exchange rate (network issue, invalid response, ...) - * - * @see ExchangeRateProvider - */ -class CurrencyFeedException extends CoreException -{ -} diff --git a/src/Core/Currency/ExchangeRateProvider.php b/src/Core/Currency/ExchangeRateProvider.php deleted file mode 100644 index 0fe677e2..00000000 --- a/src/Core/Currency/ExchangeRateProvider.php +++ /dev/null @@ -1,234 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Currency; - -use PrestaShop\CircuitBreaker\Contract\CircuitBreakerInterface; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Currency\Exception\CurrencyFeedException; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\ExchangeRate; -use SimpleXMLElement; -use Symfony\Component\Cache\Adapter\AdapterInterface as CacheInterface; - -/** - * Retrieves the exchange rate of a currency (based on the default currency). It uses a circuit breaker - * to avoid being blocked in case of network problems and it saves each of its request in a cache to be - * able to have a fallback response. - */ -class ExchangeRateProvider -{ - /** - * This url was set in the _PS_CURRENCY_FEED_URL_ const but it is not accessible in every - * context because it is weirdly defined in defines_uri.inc.php So it is safer to define - * it properly here. - */ - const CURRENCY_FEED_URL = 'http://api.prestashop.com/xml/currencies.xml'; - - const CLOSED_ALLOWED_FAILURES = 3; - const CLOSED_TIMEOUT_SECONDS = 1; - - const OPEN_ALLOWED_FAILURES = 3; - const OPEN_TIMEOUT_SECONDS = 2; - const OPEN_THRESHOLD_SECONDS = 3600; // 1 hour - - const CACHE_KEY_XML = 'currency_feed.xml'; - - /** @var string */ - private $currencyFeedUrl; - - /** @var string */ - private $defaultCurrencyIsoCode; - - /** @var CircuitBreakerInterface */ - private $remoteServiceProvider; - - /** @var CacheInterface */ - private $cache; - - /** @var string */ - private $sourceIsoCode; - - /** @var array */ - private $currencies = []; - - /** - * @param string $currencyFeedUrl - * @param string $defaultCurrencyIsoCode - * @param CircuitBreakerInterface $remoteServiceProvider - * @param CacheInterface $cache - */ - public function __construct( - $currencyFeedUrl, - $defaultCurrencyIsoCode, - CircuitBreakerInterface $remoteServiceProvider, - CacheInterface $cache - ) { - $this->currencyFeedUrl = $currencyFeedUrl; - $this->defaultCurrencyIsoCode = $defaultCurrencyIsoCode; - $this->remoteServiceProvider = $remoteServiceProvider; - $this->cache = $cache; - } - - /** - * @param string $currencyIsoCode - * - * @return Number - * - * @throws CurrencyFeedException - */ - public function getExchangeRate($currencyIsoCode) - { - $this->fetchCurrencyFeed(); - - // Default feed currency (usually EUR) - if ($this->defaultCurrencyIsoCode == $currencyIsoCode) { - return ExchangeRate::getDefaultExchangeRate(); - } - - /* - * Search for the currency rate in the source feed, this represents the rate - * relative to the source feed (compared to the feed default currency) - */ - $sourceRate = $this->getExchangeRateFromFeed($currencyIsoCode); - - /* - * Fetch the exchange rate of the default currency (compared to the source currency) - * and finally compute the asked currency rate compared to the shop default currency rate - */ - $defaultExchangeRate = $this->getExchangeRateFromFeed($this->defaultCurrencyIsoCode); - - return $sourceRate->dividedBy($defaultExchangeRate); - } - - /** - * @param string $currencyIsoCode - * - * @return Number - * - * @throws CurrencyFeedException - */ - private function getExchangeRateFromFeed(string $currencyIsoCode) - { - if ($this->sourceIsoCode == $currencyIsoCode) { - return new Number('1.0'); - } - - if (!isset($this->currencies[$currencyIsoCode])) { - throw new CurrencyFeedException(sprintf('Exchange rate for currency with ISO code %s was not found', $currencyIsoCode)); - } - - return $this->currencies[$currencyIsoCode]; - } - - /** - * Fetch the currency from its url using circuit breaker, if no content was fetched - * fallback on the cache file. This is only performed once per process, if the currencies - * are already present then there is nothing to do. - * - * @throws CurrencyFeedException - */ - private function fetchCurrencyFeed() - { - if (!empty($this->currencies)) { - return; - } - - $remoteFeedData = $this->remoteServiceProvider->call($this->currencyFeedUrl); - $cachedFeedData = $this->getCachedCurrencyFeed(); - if (empty($remoteFeedData) && empty($cachedFeedData)) { - throw new CurrencyFeedException('Currency feed could not be fetched'); - } - - $xmlFeed = $this->parseAndSaveXMLFeed($remoteFeedData); - if (null === $xmlFeed) { - $xmlFeed = $this->parseAndSaveXMLFeed($cachedFeedData); - } - - if (null === $xmlFeed) { - throw new CurrencyFeedException('Invalid currency XML feed'); - } - - $this->parseXmlFeed($xmlFeed); - } - - /** - * @param string $feedContent - * - * @return SimpleXMLElement|null - */ - private function parseAndSaveXMLFeed($feedContent) - { - $xmlFeed = @simplexml_load_string($feedContent); - if (!$xmlFeed || !$this->isValidXMLFeed($xmlFeed)) { - return null; - } - - //Cache the feed - $cacheItem = $this->cache->getItem(self::CACHE_KEY_XML); - $cacheItem->set($feedContent); - $this->cache->save($cacheItem); - - return $xmlFeed; - } - - /** - * @param SimpleXMLElement $xmlFeed - */ - private function parseXmlFeed($xmlFeed) - { - $xmlCurrencies = $xmlFeed->list->currency; - - $this->sourceIsoCode = (string) ($xmlFeed->source['iso_code']); - foreach ($xmlCurrencies as $currency) { - $this->currencies[(string) $currency['iso_code']] = new Number((string) $currency['rate']); - } - } - - /** - * @return string - */ - private function getCachedCurrencyFeed() - { - $cacheItem = $this->cache->getItem(self::CACHE_KEY_XML); - if (!$cacheItem->isHit()) { - return ''; - } - - $feedContent = $cacheItem->get(); - - return !empty($feedContent) ? $feedContent : ''; - } - - /** - * @param SimpleXMLElement $xmlFeed - * - * @return bool - */ - private function isValidXMLFeed(SimpleXMLElement $xmlFeed) - { - return $xmlFeed && $xmlFeed->list && count($xmlFeed->list->currency) && $xmlFeed->source; - } -} diff --git a/src/Core/Customer/CustomerDataSourceInterface.php b/src/Core/Customer/CustomerDataSourceInterface.php deleted file mode 100644 index c5dbd697..00000000 --- a/src/Core/Customer/CustomerDataSourceInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Customer; - -interface CustomerDataSourceInterface -{ - /** - * @param string $email - * - * @return bool - */ - public function hasCustomerWithEmail(string $email): bool; -} diff --git a/src/Core/Data/AbstractTypedCollection.php b/src/Core/Data/AbstractTypedCollection.php deleted file mode 100644 index bf9e06d7..00000000 --- a/src/Core/Data/AbstractTypedCollection.php +++ /dev/null @@ -1,167 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Data; - -use Doctrine\Common\Collections\ArrayCollection; -use PrestaShop\PrestaShop\Core\Exception\TypeException; - -/** - * Class AbstractTypedCollection is an abstract collection class which checks - * that the inserted elements match the requested type. - */ -abstract class AbstractTypedCollection extends ArrayCollection -{ - /** - * Define the type of the elements contained in the collection. - * Example: for a ProductCollection you need to return Product::class - * - * @return string - */ - abstract protected function getType(); - - /** - * AbstractTypedCollection constructor. - * - * @param array $elements - * - * @throws TypeException - */ - public function __construct(array $elements = []) - { - $this->checkElementsType($elements); - parent::__construct($elements); - } - - /** - * @param mixed $element - * - * @return bool - * - * @throws TypeException - */ - public function removeElement($element) - { - $this->checkElementType($element); - - return parent::removeElement($element); - } - - /** - * @param mixed $offset - * @param mixed $value - * - * @return bool|void - * - * @throws TypeException - */ - public function offsetSet($offset, $value) - { - $this->checkElementType($value); - - return parent::offsetSet($offset, $value); - } - - /** - * @param mixed $element - * - * @return bool - * - * @throws TypeException - */ - public function contains($element) - { - $this->checkElementType($element); - - return parent::contains($element); - } - - /** - * @param mixed $element - * - * @return bool|false|int|string - * - * @throws TypeException - */ - public function indexOf($element) - { - $this->checkElementType($element); - - return parent::indexOf($element); - } - - /** - * @param mixed $key - * @param mixed $value - * - * @throws TypeException - */ - public function set($key, $value) - { - $this->checkElementType($value); - - parent::set($key, $value); - } - - /** - * @param mixed $element - * - * @return bool - * - * @throws TypeException - */ - public function add($element) - { - $this->checkElementType($element); - - return parent::add($element); - } - - /** - * @param array $elements - * - * @throws TypeException - */ - private function checkElementsType(array $elements) - { - foreach ($elements as $element) { - $this->checkElementType($element); - } - } - - /** - * @param mixed $element - * - * @throws TypeException - */ - private function checkElementType($element) - { - $expectedType = $this->getType(); - if (!($element instanceof $expectedType)) { - throw new TypeException(sprintf('Invalid element type %s, expected %s', is_object($element) ? get_class($element) : gettype($element), $expectedType)); - } - } -} diff --git a/src/Core/Data/Layer/AbstractDataLayer.php b/src/Core/Data/Layer/AbstractDataLayer.php deleted file mode 100644 index 3badbee6..00000000 --- a/src/Core/Data/Layer/AbstractDataLayer.php +++ /dev/null @@ -1,296 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Data\Layer; - -use Exception; - -/** - * Abstract data layer class - * Provides common behavior to any data layer. - * - * A data layer acts as a middleware, chained to other data layers, and is meant to - * read/write data from/to it's data source but also from/to other data layers - * - * A data layer knows only the next (lower) layer for read/write chaining. - */ -abstract class AbstractDataLayer -{ - /** - * The lower data layer to communicate with (read/write). - * - * @var AbstractDataLayer|null - */ - protected $lowerDataLayer; - - /** - * Is this data layer writable ? - * - * If it is writable, then it will be allowed to insert/update into its data source. - * Read/write propagation is NOT affected by this property. - * - * A read-only data layer can only hydrate data from lower layers, and return it to the upper layer. - * Data present in a read-only data layer is very likely to be incomplete and can be used only to hydrate data - * from lower layers (unless this is the very last layer containing comprehensive reference data). - * - * @var bool - */ - protected $isWritable = true; - - /** - * Is this data layer writable ? - * - * @return bool - * True if writable. False if read-only layer. - */ - public function isWritable() - { - return $this->isWritable; - } - - /** - * Read a data object, by identifier. - * - * Lower layer might be called if nothing found in current layer - * - * @param mixed $id - * The data object identifier - * - * @return mixed|null - * A data object. Null if not found. - * - * @throws DataLayerException - */ - public function read($id) - { - $data = $this->doRead($id); - - // If nothing found, ask lower layer - if (null === $data) { - $data = $this->propagateRead($id); - - // If nothing was found deeper, there is nothing more to do - if (null === $data) { - return null; - } - - // Save result for next Read requests - $this->saveReadPropagationResult($id, $data); - } - - return $data; - } - - /** - * Write a data object. - * - * Write request is propagated to lower layer, and the propagation result is actually written in - * current layer (because lower layer might hydrate/update the data object). - * - * @param mixed $id - * The data object identifier - * @param mixed $data - * The data object to write - * - * @return mixed - * The data object to be written by the upper data layer - * (each layer might hydrate/update the data object for upper layers) - * - * @throws DataLayerException - * When write fails - */ - public function write($id, $data) - { - // First, write $data in lower layers and store the (probably hydrated/updated) result - $data = $this->propagateWrite($id, $data); - - // Then write this result in current layer - $data = $this->saveWritePropagationResult($id, $data); - - return $data; - } - - /** - * Propagate read to the lower layer. - * - * @param $field - * The field to read - * - * @return mixed|null - * - * @throws DataLayerException - */ - protected function propagateRead($field) - { - if (isset($this->lowerDataLayer)) { - return $this->lowerDataLayer->read($field); - } - - return null; - } - - /** - * Propagate write to lower layer. - * - * @param mixed $id - * The data object identifier - * @param mixed $data - * The data object to write into this field - * - * @return mixed - * The data object to be written by the upper data layer - * - * @throws DataLayerException - * When write fails - */ - protected function propagateWrite($id, $data) - { - if (isset($this->lowerDataLayer)) { - return $this->lowerDataLayer->write($id, $data); - } - - return $data; - } - - /** - * Save data object received from lower layers after a Read request. - * - * This data object is written in the current layer to avoid read propagation next time. - * - * @param mixed $id - * Data object identifier - * @param mixed $data - * Data object received from lower layers - * - * @throws DataLayerException - * When write failed - */ - protected function saveReadPropagationResult($id, $data) - { - if ($this->isWritable()) { - try { - $this->doWrite($id, $data); - } catch (Exception $e) { - throw new DataLayerException('Unable to write into "' . $id . '"" (data layer : "' . get_class($this) . '")', 0, $e); - } - } - } - - /** - * Save data object received from lower layers after a Write request. - * - * This data object is written in the current layer after lower layers have hydrated/updated (and written) it - * - * @param mixed $id - * Data object identifier - * @param mixed $data - * Data object received from lower layers - * - * @return mixed - * Data object to be written by upper layer - * - * @throws DataLayerException - * When write failed - */ - protected function saveWritePropagationResult($id, $data) - { - if ($this->isWritable()) { - // If update needed before write - $data = $this->beforeWrite($data); - - try { - $this->doWrite($id, $data); - } catch (Exception $e) { - throw new DataLayerException('Unable to write into "' . $id . '" (data layer "' . get_class($this) . '")', 0, $e); - } - - // If update needed after write - $data = $this->afterWrite($data); - } - - return $data; - } - - /** - * Process some updates on $data before writing it in the current layer. - * - * @param mixed $data - * Data object to be updated before write - * - * @return mixed - * The updated data object - */ - protected function beforeWrite($data) - { - return $data; - } - - /** - * Process some updates on $data after writing it in the current layer. - * - * @param mixed $data - * Data object to be updated after write - * - * @return mixed - * The updated data object - */ - protected function afterWrite($data) - { - return $data; - } - - /** - * Actually read a data object into the current layer. - * - * Might be a file access, cache read, DB select... - * - * @param mixed $id - * The data object identifier - * - * @return mixed|null - * The wanted data object (null if not found) - * - * @throws DataLayerException - * When read fails - */ - abstract protected function doRead($id); - - /** - * Actually write a data object into the current layer. - * - * Might be a file edit, cache update, DB insert/update... - * - * @param mixed $id - * The data object identifier - * @param mixed $data - * The data object to be written - * - * @throws DataLayerException - * When write fails - */ - abstract protected function doWrite($id, $data); -} diff --git a/src/Core/Data/Layer/DataLayerException.php b/src/Core/Data/Layer/DataLayerException.php deleted file mode 100644 index 568a4689..00000000 --- a/src/Core/Data/Layer/DataLayerException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Data\Layer; - -use Exception; - -class DataLayerException extends Exception -{ -} diff --git a/src/Core/Domain/Address/AddressSettings.php b/src/Core/Domain/Address/AddressSettings.php deleted file mode 100644 index 48e0ab1a..00000000 --- a/src/Core/Domain/Address/AddressSettings.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address; - -/** - * Defines settings for addresses - */ -final class AddressSettings -{ - /** - * Maximum allowed length of symbols for 'firstname' and 'lastname' fields - */ - const MAX_NAME_LENGTH = 255; - - /** - * Maximum allowed length of symbols for phone number (both phone and mobile_phone) - */ - const MAX_PHONE_LENGTH = 32; - - /** - * Maximum allowed length of symbols for address - */ - const MAX_ADDRESS_LENGTH = 128; - - /** - * Maximum allowed length of symbols for post code - */ - const MAX_POST_CODE_LENGTH = 12; - - /** - * Maximum allowed length of symbols for city name - */ - const MAX_CITY_NAME_LENGTH = 64; - - /** - * Maximum allowed length of symbols for field named 'other' - */ - const MAX_OTHER_LENGTH = 300; -} diff --git a/src/Core/Domain/Address/Command/AbstractEditAddressCommand.php b/src/Core/Domain/Address/Command/AbstractEditAddressCommand.php deleted file mode 100644 index 713c0355..00000000 --- a/src/Core/Domain/Address/Command/AbstractEditAddressCommand.php +++ /dev/null @@ -1,415 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Command; - -use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Country\ValueObject\CountryId; -use PrestaShop\PrestaShop\Core\Domain\State\Exception\StateConstraintException; -use PrestaShop\PrestaShop\Core\Domain\State\ValueObject\StateId; - -class AbstractEditAddressCommand -{ - /** - * @var string|null - */ - protected $addressAlias; - - /** - * @var string|null - */ - protected $firstName; - - /** - * @var string|null - */ - protected $lastName; - - /** - * @var string|null - */ - protected $address; - - /** - * @var string|null - */ - protected $city; - - /** - * @var string|null - */ - protected $postCode; - - /** - * @var CountryId|null - */ - protected $countryId; - - /** - * @var string|null - */ - protected $dni; - - /** - * @var string|null - */ - protected $company; - - /** - * @var string|null - */ - protected $vatNumber; - - /** - * @var string|null - */ - protected $address2; - - /** - * @var StateId|null - */ - protected $stateId; - - /** - * @var string|null - */ - protected $homePhone; - - /** - * @var string|null - */ - protected $mobilePhone; - - /** - * @var string|null - */ - protected $other; - - /** - * @return string|null - */ - public function getAddressAlias(): ?string - { - return $this->addressAlias; - } - - /** - * @param string $addressAlias - * - * @return self - */ - public function setAddressAlias(string $addressAlias): self - { - $this->addressAlias = $addressAlias; - - return $this; - } - - /** - * @return string|null - */ - public function getFirstName(): ?string - { - return $this->firstName; - } - - /** - * @param string $firstName - * - * @return self - */ - public function setFirstName(string $firstName): self - { - $this->firstName = $firstName; - - return $this; - } - - /** - * @return string|null - */ - public function getLastName(): ?string - { - return $this->lastName; - } - - /** - * @param string $lastName - * - * @return self - */ - public function setLastName(string $lastName): self - { - $this->lastName = $lastName; - - return $this; - } - - /** - * @return string|null - */ - public function getAddress(): ?string - { - return $this->address; - } - - /** - * @param string $address - * - * @return self - */ - public function setAddress(string $address): self - { - $this->address = $address; - - return $this; - } - - /** - * @return string|null - */ - public function getCity(): ?string - { - return $this->city; - } - - /** - * @param string $city - * - * @return self - */ - public function setCity(string $city): self - { - $this->city = $city; - - return $this; - } - - /** - * @return string|null - */ - public function getPostCode(): ?string - { - return $this->postCode; - } - - /** - * @param string $postCode - * - * @return self - */ - public function setPostCode(string $postCode): self - { - $this->postCode = $postCode; - - return $this; - } - - /** - * @return CountryId|null - */ - public function getCountryId(): ?CountryId - { - return $this->countryId; - } - - /** - * @param int|null $countryId - * - * @return self - * - * @throws CountryConstraintException - */ - public function setCountryId(int $countryId): self - { - $this->countryId = new CountryId($countryId); - - return $this; - } - - /** - * @return string|null - */ - public function getDni(): ?string - { - return $this->dni; - } - - /** - * @param string $dni - * - * @return self - */ - public function setDni(string $dni): self - { - $this->dni = $dni; - - return $this; - } - - /** - * @return string|null - */ - public function getCompany(): ?string - { - return $this->company; - } - - /** - * @param string $company - * - * @return self - */ - public function setCompany(string $company): self - { - $this->company = $company; - - return $this; - } - - /** - * @return string|null - */ - public function getVatNumber(): ?string - { - return $this->vatNumber; - } - - /** - * @param string $vatNumber - * - * @return self - */ - public function setVatNumber(string $vatNumber): self - { - $this->vatNumber = $vatNumber; - - return $this; - } - - /** - * @return string|null - */ - public function getAddress2(): ?string - { - return $this->address2; - } - - /** - * @param string $address2 - * - * @return self - */ - public function setAddress2(string $address2): self - { - $this->address2 = $address2; - - return $this; - } - - /** - * @return StateId|null - */ - public function getStateId(): ?StateId - { - return $this->stateId; - } - - /** - * @param int $stateId - * - * @return self - * - * @throws StateConstraintException - */ - public function setStateId(int $stateId): self - { - $this->stateId = new StateId($stateId); - - return $this; - } - - /** - * @return string|null - */ - public function getHomePhone(): ?string - { - return $this->homePhone; - } - - /** - * @param string|null $homePhone - * - * @return self - */ - public function setHomePhone(string $homePhone): self - { - $this->homePhone = $homePhone; - - return $this; - } - - /** - * @return string|null - */ - public function getMobilePhone(): ?string - { - return $this->mobilePhone; - } - - /** - * @param string $mobilePhone - * - * @return self - */ - public function setMobilePhone(string $mobilePhone): self - { - $this->mobilePhone = $mobilePhone; - - return $this; - } - - /** - * @return string|null - */ - public function getOther(): ?string - { - return $this->other; - } - - /** - * @param string $other - * - * @return self - */ - public function setOther(string $other): self - { - $this->other = $other; - - return $this; - } -} diff --git a/src/Core/Domain/Address/Command/AddCustomerAddressCommand.php b/src/Core/Domain/Address/Command/AddCustomerAddressCommand.php deleted file mode 100644 index c2d8afb0..00000000 --- a/src/Core/Domain/Address/Command/AddCustomerAddressCommand.php +++ /dev/null @@ -1,304 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Command; - -use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Country\ValueObject\CountryId; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; -use PrestaShop\PrestaShop\Core\Domain\State\Exception\StateConstraintException; -use PrestaShop\PrestaShop\Core\Domain\State\ValueObject\StateId; - -/** - * Adds new customer address - */ -class AddCustomerAddressCommand -{ - /** - * @var CustomerId - */ - private $customerId; - - /** - * @var string - */ - private $addressAlias; - - /** - * @var string - */ - private $firstName; - - /** - * @var string - */ - private $lastName; - - /** - * @var string - */ - private $address; - - /** - * @var string - */ - private $city; - - /** - * @var string|null - */ - private $postCode; - - /** - * @var CountryId - */ - private $countryId; - - /** - * @var string|null - */ - private $dni; - - /** - * @var string|null - */ - private $company; - - /** - * @var string|null - */ - private $vatNumber; - - /** - * @var string|null - */ - private $address2; - - /** - * @var StateId|null - */ - private $stateId; - - /** - * @var string|null - */ - private $homePhone; - - /** - * @var string|null - */ - private $mobilePhone; - - /** - * @var string|null - */ - private $other; - - /** - * @param int $customerId - * @param string $addressAlias - * @param string $firstName - * @param string $lastName - * @param string $address - * @param string $city - * @param int $countryId - * @param string $postcode - * @param string $dni - * @param string $company - * @param string $vat_number - * @param string $address2 - * @param int $id_state - * @param string $phone - * @param string $phone_mobile - * @param string $other - * - * @throws CountryConstraintException - * @throws StateConstraintException - */ - public function __construct( - int $customerId, - string $addressAlias, - string $firstName, - string $lastName, - string $address, - string $city, - int $countryId, - string $postcode, - string $dni = null, - string $company = null, - string $vat_number = null, - string $address2 = null, - int $id_state = 0, - string $phone = null, - ?string $phone_mobile = null, - string $other = null - ) { - $this->customerId = new CustomerId($customerId); - $this->addressAlias = $addressAlias; - $this->firstName = $firstName; - $this->lastName = $lastName; - $this->address = $address; - $this->city = $city; - $this->countryId = new CountryId($countryId); - $this->postCode = $postcode; - $this->dni = $dni; - $this->company = $company; - $this->vatNumber = $vat_number; - $this->address2 = $address2; - $this->stateId = new StateId($id_state); - $this->homePhone = $phone; - $this->mobilePhone = $phone_mobile; - $this->other = $other; - } - - /** - * @return CustomerId - */ - public function getCustomerId(): CustomerId - { - return $this->customerId; - } - - /** - * @return string - */ - public function getAddressAlias(): string - { - return $this->addressAlias; - } - - /** - * @return string - */ - public function getFirstName(): string - { - return $this->firstName; - } - - /** - * @return string - */ - public function getLastName(): string - { - return $this->lastName; - } - - /** - * @return string - */ - public function getAddress(): string - { - return $this->address; - } - - /** - * @return string - */ - public function getCity(): string - { - return $this->city; - } - - /** - * @return string|null - */ - public function getPostCode(): ?string - { - return $this->postCode; - } - - /** - * @return CountryId - */ - public function getCountryId(): CountryId - { - return $this->countryId; - } - - /** - * @return string|null - */ - public function getDni(): ?string - { - return $this->dni; - } - - /** - * @return string|null - */ - public function getCompany(): ?string - { - return $this->company; - } - - /** - * @return string|null - */ - public function getVatNumber(): ?string - { - return $this->vatNumber; - } - - /** - * @return string|null - */ - public function getAddress2(): ?string - { - return $this->address2; - } - - /** - * @return StateId|null - */ - public function getStateId(): ?StateId - { - return $this->stateId; - } - - /** - * @return string|null - */ - public function getHomePhone(): ?string - { - return $this->homePhone; - } - - /** - * @return string|null - */ - public function getMobilePhone(): ?string - { - return $this->mobilePhone; - } - - /** - * @return string|null - */ - public function getOther(): ?string - { - return $this->other; - } -} diff --git a/src/Core/Domain/Address/Command/AddManufacturerAddressCommand.php b/src/Core/Domain/Address/Command/AddManufacturerAddressCommand.php deleted file mode 100644 index e26b2c85..00000000 --- a/src/Core/Domain/Address/Command/AddManufacturerAddressCommand.php +++ /dev/null @@ -1,266 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Command; - -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; - -/** - * Adds new address - */ -class AddManufacturerAddressCommand -{ - /** - * @var int|null - */ - private $manufacturerId; - - /** - * @var string - */ - private $lastName; - - /** - * @var string - */ - private $firstName; - - /** - * @var string - */ - private $address; - - /** - * @var string - */ - private $city; - - /** - * @var string|null - */ - private $address2; - - /** - * @var int|null - */ - private $countryId; - - /** - * @var string|null - */ - private $postCode; - - /** - * @var int|null - */ - private $stateId; - - /** - * @var string|null - */ - private $homePhone; - - /** - * @var string|null - */ - private $mobilePhone; - - /** - * @var string|null - */ - private $other; - - /** - * @var string|null - */ - private $dni; - - /** - * @param string $lastName - * @param string $firstName - * @param string $address - * @param int|null $countryId - * @param string $city - * @param int - * @param string|null $address2 - * @param string|null $postCode - * @param int|null $stateId - * @param string|null $homePhone - * @param string $mobilePhone - * @param string|null $other - * @param string|null $dni - * - * @throws AddressConstraintException - */ - public function __construct( - $lastName, - $firstName, - $address, - $countryId, - $city, - $manufacturerId = null, - $address2 = null, - $postCode = null, - $stateId = null, - $homePhone = null, - $mobilePhone = null, - $other = null, - $dni = null - ) { - $this->assertIsNullOrNonNegativeInt($manufacturerId); - $this->manufacturerId = $manufacturerId; - $this->lastName = $lastName; - $this->firstName = $firstName; - $this->address = $address; - $this->countryId = $countryId; - $this->city = $city; - $this->address2 = $address2; - $this->postCode = $postCode; - $this->stateId = $stateId; - $this->homePhone = $homePhone; - $this->mobilePhone = $mobilePhone; - $this->other = $other; - $this->dni = $dni; - } - - /** - * @return int - */ - public function getManufacturerId() - { - return $this->manufacturerId; - } - - /** - * @return string - */ - public function getLastName() - { - return $this->lastName; - } - - /** - * @return string - */ - public function getFirstName() - { - return $this->firstName; - } - - /** - * @return string - */ - public function getAddress() - { - return $this->address; - } - - /** - * @return string - */ - public function getCity() - { - return $this->city; - } - - /** - * @return string|null - */ - public function getAddress2() - { - return $this->address2; - } - - /** - * @return int - */ - public function getCountryId() - { - return $this->countryId; - } - - /** - * @return string|null - */ - public function getPostCode() - { - return $this->postCode; - } - - /** - * @return int|null - */ - public function getStateId() - { - return $this->stateId; - } - - /** - * @return string|null - */ - public function getHomePhone() - { - return $this->homePhone; - } - - /** - * @return string|null - */ - public function getMobilePhone() - { - return $this->mobilePhone; - } - - /** - * @return string|null - */ - public function getOther() - { - return $this->other; - } - - /** - * @return string|null - */ - public function getDni() - { - return $this->dni; - } - - /** - * @param $value - * - * @throws AddressConstraintException - */ - private function assertIsNullOrNonNegativeInt($value) - { - if (null === $value || is_int($value) || 0 <= $value) { - return; - } - - throw new AddressConstraintException(sprintf('Invalid manufacturer id "%s" provided for address.', var_export($value, true)), AddressConstraintException::INVALID_MANUFACTURER_ID); - } -} diff --git a/src/Core/Domain/Address/Command/BulkDeleteAddressCommand.php b/src/Core/Domain/Address/Command/BulkDeleteAddressCommand.php deleted file mode 100644 index 78d3354e..00000000 --- a/src/Core/Domain/Address/Command/BulkDeleteAddressCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Command; - -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; - -/** - * Deletes addresses in bulk action - */ -class BulkDeleteAddressCommand -{ - /** - * @var AddressId[] - */ - private $addressIds; - - /** - * @param int[] $addressIds - * - * @throws AddressConstraintException - */ - public function __construct($addressIds) - { - $this->setAddressIds($addressIds); - } - - /** - * @return AddressId[] - */ - public function getAdressIds() - { - return $this->addressIds; - } - - /** - * @param int[] $addressIds - * - * @throws AddressConstraintException - */ - private function setAddressIds(array $addressIds) - { - foreach ($addressIds as $addressId) { - $this->addressIds[] = new AddressId($addressId); - } - } -} diff --git a/src/Core/Domain/Address/Command/DeleteAddressCommand.php b/src/Core/Domain/Address/Command/DeleteAddressCommand.php deleted file mode 100644 index da353e72..00000000 --- a/src/Core/Domain/Address/Command/DeleteAddressCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Command; - -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; - -/** - * Deletes Address - */ -class DeleteAddressCommand -{ - /** - * @var AddressId - */ - private $addressId; - - /** - * @param int $addressId - * - * @throws AddressConstraintException - */ - public function __construct($addressId) - { - $this->addressId = new AddressId($addressId); - } - - /** - * @return AddressId - */ - public function getAddressId() - { - return $this->addressId; - } -} diff --git a/src/Core/Domain/Address/Command/EditCartAddressCommand.php b/src/Core/Domain/Address/Command/EditCartAddressCommand.php deleted file mode 100644 index cadb39f3..00000000 --- a/src/Core/Domain/Address/Command/EditCartAddressCommand.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Command; - -use PrestaShop\PrestaShop\Core\Domain\Cart\CartAddressType; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\InvalidAddressTypeException; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; - -/** - * Class EditCartAddressCommand used to edit a cart address and then update the related field - * so that it uses the new duplicated address. - */ -class EditCartAddressCommand extends AbstractEditAddressCommand -{ - const ALLOWED_ADDRESS_TYPES = [ - CartAddressType::INVOICE_ADDRESS_TYPE, - CartAddressType::DELIVERY_ADDRESS_TYPE, - ]; - - /** - * @var CartId - */ - private $cartId; - - /** - * @var - */ - private $addressType; - - /** - * @param int $cartId - * @param string $addressType - * - * @throws InvalidAddressTypeException - * @throws CartConstraintException - */ - public function __construct( - int $cartId, - string $addressType - ) { - $this->cartId = new CartId($cartId); - $this->setAddressType($addressType); - } - - /** - * @return CartId - */ - public function getCartId(): CartId - { - return $this->cartId; - } - - /** - * @return string - */ - public function getAddressType(): string - { - return $this->addressType; - } - - /** - * @param string $addressType - * - * @throws InvalidAddressTypeException - */ - private function setAddressType(string $addressType): void - { - if (!in_array($addressType, self::ALLOWED_ADDRESS_TYPES)) { - throw new InvalidAddressTypeException(sprintf( - 'Invalid address type %s, allowed values are: %s', - $addressType, - implode(',', self::ALLOWED_ADDRESS_TYPES) - )); - } - - $this->addressType = $addressType; - } -} diff --git a/src/Core/Domain/Address/Command/EditCustomerAddressCommand.php b/src/Core/Domain/Address/Command/EditCustomerAddressCommand.php deleted file mode 100644 index b0d095e0..00000000 --- a/src/Core/Domain/Address/Command/EditCustomerAddressCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Command; - -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; - -/** - * Command responsible for holding edits customer address data - */ -class EditCustomerAddressCommand extends AbstractEditAddressCommand -{ - /** - * @var AddressId - */ - private $addressId; - - /** - * @param int $addressId - * - * @throws AddressConstraintException - */ - public function __construct(int $addressId) - { - $this->addressId = new AddressId($addressId); - } - - /** - * @return AddressId - */ - public function getAddressId(): AddressId - { - return $this->addressId; - } -} diff --git a/src/Core/Domain/Address/Command/EditManufacturerAddressCommand.php b/src/Core/Domain/Address/Command/EditManufacturerAddressCommand.php deleted file mode 100644 index f85b727d..00000000 --- a/src/Core/Domain/Address/Command/EditManufacturerAddressCommand.php +++ /dev/null @@ -1,356 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Command; - -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; - -/** - * Edits manufacturer address - */ -class EditManufacturerAddressCommand -{ - /** - * @var AddressId - */ - private $addressId; - - /** - * @var int|null - */ - private $manufacturerId; - - /** - * @var string|null - */ - private $lastName; - - /** - * @var string|null - */ - private $firstName; - - /** - * @var string|null - */ - private $address; - - /** - * @var string|null - */ - private $city; - - /** - * @var string|null - */ - private $address2; - - /** - * @var int|null - */ - private $countryId; - - /** - * @var string|null - */ - private $postCode; - - /** - * @var int|null - */ - private $stateId; - - /** - * @var string|null - */ - private $homePhone; - - /** - * @var string|null - */ - private $mobilePhone; - - /** - * @var string|null - */ - private $other; - - /** - * @var string|null - */ - private $dni; - - /** - * @param int $addressId - * - * @throws AddressConstraintException - */ - public function __construct($addressId) - { - $this->addressId = new AddressId($addressId); - } - - /** - * @return AddressId - */ - public function getAddressId() - { - return $this->addressId; - } - - /** - * @param AddressId $addressId - */ - public function setAddressId($addressId) - { - $this->addressId = $addressId; - } - - /** - * @return int|null - */ - public function getManufacturerId() - { - return $this->manufacturerId; - } - - /** - * @param int $manufacturerId - * - * @throws AddressConstraintException - */ - public function setManufacturerId($manufacturerId) - { - $this->assertIsNullOrNonNegativeInt($manufacturerId); - $this->manufacturerId = $manufacturerId; - } - - /** - * @return string|null - */ - public function getLastName() - { - return $this->lastName; - } - - /** - * @param string|null $lastName - */ - public function setLastName($lastName) - { - $this->lastName = $lastName; - } - - /** - * @return string|null - */ - public function getFirstName() - { - return $this->firstName; - } - - /** - * @param string|null $firstName - */ - public function setFirstName($firstName) - { - $this->firstName = $firstName; - } - - /** - * @return string|null - */ - public function getAddress() - { - return $this->address; - } - - /** - * @param string|null $address - */ - public function setAddress($address) - { - $this->address = $address; - } - - /** - * @return string|null - */ - public function getCity() - { - return $this->city; - } - - /** - * @param string|null $city - */ - public function setCity($city) - { - $this->city = $city; - } - - /** - * @return string|null - */ - public function getAddress2() - { - return $this->address2; - } - - /** - * @param string|null $address2 - */ - public function setAddress2($address2) - { - $this->address2 = $address2; - } - - /** - * @return int|null - */ - public function getCountryId() - { - return $this->countryId; - } - - /** - * @param int|null $countryId - */ - public function setCountryId($countryId) - { - $this->countryId = $countryId; - } - - /** - * @return string|null - */ - public function getPostCode() - { - return $this->postCode; - } - - /** - * @param string|null $postCode - */ - public function setPostCode($postCode) - { - $this->postCode = $postCode; - } - - /** - * @return int|null - */ - public function getStateId() - { - return $this->stateId; - } - - /** - * @param int|null $stateId - */ - public function setStateId($stateId) - { - $this->stateId = $stateId; - } - - /** - * @return string|null - */ - public function getHomePhone() - { - return $this->homePhone; - } - - /** - * @param string|null $homePhone - */ - public function setHomePhone($homePhone) - { - $this->homePhone = $homePhone; - } - - /** - * @return string|null - */ - public function getMobilePhone() - { - return $this->mobilePhone; - } - - /** - * @param string|null $mobilePhone - */ - public function setMobilePhone($mobilePhone) - { - $this->mobilePhone = $mobilePhone; - } - - /** - * @return string|null - */ - public function getOther() - { - return $this->other; - } - - /** - * @param string|null $other - */ - public function setOther($other) - { - $this->other = $other; - } - - /** - * @return string|null - */ - public function getDni() - { - return $this->dni; - } - - /** - * @param string|null $dni - */ - public function setDni($dni) - { - $this->dni = $dni; - } - - /** - * @param $value - * - * @throws AddressConstraintException - */ - private function assertIsNullOrNonNegativeInt($value) - { - if (null === $value || is_int($value) || 0 <= $value) { - return; - } - throw new AddressConstraintException(sprintf('Invalid manufacturer id "%s" provided for address.', var_export($value, true)), AddressConstraintException::INVALID_MANUFACTURER_ID); - } -} diff --git a/src/Core/Domain/Address/Command/EditOrderAddressCommand.php b/src/Core/Domain/Address/Command/EditOrderAddressCommand.php deleted file mode 100644 index 3f184d14..00000000 --- a/src/Core/Domain/Address/Command/EditOrderAddressCommand.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Command; - -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidAddressTypeException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\OrderAddressType; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Class EditOrderAddressCommand used to edit an order address and then update the related field - * so that it uses the new duplicated address. - */ -class EditOrderAddressCommand extends AbstractEditAddressCommand -{ - const ALLOWED_ADDRESS_TYPES = [ - OrderAddressType::INVOICE_ADDRESS_TYPE, - OrderAddressType::DELIVERY_ADDRESS_TYPE, - ]; - - /** - * @var OrderId - */ - private $orderId; - - /** - * @var - */ - private $addressType; - - /** - * @param int $orderId - * @param string $addressType - * - * @throws InvalidAddressTypeException - * @throws OrderException - */ - public function __construct( - int $orderId, - string $addressType - ) { - $this->orderId = new OrderId($orderId); - $this->setAddressType($addressType); - } - - /** - * @return OrderId - */ - public function getOrderId(): OrderId - { - return $this->orderId; - } - - /** - * @return mixed - */ - public function getAddressType() - { - return $this->addressType; - } - - /** - * @param string $addressType - * - * @throws InvalidAddressTypeException - */ - private function setAddressType(string $addressType): void - { - if (!in_array($addressType, self::ALLOWED_ADDRESS_TYPES)) { - throw new InvalidAddressTypeException(sprintf( - 'Invalid address type %s, allowed values are: %s', - $addressType, - implode(',', self::ALLOWED_ADDRESS_TYPES) - )); - } - - $this->addressType = $addressType; - } -} diff --git a/src/Core/Domain/Address/Command/SetRequiredFieldsForAddressCommand.php b/src/Core/Domain/Address/Command/SetRequiredFieldsForAddressCommand.php deleted file mode 100644 index fc37e54c..00000000 --- a/src/Core/Domain/Address/Command/SetRequiredFieldsForAddressCommand.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Command; - -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\RequiredFields; - -/** - * Sets required fields for new address when adding - */ -class SetRequiredFieldsForAddressCommand -{ - /** - * @var string[] - */ - private $requiredFields; - - /** - * @param string[] $requiredFields - */ - public function __construct(array $requiredFields) - { - $this->assertContainsOnlyAllowedFields($requiredFields); - - $this->requiredFields = $requiredFields; - } - - /** - * @return string[] - */ - public function getRequiredFields() - { - return $this->requiredFields; - } - - /** - * Check that all provided fields are allowed. - * - * @param string[] $requiredFields - */ - private function assertContainsOnlyAllowedFields(array $requiredFields) - { - if (empty($requiredFields)) { - return; - } - - foreach ($requiredFields as $requiredField) { - if (!in_array($requiredField, RequiredFields::ALLOWED_REQUIRED_FIELDS)) { - throw new AddressConstraintException(sprintf('Required field %s is invalid. Allowed fields are: %s', $requiredField, implode(',', RequiredFields::ALLOWED_REQUIRED_FIELDS)), AddressConstraintException::INVALID_REQUIRED_FIELDS); - } - } - } -} diff --git a/src/Core/Domain/Address/CommandHandler/AddCustomerAddressHandlerInterface.php b/src/Core/Domain/Address/CommandHandler/AddCustomerAddressHandlerInterface.php deleted file mode 100644 index c57e9045..00000000 --- a/src/Core/Domain/Address/CommandHandler/AddCustomerAddressHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Address\Command\AddCustomerAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; - -/** - * Interface for service that handles command which adds new customer address - */ -interface AddCustomerAddressHandlerInterface -{ - /** - * @param AddCustomerAddressCommand $command - * - * @return AddressId - */ - public function handle(AddCustomerAddressCommand $command): AddressId; -} diff --git a/src/Core/Domain/Address/CommandHandler/AddManufacturerAddressHandlerInterface.php b/src/Core/Domain/Address/CommandHandler/AddManufacturerAddressHandlerInterface.php deleted file mode 100644 index 019c54da..00000000 --- a/src/Core/Domain/Address/CommandHandler/AddManufacturerAddressHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Address\Command\AddManufacturerAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; - -/** - * Interface for services that handles command which adds new manufacturer address - */ -interface AddManufacturerAddressHandlerInterface -{ - /** - * @param AddManufacturerAddressCommand $command - * - * @return AddressId - */ - public function handle(AddManufacturerAddressCommand $command); -} diff --git a/src/Core/Domain/Address/CommandHandler/BulkDeleteAddressHandlerInterface.php b/src/Core/Domain/Address/CommandHandler/BulkDeleteAddressHandlerInterface.php deleted file mode 100644 index 4bb35547..00000000 --- a/src/Core/Domain/Address/CommandHandler/BulkDeleteAddressHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Address\Command\BulkDeleteAddressCommand; - -/** - * Defines contract for BulkDeleteAddressHandler - */ -interface BulkDeleteAddressHandlerInterface -{ - /** - * @param BulkDeleteAddressCommand $command - */ - public function handle(BulkDeleteAddressCommand $command); -} diff --git a/src/Core/Domain/Address/CommandHandler/DeleteAddressHandlerInterface.php b/src/Core/Domain/Address/CommandHandler/DeleteAddressHandlerInterface.php deleted file mode 100644 index 6b956784..00000000 --- a/src/Core/Domain/Address/CommandHandler/DeleteAddressHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Address\Command\DeleteAddressCommand; - -/** - * Defines contract for DeleteAddressHandler - */ -interface DeleteAddressHandlerInterface -{ - /** - * @param DeleteAddressCommand $command - */ - public function handle(DeleteAddressCommand $command); -} diff --git a/src/Core/Domain/Address/CommandHandler/EditCartAddressHandlerInterface.php b/src/Core/Domain/Address/CommandHandler/EditCartAddressHandlerInterface.php deleted file mode 100644 index 89f0df5c..00000000 --- a/src/Core/Domain/Address/CommandHandler/EditCartAddressHandlerInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Address\Command\EditCartAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; - -/** - * Interface for services that handles command which edits cart address - */ -interface EditCartAddressHandlerInterface -{ - /** - * @param EditCartAddressCommand $command - * - * @return AddressId The newly created address id - */ - public function handle(EditCartAddressCommand $command): AddressId; -} diff --git a/src/Core/Domain/Address/CommandHandler/EditCustomerAddressHandlerInterface.php b/src/Core/Domain/Address/CommandHandler/EditCustomerAddressHandlerInterface.php deleted file mode 100644 index f27e9940..00000000 --- a/src/Core/Domain/Address/CommandHandler/EditCustomerAddressHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Address\Command\EditCustomerAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; - -/** - * Interface for services that handles command which edits customer address - */ -interface EditCustomerAddressHandlerInterface -{ - /** - * @param EditCustomerAddressCommand $command - * - * @return AddressId The (potentially) newly created address id - */ - public function handle(EditCustomerAddressCommand $command): AddressId; -} diff --git a/src/Core/Domain/Address/CommandHandler/EditManufacturerAddressHandlerInterface.php b/src/Core/Domain/Address/CommandHandler/EditManufacturerAddressHandlerInterface.php deleted file mode 100644 index 37fa08ba..00000000 --- a/src/Core/Domain/Address/CommandHandler/EditManufacturerAddressHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Address\Command\EditManufacturerAddressCommand; - -/** - * Interface for services that handles command which edits manufacturer address - */ -interface EditManufacturerAddressHandlerInterface -{ - /** - * @param EditManufacturerAddressCommand $command - */ - public function handle(EditManufacturerAddressCommand $command); -} diff --git a/src/Core/Domain/Address/CommandHandler/EditOrderAddressHandlerInterface.php b/src/Core/Domain/Address/CommandHandler/EditOrderAddressHandlerInterface.php deleted file mode 100644 index 46d161fe..00000000 --- a/src/Core/Domain/Address/CommandHandler/EditOrderAddressHandlerInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Address\Command\EditOrderAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; - -/** - * Interface for services that handles command which edits order address - */ -interface EditOrderAddressHandlerInterface -{ - /** - * @param EditOrderAddressCommand $command - * - * @return AddressId The newly created address id - */ - public function handle(EditOrderAddressCommand $command): AddressId; -} diff --git a/src/Core/Domain/Address/CommandHandler/SetRequiredFieldsForAddressHandlerInterface.php b/src/Core/Domain/Address/CommandHandler/SetRequiredFieldsForAddressHandlerInterface.php deleted file mode 100644 index 5ab33f81..00000000 --- a/src/Core/Domain/Address/CommandHandler/SetRequiredFieldsForAddressHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Address\Command\SetRequiredFieldsForAddressCommand; - -/** - * Defines interface for services that handles setting required fields for address command. - */ -interface SetRequiredFieldsForAddressHandlerInterface -{ - /** - * @param SetRequiredFieldsForAddressCommand $command - */ - public function handle(SetRequiredFieldsForAddressCommand $command); -} diff --git a/src/Core/Domain/Address/Configuration/AddressConstraint.php b/src/Core/Domain/Address/Configuration/AddressConstraint.php deleted file mode 100644 index 2d56d755..00000000 --- a/src/Core/Domain/Address/Configuration/AddressConstraint.php +++ /dev/null @@ -1,100 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Configuration; - -/** - * Stores address form constraints configuration values - */ -final class AddressConstraint -{ - /** - * Maximum length for address alias (value is constrained by database) - */ - const MAX_ALIAS_LENGTH = 32; - - /** - * Maximum length for company name (value is constrained by database) - */ - const MAX_COMPANY_LENGTH = 255; - - /** - * Maximum length for last name (value is constrained by database) - */ - const MAX_LAST_NAME_LENGTH = 255; - - /** - * Maximum length for first name (value is constrained by database) - */ - const MAX_FIRST_NAME_LENGTH = 255; - - /** - * Maximum length for address (value is constrained by database) - */ - const MAX_ADDRESS_LENGTH = 255; - - /** - * Maximum length for post code (value is constrained by database) - */ - const MAX_POSTCODE_LENGTH = 12; - - /** - * Maximum length for city name (value is constrained by database) - */ - const MAX_CITY_LENGTH = 64; - - /** - * Maximum length for other information - */ - const MAX_OTHER_LENGTH = 300; - - /** - * Maximum length for phone number (value is constrained by database) - */ - const MAX_PHONE_LENGTH = 32; - - /** - * Maximum length for VAT number (value is constrained by database) - */ - const MAX_VAT_LENGTH = 32; - - /** - * Maximum length for identification number (value is constrained by database) - */ - const MAX_DNI_LENGTH = 16; - - /** - * DNI field value regexp validation pattern - */ - const DNI_LITE_PATTERN = '/^[0-9A-Za-z-.]{1,16}$/U'; - - /** - * Prevents class to be instantiated - */ - private function __construct() - { - } -} diff --git a/src/Core/Domain/Address/Exception/AddressConstraintException.php b/src/Core/Domain/Address/Exception/AddressConstraintException.php deleted file mode 100644 index 8f50c8e2..00000000 --- a/src/Core/Domain/Address/Exception/AddressConstraintException.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Exception; - -/** - * Is thrown when address constraint is violated - */ -class AddressConstraintException extends AddressException -{ - /** - * When address id is not valid - */ - const INVALID_ID = 10; - - /** - * When manufacturer id provided for address is not valid - */ - const INVALID_MANUFACTURER_ID = 20; - - /** - * When one or more unspecified fields in address are invalid - */ - const INVALID_REQUIRED_FIELDS = 30; -} diff --git a/src/Core/Domain/Address/Exception/AddressException.php b/src/Core/Domain/Address/Exception/AddressException.php deleted file mode 100644 index 8885c72a..00000000 --- a/src/Core/Domain/Address/Exception/AddressException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for address sub-domain - */ -class AddressException extends DomainException -{ -} diff --git a/src/Core/Domain/Address/Exception/AddressNotFoundException.php b/src/Core/Domain/Address/Exception/AddressNotFoundException.php deleted file mode 100644 index 25b01c05..00000000 --- a/src/Core/Domain/Address/Exception/AddressNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Exception; - -/** - * Is thrown when address is not found - */ -class AddressNotFoundException extends AddressException -{ -} diff --git a/src/Core/Domain/Address/Exception/BulkDeleteAddressException.php b/src/Core/Domain/Address/Exception/BulkDeleteAddressException.php deleted file mode 100644 index 35daa74f..00000000 --- a/src/Core/Domain/Address/Exception/BulkDeleteAddressException.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Exception; - -use Exception; - -/** - * Thrown on failure to delete all selected addresses without errors - */ -class BulkDeleteAddressException extends AddressException -{ - /** - * @var int[] - */ - private $addressIds; - - /** - * @param int[] $addressIds - * @param string $message - * @param int $code - * @param Exception $previous - */ - public function __construct(array $addressIds, $message = '', $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - - $this->addressIds = $addressIds; - } - - /** - * @return int[] - */ - public function getAddressIds(): array - { - return $this->addressIds; - } -} diff --git a/src/Core/Domain/Address/Exception/CannotAddAddressException.php b/src/Core/Domain/Address/Exception/CannotAddAddressException.php deleted file mode 100644 index 71f29fa1..00000000 --- a/src/Core/Domain/Address/Exception/CannotAddAddressException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Exception; - -/** - * Thrown on failure to create address - */ -class CannotAddAddressException extends AddressException -{ -} diff --git a/src/Core/Domain/Address/Exception/CannotSetRequiredFieldsForAddressException.php b/src/Core/Domain/Address/Exception/CannotSetRequiredFieldsForAddressException.php deleted file mode 100644 index 1c32a550..00000000 --- a/src/Core/Domain/Address/Exception/CannotSetRequiredFieldsForAddressException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Exception; - -/** - * Exception thrown on failure to update address required fields - */ -class CannotSetRequiredFieldsForAddressException extends AddressException -{ -} diff --git a/src/Core/Domain/Address/Exception/CannotUpdateAddressException.php b/src/Core/Domain/Address/Exception/CannotUpdateAddressException.php deleted file mode 100644 index 7a76bf38..00000000 --- a/src/Core/Domain/Address/Exception/CannotUpdateAddressException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Exception; - -/** - * Thrown on failure to update address - */ -class CannotUpdateAddressException extends AddressException -{ -} diff --git a/src/Core/Domain/Address/Exception/CannotUpdateCartAddressException.php b/src/Core/Domain/Address/Exception/CannotUpdateCartAddressException.php deleted file mode 100644 index 7fc6a7ed..00000000 --- a/src/Core/Domain/Address/Exception/CannotUpdateCartAddressException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Exception; - -/** - * Thrown on failure to update address - */ -class CannotUpdateCartAddressException extends AddressException -{ -} diff --git a/src/Core/Domain/Address/Exception/CannotUpdateOrderAddressException.php b/src/Core/Domain/Address/Exception/CannotUpdateOrderAddressException.php deleted file mode 100644 index db241386..00000000 --- a/src/Core/Domain/Address/Exception/CannotUpdateOrderAddressException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Exception; - -/** - * Thrown on failure to update address - */ -class CannotUpdateOrderAddressException extends AddressException -{ -} diff --git a/src/Core/Domain/Address/Exception/DeleteAddressException.php b/src/Core/Domain/Address/Exception/DeleteAddressException.php deleted file mode 100644 index 2581a1ca..00000000 --- a/src/Core/Domain/Address/Exception/DeleteAddressException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Exception; - -/** - * Is thrown when address or addresses cannot be deleted - */ -class DeleteAddressException extends AddressException -{ - /** - * When fails to delete single address - */ - const FAILED_DELETE = 10; - - /** - * When fails to delete address in bulk action - */ - const FAILED_BULK_DELETE = 20; -} diff --git a/src/Core/Domain/Address/Exception/InvalidAddressFieldException.php b/src/Core/Domain/Address/Exception/InvalidAddressFieldException.php deleted file mode 100644 index a1af8407..00000000 --- a/src/Core/Domain/Address/Exception/InvalidAddressFieldException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Exception; - -/** - * Is thrown when address has invalid fields on saving/updating - */ -class InvalidAddressFieldException extends AddressException -{ -} diff --git a/src/Core/Domain/Address/Exception/InvalidAddressRequiredFieldsException.php b/src/Core/Domain/Address/Exception/InvalidAddressRequiredFieldsException.php deleted file mode 100644 index 759064a2..00000000 --- a/src/Core/Domain/Address/Exception/InvalidAddressRequiredFieldsException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Exception; - -/** - * Thrown when invalid address required fields provided for saving - */ -class InvalidAddressRequiredFieldsException extends AddressException -{ -} diff --git a/src/Core/Domain/Address/Query/GetCustomerAddressForEditing.php b/src/Core/Domain/Address/Query/GetCustomerAddressForEditing.php deleted file mode 100644 index 94104c20..00000000 --- a/src/Core/Domain/Address/Query/GetCustomerAddressForEditing.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Query; - -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; - -/** - * Gets customer address for editing - */ -class GetCustomerAddressForEditing -{ - /** - * @var AddressId - */ - private $addressId; - - /** - * @param int $addressId - * - * @throws AddressConstraintException - */ - public function __construct($addressId) - { - $this->addressId = new AddressId($addressId); - } - - /** - * @return AddressId - */ - public function getAddressId() - { - return $this->addressId; - } -} diff --git a/src/Core/Domain/Address/Query/GetManufacturerAddressForEditing.php b/src/Core/Domain/Address/Query/GetManufacturerAddressForEditing.php deleted file mode 100644 index b1f210d0..00000000 --- a/src/Core/Domain/Address/Query/GetManufacturerAddressForEditing.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Query; - -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; - -/** - * Gets manufacturer address for editing - */ -class GetManufacturerAddressForEditing -{ - /** - * @var AddressId - */ - private $addressId; - - /** - * @param int $addressId - * - * @throws AddressConstraintException - */ - public function __construct($addressId) - { - $this->addressId = new AddressId($addressId); - } - - /** - * @return AddressId - */ - public function getAddressId() - { - return $this->addressId; - } -} diff --git a/src/Core/Domain/Address/Query/GetRequiredFieldsForAddress.php b/src/Core/Domain/Address/Query/GetRequiredFieldsForAddress.php deleted file mode 100644 index 0a0bda60..00000000 --- a/src/Core/Domain/Address/Query/GetRequiredFieldsForAddress.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\Query; - -/** - * Gets fields that are required for address - */ -class GetRequiredFieldsForAddress -{ -} diff --git a/src/Core/Domain/Address/QueryHandler/GetCustomerAddressForEditingHandlerInterface.php b/src/Core/Domain/Address/QueryHandler/GetCustomerAddressForEditingHandlerInterface.php deleted file mode 100644 index 97135405..00000000 --- a/src/Core/Domain/Address/QueryHandler/GetCustomerAddressForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Address\Query\GetCustomerAddressForEditing; -use PrestaShop\PrestaShop\Core\Domain\Address\QueryResult\EditableCustomerAddress; - -/** - * Interface for services that handles query which gets customer address for editing - */ -interface GetCustomerAddressForEditingHandlerInterface -{ - /** - * @param GetCustomerAddressForEditing $query - * - * @return EditableCustomerAddress - */ - public function handle(GetCustomerAddressForEditing $query): EditableCustomerAddress; -} diff --git a/src/Core/Domain/Address/QueryHandler/GetManufacturerAddressForEditingHandlerInterface.php b/src/Core/Domain/Address/QueryHandler/GetManufacturerAddressForEditingHandlerInterface.php deleted file mode 100644 index 6222c916..00000000 --- a/src/Core/Domain/Address/QueryHandler/GetManufacturerAddressForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Address\Query\GetManufacturerAddressForEditing; -use PrestaShop\PrestaShop\Core\Domain\Address\QueryResult\EditableManufacturerAddress; - -/** - * Interface for services that handles query which gets manufacturer address for editing - */ -interface GetManufacturerAddressForEditingHandlerInterface -{ - /** - * @param GetManufacturerAddressForEditing $query - * - * @return EditableManufacturerAddress - */ - public function handle(GetManufacturerAddressForEditing $query); -} diff --git a/src/Core/Domain/Address/QueryHandler/GetRequiredFieldsForAddressHandlerInterface.php b/src/Core/Domain/Address/QueryHandler/GetRequiredFieldsForAddressHandlerInterface.php deleted file mode 100644 index 2e41d5a8..00000000 --- a/src/Core/Domain/Address/QueryHandler/GetRequiredFieldsForAddressHandlerInterface.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Address\Query\GetRequiredFieldsForAddress; - -interface GetRequiredFieldsForAddressHandlerInterface -{ - /** - * @param GetRequiredFieldsForAddress $query - * - * @return string[] - */ - public function handle(GetRequiredFieldsForAddress $query): array; -} diff --git a/src/Core/Domain/Address/QueryResult/EditableCustomerAddress.php b/src/Core/Domain/Address/QueryResult/EditableCustomerAddress.php deleted file mode 100644 index 7feabc98..00000000 --- a/src/Core/Domain/Address/QueryResult/EditableCustomerAddress.php +++ /dev/null @@ -1,348 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; -use PrestaShop\PrestaShop\Core\Domain\Country\ValueObject\CountryId; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; -use PrestaShop\PrestaShop\Core\Domain\State\ValueObject\StateId; - -/** - * Transfers customer address data for editing - */ -class EditableCustomerAddress -{ - /** - * @var AddressId - */ - private $addressId; - - /** - * @var CustomerId - */ - private $customerId; - - /** - * @var string - */ - private $customerEmail; - - /** - * @var string - */ - private $addressAlias; - - /** - * @var string - */ - private $firstName; - - /** - * @var string - */ - private $lastName; - - /** - * @var string - */ - private $address; - - /** - * @var string - */ - private $city; - - /** - * @var CountryId - */ - private $countryId; - - /** - * @var string|null - */ - private $postCode; - - /** - * @var string|null - */ - private $dni; - - /** - * @var string|null - */ - private $company; - - /** - * @var string|null - */ - private $vatNumber; - - /** - * @var string|null - */ - private $address2; - - /** - * @var StateId|null - */ - private $stateId; - - /** - * @var string|null - */ - private $homePhone; - - /** - * @var string|null - */ - private $mobilePhone; - - /** - * @var string|null - */ - private $other; - - /** - * @var string[] - */ - private $requiredFields; - - /** - * @param AddressId $addressId - * @param CustomerId $customerId - * @param string $customerEmail - * @param string $addressAlias - * @param string $firstName - * @param string $lastName - * @param string $address - * @param string $city - * @param CountryId $countryId - * @param string $postCode - * @param string $dni - * @param string $company - * @param string $vatNumber - * @param string $address2 - * @param StateId $stateId - * @param string $homePhone - * @param string $mobilePhone - * @param string $other - * @param string[] $requiredFields - */ - public function __construct( - AddressId $addressId, - CustomerId $customerId, - string $customerEmail, - string $addressAlias, - string $firstName, - string $lastName, - string $address, - string $city, - CountryId $countryId, - string $postCode, - string $dni, - string $company, - string $vatNumber, - string $address2, - StateId $stateId, - string $homePhone, - string $mobilePhone, - string $other, - array $requiredFields - ) { - $this->addressId = $addressId; - $this->customerId = $customerId; - $this->customerEmail = $customerEmail; - $this->addressAlias = $addressAlias; - $this->firstName = $firstName; - $this->lastName = $lastName; - $this->address = $address; - $this->city = $city; - $this->countryId = $countryId; - $this->postCode = $postCode; - $this->dni = $dni; - $this->company = $company; - $this->vatNumber = $vatNumber; - $this->address2 = $address2; - $this->stateId = $stateId; - $this->homePhone = $homePhone; - $this->mobilePhone = $mobilePhone; - $this->other = $other; - $this->requiredFields = $requiredFields; - } - - /** - * @return AddressId - */ - public function getAddressId(): AddressId - { - return $this->addressId; - } - - /** - * @return CustomerId - */ - public function getCustomerId(): CustomerId - { - return $this->customerId; - } - - /** - * @return string - */ - public function getCustomerEmail(): string - { - return $this->customerEmail; - } - - /** - * @return string - */ - public function getAddressAlias(): string - { - return $this->addressAlias; - } - - /** - * @return string - */ - public function getFirstName(): string - { - return $this->firstName; - } - - /** - * @return string - */ - public function getLastName(): string - { - return $this->lastName; - } - - /** - * @return string - */ - public function getAddress(): string - { - return $this->address; - } - - /** - * @return string - */ - public function getCity(): string - { - return $this->city; - } - - /** - * @return CountryId - */ - public function getCountryId(): CountryId - { - return $this->countryId; - } - - /** - * @return string[] - */ - public function getRequiredFields(): array - { - return $this->requiredFields; - } - - /** - * @return string|null - */ - public function getPostCode(): ?string - { - return $this->postCode; - } - - /** - * @return string|null - */ - public function getDni(): ?string - { - return $this->dni; - } - - /** - * @return string|null - */ - public function getCompany(): ?string - { - return $this->company; - } - - /** - * @return string|null - */ - public function getVatNumber(): ?string - { - return $this->vatNumber; - } - - /** - * @return string|null - */ - public function getAddress2(): ?string - { - return $this->address2; - } - - /** - * @return StateId|null - */ - public function getStateId(): ?StateId - { - return $this->stateId; - } - - /** - * @return string|null - */ - public function getHomePhone(): ?string - { - return $this->homePhone; - } - - /** - * @return string|null - */ - public function getMobilePhone(): ?string - { - return $this->mobilePhone; - } - - /** - * @return string|null - */ - public function getOther(): ?string - { - return $this->other; - } -} diff --git a/src/Core/Domain/Address/QueryResult/EditableManufacturerAddress.php b/src/Core/Domain/Address/QueryResult/EditableManufacturerAddress.php deleted file mode 100644 index 5514d0ca..00000000 --- a/src/Core/Domain/Address/QueryResult/EditableManufacturerAddress.php +++ /dev/null @@ -1,265 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; - -/** - * Transfers manufacturer address data for editing - */ -class EditableManufacturerAddress -{ - /** - * @var AddressId - */ - private $addressId; - - /** - * @var int - */ - private $manufacturerId; - - /** - * @var string - */ - private $lastName; - - /** - * @var string - */ - private $firstName; - - /** - * @var string - */ - private $address; - - /** - * @var string - */ - private $city; - - /** - * @var string - */ - private $address2; - - /** - * @var int - */ - private $countryId; - - /** - * @var string - */ - private $postCode; - - /** - * @var int - */ - private $stateId; - - /** - * @var string - */ - private $homePhone; - - /** - * @var string - */ - private $mobilePhone; - - /** - * @var string - */ - private $other; - - /** - * @var string - */ - private $dni; - - /** - * @param AddressId $addressId - * @param string $lastName - * @param string $firstName - * @param string $address - * @param string $city - * @param int $manufacturerId - * @param int $countryId - * @param string $address2 - * @param string $postCode - * @param int $stateId - * @param string $homePhone - * @param string $mobilePhone - * @param string $other - * @param string $dni - */ - public function __construct( - AddressId $addressId, - $lastName, - $firstName, - $address, - $city, - $manufacturerId, - $countryId, - $address2 = null, - $postCode = null, - $stateId = null, - $homePhone = null, - $mobilePhone = null, - $other = null, - $dni = null - ) { - $this->addressId = $addressId; - $this->lastName = $lastName; - $this->firstName = $firstName; - $this->address = $address; - $this->city = $city; - $this->manufacturerId = $manufacturerId; - $this->countryId = $countryId; - $this->address2 = $address2; - $this->postCode = $postCode; - $this->stateId = $stateId; - $this->homePhone = $homePhone; - $this->mobilePhone = $mobilePhone; - $this->other = $other; - $this->dni = $dni; - } - - /** - * @return AddressId - */ - public function getAddressId() - { - return $this->addressId; - } - - /** - * @return int - */ - public function getManufacturerId() - { - return $this->manufacturerId; - } - - /** - * @return string - */ - public function getLastName() - { - return $this->lastName; - } - - /** - * @return string - */ - public function getFirstName() - { - return $this->firstName; - } - - /** - * @return string - */ - public function getAddress() - { - return $this->address; - } - - /** - * @return string - */ - public function getCity() - { - return $this->city; - } - - /** - * @return string - */ - public function getAddress2() - { - return $this->address2; - } - - /** - * @return int - */ - public function getCountryId() - { - return $this->countryId; - } - - /** - * @return string - */ - public function getPostCode() - { - return $this->postCode; - } - - /** - * @return int - */ - public function getStateId() - { - return $this->stateId; - } - - /** - * @return string - */ - public function getHomePhone() - { - return $this->homePhone; - } - - /** - * @return string - */ - public function getMobilePhone() - { - return $this->mobilePhone; - } - - /** - * @return string - */ - public function getOther() - { - return $this->other; - } - - /** - * @return string - */ - public function getDni() - { - return $this->dni; - } -} diff --git a/src/Core/Domain/Address/ValueObject/AddressId.php b/src/Core/Domain/Address/ValueObject/AddressId.php deleted file mode 100644 index c02ba35d..00000000 --- a/src/Core/Domain/Address/ValueObject/AddressId.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; - -/** - * Provides address id - */ -class AddressId -{ - /** - * @var int - */ - private $addressId; - - /** - * @param int $addressId - * - * @throws AddressConstraintException - */ - public function __construct($addressId) - { - $this->assertIsIntegerGreaterThanZero($addressId); - $this->addressId = $addressId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->addressId; - } - - /** - * Validates that the value is integer and is greater than zero - * - * @param $value - * - * @throws AddressConstraintException - */ - private function assertIsIntegerGreaterThanZero($value) - { - if (!is_int($value) || 0 >= $value) { - throw new AddressConstraintException(sprintf('Invalid address id "%s".', var_export($value, true)), AddressConstraintException::INVALID_ID); - } - } -} diff --git a/src/Core/Domain/Address/ValueObject/RequiredFields.php b/src/Core/Domain/Address/ValueObject/RequiredFields.php deleted file mode 100644 index fd107245..00000000 --- a/src/Core/Domain/Address/ValueObject/RequiredFields.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Address\ValueObject; - -/** - * Stores configurable required field values for address. - */ -class RequiredFields -{ - const REQUIRED_FIELD_COMPANY = 'company'; - const REQUIRED_FIELD_ADDRESS_2 = 'address2'; - const REQUIRED_FIELD_POST_CODE = 'postcode'; - const REQUIRED_FIELD_OTHER = 'other'; - const REQUIRED_FIELD_PHONE = 'phone'; - const REQUIRED_FIELD_PHONE_MOBILE = 'phone_mobile'; - const REQUIRED_FIELD_VAT_NUMBER = 'vat_number'; - const REQUIRED_FIELD_DNI = 'dni'; - - /** - * Stores all allowed required fields to be configured for address - */ - const ALLOWED_REQUIRED_FIELDS = [ - self::REQUIRED_FIELD_COMPANY, - self::REQUIRED_FIELD_ADDRESS_2, - self::REQUIRED_FIELD_POST_CODE, - self::REQUIRED_FIELD_OTHER, - self::REQUIRED_FIELD_PHONE, - self::REQUIRED_FIELD_PHONE_MOBILE, - self::REQUIRED_FIELD_VAT_NUMBER, - self::REQUIRED_FIELD_DNI, - ]; -} diff --git a/src/Core/Domain/Attachment/AttachmentFileUploaderInterface.php b/src/Core/Domain/Attachment/AttachmentFileUploaderInterface.php deleted file mode 100644 index 142d6087..00000000 --- a/src/Core/Domain/Attachment/AttachmentFileUploaderInterface.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment; - -interface AttachmentFileUploaderInterface -{ - /** - * @param string $filePath - * @param string $uniqueFileName - * @param int $fileSize - * @param int|null $id - */ - public function upload(string $filePath, string $uniqueFileName, int $fileSize, int $id = null): void; -} diff --git a/src/Core/Domain/Attachment/Command/AddAttachmentCommand.php b/src/Core/Domain/Attachment/Command/AddAttachmentCommand.php deleted file mode 100644 index 9ad58193..00000000 --- a/src/Core/Domain/Attachment/Command/AddAttachmentCommand.php +++ /dev/null @@ -1,141 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Command; - -/** - * Attachment creation command - */ -class AddAttachmentCommand -{ - /** - * @var string|null - */ - private $pathName; - - /** - * @var int|null - */ - private $fileSize; - - /** - * @var string[] - */ - private $localizedNames; - - /** - * @var string[] - */ - private $localizedDescriptions = []; - - /** - * @var string|null - */ - private $mimeType; - - /** - * @var string|null - */ - private $originalName; - - /** - * @param array $localizedNames - * @param array $localizedDescriptions - */ - public function __construct( - array $localizedNames, - array $localizedDescriptions - ) { - $this->localizedNames = $localizedNames; - $this->localizedDescriptions = $localizedDescriptions; - } - - /** - * @param string $pathName - * @param int $fileSize - * @param string $mimeType - * @param string $originalName - */ - public function setFileInformation( - string $pathName, - int $fileSize, - string $mimeType, - string $originalName - ): void { - $this->pathName = $pathName; - $this->fileSize = $fileSize; - $this->mimeType = $mimeType; - $this->originalName = $originalName; - } - - /** - * @return string|null - */ - public function getFilePathName(): ?string - { - return $this->pathName; - } - - /** - * @return int|null - */ - public function getFileSize(): ?int - { - return $this->fileSize; - } - - /** - * @return string[] - */ - public function getLocalizedNames(): array - { - return $this->localizedNames; - } - - /** - * @return string[] - */ - public function getLocalizedDescriptions(): array - { - return $this->localizedDescriptions; - } - - /** - * @return string|null - */ - public function getMimeType(): ?string - { - return $this->mimeType; - } - - /** - * @return string|null - */ - public function getOriginalName(): ?string - { - return $this->originalName; - } -} diff --git a/src/Core/Domain/Attachment/Command/BulkDeleteAttachmentsCommand.php b/src/Core/Domain/Attachment/Command/BulkDeleteAttachmentsCommand.php deleted file mode 100644 index ed5fbcaa..00000000 --- a/src/Core/Domain/Attachment/Command/BulkDeleteAttachmentsCommand.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Command; - -use PrestaShop\PrestaShop\Core\Domain\Attachment\ValueObject\AttachmentId; - -/** - * Bulk delete attachment command is responsible for deleting Attachment - */ -class BulkDeleteAttachmentsCommand -{ - /** - * @var AttachmentId[] - */ - private $attachmentIds; - - /** - * @param int[] $attachmentIds - */ - public function __construct(array $attachmentIds) - { - $this->setAttachmentIds($attachmentIds); - } - - /** - * @return AttachmentId[] - */ - public function getAttachmentIds(): array - { - return $this->attachmentIds; - } - - /** - * @param array $attachmentIds - */ - private function setAttachmentIds(array $attachmentIds) - { - foreach ($attachmentIds as $attachmentId) { - $this->attachmentIds[] = new AttachmentId($attachmentId); - } - } -} diff --git a/src/Core/Domain/Attachment/Command/DeleteAttachmentCommand.php b/src/Core/Domain/Attachment/Command/DeleteAttachmentCommand.php deleted file mode 100644 index fa45ad37..00000000 --- a/src/Core/Domain/Attachment/Command/DeleteAttachmentCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Command; - -use PrestaShop\PrestaShop\Core\Domain\Attachment\ValueObject\AttachmentId; - -/** - * Delete attachment command is responsible for deleting Attachment - */ -class DeleteAttachmentCommand -{ - /** - * @var AttachmentId - */ - private $attachmentId; - - /** - * @param int $attachmentId - */ - public function __construct(int $attachmentId) - { - $this->attachmentId = new AttachmentId($attachmentId); - } - - /** - * @return AttachmentId - */ - public function getAttachmentId(): AttachmentId - { - return $this->attachmentId; - } -} diff --git a/src/Core/Domain/Attachment/Command/EditAttachmentCommand.php b/src/Core/Domain/Attachment/Command/EditAttachmentCommand.php deleted file mode 100644 index 164cb96a..00000000 --- a/src/Core/Domain/Attachment/Command/EditAttachmentCommand.php +++ /dev/null @@ -1,180 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Command; - -use PrestaShop\PrestaShop\Core\Domain\Attachment\ValueObject\AttachmentId; - -/** - * Attachment editing command - */ -class EditAttachmentCommand -{ - /** - * @var AttachmentId - */ - private $attachmentId; - - /** - * @var string|null - */ - private $pathName; - - /** - * @var string|null - */ - private $originalFileName; - - /** - * @var string|null - */ - private $mimeType; - - /** - * @var string[] - */ - private $localizedNames; - - /** - * @var string[]|null - */ - private $localizedDescriptions; - - /** - * @var string|null - */ - private $fileSize; - - /** - * @param AttachmentId $attachmentId - */ - public function __construct(AttachmentId $attachmentId) - { - $this->attachmentId = $attachmentId; - } - - /** - * @return AttachmentId - */ - public function getAttachmentId(): AttachmentId - { - return $this->attachmentId; - } - - /** - * @return string|null - */ - public function getPathName(): ?string - { - return $this->pathName; - } - - /** - * @param string|null $pathName - * @param string $mimeType - * @param string $originalFileName - * @param int $fileSize - * - * @return EditAttachmentCommand - */ - public function setFileInfo( - string $pathName, - string $mimeType, - string $originalFileName, - int $fileSize - ): EditAttachmentCommand { - $this->pathName = $pathName; - $this->mimeType = $mimeType; - $this->originalFileName = $originalFileName; - $this->fileSize = $fileSize; - - return $this; - } - - /** - * @return string|null - */ - public function getOriginalFileName(): ?string - { - return $this->originalFileName; - } - - /** - * @return string|null - */ - public function getMimeType(): ?string - { - return $this->mimeType; - } - - /** - * @return string[] - */ - public function getLocalizedNames(): array - { - return $this->localizedNames; - } - - /** - * @param string[] $localizedNames - * - * @return EditAttachmentCommand - */ - public function setLocalizedNames(array $localizedNames): EditAttachmentCommand - { - $this->localizedNames = $localizedNames; - - return $this; - } - - /** - * @return string[]|null - */ - public function getLocalizedDescriptions(): ?array - { - return $this->localizedDescriptions; - } - - /** - * @param string[]|null $localizedDescriptions - * - * @return EditAttachmentCommand - */ - public function setLocalizedDescriptions(?array $localizedDescriptions): EditAttachmentCommand - { - $this->localizedDescriptions = $localizedDescriptions; - - return $this; - } - - /** - * @return int|null - */ - public function getFileSize(): ?int - { - return $this->fileSize; - } -} diff --git a/src/Core/Domain/Attachment/CommandHandler/AddAttachmentHandlerInterface.php b/src/Core/Domain/Attachment/CommandHandler/AddAttachmentHandlerInterface.php deleted file mode 100644 index a5fe0c0f..00000000 --- a/src/Core/Domain/Attachment/CommandHandler/AddAttachmentHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Attachment\Command\AddAttachmentCommand; -use PrestaShop\PrestaShop\Core\Domain\Attachment\ValueObject\AttachmentId; - -interface AddAttachmentHandlerInterface -{ - /** - * @param AddAttachmentCommand $command - * - * @return AttachmentId - */ - public function handle(AddAttachmentCommand $command): AttachmentId; -} diff --git a/src/Core/Domain/Attachment/CommandHandler/BulkDeleteAttachmentsHandlerInterface.php b/src/Core/Domain/Attachment/CommandHandler/BulkDeleteAttachmentsHandlerInterface.php deleted file mode 100644 index fe31edc7..00000000 --- a/src/Core/Domain/Attachment/CommandHandler/BulkDeleteAttachmentsHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Attachment\Command\BulkDeleteAttachmentsCommand; - -/** - * Defines contract for bulk delete attachments handler - */ -interface BulkDeleteAttachmentsHandlerInterface -{ - /** - * @param BulkDeleteAttachmentsCommand $command - */ - public function handle(BulkDeleteAttachmentsCommand $command); -} diff --git a/src/Core/Domain/Attachment/CommandHandler/DeleteAttachmentHandlerInterface.php b/src/Core/Domain/Attachment/CommandHandler/DeleteAttachmentHandlerInterface.php deleted file mode 100644 index 9a43296a..00000000 --- a/src/Core/Domain/Attachment/CommandHandler/DeleteAttachmentHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Attachment\Command\DeleteAttachmentCommand; - -/** - * Defines contract for DeleteAttachmentHandler - */ -interface DeleteAttachmentHandlerInterface -{ - /** - * @param DeleteAttachmentCommand $command - */ - public function handle(DeleteAttachmentCommand $command); -} diff --git a/src/Core/Domain/Attachment/CommandHandler/EditAttachmentHandlerInterface.php b/src/Core/Domain/Attachment/CommandHandler/EditAttachmentHandlerInterface.php deleted file mode 100644 index 71bca86e..00000000 --- a/src/Core/Domain/Attachment/CommandHandler/EditAttachmentHandlerInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Attachment\Command\EditAttachmentCommand; - -interface EditAttachmentHandlerInterface -{ - /** - * @param EditAttachmentCommand $command - */ - public function handle(EditAttachmentCommand $command); -} diff --git a/src/Core/Domain/Attachment/Configuration/AttachmentConstraint.php b/src/Core/Domain/Attachment/Configuration/AttachmentConstraint.php deleted file mode 100644 index 8e82219c..00000000 --- a/src/Core/Domain/Attachment/Configuration/AttachmentConstraint.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Configuration; - -/** - * Stores attachment validation configuration values - */ -final class AttachmentConstraint -{ - /** - * Maximum length for name (value is constrained by database) - */ - const MAX_NAME_LENGTH = 32; - - /** - * Prevents class to be instantiated - */ - private function __construct() - { - } -} diff --git a/src/Core/Domain/Attachment/Exception/AttachmentConstraintException.php b/src/Core/Domain/Attachment/Exception/AttachmentConstraintException.php deleted file mode 100644 index 33aa5c2d..00000000 --- a/src/Core/Domain/Attachment/Exception/AttachmentConstraintException.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Exception; - -/** - * Exception is thrown when Attachment constraint is violated - */ -class AttachmentConstraintException extends AttachmentException -{ - const INVALID_ID = 1; - - const INVALID_FILE_SIZE = 2; - - const EMPTY_NAME = 3; - - const EMPTY_DESCRIPTION = 4; - - const INVALID_FIELDS = 5; - - const INVALID_DESCRIPTION = 6; - - const MISSING_NAME_IN_DEFAULT_LANGUAGE = 7; -} diff --git a/src/Core/Domain/Attachment/Exception/AttachmentException.php b/src/Core/Domain/Attachment/Exception/AttachmentException.php deleted file mode 100644 index 9052d9cd..00000000 --- a/src/Core/Domain/Attachment/Exception/AttachmentException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for Attachment subdomain - */ -class AttachmentException extends DomainException -{ -} diff --git a/src/Core/Domain/Attachment/Exception/AttachmentNotFoundException.php b/src/Core/Domain/Attachment/Exception/AttachmentNotFoundException.php deleted file mode 100644 index 5266438c..00000000 --- a/src/Core/Domain/Attachment/Exception/AttachmentNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Exception; - -/** - * Attachment not found exception - */ -class AttachmentNotFoundException extends AttachmentException -{ -} diff --git a/src/Core/Domain/Attachment/Exception/AttachmentUploadFailedException.php b/src/Core/Domain/Attachment/Exception/AttachmentUploadFailedException.php deleted file mode 100644 index d28ceb65..00000000 --- a/src/Core/Domain/Attachment/Exception/AttachmentUploadFailedException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Exception; - -/** - * Thrown when upload error occurs - */ -class AttachmentUploadFailedException extends AttachmentException -{ -} diff --git a/src/Core/Domain/Attachment/Exception/BulkDeleteAttachmentsException.php b/src/Core/Domain/Attachment/Exception/BulkDeleteAttachmentsException.php deleted file mode 100644 index 3550b6ea..00000000 --- a/src/Core/Domain/Attachment/Exception/BulkDeleteAttachmentsException.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Exception; - -use Exception; - -/** - * Exception is thrown on attachments bulk delete failure - */ -class BulkDeleteAttachmentsException extends AttachmentException -{ - /** - * @var int[] - */ - private $attachmentIds; - - /** - * @param int[] $attachmentIds - * @param string $message - * @param int $code - * @param Exception $previous - */ - public function __construct(array $attachmentIds, $message = '', $code = 0, $previous = null) - { - parent::__construct($message, $code, $previous); - - $this->attachmentIds = $attachmentIds; - } - - /** - * @return int[] - */ - public function getAttachmentIds(): array - { - return $this->attachmentIds; - } -} diff --git a/src/Core/Domain/Attachment/Exception/CannotAddAttachmentException.php b/src/Core/Domain/Attachment/Exception/CannotAddAttachmentException.php deleted file mode 100644 index e1bf5119..00000000 --- a/src/Core/Domain/Attachment/Exception/CannotAddAttachmentException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Exception; - -/** - * Attachment can not be added exception - */ -class CannotAddAttachmentException extends AttachmentException -{ -} diff --git a/src/Core/Domain/Attachment/Exception/CannotUnlinkAttachmentException.php b/src/Core/Domain/Attachment/Exception/CannotUnlinkAttachmentException.php deleted file mode 100644 index 0802b6ed..00000000 --- a/src/Core/Domain/Attachment/Exception/CannotUnlinkAttachmentException.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Exception; - -use Throwable; - -/** - * Thrown when file unlink fails - */ -class CannotUnlinkAttachmentException extends AttachmentException -{ - /** - * @var string - */ - private $filePath = ''; - - /** - * @param string $message - * @param int $code - */ - public function __construct($message = '', $code = 0, Throwable $previous = null, string $filePath = '') - { - parent::__construct($message, $code, $previous); - $this->filePath = $filePath; - } - - public function getFilePath(): string - { - return $this->filePath; - } -} diff --git a/src/Core/Domain/Attachment/Exception/CannotUpdateAttachmentException.php b/src/Core/Domain/Attachment/Exception/CannotUpdateAttachmentException.php deleted file mode 100644 index 500bd035..00000000 --- a/src/Core/Domain/Attachment/Exception/CannotUpdateAttachmentException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Exception; - -/** - * Is thrown when error occurred on attachment update - */ -class CannotUpdateAttachmentException extends AttachmentException -{ -} diff --git a/src/Core/Domain/Attachment/Exception/DeleteAttachmentException.php b/src/Core/Domain/Attachment/Exception/DeleteAttachmentException.php deleted file mode 100644 index a4efa6f7..00000000 --- a/src/Core/Domain/Attachment/Exception/DeleteAttachmentException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Exception; - -/** - * Exception is thrown when attachment or attachments cannot be deleted - */ -class DeleteAttachmentException extends AttachmentException -{ -} diff --git a/src/Core/Domain/Attachment/Exception/EmptyFileException.php b/src/Core/Domain/Attachment/Exception/EmptyFileException.php deleted file mode 100644 index 46aeee8f..00000000 --- a/src/Core/Domain/Attachment/Exception/EmptyFileException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Exception; - -/** - * Thrown on trying to upload empty file - */ -class EmptyFileException extends AttachmentException -{ -} diff --git a/src/Core/Domain/Attachment/Query/GetAttachment.php b/src/Core/Domain/Attachment/Query/GetAttachment.php deleted file mode 100644 index d4605538..00000000 --- a/src/Core/Domain/Attachment/Query/GetAttachment.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Query; - -use PrestaShop\PrestaShop\Core\Domain\Attachment\ValueObject\AttachmentId; - -/** - * Get attachment query - */ -class GetAttachment -{ - /** - * @var AttachmentId - */ - private $attachmentId; - - /** - * @param int $attachmentId - */ - public function __construct(int $attachmentId) - { - $this->attachmentId = new AttachmentId($attachmentId); - } - - /** - * @return AttachmentId - */ - public function getAttachmentId(): AttachmentId - { - return $this->attachmentId; - } -} diff --git a/src/Core/Domain/Attachment/Query/GetAttachmentForEditing.php b/src/Core/Domain/Attachment/Query/GetAttachmentForEditing.php deleted file mode 100644 index f1b41e6c..00000000 --- a/src/Core/Domain/Attachment/Query/GetAttachmentForEditing.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\Query; - -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\ValueObject\AttachmentId; - -/** - * Gets attachment information for editing. - */ -class GetAttachmentForEditing -{ - /** - * @var AttachmentId - */ - private $attachmentId; - - /** - * @param int $attachmentIdValue - * - * @throws AttachmentConstraintException - */ - public function __construct(int $attachmentIdValue) - { - $this->attachmentId = new AttachmentId($attachmentIdValue); - } - - /** - * @return AttachmentId - */ - public function getAttachmentId(): AttachmentId - { - return $this->attachmentId; - } -} diff --git a/src/Core/Domain/Attachment/QueryHandler/GetAttachmentForEditingHandlerInterface.php b/src/Core/Domain/Attachment/QueryHandler/GetAttachmentForEditingHandlerInterface.php deleted file mode 100644 index 04c1e418..00000000 --- a/src/Core/Domain/Attachment/QueryHandler/GetAttachmentForEditingHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Attachment\Query\GetAttachmentForEditing; -use PrestaShop\PrestaShop\Core\Domain\Attachment\QueryResult\EditableAttachment; - -interface GetAttachmentForEditingHandlerInterface -{ - /** - * @param GetAttachmentForEditing $query - * - * @return EditableAttachment - */ - public function handle(GetAttachmentForEditing $query): EditableAttachment; -} diff --git a/src/Core/Domain/Attachment/QueryHandler/GetAttachmentHandlerInterface.php b/src/Core/Domain/Attachment/QueryHandler/GetAttachmentHandlerInterface.php deleted file mode 100644 index 66389822..00000000 --- a/src/Core/Domain/Attachment/QueryHandler/GetAttachmentHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Attachment\Query\GetAttachment; -use PrestaShop\PrestaShop\Core\Domain\Attachment\QueryResult\Attachment; - -/** - * Defines contract for get attachment handler - */ -interface GetAttachmentHandlerInterface -{ - /** - * @param GetAttachment $query - * - * @return Attachment - */ - public function handle(GetAttachment $query): Attachment; -} diff --git a/src/Core/Domain/Attachment/QueryResult/Attachment.php b/src/Core/Domain/Attachment/QueryResult/Attachment.php deleted file mode 100644 index a1fbcd8c..00000000 --- a/src/Core/Domain/Attachment/QueryResult/Attachment.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\QueryResult; - -/** - * Stores attachment path and original name information. - */ -class Attachment -{ - /** - * @var string - */ - private $path; - - /** - * @var string - */ - private $name; - - /** - * @param string $path - * @param string $name - */ - public function __construct(string $path, string $name) - { - $this->path = $path; - $this->name = $name; - } - - /** - * @return string - */ - public function getPath(): string - { - return $this->path; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } -} diff --git a/src/Core/Domain/Attachment/QueryResult/EditableAttachment.php b/src/Core/Domain/Attachment/QueryResult/EditableAttachment.php deleted file mode 100644 index 75467cff..00000000 --- a/src/Core/Domain/Attachment/QueryResult/EditableAttachment.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\QueryResult; - -use SplFileInfo; - -/** - * Stores editable data for attachment - */ -class EditableAttachment -{ - /** - * @var string - */ - private $fileName; - - /** - * @var string[] - */ - private $name; - - /** - * @var string[]|null - */ - private $description; - - /** - * @var SplFileInfo|null - */ - private $file; - - /** - * @param string $fileName - * @param string[] $name - * @param string[]|null $description - */ - public function __construct( - string $fileName, - array $name, - array $description - ) { - $this->fileName = $fileName; - $this->name = $name; - $this->description = $description; - } - - /** - * @return string - */ - public function getFileName(): string - { - return $this->fileName; - } - - /** - * @return string[] - */ - public function getName(): array - { - return $this->name; - } - - /** - * @return string[]|null - */ - public function getDescription(): ?array - { - return $this->description; - } - - /** - * @return SplFileInfo|null - */ - public function getFile(): ?SplFileInfo - { - return $this->file; - } - - /** - * @param SplFileInfo|null $file - * - * @return EditableAttachment - */ - public function setFile(?SplFileInfo $file): EditableAttachment - { - $this->file = $file; - - return $this; - } -} diff --git a/src/Core/Domain/Attachment/ValueObject/AttachmentId.php b/src/Core/Domain/Attachment/ValueObject/AttachmentId.php deleted file mode 100644 index 1a73c762..00000000 --- a/src/Core/Domain/Attachment/ValueObject/AttachmentId.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Attachment\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentConstraintException; - -/** - * Class provides attachment id - */ -class AttachmentId -{ - /** - * @var int - */ - private $id; - - /** - * @param int $id - * - * @throws AttachmentConstraintException] - */ - public function __construct(int $id) - { - $this->assertIsValidId($id); - - $this->id = $id; - } - - /** - * @return int - */ - public function getValue(): int - { - return $this->id; - } - - /** - * @param int $attachmentId - * - * @throws AttachmentConstraintException - */ - private function assertIsValidId(int $attachmentId): void - { - if (0 >= $attachmentId) { - throw new AttachmentConstraintException(sprintf('Invalid Attachment id %s supplied', var_export($attachmentId, true)), AttachmentConstraintException::INVALID_ID); - } - } -} diff --git a/src/Core/Domain/Cart/CartAddressType.php b/src/Core/Domain/Cart/CartAddressType.php deleted file mode 100644 index 400f3ebe..00000000 --- a/src/Core/Domain/Cart/CartAddressType.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Cart; - -/** - * Used to identity which type of address has to be edited - */ -class CartAddressType -{ - const DELIVERY_ADDRESS_TYPE = 'delivery_address'; - - const INVOICE_ADDRESS_TYPE = 'invoice_address'; -} diff --git a/src/Core/Domain/Cart/Command/AddCartRuleToCartCommand.php b/src/Core/Domain/Cart/Command/AddCartRuleToCartCommand.php deleted file mode 100644 index 377ba6e6..00000000 --- a/src/Core/Domain/Cart/Command/AddCartRuleToCartCommand.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Command; - -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\CartRuleId; - -/** - * Adds cart rule to given cart. - */ -class AddCartRuleToCartCommand -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @var CartRuleId - */ - private $cartRuleId; - - /** - * @param int $cartId - * @param int $cartRuleId - */ - public function __construct($cartId, $cartRuleId) - { - $this->cartId = new CartId($cartId); - $this->cartRuleId = new CartRuleId($cartRuleId); - } - - /** - * @return CartId - */ - public function getCartId() - { - return $this->cartId; - } - - /** - * @return CartRuleId - */ - public function getCartRuleId() - { - return $this->cartRuleId; - } -} diff --git a/src/Core/Domain/Cart/Command/AddCustomizationCommand.php b/src/Core/Domain/Cart/Command/AddCustomizationCommand.php deleted file mode 100644 index 0f4aee62..00000000 --- a/src/Core/Domain/Cart/Command/AddCustomizationCommand.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Command; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; - -/** - * Adds product customization - */ -class AddCustomizationCommand -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @var ProductId - */ - private $productId; - - /** - * @var array key - value pairs where key is the id of customization field and the value is the customization value - */ - private $customizationValuesByFieldIds; - - /** - * @param int $cartId - * @param int $productId - * @param array $customizationValuesByFieldIds - * - * @throws CartConstraintException - */ - public function __construct(int $cartId, int $productId, array $customizationValuesByFieldIds) - { - $this->cartId = new CartId($cartId); - $this->productId = new ProductId($productId); - $this->customizationValuesByFieldIds = $customizationValuesByFieldIds; - } - - /** - * @return CartId - */ - public function getCartId(): CartId - { - return $this->cartId; - } - - /** - * @return ProductId - */ - public function getProductId(): ProductId - { - return $this->productId; - } - - /** - * @return array - */ - public function getCustomizationValuesByFieldIds(): array - { - return $this->customizationValuesByFieldIds; - } -} diff --git a/src/Core/Domain/Cart/Command/AddProductToCartCommand.php b/src/Core/Domain/Cart/Command/AddProductToCartCommand.php deleted file mode 100644 index 01c887c7..00000000 --- a/src/Core/Domain/Cart/Command/AddProductToCartCommand.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Command; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShop\PrestaShop\Core\Domain\Product\Combination\ValueObject\CombinationId; -use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; - -/** - * Responsible for adding product to cart - */ -class AddProductToCartCommand -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @var ProductId - */ - private $productId; - - /** - * @var int - */ - private $quantity; - - /** - * @var CombinationId|null - */ - private $combinationId; - - /** - * @var array key-value pairs where key is customizationFieldId and value is customization field value - */ - private $customizationsByFieldIds; - - /** - * @param int $cartId - * @param int $productId - * @param int $quantity - * @param int|null $combinationId - * @param array $customizationsByFieldIds - * - * @throws CartConstraintException - */ - public function __construct( - int $cartId, - int $productId, - int $quantity, - ?int $combinationId = null, - array $customizationsByFieldIds = [] - ) { - $this->assertQtyIsPositive($quantity); - $this->setCombinationId($combinationId); - $this->cartId = new CartId($cartId); - $this->productId = new ProductId($productId); - $this->quantity = $quantity; - $this->customizationsByFieldIds = $customizationsByFieldIds; - } - - /** - * @return CartId - */ - public function getCartId(): CartId - { - return $this->cartId; - } - - /** - * @return ProductId - */ - public function getProductId(): ProductId - { - return $this->productId; - } - - /** - * @return int - */ - public function getQuantity(): int - { - return $this->quantity; - } - - /** - * @return CombinationId|null - */ - public function getCombinationId(): ?CombinationId - { - return $this->combinationId; - } - - /** - * @return array - */ - public function getCustomizationsByFieldIds(): array - { - return $this->customizationsByFieldIds; - } - - /** - * @param int $qty - * - * @throws CartConstraintException - */ - private function assertQtyIsPositive(int $qty) - { - if (0 >= $qty) { - throw new CartConstraintException(sprintf('Quantity must be positive integer. "%s" given.', $qty), CartConstraintException::INVALID_QUANTITY); - } - } - - /** - * @param int|null $combinationId - */ - private function setCombinationId(?int $combinationId) - { - if (null !== $combinationId) { - $combinationId = new CombinationId($combinationId); - } - - $this->combinationId = $combinationId; - } -} diff --git a/src/Core/Domain/Cart/Command/CreateEmptyCustomerCartCommand.php b/src/Core/Domain/Cart/Command/CreateEmptyCustomerCartCommand.php deleted file mode 100644 index c5338ab6..00000000 --- a/src/Core/Domain/Cart/Command/CreateEmptyCustomerCartCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Command; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Creates empty cart for given customer. - */ -class CreateEmptyCustomerCartCommand -{ - /** - * @var CustomerId - */ - private $customerId; - - /** - * @param int $customerId Customer for which cart is being created - */ - public function __construct($customerId) - { - $this->customerId = new CustomerId($customerId); - } - - /** - * @return CustomerId - */ - public function getCustomerId() - { - return $this->customerId; - } -} diff --git a/src/Core/Domain/Cart/Command/RemoveCartRuleFromCartCommand.php b/src/Core/Domain/Cart/Command/RemoveCartRuleFromCartCommand.php deleted file mode 100644 index 34b67b57..00000000 --- a/src/Core/Domain/Cart/Command/RemoveCartRuleFromCartCommand.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Command; - -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\CartRuleId; - -/** - * Removes given cart rule from cart. - */ -class RemoveCartRuleFromCartCommand -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @var CartRuleId - */ - private $cartRuleId; - - /** - * @param $cartId - * @param $cartRuleId - */ - public function __construct(int $cartId, int $cartRuleId) - { - $this->cartId = new CartId($cartId); - $this->cartRuleId = new CartRuleId($cartRuleId); - } - - /** - * @return CartId - */ - public function getCartId() - { - return $this->cartId; - } - - /** - * @return CartRuleId - */ - public function getCartRuleId() - { - return $this->cartRuleId; - } -} diff --git a/src/Core/Domain/Cart/Command/RemoveProductFromCartCommand.php b/src/Core/Domain/Cart/Command/RemoveProductFromCartCommand.php deleted file mode 100644 index 62066dd9..00000000 --- a/src/Core/Domain/Cart/Command/RemoveProductFromCartCommand.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Command; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; - -/** - * Removes given product from cart. - */ -class RemoveProductFromCartCommand -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @var ProductId - */ - private $productId; - - /** - * @var int|null - */ - private $combinationId; - - /** - * @var int|null - */ - private $customizationId; - - /** - * @param int $cartId - * @param int $productId - * @param int|null $combinationId - * @param int|null $customizationId - * - * @throws CartConstraintException - */ - public function __construct( - int $cartId, - int $productId, - int $combinationId = null, - int $customizationId = null - ) { - $this->cartId = new CartId($cartId); - $this->productId = new ProductId($productId); - $this->combinationId = $combinationId; - $this->customizationId = $customizationId; - } - - /** - * @return CartId - */ - public function getCartId() - { - return $this->cartId; - } - - /** - * @return ProductId - */ - public function getProductId() - { - return $this->productId; - } - - /** - * @return int|null - */ - public function getCombinationId() - { - return $this->combinationId; - } - - /** - * @return int|null - */ - public function getCustomizationId() - { - return $this->customizationId; - } -} diff --git a/src/Core/Domain/Cart/Command/SendCartToCustomerCommand.php b/src/Core/Domain/Cart/Command/SendCartToCustomerCommand.php deleted file mode 100644 index 071f0cee..00000000 --- a/src/Core/Domain/Cart/Command/SendCartToCustomerCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Command; - -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; - -/** - * Sends email to the customer to process the payment for cart. - */ -class SendCartToCustomerCommand -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @param int $cartId - */ - public function __construct($cartId) - { - $this->cartId = new CartId($cartId); - } - - /** - * @return CartId - */ - public function getCartId() - { - return $this->cartId; - } -} diff --git a/src/Core/Domain/Cart/Command/UpdateCartAddressesCommand.php b/src/Core/Domain/Cart/Command/UpdateCartAddressesCommand.php deleted file mode 100644 index 6f52f0da..00000000 --- a/src/Core/Domain/Cart/Command/UpdateCartAddressesCommand.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Command; - -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; - -class UpdateCartAddressesCommand -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @var AddressId - */ - private $newDeliveryAddressId; - - /** - * @var AddressId - */ - private $newInvoiceAddressId; - - /** - * @param int $cartId - * @param int $newDeliveryAddressId - * @param int $newInvoiceAddressId - * - * @throws AddressConstraintException - * @throws CartConstraintException - */ - public function __construct(int $cartId, int $newDeliveryAddressId, int $newInvoiceAddressId) - { - $this->cartId = new CartId($cartId); - $this->setNewDeliveryAddressId($newDeliveryAddressId); - $this->setNewInvoiceAddressId($newInvoiceAddressId); - } - - /** - * @return CartId - */ - public function getCartId(): CartId - { - return $this->cartId; - } - - /** - * @return AddressId - */ - public function getNewDeliveryAddressId(): AddressId - { - return $this->newDeliveryAddressId; - } - - /** - * @return AddressId - */ - public function getNewInvoiceAddressId(): AddressId - { - return $this->newInvoiceAddressId; - } - - /** - * @param int $newDeliveryAddressId - * - * @throws AddressConstraintException - */ - private function setNewDeliveryAddressId(int $newDeliveryAddressId): void - { - $this->newDeliveryAddressId = new AddressId($newDeliveryAddressId); - } - - /** - * @param int $newInvoiceAddressId - * - * @throws AddressConstraintException - */ - private function setNewInvoiceAddressId(int $newInvoiceAddressId): void - { - $this->newInvoiceAddressId = new AddressId($newInvoiceAddressId); - } -} diff --git a/src/Core/Domain/Cart/Command/UpdateCartCarrierCommand.php b/src/Core/Domain/Cart/Command/UpdateCartCarrierCommand.php deleted file mode 100644 index b36f432d..00000000 --- a/src/Core/Domain/Cart/Command/UpdateCartCarrierCommand.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Command; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; - -/** - * Updates cart carrier (a.k.a delivery option) with new one. - */ -class UpdateCartCarrierCommand -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @var int - */ - private $newCarrierId; - - /** - * @param int $cartId - * @param $newCarrierId - * - * @throws CartConstraintException - */ - public function __construct($cartId, $newCarrierId) - { - $this->cartId = new CartId($cartId); - $this->newCarrierId = $newCarrierId; - } - - /** - * @return CartId - */ - public function getCartId(): CartId - { - return $this->cartId; - } - - /** - * @return int - */ - public function getNewCarrierId(): int - { - return $this->newCarrierId; - } -} diff --git a/src/Core/Domain/Cart/Command/UpdateCartCurrencyCommand.php b/src/Core/Domain/Cart/Command/UpdateCartCurrencyCommand.php deleted file mode 100644 index 3bf001cb..00000000 --- a/src/Core/Domain/Cart/Command/UpdateCartCurrencyCommand.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Command; - -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\CurrencyId; - -/** - * Updates cart currency - */ -class UpdateCartCurrencyCommand -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @var CurrencyId - */ - private $newCurrencyId; - - /** - * @param int $cartId - * @param int $newCurrencyId - */ - public function __construct($cartId, $newCurrencyId) - { - $this->cartId = new CartId($cartId); - $this->newCurrencyId = new CurrencyId($newCurrencyId); - } - - /** - * @return CartId - */ - public function getCartId() - { - return $this->cartId; - } - - /** - * @return CurrencyId - */ - public function getNewCurrencyId() - { - return $this->newCurrencyId; - } -} diff --git a/src/Core/Domain/Cart/Command/UpdateCartDeliverySettingsCommand.php b/src/Core/Domain/Cart/Command/UpdateCartDeliverySettingsCommand.php deleted file mode 100644 index 59dd5669..00000000 --- a/src/Core/Domain/Cart/Command/UpdateCartDeliverySettingsCommand.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Command; - -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; - -class UpdateCartDeliverySettingsCommand -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @var bool - */ - private $allowFreeShipping; - - /** - * @var bool - */ - private $isAGift; - - /** - * @var bool - */ - private $useRecycledPackaging; - - /** - * @var string - */ - private $giftMessage; - - /** - * @param int $cartId - * @param bool $allowFreeShipping - * @param bool|null $isAGift - * @param bool|null $useRecycledPackaging - * @param string|null $giftMessage - */ - public function __construct( - int $cartId, - bool $allowFreeShipping, - ?bool $isAGift = null, - ?bool $useRecycledPackaging = null, - ?string $giftMessage = null - ) { - $this->cartId = new CartId($cartId); - $this->allowFreeShipping = $allowFreeShipping; - $this->isAGift = $isAGift; - $this->useRecycledPackaging = $useRecycledPackaging; - $this->giftMessage = $giftMessage; - } - - /** - * @return CartId - */ - public function getCartId(): CartId - { - return $this->cartId; - } - - /** - * @return bool - */ - public function allowFreeShipping(): bool - { - return $this->allowFreeShipping; - } - - /** - * @return bool|null - */ - public function isAGift(): ?bool - { - return $this->isAGift; - } - - /** - * @return bool|null - */ - public function useRecycledPackaging(): ?bool - { - return $this->useRecycledPackaging; - } - - /** - * @return string|null - */ - public function getGiftMessage(): ?string - { - return $this->giftMessage; - } -} diff --git a/src/Core/Domain/Cart/Command/UpdateCartLanguageCommand.php b/src/Core/Domain/Cart/Command/UpdateCartLanguageCommand.php deleted file mode 100644 index ed1db92f..00000000 --- a/src/Core/Domain/Cart/Command/UpdateCartLanguageCommand.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Command; - -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; - -/** - * Updates language for given cart - */ -class UpdateCartLanguageCommand -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @var LanguageId - */ - private $newLanguageId; - - /** - * @param int $cartId - * @param int $newLanguageId - */ - public function __construct($cartId, $newLanguageId) - { - $this->cartId = new CartId($cartId); - $this->newLanguageId = new LanguageId($newLanguageId); - } - - /** - * @return CartId - */ - public function getCartId() - { - return $this->cartId; - } - - /** - * @return LanguageId - */ - public function getNewLanguageId() - { - return $this->newLanguageId; - } -} diff --git a/src/Core/Domain/Cart/Command/UpdateProductPriceInCartCommand.php b/src/Core/Domain/Cart/Command/UpdateProductPriceInCartCommand.php deleted file mode 100644 index c51c2c3b..00000000 --- a/src/Core/Domain/Cart/Command/UpdateProductPriceInCartCommand.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Command; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartException; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; - -/** - * Updates cart product price - */ -class UpdateProductPriceInCartCommand -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @var ProductId - */ - private $productId; - - /** - * @var int - */ - private $combinationId; - - /** - * @var float - */ - private $price; - - /** - * @param int $cartId - * @param int $productId - * @param int $combinationId - * @param float $price - */ - public function __construct($cartId, $productId, $combinationId, $price) - { - $this->assertPriceIsPositiveFloat($price); - - $this->cartId = new CartId($cartId); - $this->productId = new ProductId($productId); - $this->combinationId = $combinationId; - $this->price = $price; - } - - /** - * @return CartId - */ - public function getCartId() - { - return $this->cartId; - } - - /** - * @return ProductId - */ - public function getProductId() - { - return $this->productId; - } - - /** - * @return int - */ - public function getCombinationId() - { - return $this->combinationId; - } - - /** - * @return float - */ - public function getPrice() - { - return $this->price; - } - - /** - * @param float $price - */ - private function assertPriceIsPositiveFloat($price) - { - if (!is_float($price) || 0 > $price) { - throw new CartException(sprintf('Price %s is invalid. Price must be float greater than zero.', var_export($price, true))); - } - } -} diff --git a/src/Core/Domain/Cart/Command/UpdateProductQuantityInCartCommand.php b/src/Core/Domain/Cart/Command/UpdateProductQuantityInCartCommand.php deleted file mode 100644 index cb3e85d1..00000000 --- a/src/Core/Domain/Cart/Command/UpdateProductQuantityInCartCommand.php +++ /dev/null @@ -1,168 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Command; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartException; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShop\PrestaShop\Core\Domain\Product\Combination\ValueObject\CombinationId; -use PrestaShop\PrestaShop\Core\Domain\Product\Customization\ValueObject\CustomizationId; -use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; - -/** - * Updates product quantity in cart - * Quantity given must include gift product - */ -class UpdateProductQuantityInCartCommand -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @var ProductId - */ - private $productId; - - /** - * @var int - */ - private $newQuantity; - - /** - * @var CombinationId|null - */ - private $combinationId; - - /** - * @var CustomizationId|null - */ - private $customizationId; - - /** - * @param int $cartId - * @param int $productId - * @param int $quantity - * @param int|null $combinationId - * @param int|null $customizationId - * - * @throws CartConstraintException - * @throws CartException - */ - public function __construct( - $cartId, - $productId, - $quantity, - $combinationId = null, - $customizationId = null - ) { - $this->setCombinationId($combinationId); - $this->setCustomizationId($customizationId); - $this->assertQuantityIsPositive($quantity); - - $this->cartId = new CartId($cartId); - $this->productId = new ProductId($productId); - $this->newQuantity = $quantity; - } - - /** - * @return CartId - */ - public function getCartId() - { - return $this->cartId; - } - - /** - * @return ProductId - */ - public function getProductId() - { - return $this->productId; - } - - /** - * @return int - */ - public function getNewQuantity() - { - return $this->newQuantity; - } - - /** - * @return CombinationId|null - */ - public function getCombinationId(): ?CombinationId - { - return $this->combinationId; - } - - /** - * @return CustomizationId|null - */ - public function getCustomizationId(): ?CustomizationId - { - return $this->customizationId; - } - - /** - * @param int|null $combinationId - */ - private function setCombinationId(?int $combinationId) - { - if (null !== $combinationId) { - $combinationId = new CombinationId($combinationId); - } - - $this->combinationId = $combinationId; - } - - /** - * @param int|null $customizationId - */ - private function setCustomizationId(?int $customizationId) - { - if (null !== $customizationId) { - $customizationId = new CustomizationId($customizationId); - } - - $this->customizationId = $customizationId; - } - - /** - * @param int $qty - * - * @throws CartConstraintException - */ - private function assertQuantityIsPositive(int $qty) - { - if (0 >= $qty) { - throw new CartConstraintException(sprintf('Quantity must be positive integer. "%s" given.', $qty), CartConstraintException::INVALID_QUANTITY); - } - } -} diff --git a/src/Core/Domain/Cart/CommandHandler/AddCartRuleToCartHandlerInterface.php b/src/Core/Domain/Cart/CommandHandler/AddCartRuleToCartHandlerInterface.php deleted file mode 100644 index f99e1d06..00000000 --- a/src/Core/Domain/Cart/CommandHandler/AddCartRuleToCartHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\AddCartRuleToCartCommand; - -/** - * Interface for service that handles adding cart rule to cart. - */ -interface AddCartRuleToCartHandlerInterface -{ - /** - * @param AddCartRuleToCartCommand $command - */ - public function handle(AddCartRuleToCartCommand $command); -} diff --git a/src/Core/Domain/Cart/CommandHandler/AddCustomizationHandlerInterface.php b/src/Core/Domain/Cart/CommandHandler/AddCustomizationHandlerInterface.php deleted file mode 100644 index f00baa52..00000000 --- a/src/Core/Domain/Cart/CommandHandler/AddCustomizationHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\AddCustomizationCommand; -use PrestaShop\PrestaShop\Core\Domain\Product\Customization\ValueObject\CustomizationId; - -/** - * Defines contract to handle @var AddCustomizationCommand - */ -interface AddCustomizationHandlerInterface -{ - /** - * @param AddCustomizationCommand $command - * - * @return CustomizationId|null customizationId - */ - public function handle(AddCustomizationCommand $command): ?CustomizationId; -} diff --git a/src/Core/Domain/Cart/CommandHandler/AddProductToCartHandlerInterface.php b/src/Core/Domain/Cart/CommandHandler/AddProductToCartHandlerInterface.php deleted file mode 100644 index 213bf2f9..00000000 --- a/src/Core/Domain/Cart/CommandHandler/AddProductToCartHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\AddProductToCartCommand; - -/** - * Interface for handling addProductToCart command - */ -interface AddProductToCartHandlerInterface -{ - /** - * @param AddProductToCartCommand $command - */ - public function handle(AddProductToCartCommand $command): void; -} diff --git a/src/Core/Domain/Cart/CommandHandler/CreateEmptyCustomerCartHandlerInterface.php b/src/Core/Domain/Cart/CommandHandler/CreateEmptyCustomerCartHandlerInterface.php deleted file mode 100644 index f85eb2a2..00000000 --- a/src/Core/Domain/Cart/CommandHandler/CreateEmptyCustomerCartHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\CreateEmptyCustomerCartCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; - -/** - * Interface for service that handles creating empty customer cart. - */ -interface CreateEmptyCustomerCartHandlerInterface -{ - /** - * @param CreateEmptyCustomerCartCommand $command - * - * @return CartId - */ - public function handle(CreateEmptyCustomerCartCommand $command); -} diff --git a/src/Core/Domain/Cart/CommandHandler/RemoveCartRuleFromCartHandlerInterface.php b/src/Core/Domain/Cart/CommandHandler/RemoveCartRuleFromCartHandlerInterface.php deleted file mode 100644 index fabde6b6..00000000 --- a/src/Core/Domain/Cart/CommandHandler/RemoveCartRuleFromCartHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\RemoveCartRuleFromCartCommand; - -/** - * Interface for service that handling removing cart rule from cart. - */ -interface RemoveCartRuleFromCartHandlerInterface -{ - /** - * @param RemoveCartRuleFromCartCommand $command - */ - public function handle(RemoveCartRuleFromCartCommand $command); -} diff --git a/src/Core/Domain/Cart/CommandHandler/RemoveProductFromCartHandlerInterface.php b/src/Core/Domain/Cart/CommandHandler/RemoveProductFromCartHandlerInterface.php deleted file mode 100644 index ea9b8268..00000000 --- a/src/Core/Domain/Cart/CommandHandler/RemoveProductFromCartHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\RemoveProductFromCartCommand; - -/** - * Interface for service that handles product removing from cart. - */ -interface RemoveProductFromCartHandlerInterface -{ - /** - * @param RemoveProductFromCartCommand $command - */ - public function handle(RemoveProductFromCartCommand $command); -} diff --git a/src/Core/Domain/Cart/CommandHandler/SendCartToCustomerHanlderInterface.php b/src/Core/Domain/Cart/CommandHandler/SendCartToCustomerHanlderInterface.php deleted file mode 100644 index a1288fcb..00000000 --- a/src/Core/Domain/Cart/CommandHandler/SendCartToCustomerHanlderInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\SendCartToCustomerCommand; - -/** - * Interface for service that handles sending cart to customer. - */ -interface SendCartToCustomerHanlderInterface -{ - /** - * @param SendCartToCustomerCommand $command - */ - public function handle(SendCartToCustomerCommand $command); -} diff --git a/src/Core/Domain/Cart/CommandHandler/UpdateCartAddressesHandlerInterface.php b/src/Core/Domain/Cart/CommandHandler/UpdateCartAddressesHandlerInterface.php deleted file mode 100644 index 32be4da2..00000000 --- a/src/Core/Domain/Cart/CommandHandler/UpdateCartAddressesHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateCartAddressesCommand; - -/** - * Interface for service that updates addresses for given cart - */ -interface UpdateCartAddressesHandlerInterface -{ - /** - * @param UpdateCartAddressesCommand $command - */ - public function handle(UpdateCartAddressesCommand $command); -} diff --git a/src/Core/Domain/Cart/CommandHandler/UpdateCartCarrierHandlerInterface.php b/src/Core/Domain/Cart/CommandHandler/UpdateCartCarrierHandlerInterface.php deleted file mode 100644 index bcb3f987..00000000 --- a/src/Core/Domain/Cart/CommandHandler/UpdateCartCarrierHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateCartCarrierCommand; - -/** - * Interface for service that updates delivery options for cart - */ -interface UpdateCartCarrierHandlerInterface -{ - /** - * @param UpdateCartCarrierCommand $command - */ - public function handle(UpdateCartCarrierCommand $command); -} diff --git a/src/Core/Domain/Cart/CommandHandler/UpdateCartCurrencyHandlerInterface.php b/src/Core/Domain/Cart/CommandHandler/UpdateCartCurrencyHandlerInterface.php deleted file mode 100644 index e6f9d1e8..00000000 --- a/src/Core/Domain/Cart/CommandHandler/UpdateCartCurrencyHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateCartCurrencyCommand; - -/** - * Interface for service that handles cart currency updating - */ -interface UpdateCartCurrencyHandlerInterface -{ - /** - * @param UpdateCartCurrencyCommand $command - */ - public function handle(UpdateCartCurrencyCommand $command): void; -} diff --git a/src/Core/Domain/Cart/CommandHandler/UpdateCartDeliverySettingsHandlerInterface.php b/src/Core/Domain/Cart/CommandHandler/UpdateCartDeliverySettingsHandlerInterface.php deleted file mode 100644 index 80dc9da6..00000000 --- a/src/Core/Domain/Cart/CommandHandler/UpdateCartDeliverySettingsHandlerInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateCartDeliverySettingsCommand; - -interface UpdateCartDeliverySettingsHandlerInterface -{ - /** - * @param UpdateCartDeliverySettingsCommand $command - */ - public function handle(UpdateCartDeliverySettingsCommand $command); -} diff --git a/src/Core/Domain/Cart/CommandHandler/UpdateCartLanguageHandlerInterface.php b/src/Core/Domain/Cart/CommandHandler/UpdateCartLanguageHandlerInterface.php deleted file mode 100644 index 02ddc592..00000000 --- a/src/Core/Domain/Cart/CommandHandler/UpdateCartLanguageHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateCartLanguageCommand; - -/** - * Interface for service that updates cart language - */ -interface UpdateCartLanguageHandlerInterface -{ - /** - * @param UpdateCartLanguageCommand $command - */ - public function handle(UpdateCartLanguageCommand $command): void; -} diff --git a/src/Core/Domain/Cart/CommandHandler/UpdateProductPriceInCartHandlerInterface.php b/src/Core/Domain/Cart/CommandHandler/UpdateProductPriceInCartHandlerInterface.php deleted file mode 100644 index 8e023357..00000000 --- a/src/Core/Domain/Cart/CommandHandler/UpdateProductPriceInCartHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateProductPriceInCartCommand; - -/** - * Interface for service that updates product price in cart. - */ -interface UpdateProductPriceInCartHandlerInterface -{ - /** - * @param UpdateProductPriceInCartCommand $command - */ - public function handle(UpdateProductPriceInCartCommand $command); -} diff --git a/src/Core/Domain/Cart/CommandHandler/UpdateProductQuantityInCartHandlerInterface.php b/src/Core/Domain/Cart/CommandHandler/UpdateProductQuantityInCartHandlerInterface.php deleted file mode 100644 index 60ee84af..00000000 --- a/src/Core/Domain/Cart/CommandHandler/UpdateProductQuantityInCartHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateProductQuantityInCartCommand; - -/** - * Interface for service that updates (increases or decreases) product quantity in cart - */ -interface UpdateProductQuantityInCartHandlerInterface -{ - /** - * @param UpdateProductQuantityInCartCommand $command - */ - public function handle(UpdateProductQuantityInCartCommand $command); -} diff --git a/src/Core/Domain/Cart/Exception/CannotUpdateCartException.php b/src/Core/Domain/Cart/Exception/CannotUpdateCartException.php deleted file mode 100644 index 92f7abe5..00000000 --- a/src/Core/Domain/Cart/Exception/CannotUpdateCartException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Exception; - -/** - * Thrown on failure to update cart - */ -class CannotUpdateCartException extends CartException -{ -} diff --git a/src/Core/Domain/Cart/Exception/CartConstraintException.php b/src/Core/Domain/Cart/Exception/CartConstraintException.php deleted file mode 100644 index 0d8f6c21..00000000 --- a/src/Core/Domain/Cart/Exception/CartConstraintException.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Exception; - -/** - * Thrown when cart constraints are violated - */ -class CartConstraintException extends CartException -{ - /** - * When cart product quantity is invalid - */ - const INVALID_QUANTITY = 1; - - /** - * When cart product quantity is already correct - */ - const UNCHANGED_QUANTITY = 2; - - /** - * When carrier is not found or inactive - */ - const INVALID_CARRIER = 3; -} diff --git a/src/Core/Domain/Cart/Exception/CartException.php b/src/Core/Domain/Cart/Exception/CartException.php deleted file mode 100644 index f8326140..00000000 --- a/src/Core/Domain/Cart/Exception/CartException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Is base exception for Cart subdomain - */ -class CartException extends DomainException -{ -} diff --git a/src/Core/Domain/Cart/Exception/CartNotFoundException.php b/src/Core/Domain/Cart/Exception/CartNotFoundException.php deleted file mode 100644 index db5739b2..00000000 --- a/src/Core/Domain/Cart/Exception/CartNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Exception; - -/** - * Is thrown when cart is not found - */ -class CartNotFoundException extends CartException -{ -} diff --git a/src/Core/Domain/Cart/Exception/InvalidAddressTypeException.php b/src/Core/Domain/Cart/Exception/InvalidAddressTypeException.php deleted file mode 100644 index 5d96b234..00000000 --- a/src/Core/Domain/Cart/Exception/InvalidAddressTypeException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Exception; - -/** - * Class InvalidAddressTypeException - */ -class InvalidAddressTypeException extends CartException -{ -} diff --git a/src/Core/Domain/Cart/Exception/InvalidGiftMessageException.php b/src/Core/Domain/Cart/Exception/InvalidGiftMessageException.php deleted file mode 100644 index 44840132..00000000 --- a/src/Core/Domain/Cart/Exception/InvalidGiftMessageException.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Exception; - -class InvalidGiftMessageException extends CartException -{ -} diff --git a/src/Core/Domain/Cart/Exception/MinimalQuantityException.php b/src/Core/Domain/Cart/Exception/MinimalQuantityException.php deleted file mode 100644 index afb6a76c..00000000 --- a/src/Core/Domain/Cart/Exception/MinimalQuantityException.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Exception; - -use Throwable; - -/** - * Thrown when minimal product - */ -class MinimalQuantityException extends CartException -{ - /** - * @var int - */ - protected $minimalQuantity; - - /** - * @param string $message - * @param int $minimalQuantity - * @param int $code - * @param Throwable|null $previous - */ - public function __construct(string $message, int $minimalQuantity, int $code = 0, Throwable $previous = null) - { - parent::__construct($message, $code, $previous); - - $this->minimalQuantity = $minimalQuantity; - } - - /** - * @return int - */ - public function getMinimalQuantity(): int - { - return $this->minimalQuantity; - } -} diff --git a/src/Core/Domain/Cart/Query/GetCartForOrderCreation.php b/src/Core/Domain/Cart/Query/GetCartForOrderCreation.php deleted file mode 100644 index 7bbb133f..00000000 --- a/src/Core/Domain/Cart/Query/GetCartForOrderCreation.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Query; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; - -/** - * Query for getting cart information - */ -class GetCartForOrderCreation -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @var bool - */ - private $hideDiscounts = false; - - /** - * @param int $cartId - * - * @throws CartConstraintException - */ - public function __construct(int $cartId) - { - $this->cartId = new CartId($cartId); - } - - /** - * @return CartId - */ - public function getCartId(): CartId - { - return $this->cartId; - } - - /** - * @return bool - */ - public function hideDiscounts(): bool - { - return $this->hideDiscounts; - } - - /** - * When hideDiscounts is set to TRUE, - * Gift products are in a separate line from other products which are charged for - * The price of any gift products is not included in the overall discounts, total products and cart total - * Shipping is set to 0 if there is a free_shipping cart rule - * - * Otherwise, - * There is one line per product type, any gift products will be included in the quantity of charged products, but the price of gift products will appear as a discount - * Shipping has its original price, and if it's free, the shipping value will be added as a discount - * - * @param bool $hideDiscounts - * - * @return GetCartForOrderCreation - */ - public function setHideDiscounts(bool $hideDiscounts): self - { - $this->hideDiscounts = $hideDiscounts; - - return $this; - } -} diff --git a/src/Core/Domain/Cart/Query/GetCartForViewing.php b/src/Core/Domain/Cart/Query/GetCartForViewing.php deleted file mode 100644 index 6711eeb1..00000000 --- a/src/Core/Domain/Cart/Query/GetCartForViewing.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Query; - -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; - -/** - * Get cart for viewing in Back Office - */ -class GetCartForViewing -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @param int $cartId - */ - public function __construct($cartId) - { - $this->cartId = new CartId($cartId); - } - - /** - * @return CartId - */ - public function getCartId() - { - return $this->cartId; - } -} diff --git a/src/Core/Domain/Cart/Query/GetLastEmptyCustomerCart.php b/src/Core/Domain/Cart/Query/GetLastEmptyCustomerCart.php deleted file mode 100644 index 8a6970ad..00000000 --- a/src/Core/Domain/Cart/Query/GetLastEmptyCustomerCart.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\Query; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Query for retrieving last empty cart for customer - */ -class GetLastEmptyCustomerCart -{ - /** - * @var CustomerId - */ - private $customerId; - - /** - * @param int $customerId - */ - public function __construct(int $customerId) - { - $this->customerId = new CustomerId($customerId); - } - - /** - * @return CustomerId - */ - public function getCustomerId(): CustomerId - { - return $this->customerId; - } -} diff --git a/src/Core/Domain/Cart/QueryHandler/GetCartForOrderCreationHandlerInterface.php b/src/Core/Domain/Cart/QueryHandler/GetCartForOrderCreationHandlerInterface.php deleted file mode 100644 index b8adb320..00000000 --- a/src/Core/Domain/Cart/QueryHandler/GetCartForOrderCreationHandlerInterface.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Query\GetCartForOrderCreation; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation; - -/** - * Interface for handling GetCartForOrderCreation query - */ -interface GetCartForOrderCreationHandlerInterface -{ - public function handle(GetCartForOrderCreation $query): CartForOrderCreation; -} diff --git a/src/Core/Domain/Cart/QueryHandler/GetCartForViewingHandlerInterface.php b/src/Core/Domain/Cart/QueryHandler/GetCartForViewingHandlerInterface.php deleted file mode 100644 index 5f422f44..00000000 --- a/src/Core/Domain/Cart/QueryHandler/GetCartForViewingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Query\GetCartForViewing; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartView; - -/** - * Interface for service that gets cart for viewing - */ -interface GetCartForViewingHandlerInterface -{ - /** - * @param GetCartForViewing $query - * - * @return CartView - */ - public function handle(GetCartForViewing $query); -} diff --git a/src/Core/Domain/Cart/QueryHandler/GetLastEmptyCustomerCartHandlerInterface.php b/src/Core/Domain/Cart/QueryHandler/GetLastEmptyCustomerCartHandlerInterface.php deleted file mode 100644 index deb37b22..00000000 --- a/src/Core/Domain/Cart/QueryHandler/GetLastEmptyCustomerCartHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Query\GetLastEmptyCustomerCart; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; - -/** - * Interface for handling GetLastEmptyCustomerCart query - */ -interface GetLastEmptyCustomerCartHandlerInterface -{ - /** - * @param GetLastEmptyCustomerCart $query - * - * @return CartId - */ - public function handle(GetLastEmptyCustomerCart $query): CartId; -} diff --git a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation.php b/src/Core/Domain/Cart/QueryResult/CartForOrderCreation.php deleted file mode 100644 index 2abd7847..00000000 --- a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation.php +++ /dev/null @@ -1,173 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation\CartAddress; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation\CartProduct; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation\CartRule; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation\CartShipping; -use PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation\CartSummary; - -/** - * Holds cart information data - */ -class CartForOrderCreation -{ - /** - * @var int - */ - private $cartId; - - /** - * @var CartProduct[] - */ - private $products; - - /** - * @var int - */ - private $currencyId; - - /** - * @var int - */ - private $langId; - - /** - * @var CartRule[] - */ - private $cartRules; - - /** - * @var CartAddress[] - */ - private $addresses; - - /** - * @var CartShipping|null - */ - private $shipping; - - /** - * @var CartSummary - */ - private $summary; - - /** - * @param int $cartId - * @param array $products - * @param int $currencyId - * @param int $langId - * @param CartRule[] $cartRules - * @param CartAddress[] $addresses - * @param CartSummary $summary - * @param CartShipping $shipping - */ - public function __construct( - int $cartId, - array $products, - int $currencyId, - int $langId, - array $cartRules, - array $addresses, - CartSummary $summary, - CartShipping $shipping = null - ) { - $this->cartId = $cartId; - $this->products = $products; - $this->currencyId = $currencyId; - $this->langId = $langId; - $this->cartRules = $cartRules; - $this->addresses = $addresses; - $this->shipping = $shipping; - $this->summary = $summary; - } - - /** - * @return int - */ - public function getCartId(): int - { - return $this->cartId; - } - - /** - * @return CartProduct[] - */ - public function getProducts(): array - { - return $this->products; - } - - /** - * @return int - */ - public function getCurrencyId(): int - { - return $this->currencyId; - } - - /** - * @return int - */ - public function getLangId(): int - { - return $this->langId; - } - - /** - * @return CartRule[] - */ - public function getCartRules(): array - { - return $this->cartRules; - } - - /** - * @return CartAddress[] - */ - public function getAddresses(): array - { - return $this->addresses; - } - - /** - * @return CartShipping|null - */ - public function getShipping(): ?CartShipping - { - return $this->shipping; - } - - /** - * @return CartSummary - */ - public function getSummary(): CartSummary - { - return $this->summary; - } -} diff --git a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartAddress.php b/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartAddress.php deleted file mode 100644 index 68ac411a..00000000 --- a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartAddress.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation; - -/** - * Holds address data for cart information - */ -class CartAddress -{ - /** - * @var int - */ - private $addressId; - - /** - * @var string - */ - private $alias; - - /** - * @var string - */ - private $formattedAddress; - - /** - * @var bool is it used as delivery address - */ - private $delivery; - - /** - * @var bool is it used as invoice address - */ - private $invoice; - - /** - * @param int $addressId - * @param string $alias - * @param string $formattedAddress - * @param bool $delivery - * @param bool $invoice - */ - public function __construct( - int $addressId, - string $alias, - string $formattedAddress, - bool $delivery, - bool $invoice - ) { - $this->addressId = $addressId; - $this->alias = $alias; - $this->formattedAddress = $formattedAddress; - $this->delivery = $delivery; - $this->invoice = $invoice; - } - - /** - * @return int - */ - public function getAddressId(): int - { - return $this->addressId; - } - - /** - * @return string - */ - public function getAlias(): string - { - return $this->alias; - } - - /** - * @return string - */ - public function getFormattedAddress(): string - { - return $this->formattedAddress; - } - - /** - * @return bool - */ - public function isDelivery(): bool - { - return $this->delivery; - } - - /** - * @return bool - */ - public function isInvoice(): bool - { - return $this->invoice; - } -} diff --git a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartDeliveryOption.php b/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartDeliveryOption.php deleted file mode 100644 index 735f2af1..00000000 --- a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartDeliveryOption.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation; - -/** - * Holds data of cart delivery option - */ -class CartDeliveryOption -{ - /** - * @var int - */ - private $carrierId; - - /** - * @var string - */ - private $carrierName; - - /** - * @var string - */ - private $carrierDelay; - - /** - * @param $carrierId - * @param $carrierName - * @param $carrierDelay - */ - public function __construct(int $carrierId, string $carrierName, string $carrierDelay) - { - $this->carrierId = $carrierId; - $this->carrierName = $carrierName; - $this->carrierDelay = $carrierDelay; - } - - /** - * @return int - */ - public function getCarrierId(): int - { - return $this->carrierId; - } - - /** - * @return string - */ - public function getCarrierName(): string - { - return $this->carrierName; - } - - /** - * @return string - */ - public function getCarrierDelay(): string - { - return $this->carrierDelay; - } -} diff --git a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartProduct.php b/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartProduct.php deleted file mode 100644 index ce8f4895..00000000 --- a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartProduct.php +++ /dev/null @@ -1,216 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation; - -/** - * Holds data of cart product information - */ -class CartProduct -{ - /** - * @var int - */ - private $productId; - - /** - * @var int - */ - private $attributeId; - - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $attribute; - - /** - * @var string - */ - private $reference; - - /** - * @var string - */ - private $unitPrice; - - /** - * @var int - */ - private $quantity; - - /** - * @var string - */ - private $price; - /** - * @var string - */ - private $imageLink; - - /** - * @var Customization|null - */ - private $customization; - - /** - * @var bool - */ - private $isGift; - - /** - * CartProduct constructor. - * - * @param int $productId - * @param int $attributeId - * @param string $name - * @param string $attribute - * @param string $reference - * @param string $unitPrice - * @param int $quantity - * @param string $price - * @param string $imageLink - * @param Customization|null $customization - * @param bool $isGift - */ - public function __construct( - int $productId, - int $attributeId, - string $name, - string $attribute, - string $reference, - string $unitPrice, - int $quantity, - string $price, - string $imageLink, - ?Customization $customization, - bool $isGift = false - ) { - $this->productId = $productId; - $this->attributeId = $attributeId; - $this->name = $name; - $this->attribute = $attribute; - $this->reference = $reference; - $this->unitPrice = $unitPrice; - $this->quantity = $quantity; - $this->price = $price; - $this->imageLink = $imageLink; - $this->customization = $customization; - $this->isGift = $isGift; - } - - /** - * @return int - */ - public function getProductId(): int - { - return $this->productId; - } - - /** - * @return string - */ - public function getReference(): string - { - return $this->reference; - } - - /** - * @return string - */ - public function getUnitPrice(): string - { - return $this->unitPrice; - } - - /** - * @return int - */ - public function getQuantity(): int - { - return $this->quantity; - } - - /** - * @return string - */ - public function getPrice(): string - { - return $this->price; - } - - /** - * @return string - */ - public function getImageLink(): string - { - return $this->imageLink; - } - - /** - * @return int - */ - public function getAttributeId(): int - { - return $this->attributeId; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return string - */ - public function getAttribute(): string - { - return $this->attribute; - } - - /** - * @return Customization|null - */ - public function getCustomization(): ?Customization - { - return $this->customization; - } - - /** - * @return bool - */ - public function isGift(): bool - { - return $this->isGift; - } -} diff --git a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartRule.php b/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartRule.php deleted file mode 100644 index a39b988e..00000000 --- a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartRule.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation; - -/** - * Holds cart rule (a.k.a voucher) data for cart information - */ -class CartRule -{ - /** - * @var int - */ - private $cartRuleId; - - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $description; - - /** - * @var string - */ - private $value; - - /** - * @param int $cartRuleId - * @param string $name - * @param string $description - * @param string $value - */ - public function __construct( - int $cartRuleId, - string $name, - string $description, - string $value - ) { - $this->cartRuleId = $cartRuleId; - $this->name = $name; - $this->description = $description; - $this->value = $value; - } - - /** - * @return int - */ - public function getCartRuleId(): int - { - return $this->cartRuleId; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return string - */ - public function getDescription(): string - { - return $this->description; - } - - /** - * @return string - */ - public function getValue(): string - { - return $this->value; - } -} diff --git a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartShipping.php b/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartShipping.php deleted file mode 100644 index 44df023d..00000000 --- a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartShipping.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation; - -/** - * Holds data for cart shipping information - */ -class CartShipping -{ - /** - * @var ?int - */ - private $selectedCarrierId; - - /** - * @var string - */ - private $shippingPrice; - - /** - * @var bool - */ - private $freeShipping; - - /** - * @var CartDeliveryOption[] - */ - private $deliveryOptions; - - /** - * @var bool - */ - private $isRecycledPackaging; - - /** - * @var bool - */ - private $isGift; - - /** - * @var string - */ - private $giftMessage; - - /** - * @param string $shippingPrice - * @param bool $freeShipping - * @param CartDeliveryOption[] $deliveryOptions - * @param int|null $selectedCarrierId - * @param bool $isGift - * @param bool $isRecycledPackaging - * @param string $giftMessage - */ - public function __construct( - string $shippingPrice, - bool $freeShipping, - array $deliveryOptions, - ?int $selectedCarrierId, - bool $isGift, - bool $isRecycledPackaging, - string $giftMessage - ) { - $this->shippingPrice = $shippingPrice; - $this->freeShipping = $freeShipping; - $this->deliveryOptions = $deliveryOptions; - $this->selectedCarrierId = $selectedCarrierId; - $this->isGift = $isGift; - $this->isRecycledPackaging = $isRecycledPackaging; - $this->giftMessage = $giftMessage; - } - - /** - * @return string - */ - public function getShippingPrice(): string - { - return $this->shippingPrice; - } - - /** - * @return bool - */ - public function isFreeShipping(): bool - { - return $this->freeShipping; - } - - /** - * @return CartDeliveryOption[] - */ - public function getDeliveryOptions(): array - { - return $this->deliveryOptions; - } - - /** - * @return mixed - */ - public function getSelectedCarrierId() - { - return $this->selectedCarrierId; - } - - /** - * @return bool - */ - public function isRecycledPackaging(): bool - { - return $this->isRecycledPackaging; - } - - /** - * @return bool - */ - public function isGift(): bool - { - return $this->isGift; - } - - /** - * @return string - */ - public function getGiftMessage(): string - { - return $this->giftMessage; - } -} diff --git a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartSummary.php b/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartSummary.php deleted file mode 100644 index d63d7e65..00000000 --- a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CartSummary.php +++ /dev/null @@ -1,183 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation; - -/** - * Holds cart summary data - */ -class CartSummary -{ - /** - * @var string - */ - private $totalProductsPrice; - - /** - * @var string - */ - private $totalDiscount; - - /** - * @var string - */ - private $totalShippingPrice; - - /** - * @var string - */ - private $totalShippingWithoutTaxes; - - /** - * @var string - */ - private $totalTaxes; - - /** - * @var string - */ - private $totalPriceWithTaxes; - - /** - * @var string - */ - private $totalPriceWithoutTaxes; - - /** - * @var string - */ - private $orderMessage; - - /** - * @var string - */ - private $processOrderLink; - - /** - * @param string $totalProductsPrice - * @param string $totalDiscount - * @param string $totalShippingPrice - * @param string $totalShippingWithoutTaxes - * @param string $totalTaxes - * @param string $totalPriceWithTaxes - * @param string $totalPriceWithoutTaxes - * @param string $orderMessage - * @param string $processOrderLink - */ - public function __construct( - string $totalProductsPrice, - string $totalDiscount, - string $totalShippingPrice, - string $totalShippingWithoutTaxes, - string $totalTaxes, - string $totalPriceWithTaxes, - string $totalPriceWithoutTaxes, - string $orderMessage, - string $processOrderLink - ) { - $this->totalProductsPrice = $totalProductsPrice; - $this->totalDiscount = $totalDiscount; - $this->totalShippingPrice = $totalShippingPrice; - $this->totalShippingWithoutTaxes = $totalShippingWithoutTaxes; - $this->totalTaxes = $totalTaxes; - $this->totalPriceWithTaxes = $totalPriceWithTaxes; - $this->totalPriceWithoutTaxes = $totalPriceWithoutTaxes; - $this->processOrderLink = $processOrderLink; - $this->orderMessage = $orderMessage; - } - - /** - * @return string - */ - public function getTotalProductsPrice(): string - { - return $this->totalProductsPrice; - } - - /** - * @return string - */ - public function getTotalDiscount(): string - { - return $this->totalDiscount; - } - - /** - * @return string - */ - public function getTotalShippingPrice(): string - { - return $this->totalShippingPrice; - } - - /** - * @return string - */ - public function getTotalShippingWithoutTaxes(): string - { - return $this->totalShippingWithoutTaxes; - } - - /** - * @return string - */ - public function getTotalTaxes(): string - { - return $this->totalTaxes; - } - - /** - * @return string - */ - public function getTotalPriceWithTaxes(): string - { - return $this->totalPriceWithTaxes; - } - - /** - * @return string - */ - public function getTotalPriceWithoutTaxes(): string - { - return $this->totalPriceWithoutTaxes; - } - - /** - * @return string - */ - public function getProcessOrderLink(): string - { - return $this->processOrderLink; - } - - /** - * @return string - */ - public function getOrderMessage(): string - { - return $this->orderMessage; - } -} diff --git a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/Customization.php b/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/Customization.php deleted file mode 100644 index 0cee4cb1..00000000 --- a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/Customization.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation; - -/** - * Holds product customization data along with its custom fields data - */ -class Customization -{ - /** - * @var int - */ - private $customizationId; - - /** - * @var CustomizationFieldData[] - */ - private $customizationFieldsData; - - public function __construct( - int $customizationId, - array $customizationFieldsData - ) { - $this->customizationId = $customizationId; - $this->customizationFieldsData = $customizationFieldsData; - } - - /** - * @return int - */ - public function getCustomizationId(): int - { - return $this->customizationId; - } - - /** - * @return CustomizationFieldData[] - */ - public function getCustomizationFieldsData(): array - { - return $this->customizationFieldsData; - } -} diff --git a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CustomizationFieldData.php b/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CustomizationFieldData.php deleted file mode 100644 index 155c1cf9..00000000 --- a/src/Core/Domain/Cart/QueryResult/CartForOrderCreation/CustomizationFieldData.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult\CartForOrderCreation; - -/** - * Holds product customized data of customization field - */ -class CustomizationFieldData -{ - /** - * @var int - */ - private $type; - - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $value; - - public function __construct( - int $type, - string $name, - string $value - ) { - $this->type = $type; - $this->name = $name; - $this->value = $value; - } - - /** - * @return int - */ - public function getType(): int - { - return $this->type; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return string - */ - public function getValue(): string - { - return $this->value; - } -} diff --git a/src/Core/Domain/Cart/QueryResult/CartView.php b/src/Core/Domain/Cart/QueryResult/CartView.php deleted file mode 100644 index b5c113ff..00000000 --- a/src/Core/Domain/Cart/QueryResult/CartView.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\QueryResult; - -class CartView -{ - /** - * @var array - */ - private $customerInformation; - - /** - * @var array - */ - private $orderInformation; - - /** - * @var int - */ - private $cartId; - - /** - * @var array - */ - private $cartSummary; - - /** - * @var int - */ - private $currencyId; - - /** - * @param int $cartId - * @param int $currencyId - * @param array $customerInformation - * @param array $orderInformation - * @param array $cartSummary - */ - public function __construct( - $cartId, - $currencyId, - array $customerInformation, - array $orderInformation, - array $cartSummary - ) { - $this->customerInformation = $customerInformation; - $this->orderInformation = $orderInformation; - $this->cartId = $cartId; - $this->cartSummary = $cartSummary; - $this->currencyId = $currencyId; - } - - /** - * @return array - */ - public function getCustomerInformation() - { - return $this->customerInformation; - } - - /** - * @return array - */ - public function getOrderInformation() - { - return $this->orderInformation; - } - - /** - * @return int - */ - public function getCartId() - { - return $this->cartId; - } - - /** - * @return int - */ - public function getCartCurrencyId() - { - return $this->currencyId; - } - - /** - * @return array - */ - public function getCartSummary() - { - return $this->cartSummary; - } -} diff --git a/src/Core/Domain/Cart/ValueObject/CartId.php b/src/Core/Domain/Cart/ValueObject/CartId.php deleted file mode 100644 index 0bcf9798..00000000 --- a/src/Core/Domain/Cart/ValueObject/CartId.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartConstraintException; - -/** - * Cart identity - */ -class CartId -{ - /** - * @var int - */ - private $cartId; - - /** - * @param int $cartId - * - * @throws CartConstraintException if cart id is not valid - */ - public function __construct($cartId) - { - if (!is_int($cartId) || 0 >= $cartId) { - throw new CartConstraintException(sprintf('Cart id must be integer greater than zero, but %s given.', var_export($cartId, true))); - } - - $this->cartId = $cartId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->cartId; - } -} diff --git a/src/Core/Domain/CartRule/Command/AddCartRuleCommand.php b/src/Core/Domain/CartRule/Command/AddCartRuleCommand.php deleted file mode 100644 index 120a3337..00000000 --- a/src/Core/Domain/CartRule/Command/AddCartRuleCommand.php +++ /dev/null @@ -1,621 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\Command; - -use DateTime; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Domain\CartRule\Exception\CartRuleConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\CartRuleAction\CartRuleActionInterface; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\DiscountApplicationType; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\MoneyAmountCondition; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\CurrencyId; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; -use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Money; - -/** - * Adds new cart rule - */ -class AddCartRuleCommand -{ - /** - * @var string - */ - private $description; - - /** - * @var string - */ - private $code; - - /** - * @var MoneyAmountCondition - */ - private $minimumAmountCondition; - - /** - * @var CustomerId|null - */ - private $customerId; - - /** - * @var bool - */ - private $hasCountryRestriction = false; - - /** - * @var bool - */ - private $hasCarrierRestriction = false; - - /** - * @var bool - */ - private $hasGroupRestriction = false; - - /** - * @var bool - */ - private $hasCartRuleRestriction = false; - - /** - * @var bool - */ - private $hasProductRestriction = false; - - /** - * @var bool - */ - private $hasShopRestriction = false; - - /** - * @var array - */ - private $localizedNames; - - /** - * @var bool - */ - private $highlightInCart; - - /** - * @var bool - */ - private $allowPartialUse; - - /** - * @var int - */ - private $priority; - - /** - * @var bool - */ - private $isActive; - - /** - * @var DateTime - */ - private $validFrom; - - /** - * @var DateTime - */ - private $validTo; - - /** - * @var int - */ - private $totalQuantity; - - /** - * @var int - */ - private $quantityPerUser; - - /** - * @var CartRuleActionInterface - */ - private $cartRuleAction; - - /** - * Discount application type indicates what the discount should be applied to. - * E.g. to whole order, to a specific product, to cheapest product. - * - * @var DiscountApplicationType|null - */ - private $discountApplicationType; - - /** - * This is the product to which discount is applied, when discount application type is "specific product". - * - * @var ProductId|null - */ - private $discountProductId; - - /** - * @param array $localizedNames - * @param bool $highlightInCart - * @param bool $allowPartialUse - * @param int $priority - * @param bool $isActive - * @param DateTime $validFrom - * @param DateTime $validTo - * @param int $totalQuantity - * @param int $quantityPerUser - * @param CartRuleActionInterface $cartRuleAction - * @param float $minimumAmount - * @param int $minimumAmountCurrencyId - * @param bool $isMinimumAmountTaxExcluded - * @param bool $isMinimumAmountShippingExcluded - * - * @throws CartRuleConstraintException - * @throws DomainConstraintException - */ - public function __construct( - array $localizedNames, - bool $highlightInCart, - bool $allowPartialUse, - int $priority, - bool $isActive, - DateTime $validFrom, - DateTime $validTo, - int $totalQuantity, - int $quantityPerUser, - CartRuleActionInterface $cartRuleAction, - float $minimumAmount, - int $minimumAmountCurrencyId, - bool $isMinimumAmountTaxExcluded, - bool $isMinimumAmountShippingExcluded - ) { - $this->assertDateRangeIsValid($validFrom, $validTo); - $this->setLocalizedNames($localizedNames); - $this->setPriority($priority); - $this->setTotalQuantity($totalQuantity); - $this->setQuantityPerUser($quantityPerUser); - $this->minimumAmountCondition = new MoneyAmountCondition( - new Money(new Number((string) $minimumAmount), new CurrencyId($minimumAmountCurrencyId)), - $isMinimumAmountTaxExcluded, - $isMinimumAmountShippingExcluded - ); - $this->highlightInCart = $highlightInCart; - $this->allowPartialUse = $allowPartialUse; - $this->isActive = $isActive; - $this->validFrom = $validFrom; - $this->validTo = $validTo; - $this->cartRuleAction = $cartRuleAction; - } - - /** - * @return DiscountApplicationType|null - */ - public function getDiscountApplicationType(): ?DiscountApplicationType - { - return $this->discountApplicationType; - } - - /** - * @param string $discountApplicationType - * - * @return AddCartRuleCommand - * - * @throws CartRuleConstraintException - */ - public function setDiscountApplicationType(string $discountApplicationType): AddCartRuleCommand - { - $this->discountApplicationType = new DiscountApplicationType($discountApplicationType); - - return $this; - } - - /** - * @return ProductId|null - */ - public function getDiscountProductId(): ?ProductId - { - return $this->discountProductId; - } - - /** - * @param int $discountProductId - * - * @return AddCartRuleCommand - */ - public function setDiscountProductId(int $discountProductId): AddCartRuleCommand - { - $this->discountProductId = new ProductId($discountProductId); - - return $this; - } - - /** - * @return string - */ - public function getDescription(): string - { - return $this->description; - } - - /** - * @return string - */ - public function getCode(): string - { - return $this->code; - } - - /** - * @return MoneyAmountCondition - */ - public function getMinimumAmountCondition(): MoneyAmountCondition - { - return $this->minimumAmountCondition; - } - - /** - * @return CustomerId|null - */ - public function getCustomerId(): ?CustomerId - { - return $this->customerId; - } - - /** - * @return bool - */ - public function hasCountryRestriction(): bool - { - return $this->hasCountryRestriction; - } - - /** - * @return bool - */ - public function hasCarrierRestriction(): bool - { - return $this->hasCarrierRestriction; - } - - /** - * @return bool - */ - public function hasGroupRestriction(): bool - { - return $this->hasGroupRestriction; - } - - /** - * @return bool - */ - public function hasCartRuleRestriction(): bool - { - return $this->hasCartRuleRestriction; - } - - /** - * @return bool - */ - public function hasProductRestriction(): bool - { - return $this->hasProductRestriction; - } - - /** - * @return bool - */ - public function hasShopRestriction(): bool - { - return $this->hasShopRestriction; - } - - /** - * @return array - */ - public function getLocalizedNames(): array - { - return $this->localizedNames; - } - - /** - * @return bool - */ - public function isHighlightInCart(): bool - { - return $this->highlightInCart; - } - - /** - * @return bool - */ - public function isAllowPartialUse(): bool - { - return $this->allowPartialUse; - } - - /** - * @return int - */ - public function getPriority(): int - { - return $this->priority; - } - - /** - * @return bool - */ - public function isActive(): bool - { - return $this->isActive; - } - - /** - * @return DateTime - */ - public function getValidFrom(): DateTime - { - return $this->validFrom; - } - - /** - * @return DateTime - */ - public function getValidTo(): DateTime - { - return $this->validTo; - } - - /** - * @return int - */ - public function getTotalQuantity(): int - { - return $this->totalQuantity; - } - - /** - * @return int - */ - public function getQuantityPerUser(): int - { - return $this->quantityPerUser; - } - - /** - * @return CartRuleActionInterface - */ - public function getCartRuleAction(): CartRuleActionInterface - { - return $this->cartRuleAction; - } - - /** - * @param string $description - * - * @return AddCartRuleCommand - */ - public function setDescription(string $description): AddCartRuleCommand - { - $this->description = $description; - - return $this; - } - - /** - * @param string $code - * - * @return AddCartRuleCommand - */ - public function setCode(string $code): AddCartRuleCommand - { - $this->code = $code; - - return $this; - } - - /** - * @param int $customerId - * - * @return AddCartRuleCommand - */ - public function setCustomerId(int $customerId): AddCartRuleCommand - { - $this->customerId = new CustomerId($customerId); - - return $this; - } - - /** - * @param bool $hasCountryRestriction - * - * @return AddCartRuleCommand - */ - public function setHasCountryRestriction(bool $hasCountryRestriction): AddCartRuleCommand - { - $this->hasCountryRestriction = $hasCountryRestriction; - - return $this; - } - - /** - * @param bool $hasCarrierRestriction - * - * @return AddCartRuleCommand - */ - public function setHasCarrierRestriction(bool $hasCarrierRestriction): AddCartRuleCommand - { - $this->hasCarrierRestriction = $hasCarrierRestriction; - - return $this; - } - - /** - * @param bool $hasGroupRestriction - * - * @return AddCartRuleCommand - */ - public function setHasGroupRestriction(bool $hasGroupRestriction): AddCartRuleCommand - { - $this->hasGroupRestriction = $hasGroupRestriction; - - return $this; - } - - /** - * @param bool $hasCartRuleRestriction - * - * @return AddCartRuleCommand - */ - public function setHasCartRuleRestriction(bool $hasCartRuleRestriction): AddCartRuleCommand - { - $this->hasCartRuleRestriction = $hasCartRuleRestriction; - - return $this; - } - - /** - * @param bool $hasProductRestriction - * - * @return AddCartRuleCommand - */ - public function setHasProductRestriction(bool $hasProductRestriction): AddCartRuleCommand - { - $this->hasProductRestriction = $hasProductRestriction; - - return $this; - } - - /** - * @param bool $hasShopRestriction - * - * @return AddCartRuleCommand - */ - public function setHasShopRestriction(bool $hasShopRestriction): AddCartRuleCommand - { - $this->hasShopRestriction = $hasShopRestriction; - - return $this; - } - - /** - * @param array $localizedNames - * - * @return AddCartRuleCommand - * - * @throws CartRuleConstraintException - */ - private function setLocalizedNames(array $localizedNames): AddCartRuleCommand - { - $this->assertAtLeastOneNameIsPresent($localizedNames); - - foreach ($localizedNames as $languageId => $name) { - $this->localizedNames[(new LanguageId($languageId))->getValue()] = $name; - } - - return $this; - } - - /** - * @param int $priority - * - * @return AddCartRuleCommand - * - * @throws CartRuleConstraintException - */ - private function setPriority(int $priority): AddCartRuleCommand - { - if (0 >= $priority) { - throw new CartRuleConstraintException(sprintf('Invalid cart rule priority "%s". Must be a positive integer.', var_export($priority, true)), CartRuleConstraintException::INVALID_PRIORITY); - } - - $this->priority = $priority; - - return $this; - } - - /** - * @param int $quantity - * - * @return AddCartRuleCommand - * - * @throws CartRuleConstraintException - */ - private function setTotalQuantity(int $quantity): AddCartRuleCommand - { - if (0 > $quantity) { - throw new CartRuleConstraintException(sprintf('Quantity cannot be lower than zero, %d given', $quantity), CartRuleConstraintException::INVALID_QUANTITY); - } - - $this->totalQuantity = $quantity; - - return $this; - } - - /** - * @param int $quantity - * - * @return AddCartRuleCommand - * - * @throws CartRuleConstraintException - */ - private function setQuantityPerUser(int $quantity): AddCartRuleCommand - { - if (0 > $quantity) { - throw new CartRuleConstraintException(sprintf('Quantity per user cannot be lower than zero, %d given', $quantity), CartRuleConstraintException::INVALID_QUANTITY_PER_USER); - } - - $this->quantityPerUser = $quantity; - - return $this; - } - - /** - * @param array $names - * - * @throws CartRuleConstraintException - */ - private function assertAtLeastOneNameIsPresent(array $names): void - { - if (empty($names)) { - throw new CartRuleConstraintException('Cart rule name is mandatory in at least one language', CartRuleConstraintException::EMPTY_NAME); - } - } - - /** - * @param DateTime $dateFrom - * @param DateTime $dateTo - * - * @throws CartRuleConstraintException - */ - private function assertDateRangeIsValid(DateTime $dateFrom, DateTime $dateTo): void - { - if ($dateFrom > $dateTo) { - throw new CartRuleConstraintException('Date from cannot be greater than date to.', CartRuleConstraintException::DATE_FROM_GREATER_THAN_DATE_TO); - } - } -} diff --git a/src/Core/Domain/CartRule/CommandHandler/AddCartRuleHandlerInterface.php b/src/Core/Domain/CartRule/CommandHandler/AddCartRuleHandlerInterface.php deleted file mode 100644 index 08560e63..00000000 --- a/src/Core/Domain/CartRule/CommandHandler/AddCartRuleHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CartRule\Command\AddCartRuleCommand; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\CartRuleId; - -/** - * Interface for service that handles adding new cart rule. - */ -interface AddCartRuleHandlerInterface -{ - /** - * @param AddCartRuleCommand $command - * - * @return CartRuleId - */ - public function handle(AddCartRuleCommand $command): CartRuleId; -} diff --git a/src/Core/Domain/CartRule/Exception/CannotDeleteCartRuleException.php b/src/Core/Domain/CartRule/Exception/CannotDeleteCartRuleException.php deleted file mode 100644 index 2f88a0e2..00000000 --- a/src/Core/Domain/CartRule/Exception/CannotDeleteCartRuleException.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\Exception; - -class CannotDeleteCartRuleException extends CartRuleException -{ -} diff --git a/src/Core/Domain/CartRule/Exception/CartRuleConstraintException.php b/src/Core/Domain/CartRule/Exception/CartRuleConstraintException.php deleted file mode 100644 index 60187cfc..00000000 --- a/src/Core/Domain/CartRule/Exception/CartRuleConstraintException.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\Exception; - -/** - * Thrown when validating cart rule's data - */ -class CartRuleConstraintException extends CartRuleException -{ - /** - * Used when cart rule is using an invalid discount application type - */ - const INVALID_DISCOUNT_APPLICATION_TYPE = 1; - - /** - * Used when cart rule name is empty - */ - const EMPTY_NAME = 2; - - /** - * Used when cart rule's priority is invalid - */ - const INVALID_PRIORITY = 3; - - /** - * Used when cart rule's date from is greater than date to - */ - const DATE_FROM_GREATER_THAN_DATE_TO = 4; - - /** - * Used when cart rule's quantity is invalid - */ - const INVALID_QUANTITY = 5; - - /** - * Used when quantity per user is invalid - */ - const INVALID_QUANTITY_PER_USER = 6; - - /** - * Used when percentage discount is invalid - */ - const INVALID_PERCENTAGE = 7; - - /** - * Used when cart rule has invalid gift product assigned - */ - const INVALID_GIFT_PRODUCT = 8; - - /** - * Used when cart rule has invalid gift product attribute - */ - const INVALID_GIFT_PRODUCT_ATTRIBUTE = 9; - - /** - * Used when cart rule has incompatible actions, - * e.g. both amount and percentage discounts at the same time. - */ - const INCOMPATIBLE_CART_RULE_ACTIONS = 10; - - /** - * Used when cart rule is missing an action. - */ - const MISSING_ACTION = 11; - - /** - * Used when discount is applied to specific product, but that product is not set. - */ - const MISSING_DISCOUNT_APPLICATION_PRODUCT = 12; - - /** - * Used when cart rule id constraints are violated - */ - const INVALID_ID = 13; -} diff --git a/src/Core/Domain/CartRule/Exception/CartRuleException.php b/src/Core/Domain/CartRule/Exception/CartRuleException.php deleted file mode 100644 index 62432b1f..00000000 --- a/src/Core/Domain/CartRule/Exception/CartRuleException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Thrown in cart rules context - */ -class CartRuleException extends DomainException -{ -} diff --git a/src/Core/Domain/CartRule/Exception/CartRuleValidityException.php b/src/Core/Domain/CartRule/Exception/CartRuleValidityException.php deleted file mode 100644 index 989d38ca..00000000 --- a/src/Core/Domain/CartRule/Exception/CartRuleValidityException.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\Exception; - -use PrestaShop\PrestaShop\Core\Exception\TranslatedException; - -/** - * Thrown when cart rule validation fails. - * This exception must contain already translated error message, which can be displayed to end-user - */ -class CartRuleValidityException extends TranslatedException -{ -} diff --git a/src/Core/Domain/CartRule/Exception/InvalidCartRuleDiscountValueException.php b/src/Core/Domain/CartRule/Exception/InvalidCartRuleDiscountValueException.php deleted file mode 100644 index 0d0945ba..00000000 --- a/src/Core/Domain/CartRule/Exception/InvalidCartRuleDiscountValueException.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\Exception; - -/** - * Thrown when a discount is added with an invalid amount/percentage - */ -class InvalidCartRuleDiscountValueException extends InvalidCartRuleValueException -{ - /** - * Code used when an invalid percent value is under min value - */ - const INVALID_MIN_PERCENT = 10; - - /** - * Code used when an invalid percent value is above max value - */ - const INVALID_MAX_PERCENT = 20; - - /** - * Code used when the specified amount is under min value - */ - const INVALID_MIN_AMOUNT = 30; - - /** - * Code used when the specified amount is above max value - */ - const INVALID_MAX_AMOUNT = 40; - - /** - * Code used when free shipping cannot be applied - */ - const INVALID_FREE_SHIPPING = 50; -} diff --git a/src/Core/Domain/CartRule/Exception/InvalidCartRuleValueException.php b/src/Core/Domain/CartRule/Exception/InvalidCartRuleValueException.php deleted file mode 100644 index 670d73d7..00000000 --- a/src/Core/Domain/CartRule/Exception/InvalidCartRuleValueException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\Exception; - -/** - * Thrown when a value is invalid - */ -class InvalidCartRuleValueException extends CartRuleException -{ -} diff --git a/src/Core/Domain/CartRule/Query/SearchCartRules.php b/src/Core/Domain/CartRule/Query/SearchCartRules.php deleted file mode 100644 index e7278be7..00000000 --- a/src/Core/Domain/CartRule/Query/SearchCartRules.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\Query; - -/** - * Searches for cart rules - */ -class SearchCartRules -{ - /** - * @var string - */ - private $searchPhrase; - - /** - * @param string $searchPhrase - */ - public function __construct(string $searchPhrase) - { - $this->searchPhrase = $searchPhrase; - } - - /** - * @return string - */ - public function getSearchPhrase(): string - { - return $this->searchPhrase; - } -} diff --git a/src/Core/Domain/CartRule/QueryHandler/SearchCartRulesHandlerInterface.php b/src/Core/Domain/CartRule/QueryHandler/SearchCartRulesHandlerInterface.php deleted file mode 100644 index acc962d7..00000000 --- a/src/Core/Domain/CartRule/QueryHandler/SearchCartRulesHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\CartRule\Query\SearchCartRules; -use PrestaShop\PrestaShop\Core\Domain\CartRule\QueryResult\FoundCartRule; - -/** - * Interface for handling SearchCartRules query - */ -interface SearchCartRulesHandlerInterface -{ - /** - * @param SearchCartRules $query - * - * @return FoundCartRule[] - */ - public function handle(SearchCartRules $query): array; -} diff --git a/src/Core/Domain/CartRule/QueryResult/FoundCartRule.php b/src/Core/Domain/CartRule/QueryResult/FoundCartRule.php deleted file mode 100644 index c9061071..00000000 --- a/src/Core/Domain/CartRule/QueryResult/FoundCartRule.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\QueryResult; - -/** - * Holds data for cart rule found after search operation - */ -class FoundCartRule -{ - /** - * @var int - */ - private $cartRuleId; - - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $code; - - /** - * @param int $cartRuleId - * @param string $name - * @param string $code - */ - public function __construct( - int $cartRuleId, - string $name, - string $code - ) { - $this->cartRuleId = $cartRuleId; - $this->name = $name; - $this->code = $code; - } - - /** - * @return int - */ - public function getCartRuleId(): int - { - return $this->cartRuleId; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return string - */ - public function getCode(): string - { - return $this->code; - } -} diff --git a/src/Core/Domain/CartRule/ValueObject/CartRuleAction/AmountDiscountAction.php b/src/Core/Domain/CartRule/ValueObject/CartRuleAction/AmountDiscountAction.php deleted file mode 100644 index f126a610..00000000 --- a/src/Core/Domain/CartRule/ValueObject/CartRuleAction/AmountDiscountAction.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\CartRuleAction; - -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\GiftProduct; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\MoneyAmountCondition; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\PercentageDiscount; - -/** - * Cart rule action that gives amount discount. - * Amount discount must have a money amount and currency. - * It can optionally have free shipping and gift product. - * It cannot have percentage discount. - */ -final class AmountDiscountAction implements CartRuleActionInterface -{ - /** - * @var MoneyAmountCondition - */ - private $moneyAmountCondition; - - /** - * @var bool - */ - private $isFreeShipping; - - /** - * @var GiftProduct|null - */ - private $giftProduct; - - /** - * @param MoneyAmountCondition $moneyAmountCondition - * @param bool $isFreeShipping - * @param GiftProduct|null $giftProduct - */ - public function __construct( - MoneyAmountCondition $moneyAmountCondition, - bool $isFreeShipping, - GiftProduct $giftProduct = null - ) { - $this->moneyAmountCondition = $moneyAmountCondition; - $this->isFreeShipping = $isFreeShipping; - $this->giftProduct = $giftProduct; - } - - /** - * {@inheritdoc} - */ - public function isFreeShipping(): bool - { - return $this->isFreeShipping; - } - - /** - * {@inheritdoc} - */ - public function getPercentageDiscount(): ?PercentageDiscount - { - return null; - } - - /** - * {@inheritdoc} - */ - public function getAmountDiscount(): ?MoneyAmountCondition - { - return $this->moneyAmountCondition; - } - - /** - * {@inheritdoc} - */ - public function getGiftProduct(): ?GiftProduct - { - return $this->giftProduct; - } -} diff --git a/src/Core/Domain/CartRule/ValueObject/CartRuleAction/CartRuleActionBuilder.php b/src/Core/Domain/CartRule/ValueObject/CartRuleAction/CartRuleActionBuilder.php deleted file mode 100644 index 7dcb44cb..00000000 --- a/src/Core/Domain/CartRule/ValueObject/CartRuleAction/CartRuleActionBuilder.php +++ /dev/null @@ -1,144 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\CartRuleAction; - -use PrestaShop\PrestaShop\Core\Domain\CartRule\Exception\CartRuleConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\GiftProduct; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\MoneyAmountCondition; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\PercentageDiscount; - -/** - * Builds cart rule actions. - */ -final class CartRuleActionBuilder implements CartRuleActionBuilderInterface -{ - /** - * @var bool - */ - private $isFreeShipping = false; - - /** - * @var PercentageDiscount|null - */ - private $percentageDiscount; - - /** - * @var MoneyAmountCondition|null - */ - private $amountDiscount; - - /** - * @var GiftProduct|null - */ - private $giftProduct; - - /** - * {@inheritdoc} - */ - public function setFreeShipping(bool $isFreeShipping): CartRuleActionBuilderInterface - { - $this->isFreeShipping = $isFreeShipping; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setPercentageDiscount(PercentageDiscount $percentageDiscount): CartRuleActionBuilderInterface - { - $this->percentageDiscount = $percentageDiscount; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setAmountDiscount(MoneyAmountCondition $amount): CartRuleActionBuilderInterface - { - $this->amountDiscount = $amount; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setGiftProduct(GiftProduct $giftProduct): CartRuleActionBuilderInterface - { - $this->giftProduct = $giftProduct; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function build(): CartRuleActionInterface - { - $this->assertCartRuleActionsAreValid(); - - if (null !== $this->percentageDiscount) { - $action = new PercentageDiscountAction( - $this->percentageDiscount, - $this->isFreeShipping, - $this->giftProduct - ); - } elseif (null !== $this->amountDiscount) { - $action = new AmountDiscountAction( - $this->amountDiscount, - $this->isFreeShipping, - $this->giftProduct - ); - } elseif (true === $this->isFreeShipping) { - $action = new FreeShippingAction($this->giftProduct); - } else { - $action = new GiftProductAction($this->giftProduct); - } - - return $action; - } - - /** - * @throws CartRuleConstraintException - */ - private function assertCartRuleActionsAreValid() - { - if (null !== $this->percentageDiscount && null !== $this->amountDiscount) { - throw new CartRuleConstraintException('Cart rule cannot have both percentage and amount discount actions.', CartRuleConstraintException::INCOMPATIBLE_CART_RULE_ACTIONS); - } - - if (null === $this->percentageDiscount && - null === $this->amountDiscount && - null === $this->giftProduct && - false === $this->isFreeShipping - ) { - throw new CartRuleConstraintException('Cart rule must have at least one action', CartRuleConstraintException::MISSING_ACTION); - } - } -} diff --git a/src/Core/Domain/CartRule/ValueObject/CartRuleAction/CartRuleActionBuilderInterface.php b/src/Core/Domain/CartRule/ValueObject/CartRuleAction/CartRuleActionBuilderInterface.php deleted file mode 100644 index 392212db..00000000 --- a/src/Core/Domain/CartRule/ValueObject/CartRuleAction/CartRuleActionBuilderInterface.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\CartRuleAction; - -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\GiftProduct; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\MoneyAmountCondition; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\PercentageDiscount; - -/** - * Describes a builder which builds cart rule actions. - */ -interface CartRuleActionBuilderInterface -{ - /** - * Set free shipping for cart rule action. - * - * @param bool $freeShipping - * - * @return CartRuleActionBuilderInterface - */ - public function setFreeShipping(bool $freeShipping): CartRuleActionBuilderInterface; - - /** - * Set percentage discount for cart rule action. - * - * @param PercentageDiscount $percentageDiscount - * - * @return CartRuleActionBuilderInterface - */ - public function setPercentageDiscount(PercentageDiscount $percentageDiscount): CartRuleActionBuilderInterface; - - /** - * Set amount discount for cart rule action. - * - * @param MoneyAmountCondition $amount - * - * @return CartRuleActionBuilderInterface - */ - public function setAmountDiscount(MoneyAmountCondition $amount): CartRuleActionBuilderInterface; - - /** - * Set the gift product for cart rule action. - * - * @param GiftProduct $giftProduct - * - * @return CartRuleActionBuilderInterface - */ - public function setGiftProduct(GiftProduct $giftProduct): CartRuleActionBuilderInterface; - - /** - * Build the cart rule action. - * - * @return CartRuleActionInterface - */ - public function build(): CartRuleActionInterface; -} diff --git a/src/Core/Domain/CartRule/ValueObject/CartRuleAction/CartRuleActionInterface.php b/src/Core/Domain/CartRule/ValueObject/CartRuleAction/CartRuleActionInterface.php deleted file mode 100644 index f63f7a99..00000000 --- a/src/Core/Domain/CartRule/ValueObject/CartRuleAction/CartRuleActionInterface.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\CartRuleAction; - -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\GiftProduct; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\MoneyAmountCondition; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\PercentageDiscount; - -/** - * Describes a cart rule action. - */ -interface CartRuleActionInterface -{ - /** - * Check if this cart rule is giving free shipping. - * - * @return bool - */ - public function isFreeShipping(): bool; - - /** - * Get the amount discount, which this cart rule action is giving. - * - * @return MoneyAmountCondition|null - */ - public function getAmountDiscount(): ?MoneyAmountCondition; - - /** - * Get the percentage discount, which this cart rule action is giving. - * - * @return PercentageDiscount|null - */ - public function getPercentageDiscount(): ?PercentageDiscount; - - /** - * Get the gift product, which this cart rule action is giving. - * - * @return GiftProduct|null returns null when not applicable - */ - public function getGiftProduct(): ?GiftProduct; -} diff --git a/src/Core/Domain/CartRule/ValueObject/CartRuleAction/FreeShippingAction.php b/src/Core/Domain/CartRule/ValueObject/CartRuleAction/FreeShippingAction.php deleted file mode 100644 index 195254c4..00000000 --- a/src/Core/Domain/CartRule/ValueObject/CartRuleAction/FreeShippingAction.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\CartRuleAction; - -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\GiftProduct; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\MoneyAmountCondition; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\PercentageDiscount; - -/** - * Cart rule action that gives free shipping. - * It cannot have percentage or amount discount. - * It can optionally have gift product. - */ -final class FreeShippingAction implements CartRuleActionInterface -{ - /** - * @var GiftProduct|null - */ - private $giftProduct; - - /** - * @param GiftProduct|null $giftProduct - */ - public function __construct(GiftProduct $giftProduct = null) - { - $this->giftProduct = $giftProduct; - } - - /** - * {@inheritdoc} - */ - public function isFreeShipping(): bool - { - return true; - } - - /** - * {@inheritdoc} - */ - public function getPercentageDiscount(): ?PercentageDiscount - { - return null; - } - - /** - * {@inheritdoc} - */ - public function getAmountDiscount(): ?MoneyAmountCondition - { - return null; - } - - /** - * {@inheritdoc} - */ - public function getGiftProduct(): ?GiftProduct - { - return $this->giftProduct; - } -} diff --git a/src/Core/Domain/CartRule/ValueObject/CartRuleAction/GiftProductAction.php b/src/Core/Domain/CartRule/ValueObject/CartRuleAction/GiftProductAction.php deleted file mode 100644 index 53fb63e8..00000000 --- a/src/Core/Domain/CartRule/ValueObject/CartRuleAction/GiftProductAction.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\CartRuleAction; - -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\GiftProduct; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\MoneyAmountCondition; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\PercentageDiscount; - -/** - * Cart rule action that gives gift product. - * It cannot have percentage or amount discount, or free shipping. - */ -final class GiftProductAction implements CartRuleActionInterface -{ - /** - * @var GiftProduct - */ - private $giftProduct; - - /** - * @param GiftProduct $giftProduct - */ - public function __construct(GiftProduct $giftProduct) - { - $this->giftProduct = $giftProduct; - } - - /** - * {@inheritdoc} - */ - public function isFreeShipping(): bool - { - return false; - } - - /** - * {@inheritdoc} - */ - public function getPercentageDiscount(): ?PercentageDiscount - { - return null; - } - - /** - * {@inheritdoc} - */ - public function getAmountDiscount(): ?MoneyAmountCondition - { - return null; - } - - /** - * {@inheritdoc} - */ - public function getGiftProduct(): ?GiftProduct - { - return $this->giftProduct; - } -} diff --git a/src/Core/Domain/CartRule/ValueObject/CartRuleAction/PercentageDiscountAction.php b/src/Core/Domain/CartRule/ValueObject/CartRuleAction/PercentageDiscountAction.php deleted file mode 100644 index 38191568..00000000 --- a/src/Core/Domain/CartRule/ValueObject/CartRuleAction/PercentageDiscountAction.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\CartRuleAction; - -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\GiftProduct; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\MoneyAmountCondition; -use PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject\PercentageDiscount; - -/** - * Cart rule action that gives percentage discount. - * Percentage discount must have a percentage set. - * It can optionally have free shipping and gift product. - * It cannot have amount discount. - */ -final class PercentageDiscountAction implements CartRuleActionInterface -{ - /** - * @var PercentageDiscount - */ - private $percentageDiscount; - - /** - * @var bool - */ - private $isFreeShipping; - - /** - * @var GiftProduct|null - */ - private $giftProduct; - - /** - * @param PercentageDiscount $percentageDiscount - * @param bool $isFreeShipping - * @param GiftProduct|null $giftProduct - */ - public function __construct( - PercentageDiscount $percentageDiscount, - bool $isFreeShipping, - GiftProduct $giftProduct = null - ) { - $this->percentageDiscount = $percentageDiscount; - $this->isFreeShipping = $isFreeShipping; - $this->giftProduct = $giftProduct; - } - - /** - * {@inheritdoc} - */ - public function isFreeShipping(): bool - { - return $this->isFreeShipping; - } - - /** - * {@inheritdoc} - */ - public function getPercentageDiscount(): ?PercentageDiscount - { - return $this->percentageDiscount; - } - - /** - * {@inheritdoc} - */ - public function getAmountDiscount(): ?MoneyAmountCondition - { - return null; - } - - /** - * {@inheritdoc} - */ - public function getGiftProduct(): ?GiftProduct - { - return $this->giftProduct; - } -} diff --git a/src/Core/Domain/CartRule/ValueObject/CartRuleId.php b/src/Core/Domain/CartRule/ValueObject/CartRuleId.php deleted file mode 100644 index 981610a4..00000000 --- a/src/Core/Domain/CartRule/ValueObject/CartRuleId.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\CartRule\Exception\CartRuleConstraintException; - -/** - * Cart rule identity. - */ -class CartRuleId -{ - /** - * @var int - */ - private $cartRuleId; - - /** - * @param int $cartRuleId - */ - public function __construct(int $cartRuleId) - { - $this->assertIsPositiveInt($cartRuleId); - $this->cartRuleId = $cartRuleId; - } - - /** - * @return int - */ - public function getValue(): int - { - return $this->cartRuleId; - } - - /** - * @param int $value - * - * @throws CartRuleConstraintException - */ - private function assertIsPositiveInt(int $value): void - { - if (0 > $value) { - throw new CartRuleConstraintException(sprintf('Invalid cart rule id "%s".', $value), CartRuleConstraintException::INVALID_ID); - } - } -} diff --git a/src/Core/Domain/CartRule/ValueObject/DiscountApplicationType.php b/src/Core/Domain/CartRule/ValueObject/DiscountApplicationType.php deleted file mode 100644 index 4acecd2d..00000000 --- a/src/Core/Domain/CartRule/ValueObject/DiscountApplicationType.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\CartRule\Exception\CartRuleConstraintException; - -/** - * Discount application type - */ -class DiscountApplicationType -{ - /** - * Discount will be applied to order without shipping - */ - public const ORDER_WITHOUT_SHIPPING = 'order_without_shipping'; - - /** - * Discount will be applied to specifically selected product - */ - public const SPECIFIC_PRODUCT = 'specific_product'; - - /** - * Discount will be applied to cheapest product of the cart - */ - public const CHEAPEST_PRODUCT = 'cheapest_product'; - - /** - * Discount will be applied to products selection from cart rule's conditions. - */ - public const SELECTED_PRODUCTS = 'selected_products'; - - private const AVAILABLE_TYPES = [ - self::ORDER_WITHOUT_SHIPPING, - self::SPECIFIC_PRODUCT, - self::CHEAPEST_PRODUCT, - self::SELECTED_PRODUCTS, - ]; - - /** - * @var string - */ - private $type; - - /** - * @param string $type - */ - public function __construct(string $type) - { - if (!in_array($type, self::AVAILABLE_TYPES)) { - throw new CartRuleConstraintException(sprintf('Invalid cart rule discount application type %s. Available types are: %s', var_export($type, true), implode(', ', self::AVAILABLE_TYPES)), CartRuleConstraintException::INVALID_DISCOUNT_APPLICATION_TYPE); - } - - $this->type = $type; - } - - /** - * @return string - */ - public function getValue(): string - { - return $this->type; - } -} diff --git a/src/Core/Domain/CartRule/ValueObject/GiftProduct.php b/src/Core/Domain/CartRule/ValueObject/GiftProduct.php deleted file mode 100644 index 579e7e45..00000000 --- a/src/Core/Domain/CartRule/ValueObject/GiftProduct.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\CartRule\Exception\CartRuleConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; - -/** - * Gift product VO - */ -class GiftProduct -{ - /** - * @var ProductId - */ - private $productId; - /** - * @var int - */ - private $productAttributeId; - - /** - * @param int $productId - * @param int|null $productAttributeId - * - * @throws CartRuleConstraintException - */ - public function __construct(int $productId, int $productAttributeId = null) - { - $this->assertGiftProductIsValid($productId, $productAttributeId); - - $this->productId = new ProductId($productId); - $this->productAttributeId = $productAttributeId; - } - - /** - * @return ProductId - */ - public function getProductId(): ProductId - { - return $this->productId; - } - - /** - * @return int|null - */ - public function getProductAttributeId(): ?int - { - return $this->productAttributeId; - } - - /** - * @param int $productId - * @param int|null $productAttributeId - * - * @throws CartRuleConstraintException - */ - private function assertGiftProductIsValid(int $productId, ?int $productAttributeId): void - { - if (0 >= $productId) { - throw new CartRuleConstraintException('Gift product ID must be a positive integer', CartRuleConstraintException::INVALID_GIFT_PRODUCT); - } - - if (null !== $productAttributeId && 0 >= $productAttributeId) { - throw new CartRuleConstraintException('Gift product attribute ID must be a positive integer', CartRuleConstraintException::INVALID_GIFT_PRODUCT_ATTRIBUTE); - } - } -} diff --git a/src/Core/Domain/CartRule/ValueObject/MoneyAmountCondition.php b/src/Core/Domain/CartRule/ValueObject/MoneyAmountCondition.php deleted file mode 100644 index d35cbba6..00000000 --- a/src/Core/Domain/CartRule/ValueObject/MoneyAmountCondition.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Money; - -/** - * A cart rule condition for amount of money - */ -class MoneyAmountCondition -{ - /** - * @var Money - */ - private $money; - - /** - * @var bool - */ - private $taxExcluded; - - /** - * @var bool|null - */ - private $shippingExcluded; - - /** - * @param Money $money - * @param bool $taxExcluded - * @param bool|null $shippingExcluded - */ - public function __construct(Money $money, bool $taxExcluded, bool $shippingExcluded = null) - { - $this->money = $money; - $this->taxExcluded = $taxExcluded; - $this->shippingExcluded = $shippingExcluded; - } - - /** - * @return Money - */ - public function getMoneyAmount(): Money - { - return $this->money; - } - - /** - * @return bool - */ - public function isTaxExcluded(): bool - { - return $this->taxExcluded; - } - - /** - * @return bool|null - */ - public function isShippingExcluded(): ?bool - { - return $this->shippingExcluded; - } -} diff --git a/src/Core/Domain/CartRule/ValueObject/PercentageDiscount.php b/src/Core/Domain/CartRule/ValueObject/PercentageDiscount.php deleted file mode 100644 index b1e7ce69..00000000 --- a/src/Core/Domain/CartRule/ValueObject/PercentageDiscount.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CartRule\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\CartRule\Exception\CartRuleConstraintException; - -/** - * Percentage discount - */ -class PercentageDiscount -{ - /** - * @var float - */ - private $percentage; - - /** - * @var bool - */ - private $appliesToDiscountedProducts; - - /** - * @param float $percentage - * @param bool $appliesToDiscountedProducts - */ - public function __construct(float $percentage, bool $appliesToDiscountedProducts) - { - if ($percentage <= 0 || $percentage > 100) { - throw new CartRuleConstraintException('Percentage must be greater than 0 and not greater than 100', CartRuleConstraintException::INVALID_PERCENTAGE); - } - - $this->percentage = $percentage; - $this->appliesToDiscountedProducts = $appliesToDiscountedProducts; - } - - /** - * @return float - */ - public function getPercentage(): float - { - return $this->percentage; - } - - /** - * @return bool - */ - public function appliesToDiscountedProducts(): bool - { - return $this->appliesToDiscountedProducts; - } -} diff --git a/src/Core/Domain/CatalogPriceRule/Command/AddCatalogPriceRuleCommand.php b/src/Core/Domain/CatalogPriceRule/Command/AddCatalogPriceRuleCommand.php deleted file mode 100644 index f1459ab2..00000000 --- a/src/Core/Domain/CatalogPriceRule/Command/AddCatalogPriceRuleCommand.php +++ /dev/null @@ -1,256 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command; - -use DateTime; -use Exception; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CatalogPriceRuleConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainConstraintException; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Reduction; - -/** - * Adds new catalog price rule with provided data - */ -class AddCatalogPriceRuleCommand -{ - /** - * @var string - */ - private $name; - - /** - * @var int - */ - private $shopId; - - /** - * @var int - */ - private $currencyId; - - /** - * @var int - */ - private $countryId; - - /** - * @var int - */ - private $groupId; - - /** - * @var int - */ - private $fromQuantity; - - /** - * @var Reduction - */ - private $reduction; - - /** - * @var bool - */ - private $includeTax; - - /** - * @var Number - */ - private $price; - - /** - * @var DateTime|null - */ - private $dateTimeFrom; - - /** - * @var DateTime|null - */ - private $dateTimeTo; - - /** - * @param string $name - * @param int $currencyId - * @param int $countryId - * @param int $groupId - * @param int $fromQuantity - * @param string $reductionType - * @param float $reductionValue - * @param int $shopId - * @param bool $includeTax - * @param float $price - * - * @throws DomainConstraintException - */ - public function __construct( - string $name, - int $currencyId, - int $countryId, - int $groupId, - int $fromQuantity, - string $reductionType, - float $reductionValue, - int $shopId, - bool $includeTax, - float $price - ) { - $this->name = $name; - $this->currencyId = $currencyId; - $this->countryId = $countryId; - $this->groupId = $groupId; - $this->fromQuantity = $fromQuantity; - $this->reduction = new Reduction($reductionType, $reductionValue); - $this->shopId = $shopId; - $this->price = new Number((string) $price); - $this->includeTax = $includeTax; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return int - */ - public function getShopId(): int - { - return $this->shopId; - } - - /** - * @return int - */ - public function getCurrencyId(): int - { - return $this->currencyId; - } - - /** - * @return int - */ - public function getCountryId(): int - { - return $this->countryId; - } - - /** - * @return int - */ - public function getGroupId(): int - { - return $this->groupId; - } - - /** - * @return int - */ - public function getFromQuantity(): int - { - return $this->fromQuantity; - } - - /** - * @return Reduction - */ - public function getReduction(): Reduction - { - return $this->reduction; - } - - /** - * @return Number - */ - public function getPrice(): Number - { - return $this->price; - } - - /** - * @return DateTime|null - */ - public function getDateTimeFrom(): ?DateTime - { - return $this->dateTimeFrom; - } - - /** - * @return DateTime|null - */ - public function getDateTimeTo(): ?DateTime - { - return $this->dateTimeTo; - } - - /** - * @return bool - */ - public function isTaxIncluded(): bool - { - return $this->includeTax; - } - - /** - * @param string $dateTimeFrom - * - * @throws CatalogPriceRuleConstraintException - */ - public function setDateTimeFrom(string $dateTimeFrom) - { - $this->dateTimeFrom = $this->createDateTime($dateTimeFrom); - } - - /** - * @param string $dateTimeTo - * - * @throws CatalogPriceRuleConstraintException - */ - public function setDateTimeTo(string $dateTimeTo) - { - $this->dateTimeTo = $this->createDateTime($dateTimeTo); - } - - /** - * @param string $dateTime - * - * @return DateTime - * - * @throws CatalogPriceRuleConstraintException - */ - private function createDateTime(string $dateTime): DateTime - { - try { - return new DateTime($dateTime); - } catch (Exception $e) { - throw new CatalogPriceRuleConstraintException('An error occured when creating DateTime object for catalog price rule', CatalogPriceRuleConstraintException::INVALID_DATETIME, $e); - } - } -} diff --git a/src/Core/Domain/CatalogPriceRule/Command/BulkDeleteCatalogPriceRuleCommand.php b/src/Core/Domain/CatalogPriceRule/Command/BulkDeleteCatalogPriceRuleCommand.php deleted file mode 100644 index a733eb4b..00000000 --- a/src/Core/Domain/CatalogPriceRule/Command/BulkDeleteCatalogPriceRuleCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command; - -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CatalogPriceRuleConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\ValueObject\CatalogPriceRuleId; - -/** - * Deletes catalog price rules in bulk acton - */ -class BulkDeleteCatalogPriceRuleCommand -{ - /** - * @var CatalogPriceRuleId[] - */ - private $catalogPriceRuleIds; - - /** - * @param int[] $catalogPriceRuleIds - * - * @throws CatalogPriceRuleConstraintException - */ - public function __construct(array $catalogPriceRuleIds) - { - $this->setCatalogPriceRuleIds($catalogPriceRuleIds); - } - - /** - * @return CatalogPriceRuleId[] - */ - public function getCatalogPriceRuleIds() - { - return $this->catalogPriceRuleIds; - } - - /** - * @param int[] $catalogPriceRuleIds - * - * @throws CatalogPriceRuleConstraintException - */ - private function setCatalogPriceRuleIds(array $catalogPriceRuleIds) - { - foreach ($catalogPriceRuleIds as $catalogPriceRuleId) { - $this->catalogPriceRuleIds[] = new CatalogPriceRuleId($catalogPriceRuleId); - } - } -} diff --git a/src/Core/Domain/CatalogPriceRule/Command/DeleteCatalogPriceRuleCommand.php b/src/Core/Domain/CatalogPriceRule/Command/DeleteCatalogPriceRuleCommand.php deleted file mode 100644 index 0825a784..00000000 --- a/src/Core/Domain/CatalogPriceRule/Command/DeleteCatalogPriceRuleCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command; - -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CatalogPriceRuleConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\ValueObject\CatalogPriceRuleId; - -/** - * Deletes catalog price rule - */ -class DeleteCatalogPriceRuleCommand -{ - /** - * @var CatalogPriceRuleId - */ - private $catalogPriceRuleId; - - /** - * @param int $catalogPriceRuleId - * - * @throws CatalogPriceRuleConstraintException - */ - public function __construct($catalogPriceRuleId) - { - $this->catalogPriceRuleId = new CatalogPriceRuleId($catalogPriceRuleId); - } - - /** - * @return CatalogPriceRuleId - */ - public function getCatalogPriceRuleId() - { - return $this->catalogPriceRuleId; - } -} diff --git a/src/Core/Domain/CatalogPriceRule/Command/EditCatalogPriceRuleCommand.php b/src/Core/Domain/CatalogPriceRule/Command/EditCatalogPriceRuleCommand.php deleted file mode 100644 index 74d072a6..00000000 --- a/src/Core/Domain/CatalogPriceRule/Command/EditCatalogPriceRuleCommand.php +++ /dev/null @@ -1,312 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command; - -use DateTime; -use Exception; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CatalogPriceRuleConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\ValueObject\CatalogPriceRuleId; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Reduction; - -/** - * Edits catalog price rule with given data - */ -class EditCatalogPriceRuleCommand -{ - /** - * @var CatalogPriceRuleId - */ - private $catalogPriceRuleId; - - /** - * @var string|null - */ - private $name; - - /** - * @var int|null - */ - private $shopId; - - /** - * @var int|null - */ - private $currencyId; - - /** - * @var int|null - */ - private $countryId; - - /** - * @var int|null - */ - private $groupId; - - /** - * @var int|null - */ - private $fromQuantity; - - /** - * @var float|null - */ - private $price; - - /** - * @var DateTime|null - */ - private $dateTimeFrom; - - /** - * @var DateTime|null - */ - private $dateTimeTo; - - /** - * @var bool|null - */ - private $includeTax; - - /** - * @var Reduction - */ - private $reduction; - - /** - * @param int $catalogPriceRuleId - * - * @throws CatalogPriceRuleConstraintException - */ - public function __construct(int $catalogPriceRuleId) - { - $this->catalogPriceRuleId = new CatalogPriceRuleId($catalogPriceRuleId); - } - - /** - * @return CatalogPriceRuleId - */ - public function getCatalogPriceRuleId(): CatalogPriceRuleId - { - return $this->catalogPriceRuleId; - } - - /** - * @return string|null - */ - public function getName(): ?string - { - return $this->name; - } - - /** - * @param string $name - */ - public function setName(string $name) - { - $this->name = $name; - } - - /** - * @return int|null - */ - public function getShopId(): ?int - { - return $this->shopId; - } - - /** - * @param int $shopId - */ - public function setShopId(int $shopId) - { - $this->shopId = $shopId; - } - - /** - * @return int|null - */ - public function getCurrencyId(): ?int - { - return $this->currencyId; - } - - /** - * @param int $currencyId - */ - public function setCurrencyId(int $currencyId) - { - $this->currencyId = $currencyId; - } - - /** - * @return int|null - */ - public function getCountryId(): ?int - { - return $this->countryId; - } - - /** - * @param int $countryId - */ - public function setCountryId(int $countryId) - { - $this->countryId = $countryId; - } - - /** - * @return int|null - */ - public function getGroupId(): ?int - { - return $this->groupId; - } - - /** - * @param int $groupId - */ - public function setGroupId(int $groupId) - { - $this->groupId = $groupId; - } - - /** - * @return int|null - */ - public function getFromQuantity(): ?int - { - return $this->fromQuantity; - } - - /** - * @param int $fromQuantity - */ - public function setFromQuantity(int $fromQuantity) - { - $this->fromQuantity = $fromQuantity; - } - - /** - * @return float|null - */ - public function getPrice(): ?float - { - return $this->price; - } - - /** - * @param float $price - */ - public function setPrice(float $price) - { - $this->price = $price; - } - - /** - * @return DateTime|null - */ - public function getDateTimeFrom(): ?DateTime - { - return $this->dateTimeFrom; - } - - /** - * @param string $dateTimeFrom - * - * @throws CatalogPriceRuleConstraintException - */ - public function setDateTimeFrom(string $dateTimeFrom) - { - $this->dateTimeFrom = $this->createDateTime($dateTimeFrom); - } - - /** - * @return DateTime|null - */ - public function getDateTimeTo(): ?DateTime - { - return $this->dateTimeTo; - } - - /** - * @param string $dateTimeTo - * - * @throws CatalogPriceRuleConstraintException - */ - public function setDateTimeTo(string $dateTimeTo) - { - $this->dateTimeTo = $this->createDateTime($dateTimeTo); - } - - /** - * @return bool|null - */ - public function isTaxIncluded(): ?bool - { - return $this->includeTax; - } - - /** - * @param bool $includeTax - */ - public function setIncludeTax(bool $includeTax) - { - $this->includeTax = $includeTax; - } - - /** - * @return Reduction|null - */ - public function getReduction(): ?Reduction - { - return $this->reduction; - } - - /** - * @param string $type - * @param float $value - */ - public function setReduction(string $type, float $value) - { - $this->reduction = new Reduction($type, $value); - } - - /** - * @param string $dateTime - * - * @return DateTime - */ - private function createDateTime(string $dateTime) - { - try { - return new DateTime($dateTime); - } catch (Exception $e) { - throw new CatalogPriceRuleConstraintException('Invalid date time format', CatalogPriceRuleConstraintException::INVALID_DATETIME, $e); - } - } -} diff --git a/src/Core/Domain/CatalogPriceRule/CommandHandler/AddCatalogPriceRuleHandlerInterface.php b/src/Core/Domain/CatalogPriceRule/CommandHandler/AddCatalogPriceRuleHandlerInterface.php deleted file mode 100644 index 59054bf2..00000000 --- a/src/Core/Domain/CatalogPriceRule/CommandHandler/AddCatalogPriceRuleHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command\AddCatalogPriceRuleCommand; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\ValueObject\CatalogPriceRuleId; - -/** - * Interface for handling addCatalogPriceRule command - */ -interface AddCatalogPriceRuleHandlerInterface -{ - /** - * @param AddCatalogPriceRuleCommand $command - * - * @return CatalogPriceRuleId - */ - public function handle(AddCatalogPriceRuleCommand $command): CatalogPriceRuleId; -} diff --git a/src/Core/Domain/CatalogPriceRule/CommandHandler/BulkDeleteCatalogPriceRuleHandlerInterface.php b/src/Core/Domain/CatalogPriceRule/CommandHandler/BulkDeleteCatalogPriceRuleHandlerInterface.php deleted file mode 100644 index f410403c..00000000 --- a/src/Core/Domain/CatalogPriceRule/CommandHandler/BulkDeleteCatalogPriceRuleHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command\BulkDeleteCatalogPriceRuleCommand; - -/** - * Defines contract for BulkDeleteCatalogPriceRuleHandler - */ -interface BulkDeleteCatalogPriceRuleHandlerInterface -{ - /** - * @param BulkDeleteCatalogPriceRuleCommand $command - */ - public function handle(BulkDeleteCatalogPriceRuleCommand $command); -} diff --git a/src/Core/Domain/CatalogPriceRule/CommandHandler/DeleteCatalogPriceRuleHandlerInterface.php b/src/Core/Domain/CatalogPriceRule/CommandHandler/DeleteCatalogPriceRuleHandlerInterface.php deleted file mode 100644 index 5b7508ca..00000000 --- a/src/Core/Domain/CatalogPriceRule/CommandHandler/DeleteCatalogPriceRuleHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command\DeleteCatalogPriceRuleCommand; - -/** - * Defines contract for delete catalog price rule handler - */ -interface DeleteCatalogPriceRuleHandlerInterface -{ - /** - * @param DeleteCatalogPriceRuleCommand $command - */ - public function handle(DeleteCatalogPriceRuleCommand $command); -} diff --git a/src/Core/Domain/CatalogPriceRule/CommandHandler/EditCatalogPriceRuleHandlerInterface.php b/src/Core/Domain/CatalogPriceRule/CommandHandler/EditCatalogPriceRuleHandlerInterface.php deleted file mode 100644 index be0dc602..00000000 --- a/src/Core/Domain/CatalogPriceRule/CommandHandler/EditCatalogPriceRuleHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command\EditCatalogPriceRuleCommand; - -/** - * Defines contract for CatalogPriceRuleHandler - */ -interface EditCatalogPriceRuleHandlerInterface -{ - /** - * @param EditCatalogPriceRuleCommand $command - */ - public function handle(EditCatalogPriceRuleCommand $command); -} diff --git a/src/Core/Domain/CatalogPriceRule/Exception/CannotDeleteCatalogPriceRuleException.php b/src/Core/Domain/CatalogPriceRule/Exception/CannotDeleteCatalogPriceRuleException.php deleted file mode 100644 index 22d246b0..00000000 --- a/src/Core/Domain/CatalogPriceRule/Exception/CannotDeleteCatalogPriceRuleException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception; - -/** - * Is thrown when catalog price rule cannot be deleted - */ -class CannotDeleteCatalogPriceRuleException extends CatalogPriceRuleException -{ - /** - * When fails to delete single catalog price rule - */ - const FAILED_DELETE = 10; - - /** - * When fails to delete catalog price rule in bulk action - */ - const FAILED_BULK_DELETE = 20; -} diff --git a/src/Core/Domain/CatalogPriceRule/Exception/CannotUpdateCatalogPriceRuleException.php b/src/Core/Domain/CatalogPriceRule/Exception/CannotUpdateCatalogPriceRuleException.php deleted file mode 100644 index 3362a1aa..00000000 --- a/src/Core/Domain/CatalogPriceRule/Exception/CannotUpdateCatalogPriceRuleException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception; - -/** - * Thrown when unable to update catalog price rule - */ -class CannotUpdateCatalogPriceRuleException extends CatalogPriceRuleException -{ -} diff --git a/src/Core/Domain/CatalogPriceRule/Exception/CatalogPriceRuleConstraintException.php b/src/Core/Domain/CatalogPriceRule/Exception/CatalogPriceRuleConstraintException.php deleted file mode 100644 index aa707d1b..00000000 --- a/src/Core/Domain/CatalogPriceRule/Exception/CatalogPriceRuleConstraintException.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception; - -/** - * Thrown when catalog price rule constraints are violated - */ -class CatalogPriceRuleConstraintException extends CatalogPriceRuleException -{ - /** - * When catalog price rule id is not valid - */ - const INVALID_ID = 10; - - /** - * When date-time format is invalid - */ - const INVALID_DATETIME = 20; - - /** - * When date range is not valid - */ - const INVALID_DATE_RANGE = 30; -} diff --git a/src/Core/Domain/CatalogPriceRule/Exception/CatalogPriceRuleException.php b/src/Core/Domain/CatalogPriceRule/Exception/CatalogPriceRuleException.php deleted file mode 100644 index c02fca79..00000000 --- a/src/Core/Domain/CatalogPriceRule/Exception/CatalogPriceRuleException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for CatalogPriceRule subdomain - */ -class CatalogPriceRuleException extends DomainException -{ -} diff --git a/src/Core/Domain/CatalogPriceRule/Exception/CatalogPriceRuleNotFoundException.php b/src/Core/Domain/CatalogPriceRule/Exception/CatalogPriceRuleNotFoundException.php deleted file mode 100644 index 099dded7..00000000 --- a/src/Core/Domain/CatalogPriceRule/Exception/CatalogPriceRuleNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception; - -/** - * Thrown when cannot find required catalog price rule - */ -class CatalogPriceRuleNotFoundException extends CatalogPriceRuleException -{ -} diff --git a/src/Core/Domain/CatalogPriceRule/Query/GetCatalogPriceRuleForEditing.php b/src/Core/Domain/CatalogPriceRule/Query/GetCatalogPriceRuleForEditing.php deleted file mode 100644 index 21103773..00000000 --- a/src/Core/Domain/CatalogPriceRule/Query/GetCatalogPriceRuleForEditing.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Query; - -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CatalogPriceRuleConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\ValueObject\CatalogPriceRuleId; - -/** - * Provides data transfer object for editing CatalogPriceRule - */ -class GetCatalogPriceRuleForEditing -{ - /** - * @var CatalogPriceRuleId - */ - private $catalogPriceRuleId; - - /** - * @param int $catalogPriceRuleId - * - * @throws CatalogPriceRuleConstraintException - */ - public function __construct($catalogPriceRuleId) - { - $this->catalogPriceRuleId = new CatalogPriceRuleId($catalogPriceRuleId); - } - - /** - * @return CatalogPriceRuleId - */ - public function getCatalogPriceRuleId(): CatalogPriceRuleId - { - return $this->catalogPriceRuleId; - } -} diff --git a/src/Core/Domain/CatalogPriceRule/QueryHandler/GetCatalogPriceRuleForEditingHandlerInterface.php b/src/Core/Domain/CatalogPriceRule/QueryHandler/GetCatalogPriceRuleForEditingHandlerInterface.php deleted file mode 100644 index 02faea0e..00000000 --- a/src/Core/Domain/CatalogPriceRule/QueryHandler/GetCatalogPriceRuleForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Query\GetCatalogPriceRuleForEditing; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\QueryResult\EditableCatalogPriceRule; - -/** - * Defines contract for GetCatalogPriceRuleForEditingHandler - */ -interface GetCatalogPriceRuleForEditingHandlerInterface -{ - /** - * @param GetCatalogPriceRuleForEditing $query - * - * @return EditableCatalogPriceRule - */ - public function handle(GetCatalogPriceRuleForEditing $query); -} diff --git a/src/Core/Domain/CatalogPriceRule/QueryResult/EditableCatalogPriceRule.php b/src/Core/Domain/CatalogPriceRule/QueryResult/EditableCatalogPriceRule.php deleted file mode 100644 index 255870e2..00000000 --- a/src/Core/Domain/CatalogPriceRule/QueryResult/EditableCatalogPriceRule.php +++ /dev/null @@ -1,236 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\QueryResult; - -use DateTime; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\ValueObject\CatalogPriceRuleId; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Reduction; - -/** - * Provides data for editing CatalogPriceRule - */ -class EditableCatalogPriceRule -{ - /** - * @var CatalogPriceRuleId - */ - private $catalogPriceRuleId; - - /** - * @var string - */ - private $name; - - /** - * @var int - */ - private $shopId; - - /** - * @var int - */ - private $currencyId; - - /** - * @var int - */ - private $countryId; - - /** - * @var int - */ - private $groupId; - - /** - * @var int - */ - private $fromQuantity; - - /** - * @var Number - */ - private $price; - - /** - * @var ?DateTime - */ - private $from; - - /** - * @var ?DateTime - */ - private $to; - - /** - * @var bool - */ - private $includeTax; - - /** - * @var Reduction - */ - private $reduction; - - /** - * @param CatalogPriceRuleId $catalogPriceRuleId - * @param string $name - * @param int $shopId - * @param int $currencyId - * @param int $countryId - * @param int $groupId - * @param int $fromQuantity - * @param Number $price - * @param Reduction $reduction - * @param bool $includeTax - * @param DateTime|null $from - * @param DateTime|null $to - */ - public function __construct( - CatalogPriceRuleId $catalogPriceRuleId, - string $name, - int $shopId, - int $currencyId, - int $countryId, - int $groupId, - int $fromQuantity, - Number $price, - Reduction $reduction, - bool $includeTax, - ?DateTime $from, - ?DateTime $to - ) { - $this->catalogPriceRuleId = $catalogPriceRuleId; - $this->name = $name; - $this->shopId = $shopId; - $this->currencyId = $currencyId; - $this->countryId = $countryId; - $this->groupId = $groupId; - $this->fromQuantity = $fromQuantity; - $this->price = $price; - $this->from = $from; - $this->to = $to; - $this->reduction = $reduction; - $this->includeTax = $includeTax; - } - - /** - * @return CatalogPriceRuleId - */ - public function getCatalogPriceRuleId(): CatalogPriceRuleId - { - return $this->catalogPriceRuleId; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return int - */ - public function getShopId(): int - { - return $this->shopId; - } - - /** - * @return int - */ - public function getCurrencyId(): int - { - return $this->currencyId; - } - - /** - * @return int - */ - public function getCountryId(): int - { - return $this->countryId; - } - - /** - * @return int - */ - public function getGroupId(): int - { - return $this->groupId; - } - - /** - * @return int - */ - public function getFromQuantity(): int - { - return $this->fromQuantity; - } - - /** - * @return Number - */ - public function getPrice(): Number - { - return $this->price; - } - - /** - * @return DateTime|null - */ - public function getFrom(): ?DateTime - { - return $this->from; - } - - /** - * @return DateTime|null - */ - public function getTo(): ?DateTime - { - return $this->to; - } - - /** - * @return Reduction - */ - public function getReduction(): Reduction - { - return $this->reduction; - } - - /** - * @return bool - */ - public function isTaxIncluded(): bool - { - return $this->includeTax; - } -} diff --git a/src/Core/Domain/CatalogPriceRule/ValueObject/CatalogPriceRuleId.php b/src/Core/Domain/CatalogPriceRule/ValueObject/CatalogPriceRuleId.php deleted file mode 100644 index f5fe7c12..00000000 --- a/src/Core/Domain/CatalogPriceRule/ValueObject/CatalogPriceRuleId.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CatalogPriceRuleConstraintException; - -/** - * Provides catalog price rule id - */ -final class CatalogPriceRuleId -{ - /** - * @var int - */ - private $catalogPriceRuleId; - - /** - * @param int $catalogPriceRuleId - * - * @throws CatalogPriceRuleConstraintException - */ - public function __construct(int $catalogPriceRuleId) - { - $this->assertIsGreaterThanZero($catalogPriceRuleId); - $this->catalogPriceRuleId = $catalogPriceRuleId; - } - - /** - * @return int - */ - public function getValue(): int - { - return $this->catalogPriceRuleId; - } - - /** - * Validates that the value is greater than zero - * - * @param int $value - * - * @throws CatalogPriceRuleConstraintException - */ - private function assertIsGreaterThanZero(int $value) - { - if (0 >= $value) { - throw new CatalogPriceRuleConstraintException(sprintf('Invalid catalog price rule id "%s".', $value), CatalogPriceRuleConstraintException::INVALID_ID); - } - } -} diff --git a/src/Core/Domain/Category/Command/AddCategoryCommand.php b/src/Core/Domain/Category/Command/AddCategoryCommand.php deleted file mode 100644 index 50a93af5..00000000 --- a/src/Core/Domain/Category/Command/AddCategoryCommand.php +++ /dev/null @@ -1,326 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Command; - -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryConstraintException; - -/** - * Class AddCategoryCommand adds new category. - */ -class AddCategoryCommand -{ - /** - * @var string[] - */ - private $localizedNames; - - /** - * @var int - */ - private $parentCategoryId; - - /** - * @var string[] - */ - private $localizedLinkRewrites; - - /** - * @var string[] - */ - private $localizedDescriptions; - - /** - * @var bool - */ - private $isActive; - - /** - * @var string[] - */ - private $localizedMetaTitles; - - /** - * @var string[] - */ - private $localizedMetaDescriptions; - - /** - * @var string[] - */ - private $localizedMetaKeywords; - - /** - * @var int[] - */ - private $associatedGroupIds; - - /** - * @var int[] - */ - private $associatedShopIds; - - /** - * @param string[] $localizedNames - * @param string[] $localizedLinkRewrites - * @param bool $isActive - * @param int $parentCategoryId - * - * @throws CategoryConstraintException - */ - public function __construct(array $localizedNames, array $localizedLinkRewrites, $isActive, $parentCategoryId) - { - $this - ->setLocalizedNames($localizedNames) - ->setLocalizedLinkRewrites($localizedLinkRewrites) - ->setIsActive($isActive) - ->setParentCategoryId($parentCategoryId); - } - - /** - * @return int - */ - public function getParentCategoryId() - { - return $this->parentCategoryId; - } - - /** - * @param int $parentCategoryId - * - * @return self - * - * @throws CategoryConstraintException - */ - public function setParentCategoryId($parentCategoryId) - { - if (!is_int($parentCategoryId) || 0 >= $parentCategoryId) { - throw new CategoryConstraintException(sprintf('Invalid Category parent id %s supplied', var_export($parentCategoryId, true)), CategoryConstraintException::INVALID_PARENT_ID); - } - - $this->parentCategoryId = $parentCategoryId; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedNames() - { - return $this->localizedNames; - } - - /** - * @param string[] $localizedNames - * - * @return $this - * - * @throws CategoryConstraintException - */ - public function setLocalizedNames(array $localizedNames) - { - if (empty($localizedNames)) { - throw new CategoryConstraintException('Category name cannot be empty', CategoryConstraintException::EMPTY_NAME); - } - - $this->localizedNames = $localizedNames; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedLinkRewrites() - { - return $this->localizedLinkRewrites; - } - - /** - * @param string[] $localizedLinkRewrites - * - * @return $this - * - * @throws CategoryConstraintException - */ - public function setLocalizedLinkRewrites(array $localizedLinkRewrites) - { - if (empty($localizedLinkRewrites)) { - throw new CategoryConstraintException('Category link rewrite cannot be empty', CategoryConstraintException::EMPTY_LINK_REWRITE); - } - - $this->localizedLinkRewrites = $localizedLinkRewrites; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedDescriptions() - { - return $this->localizedDescriptions; - } - - /** - * @param string[] $localizedDescriptions - * - * @return $this - */ - public function setLocalizedDescriptions(array $localizedDescriptions) - { - $this->localizedDescriptions = $localizedDescriptions; - - return $this; - } - - /** - * @return bool - */ - public function isActive() - { - return $this->isActive; - } - - /** - * @param bool $isActive - * - * @return $this - * - * @throws CategoryConstraintException - */ - public function setIsActive($isActive) - { - if (!is_bool($isActive)) { - throw new CategoryConstraintException('Invalid Category status supplied', CategoryConstraintException::INVALID_STATUS); - } - - $this->isActive = $isActive; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedMetaTitles() - { - return $this->localizedMetaTitles; - } - - /** - * @param string[] $localizedMetaTitles - * - * @return $this - */ - public function setLocalizedMetaTitles(array $localizedMetaTitles) - { - $this->localizedMetaTitles = $localizedMetaTitles; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedMetaDescriptions() - { - return $this->localizedMetaDescriptions; - } - - /** - * @param string[] $localizedMetaDescriptions - * - * @return $this - */ - public function setLocalizedMetaDescriptions(array $localizedMetaDescriptions) - { - $this->localizedMetaDescriptions = $localizedMetaDescriptions; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedMetaKeywords() - { - return $this->localizedMetaKeywords; - } - - /** - * @param string[] $localizedMetaKeywords - * - * @return $this - */ - public function setLocalizedMetaKeywords(array $localizedMetaKeywords) - { - $this->localizedMetaKeywords = $localizedMetaKeywords; - - return $this; - } - - /** - * @return int[] - */ - public function getAssociatedGroupIds() - { - return $this->associatedGroupIds; - } - - /** - * @param int[] $associatedGroupIds - * - * @return $this - */ - public function setAssociatedGroupIds(array $associatedGroupIds) - { - $this->associatedGroupIds = $associatedGroupIds; - - return $this; - } - - /** - * @return int[] - */ - public function getAssociatedShopIds() - { - return $this->associatedShopIds; - } - - /** - * @param int[] $associatedShopIds - * - * @return $this - */ - public function setAssociatedShopIds(array $associatedShopIds) - { - $this->associatedShopIds = $associatedShopIds; - - return $this; - } -} diff --git a/src/Core/Domain/Category/Command/AddRootCategoryCommand.php b/src/Core/Domain/Category/Command/AddRootCategoryCommand.php deleted file mode 100644 index 49bb12e2..00000000 --- a/src/Core/Domain/Category/Command/AddRootCategoryCommand.php +++ /dev/null @@ -1,293 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Command; - -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryConstraintException; - -/** - * Class AddRootCategoryCommand adds new root category. - */ -class AddRootCategoryCommand -{ - /** - * @var string[] - */ - private $localizedNames; - - /** - * @var string[] - */ - private $localizedLinkRewrites; - - /** - * @var string[] - */ - private $localizedDescriptions; - - /** - * @var bool - */ - private $isActive; - - /** - * @var string[] - */ - private $localizedMetaTitles; - - /** - * @var string[] - */ - private $localizedMetaDescriptions; - - /** - * @var string[] - */ - private $localizedMetaKeywords; - - /** - * @var int[] - */ - private $associatedGroupIds; - - /** - * @var int[] - */ - private $associatedShopIds; - - /** - * @param string[] $name - * @param string[] $linkRewrite - * @param bool $isActive - * - * @throws CategoryConstraintException - */ - public function __construct(array $name, array $linkRewrite, $isActive) - { - $this - ->setLocalizedNames($name) - ->setLocalizedLinkRewrites($linkRewrite) - ->setIsActive($isActive); - } - - /** - * @return string[] - */ - public function getLocalizedNames() - { - return $this->localizedNames; - } - - /** - * @param string[] $localizedNames - * - * @return $this - * - * @throws CategoryConstraintException - */ - public function setLocalizedNames(array $localizedNames) - { - if (empty($localizedNames)) { - throw new CategoryConstraintException('Category name cannot be empty', CategoryConstraintException::EMPTY_NAME); - } - - $this->localizedNames = $localizedNames; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedLinkRewrites() - { - return $this->localizedLinkRewrites; - } - - /** - * @param string[] $localizedLinkRewrites - * - * @return $this - * - * @throws CategoryConstraintException - */ - public function setLocalizedLinkRewrites(array $localizedLinkRewrites) - { - if (empty($localizedLinkRewrites)) { - throw new CategoryConstraintException('Category link rewrite cannot be empty', CategoryConstraintException::EMPTY_LINK_REWRITE); - } - - $this->localizedLinkRewrites = $localizedLinkRewrites; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedDescriptions() - { - return $this->localizedDescriptions; - } - - /** - * @param string[] $localizedDescriptions - * - * @return $this - */ - public function setLocalizedDescriptions(array $localizedDescriptions) - { - $this->localizedDescriptions = $localizedDescriptions; - - return $this; - } - - /** - * @return bool - */ - public function isActive() - { - return $this->isActive; - } - - /** - * @param bool $isActive - * - * @return $this - * - * @throws CategoryConstraintException - */ - public function setIsActive($isActive) - { - if (!is_bool($isActive)) { - throw new CategoryConstraintException('Invalid Category status supplied', CategoryConstraintException::INVALID_STATUS); - } - - $this->isActive = $isActive; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedMetaTitles() - { - return $this->localizedMetaTitles; - } - - /** - * @param string[] $localizedMetaTitles - * - * @return $this - */ - public function setLocalizedMetaTitles(array $localizedMetaTitles) - { - $this->localizedMetaTitles = $localizedMetaTitles; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedMetaDescriptions() - { - return $this->localizedMetaDescriptions; - } - - /** - * @param string[] $localizedMetaDescriptions - * - * @return $this - */ - public function setLocalizedMetaDescriptions(array $localizedMetaDescriptions) - { - $this->localizedMetaDescriptions = $localizedMetaDescriptions; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedMetaKeywords() - { - return $this->localizedMetaKeywords; - } - - /** - * @param string[] $localizedMetaKeywords - * - * @return $this - */ - public function setLocalizedMetaKeywords(array $localizedMetaKeywords) - { - $this->localizedMetaKeywords = $localizedMetaKeywords; - - return $this; - } - - /** - * @return int[] - */ - public function getAssociatedGroupIds() - { - return $this->associatedGroupIds; - } - - /** - * @param int[] $associatedGroupIds - * - * @return $this - */ - public function setAssociatedGroupIds(array $associatedGroupIds) - { - $this->associatedGroupIds = $associatedGroupIds; - - return $this; - } - - /** - * @return int[] - */ - public function getAssociatedShopIds() - { - return $this->associatedShopIds; - } - - /** - * @param int[] $associatedShopIds - * - * @return $this - */ - public function setAssociatedShopIds(array $associatedShopIds) - { - $this->associatedShopIds = $associatedShopIds; - - return $this; - } -} diff --git a/src/Core/Domain/Category/Command/BulkDeleteCategoriesCommand.php b/src/Core/Domain/Category/Command/BulkDeleteCategoriesCommand.php deleted file mode 100644 index 6ab7b2a7..00000000 --- a/src/Core/Domain/Category/Command/BulkDeleteCategoriesCommand.php +++ /dev/null @@ -1,112 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Command; - -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryException; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryDeleteMode; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; - -/** - * Class BulkDeleteCategoriesCommand. - */ -class BulkDeleteCategoriesCommand -{ - /** - * @var CategoryId[] - */ - private $categoryIds; - - /** - * @var CategoryDeleteMode - */ - private $deleteMode; - - /** - * @param int[] $categoryIds - * @param string $deleteMode - * - * @throws CategoryConstraintException - * @throws CategoryException - */ - public function __construct(array $categoryIds, $deleteMode) - { - $this - ->setCategoryIds($categoryIds) - ->setDeleteMode($deleteMode) - ; - } - - /** - * @return CategoryId[] - */ - public function getCategoryIds() - { - return $this->categoryIds; - } - - /** - * @return CategoryDeleteMode - */ - public function getDeleteMode() - { - return $this->deleteMode; - } - - /** - * @param string $mode - * - * @return self - */ - private function setDeleteMode($mode) - { - $this->deleteMode = new CategoryDeleteMode($mode); - - return $this; - } - - /** - * @param int[] $categoryIds - * - * @throws CategoryConstraintException - * @throws CategoryException - * - * @return self - */ - private function setCategoryIds(array $categoryIds) - { - if (empty($categoryIds)) { - throw new CategoryConstraintException('Missing Category data for bulk deleting', CategoryConstraintException::EMPTY_BULK_DELETE_DATA); - } - - foreach ($categoryIds as $categoryId) { - $this->categoryIds[] = new CategoryId((int) $categoryId); - } - - return $this; - } -} diff --git a/src/Core/Domain/Category/Command/BulkDisableCategoriesCommand.php b/src/Core/Domain/Category/Command/BulkDisableCategoriesCommand.php deleted file mode 100644 index 3b093b81..00000000 --- a/src/Core/Domain/Category/Command/BulkDisableCategoriesCommand.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Command; - -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryConstraintException; - -/** - * Class DisableCategoriesCommand disables provided categories. - */ -class BulkDisableCategoriesCommand extends BulkUpdateCategoriesStatusCommand -{ - /** - * @param int[] $categoryIds - * - * @throws CategoryConstraintException - */ - public function __construct(array $categoryIds) - { - parent::__construct($categoryIds, false); - } -} diff --git a/src/Core/Domain/Category/Command/BulkEnableCategoriesCommand.php b/src/Core/Domain/Category/Command/BulkEnableCategoriesCommand.php deleted file mode 100644 index 67b307f8..00000000 --- a/src/Core/Domain/Category/Command/BulkEnableCategoriesCommand.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Command; - -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryException; - -/** - * Enables given categories - */ -class BulkEnableCategoriesCommand extends BulkUpdateCategoriesStatusCommand -{ - /** - * @param int[] $categoryIds - * - * @throws CategoryConstraintException - * @throws CategoryException - */ - public function __construct(array $categoryIds) - { - parent::__construct($categoryIds, true); - } -} diff --git a/src/Core/Domain/Category/Command/BulkUpdateCategoriesStatusCommand.php b/src/Core/Domain/Category/Command/BulkUpdateCategoriesStatusCommand.php deleted file mode 100644 index be7343a1..00000000 --- a/src/Core/Domain/Category/Command/BulkUpdateCategoriesStatusCommand.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Command; - -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryException; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; - -/** - * Updates provided categories to new status - */ -class BulkUpdateCategoriesStatusCommand -{ - /** - * @var CategoryId[] - */ - private $categoryIds; - - /** - * @var bool - */ - private $newStatus; - - /** - * @param int[] $categoryIds - * @param bool $newStatus - * - * @throws CategoryConstraintException - * @throws CategoryException - */ - public function __construct(array $categoryIds, $newStatus) - { - $this - ->setCategoryIds($categoryIds) - ->setNewStatus($newStatus) - ; - } - - /** - * @return CategoryId[] - */ - public function getCategoryIds() - { - return $this->categoryIds; - } - - /** - * @return bool - */ - public function getNewStatus() - { - return $this->newStatus; - } - - /** - * @param int[] $categoryIds - * - * @return self - * - * @throws CategoryConstraintException - * @throws CategoryException - */ - private function setCategoryIds(array $categoryIds) - { - if (empty($categoryIds)) { - throw new CategoryConstraintException('Missing categories data for status change'); - } - - foreach ($categoryIds as $categoryId) { - $this->categoryIds[] = new CategoryId((int) $categoryId); - } - - return $this; - } - - /** - * @param bool $newStatus - * - * @return self - */ - private function setNewStatus($newStatus) - { - if (!is_bool($newStatus)) { - throw new CategoryConstraintException(sprintf('Category status %s is invalid. Status must be of type "bool".', var_export($newStatus, true)), CategoryConstraintException::INVALID_STATUS); - } - - $this->newStatus = $newStatus; - - return $this; - } -} diff --git a/src/Core/Domain/Category/Command/DeleteCategoryCommand.php b/src/Core/Domain/Category/Command/DeleteCategoryCommand.php deleted file mode 100644 index 81b4403a..00000000 --- a/src/Core/Domain/Category/Command/DeleteCategoryCommand.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Command; - -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryDeleteMode; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; - -/** - * Class DeleteCategoryCommand deletes provided category. - */ -class DeleteCategoryCommand -{ - /** - * @var CategoryId - */ - private $categoryId; - - /** - * @var CategoryDeleteMode - */ - private $deleteMode; - - /** - * @param int $categoryId - * @param string $mode - */ - public function __construct($categoryId, $mode) - { - $this->categoryId = new CategoryId($categoryId); - $this->deleteMode = new CategoryDeleteMode($mode); - } - - /** - * @return CategoryId - */ - public function getCategoryId() - { - return $this->categoryId; - } - - /** - * @return CategoryDeleteMode - */ - public function getDeleteMode() - { - return $this->deleteMode; - } -} diff --git a/src/Core/Domain/Category/Command/DeleteCategoryCoverImageCommand.php b/src/Core/Domain/Category/Command/DeleteCategoryCoverImageCommand.php deleted file mode 100644 index 3d98592c..00000000 --- a/src/Core/Domain/Category/Command/DeleteCategoryCoverImageCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Command; - -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; - -/** - * Deletes cover image for given category. - */ -class DeleteCategoryCoverImageCommand -{ - /** - * @var CategoryId - */ - private $categoryId; - - /** - * @param int $categoryId - */ - public function __construct($categoryId) - { - $this->categoryId = new CategoryId($categoryId); - } - - /** - * @return CategoryId - */ - public function getCategoryId() - { - return $this->categoryId; - } -} diff --git a/src/Core/Domain/Category/Command/DeleteCategoryMenuThumbnailImageCommand.php b/src/Core/Domain/Category/Command/DeleteCategoryMenuThumbnailImageCommand.php deleted file mode 100644 index 4e495e9f..00000000 --- a/src/Core/Domain/Category/Command/DeleteCategoryMenuThumbnailImageCommand.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Command; - -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\MenuThumbnailId; - -/** - * Deletes given menu thumbnail for category. - */ -class DeleteCategoryMenuThumbnailImageCommand -{ - /** - * @var CategoryId - */ - private $categoryId; - - /** - * @var MenuThumbnailId - */ - private $menuThumbnailId; - - /** - * @param int $categoryId - * @param int $menuThumbnailId - */ - public function __construct($categoryId, $menuThumbnailId) - { - $this->categoryId = new CategoryId($categoryId); - $this->menuThumbnailId = new MenuThumbnailId($menuThumbnailId); - } - - /** - * @return CategoryId - */ - public function getCategoryId() - { - return $this->categoryId; - } - - /** - * @return MenuThumbnailId - */ - public function getMenuThumbnailId() - { - return $this->menuThumbnailId; - } -} diff --git a/src/Core/Domain/Category/Command/EditCategoryCommand.php b/src/Core/Domain/Category/Command/EditCategoryCommand.php deleted file mode 100644 index b18fd31e..00000000 --- a/src/Core/Domain/Category/Command/EditCategoryCommand.php +++ /dev/null @@ -1,335 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Command; - -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; - -/** - * Class EditCategoryCommand edits given category. - */ -class EditCategoryCommand -{ - /** - * @var CategoryId - */ - private $categoryId; - - /** - * @var int - */ - private $parentCategoryId; - - /** - * @var string[] - */ - private $localizedNames; - - /** - * @var string[] - */ - private $localizedLinkRewrites; - - /** - * @var string[] - */ - private $localizedDescriptions; - - /** - * @var bool - */ - private $isActive; - - /** - * @var string[] - */ - private $localizedMetaTitles; - - /** - * @var string[] - */ - private $localizedMetaDescriptions; - - /** - * @var string[] - */ - private $localizedMetaKeywords; - - /** - * @var int[] - */ - private $associatedGroupIds; - - /** - * @var int[] - */ - private $associatedShopIds; - - /** - * @param int $categoryId - */ - public function __construct($categoryId) - { - $this->categoryId = new CategoryId($categoryId); - } - - /** - * @return CategoryId - */ - public function getCategoryId() - { - return $this->categoryId; - } - - /** - * @return int - */ - public function getParentCategoryId() - { - return $this->parentCategoryId; - } - - /** - * @param int $parentCategoryId - * - * @return self - * - * @throws CategoryConstraintException - */ - public function setParentCategoryId($parentCategoryId) - { - if (!is_numeric($parentCategoryId) || 0 >= $parentCategoryId) { - throw new CategoryConstraintException(sprintf('Invalid Category parent id %s supplied', var_export($parentCategoryId, true)), CategoryConstraintException::INVALID_PARENT_ID); - } - - if ($this->categoryId->isEqual(new CategoryId((int) $parentCategoryId))) { - throw new CategoryConstraintException('Category cannot be parent of itself.'); - } - - $this->parentCategoryId = $parentCategoryId; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedNames() - { - return $this->localizedNames; - } - - /** - * @param string[] $localizedNames - * - * @return $this - * - * @throws CategoryConstraintException - */ - public function setLocalizedNames(array $localizedNames) - { - if (empty($localizedNames)) { - throw new CategoryConstraintException('Category name cannot be empty', CategoryConstraintException::EMPTY_NAME); - } - - $this->localizedNames = $localizedNames; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedLinkRewrites() - { - return $this->localizedLinkRewrites; - } - - /** - * @param string[] $localizedLinkRewrites - * - * @return $this - * - * @throws CategoryConstraintException - */ - public function setLocalizedLinkRewrites(array $localizedLinkRewrites) - { - if (empty($localizedLinkRewrites)) { - throw new CategoryConstraintException('Category link rewrite cannot be empty', CategoryConstraintException::EMPTY_LINK_REWRITE); - } - - $this->localizedLinkRewrites = $localizedLinkRewrites; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedDescriptions() - { - return $this->localizedDescriptions; - } - - /** - * @param string[] $localizedDescriptions - * - * @return $this - */ - public function setLocalizedDescriptions(array $localizedDescriptions) - { - $this->localizedDescriptions = $localizedDescriptions; - - return $this; - } - - /** - * @return bool - */ - public function isActive() - { - return $this->isActive; - } - - /** - * @param bool $isActive - * - * @return $this - * - * @throws CategoryConstraintException - */ - public function setIsActive($isActive) - { - if (!is_bool($isActive)) { - throw new CategoryConstraintException('Invalid Category status supplied', CategoryConstraintException::INVALID_STATUS); - } - - $this->isActive = $isActive; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedMetaTitles() - { - return $this->localizedMetaTitles; - } - - /** - * @param string[] $localizedMetaTitles - * - * @return $this - */ - public function setLocalizedMetaTitles(array $localizedMetaTitles) - { - $this->localizedMetaTitles = $localizedMetaTitles; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedMetaDescriptions() - { - return $this->localizedMetaDescriptions; - } - - /** - * @param string[] $localizedMetaDescriptions - * - * @return $this - */ - public function setLocalizedMetaDescriptions(array $localizedMetaDescriptions) - { - $this->localizedMetaDescriptions = $localizedMetaDescriptions; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedMetaKeywords() - { - return $this->localizedMetaKeywords; - } - - /** - * @param string[] $localizedMetaKeywords - * - * @return $this - */ - public function setLocalizedMetaKeywords(array $localizedMetaKeywords) - { - $this->localizedMetaKeywords = $localizedMetaKeywords; - - return $this; - } - - /** - * @return int[] - */ - public function getAssociatedGroupIds() - { - return $this->associatedGroupIds; - } - - /** - * @param int[] $associatedGroupIds - * - * @return $this - */ - public function setAssociatedGroupIds(array $associatedGroupIds) - { - $this->associatedGroupIds = $associatedGroupIds; - - return $this; - } - - /** - * @return int[] - */ - public function getAssociatedShopIds() - { - return $this->associatedShopIds; - } - - /** - * @param int[] $associatedShopIds - * - * @return $this - */ - public function setAssociatedShopIds(array $associatedShopIds) - { - $this->associatedShopIds = $associatedShopIds; - - return $this; - } -} diff --git a/src/Core/Domain/Category/Command/EditRootCategoryCommand.php b/src/Core/Domain/Category/Command/EditRootCategoryCommand.php deleted file mode 100644 index 5d297441..00000000 --- a/src/Core/Domain/Category/Command/EditRootCategoryCommand.php +++ /dev/null @@ -1,300 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Command; - -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; - -/** - * Class EditRootCategoryCommand edits given root category. - */ -class EditRootCategoryCommand -{ - /** - * @var CategoryId - */ - private $categoryId; - - /** - * @var string[] - */ - private $localizedNames; - - /** - * @var string[] - */ - private $localizedLinkRewrites; - - /** - * @var string[] - */ - private $localizedDescriptions; - - /** - * @var bool - */ - private $isActive; - - /** - * @var string[] - */ - private $localizedMetaTitles; - - /** - * @var string[] - */ - private $localizedMetaDescriptions; - - /** - * @var string[] - */ - private $localizedMetaKeywords; - - /** - * @var int[] - */ - private $associatedGroupIds; - - /** - * @var int[] - */ - private $associatedShopIds; - - /** - * @param int $categoryId - */ - public function __construct($categoryId) - { - $this->categoryId = new CategoryId($categoryId); - } - - /** - * @return CategoryId - */ - public function getCategoryId() - { - return $this->categoryId; - } - - /** - * @return string[] - */ - public function getLocalizedNames() - { - return $this->localizedNames; - } - - /** - * @param string[] $localizedNames - * - * @return $this - * - * @throws CategoryConstraintException - */ - public function setLocalizedNames(array $localizedNames) - { - if (empty($localizedNames)) { - throw new CategoryConstraintException('Category name cannot be empty', CategoryConstraintException::EMPTY_NAME); - } - - $this->localizedNames = $localizedNames; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedLinkRewrites() - { - return $this->localizedLinkRewrites; - } - - /** - * @param string[] $localizedLinkRewrites - * - * @return $this - * - * @throws CategoryConstraintException - */ - public function setLocalizedLinkRewrites(array $localizedLinkRewrites) - { - if (empty($localizedLinkRewrites)) { - throw new CategoryConstraintException('Category link rewrite cannot be empty', CategoryConstraintException::EMPTY_LINK_REWRITE); - } - - $this->localizedLinkRewrites = $localizedLinkRewrites; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedDescriptions() - { - return $this->localizedDescriptions; - } - - /** - * @param string[] $localizedDescriptions - * - * @return $this - */ - public function setLocalizedDescriptions(array $localizedDescriptions) - { - $this->localizedDescriptions = $localizedDescriptions; - - return $this; - } - - /** - * @return bool - */ - public function isActive() - { - return $this->isActive; - } - - /** - * @param bool $isActive - * - * @return $this - * - * @throws CategoryConstraintException - */ - public function setIsActive($isActive) - { - if (!is_bool($isActive)) { - throw new CategoryConstraintException('Invalid Category status supplied', CategoryConstraintException::INVALID_STATUS); - } - - $this->isActive = $isActive; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedMetaTitles() - { - return $this->localizedMetaTitles; - } - - /** - * @param string[] $localizedMetaTitles - * - * @return $this - */ - public function setLocalizedMetaTitles(array $localizedMetaTitles) - { - $this->localizedMetaTitles = $localizedMetaTitles; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedMetaDescriptions() - { - return $this->localizedMetaDescriptions; - } - - /** - * @param string[] $localizedMetaDescriptions - * - * @return $this - */ - public function setLocalizedMetaDescriptions(array $localizedMetaDescriptions) - { - $this->localizedMetaDescriptions = $localizedMetaDescriptions; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedMetaKeywords() - { - return $this->localizedMetaKeywords; - } - - /** - * @param string[] $localizedMetaKeywords - * - * @return $this - */ - public function setLocalizedMetaKeywords(array $localizedMetaKeywords) - { - $this->localizedMetaKeywords = $localizedMetaKeywords; - - return $this; - } - - /** - * @return int[] - */ - public function getAssociatedGroupIds() - { - return $this->associatedGroupIds; - } - - /** - * @param int[] $associatedGroupIds - * - * @return $this - */ - public function setAssociatedGroupIds(array $associatedGroupIds) - { - $this->associatedGroupIds = $associatedGroupIds; - - return $this; - } - - /** - * @return int[] - */ - public function getAssociatedShopIds() - { - return $this->associatedShopIds; - } - - /** - * @param int[] $associatedShopIds - * - * @return $this - */ - public function setAssociatedShopIds(array $associatedShopIds) - { - $this->associatedShopIds = $associatedShopIds; - - return $this; - } -} diff --git a/src/Core/Domain/Category/Command/SetCategoryIsEnabledCommand.php b/src/Core/Domain/Category/Command/SetCategoryIsEnabledCommand.php deleted file mode 100644 index a77376cb..00000000 --- a/src/Core/Domain/Category/Command/SetCategoryIsEnabledCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Command; - -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; - -/** - * Class ToggleCategoryStatusCommand toggles given category status. - */ -class SetCategoryIsEnabledCommand -{ - /** - * @var CategoryId - */ - private $categoryId; - - /** - * @var bool - */ - private $isEnabled; - - /** - * @param int $categoryId - * @param bool $isEnabled - */ - public function __construct($categoryId, $isEnabled) - { - $this->categoryId = new CategoryId($categoryId); - $this->isEnabled = $isEnabled; - } - - /** - * @return CategoryId - */ - public function getCategoryId() - { - return $this->categoryId; - } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->isEnabled; - } -} diff --git a/src/Core/Domain/Category/Command/UpdateCategoryPositionCommand.php b/src/Core/Domain/Category/Command/UpdateCategoryPositionCommand.php deleted file mode 100644 index aef332cb..00000000 --- a/src/Core/Domain/Category/Command/UpdateCategoryPositionCommand.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Command; - -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; - -/** - * Updates category position - */ -class UpdateCategoryPositionCommand -{ - /** - * @var CategoryId - */ - private $categoryId; - - /** - * @var CategoryId - */ - private $parentCategoryId; - - /** - * @var int - */ - private $way; - - /** - * @var array - */ - private $positions; - - /** - * @var bool - */ - private $foundFirst; - - /** - * @param int $categoryId - * @param int $parentCategoryId - * @param int $way - * @param array $positions - * @param bool $foundFirst - */ - public function __construct($categoryId, $parentCategoryId, $way, array $positions, $foundFirst) - { - $this->categoryId = new CategoryId($categoryId); - $this->parentCategoryId = new CategoryId($parentCategoryId); - $this->way = $way; - $this->positions = $positions; - $this->foundFirst = $foundFirst; - } - - /** - * @return CategoryId - */ - public function getCategoryId() - { - return $this->categoryId; - } - - /** - * @return CategoryId - */ - public function getParentCategoryId() - { - return $this->parentCategoryId; - } - - /** - * @return int - */ - public function getWay() - { - return $this->way; - } - - /** - * @return array - */ - public function getPositions() - { - return $this->positions; - } - - /** - * @return bool - */ - public function isFoundFirst() - { - return $this->foundFirst; - } -} diff --git a/src/Core/Domain/Category/CommandHandler/AddCategoryHandlerInterface.php b/src/Core/Domain/Category/CommandHandler/AddCategoryHandlerInterface.php deleted file mode 100644 index 29945f17..00000000 --- a/src/Core/Domain/Category/CommandHandler/AddCategoryHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Category\Command\AddCategoryCommand; - -/** - * Interface AddCategoryHandlerInterface. - */ -interface AddCategoryHandlerInterface -{ - /** - * @param AddCategoryCommand $command - */ - public function handle(AddCategoryCommand $command); -} diff --git a/src/Core/Domain/Category/CommandHandler/AddRootCategoryHandlerInterface.php b/src/Core/Domain/Category/CommandHandler/AddRootCategoryHandlerInterface.php deleted file mode 100644 index 198e178a..00000000 --- a/src/Core/Domain/Category/CommandHandler/AddRootCategoryHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Category\Command\AddRootCategoryCommand; - -/** - * Interface AddRootCategoryHandler. - */ -interface AddRootCategoryHandlerInterface -{ - /** - * @param AddRootCategoryCommand $command - */ - public function handle(AddRootCategoryCommand $command); -} diff --git a/src/Core/Domain/Category/CommandHandler/BulkDeleteCategoriesHandlerInterface.php b/src/Core/Domain/Category/CommandHandler/BulkDeleteCategoriesHandlerInterface.php deleted file mode 100644 index 2dafc03f..00000000 --- a/src/Core/Domain/Category/CommandHandler/BulkDeleteCategoriesHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Category\Command\BulkDeleteCategoriesCommand; - -/** - * Interface BulkDeleteCategoriesHandlerInterface. - */ -interface BulkDeleteCategoriesHandlerInterface -{ - /** - * @param BulkDeleteCategoriesCommand $command - */ - public function handle(BulkDeleteCategoriesCommand $command); -} diff --git a/src/Core/Domain/Category/CommandHandler/BulkUpdateCategoriesStatusHandlerInterface.php b/src/Core/Domain/Category/CommandHandler/BulkUpdateCategoriesStatusHandlerInterface.php deleted file mode 100644 index bf2e78d2..00000000 --- a/src/Core/Domain/Category/CommandHandler/BulkUpdateCategoriesStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Category\Command\BulkUpdateCategoriesStatusCommand; - -/** - * Interface UpdateCategoriesStatusHandlerInterface. - */ -interface BulkUpdateCategoriesStatusHandlerInterface -{ - /** - * @param BulkUpdateCategoriesStatusCommand $command - */ - public function handle(BulkUpdateCategoriesStatusCommand $command); -} diff --git a/src/Core/Domain/Category/CommandHandler/DeleteCategoryCoverImageHandlerInterface.php b/src/Core/Domain/Category/CommandHandler/DeleteCategoryCoverImageHandlerInterface.php deleted file mode 100644 index eaefef74..00000000 --- a/src/Core/Domain/Category/CommandHandler/DeleteCategoryCoverImageHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Category\Command\DeleteCategoryCoverImageCommand; - -/** - * Defines contract for service which handles cover image delete command. - */ -interface DeleteCategoryCoverImageHandlerInterface -{ - /** - * @param DeleteCategoryCoverImageCommand $command - */ - public function handle(DeleteCategoryCoverImageCommand $command); -} diff --git a/src/Core/Domain/Category/CommandHandler/DeleteCategoryHandlerInterface.php b/src/Core/Domain/Category/CommandHandler/DeleteCategoryHandlerInterface.php deleted file mode 100644 index d90a628f..00000000 --- a/src/Core/Domain/Category/CommandHandler/DeleteCategoryHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Category\Command\DeleteCategoryCommand; - -/** - * Interface DeleteCategoryHandlerInterface. - */ -interface DeleteCategoryHandlerInterface -{ - /** - * @param DeleteCategoryCommand $command - */ - public function handle(DeleteCategoryCommand $command); -} diff --git a/src/Core/Domain/Category/CommandHandler/DeleteCategoryMenuThumbnailImageHandlerInterface.php b/src/Core/Domain/Category/CommandHandler/DeleteCategoryMenuThumbnailImageHandlerInterface.php deleted file mode 100644 index 6883ef90..00000000 --- a/src/Core/Domain/Category/CommandHandler/DeleteCategoryMenuThumbnailImageHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Category\Command\DeleteCategoryMenuThumbnailImageCommand; - -/** - * Defines contract for service that handles category menu thumbnail deleting command. - */ -interface DeleteCategoryMenuThumbnailImageHandlerInterface -{ - /** - * @param DeleteCategoryMenuThumbnailImageCommand $command - */ - public function handle(DeleteCategoryMenuThumbnailImageCommand $command); -} diff --git a/src/Core/Domain/Category/CommandHandler/EditCategoryHandlerInterface.php b/src/Core/Domain/Category/CommandHandler/EditCategoryHandlerInterface.php deleted file mode 100644 index b3e836d7..00000000 --- a/src/Core/Domain/Category/CommandHandler/EditCategoryHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Category\Command\EditCategoryCommand; - -/** - * Interface EditCategoryHandlerInterface. - */ -interface EditCategoryHandlerInterface -{ - /** - * @param EditCategoryCommand $command - */ - public function handle(EditCategoryCommand $command); -} diff --git a/src/Core/Domain/Category/CommandHandler/EditRootCategoryHandlerInterface.php b/src/Core/Domain/Category/CommandHandler/EditRootCategoryHandlerInterface.php deleted file mode 100644 index 02fa2ebc..00000000 --- a/src/Core/Domain/Category/CommandHandler/EditRootCategoryHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Category\Command\EditRootCategoryCommand; - -/** - * Interface EditRootCategoryHandlerInterface. - */ -interface EditRootCategoryHandlerInterface -{ - /** - * @param EditRootCategoryCommand $command - */ - public function handle(EditRootCategoryCommand $command); -} diff --git a/src/Core/Domain/Category/CommandHandler/SetCategoryIsEnabledHandlerInterface.php b/src/Core/Domain/Category/CommandHandler/SetCategoryIsEnabledHandlerInterface.php deleted file mode 100644 index e949b337..00000000 --- a/src/Core/Domain/Category/CommandHandler/SetCategoryIsEnabledHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Category\Command\SetCategoryIsEnabledCommand; - -/** - * Interface for service that set category to be enabled or disabled. - */ -interface SetCategoryIsEnabledHandlerInterface -{ - /** - * @param SetCategoryIsEnabledCommand $command - */ - public function handle(SetCategoryIsEnabledCommand $command); -} diff --git a/src/Core/Domain/Category/CommandHandler/UpdateCategoryPositionHandlerInterface.php b/src/Core/Domain/Category/CommandHandler/UpdateCategoryPositionHandlerInterface.php deleted file mode 100644 index fba00be3..00000000 --- a/src/Core/Domain/Category/CommandHandler/UpdateCategoryPositionHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Category\Command\UpdateCategoryPositionCommand; - -/** - * Interface for service that updates category position - */ -interface UpdateCategoryPositionHandlerInterface -{ - /** - * @param UpdateCategoryPositionCommand $command - */ - public function handle(UpdateCategoryPositionCommand $command); -} diff --git a/src/Core/Domain/Category/Exception/CannotAddCategoryException.php b/src/Core/Domain/Category/Exception/CannotAddCategoryException.php deleted file mode 100644 index 8a575df4..00000000 --- a/src/Core/Domain/Category/Exception/CannotAddCategoryException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Exception; - -/** - * Class CannotAddCategoryException is throw when adding category fails. - */ -class CannotAddCategoryException extends CategoryException -{ -} diff --git a/src/Core/Domain/Category/Exception/CannotDeleteImageException.php b/src/Core/Domain/Category/Exception/CannotDeleteImageException.php deleted file mode 100644 index ae1ef720..00000000 --- a/src/Core/Domain/Category/Exception/CannotDeleteImageException.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Exception; - -/** - * Thrown when category image was attempted to delete but failed. - */ -class CannotDeleteImageException extends CategoryException -{ - /** - * Error codes to specify which type of image were not deleted. - */ - const COVER_IMAGE = 1; - const THUMBNAIL_IMAGE = 2; - const MENU_THUMBNAIL_IMAGE = 3; -} diff --git a/src/Core/Domain/Category/Exception/CannotDeleteRootCategoryForShopException.php b/src/Core/Domain/Category/Exception/CannotDeleteRootCategoryForShopException.php deleted file mode 100644 index 91026a95..00000000 --- a/src/Core/Domain/Category/Exception/CannotDeleteRootCategoryForShopException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Exception; - -/** - * Is thrown when trying to delete a root category for current shop context - */ -class CannotDeleteRootCategoryForShopException extends CategoryException -{ -} diff --git a/src/Core/Domain/Category/Exception/CannotEditCategoryException.php b/src/Core/Domain/Category/Exception/CannotEditCategoryException.php deleted file mode 100644 index 6fe79130..00000000 --- a/src/Core/Domain/Category/Exception/CannotEditCategoryException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Exception; - -/** - * Class CannotEditCategoryException is thrown when editing category fails. - */ -class CannotEditCategoryException extends CategoryException -{ -} diff --git a/src/Core/Domain/Category/Exception/CannotUpdateCategoryStatusException.php b/src/Core/Domain/Category/Exception/CannotUpdateCategoryStatusException.php deleted file mode 100644 index 796c69a0..00000000 --- a/src/Core/Domain/Category/Exception/CannotUpdateCategoryStatusException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Exception; - -/** - * Class CannotUpdateCategoryStatusException is thrown when Category status update failed. - */ -class CannotUpdateCategoryStatusException extends CategoryException -{ -} diff --git a/src/Core/Domain/Category/Exception/CategoryConstraintException.php b/src/Core/Domain/Category/Exception/CategoryConstraintException.php deleted file mode 100644 index 60ba4c3a..00000000 --- a/src/Core/Domain/Category/Exception/CategoryConstraintException.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Exception; - -/** - * Class CategoryConstraintException. - */ -class CategoryConstraintException extends CategoryException -{ - /** - * Code is used when category does not have name. - */ - const EMPTY_NAME = 1; - - /** - * Code is used when category does not have link rewrite. - */ - const EMPTY_LINK_REWRITE = 2; - - /** - * Code is used when invalid status is set to category. - */ - const INVALID_STATUS = 4; - - /** - * Code is used when invalid delete mode is used to delete a category. - */ - const INVALID_DELETE_MODE = 5; - - /** - * Code is used when invalid parent id is supplied. - */ - const INVALID_PARENT_ID = 6; - - /** - * Code is used when too many menu thumbnails is being set for category. - */ - const TOO_MANY_MENU_THUMBNAILS = 8; - - /** - * Code is used when invalid id is supplied. - */ - const INVALID_ID = 10; - - /** - * Code is used when performing bulk delete of categories with empty data. - */ - const EMPTY_BULK_DELETE_DATA = 12; -} diff --git a/src/Core/Domain/Category/Exception/CategoryException.php b/src/Core/Domain/Category/Exception/CategoryException.php deleted file mode 100644 index 89ee3338..00000000 --- a/src/Core/Domain/Category/Exception/CategoryException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Class CategoryException is base exception for Category bounded context. - */ -class CategoryException extends DomainException -{ -} diff --git a/src/Core/Domain/Category/Exception/CategoryNotFoundException.php b/src/Core/Domain/Category/Exception/CategoryNotFoundException.php deleted file mode 100644 index 2852fe1a..00000000 --- a/src/Core/Domain/Category/Exception/CategoryNotFoundException.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Exception; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; - -/** - * Class CategoryNotFoundException. - */ -class CategoryNotFoundException extends CategoryException -{ - /** - * @var CategoryId - */ - private $categoryId; - - /** - * @param CategoryId $categoryId - * @param string $message - * @param int $code - * @param Exception $previous - */ - public function __construct(CategoryId $categoryId, $message = '', $code = 0, $previous = null) - { - parent::__construct($message, $code, $previous); - - $this->categoryId = $categoryId; - } - - /** - * @return CategoryId - */ - public function getCategoryId() - { - return $this->categoryId; - } -} diff --git a/src/Core/Domain/Category/Exception/FailedToDeleteCategoryException.php b/src/Core/Domain/Category/Exception/FailedToDeleteCategoryException.php deleted file mode 100644 index d7cbf6dc..00000000 --- a/src/Core/Domain/Category/Exception/FailedToDeleteCategoryException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Exception; - -/** - * Is thrown when unable to delete category - */ -class FailedToDeleteCategoryException extends CategoryException -{ -} diff --git a/src/Core/Domain/Category/Exception/MenuThumbnailsLimitException.php b/src/Core/Domain/Category/Exception/MenuThumbnailsLimitException.php deleted file mode 100644 index 746b18e3..00000000 --- a/src/Core/Domain/Category/Exception/MenuThumbnailsLimitException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Exception; - -/** - * Class MenuThumbnailsLimitException is thrown when maximum number of thumbnail images is reached. - */ -class MenuThumbnailsLimitException extends CategoryException -{ -} diff --git a/src/Core/Domain/Category/Query/GetCategoryForEditing.php b/src/Core/Domain/Category/Query/GetCategoryForEditing.php deleted file mode 100644 index 22b119ae..00000000 --- a/src/Core/Domain/Category/Query/GetCategoryForEditing.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Query; - -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; - -/** - * Class GetCategoryForEditing retrieves category data for editing. - */ -class GetCategoryForEditing -{ - /** - * @var CategoryId - */ - private $categoryId; - - /** - * @param int $categoryId - */ - public function __construct($categoryId) - { - $this->categoryId = new CategoryId($categoryId); - } - - /** - * @return CategoryId - */ - public function getCategoryId() - { - return $this->categoryId; - } -} diff --git a/src/Core/Domain/Category/Query/GetCategoryIsEnabled.php b/src/Core/Domain/Category/Query/GetCategoryIsEnabled.php deleted file mode 100644 index 750a6f69..00000000 --- a/src/Core/Domain/Category/Query/GetCategoryIsEnabled.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\Query; - -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; - -/** - * Get current status (enabled/disabled) for given category. - */ -class GetCategoryIsEnabled -{ - /** - * @var CategoryId - */ - private $categoryId; - - /** - * @param int $categoryId - */ - public function __construct($categoryId) - { - $this->categoryId = new CategoryId($categoryId); - } - - /** - * @return CategoryId - */ - public function getCategoryId() - { - return $this->categoryId; - } -} diff --git a/src/Core/Domain/Category/QueryHandler/GetCategoryForEditingHandlerInterface.php b/src/Core/Domain/Category/QueryHandler/GetCategoryForEditingHandlerInterface.php deleted file mode 100644 index e513e054..00000000 --- a/src/Core/Domain/Category/QueryHandler/GetCategoryForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Category\Query\GetCategoryForEditing; -use PrestaShop\PrestaShop\Core\Domain\Category\QueryResult\EditableCategory; - -/** - * Interface GetCategoryForEditingHandlerInterface. - */ -interface GetCategoryForEditingHandlerInterface -{ - /** - * @param GetCategoryForEditing $query - * - * @return EditableCategory - */ - public function handle(GetCategoryForEditing $query); -} diff --git a/src/Core/Domain/Category/QueryHandler/GetCategoryIsEnabledHandlerInterface.php b/src/Core/Domain/Category/QueryHandler/GetCategoryIsEnabledHandlerInterface.php deleted file mode 100644 index 4e50fa60..00000000 --- a/src/Core/Domain/Category/QueryHandler/GetCategoryIsEnabledHandlerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Category\Query\GetCategoryIsEnabled; - -/** - * Interface for service that handles getting category status. - */ -interface GetCategoryIsEnabledHandlerInterface -{ - /** - * @param GetCategoryIsEnabled $query - * - * @return bool - */ - public function handle(GetCategoryIsEnabled $query); -} diff --git a/src/Core/Domain/Category/QueryResult/EditableCategory.php b/src/Core/Domain/Category/QueryResult/EditableCategory.php deleted file mode 100644 index 9a507af9..00000000 --- a/src/Core/Domain/Category/QueryResult/EditableCategory.php +++ /dev/null @@ -1,306 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\MenuThumbnailId; - -/** - * Stores category data needed for editing. - */ -class EditableCategory -{ - /** - * @var CategoryId - */ - private $id; - - /** - * @var string[] - */ - private $name; - - /** - * @var bool - */ - private $isActive; - - /** - * @var string[] - */ - private $description; - - /** - * @var int - */ - private $parentId; - - /** - * @var string[] - */ - private $metaTitle; - - /** - * @var string[] - */ - private $metaDescription; - - /** - * @var string[] - */ - private $metaKeywords; - - /** - * @var string[] - */ - private $linkRewrite; - - /** - * @var int[] - */ - private $groupAssociationIds; - - /** - * @var int[] - */ - private $shopAssociationIds; - - /** - * @var mixed - */ - private $thumbnailImage; - - /** - * @var null - */ - private $coverImage; - - /** - * @var array - */ - private $menuThumbnailImages; - - /** - * @var bool - */ - private $isRootCategory; - - /** - * @var array - */ - private $subCategories; - - /** - * @param CategoryId $id - * @param string[] $name - * @param bool $isActive - * @param string[] $description - * @param int $parentId - * @param string[] $metaTitle - * @param string[] $metaDescription - * @param string[] $metaKeywords - * @param string[] $linkRewrite - * @param int[] $groupAssociationIds - * @param int[] $shopAssociationIds - * @param bool $isRootCategory - * @param mixed $coverImage - * @param mixed $thumbnailImage - * @param array $menuThumbnailImages - * @param array $subCategories - */ - public function __construct( - CategoryId $id, - array $name, - $isActive, - array $description, - $parentId, - array $metaTitle, - array $metaDescription, - array $metaKeywords, - array $linkRewrite, - array $groupAssociationIds, - array $shopAssociationIds, - $isRootCategory, - $coverImage = null, - $thumbnailImage = null, - array $menuThumbnailImages = [], - array $subCategories = [] - ) { - $this->id = $id; - $this->name = $name; - $this->isActive = $isActive; - $this->description = $description; - $this->parentId = $parentId; - $this->metaTitle = $metaTitle; - $this->metaDescription = $metaDescription; - $this->metaKeywords = $metaKeywords; - $this->linkRewrite = $linkRewrite; - $this->groupAssociationIds = $groupAssociationIds; - $this->shopAssociationIds = $shopAssociationIds; - $this->thumbnailImage = $thumbnailImage; - $this->coverImage = $coverImage; - $this->menuThumbnailImages = $menuThumbnailImages; - $this->isRootCategory = $isRootCategory; - $this->subCategories = $subCategories; - } - - /** - * @return CategoryId - */ - public function getId() - { - return $this->id; - } - - /** - * @return string[] - */ - public function getName() - { - return $this->name; - } - - /** - * @return bool - */ - public function isActive() - { - return $this->isActive; - } - - /** - * @return string[] - */ - public function getDescription() - { - return $this->description; - } - - /** - * @return int - */ - public function getParentId() - { - return $this->parentId; - } - - /** - * @return string[] - */ - public function getMetaTitle() - { - return $this->metaTitle; - } - - /** - * @return string[] - */ - public function getMetaDescription() - { - return $this->metaDescription; - } - - /** - * @return string[] - */ - public function getMetaKeywords() - { - return $this->metaKeywords; - } - - /** - * @return string[] - */ - public function getLinkRewrite() - { - return $this->linkRewrite; - } - - /** - * @return int[] - */ - public function getGroupAssociationIds() - { - return $this->groupAssociationIds; - } - - /** - * @return int[] - */ - public function getShopAssociationIds() - { - return $this->shopAssociationIds; - } - - /** - * @return mixed - */ - public function getCoverImage() - { - return $this->coverImage; - } - - /** - * @return mixed - */ - public function getThumbnailImage() - { - return $this->thumbnailImage; - } - - /** - * @return array - */ - public function getMenuThumbnailImages() - { - return $this->menuThumbnailImages; - } - - /** - * @return bool - */ - public function isRootCategory() - { - return $this->isRootCategory; - } - - /** - * @return bool - */ - public function canContainMoreMenuThumbnails() - { - return count($this->getMenuThumbnailImages()) < count(MenuThumbnailId::ALLOWED_ID_VALUES); - } - - /** - * @return array - */ - public function getSubCategories() - { - return $this->subCategories; - } -} diff --git a/src/Core/Domain/Category/SeoSettings.php b/src/Core/Domain/Category/SeoSettings.php deleted file mode 100644 index 06abb13d..00000000 --- a/src/Core/Domain/Category/SeoSettings.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category; - -/** - * Defines settings for Category's SEO - */ -final class SeoSettings -{ - /** - * Maximum length of SEO title (value is constrained by database) - */ - const MAX_TITLE_LENGTH = 255; - - /** - * Recommended length of SEO title - */ - const RECOMMENDED_TITLE_LENGTH = 70; - - /** - * Maximum length of SEO description (value is constrained by database) - */ - const MAX_DESCRIPTION_LENGTH = 512; - - /** - * Recommended length of SEO description - */ - const RECOMMENDED_DESCRIPTION_LENGTH = 160; -} diff --git a/src/Core/Domain/Category/ValueObject/CategoryDeleteMode.php b/src/Core/Domain/Category/ValueObject/CategoryDeleteMode.php deleted file mode 100644 index 2caa469d..00000000 --- a/src/Core/Domain/Category/ValueObject/CategoryDeleteMode.php +++ /dev/null @@ -1,108 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryConstraintException; - -/** - * Class CategoryDeleteMode stores mode for category deletion. - */ -class CategoryDeleteMode -{ - /** - * Associate products with parent category and disable them. - */ - const ASSOCIATE_PRODUCTS_WITH_PARENT_AND_DISABLE = 'associate_and_disable'; - - /** - * Associate products with parent and do not change their status. - */ - const ASSOCIATE_PRODUCTS_WITH_PARENT_ONLY = 'associate_only'; - - /** - * Remove products that are associated only with category that is being deleted. - */ - const REMOVE_ASSOCIATED_PRODUCTS = 'remove_associated'; - - /** - * @internal - */ - const AVAILABLE_MODES = [ - self::ASSOCIATE_PRODUCTS_WITH_PARENT_AND_DISABLE, - self::ASSOCIATE_PRODUCTS_WITH_PARENT_ONLY, - self::REMOVE_ASSOCIATED_PRODUCTS, - ]; - - /** - * @var string - */ - private $mode; - - /** - * @param string $mode - * - * @throws CategoryConstraintException - */ - public function __construct($mode) - { - $this->setMode($mode); - } - - /** - * @param string $mode - * - * @throws CategoryConstraintException - */ - private function setMode($mode) - { - if (!in_array($mode, self::AVAILABLE_MODES)) { - throw new CategoryConstraintException(sprintf('Invalid Category delete mode %s supplied. Available delete modes are: "%s"', var_export($mode, true), implode(',', self::AVAILABLE_MODES)), CategoryConstraintException::INVALID_DELETE_MODE); - } - - $this->mode = $mode; - } - - /** - * Whether products associated with category should be removed. - * - * @return bool - */ - public function shouldRemoveProducts() - { - return self::REMOVE_ASSOCIATED_PRODUCTS === $this->mode; - } - - /** - * Whether products should be disabled when category is deleted. - * - * @return bool - */ - public function shouldDisableProducts() - { - return self::ASSOCIATE_PRODUCTS_WITH_PARENT_AND_DISABLE === $this->mode; - } -} diff --git a/src/Core/Domain/Category/ValueObject/CategoryId.php b/src/Core/Domain/Category/ValueObject/CategoryId.php deleted file mode 100644 index 7f665f71..00000000 --- a/src/Core/Domain/Category/ValueObject/CategoryId.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryException; - -/** - * Class CategoryId. - */ -class CategoryId -{ - /** - * @var int - */ - private $categoryId; - - /** - * @param int $categoryId - */ - public function __construct($categoryId) - { - $this->setCategoryId($categoryId); - } - - /** - * @return int - */ - public function getValue() - { - return $this->categoryId; - } - - /** - * @param CategoryId $categoryId - * - * @return bool - */ - public function isEqual(CategoryId $categoryId) - { - return $this->getValue() === $categoryId->getValue(); - } - - /** - * @param int $categoryId - */ - private function setCategoryId($categoryId) - { - if (!is_int($categoryId) || 0 >= $categoryId) { - throw new CategoryException(sprintf('Invalid Category id %s supplied', var_export($categoryId, true))); - } - - $this->categoryId = $categoryId; - } -} diff --git a/src/Core/Domain/Category/ValueObject/MenuThumbnailId.php b/src/Core/Domain/Category/ValueObject/MenuThumbnailId.php deleted file mode 100644 index 2e9a597a..00000000 --- a/src/Core/Domain/Category/ValueObject/MenuThumbnailId.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Category\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryException; - -/** - * Stores id for category's menu thumbnail image. - */ -class MenuThumbnailId -{ - /** - * @var array category is of having maximum of 3 menu thumbnails with defined Ids - */ - const ALLOWED_ID_VALUES = [0, 1, 2]; - - /** - * @var int - */ - private $menuThumbnailId; - - /** - * @param int $menuThumbnailId - */ - public function __construct($menuThumbnailId) - { - $this->assertMenuThumbnailIsWithinAllowedValueRange($menuThumbnailId); - - $this->menuThumbnailId = $menuThumbnailId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->menuThumbnailId; - } - - /** - * @param int $menuThumbnailId - */ - private function assertMenuThumbnailIsWithinAllowedValueRange($menuThumbnailId) - { - if (!is_int($menuThumbnailId) || !in_array($menuThumbnailId, self::ALLOWED_ID_VALUES)) { - throw new CategoryException(sprintf('Category menu thumbnail id "%s" invalid. Available values are: %s', var_export($menuThumbnailId, true), implode(',', self::ALLOWED_ID_VALUES))); - } - } -} diff --git a/src/Core/Domain/CmsPage/Command/AddCmsPageCommand.php b/src/Core/Domain/CmsPage/Command/AddCmsPageCommand.php deleted file mode 100644 index 14d11567..00000000 --- a/src/Core/Domain/CmsPage/Command/AddCmsPageCommand.php +++ /dev/null @@ -1,204 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Command; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Adds new cms page - */ -class AddCmsPageCommand -{ - /** - * @var CmsPageCategoryId - */ - private $cmsPageCategoryId; - - /** - * @var string[] - */ - private $localizedTitle; - - /** - * @var string[] - */ - private $localizedMetaTitle; - - /** - * @var string[] - */ - private $localizedMetaDescription; - - /** - * @var string[] - */ - private $LocalizedMetaKeyword; - - /** - * @var string[] - */ - private $localizedFriendlyUrl; - - /** - * @var string[] - */ - private $localizedContent; - - /** - * @var bool - */ - private $indexedForSearch; - - /** - * @var bool - */ - private $displayed; - - /** - * @var array - */ - private $shopAssociation; - - /** - * @param int $cmsPageCategoryId - * @param string[] $localizedTitle - * @param string[] $localizedMetaTitle - * @param string[] $localizedMetaDescription - * @param string[] $LocalizedMetaKeyword - * @param string[] $localizedFriendlyUrl - * @param string[] $localizedContent - * @param bool $indexedForSearch - * @param bool $displayed - * @param array $shopAssociation - * - * @throws CmsPageCategoryException - */ - public function __construct( - $cmsPageCategoryId, - array $localizedTitle, - array $localizedMetaTitle, - array $localizedMetaDescription, - array $LocalizedMetaKeyword, - array $localizedFriendlyUrl, - array $localizedContent, - $indexedForSearch, - $displayed, - array $shopAssociation - ) { - $this->cmsPageCategoryId = new CmsPageCategoryId($cmsPageCategoryId); - $this->localizedTitle = $localizedTitle; - $this->localizedMetaTitle = $localizedMetaTitle; - $this->localizedMetaDescription = $localizedMetaDescription; - $this->LocalizedMetaKeyword = $LocalizedMetaKeyword; - $this->localizedFriendlyUrl = $localizedFriendlyUrl; - $this->localizedContent = $localizedContent; - $this->indexedForSearch = $indexedForSearch; - $this->displayed = $displayed; - $this->shopAssociation = $shopAssociation; - } - - /** - * @return CmsPageCategoryId - */ - public function getCmsPageCategory() - { - return $this->cmsPageCategoryId; - } - - /** - * @return string[] - */ - public function getLocalizedTitle() - { - return $this->localizedTitle; - } - - /** - * @return string[] - */ - public function getLocalizedMetaTitle() - { - return $this->localizedMetaTitle; - } - - /** - * @return string[] - */ - public function getLocalizedMetaDescription() - { - return $this->localizedMetaDescription; - } - - /** - * @return string[] - */ - public function getLocalizedMetaKeyword() - { - return $this->LocalizedMetaKeyword; - } - - /** - * @return string[] - */ - public function getLocalizedFriendlyUrl() - { - return $this->localizedFriendlyUrl; - } - - /** - * @return string[] - */ - public function getLocalizedContent() - { - return $this->localizedContent; - } - - /** - * @return bool - */ - public function isIndexedForSearch() - { - return $this->indexedForSearch; - } - - /** - * @return bool - */ - public function isDisplayed() - { - return $this->displayed; - } - - /** - * @return array - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } -} diff --git a/src/Core/Domain/CmsPage/Command/BulkDeleteCmsPageCommand.php b/src/Core/Domain/CmsPage/Command/BulkDeleteCmsPageCommand.php deleted file mode 100644 index 0c3e0ca2..00000000 --- a/src/Core/Domain/CmsPage/Command/BulkDeleteCmsPageCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Command; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\ValueObject\CmsPageId; - -/** - * Deletes multiple cms pages according to given array. - */ -class BulkDeleteCmsPageCommand -{ - /** - * @var CmsPageId[] - */ - private $cmsPages; - - /** - * @param array $cmsPageIds - * - * @throws CmsPageException - */ - public function __construct(array $cmsPageIds) - { - $this->setCmsPages($cmsPageIds); - } - - /** - * @return CmsPageId[] - */ - public function getCmsPages() - { - return $this->cmsPages; - } - - /** - * @param array $cmsPageIds - * - * @throws CmsPageException - */ - private function setCmsPages(array $cmsPageIds) - { - foreach ($cmsPageIds as $cmsPageId) { - $this->cmsPages[] = new CmsPageId($cmsPageId); - } - } -} diff --git a/src/Core/Domain/CmsPage/Command/BulkDisableCmsPageCommand.php b/src/Core/Domain/CmsPage/Command/BulkDisableCmsPageCommand.php deleted file mode 100644 index e0899ea3..00000000 --- a/src/Core/Domain/CmsPage/Command/BulkDisableCmsPageCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Command; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\ValueObject\CmsPageId; - -/** - * Disables multiple cms pages. - */ -class BulkDisableCmsPageCommand -{ - /** - * @var CmsPageId[] - */ - private $cmsPages; - - /** - * @param array $cmsPageIds - * - * @throws CmsPageException - */ - public function __construct(array $cmsPageIds) - { - $this->setCmsPages($cmsPageIds); - } - - /** - * @return CmsPageId[] - */ - public function getCmsPages() - { - return $this->cmsPages; - } - - /** - * @param array $cmsPageIds - * - * @throws CmsPageException - */ - private function setCmsPages(array $cmsPageIds) - { - foreach ($cmsPageIds as $cmsPageId) { - $this->cmsPages[] = new CmsPageId($cmsPageId); - } - } -} diff --git a/src/Core/Domain/CmsPage/Command/BulkEnableCmsPageCommand.php b/src/Core/Domain/CmsPage/Command/BulkEnableCmsPageCommand.php deleted file mode 100644 index ce20f32e..00000000 --- a/src/Core/Domain/CmsPage/Command/BulkEnableCmsPageCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Command; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\ValueObject\CmsPageId; - -/** - * Enables multiple cms pages. - */ -class BulkEnableCmsPageCommand -{ - /** - * @var CmsPageId[] - */ - private $cmsPages; - - /** - * @param array $cmsPageIds - * - * @throws CmsPageException - */ - public function __construct(array $cmsPageIds) - { - $this->setCmsPages($cmsPageIds); - } - - /** - * @return CmsPageId[] - */ - public function getCmsPages() - { - return $this->cmsPages; - } - - /** - * @param array $cmsPageIds - * - * @throws CmsPageException - */ - private function setCmsPages(array $cmsPageIds) - { - foreach ($cmsPageIds as $cmsPageId) { - $this->cmsPages[] = new CmsPageId($cmsPageId); - } - } -} diff --git a/src/Core/Domain/CmsPage/Command/DeleteCmsPageCommand.php b/src/Core/Domain/CmsPage/Command/DeleteCmsPageCommand.php deleted file mode 100644 index 06e89b82..00000000 --- a/src/Core/Domain/CmsPage/Command/DeleteCmsPageCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Command; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\ValueObject\CmsPageId; - -/** - * Deletes given cms page. - */ -class DeleteCmsPageCommand -{ - /** - * @var CmsPageId - */ - private $cmsPageId; - - /** - * @param $cmsPageId - * - * @throws CmsPageException - */ - public function __construct($cmsPageId) - { - $this->cmsPageId = new CmsPageId($cmsPageId); - } - - /** - * @return CmsPageId - */ - public function getCmsPageId() - { - return $this->cmsPageId; - } -} diff --git a/src/Core/Domain/CmsPage/Command/EditCmsPageCommand.php b/src/Core/Domain/CmsPage/Command/EditCmsPageCommand.php deleted file mode 100644 index be58ed2a..00000000 --- a/src/Core/Domain/CmsPage/Command/EditCmsPageCommand.php +++ /dev/null @@ -1,313 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Command; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\ValueObject\CmsPageId; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Edits cms page - */ -class EditCmsPageCommand -{ - /** - * @var CmsPageId - */ - private $cmsPageId; - - /** - * @var CmsPageCategoryId|null - */ - private $cmsPageCategoryId; - - /** - * @var string[]|null - */ - private $localizedTitle; - - /** - * @var string[]|null - */ - private $localizedMetaTitle; - - /** - * @var string[]|null - */ - private $localizedMetaDescription; - - /** - * @var string[]|null - */ - private $LocalizedMetaKeyword; - - /** - * @var string[]|null - */ - private $localizedFriendlyUrl; - - /** - * @var string[]|null - */ - private $localizedContent; - - /** - * @var bool|null - */ - private $isIndexedForSearch; - - /** - * @var bool|null - */ - private $isDisplayed; - - /** - * @var array|null - */ - private $shopAssociation; - - /** - * @param int $cmsPageId - * - * @throws CmsPageException - */ - public function __construct($cmsPageId) - { - $this->cmsPageId = new CmsPageId($cmsPageId); - } - - /** - * @return CmsPageId - */ - public function getCmsPageId() - { - return $this->cmsPageId; - } - - /** - * @return CmsPageCategoryId|null - */ - public function getCmsPageCategoryId() - { - return $this->cmsPageCategoryId; - } - - /** - * @param int|null $cmsPageCategoryId - * - * @return self - * - * @throws CmsPageCategoryException - */ - public function setCmsPageCategoryId($cmsPageCategoryId) - { - $this->cmsPageCategoryId = new CmsPageCategoryId($cmsPageCategoryId); - - return $this; - } - - /** - * @return string[]|null - */ - public function getLocalizedTitle() - { - return $this->localizedTitle; - } - - /** - * @param string[]|null $localizedTitle - * - * @return self - */ - public function setLocalizedTitle(array $localizedTitle) - { - $this->localizedTitle = $localizedTitle; - - return $this; - } - - /** - * @return string[]|null - */ - public function getLocalizedMetaTitle() - { - return $this->localizedMetaTitle; - } - - /** - * @param string[]|null $localizedMetaTitle - * - * @return self - */ - public function setLocalizedMetaTitle(array $localizedMetaTitle) - { - $this->localizedMetaTitle = $localizedMetaTitle; - - return $this; - } - - /** - * @return string[]|null - */ - public function getLocalizedMetaDescription() - { - return $this->localizedMetaDescription; - } - - /** - * @param string[]|null $localizedMetaDescription - * - * @return self - */ - public function setLocalizedMetaDescription(array $localizedMetaDescription) - { - $this->localizedMetaDescription = $localizedMetaDescription; - - return $this; - } - - /** - * @return string[]|null - */ - public function getLocalizedMetaKeyword() - { - return $this->LocalizedMetaKeyword; - } - - /** - * @param string[]|null $LocalizedMetaKeyword - * - * @return self - */ - public function setLocalizedMetaKeyword(array $LocalizedMetaKeyword) - { - $this->LocalizedMetaKeyword = $LocalizedMetaKeyword; - - return $this; - } - - /** - * @return string[]|null - */ - public function getLocalizedFriendlyUrl() - { - return $this->localizedFriendlyUrl; - } - - /** - * @param string[]|null $localizedFriendlyUrl - * - * @return self - */ - public function setLocalizedFriendlyUrl(array $localizedFriendlyUrl) - { - $this->localizedFriendlyUrl = $localizedFriendlyUrl; - - return $this; - } - - /** - * @return string[]|null - */ - public function getLocalizedContent() - { - return $this->localizedContent; - } - - /** - * @param string[]|null $localizedContent - * - * @return self - */ - public function setLocalizedContent(array $localizedContent) - { - $this->localizedContent = $localizedContent; - - return $this; - } - - /** - * @return bool|null - */ - public function isIndexedForSearch() - { - return $this->isIndexedForSearch; - } - - /** - * @param bool|null $isIndexedForSearch - * - * @return self - */ - public function setIsIndexedForSearch($isIndexedForSearch) - { - $this->isIndexedForSearch = $isIndexedForSearch; - - return $this; - } - - /** - * @return bool|null - */ - public function isDisplayed() - { - return $this->isDisplayed; - } - - /** - * @param bool|null $isDisplayed - * - * @return self - */ - public function setIsDisplayed($isDisplayed) - { - $this->isDisplayed = $isDisplayed; - - return $this; - } - - /** - * @return array|null - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } - - /** - * @param array|null $shopAssociation - * - * @return self - */ - public function setShopAssociation(array $shopAssociation) - { - $this->shopAssociation = $shopAssociation; - - return $this; - } -} diff --git a/src/Core/Domain/CmsPage/Command/ToggleCmsPageStatusCommand.php b/src/Core/Domain/CmsPage/Command/ToggleCmsPageStatusCommand.php deleted file mode 100644 index f445ebc2..00000000 --- a/src/Core/Domain/CmsPage/Command/ToggleCmsPageStatusCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Command; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\ValueObject\CmsPageId; - -/** - * Changes the status of cms page. - */ -class ToggleCmsPageStatusCommand -{ - /** - * @var CmsPageId - */ - private $cmsPageId; - - /** - * @param int $cmsPageId - * - * @throws CmsPageException - */ - public function __construct($cmsPageId) - { - $this->cmsPageId = new CmsPageId($cmsPageId); - } - - /** - * @return CmsPageId - */ - public function getCmsPageId() - { - return $this->cmsPageId; - } -} diff --git a/src/Core/Domain/CmsPage/CommandHandler/AddCmsPageHandlerInterface.php b/src/Core/Domain/CmsPage/CommandHandler/AddCmsPageHandlerInterface.php deleted file mode 100644 index 38f0b2fb..00000000 --- a/src/Core/Domain/CmsPage/CommandHandler/AddCmsPageHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\AddCmsPageCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\ValueObject\CmsPageId; - -/** - * Interface for services that handles AddCmsPageCommand - */ -interface AddCmsPageHandlerInterface -{ - /** - * @param AddCmsPageCommand $command - * - * @return CmsPageId - */ - public function handle(AddCmsPageCommand $command); -} diff --git a/src/Core/Domain/CmsPage/CommandHandler/BulkDeleteCmsPageHandlerInterface.php b/src/Core/Domain/CmsPage/CommandHandler/BulkDeleteCmsPageHandlerInterface.php deleted file mode 100644 index ba9cdd70..00000000 --- a/src/Core/Domain/CmsPage/CommandHandler/BulkDeleteCmsPageHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\BulkDeleteCmsPageCommand; - -/** - * Defines contract for BulkDeleteCmsPageHandler. - */ -interface BulkDeleteCmsPageHandlerInterface -{ - /** - * @param BulkDeleteCmsPageCommand $command - */ - public function handle(BulkDeleteCmsPageCommand $command); -} diff --git a/src/Core/Domain/CmsPage/CommandHandler/BulkDisableCmsPageHandlerInterface.php b/src/Core/Domain/CmsPage/CommandHandler/BulkDisableCmsPageHandlerInterface.php deleted file mode 100644 index 79a23437..00000000 --- a/src/Core/Domain/CmsPage/CommandHandler/BulkDisableCmsPageHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\BulkDisableCmsPageCommand; - -/** - * Defines contract for BulkDisableCmsPageHandler. - */ -interface BulkDisableCmsPageHandlerInterface -{ - /** - * @param BulkDisableCmsPageCommand $command - */ - public function handle(BulkDisableCmsPageCommand $command); -} diff --git a/src/Core/Domain/CmsPage/CommandHandler/BulkEnableCmsPageHandlerInterface.php b/src/Core/Domain/CmsPage/CommandHandler/BulkEnableCmsPageHandlerInterface.php deleted file mode 100644 index b40f4b55..00000000 --- a/src/Core/Domain/CmsPage/CommandHandler/BulkEnableCmsPageHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\BulkEnableCmsPageCommand; - -/** - * Defines contract for BulkEnableCmsPageHandler. - */ -interface BulkEnableCmsPageHandlerInterface -{ - /** - * @param BulkEnableCmsPageCommand $command - */ - public function handle(BulkEnableCmsPageCommand $command); -} diff --git a/src/Core/Domain/CmsPage/CommandHandler/DeleteCmsPageHandlerInterface.php b/src/Core/Domain/CmsPage/CommandHandler/DeleteCmsPageHandlerInterface.php deleted file mode 100644 index f47e1740..00000000 --- a/src/Core/Domain/CmsPage/CommandHandler/DeleteCmsPageHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\DeleteCmsPageCommand; - -/** - * Defines contract for DeleteCmsPageHandler. - */ -interface DeleteCmsPageHandlerInterface -{ - /** - * @param DeleteCmsPageCommand $command - */ - public function handle(DeleteCmsPageCommand $command); -} diff --git a/src/Core/Domain/CmsPage/CommandHandler/EditCmsPageHandlerInterface.php b/src/Core/Domain/CmsPage/CommandHandler/EditCmsPageHandlerInterface.php deleted file mode 100644 index 76f611c3..00000000 --- a/src/Core/Domain/CmsPage/CommandHandler/EditCmsPageHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\EditCmsPageCommand; - -/** - * Defines contract for EditCmsPageHandler. - */ -interface EditCmsPageHandlerInterface -{ - /** - * @param EditCmsPageCommand $command - */ - public function handle(EditCmsPageCommand $command); -} diff --git a/src/Core/Domain/CmsPage/CommandHandler/ToggleCmsPageStatusHandlerInterface.php b/src/Core/Domain/CmsPage/CommandHandler/ToggleCmsPageStatusHandlerInterface.php deleted file mode 100644 index 824847f0..00000000 --- a/src/Core/Domain/CmsPage/CommandHandler/ToggleCmsPageStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\ToggleCmsPageStatusCommand; - -/** - * Defines contract for ToggleCmsPageStatusHandler. - */ -interface ToggleCmsPageStatusHandlerInterface -{ - /** - * @param ToggleCmsPageStatusCommand $command - */ - public function handle(ToggleCmsPageStatusCommand $command); -} diff --git a/src/Core/Domain/CmsPage/Exception/CannotAddCmsPageException.php b/src/Core/Domain/CmsPage/Exception/CannotAddCmsPageException.php deleted file mode 100644 index 981bb56c..00000000 --- a/src/Core/Domain/CmsPage/Exception/CannotAddCmsPageException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception; - -/** - * Thrown on failure when adding new cms page - */ -class CannotAddCmsPageException extends CmsPageException -{ -} diff --git a/src/Core/Domain/CmsPage/Exception/CannotDeleteCmsPageException.php b/src/Core/Domain/CmsPage/Exception/CannotDeleteCmsPageException.php deleted file mode 100644 index df9cedca..00000000 --- a/src/Core/Domain/CmsPage/Exception/CannotDeleteCmsPageException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception; - -/** - * Is thrown on failure when deleting cms page - */ -class CannotDeleteCmsPageException extends CmsPageException -{ - /** - * When fails to delete single cms page - */ - const FAILED_DELETE = 10; - - /** - * When fails to delete cms pages on bulk action - */ - const FAILED_BULK_DELETE = 20; -} diff --git a/src/Core/Domain/CmsPage/Exception/CannotDisableCmsPageException.php b/src/Core/Domain/CmsPage/Exception/CannotDisableCmsPageException.php deleted file mode 100644 index e41f8c9d..00000000 --- a/src/Core/Domain/CmsPage/Exception/CannotDisableCmsPageException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception; - -/** - * Is thrown when cms page cannot be disabled - */ -class CannotDisableCmsPageException extends CmsPageException -{ -} diff --git a/src/Core/Domain/CmsPage/Exception/CannotEditCmsPageException.php b/src/Core/Domain/CmsPage/Exception/CannotEditCmsPageException.php deleted file mode 100644 index b48f19dc..00000000 --- a/src/Core/Domain/CmsPage/Exception/CannotEditCmsPageException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception; - -/** - * Is thrown when cms page cannot be edited - */ -class CannotEditCmsPageException extends CmsPageException -{ -} diff --git a/src/Core/Domain/CmsPage/Exception/CannotEnableCmsPageException.php b/src/Core/Domain/CmsPage/Exception/CannotEnableCmsPageException.php deleted file mode 100644 index 79e41154..00000000 --- a/src/Core/Domain/CmsPage/Exception/CannotEnableCmsPageException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception; - -/** - * Is thrown when cms page cannot be enabled - */ -class CannotEnableCmsPageException extends CmsPageException -{ -} diff --git a/src/Core/Domain/CmsPage/Exception/CannotToggleCmsPageException.php b/src/Core/Domain/CmsPage/Exception/CannotToggleCmsPageException.php deleted file mode 100644 index ffd81e0d..00000000 --- a/src/Core/Domain/CmsPage/Exception/CannotToggleCmsPageException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception; - -/** - * Is thrown when cms page cannot be enabled or disabled in toggling action - */ -class CannotToggleCmsPageException extends CmsPageException -{ -} diff --git a/src/Core/Domain/CmsPage/Exception/CmsPageException.php b/src/Core/Domain/CmsPage/Exception/CmsPageException.php deleted file mode 100644 index 9b521657..00000000 --- a/src/Core/Domain/CmsPage/Exception/CmsPageException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for cms page sub-domain - */ -class CmsPageException extends DomainException -{ -} diff --git a/src/Core/Domain/CmsPage/Exception/CmsPageNotFoundException.php b/src/Core/Domain/CmsPage/Exception/CmsPageNotFoundException.php deleted file mode 100644 index 6994df9c..00000000 --- a/src/Core/Domain/CmsPage/Exception/CmsPageNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception; - -/** - * Is thrown when required cms page is not found - */ -class CmsPageNotFoundException extends CmsPageException -{ -} diff --git a/src/Core/Domain/CmsPage/Query/GetCmsCategoryIdForRedirection.php b/src/Core/Domain/CmsPage/Query/GetCmsCategoryIdForRedirection.php deleted file mode 100644 index ca035759..00000000 --- a/src/Core/Domain/CmsPage/Query/GetCmsCategoryIdForRedirection.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Query; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\ValueObject\CmsPageId; - -/** - * This class is used for getting the id which is used later on to redirect to the right page after certain controller - * actions. - */ -class GetCmsCategoryIdForRedirection -{ - /** - * @var CmsPageId - */ - private $cmsPageId; - - /** - * @param $cmsPageId - * - * @throws CmsPageException - */ - public function __construct($cmsPageId) - { - $this->cmsPageId = new CmsPageId($cmsPageId); - } - - /** - * @return CmsPageId - */ - public function getCmsPageId() - { - return $this->cmsPageId; - } -} diff --git a/src/Core/Domain/CmsPage/Query/GetCmsPageForEditing.php b/src/Core/Domain/CmsPage/Query/GetCmsPageForEditing.php deleted file mode 100644 index 3495ac25..00000000 --- a/src/Core/Domain/CmsPage/Query/GetCmsPageForEditing.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\Query; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\ValueObject\CmsPageId; - -/** - * Gets object which transfers cms page data for editing - */ -class GetCmsPageForEditing -{ - /** - * @var CmsPageId - */ - private $cmsPageId; - - /** - * @param int $cmsPageId - * - * @throws CmsPageException - */ - public function __construct($cmsPageId) - { - $this->cmsPageId = new CmsPageId($cmsPageId); - } - - /** - * @return CmsPageId - */ - public function getCmsPageId() - { - return $this->cmsPageId; - } -} diff --git a/src/Core/Domain/CmsPage/QueryHandler/GetCmsCategoryIdHandlerForRedirectionInterface.php b/src/Core/Domain/CmsPage/QueryHandler/GetCmsCategoryIdHandlerForRedirectionInterface.php deleted file mode 100644 index 04e9629d..00000000 --- a/src/Core/Domain/CmsPage/QueryHandler/GetCmsCategoryIdHandlerForRedirectionInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Query\GetCmsCategoryIdForRedirection; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Defines contract for GetCmsCategoryIdHandlerForRedirection. - */ -interface GetCmsCategoryIdHandlerForRedirectionInterface -{ - /** - * @param GetCmsCategoryIdForRedirection $query - * - * @return CmsPageCategoryId - */ - public function handle(GetCmsCategoryIdForRedirection $query); -} diff --git a/src/Core/Domain/CmsPage/QueryHandler/GetCmsPageForEditingHandlerInterface.php b/src/Core/Domain/CmsPage/QueryHandler/GetCmsPageForEditingHandlerInterface.php deleted file mode 100644 index 744d5df8..00000000 --- a/src/Core/Domain/CmsPage/QueryHandler/GetCmsPageForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Query\GetCmsPageForEditing; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\QueryResult\EditableCmsPage; - -/** - * Interface for service that handles getCmsPageForEditing query - */ -interface GetCmsPageForEditingHandlerInterface -{ - /** - * @param GetCmsPageForEditing $query - * - * @return EditableCmsPage - */ - public function handle(GetCmsPageForEditing $query); -} diff --git a/src/Core/Domain/CmsPage/QueryResult/EditableCmsPage.php b/src/Core/Domain/CmsPage/QueryResult/EditableCmsPage.php deleted file mode 100644 index 4df3212e..00000000 --- a/src/Core/Domain/CmsPage/QueryResult/EditableCmsPage.php +++ /dev/null @@ -1,241 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\ValueObject\CmsPageId; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Transfers cms page data for editing - */ -class EditableCmsPage -{ - /** - * @var CmsPageId - */ - private $cmsPageId; - - /** - * @var CmsPageCategoryId - */ - private $cmsPageCategoryId; - - /** - * @var string[] - */ - private $localizedTitle; - - /** - * @var string[] - */ - private $localizedMetaTitle; - - /** - * @var string[] - */ - private $localizedMetaDescription; - - /** - * @var string[] - */ - private $localizedMetaKeyword; - - /** - * @var string[] - */ - private $localizedFriendlyUrl; - - /** - * @var string[] - */ - private $localizedContent; - - /** - * @var bool - */ - private $indexedForSearch; - - /** - * @var bool - */ - private $displayed; - - /** - * @var array - */ - private $shopAssociation; - - /** - * Url for opening FO page on save and preview action - * - * @var string - */ - private $previewUrl; - - /** - * @param int $cmsPageId - * @param int $cmsPageCategoryId - * @param string[] $localizedTitle - * @param string[] $localizedMetaTitle - * @param string[] $localizedMetaDescription - * @param string[] $localizedMetaKeyword - * @param string[] $localizedFriendlyUrl - * @param string[] $localizedContent - * @param bool $indexedForSearch - * @param bool $displayed - * @param array $shopAssociation - * @param string $previewUrl - * - * @throws CmsPageCategoryException - * @throws CmsPageException - */ - public function __construct( - $cmsPageId, - $cmsPageCategoryId, - array $localizedTitle, - array $localizedMetaTitle, - array $localizedMetaDescription, - array $localizedMetaKeyword, - array $localizedFriendlyUrl, - array $localizedContent, - $indexedForSearch, - $displayed, - array $shopAssociation, - $previewUrl - ) { - $this->cmsPageId = new CmsPageId($cmsPageId); - $this->cmsPageCategoryId = new CmsPageCategoryId($cmsPageCategoryId); - $this->localizedTitle = $localizedTitle; - $this->localizedMetaTitle = $localizedMetaTitle; - $this->localizedMetaDescription = $localizedMetaDescription; - $this->localizedMetaKeyword = $localizedMetaKeyword; - $this->localizedFriendlyUrl = $localizedFriendlyUrl; - $this->localizedContent = $localizedContent; - $this->indexedForSearch = $indexedForSearch; - $this->displayed = $displayed; - $this->shopAssociation = $shopAssociation; - $this->previewUrl = $previewUrl; - } - - /** - * @return CmsPageId - */ - public function getCmsPageId() - { - return $this->cmsPageId; - } - - /** - * @return CmsPageCategoryId - */ - public function getCmsPageCategoryId() - { - return $this->cmsPageCategoryId; - } - - /** - * @return string[] - */ - public function getLocalizedTitle() - { - return $this->localizedTitle; - } - - /** - * @return string[] - */ - public function getLocalizedMetaTitle() - { - return $this->localizedMetaTitle; - } - - /** - * @return string[] - */ - public function getLocalizedMetaDescription() - { - return $this->localizedMetaDescription; - } - - /** - * @return string[] - */ - public function getLocalizedMetaKeyword() - { - return $this->localizedMetaKeyword; - } - - /** - * @return string[] - */ - public function getLocalizedFriendlyUrl() - { - return $this->localizedFriendlyUrl; - } - - /** - * @return string[] - */ - public function getLocalizedContent() - { - return $this->localizedContent; - } - - /** - * @return bool - */ - public function isIndexedForSearch() - { - return $this->indexedForSearch; - } - - /** - * @return bool - */ - public function isDisplayed() - { - return $this->displayed; - } - - /** - * @return array - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } - - /** - * @return string - */ - public function getPreviewUrl() - { - return $this->previewUrl; - } -} diff --git a/src/Core/Domain/CmsPage/ValueObject/CmsPageId.php b/src/Core/Domain/CmsPage/ValueObject/CmsPageId.php deleted file mode 100644 index d2944d90..00000000 --- a/src/Core/Domain/CmsPage/ValueObject/CmsPageId.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPage\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; - -/** - * Class which holds the cms page id value. - */ -class CmsPageId -{ - /** - * @var int - */ - private $cmsPageId; - - /** - * @param int $cmsPageId - * - * @throws CmsPageException - */ - public function __construct($cmsPageId) - { - $this->assertIsIntegerGreaterThanZero($cmsPageId); - $this->cmsPageId = $cmsPageId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->cmsPageId; - } - - /** - * Validates that the value is integer and is greater than zero. - * - * @param int $cmsPageId - * - * @throws CmsPageException - */ - private function assertIsIntegerGreaterThanZero($cmsPageId) - { - if (!is_int($cmsPageId) || 0 >= $cmsPageId) { - throw new CmsPageException(sprintf('Invalid cms page id %s supplied', var_export($cmsPageId, true))); - } - } -} diff --git a/src/Core/Domain/CmsPageCategory/Command/AbstractBulkCmsPageCategoryCommand.php b/src/Core/Domain/CmsPageCategory/Command/AbstractBulkCmsPageCategoryCommand.php deleted file mode 100644 index e1de1468..00000000 --- a/src/Core/Domain/CmsPageCategory/Command/AbstractBulkCmsPageCategoryCommand.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command; - -/** - * Class AbstractBulkCmsPageCategoryCommand is responsible for providing shared logic between all bulk actions - * in cms page category listing. - */ -abstract class AbstractBulkCmsPageCategoryCommand -{ - /** - * @param array $ids - * - * @return bool - */ - protected function assertIsEmptyOrContainsNonIntegerValues(array $ids) - { - return empty($ids) || $ids !== array_filter($ids, 'is_int'); - } -} diff --git a/src/Core/Domain/CmsPageCategory/Command/AbstractCmsPageCategoryCommand.php b/src/Core/Domain/CmsPageCategory/Command/AbstractCmsPageCategoryCommand.php deleted file mode 100644 index b091d1d5..00000000 --- a/src/Core/Domain/CmsPageCategory/Command/AbstractCmsPageCategoryCommand.php +++ /dev/null @@ -1,112 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryConstraintException; - -/** - * Class AbstractCmsPageCategoryCommand - */ -abstract class AbstractCmsPageCategoryCommand -{ - const CATEGORY_NAME_REGEX_PATTERN = '/^[^<>;=#{}]*$/u'; - const GENERIC_NAME_REGEX_PATTERN = '/^[^<>={}]*$/u'; - - /** - * Checks if given names matches pattern. - * - * @param array $names - * - * @throws CmsPageCategoryConstraintException - */ - protected function assertCategoryName(array $names) - { - foreach ($names as $name) { - if (!preg_match(self::CATEGORY_NAME_REGEX_PATTERN, $name)) { - throw new CmsPageCategoryConstraintException(sprintf('Given category name "%s" does not match pattern "%s"', $name, self::CATEGORY_NAME_REGEX_PATTERN), CmsPageCategoryConstraintException::INVALID_CATEGORY_NAME); - } - } - } - - /** - * @param array $localisedMetaTitles - * - * @throws CmsPageCategoryConstraintException - */ - protected function assertIsGenericNameForMetaTitle(array $localisedMetaTitles) - { - $assertionResult = $this->assertIsGenericName($localisedMetaTitles); - - if (true !== $assertionResult) { - throw new CmsPageCategoryConstraintException(sprintf('Given meta title "%s" does not match pattern "%s"', $assertionResult, self::GENERIC_NAME_REGEX_PATTERN), CmsPageCategoryConstraintException::INVALID_META_TITLE); - } - } - - /** - * @param array $localisedMetaDescription - * - * @throws CmsPageCategoryConstraintException - */ - protected function assertIsGenericNameForMetaDescription(array $localisedMetaDescription) - { - $assertionResult = $this->assertIsGenericName($localisedMetaDescription); - - if (true !== $assertionResult) { - throw new CmsPageCategoryConstraintException(sprintf('Given meta description "%s" does not match pattern "%s"', $assertionResult, self::GENERIC_NAME_REGEX_PATTERN), CmsPageCategoryConstraintException::INVALID_META_DESCRIPTION); - } - } - - /** - * @param array $localisedMetaKeywords - * - * @throws CmsPageCategoryConstraintException - */ - protected function assertIsGenericNameForMetaKeywords(array $localisedMetaKeywords) - { - $assertionResult = $this->assertIsGenericName($localisedMetaKeywords); - - if (true !== $assertionResult) { - throw new CmsPageCategoryConstraintException(sprintf('Given meta keyword "%s" does not match pattern "%s"', $assertionResult, self::GENERIC_NAME_REGEX_PATTERN), CmsPageCategoryConstraintException::INVALID_META_KEYWORDS); - } - } - - /** - * @param array $localisedNames - * - * @return bool|string - */ - private function assertIsGenericName(array $localisedNames) - { - foreach ($localisedNames as $localisedName) { - if (!preg_match(self::GENERIC_NAME_REGEX_PATTERN, $localisedName)) { - return $localisedName; - } - } - - return true; - } -} diff --git a/src/Core/Domain/CmsPageCategory/Command/AddCmsPageCategoryCommand.php b/src/Core/Domain/CmsPageCategory/Command/AddCmsPageCategoryCommand.php deleted file mode 100644 index 34f49f08..00000000 --- a/src/Core/Domain/CmsPageCategory/Command/AddCmsPageCategoryCommand.php +++ /dev/null @@ -1,245 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Class AddCmsPageCategoryCommand is responsible for adding cms page category. - */ -class AddCmsPageCategoryCommand extends AbstractCmsPageCategoryCommand -{ - /** - * @var array - */ - private $localisedName; - - /** - * @var array - */ - private $localisedFriendlyUrl; - - /** - * @var CmsPageCategoryId - */ - private $parentId; - - /** - * @var bool - */ - private $isDisplayed; - - /** - * @var string[] - */ - private $localisedDescription; - - /** - * @var string[] - */ - private $localisedMetaTitle; - - /** - * @var string[] - */ - private $localisedMetaDescription; - - /** - * @var string[] - */ - private $localisedMetaKeywords; - - /** - * @var int[] - */ - private $shopAssociation; - - /** - * @param array $localisedName - * @param array $localisedFriendlyUrl - * @param int $parentId - * @param bool $isDisplayed - * - * @throws CmsPageCategoryException - */ - public function __construct( - array $localisedName, - array $localisedFriendlyUrl, - $parentId, - $isDisplayed - ) { - $this->assertCategoryName($localisedName); - - $this->localisedName = $localisedName; - $this->localisedFriendlyUrl = $localisedFriendlyUrl; - $this->parentId = new CmsPageCategoryId($parentId); - $this->isDisplayed = $isDisplayed; - } - - /** - * @return array - */ - public function getLocalisedName() - { - return $this->localisedName; - } - - /** - * @return array - */ - public function getLocalisedFriendlyUrl() - { - return $this->localisedFriendlyUrl; - } - - /** - * @return CmsPageCategoryId - */ - public function getParentId() - { - return $this->parentId; - } - - /** - * @return bool - */ - public function isDisplayed() - { - return $this->isDisplayed; - } - - /** - * @return string[] - */ - public function getLocalisedDescription() - { - return $this->localisedDescription; - } - - /** - * @param string[] $localisedDescription - * - * @return self - */ - public function setLocalisedDescription(array $localisedDescription) - { - $this->localisedDescription = $localisedDescription; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalisedMetaTitle() - { - return $this->localisedMetaTitle; - } - - /** - * @param string[] $localisedMetaTitle - * - * @return self - * - * @throws CmsPageCategoryConstraintException - */ - public function setLocalisedMetaTitle(array $localisedMetaTitle) - { - $this->assertIsGenericNameForMetaTitle($localisedMetaTitle); - $this->localisedMetaTitle = $localisedMetaTitle; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalisedMetaDescription() - { - return $this->localisedMetaDescription; - } - - /** - * @param string[] $localisedMetaDescription - * - * @return self - * - * @throws CmsPageCategoryConstraintException - */ - public function setLocalisedMetaDescription(array $localisedMetaDescription) - { - $this->assertIsGenericNameForMetaDescription($localisedMetaDescription); - $this->localisedMetaDescription = $localisedMetaDescription; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalisedMetaKeywords() - { - return $this->localisedMetaKeywords; - } - - /** - * @param string[] $localisedMetaKeywords - * - * @return self - * - * @throws CmsPageCategoryConstraintException - */ - public function setLocalisedMetaKeywords(array $localisedMetaKeywords) - { - $this->assertIsGenericNameForMetaKeywords($localisedMetaKeywords); - $this->localisedMetaKeywords = $localisedMetaKeywords; - - return $this; - } - - /** - * @return int[] - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } - - /** - * @param int[] $shopAssociation - * - * @return self - */ - public function setShopAssociation(array $shopAssociation) - { - $this->shopAssociation = $shopAssociation; - - return $this; - } -} diff --git a/src/Core/Domain/CmsPageCategory/Command/BulkDeleteCmsPageCategoryCommand.php b/src/Core/Domain/CmsPageCategory/Command/BulkDeleteCmsPageCategoryCommand.php deleted file mode 100644 index 97512184..00000000 --- a/src/Core/Domain/CmsPageCategory/Command/BulkDeleteCmsPageCategoryCommand.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Class BulkDeleteCmsPageCategoryCommand is responsible for deleting multiple cms page categories. - */ -class BulkDeleteCmsPageCategoryCommand extends AbstractBulkCmsPageCategoryCommand -{ - /** - * @var CmsPageCategoryId[] - */ - private $cmsPageCategoryIds; - - /** - * @param int[] $cmsPageCategoryIds - * - * @throws CmsPageCategoryException - */ - public function __construct(array $cmsPageCategoryIds) - { - if ($this->assertIsEmptyOrContainsNonIntegerValues($cmsPageCategoryIds)) { - throw new CmsPageCategoryConstraintException(sprintf('Missing cms page category data or array %s contains non integer values for bulk deleting', var_export($cmsPageCategoryIds, true)), CmsPageCategoryConstraintException::INVALID_BULK_DATA); - } - - $this->setCmsPageCategoryIds($cmsPageCategoryIds); - } - - /** - * @return CmsPageCategoryId[] - */ - public function getCmsPageCategoryIds() - { - return $this->cmsPageCategoryIds; - } - - /** - * @param int[] $cmsPageCategoryIds - * - * @throws CmsPageCategoryException - */ - private function setCmsPageCategoryIds(array $cmsPageCategoryIds) - { - foreach ($cmsPageCategoryIds as $id) { - $this->cmsPageCategoryIds[] = new CmsPageCategoryId($id); - } - } -} diff --git a/src/Core/Domain/CmsPageCategory/Command/BulkDisableCmsPageCategoryCommand.php b/src/Core/Domain/CmsPageCategory/Command/BulkDisableCmsPageCategoryCommand.php deleted file mode 100644 index cd6f1604..00000000 --- a/src/Core/Domain/CmsPageCategory/Command/BulkDisableCmsPageCategoryCommand.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Class BulkDisableCmsPageCategoryCommand is responsible for disabling cms category pages. - */ -class BulkDisableCmsPageCategoryCommand extends AbstractBulkCmsPageCategoryCommand -{ - /** - * @var CmsPageCategoryId[] - */ - private $cmsPageCategoryIds; - - /** - * @param int[] $cmsPageCategoryIds - * - * @throws CmsPageCategoryConstraintException - * @throws CmsPageCategoryException - */ - public function __construct(array $cmsPageCategoryIds) - { - if ($this->assertIsEmptyOrContainsNonIntegerValues($cmsPageCategoryIds)) { - throw new CmsPageCategoryConstraintException(sprintf('Missing cms page category data or array %s contains non integer values for bulk disabling', var_export($cmsPageCategoryIds, true)), CmsPageCategoryConstraintException::INVALID_BULK_DATA); - } - - $this->setCmsPageCategoryIds($cmsPageCategoryIds); - } - - /** - * @return CmsPageCategoryId[] - */ - public function getCmsPageCategoryIds() - { - return $this->cmsPageCategoryIds; - } - - /** - * @param int[] $cmsPageCategoryIds - * - * @throws CmsPageCategoryException - */ - private function setCmsPageCategoryIds(array $cmsPageCategoryIds) - { - foreach ($cmsPageCategoryIds as $id) { - $this->cmsPageCategoryIds[] = new CmsPageCategoryId($id); - } - } -} diff --git a/src/Core/Domain/CmsPageCategory/Command/BulkEnableCmsPageCategoryCommand.php b/src/Core/Domain/CmsPageCategory/Command/BulkEnableCmsPageCategoryCommand.php deleted file mode 100644 index 1241e802..00000000 --- a/src/Core/Domain/CmsPageCategory/Command/BulkEnableCmsPageCategoryCommand.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Class BulkEnableCmsPageCategoryCommand is responsible for enabling cms category pages. - */ -class BulkEnableCmsPageCategoryCommand extends AbstractBulkCmsPageCategoryCommand -{ - /** - * @var CmsPageCategoryId[] - */ - private $cmsPageCategoryIds; - - /** - * @param int[] $cmsPageCategoryIds - * - * @throws CmsPageCategoryException - */ - public function __construct(array $cmsPageCategoryIds) - { - if ($this->assertIsEmptyOrContainsNonIntegerValues($cmsPageCategoryIds)) { - throw new CmsPageCategoryConstraintException(sprintf('Missing cms page category data or array %s contains non integer values for bulk enabling', var_export($cmsPageCategoryIds, true)), CmsPageCategoryConstraintException::INVALID_BULK_DATA); - } - - $this->setCmsPageCategoryIds($cmsPageCategoryIds); - } - - /** - * @return CmsPageCategoryId[] - */ - public function getCmsPageCategoryIds() - { - return $this->cmsPageCategoryIds; - } - - /** - * @param int[] $cmsPageCategoryIds - * - * @throws CmsPageCategoryException - */ - private function setCmsPageCategoryIds(array $cmsPageCategoryIds) - { - foreach ($cmsPageCategoryIds as $id) { - $this->cmsPageCategoryIds[] = new CmsPageCategoryId($id); - } - } -} diff --git a/src/Core/Domain/CmsPageCategory/Command/DeleteCmsPageCategoryCommand.php b/src/Core/Domain/CmsPageCategory/Command/DeleteCmsPageCategoryCommand.php deleted file mode 100644 index 59f4aad5..00000000 --- a/src/Core/Domain/CmsPageCategory/Command/DeleteCmsPageCategoryCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Class DeleteCmsPageCategoryCommand is responsible for deleting cms page category. - */ -class DeleteCmsPageCategoryCommand -{ - /** - * @var CmsPageCategoryId - */ - private $cmsPageCategoryId; - - /** - * @param int $cmsPageCategoryId - * - * @throws CmsPageCategoryException - */ - public function __construct($cmsPageCategoryId) - { - $this->cmsPageCategoryId = new CmsPageCategoryId($cmsPageCategoryId); - } - - /** - * @return CmsPageCategoryId - */ - public function getCmsPageCategoryId() - { - return $this->cmsPageCategoryId; - } -} diff --git a/src/Core/Domain/CmsPageCategory/Command/EditCmsPageCategoryCommand.php b/src/Core/Domain/CmsPageCategory/Command/EditCmsPageCategoryCommand.php deleted file mode 100644 index 0025d975..00000000 --- a/src/Core/Domain/CmsPageCategory/Command/EditCmsPageCategoryCommand.php +++ /dev/null @@ -1,299 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Edits cms page category. - */ -class EditCmsPageCategoryCommand extends AbstractCmsPageCategoryCommand -{ - /** - * @var CmsPageCategoryId - */ - private $cmsPageCategoryId; - - /** - * @var array - */ - private $localisedName; - - /** - * @var array - */ - private $localisedFriendlyUrl; - - /** - * @var CmsPageCategoryId - */ - private $parentId; - - /** - * @var bool - */ - private $isDisplayed; - - /** - * @var string[] - */ - private $localisedDescription; - - /** - * @var string[] - */ - private $localisedMetaTitle; - - /** - * @var string[] - */ - private $localisedMetaDescription; - - /** - * @var string[] - */ - private $localisedMetaKeywords; - - /** - * @var int[] - */ - private $shopAssociation; - - /** - * @param int $cmsPageCategoryId - * - * @throws CmsPageCategoryException - */ - public function __construct($cmsPageCategoryId) - { - $this->cmsPageCategoryId = new CmsPageCategoryId($cmsPageCategoryId); - } - - /** - * @return CmsPageCategoryId - */ - public function getCmsPageCategoryId() - { - return $this->cmsPageCategoryId; - } - - /** - * @return array - */ - public function getLocalisedName() - { - return $this->localisedName; - } - - /** - * @param array $localisedName - * - * @return self - * - * @throws CmsPageCategoryConstraintException - */ - public function setLocalisedName(array $localisedName) - { - $this->assertCategoryName($localisedName); - $this->localisedName = $localisedName; - - return $this; - } - - /** - * @return array - */ - public function getLocalisedFriendlyUrl() - { - return $this->localisedFriendlyUrl; - } - - /** - * @param array $localisedFriendlyUrl - * - * @return self - */ - public function setLocalisedFriendlyUrl(array $localisedFriendlyUrl) - { - $this->localisedFriendlyUrl = $localisedFriendlyUrl; - - return $this; - } - - /** - * @return CmsPageCategoryId - */ - public function getParentId() - { - return $this->parentId; - } - - /** - * @param int $parentId - * - * @return self - * - * @throws CmsPageCategoryException - */ - public function setParentId($parentId) - { - $this->parentId = new CmsPageCategoryId($parentId); - - return $this; - } - - /** - * @return bool - */ - public function isDisplayed() - { - return $this->isDisplayed; - } - - /** - * @param bool $isDisplayed - * - * @return self - */ - public function setIsDisplayed($isDisplayed) - { - $this->isDisplayed = $isDisplayed; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalisedDescription() - { - return $this->localisedDescription; - } - - /** - * @param string[] $localisedDescription - * - * @return self - */ - public function setLocalisedDescription(array $localisedDescription) - { - $this->localisedDescription = $localisedDescription; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalisedMetaTitle() - { - return $this->localisedMetaTitle; - } - - /** - * @param string[] $localisedMetaTitle - * - * @return self - * - * @throws CmsPageCategoryConstraintException - */ - public function setLocalisedMetaTitle(array $localisedMetaTitle) - { - $this->assertIsGenericNameForMetaTitle($localisedMetaTitle); - $this->localisedMetaTitle = $localisedMetaTitle; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalisedMetaDescription() - { - return $this->localisedMetaDescription; - } - - /** - * @param string[] $localisedMetaDescription - * - * @return self - * - * @throws CmsPageCategoryConstraintException - */ - public function setLocalisedMetaDescription(array $localisedMetaDescription) - { - $this->assertIsGenericNameForMetaDescription($localisedMetaDescription); - $this->localisedMetaDescription = $localisedMetaDescription; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalisedMetaKeywords() - { - return $this->localisedMetaKeywords; - } - - /** - * @param string[] $localisedMetaKeywords - * - * @return self - * - * @throws CmsPageCategoryConstraintException - */ - public function setLocalisedMetaKeywords(array $localisedMetaKeywords) - { - $this->assertIsGenericNameForMetaKeywords($localisedMetaKeywords); - $this->localisedMetaKeywords = $localisedMetaKeywords; - - return $this; - } - - /** - * @return int[] - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } - - /** - * @param int[] $shopAssociation - * - * @return self - */ - public function setShopAssociation(array $shopAssociation) - { - $this->shopAssociation = $shopAssociation; - - return $this; - } -} diff --git a/src/Core/Domain/CmsPageCategory/Command/ToggleCmsPageCategoryStatusCommand.php b/src/Core/Domain/CmsPageCategory/Command/ToggleCmsPageCategoryStatusCommand.php deleted file mode 100644 index 7abba327..00000000 --- a/src/Core/Domain/CmsPageCategory/Command/ToggleCmsPageCategoryStatusCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Class ToggleCmsPageCategoryStatusCommand is responsible for turning on and off cms page category status. - */ -class ToggleCmsPageCategoryStatusCommand -{ - /** - * @var CmsPageCategoryId - */ - private $cmsPageCategoryId; - - /** - * @param int $cmsPageCategoryId - * - * @throws CmsPageCategoryException - */ - public function __construct($cmsPageCategoryId) - { - $this->cmsPageCategoryId = new CmsPageCategoryId($cmsPageCategoryId); - } - - /** - * @return CmsPageCategoryId - */ - public function getCmsPageCategoryId() - { - return $this->cmsPageCategoryId; - } -} diff --git a/src/Core/Domain/CmsPageCategory/CommandHandler/AddCmsPageCategoryHandlerInterface.php b/src/Core/Domain/CmsPageCategory/CommandHandler/AddCmsPageCategoryHandlerInterface.php deleted file mode 100644 index 3139179c..00000000 --- a/src/Core/Domain/CmsPageCategory/CommandHandler/AddCmsPageCategoryHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\AddCmsPageCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Interface AddCmsPageCategoryHandlerInterface defines contract for AddCmsPageCategoryHandler. - */ -interface AddCmsPageCategoryHandlerInterface -{ - /** - * @param AddCmsPageCategoryCommand $command - * - * @return CmsPageCategoryId - */ - public function handle(AddCmsPageCategoryCommand $command); -} diff --git a/src/Core/Domain/CmsPageCategory/CommandHandler/BulkDeleteCmsPageCategoryHandlerInterface.php b/src/Core/Domain/CmsPageCategory/CommandHandler/BulkDeleteCmsPageCategoryHandlerInterface.php deleted file mode 100644 index a100084a..00000000 --- a/src/Core/Domain/CmsPageCategory/CommandHandler/BulkDeleteCmsPageCategoryHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\BulkDeleteCmsPageCategoryCommand; - -/** - * Interface BulkDeleteCmsPageCategoryHandlerInterface defines contract for BulkDeleteCmsPageCategoryHandler. - */ -interface BulkDeleteCmsPageCategoryHandlerInterface -{ - /** - * @param BulkDeleteCmsPageCategoryCommand $command - */ - public function handle(BulkDeleteCmsPageCategoryCommand $command); -} diff --git a/src/Core/Domain/CmsPageCategory/CommandHandler/BulkDisableCmsPageCategoryHandlerInterface.php b/src/Core/Domain/CmsPageCategory/CommandHandler/BulkDisableCmsPageCategoryHandlerInterface.php deleted file mode 100644 index c20a3549..00000000 --- a/src/Core/Domain/CmsPageCategory/CommandHandler/BulkDisableCmsPageCategoryHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\BulkDisableCmsPageCategoryCommand; - -/** - * Interface BulkDisableCmsPageCategoryHandlerInterface defines contract for BulkDisableCmsPageCategoryHandler. - */ -interface BulkDisableCmsPageCategoryHandlerInterface -{ - /** - * @param BulkDisableCmsPageCategoryCommand $command - */ - public function handle(BulkDisableCmsPageCategoryCommand $command); -} diff --git a/src/Core/Domain/CmsPageCategory/CommandHandler/BulkEnableCmsPageCategoryHandlerInterface.php b/src/Core/Domain/CmsPageCategory/CommandHandler/BulkEnableCmsPageCategoryHandlerInterface.php deleted file mode 100644 index 49a087c1..00000000 --- a/src/Core/Domain/CmsPageCategory/CommandHandler/BulkEnableCmsPageCategoryHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\BulkEnableCmsPageCategoryCommand; - -/** - * Interface BulkEnableCmsPageCategoryHandlerInterface defines contract for BulkEnableCmsPageCategoryHandler. - */ -interface BulkEnableCmsPageCategoryHandlerInterface -{ - /** - * @param BulkEnableCmsPageCategoryCommand $command - */ - public function handle(BulkEnableCmsPageCategoryCommand $command); -} diff --git a/src/Core/Domain/CmsPageCategory/CommandHandler/DeleteCmsPageCategoryHandlerInterface.php b/src/Core/Domain/CmsPageCategory/CommandHandler/DeleteCmsPageCategoryHandlerInterface.php deleted file mode 100644 index 1c5c7968..00000000 --- a/src/Core/Domain/CmsPageCategory/CommandHandler/DeleteCmsPageCategoryHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\DeleteCmsPageCategoryCommand; - -/** - * Interface DeleteCmsPageCategoryHandlerInterface defines contract for DeleteCmsPageCategoryHandler. - */ -interface DeleteCmsPageCategoryHandlerInterface -{ - /** - * @param DeleteCmsPageCategoryCommand $command - */ - public function handle(DeleteCmsPageCategoryCommand $command); -} diff --git a/src/Core/Domain/CmsPageCategory/CommandHandler/EditCmsPageCategoryHandlerInterface.php b/src/Core/Domain/CmsPageCategory/CommandHandler/EditCmsPageCategoryHandlerInterface.php deleted file mode 100644 index 60a663e6..00000000 --- a/src/Core/Domain/CmsPageCategory/CommandHandler/EditCmsPageCategoryHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\EditCmsPageCategoryCommand; - -/** - * Defines contract for EditCmsPageCategoryHandler. - */ -interface EditCmsPageCategoryHandlerInterface -{ - /** - * @param EditCmsPageCategoryCommand $command - */ - public function handle(EditCmsPageCategoryCommand $command); -} diff --git a/src/Core/Domain/CmsPageCategory/CommandHandler/ToggleCmsPageCategoryStatusHandlerInterface.php b/src/Core/Domain/CmsPageCategory/CommandHandler/ToggleCmsPageCategoryStatusHandlerInterface.php deleted file mode 100644 index aa9f98ff..00000000 --- a/src/Core/Domain/CmsPageCategory/CommandHandler/ToggleCmsPageCategoryStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\ToggleCmsPageCategoryStatusCommand; - -/** - * Interface ToggleCmsPageCategoryStatusHandlerInterface defines contract for ToggleCmsPageCategoryStatusHandler. - */ -interface ToggleCmsPageCategoryStatusHandlerInterface -{ - /** - * @param ToggleCmsPageCategoryStatusCommand $command - */ - public function handle(ToggleCmsPageCategoryStatusCommand $command); -} diff --git a/src/Core/Domain/CmsPageCategory/Exception/CannotAddCmsPageCategoryException.php b/src/Core/Domain/CmsPageCategory/Exception/CannotAddCmsPageCategoryException.php deleted file mode 100644 index afcc7694..00000000 --- a/src/Core/Domain/CmsPageCategory/Exception/CannotAddCmsPageCategoryException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception; - -/** - * Is thrown on failure when adding new cms page - */ -class CannotAddCmsPageCategoryException extends CmsPageCategoryException -{ -} diff --git a/src/Core/Domain/CmsPageCategory/Exception/CannotDeleteCmsPageCategoryException.php b/src/Core/Domain/CmsPageCategory/Exception/CannotDeleteCmsPageCategoryException.php deleted file mode 100644 index e7f76282..00000000 --- a/src/Core/Domain/CmsPageCategory/Exception/CannotDeleteCmsPageCategoryException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception; - -/** - * Is thrown on failure when deleting a cms page category - */ -class CannotDeleteCmsPageCategoryException extends CmsPageCategoryException -{ - /** - * When fails to delete single cms page category - */ - const FAILED_DELETE = 10; - - /** - * When fails to delete cms page categories on bulk action - */ - const FAILED_BULK_DELETE = 20; -} diff --git a/src/Core/Domain/CmsPageCategory/Exception/CannotDisableCmsPageCategoryException.php b/src/Core/Domain/CmsPageCategory/Exception/CannotDisableCmsPageCategoryException.php deleted file mode 100644 index 612d086a..00000000 --- a/src/Core/Domain/CmsPageCategory/Exception/CannotDisableCmsPageCategoryException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception; - -/** - * Is thrown when cms page category cannot be disabled - */ -class CannotDisableCmsPageCategoryException extends CmsPageCategoryException -{ -} diff --git a/src/Core/Domain/CmsPageCategory/Exception/CannotEnableCmsPageCategoryException.php b/src/Core/Domain/CmsPageCategory/Exception/CannotEnableCmsPageCategoryException.php deleted file mode 100644 index d725c60a..00000000 --- a/src/Core/Domain/CmsPageCategory/Exception/CannotEnableCmsPageCategoryException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception; - -/** - * Is thrown when cms page category cannot be enabled - */ -class CannotEnableCmsPageCategoryException extends CmsPageCategoryException -{ -} diff --git a/src/Core/Domain/CmsPageCategory/Exception/CannotToggleCmsPageCategoryStatusException.php b/src/Core/Domain/CmsPageCategory/Exception/CannotToggleCmsPageCategoryStatusException.php deleted file mode 100644 index 1a10cc58..00000000 --- a/src/Core/Domain/CmsPageCategory/Exception/CannotToggleCmsPageCategoryStatusException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception; - -/** - * Is thrown when cms page category cannot be enabled or disabled in toggling action - */ -class CannotToggleCmsPageCategoryStatusException extends CmsPageCategoryException -{ -} diff --git a/src/Core/Domain/CmsPageCategory/Exception/CannotUpdateCmsPageCategoryException.php b/src/Core/Domain/CmsPageCategory/Exception/CannotUpdateCmsPageCategoryException.php deleted file mode 100644 index c3b145cc..00000000 --- a/src/Core/Domain/CmsPageCategory/Exception/CannotUpdateCmsPageCategoryException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception; - -/** - * Is thrown when cms page category cannot be updated - */ -class CannotUpdateCmsPageCategoryException extends CmsPageCategoryException -{ -} diff --git a/src/Core/Domain/CmsPageCategory/Exception/CmsPageCategoryConstraintException.php b/src/Core/Domain/CmsPageCategory/Exception/CmsPageCategoryConstraintException.php deleted file mode 100644 index d5f0abd5..00000000 --- a/src/Core/Domain/CmsPageCategory/Exception/CmsPageCategoryConstraintException.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception; - -/** - * Is thrown when cms page category constraints are violated - */ -class CmsPageCategoryConstraintException extends CmsPageCategoryException -{ - /** - * @var int is used when incorrect values supplied for bulk cms categories operations - */ - const INVALID_BULK_DATA = 1; - - /** - * @var int is used when cms page category is moved to the same category as it is - * or if it is moved to its child category - */ - const CANNOT_MOVE_CATEGORY_TO_PARENT = 2; - - /** - * @var int is used to raise an error when default language is missing for the field - */ - const MISSING_DEFAULT_LANGUAGE_FOR_NAME = 3; - - /** - * @var int is used to raise an error when friendly url is missing for the field - */ - const MISSING_DEFAULT_LANGUAGE_FOR_FRIENDLY_URL = 4; - - /** - * @var int is used to validate category name to match the specific pattern - */ - const INVALID_CATEGORY_NAME = 5; - - /** - * @var int is used to validate link rewrite that matches specific regex pattern - */ - const INVALID_LINK_REWRITE = 6; - - /** - * @var int is used to validate meta title for specific regex pattern - */ - const INVALID_META_TITLE = 7; - - /** - * @var int Is used to validate meta description for specific regex pattern - */ - const INVALID_META_DESCRIPTION = 8; - - /** - * @var int is used to validate meta keywords for specific regex pattern - */ - const INVALID_META_KEYWORDS = 9; - - /** - * @var int Is used to validate description according to clean html standard/ - */ - const INVALID_DESCRIPTION = 10; -} diff --git a/src/Core/Domain/CmsPageCategory/Exception/CmsPageCategoryException.php b/src/Core/Domain/CmsPageCategory/Exception/CmsPageCategoryException.php deleted file mode 100644 index 70a788d1..00000000 --- a/src/Core/Domain/CmsPageCategory/Exception/CmsPageCategoryException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for CmsPageCategory sub-domain - */ -class CmsPageCategoryException extends DomainException -{ -} diff --git a/src/Core/Domain/CmsPageCategory/Exception/CmsPageCategoryNotFoundException.php b/src/Core/Domain/CmsPageCategory/Exception/CmsPageCategoryNotFoundException.php deleted file mode 100644 index 202d0c2c..00000000 --- a/src/Core/Domain/CmsPageCategory/Exception/CmsPageCategoryNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception; - -/** - * Thrown when unable to find required cms page category - */ -class CmsPageCategoryNotFoundException extends CmsPageCategoryException -{ -} diff --git a/src/Core/Domain/CmsPageCategory/Query/GetCmsPageCategoriesForBreadcrumb.php b/src/Core/Domain/CmsPageCategory/Query/GetCmsPageCategoriesForBreadcrumb.php deleted file mode 100644 index 534f9783..00000000 --- a/src/Core/Domain/CmsPageCategory/Query/GetCmsPageCategoriesForBreadcrumb.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Class GetCmsPageCategoriesForBreadcrumb is responsible for providing required data for displaying cms page category - * breadcrumbs. - */ -class GetCmsPageCategoriesForBreadcrumb -{ - /** - * @var CmsPageCategoryId - */ - private $currentCategoryId; - - /** - * @param int $currentCategoryId - * - * @throws CmsPageCategoryException - */ - public function __construct($currentCategoryId) - { - $this->currentCategoryId = new CmsPageCategoryId($currentCategoryId); - } - - /** - * Gets current category id. - * - * @return CmsPageCategoryId - */ - public function getCurrentCategoryId() - { - return $this->currentCategoryId; - } -} diff --git a/src/Core/Domain/CmsPageCategory/Query/GetCmsPageCategoryForEditing.php b/src/Core/Domain/CmsPageCategory/Query/GetCmsPageCategoryForEditing.php deleted file mode 100644 index 7a51f996..00000000 --- a/src/Core/Domain/CmsPageCategory/Query/GetCmsPageCategoryForEditing.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Class GetCmsPageCategoryForEditing is responsible for retrieving cms page category form data. - */ -class GetCmsPageCategoryForEditing -{ - /** - * @var CmsPageCategoryId - */ - private $cmsPageCategoryId; - - /** - * @param int $cmsPageCategoryId - * - * @throws CmsPageCategoryException - */ - public function __construct($cmsPageCategoryId) - { - $this->cmsPageCategoryId = new CmsPageCategoryId($cmsPageCategoryId); - } - - /** - * @return CmsPageCategoryId - */ - public function getCmsPageCategoryId() - { - return $this->cmsPageCategoryId; - } -} diff --git a/src/Core/Domain/CmsPageCategory/Query/GetCmsPageCategoryNameForListing.php b/src/Core/Domain/CmsPageCategory/Query/GetCmsPageCategoryNameForListing.php deleted file mode 100644 index ca63809d..00000000 --- a/src/Core/Domain/CmsPageCategory/Query/GetCmsPageCategoryNameForListing.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query; - -/** - * Gets name by cms category which are used for display in cms listing. - */ -class GetCmsPageCategoryNameForListing -{ -} diff --git a/src/Core/Domain/CmsPageCategory/Query/GetCmsPageParentCategoryIdForRedirection.php b/src/Core/Domain/CmsPageCategory/Query/GetCmsPageParentCategoryIdForRedirection.php deleted file mode 100644 index ebed1c78..00000000 --- a/src/Core/Domain/CmsPageCategory/Query/GetCmsPageParentCategoryIdForRedirection.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Class GetCmsPageParentCategoryIdForRedirection is responsible for providing cms page categories parent id - * for redirecting to the right controller after create, edit, delete, toggle actions. - */ -class GetCmsPageParentCategoryIdForRedirection -{ - /** - * @var CmsPageCategoryId - */ - private $cmsPageCategoryId; - - /** - * @param int $cmsPageCategoryId - * - * @throws CmsPageCategoryException - */ - public function __construct($cmsPageCategoryId) - { - $this->cmsPageCategoryId = new CmsPageCategoryId($cmsPageCategoryId); - } - - /** - * @return CmsPageCategoryId - */ - public function getCmsPageCategoryId() - { - return $this->cmsPageCategoryId; - } -} diff --git a/src/Core/Domain/CmsPageCategory/QueryHandler/GetCmsPageCategoriesForBreadcrumbHandlerInterface.php b/src/Core/Domain/CmsPageCategory/QueryHandler/GetCmsPageCategoriesForBreadcrumbHandlerInterface.php deleted file mode 100644 index 47de5b69..00000000 --- a/src/Core/Domain/CmsPageCategory/QueryHandler/GetCmsPageCategoriesForBreadcrumbHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query\GetCmsPageCategoriesForBreadcrumb; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryResult\Breadcrumb; - -/** - * Interface GetCmsPageCategoriesForBreadcrumbHandlerInterface defines contract for GetCmsPageCategoriesForBreadcrumbHandlerInterface. - */ -interface GetCmsPageCategoriesForBreadcrumbHandlerInterface -{ - /** - * @param GetCmsPageCategoriesForBreadcrumb $query - * - * @return Breadcrumb - */ - public function handle(GetCmsPageCategoriesForBreadcrumb $query); -} diff --git a/src/Core/Domain/CmsPageCategory/QueryHandler/GetCmsPageCategoryForEditingHandlerInterface.php b/src/Core/Domain/CmsPageCategory/QueryHandler/GetCmsPageCategoryForEditingHandlerInterface.php deleted file mode 100644 index e6530b4d..00000000 --- a/src/Core/Domain/CmsPageCategory/QueryHandler/GetCmsPageCategoryForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query\GetCmsPageCategoryForEditing; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryResult\EditableCmsPageCategory; - -/** - * Interface GetCmsPageCategoryForEditingHandlerInterface defines contract for GetCmsPageCategoryForEditingHandler. - */ -interface GetCmsPageCategoryForEditingHandlerInterface -{ - /** - * @param GetCmsPageCategoryForEditing $query - * - * @return EditableCmsPageCategory - */ - public function handle(GetCmsPageCategoryForEditing $query); -} diff --git a/src/Core/Domain/CmsPageCategory/QueryHandler/GetCmsPageCategoryNameForListingHandlerInterface.php b/src/Core/Domain/CmsPageCategory/QueryHandler/GetCmsPageCategoryNameForListingHandlerInterface.php deleted file mode 100644 index dad54d91..00000000 --- a/src/Core/Domain/CmsPageCategory/QueryHandler/GetCmsPageCategoryNameForListingHandlerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query\GetCmsPageCategoryNameForListing; - -/** - * Defines contract for GetCmsPageCategoryNameForListingHandler. - */ -interface GetCmsPageCategoryNameForListingHandlerInterface -{ - /** - * @param GetCmsPageCategoryNameForListing $query - * - * @return string - */ - public function handle(GetCmsPageCategoryNameForListing $query); -} diff --git a/src/Core/Domain/CmsPageCategory/QueryHandler/GetCmsPageParentCategoryIdForRedirectionHandlerInterface.php b/src/Core/Domain/CmsPageCategory/QueryHandler/GetCmsPageParentCategoryIdForRedirectionHandlerInterface.php deleted file mode 100644 index 7554b634..00000000 --- a/src/Core/Domain/CmsPageCategory/QueryHandler/GetCmsPageParentCategoryIdForRedirectionHandlerInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query\GetCmsPageParentCategoryIdForRedirection; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Interface GetCmsPageParentCategoryIdForRedirectionHandlerInterface defines contract - * for GetCmsPageParentCategoryIdForRedirectionHandler. - */ -interface GetCmsPageParentCategoryIdForRedirectionHandlerInterface -{ - /** - * @param GetCmsPageParentCategoryIdForRedirection $query - * - * @return CmsPageCategoryId - */ - public function handle(GetCmsPageParentCategoryIdForRedirection $query); -} diff --git a/src/Core/Domain/CmsPageCategory/QueryResult/Breadcrumb.php b/src/Core/Domain/CmsPageCategory/QueryResult/Breadcrumb.php deleted file mode 100644 index 89dde026..00000000 --- a/src/Core/Domain/CmsPageCategory/QueryResult/Breadcrumb.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryResult; - -use ArrayIterator; -use IteratorAggregate; - -/** - * Transfers CMS Page Categories used for breadrumb - */ -class Breadcrumb implements IteratorAggregate -{ - /** - * @var BreadcrumbItem[] - */ - private $cmsPageCategories; - - /** - * @param BreadcrumbItem[] $cmsPageCategories - */ - public function __construct(array $cmsPageCategories) - { - $this->cmsPageCategories = $cmsPageCategories; - } - - /** - * {@inheritdoc} - */ - public function getIterator() - { - return new ArrayIterator($this->cmsPageCategories); - } -} diff --git a/src/Core/Domain/CmsPageCategory/QueryResult/BreadcrumbItem.php b/src/Core/Domain/CmsPageCategory/QueryResult/BreadcrumbItem.php deleted file mode 100644 index cd767617..00000000 --- a/src/Core/Domain/CmsPageCategory/QueryResult/BreadcrumbItem.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Class CmsPageCategory is responsible for providing cms page id and name combination. - */ -class BreadcrumbItem -{ - /** - * @var CmsPageCategoryId - */ - private $cmsPageCategoryId; - - /** - * @var string - */ - private $name; - - /** - * @param int $cmsPageCategoryId - * @param string $name - * - * @throws CmsPageCategoryException - */ - public function __construct($cmsPageCategoryId, $name) - { - $this->cmsPageCategoryId = new CmsPageCategoryId($cmsPageCategoryId); - $this->name = $name; - } - - /** - * @return CmsPageCategoryId - */ - public function getCmsPageCategoryId() - { - return $this->cmsPageCategoryId; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } -} diff --git a/src/Core/Domain/CmsPageCategory/QueryResult/EditableCmsPageCategory.php b/src/Core/Domain/CmsPageCategory/QueryResult/EditableCmsPageCategory.php deleted file mode 100644 index 4f22f3df..00000000 --- a/src/Core/Domain/CmsPageCategory/QueryResult/EditableCmsPageCategory.php +++ /dev/null @@ -1,186 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Class EditableCmsPageCategory - */ -class EditableCmsPageCategory -{ - /** - * @var array - */ - private $localisedName; - - /** - * @var bool - */ - private $isDisplayed; - - /** - * @var CmsPageCategoryId - */ - private $parentId; - - /** - * @var array - */ - private $localisedDescription; - - /** - * @var array - */ - private $localisedMetaDescription; - - /** - * @var array - */ - private $localisedMetaKeywords; - - /** - * @var array - */ - private $localisedFriendlyUrl; - /** - * @var array - */ - private $metaTitle; - /** - * @var array - */ - private $shopIds; - - /** - * @param array $localisedName - * @param bool $isDisplayed - * @param int $parentId - * @param array $localisedDescription - * @param array $localisedMetaDescription - * @param array $localisedMetaKeywords - * @param array $metaTitle - * @param array $localisedFriendlyUrl - * @param array $shopIds - * - * @throws CmsPageCategoryException - */ - public function __construct( - array $localisedName, - $isDisplayed, - $parentId, - array $localisedDescription, - array $localisedMetaDescription, - array $localisedMetaKeywords, - array $metaTitle, - array $localisedFriendlyUrl, - array $shopIds - ) { - $this->localisedName = $localisedName; - $this->isDisplayed = $isDisplayed; - $this->parentId = new CmsPageCategoryId($parentId); - $this->localisedDescription = $localisedDescription; - $this->localisedMetaDescription = $localisedMetaDescription; - $this->localisedMetaKeywords = $localisedMetaKeywords; - $this->localisedFriendlyUrl = $localisedFriendlyUrl; - $this->metaTitle = $metaTitle; - $this->shopIds = $shopIds; - } - - /** - * @return array - */ - public function getLocalisedName() - { - return $this->localisedName; - } - - /** - * @return bool - */ - public function isDisplayed() - { - return $this->isDisplayed; - } - - /** - * @return CmsPageCategoryId - */ - public function getParentId() - { - return $this->parentId; - } - - /** - * @return array - */ - public function getLocalisedDescription() - { - return $this->localisedDescription; - } - - /** - * @return array - */ - public function getLocalisedMetaDescription() - { - return $this->localisedMetaDescription; - } - - /** - * @return array - */ - public function getLocalisedMetaKeywords() - { - return $this->localisedMetaKeywords; - } - - /** - * @return array - */ - public function getMetaTitle() - { - return $this->metaTitle; - } - - /** - * @return array - */ - public function getLocalisedFriendlyUrl() - { - return $this->localisedFriendlyUrl; - } - - /** - * @return array - */ - public function getShopIds() - { - return $this->shopIds; - } -} diff --git a/src/Core/Domain/CmsPageCategory/ValueObject/CmsPageCategoryId.php b/src/Core/Domain/CmsPageCategory/ValueObject/CmsPageCategoryId.php deleted file mode 100644 index 2d743aee..00000000 --- a/src/Core/Domain/CmsPageCategory/ValueObject/CmsPageCategoryId.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; - -/** - * Class CmsPageCategoryId is responsible for providing identificator for cms page category - */ -class CmsPageCategoryId -{ - /** - * ID for the topmost Cms Page category - */ - const ROOT_CMS_PAGE_CATEGORY_ID = 1; - - /** - * @var int - */ - private $cmsPageCategoryId; - - /** - * @param int $cmsPageCategoryId - * - * @throws CmsPageCategoryException - */ - public function __construct($cmsPageCategoryId) - { - $this->assertIsIntegerGreaterThanZero($cmsPageCategoryId); - $this->cmsPageCategoryId = $cmsPageCategoryId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->cmsPageCategoryId; - } - - /** - * Validates that the value is integer and is greater than zero. - * - * @param int $cmsPageCategoryId - * - * @throws CmsPageCategoryException - */ - private function assertIsIntegerGreaterThanZero($cmsPageCategoryId) - { - if (!is_int($cmsPageCategoryId) || 0 >= $cmsPageCategoryId) { - throw new CmsPageCategoryException(sprintf('Invalid cms page category id %s', var_export($cmsPageCategoryId, true))); - } - } -} diff --git a/src/Core/Domain/Configuration/Command/SwitchDebugModeCommand.php b/src/Core/Domain/Configuration/Command/SwitchDebugModeCommand.php deleted file mode 100644 index 50fc64b9..00000000 --- a/src/Core/Domain/Configuration/Command/SwitchDebugModeCommand.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Configuration\Command; - -/** - * Switches debug mode on/off - */ -class SwitchDebugModeCommand -{ - /** - * @var bool - */ - private $enableDebugMode; - - /** - * @param bool $enableDebugMode - */ - public function __construct($enableDebugMode) - { - $this->enableDebugMode = $enableDebugMode; - } - - /** - * @return bool - */ - public function enableDebugMode() - { - return true === $this->enableDebugMode; - } -} diff --git a/src/Core/Domain/Configuration/CommandHandler/SwitchDebugModeHandlerInterface.php b/src/Core/Domain/Configuration/CommandHandler/SwitchDebugModeHandlerInterface.php deleted file mode 100644 index 5eb45264..00000000 --- a/src/Core/Domain/Configuration/CommandHandler/SwitchDebugModeHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Configuration\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Configuration\Command\SwitchDebugModeCommand; - -/** - * Interface for service that implements debug mode switching - */ -interface SwitchDebugModeHandlerInterface -{ - /** - * @param SwitchDebugModeCommand $command - */ - public function handle(SwitchDebugModeCommand $command); -} diff --git a/src/Core/Domain/Configuration/ShopConfigurationInterface.php b/src/Core/Domain/Configuration/ShopConfigurationInterface.php deleted file mode 100644 index a36e1e58..00000000 --- a/src/Core/Domain/Configuration/ShopConfigurationInterface.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Configuration; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Shop\ValueObject\ShopConstraint; - -interface ShopConfigurationInterface extends ConfigurationInterface -{ - /** - * @param string $key - * @param mixed|null $default - * @param ShopConstraint|null $shopConstraint - * - * @return mixed - */ - public function get($key, $default = null, ShopConstraint $shopConstraint = null); - - /** - * @param string $key - * @param mixed $value - * @param ShopConstraint|null $shopConstraint - * - * @return ShopConfigurationInterface - */ - public function set($key, $value, ShopConstraint $shopConstraint = null); - - /** - * @param string $key - * @param ShopConstraint|null $shopConstraint - * - * @return bool - */ - public function has($key, ShopConstraint $shopConstraint = null); -} diff --git a/src/Core/Domain/Contact/Command/AbstractContactCommand.php b/src/Core/Domain/Contact/Command/AbstractContactCommand.php deleted file mode 100644 index 8d9e2a8f..00000000 --- a/src/Core/Domain/Contact/Command/AbstractContactCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Contact\Command; - -/** - * Class AbstractContactCommand is responsible for providing common behavior for AddContactCommand and EditContactCommand. - */ -abstract class AbstractContactCommand -{ - /** - * @param array $values - * - * @return bool - */ - protected function assertIsNotEmptyAndContainsAllNonEmptyStringValues(array $values) - { - $filterNonEmptyStrings = function ($value) { - return is_string($value) && $value; - }; - - return !empty($values) && count($values) === count(array_filter($values, $filterNonEmptyStrings)); - } - - /** - * @param $value - * - * @return false|int - */ - protected function assertIsGenericName($value) - { - return preg_match('/^[^<>={}]*$/u', $value); - } - - /** - * @param array $values - * - * @return bool - */ - protected function assertArrayContainsAllIntegerValues(array $values) - { - $filterAllIntegers = function ($value) { - return is_int($value); - }; - - return !empty($values) && count($values) === count(array_filter($values, $filterAllIntegers)); - } -} diff --git a/src/Core/Domain/Contact/Command/AddContactCommand.php b/src/Core/Domain/Contact/Command/AddContactCommand.php deleted file mode 100644 index 090a1f74..00000000 --- a/src/Core/Domain/Contact/Command/AddContactCommand.php +++ /dev/null @@ -1,178 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Contact\Command; - -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\ContactConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainConstraintException; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -/** - * Class AddContactCommand is responsible for adding the contact data. - */ -class AddContactCommand extends AbstractContactCommand -{ - /** - * @var string[] - */ - private $localisedTitles; - - /** - * @var bool - */ - private $isMessageSavingEnabled; - - /** - * @var Email - */ - private $email; - - /** - * @var string[] - */ - private $localisedDescription; - - /** - * @var int[] - */ - private $shopAssociation; - - /** - * @param string[] $localisedTitles - sample: [$langId => $title] - * @param bool $isMessageSavingEnabled - * - * @throws ContactConstraintException - */ - public function __construct(array $localisedTitles, $isMessageSavingEnabled) - { - $this->assertIsLocalisedTitleValid($localisedTitles); - - $this->localisedTitles = $localisedTitles; - $this->isMessageSavingEnabled = $isMessageSavingEnabled; - } - - /** - * @return string[] - */ - public function getLocalisedTitles() - { - return $this->localisedTitles; - } - - /** - * @return bool - */ - public function isMessageSavingEnabled() - { - return $this->isMessageSavingEnabled; - } - - /** - * @return Email - */ - public function getEmail() - { - return $this->email; - } - - /** - * @param string $email - * - * @return self - * - * @throws DomainConstraintException - */ - public function setEmail($email) - { - $this->email = new Email($email); - - return $this; - } - - /** - * @return string[] - */ - public function getLocalisedDescription() - { - return $this->localisedDescription; - } - - /** - * @param string[] $localisedDescription - * - * @return self - */ - public function setLocalisedDescription(array $localisedDescription) - { - $this->localisedDescription = $localisedDescription; - - return $this; - } - - /** - * @return int[] - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } - - /** - * @param int[] $shopAssociation - * - * @return self - * - * @throws ContactConstraintException - */ - public function setShopAssociation(array $shopAssociation) - { - if (!$this->assertArrayContainsAllIntegerValues($shopAssociation)) { - throw new ContactConstraintException(sprintf('Given shop association %s must contain all integer values', var_export($shopAssociation, true)), ContactConstraintException::INVALID_SHOP_ASSOCIATION); - } - - $this->shopAssociation = $shopAssociation; - - return $this; - } - - /** - * @param array $localisedTitles - * - * @throws ContactConstraintException - */ - private function assertIsLocalisedTitleValid(array $localisedTitles) - { - if (!$this->assertIsNotEmptyAndContainsAllNonEmptyStringValues($localisedTitles)) { - throw new ContactConstraintException(sprintf('Expected to have not empty titles array but received %s', var_export($localisedTitles, true)), ContactConstraintException::INVALID_TITLE); - } - - foreach ($localisedTitles as $title) { - if (!$this->assertIsGenericName($title)) { - throw new ContactConstraintException(sprintf('Expected value %s to match given regex /^[^<>={}]*$/u but failed', var_export($title, true)), ContactConstraintException::INVALID_TITLE); - } - } - } -} diff --git a/src/Core/Domain/Contact/Command/EditContactCommand.php b/src/Core/Domain/Contact/Command/EditContactCommand.php deleted file mode 100644 index fb7a43cf..00000000 --- a/src/Core/Domain/Contact/Command/EditContactCommand.php +++ /dev/null @@ -1,207 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Contact\Command; - -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\ContactConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\ContactException; -use PrestaShop\PrestaShop\Core\Domain\Contact\ValueObject\ContactId; -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainConstraintException; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -/** - * Class EditContactCommand is responsible for editing contact data. - */ -class EditContactCommand extends AbstractContactCommand -{ - /** - * @var ContactId - */ - private $contactId; - - /** - * @var string[] - */ - private $localisedTitles; - - /** - * @var Email - */ - private $email; - - /** - * @var bool - */ - private $isMessagesSavingEnabled; - - /** - * @var string[] - */ - private $localisedDescription; - - /** - * @var int[] - */ - private $shopAssociation; - - /** - * @param int $contactId - * - * @throws ContactException - */ - public function __construct($contactId) - { - $this->contactId = new ContactId($contactId); - } - - /** - * @return ContactId - */ - public function getContactId() - { - return $this->contactId; - } - - /** - * @return string[] - */ - public function getLocalisedTitles() - { - return $this->localisedTitles; - } - - /** - * @param string[] $localisedTitles - * - * @return self - * - * @throws ContactConstraintException - */ - public function setLocalisedTitles(array $localisedTitles) - { - if (!$this->assertIsNotEmptyAndContainsAllNonEmptyStringValues($localisedTitles)) { - throw new ContactConstraintException(sprintf('Expected to have not empty titles array but received %s', var_export($localisedTitles, true)), ContactConstraintException::INVALID_TITLE); - } - - foreach ($localisedTitles as $title) { - if (!$this->assertIsGenericName($title)) { - throw new ContactConstraintException(sprintf('Expected value %s to match given regex /^[^<>={}]*$/u but failed', var_export($title, true)), ContactConstraintException::INVALID_TITLE); - } - } - - $this->localisedTitles = $localisedTitles; - - return $this; - } - - /** - * @return Email - */ - public function getEmail() - { - return $this->email; - } - - /** - * @param string $email - * - * @return self - * - * @throws DomainConstraintException - */ - public function setEmail($email) - { - $this->email = new Email($email); - - return $this; - } - - /** - * @return bool - */ - public function isMessagesSavingEnabled() - { - return $this->isMessagesSavingEnabled; - } - - /** - * @param bool $isMessagesSavingEnabled - * - * @return self - */ - public function setIsMessagesSavingEnabled($isMessagesSavingEnabled) - { - $this->isMessagesSavingEnabled = $isMessagesSavingEnabled; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalisedDescription() - { - return $this->localisedDescription; - } - - /** - * @param string[] $localisedDescription - * - * @return self - */ - public function setLocalisedDescription(array $localisedDescription) - { - $this->localisedDescription = $localisedDescription; - - return $this; - } - - /** - * @return int[] - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } - - /** - * @param int[] $shopAssociation - * - * @return self - * - * @throws ContactConstraintException - */ - public function setShopAssociation(array $shopAssociation) - { - if (!$this->assertArrayContainsAllIntegerValues($shopAssociation)) { - throw new ContactConstraintException(sprintf('Given shop association %s must contain all integer values', var_export($shopAssociation, true)), ContactConstraintException::INVALID_SHOP_ASSOCIATION); - } - - $this->shopAssociation = $shopAssociation; - - return $this; - } -} diff --git a/src/Core/Domain/Contact/CommandHandler/AddContactHandlerInterface.php b/src/Core/Domain/Contact/CommandHandler/AddContactHandlerInterface.php deleted file mode 100644 index 8bb1cdc0..00000000 --- a/src/Core/Domain/Contact/CommandHandler/AddContactHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Contact\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Contact\Command\AddContactCommand; -use PrestaShop\PrestaShop\Core\Domain\Contact\ValueObject\ContactId; - -/** - * Interface AddContactHandlerInterface defines contract for AddContactHandler. - */ -interface AddContactHandlerInterface -{ - /** - * @param AddContactCommand $command - * - * @return ContactId - */ - public function handle(AddContactCommand $command); -} diff --git a/src/Core/Domain/Contact/CommandHandler/EditContactHandlerInterface.php b/src/Core/Domain/Contact/CommandHandler/EditContactHandlerInterface.php deleted file mode 100644 index e434a90b..00000000 --- a/src/Core/Domain/Contact/CommandHandler/EditContactHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Contact\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Contact\Command\EditContactCommand; - -/** - * Interface EditContactHandlerInterface defines contract for EditContactHandler. - */ -interface EditContactHandlerInterface -{ - /** - * @param EditContactCommand $command - */ - public function handle(EditContactCommand $command); -} diff --git a/src/Core/Domain/Contact/Exception/CannotAddContactException.php b/src/Core/Domain/Contact/Exception/CannotAddContactException.php deleted file mode 100644 index cd4d6560..00000000 --- a/src/Core/Domain/Contact/Exception/CannotAddContactException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Contact\Exception; - -/** - * Raised when failed to add contact entity. - */ -class CannotAddContactException extends ContactException -{ -} diff --git a/src/Core/Domain/Contact/Exception/CannotUpdateContactException.php b/src/Core/Domain/Contact/Exception/CannotUpdateContactException.php deleted file mode 100644 index 10eb5b16..00000000 --- a/src/Core/Domain/Contact/Exception/CannotUpdateContactException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Contact\Exception; - -/** - * Raised when failed to update contact entity. - */ -class CannotUpdateContactException extends ContactException -{ -} diff --git a/src/Core/Domain/Contact/Exception/ContactConstraintException.php b/src/Core/Domain/Contact/Exception/ContactConstraintException.php deleted file mode 100644 index d4cfbb0b..00000000 --- a/src/Core/Domain/Contact/Exception/ContactConstraintException.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Contact\Exception; - -/** - * holds all validation constraints that are used together with contact entity. - */ -class ContactConstraintException extends ContactException -{ - /** - * @var int - error is raised when preg match fails to validate according to regex /^[^<>={}]*$/u - */ - const INVALID_TITLE = 1; - - /** - * @var int - error is raised when a value in array is not integer type - */ - const INVALID_SHOP_ASSOCIATION = 2; - - /** - * @var int - error is raised when CleanHtml constraint validation fails - */ - const INVALID_DESCRIPTION = 3; - - /** - * @var int - error is raised when an array does not have the default language value. It might not exist or is empty. - * DefaultLanguage constraint is used here. - */ - const MISSING_TITLE_FOR_DEFAULT_LANGUAGE = 4; -} diff --git a/src/Core/Domain/Contact/Exception/ContactException.php b/src/Core/Domain/Contact/Exception/ContactException.php deleted file mode 100644 index b6872245..00000000 --- a/src/Core/Domain/Contact/Exception/ContactException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Contact\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * An abstraction for all contact related exceptions. Use this one in catch clause to detect all related exceptions. - */ -class ContactException extends DomainException -{ -} diff --git a/src/Core/Domain/Contact/Exception/ContactNotFoundException.php b/src/Core/Domain/Contact/Exception/ContactNotFoundException.php deleted file mode 100644 index f6a4f9ef..00000000 --- a/src/Core/Domain/Contact/Exception/ContactNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Contact\Exception; - -/** - * Raised when contact was not found. - */ -class ContactNotFoundException extends ContactException -{ -} diff --git a/src/Core/Domain/Contact/Query/GetContactForEditing.php b/src/Core/Domain/Contact/Query/GetContactForEditing.php deleted file mode 100644 index 5b00ce6e..00000000 --- a/src/Core/Domain/Contact/Query/GetContactForEditing.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Contact\Query; - -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\ContactException; -use PrestaShop\PrestaShop\Core\Domain\Contact\ValueObject\ContactId; - -/** - * Class GetContactForEditing is responsible for getting the data related with contact entity. - */ -class GetContactForEditing -{ - /** @var ContactId */ - private $contactId; - - /** - * @param int $contactId - * - * @throws ContactException - */ - public function __construct($contactId) - { - $this->contactId = new ContactId($contactId); - } - - /** - * @return ContactId - */ - public function getContactId() - { - return $this->contactId; - } -} diff --git a/src/Core/Domain/Contact/QueryHandler/GetContactForEditingHandlerInterface.php b/src/Core/Domain/Contact/QueryHandler/GetContactForEditingHandlerInterface.php deleted file mode 100644 index d2a1996c..00000000 --- a/src/Core/Domain/Contact/QueryHandler/GetContactForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Contact\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Contact\Query\GetContactForEditing; -use PrestaShop\PrestaShop\Core\Domain\Contact\QueryResult\EditableContact; - -/** - * Interface GetContactForEditingHandlerInterface defines contract for GetContactForEditingHandler - */ -interface GetContactForEditingHandlerInterface -{ - /** - * @param GetContactForEditing $query - * - * @return EditableContact - */ - public function handle(GetContactForEditing $query); -} diff --git a/src/Core/Domain/Contact/QueryResult/EditableContact.php b/src/Core/Domain/Contact/QueryResult/EditableContact.php deleted file mode 100644 index 0fd1bffb..00000000 --- a/src/Core/Domain/Contact/QueryResult/EditableContact.php +++ /dev/null @@ -1,144 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Contact\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\ContactException; -use PrestaShop\PrestaShop\Core\Domain\Contact\ValueObject\ContactId; -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainConstraintException; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -/** - * Transfers contact data for editing. - */ -class EditableContact -{ - /** - * @var ContactId - */ - private $contactId; - - /** - * @var array|string[] - */ - private $localisedTitles; - - /** - * @var Email|null - */ - private $email; - - /** - * @var bool - */ - private $isMessagesSavingEnabled; - - /** - * @var string[] - */ - private $localisedDescription; - - /** - * @var int[] - */ - private $shopAssociation; - - /** - * @param int $contactId - * @param string[] $localisedTitles - * @param string $email - * @param bool $isMessagesSavingEnabled - * @param string[] $localisedDescription - * @param int[] $shopAssociation - * - * @throws ContactException - * @throws DomainConstraintException - */ - public function __construct( - $contactId, - array $localisedTitles, - $email, - $isMessagesSavingEnabled, - $localisedDescription, - array $shopAssociation - ) { - $this->contactId = new ContactId($contactId); - $this->localisedTitles = $localisedTitles; - $this->isMessagesSavingEnabled = $isMessagesSavingEnabled; - $this->localisedDescription = $localisedDescription; - $this->contactId = $contactId; - $this->shopAssociation = $shopAssociation; - $this->email = $email ? new Email($email) : null; - } - - /** - * @return ContactId - */ - public function getContactId() - { - return $this->contactId; - } - - /** - * @return string[] - */ - public function getLocalisedTitles() - { - return $this->localisedTitles; - } - - /** - * @return Email|null - */ - public function getEmail() - { - return $this->email; - } - - /** - * @return bool - */ - public function isMessagesSavingEnabled() - { - return $this->isMessagesSavingEnabled; - } - - /** - * @return string[] - */ - public function getLocalisedDescription() - { - return $this->localisedDescription; - } - - /** - * @return int[] - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } -} diff --git a/src/Core/Domain/Contact/ValueObject/ContactId.php b/src/Core/Domain/Contact/ValueObject/ContactId.php deleted file mode 100644 index 54a9144a..00000000 --- a/src/Core/Domain/Contact/ValueObject/ContactId.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Contact\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\ContactException; - -/** - * Class ContactId - */ -class ContactId -{ - /** - * @var int - */ - private $contactId; - - /** - * @param int $contactId - * - * @throws ContactException - */ - public function __construct($contactId) - { - $this->assertIsIntegerOrMoreThanZero($contactId); - - $this->contactId = $contactId; - } - - /** - * @param $contactId - * - * @throws ContactException - */ - private function assertIsIntegerOrMoreThanZero($contactId) - { - if (!is_int($contactId) || 0 >= $contactId) { - throw new ContactException(sprintf('Invalid Contact id: %s', var_export($contactId, true))); - } - } - - /** - * @return int - */ - public function getValue() - { - return $this->contactId; - } -} diff --git a/src/Core/Domain/Country/Exception/CountryConstraintException.php b/src/Core/Domain/Country/Exception/CountryConstraintException.php deleted file mode 100644 index b3dcab0e..00000000 --- a/src/Core/Domain/Country/Exception/CountryConstraintException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Country\Exception; - -/** - * Is thrown when country constraint is violated - */ -class CountryConstraintException extends CountryException -{ - public const INVALID_ID = 1; -} diff --git a/src/Core/Domain/Country/Exception/CountryException.php b/src/Core/Domain/Country/Exception/CountryException.php deleted file mode 100644 index b9143192..00000000 --- a/src/Core/Domain/Country/Exception/CountryException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Country\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for countries subdomain - */ -class CountryException extends DomainException -{ -} diff --git a/src/Core/Domain/Country/Exception/CountryNotFoundException.php b/src/Core/Domain/Country/Exception/CountryNotFoundException.php deleted file mode 100644 index 4c2e8e50..00000000 --- a/src/Core/Domain/Country/Exception/CountryNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Country\Exception; - -/** - * Is thrown on failure to find existing country - */ -class CountryNotFoundException extends CountryException -{ -} diff --git a/src/Core/Domain/Country/Query/GetCountryRequiredFields.php b/src/Core/Domain/Country/Query/GetCountryRequiredFields.php deleted file mode 100644 index 1cd90077..00000000 --- a/src/Core/Domain/Country/Query/GetCountryRequiredFields.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Country\Query; - -use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Country\ValueObject\CountryId; - -/** - * Query for getting country required fields - */ -class GetCountryRequiredFields -{ - /** - * @var CountryId - */ - private $countryId; - - /** - * @param int $countryId - * - * @throws CountryConstraintException - */ - public function __construct(int $countryId) - { - $this->countryId = new CountryId($countryId); - } - - /** - * @return CountryId - */ - public function getCountryId(): CountryId - { - return $this->countryId; - } -} diff --git a/src/Core/Domain/Country/QueryHandler/GetCountryRequiredFieldsHandlerInterface.php b/src/Core/Domain/Country/QueryHandler/GetCountryRequiredFieldsHandlerInterface.php deleted file mode 100644 index db1d0cfe..00000000 --- a/src/Core/Domain/Country/QueryHandler/GetCountryRequiredFieldsHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Country\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Country\Query\GetCountryRequiredFields; -use PrestaShop\PrestaShop\Core\Domain\Country\QueryResult\CountryRequiredFields; - -/** - * Defines contract for country required fields handler - */ -interface GetCountryRequiredFieldsHandlerInterface -{ - /** - * @param GetCountryRequiredFields $query - * - * @return CountryRequiredFields - */ - public function handle(GetCountryRequiredFields $query): CountryRequiredFields; -} diff --git a/src/Core/Domain/Country/QueryResult/CountryRequiredFields.php b/src/Core/Domain/Country/QueryResult/CountryRequiredFields.php deleted file mode 100644 index bd6fdaa8..00000000 --- a/src/Core/Domain/Country/QueryResult/CountryRequiredFields.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Country\QueryResult; - -/** - * Stores data about address fields which are required by country - */ -class CountryRequiredFields -{ - /** @var bool */ - private $stateRequired; - - /** @var bool */ - private $dniRequired; - - /** - * @param bool $stateRequired - * @param bool $dniRequired - */ - public function __construct(bool $stateRequired, bool $dniRequired) - { - $this->stateRequired = $stateRequired; - $this->dniRequired = $dniRequired; - } - - /** - * @return bool - */ - public function isStateRequired(): bool - { - return $this->stateRequired; - } - - /** - * @return bool - */ - public function isDniRequired(): bool - { - return $this->dniRequired; - } -} diff --git a/src/Core/Domain/Country/ValueObject/CountryId.php b/src/Core/Domain/Country/ValueObject/CountryId.php deleted file mode 100644 index 50740d32..00000000 --- a/src/Core/Domain/Country/ValueObject/CountryId.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Country\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryConstraintException; - -/** - * Provides country id value - */ -class CountryId -{ - /** - * @var int - */ - private $id; - - /** - * @param int $id - * - * @throws CountryConstraintException - */ - public function __construct(int $id) - { - $this->assertPositiveInt($id); - $this->id = $id; - } - - /** - * @return int - */ - public function getValue(): int - { - return $this->id; - } - - /** - * @param int $value - * - * @throws CountryConstraintException - */ - private function assertPositiveInt(int $value) - { - if (0 > $value) { - throw new CountryConstraintException(sprintf('Invalid country id "%s".', var_export($value, true)), CountryConstraintException::INVALID_ID); - } - } -} diff --git a/src/Core/Domain/Country/ZipCodePatternResolver.php b/src/Core/Domain/Country/ZipCodePatternResolver.php deleted file mode 100644 index abfd371a..00000000 --- a/src/Core/Domain/Country/ZipCodePatternResolver.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Country; - -/** - * Call responsible for resolving country zip code format and returning it as other usable patterns - */ -final class ZipCodePatternResolver implements ZipCodePatternResolverInterface -{ - /** - * @param string $format - * @param string $isoCode - * - * @return string - */ - public function getRegexPattern(string $format, string $isoCode): string - { - return str_replace(['N', 'L', 'C'], ['[0-9]', '[a-zA-Z]', $isoCode], '/^' . $format . '$/ui'); - } - - /** - * @param string $format - * @param string $isoCode - * - * @return string - */ - public function getHumanReadablePattern(string $format, string $isoCode): string - { - return str_replace(['N', 'L', 'C'], ['0', 'A', $isoCode], $format); - } -} diff --git a/src/Core/Domain/Country/ZipCodePatternResolverInterface.php b/src/Core/Domain/Country/ZipCodePatternResolverInterface.php deleted file mode 100644 index eb2f23ca..00000000 --- a/src/Core/Domain/Country/ZipCodePatternResolverInterface.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Country; - -/** - * Call responsible for resolving country zip code format and returning it as other usable patterns - */ -interface ZipCodePatternResolverInterface -{ - /** - * @param string $format - * @param string $isoCode - * - * @return string - */ - public function getRegexPattern(string $format, string $isoCode): string; - - /** - * @param string $format - * @param string $isoCode - * - * @return string - */ - public function getHumanReadablePattern(string $format, string $isoCode): string; -} diff --git a/src/Core/Domain/CreditSlip/Exception/CreditSlipConstraintException.php b/src/Core/Domain/CreditSlip/Exception/CreditSlipConstraintException.php deleted file mode 100644 index deaa0582..00000000 --- a/src/Core/Domain/CreditSlip/Exception/CreditSlipConstraintException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CreditSlip\Exception; - -/** - * Is thrown when credit slip constraints are violated - */ -class CreditSlipConstraintException extends CreditSlipException -{ - /** - * When id value is not valid - */ - const INVALID_ID = 10; -} diff --git a/src/Core/Domain/CreditSlip/Exception/CreditSlipException.php b/src/Core/Domain/CreditSlip/Exception/CreditSlipException.php deleted file mode 100644 index 1e7b48ab..00000000 --- a/src/Core/Domain/CreditSlip/Exception/CreditSlipException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CreditSlip\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base class for CreditSlip subdomain - */ -class CreditSlipException extends DomainException -{ -} diff --git a/src/Core/Domain/CreditSlip/Exception/CreditSlipNotFoundException.php b/src/Core/Domain/CreditSlip/Exception/CreditSlipNotFoundException.php deleted file mode 100644 index 02459a46..00000000 --- a/src/Core/Domain/CreditSlip/Exception/CreditSlipNotFoundException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CreditSlip\Exception; - -/** - * Thrown when requested credit slip/slips are not found - */ -class CreditSlipNotFoundException extends CreditSlipException -{ - /** - * Thrown when no credit slips are found when querying by specific date range - */ - const BY_DATE_RANGE = 1; -} diff --git a/src/Core/Domain/CreditSlip/Query/GetCreditSlipIdsByDateRange.php b/src/Core/Domain/CreditSlip/Query/GetCreditSlipIdsByDateRange.php deleted file mode 100644 index e42b5074..00000000 --- a/src/Core/Domain/CreditSlip/Query/GetCreditSlipIdsByDateRange.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CreditSlip\Query; - -use DateTime; - -/** - * Gets CreditSlipIds for provided date range - */ -final class GetCreditSlipIdsByDateRange -{ - /** - * @var DateTime - */ - private $dateTimeFrom; - - /** - * @var DateTime - */ - private $dateTimeTo; - - /** - * @param DateTime $dateTimeFrom - * @param DateTime $dateTimeTo - */ - public function __construct(DateTime $dateTimeFrom, DateTime $dateTimeTo) - { - $this->dateTimeFrom = $dateTimeFrom; - $this->dateTimeTo = $dateTimeTo; - } - - /** - * @return DateTime - */ - public function getDateTimeFrom() - { - return $this->dateTimeFrom; - } - - /** - * @return DateTime - */ - public function getDateTimeTo() - { - return $this->dateTimeTo; - } -} diff --git a/src/Core/Domain/CreditSlip/QueryHandler/GetCreditSlipIdsByDateRangeHandlerInterface.php b/src/Core/Domain/CreditSlip/QueryHandler/GetCreditSlipIdsByDateRangeHandlerInterface.php deleted file mode 100644 index c10370c5..00000000 --- a/src/Core/Domain/CreditSlip/QueryHandler/GetCreditSlipIdsByDateRangeHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CreditSlip\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\CreditSlip\Query\GetCreditSlipIdsByDateRange; -use PrestaShop\PrestaShop\Core\Domain\CreditSlip\ValueObject\CreditSlipId; - -/** - * Interface for handling GetCreditSlipIdsByDateRange query - */ -interface GetCreditSlipIdsByDateRangeHandlerInterface -{ - /** - * @param GetCreditSlipIdsByDateRange $query - * - * @return CreditSlipId[] - */ - public function handle(GetCreditSlipIdsByDateRange $query); -} diff --git a/src/Core/Domain/CreditSlip/ValueObject/CreditSlipId.php b/src/Core/Domain/CreditSlip/ValueObject/CreditSlipId.php deleted file mode 100644 index 3700f81d..00000000 --- a/src/Core/Domain/CreditSlip/ValueObject/CreditSlipId.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CreditSlip\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\CreditSlip\Exception\CreditSlipConstraintException; - -/** - * Provides identification data for Credit slip - */ -final class CreditSlipId -{ - /** - * @var int - */ - private $creditSlipId; - - /** - * @param int $creditSlipId - * - * @throws CreditSlipConstraintException - */ - public function __construct($creditSlipId) - { - $this->assertIsIntegerGreaterThanZero($creditSlipId); - $this->creditSlipId = $creditSlipId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->creditSlipId; - } - - /** - * Validates that the value is integer and is greater than zero - * - * @param $value - * - * @throws CreditSlipConstraintException - */ - private function assertIsIntegerGreaterThanZero($value) - { - if (!is_int($value) || 0 >= $value) { - throw new CreditSlipConstraintException(sprintf('Invalid credit slip id "%s".', var_export($value, true))); - } - } -} diff --git a/src/Core/Domain/Currency/Command/AddCurrencyCommand.php b/src/Core/Domain/Currency/Command/AddCurrencyCommand.php deleted file mode 100644 index c1a1ea7c..00000000 --- a/src/Core/Domain/Currency/Command/AddCurrencyCommand.php +++ /dev/null @@ -1,235 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Command; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\AlphaIsoCode; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\ExchangeRate; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\Precision; - -/** - * Class AddCurrencyCommand used to add an official currency - */ -class AddCurrencyCommand -{ - /** - * @var AlphaIsoCode - */ - protected $isoCode; - - /** - * @var ExchangeRate - */ - protected $exchangeRate; - - /** - * @var Precision|null - */ - protected $precision; - - /** - * @var string[] - */ - protected $localizedNames = []; - - /** - * @var string[] - */ - protected $localizedSymbols = []; - - /** - * @var bool - */ - protected $isEnabled; - - /** - * @var int[] - */ - protected $shopIds = []; - - /** - * @var string[] - */ - protected $localizedTransformations = []; - - /** - * @param string $isoCode - * @param float $exchangeRate - * @param bool $isEnabled - * - * @throws CurrencyConstraintException - */ - public function __construct( - $isoCode, - $exchangeRate, - $isEnabled - ) { - $this->isoCode = new AlphaIsoCode($isoCode); - $this->exchangeRate = new ExchangeRate($exchangeRate); - $this->isEnabled = $isEnabled; - } - - /** - * @return AlphaIsoCode - */ - public function getIsoCode() - { - return $this->isoCode; - } - - /** - * @return Precision|null - */ - public function getPrecision(): ?Precision - { - return $this->precision; - } - - /** - * @param int|string $precision - * - * @return self - * - * @throws CurrencyConstraintException - */ - public function setPrecision($precision): AddCurrencyCommand - { - $this->precision = new Precision($precision); - - return $this; - } - - /** - * @return ExchangeRate - */ - public function getExchangeRate() - { - return $this->exchangeRate; - } - - /** - * @return string[] - */ - public function getLocalizedNames(): array - { - return $this->localizedNames; - } - - /** - * @param string[] $localizedNames currency's localized names, indexed by language id - * - * @return $this - * - * @throws CurrencyConstraintException - */ - public function setLocalizedNames(array $localizedNames): AddCurrencyCommand - { - if (empty($localizedNames)) { - throw new CurrencyConstraintException('Currency name cannot be empty', CurrencyConstraintException::EMPTY_NAME); - } - - $this->localizedNames = $localizedNames; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedSymbols(): array - { - return $this->localizedSymbols; - } - - /** - * @param string[] $localizedSymbols currency's localized symbols, indexed by language id - * - * @return $this - * - * @throws CurrencyConstraintException - */ - public function setLocalizedSymbols(array $localizedSymbols): AddCurrencyCommand - { - if (empty($localizedSymbols)) { - throw new CurrencyConstraintException('Currency symbol cannot be empty', CurrencyConstraintException::EMPTY_SYMBOL); - } - - $this->localizedSymbols = $localizedSymbols; - - return $this; - } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->isEnabled; - } - - /** - * @return int[] - */ - public function getShopIds() - { - return $this->shopIds; - } - - /** - * @param int[] $shopIds - * - * @return self - */ - public function setShopIds(array $shopIds) - { - $this->shopIds = $shopIds; - - return $this; - } - - /** - * Returns the currency's localized transformations, indexed by language id - * - * @return string[] - */ - public function getLocalizedTransformations(): array - { - return $this->localizedTransformations; - } - - /** - * @param string[] $localizedTransformations currency's localized transformations, indexed by language id - * - * @return $this - */ - public function setLocalizedTransformations(array $localizedTransformations): AddCurrencyCommand - { - $this->localizedTransformations = $localizedTransformations; - - return $this; - } -} diff --git a/src/Core/Domain/Currency/Command/AddUnofficialCurrencyCommand.php b/src/Core/Domain/Currency/Command/AddUnofficialCurrencyCommand.php deleted file mode 100644 index 5cca9920..00000000 --- a/src/Core/Domain/Currency/Command/AddUnofficialCurrencyCommand.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Command; - -/** - * Class AddUnofficialCurrencyCommand used to add an alternative currency - */ -class AddUnofficialCurrencyCommand extends AddCurrencyCommand -{ -} diff --git a/src/Core/Domain/Currency/Command/DeleteCurrencyCommand.php b/src/Core/Domain/Currency/Command/DeleteCurrencyCommand.php deleted file mode 100644 index b656734f..00000000 --- a/src/Core/Domain/Currency/Command/DeleteCurrencyCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Command; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\CurrencyId; - -/** - * Class DeleteCurrencyCommand is responsible for deleting Currency. - */ -class DeleteCurrencyCommand -{ - /** - * @var CurrencyId - */ - private $currencyId; - - /** - * @param int $currencyId - * - * @throws CurrencyException - */ - public function __construct($currencyId) - { - $this->currencyId = new CurrencyId($currencyId); - } - - /** - * @return CurrencyId - */ - public function getCurrencyId() - { - return $this->currencyId; - } -} diff --git a/src/Core/Domain/Currency/Command/EditCurrencyCommand.php b/src/Core/Domain/Currency/Command/EditCurrencyCommand.php deleted file mode 100644 index b2b33250..00000000 --- a/src/Core/Domain/Currency/Command/EditCurrencyCommand.php +++ /dev/null @@ -1,255 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Command; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\CurrencyId; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\ExchangeRate; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\Precision; - -/** - * Class EditCurrencyCommand - */ -class EditCurrencyCommand -{ - /** - * @var CurrencyId - */ - protected $currencyId; - - /** - * @var ExchangeRate|null - */ - protected $exchangeRate; - - /** - * @var Precision|null - */ - protected $precision; - - /** - * @var string[] - */ - protected $localizedNames = []; - - /** - * @var string[] - */ - protected $localizedSymbols = []; - - /** - * @var bool - */ - protected $isEnabled; - - /** - * @var int[] - */ - protected $shopIds = []; - - /** - * @var string[] - */ - protected $localizedTransformations = []; - - /** - * @param int $currencyId - * - * @throws CurrencyException - */ - public function __construct($currencyId) - { - $this->currencyId = new CurrencyId($currencyId); - } - - /** - * @return CurrencyId - */ - public function getCurrencyId() - { - return $this->currencyId; - } - - /** - * @return ExchangeRate|null - */ - public function getExchangeRate() - { - return $this->exchangeRate; - } - - /** - * @param float $exchangeRate - * - * @return self - * - * @throws CurrencyConstraintException - */ - public function setExchangeRate($exchangeRate) - { - $this->exchangeRate = new ExchangeRate($exchangeRate); - - return $this; - } - - /** - * @return Precision|null - */ - public function getPrecision(): ?Precision - { - return $this->precision; - } - - /** - * @param int|string $precision - * - * @return self - * - * @throws CurrencyConstraintException - */ - public function setPrecision($precision): EditCurrencyCommand - { - $this->precision = new Precision($precision); - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedNames(): array - { - return $this->localizedNames; - } - - /** - * @param string[] $localizedNames currency's localized names, indexed by language id - * - * @return $this - * - * @throws CurrencyConstraintException - */ - public function setLocalizedNames(array $localizedNames): EditCurrencyCommand - { - if (empty($localizedNames)) { - throw new CurrencyConstraintException('Currency name cannot be empty', CurrencyConstraintException::EMPTY_NAME); - } - - $this->localizedNames = $localizedNames; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalizedSymbols() - { - return $this->localizedSymbols; - } - - /** - * @param string[] $localizedSymbols currency's localized symbols, indexed by language id - * - * @return $this - * - * @throws CurrencyConstraintException - */ - public function setLocalizedSymbols(array $localizedSymbols): EditCurrencyCommand - { - if (empty($localizedSymbols)) { - throw new CurrencyConstraintException('Currency symbol cannot be empty', CurrencyConstraintException::EMPTY_SYMBOL); - } - - $this->localizedSymbols = $localizedSymbols; - - return $this; - } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->isEnabled; - } - - /** - * @param bool $isEnabled - * - * @return self - */ - public function setIsEnabled($isEnabled) - { - $this->isEnabled = $isEnabled; - - return $this; - } - - /** - * @return int[] - */ - public function getShopIds() - { - return $this->shopIds; - } - - /** - * @param int[] $shopIds - * - * @return self - */ - public function setShopIds(array $shopIds) - { - $this->shopIds = $shopIds; - - return $this; - } - - /** - * Returns the currency's localized transformations, indexed by language id - * - * @return string[] - */ - public function getLocalizedTransformations(): array - { - return $this->localizedTransformations; - } - - /** - * @param string[] $localizedTransformations currency's localized transformations, indexed by language id - * - * @return $this - */ - public function setLocalizedTransformations(array $localizedTransformations): EditCurrencyCommand - { - $this->localizedTransformations = $localizedTransformations; - - return $this; - } -} diff --git a/src/Core/Domain/Currency/Command/EditUnofficialCurrencyCommand.php b/src/Core/Domain/Currency/Command/EditUnofficialCurrencyCommand.php deleted file mode 100644 index 8b029b81..00000000 --- a/src/Core/Domain/Currency/Command/EditUnofficialCurrencyCommand.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Command; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\AlphaIsoCode; - -class EditUnofficialCurrencyCommand extends EditCurrencyCommand -{ - /** - * @var AlphaIsoCode|null - */ - private $isoCode; - - /** - * @return AlphaIsoCode|null - */ - public function getIsoCode() - { - return $this->isoCode; - } - - /** - * @param string $isoCode - * - * @return self - * - * @throws CurrencyConstraintException - */ - public function setIsoCode($isoCode) - { - $this->isoCode = new AlphaIsoCode($isoCode); - - return $this; - } -} diff --git a/src/Core/Domain/Currency/Command/RefreshExchangeRatesCommand.php b/src/Core/Domain/Currency/Command/RefreshExchangeRatesCommand.php deleted file mode 100644 index 9d89554f..00000000 --- a/src/Core/Domain/Currency/Command/RefreshExchangeRatesCommand.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Command; - -/** - * Class RefreshExchangeRatesCommand - */ -class RefreshExchangeRatesCommand -{ -} diff --git a/src/Core/Domain/Currency/Command/ToggleCurrencyStatusCommand.php b/src/Core/Domain/Currency/Command/ToggleCurrencyStatusCommand.php deleted file mode 100644 index 336d2351..00000000 --- a/src/Core/Domain/Currency/Command/ToggleCurrencyStatusCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Command; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\CurrencyId; - -/** - * Class ToggleCurrencyStatusCommand is responsible for changing the status of the currency. - */ -class ToggleCurrencyStatusCommand -{ - /** - * @var CurrencyId - */ - private $currencyId; - - /** - * @param int $currencyId - * - * @throws CurrencyException - */ - public function __construct($currencyId) - { - $this->currencyId = new CurrencyId($currencyId); - } - - /** - * @return CurrencyId - */ - public function getCurrencyId() - { - return $this->currencyId; - } -} diff --git a/src/Core/Domain/Currency/Command/ToggleExchangeRateAutomatizationCommand.php b/src/Core/Domain/Currency/Command/ToggleExchangeRateAutomatizationCommand.php deleted file mode 100644 index a61467ce..00000000 --- a/src/Core/Domain/Currency/Command/ToggleExchangeRateAutomatizationCommand.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Command; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyConstraintException; - -/** - * Class ToggleExchangeRateAutomatizationCommand is responsible for turning on or off the setting - if its on then - * in CronJobs module it creates new record with url which points to the script which is being executed at certain time - * of period. If the setting is off then it removes that record. - */ -class ToggleExchangeRateAutomatizationCommand -{ - /** - * @var bool - */ - private $exchangeRateStatus; - - /** - * @param bool $exchangeRateStatus - * - * @throws CurrencyConstraintException - */ - public function __construct($exchangeRateStatus) - { - $this->assertIsBool($exchangeRateStatus); - - $this->exchangeRateStatus = $exchangeRateStatus; - } - - /** - * @return bool - */ - public function exchangeRateStatus() - { - return $this->exchangeRateStatus; - } - - /** - * @param bool $isExchangeRateEnabled - * - * @throws CurrencyConstraintException - */ - private function assertIsBool($isExchangeRateEnabled) - { - if (!is_bool($isExchangeRateEnabled)) { - throw new CurrencyConstraintException(sprintf('Unexpected type of live exchange rates. Expected bool, got "%s"', var_export($isExchangeRateEnabled, true)), CurrencyConstraintException::INVALID_LIVE_EXCHANGE_RATES); - } - } -} diff --git a/src/Core/Domain/Currency/CommandHandler/AddCurrencyHandlerInterface.php b/src/Core/Domain/Currency/CommandHandler/AddCurrencyHandlerInterface.php deleted file mode 100644 index b4084068..00000000 --- a/src/Core/Domain/Currency/CommandHandler/AddCurrencyHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\AddCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\CurrencyId; - -/** - * Interface AddCurrencyHandlerInterface defines contract for AddOfficialCurrencyHandler - */ -interface AddCurrencyHandlerInterface -{ - /** - * @param AddCurrencyCommand $command - * - * @return CurrencyId - */ - public function handle(AddCurrencyCommand $command); -} diff --git a/src/Core/Domain/Currency/CommandHandler/AddUnofficialCurrencyHandlerInterface.php b/src/Core/Domain/Currency/CommandHandler/AddUnofficialCurrencyHandlerInterface.php deleted file mode 100644 index 25c1f0b0..00000000 --- a/src/Core/Domain/Currency/CommandHandler/AddUnofficialCurrencyHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\AddUnofficialCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\CurrencyId; - -/** - * Interface AddUnofficialCurrencyHandlerInterface defines contract for AddUnofficialCurrencyHandler - */ -interface AddUnofficialCurrencyHandlerInterface -{ - /** - * @param AddUnofficialCurrencyCommand $command - * - * @return CurrencyId - */ - public function handle(AddUnofficialCurrencyCommand $command); -} diff --git a/src/Core/Domain/Currency/CommandHandler/DeleteCurrencyHandlerInterface.php b/src/Core/Domain/Currency/CommandHandler/DeleteCurrencyHandlerInterface.php deleted file mode 100644 index e8d7a6dc..00000000 --- a/src/Core/Domain/Currency/CommandHandler/DeleteCurrencyHandlerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\DeleteCurrencyCommand; - -/** - * Interface DeleteCurrencyHandlerInterface defines contract for DeleteCurrencyHandler. - */ -interface DeleteCurrencyHandlerInterface -{ - /** - * Handles the deletion logic of currency. - * - * @param DeleteCurrencyCommand $command - */ - public function handle(DeleteCurrencyCommand $command); -} diff --git a/src/Core/Domain/Currency/CommandHandler/EditCurrencyHandlerInterface.php b/src/Core/Domain/Currency/CommandHandler/EditCurrencyHandlerInterface.php deleted file mode 100644 index 11c3e2d0..00000000 --- a/src/Core/Domain/Currency/CommandHandler/EditCurrencyHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\EditCurrencyCommand; - -/** - * Interface EditCurrencyHandlerInterface defines contract for UpdateCurrencyHandler. - */ -interface EditCurrencyHandlerInterface -{ - /** - * @param EditCurrencyCommand $command - */ - public function handle(EditCurrencyCommand $command); -} diff --git a/src/Core/Domain/Currency/CommandHandler/EditUnofficialCurrencyHandlerInterface.php b/src/Core/Domain/Currency/CommandHandler/EditUnofficialCurrencyHandlerInterface.php deleted file mode 100644 index 93039723..00000000 --- a/src/Core/Domain/Currency/CommandHandler/EditUnofficialCurrencyHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\EditUnofficialCurrencyCommand; - -/** - * Interface EditUnofficialCurrencyHandlerInterface defines contract for UpdateCurrencyHandler. - */ -interface EditUnofficialCurrencyHandlerInterface -{ - /** - * @param EditUnofficialCurrencyCommand $command - */ - public function handle(EditUnofficialCurrencyCommand $command); -} diff --git a/src/Core/Domain/Currency/CommandHandler/RefreshExchangeRatesHandlerInterface.php b/src/Core/Domain/Currency/CommandHandler/RefreshExchangeRatesHandlerInterface.php deleted file mode 100644 index 91744c27..00000000 --- a/src/Core/Domain/Currency/CommandHandler/RefreshExchangeRatesHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\RefreshExchangeRatesCommand; - -/** - * Interface RefreshExchangeRatesHandlerInterface defines contract for UpdateExchangeRatesHandler. - */ -interface RefreshExchangeRatesHandlerInterface -{ - /** - * @param RefreshExchangeRatesCommand $command - */ - public function handle(RefreshExchangeRatesCommand $command); -} diff --git a/src/Core/Domain/Currency/CommandHandler/ToggleCurrencyStatusHandlerInterface.php b/src/Core/Domain/Currency/CommandHandler/ToggleCurrencyStatusHandlerInterface.php deleted file mode 100644 index ae9f6ef5..00000000 --- a/src/Core/Domain/Currency/CommandHandler/ToggleCurrencyStatusHandlerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\ToggleCurrencyStatusCommand; - -/** - * Interface ToggleCurrencyStatusHandlerInterface defines contract for ToggleCurrencyStatusHandler. - */ -interface ToggleCurrencyStatusHandlerInterface -{ - /** - * Handles currency status toggling logic. - * - * @param ToggleCurrencyStatusCommand $command - */ - public function handle(ToggleCurrencyStatusCommand $command); -} diff --git a/src/Core/Domain/Currency/CommandHandler/ToggleExchangeRateAutomatizationHandlerInterface.php b/src/Core/Domain/Currency/CommandHandler/ToggleExchangeRateAutomatizationHandlerInterface.php deleted file mode 100644 index bcd60a6c..00000000 --- a/src/Core/Domain/Currency/CommandHandler/ToggleExchangeRateAutomatizationHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\ToggleExchangeRateAutomatizationCommand; - -/** - * Interface ToggleExchangeRateAutomatizationHandlerInterface defines contract for UpdateLiveExchangeRatesHandler. - */ -interface ToggleExchangeRateAutomatizationHandlerInterface -{ - /** - * @param ToggleExchangeRateAutomatizationCommand $command - */ - public function handle(ToggleExchangeRateAutomatizationCommand $command); -} diff --git a/src/Core/Domain/Currency/Exception/AutomateExchangeRatesUpdateException.php b/src/Core/Domain/Currency/Exception/AutomateExchangeRatesUpdateException.php deleted file mode 100644 index 646e8372..00000000 --- a/src/Core/Domain/Currency/Exception/AutomateExchangeRatesUpdateException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Exception; - -/** - * Thrown on currency exchange rates automatic update failure - */ -class AutomateExchangeRatesUpdateException extends CurrencyException -{ - const CRON_TASK_CREATION_FAILED = 1; - const CRON_TASK_MANAGER_MODULE_NOT_INSTALLED = 2; -} diff --git a/src/Core/Domain/Currency/Exception/CannotCreateCurrencyException.php b/src/Core/Domain/Currency/Exception/CannotCreateCurrencyException.php deleted file mode 100644 index ab0976a8..00000000 --- a/src/Core/Domain/Currency/Exception/CannotCreateCurrencyException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Exception; - -/** - * Is thrown when new currency cannot be created - */ -class CannotCreateCurrencyException extends CurrencyException -{ -} diff --git a/src/Core/Domain/Currency/Exception/CannotDeleteCurrencyException.php b/src/Core/Domain/Currency/Exception/CannotDeleteCurrencyException.php deleted file mode 100644 index 0e3bc339..00000000 --- a/src/Core/Domain/Currency/Exception/CannotDeleteCurrencyException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Exception; - -/** - * Is thrown on failure while deleting currency - */ -class CannotDeleteCurrencyException extends CurrencyException -{ -} diff --git a/src/Core/Domain/Currency/Exception/CannotDeleteDefaultCurrencyException.php b/src/Core/Domain/Currency/Exception/CannotDeleteDefaultCurrencyException.php deleted file mode 100644 index 0083d117..00000000 --- a/src/Core/Domain/Currency/Exception/CannotDeleteDefaultCurrencyException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Exception; - -/** - * Is thrown when currency cannot be deleted because it is default - */ -class CannotDeleteDefaultCurrencyException extends CurrencyException -{ -} diff --git a/src/Core/Domain/Currency/Exception/CannotDisableDefaultCurrencyException.php b/src/Core/Domain/Currency/Exception/CannotDisableDefaultCurrencyException.php deleted file mode 100644 index 4ca12731..00000000 --- a/src/Core/Domain/Currency/Exception/CannotDisableDefaultCurrencyException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Exception; - -/** - * Is thrown when currency cannot be disabled because it is default - */ -class CannotDisableDefaultCurrencyException extends CurrencyException -{ -} diff --git a/src/Core/Domain/Currency/Exception/CannotRefreshExchangeRatesException.php b/src/Core/Domain/Currency/Exception/CannotRefreshExchangeRatesException.php deleted file mode 100644 index ffe30cbe..00000000 --- a/src/Core/Domain/Currency/Exception/CannotRefreshExchangeRatesException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Exception; - -/** - * Is thrown when refreshing currency exchange rates fails - */ -class CannotRefreshExchangeRatesException extends CurrencyException -{ -} diff --git a/src/Core/Domain/Currency/Exception/CannotToggleCurrencyException.php b/src/Core/Domain/Currency/Exception/CannotToggleCurrencyException.php deleted file mode 100644 index d071f706..00000000 --- a/src/Core/Domain/Currency/Exception/CannotToggleCurrencyException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Exception; - -/** - * Is thrown when toggling currency status fails - */ -class CannotToggleCurrencyException extends CurrencyException -{ -} diff --git a/src/Core/Domain/Currency/Exception/CannotUpdateCurrencyException.php b/src/Core/Domain/Currency/Exception/CannotUpdateCurrencyException.php deleted file mode 100644 index 4f0542b3..00000000 --- a/src/Core/Domain/Currency/Exception/CannotUpdateCurrencyException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Exception; - -/** - * Is thrown when currency cannot be updated - */ -class CannotUpdateCurrencyException extends CurrencyException -{ -} diff --git a/src/Core/Domain/Currency/Exception/CurrencyConstraintException.php b/src/Core/Domain/Currency/Exception/CurrencyConstraintException.php deleted file mode 100644 index 0d4c232b..00000000 --- a/src/Core/Domain/Currency/Exception/CurrencyConstraintException.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Exception; - -/** - * Is thrown when currency constraints are violated - */ -class CurrencyConstraintException extends CurrencyException -{ - /** - * Code used when the ISO code doesn't respect it's appropriate format - * - * @see AlphaIsoCode::PATTERN - */ - const INVALID_ISO_CODE = 1; - - /** - * Code used when an invalid exchange rate is used (positive float expected) - * - * @see ExchangeRate - */ - const INVALID_EXCHANGE_RATE = 2; - - /** - * Code used when trying to insert a currency already in database - */ - const CURRENCY_ALREADY_EXISTS = 3; - - /** - * Code used when an invalid liveExchangeRate is used (boolean expected) - */ - const INVALID_LIVE_EXCHANGE_RATES = 4; - - /** - * Code used when the numeric ISO code doesn't respect it's appropriate format - * - * @see NumericIsoCode::PATTERN - */ - const INVALID_NUMERIC_ISO_CODE = 5; - - /** - * Code used when trying to set an empty array of names - */ - const EMPTY_NAME = 6; - - /** - * Code used when trying to set an empty array of symbols - */ - const EMPTY_SYMBOL = 7; - - /** - * Code used when an invalid precision is used (positive integer expected) - * - * @see Precision - */ - const INVALID_PRECISION = 8; - - /** - * Code used when an invalid name is used - */ - const INVALID_NAME = 9; - - /** - * Code used when an invalid symbol is used - */ - const INVALID_SYMBOL = 10; - - /** - * Code used when an invalid pattern is used - */ - const INVALID_PATTERN = 11; -} diff --git a/src/Core/Domain/Currency/Exception/CurrencyException.php b/src/Core/Domain/Currency/Exception/CurrencyException.php deleted file mode 100644 index a17e248e..00000000 --- a/src/Core/Domain/Currency/Exception/CurrencyException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for Currency sub-domain - */ -class CurrencyException extends DomainException -{ - /** - * When currency cannot be used because it is disabled - */ - const IS_DISABLED = 1; - - /** - * When currency cannot be used because it is deleted - */ - const IS_DELETED = 2; -} diff --git a/src/Core/Domain/Currency/Exception/CurrencyNotFoundException.php b/src/Core/Domain/Currency/Exception/CurrencyNotFoundException.php deleted file mode 100644 index d33beab9..00000000 --- a/src/Core/Domain/Currency/Exception/CurrencyNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Exception; - -/** - * Is thrown when required currency cannot be found - */ -class CurrencyNotFoundException extends CurrencyException -{ -} diff --git a/src/Core/Domain/Currency/Exception/DefaultCurrencyInMultiShopException.php b/src/Core/Domain/Currency/Exception/DefaultCurrencyInMultiShopException.php deleted file mode 100644 index 1499bd38..00000000 --- a/src/Core/Domain/Currency/Exception/DefaultCurrencyInMultiShopException.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Exception; - -/** - * Is thrown when action associated with currency is done from multi-shop context - * and that action cannot be done because the currency is set as default in one of shops - */ -class DefaultCurrencyInMultiShopException extends CurrencyException -{ - /** - * When trying to remove default currency in multi-shop context - */ - const CANNOT_REMOVE_CURRENCY = 1; - - /** - * When trying to disable default currency in multi-shop context - */ - const CANNOT_DISABLE_CURRENCY = 2; - - /** - * @var string - */ - private $currencyName; - - /** - * @var string - */ - private $shopName; - - /** - * @param string $currencyName - * @param string $shopName - * @param string $message - * @param int $code - * @param null $previous - */ - public function __construct($currencyName, $shopName, $message = '', $code = 0, $previous = null) - { - parent::__construct($message, $code, $previous); - - $this->currencyName = $currencyName; - $this->shopName = $shopName; - } - - /** - * @return string - */ - public function getCurrencyName() - { - return $this->currencyName; - } - - /** - * @return string - */ - public function getShopName() - { - return $this->shopName; - } -} diff --git a/src/Core/Domain/Currency/Exception/ExchangeRateNotFoundException.php b/src/Core/Domain/Currency/Exception/ExchangeRateNotFoundException.php deleted file mode 100644 index 51f2d9e8..00000000 --- a/src/Core/Domain/Currency/Exception/ExchangeRateNotFoundException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Exception; - -/** - * Class CannotFindExchangeRateException is thrown if the exchange rate could not be found - * for the required currency. - */ -class ExchangeRateNotFoundException extends CurrencyException -{ -} diff --git a/src/Core/Domain/Currency/Exception/InvalidUnofficialCurrencyException.php b/src/Core/Domain/Currency/Exception/InvalidUnofficialCurrencyException.php deleted file mode 100644 index ce8fbe8b..00000000 --- a/src/Core/Domain/Currency/Exception/InvalidUnofficialCurrencyException.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Exception; - -use Throwable; - -/** - * Class InvalidUnofficialCurrencyException is thrown when an invalid currency - * is being added (matching an ISO code from CLDR database) - */ -class InvalidUnofficialCurrencyException extends CurrencyException -{ - /** @var string */ - private $isoCode; - - /** - * @param string $message the Exception message to throw - * @param string $isoCode Invalid currency ISO code - * @param int $code [optional] The Exception code - * @param Throwable $previous [optional] The previous throwable used for the exception chaining - * - * @since 5.1.0 - */ - public function __construct($message, $isoCode, $code = 0, Throwable $previous = null) - { - parent::__construct($message, $code, $previous); - $this->isoCode = $isoCode; - } - - /** - * @return string - */ - public function getIsoCode(): string - { - return $this->isoCode; - } -} diff --git a/src/Core/Domain/Currency/Query/GetCurrencyExchangeRate.php b/src/Core/Domain/Currency/Query/GetCurrencyExchangeRate.php deleted file mode 100644 index b38c128f..00000000 --- a/src/Core/Domain/Currency/Query/GetCurrencyExchangeRate.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Query; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\AlphaIsoCode; - -/** - * Retrieves the exchange rate for a currency compared to the shop's default - */ -class GetCurrencyExchangeRate -{ - /** - * @var AlphaIsoCode - */ - private $isoCode; - - /** - * @param string $isoCode Currency ISO code - * - * @throws CurrencyException - */ - public function __construct(string $isoCode) - { - $this->isoCode = new AlphaIsoCode($isoCode); - } - - /** - * @return AlphaIsoCode - */ - public function getIsoCode(): AlphaIsoCode - { - return $this->isoCode; - } -} diff --git a/src/Core/Domain/Currency/Query/GetCurrencyForEditing.php b/src/Core/Domain/Currency/Query/GetCurrencyForEditing.php deleted file mode 100644 index a06b72ee..00000000 --- a/src/Core/Domain/Currency/Query/GetCurrencyForEditing.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Query; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\CurrencyId; - -/** - * Class GetCurrencyForEditing - */ -class GetCurrencyForEditing -{ - /** - * @var CurrencyId - */ - private $currencyId; - - /** - * @param int $currencyId - * - * @throws CurrencyException - */ - public function __construct($currencyId) - { - $this->currencyId = new CurrencyId($currencyId); - } - - /** - * @return CurrencyId - */ - public function getCurrencyId() - { - return $this->currencyId; - } -} diff --git a/src/Core/Domain/Currency/Query/GetReferenceCurrency.php b/src/Core/Domain/Currency/Query/GetReferenceCurrency.php deleted file mode 100644 index 5be7354c..00000000 --- a/src/Core/Domain/Currency/Query/GetReferenceCurrency.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\Query; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\AlphaIsoCode; - -/** - * Get reference currency data, which are data from the unicode CLDR database, thus - * only official currencies have one. The result is exposed with a ReferenceCurrency - * object, and if the currency doesn't exist a CurrencyNotFoundException is thrown. - */ -class GetReferenceCurrency -{ - /** - * @var AlphaIsoCode - */ - private $isoCode; - - /** - * @param string $isoCode - * - * @throws CurrencyException - */ - public function __construct(string $isoCode) - { - $this->isoCode = new AlphaIsoCode($isoCode); - } - - /** - * @return AlphaIsoCode - */ - public function getIsoCode(): AlphaIsoCode - { - return $this->isoCode; - } -} diff --git a/src/Core/Domain/Currency/QueryHandler/GetCurrencyExchangeRateHandlerInterface.php b/src/Core/Domain/Currency/QueryHandler/GetCurrencyExchangeRateHandlerInterface.php deleted file mode 100644 index b0dd6d74..00000000 --- a/src/Core/Domain/Currency/QueryHandler/GetCurrencyExchangeRateHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetCurrencyExchangeRate; -use PrestaShop\PrestaShop\Core\Domain\Currency\QueryResult\ExchangeRate; - -/** - * Interface GetCurrencyExchangeRateHandlerInterface defines contract for GetCurrencyExchangeRateHandler. - */ -interface GetCurrencyExchangeRateHandlerInterface -{ - /** - * @param GetCurrencyExchangeRate $query - * - * @return ExchangeRate - */ - public function handle(GetCurrencyExchangeRate $query); -} diff --git a/src/Core/Domain/Currency/QueryHandler/GetCurrencyForEditingHandlerInterface.php b/src/Core/Domain/Currency/QueryHandler/GetCurrencyForEditingHandlerInterface.php deleted file mode 100644 index 7dc0b5a7..00000000 --- a/src/Core/Domain/Currency/QueryHandler/GetCurrencyForEditingHandlerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetCurrencyForEditing; - -/** - * Interface GetCurrencyForEditingHandlerInterface defines contract for GetCurrencyForFormEditingHandler. - */ -interface GetCurrencyForEditingHandlerInterface -{ - /** - * @param GetCurrencyForEditing $query - * - * @return \PrestaShop\PrestaShop\Core\Domain\Currency\QueryResult\EditableCurrency - */ - public function handle(GetCurrencyForEditing $query); -} diff --git a/src/Core/Domain/Currency/QueryHandler/GetReferenceCurrencyHandlerInterface.php b/src/Core/Domain/Currency/QueryHandler/GetReferenceCurrencyHandlerInterface.php deleted file mode 100644 index e3416334..00000000 --- a/src/Core/Domain/Currency/QueryHandler/GetReferenceCurrencyHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetReferenceCurrency; -use PrestaShop\PrestaShop\Core\Domain\Currency\QueryResult\ReferenceCurrency; - -/** - * Interface GetReferenceCurrencyHandlerInterface defines contract for GetReferenceCurrencyHandler. - */ -interface GetReferenceCurrencyHandlerInterface -{ - /** - * @param GetReferenceCurrency $query - * - * @return ReferenceCurrency - */ - public function handle(GetReferenceCurrency $query): ReferenceCurrency; -} diff --git a/src/Core/Domain/Currency/QueryResult/EditableCurrency.php b/src/Core/Domain/Currency/QueryResult/EditableCurrency.php deleted file mode 100644 index b50ee22a..00000000 --- a/src/Core/Domain/Currency/QueryResult/EditableCurrency.php +++ /dev/null @@ -1,222 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\CurrencyId; - -/** - * Class EditableCurrency - */ -class EditableCurrency -{ - /** - * @var CurrencyId - */ - private $currencyId; - - /** - * @var array - */ - private $names; - - /** - * @var array - */ - private $symbols; - - /** - * @var array - */ - private $transformations; - - /** - * @var string - */ - private $isoCode; - - /** - * @var float - */ - private $exchangeRate; - - /** - * @var int - */ - private $precision; - - /** - * @var bool - */ - private $isEnabled; - - /** - * @var bool - */ - private $isUnofficial; - - /** - * @var int[] - */ - private $associatedShopIds; - - /** - * @param int $currencyId - * @param string $isoCode - * @param array $names - * @param array $symbols - * @param array $transformations - * @param float $exchangeRate - * @param int $precision - * @param bool $isEnabled - * @param bool $isUnofficial - * @param int[] $associatedShopIds - * - * @throws CurrencyException - */ - public function __construct( - $currencyId, - $isoCode, - array $names, - array $symbols, - array $transformations, - $exchangeRate, - int $precision, - $isEnabled, - bool $isUnofficial, - array $associatedShopIds - ) { - $this->currencyId = new CurrencyId($currencyId); - $this->isoCode = $isoCode; - $this->names = $names; - $this->symbols = $symbols; - $this->transformations = $transformations; - $this->exchangeRate = $exchangeRate; - $this->precision = $precision; - $this->isEnabled = $isEnabled; - $this->isUnofficial = $isUnofficial; - $this->associatedShopIds = $associatedShopIds; - } - - /** - * @return CurrencyId - */ - public function getCurrencyId() - { - return $this->currencyId; - } - - /** - * Currency ISO code - * - * @return string - */ - public function getIsoCode() - { - return $this->isoCode; - } - - /** - * Currency's names, indexed by language id. - * - * @return array - */ - public function getNames(): array - { - return $this->names; - } - - /** - * Currency's names, indexed by language id. - * - * @return array - */ - public function getSymbols(): array - { - return $this->symbols; - } - - /** - * Currency's transformations, indexed by language id. - * - * @return array - */ - public function getTransformations(): array - { - return $this->transformations; - } - - /** - * Exchange rate of the currency compared to the shop's default one - * - * @return float - */ - public function getExchangeRate() - { - return $this->exchangeRate; - } - - /** - * Currency decimal precision - * - * @return int - */ - public function getPrecision(): int - { - return $this->precision; - } - - /** - * Whether the currency is enabled on the front - * - * @return bool - */ - public function isEnabled() - { - return $this->isEnabled; - } - - /** - * Whether the currency is an unofficial one (custom created) - * - * @return bool - */ - public function isUnofficial(): bool - { - return $this->isUnofficial; - } - - /** - * List of shops that use this currency (shop IDs) - * - * @return int[] - */ - public function getAssociatedShopIds() - { - return $this->associatedShopIds; - } -} diff --git a/src/Core/Domain/Currency/QueryResult/ExchangeRate.php b/src/Core/Domain/Currency/QueryResult/ExchangeRate.php deleted file mode 100644 index 3a5b9b7f..00000000 --- a/src/Core/Domain/Currency/QueryResult/ExchangeRate.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\QueryResult; - -use PrestaShop\Decimal\Number; - -/** - * Class ExchangeRate - */ -class ExchangeRate -{ - /** - * @var Number - */ - private $exchangeRate; - - /** - * @param Number $exchangeRate - */ - public function __construct(Number $exchangeRate) - { - $this->exchangeRate = $exchangeRate; - } - - /** - * @return Number - */ - public function getValue(): Number - { - return $this->exchangeRate; - } -} diff --git a/src/Core/Domain/Currency/QueryResult/ReferenceCurrency.php b/src/Core/Domain/Currency/QueryResult/ReferenceCurrency.php deleted file mode 100644 index c63a286c..00000000 --- a/src/Core/Domain/Currency/QueryResult/ReferenceCurrency.php +++ /dev/null @@ -1,144 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\QueryResult; - -class ReferenceCurrency -{ - /** - * @var string[] - */ - private $names; - - /** - * @var string[] - */ - private $symbols; - - /** - * @var string[] - */ - private $patterns; - - /** - * @var string - */ - private $isoCode; - - /** - * @var string|null - */ - private $numericIsoCode; - - /** - * @var int - */ - private $precision; - - /** - * @param string $isoCode - * @param string $numericIsoCode - * @param array $names - * @param array $symbols - * @param array $patterns - * @param int $precision - */ - public function __construct( - string $isoCode, - string $numericIsoCode, - array $names, - array $symbols, - array $patterns, - int $precision - ) { - $this->isoCode = $isoCode; - $this->numericIsoCode = $numericIsoCode; - $this->names = $names; - $this->symbols = $symbols; - $this->patterns = $patterns; - $this->precision = $precision; - } - - /** - * Currency ISO code - * - * @return string - */ - public function getIsoCode(): string - { - return $this->isoCode; - } - - /** - * Currency numeric ISO code - * - * @return string - */ - public function getNumericIsoCode(): string - { - return $this->numericIsoCode; - } - - /** - * Currency's names, indexed by language id. - * - * @return array - */ - public function getNames(): array - { - return $this->names; - } - - /** - * Currency's names, indexed by language id. - * - * @return array - */ - public function getSymbols(): array - { - return $this->symbols; - } - - /** - * Currency's patterns, indexed by language id. - * - * @return array - */ - public function getPatterns(): array - { - return $this->patterns; - } - - /** - * Currency decimal precision - * - * @return int - */ - public function getPrecision(): int - { - return $this->precision; - } -} diff --git a/src/Core/Domain/Currency/ValueObject/AlphaIsoCode.php b/src/Core/Domain/Currency/ValueObject/AlphaIsoCode.php deleted file mode 100644 index bf74bc7d..00000000 --- a/src/Core/Domain/Currency/ValueObject/AlphaIsoCode.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyConstraintException; - -/** - * Class AlphaIsoCode - */ -class AlphaIsoCode -{ - /** - * @var string ISO Code validation pattern - */ - const PATTERN = '/^[a-zA-Z]{2,3}$/'; - - /** - * @var string - */ - private $isoCode; - - /** - * @param string $isoCode - * - * @throws CurrencyConstraintException - */ - public function __construct($isoCode) - { - $this->assertIsValidIsoCode($isoCode); - $this->isoCode = $isoCode; - } - - /** - * @return string - */ - public function getValue() - { - return $this->isoCode; - } - - /** - * @param string $isoCode - * - * @throws CurrencyConstraintException - */ - private function assertIsValidIsoCode($isoCode) - { - if (!is_string($isoCode) || !preg_match(self::PATTERN, $isoCode)) { - throw new CurrencyConstraintException(sprintf('Given iso code "%s" is not valid. It did not matched given regex %s', var_export($isoCode, true), self::PATTERN), CurrencyConstraintException::INVALID_ISO_CODE); - } - } -} diff --git a/src/Core/Domain/Currency/ValueObject/CurrencyId.php b/src/Core/Domain/Currency/ValueObject/CurrencyId.php deleted file mode 100644 index 041803f9..00000000 --- a/src/Core/Domain/Currency/ValueObject/CurrencyId.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; - -/** - * Class CurrencyId is responsible for providing currency id data. - */ -class CurrencyId -{ - /** - * @var int - */ - private $currencyId; - - /** - * @param int $currencyId - * - * @throws CurrencyException - */ - public function __construct($currencyId) - { - if (!is_int($currencyId) || $currencyId <= 0) { - throw new CurrencyException(sprintf('Invalid Currency id: %s', var_export($currencyId, true))); - } - - $this->currencyId = $currencyId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->currencyId; - } -} diff --git a/src/Core/Domain/Currency/ValueObject/ExchangeRate.php b/src/Core/Domain/Currency/ValueObject/ExchangeRate.php deleted file mode 100644 index 9da31983..00000000 --- a/src/Core/Domain/Currency/ValueObject/ExchangeRate.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject; - -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyConstraintException; - -/** - * Class ExchangeRate - */ -class ExchangeRate -{ - const DEFAULT_RATE = 1.0; - - /** - * Get the default exchange rate as a Number - * - * @return Number - */ - public static function getDefaultExchangeRate(): Number - { - return new Number((string) self::DEFAULT_RATE); - } - - /** - * @var float - */ - private $exchangeRate; - - /** - * @param float $exchangeRate - * - * @throws CurrencyConstraintException - */ - public function __construct($exchangeRate) - { - $this->assertIsNumberAndMoreThanZero($exchangeRate); - $this->exchangeRate = $exchangeRate; - } - - /** - * @return float - */ - public function getValue() - { - return $this->exchangeRate; - } - - /** - * @param float|int $exchangeRate - * - * @throws CurrencyConstraintException - */ - private function assertIsNumberAndMoreThanZero($exchangeRate) - { - $isIntegerOrFloat = is_int($exchangeRate) || is_float($exchangeRate); - - if (!$isIntegerOrFloat || 0 >= $exchangeRate) { - throw new CurrencyConstraintException(sprintf('Given exchange rate %s is not valid. It must be more than 0', var_export($exchangeRate, true)), CurrencyConstraintException::INVALID_EXCHANGE_RATE); - } - } -} diff --git a/src/Core/Domain/Currency/ValueObject/NumericIsoCode.php b/src/Core/Domain/Currency/ValueObject/NumericIsoCode.php deleted file mode 100644 index 4405b32f..00000000 --- a/src/Core/Domain/Currency/ValueObject/NumericIsoCode.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyConstraintException; - -/** - * Class NumericIsoCode - */ -class NumericIsoCode -{ - /** - * @var string Numeric ISO Code validation pattern - */ - const PATTERN = '/^[0-9]{3}$/'; - - /** - * @var string - */ - private $numericIsoCode; - - /** - * @param string $numericIsoCode - * - * @throws CurrencyConstraintException - */ - public function __construct($numericIsoCode) - { - $this->assertIsValidNumericIsoCode($numericIsoCode); - $this->numericIsoCode = $numericIsoCode; - } - - /** - * @return string - */ - public function getValue(): string - { - return $this->numericIsoCode; - } - - /** - * @param string $numericIsoCode - * - * @throws CurrencyConstraintException - */ - private function assertIsValidNumericIsoCode($numericIsoCode) - { - if (!is_string($numericIsoCode) || !preg_match(self::PATTERN, $numericIsoCode)) { - throw new CurrencyConstraintException(sprintf('Given numeric iso code "%s" is not valid. It must be a string composed of three digits', var_export($numericIsoCode, true)), CurrencyConstraintException::INVALID_NUMERIC_ISO_CODE); - } - } -} diff --git a/src/Core/Domain/Currency/ValueObject/Precision.php b/src/Core/Domain/Currency/ValueObject/Precision.php deleted file mode 100644 index f0910f6e..00000000 --- a/src/Core/Domain/Currency/ValueObject/Precision.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyConstraintException; - -class Precision -{ - const DEFAULT_PRECISION = 2; - - /** - * @var int - */ - private $precision; - - /** - * @param int $precision - * - * @throws CurrencyConstraintException - */ - public function __construct(int $precision) - { - $this->assertIsPositiveInteger($precision); - $this->precision = $precision; - } - - /** - * @return int - */ - public function getValue() - { - return $this->precision; - } - - /** - * @param int $precision - * - * @throws CurrencyConstraintException - */ - private function assertIsPositiveInteger(int $precision) - { - if ((int) $precision < 0) { - throw new CurrencyConstraintException(sprintf('Given precision "%s" is not valid. It must be a positive integer', var_export($precision, true)), CurrencyConstraintException::INVALID_PRECISION); - } - } -} diff --git a/src/Core/Domain/Customer/Command/AddCustomerCommand.php b/src/Core/Domain/Customer/Command/AddCustomerCommand.php deleted file mode 100644 index 79b4257e..00000000 --- a/src/Core/Domain/Customer/Command/AddCustomerCommand.php +++ /dev/null @@ -1,397 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Command; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\ApeCode; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\Birthday; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\FirstName; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\LastName; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\Password; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -/** - * Adds new customer with provided data - */ -class AddCustomerCommand -{ - /** - * @var FirstName - */ - private $firstName; - - /** - * @var LastName - */ - private $lastName; - - /** - * @var Email - */ - private $email; - - /** - * @var Password - */ - private $password; - - /** - * @var int - */ - private $defaultGroupId; - - /** - * @var int[] - */ - private $groupIds; - - /** - * @var int|null - */ - private $genderId; - - /** - * @var bool - */ - private $isEnabled; - - /** - * @var bool - */ - private $isPartnerOffersSubscribed; - - /** - * @var Birthday - */ - private $birthday; - - /** - * @var int - */ - private $shopId; - - /** - * @var string|null Only for B2b customers - */ - private $companyName; - - /** - * @var string|null Only for B2b customers - */ - private $siretCode; - - /** - * @var ApeCode|null Only for B2b customers - */ - private $apeCode; - - /** - * @var string|null Only for B2b customers - */ - private $website; - - /** - * @var float|null Only for B2b customers - */ - private $allowedOutstandingAmount; - - /** - * @var int|null Only for B2b customers - */ - private $maxPaymentDays; - - /** - * @var int|null Only for B2b customers - */ - private $riskId; - - /** - * @param string $firstName - * @param string $lastName - * @param string $email - * @param string $password - * @param int $defaultGroupId - * @param int[] $groupIds - * @param int $shopId - * @param int|null $genderId - * @param bool $isEnabled - * @param bool $isPartnerOffersSubscribed - * @param string|null $birthday - */ - public function __construct( - $firstName, - $lastName, - $email, - $password, - $defaultGroupId, - array $groupIds, - $shopId, - $genderId = null, - $isEnabled = true, - $isPartnerOffersSubscribed = false, - $birthday = null - ) { - $this->firstName = new FirstName($firstName); - $this->lastName = new LastName($lastName); - $this->email = new Email($email); - $this->password = new Password($password); - $this->defaultGroupId = $defaultGroupId; - $this->groupIds = $groupIds; - $this->shopId = $shopId; - $this->genderId = $genderId; - $this->isEnabled = $isEnabled; - $this->isPartnerOffersSubscribed = $isPartnerOffersSubscribed; - $this->birthday = null !== $birthday ? new Birthday($birthday) : Birthday::createEmpty(); - } - - /** - * @return FirstName - */ - public function getFirstName() - { - return $this->firstName; - } - - /** - * @return LastName - */ - public function getLastName() - { - return $this->lastName; - } - - /** - * @return Email - */ - public function getEmail() - { - return $this->email; - } - - /** - * @return Password - */ - public function getPassword() - { - return $this->password; - } - - /** - * @return int - */ - public function getDefaultGroupId() - { - return $this->defaultGroupId; - } - - /** - * @return int[] - */ - public function getGroupIds() - { - return $this->groupIds; - } - - /** - * @return int|null - */ - public function getGenderId() - { - return $this->genderId; - } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->isEnabled; - } - - /** - * @return bool - */ - public function isPartnerOffersSubscribed() - { - return $this->isPartnerOffersSubscribed; - } - - /** - * @return Birthday - */ - public function getBirthday() - { - return $this->birthday; - } - - /** - * @return int - */ - public function getShopId() - { - return $this->shopId; - } - - /** - * @return string|null - */ - public function getCompanyName() - { - return $this->companyName; - } - - /** - * @param string $companyName - * - * @return self - */ - public function setCompanyName($companyName) - { - $this->companyName = $companyName; - - return $this; - } - - /** - * @return string|null - */ - public function getSiretCode() - { - return $this->siretCode; - } - - /** - * @param string $siretCode - * - * @return self - */ - public function setSiretCode($siretCode) - { - $this->siretCode = $siretCode; - - return $this; - } - - /** - * @return ApeCode|null - */ - public function getApeCode() - { - return $this->apeCode; - } - - /** - * @param string $apeCode - * - * @return self - */ - public function setApeCode($apeCode) - { - $this->apeCode = new ApeCode($apeCode); - - return $this; - } - - /** - * @return string|null - */ - public function getWebsite() - { - return $this->website; - } - - /** - * @param string $website - * - * @return self - */ - public function setWebsite($website) - { - $this->website = $website; - - return $this; - } - - /** - * @return float|null - */ - public function getAllowedOutstandingAmount() - { - return $this->allowedOutstandingAmount; - } - - /** - * @param float $allowedOutstandingAmount - * - * @return self - */ - public function setAllowedOutstandingAmount($allowedOutstandingAmount) - { - $this->allowedOutstandingAmount = $allowedOutstandingAmount; - - return $this; - } - - /** - * @return int|null - */ - public function getMaxPaymentDays() - { - return $this->maxPaymentDays; - } - - /** - * @param int $maxPaymentDays - * - * @return self - */ - public function setMaxPaymentDays($maxPaymentDays) - { - $this->maxPaymentDays = $maxPaymentDays; - - return $this; - } - - /** - * @return int|null - */ - public function getRiskId() - { - return $this->riskId; - } - - /** - * @param int $riskId - * - * @return self - */ - public function setRiskId($riskId) - { - $this->riskId = $riskId; - - return $this; - } -} diff --git a/src/Core/Domain/Customer/Command/BulkDeleteCustomerCommand.php b/src/Core/Domain/Customer/Command/BulkDeleteCustomerCommand.php deleted file mode 100644 index b2f758b7..00000000 --- a/src/Core/Domain/Customer/Command/BulkDeleteCustomerCommand.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Command; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerDeleteMethod; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Deletes given customers. - */ -class BulkDeleteCustomerCommand -{ - /** - * @var CustomerId[] - */ - private $customerIds; - - /** - * @var CustomerDeleteMethod - */ - private $deleteMethod; - - /** - * @param int[] $customerIds - * @param string $deleteMethod - */ - public function __construct(array $customerIds, $deleteMethod) - { - $this->setCustomerIds($customerIds); - $this->deleteMethod = new CustomerDeleteMethod($deleteMethod); - } - - /** - * @return CustomerId[] - */ - public function getCustomerIds() - { - return $this->customerIds; - } - - /** - * @return CustomerDeleteMethod - */ - public function getDeleteMethod() - { - return $this->deleteMethod; - } - - /** - * @param int[] $customerIds - */ - private function setCustomerIds(array $customerIds) - { - foreach ($customerIds as $customerId) { - $this->customerIds[] = new CustomerId($customerId); - } - } -} diff --git a/src/Core/Domain/Customer/Command/BulkDisableCustomerCommand.php b/src/Core/Domain/Customer/Command/BulkDisableCustomerCommand.php deleted file mode 100644 index 9bb8720d..00000000 --- a/src/Core/Domain/Customer/Command/BulkDisableCustomerCommand.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Command; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Disables customers in bulk action. - */ -class BulkDisableCustomerCommand -{ - /** - * @var CustomerId[] - */ - private $customerIds = []; - - /** - * @param int[] $customerIds - */ - public function __construct(array $customerIds) - { - $this->setCustomerIds($customerIds); - } - - /** - * @return CustomerId[] - */ - public function getCustomerIds() - { - return $this->customerIds; - } - - /** - * @param int[] $customerIds - */ - private function setCustomerIds(array $customerIds) - { - foreach ($customerIds as $customerId) { - $this->customerIds[] = new CustomerId($customerId); - } - } -} diff --git a/src/Core/Domain/Customer/Command/BulkEnableCustomerCommand.php b/src/Core/Domain/Customer/Command/BulkEnableCustomerCommand.php deleted file mode 100644 index a0d2776e..00000000 --- a/src/Core/Domain/Customer/Command/BulkEnableCustomerCommand.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Command; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Enables customers in bulk action. - */ -class BulkEnableCustomerCommand -{ - /** - * @var CustomerId[] - */ - private $customerIds = []; - - /** - * @param int[] $customerIds - */ - public function __construct(array $customerIds) - { - $this->setCustomerIds($customerIds); - } - - /** - * @return CustomerId[] - */ - public function getCustomerIds() - { - return $this->customerIds; - } - - /** - * @param int[] $customerIds - */ - private function setCustomerIds(array $customerIds) - { - foreach ($customerIds as $customerId) { - $this->customerIds[] = new CustomerId($customerId); - } - } -} diff --git a/src/Core/Domain/Customer/Command/DeleteCustomerCommand.php b/src/Core/Domain/Customer/Command/DeleteCustomerCommand.php deleted file mode 100644 index c2626633..00000000 --- a/src/Core/Domain/Customer/Command/DeleteCustomerCommand.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Command; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerDeleteMethod; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Deletes given customer. - */ -class DeleteCustomerCommand -{ - /** - * @var CustomerId - */ - private $customerId; - - /** - * @var CustomerDeleteMethod - */ - private $deleteMethod; - - /** - * @param int $customerId - * @param string $deleteMethod - */ - public function __construct($customerId, $deleteMethod) - { - $this->customerId = new CustomerId($customerId); - $this->deleteMethod = new CustomerDeleteMethod($deleteMethod); - } - - /** - * @return CustomerId - */ - public function getCustomerId() - { - return $this->customerId; - } - - /** - * @return CustomerDeleteMethod - */ - public function getDeleteMethod() - { - return $this->deleteMethod; - } -} diff --git a/src/Core/Domain/Customer/Command/EditCustomerCommand.php b/src/Core/Domain/Customer/Command/EditCustomerCommand.php deleted file mode 100644 index 7c624394..00000000 --- a/src/Core/Domain/Customer/Command/EditCustomerCommand.php +++ /dev/null @@ -1,513 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Command; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\ApeCode; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\Birthday; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\FirstName; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\LastName; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\Password; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -/** - * Edits provided customer. - * It can edit either all or partial data. - * - * Only not-null values are considered when editing customer. - * For example, if the email is null, then the original value is not modified, - * however, if email is set, then the original value will be overwritten. - */ -class EditCustomerCommand -{ - /** - * @var CustomerId - */ - private $customerId; - - /** - * @var FirstName|null - */ - private $firstName; - - /** - * @var LastName|null - */ - private $lastName; - - /** - * @var Email|null - */ - private $email; - - /** - * @var Password|null - */ - private $password; - - /** - * @var int|null - */ - private $defaultGroupId; - - /** - * @var int[]|null - */ - private $groupIds; - - /** - * @var int|null - */ - private $genderId; - - /** - * @var bool|null - */ - private $isNewsletterSubscribed; - - /** - * @var bool - */ - private $isEnabled; - - /** - * @var bool|null - */ - private $isPartnerOffersSubscribed; - - /** - * @var Birthday|null - */ - private $birthday; - - /** - * @var string|null - */ - private $companyName; - - /** - * @var string|null - */ - private $siretCode; - - /** - * @var ApeCode|null - */ - private $apeCode; - - /** - * @var string|null - */ - private $website; - - /** - * @var float|null - */ - private $allowedOutstandingAmount; - - /** - * @var int|null - */ - private $maxPaymentDays; - - /** - * @var int|null - */ - private $riskId; - - /** - * @param int $customerId - */ - public function __construct($customerId) - { - $this->customerId = new CustomerId($customerId); - } - - /** - * @return CustomerId - */ - public function getCustomerId() - { - return $this->customerId; - } - - /** - * @return FirstName|null - */ - public function getFirstName() - { - return $this->firstName; - } - - /** - * @param string $firstName - * - * @return self - */ - public function setFirstName($firstName) - { - $this->firstName = new FirstName($firstName); - - return $this; - } - - /** - * @return LastName|null - */ - public function getLastName() - { - return $this->lastName; - } - - /** - * @param string $lastName - * - * @return self - */ - public function setLastName($lastName) - { - $this->lastName = new LastName($lastName); - - return $this; - } - - /** - * @return Email|null - */ - public function getEmail() - { - return $this->email; - } - - /** - * @param string $email - * - * @return self - */ - public function setEmail($email) - { - $this->email = new Email($email); - - return $this; - } - - /** - * @return Password|null - */ - public function getPassword() - { - return $this->password; - } - - /** - * @param string $password - * - * @return self - */ - public function setPassword($password) - { - $this->password = new Password($password); - - return $this; - } - - /** - * @return int|null - */ - public function getDefaultGroupId() - { - return $this->defaultGroupId; - } - - /** - * @param int $defaultGroupId - * - * @return self - */ - public function setDefaultGroupId($defaultGroupId) - { - $this->defaultGroupId = $defaultGroupId; - - return $this; - } - - /** - * @return int[]|null - */ - public function getGroupIds() - { - return $this->groupIds; - } - - /** - * @param int[] $groupIds - * - * @return self - */ - public function setGroupIds(array $groupIds) - { - $this->groupIds = $groupIds; - - return $this; - } - - /** - * @return int|null - */ - public function getGenderId() - { - return $this->genderId; - } - - /** - * @param int $genderId - * - * @return self - */ - public function setGenderId($genderId) - { - $this->genderId = $genderId; - - return $this; - } - - /** - * @return bool - */ - public function isNewsletterSubscribed() - { - return $this->isNewsletterSubscribed; - } - - /** - * @param bool $isNewsletterSubscribed - */ - public function setNewsletterSubscribed($isNewsletterSubscribed) - { - $this->isNewsletterSubscribed = $isNewsletterSubscribed; - } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->isEnabled; - } - - /** - * @param bool $isEnabled - * - * @return self - */ - public function setIsEnabled($isEnabled) - { - $this->isEnabled = $isEnabled; - - return $this; - } - - /** - * @return bool - */ - public function isPartnerOffersSubscribed() - { - return $this->isPartnerOffersSubscribed; - } - - /** - * @param bool $isPartnerOffersSubscribed - * - * @return self - */ - public function setIsPartnerOffersSubscribed($isPartnerOffersSubscribed) - { - $this->isPartnerOffersSubscribed = $isPartnerOffersSubscribed; - - return $this; - } - - /** - * @return Birthday|null - */ - public function getBirthday() - { - return $this->birthday; - } - - /** - * @param string $birthday - * - * @return self - */ - public function setBirthday($birthday) - { - $this->birthday = new Birthday($birthday); - - return $this; - } - - /** - * @return string|null - */ - public function getCompanyName() - { - return $this->companyName; - } - - /** - * @param string $companyName - * - * @return self - */ - public function setCompanyName($companyName) - { - $this->companyName = $companyName; - - return $this; - } - - /** - * @return string|null - */ - public function getSiretCode() - { - return $this->siretCode; - } - - /** - * @param string $siretCode - * - * @return self - */ - public function setSiretCode($siretCode) - { - $this->siretCode = $siretCode; - - return $this; - } - - /** - * @return ApeCode|null - */ - public function getApeCode() - { - return $this->apeCode; - } - - /** - * @param string $apeCode - * - * @return self - */ - public function setApeCode($apeCode) - { - $this->apeCode = new ApeCode($apeCode); - - return $this; - } - - /** - * @return string|null - */ - public function getWebsite() - { - return $this->website; - } - - /** - * @param string $website - * - * @return self - */ - public function setWebsite($website) - { - $this->website = $website; - - return $this; - } - - /** - * @return float|null - */ - public function getAllowedOutstandingAmount() - { - return $this->allowedOutstandingAmount; - } - - /** - * @param float $allowedOutstandingAmount - * - * @return self - */ - public function setAllowedOutstandingAmount($allowedOutstandingAmount) - { - $this->allowedOutstandingAmount = $allowedOutstandingAmount; - - return $this; - } - - /** - * @return int|null - */ - public function getMaxPaymentDays() - { - return $this->maxPaymentDays; - } - - /** - * @param int $maxPaymentDays - * - * @return self - */ - public function setMaxPaymentDays($maxPaymentDays) - { - $this->maxPaymentDays = $maxPaymentDays; - - return $this; - } - - /** - * @return int|null - */ - public function getRiskId() - { - return $this->riskId; - } - - /** - * @param int $riskId - * - * @return self - */ - public function setRiskId($riskId) - { - $this->riskId = $riskId; - - return $this; - } -} diff --git a/src/Core/Domain/Customer/Command/SetPrivateNoteAboutCustomerCommand.php b/src/Core/Domain/Customer/Command/SetPrivateNoteAboutCustomerCommand.php deleted file mode 100644 index fc899c71..00000000 --- a/src/Core/Domain/Customer/Command/SetPrivateNoteAboutCustomerCommand.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Command; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Sets private note about customer that can only be seen in Back Office - */ -class SetPrivateNoteAboutCustomerCommand -{ - /** - * @var CustomerId - */ - private $customerId; - - /** - * @var string - */ - private $privateNote; - - /** - * @param int $customerId - * @param string $privateNote - */ - public function __construct($customerId, $privateNote) - { - $this->assertPrivateNoteIsString($privateNote); - - $this->customerId = new CustomerId($customerId); - $this->privateNote = $privateNote; - } - - /** - * @return CustomerId - */ - public function getCustomerId() - { - return $this->customerId; - } - - /** - * @return string - */ - public function getPrivateNote() - { - return $this->privateNote; - } - - /** - * @param string $privateNote - * - * @throws CustomerConstraintException - */ - private function assertPrivateNoteIsString($privateNote) - { - if (!is_string($privateNote)) { - throw new CustomerConstraintException('Invalid private note provided. Private note must be a string.', CustomerConstraintException::INVALID_PRIVATE_NOTE); - } - } -} diff --git a/src/Core/Domain/Customer/Command/SetRequiredFieldsForCustomerCommand.php b/src/Core/Domain/Customer/Command/SetRequiredFieldsForCustomerCommand.php deleted file mode 100644 index 75e8d4da..00000000 --- a/src/Core/Domain/Customer/Command/SetRequiredFieldsForCustomerCommand.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Command; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\InvalidCustomerRequiredFieldsException; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\RequiredField; - -/** - * Sets required fields for new customer when signing up in Front Office - */ -class SetRequiredFieldsForCustomerCommand -{ - /** - * @var string[] - */ - private $requiredFields; - - /** - * @param string[] $requiredFields - */ - public function __construct(array $requiredFields) - { - $this->assertContainsOnlyAllowedFields($requiredFields); - - $this->requiredFields = $requiredFields; - } - - /** - * @return string[] - */ - public function getRequiredFields() - { - return $this->requiredFields; - } - - /** - * Check that all provided fields are allowed. - * - * @param string[] $requiredFields - */ - private function assertContainsOnlyAllowedFields(array $requiredFields) - { - if (empty($requiredFields)) { - return; - } - - if (!empty(array_diff($requiredFields, RequiredField::ALLOWED_REQUIRED_FIELDS))) { - throw new InvalidCustomerRequiredFieldsException(sprintf('Invalid customer required fields provided. Allowed fields are: %s', implode(',', RequiredField::ALLOWED_REQUIRED_FIELDS))); - } - } -} diff --git a/src/Core/Domain/Customer/Command/TransformGuestToCustomerCommand.php b/src/Core/Domain/Customer/Command/TransformGuestToCustomerCommand.php deleted file mode 100644 index ec845b4c..00000000 --- a/src/Core/Domain/Customer/Command/TransformGuestToCustomerCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Command; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Transforms guest (customer without password) into registered customer account - */ -class TransformGuestToCustomerCommand -{ - /** - * @var CustomerId - */ - private $customerId; - - /** - * @param int $customerId - */ - public function __construct($customerId) - { - $this->customerId = new CustomerId($customerId); - } - - /** - * @return CustomerId - */ - public function getCustomerId() - { - return $this->customerId; - } -} diff --git a/src/Core/Domain/Customer/CommandHandler/AddCustomerHandlerInterface.php b/src/Core/Domain/Customer/CommandHandler/AddCustomerHandlerInterface.php deleted file mode 100644 index b5369f81..00000000 --- a/src/Core/Domain/Customer/CommandHandler/AddCustomerHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\AddCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Interface for service that handles command that adds new customer - */ -interface AddCustomerHandlerInterface -{ - /** - * @param AddCustomerCommand $command - * - * @return CustomerId - */ - public function handle(AddCustomerCommand $command); -} diff --git a/src/Core/Domain/Customer/CommandHandler/BulkDeleteCustomerHandlerInterface.php b/src/Core/Domain/Customer/CommandHandler/BulkDeleteCustomerHandlerInterface.php deleted file mode 100644 index 9d5b6ceb..00000000 --- a/src/Core/Domain/Customer/CommandHandler/BulkDeleteCustomerHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\BulkDeleteCustomerCommand; - -/** - * Defines interface for customer bulk delete command handler. - */ -interface BulkDeleteCustomerHandlerInterface -{ - /** - * @param BulkDeleteCustomerCommand $command - */ - public function handle(BulkDeleteCustomerCommand $command); -} diff --git a/src/Core/Domain/Customer/CommandHandler/BulkDisableCustomerHandlerInterface.php b/src/Core/Domain/Customer/CommandHandler/BulkDisableCustomerHandlerInterface.php deleted file mode 100644 index 5c9bd359..00000000 --- a/src/Core/Domain/Customer/CommandHandler/BulkDisableCustomerHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\BulkDisableCustomerCommand; - -/** - * Defines interface for handling command that disables given customers. - */ -interface BulkDisableCustomerHandlerInterface -{ - /** - * @param BulkDisableCustomerCommand $command - */ - public function handle(BulkDisableCustomerCommand $command); -} diff --git a/src/Core/Domain/Customer/CommandHandler/BulkEnableCustomerHandlerInterface.php b/src/Core/Domain/Customer/CommandHandler/BulkEnableCustomerHandlerInterface.php deleted file mode 100644 index d12c0abb..00000000 --- a/src/Core/Domain/Customer/CommandHandler/BulkEnableCustomerHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\BulkEnableCustomerCommand; - -/** - * Defines interface for handling command that enables given customers. - */ -interface BulkEnableCustomerHandlerInterface -{ - /** - * @param BulkEnableCustomerCommand $command - */ - public function handle(BulkEnableCustomerCommand $command); -} diff --git a/src/Core/Domain/Customer/CommandHandler/DeleteCustomerHandlerInterface.php b/src/Core/Domain/Customer/CommandHandler/DeleteCustomerHandlerInterface.php deleted file mode 100644 index 33644f06..00000000 --- a/src/Core/Domain/Customer/CommandHandler/DeleteCustomerHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\DeleteCustomerCommand; - -/** - * Defines interface for handling command that deletes given customer. - */ -interface DeleteCustomerHandlerInterface -{ - /** - * @param DeleteCustomerCommand $command - */ - public function handle(DeleteCustomerCommand $command); -} diff --git a/src/Core/Domain/Customer/CommandHandler/EditCustomerHandlerInterface.php b/src/Core/Domain/Customer/CommandHandler/EditCustomerHandlerInterface.php deleted file mode 100644 index f06165bb..00000000 --- a/src/Core/Domain/Customer/CommandHandler/EditCustomerHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\EditCustomerCommand; - -/** - * Interface for service that handles customer editing command - */ -interface EditCustomerHandlerInterface -{ - /** - * @param EditCustomerCommand $command - */ - public function handle(EditCustomerCommand $command); -} diff --git a/src/Core/Domain/Customer/CommandHandler/SetPrivateNoteAboutCustomerHandlerInterface.php b/src/Core/Domain/Customer/CommandHandler/SetPrivateNoteAboutCustomerHandlerInterface.php deleted file mode 100644 index b93ccceb..00000000 --- a/src/Core/Domain/Customer/CommandHandler/SetPrivateNoteAboutCustomerHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\SetPrivateNoteAboutCustomerCommand; - -/** - * Defines interface for service that handles command which sets private note about customer - */ -interface SetPrivateNoteAboutCustomerHandlerInterface -{ - /** - * @param SetPrivateNoteAboutCustomerCommand $command - */ - public function handle(SetPrivateNoteAboutCustomerCommand $command); -} diff --git a/src/Core/Domain/Customer/CommandHandler/SetRequiredFieldsForCustomerHandlerInterface.php b/src/Core/Domain/Customer/CommandHandler/SetRequiredFieldsForCustomerHandlerInterface.php deleted file mode 100644 index ac46be49..00000000 --- a/src/Core/Domain/Customer/CommandHandler/SetRequiredFieldsForCustomerHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\SetRequiredFieldsForCustomerCommand; - -/** - * Defines interface for services that handles setting required fields for customer command. - */ -interface SetRequiredFieldsForCustomerHandlerInterface -{ - /** - * @param SetRequiredFieldsForCustomerCommand $command - */ - public function handle(SetRequiredFieldsForCustomerCommand $command); -} diff --git a/src/Core/Domain/Customer/CommandHandler/TransformGuestToCustomerHandlerInterface.php b/src/Core/Domain/Customer/CommandHandler/TransformGuestToCustomerHandlerInterface.php deleted file mode 100644 index e9e82f81..00000000 --- a/src/Core/Domain/Customer/CommandHandler/TransformGuestToCustomerHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\TransformGuestToCustomerCommand; - -/** - * Defines contract for service that handles command which transforms guest into customer - */ -interface TransformGuestToCustomerHandlerInterface -{ - /** - * @param TransformGuestToCustomerCommand $command - */ - public function handle(TransformGuestToCustomerCommand $command); -} diff --git a/src/Core/Domain/Customer/Exception/CannotSetRequiredFieldsForCustomerException.php b/src/Core/Domain/Customer/Exception/CannotSetRequiredFieldsForCustomerException.php deleted file mode 100644 index 99cb2467..00000000 --- a/src/Core/Domain/Customer/Exception/CannotSetRequiredFieldsForCustomerException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Exception; - -/** - * Is thrown when setting required fields for customer fails - */ -class CannotSetRequiredFieldsForCustomerException extends CustomerException -{ -} diff --git a/src/Core/Domain/Customer/Exception/CustomerByEmailNotFoundException.php b/src/Core/Domain/Customer/Exception/CustomerByEmailNotFoundException.php deleted file mode 100644 index 231e7cac..00000000 --- a/src/Core/Domain/Customer/Exception/CustomerByEmailNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Exception; - -/** - * Thrown on failure to find customer by email - */ -class CustomerByEmailNotFoundException extends CustomerException -{ -} diff --git a/src/Core/Domain/Customer/Exception/CustomerConstraintException.php b/src/Core/Domain/Customer/Exception/CustomerConstraintException.php deleted file mode 100644 index f760dac6..00000000 --- a/src/Core/Domain/Customer/Exception/CustomerConstraintException.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Exception; - -/** - * Is thrown when customer constraint is violated - */ -class CustomerConstraintException extends CustomerException -{ - /** - * @var int Code is used when invalid email is provided for customer - */ - const INVALID_EMAIL = 1; - - /** - * @var int Code is used when invalid first name is provided for customer - */ - const INVALID_FIRST_NAME = 2; - - /** - * @var int Code is used when invalid last name is provided for customer - */ - const INVALID_LAST_NAME = 3; - - /** - * @var int Code is used when invalid password is provided for customer - */ - const INVALID_PASSWORD = 4; - - /** - * @var int Code is used when invalid APE code is provided - */ - const INVALID_APE_CODE = 5; - - /** - * @var int Is used when invalid (not string) private note is provided as private note - */ - const INVALID_PRIVATE_NOTE = 6; - - /** - * @var int Code is used when invalid customer birthday is provided - */ - const INVALID_BIRTHDAY = 7; -} diff --git a/src/Core/Domain/Customer/Exception/CustomerDefaultGroupAccessException.php b/src/Core/Domain/Customer/Exception/CustomerDefaultGroupAccessException.php deleted file mode 100644 index da7e8749..00000000 --- a/src/Core/Domain/Customer/Exception/CustomerDefaultGroupAccessException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Exception; - -/** - * Exception is thrown when customer's default groups is not configured as access group. - * This means that default group must also be configured as access group for customer. - */ -class CustomerDefaultGroupAccessException extends CustomerException -{ -} diff --git a/src/Core/Domain/Customer/Exception/CustomerException.php b/src/Core/Domain/Customer/Exception/CustomerException.php deleted file mode 100644 index 3f0e983e..00000000 --- a/src/Core/Domain/Customer/Exception/CustomerException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Class CustomerException is base "Customer" context exception - */ -class CustomerException extends DomainException -{ -} diff --git a/src/Core/Domain/Customer/Exception/CustomerNotFoundException.php b/src/Core/Domain/Customer/Exception/CustomerNotFoundException.php deleted file mode 100644 index 5409a7d3..00000000 --- a/src/Core/Domain/Customer/Exception/CustomerNotFoundException.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Is thrown when customer is not found - */ -class CustomerNotFoundException extends CustomerException -{ - /** - * @var CustomerId - */ - private $customerId; - - /** - * @param CustomerId $customerId - * @param string $message - * @param int $code - * @param \Exception|null $previous - */ - public function __construct(CustomerId $customerId, $message = '', $code = 0, $previous = null) - { - $this->customerId = $customerId; - - parent::__construct($message, $code, $previous); - } - - /** - * @return CustomerId - */ - public function getCustomerId() - { - return $this->customerId; - } -} diff --git a/src/Core/Domain/Customer/Exception/CustomerTransformationException.php b/src/Core/Domain/Customer/Exception/CustomerTransformationException.php deleted file mode 100644 index 6e9950b8..00000000 --- a/src/Core/Domain/Customer/Exception/CustomerTransformationException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Exception; - -/** - * Is thrown when customer transformation error occurs - */ -class CustomerTransformationException extends CustomerException -{ - /** - * @var int Code is used when customer which is not guest is being transformed into customer - */ - const CUSTOMER_IS_NOT_GUEST = 1; - - /** - * @var int Code is used when guest transformation into customer has failed - */ - const TRANSFORMATION_FAILED = 2; -} diff --git a/src/Core/Domain/Customer/Exception/DuplicateCustomerEmailException.php b/src/Core/Domain/Customer/Exception/DuplicateCustomerEmailException.php deleted file mode 100644 index b67e35e2..00000000 --- a/src/Core/Domain/Customer/Exception/DuplicateCustomerEmailException.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Exception; - -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -/** - * Exception is thrown when email which already exists is being used to create or update other customer - */ -class DuplicateCustomerEmailException extends CustomerException -{ - /** - * @var Email - */ - private $email; - - /** - * @param Email $email - * @param string $message - * @param int $code - * @param null $previous - */ - public function __construct(Email $email, $message = '', $code = 0, $previous = null) - { - parent::__construct($message, $code, $previous); - - $this->email = $email; - } - - /** - * @return Email - */ - public function getEmail() - { - return $this->email; - } -} diff --git a/src/Core/Domain/Customer/Exception/InvalidCustomerIdException.php b/src/Core/Domain/Customer/Exception/InvalidCustomerIdException.php deleted file mode 100644 index f2007dc0..00000000 --- a/src/Core/Domain/Customer/Exception/InvalidCustomerIdException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Exception; - -/** - * Class InvalidCustomerIdException is thrown when CustomerId with invalid value is being created. - */ -class InvalidCustomerIdException extends CustomerException -{ -} diff --git a/src/Core/Domain/Customer/Exception/InvalidCustomerRequiredFieldsException.php b/src/Core/Domain/Customer/Exception/InvalidCustomerRequiredFieldsException.php deleted file mode 100644 index 10a7057b..00000000 --- a/src/Core/Domain/Customer/Exception/InvalidCustomerRequiredFieldsException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Exception; - -/** - * Thrown when trying to set invalid required fields for customer - */ -class InvalidCustomerRequiredFieldsException extends CustomerException -{ -} diff --git a/src/Core/Domain/Customer/Exception/MissingCustomerRequiredFieldsException.php b/src/Core/Domain/Customer/Exception/MissingCustomerRequiredFieldsException.php deleted file mode 100644 index d9352126..00000000 --- a/src/Core/Domain/Customer/Exception/MissingCustomerRequiredFieldsException.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Exception; - -/** - * Is thrown when adding/editing customer with missing required fields - */ -class MissingCustomerRequiredFieldsException extends CustomerException -{ - /** - * @var string[] - */ - private $missingRequiredFields; - - /** - * @param string[] $missingRequiredFields - * @param string $message - * @param int $code - * @param \Exception|null $previous - */ - public function __construct(array $missingRequiredFields, $message = '', $code = 0, $previous = null) - { - parent::__construct($message, $code, $previous); - - $this->missingRequiredFields = $missingRequiredFields; - } - - /** - * @return string[] - */ - public function getMissingRequiredFields() - { - return $this->missingRequiredFields; - } -} diff --git a/src/Core/Domain/Customer/Query/GetCustomerCarts.php b/src/Core/Domain/Customer/Query/GetCustomerCarts.php deleted file mode 100644 index 36c07108..00000000 --- a/src/Core/Domain/Customer/Query/GetCustomerCarts.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Query; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Query for getting summarized customer carts - */ -class GetCustomerCarts -{ - /** - * @var CustomerId - */ - private $customerId; - - /** - * @param int $customerId - */ - public function __construct(int $customerId) - { - $this->customerId = new CustomerId($customerId); - } - - /** - * @return CustomerId - */ - public function getCustomerId(): CustomerId - { - return $this->customerId; - } -} diff --git a/src/Core/Domain/Customer/Query/GetCustomerForAddressCreation.php b/src/Core/Domain/Customer/Query/GetCustomerForAddressCreation.php deleted file mode 100644 index 13b5ed87..00000000 --- a/src/Core/Domain/Customer/Query/GetCustomerForAddressCreation.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Query; - -/** - * Gets customer information for address creation. - */ -class GetCustomerForAddressCreation -{ - /** - * @var string - */ - private $customerEmail; - - /** - * Query is used for customer search so email string might not be complete so no email validation - * - * @param string $customerEmail - */ - public function __construct(string $customerEmail) - { - $this->customerEmail = $customerEmail; - } - - /** - * @return string - */ - public function getCustomerEmail(): string - { - return $this->customerEmail; - } -} diff --git a/src/Core/Domain/Customer/Query/GetCustomerForEditing.php b/src/Core/Domain/Customer/Query/GetCustomerForEditing.php deleted file mode 100644 index 781f243f..00000000 --- a/src/Core/Domain/Customer/Query/GetCustomerForEditing.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Query; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Gets customer information for editing. - */ -class GetCustomerForEditing -{ - /** - * @var CustomerId - */ - private $customerId; - - /** - * @param int $customerId - */ - public function __construct($customerId) - { - $this->customerId = new CustomerId($customerId); - } - - /** - * @return CustomerId - */ - public function getCustomerId() - { - return $this->customerId; - } -} diff --git a/src/Core/Domain/Customer/Query/GetCustomerForViewing.php b/src/Core/Domain/Customer/Query/GetCustomerForViewing.php deleted file mode 100644 index eb27e187..00000000 --- a/src/Core/Domain/Customer/Query/GetCustomerForViewing.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Query; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Gets detailed customer information for viewing in Back Office. - */ -class GetCustomerForViewing -{ - /** - * @var CustomerId - */ - private $customerId; - - /** - * @param int $customerId - */ - public function __construct($customerId) - { - $this->customerId = new CustomerId($customerId); - } - - /** - * @return CustomerId - */ - public function getCustomerId() - { - return $this->customerId; - } -} diff --git a/src/Core/Domain/Customer/Query/GetCustomerOrders.php b/src/Core/Domain/Customer/Query/GetCustomerOrders.php deleted file mode 100644 index 4efd5365..00000000 --- a/src/Core/Domain/Customer/Query/GetCustomerOrders.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Query; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Query for getting summarized customer orders - */ -class GetCustomerOrders -{ - /** - * @var CustomerId - */ - private $customerId; - - /** - * @param int $customerId - */ - public function __construct(int $customerId) - { - $this->customerId = new CustomerId($customerId); - } - - /** - * @return CustomerId - */ - public function getCustomerId(): CustomerId - { - return $this->customerId; - } -} diff --git a/src/Core/Domain/Customer/Query/GetRequiredFieldsForCustomer.php b/src/Core/Domain/Customer/Query/GetRequiredFieldsForCustomer.php deleted file mode 100644 index 5365b4dd..00000000 --- a/src/Core/Domain/Customer/Query/GetRequiredFieldsForCustomer.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Query; - -/** - * Gets fields that are required for customer sign up - */ -class GetRequiredFieldsForCustomer -{ -} diff --git a/src/Core/Domain/Customer/Query/SearchCustomers.php b/src/Core/Domain/Customer/Query/SearchCustomers.php deleted file mode 100644 index 744ca73b..00000000 --- a/src/Core/Domain/Customer/Query/SearchCustomers.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\Query; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerException; - -/** - * Searchers for customers by phrases matching customer's first name, last name, email and id - */ -class SearchCustomers -{ - /** - * @var string[] - */ - private $phrases; - - /** - * @param string[] $phrases - */ - public function __construct(array $phrases) - { - $this->assertPhrasesAreNotEmpty($phrases); - - $this->phrases = $phrases; - } - - /** - * @return string[] - */ - public function getPhrases() - { - return $this->phrases; - } - - /** - * @param string[] $phrases - */ - private function assertPhrasesAreNotEmpty(array $phrases) - { - if (empty($phrases)) { - throw new CustomerException('Phrases cannot be empty when searching customers.'); - } - } -} diff --git a/src/Core/Domain/Customer/QueryHandler/GetCustomerCartsHandlerInterface.php b/src/Core/Domain/Customer/QueryHandler/GetCustomerCartsHandlerInterface.php deleted file mode 100644 index a46cd939..00000000 --- a/src/Core/Domain/Customer/QueryHandler/GetCustomerCartsHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerCarts; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\CartSummary; - -/** - * Interface for handling GetCustomerCarts query - */ -interface GetCustomerCartsHandlerInterface -{ - /** - * @param GetCustomerCarts $query - * - * @return CartSummary[] - */ - public function handle(GetCustomerCarts $query): array; -} diff --git a/src/Core/Domain/Customer/QueryHandler/GetCustomerForAddressCreationHandlerInterface.php b/src/Core/Domain/Customer/QueryHandler/GetCustomerForAddressCreationHandlerInterface.php deleted file mode 100644 index 824af348..00000000 --- a/src/Core/Domain/Customer/QueryHandler/GetCustomerForAddressCreationHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerForAddressCreation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\AddressCreationCustomerInformation; - -/** - * Defines contract for customer by email search handler - */ -interface GetCustomerForAddressCreationHandlerInterface -{ - /** - * @param GetCustomerForAddressCreation $query - * - * @return AddressCreationCustomerInformation - */ - public function handle(GetCustomerForAddressCreation $query): AddressCreationCustomerInformation; -} diff --git a/src/Core/Domain/Customer/QueryHandler/GetCustomerForEditingHandlerInterface.php b/src/Core/Domain/Customer/QueryHandler/GetCustomerForEditingHandlerInterface.php deleted file mode 100644 index 22bc87e6..00000000 --- a/src/Core/Domain/Customer/QueryHandler/GetCustomerForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerForEditing; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\EditableCustomer; - -/** - * Interface for service that gets customer data for editing - */ -interface GetCustomerForEditingHandlerInterface -{ - /** - * @param GetCustomerForEditing $query - * - * @return EditableCustomer - */ - public function handle(GetCustomerForEditing $query); -} diff --git a/src/Core/Domain/Customer/QueryHandler/GetCustomerForViewingHandlerInterface.php b/src/Core/Domain/Customer/QueryHandler/GetCustomerForViewingHandlerInterface.php deleted file mode 100644 index 0b882371..00000000 --- a/src/Core/Domain/Customer/QueryHandler/GetCustomerForViewingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerForViewing; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\ViewableCustomer; - -/** - * Class GetCustomerInformationHandlerInterface. - */ -interface GetCustomerForViewingHandlerInterface -{ - /** - * @param GetCustomerForViewing $query - * - * @return ViewableCustomer - */ - public function handle(GetCustomerForViewing $query); -} diff --git a/src/Core/Domain/Customer/QueryHandler/GetCustomerOrdersHandlerInterface.php b/src/Core/Domain/Customer/QueryHandler/GetCustomerOrdersHandlerInterface.php deleted file mode 100644 index f51ae57f..00000000 --- a/src/Core/Domain/Customer/QueryHandler/GetCustomerOrdersHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerOrders; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\OrderSummary; - -/** - * Interface for handling GetCustomerOrders query - */ -interface GetCustomerOrdersHandlerInterface -{ - /** - * @param GetCustomerOrders $query - * - * @return OrderSummary[] - */ - public function handle(GetCustomerOrders $query): array; -} diff --git a/src/Core/Domain/Customer/QueryHandler/GetRequiredFieldsForCustomerHandlerInterface.php b/src/Core/Domain/Customer/QueryHandler/GetRequiredFieldsForCustomerHandlerInterface.php deleted file mode 100644 index f587deb6..00000000 --- a/src/Core/Domain/Customer/QueryHandler/GetRequiredFieldsForCustomerHandlerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetRequiredFieldsForCustomer; - -/** - * Defines interface for service that get required fields for customer sign up - */ -interface GetRequiredFieldsForCustomerHandlerInterface -{ - /** - * @param GetRequiredFieldsForCustomer $query - * - * @return string[] - */ - public function handle(GetRequiredFieldsForCustomer $query); -} diff --git a/src/Core/Domain/Customer/QueryHandler/SearchCustomersHandlerInterface.php b/src/Core/Domain/Customer/QueryHandler/SearchCustomersHandlerInterface.php deleted file mode 100644 index 66e0f992..00000000 --- a/src/Core/Domain/Customer/QueryHandler/SearchCustomersHandlerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\SearchCustomers; - -/** - * Interface for service that handles customers searching command - */ -interface SearchCustomersHandlerInterface -{ - /** - * @param SearchCustomers $query - * - * @return array - */ - public function handle(SearchCustomers $query); -} diff --git a/src/Core/Domain/Customer/QueryResult/AddressCreationCustomerInformation.php b/src/Core/Domain/Customer/QueryResult/AddressCreationCustomerInformation.php deleted file mode 100644 index 5a85341a..00000000 --- a/src/Core/Domain/Customer/QueryResult/AddressCreationCustomerInformation.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Provides customer data for address creation - */ -class AddressCreationCustomerInformation -{ - /** - * @var CustomerId - */ - private $customerId; - - /** - * @var string - */ - private $firstName; - - /** - * @var string - */ - private $lastName; - - /** - * @var string|null - */ - private $company; - - /** - * @param int $customerId - * @param string $firstName - * @param string $lastName - */ - public function __construct(int $customerId, string $firstName, string $lastName) - { - $this->customerId = new CustomerId($customerId); - $this->firstName = $firstName; - $this->lastName = $lastName; - } - - /** - * @return CustomerId - */ - public function getCustomerId(): CustomerId - { - return $this->customerId; - } - - /** - * @return string - */ - public function getFirstName(): string - { - return $this->firstName; - } - - /** - * @return string - */ - public function getLastName(): string - { - return $this->lastName; - } - - /** - * @return string|null - */ - public function getCompany(): ?string - { - return $this->company; - } - - /** - * @param string $company - * - * @return AddressCreationCustomerInformation - */ - public function setCompany(string $company): AddressCreationCustomerInformation - { - $this->company = $company; - - return $this; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/AddressInformation.php b/src/Core/Domain/Customer/QueryResult/AddressInformation.php deleted file mode 100644 index 89bb743f..00000000 --- a/src/Core/Domain/Customer/QueryResult/AddressInformation.php +++ /dev/null @@ -1,144 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Class AddressInformation. - */ -class AddressInformation -{ - /** - * @var string - */ - private $company; - - /** - * @var string - */ - private $fullName; - - /** - * @var string - */ - private $fullAddress; - - /** - * @var string - */ - private $countryName; - - /** - * @var string - */ - private $phone; - - /** - * @var string - */ - private $phoneMobile; - - /** - * @var int - */ - private $addressId; - - /** - * @param int $addressId - * @param string $company - * @param string $fullName - * @param string $fullAddress - * @param string $countryName - * @param string $phone - * @param string $phoneMobile - */ - public function __construct($addressId, $company, $fullName, $fullAddress, $countryName, $phone, $phoneMobile) - { - $this->addressId = $addressId; - $this->company = $company; - $this->fullName = $fullName; - $this->fullAddress = $fullAddress; - $this->countryName = $countryName; - $this->phone = $phone; - $this->phoneMobile = $phoneMobile; - } - - /** - * @return int - */ - public function getAddressId() - { - return $this->addressId; - } - - /** - * @return string - */ - public function getCompany() - { - return $this->company; - } - - /** - * @return string - */ - public function getFullName() - { - return $this->fullName; - } - - /** - * @return string - */ - public function getFullAddress() - { - return $this->fullAddress; - } - - /** - * @return string - */ - public function getCountryName() - { - return $this->countryName; - } - - /** - * @return string - */ - public function getPhone() - { - return $this->phone; - } - - /** - * @return string - */ - public function getPhoneMobile() - { - return $this->phoneMobile; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/BoughtProductInformation.php b/src/Core/Domain/Customer/QueryResult/BoughtProductInformation.php deleted file mode 100644 index 5082ec99..00000000 --- a/src/Core/Domain/Customer/QueryResult/BoughtProductInformation.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Class BoughtProductInformation holds information about product that customer has bought. - */ -class BoughtProductInformation -{ - /** - * @var int - */ - private $orderId; - - /** - * @var string - */ - private $boughtDate; - - /** - * @var string - */ - private $productName; - - /** - * @var int - */ - private $boughtQuantity; - - /** - * @param int $orderId - * @param string $boughtDate - * @param string $productName - * @param int $boughtQuantity - */ - public function __construct( - $orderId, - $boughtDate, - $productName, - $boughtQuantity - ) { - $this->orderId = $orderId; - $this->boughtDate = $boughtDate; - $this->productName = $productName; - $this->boughtQuantity = $boughtQuantity; - } - - /** - * @return int - */ - public function getOrderId() - { - return $this->orderId; - } - - /** - * @return string - */ - public function getBoughtDate() - { - return $this->boughtDate; - } - - /** - * @return string - */ - public function getProductName() - { - return $this->productName; - } - - /** - * @return int - */ - public function getBoughtQuantity() - { - return $this->boughtQuantity; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/CartInformation.php b/src/Core/Domain/Customer/QueryResult/CartInformation.php deleted file mode 100644 index badc1969..00000000 --- a/src/Core/Domain/Customer/QueryResult/CartInformation.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Class CustomerCartInformation. - */ -class CartInformation -{ - /** - * @var string - */ - private $cartId; - - /** - * @var string - */ - private $cartCreationDate; - - /** - * @var string - */ - private $cartTotal; - - /** - * @var string - */ - private $carrierName; - - /** - * @param string $cartId - * @param string $cartCreationDate - * @param string $cartTotal - * @param string $carrierName - */ - public function __construct( - $cartId, - $cartCreationDate, - $cartTotal, - $carrierName - ) { - $this->cartId = $cartId; - $this->cartCreationDate = $cartCreationDate; - $this->cartTotal = $cartTotal; - $this->carrierName = $carrierName; - } - - /** - * @return string - */ - public function getCartId() - { - return $this->cartId; - } - - /** - * @return string - */ - public function getCartCreationDate() - { - return $this->cartCreationDate; - } - - /** - * @return string - */ - public function getCartTotal() - { - return $this->cartTotal; - } - - /** - * @return string - */ - public function getCarrierName() - { - return $this->carrierName; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/CartSummary.php b/src/Core/Domain/Customer/QueryResult/CartSummary.php deleted file mode 100644 index 5d7ecf37..00000000 --- a/src/Core/Domain/Customer/QueryResult/CartSummary.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Holds data of summarized cart - */ -class CartSummary -{ - /** - * @var int - */ - private $cartId; - - /** - * @var string - */ - private $creationDate; - - /** - * @var string - */ - private $totalPrice; - - /** - * @param int $cartId - * @param string $creationDate - * @param string $totalPrice - */ - public function __construct( - int $cartId, - string $creationDate, - string $totalPrice - ) { - $this->cartId = $cartId; - $this->creationDate = $creationDate; - $this->totalPrice = $totalPrice; - } - - /** - * @return int - */ - public function getCartId(): int - { - return $this->cartId; - } - - /** - * @return string - */ - public function getCreationDate(): string - { - return $this->creationDate; - } - - /** - * @return string - */ - public function getTotalPrice(): string - { - return $this->totalPrice; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/DiscountInformation.php b/src/Core/Domain/Customer/QueryResult/DiscountInformation.php deleted file mode 100644 index 0c301ba2..00000000 --- a/src/Core/Domain/Customer/QueryResult/DiscountInformation.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Class DiscountInformation. - */ -class DiscountInformation -{ - /** - * @var int - */ - private $discountId; - - /** - * @var string - */ - private $code; - - /** - * @var string - */ - private $name; - - /** - * @var bool - */ - private $isActive; - - /** - * @var int - */ - private $availableQuantity; - - /** - * @param int $discountId - * @param string $code - * @param string $name - * @param bool $isActive - * @param int $availableQuantity - */ - public function __construct( - $discountId, - $code, - $name, - $isActive, - $availableQuantity - ) { - $this->discountId = $discountId; - $this->code = $code; - $this->name = $name; - $this->isActive = $isActive; - $this->availableQuantity = $availableQuantity; - } - - /** - * @return int - */ - public function getDiscountId() - { - return $this->discountId; - } - - /** - * @return string - */ - public function getCode() - { - return $this->code; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return bool - */ - public function isActive() - { - return $this->isActive; - } - - /** - * @return int - */ - public function getAvailableQuantity() - { - return $this->availableQuantity; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/EditableCustomer.php b/src/Core/Domain/Customer/QueryResult/EditableCustomer.php deleted file mode 100644 index e992846b..00000000 --- a/src/Core/Domain/Customer/QueryResult/EditableCustomer.php +++ /dev/null @@ -1,333 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\Birthday; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\FirstName; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\LastName; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -/** - * Stores editable data for customer - */ -class EditableCustomer -{ - /** - * @var CustomerId - */ - private $customerId; - - /** - * @var int - */ - private $genderId; - - /** - * @var string - */ - private $firstName; - - /** - * @var string - */ - private $lastName; - - /** - * @var string - */ - private $email; - - /** - * @var Birthday - */ - private $birthday; - - /** - * @var bool - */ - private $isEnabled; - - /** - * @var bool - */ - private $isPartnerOffersSubscribed; - - /** - * @var bool - */ - private $isNewsletterSubscribed; - - /** - * @var array|int[] - */ - private $groupIds; - - /** - * @var int - */ - private $defaultGroupId; - - /** - * @var string - */ - private $companyName; - - /** - * @var string - */ - private $siretCode; - - /** - * @var string - */ - private $apeCode; - - /** - * @var string - */ - private $website; - - /** - * @var float - */ - private $allowedOutstandingAmount; - - /** - * @var int - */ - private $maxPaymentDays; - - /** - * @var int - */ - private $riskId; - - /** - * @param CustomerId $customerId - * @param int $genderId - * @param FirstName $firstName - * @param LastName $lastName - * @param Email $email - * @param Birthday $birthday - * @param bool $isEnabled - * @param bool $isPartnerOffersSubscribed - * @param bool $isNewsletterSubscribed - * @param int[] $groupIds - * @param int $defaultGroupId - * @param string $companyName - * @param string $siretCode - * @param string $apeCode - * @param string $website - * @param float $allowedOutstandingAmount - * @param int $maxPaymentDays - * @param int $riskId - */ - public function __construct( - CustomerId $customerId, - $genderId, - FirstName $firstName, - LastName $lastName, - Email $email, - Birthday $birthday, - $isEnabled, - $isPartnerOffersSubscribed, - $isNewsletterSubscribed, - array $groupIds, - $defaultGroupId, - $companyName, - $siretCode, - $apeCode, - $website, - $allowedOutstandingAmount, - $maxPaymentDays, - $riskId - ) { - $this->customerId = $customerId; - $this->genderId = $genderId; - $this->firstName = $firstName; - $this->lastName = $lastName; - $this->email = $email; - $this->birthday = $birthday; - $this->isEnabled = $isEnabled; - $this->isPartnerOffersSubscribed = $isPartnerOffersSubscribed; - $this->isNewsletterSubscribed = $isNewsletterSubscribed; - $this->groupIds = $groupIds; - $this->defaultGroupId = $defaultGroupId; - $this->companyName = $companyName; - $this->siretCode = $siretCode; - $this->apeCode = $apeCode; - $this->website = $website; - $this->allowedOutstandingAmount = $allowedOutstandingAmount; - $this->maxPaymentDays = $maxPaymentDays; - $this->riskId = $riskId; - } - - /** - * @return CustomerId - */ - public function getCustomerId() - { - return $this->customerId; - } - - /** - * @return int - */ - public function getGenderId() - { - return $this->genderId; - } - - /** - * @return FirstName - */ - public function getFirstName() - { - return $this->firstName; - } - - /** - * @return LastName - */ - public function getLastName() - { - return $this->lastName; - } - - /** - * @return Email - */ - public function getEmail() - { - return $this->email; - } - - /** - * @return Birthday - */ - public function getBirthday() - { - return $this->birthday; - } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->isEnabled; - } - - /** - * @return bool - */ - public function isPartnerOffersSubscribed() - { - return $this->isPartnerOffersSubscribed; - } - - /** - * @return array|int[] - */ - public function getGroupIds() - { - return $this->groupIds; - } - - /** - * @return int - */ - public function getDefaultGroupId() - { - return $this->defaultGroupId; - } - - /** - * @return string - */ - public function getCompanyName() - { - return $this->companyName; - } - - /** - * @return string - */ - public function getSiretCode() - { - return $this->siretCode; - } - - /** - * @return string - */ - public function getApeCode() - { - return $this->apeCode; - } - - /** - * @return string - */ - public function getWebsite() - { - return $this->website; - } - - /** - * @return float - */ - public function getAllowedOutstandingAmount() - { - return $this->allowedOutstandingAmount; - } - - /** - * @return int - */ - public function getMaxPaymentDays() - { - return $this->maxPaymentDays; - } - - /** - * @return int - */ - public function getRiskId() - { - return $this->riskId; - } - - /** - * @return bool - */ - public function isNewsletterSubscribed() - { - return $this->isNewsletterSubscribed; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/GeneralInformation.php b/src/Core/Domain/Customer/QueryResult/GeneralInformation.php deleted file mode 100644 index d1cf5620..00000000 --- a/src/Core/Domain/Customer/QueryResult/GeneralInformation.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Class GeneralInformation. - */ -class GeneralInformation -{ - /** - * @var string - */ - private $privateNote; - - /** - * @var string - */ - private $customerBySameEmailExists; - - /** - * @param string $privateNote - * @param bool $customerBySameEmailExists - */ - public function __construct($privateNote, $customerBySameEmailExists) - { - $this->privateNote = $privateNote; - $this->customerBySameEmailExists = $customerBySameEmailExists; - } - - /** - * @return string - */ - public function getPrivateNote() - { - return $this->privateNote; - } - - /** - * @return string - */ - public function getCustomerBySameEmailExists() - { - return $this->customerBySameEmailExists; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/GroupInformation.php b/src/Core/Domain/Customer/QueryResult/GroupInformation.php deleted file mode 100644 index 1046371c..00000000 --- a/src/Core/Domain/Customer/QueryResult/GroupInformation.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Class GroupInformation holds customer group information. - */ -class GroupInformation -{ - /** - * @var int - */ - private $groupId; - - /** - * @var string - */ - private $name; - - /** - * @param int $groupId - * @param string $name - */ - public function __construct($groupId, $name) - { - $this->groupId = $groupId; - $this->name = $name; - } - - /** - * @return int - */ - public function getGroupId() - { - return $this->groupId; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/LastConnectionInformation.php b/src/Core/Domain/Customer/QueryResult/LastConnectionInformation.php deleted file mode 100644 index 68a02e83..00000000 --- a/src/Core/Domain/Customer/QueryResult/LastConnectionInformation.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Class LastConnectionInformation holds information about last customer connection to shop. - */ -class LastConnectionInformation -{ - /** - * @var int - */ - private $connectionId; - - /** - * @var string - */ - private $connectionDate; - - /** - * @var int - */ - private $pagesViewed; - - /** - * @var string - */ - private $totalTime; - - /** - * @var string - */ - private $httpReferer; - - /** - * @var string - */ - private $ipAddress; - - /** - * @param int $connectionId - * @param string $connectionDate - * @param int $pagesViewed - * @param string $totalTime - * @param string $httpReferer - * @param string $ipAddress - */ - public function __construct( - $connectionId, - $connectionDate, - $pagesViewed, - $totalTime, - $httpReferer, - $ipAddress - ) { - $this->connectionId = $connectionId; - $this->connectionDate = $connectionDate; - $this->pagesViewed = $pagesViewed; - $this->totalTime = $totalTime; - $this->httpReferer = $httpReferer; - $this->ipAddress = $ipAddress; - } - - /** - * @return int - */ - public function getConnectionId() - { - return $this->connectionId; - } - - /** - * @return string - */ - public function getConnectionDate() - { - return $this->connectionDate; - } - - /** - * @return int - */ - public function getPagesViewed() - { - return $this->pagesViewed; - } - - /** - * @return string - */ - public function getTotalTime() - { - return $this->totalTime; - } - - /** - * @return string - */ - public function getHttpReferer() - { - return $this->httpReferer; - } - - /** - * @return string - */ - public function getIpAddress() - { - return $this->ipAddress; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/MessageInformation.php b/src/Core/Domain/Customer/QueryResult/MessageInformation.php deleted file mode 100644 index 6f4536fd..00000000 --- a/src/Core/Domain/Customer/QueryResult/MessageInformation.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Class CustomerMessageInformation holds customer message information. - */ -class MessageInformation -{ - /** - * @var int - */ - private $customerThreadId; - - /** - * @var string - */ - private $message; - - /** - * @var string - */ - private $status; - - /** - * @var string - */ - private $date; - - /** - * @param int $customerThreadId - * @param string $message - * @param string $status - * @param string $date - */ - public function __construct($customerThreadId, $message, $status, $date) - { - $this->customerThreadId = $customerThreadId; - $this->message = $message; - $this->status = $status; - $this->date = $date; - } - - /** - * @return int - */ - public function getCustomerThreadId() - { - return $this->customerThreadId; - } - - /** - * @return string - */ - public function getMessage() - { - return $this->message; - } - - /** - * @return string - */ - public function getStatus() - { - return $this->status; - } - - /** - * @return string - */ - public function getDate() - { - return $this->date; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/OrderInformation.php b/src/Core/Domain/Customer/QueryResult/OrderInformation.php deleted file mode 100644 index caf4bd5b..00000000 --- a/src/Core/Domain/Customer/QueryResult/OrderInformation.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Class CustomerOrderInformation. - */ -class OrderInformation -{ - /** - * @var int - */ - private $orderId; - - /** - * @var string - */ - private $orderPlacedDate; - - /** - * @var string - */ - private $paymentMethodName; - - /** - * @var string - */ - private $orderStatus; - - /** - * @var int - */ - private $orderProductsCount; - - /** - * @var string - */ - private $totalPaid; - - /** - * @param int $orderId - * @param string $orderPlacedDate - * @param string $paymentMethodName - * @param string $orderStatus - * @param int $orderProductsCount - * @param string $totalPaid - */ - public function __construct($orderId, $orderPlacedDate, $paymentMethodName, $orderStatus, $orderProductsCount, $totalPaid) - { - $this->orderId = $orderId; - $this->orderPlacedDate = $orderPlacedDate; - $this->paymentMethodName = $paymentMethodName; - $this->orderStatus = $orderStatus; - $this->orderProductsCount = $orderProductsCount; - $this->totalPaid = $totalPaid; - } - - /** - * @return int - */ - public function getOrderId() - { - return $this->orderId; - } - - /** - * @return string - */ - public function getOrderPlacedDate() - { - return $this->orderPlacedDate; - } - - /** - * @return string - */ - public function getPaymentMethodName() - { - return $this->paymentMethodName; - } - - /** - * @return string - */ - public function getOrderStatus() - { - return $this->orderStatus; - } - - /** - * @return int - */ - public function getOrderProductsCount() - { - return $this->orderProductsCount; - } - - /** - * @return string - */ - public function getTotalPaid() - { - return $this->totalPaid; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/OrderSummary.php b/src/Core/Domain/Customer/QueryResult/OrderSummary.php deleted file mode 100644 index 5f9a4959..00000000 --- a/src/Core/Domain/Customer/QueryResult/OrderSummary.php +++ /dev/null @@ -1,136 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Holds data of summarized order - */ -class OrderSummary -{ - /** - * @var int - */ - private $orderId; - - /** - * @var string - */ - private $orderPlacedDate; - - /** - * @var string - */ - private $paymentMethodName; - - /** - * @var string - */ - private $orderStatus; - - /** - * @var int - */ - private $orderProductsCount; - - /** - * @var string - */ - private $totalPaid; - - /** - * OrderForOrderCreation constructor. - * - * @param int $orderId - * @param string $orderPlacedDate - * @param string $paymentMethodName - * @param string $orderStatus - * @param int $orderProductsCount - * @param string $totalPaid - */ - public function __construct( - int $orderId, string $orderPlacedDate, - string $paymentMethodName, - string $orderStatus, - int $orderProductsCount, - string $totalPaid - ) { - $this->orderId = $orderId; - $this->orderPlacedDate = $orderPlacedDate; - $this->paymentMethodName = $paymentMethodName; - $this->orderStatus = $orderStatus; - $this->orderProductsCount = $orderProductsCount; - $this->totalPaid = $totalPaid; - } - - /** - * @return int - */ - public function getOrderId(): int - { - return $this->orderId; - } - - /** - * @return string - */ - public function getOrderPlacedDate(): string - { - return $this->orderPlacedDate; - } - - /** - * @return string - */ - public function getPaymentMethodName(): string - { - return $this->paymentMethodName; - } - - /** - * @return string - */ - public function getOrderStatus(): string - { - return $this->orderStatus; - } - - /** - * @return int - */ - public function getOrderProductsCount(): int - { - return $this->orderProductsCount; - } - - /** - * @return string - */ - public function getTotalPaid(): string - { - return $this->totalPaid; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/OrdersInformation.php b/src/Core/Domain/Customer/QueryResult/OrdersInformation.php deleted file mode 100644 index fc7ac1cf..00000000 --- a/src/Core/Domain/Customer/QueryResult/OrdersInformation.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Class CustomerOrders. - */ -class OrdersInformation -{ - /** - * @var array|OrderInformation[] - */ - private $validOrders; - - /** - * @var array|OrderInformation[] - */ - private $invalidOrders; - - /** - * @var string - */ - private $totalSpent; - - /** - * @param string $totalSpent - * @param OrderInformation[] $validOrders - * @param OrderInformation[] $invalidOrders - */ - public function __construct($totalSpent, array $validOrders, array $invalidOrders) - { - $this->validOrders = $validOrders; - $this->invalidOrders = $invalidOrders; - $this->totalSpent = $totalSpent; - } - - /** - * @return OrderInformation[] - */ - public function getValidOrders() - { - return $this->validOrders; - } - - /** - * @return OrderInformation[] - */ - public function getInvalidOrders() - { - return $this->invalidOrders; - } - - /** - * @return string - */ - public function getTotalSpent() - { - return $this->totalSpent; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/PersonalInformation.php b/src/Core/Domain/Customer/QueryResult/PersonalInformation.php deleted file mode 100644 index 5019deac..00000000 --- a/src/Core/Domain/Customer/QueryResult/PersonalInformation.php +++ /dev/null @@ -1,263 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Class PersonalInformation holds personal customer information. - */ -class PersonalInformation -{ - /** - * @var string - */ - private $firstName; - - /** - * @var string - */ - private $lastName; - - /** - * @var string - */ - private $email; - - /** - * @var bool - */ - private $isGuest; - - /** - * @var string - */ - private $socialTitle; - - /** - * @var string - */ - private $birthday; - - /** - * @var string - */ - private $registrationDate; - - /** - * @var string - */ - private $lastUpdateDate; - - /** - * @var string - */ - private $lastVisitDate; - - /** - * @var string - */ - private $rankBySales; - - /** - * @var string - */ - private $shopName; - - /** - * @var string - */ - private $languageName; - - /** - * @var Subscriptions - */ - private $subscriptions; - - /** - * @var bool - */ - private $isActive; - - /** - * @param string $firstName - * @param string $lastName - * @param string $email - * @param bool $isGuest - * @param string $socialTitle - * @param string $birthday - * @param string $registrationDate - * @param string $lastUpdateDate - * @param string $lastVisitDate - * @param string $rankBySales - * @param string $shopName - * @param string $languageName - * @param Subscriptions $subscriptions - * @param bool $isActive - */ - public function __construct( - $firstName, - $lastName, - $email, - $isGuest, - $socialTitle, - $birthday, - $registrationDate, - $lastUpdateDate, - $lastVisitDate, - $rankBySales, - $shopName, - $languageName, - Subscriptions $subscriptions, - $isActive - ) { - $this->firstName = $firstName; - $this->lastName = $lastName; - $this->email = $email; - $this->isGuest = $isGuest; - $this->socialTitle = $socialTitle; - $this->birthday = $birthday; - $this->registrationDate = $registrationDate; - $this->lastUpdateDate = $lastUpdateDate; - $this->lastVisitDate = $lastVisitDate; - $this->rankBySales = $rankBySales; - $this->shopName = $shopName; - $this->languageName = $languageName; - $this->subscriptions = $subscriptions; - $this->isActive = $isActive; - } - - /** - * @return string - */ - public function getFirstName() - { - return $this->firstName; - } - - /** - * @return string - */ - public function getLastName() - { - return $this->lastName; - } - - /** - * @return string - */ - public function getEmail() - { - return $this->email; - } - - /** - * @return bool - */ - public function isGuest() - { - return $this->isGuest; - } - - /** - * @return string - */ - public function getSocialTitle() - { - return $this->socialTitle; - } - - /** - * @return string - */ - public function getBirthday() - { - return $this->birthday; - } - - /** - * @return string - */ - public function getRegistrationDate() - { - return $this->registrationDate; - } - - /** - * @return string - */ - public function getLastUpdateDate() - { - return $this->lastUpdateDate; - } - - /** - * @return string - */ - public function getLastVisitDate() - { - return $this->lastVisitDate; - } - - /** - * @return string - */ - public function getRankBySales() - { - return $this->rankBySales; - } - - /** - * @return string - */ - public function getShopName() - { - return $this->shopName; - } - - /** - * @return string - */ - public function getLanguageName() - { - return $this->languageName; - } - - /** - * @return Subscriptions - */ - public function getSubscriptions() - { - return $this->subscriptions; - } - - /** - * @return bool - */ - public function isActive() - { - return $this->isActive; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/ProductsInformation.php b/src/Core/Domain/Customer/QueryResult/ProductsInformation.php deleted file mode 100644 index 4dc04522..00000000 --- a/src/Core/Domain/Customer/QueryResult/ProductsInformation.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Class CustomerProductsInformation holds information about products that customers has bought and viewed. - */ -class ProductsInformation -{ - /** - * @var BoughtProductInformation[] - */ - private $boughtProductsInformation; - - /** - * @var ViewedProductInformation[] - */ - private $viewedProductsInformation; - - /** - * @param BoughtProductInformation[] $boughtProductsInformation - * @param ViewedProductInformation[] $viewedProductsInformation - */ - public function __construct(array $boughtProductsInformation, array $viewedProductsInformation) - { - $this->boughtProductsInformation = $boughtProductsInformation; - $this->viewedProductsInformation = $viewedProductsInformation; - } - - /** - * @return BoughtProductInformation[] - */ - public function getBoughtProductsInformation() - { - return $this->boughtProductsInformation; - } - - /** - * @return ViewedProductInformation[] - */ - public function getViewedProductsInformation() - { - return $this->viewedProductsInformation; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/ReferrerInformation.php b/src/Core/Domain/Customer/QueryResult/ReferrerInformation.php deleted file mode 100644 index 995cee6a..00000000 --- a/src/Core/Domain/Customer/QueryResult/ReferrerInformation.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Class ReferrerInformation holds information about customer referrer. - */ -class ReferrerInformation -{ - /** - * @var string - */ - private $date; - - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $shop; - - /** - * @param string $date - * @param string $name - * @param string $shop - */ - public function __construct($date, $name, $shop) - { - $this->date = $date; - $this->name = $name; - $this->shop = $shop; - } - - /** - * @return string - */ - public function getDate() - { - return $this->date; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return string - */ - public function getShop() - { - return $this->shop; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/SentEmailInformation.php b/src/Core/Domain/Customer/QueryResult/SentEmailInformation.php deleted file mode 100644 index 41adedce..00000000 --- a/src/Core/Domain/Customer/QueryResult/SentEmailInformation.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Class SentEmailInformation holds information about email sent to customer. - */ -class SentEmailInformation -{ - /** - * @var string - */ - private $date; - - /** - * @var string - */ - private $language; - - /** - * @var string - */ - private $subject; - - /** - * @var string - */ - private $template; - - /** - * @param string $date - * @param string $language - * @param string $subject - * @param string $template - */ - public function __construct($date, $language, $subject, $template) - { - $this->date = $date; - $this->language = $language; - $this->subject = $subject; - $this->template = $template; - } - - /** - * @return string - */ - public function getDate() - { - return $this->date; - } - - /** - * @return string - */ - public function getLanguage() - { - return $this->language; - } - - /** - * @return string - */ - public function getSubject() - { - return $this->subject; - } - - /** - * @return string - */ - public function getTemplate() - { - return $this->template; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/Subscriptions.php b/src/Core/Domain/Customer/QueryResult/Subscriptions.php deleted file mode 100644 index 47be69e3..00000000 --- a/src/Core/Domain/Customer/QueryResult/Subscriptions.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -class Subscriptions -{ - /** - * @var bool - */ - private $isNewsletterSubscribed; - - /** - * @var bool - */ - private $isPartnerOffersSubscribed; - - /** - * @param bool $isNewsletterSubscribed - * @param bool $isPartnerOffersSubscribed - */ - public function __construct($isNewsletterSubscribed, $isPartnerOffersSubscribed) - { - $this->isNewsletterSubscribed = $isNewsletterSubscribed; - $this->isPartnerOffersSubscribed = $isPartnerOffersSubscribed; - } - - /** - * @return bool - */ - public function isNewsletterSubscribed() - { - return $this->isNewsletterSubscribed; - } - - /** - * @return bool - */ - public function isPartnerOffersSubscribed() - { - return $this->isPartnerOffersSubscribed; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/ViewableCustomer.php b/src/Core/Domain/Customer/QueryResult/ViewableCustomer.php deleted file mode 100644 index 1e9aa606..00000000 --- a/src/Core/Domain/Customer/QueryResult/ViewableCustomer.php +++ /dev/null @@ -1,249 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Class CustomerInformation stores customer information for viewing in Back Office. - */ -class ViewableCustomer -{ - /** - * @var CustomerId - */ - private $customerId; - - /** - * @var PersonalInformation - */ - private $personalInformation; - - /** - * @var OrdersInformation - */ - private $ordersInformation; - - /** - * @var CartInformation[] - */ - private $cartsInformation; - - /** - * @var ProductsInformation - */ - private $productsInformation; - - /** - * @var MessageInformation[] - */ - private $messagesInformation; - - /** - * @var DiscountInformation[] - */ - private $discountsInformation; - - /** - * @var SentEmailInformation[] - */ - private $sentEmailsInformation; - - /** - * @var LastConnectionInformation[] - */ - private $lastConnectionsInformation; - - /** - * @var GroupInformation[] - */ - private $groupsInformation; - - /** - * @var ReferrerInformation[] - */ - private $referrersInformation; - - /** - * @var AddressInformation[] - */ - private $addressesInformation; - - /** - * @var GeneralInformation - */ - private $generalInformation; - - /** - * @param CustomerId $customerId - * @param GeneralInformation $generalInformation - * @param PersonalInformation $personalInformation - * @param OrdersInformation $ordersInformation - * @param CartInformation[] $cartsInformation - * @param ProductsInformation $productsInformation - * @param MessageInformation[] $messagesInformation - * @param DiscountInformation[] $discountsInformation - * @param SentEmailInformation[] $sentEmailsInformation - * @param LastConnectionInformation[] $lastConnectionsInformation - * @param GroupInformation[] $groupsInformation - * @param ReferrerInformation[] $referrersInformation - * @param AddressInformation[] $addressesInformation - */ - public function __construct( - CustomerId $customerId, - GeneralInformation $generalInformation, - PersonalInformation $personalInformation, - OrdersInformation $ordersInformation, - array $cartsInformation, - ProductsInformation $productsInformation, - array $messagesInformation, - array $discountsInformation, - array $sentEmailsInformation, - array $lastConnectionsInformation, - array $groupsInformation, - array $referrersInformation, - array $addressesInformation - ) { - $this->customerId = $customerId; - $this->personalInformation = $personalInformation; - $this->ordersInformation = $ordersInformation; - $this->cartsInformation = $cartsInformation; - $this->productsInformation = $productsInformation; - $this->messagesInformation = $messagesInformation; - $this->discountsInformation = $discountsInformation; - $this->sentEmailsInformation = $sentEmailsInformation; - $this->lastConnectionsInformation = $lastConnectionsInformation; - $this->groupsInformation = $groupsInformation; - $this->referrersInformation = $referrersInformation; - $this->addressesInformation = $addressesInformation; - $this->generalInformation = $generalInformation; - } - - /** - * @return CustomerId - */ - public function getCustomerId() - { - return $this->customerId; - } - - /** - * @return PersonalInformation - */ - public function getPersonalInformation() - { - return $this->personalInformation; - } - - /** - * @return OrdersInformation - */ - public function getOrdersInformation() - { - return $this->ordersInformation; - } - - /** - * @return CartInformation[] - */ - public function getCartsInformation() - { - return $this->cartsInformation; - } - - /** - * @return ProductsInformation - */ - public function getProductsInformation() - { - return $this->productsInformation; - } - - /** - * @return MessageInformation[] - */ - public function getMessagesInformation() - { - return $this->messagesInformation; - } - - /** - * @return DiscountInformation[] - */ - public function getDiscountsInformation() - { - return $this->discountsInformation; - } - - /** - * @return SentEmailInformation[] - */ - public function getSentEmailsInformation() - { - return $this->sentEmailsInformation; - } - - /** - * @return LastConnectionInformation[] - */ - public function getLastConnectionsInformation() - { - return $this->lastConnectionsInformation; - } - - /** - * @return GroupInformation[] - */ - public function getGroupsInformation() - { - return $this->groupsInformation; - } - - /** - * @return ReferrerInformation[] - */ - public function getReferrersInformation() - { - return $this->referrersInformation; - } - - /** - * @return AddressInformation[] - */ - public function getAddressesInformation() - { - return $this->addressesInformation; - } - - /** - * @return GeneralInformation - */ - public function getGeneralInformation() - { - return $this->generalInformation; - } -} diff --git a/src/Core/Domain/Customer/QueryResult/ViewedProductInformation.php b/src/Core/Domain/Customer/QueryResult/ViewedProductInformation.php deleted file mode 100644 index ef58c5d0..00000000 --- a/src/Core/Domain/Customer/QueryResult/ViewedProductInformation.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult; - -/** - * Class ViewedProductInformation holds information about product that customer has viewed. - */ -class ViewedProductInformation -{ - /** - * @var int - */ - private $productId; - - /** - * @var string - */ - private $productName; - - /** - * @var string - */ - private $productUrl; - - /** - * @param int $productId - * @param string $productName - * @param string $productUrl - */ - public function __construct($productId, $productName, $productUrl) - { - $this->productId = $productId; - $this->productName = $productName; - $this->productUrl = $productUrl; - } - - /** - * @return int - */ - public function getProductId() - { - return $this->productId; - } - - /** - * @return string - */ - public function getProductName() - { - return $this->productName; - } - - /** - * @return string - */ - public function getProductUrl() - { - return $this->productUrl; - } -} diff --git a/src/Core/Domain/Customer/ValueObject/ApeCode.php b/src/Core/Domain/Customer/ValueObject/ApeCode.php deleted file mode 100644 index 5a018809..00000000 --- a/src/Core/Domain/Customer/ValueObject/ApeCode.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerConstraintException; - -/** - * Every business in France is classified under an activity code - * entitled APE - Activite Principale de l’Entreprise - */ -class ApeCode -{ - /** - * @var string - */ - private $code; - - /** - * @param $code - */ - public function __construct($code) - { - $this->assertIsApeCode($code); - - $this->code = $code; - } - - /** - * @return string - */ - public function getValue() - { - return $this->code; - } - - private function assertIsApeCode($code) - { - if (is_string($code) && empty($code)) { - return; - } - - $isApeCode = is_string($code) && (bool) preg_match('/^\d{3,4}[a-zA-Z]{1}$/', $code); - - if (!$isApeCode) { - throw new CustomerConstraintException(sprintf('Invalid ape code %s provided', var_export($code, true)), CustomerConstraintException::INVALID_APE_CODE); - } - } -} diff --git a/src/Core/Domain/Customer/ValueObject/Birthday.php b/src/Core/Domain/Customer/ValueObject/Birthday.php deleted file mode 100644 index 0529b5eb..00000000 --- a/src/Core/Domain/Customer/ValueObject/Birthday.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject; - -use DateTime; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerConstraintException; - -/** - * Defines rules for customer birthday and stores it's value - */ -class Birthday -{ - /** - * @var string empty birthday value - * - * It is used as a placeholder value when real birthday is not provided - */ - const EMPTY_BIRTHDAY = '0000-00-00'; - - /** - * @var string Date in format of Y-m-d or empty string for non defined birthday - */ - private $birthday; - - /** - * @return Birthday - */ - public static function createEmpty() - { - return new self(self::EMPTY_BIRTHDAY); - } - - /** - * @param string $birthday - */ - public function __construct($birthday) - { - $this->assertBirthdayIsInValidFormat($birthday); - $this->assertBirthdayIsNotAFutureDate($birthday); - - $this->birthday = $birthday; - } - - /** - * @return string - */ - public function getValue() - { - return $this->birthday; - } - - /** - * @return bool - */ - public function isEmpty() - { - return self::EMPTY_BIRTHDAY === $this->birthday; - } - - /** - * Birthday cannot be date in a future - * - * @param string $birthday - */ - private function assertBirthdayIsNotAFutureDate($birthday) - { - if (self::EMPTY_BIRTHDAY === $birthday) { - return; - } - - $birthdayDateTime = new DateTime($birthday); - $now = new DateTime(); - - if ($birthdayDateTime > $now) { - throw new CustomerConstraintException(sprintf('Invalid birthday "%s" provided. Birthday must be a past date.', $birthdayDateTime->format('Y-m-d')), CustomerConstraintException::INVALID_BIRTHDAY); - } - } - - /** - * Assert that birthday is actual date - * - * @param string $birthday - */ - private function assertBirthdayIsInValidFormat($birthday) - { - if (self::EMPTY_BIRTHDAY === $birthday) { - return; - } - - if (!is_string($birthday) || false === strtotime($birthday)) { - throw new CustomerConstraintException(sprintf('Invalid birthday %s value provided.', var_export($birthday, true)), CustomerConstraintException::INVALID_BIRTHDAY); - } - } -} diff --git a/src/Core/Domain/Customer/ValueObject/CustomerDeleteMethod.php b/src/Core/Domain/Customer/ValueObject/CustomerDeleteMethod.php deleted file mode 100644 index 9b44e207..00000000 --- a/src/Core/Domain/Customer/ValueObject/CustomerDeleteMethod.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerException; - -/** - * Stores method in which customer can be deleted. - */ -class CustomerDeleteMethod -{ - /** - * If this option is used, then deleted customer can register again using same email. - */ - const ALLOW_CUSTOMER_REGISTRATION = 'allow_registration_after'; - - /** - * If this option is used, then deleted customer won't be able to register again using same email. - */ - const DENY_CUSTOMER_REGISTRATION = 'deny_registration_after'; - - /** - * @var int - */ - private $method; - - /** - * @param $method - */ - public function __construct($method) - { - $this->assertMethodIsDefined($method); - - $this->method = $method; - } - - /** - * Check if customer can register after it's deletion. - */ - public function isAllowedToRegisterAfterDelete() - { - return self::ALLOW_CUSTOMER_REGISTRATION === $this->method; - } - - /** - * @return string[] - */ - public static function getAvailableMethods() - { - return [self::ALLOW_CUSTOMER_REGISTRATION, self::DENY_CUSTOMER_REGISTRATION]; - } - - /** - * @param string $method - */ - private function assertMethodIsDefined($method) - { - $definedMethods = [self::ALLOW_CUSTOMER_REGISTRATION, self::DENY_CUSTOMER_REGISTRATION]; - - if (!in_array($method, $definedMethods)) { - throw new CustomerException(sprintf('Supplied customer delete method "%s" does not exists. Available methods are: %s.', $method, implode(',', $definedMethods))); - } - } -} diff --git a/src/Core/Domain/Customer/ValueObject/CustomerId.php b/src/Core/Domain/Customer/ValueObject/CustomerId.php deleted file mode 100644 index a22fc489..00000000 --- a/src/Core/Domain/Customer/ValueObject/CustomerId.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerException; - -/** - * Defines Customer ID with it's constraints - */ -class CustomerId -{ - /** - * @var int - */ - private $customerId; - - /** - * @param int $customerId - */ - public function __construct($customerId) - { - $this->assertIntegerIsGreaterThanZero($customerId); - - $this->customerId = $customerId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->customerId; - } - - /** - * @param int $customerId - */ - private function assertIntegerIsGreaterThanZero($customerId) - { - if (!is_int($customerId) || 0 > $customerId) { - throw new CustomerException(sprintf('Customer id %s is invalid. Customer id must be number that is greater than zero.', var_export($customerId, true))); - } - } -} diff --git a/src/Core/Domain/Customer/ValueObject/Email.php b/src/Core/Domain/Customer/ValueObject/Email.php deleted file mode 100644 index b147e01f..00000000 --- a/src/Core/Domain/Customer/ValueObject/Email.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email as ValueObjectEmail; - -/** - * @deprecated since version 1.7.6.4 use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email instead - */ -class Email extends ValueObjectEmail -{ - public function __construct($email) - { - @trigger_error(self::class . ' is deprecated. Use ' . ValueObjectEmail::class . ' instead', E_USER_DEPRECATED); - parent::__construct($email); - } -} diff --git a/src/Core/Domain/Customer/ValueObject/FirstName.php b/src/Core/Domain/Customer/ValueObject/FirstName.php deleted file mode 100644 index f00cfd74..00000000 --- a/src/Core/Domain/Customer/ValueObject/FirstName.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerConstraintException; - -/** - * Stores customer's first name - */ -class FirstName -{ - /** - * @var string Maximum allowed length for first name - */ - const MAX_LENGTH = 255; - - /** - * @var string - */ - private $firstName; - - /** - * @param string $firstName - */ - public function __construct($firstName) - { - $this->assertFirstNameDoesNotExceedAllowedLength($firstName); - $this->assertFirstNameIsValid($firstName); - - $this->firstName = $firstName; - } - - /** - * @return string - */ - public function getValue() - { - return $this->firstName; - } - - /** - * @param string $firstName - * - * @throws CustomerConstraintException - */ - private function assertFirstNameIsValid($firstName) - { - $matchesFirstNamePattern = preg_match('/^[^0-9!<>,;?=+()@#"°{}_$%:¤|]*$/u', stripslashes($firstName)); - - if (!$matchesFirstNamePattern) { - throw new CustomerConstraintException(sprintf('Customer first name %s is invalid', var_export($firstName, true)), CustomerConstraintException::INVALID_FIRST_NAME); - } - } - - /** - * @param string $firstName - * - * @throws CustomerConstraintException - */ - private function assertFirstNameDoesNotExceedAllowedLength($firstName) - { - $firstName = html_entity_decode($firstName, ENT_COMPAT, 'UTF-8'); - - $length = function_exists('mb_strlen') ? mb_strlen($firstName, 'UTF-8') : strlen($firstName); - if (self::MAX_LENGTH < $length) { - throw new CustomerConstraintException(sprintf('Customer first name is too long. Max allowed length is %s', self::MAX_LENGTH), CustomerConstraintException::INVALID_FIRST_NAME); - } - } -} diff --git a/src/Core/Domain/Customer/ValueObject/LastName.php b/src/Core/Domain/Customer/ValueObject/LastName.php deleted file mode 100644 index 31794464..00000000 --- a/src/Core/Domain/Customer/ValueObject/LastName.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerConstraintException; - -/** - * Stores customer's last name - */ -class LastName -{ - /** - * @var int Maximum allowed length for customer's last name - */ - const MAX_LENGTH = 255; - - /** - * @var string - */ - private $lastName; - - /** - * @param string $lastName - */ - public function __construct($lastName) - { - $this->assertLastNameDoesNotExceedAllowedLength($lastName); - $this->assertLastNameIsValid($lastName); - - $this->lastName = $lastName; - } - - /** - * @return string - */ - public function getValue() - { - return $this->lastName; - } - - /** - * @param string $lastName - * - * @throws CustomerConstraintException - */ - private function assertLastNameIsValid($lastName) - { - $matchesLastNamePattern = preg_match('/^[^0-9!<>,;?=+()@#"°{}_$%:¤|]*$/u', stripslashes($lastName)); - - if (!$matchesLastNamePattern) { - throw new CustomerConstraintException(sprintf('Customer last name %s is invalid', var_export($lastName, true)), CustomerConstraintException::INVALID_LAST_NAME); - } - } - - /** - * @param string $lastName - * - * @throws CustomerConstraintException - */ - private function assertLastNameDoesNotExceedAllowedLength($lastName) - { - $lastName = html_entity_decode($lastName, ENT_COMPAT, 'UTF-8'); - - $length = function_exists('mb_strlen') ? mb_strlen($lastName, 'UTF-8') : strlen($lastName); - if (self::MAX_LENGTH < $length) { - throw new CustomerConstraintException(sprintf('Customer email is too long. Max allowed length is %s', self::MAX_LENGTH), CustomerConstraintException::INVALID_LAST_NAME); - } - } -} diff --git a/src/Core/Domain/Customer/ValueObject/Password.php b/src/Core/Domain/Customer/ValueObject/Password.php deleted file mode 100644 index bef215eb..00000000 --- a/src/Core/Domain/Customer/ValueObject/Password.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerConstraintException; - -/** - * Stores customer's plain password - */ -class Password -{ - /** - * @var string Minimum required password length for customer - */ - const MIN_LENGTH = 5; - - /** - * @var string Maximum allowed password length for customer. - * - * It's limited to 72 chars because of PASSWORD_BCRYPT algorithm - * used in password_hash() function. - */ - const MAX_LENGTH = 72; - - /** - * @var string - */ - private $password; - - /** - * @param string $password - */ - public function __construct($password) - { - $this->assertPasswordIsWithinAllowedLength($password); - - $this->password = $password; - } - - /** - * @return string - */ - public function getValue() - { - return $this->password; - } - - /** - * @param string $password - */ - private function assertPasswordIsWithinAllowedLength($password) - { - $length = function_exists('mb_strlen') ? mb_strlen($password, 'UTF-8') : strlen($password); - - if (self::MIN_LENGTH > $length || $length > self::MAX_LENGTH) { - throw new CustomerConstraintException(sprintf('Customer password length must be between %s and %s', self::MIN_LENGTH, self::MAX_LENGTH), CustomerConstraintException::INVALID_PASSWORD); - } - } -} diff --git a/src/Core/Domain/Customer/ValueObject/RequiredField.php b/src/Core/Domain/Customer/ValueObject/RequiredField.php deleted file mode 100644 index 10c89ee7..00000000 --- a/src/Core/Domain/Customer/ValueObject/RequiredField.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject; - -/** - * Stores required field values for customer. - */ -class RequiredField -{ - /** - * Partner offers field name - */ - const PARTNER_OFFERS = 'optin'; - - /** - * Newsletter field name - */ - const NEWSLETTER = 'newsletter'; - - /** - * All allowed required fields for customer - */ - const ALLOWED_REQUIRED_FIELDS = [ - self::PARTNER_OFFERS, - self::NEWSLETTER, - ]; -} diff --git a/src/Core/Domain/CustomerMessage/Command/AddOrderCustomerMessageCommand.php b/src/Core/Domain/CustomerMessage/Command/AddOrderCustomerMessageCommand.php deleted file mode 100644 index dbfd72a9..00000000 --- a/src/Core/Domain/CustomerMessage/Command/AddOrderCustomerMessageCommand.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerMessage\Command; - -use PrestaShop\PrestaShop\Core\Domain\CustomerMessage\Exception\CustomerMessageConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * This command adds/sends message to the customer related with the order. - */ -class AddOrderCustomerMessageCommand -{ - /** - * @var string - */ - private $message; - - /** - * @var OrderId - */ - private $orderId; - /** - * @var bool - */ - private $isPrivate; - - /** - * @param int $orderId - * @param string $message - * @param bool $isPrivate - * - * @throws OrderException - * @throws CustomerMessageConstraintException - */ - public function __construct(int $orderId, string $message, bool $isPrivate) - { - $this->orderId = new OrderId($orderId); - $this->setMessage($message); - $this->isPrivate = $isPrivate; - } - - /** - * @return OrderId - */ - public function getOrderId(): OrderId - { - return $this->orderId; - } - - /** - * @return string - */ - public function getMessage(): string - { - return $this->message; - } - - /** - * @return bool - */ - public function isPrivate(): bool - { - return $this->isPrivate; - } - - /** - * @param string $message - * - * @throws CustomerMessageConstraintException - */ - private function setMessage(string $message): void - { - if (!$message) { - throw new CustomerMessageConstraintException('Missing required message', CustomerMessageConstraintException::MISSING_MESSAGE); - } - - $this->message = $message; - } -} diff --git a/src/Core/Domain/CustomerMessage/CommandHandler/AddOrderCustomerMessageHandlerInterface.php b/src/Core/Domain/CustomerMessage/CommandHandler/AddOrderCustomerMessageHandlerInterface.php deleted file mode 100644 index 3c13ef37..00000000 --- a/src/Core/Domain/CustomerMessage/CommandHandler/AddOrderCustomerMessageHandlerInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerMessage\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CustomerMessage\Command\AddOrderCustomerMessageCommand; - -/** - * Interface AddOrderCustomerMessageHandlerInterface - */ -interface AddOrderCustomerMessageHandlerInterface -{ - public function handle(AddOrderCustomerMessageCommand $command); -} diff --git a/src/Core/Domain/CustomerMessage/Exception/CannotSendEmailException.php b/src/Core/Domain/CustomerMessage/Exception/CannotSendEmailException.php deleted file mode 100644 index 24ade2f9..00000000 --- a/src/Core/Domain/CustomerMessage/Exception/CannotSendEmailException.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerMessage\Exception; - -class CannotSendEmailException extends CustomerMessageException -{ -} diff --git a/src/Core/Domain/CustomerMessage/Exception/CustomerMessageConstraintException.php b/src/Core/Domain/CustomerMessage/Exception/CustomerMessageConstraintException.php deleted file mode 100644 index aadb8789..00000000 --- a/src/Core/Domain/CustomerMessage/Exception/CustomerMessageConstraintException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerMessage\Exception; - -class CustomerMessageConstraintException extends CustomerMessageException -{ - public const MISSING_MESSAGE = 1; - public const INVALID_MESSAGE = 2; -} diff --git a/src/Core/Domain/CustomerMessage/Exception/CustomerMessageException.php b/src/Core/Domain/CustomerMessage/Exception/CustomerMessageException.php deleted file mode 100644 index 6070e8bd..00000000 --- a/src/Core/Domain/CustomerMessage/Exception/CustomerMessageException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerMessage\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -class CustomerMessageException extends DomainException -{ - public const ORDER_CUSTOMER_NOT_FOUND = 1; -} diff --git a/src/Core/Domain/CustomerService/Command/ForwardCustomerThreadCommand.php b/src/Core/Domain/CustomerService/Command/ForwardCustomerThreadCommand.php deleted file mode 100644 index 94f9947d..00000000 --- a/src/Core/Domain/CustomerService/Command/ForwardCustomerThreadCommand.php +++ /dev/null @@ -1,142 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\Command; - -use PrestaShop\PrestaShop\Core\Domain\CustomerService\ValueObject\CustomerThreadId; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -/** - * Forwards customer thread - */ -class ForwardCustomerThreadCommand -{ - /** - * @var EmployeeId|null - */ - private $employeeId; - - /** - * @var CustomerThreadId - */ - private $customerThreadId; - - /** - * @var Email|null - */ - private $email; - - /** - * @var string - */ - private $comment; - - /** - * Creates command for forwarding customer thread for another employee - * - * @param int $customerThreadId - * @param int $employeeId - * @param string $comment - * - * @return self - */ - public static function toAnotherEmployee($customerThreadId, $employeeId, $comment) - { - $command = new self(); - $command->employeeId = new EmployeeId($employeeId); - $command->customerThreadId = new CustomerThreadId($customerThreadId); - $command->comment = $comment; - - return $command; - } - - /** - * Creates command for forwarding customer thread for someone else (not employee) - * - * @param int $customerThreadId - * @param string $email - * @param string $comment - * - * @return ForwardCustomerThreadCommand - */ - public static function toSomeoneElse($customerThreadId, $email, $comment) - { - $command = new self(); - $command->email = new Email($email); - $command->customerThreadId = new CustomerThreadId($customerThreadId); - $command->comment = $comment; - - return $command; - } - - /** - * Command should be created using static factories - */ - private function __construct() - { - } - - /** - * @return EmployeeId|null - */ - public function getEmployeeId() - { - return $this->employeeId; - } - - /** - * @return CustomerThreadId - */ - public function getCustomerThreadId() - { - return $this->customerThreadId; - } - - /** - * @return Email|null - */ - public function getEmail() - { - return $this->email; - } - - /** - * @return string - */ - public function getComment() - { - return $this->comment; - } - - /** - * @return bool - */ - public function forwardToEmployee() - { - return null !== $this->employeeId; - } -} diff --git a/src/Core/Domain/CustomerService/Command/ReplyToCustomerThreadCommand.php b/src/Core/Domain/CustomerService/Command/ReplyToCustomerThreadCommand.php deleted file mode 100644 index f567229f..00000000 --- a/src/Core/Domain/CustomerService/Command/ReplyToCustomerThreadCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\Command; - -use PrestaShop\PrestaShop\Core\Domain\CustomerService\ValueObject\CustomerThreadId; - -/** - * Reply to given customer thread - */ -class ReplyToCustomerThreadCommand -{ - /** - * @var CustomerThreadId - */ - private $customerThreadId; - - /** - * @var string - */ - private $replyMessage; - - /** - * @param int $customerThreadId - * @param string $replyMessage - */ - public function __construct($customerThreadId, $replyMessage) - { - $this->customerThreadId = new CustomerThreadId($customerThreadId); - $this->replyMessage = $replyMessage; - } - - /** - * @return CustomerThreadId - */ - public function getCustomerThreadId() - { - return $this->customerThreadId; - } - - /** - * @return string - */ - public function getReplyMessage() - { - return $this->replyMessage; - } -} diff --git a/src/Core/Domain/CustomerService/Command/UpdateCustomerThreadStatusCommand.php b/src/Core/Domain/CustomerService/Command/UpdateCustomerThreadStatusCommand.php deleted file mode 100644 index 793d51d3..00000000 --- a/src/Core/Domain/CustomerService/Command/UpdateCustomerThreadStatusCommand.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\Command; - -use PrestaShop\PrestaShop\Core\Domain\CustomerService\ValueObject\CustomerThreadId; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\ValueObject\CustomerThreadStatus; - -/** - * Updates customer thread with given status - */ -class UpdateCustomerThreadStatusCommand -{ - /** - * @var CustomerThreadId - */ - private $customerThreadId; - - /** - * @var CustomerThreadStatus - */ - private $customerThreadStatus; - - /** - * @param int $customerThreadId - * @param string $newCustomerThreadStatus - */ - public function __construct($customerThreadId, $newCustomerThreadStatus) - { - $this->customerThreadId = new CustomerThreadId($customerThreadId); - $this->customerThreadStatus = new CustomerThreadStatus($newCustomerThreadStatus); - } - - /** - * @return CustomerThreadId - */ - public function getCustomerThreadId() - { - return $this->customerThreadId; - } - - /** - * @return CustomerThreadStatus - */ - public function getCustomerThreadStatus() - { - return $this->customerThreadStatus; - } -} diff --git a/src/Core/Domain/CustomerService/CommandHandler/ForwardCustomerThreadHandlerInterface.php b/src/Core/Domain/CustomerService/CommandHandler/ForwardCustomerThreadHandlerInterface.php deleted file mode 100644 index 7ae4f05e..00000000 --- a/src/Core/Domain/CustomerService/CommandHandler/ForwardCustomerThreadHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Command\ForwardCustomerThreadCommand; - -/** - * Interface for service that forwards customer thread to another employee - */ -interface ForwardCustomerThreadHandlerInterface -{ - /** - * @param ForwardCustomerThreadCommand $command - */ - public function handle(ForwardCustomerThreadCommand $command); -} diff --git a/src/Core/Domain/CustomerService/CommandHandler/ReplyToCustomerThreadHandlerInterface.php b/src/Core/Domain/CustomerService/CommandHandler/ReplyToCustomerThreadHandlerInterface.php deleted file mode 100644 index ac175e62..00000000 --- a/src/Core/Domain/CustomerService/CommandHandler/ReplyToCustomerThreadHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Command\ReplyToCustomerThreadCommand; - -/** - * Interface for service that handles replying to customer thread - */ -interface ReplyToCustomerThreadHandlerInterface -{ - /** - * @param ReplyToCustomerThreadCommand $command - */ - public function handle(ReplyToCustomerThreadCommand $command); -} diff --git a/src/Core/Domain/CustomerService/CommandHandler/UpdateCustomerThreadStatusHandler.php b/src/Core/Domain/CustomerService/CommandHandler/UpdateCustomerThreadStatusHandler.php deleted file mode 100644 index 1387c847..00000000 --- a/src/Core/Domain/CustomerService/CommandHandler/UpdateCustomerThreadStatusHandler.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\CommandHandler; - -use Doctrine\DBAL\Driver\Connection; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Command\UpdateCustomerThreadStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Exception\CustomerServiceException; - -/** - * @internal - */ -final class UpdateCustomerThreadStatusHandler implements UpdateCustomerThreadStatusHandlerInterface -{ - /** - * @var Connection - */ - private $connection; - - /** - * @var string - */ - private $dbPrefix; - - /** - * @param Connection $connection - * @param string $dbPrefix - */ - public function __construct(Connection $connection, $dbPrefix) - { - $this->connection = $connection; - $this->dbPrefix = $dbPrefix; - } - - /** - * {@inheritdoc} - */ - public function handle(UpdateCustomerThreadStatusCommand $command) - { - $statement = $this->connection->prepare(' - UPDATE ' . $this->dbPrefix . 'customer_thread - SET status = :status - WHERE id_customer_thread = :id_customer_thread - LIMIT 1 - '); - - $statement->bindValue(':status', $command->getCustomerThreadStatus()->getValue()); - $statement->bindValue(':id_customer_thread', $command->getCustomerThreadId()->getValue()); - - if (false === $statement->execute()) { - throw new CustomerServiceException('Failed to update customer thread status'); - } - } -} diff --git a/src/Core/Domain/CustomerService/CommandHandler/UpdateCustomerThreadStatusHandlerInterface.php b/src/Core/Domain/CustomerService/CommandHandler/UpdateCustomerThreadStatusHandlerInterface.php deleted file mode 100644 index f79a36c6..00000000 --- a/src/Core/Domain/CustomerService/CommandHandler/UpdateCustomerThreadStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Command\UpdateCustomerThreadStatusCommand; - -/** - * Interface for service that handles updating thread status - */ -interface UpdateCustomerThreadStatusHandlerInterface -{ - /** - * @param UpdateCustomerThreadStatusCommand $command - */ - public function handle(UpdateCustomerThreadStatusCommand $command); -} diff --git a/src/Core/Domain/CustomerService/Exception/CustomerServiceException.php b/src/Core/Domain/CustomerService/Exception/CustomerServiceException.php deleted file mode 100644 index 4e9f8db2..00000000 --- a/src/Core/Domain/CustomerService/Exception/CustomerServiceException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for customer service subdomain - */ -class CustomerServiceException extends DomainException -{ -} diff --git a/src/Core/Domain/CustomerService/Exception/CustomerThreadNotFoundException.php b/src/Core/Domain/CustomerService/Exception/CustomerThreadNotFoundException.php deleted file mode 100644 index 55a0033e..00000000 --- a/src/Core/Domain/CustomerService/Exception/CustomerThreadNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\Exception; - -/** - * Thrown when customer thread is not found - */ -class CustomerThreadNotFoundException extends CustomerServiceException -{ -} diff --git a/src/Core/Domain/CustomerService/Query/GetCustomerServiceSignature.php b/src/Core/Domain/CustomerService/Query/GetCustomerServiceSignature.php deleted file mode 100644 index 1e6f5bab..00000000 --- a/src/Core/Domain/CustomerService/Query/GetCustomerServiceSignature.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\Query; - -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; - -/** - * Gets signature for replying in customer thread - */ -class GetCustomerServiceSignature -{ - /** - * @var LanguageId - */ - private $languageId; - - /** - * @param int $languageId - */ - public function __construct($languageId) - { - $this->languageId = new LanguageId($languageId); - } - - /** - * @return LanguageId - */ - public function getLanguageId() - { - return $this->languageId; - } -} diff --git a/src/Core/Domain/CustomerService/Query/GetCustomerThreadForViewing.php b/src/Core/Domain/CustomerService/Query/GetCustomerThreadForViewing.php deleted file mode 100644 index 115d5ffb..00000000 --- a/src/Core/Domain/CustomerService/Query/GetCustomerThreadForViewing.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\Query; - -use PrestaShop\PrestaShop\Core\Domain\CustomerService\ValueObject\CustomerThreadId; - -/** - * Gets customer thread for viewing - */ -class GetCustomerThreadForViewing -{ - /** - * @var CustomerThreadId - */ - private $customerThreadId; - - /** - * @param int $customerThreadId - */ - public function __construct($customerThreadId) - { - $this->customerThreadId = new CustomerThreadId($customerThreadId); - } - - /** - * @return CustomerThreadId - */ - public function getCustomerThreadId() - { - return $this->customerThreadId; - } -} diff --git a/src/Core/Domain/CustomerService/QueryHandler/GetCustomerServiceSignatureHandler.php b/src/Core/Domain/CustomerService/QueryHandler/GetCustomerServiceSignatureHandler.php deleted file mode 100644 index 22107e97..00000000 --- a/src/Core/Domain/CustomerService/QueryHandler/GetCustomerServiceSignatureHandler.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryHandler; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Query\GetCustomerServiceSignature; - -/** - * @internal - */ -final class GetCustomerServiceSignatureHandler implements GetCustomerServiceSignatureHandlerInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function handle(GetCustomerServiceSignature $query) - { - $signature = $this->configuration->get('PS_CUSTOMER_SERVICE_SIGNATURE'); - - return $signature[$query->getLanguageId()->getValue()]; - } -} diff --git a/src/Core/Domain/CustomerService/QueryHandler/GetCustomerServiceSignatureHandlerInterface.php b/src/Core/Domain/CustomerService/QueryHandler/GetCustomerServiceSignatureHandlerInterface.php deleted file mode 100644 index 71fa6205..00000000 --- a/src/Core/Domain/CustomerService/QueryHandler/GetCustomerServiceSignatureHandlerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Query\GetCustomerServiceSignature; - -/** - * Interface for service that gets customer service signature - */ -interface GetCustomerServiceSignatureHandlerInterface -{ - /** - * @param GetCustomerServiceSignature $query - * - * @return string - */ - public function handle(GetCustomerServiceSignature $query); -} diff --git a/src/Core/Domain/CustomerService/QueryHandler/GetCustomerThreadForViewingHandlerInterface.php b/src/Core/Domain/CustomerService/QueryHandler/GetCustomerThreadForViewingHandlerInterface.php deleted file mode 100644 index 7b7f5cfd..00000000 --- a/src/Core/Domain/CustomerService/QueryHandler/GetCustomerThreadForViewingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Query\GetCustomerThreadForViewing; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryResult\CustomerThreadView; - -/** - * Interface for service that gets customer thread for viewing - */ -interface GetCustomerThreadForViewingHandlerInterface -{ - /** - * @param GetCustomerThreadForViewing $query - * - * @return CustomerThreadView - */ - public function handle(GetCustomerThreadForViewing $query); -} diff --git a/src/Core/Domain/CustomerService/QueryResult/CustomerInformation.php b/src/Core/Domain/CustomerService/QueryResult/CustomerInformation.php deleted file mode 100644 index 205f29b1..00000000 --- a/src/Core/Domain/CustomerService/QueryResult/CustomerInformation.php +++ /dev/null @@ -1,161 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryResult; - -/** - * Carries data about customer for customer thread - */ -class CustomerInformation -{ - /** - * @var int|null - */ - private $customerId; - - /** - * @var string|null - */ - private $firstName; - - /** - * @var string|null - */ - private $lastName; - - /** - * @var string - */ - private $email; - - /** - * @var int - */ - private $validatedOrdersCount; - - /** - * @var string - */ - private $validatedOrdersAmount; - - /** - * @var string|null - */ - private $customerSinceDate; - - /** - * @param string $email - * - * @return self - */ - public static function withEmailOnly($email) - { - return new self(null, null, null, $email, null, null, null); - } - - /** - * @param int|null $customerId - * @param string|null $firstName - * @param string|null $lastName - * @param string $email - * @param int $validatedOrdersCount - * @param string $validatedOrdersAmount - * @param string $customerSinceDate - */ - public function __construct( - $customerId, - $firstName, - $lastName, - $email, - $validatedOrdersCount, - $validatedOrdersAmount, - $customerSinceDate - ) { - $this->customerId = $customerId; - $this->firstName = $firstName; - $this->lastName = $lastName; - $this->email = $email; - $this->validatedOrdersCount = $validatedOrdersCount; - $this->validatedOrdersAmount = $validatedOrdersAmount; - $this->customerSinceDate = $customerSinceDate; - } - - /** - * @return int|null - */ - public function getCustomerId() - { - return $this->customerId; - } - - /** - * @return string|null - */ - public function getFirstName() - { - return $this->firstName; - } - - /** - * @return string|null - */ - public function getLastName() - { - return $this->lastName; - } - - /** - * @return string - */ - public function getEmail() - { - return $this->email; - } - - /** - * @return int - */ - public function getValidatedOrdersCount() - { - return $this->validatedOrdersCount; - } - - /** - * @return string - */ - public function getValidatedOrdersAmount() - { - return $this->validatedOrdersAmount; - } - - /** - * @return string|null - */ - public function getCustomerSinceDate() - { - return $this->customerSinceDate; - } -} diff --git a/src/Core/Domain/CustomerService/QueryResult/CustomerThreadMessage.php b/src/Core/Domain/CustomerService/QueryResult/CustomerThreadMessage.php deleted file mode 100644 index 5691ca41..00000000 --- a/src/Core/Domain/CustomerService/QueryResult/CustomerThreadMessage.php +++ /dev/null @@ -1,183 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryResult; - -/** - * Carries data for single customer thread message - */ -class CustomerThreadMessage -{ - /** - * @var string - */ - private $type; - - /** - * @var string - */ - private $message; - - /** - * @var string - */ - private $date; - - /** - * @var string|null - */ - private $employeeImage; - - /** - * @var string|null - */ - private $employeeName; - - /** - * @var string|null - */ - private $customerName; - - /** - * @var string|null - */ - private $attachmentFile; - - /** - * @var int|null - */ - private $productId; - - /** - * @var string|null - */ - private $productName; - - /** - * @param string $type - * @param string $message - * @param string $date - * @param string|null $employeeImage - * @param string|null $employeeName - * @param string|null $customerName - * @param string|null $attachmentFile - * @param int|null $productId - * @param string|null $productName - */ - public function __construct( - $type, - $message, - $date, - $employeeImage, - $employeeName, - $customerName, - $attachmentFile, - $productId, - $productName - ) { - $this->type = $type; - $this->message = $message; - $this->date = $date; - $this->employeeImage = $employeeImage; - $this->employeeName = $employeeName; - $this->customerName = $customerName; - $this->attachmentFile = $attachmentFile; - $this->productId = $productId; - $this->productName = $productName; - } - - /** - * @return string - */ - public function getType() - { - return $this->type; - } - - /** - * @return string - */ - public function getMessage() - { - return $this->message; - } - - /** - * @return string - */ - public function getDate() - { - return $this->date; - } - - /** - * @return string|null - */ - public function getEmployeeImage() - { - return $this->employeeImage; - } - - /** - * @return string|null - */ - public function getEmployeeName() - { - return $this->employeeName; - } - - /** - * @return string|null - */ - public function getCustomerName() - { - return $this->customerName; - } - - /** - * @return string|null - */ - public function getAttachmentFile() - { - return $this->attachmentFile; - } - - /** - * @return int|null - */ - public function getProductId() - { - return $this->productId; - } - - /** - * @return string|null - */ - public function getProductName() - { - return $this->productName; - } -} diff --git a/src/Core/Domain/CustomerService/QueryResult/CustomerThreadTimeline.php b/src/Core/Domain/CustomerService/QueryResult/CustomerThreadTimeline.php deleted file mode 100644 index 649c2817..00000000 --- a/src/Core/Domain/CustomerService/QueryResult/CustomerThreadTimeline.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryResult; - -/** - * Carries data for customer thread timeline - */ -class CustomerThreadTimeline -{ - /** @var CustomerThreadTimelineItem[] */ - private $timelineItems; - - /** - * @param CustomerThreadTimelineItem[] - */ - public function __construct(array $timelineItems) - { - $this->timelineItems = $timelineItems; - } - - /** - * @return CustomerThreadTimelineItem[] - */ - public function getTimelineItems() - { - return $this->timelineItems; - } -} diff --git a/src/Core/Domain/CustomerService/QueryResult/CustomerThreadTimelineItem.php b/src/Core/Domain/CustomerService/QueryResult/CustomerThreadTimelineItem.php deleted file mode 100644 index 0a02bb29..00000000 --- a/src/Core/Domain/CustomerService/QueryResult/CustomerThreadTimelineItem.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryResult; - -/** - * Carries data about single timeline item - */ -class CustomerThreadTimelineItem -{ - /** - * @var string - */ - private $content; - - /** - * @var string - */ - private $icon; - - /** - * @var string - */ - private $arrow; - - /** - * @var string - */ - private $date; - - /** - * @var string|null - */ - private $color; - - /** - * @var int|null - */ - private $relatedOrderId; - - /** - * @param string $content - * @param string $icon - * @param string $arrow - * @param string $date - * @param string|null $color - * @param int|null $relatedOrderId - */ - public function __construct( - $content, - $icon, - $arrow, - $date, - $color = null, - $relatedOrderId = null - ) { - $this->content = $content; - $this->icon = $icon; - $this->arrow = $arrow; - $this->date = $date; - $this->color = $color; - $this->relatedOrderId = $relatedOrderId; - } - - /** - * @return string - */ - public function getContent() - { - return $this->content; - } - - /** - * @return string - */ - public function getIcon() - { - return $this->icon; - } - - /** - * @return string - */ - public function getArrow() - { - return $this->arrow; - } - - /** - * @return string - */ - public function getDate() - { - return $this->date; - } - - /** - * @return string|null - */ - public function getColor() - { - return $this->color; - } - - /** - * @return int|null - */ - public function getRelatedOrderId() - { - return $this->relatedOrderId; - } -} diff --git a/src/Core/Domain/CustomerService/QueryResult/CustomerThreadView.php b/src/Core/Domain/CustomerService/QueryResult/CustomerThreadView.php deleted file mode 100644 index 0169fd7e..00000000 --- a/src/Core/Domain/CustomerService/QueryResult/CustomerThreadView.php +++ /dev/null @@ -1,154 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\CustomerService\ValueObject\CustomerThreadId; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; - -/** - * Carries data for customer thread view - */ -class CustomerThreadView -{ - /** - * @var CustomerThreadId - */ - private $customerThreadId; - - /** - * @var array - */ - private $actions; - - /** - * @var CustomerInformation - */ - private $customerInformation; - - /** - * @var string - */ - private $contactName; - - /** - * @var CustomerThreadMessage[] - */ - private $messages; - - /** - * @var LanguageId - */ - private $languageId; - - /** - * @var CustomerThreadTimeline - */ - private $timeline; - - /** - * @param CustomerThreadId $customerThreadId - * @param LanguageId $languageId - * @param array $actions - * @param CustomerInformation $customerInformation - * @param string $contactName - * @param CustomerThreadMessage[] $messages - * @param CustomerThreadTimeline $timeline - */ - public function __construct( - CustomerThreadId $customerThreadId, - LanguageId $languageId, - array $actions, - CustomerInformation $customerInformation, - $contactName, - array $messages, - CustomerThreadTimeline $timeline - ) { - $this->customerThreadId = $customerThreadId; - $this->actions = $actions; - $this->customerInformation = $customerInformation; - $this->contactName = $contactName; - $this->messages = $messages; - $this->languageId = $languageId; - $this->timeline = $timeline; - } - - /** - * @return CustomerThreadId - */ - public function getCustomerThreadId() - { - return $this->customerThreadId; - } - - /** - * @return array - */ - public function getActions() - { - return $this->actions; - } - - /** - * @return CustomerInformation - */ - public function getCustomerInformation() - { - return $this->customerInformation; - } - - /** - * @return string - */ - public function getContactName() - { - return $this->contactName; - } - - /** - * @return CustomerThreadMessage[] - */ - public function getMessages() - { - return $this->messages; - } - - /** - * @return LanguageId - */ - public function getLanguageId() - { - return $this->languageId; - } - - /** - * @return CustomerThreadTimeline - */ - public function getTimeline() - { - return $this->timeline; - } -} diff --git a/src/Core/Domain/CustomerService/ValueObject/CustomerThreadId.php b/src/Core/Domain/CustomerService/ValueObject/CustomerThreadId.php deleted file mode 100644 index 361324a8..00000000 --- a/src/Core/Domain/CustomerService/ValueObject/CustomerThreadId.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Exception\CustomerServiceException; - -/** - * Defines customer thread id - */ -class CustomerThreadId -{ - /** - * @var int - */ - private $customerThreadId; - - /** - * @param int $customerThreadId - */ - public function __construct($customerThreadId) - { - if (!is_int($customerThreadId) || 0 > $customerThreadId) { - throw new CustomerServiceException('CustomerThreadId must be of type int and greater than zero.'); - } - - $this->customerThreadId = $customerThreadId; - } - - /** - * @return int - */ - public function getValue(): int - { - return $this->customerThreadId; - } -} diff --git a/src/Core/Domain/CustomerService/ValueObject/CustomerThreadMessageType.php b/src/Core/Domain/CustomerService/ValueObject/CustomerThreadMessageType.php deleted file mode 100644 index 96ee069c..00000000 --- a/src/Core/Domain/CustomerService/ValueObject/CustomerThreadMessageType.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\ValueObject; - -/** - * Defines types of thread messages - */ -final class CustomerThreadMessageType -{ - /** - * When message is written by employee - */ - const EMPLOYEE = 'employee'; - - /** - * When message is written by customer - */ - const CUSTOMER = 'customer'; -} diff --git a/src/Core/Domain/CustomerService/ValueObject/CustomerThreadStatus.php b/src/Core/Domain/CustomerService/ValueObject/CustomerThreadStatus.php deleted file mode 100644 index 7a5fe77b..00000000 --- a/src/Core/Domain/CustomerService/ValueObject/CustomerThreadStatus.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\CustomerService\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Exception\CustomerServiceException; - -/** - * Status that customer thread can have - */ -final class CustomerThreadStatus -{ - const OPEN = 'open'; - const CLOSED = 'closed'; - const PENDING_1 = 'pending1'; - const PENDING_2 = 'pending2'; - - /** - * @var string - */ - private $status; - - /** - * @param string $status - */ - public function __construct($status) - { - $availableStatuses = [ - self::OPEN, - self::CLOSED, - self::PENDING_1, - self::PENDING_2, - ]; - - if (!in_array($status, $availableStatuses)) { - throw new CustomerServiceException(sprintf('Customer thread status "%s" is not defined, available statuses are "%s"', $status, implode(',', $availableStatuses))); - } - - $this->status = $status; - } - - /** - * @return string - */ - public function getValue() - { - return $this->status; - } -} diff --git a/src/Core/Domain/Employee/Command/AddEmployeeCommand.php b/src/Core/Domain/Employee/Command/AddEmployeeCommand.php deleted file mode 100644 index 644f5761..00000000 --- a/src/Core/Domain/Employee/Command/AddEmployeeCommand.php +++ /dev/null @@ -1,188 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Command; - -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\FirstName; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\LastName; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\Password; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -/** - * Adds new employee with given data - */ -class AddEmployeeCommand -{ - /** - * @var FirstName - */ - private $firstName; - - /** - * @var LastName - */ - private $lastName; - - /** - * @var Email - */ - private $email; - - /** - * @var int - */ - private $defaultPageId; - - /** - * @var int - */ - private $languageId; - - /** - * @var bool - */ - private $active; - - /** - * @var int - */ - private $profileId; - - /** - * @var array - */ - private $shopAssociation; - - /** - * @var Password - */ - private $plainPassword; - - /** - * @param string $firstName - * @param string $lastName - * @param string $email - * @param string $plainPassword - * @param int $defaultPageId - * @param int $languageId - * @param bool $active - * @param int $profileId - * @param array $shopAssociation - */ - public function __construct( - $firstName, - $lastName, - $email, - $plainPassword, - $defaultPageId, - $languageId, - $active, - $profileId, - array $shopAssociation - ) { - $this->firstName = new FirstName($firstName); - $this->lastName = new LastName($lastName); - $this->email = new Email($email); - $this->defaultPageId = $defaultPageId; - $this->languageId = $languageId; - $this->active = $active; - $this->profileId = $profileId; - $this->shopAssociation = $shopAssociation; - $this->plainPassword = new Password($plainPassword); - } - - /** - * @return FirstName - */ - public function getFirstName() - { - return $this->firstName; - } - - /** - * @return LastName - */ - public function getLastName() - { - return $this->lastName; - } - - /** - * @return Email - */ - public function getEmail() - { - return $this->email; - } - - /** - * @return int - */ - public function getDefaultPageId() - { - return $this->defaultPageId; - } - - /** - * @return int - */ - public function getLanguageId() - { - return $this->languageId; - } - - /** - * @return bool - */ - public function isActive() - { - return $this->active; - } - - /** - * @return int - */ - public function getProfileId() - { - return $this->profileId; - } - - /** - * @return array - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } - - /** - * @return Password - */ - public function getPlainPassword() - { - return $this->plainPassword; - } -} diff --git a/src/Core/Domain/Employee/Command/BulkDeleteEmployeeCommand.php b/src/Core/Domain/Employee/Command/BulkDeleteEmployeeCommand.php deleted file mode 100644 index 94677e28..00000000 --- a/src/Core/Domain/Employee/Command/BulkDeleteEmployeeCommand.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Command; - -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; - -/** - * Class BulkDeleteEmployeeCommand. - */ -class BulkDeleteEmployeeCommand -{ - /** - * @var EmployeeId[] - */ - private $employeeIds; - - /** - * @param int[] $employeeIds - */ - public function __construct(array $employeeIds) - { - $this->setEmployeeIds($employeeIds); - } - - /** - * @return EmployeeId[] - */ - public function getEmployeeIds() - { - return $this->employeeIds; - } - - /** - * @param int[] $employeeIds - */ - private function setEmployeeIds(array $employeeIds) - { - foreach ($employeeIds as $employeeId) { - $this->employeeIds[] = new EmployeeId((int) $employeeId); - } - } -} diff --git a/src/Core/Domain/Employee/Command/BulkUpdateEmployeeStatusCommand.php b/src/Core/Domain/Employee/Command/BulkUpdateEmployeeStatusCommand.php deleted file mode 100644 index febe03f6..00000000 --- a/src/Core/Domain/Employee/Command/BulkUpdateEmployeeStatusCommand.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Command; - -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; - -/** - * Class UpdateEmployeesStatusCommand updates employees status. - */ -class BulkUpdateEmployeeStatusCommand -{ - /** - * @var bool - */ - private $status; - - /** - * @var EmployeeId[] - */ - private $employeeIds; - - /** - * @param int[] $employeeIds - * @param bool $status - */ - public function __construct(array $employeeIds, $status) - { - $this->status = $status; - - $this->setEmployeeIds($employeeIds); - } - - /** - * @return bool - */ - public function getStatus() - { - return $this->status; - } - - /** - * @return EmployeeId[] - */ - public function getEmployeeIds() - { - return $this->employeeIds; - } - - /** - * @param int[] $employeeIds - */ - private function setEmployeeIds(array $employeeIds) - { - foreach ($employeeIds as $employeeId) { - $this->employeeIds[] = new EmployeeId((int) $employeeId); - } - } -} diff --git a/src/Core/Domain/Employee/Command/DeleteEmployeeCommand.php b/src/Core/Domain/Employee/Command/DeleteEmployeeCommand.php deleted file mode 100644 index 489650fc..00000000 --- a/src/Core/Domain/Employee/Command/DeleteEmployeeCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Command; - -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; - -/** - * Class DeleteEmployeeCommand deletes given employee. - */ -class DeleteEmployeeCommand -{ - /** - * @var EmployeeId - */ - private $employeeId; - - /** - * @param int $employeeId - */ - public function __construct($employeeId) - { - $this->employeeId = new EmployeeId($employeeId); - } - - /** - * @return EmployeeId - */ - public function getEmployeeId() - { - return $this->employeeId; - } -} diff --git a/src/Core/Domain/Employee/Command/EditEmployeeCommand.php b/src/Core/Domain/Employee/Command/EditEmployeeCommand.php deleted file mode 100644 index 10314e18..00000000 --- a/src/Core/Domain/Employee/Command/EditEmployeeCommand.php +++ /dev/null @@ -1,297 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Command; - -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\FirstName; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\LastName; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\Password; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -/** - * Edit employee with given data. - */ -class EditEmployeeCommand -{ - /** - * @var EmployeeId - */ - private $employeeId; - - /** - * @var FirstName - */ - private $firstName; - - /** - * @var LastName - */ - private $lastName; - - /** - * @var Email - */ - private $email; - - /** - * @var int - */ - private $defaultPageId; - - /** - * @var int - */ - private $languageId; - - /** - * @var bool - */ - private $active; - - /** - * @var int - */ - private $profileId; - - /** - * @var array - */ - private $shopAssociation; - - /** - * @var Password - */ - private $plainPassword; - - /** - * @param int $employeeId - */ - public function __construct($employeeId) - { - $this->employeeId = new EmployeeId((int) $employeeId); - } - - /** - * @return EmployeeId - */ - public function getEmployeeId() - { - return $this->employeeId; - } - - /** - * @param EmployeeId $employeeId - * - * @return EditEmployeeCommand - */ - public function setEmployeeId($employeeId) - { - $this->employeeId = $employeeId; - - return $this; - } - - /** - * @return FirstName - */ - public function getFirstName() - { - return $this->firstName; - } - - /** - * @param string $firstName - * - * @return EditEmployeeCommand - */ - public function setFirstName($firstName) - { - $this->firstName = new FirstName($firstName); - - return $this; - } - - /** - * @return LastName - */ - public function getLastName() - { - return $this->lastName; - } - - /** - * @param string $lastName - * - * @return EditEmployeeCommand - */ - public function setLastName($lastName) - { - $this->lastName = new LastName($lastName); - - return $this; - } - - /** - * @return Email - */ - public function getEmail() - { - return $this->email; - } - - /** - * @param string $email - * - * @return EditEmployeeCommand - */ - public function setEmail($email) - { - $this->email = new Email($email); - - return $this; - } - - /** - * @return int - */ - public function getDefaultPageId() - { - return $this->defaultPageId; - } - - /** - * @param int $defaultPageId - * - * @return EditEmployeeCommand - */ - public function setDefaultPageId($defaultPageId) - { - $this->defaultPageId = $defaultPageId; - - return $this; - } - - /** - * @return int - */ - public function getLanguageId() - { - return $this->languageId; - } - - /** - * @param int $languageId - * - * @return EditEmployeeCommand - */ - public function setLanguageId($languageId) - { - $this->languageId = $languageId; - - return $this; - } - - /** - * @return bool - */ - public function isActive() - { - return $this->active; - } - - /** - * @param bool $active - * - * @return EditEmployeeCommand - */ - public function setActive($active) - { - $this->active = $active; - - return $this; - } - - /** - * @return int - */ - public function getProfileId() - { - return $this->profileId; - } - - /** - * @param int $profileId - * - * @return EditEmployeeCommand - */ - public function setProfileId($profileId) - { - $this->profileId = $profileId; - - return $this; - } - - /** - * @return array - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } - - /** - * @param array $shopAssociation - * - * @return EditEmployeeCommand - */ - public function setShopAssociation($shopAssociation) - { - $this->shopAssociation = $shopAssociation; - - return $this; - } - - /** - * @return Password - */ - public function getPlainPassword() - { - return $this->plainPassword; - } - - /** - * @param string $plainPassword - * - * @return EditEmployeeCommand - */ - public function setPlainPassword($plainPassword) - { - $this->plainPassword = new Password($plainPassword); - - return $this; - } -} diff --git a/src/Core/Domain/Employee/Command/ToggleEmployeeStatusCommand.php b/src/Core/Domain/Employee/Command/ToggleEmployeeStatusCommand.php deleted file mode 100644 index 39fb5d16..00000000 --- a/src/Core/Domain/Employee/Command/ToggleEmployeeStatusCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Command; - -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; - -/** - * Class ToggleEmployeeStatusCommand. - */ -class ToggleEmployeeStatusCommand -{ - /** - * @var EmployeeId - */ - private $employeeId; - - /** - * @param int $employeeId - */ - public function __construct($employeeId) - { - $this->employeeId = new EmployeeId($employeeId); - } - - /** - * @return EmployeeId - */ - public function getEmployeeId() - { - return $this->employeeId; - } -} diff --git a/src/Core/Domain/Employee/CommandHandler/AddEmployeeHandlerInterface.php b/src/Core/Domain/Employee/CommandHandler/AddEmployeeHandlerInterface.php deleted file mode 100644 index 72d2a8b6..00000000 --- a/src/Core/Domain/Employee/CommandHandler/AddEmployeeHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\AddEmployeeCommand; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; - -/** - * Interface for services that handle command which adds new employee - */ -interface AddEmployeeHandlerInterface -{ - /** - * @param AddEmployeeCommand $command - * - * @return EmployeeId Added employee's ID - */ - public function handle(AddEmployeeCommand $command); -} diff --git a/src/Core/Domain/Employee/CommandHandler/BulkDeleteEmployeeHandlerInterface.php b/src/Core/Domain/Employee/CommandHandler/BulkDeleteEmployeeHandlerInterface.php deleted file mode 100644 index 6a341b71..00000000 --- a/src/Core/Domain/Employee/CommandHandler/BulkDeleteEmployeeHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\BulkDeleteEmployeeCommand; - -/** - * Interface BulkDeleteEmployeeHandlerInterface. - */ -interface BulkDeleteEmployeeHandlerInterface -{ - /** - * @param BulkDeleteEmployeeCommand $command - */ - public function handle(BulkDeleteEmployeeCommand $command); -} diff --git a/src/Core/Domain/Employee/CommandHandler/BulkUpdateEmployeeStatusHandlerInterface.php b/src/Core/Domain/Employee/CommandHandler/BulkUpdateEmployeeStatusHandlerInterface.php deleted file mode 100644 index 96674576..00000000 --- a/src/Core/Domain/Employee/CommandHandler/BulkUpdateEmployeeStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\BulkUpdateEmployeeStatusCommand; - -/** - * Interface UpdateEmployeeStatusHandlerInterface. - */ -interface BulkUpdateEmployeeStatusHandlerInterface -{ - /** - * @param BulkUpdateEmployeeStatusCommand $command - */ - public function handle(BulkUpdateEmployeeStatusCommand $command); -} diff --git a/src/Core/Domain/Employee/CommandHandler/DeleteEmployeeHandlerInterface.php b/src/Core/Domain/Employee/CommandHandler/DeleteEmployeeHandlerInterface.php deleted file mode 100644 index edef70e0..00000000 --- a/src/Core/Domain/Employee/CommandHandler/DeleteEmployeeHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\DeleteEmployeeCommand; - -/** - * Interface DeleteEmployeeHandlerInterface. - */ -interface DeleteEmployeeHandlerInterface -{ - /** - * @param DeleteEmployeeCommand $command - */ - public function handle(DeleteEmployeeCommand $command); -} diff --git a/src/Core/Domain/Employee/CommandHandler/EditEmployeeHandlerInterface.php b/src/Core/Domain/Employee/CommandHandler/EditEmployeeHandlerInterface.php deleted file mode 100644 index 51f8ec55..00000000 --- a/src/Core/Domain/Employee/CommandHandler/EditEmployeeHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\EditEmployeeCommand; - -/** - * Interface for services that handle command which edits employee. - */ -interface EditEmployeeHandlerInterface -{ - /** - * @param EditEmployeeCommand $command - */ - public function handle(EditEmployeeCommand $command); -} diff --git a/src/Core/Domain/Employee/CommandHandler/ToggleEmployeeStatusHandlerInterface.php b/src/Core/Domain/Employee/CommandHandler/ToggleEmployeeStatusHandlerInterface.php deleted file mode 100644 index 2c897c1e..00000000 --- a/src/Core/Domain/Employee/CommandHandler/ToggleEmployeeStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\ToggleEmployeeStatusCommand; - -/** - * Interface ToggleEmployeeStatusHandlerInterface. - */ -interface ToggleEmployeeStatusHandlerInterface -{ - /** - * @param ToggleEmployeeStatusCommand $command - */ - public function handle(ToggleEmployeeStatusCommand $command); -} diff --git a/src/Core/Domain/Employee/Exception/AdminEmployeeException.php b/src/Core/Domain/Employee/Exception/AdminEmployeeException.php deleted file mode 100644 index 723cc94e..00000000 --- a/src/Core/Domain/Employee/Exception/AdminEmployeeException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Exception; - -/** - * Class AdminEmployeeException is thrown when last admin of the shop is being disabled or deleted. - */ -class AdminEmployeeException extends EmployeeException -{ - /** - * Code is used when the only admin of the shop is being disabled or deleted. - */ - const CANNOT_CHANGE_LAST_ADMIN = 1; -} diff --git a/src/Core/Domain/Employee/Exception/CannotDeleteEmployeeException.php b/src/Core/Domain/Employee/Exception/CannotDeleteEmployeeException.php deleted file mode 100644 index 30ae4885..00000000 --- a/src/Core/Domain/Employee/Exception/CannotDeleteEmployeeException.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; - -/** - * Is thrown when employee cannot be deleted - */ -class CannotDeleteEmployeeException extends EmployeeException -{ - /** - * @var EmployeeId - */ - private $employeeId; - - /** - * @param EmployeeId $employeeId - * @param string $message - * @param int $code - * @param \Exception|null $previous - */ - public function __construct(EmployeeId $employeeId, $message = '', $code = 0, $previous = null) - { - parent::__construct($message, $code, $previous); - - $this->employeeId = $employeeId; - } - - /** - * @return EmployeeId - */ - public function getEmployeeId() - { - return $this->employeeId; - } -} diff --git a/src/Core/Domain/Employee/Exception/CannotDeleteWarehouseManagerException.php b/src/Core/Domain/Employee/Exception/CannotDeleteWarehouseManagerException.php deleted file mode 100644 index 1460aaf4..00000000 --- a/src/Core/Domain/Employee/Exception/CannotDeleteWarehouseManagerException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Exception; - -/** - * Is thrown when warehouse manager cannot be deleted - */ -class CannotDeleteWarehouseManagerException extends EmployeeException -{ -} diff --git a/src/Core/Domain/Employee/Exception/EmailAlreadyUsedException.php b/src/Core/Domain/Employee/Exception/EmailAlreadyUsedException.php deleted file mode 100644 index 4e8b57e7..00000000 --- a/src/Core/Domain/Employee/Exception/EmailAlreadyUsedException.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Exception; - -use Exception; - -/** - * Thrown when employee's email is already used by another employee. - */ -class EmailAlreadyUsedException extends EmployeeException -{ - /** - * @var string - */ - private $email; - - /** - * @param string $email the email that's being used - * @param string $message - * @param int $code - * @param Exception|null $previous - */ - public function __construct($email, $message = '', $code = 0, $previous = null) - { - parent::__construct($message, $code, $previous); - - $this->email = $email; - } - - /** - * @return string - */ - public function getEmail() - { - return $this->email; - } -} diff --git a/src/Core/Domain/Employee/Exception/EmployeeCannotChangeItselfException.php b/src/Core/Domain/Employee/Exception/EmployeeCannotChangeItselfException.php deleted file mode 100644 index 4ebeb6cd..00000000 --- a/src/Core/Domain/Employee/Exception/EmployeeCannotChangeItselfException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Exception; - -/** - * Class EmployeeCannotChangeItselfException is thrown when employee is trying to change status or delete itself. - */ -class EmployeeCannotChangeItselfException extends EmployeeException -{ - /** - * Code is used when employee which is logged in tries to change its status. - */ - const CANNOT_CHANGE_STATUS = 1; -} diff --git a/src/Core/Domain/Employee/Exception/EmployeeConstraintException.php b/src/Core/Domain/Employee/Exception/EmployeeConstraintException.php deleted file mode 100644 index 1d922872..00000000 --- a/src/Core/Domain/Employee/Exception/EmployeeConstraintException.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Exception; - -/** - * Is thrown when employee constraint is violated - */ -class EmployeeConstraintException extends EmployeeException -{ - /** - * @var int Code is used when invalid email is provided for employee - */ - const INVALID_EMAIL = 1; - - /** - * @var int Code is used when invalid first name is provided for employee - */ - const INVALID_FIRST_NAME = 2; - - /** - * @var int Code is used when invalid last name is provided for employee - */ - const INVALID_LAST_NAME = 3; - - /** - * @var int code is used when password of invalid length is provided for employee - */ - const INVALID_PASSWORD = 4; - - /** - * @var int Code is used when incorrect password is provided for employee - */ - const INCORRECT_PASSWORD = 5; -} diff --git a/src/Core/Domain/Employee/Exception/EmployeeException.php b/src/Core/Domain/Employee/Exception/EmployeeException.php deleted file mode 100644 index 536aba35..00000000 --- a/src/Core/Domain/Employee/Exception/EmployeeException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for employee sub-domain - */ -class EmployeeException extends DomainException -{ -} diff --git a/src/Core/Domain/Employee/Exception/EmployeeNotFoundException.php b/src/Core/Domain/Employee/Exception/EmployeeNotFoundException.php deleted file mode 100644 index 7ecc0e01..00000000 --- a/src/Core/Domain/Employee/Exception/EmployeeNotFoundException.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; - -/** - * Class EmployeeNotFoundException is thrown when employee cannot be found. - */ -class EmployeeNotFoundException extends EmployeeException -{ - /** - * @var EmployeeId - */ - private $employeeId; - - /** - * @param EmployeeId $employeeId - * @param string $message - * @param int $code - * @param \Exception|null $previous - */ - public function __construct(EmployeeId $employeeId, $message = '', $code = 0, $previous = null) - { - parent::__construct($message, $code, $previous); - - $this->employeeId = $employeeId; - } - - /** - * @return EmployeeId - */ - public function getEmployeeId() - { - return $this->employeeId; - } -} diff --git a/src/Core/Domain/Employee/Exception/InvalidEmployeeIdException.php b/src/Core/Domain/Employee/Exception/InvalidEmployeeIdException.php deleted file mode 100644 index 0bce19a8..00000000 --- a/src/Core/Domain/Employee/Exception/InvalidEmployeeIdException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Exception; - -/** - * Class InvalidEmployeeIdException is thrown when EmployeeId with invalid value is being created. - */ -class InvalidEmployeeIdException extends EmployeeException -{ -} diff --git a/src/Core/Domain/Employee/Exception/InvalidPasswordException.php b/src/Core/Domain/Employee/Exception/InvalidPasswordException.php deleted file mode 100644 index c11d10b1..00000000 --- a/src/Core/Domain/Employee/Exception/InvalidPasswordException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Exception; - -/** - * Class InvalidPasswordException thrown when employee password is invalid. - */ -class InvalidPasswordException extends EmployeeException -{ -} diff --git a/src/Core/Domain/Employee/Exception/InvalidProfileException.php b/src/Core/Domain/Employee/Exception/InvalidProfileException.php deleted file mode 100644 index 162367a4..00000000 --- a/src/Core/Domain/Employee/Exception/InvalidProfileException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Exception; - -/** - * Thrown when invalid profile is selected for an employee. - */ -class InvalidProfileException extends EmployeeException -{ -} diff --git a/src/Core/Domain/Employee/Exception/MissingShopAssociationException.php b/src/Core/Domain/Employee/Exception/MissingShopAssociationException.php deleted file mode 100644 index 8d362ca8..00000000 --- a/src/Core/Domain/Employee/Exception/MissingShopAssociationException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Exception; - -/** - * Thrown when shop association is missing for an employee. - */ -class MissingShopAssociationException extends EmployeeException -{ -} diff --git a/src/Core/Domain/Employee/Query/GetEmployeeEmailById.php b/src/Core/Domain/Employee/Query/GetEmployeeEmailById.php deleted file mode 100644 index 20a08b81..00000000 --- a/src/Core/Domain/Employee/Query/GetEmployeeEmailById.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Query; - -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; - -class GetEmployeeEmailById -{ - /** - * @var EmployeeId - */ - private $employeeId; - - /** - * @param int $employeeId - */ - public function __construct(int $employeeId) - { - $this->employeeId = new EmployeeId($employeeId); - } - - /** - * @return EmployeeId - */ - public function getEmployeeId(): EmployeeId - { - return $this->employeeId; - } -} diff --git a/src/Core/Domain/Employee/Query/GetEmployeeForEditing.php b/src/Core/Domain/Employee/Query/GetEmployeeForEditing.php deleted file mode 100644 index 242e5156..00000000 --- a/src/Core/Domain/Employee/Query/GetEmployeeForEditing.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\Query; - -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; - -/** - * Gets employee information for editing. - */ -class GetEmployeeForEditing -{ - /** - * @var EmployeeId - */ - private $employeeId; - - /** - * @param int $employeeId - */ - public function __construct($employeeId) - { - $this->employeeId = new EmployeeId($employeeId); - } - - /** - * @return EmployeeId - */ - public function getEmployeeId() - { - return $this->employeeId; - } -} diff --git a/src/Core/Domain/Employee/QueryHandler/GetEmployeeEmailByIdHandlerInterface.php b/src/Core/Domain/Employee/QueryHandler/GetEmployeeEmailByIdHandlerInterface.php deleted file mode 100644 index 86c670a9..00000000 --- a/src/Core/Domain/Employee/QueryHandler/GetEmployeeEmailByIdHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Employee\Query\GetEmployeeEmailById; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -interface GetEmployeeEmailByIdHandlerInterface -{ - /** - * @param GetEmployeeEmailById $query - * - * @return Email - */ - public function handle(GetEmployeeEmailById $query): Email; -} diff --git a/src/Core/Domain/Employee/QueryHandler/GetEmployeeForEditingHandlerInterface.php b/src/Core/Domain/Employee/QueryHandler/GetEmployeeForEditingHandlerInterface.php deleted file mode 100644 index 15e96630..00000000 --- a/src/Core/Domain/Employee/QueryHandler/GetEmployeeForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Employee\Query\GetEmployeeForEditing; -use PrestaShop\PrestaShop\Core\Domain\Employee\QueryResult\EditableEmployee; - -/** - * Interface for service that gets employee data for editing - */ -interface GetEmployeeForEditingHandlerInterface -{ - /** - * @param GetEmployeeForEditing $query - * - * @return EditableEmployee - */ - public function handle(GetEmployeeForEditing $query); -} diff --git a/src/Core/Domain/Employee/QueryResult/EditableEmployee.php b/src/Core/Domain/Employee/QueryResult/EditableEmployee.php deleted file mode 100644 index 23384afe..00000000 --- a/src/Core/Domain/Employee/QueryResult/EditableEmployee.php +++ /dev/null @@ -1,204 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\FirstName; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\LastName; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; - -/** - * Stores editable data of an employee. - */ -class EditableEmployee -{ - /** - * @var EmployeeId - */ - private $employeeId; - - /** - * @var FirstName - */ - private $firstName; - - /** - * @var LastName - */ - private $lastName; - - /** - * @var Email - */ - private $email; - - /** - * @var int - */ - private $defaultPageId; - - /** - * @var int - */ - private $languageId; - - /** - * @var bool - */ - private $active; - - /** - * @var int - */ - private $profileId; - - /** - * @var array - */ - private $shopAssociation; - - /** - * @var string - */ - private $avatarUrl; - - /** - * @param EmployeeId $employeeId - * @param FirstName $firstName - * @param LastName $lastName - * @param Email $email - * @param string $avatarUrl - * @param int $defaultPageId - * @param int $languageId - * @param bool $active - * @param int $profileId - * @param array $shopAssociation - */ - public function __construct( - EmployeeId $employeeId, - FirstName $firstName, - LastName $lastName, - Email $email, - $avatarUrl, - $defaultPageId, - $languageId, - $active, - $profileId, - array $shopAssociation - ) { - $this->employeeId = $employeeId; - $this->firstName = $firstName; - $this->lastName = $lastName; - $this->email = $email; - $this->defaultPageId = $defaultPageId; - $this->languageId = $languageId; - $this->active = $active; - $this->profileId = $profileId; - $this->shopAssociation = $shopAssociation; - $this->avatarUrl = $avatarUrl; - } - - /** - * @return EmployeeId - */ - public function getEmployeeId() - { - return $this->employeeId; - } - - /** - * @return FirstName - */ - public function getFirstName() - { - return $this->firstName; - } - - /** - * @return LastName - */ - public function getLastName() - { - return $this->lastName; - } - - /** - * @return Email - */ - public function getEmail() - { - return $this->email; - } - - /** - * @return int - */ - public function getDefaultPageId() - { - return $this->defaultPageId; - } - - /** - * @return int - */ - public function getLanguageId() - { - return $this->languageId; - } - - /** - * @return bool - */ - public function isActive() - { - return $this->active; - } - - /** - * @return int - */ - public function getProfileId() - { - return $this->profileId; - } - - /** - * @return array - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } - - /** - * @return string - */ - public function getAvatarUrl() - { - return $this->avatarUrl; - } -} diff --git a/src/Core/Domain/Employee/ValueObject/EmployeeId.php b/src/Core/Domain/Employee/ValueObject/EmployeeId.php deleted file mode 100644 index 33d68357..00000000 --- a/src/Core/Domain/Employee/ValueObject/EmployeeId.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\InvalidEmployeeIdException; - -/** - * Defines Employee ID with it's constraints. - */ -class EmployeeId -{ - /** - * @var int - */ - private $employeeId; - - /** - * @param int $employeeId - * - * @throws InvalidEmployeeIdException - */ - public function __construct($employeeId) - { - $this->assertIntegerIsGreaterThanZero($employeeId); - - $this->employeeId = $employeeId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->employeeId; - } - - /** - * @param int $employeeId - * - * @throws InvalidEmployeeIdException - */ - private function assertIntegerIsGreaterThanZero($employeeId) - { - if (!is_int($employeeId) || 0 > $employeeId) { - throw new InvalidEmployeeIdException(sprintf('Invalid employee id %s supplied. Employee id must be positive integer.', var_export($employeeId, true))); - } - } -} diff --git a/src/Core/Domain/Employee/ValueObject/FirstName.php b/src/Core/Domain/Employee/ValueObject/FirstName.php deleted file mode 100644 index abaf4589..00000000 --- a/src/Core/Domain/Employee/ValueObject/FirstName.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeConstraintException; - -/** - * Carries employee's first name - */ -class FirstName -{ - /** - * @var string Maximum allowed length for first name - */ - const MAX_LENGTH = 255; - - /** - * @var string - */ - private $firstName; - - /** - * @param string $firstName - */ - public function __construct($firstName) - { - $this->assertFirstNameDoesNotExceedAllowedLength($firstName); - $this->assertFirstNameIsValid($firstName); - - $this->firstName = $firstName; - } - - /** - * @return string - */ - public function getValue() - { - return $this->firstName; - } - - /** - * @param string $firstName - * - * @throws EmployeeConstraintException - */ - private function assertFirstNameIsValid($firstName) - { - $matchesFirstNamePattern = preg_match('/^[^0-9!<>,;?=+()@#"°{}_$%:¤|]*$/u', stripslashes($firstName)); - - if (!$matchesFirstNamePattern) { - throw new EmployeeConstraintException(sprintf('Employee first name %s is invalid', var_export($firstName, true)), EmployeeConstraintException::INVALID_FIRST_NAME); - } - } - - /** - * @param string $firstName - * - * @throws EmployeeConstraintException - */ - private function assertFirstNameDoesNotExceedAllowedLength($firstName) - { - $firstName = html_entity_decode($firstName, ENT_COMPAT, 'UTF-8'); - - $length = function_exists('mb_strlen') ? mb_strlen($firstName, 'UTF-8') : strlen($firstName); - if (self::MAX_LENGTH < $length) { - throw new EmployeeConstraintException(sprintf('Employee first name is too long. Max allowed length is %s', self::MAX_LENGTH), EmployeeConstraintException::INVALID_FIRST_NAME); - } - } -} diff --git a/src/Core/Domain/Employee/ValueObject/LastName.php b/src/Core/Domain/Employee/ValueObject/LastName.php deleted file mode 100644 index ab4f43ca..00000000 --- a/src/Core/Domain/Employee/ValueObject/LastName.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeConstraintException; - -/** - * Stores employee's last name - */ -class LastName -{ - /** - * @var string Maximum allowed length for last name - */ - const MAX_LENGTH = 255; - - /** - * @var string - */ - private $lastName; - - /** - * @param string $lastName - */ - public function __construct($lastName) - { - $this->assertLastNameDoesNotExceedAllowedLength($lastName); - $this->assertLastNameIsValid($lastName); - - $this->lastName = $lastName; - } - - /** - * @return string - */ - public function getValue() - { - return $this->lastName; - } - - /** - * @param string $lastName - * - * @throws EmployeeConstraintException - */ - private function assertLastNameIsValid($lastName) - { - $matchesLastNamePattern = preg_match('/^[^0-9!<>,;?=+()@#"°{}_$%:¤|]*$/u', stripslashes($lastName)); - - if (!$matchesLastNamePattern) { - throw new EmployeeConstraintException(sprintf('Employee last name %s is invalid', var_export($lastName, true)), EmployeeConstraintException::INVALID_LAST_NAME); - } - } - - /** - * @param string $lastName - * - * @throws EmployeeConstraintException - */ - private function assertLastNameDoesNotExceedAllowedLength($lastName) - { - $lastName = html_entity_decode($lastName, ENT_COMPAT, 'UTF-8'); - - $length = function_exists('mb_strlen') ? mb_strlen($lastName, 'UTF-8') : strlen($lastName); - if (self::MAX_LENGTH < $length) { - throw new EmployeeConstraintException(sprintf('Employee last name is too long. Max allowed length is %s', self::MAX_LENGTH), EmployeeConstraintException::INVALID_LAST_NAME); - } - } -} diff --git a/src/Core/Domain/Employee/ValueObject/Password.php b/src/Core/Domain/Employee/ValueObject/Password.php deleted file mode 100644 index 0fea673a..00000000 --- a/src/Core/Domain/Employee/ValueObject/Password.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeConstraintException; - -/** - * Stores employee's plain password. - */ -class Password -{ - /** - * @var string minimum required password length - */ - const MIN_LENGTH = 8; - - /** - * @var string maximum allowed password length - */ - const MAX_LENGTH = 255; - - /** - * @var string - */ - private $password; - - /** - * @param string $password - */ - public function __construct($password) - { - $this->assertPasswordIsWithinAllowedLength($password); - - $this->password = $password; - } - - /** - * @return string - */ - public function getValue() - { - return $this->password; - } - - /** - * @param string $password - */ - private function assertPasswordIsWithinAllowedLength($password) - { - $length = function_exists('mb_strlen') ? mb_strlen($password, 'UTF-8') : strlen($password); - - if (self::MIN_LENGTH > $length || $length > self::MAX_LENGTH) { - throw new EmployeeConstraintException(sprintf('Employee password length must be between %s and %s', self::MIN_LENGTH, self::MAX_LENGTH), EmployeeConstraintException::INVALID_PASSWORD); - } - } -} diff --git a/src/Core/Domain/Exception/DomainConstraintException.php b/src/Core/Domain/Exception/DomainConstraintException.php deleted file mode 100644 index 88d9b6ed..00000000 --- a/src/Core/Domain/Exception/DomainConstraintException.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Exception; - -/** - * Class DomainConstraintException is responsible for holding exception codes which can be raised in reusable way. - */ -class DomainConstraintException extends DomainException -{ - /** - * @var int - raised when native php email validation fails. E.g filter_var($email, FILTER_VALIDATE_EMAIL) - */ - const INVALID_EMAIL = 1; - - /** - * Used when invalid money amount is provided - */ - const INVALID_MONEY_AMOUNT = 2; - - /** - * When price reduction type is not within defined types - */ - const INVALID_REDUCTION_TYPE = 3; - - /** - * When price reduction percentage value is not valid - */ - const INVALID_REDUCTION_PERCENTAGE = 4; - - /** - * When price reduction amount value is not valid - */ - const INVALID_REDUCTION_AMOUNT = 5; -} diff --git a/src/Core/Domain/Exception/DomainException.php b/src/Core/Domain/Exception/DomainException.php deleted file mode 100644 index 90ed40a4..00000000 --- a/src/Core/Domain/Exception/DomainException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Base class for all domain exceptions - */ -class DomainException extends CoreException -{ -} diff --git a/src/Core/Domain/Exception/FileUploadException.php b/src/Core/Domain/Exception/FileUploadException.php deleted file mode 100644 index bf92238f..00000000 --- a/src/Core/Domain/Exception/FileUploadException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Exception; - -/** - * This exception on success case has code 0 which is equal to constant UPLOAD_ERR_OK. - * On every other case it has one of the following error code constants: - * - * UPLOAD_ERR_INI_SIZE, - * UPLOAD_ERR_FORM_SIZE, - * UPLOAD_ERR_PARTIAL, - * UPLOAD_ERR_NO_FILE, - * UPLOAD_ERR_NO_TMP_DIR, - * UPLOAD_ERR_CANT_WRITE, - * UPLOAD_ERR_EXTENSION - */ -class FileUploadException extends DomainException -{ -} diff --git a/src/Core/Domain/Exception/InvalidSortingException.php b/src/Core/Domain/Exception/InvalidSortingException.php deleted file mode 100644 index 1cce839c..00000000 --- a/src/Core/Domain/Exception/InvalidSortingException.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Sorting parameter not supported - */ -class InvalidSortingException extends CoreException -{ -} diff --git a/src/Core/Domain/Feature/Command/AddFeatureCommand.php b/src/Core/Domain/Feature/Command/AddFeatureCommand.php deleted file mode 100644 index 19098071..00000000 --- a/src/Core/Domain/Feature/Command/AddFeatureCommand.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Feature\Command; - -use PrestaShop\PrestaShop\Core\Domain\Feature\Exception\FeatureConstraintException; - -/** - * Adds new feature - */ -class AddFeatureCommand -{ - /** - * @var string[] - */ - private $localizedNames; - - /** - * @var int[] - */ - private $shopAssociation; - - /** - * @param string[] $localizedNames - * @param int[] $shopAssociation - */ - public function __construct(array $localizedNames, array $shopAssociation = []) - { - $this->assertNamesAreValid($localizedNames); - - $this->localizedNames = $localizedNames; - $this->shopAssociation = $shopAssociation; - } - - /** - * @return string[] - */ - public function getLocalizedNames() - { - return $this->localizedNames; - } - - /** - * @return int[] - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } - - /** - * Asserts that feature names are valid. - * - * @param string[] $names - * - * @throws FeatureConstraintException - */ - private function assertNamesAreValid(array $names) - { - if (empty($names)) { - throw new FeatureConstraintException('Feature name cannot be empty', FeatureConstraintException::EMPTY_NAME); - } - } -} diff --git a/src/Core/Domain/Feature/Command/EditFeatureCommand.php b/src/Core/Domain/Feature/Command/EditFeatureCommand.php deleted file mode 100644 index 04b54fbe..00000000 --- a/src/Core/Domain/Feature/Command/EditFeatureCommand.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Feature\Command; - -use PrestaShop\PrestaShop\Core\Domain\Feature\Exception\FeatureConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Feature\ValueObject\FeatureId; - -/** - * Edit feature with given data. - */ -class EditFeatureCommand -{ - /** - * @var FeatureId - */ - private $featureId; - - /** - * @var string[] - */ - private $localizedNames; - - /** - * @var int[] - */ - private $associatedShopIds; - - /** - * @param int $featureId - */ - public function __construct($featureId) - { - $this->featureId = new FeatureId($featureId); - } - - /** - * @return FeatureId - */ - public function getFeatureId() - { - return $this->featureId; - } - - /** - * @return string[]|null - */ - public function getLocalizedNames() - { - return $this->localizedNames; - } - - /** - * @param string[] $localizedNames - * - * @return EditFeatureCommand - */ - public function setLocalizedNames(array $localizedNames) - { - if (empty($localizedNames)) { - throw new FeatureConstraintException('Feature name cannot be empty', FeatureConstraintException::EMPTY_NAME); - } - - $this->localizedNames = $localizedNames; - - return $this; - } - - /** - * @return int[]|null - */ - public function getAssociatedShopIds() - { - return $this->associatedShopIds; - } - - /** - * @param int[] $associatedShopIds - * - * @return EditFeatureCommand - */ - public function setAssociatedShopIds($associatedShopIds) - { - $this->associatedShopIds = $associatedShopIds; - - return $this; - } -} diff --git a/src/Core/Domain/Feature/CommandHandler/AddFeatureHandlerInterface.php b/src/Core/Domain/Feature/CommandHandler/AddFeatureHandlerInterface.php deleted file mode 100644 index 755ea2ce..00000000 --- a/src/Core/Domain/Feature/CommandHandler/AddFeatureHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Feature\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Feature\Command\AddFeatureCommand; -use PrestaShop\PrestaShop\Core\Domain\Feature\ValueObject\FeatureId; - -/** - * Describes add feature command handler - */ -interface AddFeatureHandlerInterface -{ - /** - * @param AddFeatureCommand $command - * - * @return FeatureId id of the created feature - */ - public function handle(AddFeatureCommand $command); -} diff --git a/src/Core/Domain/Feature/CommandHandler/EditFeatureHandlerInterface.php b/src/Core/Domain/Feature/CommandHandler/EditFeatureHandlerInterface.php deleted file mode 100644 index 9d410048..00000000 --- a/src/Core/Domain/Feature/CommandHandler/EditFeatureHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Feature\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Feature\Command\EditFeatureCommand; - -/** - * Describes a service that handles feature edit command. - */ -interface EditFeatureHandlerInterface -{ - /** - * @param EditFeatureCommand $command - */ - public function handle(EditFeatureCommand $command); -} diff --git a/src/Core/Domain/Feature/Exception/CannotAddFeatureException.php b/src/Core/Domain/Feature/Exception/CannotAddFeatureException.php deleted file mode 100644 index 4fc320f2..00000000 --- a/src/Core/Domain/Feature/Exception/CannotAddFeatureException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Feature\Exception; - -/** - * Thrown when feature cannot be added. - */ -class CannotAddFeatureException extends FeatureException -{ -} diff --git a/src/Core/Domain/Feature/Exception/CannotEditFeatureException.php b/src/Core/Domain/Feature/Exception/CannotEditFeatureException.php deleted file mode 100644 index 62ddcf88..00000000 --- a/src/Core/Domain/Feature/Exception/CannotEditFeatureException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Feature\Exception; - -/** - * Thrown when feature cannot be edited. - */ -class CannotEditFeatureException extends FeatureException -{ -} diff --git a/src/Core/Domain/Feature/Exception/FeatureConstraintException.php b/src/Core/Domain/Feature/Exception/FeatureConstraintException.php deleted file mode 100644 index 98b61243..00000000 --- a/src/Core/Domain/Feature/Exception/FeatureConstraintException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Feature\Exception; - -/** - * Thrown when Feature data is not valid. - */ -class FeatureConstraintException extends FeatureException -{ - /** - * Code is used when feature does not have name. - */ - const EMPTY_NAME = 1; - - /** - * Used when feature name is invalid. - */ - const INVALID_NAME = 2; -} diff --git a/src/Core/Domain/Feature/Exception/FeatureException.php b/src/Core/Domain/Feature/Exception/FeatureException.php deleted file mode 100644 index 0443b225..00000000 --- a/src/Core/Domain/Feature/Exception/FeatureException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Feature\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Thrown in Feature context. - */ -class FeatureException extends DomainException -{ -} diff --git a/src/Core/Domain/Feature/Exception/FeatureNotFoundException.php b/src/Core/Domain/Feature/Exception/FeatureNotFoundException.php deleted file mode 100644 index 23930326..00000000 --- a/src/Core/Domain/Feature/Exception/FeatureNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Feature\Exception; - -/** - * Thrown when feature could not be found - */ -class FeatureNotFoundException extends FeatureException -{ -} diff --git a/src/Core/Domain/Feature/Exception/InvalidFeatureIdException.php b/src/Core/Domain/Feature/Exception/InvalidFeatureIdException.php deleted file mode 100644 index 17528add..00000000 --- a/src/Core/Domain/Feature/Exception/InvalidFeatureIdException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Feature\Exception; - -/** - * Thrown when invalid feature id is used - */ -class InvalidFeatureIdException extends FeatureException -{ -} diff --git a/src/Core/Domain/Feature/Query/GetFeatureForEditing.php b/src/Core/Domain/Feature/Query/GetFeatureForEditing.php deleted file mode 100644 index f58611c4..00000000 --- a/src/Core/Domain/Feature/Query/GetFeatureForEditing.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Feature\Query; - -use PrestaShop\PrestaShop\Core\Domain\Feature\ValueObject\FeatureId; - -/** - * Retrieves feature data for editing - */ -class GetFeatureForEditing -{ - /** - * @var FeatureId - */ - private $featureId; - - /** - * @param int $featureId - */ - public function __construct($featureId) - { - $this->featureId = new FeatureId($featureId); - } - - /** - * @return FeatureId - */ - public function getFeatureId() - { - return $this->featureId; - } -} diff --git a/src/Core/Domain/Feature/QueryHandler/GetFeatureForEditingHandlerInterface.php b/src/Core/Domain/Feature/QueryHandler/GetFeatureForEditingHandlerInterface.php deleted file mode 100644 index 599b3f1a..00000000 --- a/src/Core/Domain/Feature/QueryHandler/GetFeatureForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Feature\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Feature\Query\GetFeatureForEditing; -use PrestaShop\PrestaShop\Core\Domain\Feature\QueryResult\EditableFeature; - -/** - * Describes feature for editing handler. - */ -interface GetFeatureForEditingHandlerInterface -{ - /** - * @param GetFeatureForEditing $query - * - * @return EditableFeature - */ - public function handle(GetFeatureForEditing $query); -} diff --git a/src/Core/Domain/Feature/QueryResult/EditableFeature.php b/src/Core/Domain/Feature/QueryResult/EditableFeature.php deleted file mode 100644 index 5f2d00fb..00000000 --- a/src/Core/Domain/Feature/QueryResult/EditableFeature.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Feature\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Feature\ValueObject\FeatureId; - -/** - * Stores feature data that's needed for editing. - */ -class EditableFeature -{ - /** - * @var FeatureId - */ - private $featureId; - - /** - * @var string[] - */ - private $name; - - /** - * @var int[] - */ - private $shopAssociationIds; - - /** - * @param FeatureId $featureId - * @param string[] $name - * @param int[] $shopAssociationIds - */ - public function __construct(FeatureId $featureId, array $name, array $shopAssociationIds) - { - $this->featureId = $featureId; - $this->name = $name; - $this->shopAssociationIds = $shopAssociationIds; - } - - /** - * @return FeatureId - */ - public function getFeatureId() - { - return $this->featureId; - } - - /** - * @return string[] - */ - public function getName() - { - return $this->name; - } - - /** - * @return int[] - */ - public function getShopAssociationIds() - { - return $this->shopAssociationIds; - } -} diff --git a/src/Core/Domain/Feature/ValueObject/FeatureId.php b/src/Core/Domain/Feature/ValueObject/FeatureId.php deleted file mode 100644 index 4105b8a0..00000000 --- a/src/Core/Domain/Feature/ValueObject/FeatureId.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Feature\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Feature\Exception\InvalidFeatureIdException; - -/** - * Defines Feature ID with it's constraints. - */ -class FeatureId -{ - /** - * @var int - */ - private $featureId; - - /** - * @param int $featureId - */ - public function __construct($featureId) - { - $this->assertIntegerIsGreaterThanZero($featureId); - - $this->featureId = $featureId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->featureId; - } - - /** - * @param int $featureId - * - * @throws InvalidFeatureIdException - */ - private function assertIntegerIsGreaterThanZero($featureId) - { - if (!is_numeric($featureId) || 0 > $featureId) { - throw new InvalidFeatureIdException(sprintf('Invalid feature id %s supplied. Feature id must be positive integer.', var_export($featureId, true))); - } - } -} diff --git a/src/Core/Domain/Language/Command/AddLanguageCommand.php b/src/Core/Domain/Language/Command/AddLanguageCommand.php deleted file mode 100644 index 7bcf2632..00000000 --- a/src/Core/Domain/Language/Command/AddLanguageCommand.php +++ /dev/null @@ -1,204 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\Command; - -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\IsoCode; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\TagIETF; - -/** - * Adds new language with given data - */ -class AddLanguageCommand -{ - /** - * @var string Language's name - */ - private $name; - - /** - * @var IsoCode Two-letter (639-1) language ISO code, e.g. FR, EN - */ - private $isoCode; - - /** - * @var TagIETF IETF language tag, e.g. en-US - */ - private $tagIETF; - - /** - * @var string - */ - private $flagImagePath; - - /** - * @var string Image that is used as fallback image for product, category and brand - * when the actual image is not available. - * Each language has different "No picture" image. - */ - private $noPictureImagePath; - - /** - * @var string Short date format. e.g. Y-m-d - */ - private $shortDateFormat; - - /** - * @var string Full date format, e.g. Y-m-d H:i:s - */ - private $fullDateFormat; - - /** - * @var bool Is language read from right to left - */ - private $isRtl; - - /** - * @var bool - */ - private $isActive; - - /** - * @var int[] ID of shops which are associated with language - */ - private $shopAssociation; - - /** - * @param string $name - * @param string $isoCode - * @param string $tagIETF - * @param string $shortDateFormat - * @param string $fullDateFormat - * @param string $flagImagePath - * @param string $noPictureImagePath - * @param bool $isRtl - * @param bool $isActive - * @param int[] $shopAssociation - */ - public function __construct( - $name, - $isoCode, - $tagIETF, - $shortDateFormat, - $fullDateFormat, - $flagImagePath, - $noPictureImagePath, - $isRtl, - $isActive, - array $shopAssociation - ) { - $this->name = $name; - $this->isoCode = new IsoCode($isoCode); - $this->tagIETF = new TagIETF($tagIETF); - $this->shortDateFormat = $shortDateFormat; - $this->fullDateFormat = $fullDateFormat; - $this->flagImagePath = $flagImagePath; - $this->noPictureImagePath = $noPictureImagePath; - $this->isRtl = $isRtl; - $this->isActive = $isActive; - $this->shopAssociation = $shopAssociation; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return IsoCode - */ - public function getIsoCode() - { - return $this->isoCode; - } - - /** - * @return TagIETF - */ - public function getTagIETF() - { - return $this->tagIETF; - } - - /** - * @return string - */ - public function getShortDateFormat() - { - return $this->shortDateFormat; - } - - /** - * @return string - */ - public function getFullDateFormat() - { - return $this->fullDateFormat; - } - - /** - * @return string - */ - public function getFlagImagePath() - { - return $this->flagImagePath; - } - - /** - * @return string - */ - public function getNoPictureImagePath() - { - return $this->noPictureImagePath; - } - - /** - * @return bool - */ - public function isRtl() - { - return $this->isRtl; - } - - /** - * @return bool - */ - public function isActive() - { - return $this->isActive; - } - - /** - * @return int[] - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } -} diff --git a/src/Core/Domain/Language/Command/BulkDeleteLanguagesCommand.php b/src/Core/Domain/Language/Command/BulkDeleteLanguagesCommand.php deleted file mode 100644 index 24629e9c..00000000 --- a/src/Core/Domain/Language/Command/BulkDeleteLanguagesCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\Command; - -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; - -/** - * Deletes given languages - */ -class BulkDeleteLanguagesCommand -{ - /** - * @var LanguageId[] - */ - private $languageIds = []; - - /** - * @param int[] $languageIds - */ - public function __construct(array $languageIds) - { - $this->setLanguageIds($languageIds); - } - - /** - * @return LanguageId[] - */ - public function getLanguageIds() - { - return $this->languageIds; - } - - /** - * @param int[] $languageIds - */ - private function setLanguageIds(array $languageIds) - { - if (empty($languageIds)) { - throw new LanguageConstraintException('At least one language must be provided for deleting', LanguageConstraintException::EMPTY_BULK_DELETE); - } - - foreach ($languageIds as $languageId) { - $this->languageIds[] = new LanguageId($languageId); - } - } -} diff --git a/src/Core/Domain/Language/Command/BulkToggleLanguagesStatusCommand.php b/src/Core/Domain/Language/Command/BulkToggleLanguagesStatusCommand.php deleted file mode 100644 index 82368c35..00000000 --- a/src/Core/Domain/Language/Command/BulkToggleLanguagesStatusCommand.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\Command; - -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; - -/** - * Enables/disables languages status - */ -class BulkToggleLanguagesStatusCommand -{ - /** - * @var LanguageId[] - */ - private $languageIds = []; - - /** - * @var bool - */ - private $expectedStatus; - - /** - * @param int[] $languageIds - * @param bool $expectedStatus - */ - public function __construct(array $languageIds, $expectedStatus) - { - $this->assertStatusIsBool($expectedStatus); - - $this->setLanguages($languageIds); - $this->expectedStatus = $expectedStatus; - } - - /** - * @return LanguageId[] - */ - public function getLanguageIds() - { - return $this->languageIds; - } - - /** - * @return bool - */ - public function getStatus() - { - return $this->expectedStatus; - } - - /** - * @param int[] $languageIds - */ - private function setLanguages(array $languageIds) - { - if (empty($languageIds)) { - throw new CategoryConstraintException('Languages must be provided in order to toggle their status'); - } - - foreach ($languageIds as $languageId) { - $this->languageIds[] = new LanguageId($languageId); - } - } - - /** - * @param bool $status - * - * @throws LanguageConstraintException - */ - private function assertStatusIsBool($status) - { - if (!is_bool($status)) { - throw new LanguageConstraintException('Invalid status provided, language status must be type of "bool"'); - } - } -} diff --git a/src/Core/Domain/Language/Command/DeleteLanguageCommand.php b/src/Core/Domain/Language/Command/DeleteLanguageCommand.php deleted file mode 100644 index baea27fb..00000000 --- a/src/Core/Domain/Language/Command/DeleteLanguageCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\Command; - -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; - -/** - * Deletes given languages - */ -class DeleteLanguageCommand -{ - /** - * @var LanguageId - */ - private $languageId; - - /** - * @param int $languageId - */ - public function __construct($languageId) - { - $this->languageId = new LanguageId($languageId); - } - - /** - * @return LanguageId - */ - public function getLanguageId() - { - return $this->languageId; - } -} diff --git a/src/Core/Domain/Language/Command/EditLanguageCommand.php b/src/Core/Domain/Language/Command/EditLanguageCommand.php deleted file mode 100644 index 719e98be..00000000 --- a/src/Core/Domain/Language/Command/EditLanguageCommand.php +++ /dev/null @@ -1,320 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\Command; - -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\IsoCode; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\TagIETF; - -/** - * Edits given language with provided data - */ -class EditLanguageCommand -{ - /** - * @var LanguageId - */ - private $languageId; - - /** - * @var string|null - */ - private $name; - - /** - * @var IsoCode|null - */ - private $isoCode; - - /** - * @var TagIETF|null - */ - private $tagIETF; - - /** - * @var string|null - */ - private $shortDateFormat; - - /** - * @var string|null - */ - private $fullDateFormat; - - /** - * @var string|null - */ - private $flagImagePath; - - /** - * @var string|null - */ - private $noPictureImagePath; - - /** - * @var bool|null - */ - private $isRtl; - - /** - * @var bool|null - */ - private $isActive; - - /** - * @var int[]|null - */ - private $shopAssociation; - - /** - * @param int $languageId - */ - public function __construct($languageId) - { - $this->languageId = new LanguageId($languageId); - } - - /** - * @return LanguageId - */ - public function getLanguageId() - { - return $this->languageId; - } - - /** - * @param LanguageId $languageId - * - * @return self - */ - public function setLanguageId($languageId) - { - $this->languageId = $languageId; - - return $this; - } - - /** - * @return string|null - */ - public function getName() - { - return $this->name; - } - - /** - * @param string|null $name - * - * @return self - */ - public function setName($name) - { - $this->name = $name; - - return $this; - } - - /** - * @return IsoCode|null - */ - public function getIsoCode() - { - return $this->isoCode; - } - - /** - * @param string $isoCode - * - * @return self - */ - public function setIsoCode($isoCode) - { - $this->isoCode = new IsoCode($isoCode); - - return $this; - } - - /** - * @return TagIETF|null - */ - public function getTagIETF() - { - return $this->tagIETF; - } - - /** - * @param string $tagIETF - * - * @return self - */ - public function setTagIETF($tagIETF) - { - $this->tagIETF = new TagIETF($tagIETF); - - return $this; - } - - /** - * @return string|null - */ - public function getShortDateFormat() - { - return $this->shortDateFormat; - } - - /** - * @param string $shortDateFormat - * - * @return self - */ - public function setShortDateFormat($shortDateFormat) - { - $this->shortDateFormat = $shortDateFormat; - - return $this; - } - - /** - * @return string|null - */ - public function getFullDateFormat() - { - return $this->fullDateFormat; - } - - /** - * @param string $fullDateFormat - * - * @return self - */ - public function setFullDateFormat($fullDateFormat) - { - $this->fullDateFormat = $fullDateFormat; - - return $this; - } - - /** - * @return string|null - */ - public function getFlagImagePath() - { - return $this->flagImagePath; - } - - /** - * @param string $flagImagePath - * - * @return self - */ - public function setFlagImagePath($flagImagePath) - { - $this->flagImagePath = $flagImagePath; - - return $this; - } - - /** - * @return string|null - */ - public function getNoPictureImagePath() - { - return $this->noPictureImagePath; - } - - /** - * @param string $noPictureImagePath - * - * @return self - */ - public function setNoPictureImagePath($noPictureImagePath) - { - $this->noPictureImagePath = $noPictureImagePath; - - return $this; - } - - /** - * @return bool|null - */ - public function isRtl() - { - return $this->isRtl; - } - - /** - * @param bool $isRtl - * - * @return self - */ - public function setIsRtl($isRtl) - { - $this->isRtl = $isRtl; - - return $this; - } - - /** - * @return bool|null - */ - public function isActive() - { - return $this->isActive; - } - - /** - * @param bool $isActive - * - * @return self - */ - public function setIsActive($isActive) - { - $this->isActive = $isActive; - - return $this; - } - - /** - * @return int[]|null - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } - - /** - * @param int[] $shopAssociation - * - * @return self - */ - public function setShopAssociation(array $shopAssociation) - { - $this->shopAssociation = $shopAssociation; - - return $this; - } -} diff --git a/src/Core/Domain/Language/Command/ToggleLanguageStatusCommand.php b/src/Core/Domain/Language/Command/ToggleLanguageStatusCommand.php deleted file mode 100644 index c7e4bf17..00000000 --- a/src/Core/Domain/Language/Command/ToggleLanguageStatusCommand.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\Command; - -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; - -/** - * Enables or disables language based in given status - */ -class ToggleLanguageStatusCommand -{ - /** - * @var bool - */ - private $expectedStatus; - - /** - * @var int - */ - private $languageId; - - /** - * @param int $languageId - * @param bool $expectedStatus - * - * @throws LanguageConstraintException Is thrown when invalid data is provided - */ - public function __construct($languageId, $expectedStatus) - { - $this->assertStatusIsBool($expectedStatus); - - $this->expectedStatus = $expectedStatus; - $this->languageId = new LanguageId($languageId); - } - - /** - * @return int|LanguageId - */ - public function getLanguageId() - { - return $this->languageId; - } - - /** - * @return bool - */ - public function getStatus() - { - return $this->expectedStatus; - } - - /** - * @param bool $status - * - * @throws LanguageConstraintException - */ - private function assertStatusIsBool($status) - { - if (!is_bool($status)) { - throw new LanguageConstraintException('Invalid status provided, language status must be type of "bool"'); - } - } -} diff --git a/src/Core/Domain/Language/CommandHandler/AddLanguageHandlerInterface.php b/src/Core/Domain/Language/CommandHandler/AddLanguageHandlerInterface.php deleted file mode 100644 index dd18d15a..00000000 --- a/src/Core/Domain/Language/CommandHandler/AddLanguageHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Language\Command\AddLanguageCommand; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; - -/** - * Interface for services that handles command which adds new language - */ -interface AddLanguageHandlerInterface -{ - /** - * @param AddLanguageCommand $command - * - * @return LanguageId Added language's identity - */ - public function handle(AddLanguageCommand $command); -} diff --git a/src/Core/Domain/Language/CommandHandler/BulkDeleteLanguagesHandlerInterface.php b/src/Core/Domain/Language/CommandHandler/BulkDeleteLanguagesHandlerInterface.php deleted file mode 100644 index 9e2626b6..00000000 --- a/src/Core/Domain/Language/CommandHandler/BulkDeleteLanguagesHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Language\Command\BulkDeleteLanguagesCommand; - -/** - * Interface for service that deletes languages in bulk action - */ -interface BulkDeleteLanguagesHandlerInterface -{ - /** - * @param BulkDeleteLanguagesCommand $command - */ - public function handle(BulkDeleteLanguagesCommand $command); -} diff --git a/src/Core/Domain/Language/CommandHandler/BulkToggleLanguagesStatusHandlerInterface.php b/src/Core/Domain/Language/CommandHandler/BulkToggleLanguagesStatusHandlerInterface.php deleted file mode 100644 index 3a801050..00000000 --- a/src/Core/Domain/Language/CommandHandler/BulkToggleLanguagesStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Language\Command\BulkToggleLanguagesStatusCommand; - -/** - * Interface for service that toggles status for multiple languages - */ -interface BulkToggleLanguagesStatusHandlerInterface -{ - /** - * @param BulkToggleLanguagesStatusCommand $command - */ - public function handle(BulkToggleLanguagesStatusCommand $command); -} diff --git a/src/Core/Domain/Language/CommandHandler/DeleteLanguageHandlerInterface.php b/src/Core/Domain/Language/CommandHandler/DeleteLanguageHandlerInterface.php deleted file mode 100644 index 8b83ae0a..00000000 --- a/src/Core/Domain/Language/CommandHandler/DeleteLanguageHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Language\Command\DeleteLanguageCommand; - -/** - * Interface for service that deletes language - */ -interface DeleteLanguageHandlerInterface -{ - /** - * @param DeleteLanguageCommand $command - */ - public function handle(DeleteLanguageCommand $command); -} diff --git a/src/Core/Domain/Language/CommandHandler/EditLanguageHandlerInterface.php b/src/Core/Domain/Language/CommandHandler/EditLanguageHandlerInterface.php deleted file mode 100644 index 696374f8..00000000 --- a/src/Core/Domain/Language/CommandHandler/EditLanguageHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Language\Command\EditLanguageCommand; - -/** - * Interface for service that implements edit language command handling - */ -interface EditLanguageHandlerInterface -{ - /** - * @param EditLanguageCommand $command - */ - public function handle(EditLanguageCommand $command); -} diff --git a/src/Core/Domain/Language/CommandHandler/ToggleLanguageStatusHandlerInterface.php b/src/Core/Domain/Language/CommandHandler/ToggleLanguageStatusHandlerInterface.php deleted file mode 100644 index 926d9451..00000000 --- a/src/Core/Domain/Language/CommandHandler/ToggleLanguageStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Language\Command\ToggleLanguageStatusCommand; - -/** - * Interface for service that toggles language's status - */ -interface ToggleLanguageStatusHandlerInterface -{ - /** - * @param ToggleLanguageStatusCommand $command - */ - public function handle(ToggleLanguageStatusCommand $command); -} diff --git a/src/Core/Domain/Language/Exception/CannotDisableDefaultLanguageException.php b/src/Core/Domain/Language/Exception/CannotDisableDefaultLanguageException.php deleted file mode 100644 index eecc3fe3..00000000 --- a/src/Core/Domain/Language/Exception/CannotDisableDefaultLanguageException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\Exception; - -/** - * Exception is thrown when trying to disable default language - */ -class CannotDisableDefaultLanguageException extends LanguageException -{ -} diff --git a/src/Core/Domain/Language/Exception/CopyingNoPictureException.php b/src/Core/Domain/Language/Exception/CopyingNoPictureException.php deleted file mode 100644 index f3f1f593..00000000 --- a/src/Core/Domain/Language/Exception/CopyingNoPictureException.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\Exception; - -/** - * Is thrown when error occurs while copying "No picture" for language - */ -class CopyingNoPictureException extends LanguageException -{ - /** - * @var int Code is used when error occurs while copying "No picture" image to products directory - */ - const PRODUCT_IMAGE_COPY_ERROR = 1; - - /** - * @var int Code is used when error occurs while copying "No picture" image to categories directory - */ - const CATEGORY_IMAGE_COPY_ERROR = 2; - - /** - * @var int Code is used when error occurs while copying "No picture" image to brands (manufacturers) directory - */ - const BRAND_IMAGE_COPY_ERROR = 3; -} diff --git a/src/Core/Domain/Language/Exception/DefaultLanguageException.php b/src/Core/Domain/Language/Exception/DefaultLanguageException.php deleted file mode 100644 index 632b7286..00000000 --- a/src/Core/Domain/Language/Exception/DefaultLanguageException.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\Exception; - -/** - * Is thrown when error that is related to default language occurs - */ -class DefaultLanguageException extends LanguageException -{ - /** - * @var string Code is used when deleting default language - */ - const CANNOT_DELETE_ERROR = 1; - - /** - * @var string Code is uswed when disabling default language - */ - const CANNOT_DISABLE_ERROR = 2; - - /** - * @var string Code is used when deleting language that is use (e.g. as employee's default language) - */ - const CANNOT_DELETE_IN_USE_ERROR = 3; -} diff --git a/src/Core/Domain/Language/Exception/LanguageConstraintException.php b/src/Core/Domain/Language/Exception/LanguageConstraintException.php deleted file mode 100644 index 786a41ff..00000000 --- a/src/Core/Domain/Language/Exception/LanguageConstraintException.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\Exception; - -/** - * Is thrown when invalid data is supplied for language - */ -class LanguageConstraintException extends LanguageException -{ - /** - * @var int Code is used when invalid language IETF tag is encountered - */ - const INVALID_IETF_TAG = 1; - - /** - * @var int Code is used when invalid language ISO code in encountered - */ - const INVALID_ISO_CODE = 2; - - /** - * @var int Code is used when duplicate language ISO code in encountered when creating new language - */ - const DUPLICATE_ISO_CODE = 3; - - /** - * @var int Code is used when empty data is used when deleting languages - */ - const EMPTY_BULK_DELETE = 4; -} diff --git a/src/Core/Domain/Language/Exception/LanguageException.php b/src/Core/Domain/Language/Exception/LanguageException.php deleted file mode 100644 index fdbfb6b5..00000000 --- a/src/Core/Domain/Language/Exception/LanguageException.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * LanguageException is base exception for language subdomain - */ -class LanguageException extends DomainException -{ - /** - * When language is not active - */ - const NOT_ACTIVE = 1; -} diff --git a/src/Core/Domain/Language/Exception/LanguageImageUploadingException.php b/src/Core/Domain/Language/Exception/LanguageImageUploadingException.php deleted file mode 100644 index 443b06ea..00000000 --- a/src/Core/Domain/Language/Exception/LanguageImageUploadingException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\Exception; - -/** - * Is thrown when error occurs when uploading language image - */ -class LanguageImageUploadingException extends LanguageException -{ - /** - * @var int Code is used when there are less memory than needed to upload image - */ - const MEMORY_LIMIT_RESTRICTION = 1; - - /** - * @var int Code is used when unexpected error occurs while uploading image - */ - const UNEXPECTED_ERROR = 2; -} diff --git a/src/Core/Domain/Language/Exception/LanguageNotFoundException.php b/src/Core/Domain/Language/Exception/LanguageNotFoundException.php deleted file mode 100644 index 3274020b..00000000 --- a/src/Core/Domain/Language/Exception/LanguageNotFoundException.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; - -/** - * Exception is thrown when language is not found - */ -class LanguageNotFoundException extends LanguageException -{ - /** - * @var LanguageId - */ - private $languageId; - - /** - * @param LanguageId $languageId - * @param string $message - * @param int $code - * @param \Exception|null $previous - */ - public function __construct(LanguageId $languageId, $message = '', $code = 0, $previous = null) - { - $this->languageId = $languageId; - - parent::__construct($message, $code, $previous); - } - - /** - * @return LanguageId - */ - public function getLanguageId() - { - return $this->languageId; - } -} diff --git a/src/Core/Domain/Language/Query/GetLanguageForEditing.php b/src/Core/Domain/Language/Query/GetLanguageForEditing.php deleted file mode 100644 index da0d13d9..00000000 --- a/src/Core/Domain/Language/Query/GetLanguageForEditing.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\Query; - -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; - -/** - * Gets language for editing in Back Office - */ -class GetLanguageForEditing -{ - /** - * @var LanguageId - */ - private $languageId; - - /** - * @param int $languageId - */ - public function __construct($languageId) - { - $this->languageId = new LanguageId($languageId); - } - - /** - * @return LanguageId - */ - public function getLanguageId() - { - return $this->languageId; - } -} diff --git a/src/Core/Domain/Language/QueryHandler/GetLanguageForEditingHandlerInterface.php b/src/Core/Domain/Language/QueryHandler/GetLanguageForEditingHandlerInterface.php deleted file mode 100644 index 38502034..00000000 --- a/src/Core/Domain/Language/QueryHandler/GetLanguageForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Language\Query\GetLanguageForEditing; -use PrestaShop\PrestaShop\Core\Domain\Language\QueryResult\EditableLanguage; - -/** - * Interface for service that gets language for editing - */ -interface GetLanguageForEditingHandlerInterface -{ - /** - * @param GetLanguageForEditing $query - * - * @return EditableLanguage - */ - public function handle(GetLanguageForEditing $query); -} diff --git a/src/Core/Domain/Language/QueryResult/EditableLanguage.php b/src/Core/Domain/Language/QueryResult/EditableLanguage.php deleted file mode 100644 index 4f6c6f61..00000000 --- a/src/Core/Domain/Language/QueryResult/EditableLanguage.php +++ /dev/null @@ -1,187 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\IsoCode; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\TagIETF; - -/** - * Transfers editable language's data - */ -class EditableLanguage -{ - /** - * @var LanguageId - */ - private $languageId; - - /** - * @var string - */ - private $name; - - /** - * @var IsoCode - */ - private $isoCode; - - /** - * @var TagIETF - */ - private $tagIETF; - - /** - * @var string - */ - private $shortDateFormat; - - /** - * @var string - */ - private $fullDateFormat; - - /** - * @var bool - */ - private $isRtl; - - /** - * @var bool - */ - private $isActive; - - /** - * @var array - */ - private $shopAssociation; - - /** - * @param LanguageId $languageId - * @param string $name - * @param IsoCode $isoCode - * @param TagIETF $tagIETF - * @param string $shortDateFormat - * @param string $fullDateFormat - * @param bool $isRtl - * @param bool $isActive - * @param array $shopAssociation - */ - public function __construct( - LanguageId $languageId, - $name, - IsoCode $isoCode, - TagIETF $tagIETF, - $shortDateFormat, - $fullDateFormat, - $isRtl, - $isActive, - array $shopAssociation - ) { - $this->languageId = $languageId; - $this->name = $name; - $this->isoCode = $isoCode; - $this->tagIETF = $tagIETF; - $this->shortDateFormat = $shortDateFormat; - $this->fullDateFormat = $fullDateFormat; - $this->isRtl = $isRtl; - $this->isActive = $isActive; - $this->shopAssociation = $shopAssociation; - } - - /** - * @return LanguageId - */ - public function getLanguageId() - { - return $this->languageId; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return IsoCode - */ - public function getIsoCode() - { - return $this->isoCode; - } - - /** - * @return TagIETF - */ - public function getTagIETF() - { - return $this->tagIETF; - } - - /** - * @return string - */ - public function getShortDateFormat() - { - return $this->shortDateFormat; - } - - /** - * @return string - */ - public function getFullDateFormat() - { - return $this->fullDateFormat; - } - - /** - * @return bool - */ - public function isRtl() - { - return $this->isRtl; - } - - /** - * @return bool - */ - public function isActive() - { - return $this->isActive; - } - - /** - * @return array - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } -} diff --git a/src/Core/Domain/Language/ValueObject/IsoCode.php b/src/Core/Domain/Language/ValueObject/IsoCode.php deleted file mode 100644 index ee1c8937..00000000 --- a/src/Core/Domain/Language/ValueObject/IsoCode.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageException; - -/** - * Stores language's two-letter (639-1) ISO code - */ -class IsoCode -{ - /** - * @var string ISO Code validation pattern - */ - const PATTERN = '/^[a-zA-Z]{2,3}$/'; - - /** - * @var string - */ - private $isoCode; - - /** - * @param string $isoCode - */ - public function __construct($isoCode) - { - $this->assertIsIsoCode($isoCode); - - $this->isoCode = strtolower($isoCode); - } - - /** - * @return string - */ - public function getValue() - { - return $this->isoCode; - } - - /** - * @param string $isoCode - * - * @throws LanguageException - */ - private function assertIsIsoCode($isoCode) - { - if (!is_string($isoCode) || !preg_match('/^[a-zA-Z]{2,3}$/', $isoCode)) { - throw new LanguageConstraintException(sprintf('Invalid language ISO code %s supplied', var_export($isoCode, true)), LanguageConstraintException::INVALID_ISO_CODE); - } - } -} diff --git a/src/Core/Domain/Language/ValueObject/LanguageId.php b/src/Core/Domain/Language/ValueObject/LanguageId.php deleted file mode 100644 index 651a04fa..00000000 --- a/src/Core/Domain/Language/ValueObject/LanguageId.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageException; - -/** - * Stores language's identity - */ -class LanguageId -{ - /** - * @var int - */ - private $id; - - /** - * @param int $id - */ - public function __construct($id) - { - $this->assertIsIntegerGreaterThanZero($id); - - $this->id = $id; - } - - /** - * @return int - */ - public function getValue() - { - return $this->id; - } - - /** - * @param int $id - */ - private function assertIsIntegerGreaterThanZero($id) - { - if (!is_int($id) || 0 >= $id) { - throw new LanguageException(sprintf('Invalid language id %s provided', var_export($id, true))); - } - } -} diff --git a/src/Core/Domain/Language/ValueObject/TagIETF.php b/src/Core/Domain/Language/ValueObject/TagIETF.php deleted file mode 100644 index 64bf06fe..00000000 --- a/src/Core/Domain/Language/ValueObject/TagIETF.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Language\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageConstraintException; - -/** - * Stores IETF tag value (e.g. en-US) - */ -class TagIETF -{ - /** - * @var string - */ - private $tagIETF; - - /** - * @param string $tagIETF - * - * @throws LanguageConstraintException - */ - public function __construct($tagIETF) - { - $this->assertIsTagIETF($tagIETF); - - $this->tagIETF = $tagIETF; - } - - /** - * @return string - */ - public function getValue() - { - return $this->tagIETF; - } - - /** - * @param string $tagIETF - * - * @throws LanguageConstraintException - */ - private function assertIsTagIETF($tagIETF) - { - if (!is_string($tagIETF) || !preg_match('/^[a-zA-Z]{2}(-[a-zA-Z]{2})?$/', $tagIETF)) { - throw new LanguageConstraintException(sprintf('Invalid IETF tag %s provided', var_export($tagIETF, true)), LanguageConstraintException::INVALID_IETF_TAG); - } - } -} diff --git a/src/Core/Domain/MailTemplate/Command/GenerateThemeMailTemplatesCommand.php b/src/Core/Domain/MailTemplate/Command/GenerateThemeMailTemplatesCommand.php deleted file mode 100644 index 366957b1..00000000 --- a/src/Core/Domain/MailTemplate/Command/GenerateThemeMailTemplatesCommand.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\MailTemplate\Command; - -/** - * Class GenerateThemeMailsCommand generates email theme's templates for a specific - * language. If folders are not overridden in the command then MailTemplateGenerator - * will use the default output folders (in mails folder). - */ -class GenerateThemeMailTemplatesCommand -{ - /** @var string */ - private $themeName; - - /** @var string */ - private $language; - - /** @var bool */ - private $overwriteTemplates; - - /** @var string */ - private $coreMailsFolder = ''; - - /** @var string */ - private $modulesMailFolder = ''; - - /** - * @param string $themeName - * @param string $language locale, for example: 'en' - * @param bool $overwriteTemplates - * @param string $coreMailsFolder Output folder for core emails (if left empty the default mails folder will be used) - * @param string $modulesMailFolder Output folder for modules emails (if left empty the module mails folder will be used) - */ - public function __construct( - $themeName, - $language, - $overwriteTemplates = false, - $coreMailsFolder = '', - $modulesMailFolder = '' - ) { - $this->themeName = $themeName; - $this->language = $language; - $this->overwriteTemplates = $overwriteTemplates; - $this->coreMailsFolder = $coreMailsFolder; - $this->modulesMailFolder = $modulesMailFolder; - } - - /** - * @return string - */ - public function getThemeName() - { - return $this->themeName; - } - - /** - * @return string - */ - public function getLanguage() - { - return $this->language; - } - - /** - * @return bool - */ - public function overwriteTemplates() - { - return $this->overwriteTemplates; - } - - /** - * @return string - */ - public function getCoreMailsFolder() - { - return $this->coreMailsFolder; - } - - /** - * @return string - */ - public function getModulesMailFolder() - { - return $this->modulesMailFolder; - } -} diff --git a/src/Core/Domain/MailTemplate/CommandHandler/GenerateThemeMailTemplatesCommandHandler.php b/src/Core/Domain/MailTemplate/CommandHandler/GenerateThemeMailTemplatesCommandHandler.php deleted file mode 100644 index fb6e15e6..00000000 --- a/src/Core/Domain/MailTemplate/CommandHandler/GenerateThemeMailTemplatesCommandHandler.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\MailTemplate\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\MailTemplate\Command\GenerateThemeMailTemplatesCommand; -use PrestaShop\PrestaShop\Core\Exception\InvalidArgumentException; -use PrestaShop\PrestaShop\Core\Language\LanguageInterface; -use PrestaShop\PrestaShop\Core\Language\LanguageRepositoryInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\MailTemplateGenerator; -use PrestaShop\PrestaShop\Core\MailTemplate\ThemeCatalogInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\ThemeInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class GenerateThemeMailTemplatesCommandHandler generates email templates with parameters provided - * by GenerateThemeMailTemplatesCommand. If no output folders are defined by the command its output - * folders are the default ones. - */ -class GenerateThemeMailTemplatesCommandHandler implements GenerateThemeMailTemplatesCommandHandlerInterface -{ - /** @var LanguageRepositoryInterface */ - private $languageRepository; - - /** @var ThemeCatalogInterface */ - private $themeCatalog; - - /** @var MailTemplateGenerator */ - private $generator; - - /** @var TranslatorInterface */ - private $translator; - - /** @var string */ - private $defaultCoreMailsFolder; - - /** @var string */ - private $defaultModulesMailFolder; - - /** - * @param LanguageRepositoryInterface $languageRepository - * @param ThemeCatalogInterface $themeCatalog - * @param MailTemplateGenerator $generator - * @param TranslatorInterface $translator - * @param string $defaultCoreMailsFolder - * @param string $defaultModulesMailFolder - */ - public function __construct( - LanguageRepositoryInterface $languageRepository, - ThemeCatalogInterface $themeCatalog, - MailTemplateGenerator $generator, - TranslatorInterface $translator, - $defaultCoreMailsFolder, - $defaultModulesMailFolder - ) { - $this->languageRepository = $languageRepository; - $this->themeCatalog = $themeCatalog; - $this->generator = $generator; - $this->translator = $translator; - $this->defaultCoreMailsFolder = $defaultCoreMailsFolder; - $this->defaultModulesMailFolder = $defaultModulesMailFolder; - } - - /** - * {@inheritdoc} - */ - public function handle(GenerateThemeMailTemplatesCommand $command) - { - /** @var LanguageInterface $language */ - $language = $this->languageRepository->getOneByLocaleOrIsoCode($command->getLanguage()); - if (null === $language) { - throw new InvalidArgumentException(sprintf('Could not find Language for locale: %s', $command->getLanguage())); - } - - /** @var ThemeInterface $theme */ - $theme = $this->themeCatalog->getByName($command->getThemeName()); - - $coreMailsFolder = $command->getCoreMailsFolder() ?: $this->defaultCoreMailsFolder; - $modulesMailFolder = $command->getModulesMailFolder() ?: $this->defaultModulesMailFolder; - - $this->generator->generateTemplates($theme, $language, $coreMailsFolder, $modulesMailFolder, $command->overwriteTemplates()); - } -} diff --git a/src/Core/Domain/MailTemplate/CommandHandler/GenerateThemeMailTemplatesCommandHandlerInterface.php b/src/Core/Domain/MailTemplate/CommandHandler/GenerateThemeMailTemplatesCommandHandlerInterface.php deleted file mode 100644 index 1f3737bf..00000000 --- a/src/Core/Domain/MailTemplate/CommandHandler/GenerateThemeMailTemplatesCommandHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\MailTemplate\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\MailTemplate\Command\GenerateThemeMailTemplatesCommand; - -/** - * Interface GenerateThemeMailsHandlerInterface - */ -interface GenerateThemeMailTemplatesCommandHandlerInterface -{ - /** - * @param GenerateThemeMailTemplatesCommand $command - */ - public function handle(GenerateThemeMailTemplatesCommand $command); -} diff --git a/src/Core/Domain/Manufacturer/Command/AddManufacturerCommand.php b/src/Core/Domain/Manufacturer/Command/AddManufacturerCommand.php deleted file mode 100644 index 245cf825..00000000 --- a/src/Core/Domain/Manufacturer/Command/AddManufacturerCommand.php +++ /dev/null @@ -1,167 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command; - -/** - * Creates manufacturer with provided data - */ -class AddManufacturerCommand -{ - /** - * @var string - */ - private $name; - - /** - * @var string[] - */ - private $localizedShortDescriptions; - - /** - * @var string[] - */ - private $localizedDescriptions; - - /** - * @var string[] - */ - private $localizedMetaTitles; - - /** - * @var string[] - */ - private $localizedMetaDescriptions; - - /** - * @var string[] - */ - private $localizedMetaKeywords; - - /** - * @var bool - */ - private $enabled; - - /** - * @var array - */ - private $shopAssociation; - - /** - * @param string $name - * @param bool $enabled - * @param string[] $localizedShortDescriptions - * @param string[] $localizedDescriptions - * @param string[] $localizedMetaTitles - * @param string[] $localizedMetaDescriptions - * @param string[] $localizedMetaKeywords - * @param array $shopAssociation - */ - public function __construct( - $name, - $enabled, - array $localizedShortDescriptions, - array $localizedDescriptions, - array $localizedMetaTitles, - array $localizedMetaDescriptions, - array $localizedMetaKeywords, - array $shopAssociation - ) { - $this->name = $name; - $this->enabled = $enabled; - $this->localizedShortDescriptions = $localizedShortDescriptions; - $this->localizedDescriptions = $localizedDescriptions; - $this->localizedMetaTitles = $localizedMetaTitles; - $this->localizedMetaDescriptions = $localizedMetaDescriptions; - $this->localizedMetaKeywords = $localizedMetaKeywords; - $this->shopAssociation = $shopAssociation; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return string[] - */ - public function getLocalizedShortDescriptions() - { - return $this->localizedShortDescriptions; - } - - /** - * @return string[] - */ - public function getLocalizedDescriptions() - { - return $this->localizedDescriptions; - } - - /** - * @return string[] - */ - public function getLocalizedMetaTitles() - { - return $this->localizedMetaTitles; - } - - /** - * @return string[] - */ - public function getLocalizedMetaDescriptions() - { - return $this->localizedMetaDescriptions; - } - - /** - * @return string[] - */ - public function getLocalizedMetaKeywords() - { - return $this->localizedMetaKeywords; - } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->enabled; - } - - /** - * @return array - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } -} diff --git a/src/Core/Domain/Manufacturer/Command/BulkDeleteManufacturerCommand.php b/src/Core/Domain/Manufacturer/Command/BulkDeleteManufacturerCommand.php deleted file mode 100644 index a7096802..00000000 --- a/src/Core/Domain/Manufacturer/Command/BulkDeleteManufacturerCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\ManufacturerConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\ValueObject\ManufacturerId; - -/** - * Deletes manufacturers in bulk action - */ -class BulkDeleteManufacturerCommand -{ - /** - * @var ManufacturerId[] - */ - private $manufacturerIds; - - /** - * @param int[] $manufacturerIds - * - * @throws ManufacturerConstraintException - */ - public function __construct(array $manufacturerIds) - { - $this->setManufacturerIds($manufacturerIds); - } - - /** - * @return ManufacturerId[] - */ - public function getManufacturerIds() - { - return $this->manufacturerIds; - } - - /** - * @param array $manufacturerIds - * - * @throws ManufacturerConstraintException - */ - private function setManufacturerIds(array $manufacturerIds) - { - foreach ($manufacturerIds as $manufacturerId) { - $this->manufacturerIds[] = new ManufacturerId($manufacturerId); - } - } -} diff --git a/src/Core/Domain/Manufacturer/Command/BulkToggleManufacturerStatusCommand.php b/src/Core/Domain/Manufacturer/Command/BulkToggleManufacturerStatusCommand.php deleted file mode 100644 index 31118486..00000000 --- a/src/Core/Domain/Manufacturer/Command/BulkToggleManufacturerStatusCommand.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\ManufacturerConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\ValueObject\ManufacturerId; - -/** - * Toggles manufacturer status in bulk action - */ -class BulkToggleManufacturerStatusCommand -{ - /** - * @var bool - */ - private $expectedStatus; - - /** - * @var ManufacturerId[] - */ - private $manufacturerIds; - - /** - * @param int[] $manufacturerIds - * @param bool $expectedStatus - * - * @throws ManufacturerConstraintException - * @throws ManufacturerConstraintException - */ - public function __construct(array $manufacturerIds, $expectedStatus) - { - $this->assertIsBool($expectedStatus); - $this->expectedStatus = $expectedStatus; - $this->setManufacturerIds($manufacturerIds); - } - - /** - * @return bool - */ - public function getExpectedStatus() - { - return $this->expectedStatus; - } - - /** - * @return ManufacturerId[] - */ - public function getManufacturerIds() - { - return $this->manufacturerIds; - } - - /** - * @param int[] $manufacturerIds - * - * @throws ManufacturerConstraintException - */ - private function setManufacturerIds(array $manufacturerIds) - { - foreach ($manufacturerIds as $manufacturerId) { - $this->manufacturerIds[] = new ManufacturerId($manufacturerId); - } - } - - /** - * Validates that value is of type boolean - * - * @param $value - * - * @throws ManufacturerConstraintException - */ - private function assertIsBool($value) - { - if (!is_bool($value)) { - throw new ManufacturerConstraintException(sprintf('Status must be of type bool, but given %s', var_export($value, true)), ManufacturerConstraintException::INVALID_STATUS); - } - } -} diff --git a/src/Core/Domain/Manufacturer/Command/DeleteManufacturerCommand.php b/src/Core/Domain/Manufacturer/Command/DeleteManufacturerCommand.php deleted file mode 100644 index ff13de8e..00000000 --- a/src/Core/Domain/Manufacturer/Command/DeleteManufacturerCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\ManufacturerConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\ValueObject\ManufacturerId; - -/** - * Deletes manufacturer - */ -class DeleteManufacturerCommand -{ - /** - * @var ManufacturerId - */ - private $manufacturerId; - - /** - * @param int $manufacturerId - * - * @throws ManufacturerConstraintException - */ - public function __construct($manufacturerId) - { - $this->manufacturerId = new ManufacturerId($manufacturerId); - } - - /** - * @return ManufacturerId - */ - public function getManufacturerId() - { - return $this->manufacturerId; - } -} diff --git a/src/Core/Domain/Manufacturer/Command/EditManufacturerCommand.php b/src/Core/Domain/Manufacturer/Command/EditManufacturerCommand.php deleted file mode 100644 index cf8c611d..00000000 --- a/src/Core/Domain/Manufacturer/Command/EditManufacturerCommand.php +++ /dev/null @@ -1,256 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\ValueObject\ManufacturerId; - -/** - * Edits manufacturer with provided data - */ -class EditManufacturerCommand -{ - /** - * @var ManufacturerId - */ - private $manufacturerId; - - /** - * @var string|null - */ - private $name; - - /** - * @var string[]|null - */ - private $localizedShortDescriptions; - - /** - * @var string[]|null - */ - private $localizedDescriptions; - - /** - * @var string[]|null - */ - private $localizedMetaTitles; - - /** - * @var string[]|null - */ - private $localizedMetaDescriptions; - - /** - * @var string[]|null - */ - private $localizedMetaKeywords; - - /** - * @var bool|null - */ - private $enabled; - - /** - * @var array|null - */ - private $associatedShops; - - /** - * @param int $manufacturerId - */ - public function __construct($manufacturerId) - { - $this->manufacturerId = new ManufacturerId($manufacturerId); - } - - /** - * @return ManufacturerId - */ - public function getManufacturerId() - { - return $this->manufacturerId; - } - - /** - * @return string|null - */ - public function getName() - { - return $this->name; - } - - /** - * @param string|null $name - * - * @return self - */ - public function setName($name) - { - $this->name = $name; - - return $this; - } - - /** - * @return string[]|null - */ - public function getLocalizedShortDescriptions() - { - return $this->localizedShortDescriptions; - } - - /** - * @return string[]|null - */ - public function getLocalizedDescriptions() - { - return $this->localizedDescriptions; - } - - /** - * @param string[]|null $localizedDescriptions - * - * @return self - */ - public function setLocalizedDescriptions($localizedDescriptions) - { - $this->localizedDescriptions = $localizedDescriptions; - - return $this; - } - - /** - * @param string[]|null $localizedShortDescriptions - * - * @return self - */ - public function setLocalizedShortDescriptions($localizedShortDescriptions) - { - $this->localizedShortDescriptions = $localizedShortDescriptions; - - return $this; - } - - /** - * @return string[]|null - */ - public function getLocalizedMetaTitles() - { - return $this->localizedMetaTitles; - } - - /** - * @param string[]|null $localizedMetaTitles - * - * @return self - */ - public function setLocalizedMetaTitles($localizedMetaTitles) - { - $this->localizedMetaTitles = $localizedMetaTitles; - - return $this; - } - - /** - * @return string[]|null - */ - public function getLocalizedMetaDescriptions() - { - return $this->localizedMetaDescriptions; - } - - /** - * @param string[]|null $localizedMetaDescriptions - * - * @return self - */ - public function setLocalizedMetaDescriptions($localizedMetaDescriptions) - { - $this->localizedMetaDescriptions = $localizedMetaDescriptions; - - return $this; - } - - /** - * @return string[]|null - */ - public function getLocalizedMetaKeywords() - { - return $this->localizedMetaKeywords; - } - - /** - * @param string[]|null $localizedMetaKeywords - * - * @return self - */ - public function setLocalizedMetaKeywords($localizedMetaKeywords) - { - $this->localizedMetaKeywords = $localizedMetaKeywords; - - return $this; - } - - /** - * @return bool|null - */ - public function isEnabled() - { - return $this->enabled; - } - - /** - * @param bool|null $enabled - * - * @return self - */ - public function setEnabled($enabled) - { - $this->enabled = $enabled; - - return $this; - } - - /** - * @return array - */ - public function getAssociatedShops() - { - return $this->associatedShops; - } - - /** - * @param $associatedShops - * - * @return self - */ - public function setAssociatedShops($associatedShops) - { - $this->associatedShops = $associatedShops; - - return $this; - } -} diff --git a/src/Core/Domain/Manufacturer/Command/ToggleManufacturerStatusCommand.php b/src/Core/Domain/Manufacturer/Command/ToggleManufacturerStatusCommand.php deleted file mode 100644 index d2a63543..00000000 --- a/src/Core/Domain/Manufacturer/Command/ToggleManufacturerStatusCommand.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\ManufacturerConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\ValueObject\ManufacturerId; - -/** - * Toggles manufacturer status - */ -class ToggleManufacturerStatusCommand -{ - /** - * @var ManufacturerId - */ - private $manufacturerId; - - /** - * @var bool - */ - private $expectedStatus; - - /** - * @param int $manufacturerId - * @param bool $expectedStatus - * - * @throws ManufacturerConstraintException - */ - public function __construct($manufacturerId, $expectedStatus) - { - $this->assertIsBool($expectedStatus); - $this->expectedStatus = $expectedStatus; - $this->manufacturerId = new ManufacturerId($manufacturerId); - } - - /** - * @return ManufacturerId - */ - public function getManufacturerId() - { - return $this->manufacturerId; - } - - /** - * @return bool - */ - public function getExpectedStatus() - { - return $this->expectedStatus; - } - - /** - * Validates that value is of type boolean - * - * @param $value - * - * @throws ManufacturerConstraintException - */ - private function assertIsBool($value) - { - if (!is_bool($value)) { - throw new ManufacturerConstraintException(sprintf('Status must be of type bool, but given %s', var_export($value, true)), ManufacturerConstraintException::INVALID_STATUS); - } - } -} diff --git a/src/Core/Domain/Manufacturer/CommandHandler/AddManufacturerHandlerInterface.php b/src/Core/Domain/Manufacturer/CommandHandler/AddManufacturerHandlerInterface.php deleted file mode 100644 index 48d64d00..00000000 --- a/src/Core/Domain/Manufacturer/CommandHandler/AddManufacturerHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\AddManufacturerCommand; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\ValueObject\ManufacturerId; - -/** - * Defines contract for AddManufacturerHandler - */ -interface AddManufacturerHandlerInterface -{ - /** - * @param AddManufacturerCommand $command - * - * @return ManufacturerId - */ - public function handle(AddManufacturerCommand $command); -} diff --git a/src/Core/Domain/Manufacturer/CommandHandler/BulkDeleteManufacturerHandlerInterface.php b/src/Core/Domain/Manufacturer/CommandHandler/BulkDeleteManufacturerHandlerInterface.php deleted file mode 100644 index e8d916fa..00000000 --- a/src/Core/Domain/Manufacturer/CommandHandler/BulkDeleteManufacturerHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\BulkDeleteManufacturerCommand; - -/** - * Defines contract for BulkDeleteManufacturerHandler - */ -interface BulkDeleteManufacturerHandlerInterface -{ - /** - * @param BulkDeleteManufacturerCommand $command - */ - public function handle(BulkDeleteManufacturerCommand $command); -} diff --git a/src/Core/Domain/Manufacturer/CommandHandler/BulkToggleManufacturerStatusHandlerInterface.php b/src/Core/Domain/Manufacturer/CommandHandler/BulkToggleManufacturerStatusHandlerInterface.php deleted file mode 100644 index 1ab406e3..00000000 --- a/src/Core/Domain/Manufacturer/CommandHandler/BulkToggleManufacturerStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\BulkToggleManufacturerStatusCommand; - -/** - * Defines contract for BulkToggleManufacturerStatusHandler - */ -interface BulkToggleManufacturerStatusHandlerInterface -{ - /** - * @param BulkToggleManufacturerStatusCommand $command - */ - public function handle(BulkToggleManufacturerStatusCommand $command); -} diff --git a/src/Core/Domain/Manufacturer/CommandHandler/DeleteManufacturerHandlerInterface.php b/src/Core/Domain/Manufacturer/CommandHandler/DeleteManufacturerHandlerInterface.php deleted file mode 100644 index 385c0020..00000000 --- a/src/Core/Domain/Manufacturer/CommandHandler/DeleteManufacturerHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\DeleteManufacturerCommand; - -/** - * Defines contract for DeleteManufacturerHandler - */ -interface DeleteManufacturerHandlerInterface -{ - /** - * @param DeleteManufacturerCommand $command - */ - public function handle(DeleteManufacturerCommand $command); -} diff --git a/src/Core/Domain/Manufacturer/CommandHandler/EditManufacturerHandlerInterface.php b/src/Core/Domain/Manufacturer/CommandHandler/EditManufacturerHandlerInterface.php deleted file mode 100644 index 60e98cd1..00000000 --- a/src/Core/Domain/Manufacturer/CommandHandler/EditManufacturerHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\EditManufacturerCommand; - -/** - * Defines contract for EditManufacturerHandler - */ -interface EditManufacturerHandlerInterface -{ - /** - * @param EditManufacturerCommand $command - */ - public function handle(EditManufacturerCommand $command); -} diff --git a/src/Core/Domain/Manufacturer/CommandHandler/ToggleManufacturerStatusHandlerInterface.php b/src/Core/Domain/Manufacturer/CommandHandler/ToggleManufacturerStatusHandlerInterface.php deleted file mode 100644 index d169c541..00000000 --- a/src/Core/Domain/Manufacturer/CommandHandler/ToggleManufacturerStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\ToggleManufacturerStatusCommand; - -/** - * Defines contract for ToggleManufacturerStatusHandler - */ -interface ToggleManufacturerStatusHandlerInterface -{ - /** - * @param ToggleManufacturerStatusCommand $command - */ - public function handle(ToggleManufacturerStatusCommand $command); -} diff --git a/src/Core/Domain/Manufacturer/Exception/DeleteManufacturerException.php b/src/Core/Domain/Manufacturer/Exception/DeleteManufacturerException.php deleted file mode 100644 index 8c0dd609..00000000 --- a/src/Core/Domain/Manufacturer/Exception/DeleteManufacturerException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception; - -/** - * Is thrown manufacturer or manufacturers cannot be deleted - */ -class DeleteManufacturerException extends ManufacturerException -{ - /** - * When fails to delete single manufacturer - */ - const FAILED_DELETE = 10; - - /** - * When fails to delete manufacturers in bulk action - */ - const FAILED_BULK_DELETE = 20; -} diff --git a/src/Core/Domain/Manufacturer/Exception/ManufacturerConstraintException.php b/src/Core/Domain/Manufacturer/Exception/ManufacturerConstraintException.php deleted file mode 100644 index b55502e5..00000000 --- a/src/Core/Domain/Manufacturer/Exception/ManufacturerConstraintException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception; - -/** - * Is thrown when Manufacturer constraint is violated - */ -class ManufacturerConstraintException extends ManufacturerException -{ - /** - * When manufacturer id is not valid - */ - const INVALID_ID = 10; - - /** - * When manufacturer status is not valid - */ - const INVALID_STATUS = 20; -} diff --git a/src/Core/Domain/Manufacturer/Exception/ManufacturerException.php b/src/Core/Domain/Manufacturer/Exception/ManufacturerException.php deleted file mode 100644 index 84637915..00000000 --- a/src/Core/Domain/Manufacturer/Exception/ManufacturerException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for Manufacturer subdomain - */ -class ManufacturerException extends DomainException -{ -} diff --git a/src/Core/Domain/Manufacturer/Exception/ManufacturerImageUploadingException.php b/src/Core/Domain/Manufacturer/Exception/ManufacturerImageUploadingException.php deleted file mode 100644 index 5b47f4d1..00000000 --- a/src/Core/Domain/Manufacturer/Exception/ManufacturerImageUploadingException.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception; - -/** - * Is thrown when error occurs when uploading language image - */ -class ManufacturerImageUploadingException extends ManufacturerException -{ - /** - * @var int Code is used when there are less memory than needed to upload image - */ - const MEMORY_LIMIT_RESTRICTION = 1; - - /** - * @var int Code is used when unexpected error occurs while uploading image - */ - const UNEXPECTED_ERROR = 2; - - /** - * Code is used when image/images cannot be resized - */ - const UNABLE_RESIZE = 3; -} diff --git a/src/Core/Domain/Manufacturer/Exception/ManufacturerNotFoundException.php b/src/Core/Domain/Manufacturer/Exception/ManufacturerNotFoundException.php deleted file mode 100644 index 40e5d5a5..00000000 --- a/src/Core/Domain/Manufacturer/Exception/ManufacturerNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception; - -/** - * Is thrown when manufacturer is not found in Manufacturer subdomain - */ -class ManufacturerNotFoundException extends ManufacturerException -{ -} diff --git a/src/Core/Domain/Manufacturer/Exception/UpdateManufacturerException.php b/src/Core/Domain/Manufacturer/Exception/UpdateManufacturerException.php deleted file mode 100644 index 898e36ff..00000000 --- a/src/Core/Domain/Manufacturer/Exception/UpdateManufacturerException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception; - -/** - * Is thrown when cannot update manufacturer - */ -class UpdateManufacturerException extends ManufacturerException -{ - /** - * When fails to update single manufacturer status - */ - const FAILED_UPDATE_STATUS = 10; - - /** - * When fails to update manufacturers status in bulk action - */ - const FAILED_BULK_UPDATE_STATUS = 20; -} diff --git a/src/Core/Domain/Manufacturer/Query/GetManufacturerForEditing.php b/src/Core/Domain/Manufacturer/Query/GetManufacturerForEditing.php deleted file mode 100644 index 284d3ebd..00000000 --- a/src/Core/Domain/Manufacturer/Query/GetManufacturerForEditing.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\Query; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\ManufacturerConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\ValueObject\ManufacturerId; - -/** - * Gets manufacturer for editing in Back Office - */ -class GetManufacturerForEditing -{ - /** - * @var ManufacturerId - */ - private $manufacturerId; - - /** - * @param int $manufacturerId - * - * @throws ManufacturerConstraintException - */ - public function __construct($manufacturerId) - { - $this->manufacturerId = new ManufacturerId($manufacturerId); - } - - /** - * @return ManufacturerId $manufacturerId - */ - public function getManufacturerId() - { - return $this->manufacturerId; - } -} diff --git a/src/Core/Domain/Manufacturer/Query/GetManufacturerForViewing.php b/src/Core/Domain/Manufacturer/Query/GetManufacturerForViewing.php deleted file mode 100644 index 9b13bfbe..00000000 --- a/src/Core/Domain/Manufacturer/Query/GetManufacturerForViewing.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\Query; - -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\ValueObject\ManufacturerId; - -/** - * Get manufacturer information for viewing - */ -class GetManufacturerForViewing -{ - /** - * @var ManufacturerId - */ - private $manufacturerId; - - /** - * @var LanguageId Language in which manufacturer is returned - */ - private $languageId; - - /** - * @param int $manufacturerId - * @param int $languageId - */ - public function __construct($manufacturerId, $languageId) - { - $this->manufacturerId = new ManufacturerId($manufacturerId); - $this->languageId = new LanguageId($languageId); - } - - /** - * @return ManufacturerId - */ - public function getManufacturerId() - { - return $this->manufacturerId; - } - - /** - * @return LanguageId - */ - public function getLanguageId() - { - return $this->languageId; - } -} diff --git a/src/Core/Domain/Manufacturer/QueryHandler/GetManufacturerForEditingHandlerInterface.php b/src/Core/Domain/Manufacturer/QueryHandler/GetManufacturerForEditingHandlerInterface.php deleted file mode 100644 index f348d079..00000000 --- a/src/Core/Domain/Manufacturer/QueryHandler/GetManufacturerForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Query\GetManufacturerForEditing; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\QueryResult\EditableManufacturer; - -/** - * Defines contract for GetManufacturerForEditingHandler - */ -interface GetManufacturerForEditingHandlerInterface -{ - /** - * @param GetManufacturerForEditing $query - * - * @return EditableManufacturer - */ - public function handle(GetManufacturerForEditing $query); -} diff --git a/src/Core/Domain/Manufacturer/QueryHandler/GetManufacturerForViewingHandlerInterface.php b/src/Core/Domain/Manufacturer/QueryHandler/GetManufacturerForViewingHandlerInterface.php deleted file mode 100644 index 763cf765..00000000 --- a/src/Core/Domain/Manufacturer/QueryHandler/GetManufacturerForViewingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Query\GetManufacturerForViewing; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\QueryResult\ViewableManufacturer; - -/** - * Interface for service that handles gettting manufacturer for viewing query - */ -interface GetManufacturerForViewingHandlerInterface -{ - /** - * @param GetManufacturerForViewing $query - * - * @return ViewableManufacturer - */ - public function handle(GetManufacturerForViewing $query); -} diff --git a/src/Core/Domain/Manufacturer/QueryResult/EditableManufacturer.php b/src/Core/Domain/Manufacturer/QueryResult/EditableManufacturer.php deleted file mode 100644 index a4889d25..00000000 --- a/src/Core/Domain/Manufacturer/QueryResult/EditableManufacturer.php +++ /dev/null @@ -1,201 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\ValueObject\ManufacturerId; - -/** - * Transfers manufacturer data for editing - */ -class EditableManufacturer -{ - /** - * @var ManufacturerId - */ - private $manufacturerId; - - /** - * @var string - */ - private $name; - - /** - * @var string[] - */ - private $localizedShortDescriptions; - - /** - * @var string[] - */ - private $localizedDescriptions; - - /** - * @var array - */ - private $logoImage; - - /** - * @var string[] - */ - private $localizedMetaTitles; - - /** - * @var string[] - */ - private $localizedMetaDescriptions; - - /** - * @var string[] - */ - private $localizedMetaKeywords; - - /** - * @var bool - */ - private $enabled; - - /** - * @var array - */ - private $associatedShops; - - /** - * @param ManufacturerId $manufacturerId - * @param string $name - * @param bool $enabled - * @param array $localizedShortDescriptions - * @param array $localizedDescriptions - * @param array $localizedMetaTitles - * @param array $localizedMetaDescriptions - * @param array $localizedMetaKeywords - * @param array|null $logoImage - * @param array $associatedShops - */ - public function __construct( - ManufacturerId $manufacturerId, - $name, - $enabled, - array $localizedShortDescriptions, - array $localizedDescriptions, - array $localizedMetaTitles, - array $localizedMetaDescriptions, - array $localizedMetaKeywords, - $logoImage, - array $associatedShops - ) { - $this->manufacturerId = $manufacturerId; - $this->name = $name; - $this->localizedShortDescriptions = $localizedShortDescriptions; - $this->localizedDescriptions = $localizedDescriptions; - $this->logoImage = $logoImage; - $this->localizedMetaTitles = $localizedMetaTitles; - $this->localizedMetaDescriptions = $localizedMetaDescriptions; - $this->localizedMetaKeywords = $localizedMetaKeywords; - $this->enabled = $enabled; - $this->associatedShops = $associatedShops; - } - - /** - * @return ManufacturerId - */ - public function getManufacturerId() - { - return $this->manufacturerId; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return string[] - */ - public function getLocalizedShortDescriptions() - { - return $this->localizedShortDescriptions; - } - - /** - * @return string[] - */ - public function getLocalizedDescriptions() - { - return $this->localizedDescriptions; - } - - /** - * @return array - */ - public function getLogoImage() - { - return $this->logoImage; - } - - /** - * @return string[] - */ - public function getLocalizedMetaTitles() - { - return $this->localizedMetaTitles; - } - - /** - * @return string[] - */ - public function getLocalizedMetaDescriptions() - { - return $this->localizedMetaDescriptions; - } - - /** - * @return string[] - */ - public function getLocalizedMetaKeywords() - { - return $this->localizedMetaKeywords; - } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->enabled; - } - - /** - * @return array - */ - public function getAssociatedShops() - { - return $this->associatedShops; - } -} diff --git a/src/Core/Domain/Manufacturer/QueryResult/ViewableManufacturer.php b/src/Core/Domain/Manufacturer/QueryResult/ViewableManufacturer.php deleted file mode 100644 index 6532ab52..00000000 --- a/src/Core/Domain/Manufacturer/QueryResult/ViewableManufacturer.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\QueryResult; - -/** - * Stores query result for getting manufacturer for viewing - */ -class ViewableManufacturer -{ - /** - * @var string - */ - private $name; - - /** - * @var array - */ - private $manufacturerAddresses; - - /** - * @var array - */ - private $manufacturerProducts; - - /** - * @param string $name - * @param array $manufacturerAddresses - * @param array $manufacturerProducts - */ - public function __construct($name, array $manufacturerAddresses, array $manufacturerProducts) - { - $this->name = $name; - $this->manufacturerAddresses = $manufacturerAddresses; - $this->manufacturerProducts = $manufacturerProducts; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return array - */ - public function getManufacturerAddresses() - { - return $this->manufacturerAddresses; - } - - /** - * @return array - */ - public function getManufacturerProducts() - { - return $this->manufacturerProducts; - } -} diff --git a/src/Core/Domain/Manufacturer/ValueObject/ManufacturerId.php b/src/Core/Domain/Manufacturer/ValueObject/ManufacturerId.php deleted file mode 100644 index 7a87b990..00000000 --- a/src/Core/Domain/Manufacturer/ValueObject/ManufacturerId.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Manufacturer\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\ManufacturerConstraintException; - -/** - * Provides manufacturer id - */ -class ManufacturerId -{ - /** - * @var int - */ - private $id; - - /** - * @param int $id - * - * @throws ManufacturerConstraintException - */ - public function __construct($id) - { - $this->assertIsIntegerGreaterThanZero($id); - $this->id = $id; - } - - /** - * @return int - */ - public function getValue() - { - return $this->id; - } - - /** - * Validates that the value is integer and is greater than zero - * - * @param $value - * - * @throws ManufacturerConstraintException - */ - private function assertIsIntegerGreaterThanZero($value) - { - if (!is_int($value) || 0 >= $value) { - throw new ManufacturerConstraintException(sprintf('Invalid manufacturer id "%s".', var_export($value, true))); - } - } -} diff --git a/src/Core/Domain/Meta/Command/AbstractMetaCommand.php b/src/Core/Domain/Meta/Command/AbstractMetaCommand.php deleted file mode 100644 index 0717881e..00000000 --- a/src/Core/Domain/Meta/Command/AbstractMetaCommand.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\Command; - -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaConstraintException; - -/** - * Class AbstractMetaCommand is responsible for defining the abstraction for AddMetaCommand and EditMetaCommand. - */ -abstract class AbstractMetaCommand -{ - /** - * @param int $languageId - * @param string $value - * @param int $constraintErrorCode - * - * @throws MetaConstraintException - */ - protected function assertNameMatchesRegexPattern($languageId, $value, $constraintErrorCode) - { - $regex = '/^[^<>={}]*$/u'; - - if ($value && !preg_match($regex, $value)) { - throw new MetaConstraintException(sprintf('Value "%s" for language id %s did not passed the regex expression: %s', $value, $languageId, $regex), $constraintErrorCode); - } - } -} diff --git a/src/Core/Domain/Meta/Command/AddMetaCommand.php b/src/Core/Domain/Meta/Command/AddMetaCommand.php deleted file mode 100644 index 7d805456..00000000 --- a/src/Core/Domain/Meta/Command/AddMetaCommand.php +++ /dev/null @@ -1,177 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\Command; - -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Meta\ValueObject\Name; - -/** - * Class AddMetaCommand is responsible for saving meta entities data. - */ -class AddMetaCommand extends AbstractMetaCommand -{ - /** - * @var Name - */ - private $pageName; - - /** - * @var string[] - */ - private $localisedPageTitle; - - /** - * @var string[] - */ - private $localisedMetaDescription; - - /** - * @var string[] - */ - private $localisedMetaKeywords; - - /** - * @var string[] - */ - private $LocalisedRewriteUrls; - - /** - * @param string $pageName - * - * @throws MetaConstraintException - */ - public function __construct($pageName) - { - $this->pageName = new Name($pageName); - } - - /** - * @return Name - */ - public function getPageName() - { - return $this->pageName; - } - - /** - * @return string[] - */ - public function getLocalisedPageTitles() - { - return $this->localisedPageTitle; - } - - /** - * @param string[] $localisedPageTitle - * - * @return self - * - * @throws MetaConstraintException - */ - public function setLocalisedPageTitle(array $localisedPageTitle) - { - foreach ($localisedPageTitle as $idLang => $title) { - $this->assertNameMatchesRegexPattern($idLang, $title, MetaConstraintException::INVALID_PAGE_TITLE); - } - - $this->localisedPageTitle = $localisedPageTitle; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalisedMetaDescription() - { - return $this->localisedMetaDescription; - } - - /** - * @param string[] $localisedMetaDescription - * - * @return self - * - * @throws MetaConstraintException - */ - public function setLocalisedMetaDescription(array $localisedMetaDescription) - { - foreach ($localisedMetaDescription as $idLang => $description) { - $this->assertNameMatchesRegexPattern($idLang, $description, MetaConstraintException::INVALID_META_DESCRIPTION); - } - - $this->localisedMetaDescription = $localisedMetaDescription; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalisedMetaKeywords() - { - return $this->localisedMetaKeywords; - } - - /** - * @param string[] $localisedMetaKeywords - * - * @return self - * - * @throws MetaConstraintException - */ - public function setLocalisedMetaKeywords(array $localisedMetaKeywords) - { - foreach ($localisedMetaKeywords as $idLang => $metaKeyword) { - $this->assertNameMatchesRegexPattern($idLang, $metaKeyword, MetaConstraintException::INVALID_META_KEYWORDS); - } - - $this->localisedMetaKeywords = $localisedMetaKeywords; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalisedRewriteUrls() - { - return $this->LocalisedRewriteUrls; - } - - /** - * @param string[] $LocalisedRewriteUrls - * - * @return self - */ - public function setLocalisedRewriteUrls(array $LocalisedRewriteUrls) - { - $this->LocalisedRewriteUrls = $LocalisedRewriteUrls; - - return $this; - } -} diff --git a/src/Core/Domain/Meta/Command/EditMetaCommand.php b/src/Core/Domain/Meta/Command/EditMetaCommand.php deleted file mode 100644 index f76e05d9..00000000 --- a/src/Core/Domain/Meta/Command/EditMetaCommand.php +++ /dev/null @@ -1,206 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\Command; - -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaException; -use PrestaShop\PrestaShop\Core\Domain\Meta\ValueObject\MetaId; -use PrestaShop\PrestaShop\Core\Domain\Meta\ValueObject\Name; - -/** - * Class EditMetaCommand - */ -class EditMetaCommand extends AbstractMetaCommand -{ - /** - * @var MetaId - */ - private $metaId; - - /** - * @var Name - */ - private $pageName; - - /** - * @var string[] - */ - private $localisedPageTitles; - - /** - * @var string[] - */ - private $localisedMetaDescriptions; - - /** - * @var string[] - */ - private $localisedMetaKeywords; - - /** - * @var string[] - */ - private $localisedRewriteUrls; - - /** - * @param int $metaId - * - * @throws MetaException - */ - public function __construct($metaId) - { - $this->metaId = new MetaId($metaId); - } - - /** - * @return MetaId - */ - public function getMetaId() - { - return $this->metaId; - } - - /** - * @return Name - */ - public function getPageName() - { - return $this->pageName; - } - - /** - * @param string $pageName - * - * @return self - * - * @throws MetaConstraintException - */ - public function setPageName($pageName) - { - $this->pageName = new Name($pageName); - - return $this; - } - - /** - * @param string[] $localisedPageTitles - * - * @return self - * - * @throws MetaConstraintException - */ - public function setLocalisedPageTitles(array $localisedPageTitles) - { - foreach ($localisedPageTitles as $idLang => $title) { - $this->assertNameMatchesRegexPattern($idLang, $title, MetaConstraintException::INVALID_PAGE_TITLE); - } - - $this->localisedPageTitles = $localisedPageTitles; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalisedPageTitles() - { - return $this->localisedPageTitles; - } - - /** - * @param string[] $localisedMetaDescriptions - * - * @return self - * - * @throws MetaConstraintException - */ - public function setLocalisedMetaDescriptions(array $localisedMetaDescriptions) - { - foreach ($localisedMetaDescriptions as $idLang => $description) { - $this->assertNameMatchesRegexPattern($idLang, $description, MetaConstraintException::INVALID_META_DESCRIPTION); - } - - $this->localisedMetaDescriptions = $localisedMetaDescriptions; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalisedMetaDescriptions() - { - return $this->localisedMetaDescriptions; - } - - /** - * @param string[] $localisedMetaKeywords - * - * @return self - * - * @throws MetaConstraintException - */ - public function setLocalisedMetaKeywords(array $localisedMetaKeywords) - { - foreach ($localisedMetaKeywords as $idLang => $metaKeyword) { - $this->assertNameMatchesRegexPattern($idLang, $metaKeyword, MetaConstraintException::INVALID_META_KEYWORDS); - } - - $this->localisedMetaKeywords = $localisedMetaKeywords; - - return $this; - } - - /** - * @return string[] - */ - public function getLocalisedMetaKeywords() - { - return $this->localisedMetaKeywords; - } - - /** - * @return string[] - */ - public function getLocalisedRewriteUrls() - { - return $this->localisedRewriteUrls; - } - - /** - * @param string[] $localisedRewriteUrls - * - * @return self - */ - public function setLocalisedRewriteUrls(array $localisedRewriteUrls) - { - $this->localisedRewriteUrls = $localisedRewriteUrls; - - return $this; - } -} diff --git a/src/Core/Domain/Meta/CommandHandler/AddMetaHandlerInterface.php b/src/Core/Domain/Meta/CommandHandler/AddMetaHandlerInterface.php deleted file mode 100644 index de9a5098..00000000 --- a/src/Core/Domain/Meta/CommandHandler/AddMetaHandlerInterface.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Meta\Command\AddMetaCommand; -use PrestaShop\PrestaShop\Core\Domain\Meta\ValueObject\MetaId; - -/** - * Interface AddMetaHandlerInterface defines contract for AddMetaHandler. - */ -interface AddMetaHandlerInterface -{ - /** - * Used to handle the logic required for adding meta data. - * - * @param AddMetaCommand $command - * - * @return MetaId - */ - public function handle(AddMetaCommand $command); -} diff --git a/src/Core/Domain/Meta/CommandHandler/EditMetaHandlerInterface.php b/src/Core/Domain/Meta/CommandHandler/EditMetaHandlerInterface.php deleted file mode 100644 index fe40c834..00000000 --- a/src/Core/Domain/Meta/CommandHandler/EditMetaHandlerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Meta\Command\EditMetaCommand; - -/** - * Interface EditMetaHandlerInterface defines contract for EditMetaHandler. - */ -interface EditMetaHandlerInterface -{ - /** - * Handles meta entity editing. - * - * @param EditMetaCommand $command - */ - public function handle(EditMetaCommand $command); -} diff --git a/src/Core/Domain/Meta/Exception/CannotAddMetaException.php b/src/Core/Domain/Meta/Exception/CannotAddMetaException.php deleted file mode 100644 index 5154102a..00000000 --- a/src/Core/Domain/Meta/Exception/CannotAddMetaException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\Exception; - -/** - * Is thrown when new meta cannot be added - */ -class CannotAddMetaException extends MetaException -{ -} diff --git a/src/Core/Domain/Meta/Exception/CannotEditMetaException.php b/src/Core/Domain/Meta/Exception/CannotEditMetaException.php deleted file mode 100644 index 402ffa66..00000000 --- a/src/Core/Domain/Meta/Exception/CannotEditMetaException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\Exception; - -/** - * Is thrown when meta cannot be edited - */ -class CannotEditMetaException extends MetaException -{ -} diff --git a/src/Core/Domain/Meta/Exception/MetaConstraintException.php b/src/Core/Domain/Meta/Exception/MetaConstraintException.php deleted file mode 100644 index 64f5cf8c..00000000 --- a/src/Core/Domain/Meta/Exception/MetaConstraintException.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\Exception; - -/** - * Is thrown when meta constraints are violated - */ -class MetaConstraintException extends MetaException -{ - /** - * When meta page name is invalid - */ - const INVALID_PAGE_NAME = 1; - - /** - * When meta url_rewrite is invalid - */ - const INVALID_URL_REWRITE = 2; - - /** - * When meta page title is invalid - */ - const INVALID_PAGE_TITLE = 3; - - /** - * When meta description is invalid - */ - const INVALID_META_DESCRIPTION = 4; - - /** - * When meta keywords is invalids - */ - const INVALID_META_KEYWORDS = 5; -} diff --git a/src/Core/Domain/Meta/Exception/MetaException.php b/src/Core/Domain/Meta/Exception/MetaException.php deleted file mode 100644 index 2d4498f4..00000000 --- a/src/Core/Domain/Meta/Exception/MetaException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for meta sub-domain - */ -class MetaException extends DomainException -{ -} diff --git a/src/Core/Domain/Meta/Exception/MetaNotFoundException.php b/src/Core/Domain/Meta/Exception/MetaNotFoundException.php deleted file mode 100644 index 0f5004f3..00000000 --- a/src/Core/Domain/Meta/Exception/MetaNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\Exception; - -/** - * Is thrown when required meta cannot be found - */ -class MetaNotFoundException extends MetaException -{ -} diff --git a/src/Core/Domain/Meta/Query/GetMetaForEditing.php b/src/Core/Domain/Meta/Query/GetMetaForEditing.php deleted file mode 100644 index b128c406..00000000 --- a/src/Core/Domain/Meta/Query/GetMetaForEditing.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\Query; - -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaException; -use PrestaShop\PrestaShop\Core\Domain\Meta\ValueObject\MetaId; - -/** - * Class GetMetaForEditing is responsible for providing required data for GetMetaForEditingHandler to return meta data. - */ -class GetMetaForEditing -{ - /** - * @var MetaId - */ - private $metaId; - - /** - * GetMetaForEditing constructor. - * - * @param int $metaId - * - * @throws MetaException - */ - public function __construct($metaId) - { - $this->metaId = new MetaId($metaId); - } - - /** - * @return MetaId - */ - public function getMetaId() - { - return $this->metaId; - } -} diff --git a/src/Core/Domain/Meta/Query/GetPagesForLayoutCustomization.php b/src/Core/Domain/Meta/Query/GetPagesForLayoutCustomization.php deleted file mode 100644 index b42f6925..00000000 --- a/src/Core/Domain/Meta/Query/GetPagesForLayoutCustomization.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\Query; - -/** - * Gets pages for which theme's layout can be customized. - */ -class GetPagesForLayoutCustomization -{ -} diff --git a/src/Core/Domain/Meta/QueryHandler/GetMetaForEditingHandlerInterface.php b/src/Core/Domain/Meta/QueryHandler/GetMetaForEditingHandlerInterface.php deleted file mode 100644 index 99357b7c..00000000 --- a/src/Core/Domain/Meta/QueryHandler/GetMetaForEditingHandlerInterface.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Meta\Query\GetMetaForEditing; -use PrestaShop\PrestaShop\Core\Domain\Meta\QueryResult\EditableMeta; - -/** - * Interface GetMetaForEditingHandlerInterface defines contract for GetMetaForEditingHandler. - */ -interface GetMetaForEditingHandlerInterface -{ - /** - * Gets data related with meta entity. - * - * @param GetMetaForEditing $query - * - * @return EditableMeta - */ - public function handle(GetMetaForEditing $query); -} diff --git a/src/Core/Domain/Meta/QueryHandler/GetPagesForLayoutCustomizationHandlerInterface.php b/src/Core/Domain/Meta/QueryHandler/GetPagesForLayoutCustomizationHandlerInterface.php deleted file mode 100644 index ee313d5f..00000000 --- a/src/Core/Domain/Meta/QueryHandler/GetPagesForLayoutCustomizationHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Meta\Query\GetPagesForLayoutCustomization; - -/** - * Interface GetMetaPagesHandlerInterface. - */ -interface GetPagesForLayoutCustomizationHandlerInterface -{ - /** - * @param GetPagesForLayoutCustomization $query - */ - public function handle(GetPagesForLayoutCustomization $query); -} diff --git a/src/Core/Domain/Meta/QueryResult/EditableMeta.php b/src/Core/Domain/Meta/QueryResult/EditableMeta.php deleted file mode 100644 index 98c9c880..00000000 --- a/src/Core/Domain/Meta/QueryResult/EditableMeta.php +++ /dev/null @@ -1,145 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception; -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaException; -use PrestaShop\PrestaShop\Core\Domain\Meta\ValueObject\MetaId; -use PrestaShop\PrestaShop\Core\Domain\Meta\ValueObject\Name; - -/** - * Class EditableMeta is responsible for providing data for meta form. - */ -class EditableMeta -{ - /** - * @var MetaId - */ - private $metaId; - - /** - * @var Name - */ - private $pageName; - - /** - * @var string[] - */ - private $localisedPageTitles; - - /** - * @var string[] - */ - private $localisedMetaDescriptions; - - /** - * @var string[] - */ - private $localisedMetaKeywords; - - /** - * @var string[] - */ - private $localisedUrlRewrites; - - /** - * EditableMeta constructor. - * - * @param int $metaId - * @param string $pageName - * @param string[] $localisedPageTitles - * @param string[] $localisedMetaDescriptions - * @param string[] $localisedMetaKeywords - * @param string[] $localisedUrlRewrites - * - * @throws Exception\MetaConstraintException - * @throws MetaException - */ - public function __construct( - $metaId, - $pageName, - array $localisedPageTitles, - array $localisedMetaDescriptions, - array $localisedMetaKeywords, - array $localisedUrlRewrites - ) { - $this->metaId = new MetaId($metaId); - $this->pageName = new Name($pageName); - $this->localisedPageTitles = $localisedPageTitles; - $this->localisedMetaDescriptions = $localisedMetaDescriptions; - $this->localisedMetaKeywords = $localisedMetaKeywords; - $this->localisedUrlRewrites = $localisedUrlRewrites; - } - - /** - * @return MetaId - */ - public function getMetaId() - { - return $this->metaId; - } - - /** - * @return Name - */ - public function getPageName() - { - return $this->pageName; - } - - /** - * @return string[] - */ - public function getLocalisedPageTitles() - { - return $this->localisedPageTitles; - } - - /** - * @return string[] - */ - public function getLocalisedMetaDescriptions() - { - return $this->localisedMetaDescriptions; - } - - /** - * @return string[] - */ - public function getLocalisedMetaKeywords() - { - return $this->localisedMetaKeywords; - } - - /** - * @return string[] - */ - public function getLocalisedUrlRewrites() - { - return $this->localisedUrlRewrites; - } -} diff --git a/src/Core/Domain/Meta/QueryResult/LayoutCustomizationPage.php b/src/Core/Domain/Meta/QueryResult/LayoutCustomizationPage.php deleted file mode 100644 index 060f85e9..00000000 --- a/src/Core/Domain/Meta/QueryResult/LayoutCustomizationPage.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\QueryResult; - -/** - * Class LayoutCustomizationPage. - */ -class LayoutCustomizationPage -{ - /** - * @var string - */ - private $page; - - /** - * @var string - */ - private $description; - - /** - * @var string - */ - private $title; - - /** - * @param string $page - * @param string $title - * @param string $description - */ - public function __construct($page, $title, $description) - { - $this->page = $page; - $this->description = $description; - $this->title = $title; - } - - /** - * @return string - */ - public function getPage() - { - return $this->page; - } - - /** - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * @return string - */ - public function getDescription() - { - return $this->description; - } -} diff --git a/src/Core/Domain/Meta/ValueObject/MetaId.php b/src/Core/Domain/Meta/ValueObject/MetaId.php deleted file mode 100644 index 3076e83d..00000000 --- a/src/Core/Domain/Meta/ValueObject/MetaId.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaException; - -/** - * Class MetaId is responsible for providing id of meta entity. - */ -class MetaId -{ - /** - * @var int - */ - private $id; - - /** - * MetaId constructor. - * - * @param int $metaId - * - * @throws MetaException - */ - public function __construct($metaId) - { - $this->assertIsIntAndLargerThanZero($metaId); - - $this->id = $metaId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->id; - } - - /** - * @param $metaId - * - * @throws MetaException - */ - public function assertIsIntAndLargerThanZero($metaId) - { - if (!is_int($metaId) || $metaId <= 0) { - throw new MetaException(sprintf('Invalid meta id: %s. It must be of type integer and above 0', var_export($metaId, true))); - } - } -} diff --git a/src/Core/Domain/Meta/ValueObject/Name.php b/src/Core/Domain/Meta/ValueObject/Name.php deleted file mode 100644 index 03feb3ca..00000000 --- a/src/Core/Domain/Meta/ValueObject/Name.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Meta\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaConstraintException; - -/** - * Class Name - */ -class Name -{ - /** - * @var string - */ - private $pageName; - - /** - * @param string $pageName - * - * @throws MetaConstraintException - */ - public function __construct($pageName) - { - $this->assertIsValidPageName($pageName); - - $this->pageName = $pageName; - } - - /** - * @return string - */ - public function getValue() - { - return $this->pageName; - } - - /** - * @param string $pageName - * - * @throws MetaConstraintException - */ - private function assertIsValidPageName($pageName) - { - if (!is_string($pageName) || !$pageName || !preg_match('/^[a-zA-Z0-9_.-]+$/', $pageName)) { - throw new MetaConstraintException(sprintf('Invalid Meta page name %s', var_export($pageName, true)), MetaConstraintException::INVALID_PAGE_NAME); - } - } -} diff --git a/src/Core/Domain/Notification/Command/UpdateEmployeeNotificationLastElementCommand.php b/src/Core/Domain/Notification/Command/UpdateEmployeeNotificationLastElementCommand.php deleted file mode 100644 index 9c44f77e..00000000 --- a/src/Core/Domain/Notification/Command/UpdateEmployeeNotificationLastElementCommand.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Notification\Command; - -use PrestaShop\PrestaShop\Core\Domain\Notification\Exception\TypeException; -use PrestaShop\PrestaShop\Core\Domain\Notification\ValueObject\Type; - -/** - * Updates the last notification element from a given type seen by the employee - */ -class UpdateEmployeeNotificationLastElementCommand -{ - /** - * @var Type - */ - private $type; - - /** - * UpdateEmployeeNotificationLastElementCommand constructor. - * - * @param string $type - * - * @throws TypeException - */ - public function __construct(string $type) - { - $this->type = new Type($type); - } - - /** - * @return Type - */ - public function getType() - { - return $this->type; - } -} diff --git a/src/Core/Domain/Notification/CommandHandler/UpdateEmployeeNotificationLastElementCommandHandlerInterface.php b/src/Core/Domain/Notification/CommandHandler/UpdateEmployeeNotificationLastElementCommandHandlerInterface.php deleted file mode 100644 index 0e94b21f..00000000 --- a/src/Core/Domain/Notification/CommandHandler/UpdateEmployeeNotificationLastElementCommandHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Notification\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Notification\Command\UpdateEmployeeNotificationLastElementCommand; - -/** - * Interface for service that handles ACK employee notifications last elements - */ -interface UpdateEmployeeNotificationLastElementCommandHandlerInterface -{ - /** - * @param UpdateEmployeeNotificationLastElementCommand $command - */ - public function handle(UpdateEmployeeNotificationLastElementCommand $command); -} diff --git a/src/Core/Domain/Notification/Exception/NotificationException.php b/src/Core/Domain/Notification/Exception/NotificationException.php deleted file mode 100644 index 25cbbe91..00000000 --- a/src/Core/Domain/Notification/Exception/NotificationException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Notification\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for Notification sub-domain - */ -class NotificationException extends DomainException -{ -} diff --git a/src/Core/Domain/Notification/Query/GetNotificationLastElements.php b/src/Core/Domain/Notification/Query/GetNotificationLastElements.php deleted file mode 100644 index fd2a5051..00000000 --- a/src/Core/Domain/Notification/Query/GetNotificationLastElements.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Notification\Query; - -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\InvalidEmployeeIdException; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; - -/** - * This Query return the last Notifications elements - */ -class GetNotificationLastElements -{ - /** - * @var EmployeeId - */ - private $employeeId; - - /** - * GetNotificationLastElements constructor. - * - * @param $employeeId - * - * @throws InvalidEmployeeIdException - */ - public function __construct(int $employeeId) - { - $this->employeeId = new EmployeeId($employeeId); - } - - /** - * @return EmployeeId - */ - public function getEmployeeId(): EmployeeId - { - return $this->employeeId; - } -} diff --git a/src/Core/Domain/Notification/QueryHandler/GetNotificationLastElementsHandlerInterface.php b/src/Core/Domain/Notification/QueryHandler/GetNotificationLastElementsHandlerInterface.php deleted file mode 100644 index 8755a2fe..00000000 --- a/src/Core/Domain/Notification/QueryHandler/GetNotificationLastElementsHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Notification\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Notification\Query\GetNotificationLastElements; -use PrestaShop\PrestaShop\Core\Domain\Notification\QueryResult\NotificationsResults; - -/** - * Interface for service that handles notifications last elements request - */ -interface GetNotificationLastElementsHandlerInterface -{ - /** - * @param GetNotificationLastElements $query - * - * @return NotificationsResults - */ - public function handle(GetNotificationLastElements $query): NotificationsResults; -} diff --git a/src/Core/Domain/Notification/QueryResult/NotificationResult.php b/src/Core/Domain/Notification/QueryResult/NotificationResult.php deleted file mode 100644 index e1549caa..00000000 --- a/src/Core/Domain/Notification/QueryResult/NotificationResult.php +++ /dev/null @@ -1,233 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Notification\QueryResult; - -/** - * NotificationResult contains the notification data - */ -class NotificationResult -{ - /** - * @var int - */ - private $orderId; - - /** - * @var int - */ - private $customerId; - - /** - * @var string - */ - private $customerName; - - /** - * @var int - */ - private $customerMessageId; - - /** - * @var int - */ - private $customerThreadId; - - /** - * @var string - */ - private $customerViewUrl; - - /** - * @var string - */ - private $totalPaid; - - /** - * @var string - */ - private $carrier; - - /** - * @var string - */ - private $isoCode; - - /** - * @var string - */ - private $company; - - /** - * @var string - */ - private $status; - - /** - * @var string - */ - private $dateAdd; - - /** - * NotificationResult constructor. - * - * @param int $orderId - * @param int $customerId - * @param string $customerName - * @param int $customerMessageId - * @param int $customerThreadId - * @param string $customerViewUrl - * @param string $totalPaid - * @param string $carrier - * @param string $isoCode - * @param string $company - * @param string $status - * @param string $dateAdd - */ - public function __construct( - int $orderId, - int $customerId, - string $customerName, - int $customerMessageId, - int $customerThreadId, - string $customerViewUrl, - string $totalPaid, - string $carrier, - string $isoCode, - string $company, - string $status, - string $dateAdd - ) { - $this->orderId = $orderId; - $this->customerId = $customerId; - $this->customerName = $customerName; - $this->customerMessageId = $customerMessageId; - $this->customerThreadId = $customerThreadId; - $this->customerViewUrl = $customerViewUrl; - $this->totalPaid = $totalPaid; - $this->carrier = $carrier; - $this->isoCode = $isoCode; - $this->company = $company; - $this->status = $status; - $this->dateAdd = $dateAdd; - } - - /** - * @return int - */ - public function getOrderId(): int - { - return $this->orderId; - } - - /** - * @return int - */ - public function getCustomerId(): int - { - return $this->customerId; - } - - /** - * @return string - */ - public function getCustomerName(): string - { - return $this->customerName; - } - - /** - * @return int - */ - public function getCustomerMessageId(): int - { - return $this->customerMessageId; - } - - /** - * @return int - */ - public function getCustomerThreadId(): int - { - return $this->customerThreadId; - } - - /** - * @return string - */ - public function getCustomerViewUrl(): string - { - return $this->customerViewUrl; - } - - /** - * @return string - */ - public function getTotalPaid(): string - { - return $this->totalPaid; - } - - /** - * @return string - */ - public function getCarrier(): string - { - return $this->carrier; - } - - /** - * @return string - */ - public function getIsoCode(): string - { - return $this->isoCode; - } - - /** - * @return string - */ - public function getCompany(): string - { - return $this->company; - } - - /** - * @return string - */ - public function getStatus(): string - { - return $this->status; - } - - /** - * @return string - */ - public function getDateAdd(): string - { - return $this->dateAdd; - } -} diff --git a/src/Core/Domain/Notification/QueryResult/NotificationsResult.php b/src/Core/Domain/Notification/QueryResult/NotificationsResult.php deleted file mode 100644 index 785e65b7..00000000 --- a/src/Core/Domain/Notification/QueryResult/NotificationsResult.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Notification\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Notification\Exception\TypeException; -use PrestaShop\PrestaShop\Core\Domain\Notification\ValueObject\Type; - -/** - * NotificationsResult contains a collection of Notifications as well as their type and the total - */ -class NotificationsResult -{ - /** - * @var Type - */ - private $type; - - /** - * @var int - */ - private $total; - - /** - * @var NotificationResult[] - */ - private $notifications = []; - - /** - * NotificationsResult constructor. - * - * @param string $type - * @param int $total - * @param NotificationResult[] $notifications - * - * @throws TypeException - */ - public function __construct(string $type, int $total, array $notifications) - { - $this->type = new Type($type); - $this->total = $total; - $this->notifications = $notifications; - } - - public function getType(): Type - { - return $this->type; - } - - /** - * @return int - */ - public function getTotal(): int - { - return $this->total; - } - - /** - * @return NotificationResult[] - */ - public function getNotifications(): array - { - return $this->notifications; - } -} diff --git a/src/Core/Domain/Notification/QueryResult/NotificationsResults.php b/src/Core/Domain/Notification/QueryResult/NotificationsResults.php deleted file mode 100644 index 0a48eae2..00000000 --- a/src/Core/Domain/Notification/QueryResult/NotificationsResults.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Notification\QueryResult; - -/** - * NotificationsResults is a collection of NotificationsResult - */ -class NotificationsResults -{ - /** - * @var NotificationsResult[] - */ - private $notifications = []; - - /** - * NotificationsResults constructor. - * - * @param NotificationsResult[] $notifications - */ - public function __construct(array $notifications) - { - $this->notifications = $notifications; - } - - /** - * @return NotificationsResult[] - */ - public function getNotificationsResults() - { - return $this->notifications; - } - - public function getNotificationsResultsForJS() - { - $response = []; - foreach ($this->getNotificationsResults() as $element) { - $notifications = []; - foreach ($element->getNotifications() as $notification) { - $notifications[] = [ - 'id_order' => $notification->getOrderId(), - 'id_customer' => $notification->getCustomerId(), - 'id_customer_message' => $notification->getCustomerMessageId(), - 'id_customer_thread' => $notification->getCustomerThreadId(), - 'total_paid' => $notification->getTotalPaid(), - 'carrier' => $notification->getCarrier(), - 'iso_code' => $notification->getIsoCode(), - 'company' => $notification->getCompany(), - 'status' => $notification->getStatus(), - 'customer_name' => $notification->getCustomerName(), - 'date_add' => $notification->getDateAdd(), - 'customer_view_url' => $notification->getCustomerViewUrl(), - ]; - } - $response[($element->getType()->getValue())] = [ - 'total' => $element->getTotal(), - 'results' => $notifications, - ]; - } - - return $response; - } -} diff --git a/src/Core/Domain/Notification/ValueObject/Type.php b/src/Core/Domain/Notification/ValueObject/Type.php deleted file mode 100644 index 8d284ff3..00000000 --- a/src/Core/Domain/Notification/ValueObject/Type.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Notification\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Notification\Exception\NotificationException; - -/** - * Notifications types - */ -class Type -{ - const ORDER = 'order'; - - const CUSTOMER = 'customer'; - - const CUSTOMER_MESSAGE = 'customer_message'; - - /** - * @var string - */ - private $type; - - /** - * @param string $type - * - * @throws NotificationException - */ - public function __construct(string $type) - { - $this->assertIsValidType($type); - - $this->type = $type; - } - - /** - * @return string - */ - public function getValue(): string - { - return $this->type; - } - - /** - * @param string $type - * - * @throws NotificationException - */ - private function assertIsValidType(string $type) - { - $allowedTypes = [self::ORDER, self::CUSTOMER, self::CUSTOMER_MESSAGE]; - if (!in_array($type, $allowedTypes)) { - throw new NotificationException(sprintf('Type %s is invalid. Supported types are: %s', var_export($type, true), implode(', ', $allowedTypes))); - } - } -} diff --git a/src/Core/Domain/Order/CancellationActionType.php b/src/Core/Domain/Order/CancellationActionType.php deleted file mode 100644 index 6be1bcd6..00000000 --- a/src/Core/Domain/Order/CancellationActionType.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Order; - -/** - * There are different cancellation action types, they are listed in this class - * - * Class CancellationActionType - */ -class CancellationActionType -{ - const CANCEL_PRODUCT = 0; - - const STANDARD_REFUND = 1; - - const PARTIAL_REFUND = 2; - - const RETURN_PRODUCT = 3; -} diff --git a/src/Core/Domain/Order/Command/AbstractRefundCommand.php b/src/Core/Domain/Order/Command/AbstractRefundCommand.php deleted file mode 100644 index 31df2f52..00000000 --- a/src/Core/Domain/Order/Command/AbstractRefundCommand.php +++ /dev/null @@ -1,178 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use InvalidArgumentException; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidAmountException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidCancelProductException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Command abstract class for refund commands - */ -abstract class AbstractRefundCommand -{ - /** - * @var OrderId - */ - protected $orderId; - - /** - * @var array - */ - protected $orderDetailRefunds; - - /** - * @var bool - */ - protected $restockRefundedProducts; - - /** - * @var bool - */ - protected $generateCreditSlip; - - /** - * @var bool - */ - protected $generateVoucher; - - /** - * @var int - */ - protected $voucherRefundType; - - /** - * @var Number|null - */ - protected $voucherRefundAmount; - - /** - * @param int $orderId - * @param array $orderDetailRefunds - * @param bool $restockRefundedProducts - * @param bool $generateVoucher - * @param bool $generateCreditSlip - * @param int $voucherRefundType - * @param string|null $voucherRefundAmount - * - * @throws InvalidCancelProductException - * @throws OrderException - */ - public function __construct( - int $orderId, - array $orderDetailRefunds, - bool $restockRefundedProducts, - bool $generateCreditSlip, - bool $generateVoucher, - int $voucherRefundType, - ?string $voucherRefundAmount = null - ) { - $this->orderId = new OrderId($orderId); - $this->restockRefundedProducts = $restockRefundedProducts; - $this->generateCreditSlip = $generateCreditSlip; - $this->generateVoucher = $generateVoucher; - $this->voucherRefundType = $voucherRefundType; - if (null !== $voucherRefundAmount) { - try { - $this->voucherRefundAmount = new Number($voucherRefundAmount); - } catch (InvalidArgumentException $e) { - throw new InvalidAmountException(); - } - } - $this->setOrderDetailRefunds($orderDetailRefunds); - if (!$this->generateCreditSlip && !$this->generateVoucher) { - throw new InvalidCancelProductException(InvalidCancelProductException::NO_GENERATION); - } - } - - /** - * @return OrderId - */ - public function getOrderId(): OrderId - { - return $this->orderId; - } - - /** - * @return array - */ - public function getOrderDetailRefunds(): array - { - return $this->orderDetailRefunds; - } - - /** - * @return bool - */ - public function restockRefundedProducts(): bool - { - return $this->restockRefundedProducts; - } - - /** - * @return bool - */ - public function generateCreditSlip(): bool - { - return $this->generateCreditSlip; - } - - /** - * @return bool - */ - public function generateVoucher(): bool - { - return $this->generateVoucher; - } - - /** - * @return int - */ - public function getVoucherRefundType(): int - { - return $this->voucherRefundType; - } - - /** - * @return Number|null - */ - public function getVoucherRefundAmount(): ?Number - { - return $this->voucherRefundAmount; - } - - /** - * @param array $orderDetailRefunds - * - * @throws InvalidCancelProductException - * @throws OrderException - */ - abstract protected function setOrderDetailRefunds(array $orderDetailRefunds); -} diff --git a/src/Core/Domain/Order/Command/AddCartRuleToOrderCommand.php b/src/Core/Domain/Order/Command/AddCartRuleToOrderCommand.php deleted file mode 100644 index d63a0890..00000000 --- a/src/Core/Domain/Order/Command/AddCartRuleToOrderCommand.php +++ /dev/null @@ -1,147 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Order\Invoice\ValueObject\OrderInvoiceId; -use PrestaShop\PrestaShop\Core\Domain\Order\OrderDiscountType; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Adds cart rule to given order. - */ -class AddCartRuleToOrderCommand -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @var string - */ - private $cartRuleName; - - /** - * @var int - */ - private $cartRuleType; - - /** - * @var float - */ - private $value; - - /** - * @var int|null - */ - private $orderInvoiceId; - - /** - * @param int $orderId - * @param string $cartRuleName - * @param string $cartRuleType - * @param string|null $value - * @param null $orderInvoiceId - */ - public function __construct( - int $orderId, - string $cartRuleName, - string $cartRuleType, - ?string $value, - $orderInvoiceId = null - ) { - $this->assertCartRuleNameIsNotEmpty($cartRuleName); - $this->assertCartRuleTypeAndValueCombination($cartRuleType, $value); - - $this->orderId = new OrderId($orderId); - $this->cartRuleName = $cartRuleName; - $this->cartRuleType = $cartRuleType; - $this->value = null !== $value ? new Number($value) : null; - $this->orderInvoiceId = $orderInvoiceId ? new OrderInvoiceId($orderInvoiceId) : null; - } - - /** - * @return OrderId - */ - public function getOrderId(): OrderId - { - return $this->orderId; - } - - /** - * @return string - */ - public function getCartRuleName(): string - { - return $this->cartRuleName; - } - - /** - * @return int - */ - public function getCartRuleType(): string - { - return $this->cartRuleType; - } - - /** - * @return Number|null - */ - public function getDiscountValue(): ?Number - { - return $this->value; - } - - /** - * @return OrderInvoiceId|null - */ - public function getOrderInvoiceId(): ?OrderInvoiceId - { - return $this->orderInvoiceId; - } - - /** - * @param string $cartRuleName - */ - private function assertCartRuleNameIsNotEmpty($cartRuleName): void - { - if (!is_string($cartRuleName) || empty($cartRuleName)) { - throw new OrderConstraintException('Cart rule name cannot be empty'); - } - } - - private function assertCartRuleTypeAndValueCombination(string $cartRuleType, ?string $value): void - { - $isNullValueAllowed = OrderDiscountType::FREE_SHIPPING === $cartRuleType; - - if (!$isNullValueAllowed && null === $value) { - throw new OrderConstraintException(sprintf('Null values are not allowed for "%s" discount types.', [OrderDiscountType::DISCOUNT_AMOUNT, OrderDiscountType::DISCOUNT_PERCENT])); - } - } -} diff --git a/src/Core/Domain/Order/Command/AddOrderFromBackOfficeCommand.php b/src/Core/Domain/Order/Command/AddOrderFromBackOfficeCommand.php deleted file mode 100644 index cff2ca4e..00000000 --- a/src/Core/Domain/Order/Command/AddOrderFromBackOfficeCommand.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidOrderStateException; -use PrestaShopBundle\Exception\InvalidModuleException; - -/** - * Adds new order from given cart. - */ -class AddOrderFromBackOfficeCommand -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @var string - */ - private $orderMessage; - - /** - * @var string - */ - private $paymentModuleName; - - /** - * @var int - */ - private $orderStateId; - - /** - * @var EmployeeId - */ - private $employeeId; - - /** - * @param int $cartId - * @param int $employeeId - * @param string $orderMessage - * @param string $paymentModuleName - * @param int $orderStateId - */ - public function __construct($cartId, $employeeId, $orderMessage, $paymentModuleName, $orderStateId) - { - $this->assertIsModuleName($paymentModuleName); - $this->assertOrderStateIsPositiveInt($orderStateId); - - $this->cartId = new CartId($cartId); - $this->employeeId = new EmployeeId($employeeId); - $this->orderMessage = $orderMessage; - $this->paymentModuleName = $paymentModuleName; - $this->orderStateId = $orderStateId; - } - - /** - * @return CartId - */ - public function getCartId() - { - return $this->cartId; - } - - /** - * @return string - */ - public function getOrderMessage() - { - return $this->orderMessage; - } - - /** - * @return string - */ - public function getPaymentModuleName() - { - return $this->paymentModuleName; - } - - /** - * @return int - */ - public function getOrderStateId() - { - return $this->orderStateId; - } - - /** - * @return EmployeeId - */ - public function getEmployeeId() - { - return $this->employeeId; - } - - /** - * @param string $moduleName - * - * @throws InvalidModuleException - */ - private function assertIsModuleName($moduleName) - { - if (!is_string($moduleName) || !preg_match('/^[a-zA-Z0-9_-]+$/', $moduleName)) { - throw new InvalidModuleException(); - } - } - - /** - * @param int $orderStateId - * - * @throws InvalidOrderStateException - */ - private function assertOrderStateIsPositiveInt($orderStateId) - { - if (!is_int($orderStateId) || 0 >= $orderStateId) { - throw new InvalidOrderStateException( - InvalidOrderStateException::INVALID_ID, - 'Invalid order state id' - ); - } - } -} diff --git a/src/Core/Domain/Order/Command/BulkChangeOrderStatusCommand.php b/src/Core/Domain/Order/Command/BulkChangeOrderStatusCommand.php deleted file mode 100644 index 39b7dd88..00000000 --- a/src/Core/Domain/Order/Command/BulkChangeOrderStatusCommand.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Changes status for given orders. - */ -class BulkChangeOrderStatusCommand -{ - /** - * @var OrderId[] - */ - private $orderIds; - - /** - * @var int - */ - private $newOrderStatusId; - - /** - * @param int[] $orderIds - * @param int $newOrderStatusId - */ - public function __construct(array $orderIds, $newOrderStatusId) - { - if (!is_int($newOrderStatusId) || 0 >= $newOrderStatusId) { - throw new OrderException(sprintf('Order status Id must be integer greater than 0, but %s given.', var_export($newOrderStatusId, true))); - } - - $this->newOrderStatusId = $newOrderStatusId; - $this->setOrderIds($orderIds); - } - - /** - * @return OrderId[] - */ - public function getOrderIds() - { - return $this->orderIds; - } - - /** - * @return int - */ - public function getNewOrderStatusId() - { - return $this->newOrderStatusId; - } - - /** - * @param int[] $orderIds - */ - private function setOrderIds(array $orderIds) - { - foreach ($orderIds as $orderId) { - $this->orderIds[] = new OrderId($orderId); - } - } -} diff --git a/src/Core/Domain/Order/Command/CancelOrderProductCommand.php b/src/Core/Domain/Order/Command/CancelOrderProductCommand.php deleted file mode 100644 index 5c58e0e4..00000000 --- a/src/Core/Domain/Order/Command/CancelOrderProductCommand.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -class CancelOrderProductCommand -{ - /** - * @var array - * - * key: orderDetailId, value: quantity - */ - private $cancelledProducts; - - /** - * @var OrderId - */ - private $orderId; - - /** - * CancelOrderProductCommand constructor. - * - * @param array $toBeCanceledProducts - * @param int $orderId - */ - public function __construct(array $cancelledProducts, int $orderId) - { - $this->cancelledProducts = $cancelledProducts; - $this->orderId = new OrderId($orderId); - } - - /** - * @return array - */ - public function getCancelledProducts() - { - return $this->cancelledProducts; - } - - /** - * @return OrderId - */ - public function getOrderId() - { - return $this->orderId; - } -} diff --git a/src/Core/Domain/Order/Command/ChangeOrderCurrencyCommand.php b/src/Core/Domain/Order/Command/ChangeOrderCurrencyCommand.php deleted file mode 100644 index 49b88cf5..00000000 --- a/src/Core/Domain/Order/Command/ChangeOrderCurrencyCommand.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\CurrencyId; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Changes currency for given order. - */ -class ChangeOrderCurrencyCommand -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @var CurrencyId - */ - private $newCurrencyId; - - /** - * @param int $orderId - * @param int $newCurrencyId - */ - public function __construct($orderId, $newCurrencyId) - { - $this->orderId = new OrderId($orderId); - $this->newCurrencyId = new CurrencyId($newCurrencyId); - } - - /** - * @return OrderId - */ - public function getOrderId() - { - return $this->orderId; - } - - /** - * @return CurrencyId - */ - public function getNewCurrencyId() - { - return $this->newCurrencyId; - } -} diff --git a/src/Core/Domain/Order/Command/ChangeOrderDeliveryAddressCommand.php b/src/Core/Domain/Order/Command/ChangeOrderDeliveryAddressCommand.php deleted file mode 100644 index e9cb393e..00000000 --- a/src/Core/Domain/Order/Command/ChangeOrderDeliveryAddressCommand.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Changes delivery address for given order. - */ -class ChangeOrderDeliveryAddressCommand -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @var AddressId - */ - private $newDeliveryAddressId; - - /** - * @param int $orderId - * @param int $newDeliveryAddressId - */ - public function __construct($orderId, $newDeliveryAddressId) - { - $this->orderId = new OrderId($orderId); - $this->newDeliveryAddressId = new AddressId($newDeliveryAddressId); - } - - /** - * @return OrderId - */ - public function getOrderId() - { - return $this->orderId; - } - - /** - * @return AddressId - */ - public function getNewDeliveryAddressId() - { - return $this->newDeliveryAddressId; - } -} diff --git a/src/Core/Domain/Order/Command/ChangeOrderInvoiceAddressCommand.php b/src/Core/Domain/Order/Command/ChangeOrderInvoiceAddressCommand.php deleted file mode 100644 index e0c9a49b..00000000 --- a/src/Core/Domain/Order/Command/ChangeOrderInvoiceAddressCommand.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Changes invoice address for given order. - */ -class ChangeOrderInvoiceAddressCommand -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @var AddressId - */ - private $newInvoiceAddressId; - - /** - * @param int $orderId - * @param int $newInvoiceAddressId - */ - public function __construct($orderId, $newInvoiceAddressId) - { - $this->orderId = new OrderId($orderId); - $this->newInvoiceAddressId = new AddressId($newInvoiceAddressId); - } - - /** - * @return OrderId - */ - public function getOrderId() - { - return $this->orderId; - } - - /** - * @return AddressId - */ - public function getNewInvoiceAddressId() - { - return $this->newInvoiceAddressId; - } -} diff --git a/src/Core/Domain/Order/Command/DeleteCartRuleFromOrderCommand.php b/src/Core/Domain/Order/Command/DeleteCartRuleFromOrderCommand.php deleted file mode 100644 index e2d19b29..00000000 --- a/src/Core/Domain/Order/Command/DeleteCartRuleFromOrderCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Removes cart rule from given order. - */ -class DeleteCartRuleFromOrderCommand -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @var int - */ - private $orderCartRuleId; - - /** - * @param int $orderId - * @param int $orderCartRuleId - */ - public function __construct($orderId, $orderCartRuleId) - { - $this->orderId = new OrderId($orderId); - $this->orderCartRuleId = $orderCartRuleId; - } - - /** - * @return OrderId - */ - public function getOrderId() - { - return $this->orderId; - } - - /** - * @return int - */ - public function getOrderCartRuleId() - { - return $this->orderCartRuleId; - } -} diff --git a/src/Core/Domain/Order/Command/DuplicateOrderCartCommand.php b/src/Core/Domain/Order/Command/DuplicateOrderCartCommand.php deleted file mode 100644 index 1f6108c4..00000000 --- a/src/Core/Domain/Order/Command/DuplicateOrderCartCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Duplicates cart for given order - */ -class DuplicateOrderCartCommand -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @param int $orderId - */ - public function __construct($orderId) - { - $this->orderId = new OrderId($orderId); - } - - /** - * @return OrderId - */ - public function getOrderId() - { - return $this->orderId; - } -} diff --git a/src/Core/Domain/Order/Command/IssuePartialRefundCommand.php b/src/Core/Domain/Order/Command/IssuePartialRefundCommand.php deleted file mode 100644 index c598dd37..00000000 --- a/src/Core/Domain/Order/Command/IssuePartialRefundCommand.php +++ /dev/null @@ -1,117 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use InvalidArgumentException; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidAmountException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidCancelProductException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderDetailRefund; - -/** - * Issues partial refund for given order. - */ -class IssuePartialRefundCommand extends AbstractRefundCommand -{ - /** - * @var Number - */ - private $shippingCostRefundAmount; - - /** - * The expected format for $orderDetailRefunds is an associative array indexed - * by OrderDetail id containing two fields amount and quantity - * - * ex: $orderDetailRefunds = [ - * {orderId} => [ - * 'quantity' => 2, - * 'amount' => 23.56, - * ], - * ]; - * - * @param int $orderId - * @param array $orderDetailRefunds - * @param string $shippingCostRefundAmount - * @param bool $restockRefundedProducts - * @param bool $generateVoucher - * @param bool $generateCreditSlip - * @param int $voucherRefundType - * @param string|null $voucherRefundAmount - * - * @throws InvalidCancelProductException - * @throws OrderException - */ - public function __construct( - int $orderId, - array $orderDetailRefunds, - string $shippingCostRefundAmount, - bool $restockRefundedProducts, - bool $generateCreditSlip, - bool $generateVoucher, - int $voucherRefundType, - ?string $voucherRefundAmount = null - ) { - parent::__construct( - $orderId, - $orderDetailRefunds, - $restockRefundedProducts, - $generateCreditSlip, - $generateVoucher, - $voucherRefundType, - $voucherRefundAmount - ); - try { - $this->shippingCostRefundAmount = new Number($shippingCostRefundAmount); - } catch (InvalidArgumentException $e) { - throw new InvalidAmountException(); - } - } - - /** - * @return Number - */ - public function getShippingCostRefundAmount(): Number - { - return $this->shippingCostRefundAmount; - } - - /** - * {@inheritdoc} - */ - protected function setOrderDetailRefunds(array $orderDetailRefunds) - { - $this->orderDetailRefunds = []; - foreach ($orderDetailRefunds as $orderDetailId => $detailRefund) { - $this->orderDetailRefunds[] = OrderDetailRefund::createPartialRefund( - $orderDetailId, - $detailRefund['quantity'], - $detailRefund['amount'] - ); - } - } -} diff --git a/src/Core/Domain/Order/Command/IssueReturnProductCommand.php b/src/Core/Domain/Order/Command/IssueReturnProductCommand.php deleted file mode 100644 index 2a5fbb6a..00000000 --- a/src/Core/Domain/Order/Command/IssueReturnProductCommand.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidCancelProductException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; - -/** - * Issues return product for given order. - */ -class IssueReturnProductCommand extends IssueStandardRefundCommand -{ - /** - * The expected format for $orderDetailRefunds is an associative array indexed - * by OrderDetail id containing one fields quantity - * - * ex: $orderDetailRefunds = [ - * {orderId} => [ - * 'quantity' => 2, - * ], - * ]; - * - * @param int $orderId - * @param array $orderDetailRefunds - * @param bool $restockRefundedProducts - * @param bool $refundShippingCost - * @param bool $generateCreditSlip - * @param bool $generateVoucher - * @param int $voucherRefundType - * - * @throws InvalidCancelProductException - * @throws OrderException - */ - public function __construct( - int $orderId, - array $orderDetailRefunds, - bool $restockRefundedProducts, - bool $refundShippingCost, - bool $generateCreditSlip, - bool $generateVoucher, - int $voucherRefundType - ) { - parent::__construct( - $orderId, - $orderDetailRefunds, - $refundShippingCost, - $generateCreditSlip, - $generateVoucher, - $voucherRefundType - ); - $this->restockRefundedProducts = $restockRefundedProducts; - } -} diff --git a/src/Core/Domain/Order/Command/IssueStandardRefundCommand.php b/src/Core/Domain/Order/Command/IssueStandardRefundCommand.php deleted file mode 100644 index 3466b278..00000000 --- a/src/Core/Domain/Order/Command/IssueStandardRefundCommand.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidCancelProductException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderDetailRefund; - -/** - * Issues standard refund for given order. - */ -class IssueStandardRefundCommand extends AbstractRefundCommand -{ - /** - * @var bool - */ - protected $refundShippingCost; - - /** - * The expected format for $orderDetailRefunds is an associative array indexed - * by OrderDetail id containing one fields quantity - * - * ex: $orderDetailRefunds = [ - * {orderId} => [ - * 'quantity' => 2, - * ], - * ]; - * - * @param int $orderId - * @param array $orderDetailRefunds - * @param bool $refundShippingCost - * @param bool $generateCreditSlip - * @param bool $generateVoucher - * @param int $voucherRefundType - * - * @throws InvalidCancelProductException - * @throws OrderException - */ - public function __construct( - int $orderId, - array $orderDetailRefunds, - bool $refundShippingCost, - bool $generateCreditSlip, - bool $generateVoucher, - int $voucherRefundType - ) { - parent::__construct( - $orderId, - $orderDetailRefunds, - true, - $generateCreditSlip, - $generateVoucher, - $voucherRefundType - ); - $this->refundShippingCost = $refundShippingCost; - } - - /** - * @return bool - */ - public function refundShippingCost(): bool - { - return $this->refundShippingCost; - } - - /** - * {@inheritdoc} - */ - protected function setOrderDetailRefunds(array $orderDetailRefunds) - { - $this->orderDetailRefunds = []; - foreach ($orderDetailRefunds as $orderDetailId => $detailRefund) { - $this->orderDetailRefunds[] = OrderDetailRefund::createStandardRefund( - $orderDetailId, - $detailRefund['quantity'] - ); - } - } -} diff --git a/src/Core/Domain/Order/Command/ResendOrderEmailCommand.php b/src/Core/Domain/Order/Command/ResendOrderEmailCommand.php deleted file mode 100644 index beb9aa5a..00000000 --- a/src/Core/Domain/Order/Command/ResendOrderEmailCommand.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -class ResendOrderEmailCommand -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @var int - */ - private $orderStatusId; - - /** - * @var int - */ - private $orderHistoryId; - - public function __construct(int $orderId, int $orderStatusId, int $orderHistoryId) - { - $this->orderId = new OrderId($orderId); - $this->orderStatusId = $orderStatusId; - $this->orderHistoryId = $orderHistoryId; - } - - /** - * @return OrderId - */ - public function getOrderId(): OrderId - { - return $this->orderId; - } - - /** - * @return int - */ - public function getOrderStatusId(): int - { - return $this->orderStatusId; - } - - /** - * @return int - */ - public function getOrderHistoryId(): int - { - return $this->orderHistoryId; - } -} diff --git a/src/Core/Domain/Order/Command/SendProcessOrderEmailCommand.php b/src/Core/Domain/Order/Command/SendProcessOrderEmailCommand.php deleted file mode 100644 index 4eda32fa..00000000 --- a/src/Core/Domain/Order/Command/SendProcessOrderEmailCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; - -/** - * Sends email to customer with link for processing the order from cart - */ -class SendProcessOrderEmailCommand -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @param int $cartId - * - * @throws CartConstraintException - */ - public function __construct(int $cartId) - { - $this->cartId = new CartId($cartId); - } - - /** - * @return CartId - */ - public function getCartId(): CartId - { - return $this->cartId; - } -} diff --git a/src/Core/Domain/Order/Command/UpdateOrderShippingDetailsCommand.php b/src/Core/Domain/Order/Command/UpdateOrderShippingDetailsCommand.php deleted file mode 100644 index 4d1c2308..00000000 --- a/src/Core/Domain/Order/Command/UpdateOrderShippingDetailsCommand.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Updates shipping details for given order. - */ -class UpdateOrderShippingDetailsCommand -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @var int - */ - private $newCarrierId; - - /** - * @var string|null - */ - private $trackingNumber; - - /** - * @var int - */ - private $currentOrderCarrierId; - - /** - * @param int $orderId - * @param int $currentOrderCarrierId - * @param int $newCarrierId - * @param string $trackingNumber - */ - public function __construct(int $orderId, int $currentOrderCarrierId, int $newCarrierId, ?string $trackingNumber = '') - { - $this->orderId = new OrderId($orderId); - $this->newCarrierId = $newCarrierId; - $this->trackingNumber = $trackingNumber; - $this->currentOrderCarrierId = $currentOrderCarrierId; - } - - /** - * @return OrderId - */ - public function getOrderId(): OrderId - { - return $this->orderId; - } - - /** - * @return int - */ - public function getNewCarrierId(): int - { - return $this->newCarrierId; - } - - /** - * @return string|null - */ - public function getShippingTrackingNumber(): ?string - { - return $this->trackingNumber; - } - - /** - * @return int - */ - public function getCurrentOrderCarrierId(): int - { - return $this->currentOrderCarrierId; - } -} diff --git a/src/Core/Domain/Order/Command/UpdateOrderStatusCommand.php b/src/Core/Domain/Order/Command/UpdateOrderStatusCommand.php deleted file mode 100644 index 9d5884a8..00000000 --- a/src/Core/Domain/Order/Command/UpdateOrderStatusCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Command; - -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Updates order status. - */ -class UpdateOrderStatusCommand -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @var int - */ - private $newOrderStatusId; - - /** - * @param int $orderId - * @param int $newOrderStatusId - */ - public function __construct($orderId, $newOrderStatusId) - { - $this->orderId = new OrderId($orderId); - $this->newOrderStatusId = $newOrderStatusId; - } - - /** - * @return OrderId - */ - public function getOrderId() - { - return $this->orderId; - } - - /** - * @return int - */ - public function getNewOrderStatusId() - { - return $this->newOrderStatusId; - } -} diff --git a/src/Core/Domain/Order/CommandHandler/AddCartRuleToOrderHandlerInterface.php b/src/Core/Domain/Order/CommandHandler/AddCartRuleToOrderHandlerInterface.php deleted file mode 100644 index a1e2471c..00000000 --- a/src/Core/Domain/Order/CommandHandler/AddCartRuleToOrderHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Command\AddCartRuleToOrderCommand; - -/** - * @internal - */ -interface AddCartRuleToOrderHandlerInterface -{ - /** - * @param AddCartRuleToOrderCommand $command - */ - public function handle(AddCartRuleToOrderCommand $command): void; -} diff --git a/src/Core/Domain/Order/CommandHandler/AddOrderFromBackOfficeHandlerInterface.php b/src/Core/Domain/Order/CommandHandler/AddOrderFromBackOfficeHandlerInterface.php deleted file mode 100644 index 2dca94a5..00000000 --- a/src/Core/Domain/Order/CommandHandler/AddOrderFromBackOfficeHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Command\AddOrderFromBackOfficeCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Interface for service that adds new order. - */ -interface AddOrderFromBackOfficeHandlerInterface -{ - /** - * @param AddOrderFromBackOfficeCommand $command - * - * @return OrderId - */ - public function handle(AddOrderFromBackOfficeCommand $command); -} diff --git a/src/Core/Domain/Order/CommandHandler/BulkChangeOrderStatusHandlerInterface.php b/src/Core/Domain/Order/CommandHandler/BulkChangeOrderStatusHandlerInterface.php deleted file mode 100644 index cb60689c..00000000 --- a/src/Core/Domain/Order/CommandHandler/BulkChangeOrderStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Command\BulkChangeOrderStatusCommand; - -/** - * Interface for service that handles changing orders status - */ -interface BulkChangeOrderStatusHandlerInterface -{ - /** - * @param BulkChangeOrderStatusCommand $command - */ - public function handle(BulkChangeOrderStatusCommand $command); -} diff --git a/src/Core/Domain/Order/CommandHandler/CancelOrderProductHandlerInterface.php b/src/Core/Domain/Order/CommandHandler/CancelOrderProductHandlerInterface.php deleted file mode 100644 index adb4ca72..00000000 --- a/src/Core/Domain/Order/CommandHandler/CancelOrderProductHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Command\CancelOrderProductCommand; - -/** - * Interface for service that handles issuing cancel product for given order - */ -interface CancelOrderProductHandlerInterface -{ - /** - * @param CancelOrderProductCommand $command - */ - public function handle(CancelOrderProductCommand $command); -} diff --git a/src/Core/Domain/Order/CommandHandler/ChangeOrderCurrencyHandlerInterface.php b/src/Core/Domain/Order/CommandHandler/ChangeOrderCurrencyHandlerInterface.php deleted file mode 100644 index 7c716ddf..00000000 --- a/src/Core/Domain/Order/CommandHandler/ChangeOrderCurrencyHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Command\ChangeOrderCurrencyCommand; - -/** - * Interface for service that handles changing order currency. - */ -interface ChangeOrderCurrencyHandlerInterface -{ - /** - * @param ChangeOrderCurrencyCommand $command - */ - public function handle(ChangeOrderCurrencyCommand $command); -} diff --git a/src/Core/Domain/Order/CommandHandler/ChangeOrderDeliveryAddressHandlerInterface.php b/src/Core/Domain/Order/CommandHandler/ChangeOrderDeliveryAddressHandlerInterface.php deleted file mode 100644 index 4f4338ef..00000000 --- a/src/Core/Domain/Order/CommandHandler/ChangeOrderDeliveryAddressHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Command\ChangeOrderDeliveryAddressCommand; - -/** - * Interface for service that handles changing order delivery address. - */ -interface ChangeOrderDeliveryAddressHandlerInterface -{ - /** - * @param ChangeOrderDeliveryAddressCommand $command - */ - public function handle(ChangeOrderDeliveryAddressCommand $command); -} diff --git a/src/Core/Domain/Order/CommandHandler/ChangeOrderInvoiceAddressHandlerInterface.php b/src/Core/Domain/Order/CommandHandler/ChangeOrderInvoiceAddressHandlerInterface.php deleted file mode 100644 index fd5123cd..00000000 --- a/src/Core/Domain/Order/CommandHandler/ChangeOrderInvoiceAddressHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Command\ChangeOrderInvoiceAddressCommand; - -/** - * Interface for service that handles changing order invoice address. - */ -interface ChangeOrderInvoiceAddressHandlerInterface -{ - /** - * @param ChangeOrderInvoiceAddressCommand $command - */ - public function handle(ChangeOrderInvoiceAddressCommand $command); -} diff --git a/src/Core/Domain/Order/CommandHandler/DeleteCartRuleFromOrderHandlerInterface.php b/src/Core/Domain/Order/CommandHandler/DeleteCartRuleFromOrderHandlerInterface.php deleted file mode 100644 index b6e4421f..00000000 --- a/src/Core/Domain/Order/CommandHandler/DeleteCartRuleFromOrderHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Command\DeleteCartRuleFromOrderCommand; - -/** - * Interface for service that handles removing cart rule from given order. - */ -interface DeleteCartRuleFromOrderHandlerInterface -{ - /** - * @param DeleteCartRuleFromOrderCommand $command - */ - public function handle(DeleteCartRuleFromOrderCommand $command); -} diff --git a/src/Core/Domain/Order/CommandHandler/DuplicateOrderCartHandlerInterface.php b/src/Core/Domain/Order/CommandHandler/DuplicateOrderCartHandlerInterface.php deleted file mode 100644 index 4ed84cae..00000000 --- a/src/Core/Domain/Order/CommandHandler/DuplicateOrderCartHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\DuplicateOrderCartCommand; - -/** - * Interface for service that handles duplicating order cart - */ -interface DuplicateOrderCartHandlerInterface -{ - /** - * @param DuplicateOrderCartCommand $command - * - * @return CartId Duplicated cart id - */ - public function handle(DuplicateOrderCartCommand $command); -} diff --git a/src/Core/Domain/Order/CommandHandler/IssuePartialRefundHandlerInterface.php b/src/Core/Domain/Order/CommandHandler/IssuePartialRefundHandlerInterface.php deleted file mode 100644 index 5e75b5bc..00000000 --- a/src/Core/Domain/Order/CommandHandler/IssuePartialRefundHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Command\IssuePartialRefundCommand; - -/** - * Interface for service that handles issuing partial refund for given order - */ -interface IssuePartialRefundHandlerInterface -{ - /** - * @param IssuePartialRefundCommand $command - */ - public function handle(IssuePartialRefundCommand $command): void; -} diff --git a/src/Core/Domain/Order/CommandHandler/IssueReturnProductHandlerInterface.php b/src/Core/Domain/Order/CommandHandler/IssueReturnProductHandlerInterface.php deleted file mode 100644 index 8e4a4d49..00000000 --- a/src/Core/Domain/Order/CommandHandler/IssueReturnProductHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Command\IssueReturnProductCommand; - -/** - * Interface for service that handles issuing return product for given order - */ -interface IssueReturnProductHandlerInterface -{ - /** - * @param IssueReturnProductCommand $command - */ - public function handle(IssueReturnProductCommand $command): void; -} diff --git a/src/Core/Domain/Order/CommandHandler/IssueStandardRefundHandlerInterface.php b/src/Core/Domain/Order/CommandHandler/IssueStandardRefundHandlerInterface.php deleted file mode 100644 index 20def040..00000000 --- a/src/Core/Domain/Order/CommandHandler/IssueStandardRefundHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Command\IssueStandardRefundCommand; - -/** - * Interface for service that handles issuing standard refund for given order - */ -interface IssueStandardRefundHandlerInterface -{ - /** - * @param IssueStandardRefundCommand $command - */ - public function handle(IssueStandardRefundCommand $command): void; -} diff --git a/src/Core/Domain/Order/CommandHandler/ResendOrderEmailHandlerInterface.php b/src/Core/Domain/Order/CommandHandler/ResendOrderEmailHandlerInterface.php deleted file mode 100644 index 47913e9d..00000000 --- a/src/Core/Domain/Order/CommandHandler/ResendOrderEmailHandlerInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Command\ResendOrderEmailCommand; - -interface ResendOrderEmailHandlerInterface -{ - /** - * @param ResendOrderEmailCommand $command - */ - public function handle(ResendOrderEmailCommand $command): void; -} diff --git a/src/Core/Domain/Order/CommandHandler/SendProcessOrderEmailHandlerInterface.php b/src/Core/Domain/Order/CommandHandler/SendProcessOrderEmailHandlerInterface.php deleted file mode 100644 index ab200f8a..00000000 --- a/src/Core/Domain/Order/CommandHandler/SendProcessOrderEmailHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Command\SendProcessOrderEmailCommand; - -/** - * Interface for handling SendProcessOrderEmail command - */ -interface SendProcessOrderEmailHandlerInterface -{ - /** - * @param SendProcessOrderEmailCommand $command - */ - public function handle(SendProcessOrderEmailCommand $command): void; -} diff --git a/src/Core/Domain/Order/CommandHandler/UpdateOrderShippingDetailsHandlerInterface.php b/src/Core/Domain/Order/CommandHandler/UpdateOrderShippingDetailsHandlerInterface.php deleted file mode 100644 index 21e22af0..00000000 --- a/src/Core/Domain/Order/CommandHandler/UpdateOrderShippingDetailsHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Command\UpdateOrderShippingDetailsCommand; - -/** - * Interface for service that handling updating shipping details for given order. - */ -interface UpdateOrderShippingDetailsHandlerInterface -{ - /** - * @param UpdateOrderShippingDetailsCommand $command - */ - public function handle(UpdateOrderShippingDetailsCommand $command); -} diff --git a/src/Core/Domain/Order/CommandHandler/UpdateOrderStatusHandlerInterface.php b/src/Core/Domain/Order/CommandHandler/UpdateOrderStatusHandlerInterface.php deleted file mode 100644 index d4272ac5..00000000 --- a/src/Core/Domain/Order/CommandHandler/UpdateOrderStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Command\UpdateOrderStatusCommand; - -/** - * Interface for service that handles updating order status. - */ -interface UpdateOrderStatusHandlerInterface -{ - /** - * @param UpdateOrderStatusCommand $command - */ - public function handle(UpdateOrderStatusCommand $command); -} diff --git a/src/Core/Domain/Order/Exception/CancelProductFromOrderException.php b/src/Core/Domain/Order/Exception/CancelProductFromOrderException.php deleted file mode 100644 index 55516b6a..00000000 --- a/src/Core/Domain/Order/Exception/CancelProductFromOrderException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -/** - * Exception thrown when something went wrong during a product cancel action. - */ -class CancelProductFromOrderException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Exception/CannotEditDeliveredOrderProductException.php b/src/Core/Domain/Order/Exception/CannotEditDeliveredOrderProductException.php deleted file mode 100644 index 77405dc4..00000000 --- a/src/Core/Domain/Order/Exception/CannotEditDeliveredOrderProductException.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -class CannotEditDeliveredOrderProductException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Exception/CannotFindProductInOrderException.php b/src/Core/Domain/Order/Exception/CannotFindProductInOrderException.php deleted file mode 100644 index 66e97d21..00000000 --- a/src/Core/Domain/Order/Exception/CannotFindProductInOrderException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -/** - * Thrown on failure to update product in an order - */ -class CannotFindProductInOrderException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Exception/CannotUpdateOrderException.php b/src/Core/Domain/Order/Exception/CannotUpdateOrderException.php deleted file mode 100644 index 0b987f3e..00000000 --- a/src/Core/Domain/Order/Exception/CannotUpdateOrderException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -/** - * Thrown on failure to update order - */ -class CannotUpdateOrderException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Exception/ChangeOrderStatusException.php b/src/Core/Domain/Order/Exception/ChangeOrderStatusException.php deleted file mode 100644 index 433aa7b7..00000000 --- a/src/Core/Domain/Order/Exception/ChangeOrderStatusException.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Throw when failed changing order status - */ -class ChangeOrderStatusException extends OrderException -{ - /** - * @var OrderId[] - */ - private $ordersWithFailedToUpdateStatus; - - /** - * @var OrderId[] - */ - private $ordersWithFailedToSendEmail; - - /** - * @var OrderId[] - */ - private $ordersWithAssignedStatus; - - /** - * @param OrderId[] $ordersWithFailedToUpdateStatus - * @param OrderId[] $ordersWithFailedToSendEmail - * @param OrderId[] $ordersWithAssignedStatus - * @param string $message - * @param int $code - * @param \Exception|null $previous - */ - public function __construct( - array $ordersWithFailedToUpdateStatus, - array $ordersWithFailedToSendEmail, - array $ordersWithAssignedStatus, - $message = '', - $code = 0, - $previous = null - ) { - $this->ordersWithFailedToUpdateStatus = $ordersWithFailedToUpdateStatus; - $this->ordersWithFailedToSendEmail = $ordersWithFailedToSendEmail; - $this->ordersWithAssignedStatus = $ordersWithAssignedStatus; - - parent::__construct($message, $code, $previous); - } - - /** - * @return OrderId[] - */ - public function getOrdersWithFailedToUpdateStatus() - { - return $this->ordersWithFailedToUpdateStatus; - } - - /** - * @return OrderId[] - */ - public function getOrdersWithFailedToSendEmail() - { - return $this->ordersWithFailedToSendEmail; - } - - /** - * @return OrderId[] - */ - public function getOrdersWithAssignedStatus() - { - return $this->ordersWithAssignedStatus; - } -} diff --git a/src/Core/Domain/Order/Exception/DeleteCustomizedProductFromOrderException.php b/src/Core/Domain/Order/Exception/DeleteCustomizedProductFromOrderException.php deleted file mode 100644 index 69f7a788..00000000 --- a/src/Core/Domain/Order/Exception/DeleteCustomizedProductFromOrderException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -/** - * Exception thrown when something went wrong while deleting a customized product from an order. - */ -class DeleteCustomizedProductFromOrderException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Exception/DeleteProductFromOrderException.php b/src/Core/Domain/Order/Exception/DeleteProductFromOrderException.php deleted file mode 100644 index 89f21604..00000000 --- a/src/Core/Domain/Order/Exception/DeleteProductFromOrderException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -/** - * Exception thrown when something went wrong while deleting a product from an order. - */ -class DeleteProductFromOrderException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Exception/DuplicateOrderCartException.php b/src/Core/Domain/Order/Exception/DuplicateOrderCartException.php deleted file mode 100644 index 121d0410..00000000 --- a/src/Core/Domain/Order/Exception/DuplicateOrderCartException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -/** - * Is thrown when duplicating order cart fails - */ -class DuplicateOrderCartException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Exception/DuplicateProductInOrderException.php b/src/Core/Domain/Order/Exception/DuplicateProductInOrderException.php deleted file mode 100644 index 2175a174..00000000 --- a/src/Core/Domain/Order/Exception/DuplicateProductInOrderException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -class DuplicateProductInOrderException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Exception/DuplicateProductInOrderInvoiceException.php b/src/Core/Domain/Order/Exception/DuplicateProductInOrderInvoiceException.php deleted file mode 100644 index bb8d13bb..00000000 --- a/src/Core/Domain/Order/Exception/DuplicateProductInOrderInvoiceException.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -use Throwable; - -/** - * Class DuplicateProductInOrderInvoiceException thrown when we try to add a product in an order invoice that already contains it - */ -class DuplicateProductInOrderInvoiceException extends DuplicateProductInOrderException -{ - /** - * @var string - */ - private $orderInvoiceNumber; - - /** - * @param string $orderInvoiceId - * @param string $message - * @param int $code - * @param Throwable|null $previous - */ - public function __construct(string $orderInvoiceId, $message = '', $code = 0, Throwable $previous = null) - { - parent::__construct($message, $code, $previous); - $this->orderInvoiceNumber = $orderInvoiceId; - } - - /** - * @return string - */ - public function getOrderInvoiceNumber(): string - { - return $this->orderInvoiceNumber; - } -} diff --git a/src/Core/Domain/Order/Exception/InvalidAddressTypeException.php b/src/Core/Domain/Order/Exception/InvalidAddressTypeException.php deleted file mode 100644 index 2a58f751..00000000 --- a/src/Core/Domain/Order/Exception/InvalidAddressTypeException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -/** - * Class InvalidAddressTypeException - */ -class InvalidAddressTypeException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Exception/InvalidAmountException.php b/src/Core/Domain/Order/Exception/InvalidAmountException.php deleted file mode 100644 index 6eada34f..00000000 --- a/src/Core/Domain/Order/Exception/InvalidAmountException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -/** - * Exception thrown when the amount format is not valid - */ -class InvalidAmountException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Exception/InvalidCancelProductException.php b/src/Core/Domain/Order/Exception/InvalidCancelProductException.php deleted file mode 100644 index 41260f88..00000000 --- a/src/Core/Domain/Order/Exception/InvalidCancelProductException.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -use Throwable; - -/** - * Throw new when a partial refund's is asked without a specified quantity - */ -class InvalidCancelProductException extends OrderException -{ - /** - * @var int - */ - private $refundableQuantity; - - /** - * Used when the quantity refunded is not strictly positive - */ - const INVALID_QUANTITY = 1; - - /** - * Used when the quantity refunded is higher than the remaining quantity - */ - const QUANTITY_TOO_HIGH = 2; - - /** - * Used when the amount refunded is not strictly positive - */ - const INVALID_AMOUNT = 3; - - /** - * Used when no refund details have been supplied (nor products nor shipping refund) - */ - const NO_REFUNDS = 4; - - /** - * Used when no generation is set (no credit slip and no voucher generation) - */ - const NO_GENERATION = 5; - - /** - * @param int $code - * @param int $refundableQuantity - * @param string $message - * @param Throwable|null $previous - */ - public function __construct($code = 0, int $refundableQuantity = 0, $message = '', Throwable $previous = null) - { - parent::__construct($message, $code, $previous); - $this->refundableQuantity = $refundableQuantity; - } - - /** - * @return int - */ - public function getRefundableQuantity(): int - { - return $this->refundableQuantity; - } -} diff --git a/src/Core/Domain/Order/Exception/InvalidOrderStateException.php b/src/Core/Domain/Order/Exception/InvalidOrderStateException.php deleted file mode 100644 index 9a242095..00000000 --- a/src/Core/Domain/Order/Exception/InvalidOrderStateException.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -/** - * Thrown when the order state is incompatible with an action (ex: standard - * refund on an order not paid yet). - */ -class InvalidOrderStateException extends OrderException -{ - /** - * Used when the order is not paid (and it should be) - */ - const NOT_PAID = 1; - - /** - * Used when the order is already paid (and it should not be) - */ - const ALREADY_PAID = 2; - - /** - * Used when the order has not been delivered (and it should have) - */ - const DELIVERY_NOT_FOUND = 3; - - /** - * Used when the order has been delivered (and it shouldn't have) - */ - const UNEXPECTED_DELIVERY = 4; - /** - * Used when the order state is not found - */ - const INVALID_ID = 5; - - /** - * @param int $code - * @param string $message - * @param Throwable|null $previous - */ - public function __construct($code = 0, $message = '', Throwable $previous = null) - { - parent::__construct($message, $code, $previous); - } -} diff --git a/src/Core/Domain/Order/Exception/InvalidProductQuantityException.php b/src/Core/Domain/Order/Exception/InvalidProductQuantityException.php deleted file mode 100644 index 63fea178..00000000 --- a/src/Core/Domain/Order/Exception/InvalidProductQuantityException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -/** - * Thrown when trying to add an invalid quantity or a product (<= 0) - */ -class InvalidProductQuantityException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Exception/InvalidRefundException.php b/src/Core/Domain/Order/Exception/InvalidRefundException.php deleted file mode 100644 index 65cdc3e3..00000000 --- a/src/Core/Domain/Order/Exception/InvalidRefundException.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -use Throwable; - -/** - * Throw new when a partial refund's is asked without a specified quantity - */ -class InvalidRefundException extends OrderException -{ - /** - * @var int - */ - private $refundableQuantity; - - /** - * Used when the quantity refunded is not strictly positive - */ - const INVALID_QUANTITY = 1; - - /** - * Used when the quantity refunded is higher than the remaining quantity - */ - const QUANTITY_TOO_HIGH = 2; - - /** - * Used when the amount refunded is not strictly positive - */ - const INVALID_AMOUNT = 3; - - /** - * Used when no refund details have been supplied (nor products nor shipping refund) - */ - const NO_REFUNDS = 4; - - /** - * Used when no generation is set (no credit slip and no voucher generation) - */ - const NO_GENERATION = 5; - - /** - * @param int $code - * @param int $refundableQuantity - * @param string $message - * @param Throwable|null $previous - */ - public function __construct($code = 0, int $refundableQuantity = 0, $message = '', Throwable $previous = null) - { - parent::__construct($message, $code, $previous); - $this->refundableQuantity = $refundableQuantity; - } - - /** - * @return int - */ - public function getRefundableQuantity(): int - { - return $this->refundableQuantity; - } -} diff --git a/src/Core/Domain/Order/Exception/NegativePaymentAmountException.php b/src/Core/Domain/Order/Exception/NegativePaymentAmountException.php deleted file mode 100644 index ed8f7f2b..00000000 --- a/src/Core/Domain/Order/Exception/NegativePaymentAmountException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -/** - * Exception thrown when the payment amount is negative - */ -class NegativePaymentAmountException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Exception/OrderConstraintException.php b/src/Core/Domain/Order/Exception/OrderConstraintException.php deleted file mode 100644 index a42149e6..00000000 --- a/src/Core/Domain/Order/Exception/OrderConstraintException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -/** - * Exception thrown when constraint is violated in Order subdomain. - */ -class OrderConstraintException extends OrderException -{ - /** - * Used in create order from BO when the customer message is invalid. - */ - const INVALID_CUSTOMER_MESSAGE = 1; -} diff --git a/src/Core/Domain/Order/Exception/OrderEmailSendException.php b/src/Core/Domain/Order/Exception/OrderEmailSendException.php deleted file mode 100644 index 7f5da81d..00000000 --- a/src/Core/Domain/Order/Exception/OrderEmailSendException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -/** - * Thrown when failed to send email associated with order - */ -class OrderEmailSendException extends OrderException -{ - /** - * When order email resending failed - */ - const FAILED_RESEND = 1; - - /** - * When order process email sending failed - */ - const FAILED_SEND_PROCESS_ORDER = 2; -} diff --git a/src/Core/Domain/Order/Exception/OrderException.php b/src/Core/Domain/Order/Exception/OrderException.php deleted file mode 100644 index 1c9a7b5b..00000000 --- a/src/Core/Domain/Order/Exception/OrderException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Is base exception for Order subdomain - */ -class OrderException extends DomainException -{ -} diff --git a/src/Core/Domain/Order/Exception/OrderNotFoundException.php b/src/Core/Domain/Order/Exception/OrderNotFoundException.php deleted file mode 100644 index ae654799..00000000 --- a/src/Core/Domain/Order/Exception/OrderNotFoundException.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Thrown when order is not found - */ -class OrderNotFoundException extends OrderException -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @param OrderId $orderId - * @param string $message - * @param int $code - * @param Exception|null $previous - */ - public function __construct(OrderId $orderId, $message = '', $code = 0, $previous = null) - { - parent::__construct($message, $code, $previous); - - $this->orderId = $orderId; - } - - /** - * @return OrderId - */ - public function getOrderId() - { - return $this->orderId; - } -} diff --git a/src/Core/Domain/Order/Exception/ReturnProductDisabledException.php b/src/Core/Domain/Order/Exception/ReturnProductDisabledException.php deleted file mode 100644 index af66bded..00000000 --- a/src/Core/Domain/Order/Exception/ReturnProductDisabledException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -/** - * Thrown when trying to perform a return product operation while it is disabled - */ -class ReturnProductDisabledException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Exception/TransistEmailSendingException.php b/src/Core/Domain/Order/Exception/TransistEmailSendingException.php deleted file mode 100644 index d447c2fd..00000000 --- a/src/Core/Domain/Order/Exception/TransistEmailSendingException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Exception; - -/** - * Thrown when when failed to send email to customer regarding order tracking - */ -class TransistEmailSendingException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Invoice/Command/GenerateInvoiceCommand.php b/src/Core/Domain/Order/Invoice/Command/GenerateInvoiceCommand.php deleted file mode 100644 index df47984b..00000000 --- a/src/Core/Domain/Order/Invoice/Command/GenerateInvoiceCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Invoice\Command; - -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Generates invoice for given order. - */ -class GenerateInvoiceCommand -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @param int $orderId - */ - public function __construct($orderId) - { - $this->orderId = new OrderId($orderId); - } - - /** - * @return OrderId - */ - public function getOrderId() - { - return $this->orderId; - } -} diff --git a/src/Core/Domain/Order/Invoice/Command/UpdateInvoiceNoteCommand.php b/src/Core/Domain/Order/Invoice/Command/UpdateInvoiceNoteCommand.php deleted file mode 100644 index 4a42b22a..00000000 --- a/src/Core/Domain/Order/Invoice/Command/UpdateInvoiceNoteCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Invoice\Command; - -use PrestaShop\PrestaShop\Core\Domain\Order\Invoice\ValueObject\OrderInvoiceId; - -/** - * Adds note for given invoice. - */ -class UpdateInvoiceNoteCommand -{ - /** - * @var OrderInvoiceId - */ - private $orderInvoiceId; - - /** - * @var string|null - */ - private $note; - - /** - * @param int $orderInvoiceId - * @param string|null $note - */ - public function __construct(int $orderInvoiceId, ?string $note) - { - $this->orderInvoiceId = new OrderInvoiceId($orderInvoiceId); - $this->note = $note; - } - - /** - * @return OrderInvoiceId - */ - public function getOrderInvoiceId(): OrderInvoiceId - { - return $this->orderInvoiceId; - } - - /** - * @return string|null - */ - public function getNote(): ?string - { - return $this->note; - } -} diff --git a/src/Core/Domain/Order/Invoice/CommandHandler/GenerateOrderInvoiceHandlerInterface.php b/src/Core/Domain/Order/Invoice/CommandHandler/GenerateOrderInvoiceHandlerInterface.php deleted file mode 100644 index f10b94ab..00000000 --- a/src/Core/Domain/Order/Invoice/CommandHandler/GenerateOrderInvoiceHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Invoice\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Invoice\Command\GenerateInvoiceCommand; - -/** - * Interface for service that handles generating invoice for order. - */ -interface GenerateOrderInvoiceHandlerInterface -{ - /** - * @param GenerateInvoiceCommand $command - */ - public function handle(GenerateInvoiceCommand $command); -} diff --git a/src/Core/Domain/Order/Invoice/CommandHandler/UpdateInvoiceNoteHandlerInterface.php b/src/Core/Domain/Order/Invoice/CommandHandler/UpdateInvoiceNoteHandlerInterface.php deleted file mode 100644 index 805da0ad..00000000 --- a/src/Core/Domain/Order/Invoice/CommandHandler/UpdateInvoiceNoteHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Invoice\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Invoice\Command\UpdateInvoiceNoteCommand; - -/** - * Interface for service that handles updating invoice note - */ -interface UpdateInvoiceNoteHandlerInterface -{ - /** - * @param UpdateInvoiceNoteCommand $command - */ - public function handle(UpdateInvoiceNoteCommand $command): void; -} diff --git a/src/Core/Domain/Order/Invoice/Exception/InvoiceException.php b/src/Core/Domain/Order/Invoice/Exception/InvoiceException.php deleted file mode 100644 index 793e6a2c..00000000 --- a/src/Core/Domain/Order/Invoice/Exception/InvoiceException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Invoice\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; - -/** - * Base exception for Invoice subdomain - */ -class InvoiceException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Invoice/Exception/InvoiceNotFoundException.php b/src/Core/Domain/Order/Invoice/Exception/InvoiceNotFoundException.php deleted file mode 100644 index 541b6f6f..00000000 --- a/src/Core/Domain/Order/Invoice/Exception/InvoiceNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Invoice\Exception; - -/** - * Thrown when order invoice is not found - */ -class InvoiceNotFoundException extends InvoiceException -{ -} diff --git a/src/Core/Domain/Order/Invoice/ValueObject/OrderInvoiceId.php b/src/Core/Domain/Order/Invoice/ValueObject/OrderInvoiceId.php deleted file mode 100644 index fcfe8dd8..00000000 --- a/src/Core/Domain/Order/Invoice/ValueObject/OrderInvoiceId.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Invoice\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Order\Invoice\Exception\InvoiceException; - -/** - * Order invoice identity - */ -class OrderInvoiceId -{ - /** - * @var int - */ - private $orderInvoiceId; - - /** - * @param int $orderInvoiceId - */ - public function __construct($orderInvoiceId) - { - if (!is_int($orderInvoiceId) || 0 >= $orderInvoiceId) { - throw new InvoiceException('Invalid order invoice id supplied.'); - } - - $this->orderInvoiceId = $orderInvoiceId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->orderInvoiceId; - } -} diff --git a/src/Core/Domain/Order/OrderAddressType.php b/src/Core/Domain/Order/OrderAddressType.php deleted file mode 100644 index 02532159..00000000 --- a/src/Core/Domain/Order/OrderAddressType.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Order; - -/** - * Used to identity which type of address has to be edited - */ -class OrderAddressType -{ - const DELIVERY_ADDRESS_TYPE = 'delivery_address'; - - const INVOICE_ADDRESS_TYPE = 'invoice_address'; -} diff --git a/src/Core/Domain/Order/OrderConstraints.php b/src/Core/Domain/Order/OrderConstraints.php deleted file mode 100644 index 15dd0eb1..00000000 --- a/src/Core/Domain/Order/OrderConstraints.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order; - -class OrderConstraints -{ - /** - * Number of products that are displayed in order preview - */ - public const PRODUCTS_PREVIEW_LIMIT = 10; -} diff --git a/src/Core/Domain/Order/OrderDiscountType.php b/src/Core/Domain/Order/OrderDiscountType.php deleted file mode 100644 index 9454ca0b..00000000 --- a/src/Core/Domain/Order/OrderDiscountType.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order; - -/** - * Discount types that can be added to an order - */ -final class OrderDiscountType -{ - /** - * Discount type with percent (%) amount - */ - public const DISCOUNT_PERCENT = 'percent'; - - /** - * Discount type with money (EUR, USD & etc) amount - */ - public const DISCOUNT_AMOUNT = 'amount'; - - /** - * Discount type with free shipping - */ - public const FREE_SHIPPING = 'free_shipping'; -} diff --git a/src/Core/Domain/Order/OrderDocumentType.php b/src/Core/Domain/Order/OrderDocumentType.php deleted file mode 100644 index fc81aada..00000000 --- a/src/Core/Domain/Order/OrderDocumentType.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order; - -/** - * Used to identity which type of document the orders has - */ -class OrderDocumentType -{ - const CREDIT_SLIP = 'credit_slip'; - - const DELIVERY_SLIP = 'delivery_slip'; - - const INVOICE = 'invoice'; -} diff --git a/src/Core/Domain/Order/Payment/Command/AddPaymentCommand.php b/src/Core/Domain/Order/Payment/Command/AddPaymentCommand.php deleted file mode 100644 index a5591162..00000000 --- a/src/Core/Domain/Order/Payment/Command/AddPaymentCommand.php +++ /dev/null @@ -1,176 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Payment\Command; - -use DateTimeImmutable; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\CurrencyId; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\NegativePaymentAmountException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Adds payment for given order. - */ -class AddPaymentCommand -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @var DateTimeImmutable - */ - private $paymentDate; - - /** - * @var string - */ - private $paymentMethod; - - /** - * @var Number - */ - private $paymentAmount; - - /** - * @var CurrencyId - */ - private $paymentCurrencyId; - - /** - * @var string|null - */ - private $transactionId; - - /** - * @var null - */ - private $orderInvoiceId; - - /** - * @param int $orderId - * @param string $paymentDate - * @param string $paymentMethod - * @param string $paymentAmount - * @param int $paymentCurrencyId - * @param int|null $orderInvoiceId - * @param string|null $transactionId transaction ID, usually payment ID from payment gateway - */ - public function __construct( - int $orderId, - string $paymentDate, - string $paymentMethod, - string $paymentAmount, - int $paymentCurrencyId, - ?int $orderInvoiceId = null, - ?string $transactionId = null - ) { - $amount = new Number($paymentAmount); - $this->assertAmountIsPositive($amount); - $this->assertPaymentMethodIsGenericName($paymentMethod); - - $this->orderId = new OrderId($orderId); - $this->paymentDate = new DateTimeImmutable($paymentDate); - $this->paymentMethod = $paymentMethod; - $this->paymentAmount = $amount; - $this->paymentCurrencyId = new CurrencyId($paymentCurrencyId); - $this->orderInvoiceId = $orderInvoiceId; - $this->transactionId = $transactionId; - } - - /** - * @return OrderId - */ - public function getOrderId() - { - return $this->orderId; - } - - /** - * @return DateTimeImmutable - */ - public function getPaymentDate() - { - return $this->paymentDate; - } - - /** - * @return string - */ - public function getPaymentMethod() - { - return $this->paymentMethod; - } - - /** - * @return Number - */ - public function getPaymentAmount() - { - return $this->paymentAmount; - } - - /** - * @return CurrencyId - */ - public function getPaymentCurrencyId() - { - return $this->paymentCurrencyId; - } - - public function getOrderInvoiceId() - { - return $this->orderInvoiceId; - } - - /** - * @return string|null - */ - public function getPaymentTransactionId() - { - return $this->transactionId; - } - - /** - * @param string $paymentMethod - */ - private function assertPaymentMethodIsGenericName($paymentMethod) - { - if (empty($paymentMethod) || !preg_match('/^[^<>={}]*$/u', $paymentMethod)) { - throw new OrderConstraintException('The selected payment method is invalid.'); - } - } - - private function assertAmountIsPositive(Number $amount) - { - if ($amount->isNegative()) { - throw new NegativePaymentAmountException('The amount should be greater than 0.'); - } - } -} diff --git a/src/Core/Domain/Order/Payment/CommandHandler/AddPaymentHandlerInterface.php b/src/Core/Domain/Order/Payment/CommandHandler/AddPaymentHandlerInterface.php deleted file mode 100644 index 3f6a35af..00000000 --- a/src/Core/Domain/Order/Payment/CommandHandler/AddPaymentHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Payment\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Payment\Command\AddPaymentCommand; - -/** - * Interface for service that handles adding payment for order. - */ -interface AddPaymentHandlerInterface -{ - /** - * @param AddPaymentCommand $command - */ - public function handle(AddPaymentCommand $command); -} diff --git a/src/Core/Domain/Order/Payment/Exception/PaymentException.php b/src/Core/Domain/Order/Payment/Exception/PaymentException.php deleted file mode 100644 index 36e187ef..00000000 --- a/src/Core/Domain/Order/Payment/Exception/PaymentException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Payment\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; - -/** - * Is base exception for Payment subdomain - */ -class PaymentException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Payment/ValueObject/OrderPaymentId.php b/src/Core/Domain/Order/Payment/ValueObject/OrderPaymentId.php deleted file mode 100644 index 28c717da..00000000 --- a/src/Core/Domain/Order/Payment/ValueObject/OrderPaymentId.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Payment\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Order\Payment\Exception\PaymentException; - -/** - * Order payment identity - */ -class OrderPaymentId -{ - /** - * @var int - */ - private $orderPaymentId; - - /** - * @param int $orderPaymentId - */ - public function __construct($orderPaymentId) - { - if (!is_int($orderPaymentId) || 0 >= $orderPaymentId) { - throw new PaymentException('Invalid order payment id supplied.'); - } - - $this->orderPaymentId = $orderPaymentId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->orderPaymentId; - } -} diff --git a/src/Core/Domain/Order/Product/Command/AddProductToOrderCommand.php b/src/Core/Domain/Order/Product/Command/AddProductToOrderCommand.php deleted file mode 100644 index a89ae9fd..00000000 --- a/src/Core/Domain/Order/Product/Command/AddProductToOrderCommand.php +++ /dev/null @@ -1,271 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Product\Command; - -use InvalidArgumentException; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidAmountException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidProductQuantityException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; -use PrestaShop\PrestaShop\Core\Domain\Product\Combination\ValueObject\CombinationId; -use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; - -/** - * Adds product to an existing order. - */ -class AddProductToOrderCommand -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @var ProductId - */ - private $productId; - - /** - * @var CombinationId|null - */ - private $combinationId; - - /** - * @var Number - */ - private $productPriceTaxIncluded; - - /** - * @var Number - */ - private $productPriceTaxExcluded; - - /** - * @var int - */ - private $productQuantity; - - /** - * @var int|null invoice id or null if new invoice should be created - */ - private $orderInvoiceId; - - /** - * @var bool|null bool if product is being added using new invoice - */ - private $hasFreeShipping; - - /** - * Add product to an order with new invoice. It applies to orders that were already paid and waiting for payment. - * - * @param int $orderId - * @param int $productId - * @param int $combinationId - * @param string $productPriceTaxIncluded - * @param string $productPriceTaxExcluded - * @param int $productQuantity - * @param bool|null $hasFreeShipping - * - * @return self - * - * @throws InvalidProductQuantityException - * @throws InvalidAmountException - * @throws OrderException - */ - public static function withNewInvoice( - int $orderId, - int $productId, - int $combinationId, - string $productPriceTaxIncluded, - string $productPriceTaxExcluded, - int $productQuantity, - ?bool $hasFreeShipping = null - ) { - $command = new self( - $orderId, - $productId, - $combinationId, - $productPriceTaxIncluded, - $productPriceTaxExcluded, - $productQuantity - ); - - $command->hasFreeShipping = $hasFreeShipping; - - return $command; - } - - /** - * Add product to an order using existing invoice. It applies only for orders that were not yet paid. - * - * @param int $orderId - * @param int $orderInvoiceId - * @param int $productId - * @param int $combinationId - * @param string $productPriceTaxIncluded - * @param string $productPriceTaxExcluded - * @param int $productQuantity - * - * @return self - * - * @throws InvalidProductQuantityException - * @throws InvalidAmountException - * @throws OrderException - */ - public static function toExistingInvoice( - int $orderId, - int $orderInvoiceId, - int $productId, - int $combinationId, - string $productPriceTaxIncluded, - string $productPriceTaxExcluded, - int $productQuantity - ) { - $command = new self( - $orderId, - $productId, - $combinationId, - $productPriceTaxIncluded, - $productPriceTaxExcluded, - $productQuantity - ); - - $command->orderInvoiceId = $orderInvoiceId; - - return $command; - } - - /** - * @param int $orderId - * @param int $productId - * @param int $combinationId - * @param string $productPriceTaxIncluded - * @param string $productPriceTaxExcluded - * @param int $productQuantity - * - * @throws InvalidProductQuantityException - * @throws InvalidAmountException - * @throws OrderException - */ - private function __construct( - int $orderId, - int $productId, - int $combinationId, - string $productPriceTaxIncluded, - string $productPriceTaxExcluded, - int $productQuantity - ) { - $this->orderId = new OrderId($orderId); - $this->productId = new ProductId($productId); - $this->combinationId = !empty($combinationId) ? new CombinationId($combinationId) : null; - try { - $this->productPriceTaxIncluded = new Number($productPriceTaxIncluded); - $this->productPriceTaxExcluded = new Number($productPriceTaxExcluded); - } catch (InvalidArgumentException $e) { - throw new InvalidAmountException(); - } - $this->setProductQuantity($productQuantity); - } - - /** - * @return OrderId - */ - public function getOrderId(): OrderId - { - return $this->orderId; - } - - /** - * @return ProductId - */ - public function getProductId(): ProductId - { - return $this->productId; - } - - /** - * @return CombinationId|null - */ - public function getCombinationId(): ?CombinationId - { - return $this->combinationId; - } - - /** - * @return Number - */ - public function getProductPriceTaxIncluded(): Number - { - return $this->productPriceTaxIncluded; - } - - /** - * @return Number - */ - public function getProductPriceTaxExcluded(): Number - { - return $this->productPriceTaxExcluded; - } - - /** - * @return int - */ - public function getProductQuantity(): int - { - return $this->productQuantity; - } - - /** - * @return int|null - */ - public function getOrderInvoiceId(): ?int - { - return $this->orderInvoiceId; - } - - /** - * @return bool|null - */ - public function hasFreeShipping(): ?bool - { - return $this->hasFreeShipping; - } - - /** - * @param int $productQuantity - * - * @throws InvalidProductQuantityException - */ - private function setProductQuantity(int $productQuantity): void - { - if ($productQuantity <= 0) { - throw new InvalidProductQuantityException('When adding a product quantity must be strictly positive'); - } - $this->productQuantity = $productQuantity; - } -} diff --git a/src/Core/Domain/Order/Product/Command/DeleteProductFromOrderCommand.php b/src/Core/Domain/Order/Product/Command/DeleteProductFromOrderCommand.php deleted file mode 100644 index 4a14f558..00000000 --- a/src/Core/Domain/Order/Product/Command/DeleteProductFromOrderCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Product\Command; - -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Deletes product from given order. - */ -class DeleteProductFromOrderCommand -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @var int - */ - private $orderDetailId; - - /** - * @param int $orderId - * @param int $orderDetailId - */ - public function __construct($orderId, $orderDetailId) - { - $this->orderId = new OrderId($orderId); - $this->orderDetailId = $orderDetailId; - } - - /** - * @return OrderId - */ - public function getOrderId() - { - return $this->orderId; - } - - /** - * @return int - */ - public function getOrderDetailId() - { - return $this->orderDetailId; - } -} diff --git a/src/Core/Domain/Order/Product/Command/UpdateProductInOrderCommand.php b/src/Core/Domain/Order/Product/Command/UpdateProductInOrderCommand.php deleted file mode 100644 index eb573273..00000000 --- a/src/Core/Domain/Order/Product/Command/UpdateProductInOrderCommand.php +++ /dev/null @@ -1,158 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Product\Command; - -use InvalidArgumentException; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidAmountException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidProductQuantityException; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -/** - * Updates product in given order. - */ -class UpdateProductInOrderCommand -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @var int - */ - private $orderDetailId; - - /** - * @var Number - */ - private $priceTaxIncluded; - - /** - * @var Number - */ - private $priceTaxExcluded; - - /** - * @var int - */ - private $quantity; - - /** - * @var int|null - */ - private $orderInvoiceId; - - /** - * @param int $orderId - * @param int $orderDetailId - * @param string $priceTaxIncluded - * @param string $priceTaxExcluded - * @param int $quantity - * @param int|null $orderInvoiceId - */ - public function __construct( - int $orderId, - int $orderDetailId, - string $priceTaxIncluded, - string $priceTaxExcluded, - int $quantity, - ?int $orderInvoiceId = null - ) { - $this->orderId = new OrderId($orderId); - $this->orderDetailId = $orderDetailId; - try { - $this->priceTaxIncluded = new Number($priceTaxIncluded); - $this->priceTaxExcluded = new Number($priceTaxExcluded); - } catch (InvalidArgumentException $e) { - throw new InvalidAmountException(); - } - $this->setQuantity($quantity); - $this->orderInvoiceId = $orderInvoiceId; - } - - /** - * @return OrderId - */ - public function getOrderId() - { - return $this->orderId; - } - - /** - * @return int - */ - public function getOrderDetailId() - { - return $this->orderDetailId; - } - - /** - * @return Number - */ - public function getPriceTaxIncluded() - { - return $this->priceTaxIncluded; - } - - /** - * @return Number - */ - public function getPriceTaxExcluded() - { - return $this->priceTaxExcluded; - } - - /** - * @return int - */ - public function getQuantity() - { - return $this->quantity; - } - - /** - * @return int|null - */ - public function getOrderInvoiceId() - { - return $this->orderInvoiceId; - } - - /** - * @param int $quantity - * - * @throws InvalidProductQuantityException - */ - private function setQuantity(int $quantity): void - { - if ($quantity <= 0) { - throw new InvalidProductQuantityException('When adding a product quantity must be strictly positive'); - } - $this->quantity = $quantity; - } -} diff --git a/src/Core/Domain/Order/Product/CommandHandler/AddProductToOrderHandlerInterface.php b/src/Core/Domain/Order/Product/CommandHandler/AddProductToOrderHandlerInterface.php deleted file mode 100644 index dbfa74cb..00000000 --- a/src/Core/Domain/Order/Product/CommandHandler/AddProductToOrderHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Product\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Product\Command\AddProductToOrderCommand; - -/** - * Interface for service that handles adding product to an exiting order. - */ -interface AddProductToOrderHandlerInterface -{ - /** - * @param AddProductToOrderCommand $command - */ - public function handle(AddProductToOrderCommand $command); -} diff --git a/src/Core/Domain/Order/Product/CommandHandler/DeleteProductFromOrderHandlerInterface.php b/src/Core/Domain/Order/Product/CommandHandler/DeleteProductFromOrderHandlerInterface.php deleted file mode 100644 index 312c81be..00000000 --- a/src/Core/Domain/Order/Product/CommandHandler/DeleteProductFromOrderHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Product\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Product\Command\DeleteProductFromOrderCommand; - -/** - * Interface for service that handles deleting product from order. - */ -interface DeleteProductFromOrderHandlerInterface -{ - /** - * @param DeleteProductFromOrderCommand $command - */ - public function handle(DeleteProductFromOrderCommand $command); -} diff --git a/src/Core/Domain/Order/Product/CommandHandler/UpdateProductInOrderHandlerInterface.php b/src/Core/Domain/Order/Product/CommandHandler/UpdateProductInOrderHandlerInterface.php deleted file mode 100644 index 4baf585c..00000000 --- a/src/Core/Domain/Order/Product/CommandHandler/UpdateProductInOrderHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Product\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Product\Command\UpdateProductInOrderCommand; - -/** - * Interface for service that updates product in given order. - */ -interface UpdateProductInOrderHandlerInterface -{ - /** - * @param UpdateProductInOrderCommand $command - */ - public function handle(UpdateProductInOrderCommand $command); -} diff --git a/src/Core/Domain/Order/Product/Exception/ProductException.php b/src/Core/Domain/Order/Product/Exception/ProductException.php deleted file mode 100644 index 3cdd5f08..00000000 --- a/src/Core/Domain/Order/Product/Exception/ProductException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Product\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; - -/** - * Base exception for Order/Product subdomain - */ -class ProductException extends OrderException -{ -} diff --git a/src/Core/Domain/Order/Query/GetOrderForViewing.php b/src/Core/Domain/Order/Query/GetOrderForViewing.php deleted file mode 100644 index 61f6763b..00000000 --- a/src/Core/Domain/Order/Query/GetOrderForViewing.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Query; - -use PrestaShop\PrestaShop\Core\Domain\Exception\InvalidSortingException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\QuerySorting; - -/** - * Get order for view in Back Office - */ -class GetOrderForViewing -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @var QuerySorting - */ - private $productsSorting; - - /** - * @param int $orderId - * @param string $productsSorting - * - * @throws OrderException - * @throws InvalidSortingException - */ - public function __construct(int $orderId, string $productsSorting = QuerySorting::ASC) - { - $this->orderId = new OrderId($orderId); - $this->productsSorting = new QuerySorting($productsSorting); - } - - /** - * @return OrderId - */ - public function getOrderId(): OrderId - { - return $this->orderId; - } - - /** - * @return QuerySorting - */ - public function getProductsSorting(): QuerySorting - { - return $this->productsSorting; - } -} diff --git a/src/Core/Domain/Order/Query/GetOrderPreview.php b/src/Core/Domain/Order/Query/GetOrderPreview.php deleted file mode 100644 index 29a1b9cf..00000000 --- a/src/Core/Domain/Order/Query/GetOrderPreview.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Query; - -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; - -class GetOrderPreview -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @param int $orderId - */ - public function __construct(int $orderId) - { - $this->orderId = new OrderId($orderId); - } - - /** - * @return OrderId - */ - public function getOrderId(): OrderId - { - return $this->orderId; - } -} diff --git a/src/Core/Domain/Order/Query/GetOrderProductsForViewing.php b/src/Core/Domain/Order/Query/GetOrderProductsForViewing.php deleted file mode 100644 index 94460a3b..00000000 --- a/src/Core/Domain/Order/Query/GetOrderProductsForViewing.php +++ /dev/null @@ -1,140 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Query; - -use PrestaShop\PrestaShop\Core\Domain\Exception\InvalidSortingException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\QuerySorting; - -/** - * Query for paginated order products - */ -class GetOrderProductsForViewing -{ - /** - * @var OrderId - */ - private $orderId; - - /** - * @var int|null - */ - private $offset; - - /** - * @var @var null|int - */ - private $limit; - - /** - * @var QuerySorting - */ - private $productsSorting; - - /** - * Builds query for paginated results - * - * @param int $orderId - * @param int $offset - * @param int $limit - * @param string $productsSorting - * - * @return GetOrderProductsForViewing - * - * @throws OrderException - * @throws InvalidSortingException - */ - public static function paginated( - int $orderId, - int $offset, - int $limit, - string $productsSorting = QuerySorting::ASC - ) { - $query = new self(); - - $query->orderId = new OrderId($orderId); - $query->productsSorting = new QuerySorting($productsSorting); - $query->offset = $offset; - $query->limit = $limit; - - return $query; - } - - /** - * Builds query for getting all results - * - * @param int $orderId - * @param string $productsSorting - * - * @return GetOrderProductsForViewing - * - * @throws OrderException - * @throws InvalidSortingException - */ - public static function all(int $orderId, string $productsSorting = QuerySorting::ASC) - { - $query = new self(); - $query->orderId = new OrderId($orderId); - $query->productsSorting = new QuerySorting($productsSorting); - - return $query; - } - - /** - * @return OrderId - */ - public function getOrderId(): OrderId - { - return $this->orderId; - } - - /** - * @return int|null - */ - public function getOffset(): ?int - { - return $this->offset; - } - - /** - * @return int|null - */ - public function getLimit(): ?int - { - return $this->limit; - } - - /** - * @return QuerySorting - */ - public function getProductsSorting(): QuerySorting - { - return $this->productsSorting; - } -} diff --git a/src/Core/Domain/Order/QueryHandler/GetOrderForViewingHandlerInterface.php b/src/Core/Domain/Order/QueryHandler/GetOrderForViewingHandlerInterface.php deleted file mode 100644 index 74d17756..00000000 --- a/src/Core/Domain/Order/QueryHandler/GetOrderForViewingHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Query\GetOrderForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderForViewing; - -interface GetOrderForViewingHandlerInterface -{ - /** - * @param GetOrderForViewing $query - * - * @return OrderForViewing - */ - public function handle(GetOrderForViewing $query): OrderForViewing; -} diff --git a/src/Core/Domain/Order/QueryHandler/GetOrderPreviewHandlerInterface.php b/src/Core/Domain/Order/QueryHandler/GetOrderPreviewHandlerInterface.php deleted file mode 100644 index 3a279377..00000000 --- a/src/Core/Domain/Order/QueryHandler/GetOrderPreviewHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Query\GetOrderPreview; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderPreview; - -/** - * Defines contract for getOrderPreview query handler - */ -interface GetOrderPreviewHandlerInterface -{ - /** - * @param GetOrderPreview $query - * - * @return OrderPreview - */ - public function handle(GetOrderPreview $query): OrderPreview; -} diff --git a/src/Core/Domain/Order/QueryHandler/GetOrderProductsForViewingHandlerInterface.php b/src/Core/Domain/Order/QueryHandler/GetOrderProductsForViewingHandlerInterface.php deleted file mode 100644 index b76a6297..00000000 --- a/src/Core/Domain/Order/QueryHandler/GetOrderProductsForViewingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Order\Query\GetOrderProductsForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderProductsForViewing; - -/** - * Defines contract for GetOrderProductsForViewing query handler - */ -interface GetOrderProductsForViewingHandlerInterface -{ - /** - * @param GetOrderProductsForViewing $query - * - * @return OrderProductsForViewing - */ - public function handle(GetOrderProductsForViewing $query); -} diff --git a/src/Core/Domain/Order/QueryResult/LinkedOrderForViewing.php b/src/Core/Domain/Order/QueryResult/LinkedOrderForViewing.php deleted file mode 100644 index 6ea749e9..00000000 --- a/src/Core/Domain/Order/QueryResult/LinkedOrderForViewing.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -/** - * Used in order page view to display 'linked orders': orders linked - * to the order being displayed - * - * Two orders are linked if they are the result of an Order Split - */ -class LinkedOrderForViewing -{ - /** - * @var int - */ - private $orderId; - - /** - * @var string - */ - private $statusName; - - /** - * @var string - */ - private $amount; - - /** - * @param int $orderId - * @param string $statusName - * @param string $amount - */ - public function __construct(int $orderId, string $statusName, string $amount) - { - $this->orderId = $orderId; - $this->statusName = $statusName; - $this->amount = $amount; - } - - /** - * @return int - */ - public function getOrderId(): int - { - return $this->orderId; - } - - /** - * @return string - */ - public function getStatusName(): string - { - return $this->statusName; - } - - /** - * @return string - */ - public function getAmount(): string - { - return $this->amount; - } -} diff --git a/src/Core/Domain/Order/QueryResult/LinkedOrdersForViewing.php b/src/Core/Domain/Order/QueryResult/LinkedOrdersForViewing.php deleted file mode 100644 index 018b7fb8..00000000 --- a/src/Core/Domain/Order/QueryResult/LinkedOrdersForViewing.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -class LinkedOrdersForViewing -{ - /** @var LinkedOrderForViewing[] */ - private $linkedOrders = []; - - /** - * @param LinkedOrderForViewing[] $linkedOrders - */ - public function __construct(array $linkedOrders) - { - foreach ($linkedOrders as $order) { - $this->addLinkedOrder($order); - } - } - - /** - * @return LinkedOrderForViewing[] - */ - public function getLinkedOrders(): array - { - return $this->linkedOrders; - } - - /** - * @param LinkedOrderForViewing $order - */ - private function addLinkedOrder(LinkedOrderForViewing $order): void - { - $this->linkedOrders[] = $order; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderCarrierForViewing.php b/src/Core/Domain/Order/QueryResult/OrderCarrierForViewing.php deleted file mode 100644 index 90e3e862..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderCarrierForViewing.php +++ /dev/null @@ -1,182 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -use DateTimeImmutable; - -class OrderCarrierForViewing -{ - /** - * @var int - */ - private $orderCarrierId; - - /** - * @var DateTimeImmutable - */ - private $date; - - /** - * @var string - */ - private $name; - - /** - * @var int - */ - private $carrierId; - - /** - * @var string - */ - private $price; - - /** - * @var string|null - */ - private $trackingUrl; - - /** - * @var string|null - */ - private $trackingNumber; - - /** - * @var bool - */ - private $canEdit; - - /** - * @var string - */ - private $weight; - - /** - * @param int $orderCarrierId - * @param DateTimeImmutable $date - * @param string $name Carrier name or null in case of virtual order - * @param string $weight - * @param int $carrierId - * @param string $price Price or null in case of virtual order - * @param string|null $trackingUrl - * @param string|null $trackingNumber - * @param bool $canEdit - */ - public function __construct( - int $orderCarrierId, - DateTimeImmutable $date, - ?string $name, - string $weight, - int $carrierId, - ?string $price, - ?string $trackingUrl, - ?string $trackingNumber, - bool $canEdit - ) { - $this->orderCarrierId = $orderCarrierId; - $this->date = $date; - $this->name = $name; - $this->carrierId = $carrierId; - $this->price = $price; - $this->trackingUrl = $trackingUrl; - $this->trackingNumber = $trackingNumber; - $this->canEdit = $canEdit; - $this->weight = $weight; - } - - /** - * @return int - */ - public function getOrderCarrierId(): int - { - return $this->orderCarrierId; - } - - /** - * @return DateTimeImmutable - */ - public function getDate(): DateTimeImmutable - { - return $this->date; - } - - /** - * @return string - */ - public function getName(): ?string - { - return $this->name; - } - - /** - * @return int - */ - public function getCarrierId(): int - { - return $this->carrierId; - } - - /** - * @return string - */ - public function getPrice(): ?string - { - return $this->price; - } - - /** - * @return string|null - */ - public function getTrackingUrl(): ?string - { - return $this->trackingUrl; - } - - /** - * @return string|null - */ - public function getTrackingNumber(): ?string - { - return $this->trackingNumber; - } - - /** - * @return bool - */ - public function canEdit(): bool - { - return $this->canEdit; - } - - /** - * @return string - */ - public function getWeight(): string - { - return $this->weight; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderCustomerForViewing.php b/src/Core/Domain/Order/QueryResult/OrderCustomerForViewing.php deleted file mode 100644 index debb41ff..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderCustomerForViewing.php +++ /dev/null @@ -1,198 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -use DateTimeImmutable; - -class OrderCustomerForViewing -{ - /** - * @var int - */ - private $id; - - /** - * @var string - */ - private $firstName; - - /** - * @var string Gender name - */ - private $lastName; - - /** - * @var string - */ - private $gender; - - /** - * @var string - */ - private $email; - - /** - * @var DateTimeImmutable - */ - private $accountRegistrationDate; - - /** - * @var string Formatted price with currency - */ - private $totalSpentSinceRegistration; - - /** - * @var int - */ - private $validOrdersPlaced; - - /** - * @var string - */ - private $privateNote; - - /** - * @var bool - */ - private $isGuest; - - /** - * @param int $id - * @param string $firstName - * @param string $lastName - * @param string $gender - * @param string $email - * @param DateTimeImmutable $accountRegistrationDate - * @param string $totalSpentSinceRegistration - * @param int $validOrdersPlaced - * @param string|null $privateNote - * @param bool $isGuest - */ - public function __construct( - int $id, - string $firstName, - string $lastName, - string $gender, - string $email, - DateTimeImmutable $accountRegistrationDate, - string $totalSpentSinceRegistration, - int $validOrdersPlaced, - ?string $privateNote, - bool $isGuest - ) { - $this->id = $id; - $this->firstName = $firstName; - $this->lastName = $lastName; - $this->gender = $gender; - $this->email = $email; - $this->accountRegistrationDate = $accountRegistrationDate; - $this->totalSpentSinceRegistration = $totalSpentSinceRegistration; - $this->validOrdersPlaced = $validOrdersPlaced; - $this->privateNote = $privateNote; - $this->isGuest = $isGuest; - } - - /** - * @return int - */ - public function getId(): int - { - return $this->id; - } - - /** - * @return string - */ - public function getFirstName(): string - { - return $this->firstName; - } - - /** - * @return string - */ - public function getLastName(): string - { - return $this->lastName; - } - - /** - * @return string - */ - public function getGender(): string - { - return $this->gender; - } - - /** - * @return string - */ - public function getEmail(): string - { - return $this->email; - } - - /** - * @return DateTimeImmutable - */ - public function getAccountRegistrationDate(): DateTimeImmutable - { - return $this->accountRegistrationDate; - } - - /** - * @return string - */ - public function getTotalSpentSinceRegistration(): string - { - return $this->totalSpentSinceRegistration; - } - - /** - * @return int - */ - public function getValidOrdersPlaced(): int - { - return $this->validOrdersPlaced; - } - - /** - * @return string|null - */ - public function getPrivateNote(): ?string - { - return $this->privateNote; - } - - /** - * @return bool - */ - public function isGuest(): bool - { - return $this->isGuest; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderDiscountForViewing.php b/src/Core/Domain/Order/QueryResult/OrderDiscountForViewing.php deleted file mode 100644 index 7dc04906..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderDiscountForViewing.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -use PrestaShop\Decimal\Number; - -class OrderDiscountForViewing -{ - /** - * @var int - */ - private $orderCartRuleId; - - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $amountFormatted; - - /** - * @var Number - */ - private $amountRaw; - - public function __construct( - int $orderCartRuleId, - string $name, - Number $amountRaw, - string $amountFormatted - ) { - $this->orderCartRuleId = $orderCartRuleId; - $this->name = $name; - $this->amountFormatted = $amountFormatted; - $this->amountRaw = $amountRaw; - } - - /** - * @return int - */ - public function getOrderCartRuleId(): int - { - return $this->orderCartRuleId; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return string - */ - public function getAmountFormatted(): string - { - return $this->amountFormatted; - } - - /** - * @return Number - */ - public function getAmountRaw(): Number - { - return $this->amountRaw; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderDiscountsForViewing.php b/src/Core/Domain/Order/QueryResult/OrderDiscountsForViewing.php deleted file mode 100644 index 79b022d3..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderDiscountsForViewing.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -class OrderDiscountsForViewing -{ - /** @var OrderDiscountForViewing[] */ - private $discounts = []; - - /** - * @param OrderDiscountForViewing[] $discounts - */ - public function __construct(array $discounts) - { - foreach ($discounts as $discount) { - $this->addDiscount($discount); - } - } - - /** - * @return OrderDiscountForViewing[] - */ - public function getDiscounts(): array - { - return $this->discounts; - } - - /** - * @param OrderDiscountForViewing $discount - */ - private function addDiscount(OrderDiscountForViewing $discount): void - { - $this->discounts[] = $discount; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderDocumentForViewing.php b/src/Core/Domain/Order/QueryResult/OrderDocumentForViewing.php deleted file mode 100644 index 438b58ad..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderDocumentForViewing.php +++ /dev/null @@ -1,166 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -use DateTimeImmutable; - -class OrderDocumentForViewing -{ - /** - * @var int - */ - private $id; - - /** - * @var string - */ - private $type; - - /** - * @var DateTimeImmutable - */ - private $createdAt; - - /** - * @var string - */ - private $referenceNumber; - - /** - * When eligible, document amount as a number - * - * @var float|null - */ - private $numericalAmount; - - /** - * When eligible, document amount as a string, ready to be displayed - * - * @var string|null - */ - private $amount; - - /** - * @var string|null - */ - private $amountMismatch; - - /** - * @var string - */ - private $note; - - /** - * @var bool - */ - private $isAddPaymentAllowed; - - public function __construct( - int $id, - string $type, - DateTimeImmutable $createdAt, - string $referenceNumber, - ?float $numericalAmount, - ?string $amount, - ?string $amountMismatch, - ?string $note, - bool $isAddPaymentAllowed - ) { - $this->id = $id; - $this->type = $type; - $this->createdAt = $createdAt; - $this->referenceNumber = $referenceNumber; - $this->numericalAmount = $numericalAmount; - $this->amount = $amount; - $this->amountMismatch = $amountMismatch; - $this->note = $note; - $this->isAddPaymentAllowed = $isAddPaymentAllowed; - } - - public function getId(): int - { - return $this->id; - } - - public function getType(): string - { - return $this->type; - } - - public function getCreatedAt(): DateTimeImmutable - { - return $this->createdAt; - } - - /** - * @return string - */ - public function getReferenceNumber(): string - { - return $this->referenceNumber; - } - - /** - * @return string|null - */ - public function getAmount(): ?string - { - return $this->amount; - } - - /** - * @return string|null - */ - public function getAmountMismatch(): ?string - { - return $this->amountMismatch; - } - - /** - * @return string - */ - public function getNote(): ?string - { - return $this->note; - } - - /** - * @return bool - */ - public function isAddPaymentAllowed(): bool - { - return $this->isAddPaymentAllowed; - } - - /** - * @return float|null - */ - public function getNumericalAmount(): ?float - { - return $this->numericalAmount; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderDocumentsForViewing.php b/src/Core/Domain/Order/QueryResult/OrderDocumentsForViewing.php deleted file mode 100644 index d64b56c6..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderDocumentsForViewing.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -class OrderDocumentsForViewing -{ - /** - * @var OrderDocumentForViewing[] - */ - private $documents = []; - - /** - * @var bool - */ - private $canGenerateInvoice; - - /** - * @var bool - */ - private $canGenerateDeliverySlip; - - /** - * @param bool $canGenerateInvoice - * @param bool $canGenerateDeliverySlip - * @param OrderDocumentForViewing[] $documents - */ - public function __construct(bool $canGenerateInvoice, bool $canGenerateDeliverySlip, array $documents) - { - foreach ($documents as $document) { - $this->add($document); - } - - $this->canGenerateInvoice = $canGenerateInvoice; - $this->canGenerateDeliverySlip = $canGenerateDeliverySlip; - } - - /** - * @return OrderDocumentForViewing[] - */ - public function getDocuments(): array - { - return $this->documents; - } - - /** - * @return bool - */ - public function canGenerateInvoice(): bool - { - return $this->canGenerateInvoice; - } - - /** - * @return bool - */ - public function canGenerateDeliverySlip(): bool - { - return $this->canGenerateDeliverySlip; - } - - private function add(OrderDocumentForViewing $document): void - { - $this->documents[] = $document; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderForViewing.php b/src/Core/Domain/Order/QueryResult/OrderForViewing.php deleted file mode 100644 index cd19d385..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderForViewing.php +++ /dev/null @@ -1,540 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -use DateTimeImmutable; - -/** - * Contains data about order for viewing - */ -class OrderForViewing -{ - /** - * @var int - */ - private $orderId; - - /** - * @var OrderCustomerForViewing - */ - private $customer; - - /** - * @var OrderShippingAddressForViewing - */ - private $shippingAddress; - - /** - * @var OrderInvoiceAddressForViewing - */ - private $invoiceAddress; - /** - * @var string - */ - private $reference; - - /** - * @var OrderProductsForViewing - */ - private $products; - - /** - * @var string - */ - private $taxMethod; - - /** - * @var OrderHistoryForViewing - */ - private $history; - - /** - * @var OrderDocumentsForViewing - */ - private $documents; - - /** - * @var OrderShippingForViewing - */ - private $shipping; - - /** - * @var OrderReturnsForViewing - */ - private $returns; - - /** - * @var OrderPaymentsForViewing - */ - private $payments; - - /** - * @var bool - */ - private $isValid; - - /** - * @var OrderMessagesForViewing - */ - private $messages; - - /** - * @var int - */ - private $currencyId; - - /** - * @var bool - */ - private $isDelivered; - - /** - * @var bool - */ - private $isShipped; - - /** - * @var OrderPricesForViewing - */ - private $prices; - - /** - * @var bool - */ - private $isTaxIncluded; - - /** - * @var bool - */ - private $hasBeenPaid; - - /** - * @var bool - */ - private $hasInvoice; - - /** - * @var OrderDiscountsForViewing - */ - private $discounts; - - /** - * @var LinkedOrdersForViewing - */ - private $linkedOrders; - - /** - * @var DateTimeImmutable - */ - private $createdAt; - - /** - * @var bool - */ - private $isVirtual; - - /** - * @var int - */ - private $carrierId; - - /** - * @var string - */ - private $carrierName; - - /** - * @var int - */ - private $shopId; - - /** - * @var int - */ - private $invoiceManagementIsEnabled; - - /** - * @var OrderSourcesForViewing - */ - private $sources; - - /** - * @param int $orderId - * @param int $currencyId - * @param int $carrierId - * @param string $carrierName - * @param int $shopId - * @param string $reference - * @param bool $isVirtual - * @param string $taxMethod - * @param bool $isTaxIncluded - * @param bool $isValid - * @param bool $hasBeenPaid - * @param bool $hasInvoice - * @param bool $isDelivered - * @param bool $isShipped - * @param bool $invoiceManagementIsEnabled - * @param DateTimeImmutable $createdAt - * @param OrderCustomerForViewing|null $customer - * @param OrderShippingAddressForViewing $shippingAddress - * @param OrderInvoiceAddressForViewing $invoiceAddress - * @param OrderProductsForViewing $products - * @param OrderHistoryForViewing $history - * @param OrderDocumentsForViewing $documents - * @param OrderShippingForViewing $shipping - * @param OrderReturnsForViewing $returns - * @param OrderPaymentsForViewing $payments - * @param OrderMessagesForViewing $messages - * @param OrderPricesForViewing $prices - * @param OrderDiscountsForViewing $discounts - * @param OrderSourcesForViewing $sources - * @param LinkedOrdersForViewing $linkedOrders - */ - public function __construct( - int $orderId, - int $currencyId, - int $carrierId, - string $carrierName, - int $shopId, - string $reference, - bool $isVirtual, - string $taxMethod, - bool $isTaxIncluded, - bool $isValid, - bool $hasBeenPaid, - bool $hasInvoice, - bool $isDelivered, - bool $isShipped, - bool $invoiceManagementIsEnabled, - DateTimeImmutable $createdAt, - ?OrderCustomerForViewing $customer, - OrderShippingAddressForViewing $shippingAddress, - OrderInvoiceAddressForViewing $invoiceAddress, - OrderProductsForViewing $products, - OrderHistoryForViewing $history, - OrderDocumentsForViewing $documents, - OrderShippingForViewing $shipping, - OrderReturnsForViewing $returns, - OrderPaymentsForViewing $payments, - OrderMessagesForViewing $messages, - OrderPricesForViewing $prices, - OrderDiscountsForViewing $discounts, - OrderSourcesForViewing $sources, - LinkedOrdersForViewing $linkedOrders - ) { - $this->reference = $reference; - $this->customer = $customer; - $this->shippingAddress = $shippingAddress; - $this->invoiceAddress = $invoiceAddress; - $this->products = $products; - $this->taxMethod = $taxMethod; - $this->history = $history; - $this->documents = $documents; - $this->shipping = $shipping; - $this->returns = $returns; - $this->payments = $payments; - $this->isValid = $isValid; - $this->messages = $messages; - $this->orderId = $orderId; - $this->currencyId = $currencyId; - $this->isDelivered = $isDelivered; - $this->isShipped = $isShipped; - $this->prices = $prices; - $this->isTaxIncluded = $isTaxIncluded; - $this->hasBeenPaid = $hasBeenPaid; - $this->hasInvoice = $hasInvoice; - $this->discounts = $discounts; - $this->createdAt = $createdAt; - $this->isVirtual = $isVirtual; - $this->carrierId = $carrierId; - $this->carrierName = $carrierName; - $this->shopId = $shopId; - $this->invoiceManagementIsEnabled = $invoiceManagementIsEnabled; - $this->sources = $sources; - $this->linkedOrders = $linkedOrders; - } - - /** - * @return int - */ - public function getId(): int - { - return $this->orderId; - } - - /** - * @return int - */ - public function getCurrencyId(): int - { - return $this->currencyId; - } - - /** - * @return int - */ - public function getCarrierId(): int - { - return $this->carrierId; - } - - public function getCarrierName(): string - { - return $this->carrierName; - } - - /** - * @return int - */ - public function getShopId(): int - { - return $this->shopId; - } - - /** - * @return string - */ - public function getReference(): string - { - return $this->reference; - } - - /** - * @return bool - */ - public function isValid(): bool - { - return $this->isValid; - } - - /** - * @return OrderCustomerForViewing|null - */ - public function getCustomer(): ?OrderCustomerForViewing - { - return $this->customer; - } - - /** - * @return OrderShippingAddressForViewing - */ - public function getShippingAddress(): OrderShippingAddressForViewing - { - return $this->shippingAddress; - } - - /** - * @return OrderInvoiceAddressForViewing - */ - public function getInvoiceAddress(): OrderInvoiceAddressForViewing - { - return $this->invoiceAddress; - } - - /** - * @return OrderProductsForViewing - */ - public function getProducts(): OrderProductsForViewing - { - return $this->products; - } - - /** - * @return string - */ - public function getTaxMethod(): string - { - return $this->taxMethod; - } - - /** - * @return OrderHistoryForViewing - */ - public function getHistory(): OrderHistoryForViewing - { - return $this->history; - } - - /** - * @return OrderDocumentsForViewing - */ - public function getDocuments(): OrderDocumentsForViewing - { - return $this->documents; - } - - /** - * @return OrderShippingForViewing - */ - public function getShipping(): OrderShippingForViewing - { - return $this->shipping; - } - - /** - * @return OrderReturnsForViewing - */ - public function getReturns(): OrderReturnsForViewing - { - return $this->returns; - } - - /** - * @return OrderPaymentsForViewing - */ - public function getPayments(): OrderPaymentsForViewing - { - return $this->payments; - } - - /** - * @return bool - */ - public function hasPayments(): bool - { - return count($this->payments->getPayments()) > 0; - } - - /** - * @return OrderMessagesForViewing - */ - public function getMessages(): OrderMessagesForViewing - { - return $this->messages; - } - - /** - * @return bool - */ - public function isDelivered(): bool - { - return $this->isDelivered; - } - - /** - * @return bool - */ - public function isShipped(): bool - { - return $this->isShipped; - } - - /** - * @return OrderPricesForViewing - */ - public function getPrices(): OrderPricesForViewing - { - return $this->prices; - } - - /** - * @return bool - */ - public function isTaxIncluded(): bool - { - return $this->isTaxIncluded; - } - - /** - * @return bool - */ - public function hasBeenPaid(): bool - { - return $this->hasBeenPaid; - } - - /** - * @return bool - */ - public function hasInvoice(): bool - { - return $this->hasInvoice; - } - - /** - * @return OrderDiscountsForViewing - */ - public function getDiscounts(): OrderDiscountsForViewing - { - return $this->discounts; - } - - /** - * @return LinkedOrdersForViewing - */ - public function getLinkedOrders(): LinkedOrdersForViewing - { - return $this->linkedOrders; - } - - /** - * @return DateTimeImmutable - */ - public function getCreatedAt(): DateTimeImmutable - { - return $this->createdAt; - } - - /** - * @return bool - */ - public function isVirtual(): bool - { - return $this->isVirtual; - } - - /** - * @return bool - */ - public function isInvoiceManagementIsEnabled(): bool - { - return $this->invoiceManagementIsEnabled; - } - - /** - * @return OrderSourcesForViewing - */ - public function getSources(): OrderSourcesForViewing - { - return $this->sources; - } - - /** - * @return bool - */ - public function isRefundable(): bool - { - /** @var OrderProductForViewing $product */ - foreach ($this->products->getProducts() as $product) { - if ($product->getQuantity() > $product->getQuantityRefunded()) { - return true; - } - } - - return $this->prices->getShippingRefundableAmountRaw()->isGreaterThanZero(); - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderHistoryForViewing.php b/src/Core/Domain/Order/QueryResult/OrderHistoryForViewing.php deleted file mode 100644 index 01c400e1..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderHistoryForViewing.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -class OrderHistoryForViewing -{ - /** - * @var OrderStatusForViewing[] - */ - private $statuses = []; - - /** - * @var int - */ - private $currentOrderStatusId; - - /** - * @param int $currentOrderStatusId - * @param OrderStatusForViewing[] $statuses - */ - public function __construct(int $currentOrderStatusId, array $statuses) - { - $this->currentOrderStatusId = $currentOrderStatusId; - - foreach ($statuses as $status) { - $this->add($status); - } - } - - /** - * @return OrderStatusForViewing[] - */ - public function getStatuses(): array - { - return $this->statuses; - } - - /** - * @return int - */ - public function getCurrentOrderStatusId(): int - { - return $this->currentOrderStatusId; - } - - /** - * @param OrderStatusForViewing $orderStatusForViewing - */ - private function add(OrderStatusForViewing $orderStatusForViewing): void - { - $this->statuses[] = $orderStatusForViewing; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderInvoiceAddressForViewing.php b/src/Core/Domain/Order/QueryResult/OrderInvoiceAddressForViewing.php deleted file mode 100644 index 045371bd..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderInvoiceAddressForViewing.php +++ /dev/null @@ -1,219 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -class OrderInvoiceAddressForViewing -{ - /** - * @var int - */ - private $addressId; - - /** - * @var string - */ - private $firstName; - - /** - * @var string - */ - private $lastName; - - /** - * @var string - */ - private $companyName; - /** - * @var string - */ - private $address1; - - /** - * @var string - */ - private $address2; - - /** - * @var string - */ - private $cityName; - - /** - * @var string - */ - private $stateName; - - /** - * @var string - */ - private $countryName; - - /** - * @var string - */ - private $postCode; - - /** - * @var string - */ - private $phoneNumber; - - /** - * @var string - */ - private $mobilePhoneNumber; - - /** - * @param int $addressId - * @param string $firstName - * @param string $lastName - * @param string $companyName - * @param string $address1 - * @param string $address2 - * @param string $stateName - * @param string $cityName - * @param string $countryName - * @param string $postCode - * @param string $phone - * @param string $phoneMobile - */ - public function __construct( - int $addressId, - string $firstName, - string $lastName, - string $companyName, - string $address1, - string $address2, - string $stateName, - string $cityName, - string $countryName, - string $postCode, - string $phone, - string $phoneMobile - ) { - $this->addressId = $addressId; - $this->firstName = $firstName; - $this->lastName = $lastName; - $this->companyName = $companyName; - $this->address1 = $address1; - $this->address2 = $address2; - $this->stateName = $stateName; - $this->cityName = $cityName; - $this->countryName = $countryName; - $this->postCode = $postCode; - $this->phoneNumber = $phone; - $this->mobilePhoneNumber = $phoneMobile; - } - - /** - * @return int - */ - public function getAddressId(): int - { - return $this->addressId; - } - - /** - * @return string - */ - public function getFullName(): string - { - return sprintf('%s %s', $this->firstName, $this->lastName); - } - - /** - * @return string - */ - public function getCompanyName(): string - { - return $this->companyName; - } - - /** - * @return string - */ - public function getAddress1(): string - { - return $this->address1; - } - - /** - * @return string - */ - public function getAddress2(): string - { - return $this->address2; - } - - /** - * @return string - */ - public function getCityName(): string - { - return $this->cityName; - } - - /** - * @return string - */ - public function getStateName(): string - { - return $this->stateName; - } - - /** - * @return string - */ - public function getCountryName(): string - { - return $this->countryName; - } - - /** - * @return string - */ - public function getPostCode(): string - { - return $this->postCode; - } - - /** - * @return string - */ - public function getPhoneNumber(): string - { - return $this->phoneNumber; - } - - /** - * @return string - */ - public function getMobilePhoneNumber(): string - { - return $this->mobilePhoneNumber; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderMessageDateForViewing.php b/src/Core/Domain/Order/QueryResult/OrderMessageDateForViewing.php deleted file mode 100644 index b813f5f9..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderMessageDateForViewing.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -use DateTimeImmutable; - -/** - * Used in order page view to display date in wanted format. - */ -class OrderMessageDateForViewing -{ - /** - * @var DateTimeImmutable - */ - private $date; - - /** - * @var string - */ - private $dateFormat; - - public function __construct(DateTimeImmutable $date, string $dateFormat) - { - $this->date = $date; - $this->dateFormat = $dateFormat; - } - - /** - * @return DateTimeImmutable - */ - public function getDate(): DateTimeImmutable - { - return $this->date; - } - - /** - * @return string - */ - public function getFormat(): string - { - return $this->date->format($this->dateFormat); - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderMessageForViewing.php b/src/Core/Domain/Order/QueryResult/OrderMessageForViewing.php deleted file mode 100644 index 2debeb8b..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderMessageForViewing.php +++ /dev/null @@ -1,196 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -use DateTimeImmutable; - -class OrderMessageForViewing -{ - /** - * @var int - */ - private $messageId; - - /** - * @var string - */ - private $message; - - /** - * @var DateTimeImmutable - */ - private $messageDate; - - /** - * @var string - */ - private $employeeFirstName; - - /** - * @var string - */ - private $employeeLastName; - - /** - * @var string - */ - private $customerFirstName; - - /** - * @var string - */ - private $customerLastName; - - /** - * @var int - */ - private $employeeId; - /** - * @var bool - */ - private $isPrivate; - /** - * @var bool - */ - private $isCurrentEmployeesMessage; - - /** - * @param int $messageId - * @param string $message - * @param DateTimeImmutable $messageDate - * @param int $employeeId - * @param bool $isCurrentEmployeesMessage - * @param string $employeeFirstName - * @param string $employeeLastName - * @param string $customerFirstName - * @param string $customerLastName - * @param bool $isPrivate - */ - public function __construct( - int $messageId, - string $message, - OrderMessageDateForViewing $messageDate, - int $employeeId, - bool $isCurrentEmployeesMessage, - ?string $employeeFirstName, - ?string $employeeLastName, - string $customerFirstName, - string $customerLastName, - bool $isPrivate - ) { - $this->messageId = $messageId; - $this->message = $message; - $this->messageDate = $messageDate; - $this->employeeFirstName = $employeeFirstName; - $this->employeeLastName = $employeeLastName; - $this->customerFirstName = $customerFirstName; - $this->customerLastName = $customerLastName; - $this->employeeId = $employeeId; - $this->isPrivate = $isPrivate; - $this->isCurrentEmployeesMessage = $isCurrentEmployeesMessage; - } - - /** - * @return int - */ - public function getMessageId(): int - { - return $this->messageId; - } - - /** - * @return string - */ - public function getMessage(): string - { - return $this->message; - } - - /** - * @return OrderMessageDateForViewing - */ - public function getMessageDate(): OrderMessageDateForViewing - { - return $this->messageDate; - } - - /** - * @return string - */ - public function getEmployeeFirstName(): ?string - { - return $this->employeeFirstName; - } - - /** - * @return string - */ - public function getEmployeeLastName(): ?string - { - return $this->employeeLastName; - } - - /** - * @return string - */ - public function getCustomerFirstName(): string - { - return $this->customerFirstName; - } - - /** - * @return string - */ - public function getCustomerLastName(): string - { - return $this->customerLastName; - } - - /** - * @return int - */ - public function getEmployeeId(): int - { - return $this->employeeId; - } - - /** - * @return bool - */ - public function isCurrentEmployeesMessage(): bool - { - return $this->isCurrentEmployeesMessage; - } - - /** - * @return bool - */ - public function isPrivate(): bool - { - return $this->isPrivate; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderMessagesForViewing.php b/src/Core/Domain/Order/QueryResult/OrderMessagesForViewing.php deleted file mode 100644 index b78d8d7c..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderMessagesForViewing.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -class OrderMessagesForViewing -{ - /** @var OrderMessageForViewing[] */ - private $messages = []; - - /** - * @var int - */ - private $total; - - /** - * @param OrderMessageForViewing[] $messages - * @param int $total - */ - public function __construct(array $messages, int $total) - { - foreach ($messages as $message) { - $this->add($message); - } - - $this->total = $total; - } - - /** - * @return OrderMessageForViewing[] - */ - public function getMessages(): array - { - return $this->messages; - } - - /** - * @return int - */ - public function getTotal(): int - { - return $this->total; - } - - /** - * @param OrderMessageForViewing $message - */ - private function add(OrderMessageForViewing $message): void - { - $this->messages[] = $message; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderPaymentForViewing.php b/src/Core/Domain/Order/QueryResult/OrderPaymentForViewing.php deleted file mode 100644 index 1aab0cec..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderPaymentForViewing.php +++ /dev/null @@ -1,198 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -use DateTimeImmutable; - -class OrderPaymentForViewing -{ - /** - * @var int - */ - private $paymentId; - - /** - * @var DateTimeImmutable - */ - private $date; - - /** - * @var string - */ - private $paymentMethod; - - /** - * @var string - */ - private $transactionId; - - /** - * @var string - */ - private $amount; - - /** - * @var string|null - */ - private $invoiceNumber; - - /** - * @var string - */ - private $cardNumber; - - /** - * @var string - */ - private $cardBrand; - - /** - * @var string - */ - private $cardExpiration; - - /** - * @var string - */ - private $cardHolder; - - /** - * @param int $paymentId - * @param DateTimeImmutable $date - * @param string $paymentMethod - * @param string $transactionId - * @param string $amount - * @param string|null $invoiceNumber - * @param string $cardNumber - * @param string $cardBrand - * @param string $cardExpiration - * @param string $cardHolder - */ - public function __construct( - int $paymentId, - DateTimeImmutable $date, - string $paymentMethod, - string $transactionId, - string $amount, - ?string $invoiceNumber, - string $cardNumber, - string $cardBrand, - string $cardExpiration, - string $cardHolder - ) { - $this->paymentId = $paymentId; - $this->date = $date; - $this->paymentMethod = $paymentMethod; - $this->transactionId = $transactionId; - $this->amount = $amount; - $this->invoiceNumber = $invoiceNumber; - $this->cardNumber = $cardNumber; - $this->cardBrand = $cardBrand; - $this->cardExpiration = $cardExpiration; - $this->cardHolder = $cardHolder; - } - - /** - * @return int - */ - public function getPaymentId(): int - { - return $this->paymentId; - } - - /** - * @return DateTimeImmutable - */ - public function getDate(): DateTimeImmutable - { - return $this->date; - } - - /** - * @return string - */ - public function getPaymentMethod(): string - { - return $this->paymentMethod; - } - - /** - * @return string - */ - public function getTransactionId(): string - { - return $this->transactionId; - } - - /** - * @return string - */ - public function getAmount(): string - { - return $this->amount; - } - - /** - * @return string|null - */ - public function getInvoiceNumber(): ?string - { - return $this->invoiceNumber; - } - - /** - * @return string - */ - public function getCardNumber(): string - { - return $this->cardNumber; - } - - /** - * @return string - */ - public function getCardBrand(): string - { - return $this->cardBrand; - } - - /** - * @return string - */ - public function getCardExpiration(): string - { - return $this->cardExpiration; - } - - /** - * @return string - */ - public function getCardHolder(): string - { - return $this->cardHolder; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderPaymentsForViewing.php b/src/Core/Domain/Order/QueryResult/OrderPaymentsForViewing.php deleted file mode 100644 index 7b1dd58d..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderPaymentsForViewing.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -class OrderPaymentsForViewing -{ - /** - * hint - collection would be better - * - * @var OrderPaymentForViewing[] - */ - private $payments = []; - - /** - * @var string|null - */ - private $amountToPay; - - /** - * @var string|null - */ - private $paidAmount; - - /** - * @var array - */ - private $paymentMismatchOrderIds; - - /** - * @param OrderPaymentForViewing[] $payments - * @param string|null $amountToPay - * @param string|null $paidAmount - * @param int[] $paymentMismatchOrderIds - */ - public function __construct( - array $payments, - ?string $amountToPay, - ?string $paidAmount, - array $paymentMismatchOrderIds - ) { - foreach ($payments as $payment) { - $this->add($payment); - } - - $this->amountToPay = $amountToPay; - $this->paidAmount = $paidAmount; - $this->paymentMismatchOrderIds = $paymentMismatchOrderIds; - } - - /** - * @return OrderPaymentForViewing[] - */ - public function getPayments(): array - { - return $this->payments; - } - - /** - * @return string|null - */ - public function getAmountToPay(): ?string - { - return $this->amountToPay; - } - - /** - * @return string|null - */ - public function getPaidAmount(): ?string - { - return $this->paidAmount; - } - - /** - * @return array - */ - public function getPaymentMismatchOrderIds(): array - { - return $this->paymentMismatchOrderIds; - } - - /** - * @param OrderPaymentForViewing $payment - */ - private function add(OrderPaymentForViewing $payment): void - { - $this->payments[] = $payment; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderPreview.php b/src/Core/Domain/Order/QueryResult/OrderPreview.php deleted file mode 100644 index df613989..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderPreview.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -/** - * DTO for order preview data - */ -class OrderPreview -{ - /** - * @var OrderPreviewInvoiceDetails - */ - private $invoiceDetails; - - /** - * @var OrderPreviewShippingDetails - */ - private $shippingDetails; - - /** - * @var OrderPreviewProductDetail[] - */ - private $productDetails; - - /** - * @var bool - */ - private $taxIncluded; - - /** - * @var bool - */ - private $isVirtual; - - /** - * @param OrderPreviewInvoiceDetails $invoiceDetails - * @param OrderPreviewShippingDetails $shippingDetails - * @param array $productDetails - * @param bool $isVirtual - * @param bool $taxIncluded - */ - public function __construct( - OrderPreviewInvoiceDetails $invoiceDetails, - OrderPreviewShippingDetails $shippingDetails, - array $productDetails, - bool $isVirtual, - bool $taxIncluded - ) { - $this->invoiceDetails = $invoiceDetails; - $this->shippingDetails = $shippingDetails; - $this->productDetails = $productDetails; - $this->taxIncluded = $taxIncluded; - $this->isVirtual = $isVirtual; - } - - /** - * @return OrderPreviewInvoiceDetails - */ - public function getInvoiceDetails(): OrderPreviewInvoiceDetails - { - return $this->invoiceDetails; - } - - /** - * @return OrderPreviewShippingDetails - */ - public function getShippingDetails(): OrderPreviewShippingDetails - { - return $this->shippingDetails; - } - - /** - * @return OrderPreviewProductDetail[] - */ - public function getProductDetails(): array - { - return $this->productDetails; - } - - /** - * @return bool - */ - public function isTaxIncluded(): bool - { - return $this->taxIncluded; - } - - /** - * @return bool - */ - public function isVirtual(): bool - { - return $this->isVirtual; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderPreviewInvoiceDetails.php b/src/Core/Domain/Order/QueryResult/OrderPreviewInvoiceDetails.php deleted file mode 100644 index 062c7b3f..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderPreviewInvoiceDetails.php +++ /dev/null @@ -1,233 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -/** - * DTO for order invoice details - */ -class OrderPreviewInvoiceDetails -{ - /** - * @var string - */ - private $firstName; - - /** - * @var string - */ - private $lastName; - - /** - * @var string - */ - private $address1; - - /** - * @var string - */ - private $address2; - - /** - * @var string - */ - private $city; - - /** - * @var string - */ - private $country; - - /** - * @var string - */ - private $email; - - /** - * @var string - */ - private $phone; - - /** - * @var string - */ - private $company; - - /** - * @var string|null - */ - private $vatNumber; - - /** - * @var string - */ - private $postalCode; - - /** - * @var string|null - */ - private $stateName; - - /** - * InvoiceDetails constructor. - * - * @param string $firstName - * @param string $lastName - * @param string $company - * @param string|null $vatNumber - * @param string $address1 - * @param string $address2 - * @param string $city - * @param string $postalCode - * @param string|null $stateName - * @param string $country - * @param string|null $email - * @param string $phone - */ - public function __construct( - string $firstName, - string $lastName, - ?string $company, - ?string $vatNumber, - string $address1, - string $address2, - string $city, - string $postalCode, - ?string $stateName, - string $country, - ?string $email, - string $phone - ) { - $this->firstName = $firstName; - $this->lastName = $lastName; - $this->address1 = $address1; - $this->address2 = $address2; - $this->city = $city; - $this->country = $country; - $this->email = $email; - $this->phone = $phone; - $this->company = $company; - $this->vatNumber = $vatNumber; - $this->postalCode = $postalCode; - $this->stateName = $stateName; - } - - /** - * @return string - */ - public function getFirstName(): string - { - return $this->firstName; - } - - /** - * @return string - */ - public function getLastName(): string - { - return $this->lastName; - } - - /** - * @return string - */ - public function getAddress1(): string - { - return $this->address1; - } - - /** - * @return string - */ - public function getCity(): string - { - return $this->city; - } - - /** - * @return string - */ - public function getCountry(): string - { - return $this->country; - } - - /** - * @return string|null - */ - public function getEmail(): ?string - { - return $this->email; - } - - /** - * @return string - */ - public function getPhone(): string - { - return $this->phone; - } - - /** - * @return string - */ - public function getAddress2(): string - { - return $this->address2; - } - - /** - * @return string - */ - public function getCompany(): string - { - return $this->company; - } - - /** - * @return string|null - */ - public function getVatNumber(): ?string - { - return $this->vatNumber; - } - - /** - * @return string - */ - public function getPostalCode(): string - { - return $this->postalCode; - } - - /** - * @return string|null - */ - public function getStateName(): ?string - { - return $this->stateName; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderPreviewProductDetail.php b/src/Core/Domain/Order/QueryResult/OrderPreviewProductDetail.php deleted file mode 100644 index 594597ab..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderPreviewProductDetail.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -/** - * DTO for order product details - */ -class OrderPreviewProductDetail -{ - /** - * @var string - */ - private $name; - - /** - * @var int - */ - private $quantity; - - /** - * @var string - */ - private $unitPrice; - - /** - * @var string - */ - private $totalPrice; - - /** - * @var string - */ - private $totalTax; - - /** - * @var string - */ - private $reference; - - /** - * @var string - */ - private $location; - - /** - * @param string $name - * @param string $reference - * @param string $location - * @param int $quantity - * @param string $unitPrice - * @param string $totalPrice - * @param string $totalTax - */ - public function __construct( - string $name, - string $reference, - string $location, - int $quantity, - string $unitPrice, - string $totalPrice, - string $totalTax - ) { - $this->name = $name; - $this->quantity = $quantity; - $this->unitPrice = $unitPrice; - $this->totalPrice = $totalPrice; - $this->totalTax = $totalTax; - $this->reference = $reference; - $this->location = $location; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return string - */ - public function getReference(): string - { - return $this->reference; - } - - /** - * @return string - */ - public function getUnitPrice(): string - { - return $this->unitPrice; - } - - /** - * @return string - */ - public function getTotalPrice(): string - { - return $this->totalPrice; - } - - /** - * @return int - */ - public function getQuantity(): int - { - return $this->quantity; - } - - /** - * @return string - */ - public function getTotalTax(): string - { - return $this->totalTax; - } - - /** - * @return string - */ - public function getLocation(): string - { - return $this->location; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderPreviewShippingDetails.php b/src/Core/Domain/Order/QueryResult/OrderPreviewShippingDetails.php deleted file mode 100644 index f3808080..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderPreviewShippingDetails.php +++ /dev/null @@ -1,249 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -/** - * DTO for order shipping details - */ -class OrderPreviewShippingDetails -{ - /** - * @var string - */ - private $firstName; - - /** - * @var string - */ - private $lastName; - - /** - * @var string - */ - private $address1; - - /** - * @var string - */ - private $address2; - - /** - * @var string - */ - private $city; - - /** - * @var string - */ - private $country; - - /** - * @var string - */ - private $phone; - - /** - * @var string|null - */ - private $carrierName; - - /** - * @var string|null - */ - private $trackingNumber; - - /** - * @var string - */ - private $postalCode; - - /** - * @var string|null - */ - private $stateName; - - /** - * @var string|null - */ - private $company; - - /** - * @var string|null - */ - private $vatNumber; - - /** - * InvoiceDetails constructor. - * - * @param string $firstName - * @param string $lastName - * @param string|null $company - * @param string|null $vatNumber - * @param string $address1 - * @param string $address2 - * @param string $city - * @param string $postalCode - * @param string|null $stateName - * @param string $country - * @param string $phone - * @param string|null $carrierName - * @param string|null $trackingNumber - */ - public function __construct( - string $firstName, - string $lastName, - ?string $company, - ?string $vatNumber, - string $address1, - string $address2, - string $city, - string $postalCode, - ?string $stateName, - string $country, - string $phone, - ?string $carrierName, - ?string $trackingNumber - ) { - $this->firstName = $firstName; - $this->lastName = $lastName; - $this->address1 = $address1; - $this->address2 = $address2; - $this->city = $city; - $this->country = $country; - $this->phone = $phone; - $this->carrierName = $carrierName; - $this->trackingNumber = $trackingNumber; - $this->postalCode = $postalCode; - $this->stateName = $stateName; - $this->company = $company; - $this->vatNumber = $vatNumber; - } - - /** - * @return string - */ - public function getFirstName(): string - { - return $this->firstName; - } - - /** - * @return string - */ - public function getLastName(): string - { - return $this->lastName; - } - - /** - * @return string|null - */ - public function getCompany(): ?string - { - return $this->company; - } - - /** - * @return string|null - */ - public function getVatNumber(): ?string - { - return $this->vatNumber; - } - - /** - * @return string - */ - public function getAddress1(): string - { - return $this->address1; - } - - /** - * @return string - */ - public function getCity(): string - { - return $this->city; - } - - /** - * @return string - */ - public function getPostalCode(): string - { - return $this->postalCode; - } - - /** - * @return string|null - */ - public function getStateName(): ?string - { - return $this->stateName; - } - - /** - * @return string - */ - public function getCountry(): string - { - return $this->country; - } - - /** - * @return string - */ - public function getPhone(): string - { - return $this->phone; - } - - /** - * @return string - */ - public function getAddress2(): string - { - return $this->address2; - } - - /** - * @return string|null - */ - public function getCarrierName(): ?string - { - return $this->carrierName; - } - - /** - * @return string|null - */ - public function getTrackingNumber(): ?string - { - return $this->trackingNumber; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderPricesForViewing.php b/src/Core/Domain/Order/QueryResult/OrderPricesForViewing.php deleted file mode 100644 index 76f167f1..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderPricesForViewing.php +++ /dev/null @@ -1,245 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -use PrestaShop\Decimal\Number; - -class OrderPricesForViewing -{ - /** - * @var string - */ - private $productsPriceFormatted; - - /** - * @var string - */ - private $discountsAmountFormatted; - - /** - * @var string - */ - private $wrappingPriceFormatted; - - /** - * @var string - */ - private $shippingPriceFormatted; - - /** - * @var string - */ - private $shippingRefundableAmountFormatted; - - /** - * @var string - */ - private $taxesAmountFormatted; - - /** - * @var string - */ - private $totalAmountFormatted; - - /** - * @var Number - */ - private $productsPriceRaw; - - /** - * @var Number - */ - private $discountsAmountRaw; - /** - * @var Number - */ - private $wrappingPriceRaw; - - /** - * @var Number - */ - private $shippingPriceRaw; - - /** - * @var Number - */ - private $shippingRefundableAmountRaw; - - /** - * @var Number - */ - private $taxesAmountRaw; - - /** - * @var Number - */ - private $totalAmountRaw; - - public function __construct( - Number $productsPriceRaw, - Number $discountsAmountRaw, - Number $wrappingPriceRaw, - Number $shippingPriceRaw, - Number $shippingRefundableAmountRaw, - Number $taxesAmountRaw, - Number $totalAmountRaw, - string $productsPrice, - string $discountsAmount, - string $wrappingPrice, - string $shippingPrice, - string $shippingRefundableAmount, - string $taxesAmount, - string $totalAmount - ) { - $this->productsPriceFormatted = $productsPrice; - $this->discountsAmountFormatted = $discountsAmount; - $this->wrappingPriceFormatted = $wrappingPrice; - $this->shippingPriceFormatted = $shippingPrice; - $this->shippingRefundableAmountFormatted = $shippingRefundableAmount; - $this->taxesAmountFormatted = $taxesAmount; - $this->totalAmountFormatted = $totalAmount; - $this->productsPriceRaw = $productsPriceRaw; - $this->discountsAmountRaw = $discountsAmountRaw; - $this->wrappingPriceRaw = $wrappingPriceRaw; - $this->shippingPriceRaw = $shippingPriceRaw; - $this->shippingRefundableAmountRaw = $shippingRefundableAmountRaw; - $this->taxesAmountRaw = $taxesAmountRaw; - $this->totalAmountRaw = $totalAmountRaw; - } - - /** - * @return string - */ - public function getProductsPriceFormatted(): string - { - return $this->productsPriceFormatted; - } - - /** - * @return string - */ - public function getDiscountsAmountFormatted(): ?string - { - return $this->discountsAmountFormatted; - } - - /** - * @return string - */ - public function getWrappingPriceFormatted(): ?string - { - return $this->wrappingPriceFormatted; - } - - /** - * @return string - */ - public function getShippingPriceFormatted(): ?string - { - return $this->shippingPriceFormatted; - } - - /** - * @return string - */ - public function getShippingRefundableAmountFormatted(): ?string - { - return $this->shippingRefundableAmountFormatted; - } - - /** - * @return string - */ - public function getTaxesAmountFormatted(): string - { - return $this->taxesAmountFormatted; - } - - /** - * @return string - */ - public function getTotalAmountFormatted(): string - { - return $this->totalAmountFormatted; - } - - /** - * @return Number - */ - public function getProductsPriceRaw(): Number - { - return $this->productsPriceRaw; - } - - /** - * @return Number - */ - public function getDiscountsAmountRaw(): Number - { - return $this->discountsAmountRaw; - } - - /** - * @return Number - */ - public function getWrappingPriceRaw(): Number - { - return $this->wrappingPriceRaw; - } - - /** - * @return Number - */ - public function getShippingPriceRaw(): Number - { - return $this->shippingPriceRaw; - } - - /** - * @return Number - */ - public function getShippingRefundableAmountRaw(): Number - { - return $this->shippingRefundableAmountRaw; - } - - /** - * @return Number - */ - public function getTaxesAmountRaw(): Number - { - return $this->taxesAmountRaw; - } - - /** - * @return Number - */ - public function getTotalAmountRaw(): Number - { - return $this->totalAmountRaw; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderProductCustomizationForViewing.php b/src/Core/Domain/Order/QueryResult/OrderProductCustomizationForViewing.php deleted file mode 100644 index 0dbd73a2..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderProductCustomizationForViewing.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -use PrestaShop\PrestaShop\Adapter\Entity\Product; - -class OrderProductCustomizationForViewing -{ - /** - * @var int - */ - private $type; - - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $value; - - /** - * @var string - */ - private $image; - - /** - * @param int $type - * @param string $name - * @param string $value - */ - public function __construct(int $type, string $name, string $value) - { - $this->type = $type; - $this->name = $name; - $this->value = $value; - if (Product::CUSTOMIZE_FILE === $this->type) { - $this->image = _THEME_PROD_PIC_DIR_ . $this->value . '_small'; - } - } - - /** - * @return int - */ - public function getType(): int - { - return $this->type; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return string - */ - public function getValue(): string - { - return $this->value; - } - - /** - * @return string|null - */ - public function getImage(): ?string - { - return $this->image; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderProductCustomizationsForViewing.php b/src/Core/Domain/Order/QueryResult/OrderProductCustomizationsForViewing.php deleted file mode 100644 index 26e0f574..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderProductCustomizationsForViewing.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -use PrestaShop\PrestaShop\Adapter\Entity\Product; - -class OrderProductCustomizationsForViewing -{ - /** - * @var OrderProductCustomizationForViewing[] - */ - private $textCustomizations = []; - - /** - * @var OrderProductCustomizationForViewing[] - */ - private $fileCustomizations = []; - - /** - * @param OrderProductCustomizationForViewing[] $customizations - */ - public function __construct(array $customizations) - { - foreach ($customizations as $customization) { - $this->addCustomization($customization); - } - } - - /** - * @param OrderProductCustomizationForViewing $customization - */ - private function addCustomization(OrderProductCustomizationForViewing $customization): void - { - if (Product::CUSTOMIZE_FILE === $customization->getType()) { - $this->fileCustomizations[] = $customization; - } else { - $this->textCustomizations[] = $customization; - } - } - - /** - * Returns customizations of type FILE - * - * @return OrderProductCustomizationForViewing[] - */ - public function getFileCustomizations(): array - { - return $this->fileCustomizations; - } - - /** - * Returns customizations of type TEXT - * - * @return OrderProductCustomizationForViewing[] - */ - public function getTextCustomizations(): array - { - return $this->textCustomizations; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderProductForViewing.php b/src/Core/Domain/Order/QueryResult/OrderProductForViewing.php deleted file mode 100644 index 0c6d2577..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderProductForViewing.php +++ /dev/null @@ -1,533 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -use JsonSerializable; - -class OrderProductForViewing implements JsonSerializable -{ - const TYPE_PACK = 'pack'; - const TYPE_PRODUCT_WITH_COMBINATIONS = 'product_with_combinations'; - const TYPE_PRODUCT_WITHOUT_COMBINATIONS = 'product_without_combinations'; - - /** - * @var int - */ - private $id; - - /** - * @var int - */ - private $combinationId; - - /** - * @var string - */ - private $location; - - /** - * @var string - */ - private $name; - - /** - * @var OrderProductForViewing[] - */ - private $packItems; - - /** - * @var string - */ - private $reference; - - /** - * @var string - */ - private $supplierReference; - - /** - * @var string - */ - private $type; - - /** - * @var int - */ - private $quantity; - - /** - * @var string - */ - private $unitPrice; - - /** - * @var string - */ - private $totalPrice; - - /** - * @var int - */ - private $availableQuantity; - - /** - * @var string|null - */ - private $imagePath; - - /** - * @var string - */ - private $unitPriceTaxExclRaw; - - /** - * @var string - */ - private $unitPriceTaxInclRaw; - - /** - * @var string - */ - private $taxRate; - - /** - * @var int - */ - private $orderDetailId; - - /** - * @var string - */ - private $amountRefunded; - - /** - * @var int - */ - private $quantityRefunded; - - /** - * @var string - */ - private $amountRefundable; - - /** - * @var string - */ - private $amountRefundableRaw; - - /** - * @var int - */ - private $orderInvoiceId; - - /** - * @var string - */ - private $orderInvoiceNumber; - - /** - * @var bool - */ - private $availableOutOfStock; - - /** - * @var OrderProductCustomizationsForViewing - */ - private $customizations; - - /** - * @param int $orderDetailId - * @param int $id - * @param int $combinationId - * @param string $name - * @param string $reference - * @param string $supplierReference - * @param int $quantity - * @param string $unitPrice - * @param string $totalPrice - * @param int $availableQuantity - * @param string|null $imagePath - * @param string $unitPriceTaxExclRaw - * @param string $unitPriceTaxInclRaw - * @param string $taxRate - * @param string $amountRefunded - * @param int $quantityRefunded - * @param string $amountRefundable - * @param string $amountRefundableRaw - * @param string $location - * @param int|null $orderInvoiceId - * @param string $orderInvoiceNumber - * @param string $type - * @param bool $availableOutOfStock - * @param array $packItems - * @param OrderProductCustomizationsForViewing|null $customizations - */ - public function __construct( - ?int $orderDetailId, - int $id, - int $combinationId, - string $name, - string $reference, - string $supplierReference, - int $quantity, - string $unitPrice, - string $totalPrice, - int $availableQuantity, - ?string $imagePath, - string $unitPriceTaxExclRaw, - string $unitPriceTaxInclRaw, - string $taxRate, - string $amountRefunded, - int $quantityRefunded, - string $amountRefundable, - string $amountRefundableRaw, - string $location, - ?int $orderInvoiceId, - string $orderInvoiceNumber, - string $type, - bool $availableOutOfStock, - array $packItems = [], - ?OrderProductCustomizationsForViewing $customizations = null - ) { - $this->id = $id; - $this->combinationId = $combinationId; - $this->name = $name; - $this->reference = $reference; - $this->supplierReference = $supplierReference; - $this->quantity = $quantity; - $this->unitPrice = $unitPrice; - $this->totalPrice = $totalPrice; - $this->availableQuantity = $availableQuantity; - $this->imagePath = $imagePath; - $this->unitPriceTaxExclRaw = $unitPriceTaxExclRaw; - $this->unitPriceTaxInclRaw = $unitPriceTaxInclRaw; - $this->taxRate = $taxRate; - $this->orderDetailId = $orderDetailId; - $this->amountRefunded = $amountRefunded; - $this->quantityRefunded = $quantityRefunded; - $this->amountRefundable = $amountRefundable; - $this->amountRefundableRaw = $amountRefundableRaw; - $this->location = $location; - $this->orderInvoiceId = $orderInvoiceId; - $this->orderInvoiceNumber = $orderInvoiceNumber; - $this->type = $type; - $this->availableOutOfStock = $availableOutOfStock; - $this->packItems = $packItems; - $this->customizations = $customizations; - } - - /** - * Get product's order detail ID - * - * @return int|null - */ - public function getOrderDetailId(): ?int - { - return $this->orderDetailId; - } - - /** - * Get product ID - * - * @return int - */ - public function getId(): int - { - return $this->id; - } - - /** - * @return int - */ - public function getCombinationId(): int - { - return $this->combinationId; - } - - /** - * Get product's name - * - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return OrderProductForViewing[] - */ - public function getPackItems(): array - { - return $this->packItems; - } - - /** - * Product reference - * - * @return string - */ - public function getReference(): string - { - return $this->reference; - } - - /** - * Get product's supplier reference - * - * @return string - */ - public function getSupplierReference(): string - { - return $this->supplierReference; - } - - /** - * get tax rate to be applied on this product - * - * @return string - */ - public function getTaxRate(): string - { - return $this->taxRate; - } - - /** - * @return string - */ - public function getType(): string - { - return $this->type; - } - - /** - * Get product's location - * - * @return string - */ - public function getLocation(): string - { - return $this->location; - } - - /** - * Get product's quantity - * - * @return int - */ - public function getQuantity(): int - { - return $this->quantity; - } - - /** - * Get product's unit price - * - * @return string - */ - public function getUnitPrice(): string - { - return $this->unitPrice; - } - - /** - * Get product's formatted total price - * - * @return string - */ - public function getTotalPrice(): string - { - return $this->totalPrice; - } - - /** - * Get available quantity for this product - * - * @return int - */ - public function getAvailableQuantity(): int - { - return $this->availableQuantity; - } - - /** - * Get image path for this product - * - * @return string|null - */ - public function getImagePath(): ?string - { - return $this->imagePath; - } - - /** - * Get unit price without taxes - * - * @return string - */ - public function getUnitPriceTaxExclRaw(): string - { - return $this->unitPriceTaxExclRaw; - } - - /** - * Get unit price including taxes - * - * @return string - */ - public function getUnitPriceTaxInclRaw(): string - { - return $this->unitPriceTaxInclRaw; - } - - /** - * How much (money) has already been refunded for this product - * - * @return string - */ - public function getAmountRefunded(): string - { - return $this->amountRefunded; - } - - /** - * How many (quantity) of this product has already been refunded - * - * @return int - */ - public function getQuantityRefunded(): int - { - return $this->quantityRefunded; - } - - /** - * How much (money) can be refunded for this product (formatted for display) - * - * @return string - */ - public function getAmountRefundable(): string - { - return $this->amountRefundable; - } - - /** - * How much (money) can be refunded for this product - * - * @return string - */ - public function getAmountRefundableRaw(): string - { - return $this->amountRefundableRaw; - } - - /** - * How many (quantity) of this product can be refunded - * - * @return int - */ - public function getQuantityRefundable(): int - { - return $this->quantity - $this->quantityRefunded; - } - - /** - * Can this product be refunded - * - * @return bool - */ - public function isRefundable(): bool - { - if ($this->quantity <= $this->quantityRefunded) { - return false; - } - - return true; - } - - /** - * Get the id of this product's invoice - * - * @return int - */ - public function getOrderInvoiceId(): ?int - { - return $this->orderInvoiceId; - } - - /** - * Get the number (reference) of this product's invoice - * - * @return string - */ - public function getOrderInvoiceNumber(): string - { - return $this->orderInvoiceNumber; - } - - /** - * Get customizations of this product - * - * @return OrderProductCustomizationsForViewing|null - */ - public function getCustomizations(): ?OrderProductCustomizationsForViewing - { - return $this->customizations; - } - - /** - * @return bool - */ - public function isAvailableOutOfStock(): bool - { - return $this->availableOutOfStock; - } - - /** - * @return array - */ - public function jsonSerialize(): array - { - return [ - 'id' => $this->getId(), - 'orderDetailId' => $this->getOrderDetailId(), - 'name' => $this->getName(), - 'reference' => $this->getReference(), - 'supplierReference' => $this->getSupplierReference(), - 'location' => $this->getLocation(), - 'imagePath' => $this->getImagePath(), - 'quantity' => $this->getQuantity(), - 'availableQuantity' => $this->getAvailableQuantity(), - 'unitPrice' => $this->getUnitPrice(), - 'unitPriceTaxExclRaw' => $this->getUnitPriceTaxExclRaw(), - 'unitPriceTaxInclRaw' => $this->getUnitPriceTaxInclRaw(), - 'totalPrice' => $this->getTotalPrice(), - 'taxRate' => $this->getTaxRate(), - 'type' => $this->getType(), - 'packItems' => $this->getPackItems(), - ]; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderProductsForViewing.php b/src/Core/Domain/Order/QueryResult/OrderProductsForViewing.php deleted file mode 100644 index 08dbadd9..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderProductsForViewing.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -class OrderProductsForViewing -{ - /** - * @var OrderProductForViewing[] - */ - private $products = []; - - /** - * @param OrderProductForViewing[] $products - */ - public function __construct(array $products) - { - foreach ($products as $product) { - $this->addProductForViewing($product); - } - } - - /** - * @param OrderProductForViewing $productForViewing - */ - private function addProductForViewing(OrderProductForViewing $productForViewing): void - { - $this->products[] = $productForViewing; - } - - /** - * @return OrderProductForViewing[] - */ - public function getProducts(): array - { - return $this->products; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderReturnForViewing.php b/src/Core/Domain/Order/QueryResult/OrderReturnForViewing.php deleted file mode 100644 index d0776169..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderReturnForViewing.php +++ /dev/null @@ -1,166 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -use DateTimeImmutable; - -class OrderReturnForViewing -{ - /** - * @var int - */ - private $orderInvoiceId; - - /** - * @var int - */ - private $carrierId; - - /** - * @var DateTimeImmutable - */ - private $date; - - /** - * @var string - */ - private $type; - - /** - * @var string - */ - private $stateName; - - /** - * @var string|null - */ - private $trackingUrl; - - /** - * @var string|null - */ - private $trackingNumber; - - /** - * @var int - */ - private $idOrderReturn; - - /** - * @param int $idOrderReturn - * @param int $orderInvoiceId - * @param int $carrierId - * @param DateTimeImmutable $date - * @param string $type - * @param string $stateName - * @param string|null $trackingUrl - * @param string|null $trackingNumber - */ - public function __construct( - int $idOrderReturn, - int $orderInvoiceId, - int $carrierId, - DateTimeImmutable $date, - string $type, - string $stateName, - ?string $trackingUrl, - ?string $trackingNumber - ) { - $this->orderInvoiceId = $orderInvoiceId; - $this->carrierId = $carrierId; - $this->date = $date; - $this->type = $type; - $this->stateName = $stateName; - $this->trackingUrl = $trackingUrl; - $this->trackingNumber = $trackingNumber; - $this->idOrderReturn = $idOrderReturn; - } - - /** - * @return int - */ - public function getOrderInvoiceId(): int - { - return $this->orderInvoiceId; - } - - /** - * @return int - */ - public function getCarrierId(): int - { - return $this->carrierId; - } - - /** - * @return DateTimeImmutable - */ - public function getDate(): DateTimeImmutable - { - return $this->date; - } - - /** - * @return string - */ - public function getType(): string - { - return $this->type; - } - - /** - * @return string - */ - public function getStateName(): string - { - return $this->stateName; - } - - /** - * @return string|null - */ - public function getTrackingUrl(): ?string - { - return $this->trackingUrl; - } - - /** - * @return string|null - */ - public function getTrackingNumber(): ?string - { - return $this->trackingNumber; - } - - /** - * @return int - */ - public function getIdOrderReturn(): int - { - return $this->idOrderReturn; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderReturnsForViewing.php b/src/Core/Domain/Order/QueryResult/OrderReturnsForViewing.php deleted file mode 100644 index 7bbcc3d1..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderReturnsForViewing.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -class OrderReturnsForViewing -{ - /** @var OrderReturnForViewing[] */ - private $orderReturns = []; - - /** - * @param OrderReturnForViewing[] $orderReturns - */ - public function __construct(array $orderReturns = []) - { - foreach ($orderReturns as $orderReturn) { - $this->add($orderReturn); - } - } - - /** - * @return OrderReturnForViewing[] - */ - public function getOrderReturns(): array - { - return $this->orderReturns; - } - - /** - * @param OrderReturnForViewing $orderReturn - */ - private function add(OrderReturnForViewing $orderReturn): void - { - $this->orderReturns[] = $orderReturn; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderShippingAddressForViewing.php b/src/Core/Domain/Order/QueryResult/OrderShippingAddressForViewing.php deleted file mode 100644 index 5f0cb2f8..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderShippingAddressForViewing.php +++ /dev/null @@ -1,205 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -class OrderShippingAddressForViewing -{ - /** - * @var int - */ - private $addressId; - - /** - * @var string - */ - private $firstName; - - /** - * @var string - */ - private $lastName; - - /** - * @var string - */ - private $companyName; - /** - * @var string - */ - private $address1; - - /** - * @var string - */ - private $address2; - - /** - * @var string - */ - private $cityName; - - /** - * @var string - */ - private $stateName; - - /** - * @var string - */ - private $countryName; - - /** - * @var string - */ - private $postCode; - - /** - * @var string - */ - private $phoneNumber; - - /** - * @var string - */ - private $mobilePhoneNumber; - - public function __construct( - int $addressId, - string $firstName, - string $lastName, - string $companyName, - string $address1, - string $address2, - string $stateName, - string $cityName, - string $countryName, - string $postCode, - string $phone, - string $phoneMobile - ) { - $this->addressId = $addressId; - $this->firstName = $firstName; - $this->lastName = $lastName; - $this->companyName = $companyName; - $this->address1 = $address1; - $this->address2 = $address2; - $this->stateName = $stateName; - $this->cityName = $cityName; - $this->countryName = $countryName; - $this->postCode = $postCode; - $this->phoneNumber = $phone; - $this->mobilePhoneNumber = $phoneMobile; - } - - /** - * @return int - */ - public function getAddressId(): int - { - return $this->addressId; - } - - /** - * @return string - */ - public function getFullName(): string - { - return sprintf('%s %s', $this->firstName, $this->lastName); - } - - /** - * @return string - */ - public function getCompanyName(): string - { - return $this->companyName; - } - - /** - * @return string - */ - public function getAddress1(): string - { - return $this->address1; - } - - /** - * @return string - */ - public function getAddress2(): string - { - return $this->address2; - } - - /** - * @return string - */ - public function getCityName(): string - { - return $this->cityName; - } - - /** - * @return string - */ - public function getStateName(): string - { - return $this->stateName; - } - - /** - * @return string - */ - public function getCountryName(): string - { - return $this->countryName; - } - - /** - * @return string - */ - public function getPostCode(): string - { - return $this->postCode; - } - - /** - * @return string - */ - public function getPhoneNumber(): string - { - return $this->phoneNumber; - } - - /** - * @return string - */ - public function getMobilePhoneNumber(): string - { - return $this->mobilePhoneNumber; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderShippingForViewing.php b/src/Core/Domain/Order/QueryResult/OrderShippingForViewing.php deleted file mode 100644 index 470d76c7..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderShippingForViewing.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -class OrderShippingForViewing -{ - /** - * @var OrderCarrierForViewing[] - */ - private $carriers = []; - - /** - * @var bool - */ - private $isRecycledPackaging; - - /** - * @var bool - */ - private $isGiftWrapping; - - /** - * @var string|null - */ - private $carrierModuleInfo; - - /** - * @var string|null - */ - private $giftMessage; - - /** - * @param OrderCarrierForViewing[] $carriers - * @param bool $isRecycledPackaging - * @param bool $isGiftWrapping - * @param string|null $giftMessage - * @param string|null $carrierModuleInfo - */ - public function __construct( - array $carriers, - bool $isRecycledPackaging, - bool $isGiftWrapping, - ?string $giftMessage, - ?string $carrierModuleInfo - ) { - foreach ($carriers as $carrier) { - $this->addCarrier($carrier); - } - - $this->isRecycledPackaging = $isRecycledPackaging; - $this->isGiftWrapping = $isGiftWrapping; - $this->carrierModuleInfo = $carrierModuleInfo; - $this->giftMessage = $giftMessage; - } - - /** - * hint - collection of OrderCarrierForViewing objects would be better - * - * @return OrderCarrierForViewing[] - */ - public function getCarriers(): array - { - return $this->carriers; - } - - /** - * @return bool - */ - public function isRecycledPackaging(): bool - { - return $this->isRecycledPackaging; - } - - /** - * @return bool - */ - public function isGiftWrapping(): bool - { - return $this->isGiftWrapping; - } - - /** - * @return string|null - */ - public function getCarrierModuleInfo(): ?string - { - return $this->carrierModuleInfo; - } - - /** - * @return string|null - */ - public function getGiftMessage(): ?string - { - return $this->giftMessage; - } - - /** - * @param OrderCarrierForViewing $carrier - */ - private function addCarrier(OrderCarrierForViewing $carrier): void - { - $this->carriers[] = $carrier; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderSourceForViewing.php b/src/Core/Domain/Order/QueryResult/OrderSourceForViewing.php deleted file mode 100644 index f1e1c685..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderSourceForViewing.php +++ /dev/null @@ -1,100 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -use DateTimeImmutable; - -class OrderSourceForViewing -{ - /** - * @var string - */ - private $httpReferer; - - /** - * @var string - */ - private $requestUri; - - /** - * @var DateTimeImmutable - */ - private $addedAt; - - /** - * @var string - */ - private $keywords; - - /** - * @param string $httpReferer - * @param string $requestUri - * @param DateTimeImmutable $addedAt - * @param string $keywords - */ - public function __construct(string $httpReferer, string $requestUri, DateTimeImmutable $addedAt, string $keywords) - { - $this->httpReferer = $httpReferer; - $this->requestUri = $requestUri; - $this->addedAt = $addedAt; - $this->keywords = $keywords; - } - - /** - * @return string - */ - public function getHttpReferer(): string - { - return $this->httpReferer; - } - - /** - * @return string - */ - public function getRequestUri(): string - { - return $this->requestUri; - } - - /** - * @return DateTimeImmutable - */ - public function getAddedAt(): DateTimeImmutable - { - return $this->addedAt; - } - - /** - * @return string - */ - public function getKeywords(): string - { - return $this->keywords; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderSourcesForViewing.php b/src/Core/Domain/Order/QueryResult/OrderSourcesForViewing.php deleted file mode 100644 index c58a23e3..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderSourcesForViewing.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -class OrderSourcesForViewing -{ - /** @var OrderSourceForViewing[] */ - private $sources = []; - - /** - * @param OrderSourceForViewing[] $sources - */ - public function __construct(array $sources) - { - foreach ($sources as $source) { - $this->addSource($source); - } - } - - /** - * @return OrderSourceForViewing[] - */ - public function getSources(): array - { - return $this->sources; - } - - /** - * @param OrderSourceForViewing $source - */ - private function addSource(OrderSourceForViewing $source): void - { - $this->sources[] = $source; - } -} diff --git a/src/Core/Domain/Order/QueryResult/OrderStatusForViewing.php b/src/Core/Domain/Order/QueryResult/OrderStatusForViewing.php deleted file mode 100644 index cbfde865..00000000 --- a/src/Core/Domain/Order/QueryResult/OrderStatusForViewing.php +++ /dev/null @@ -1,166 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\QueryResult; - -use DateTimeImmutable; - -class OrderStatusForViewing -{ - /** - * @var int - */ - private $orderStatusId; - - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $color; - - /** - * @var DateTimeImmutable - */ - private $createdAt; - - /** - * @var bool - */ - private $withEmail; - - /** - * @var string|null First name of employee who updated order status or null otherwise - */ - private $employeeFirstName; - - /** - * @var string|null Last name of employee who updated order status or null otherwise - */ - private $employeeLastName; - - /** - * @var int - */ - private $orderHistoryId; - - /** - * @param int $orderHistoryId - * @param int $orderStatusId - * @param string $name - * @param string $color - * @param DateTimeImmutable $createdAt - * @param bool $withEmail - * @param string|null $employeeFirstName - * @param string|null $employeeLastName - */ - public function __construct( - int $orderHistoryId, - int $orderStatusId, - string $name, - string $color, - DateTimeImmutable $createdAt, - bool $withEmail, - ?string $employeeFirstName, - ?string $employeeLastName - ) { - $this->orderStatusId = $orderStatusId; - $this->name = $name; - $this->color = $color; - $this->createdAt = $createdAt; - $this->withEmail = $withEmail; - $this->employeeFirstName = $employeeFirstName; - $this->employeeLastName = $employeeLastName; - $this->orderHistoryId = $orderHistoryId; - } - - /** - * @return int - */ - public function getOrderHistoryId(): int - { - return $this->orderHistoryId; - } - - /** - * @return int - */ - public function getOrderStatusId(): int - { - return $this->orderStatusId; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return string - */ - public function getColor(): string - { - return $this->color; - } - - /** - * @return DateTimeImmutable - */ - public function getCreatedAt(): DateTimeImmutable - { - return $this->createdAt; - } - - /** - * @return bool - */ - public function withEmail(): bool - { - return $this->withEmail; - } - - /** - * @return string|null - */ - public function getEmployeeFirstName(): ?string - { - return $this->employeeFirstName; - } - - /** - * @return string|null - */ - public function getEmployeeLastName(): ?string - { - return $this->employeeLastName; - } -} diff --git a/src/Core/Domain/Order/Status/OrderStatusColor.php b/src/Core/Domain/Order/Status/OrderStatusColor.php deleted file mode 100644 index b28c9349..00000000 --- a/src/Core/Domain/Order/Status/OrderStatusColor.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\Status; - -/** - * Defines colors for order statuses - */ -class OrderStatusColor -{ - /** - * Used for statuses that are waiting for customer actions. - * Example statuses: Awaiting bank wire payment, Awaiting check payment, On backorder (not paid). - */ - public const AWAITING_PAYMENT = '#34209E'; - - /** - * Used for statuses when further merchant action is required. - * Example statuses: Processing in progress, On backorder (paid), Payment accepted. - */ - public const ACCEPTED_PAYMENT = '#3498D8'; - - /** - * Used for statuses when no actions are required anymore. - * Example statuses: Shipped, Refunded, Delivered. - */ - public const COMPLETED = '#01b887'; - - /** - * Used for error statuses. - * Example statuses: Payment error. - */ - public const ERROR = '#E74C3C'; - - /** - * Used for statuses with special cases. - * Example statuses: Canceled. - */ - public const SPECIAL = '#2C3E50'; - - /** - * Class is not meant to be initialized. - */ - private function __construct() - { - } -} diff --git a/src/Core/Domain/Order/ValueObject/OrderDetailRefund.php b/src/Core/Domain/Order/ValueObject/OrderDetailRefund.php deleted file mode 100644 index 66b4cb7d..00000000 --- a/src/Core/Domain/Order/ValueObject/OrderDetailRefund.php +++ /dev/null @@ -1,146 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\ValueObject; - -use InvalidArgumentException; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidAmountException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidCancelProductException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; - -/** - * Class ProductRefund - */ -class OrderDetailRefund -{ - /** - * @var int - */ - private $orderDetailId; - - /** - * @var int - */ - private $productQuantity; - - /** - * @var float|null - */ - private $refundedAmount; - - /** - * @param int $orderDetailId - * @param int $productQuantity - * @param string $refundedAmount - * - * @return self - * - * @throws InvalidCancelProductException - * @throws OrderException - */ - public static function createPartialRefund(int $orderDetailId, int $productQuantity, string $refundedAmount): self - { - try { - $decimalRefundedAmount = new Number($refundedAmount); - } catch (InvalidArgumentException $e) { - throw new InvalidAmountException(); - } - - if ($decimalRefundedAmount->isLowerOrEqualThanZero()) { - throw new InvalidCancelProductException(InvalidCancelProductException::INVALID_AMOUNT); - } - - return new self($orderDetailId, $productQuantity, $decimalRefundedAmount); - } - - /** - * @param int $orderDetailId - * @param int $productQuantity - * - * @return self - * - * @throws OrderException - */ - public static function createStandardRefund(int $orderDetailId, int $productQuantity): self - { - return new self($orderDetailId, $productQuantity, null); - } - - /** - * @param int $orderDetailId - * @param int $productQuantity - * @param Number|null $refundedAmount - * - * @throws OrderException - */ - private function __construct(int $orderDetailId, int $productQuantity, ?Number $refundedAmount) - { - $this->assertOrderDetailIdIsGreaterThanZero($orderDetailId); - if (0 >= $productQuantity) { - throw new InvalidCancelProductException(InvalidCancelProductException::INVALID_QUANTITY); - } - $this->orderDetailId = $orderDetailId; - $this->productQuantity = $productQuantity; - $this->refundedAmount = $refundedAmount; - } - - /** - * @return int - */ - public function getOrderDetailId(): int - { - return $this->orderDetailId; - } - - /** - * @return int - */ - public function getProductQuantity(): int - { - return $this->productQuantity; - } - - /** - * @return Number|null - */ - public function getRefundedAmount(): ?Number - { - return $this->refundedAmount; - } - - /** - * @param int $orderDetailId - * - * @throws OrderException - */ - private function assertOrderDetailIdIsGreaterThanZero(int $orderDetailId) - { - if (0 > $orderDetailId) { - throw new OrderException(sprintf('Order detail id %s is invalid. Order detail id must be number that is greater than zero.', var_export($orderDetailId, true))); - } - } -} diff --git a/src/Core/Domain/Order/ValueObject/OrderId.php b/src/Core/Domain/Order/ValueObject/OrderId.php deleted file mode 100644 index 6ae291ab..00000000 --- a/src/Core/Domain/Order/ValueObject/OrderId.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; - -/** - * Order identity - */ -class OrderId -{ - /** - * @var int - */ - private $orderId; - - /** - * @param int $orderId - * - * @throws OrderException - */ - public function __construct($orderId) - { - $this->assertIntegerIsGreaterThanZero($orderId); - - $this->orderId = $orderId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->orderId; - } - - /** - * @param int $orderId - */ - private function assertIntegerIsGreaterThanZero($orderId) - { - if (!is_int($orderId) || 0 > $orderId) { - throw new OrderException(sprintf('Order id %s is invalid. Order id must be number that is greater than zero.', var_export($orderId, true))); - } - } -} diff --git a/src/Core/Domain/Order/VoucherRefundType.php b/src/Core/Domain/Order/VoucherRefundType.php deleted file mode 100644 index b7b50861..00000000 --- a/src/Core/Domain/Order/VoucherRefundType.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Order; - -/** - * When refunding an order that was partially paid with a voucher you have different way - * to refund it. - */ -class VoucherRefundType -{ - /** - * Refund based on product prices (the initial voucher amount is ignored) - */ - const PRODUCT_PRICES_REFUND = 0; - - /** - * Refund based on product prices, but do not refund the voucher amount - */ - const PRODUCT_PRICES_EXCLUDING_VOUCHER_REFUND = 1; - - /** - * The refund amount is specified manually - */ - const SPECIFIC_AMOUNT_REFUND = 2; -} diff --git a/src/Core/Domain/OrderMessage/Command/AddOrderMessageCommand.php b/src/Core/Domain/OrderMessage/Command/AddOrderMessageCommand.php deleted file mode 100644 index 4839af28..00000000 --- a/src/Core/Domain/OrderMessage/Command/AddOrderMessageCommand.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command; - -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Exception\OrderMessageConstraintException; - -/** - * Add new order message - */ -class AddOrderMessageCommand -{ - /** - * @var string[] - */ - private $localizedName; - - /** - * @var string[] - */ - private $localizedMessage; - - /** - * @param string[] $localizedName - * @param string[] $localizedMessage - */ - public function __construct(array $localizedName, array $localizedMessage) - { - if (empty($localizedName)) { - throw new OrderMessageConstraintException('OrderMessage name must not be empty'); - } - - if (empty($localizedMessage)) { - throw new OrderMessageConstraintException('OrderMessage message must not be empty'); - } - - $this->localizedName = $localizedName; - $this->localizedMessage = $localizedMessage; - } - - /** - * @return string[] - */ - public function getLocalizedName(): array - { - return $this->localizedName; - } - - /** - * @return string[] - */ - public function getLocalizedMessage(): array - { - return $this->localizedMessage; - } -} diff --git a/src/Core/Domain/OrderMessage/Command/BulkDeleteOrderMessageCommand.php b/src/Core/Domain/OrderMessage/Command/BulkDeleteOrderMessageCommand.php deleted file mode 100644 index 5adae1ef..00000000 --- a/src/Core/Domain/OrderMessage/Command/BulkDeleteOrderMessageCommand.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command; - -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\ValueObject\OrderMessageId; - -/** - * Delete given order messages - */ -class BulkDeleteOrderMessageCommand -{ - /** - * @var OrderMessageId[] - */ - private $orderMessageIds; - - /** - * @param int[] $orderMessageIds - */ - public function __construct(array $orderMessageIds) - { - foreach ($orderMessageIds as $orderMessageId) { - $this->orderMessageIds[] = new OrderMessageId($orderMessageId); - } - } - - /** - * @return OrderMessageId[] - */ - public function getOrderMessageIds(): array - { - return $this->orderMessageIds; - } -} diff --git a/src/Core/Domain/OrderMessage/Command/DeleteOrderMessageCommand.php b/src/Core/Domain/OrderMessage/Command/DeleteOrderMessageCommand.php deleted file mode 100644 index 05c6a51a..00000000 --- a/src/Core/Domain/OrderMessage/Command/DeleteOrderMessageCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command; - -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\ValueObject\OrderMessageId; - -/** - * Delete given order message - */ -class DeleteOrderMessageCommand -{ - /** - * @var OrderMessageId - */ - private $orderMessageId; - - /** - * @param int $orderMessageId - */ - public function __construct(int $orderMessageId) - { - $this->orderMessageId = new OrderMessageId($orderMessageId); - } - - /** - * @return OrderMessageId - */ - public function getOrderMessageId(): OrderMessageId - { - return $this->orderMessageId; - } -} diff --git a/src/Core/Domain/OrderMessage/Command/EditOrderMessageCommand.php b/src/Core/Domain/OrderMessage/Command/EditOrderMessageCommand.php deleted file mode 100644 index 6fec5a14..00000000 --- a/src/Core/Domain/OrderMessage/Command/EditOrderMessageCommand.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command; - -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\ValueObject\OrderMessageId; - -/** - * Edit given order message - */ -class EditOrderMessageCommand -{ - /** - * @var OrderMessageId - */ - private $orderMessageId; - - /** - * @var string[]|null - */ - private $localizedName; - - /** - * @var string[]|null - */ - private $localizedMessage; - - /** - * @param int $orderMessageId - * @param string[]|null $localizedName Array of localized name or null if name should not be edited - * @param string[]|null $localizedMessage Array of localized message or null if message should not be edited - */ - public function __construct(int $orderMessageId, array $localizedName = null, array $localizedMessage = null) - { - $this->orderMessageId = new OrderMessageId($orderMessageId); - $this->localizedName = $localizedName; - $this->localizedMessage = $localizedMessage; - } - - /** - * @return OrderMessageId - */ - public function getOrderMessageId(): OrderMessageId - { - return $this->orderMessageId; - } - - /** - * @return string[]|null - */ - public function getLocalizedName(): ?array - { - return $this->localizedName; - } - - /** - * @return string[]|null - */ - public function getLocalizedMessage(): ?array - { - return $this->localizedMessage; - } -} diff --git a/src/Core/Domain/OrderMessage/CommandHandler/AddOrderMessageHandlerInterface.php b/src/Core/Domain/OrderMessage/CommandHandler/AddOrderMessageHandlerInterface.php deleted file mode 100644 index f632dbb6..00000000 --- a/src/Core/Domain/OrderMessage/CommandHandler/AddOrderMessageHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\OrderMessage\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command\AddOrderMessageCommand; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\ValueObject\OrderMessageId; - -/** - * Interface for service that handles adding order message - */ -interface AddOrderMessageHandlerInterface -{ - /** - * @param AddOrderMessageCommand $command - * - * @return OrderMessageId - */ - public function handle(AddOrderMessageCommand $command): OrderMessageId; -} diff --git a/src/Core/Domain/OrderMessage/CommandHandler/BulkDeleteOrderMessageHandlerInterface.php b/src/Core/Domain/OrderMessage/CommandHandler/BulkDeleteOrderMessageHandlerInterface.php deleted file mode 100644 index 0443dae9..00000000 --- a/src/Core/Domain/OrderMessage/CommandHandler/BulkDeleteOrderMessageHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\OrderMessage\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command\BulkDeleteOrderMessageCommand; - -/** - * Interface for service that handles deleting of order messages - */ -interface BulkDeleteOrderMessageHandlerInterface -{ - /*** - * @param BulkDeleteOrderMessageCommand $command - */ - public function handle(BulkDeleteOrderMessageCommand $command): void; -} diff --git a/src/Core/Domain/OrderMessage/CommandHandler/DeleteOrderMessageHandlerInterface.php b/src/Core/Domain/OrderMessage/CommandHandler/DeleteOrderMessageHandlerInterface.php deleted file mode 100644 index e00e07b0..00000000 --- a/src/Core/Domain/OrderMessage/CommandHandler/DeleteOrderMessageHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\OrderMessage\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command\DeleteOrderMessageCommand; - -/** - * Interface for service that handles deleting order message - */ -interface DeleteOrderMessageHandlerInterface -{ - /** - * @param DeleteOrderMessageCommand $command - */ - public function handle(DeleteOrderMessageCommand $command): void; -} diff --git a/src/Core/Domain/OrderMessage/CommandHandler/EditOrderMessageHandlerInterface.php b/src/Core/Domain/OrderMessage/CommandHandler/EditOrderMessageHandlerInterface.php deleted file mode 100644 index 19710693..00000000 --- a/src/Core/Domain/OrderMessage/CommandHandler/EditOrderMessageHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\OrderMessage\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command\EditOrderMessageCommand; - -/** - * Interface for service that handles editing order message - */ -interface EditOrderMessageHandlerInterface -{ - /** - * @param EditOrderMessageCommand $command - */ - public function handle(EditOrderMessageCommand $command): void; -} diff --git a/src/Core/Domain/OrderMessage/Exception/OrderMessageConstraintException.php b/src/Core/Domain/OrderMessage/Exception/OrderMessageConstraintException.php deleted file mode 100644 index 328bd82d..00000000 --- a/src/Core/Domain/OrderMessage/Exception/OrderMessageConstraintException.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\OrderMessage\Exception; - -class OrderMessageConstraintException extends OrderMessageException -{ -} diff --git a/src/Core/Domain/OrderMessage/Exception/OrderMessageException.php b/src/Core/Domain/OrderMessage/Exception/OrderMessageException.php deleted file mode 100644 index 1ea3e362..00000000 --- a/src/Core/Domain/OrderMessage/Exception/OrderMessageException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\OrderMessage\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for order message subdomain - */ -class OrderMessageException extends DomainException -{ - public const FAILED_DELETE = 1; - public const FAILED_BULK_DELETE = 2; -} diff --git a/src/Core/Domain/OrderMessage/Exception/OrderMessageNotFoundException.php b/src/Core/Domain/OrderMessage/Exception/OrderMessageNotFoundException.php deleted file mode 100644 index 9ab77a7b..00000000 --- a/src/Core/Domain/OrderMessage/Exception/OrderMessageNotFoundException.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\OrderMessage\Exception; - -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\ValueObject\OrderMessageId; -use Throwable; - -/** - * Thrown when order message is not found - */ -class OrderMessageNotFoundException extends OrderMessageException -{ - /** - * @var OrderMessageId - */ - private $orderMessageId; - - /** - * @param OrderMessageId $orderMessageId - * @param string $message - * @param int $code - * @param Throwable|null $previous - */ - public function __construct( - OrderMessageId $orderMessageId, - string $message = '', - int $code = 0, - Throwable $previous = null - ) { - parent::__construct($message, $code, $previous); - - $this->orderMessageId = $orderMessageId; - } - - /** - * @return OrderMessageId - */ - public function getOrderMessageId(): OrderMessageId - { - return $this->orderMessageId; - } -} diff --git a/src/Core/Domain/OrderMessage/OrderMessageConstraint.php b/src/Core/Domain/OrderMessage/OrderMessageConstraint.php deleted file mode 100644 index 095adfad..00000000 --- a/src/Core/Domain/OrderMessage/OrderMessageConstraint.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\OrderMessage; - -/** - * Defines constraints for Order message attributes - */ -class OrderMessageConstraint -{ - public const MAX_NAME_LENGTH = 128; - public const MAX_MESSAGE_LENGTH = 1200; -} diff --git a/src/Core/Domain/OrderMessage/Query/GetOrderMessageForEditing.php b/src/Core/Domain/OrderMessage/Query/GetOrderMessageForEditing.php deleted file mode 100644 index 976bc880..00000000 --- a/src/Core/Domain/OrderMessage/Query/GetOrderMessageForEditing.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\OrderMessage\Query; - -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\ValueObject\OrderMessageId; - -/** - * Get order message data for editing - */ -class GetOrderMessageForEditing -{ - /** - * @var OrderMessageId - */ - private $orderMessageId; - - /** - * @param int $orderMessageId - */ - public function __construct(int $orderMessageId) - { - $this->orderMessageId = new OrderMessageId($orderMessageId); - } - - /** - * @return OrderMessageId - */ - public function getOrderMessageId(): OrderMessageId - { - return $this->orderMessageId; - } -} diff --git a/src/Core/Domain/OrderMessage/QueryHandler/GetOrderMessageForEditingHandlerInterface.php b/src/Core/Domain/OrderMessage/QueryHandler/GetOrderMessageForEditingHandlerInterface.php deleted file mode 100644 index 9e4d0307..00000000 --- a/src/Core/Domain/OrderMessage/QueryHandler/GetOrderMessageForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\OrderMessage\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Query\GetOrderMessageForEditing; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\QueryResult\EditableOrderMessage; - -/** - * Interface for service that handles retrieving order message data - */ -interface GetOrderMessageForEditingHandlerInterface -{ - /** - * @param GetOrderMessageForEditing $query - * - * @return EditableOrderMessage - */ - public function handle(GetOrderMessageForEditing $query): EditableOrderMessage; -} diff --git a/src/Core/Domain/OrderMessage/QueryResult/EditableOrderMessage.php b/src/Core/Domain/OrderMessage/QueryResult/EditableOrderMessage.php deleted file mode 100644 index 372c6993..00000000 --- a/src/Core/Domain/OrderMessage/QueryResult/EditableOrderMessage.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\OrderMessage\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\ValueObject\OrderMessageId; - -/** - * Transfers current order message data that can be edited - */ -class EditableOrderMessage -{ - /** - * @var OrderMessageId - */ - private $orderMessageId; - - /** - * @var string[] - */ - private $localizedName; - - /** - * @var string[] - */ - private $localizedMessage; - - /** - * @param OrderMessageId $orderMessageId - * @param string[] $localizedName - * @param string[] $localizedMessage - */ - public function __construct(OrderMessageId $orderMessageId, array $localizedName, array $localizedMessage) - { - $this->orderMessageId = $orderMessageId; - $this->localizedName = $localizedName; - $this->localizedMessage = $localizedMessage; - } - - /** - * @return OrderMessageId - */ - public function getOrderMessageId(): OrderMessageId - { - return $this->orderMessageId; - } - - /** - * @return string[] - */ - public function getLocalizedName(): array - { - return $this->localizedName; - } - - /** - * @return string[] - */ - public function getLocalizedMessage(): array - { - return $this->localizedMessage; - } -} diff --git a/src/Core/Domain/OrderMessage/ValueObject/OrderMessageId.php b/src/Core/Domain/OrderMessage/ValueObject/OrderMessageId.php deleted file mode 100644 index 4c38f8c0..00000000 --- a/src/Core/Domain/OrderMessage/ValueObject/OrderMessageId.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\OrderMessage\ValueObject; - -/** - * Order message identity - */ -class OrderMessageId -{ - /** - * @var int - */ - private $orderMessageId; - - /** - * @param int $orderMessageId - */ - public function __construct(int $orderMessageId) - { - $this->orderMessageId = $orderMessageId; - } - - /** - * @return int - */ - public function getValue(): int - { - return $this->orderMessageId; - } -} diff --git a/src/Core/Domain/Product/AttributeGroup/Attribute/Command/BulkDeleteAttributeCommand.php b/src/Core/Domain/Product/AttributeGroup/Attribute/Command/BulkDeleteAttributeCommand.php deleted file mode 100644 index 693dcdc2..00000000 --- a/src/Core/Domain/Product/AttributeGroup/Attribute/Command/BulkDeleteAttributeCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Command; - -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Exception\AttributeConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\ValueObject\AttributeId; - -/** - * Deletes attributes in bulk action - */ -final class BulkDeleteAttributeCommand -{ - /** - * @var AttributeId[] - */ - private $attributeIds; - - /** - * @param int[] $attributeIds - * - * @throws AttributeConstraintException - */ - public function __construct(array $attributeIds) - { - $this->setAttributeIds($attributeIds); - } - - /** - * @return AttributeId[] - */ - public function getAttributeIds() - { - return $this->attributeIds; - } - - /** - * @param array $attributeIds - * - * @throws AttributeConstraintException - */ - private function setAttributeIds(array $attributeIds) - { - foreach ($attributeIds as $attributeId) { - $this->attributeIds[] = new AttributeId($attributeId); - } - } -} diff --git a/src/Core/Domain/Product/AttributeGroup/Attribute/Command/DeleteAttributeCommand.php b/src/Core/Domain/Product/AttributeGroup/Attribute/Command/DeleteAttributeCommand.php deleted file mode 100644 index ad99c9a3..00000000 --- a/src/Core/Domain/Product/AttributeGroup/Attribute/Command/DeleteAttributeCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Command; - -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Exception\AttributeConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\ValueObject\AttributeId; - -/** - * Deletes Attribute by provided id - */ -final class DeleteAttributeCommand -{ - /** - * @var AttributeId - */ - private $attributeId; - - /** - * @param int $attributeId - * - * @throws AttributeConstraintException - */ - public function __construct($attributeId) - { - $this->attributeId = new AttributeId($attributeId); - } - - /** - * @return AttributeId - */ - public function getAttributeId() - { - return $this->attributeId; - } -} diff --git a/src/Core/Domain/Product/AttributeGroup/Attribute/CommandHandler/BulkDeleteAttributeHandlerInterface.php b/src/Core/Domain/Product/AttributeGroup/Attribute/CommandHandler/BulkDeleteAttributeHandlerInterface.php deleted file mode 100644 index 25127656..00000000 --- a/src/Core/Domain/Product/AttributeGroup/Attribute/CommandHandler/BulkDeleteAttributeHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Command\BulkDeleteAttributeCommand; - -/** - * Interface for handling command which deletes attributes in bulk action - */ -interface BulkDeleteAttributeHandlerInterface -{ - /** - * @param BulkDeleteAttributeCommand $command - */ - public function handle(BulkDeleteAttributeCommand $command); -} diff --git a/src/Core/Domain/Product/AttributeGroup/Attribute/CommandHandler/DeleteAttributeHandlerInterface.php b/src/Core/Domain/Product/AttributeGroup/Attribute/CommandHandler/DeleteAttributeHandlerInterface.php deleted file mode 100644 index 9cd22fa0..00000000 --- a/src/Core/Domain/Product/AttributeGroup/Attribute/CommandHandler/DeleteAttributeHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Command\DeleteAttributeCommand; - -/** - * Interface for handling command which deletes Attribute - */ -interface DeleteAttributeHandlerInterface -{ - /** - * @param DeleteAttributeCommand $command - */ - public function handle(DeleteAttributeCommand $command); -} diff --git a/src/Core/Domain/Product/AttributeGroup/Attribute/Exception/AttributeConstraintException.php b/src/Core/Domain/Product/AttributeGroup/Attribute/Exception/AttributeConstraintException.php deleted file mode 100644 index fdfa8bb4..00000000 --- a/src/Core/Domain/Product/AttributeGroup/Attribute/Exception/AttributeConstraintException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Exception; - -/** - * Is thrown when attribute constraints are violated - */ -class AttributeConstraintException extends AttributeException -{ - /** - * When attribute id contains invalid values - */ - const INVALID_ID = 10; -} diff --git a/src/Core/Domain/Product/AttributeGroup/Attribute/Exception/AttributeException.php b/src/Core/Domain/Product/AttributeGroup/Attribute/Exception/AttributeException.php deleted file mode 100644 index 2a6191f9..00000000 --- a/src/Core/Domain/Product/AttributeGroup/Attribute/Exception/AttributeException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for attribute subdomain - */ -class AttributeException extends DomainException -{ -} diff --git a/src/Core/Domain/Product/AttributeGroup/Attribute/Exception/AttributeNotFoundException.php b/src/Core/Domain/Product/AttributeGroup/Attribute/Exception/AttributeNotFoundException.php deleted file mode 100644 index 80435c63..00000000 --- a/src/Core/Domain/Product/AttributeGroup/Attribute/Exception/AttributeNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Exception; - -/** - * Thrown when required attribute cannot be found - */ -class AttributeNotFoundException extends AttributeException -{ -} diff --git a/src/Core/Domain/Product/AttributeGroup/Attribute/Exception/DeleteAttributeException.php b/src/Core/Domain/Product/AttributeGroup/Attribute/Exception/DeleteAttributeException.php deleted file mode 100644 index 3bf2e7a4..00000000 --- a/src/Core/Domain/Product/AttributeGroup/Attribute/Exception/DeleteAttributeException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Exception; - -/** - * Is thrown when attribute deletion fails - */ -class DeleteAttributeException extends AttributeException -{ - /** - * When fails to delete single attribute - */ - const FAILED_DELETE = 10; - - /** - * When deleting fails in bulk action - */ - const FAILED_BULK_DELETE = 20; -} diff --git a/src/Core/Domain/Product/AttributeGroup/Attribute/ValueObject/AttributeId.php b/src/Core/Domain/Product/AttributeGroup/Attribute/ValueObject/AttributeId.php deleted file mode 100644 index 1d8ad98f..00000000 --- a/src/Core/Domain/Product/AttributeGroup/Attribute/ValueObject/AttributeId.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Exception\AttributeConstraintException; - -/** - * Provides identification data of Attribute - */ -final class AttributeId -{ - /** - * @var int - */ - private $attributeId; - - /** - * @param int $attributeId - * - * @throws AttributeConstraintException - */ - public function __construct($attributeId) - { - $this->assertIsIntegerGreaterThanZero($attributeId); - $this->attributeId = $attributeId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->attributeId; - } - - /** - * Validates that the value is integer and is greater than zero - * - * @param $value - * - * @throws AttributeConstraintException - */ - private function assertIsIntegerGreaterThanZero($value) - { - if (!is_int($value) || 0 >= $value) { - throw new AttributeConstraintException(sprintf('Invalid attribute id "%s".', var_export($value, true)), AttributeConstraintException::INVALID_ID); - } - } -} diff --git a/src/Core/Domain/Product/AttributeGroup/Command/BulkDeleteAttributeGroupCommand.php b/src/Core/Domain/Product/AttributeGroup/Command/BulkDeleteAttributeGroupCommand.php deleted file mode 100644 index 1112d6bc..00000000 --- a/src/Core/Domain/Product/AttributeGroup/Command/BulkDeleteAttributeGroupCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Command; - -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception\AttributeGroupConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\ValueObject\AttributeGroupId; - -/** - * Deletes attribute groups in bulk action by provided ids - */ -final class BulkDeleteAttributeGroupCommand -{ - /** - * @var AttributeGroupId[] - */ - private $attributeGroupIds; - - /** - * @param int[] $attributeGroupIds - * - * @throws AttributeGroupConstraintException - */ - public function __construct(array $attributeGroupIds) - { - $this->setAttributeGroupIds($attributeGroupIds); - } - - /** - * @return AttributeGroupId[] - */ - public function getAttributeGroupIds() - { - return $this->attributeGroupIds; - } - - /** - * @param array $attributeGroupIds - * - * @throws AttributeGroupConstraintException - */ - private function setAttributeGroupIds(array $attributeGroupIds) - { - foreach ($attributeGroupIds as $attributeGroupId) { - $this->attributeGroupIds[] = new AttributeGroupId($attributeGroupId); - } - } -} diff --git a/src/Core/Domain/Product/AttributeGroup/Command/DeleteAttributeGroupCommand.php b/src/Core/Domain/Product/AttributeGroup/Command/DeleteAttributeGroupCommand.php deleted file mode 100644 index b454926f..00000000 --- a/src/Core/Domain/Product/AttributeGroup/Command/DeleteAttributeGroupCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Command; - -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception\AttributeGroupConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\ValueObject\AttributeGroupId; - -/** - * Deletes attribute group by provided id - */ -final class DeleteAttributeGroupCommand -{ - /** - * @var AttributeGroupId - */ - private $attributeGroupId; - - /** - * @param int $attributeGroupId - * - * @throws AttributeGroupConstraintException - */ - public function __construct($attributeGroupId) - { - $this->attributeGroupId = new AttributeGroupId($attributeGroupId); - } - - /** - * @return AttributeGroupId - */ - public function getAttributeGroupId() - { - return $this->attributeGroupId; - } -} diff --git a/src/Core/Domain/Product/AttributeGroup/CommandHandler/BulkDeleteAttributeGroupHandlerInterface.php b/src/Core/Domain/Product/AttributeGroup/CommandHandler/BulkDeleteAttributeGroupHandlerInterface.php deleted file mode 100644 index 49b99346..00000000 --- a/src/Core/Domain/Product/AttributeGroup/CommandHandler/BulkDeleteAttributeGroupHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Command\BulkDeleteAttributeGroupCommand; - -/** - * Interface for handling command which deletes mutliple attribute groups - */ -interface BulkDeleteAttributeGroupHandlerInterface -{ - /** - * @param BulkDeleteAttributeGroupCommand $command - */ - public function handle(BulkDeleteAttributeGroupCommand $command); -} diff --git a/src/Core/Domain/Product/AttributeGroup/CommandHandler/DeleteAttributeGroupHandlerInterface.php b/src/Core/Domain/Product/AttributeGroup/CommandHandler/DeleteAttributeGroupHandlerInterface.php deleted file mode 100644 index f3430de1..00000000 --- a/src/Core/Domain/Product/AttributeGroup/CommandHandler/DeleteAttributeGroupHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Command\DeleteAttributeGroupCommand; - -/** - * Interface for handling command which deletes attribute group - */ -interface DeleteAttributeGroupHandlerInterface -{ - /** - * @param DeleteAttributeGroupCommand $command - */ - public function handle(DeleteAttributeGroupCommand $command); -} diff --git a/src/Core/Domain/Product/AttributeGroup/Exception/AttributeGroupConstraintException.php b/src/Core/Domain/Product/AttributeGroup/Exception/AttributeGroupConstraintException.php deleted file mode 100644 index 519b75d8..00000000 --- a/src/Core/Domain/Product/AttributeGroup/Exception/AttributeGroupConstraintException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception; - -/** - * Is thrown when attribute group constraints are violated - */ -class AttributeGroupConstraintException extends AttributeGroupException -{ - /** - * When attribute group Id contains invalid values - */ - const INVALID_ID = 10; -} diff --git a/src/Core/Domain/Product/AttributeGroup/Exception/AttributeGroupException.php b/src/Core/Domain/Product/AttributeGroup/Exception/AttributeGroupException.php deleted file mode 100644 index 2de43786..00000000 --- a/src/Core/Domain/Product/AttributeGroup/Exception/AttributeGroupException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for attribute group subdomain - */ -class AttributeGroupException extends DomainException -{ -} diff --git a/src/Core/Domain/Product/AttributeGroup/Exception/AttributeGroupNotFoundException.php b/src/Core/Domain/Product/AttributeGroup/Exception/AttributeGroupNotFoundException.php deleted file mode 100644 index 28a37d0f..00000000 --- a/src/Core/Domain/Product/AttributeGroup/Exception/AttributeGroupNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception; - -/** - * Is thrown when required attribute group cannot be found - */ -class AttributeGroupNotFoundException extends AttributeGroupException -{ -} diff --git a/src/Core/Domain/Product/AttributeGroup/Exception/DeleteAttributeGroupException.php b/src/Core/Domain/Product/AttributeGroup/Exception/DeleteAttributeGroupException.php deleted file mode 100644 index 09337e74..00000000 --- a/src/Core/Domain/Product/AttributeGroup/Exception/DeleteAttributeGroupException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception; - -/** - * Is thrown when deleting attribute group fails - */ -class DeleteAttributeGroupException extends AttributeGroupException -{ - /** - * When trying to delete single attribute group fails - */ - const FAILED_DELETE = 10; - - /** - * When deleting in bulk action fails - */ - const FAILED_BULK_DELETE = 20; -} diff --git a/src/Core/Domain/Product/AttributeGroup/ValueObject/AttributeGroupId.php b/src/Core/Domain/Product/AttributeGroup/ValueObject/AttributeGroupId.php deleted file mode 100644 index 1bff90a4..00000000 --- a/src/Core/Domain/Product/AttributeGroup/ValueObject/AttributeGroupId.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception\AttributeGroupConstraintException; - -/** - * Provides attribute group identification data - */ -final class AttributeGroupId -{ - /** - * @var int - */ - private $attributeGroupId; - - /** - * @param int $attributeGroupId - * - * @throws AttributeGroupConstraintException - */ - public function __construct($attributeGroupId) - { - $this->assertIsIntegerGreaterThanZero($attributeGroupId); - $this->attributeGroupId = $attributeGroupId; - } - - /** - * @return mixed - */ - public function getAttributeGroupId() - { - return $this->attributeGroupId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->attributeGroupId; - } - - /** - * Validates that the value is integer and is greater than zero - * - * @param $value - * - * @throws AttributeGroupConstraintException - */ - private function assertIsIntegerGreaterThanZero($value) - { - if (!is_int($value) || 0 >= $value) { - throw new AttributeGroupConstraintException(sprintf('Invalid attribute group id "%s".', var_export($value, true)), AttributeGroupConstraintException::INVALID_ID); - } - } -} diff --git a/src/Core/Domain/Product/Combination/Exception/CombinationConstraintException.php b/src/Core/Domain/Product/Combination/Exception/CombinationConstraintException.php deleted file mode 100644 index 0aebfa04..00000000 --- a/src/Core/Domain/Product/Combination/Exception/CombinationConstraintException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Combination\Exception; - -/** - * Thrown when combination constraints are violated - */ -class CombinationConstraintException extends CombinationException -{ - const INVALID_ID = 1; -} diff --git a/src/Core/Domain/Product/Combination/Exception/CombinationException.php b/src/Core/Domain/Product/Combination/Exception/CombinationException.php deleted file mode 100644 index daf7f982..00000000 --- a/src/Core/Domain/Product/Combination/Exception/CombinationException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Combination\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for product combination subdomain - */ -class CombinationException extends DomainException -{ -} diff --git a/src/Core/Domain/Product/Combination/ValueObject/CombinationId.php b/src/Core/Domain/Product/Combination/ValueObject/CombinationId.php deleted file mode 100644 index 80498257..00000000 --- a/src/Core/Domain/Product/Combination/ValueObject/CombinationId.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Combination\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Product\Combination\Exception\CombinationConstraintException; - -/** - * Holds product combination identification data - */ -class CombinationId -{ - /** - * @var int - */ - private $combinationId; - - /** - * @param int $combinationId - * - * @throws CombinationConstraintException - */ - public function __construct(int $combinationId) - { - $this->assertValueIsPositive($combinationId); - $this->combinationId = $combinationId; - } - - /** - * @return int - */ - public function getValue(): int - { - return $this->combinationId; - } - - /** - * @param int $value - * - * @throws CombinationConstraintException - */ - private function assertValueIsPositive(int $value) - { - if (0 >= $value) { - throw new CombinationConstraintException(sprintf('Combination id must be positive integer. "%s" given', $value), CombinationConstraintException::INVALID_ID); - } - } -} diff --git a/src/Core/Domain/Product/Command/AssignProductToCategoryCommand.php b/src/Core/Domain/Product/Command/AssignProductToCategoryCommand.php deleted file mode 100644 index 0b481d9e..00000000 --- a/src/Core/Domain/Product/Command/AssignProductToCategoryCommand.php +++ /dev/null @@ -1,100 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Command; - -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; - -/** - * Class AssignProductToCategoryCommand adds a product to a category. - */ -class AssignProductToCategoryCommand -{ - /** - * @var CategoryId - */ - private $categoryId; - - /** - * @var ProductId - */ - private $productId; - - /** - * @param int $categoryId - * @param int $productId - * - * @throws CategoryConstraintException - * @throws ProductConstraintException */ - public function __construct($categoryId, $productId) - { - $this->setCategoryId($categoryId); - $this->setProductId($productId); - } - - /** - * @param int $categoryId - * - * @return self - */ - public function setCategoryId(int $categoryId): AssignProductToCategoryCommand - { - $this->categoryId = new CategoryId($categoryId); - - return $this; - } - - /** - * @return CategoryId - */ - public function getCategoryId(): CategoryId - { - return $this->categoryId; - } - - /** - * @param int $productId - * - * @return self - */ - public function setProductId(int $productId): AssignProductToCategoryCommand - { - $this->productId = new ProductId($productId); - - return $this; - } - - /** - * @return ProductId - */ - public function getProductId(): ProductId - { - return $this->productId; - } -} diff --git a/src/Core/Domain/Product/Command/UpdateProductStatusCommand.php b/src/Core/Domain/Product/Command/UpdateProductStatusCommand.php deleted file mode 100644 index 2956e50e..00000000 --- a/src/Core/Domain/Product/Command/UpdateProductStatusCommand.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Command; - -use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; - -/** - * Class UpdateProductStatusCommand update a given product status - */ -class UpdateProductStatusCommand -{ - /** - * @var ProductId - */ - private $productId; - - /** - * @var bool - */ - private $enable; - - /** - * UpdateProductStatusCommand constructor. - * - * @param int $productId - * @param bool $enable - */ - public function __construct(int $productId, bool $enable) - { - $this->productId = new ProductId($productId); - $this->enable = $enable; - } - - /** - * @return ProductId - */ - public function getProductId(): ProductId - { - return $this->productId; - } - - /** - * @return bool - */ - public function getEnable(): bool - { - return $this->enable; - } -} diff --git a/src/Core/Domain/Product/CommandHandler/AssignProductToCategoryHandlerInterface.php b/src/Core/Domain/Product/CommandHandler/AssignProductToCategoryHandlerInterface.php deleted file mode 100644 index 5e28e9b8..00000000 --- a/src/Core/Domain/Product/CommandHandler/AssignProductToCategoryHandlerInterface.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Product\Command\AssignProductToCategoryCommand; - -interface AssignProductToCategoryHandlerInterface -{ - /** - * @param AssignProductToCategoryCommand $command - */ - public function handle(AssignProductToCategoryCommand $command); -} diff --git a/src/Core/Domain/Product/CommandHandler/UpdateProductStatusCommandHandlerInterface.php b/src/Core/Domain/Product/CommandHandler/UpdateProductStatusCommandHandlerInterface.php deleted file mode 100644 index 6752d5e8..00000000 --- a/src/Core/Domain/Product/CommandHandler/UpdateProductStatusCommandHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Product\Command\UpdateProductStatusCommand; - -/** - * Interface for service that set product to be enabled or disabled - */ -interface UpdateProductStatusCommandHandlerInterface -{ - /** - * @param UpdateProductStatusCommand $command - */ - public function handle(UpdateProductStatusCommand $command); -} diff --git a/src/Core/Domain/Product/Customization/CustomizationSettings.php b/src/Core/Domain/Product/Customization/CustomizationSettings.php deleted file mode 100644 index 35aba928..00000000 --- a/src/Core/Domain/Product/Customization/CustomizationSettings.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Customization; - -/** - * Defines settings for customizations - */ -final class CustomizationSettings -{ - /** - * Maximum allowed length for customization text field value - */ - const MAX_TEXT_LENGTH = 255; -} diff --git a/src/Core/Domain/Product/Customization/Exception/CustomizationConstraintException.php b/src/Core/Domain/Product/Customization/Exception/CustomizationConstraintException.php deleted file mode 100644 index 0186f7f3..00000000 --- a/src/Core/Domain/Product/Customization/Exception/CustomizationConstraintException.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Customization\Exception; - -/** - * Thrown when customization constraints are violated - */ -class CustomizationConstraintException extends CustomizationException -{ - /** - * When customization field is required to be filled - */ - const FIELD_IS_REQUIRED = 1; - - /** - * When customization field value length is exceeded - */ - const FIELD_IS_TOO_LONG = 2; - - /** - * When customization id is invalid - */ - const INVALID_ID = 3; -} diff --git a/src/Core/Domain/Product/Customization/Exception/CustomizationException.php b/src/Core/Domain/Product/Customization/Exception/CustomizationException.php deleted file mode 100644 index 6a3d3b6a..00000000 --- a/src/Core/Domain/Product/Customization/Exception/CustomizationException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Customization\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductException; - -/** - * Base exception for Product/Customization subdomain - */ -class CustomizationException extends ProductException -{ -} diff --git a/src/Core/Domain/Product/Customization/ValueObject/CustomizationId.php b/src/Core/Domain/Product/Customization/ValueObject/CustomizationId.php deleted file mode 100644 index 3f873283..00000000 --- a/src/Core/Domain/Product/Customization/ValueObject/CustomizationId.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Customization\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Product\Customization\Exception\CustomizationConstraintException; - -/** - * Holds product customization identification data - */ -class CustomizationId -{ - /** - * @var int - */ - private $customizationId; - - /** - * @param int $customizationId - */ - public function __construct(int $customizationId) - { - $this->customizationId = $customizationId; - } - - /** - * @return int - */ - public function getValue(): int - { - return $this->customizationId; - } - - /** - * @param int $value - * - * @throws CustomizationConstraintException - */ - private function assertValueIsPositive(int $value) - { - if (0 >= $value) { - throw new CustomizationConstraintException(sprintf('Customization id must be positive integer. "%s" given', $value), CustomizationConstraintException::INVALID_ID); - } - } -} diff --git a/src/Core/Domain/Product/Exception/CannotAssignProductToCategoryException.php b/src/Core/Domain/Product/Exception/CannotAssignProductToCategoryException.php deleted file mode 100644 index 9d5eaf7e..00000000 --- a/src/Core/Domain/Product/Exception/CannotAssignProductToCategoryException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Exception; - -/** - * Is thrown when the assignation of a product to a category failed - */ -class CannotAssignProductToCategoryException extends ProductException -{ -} diff --git a/src/Core/Domain/Product/Exception/CannotUpdateProductException.php b/src/Core/Domain/Product/Exception/CannotUpdateProductException.php deleted file mode 100644 index 0de10d49..00000000 --- a/src/Core/Domain/Product/Exception/CannotUpdateProductException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Exception; - -/** - * Is thrown when updating a product failed - */ -class CannotUpdateProductException extends ProductException -{ -} diff --git a/src/Core/Domain/Product/Exception/ProductConstraintException.php b/src/Core/Domain/Product/Exception/ProductConstraintException.php deleted file mode 100644 index 05e693da..00000000 --- a/src/Core/Domain/Product/Exception/ProductConstraintException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Exception; - -class ProductConstraintException extends ProductException -{ - /** - * Code is used when invalid id is supplied. - */ - const INVALID_ID = 10; -} diff --git a/src/Core/Domain/Product/Exception/ProductCustomizationNotFoundException.php b/src/Core/Domain/Product/Exception/ProductCustomizationNotFoundException.php deleted file mode 100644 index 11b905aa..00000000 --- a/src/Core/Domain/Product/Exception/ProductCustomizationNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Exception; - -/** - * Is thrown when the customization of a product is not found - */ -class ProductCustomizationNotFoundException extends ProductException -{ -} diff --git a/src/Core/Domain/Product/Exception/ProductException.php b/src/Core/Domain/Product/Exception/ProductException.php deleted file mode 100644 index d02e67a4..00000000 --- a/src/Core/Domain/Product/Exception/ProductException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Is base exception for Product subdomain - */ -class ProductException extends DomainException -{ -} diff --git a/src/Core/Domain/Product/Exception/ProductNotFoundException.php b/src/Core/Domain/Product/Exception/ProductNotFoundException.php deleted file mode 100644 index 6a35cb5b..00000000 --- a/src/Core/Domain/Product/Exception/ProductNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Exception; - -/** - * Is thrown when product is not found - */ -class ProductNotFoundException extends ProductException -{ -} diff --git a/src/Core/Domain/Product/Exception/ProductOutOfStockException.php b/src/Core/Domain/Product/Exception/ProductOutOfStockException.php deleted file mode 100644 index 1c436719..00000000 --- a/src/Core/Domain/Product/Exception/ProductOutOfStockException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Exception; - -/** - * Is thrown when using product (e.g. adding to cart) which is out of stock - */ -class ProductOutOfStockException extends ProductException -{ -} diff --git a/src/Core/Domain/Product/Query/GetProductIsEnabled.php b/src/Core/Domain/Product/Query/GetProductIsEnabled.php deleted file mode 100644 index c04d9383..00000000 --- a/src/Core/Domain/Product/Query/GetProductIsEnabled.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Query; - -use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; - -/** - * Get current status (enabled/disabled) for a given product - */ -class GetProductIsEnabled -{ - /** - * @var ProductId - */ - private $productId; - - /** - * GetProductIsEnabled constructor. - * - * @param int $productId - */ - public function __construct(int $productId) - { - $this->productId = new ProductId($productId); - } - - /** - * @return ProductId - */ - public function getProductId(): ProductId - { - return $this->productId; - } -} diff --git a/src/Core/Domain/Product/Query/SearchProducts.php b/src/Core/Domain/Product/Query/SearchProducts.php deleted file mode 100644 index 139762aa..00000000 --- a/src/Core/Domain/Product/Query/SearchProducts.php +++ /dev/null @@ -1,137 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\Query; - -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\AlphaIsoCode; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\Order\ValueObject\OrderId; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductException; - -/** - * Queries for products by provided search phrase - */ -class SearchProducts -{ - /** - * @var string - */ - private $phrase; - - /** - * @var int - */ - private $resultsLimit; - - /** - * @var AlphaIsoCode - */ - private $alphaIsoCode; - - /** - * @var OrderId|null - */ - private $orderId; - - /** - * @param string $phrase - * @param int $resultsLimit - * @param string $isoCode - * @param int|null $orderId - * - * @throws ProductException - * @throws CurrencyConstraintException - */ - public function __construct( - string $phrase, - int $resultsLimit, - string $isoCode, - ?int $orderId = null - ) { - $this->assertIsNotEmptyString($phrase); - $this->phrase = $phrase; - $this->resultsLimit = $resultsLimit; - $this->alphaIsoCode = new AlphaIsoCode($isoCode); - if (null !== $orderId) { - $this->setOrderId($orderId); - } - } - - /** - * @return AlphaIsoCode - */ - public function getAlphaIsoCode(): AlphaIsoCode - { - return $this->alphaIsoCode; - } - - /** - * @return string - */ - public function getPhrase() - { - return $this->phrase; - } - - /** - * @return int - */ - public function getResultsLimit(): int - { - return $this->resultsLimit; - } - - /** - * @return OrderId|null - */ - public function getOrderId(): ?OrderId - { - return $this->orderId; - } - - /** - * @param int $orderId - * - * @throws OrderException - */ - private function setOrderId(int $orderId): void - { - $this->orderId = new OrderId($orderId); - } - - /** - * @param string $phrase - * - * @throws ProductException - */ - private function assertIsNotEmptyString(string $phrase): void - { - if (empty($phrase) || !is_string($phrase)) { - throw new ProductException('Product search phrase must be a not empty string'); - } - } -} diff --git a/src/Core/Domain/Product/QueryHandler/GetProductIsEnabledHandlerInterface.php b/src/Core/Domain/Product/QueryHandler/GetProductIsEnabledHandlerInterface.php deleted file mode 100644 index 62106426..00000000 --- a/src/Core/Domain/Product/QueryHandler/GetProductIsEnabledHandlerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Product\Query\GetProductIsEnabled; - -/** - * Interface for service that handles getting product status. - */ -interface GetProductIsEnabledHandlerInterface -{ - /** - * @param GetProductIsEnabled $query - * - * @return bool - */ - public function handle(GetProductIsEnabled $query); -} diff --git a/src/Core/Domain/Product/QueryHandler/SearchProductsHandlerInterface.php b/src/Core/Domain/Product/QueryHandler/SearchProductsHandlerInterface.php deleted file mode 100644 index 5e1a8b0b..00000000 --- a/src/Core/Domain/Product/QueryHandler/SearchProductsHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Product\Query\SearchProducts; -use PrestaShop\PrestaShop\Core\Domain\Product\QueryResult\FoundProduct; - -/** - * Interface for handling SearchProducts query - */ -interface SearchProductsHandlerInterface -{ - /** - * @param SearchProducts $query - * - * @return FoundProduct[] - */ - public function handle(SearchProducts $query): array; -} diff --git a/src/Core/Domain/Product/QueryResult/FoundProduct.php b/src/Core/Domain/Product/QueryResult/FoundProduct.php deleted file mode 100644 index f4a9b8a0..00000000 --- a/src/Core/Domain/Product/QueryResult/FoundProduct.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\QueryResult; - -/** - * DTO for product that was found by search - */ -class FoundProduct -{ - /** - * @var bool - */ - private $availableOutOfStock; - - /** - * @var int - */ - private $productId; - - /** - * @var string - */ - private $name; - - /** - * @var float - */ - private $taxRate; - - /** - * @var string - */ - private $formattedPrice; - - /** - * @var float - */ - private $priceTaxIncl; - - /** - * @var float - */ - private $priceTaxExcl; - - /** - * @var int - */ - private $stock; - - /** - * @var string - */ - private $location; - - /** - * @var ProductCombination[] - */ - private $combinations; - - /** - * @var ProductCustomizationField[] - */ - private $customizationFields; - - /** - * @param int $productId - * @param string $name - * @param string $formattedPrice - * @param float $priceTaxIncl - * @param float $priceTaxExcl - * @param float $taxRate - * @param int $stock - * @param string $location - * @param bool $availableOutOfStock - * @param ProductCombination[] $combinations - * @param ProductCustomizationField[] $customizationFields - */ - public function __construct( - int $productId, - string $name, - string $formattedPrice, - float $priceTaxIncl, - float $priceTaxExcl, - float $taxRate, - int $stock, - string $location, - bool $availableOutOfStock, - array $combinations = [], - array $customizationFields = [] - ) { - $this->productId = $productId; - $this->name = $name; - $this->formattedPrice = $formattedPrice; - $this->priceTaxIncl = $priceTaxIncl; - $this->priceTaxExcl = $priceTaxExcl; - $this->taxRate = $taxRate; - $this->stock = $stock; - $this->location = $location; - $this->availableOutOfStock = $availableOutOfStock; - $this->combinations = $combinations; - $this->customizationFields = $customizationFields; - } - - /** - * @return int - */ - public function getProductId(): int - { - return $this->productId; - } - - /** - * @return string - */ - public function getLocation(): string - { - return $this->location; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return string - */ - public function getFormattedPrice(): string - { - return $this->formattedPrice; - } - - /** - * @return float - */ - public function getPriceTaxIncl(): float - { - return $this->priceTaxIncl; - } - - /** - * @return float - */ - public function getPriceTaxExcl(): float - { - return $this->priceTaxExcl; - } - - /** - * @return int - */ - public function getStock(): int - { - return $this->stock; - } - - /** - * @return float - */ - public function getTaxRate(): float - { - return $this->taxRate; - } - - /** - * @return ProductCombination[] - */ - public function getCombinations(): array - { - return $this->combinations; - } - - /** - * @return ProductCustomizationField[] - */ - public function getCustomizationFields(): array - { - return $this->customizationFields; - } - - /** - * @return bool - */ - public function isAvailableOutOfStock(): bool - { - return $this->availableOutOfStock; - } -} diff --git a/src/Core/Domain/Product/QueryResult/ProductCombination.php b/src/Core/Domain/Product/QueryResult/ProductCombination.php deleted file mode 100644 index dad96872..00000000 --- a/src/Core/Domain/Product/QueryResult/ProductCombination.php +++ /dev/null @@ -1,177 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Product\QueryResult; - -/** - * Holds product combination data - */ -class ProductCombination -{ - /** - * @var int - */ - private $attributeCombinationId; - - /** - * @var string - */ - private $attribute; - - /** - * @var string - */ - private $location; - - /** - * @var string - */ - private $reference; - - /** - * @var int - */ - private $stock; - - /** - * @var float - */ - private $priceTaxExcluded; - - /** - * @var float - */ - private $priceTaxIncluded; - - /** - * @var string - */ - private $formattedPrice; - - /** - * @param int $attributeCombinationId - * @param string $attribute - * @param int $stock - * @param string $formattedPrice - * @param float $priceTaxExcluded - * @param float $priceTaxIncluded - * @param string $location - * @param string $reference - */ - public function __construct( - int $attributeCombinationId, - string $attribute, - int $stock, - string $formattedPrice, - float $priceTaxExcluded, - float $priceTaxIncluded, - string $location, - string $reference - ) { - $this->attributeCombinationId = $attributeCombinationId; - $this->attribute = $attribute; - $this->stock = $stock; - $this->formattedPrice = $formattedPrice; - $this->priceTaxExcluded = $priceTaxExcluded; - $this->priceTaxIncluded = $priceTaxIncluded; - $this->location = $location; - $this->reference = $reference; - } - - /** - * @return int - */ - public function getAttributeCombinationId(): int - { - return $this->attributeCombinationId; - } - - /** - * @return string - */ - public function getAttribute(): string - { - return $this->attribute; - } - - /** - * @return string - */ - public function getLocation(): string - { - return $this->location; - } - - /** - * @return float - */ - public function getPriceTaxExcluded(): float - { - return $this->priceTaxExcluded; - } - - /** - * @return float - */ - public function getPriceTaxIncluded(): float - { - return $this->priceTaxIncluded; - } - - /** - * @return int - */ - public function getStock(): int - { - return $this->stock; - } - - /** - * @return string - */ - public function getFormattedPrice(): string - { - return $this->formattedPrice; - } - - /** - * @return string - */ - public function getReference(): string - { - return $this->reference; - } - - /** - * @param string $name - */ - public function appendAttributeName(string $name) - { - $this->attribute .= ' - ' . $name; - } -} diff --git a/src/Core/Domain/Product/QueryResult/ProductCustomizationField.php b/src/Core/Domain/Product/QueryResult/ProductCustomizationField.php deleted file mode 100644 index 8d5ff6ef..00000000 --- a/src/Core/Domain/Product/QueryResult/ProductCustomizationField.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\QueryResult; - -/** - * Holds data of product customization field - */ -class ProductCustomizationField -{ - const TYPE_FILE = 0; - const TYPE_TEXT = 1; - - /** - * @var int - */ - private $customizationFieldId; - - /** - * @var int - */ - private $type; - - /** - * @var string - */ - private $name; - - /** - * @var bool - */ - private $isRequired; - - /** - * @param int $customizationFieldId - * @param int $type - * @param string $name - * @param bool $isRequired - */ - public function __construct( - int $customizationFieldId, - int $type, - string $name, - bool $isRequired - ) { - $this->customizationFieldId = $customizationFieldId; - $this->type = $type; - $this->name = $name; - $this->isRequired = $isRequired; - } - - /** - * @return int - */ - public function getCustomizationFieldId(): int - { - return $this->customizationFieldId; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return int - */ - public function getType(): int - { - return $this->type; - } - - /** - * @return bool - */ - public function isRequired(): bool - { - return $this->isRequired; - } -} diff --git a/src/Core/Domain/Product/ValueObject/ProductId.php b/src/Core/Domain/Product/ValueObject/ProductId.php deleted file mode 100644 index 16fa8f10..00000000 --- a/src/Core/Domain/Product/ValueObject/ProductId.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Product\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductConstraintException; - -/** - * Product identity. - */ -class ProductId -{ - /** - * @var int - */ - private $productId; - - /** - * @param int $productId - */ - public function __construct($productId) - { - $this->assertIntegerIsGreaterThanZero($productId); - - $this->productId = $productId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->productId; - } - - /** - * @param int $productId - */ - private function assertIntegerIsGreaterThanZero($productId) - { - if (!is_int($productId) || 0 > $productId) { - throw new ProductConstraintException(sprintf('Product id %s is invalid. Product id must be number that is greater than zero.', var_export($productId, true))); - } - } -} diff --git a/src/Core/Domain/Profile/Command/AbstractProfileCommand.php b/src/Core/Domain/Profile/Command/AbstractProfileCommand.php deleted file mode 100644 index 5f5d08fa..00000000 --- a/src/Core/Domain/Profile/Command/AbstractProfileCommand.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\Command; - -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\ProfileConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\ProfileException; -use PrestaShop\PrestaShop\Core\Domain\Profile\ProfileSettings; - -abstract class AbstractProfileCommand -{ - /** - * @var string[] - */ - protected $localizedNames; - - /** - * @param string[] $localizedNames - * - * @throws ProfileConstraintException - */ - public function __construct(array $localizedNames) - { - if (empty($localizedNames)) { - throw new ProfileException('Profile name cannot be empty'); - } - - foreach ($localizedNames as $localizedName) { - $this->assertNameIsStringAndRequiredLength($localizedName); - } - $this->localizedNames = $localizedNames; - } - - /** - * @return string[] - */ - public function getLocalizedNames() - { - return $this->localizedNames; - } - - /** - * @param string $name - */ - protected function assertNameIsStringAndRequiredLength($name) - { - if (null !== $name && !is_string($name) || strlen($name) > ProfileSettings::NAME_MAX_LENGTH) { - throw new ProfileConstraintException(sprintf('Profile name should not exceed %d characters length but %s given', ProfileSettings::NAME_MAX_LENGTH, var_export($name, true)), ProfileConstraintException::INVALID_NAME); - } - } -} diff --git a/src/Core/Domain/Profile/Command/AddProfileCommand.php b/src/Core/Domain/Profile/Command/AddProfileCommand.php deleted file mode 100644 index 56014050..00000000 --- a/src/Core/Domain/Profile/Command/AddProfileCommand.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\Command; - -/** - * Adds new profile - */ -class AddProfileCommand extends AbstractProfileCommand -{ -} diff --git a/src/Core/Domain/Profile/Command/BulkDeleteProfileCommand.php b/src/Core/Domain/Profile/Command/BulkDeleteProfileCommand.php deleted file mode 100644 index e5506b06..00000000 --- a/src/Core/Domain/Profile/Command/BulkDeleteProfileCommand.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\Command; - -use PrestaShop\PrestaShop\Core\Domain\Profile\ValueObject\ProfileId; - -/** - * Class BulkDeleteProfileCommand is a command to bulk delete profiles by given ids. - */ -class BulkDeleteProfileCommand -{ - /** - * @var ProfileId[] - */ - private $profileIds = []; - - /** - * @param array $profileIds - */ - public function __construct(array $profileIds) - { - $this->setProfileIds($profileIds); - } - - /** - * @return ProfileId[] - */ - public function getProfileIds() - { - return $this->profileIds; - } - - /** - * @param array $profileIds - */ - private function setProfileIds(array $profileIds) - { - foreach ($profileIds as $profileId) { - $this->profileIds[] = new ProfileId((int) $profileId); - } - } -} diff --git a/src/Core/Domain/Profile/Command/DeleteProfileCommand.php b/src/Core/Domain/Profile/Command/DeleteProfileCommand.php deleted file mode 100644 index ae6346f8..00000000 --- a/src/Core/Domain/Profile/Command/DeleteProfileCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\Command; - -use PrestaShop\PrestaShop\Core\Domain\Profile\ValueObject\ProfileId; - -/** - * Class DeleteProfileCommand is a command to delete profile by given id. - */ -class DeleteProfileCommand -{ - /** - * @var ProfileId - */ - private $profileId; - - /** - * @param int $profileId - */ - public function __construct($profileId) - { - $this->profileId = new ProfileId((int) $profileId); - } - - /** - * @return ProfileId - */ - public function getProfileId() - { - return $this->profileId; - } -} diff --git a/src/Core/Domain/Profile/Command/EditProfileCommand.php b/src/Core/Domain/Profile/Command/EditProfileCommand.php deleted file mode 100644 index eb9284ae..00000000 --- a/src/Core/Domain/Profile/Command/EditProfileCommand.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\Command; - -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\ProfileException; -use PrestaShop\PrestaShop\Core\Domain\Profile\ValueObject\ProfileId; - -/** - * Edits existing Profile - */ -class EditProfileCommand extends AbstractProfileCommand -{ - /** - * @var ProfileId - */ - private $profileId; - - /** - * @param int $profileId - * @param string[] $localizedNames - * - * @throws ProfileException - */ - public function __construct($profileId, array $localizedNames) - { - parent::__construct($localizedNames); - $this->profileId = new ProfileId((int) $profileId); - } - - /** - * @return ProfileId - */ - public function getProfileId() - { - return $this->profileId; - } -} diff --git a/src/Core/Domain/Profile/CommandHandler/AddProfileHandlerInterface.php b/src/Core/Domain/Profile/CommandHandler/AddProfileHandlerInterface.php deleted file mode 100644 index 75a1411f..00000000 --- a/src/Core/Domain/Profile/CommandHandler/AddProfileHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Profile\Command\AddProfileCommand; -use PrestaShop\PrestaShop\Core\Domain\Profile\ValueObject\ProfileId; - -/** - * Interface for service that handles adding new profile - */ -interface AddProfileHandlerInterface -{ - /** - * @param AddProfileCommand $command - * - * @return ProfileId - */ - public function handle(AddProfileCommand $command); -} diff --git a/src/Core/Domain/Profile/CommandHandler/BulkDeleteProfileHandlerInterface.php b/src/Core/Domain/Profile/CommandHandler/BulkDeleteProfileHandlerInterface.php deleted file mode 100644 index 53a943de..00000000 --- a/src/Core/Domain/Profile/CommandHandler/BulkDeleteProfileHandlerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Profile\Command\BulkDeleteProfileCommand; - -/** - * Interface BulkDeleteProfileHandlerInterface defines profile bulk deletion handler. - */ -interface BulkDeleteProfileHandlerInterface -{ - /** - * Delete multiple profiles. - * - * @param BulkDeleteProfileCommand $command - */ - public function handle(BulkDeleteProfileCommand $command); -} diff --git a/src/Core/Domain/Profile/CommandHandler/DeleteProfileHandlerInterface.php b/src/Core/Domain/Profile/CommandHandler/DeleteProfileHandlerInterface.php deleted file mode 100644 index b1d764ec..00000000 --- a/src/Core/Domain/Profile/CommandHandler/DeleteProfileHandlerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Profile\Command\DeleteProfileCommand; - -/** - * Interface DeleteProfileHandlerInterface defines profile deletion handler. - */ -interface DeleteProfileHandlerInterface -{ - /** - * Delete profile. - * - * @param DeleteProfileCommand $command - */ - public function handle(DeleteProfileCommand $command); -} diff --git a/src/Core/Domain/Profile/CommandHandler/EditProfileHandlerInterface.php b/src/Core/Domain/Profile/CommandHandler/EditProfileHandlerInterface.php deleted file mode 100644 index 0972802b..00000000 --- a/src/Core/Domain/Profile/CommandHandler/EditProfileHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Profile\Command\EditProfileCommand; - -/** - * Interface for service that edits existing Profile - */ -interface EditProfileHandlerInterface -{ - /** - * @param EditProfileCommand $command - */ - public function handle(EditProfileCommand $command); -} diff --git a/src/Core/Domain/Profile/Exception/CannotDeleteSuperAdminProfileException.php b/src/Core/Domain/Profile/Exception/CannotDeleteSuperAdminProfileException.php deleted file mode 100644 index 69df4505..00000000 --- a/src/Core/Domain/Profile/Exception/CannotDeleteSuperAdminProfileException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\Exception; - -/** - * Class CannotDeleteSuperAdminProfileException thrown on super admin profile deletion attempt. - */ -class CannotDeleteSuperAdminProfileException extends ProfileException -{ -} diff --git a/src/Core/Domain/Profile/Exception/FailedToDeleteProfileException.php b/src/Core/Domain/Profile/Exception/FailedToDeleteProfileException.php deleted file mode 100644 index 47d2698e..00000000 --- a/src/Core/Domain/Profile/Exception/FailedToDeleteProfileException.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\Exception; - -/** - * Class FailedToDeleteProfileException is thrown when Profile deletion fails. - */ -class FailedToDeleteProfileException extends ProfileException -{ - /** - * Code is used when cannot delete profile because it is assigned to employee. - */ - const PROFILE_IS_ASSIGNED_TO_EMPLOYEE = 1; - - /** - * Code is used when unexpected error (e.g. lost db connection) occures while deleting profile. - */ - const UNEXPECTED_ERROR = 2; - - /** - * Code is used when logged in employee attempts to delete its own profile. - */ - const PROFILE_IS_ASSIGNED_TO_CONTEXT_EMPLOYEE = 3; -} diff --git a/src/Core/Domain/Profile/Exception/ProfileConstraintException.php b/src/Core/Domain/Profile/Exception/ProfileConstraintException.php deleted file mode 100644 index 92d86085..00000000 --- a/src/Core/Domain/Profile/Exception/ProfileConstraintException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\Exception; - -/** - * Is thrown when some constraint is violated in Profile subdomain - */ -class ProfileConstraintException extends ProfileException -{ - /** - * @var string Code is used when invalid profile name is encountered - */ - const INVALID_NAME = 1; -} diff --git a/src/Core/Domain/Profile/Exception/ProfileException.php b/src/Core/Domain/Profile/Exception/ProfileException.php deleted file mode 100644 index 25dbf1dd..00000000 --- a/src/Core/Domain/Profile/Exception/ProfileException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Class ProfileException is a base exception for profiles context. - */ -class ProfileException extends DomainException -{ -} diff --git a/src/Core/Domain/Profile/Exception/ProfileNotFoundException.php b/src/Core/Domain/Profile/Exception/ProfileNotFoundException.php deleted file mode 100644 index af7214f7..00000000 --- a/src/Core/Domain/Profile/Exception/ProfileNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\Exception; - -/** - * Class ProfileNotFoundException is thrown when Profile cannot be found. - */ -class ProfileNotFoundException extends ProfileException -{ -} diff --git a/src/Core/Domain/Profile/ProfileSettings.php b/src/Core/Domain/Profile/ProfileSettings.php deleted file mode 100644 index 3cb40af4..00000000 --- a/src/Core/Domain/Profile/ProfileSettings.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile; - -final class ProfileSettings -{ - /** - * Profile name max length as defined in the ObjectModel - */ - const NAME_MAX_LENGTH = 32; -} diff --git a/src/Core/Domain/Profile/Query/GetProfileForEditing.php b/src/Core/Domain/Profile/Query/GetProfileForEditing.php deleted file mode 100644 index 255fe7f2..00000000 --- a/src/Core/Domain/Profile/Query/GetProfileForEditing.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\Query; - -use PrestaShop\PrestaShop\Core\Domain\Profile\ValueObject\ProfileId; - -/** - * Get Profile data for editing - */ -class GetProfileForEditing -{ - /** - * @var ProfileId - */ - private $profileId; - - /** - * @param int $profileId - */ - public function __construct($profileId) - { - $this->profileId = new ProfileId((int) $profileId); - } - - /** - * @return ProfileId - */ - public function getProfileId() - { - return $this->profileId; - } -} diff --git a/src/Core/Domain/Profile/QueryHandler/GetProfileForEditingHandlerInterface.php b/src/Core/Domain/Profile/QueryHandler/GetProfileForEditingHandlerInterface.php deleted file mode 100644 index ad4e2b52..00000000 --- a/src/Core/Domain/Profile/QueryHandler/GetProfileForEditingHandlerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Profile\Query\GetProfileForEditing; - -/** - * Interface for service that gets Profile data for editing - */ -interface GetProfileForEditingHandlerInterface -{ - /** - * @param GetProfileForEditing $query - * - * @return mixed - */ - public function handle(GetProfileForEditing $query); -} diff --git a/src/Core/Domain/Profile/QueryResult/EditableProfile.php b/src/Core/Domain/Profile/QueryResult/EditableProfile.php deleted file mode 100644 index 8125c454..00000000 --- a/src/Core/Domain/Profile/QueryResult/EditableProfile.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Profile\ValueObject\ProfileId; - -/** - * Transfers editable Profile data - */ -class EditableProfile -{ - /** - * @var ProfileId - */ - private $profileId; - - /** - * @var string[] As langId => name - */ - private $localizedNames; - - /** - * @param ProfileId $profileId - * @param string[] $localizedNames - */ - public function __construct(ProfileId $profileId, array $localizedNames) - { - $this->profileId = $profileId; - $this->localizedNames = $localizedNames; - } - - /** - * @return ProfileId - */ - public function getProfileId() - { - return $this->profileId; - } - - /** - * @return array - */ - public function getLocalizedNames() - { - return $this->localizedNames; - } -} diff --git a/src/Core/Domain/Profile/ValueObject/ProfileId.php b/src/Core/Domain/Profile/ValueObject/ProfileId.php deleted file mode 100644 index 7be08013..00000000 --- a/src/Core/Domain/Profile/ValueObject/ProfileId.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Profile\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\ProfileException; - -/** - * Class ProfileId - */ -class ProfileId -{ - /** - * @var int - */ - private $profileId; - - /** - * @param int $profileId - * - * @throws ProfileException - */ - public function __construct($profileId) - { - // Strict type should be used in next major - if (!is_int($profileId)) { - @trigger_error('Invalid type, int is expected', E_STRICT); - } - - $this->setProfileId($profileId); - } - - /** - * @return int - */ - public function getValue() - { - return $this->profileId; - } - - /** - * @param int $profileId - * - * @throws ProfileException - */ - private function setProfileId($profileId) - { - if ((!is_int($profileId) && !ctype_digit($profileId)) || 0 >= $profileId) { - throw new ProfileException(sprintf('Invalid Profile id %s supplied', var_export($profileId, true))); - } - - $this->profileId = (int) $profileId; - } -} diff --git a/src/Core/Domain/Shop/Command/UploadLogosCommand.php b/src/Core/Domain/Shop/Command/UploadLogosCommand.php deleted file mode 100644 index 436436c7..00000000 --- a/src/Core/Domain/Shop/Command/UploadLogosCommand.php +++ /dev/null @@ -1,179 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Shop\Command; - -use PrestaShop\PrestaShop\Core\Domain\Exception\FileUploadException; -use PrestaShop\PrestaShop\Core\Domain\Shop\DTO\ShopLogoSettings; -use PrestaShop\PrestaShop\Core\Domain\Shop\Exception\NotSupportedFaviconExtensionException; -use PrestaShop\PrestaShop\Core\Domain\Shop\Exception\NotSupportedLogoImageExtensionException; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Uploads logo image files - */ -class UploadLogosCommand -{ - /** - * @var UploadedFile|null - */ - private $uploadedHeaderLogo; - - /** - * @var UploadedFile|null - */ - private $uploadedInvoiceLogo; - - /** - * @var UploadedFile|null - */ - private $uploadedMailLogo; - - /** - * @var UploadedFile|null - */ - private $uploadedFavicon; - - /** - * @return UploadedFile|null - */ - public function getUploadedHeaderLogo() - { - return $this->uploadedHeaderLogo; - } - - /** - * @param UploadedFile $uploadedHeaderLogo - * - * @throws NotSupportedLogoImageExtensionException - * @throws FileUploadException - */ - public function setUploadedHeaderLogo(UploadedFile $uploadedHeaderLogo) - { - $this->assertIsValidLogoImageExtension($uploadedHeaderLogo); - $this->assertNativeFileValidationDoesNotFail($uploadedHeaderLogo); - - $this->uploadedHeaderLogo = $uploadedHeaderLogo; - } - - /** - * @return UploadedFile|null - */ - public function getUploadedInvoiceLogo() - { - return $this->uploadedInvoiceLogo; - } - - /** - * @param UploadedFile $uploadedInvoiceLogo - * - * @throws NotSupportedLogoImageExtensionException - * @throws FileUploadException - */ - public function setUploadedInvoiceLogo(UploadedFile $uploadedInvoiceLogo) - { - $this->assertIsValidLogoImageExtension($uploadedInvoiceLogo); - $this->assertNativeFileValidationDoesNotFail($uploadedInvoiceLogo); - - $this->uploadedInvoiceLogo = $uploadedInvoiceLogo; - } - - /** - * @return UploadedFile|null - */ - public function getUploadedMailLogo() - { - return $this->uploadedMailLogo; - } - - /** - * @param UploadedFile $uploadedMailLogo - * - * @throws NotSupportedLogoImageExtensionException - * @throws FileUploadException - */ - public function setUploadedMailLogo(UploadedFile $uploadedMailLogo) - { - $this->assertIsValidLogoImageExtension($uploadedMailLogo); - $this->assertNativeFileValidationDoesNotFail($uploadedMailLogo); - - $this->uploadedMailLogo = $uploadedMailLogo; - } - - /** - * @return UploadedFile|null - */ - public function getUploadedFavicon() - { - return $this->uploadedFavicon; - } - - /** - * @param UploadedFile $uploadedFavicon - * - * @throws NotSupportedFaviconExtensionException - * @throws FileUploadException - */ - public function setUploadedFavicon(UploadedFile $uploadedFavicon) - { - if (ShopLogoSettings::AVAILABLE_ICON_IMAGE_EXTENSION !== $uploadedFavicon->getClientOriginalExtension()) { - throw new NotSupportedFaviconExtensionException(sprintf('Not supported "%s" favicon extension. Supported extension is "ico".', $uploadedFavicon->getClientOriginalExtension())); - } - - $this->assertNativeFileValidationDoesNotFail($uploadedFavicon); - - $this->uploadedFavicon = $uploadedFavicon; - } - - /** - * @param UploadedFile $uploadedFile - * - * @throws NotSupportedLogoImageExtensionException - */ - private function assertIsValidLogoImageExtension(UploadedFile $uploadedFile) - { - $extension = $uploadedFile->getClientOriginalExtension(); - if (!in_array($extension, ShopLogoSettings::AVAILABLE_LOGO_IMAGE_EXTENSIONS, true)) { - throw new NotSupportedLogoImageExtensionException(sprintf('Not supported "%s" image logo extension. Supported extensions are ""', implode(',', ShopLogoSettings::AVAILABLE_LOGO_IMAGE_EXTENSIONS))); - } - } - - /** - * Checks if native file validation does not fail. - * - * @param UploadedFile $uploadedFile - * - * @throws FileUploadException - */ - private function assertNativeFileValidationDoesNotFail(UploadedFile $uploadedFile) - { - $errorCode = $uploadedFile->getError(); - - if ($errorCode !== UPLOAD_ERR_OK) { - throw new FileUploadException($uploadedFile->getErrorMessage(), $errorCode); - } - } -} diff --git a/src/Core/Domain/Shop/CommandHandler/UploadLogosHandlerInterface.php b/src/Core/Domain/Shop/CommandHandler/UploadLogosHandlerInterface.php deleted file mode 100644 index d39bb6fa..00000000 --- a/src/Core/Domain/Shop/CommandHandler/UploadLogosHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Shop\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Shop\Command\UploadLogosCommand; - -/** - * Interface for service which handles UploadLogosCommand - */ -interface UploadLogosHandlerInterface -{ - /** - * @param UploadLogosCommand $command - */ - public function handle(UploadLogosCommand $command); -} diff --git a/src/Core/Domain/Shop/DTO/ShopLogoSettings.php b/src/Core/Domain/Shop/DTO/ShopLogoSettings.php deleted file mode 100644 index 5db4b3eb..00000000 --- a/src/Core/Domain/Shop/DTO/ShopLogoSettings.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Shop\DTO; - -/** - * Holds default settings for shop logos. - */ -class ShopLogoSettings -{ - const HEADER_LOGO_FILE_NAME = 'PS_LOGO'; - - const MAIL_LOGO_FILE_NAME = 'PS_LOGO_MAIL'; - - const INVOICE_LOGO_FILE_NAME = 'PS_LOGO_INVOICE'; - - const FAVICON_FILE_NAME = 'PS_FAVICON'; - - /** - * @var array - a list of available image mime types - */ - const AVAILABLE_LOGO_IMAGE_EXTENSIONS = ['gif', 'jpg', 'jpeg', 'jpe', 'png']; - - /** - * @var string - a type used for icon images for shop logo - */ - const AVAILABLE_ICON_IMAGE_EXTENSION = 'ico'; - - /** - * Gets the list of available extensions with dot attached to the front of the extension - * - * @return array - */ - public function getLogoImageExtensionsWithDot() - { - $mimeTypes = []; - foreach (self::AVAILABLE_LOGO_IMAGE_EXTENSIONS as $imageExtension) { - $mimeTypes[] = '.' . $imageExtension; - } - - return $mimeTypes; - } - - /** - * Gets icon image extension with dot attached to the front. - * - * @return string - */ - public function getIconImageExtensionWithDot() - { - return '.' . self::AVAILABLE_ICON_IMAGE_EXTENSION; - } -} diff --git a/src/Core/Domain/Shop/Exception/NotSupportedFaviconExtensionException.php b/src/Core/Domain/Shop/Exception/NotSupportedFaviconExtensionException.php deleted file mode 100644 index 57a935a7..00000000 --- a/src/Core/Domain/Shop/Exception/NotSupportedFaviconExtensionException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Shop\Exception; - -/** - * Class NotSupportedFaviconExtensionException - */ -class NotSupportedFaviconExtensionException extends ShopException -{ -} diff --git a/src/Core/Domain/Shop/Exception/NotSupportedLogoImageExtensionException.php b/src/Core/Domain/Shop/Exception/NotSupportedLogoImageExtensionException.php deleted file mode 100644 index 77f110ae..00000000 --- a/src/Core/Domain/Shop/Exception/NotSupportedLogoImageExtensionException.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Shop\Exception; - -class NotSupportedLogoImageExtensionException extends ShopException -{ -} diff --git a/src/Core/Domain/Shop/Exception/ShopException.php b/src/Core/Domain/Shop/Exception/ShopException.php deleted file mode 100644 index a2ae25f7..00000000 --- a/src/Core/Domain/Shop/Exception/ShopException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Shop\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Class ShopException is base exception for Shop domain. - */ -class ShopException extends DomainException -{ -} diff --git a/src/Core/Domain/Shop/Query/GetLogosPaths.php b/src/Core/Domain/Shop/Query/GetLogosPaths.php deleted file mode 100644 index 292a2904..00000000 --- a/src/Core/Domain/Shop/Query/GetLogosPaths.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Shop\Query; - -/** - * Query responsible for getting header, email, invoice and favicon logos paths - */ -class GetLogosPaths -{ -} diff --git a/src/Core/Domain/Shop/QueryHandler/GetLogosPathsHandlerInterface.php b/src/Core/Domain/Shop/QueryHandler/GetLogosPathsHandlerInterface.php deleted file mode 100644 index 94132b59..00000000 --- a/src/Core/Domain/Shop/QueryHandler/GetLogosPathsHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Shop\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Shop\Query\GetLogosPaths; -use PrestaShop\PrestaShop\Core\Domain\Shop\QueryResult\LogosPaths; - -/** - * Interface for service which handles GetLogos query - */ -interface GetLogosPathsHandlerInterface -{ - /** - * @param GetLogosPaths $query - * - * @return LogosPaths - */ - public function handle(GetLogosPaths $query); -} diff --git a/src/Core/Domain/Shop/QueryResult/LogosPaths.php b/src/Core/Domain/Shop/QueryResult/LogosPaths.php deleted file mode 100644 index ae9a49ac..00000000 --- a/src/Core/Domain/Shop/QueryResult/LogosPaths.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Shop\QueryResult; - -/** - * Holds data of header, email, invoice and favicon logos paths - */ -class LogosPaths -{ - /** - * @var string - */ - private $headerLogoPath; - - /** - * @var string - */ - private $mailLogoPath; - - /** - * @var string - */ - private $invoiceLogoPath; - - /** - * @var string - */ - private $faviconPath; - - /** - * @param string $headerLogoPath - * @param string $mailLogoPath - * @param string $invoiceLogoPath - * @param string $faviconPath - */ - public function __construct( - $headerLogoPath, - $mailLogoPath, - $invoiceLogoPath, - $faviconPath - ) { - $this->headerLogoPath = $headerLogoPath; - $this->mailLogoPath = $mailLogoPath; - $this->invoiceLogoPath = $invoiceLogoPath; - $this->faviconPath = $faviconPath; - } - - /** - * @return string - */ - public function getHeaderLogoPath() - { - return $this->headerLogoPath; - } - - /** - * @return string - */ - public function getMailLogoPath() - { - return $this->mailLogoPath; - } - - /** - * @return string - */ - public function getInvoiceLogoPath() - { - return $this->invoiceLogoPath; - } - - /** - * @return string - */ - public function getFaviconPath() - { - return $this->faviconPath; - } -} diff --git a/src/Core/Domain/Shop/ValueObject/ShopConstraint.php b/src/Core/Domain/Shop/ValueObject/ShopConstraint.php deleted file mode 100644 index 3d38d182..00000000 --- a/src/Core/Domain/Shop/ValueObject/ShopConstraint.php +++ /dev/null @@ -1,127 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Shop\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Shop\Exception\ShopException; - -class ShopConstraint -{ - /** - * @var ShopId|null - */ - private $shopId; - - /** - * @var ShopGroupId|null - */ - private $shopGroupId; - - /** - * Indicate if the value returned matches the constraints strictly, else it fallbacks to Shop > Group > Global value - * - * @var bool - */ - private $strict; - - /** - * Constraint to get configuration for a specific shop - * - * @param int $shopId - * - * @return static - * - * @throws ShopException - */ - public static function shop(int $shopId): self - { - return new static($shopId, null, false); - } - - /** - * Constraint to get configuration for a specific shop group - * - * @param int $shopGroupId - * - * @return static - * - * @throws ShopException - */ - public static function shopGroup(int $shopGroupId): self - { - return new static(null, $shopGroupId, false); - } - - /** - * Constraint to get configuration for all shops (the global value) - * - * @return static - */ - public static function allShops(): self - { - return new static(null, null, false); - } - - /** - * @param int|null $shopId - * @param int|null $shopGroupId - * @param bool $strict - * - * @throws ShopException - */ - public function __construct(?int $shopId, ?int $shopGroupId, bool $strict = false) - { - $this->shopId = null !== $shopId ? new ShopId($shopId) : null; - $this->shopGroupId = null !== $shopGroupId ? new ShopGroupId($shopGroupId) : null; - $this->strict = $strict; - } - - /** - * @return ShopId|null - */ - public function getShopId(): ?ShopId - { - return $this->shopId; - } - - /** - * @return ShopGroupId|null - */ - public function getShopGroupId(): ?ShopGroupId - { - return $this->shopGroupId; - } - - /** - * @return bool - */ - public function isStrict(): bool - { - return $this->strict; - } -} diff --git a/src/Core/Domain/Shop/ValueObject/ShopGroupId.php b/src/Core/Domain/Shop/ValueObject/ShopGroupId.php deleted file mode 100644 index 176bd4d0..00000000 --- a/src/Core/Domain/Shop/ValueObject/ShopGroupId.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Shop\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Shop\Exception\ShopException; - -class ShopGroupId -{ - /** - * @var int - */ - private $shopGroupId; - - /** - * @param int $shopGroupId - * - * @throws ShopException - */ - public function __construct(int $shopGroupId) - { - $this->assertIsGreaterThanZero($shopGroupId); - - $this->shopGroupId = $shopGroupId; - } - - /** - * @return int - */ - public function getValue(): int - { - return $this->shopGroupId; - } - - /** - * @param int $shopGroupId - * - * @throws ShopException - */ - private function assertIsGreaterThanZero(int $shopGroupId): void - { - if (0 >= $shopGroupId) { - throw new ShopException( - sprintf( - 'Shop id %s is invalid. Shop id must be number that is greater than zero.', - var_export($shopGroupId, true) - ) - ); - } - } -} diff --git a/src/Core/Domain/Shop/ValueObject/ShopId.php b/src/Core/Domain/Shop/ValueObject/ShopId.php deleted file mode 100644 index 46009175..00000000 --- a/src/Core/Domain/Shop/ValueObject/ShopId.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Shop\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Shop\Exception\ShopException; - -/** - * Shop identity - */ -class ShopId -{ - /** - * @var int - */ - private $shopId; - - /** - * @param int $shopId - * - * @throws ShopException - */ - public function __construct(int $shopId) - { - $this->assertIsGreaterThanZero($shopId); - - $this->shopId = $shopId; - } - - /** - * @return int - */ - public function getValue(): int - { - return $this->shopId; - } - - /** - * @param int $shopId - * - * @throws ShopException - */ - private function assertIsGreaterThanZero(int $shopId): void - { - if (0 >= $shopId) { - throw new ShopException( - sprintf( - 'Shop id %s is invalid. Shop id must be number that is greater than zero.', - var_export($shopId, true) - ) - ); - } - } -} diff --git a/src/Core/Domain/ShowcaseCard/Command/CloseShowcaseCardCommand.php b/src/Core/Domain/ShowcaseCard/Command/CloseShowcaseCardCommand.php deleted file mode 100644 index eb4ddb70..00000000 --- a/src/Core/Domain/ShowcaseCard/Command/CloseShowcaseCardCommand.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Command; - -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Exception\InvalidShowcaseCardNameException; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Exception\ShowcaseCardException; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\ValueObject\ShowcaseCard; - -/** - * This command permanently closes a showcase card - */ -class CloseShowcaseCardCommand -{ - /** - * @var int - */ - private $employeeId; - - /** - * @var ShowcaseCard - */ - private $showcaseCard; - - /** - * CloseShowcaseCardCommand constructor. - * - * @param int $employeeId - * @param string $showcaseCardName Name of the showcase card - * - * @throws InvalidShowcaseCardNameException - * @throws ShowcaseCardException - */ - public function __construct($employeeId, $showcaseCardName) - { - if (!is_int($employeeId)) { - throw new ShowcaseCardException(sprintf('Expected employee id to be an int, but was %s', gettype($employeeId))); - } - - $this->employeeId = $employeeId; - $this->showcaseCard = new ShowcaseCard($showcaseCardName); - } - - /** - * @return int - */ - public function getEmployeeId() - { - return $this->employeeId; - } - - /** - * @return ShowcaseCard - */ - public function getShowcaseCard() - { - return $this->showcaseCard; - } -} diff --git a/src/Core/Domain/ShowcaseCard/CommandHandler/CloseShowcaseCardHandler.php b/src/Core/Domain/ShowcaseCard/CommandHandler/CloseShowcaseCardHandler.php deleted file mode 100644 index 7aaaaf16..00000000 --- a/src/Core/Domain/ShowcaseCard/CommandHandler/CloseShowcaseCardHandler.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\CommandHandler; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Command\CloseShowcaseCardCommand; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\ConfigurationMap; - -/** - * Saves the showcase card status to keep it closed - */ -final class CloseShowcaseCardHandler implements CloseShowcaseCardHandlerInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var ConfigurationMap - */ - private $configurationMap; - - /** - * CloseShowcaseCardHandler constructor. - * - * @param ConfigurationInterface $configuration - * @param ConfigurationMap $configurationMap - */ - public function __construct(ConfigurationInterface $configuration, ConfigurationMap $configurationMap) - { - $this->configuration = $configuration; - $this->configurationMap = $configurationMap; - } - - /** - * @param CloseShowcaseCardCommand $command - */ - public function handle(CloseShowcaseCardCommand $command) - { - $configurationName = $this->configurationMap->getConfigurationNameForClosedStatus($command->getShowcaseCard()); - $this->configuration->set($configurationName, '1'); - } -} diff --git a/src/Core/Domain/ShowcaseCard/CommandHandler/CloseShowcaseCardHandlerInterface.php b/src/Core/Domain/ShowcaseCard/CommandHandler/CloseShowcaseCardHandlerInterface.php deleted file mode 100644 index 6c31cf08..00000000 --- a/src/Core/Domain/ShowcaseCard/CommandHandler/CloseShowcaseCardHandlerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Command\CloseShowcaseCardCommand; - -/** - * Contract for handling CloseShowcaseCardCommand - */ -interface CloseShowcaseCardHandlerInterface -{ - /** - * Closes a showcase card permanently - * - * @param CloseShowcaseCardCommand $command - */ - public function handle(CloseShowcaseCardCommand $command); -} diff --git a/src/Core/Domain/ShowcaseCard/ConfigurationMap.php b/src/Core/Domain/ShowcaseCard/ConfigurationMap.php deleted file mode 100644 index 6805028b..00000000 --- a/src/Core/Domain/ShowcaseCard/ConfigurationMap.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\ShowcaseCard; - -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Exception\ShowcaseCardException; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\ValueObject\ShowcaseCard; - -/** - * Maps showcase card names to configuration names from ps_configuration - */ -class ConfigurationMap -{ - /** - * Template used to create configuration names for "closed status" - */ - const CLOSED_TEMPLATE = 'PS_SHOWCASECARD_%s_CLOSED'; - - /** - * @var array - */ - private $closedCardConfiguration; - - public function __construct() - { - $this->closedCardConfiguration = [ - ShowcaseCard::SEO_URLS_CARD => sprintf(self::CLOSED_TEMPLATE, 'SEO_URLS'), - ShowcaseCard::CATEGORIES_CARD => sprintf(self::CLOSED_TEMPLATE, 'CATEGORIES'), - ShowcaseCard::CUSTOMERS_CARD => sprintf(self::CLOSED_TEMPLATE, 'CUSTOMERS'), - ShowcaseCard::EMPLOYEES_CARD => sprintf(self::CLOSED_TEMPLATE, 'EMPLOYEES'), - ShowcaseCard::CMS_PAGES_CARD => sprintf(self::CLOSED_TEMPLATE, 'CMS_PAGES'), - ShowcaseCard::ATTRIBUTES_CARD => sprintf(self::CLOSED_TEMPLATE, 'ATTRIBUTES'), - ShowcaseCard::MONITORING_CARD => sprintf(self::CLOSED_TEMPLATE, 'MONITORING'), - ]; - } - - /** - * Returns the ps_configuration configuration name for "closed status" of the provided card - * - * @param ShowcaseCard $cardName - * - * @return string - * - * @throws ShowcaseCardException If there's no configuration for that showcase card - */ - public function getConfigurationNameForClosedStatus(ShowcaseCard $cardName) - { - $name = $cardName->getName(); - - if (!isset($this->closedCardConfiguration[$name])) { - throw new ShowcaseCardException(sprintf('No closed status configuration found for showcase card "%s"', $name)); - } - - return $this->closedCardConfiguration[$name]; - } -} diff --git a/src/Core/Domain/ShowcaseCard/Exception/InvalidShowcaseCardNameException.php b/src/Core/Domain/ShowcaseCard/Exception/InvalidShowcaseCardNameException.php deleted file mode 100644 index 060e6ca1..00000000 --- a/src/Core/Domain/ShowcaseCard/Exception/InvalidShowcaseCardNameException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Exception; - -/** - * Used when referencing an invalid showcase card name - */ -class InvalidShowcaseCardNameException extends ShowcaseCardException -{ -} diff --git a/src/Core/Domain/ShowcaseCard/Exception/ShowcaseCardException.php b/src/Core/Domain/ShowcaseCard/Exception/ShowcaseCardException.php deleted file mode 100644 index 5c7dbe60..00000000 --- a/src/Core/Domain/ShowcaseCard/Exception/ShowcaseCardException.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base class for Showcase card exceptions - */ -class ShowcaseCardException extends DomainException -{ -} diff --git a/src/Core/Domain/ShowcaseCard/Query/GetShowcaseCardIsClosed.php b/src/Core/Domain/ShowcaseCard/Query/GetShowcaseCardIsClosed.php deleted file mode 100644 index f5d773d0..00000000 --- a/src/Core/Domain/ShowcaseCard/Query/GetShowcaseCardIsClosed.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Query; - -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Exception\InvalidShowcaseCardNameException; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Exception\ShowcaseCardException; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\ValueObject\ShowcaseCard; - -/** - * This query retrieves the "closed status" of a showcase card - */ -class GetShowcaseCardIsClosed -{ - /** - * @var int - */ - private $employeeId; - /** - * @var ShowcaseCard - */ - private $showcaseCard; - - /** - * GetShowcaseCardIsClosed constructor. - * - * @param int $employeeId - * @param string $showcaseCardName - * - * @throws InvalidShowcaseCardNameException - * @throws ShowcaseCardException - */ - public function __construct($employeeId, $showcaseCardName) - { - if (!is_int($employeeId)) { - throw new ShowcaseCardException(sprintf('Expected employee id to be an int, but was %s', gettype($employeeId))); - } - - $this->employeeId = $employeeId; - $this->showcaseCard = new ShowcaseCard($showcaseCardName); - } - - /** - * @return int - */ - public function getEmployeeId() - { - return $this->employeeId; - } - - /** - * @return ShowcaseCard - */ - public function getShowcaseCard() - { - return $this->showcaseCard; - } -} diff --git a/src/Core/Domain/ShowcaseCard/QueryHandler/GetShowcaseCardIsClosedHandler.php b/src/Core/Domain/ShowcaseCard/QueryHandler/GetShowcaseCardIsClosedHandler.php deleted file mode 100644 index d03140ae..00000000 --- a/src/Core/Domain/ShowcaseCard/QueryHandler/GetShowcaseCardIsClosedHandler.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\QueryHandler; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\ConfigurationMap; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Exception\ShowcaseCardException; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Query\GetShowcaseCardIsClosed; - -/** - * Finds out if a showcase card has been closed - */ -final class GetShowcaseCardIsClosedHandler implements GetShowcaseCardIsClosedHandlerInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - /** - * @var ConfigurationMap - */ - private $configurationMap; - - /** - * @param ConfigurationInterface $configuration - * @param ConfigurationMap $configurationMap - */ - public function __construct(ConfigurationInterface $configuration, ConfigurationMap $configurationMap) - { - $this->configuration = $configuration; - $this->configurationMap = $configurationMap; - } - - /** - * @param GetShowcaseCardIsClosed $query - * - * @return bool - * - * @throws ShowcaseCardException - */ - public function handle(GetShowcaseCardIsClosed $query) - { - $configurationName = $this->configurationMap->getConfigurationNameForClosedStatus($query->getShowcaseCard()); - - return (bool) $this->configuration->get($configurationName); - } -} diff --git a/src/Core/Domain/ShowcaseCard/QueryHandler/GetShowcaseCardIsClosedHandlerInterface.php b/src/Core/Domain/ShowcaseCard/QueryHandler/GetShowcaseCardIsClosedHandlerInterface.php deleted file mode 100644 index bce95d8d..00000000 --- a/src/Core/Domain/ShowcaseCard/QueryHandler/GetShowcaseCardIsClosedHandlerInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Query\GetShowcaseCardIsClosed; - -/** - * Contract for handling GetShowcaseCardIsClosed - */ -interface GetShowcaseCardIsClosedHandlerInterface -{ - /** - * Returns the "closed state" of a showcase command - * - * @param GetShowcaseCardIsClosed $query - * - * @return bool True if the showcase card is closed, False otherwise - */ - public function handle(GetShowcaseCardIsClosed $query); -} diff --git a/src/Core/Domain/ShowcaseCard/ValueObject/ShowcaseCard.php b/src/Core/Domain/ShowcaseCard/ValueObject/ShowcaseCard.php deleted file mode 100644 index c8e85e0d..00000000 --- a/src/Core/Domain/ShowcaseCard/ValueObject/ShowcaseCard.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Exception\InvalidShowcaseCardNameException; - -/** - * Showcase cards are help dialogs that appear at the top of pages to guide the merchant - */ -class ShowcaseCard -{ - /** - * Card shown in SEO & URLs - */ - const SEO_URLS_CARD = 'seo-urls_card'; - - /** - * Card shown in Categories - */ - const CATEGORIES_CARD = 'categories_card'; - - /** - * Card shown in Customers - */ - const CUSTOMERS_CARD = 'customers_card'; - - /** - * Card shown in Employees - */ - const EMPLOYEES_CARD = 'employees_card'; - - /** - * Card shown in Improve -> Design -> Pages - */ - const CMS_PAGES_CARD = 'cms-pages_card'; - - /** - * Card shown in Sell -> Catalog -> Attributes & features -> Attributes - */ - const ATTRIBUTES_CARD = 'attributes_card'; - - /** - * Card shown in Sell -> Catalog -> Monitoring - */ - const MONITORING_CARD = 'monitoring_card'; - - /** - * List of supported card names - */ - const SUPPORTED_NAMES = [ - self::SEO_URLS_CARD => true, - self::CATEGORIES_CARD => true, - self::CUSTOMERS_CARD => true, - self::EMPLOYEES_CARD => true, - self::CMS_PAGES_CARD => true, - self::ATTRIBUTES_CARD => true, - self::MONITORING_CARD => true, - ]; - - /** - * @var string - */ - private $name; - - /** - * ShowcaseCardName constructor. - * - * @param string $name Showcase card name - * - * @throws InvalidShowcaseCardNameException - */ - public function __construct($name) - { - if (!$this->isSupported($name)) { - throw new InvalidShowcaseCardNameException(sprintf('Unsupported showcase card name: %s', print_r($name, true))); - } - - $this->name = $name; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Indicates if the provided name matches an existing showcase card - * - * @param string $name - * - * @return bool - */ - private function isSupported($name) - { - return array_key_exists($name, self::SUPPORTED_NAMES); - } -} diff --git a/src/Core/Domain/SpecificPrice/Command/AddSpecificPriceCommand.php b/src/Core/Domain/SpecificPrice/Command/AddSpecificPriceCommand.php deleted file mode 100644 index 3369b20b..00000000 --- a/src/Core/Domain/SpecificPrice/Command/AddSpecificPriceCommand.php +++ /dev/null @@ -1,378 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Command; - -use DateTime; -use Exception; -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Exception\SpecificPriceConstraintException; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Reduction; - -/** - * Adds specific price - */ -class AddSpecificPriceCommand -{ - /** - * @var ProductId - */ - private $productId; - - /** - * @var Reduction - */ - private $reduction; - - /** - * @var bool - */ - private $includeTax; - - /** - * @var Number - */ - private $price; - - /** - * @var int - */ - private $fromQuantity; - - /** - * @var int|null - */ - private $shopGroupId; - - /** - * @var int|null - */ - private $shopId; - - /** - * @var int|null - */ - private $cartId; - - /** - * @var int|null - */ - private $productAttributeId; - - /** - * @var int|null - */ - private $currencyId; - - /** - * @var int|null - */ - private $cartRuleId; - - /** - * @var int|null - */ - private $countryId; - - /** - * @var int|null - */ - private $groupId; - - /** - * @var int|null - */ - private $customerId; - - /** - * @var DateTime|null - */ - private $dateTimeFrom; - - /** - * @var DateTime|null - */ - private $dateTimeTo; - - /** - * @param int $productId - * @param string $reductionType - * @param float $reductionValue - * @param bool $includeTax - * @param float $price - * @param int $fromQuantity - * - * @throws DomainConstraintException - */ - public function __construct( - int $productId, - string $reductionType, - float $reductionValue, - bool $includeTax, - float $price, - int $fromQuantity - ) { - $this->productId = new ProductId($productId); - $this->reduction = new Reduction($reductionType, $reductionValue); - $this->includeTax = $includeTax; - $this->price = new Number((string) $price); - $this->fromQuantity = $fromQuantity; - } - - /** - * @return ProductId - */ - public function getProductId(): ProductId - { - return $this->productId; - } - - /** - * @return Reduction - */ - public function getReduction(): Reduction - { - return $this->reduction; - } - - /** - * @return bool - */ - public function isIncludeTax(): bool - { - return $this->includeTax; - } - - /** - * @return Number - */ - public function getPrice(): Number - { - return $this->price; - } - - /** - * @return int - */ - public function getFromQuantity(): int - { - return $this->fromQuantity; - } - - /** - * @return DateTime|null - */ - public function getDateTimeFrom(): ?DateTime - { - return $this->dateTimeFrom; - } - - /** - * @param DateTime|null $dateTimeFrom - */ - public function setDateTimeFrom(?DateTime $dateTimeFrom): void - { - $this->dateTimeFrom = $this->createDateTime($dateTimeFrom); - } - - /** - * @return int|null - */ - public function getShopGroupId(): ?int - { - return $this->shopGroupId; - } - - /** - * @param int $shopGroupId - */ - public function setShopGroupId(int $shopGroupId): void - { - $this->shopGroupId = $shopGroupId; - } - - /** - * @return int|null - */ - public function getShopId(): ?int - { - return $this->shopId; - } - - /** - * @param int $shopId - */ - public function setShopId(int $shopId): void - { - $this->shopId = $shopId; - } - - /** - * @return int|null - */ - public function getCartId(): ?int - { - return $this->cartId; - } - - /** - * @param int $cartId - */ - public function setCartId(int $cartId): void - { - $this->cartId = $cartId; - } - - /** - * @return int|null - */ - public function getProductAttributeId(): ?int - { - return $this->productAttributeId; - } - - /** - * @param int $productAttributeId - */ - public function setProductAttributeId(int $productAttributeId): void - { - $this->productAttributeId = $productAttributeId; - } - - /** - * @return int|null - */ - public function getCurrencyId(): ?int - { - return $this->currencyId; - } - - /** - * @param int $currencyId - */ - public function setCurrencyId(int $currencyId): void - { - $this->currencyId = $currencyId; - } - - /** - * @return int|null - */ - public function getCartRuleId(): ?int - { - return $this->cartRuleId; - } - - /** - * @param int $cartRuleId - */ - public function setCartRuleId(int $cartRuleId): void - { - $this->cartRuleId = $cartRuleId; - } - - /** - * @return int|null - */ - public function getCountryId(): ?int - { - return $this->countryId; - } - - /** - * @param int $countryId - */ - public function setCountryId(int $countryId): void - { - $this->countryId = $countryId; - } - - /** - * @return int|null - */ - public function getGroupId(): ?int - { - return $this->groupId; - } - - /** - * @param int $groupId - */ - public function setGroupId(int $groupId): void - { - $this->groupId = $groupId; - } - - /** - * @return int|null - */ - public function getCustomerId(): ?int - { - return $this->customerId; - } - - /** - * @param int $customerId - */ - public function setCustomerId(int $customerId): void - { - $this->customerId = $customerId; - } - - /** - * @return DateTime|null - */ - public function getDateTimeTo(): ?DateTime - { - return $this->dateTimeTo; - } - - /** - * @param DateTime|null $dateTimeTo - */ - public function setDateTimeTo(?DateTime $dateTimeTo): void - { - $this->dateTimeTo = $this->createDateTime($dateTimeTo); - } - - /** - * @param string $dateTime - * - * @return DateTime - * - * @throws SpecificPriceConstraintException - */ - private function createDateTime(string $dateTime): DateTime - { - try { - return new DateTime($dateTime); - } catch (Exception $e) { - throw new SpecificPriceConstraintException('An error occured when creating DateTime object for specific price', SpecificPriceConstraintException::INVALID_DATETIME, $e); - } - } -} diff --git a/src/Core/Domain/SpecificPrice/Command/DeleteSpecificPriceByCartProductCommand.php b/src/Core/Domain/SpecificPrice/Command/DeleteSpecificPriceByCartProductCommand.php deleted file mode 100644 index a908aef5..00000000 --- a/src/Core/Domain/SpecificPrice/Command/DeleteSpecificPriceByCartProductCommand.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Command; - -use PrestaShop\PrestaShop\Core\Domain\Cart\ValueObject\CartId; -use PrestaShop\PrestaShop\Core\Domain\Product\ValueObject\ProductId; - -/** - * Deletes specific price by cart id - */ -class DeleteSpecificPriceByCartProductCommand -{ - /** - * @var CartId - */ - private $cartId; - - /** - * @var ProductId - */ - private $productId; - - /** - * @var int|null - */ - private $productAttributeId; - - public function __construct( - int $cartId, - int $productId - ) { - $this->cartId = new CartId($cartId); - $this->productId = new ProductId($productId); - } - - /** - * @return CartId - */ - public function getCartId(): CartId - { - return $this->cartId; - } - - /** - * @return ProductId - */ - public function getProductId(): ProductId - { - return $this->productId; - } - - /** - * @return int|null - */ - public function getProductAttributeId(): ?int - { - return $this->productAttributeId; - } - - /** - * @param int $productAttributeId - */ - public function setProductAttributeId(int $productAttributeId): void - { - $this->productAttributeId = $productAttributeId; - } -} diff --git a/src/Core/Domain/SpecificPrice/CommandHandler/AddSpecificPriceHandlerInterface.php b/src/Core/Domain/SpecificPrice/CommandHandler/AddSpecificPriceHandlerInterface.php deleted file mode 100644 index ef54ef33..00000000 --- a/src/Core/Domain/SpecificPrice/CommandHandler/AddSpecificPriceHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SpecificPrice\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Command\AddSpecificPriceCommand; -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\ValueObject\SpecificPriceId; - -/** - * Interface for handling AddSpecificPrice command - */ -interface AddSpecificPriceHandlerInterface -{ - /** - * @param AddSpecificPriceCommand $command - * - * @return SpecificPriceId - */ - public function handle(AddSpecificPriceCommand $command): SpecificPriceId; -} diff --git a/src/Core/Domain/SpecificPrice/CommandHandler/DeleteSpecificPriceByCartProductHandlerInterface.php b/src/Core/Domain/SpecificPrice/CommandHandler/DeleteSpecificPriceByCartProductHandlerInterface.php deleted file mode 100644 index 889b37e3..00000000 --- a/src/Core/Domain/SpecificPrice/CommandHandler/DeleteSpecificPriceByCartProductHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SpecificPrice\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Command\DeleteSpecificPriceByCartProductCommand; - -/** - * Interface for handling DeleteSpecificPriceByCartProduct command - */ -interface DeleteSpecificPriceByCartProductHandlerInterface -{ - /** - * @param DeleteSpecificPriceByCartProductCommand $command - */ - public function handle(DeleteSpecificPriceByCartProductCommand $command): void; -} diff --git a/src/Core/Domain/SpecificPrice/Exception/SpecificPriceConstraintException.php b/src/Core/Domain/SpecificPrice/Exception/SpecificPriceConstraintException.php deleted file mode 100644 index 02b8b7fe..00000000 --- a/src/Core/Domain/SpecificPrice/Exception/SpecificPriceConstraintException.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Exception; - -/** - * Thrown when specific price constraints are violated - */ -class SpecificPriceConstraintException extends SpecificPriceException -{ - /** - * When catalog price rule id is not valid - */ - const INVALID_ID = 1; - - /** - * When date-time format is invalid - */ - const INVALID_DATETIME = 2; - - /** - * When date range is not valid - */ - const INVALID_DATE_RANGE = 3; -} diff --git a/src/Core/Domain/SpecificPrice/Exception/SpecificPriceException.php b/src/Core/Domain/SpecificPrice/Exception/SpecificPriceException.php deleted file mode 100644 index 2e59d64a..00000000 --- a/src/Core/Domain/SpecificPrice/Exception/SpecificPriceException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for SpecificPrice subdomain - */ -class SpecificPriceException extends DomainException -{ -} diff --git a/src/Core/Domain/SpecificPrice/Exception/SpecificPriceNotFoundException.php b/src/Core/Domain/SpecificPrice/Exception/SpecificPriceNotFoundException.php deleted file mode 100644 index e8b58b12..00000000 --- a/src/Core/Domain/SpecificPrice/Exception/SpecificPriceNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Exception; - -/** - * Thrown when requested specific price could not be found - */ -class SpecificPriceNotFoundException extends SpecificPriceException -{ -} diff --git a/src/Core/Domain/SpecificPrice/ValueObject/SpecificPriceId.php b/src/Core/Domain/SpecificPrice/ValueObject/SpecificPriceId.php deleted file mode 100644 index 91fa7a10..00000000 --- a/src/Core/Domain/SpecificPrice/ValueObject/SpecificPriceId.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SpecificPrice\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Exception\SpecificPriceConstraintException; - -/** - * Holds identification data of specific price - */ -class SpecificPriceId -{ - /** - * @var int - */ - private $specificPriceId; - - /** - * @param int $specificPriceId - * - * @throws SpecificPriceConstraintException - */ - public function __construct(int $specificPriceId) - { - $this->assertIsGreaterThanZero($specificPriceId); - $this->specificPriceId = $specificPriceId; - } - - /** - * @return int - */ - public function getValue(): int - { - return $this->specificPriceId; - } - - /** - * Validates that the value is greater than zero - * - * @param int $value - * - * @throws SpecificPriceConstraintException - */ - private function assertIsGreaterThanZero(int $value): void - { - if (!is_int($value) || 0 >= $value) { - throw new SpecificPriceConstraintException(sprintf('Invalid specific price id "%s".', $value), SpecificPriceConstraintException::INVALID_ID); - } - } -} diff --git a/src/Core/Domain/SqlManagement/Command/AddSqlRequestCommand.php b/src/Core/Domain/SqlManagement/Command/AddSqlRequestCommand.php deleted file mode 100644 index 2948321b..00000000 --- a/src/Core/Domain/SqlManagement/Command/AddSqlRequestCommand.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestConstraintException; - -/** - * This command creates new SqlRequest entity with provided data. - */ -class AddSqlRequestCommand -{ - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $sql; - - /** - * @param string $name - * @param string $sql - * - * @throws SqlRequestConstraintException - */ - public function __construct($name, $sql) - { - $this - ->setName($name) - ->setSql($sql); - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return string - */ - public function getSql() - { - return $this->sql; - } - - /** - * Set Request SQL name. - * - * @param string $name - * - * @return self - * - * @throws SqlRequestConstraintException - */ - private function setName($name) - { - if (!is_string($name) || empty($name)) { - throw new SqlRequestConstraintException(sprintf('Invalid SqlRequest name %s', var_export($name, true)), SqlRequestConstraintException::INVALID_NAME); - } - - $this->name = $name; - - return $this; - } - - /** - * Set Request SQL query. - * - * @param string $sql - * - * @return $this - * - * @throws SqlRequestConstraintException - */ - private function setSql($sql) - { - if (!is_string($sql) || empty($sql)) { - throw new SqlRequestConstraintException(sprintf('Invalid SqlRequest SQL query %s', var_export($sql, true)), SqlRequestConstraintException::INVALID_SQL_QUERY); - } - - $this->sql = $sql; - - return $this; - } -} diff --git a/src/Core/Domain/SqlManagement/Command/BulkDeleteSqlRequestCommand.php b/src/Core/Domain/SqlManagement/Command/BulkDeleteSqlRequestCommand.php deleted file mode 100644 index d982552d..00000000 --- a/src/Core/Domain/SqlManagement/Command/BulkDeleteSqlRequestCommand.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestConstraintException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\ValueObject\SqlRequestId; - -/** - * Class BulkDeleteSqlRequestCommand deletes provided SqlRequests. - */ -class BulkDeleteSqlRequestCommand -{ - /** - * @var SqlRequestId[] - */ - private $sqlRequestIds = []; - - /** - * @param int[] $sqlRequestIds - * - * @throws SqlRequestException - */ - public function __construct(array $sqlRequestIds) - { - $this->setSqlRequestIds($sqlRequestIds); - } - - /** - * @return SqlRequestId[] - */ - public function getSqlRequestIds() - { - return $this->sqlRequestIds; - } - - /** - * @param array $sqlRequestIds - * - * @throws SqlRequestException - * - * @return self - */ - private function setSqlRequestIds(array $sqlRequestIds) - { - if (empty($sqlRequestIds)) { - throw new SqlRequestConstraintException('Missing SqlRequest data for bulk deleting', SqlRequestConstraintException::MISSING_BULK_DATA); - } - - foreach ($sqlRequestIds as $sqlRequestId) { - $this->sqlRequestIds[] = new SqlRequestId($sqlRequestId); - } - - return $this; - } -} diff --git a/src/Core/Domain/SqlManagement/Command/DeleteSqlRequestCommand.php b/src/Core/Domain/SqlManagement/Command/DeleteSqlRequestCommand.php deleted file mode 100644 index 357c544e..00000000 --- a/src/Core/Domain/SqlManagement/Command/DeleteSqlRequestCommand.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\ValueObject\SqlRequestId; - -/** - * Class DeleteSqlRequestCommand command delete SqlRequest by given id. - */ -class DeleteSqlRequestCommand -{ - /** - * @var SqlRequestId - */ - private $sqlRequestId; - - /** - * @param SqlRequestId $sqlRequestId - */ - public function __construct(SqlRequestId $sqlRequestId) - { - $this->setSqlRequestId($sqlRequestId); - } - - /** - * @return SqlRequestId - */ - public function getSqlRequestId() - { - return $this->sqlRequestId; - } - - /** - * @param SqlRequestId $sqlRequestId - * - * @return self - */ - private function setSqlRequestId($sqlRequestId) - { - $this->sqlRequestId = $sqlRequestId; - - return $this; - } -} diff --git a/src/Core/Domain/SqlManagement/Command/EditSqlRequestCommand.php b/src/Core/Domain/SqlManagement/Command/EditSqlRequestCommand.php deleted file mode 100644 index 28328f66..00000000 --- a/src/Core/Domain/SqlManagement/Command/EditSqlRequestCommand.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestConstraintException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\ValueObject\SqlRequestId; - -/** - * This command modifies an existing SqlRequest object, replacing its data by the provided one. - */ -class EditSqlRequestCommand -{ - /** - * @var SqlRequestId - */ - private $sqlRequestId; - - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $sql; - - /** - * @param SqlRequestId $sqlRequestId - */ - public function __construct(SqlRequestId $sqlRequestId) - { - $this->setSqlRequestId($sqlRequestId); - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return string - */ - public function getSql() - { - return $this->sql; - } - - /** - * @return SqlRequestId - */ - public function getSqlRequestId() - { - return $this->sqlRequestId; - } - - /** - * @param SqlRequestId $sqlRequestId - * - * @return self - */ - private function setSqlRequestId(SqlRequestId $sqlRequestId) - { - $this->sqlRequestId = $sqlRequestId; - - return $this; - } - - /** - * Set Request SQL name. - * - * @param string $name - * - * @return self - * - * @throws SqlRequestConstraintException - */ - public function setName($name) - { - if (!is_string($name) || empty($name)) { - throw new SqlRequestConstraintException(sprintf('Invalid SqlRequest name "%s"', var_export($name, true)), SqlRequestConstraintException::INVALID_NAME); - } - - $this->name = $name; - - return $this; - } - - /** - * Set Request SQL query. - * - * @param string $sql - * - * @return self - * - * @throws SqlRequestConstraintException - */ - public function setSql($sql) - { - if (!is_string($sql) || empty($sql)) { - throw new SqlRequestConstraintException(sprintf('Invalid SqlRequest SQL query "%s"', var_export($sql, true)), SqlRequestConstraintException::INVALID_SQL_QUERY); - } - - $this->sql = $sql; - - return $this; - } -} diff --git a/src/Core/Domain/SqlManagement/Command/SaveSqlRequestSettingsCommand.php b/src/Core/Domain/SqlManagement/Command/SaveSqlRequestSettingsCommand.php deleted file mode 100644 index a6dde544..00000000 --- a/src/Core/Domain/SqlManagement/Command/SaveSqlRequestSettingsCommand.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestSettingsConstraintException; -use PrestaShop\PrestaShop\Core\Encoding\CharsetEncoding; - -/** - * Class SaveSqlManagerSettingsCommand saves default file encoding settings - * for SqlRequest's query result export file. - */ -class SaveSqlRequestSettingsCommand -{ - /** - * @var string - */ - private $fileEncoding; - - /** - * @param string $fileEncoding - * - * @throws SqlRequestSettingsConstraintException - */ - public function __construct($fileEncoding) - { - $this->setFileEncoding($fileEncoding); - } - - /** - * @return string - */ - public function getFileEncoding() - { - return $this->fileEncoding; - } - - /** - * @param string $fileEncoding - * - * @return self - * - * @throws SqlRequestSettingsConstraintException - */ - private function setFileEncoding($fileEncoding) - { - if (!is_string($fileEncoding) || empty($fileEncoding)) { - throw new SqlRequestSettingsConstraintException(sprintf('Invalid File Encoding %s supplied', var_export($fileEncoding, true)), SqlRequestSettingsConstraintException::INVALID_FILE_ENCODING); - } - - $supportedFileEncodings = [ - CharsetEncoding::ISO_8859_1, - CharsetEncoding::UTF_8, - ]; - - if (!in_array($fileEncoding, $supportedFileEncodings)) { - throw new SqlRequestSettingsConstraintException(sprintf('Not supported File Encoding %s supplied. Supported encodings are %s', var_export($fileEncoding, true), var_export(implode(',', $supportedFileEncodings), true)), SqlRequestSettingsConstraintException::NOT_SUPPORTED_FILE_ENCODING); - } - - $this->fileEncoding = $fileEncoding; - - return $this; - } -} diff --git a/src/Core/Domain/SqlManagement/CommandHandler/AddSqlRequestHandlerInterface.php b/src/Core/Domain/SqlManagement/CommandHandler/AddSqlRequestHandlerInterface.php deleted file mode 100644 index d2dd0b97..00000000 --- a/src/Core/Domain/SqlManagement/CommandHandler/AddSqlRequestHandlerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\AddSqlRequestCommand; - -/** - * Interface AddSqlRequestHandlerInterface defines contract for SqlRequest creation handler. - */ -interface AddSqlRequestHandlerInterface -{ - /** - * @param AddSqlRequestCommand $command - * - * @return int Created SqlRequest id - */ - public function handle(AddSqlRequestCommand $command); -} diff --git a/src/Core/Domain/SqlManagement/CommandHandler/BulkDeleteSqlRequestHandlerInterface.php b/src/Core/Domain/SqlManagement/CommandHandler/BulkDeleteSqlRequestHandlerInterface.php deleted file mode 100644 index 6f171c6c..00000000 --- a/src/Core/Domain/SqlManagement/CommandHandler/BulkDeleteSqlRequestHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\BulkDeleteSqlRequestCommand; - -/** - * Interface BulkDeleteSqlRequestHandlerInterface defines contract for bulk deleting handler of SqlRequest. - */ -interface BulkDeleteSqlRequestHandlerInterface -{ - /** - * @param BulkDeleteSqlRequestCommand $command - */ - public function handle(BulkDeleteSqlRequestCommand $command); -} diff --git a/src/Core/Domain/SqlManagement/CommandHandler/DeleteSqlRequestHandlerInterface.php b/src/Core/Domain/SqlManagement/CommandHandler/DeleteSqlRequestHandlerInterface.php deleted file mode 100644 index ca4e9097..00000000 --- a/src/Core/Domain/SqlManagement/CommandHandler/DeleteSqlRequestHandlerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\DeleteSqlRequestCommand; - -/** - * Interface DeleteSqlRequestHandlerInterface defines contract for SqlRequest delete handler. - */ -interface DeleteSqlRequestHandlerInterface -{ - /** - * Delete SqlRequest. - * - * @param DeleteSqlRequestCommand $command - */ - public function handle(DeleteSqlRequestCommand $command); -} diff --git a/src/Core/Domain/SqlManagement/CommandHandler/EditSqlRequestHandlerInterface.php b/src/Core/Domain/SqlManagement/CommandHandler/EditSqlRequestHandlerInterface.php deleted file mode 100644 index 5170a276..00000000 --- a/src/Core/Domain/SqlManagement/CommandHandler/EditSqlRequestHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\EditSqlRequestCommand; - -/** - * Interface EditSqlRequestHandlerInterface defines contract SqlRequest editing handler. - */ -interface EditSqlRequestHandlerInterface -{ - /** - * @param EditSqlRequestCommand $command - */ - public function handle(EditSqlRequestCommand $command); -} diff --git a/src/Core/Domain/SqlManagement/CommandHandler/SaveSqlRequestSettingsHandler.php b/src/Core/Domain/SqlManagement/CommandHandler/SaveSqlRequestSettingsHandler.php deleted file mode 100644 index 0e577256..00000000 --- a/src/Core/Domain/SqlManagement/CommandHandler/SaveSqlRequestSettingsHandler.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\CommandHandler; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\SaveSqlRequestSettingsCommand; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\SqlRequestSettings; -use PrestaShop\PrestaShop\Core\Encoding\CharsetEncoding; - -/** - * Class SaveSqlRequestSettingsHandler handles command to save SqlRequest settings. - */ -final class SaveSqlRequestSettingsHandler implements SaveSqlRequestSettingsHandlerInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function handle(SaveSqlRequestSettingsCommand $command) - { - $this->configuration->set(SqlRequestSettings::FILE_ENCODING, $this->getEncodingFileValue($command)); - } - - /** - * File encodings are saved as integer values in databases. - * - * @param SaveSqlRequestSettingsCommand $command - * - * @return int - */ - private function getEncodingFileValue(SaveSqlRequestSettingsCommand $command) - { - $valuesMapping = [ - CharsetEncoding::UTF_8 => 1, - CharsetEncoding::ISO_8859_1 => 2, - ]; - - return $valuesMapping[$command->getFileEncoding()]; - } -} diff --git a/src/Core/Domain/SqlManagement/CommandHandler/SaveSqlRequestSettingsHandlerInterface.php b/src/Core/Domain/SqlManagement/CommandHandler/SaveSqlRequestSettingsHandlerInterface.php deleted file mode 100644 index 6e263508..00000000 --- a/src/Core/Domain/SqlManagement/CommandHandler/SaveSqlRequestSettingsHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\SaveSqlRequestSettingsCommand; - -/** - * Interface SaveSqlRequestSettingsHandlerInterface. - */ -interface SaveSqlRequestSettingsHandlerInterface -{ - /** - * @param SaveSqlRequestSettingsCommand $command - */ - public function handle(SaveSqlRequestSettingsCommand $command); -} diff --git a/src/Core/Domain/SqlManagement/DatabaseTableFields.php b/src/Core/Domain/SqlManagement/DatabaseTableFields.php deleted file mode 100644 index 0f00213d..00000000 --- a/src/Core/Domain/SqlManagement/DatabaseTableFields.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlManagementConstraintException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\ValueObject\DatabaseTableField; - -/** - * Class DatabaseTableFields stores fields of single database table. - */ -class DatabaseTableFields -{ - /** - * @var DatabaseTableField[] - */ - private $fields; - - /** - * @param DatabaseTableField[] $fields - * - * @throws SqlManagementConstraintException - */ - public function __construct(array $fields) - { - $this->setFields($fields); - } - - /** - * @return DatabaseTableField[] - */ - public function getFields() - { - return $this->fields; - } - - /** - * @param DatabaseTableField[] $fields - * - * @return self - * - * @throws SqlManagementConstraintException - */ - private function setFields(array $fields) - { - foreach ($fields as $field) { - if (!$field instanceof DatabaseTableField) { - throw new SqlManagementConstraintException(sprintf('Invalid database field %s supplied. Expected instance of %s', var_export($field, true), DatabaseTableField::class), SqlManagementConstraintException::INVALID_DATABASE_TABLE_FIELD); - } - } - - $this->fields = $fields; - - return $this; - } -} diff --git a/src/Core/Domain/SqlManagement/DatabaseTablesList.php b/src/Core/Domain/SqlManagement/DatabaseTablesList.php deleted file mode 100644 index 23a9e4d3..00000000 --- a/src/Core/Domain/SqlManagement/DatabaseTablesList.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestException; - -/** - * Class DatabaseTablesList stores list of database tables. - */ -class DatabaseTablesList -{ - /** - * @var string[] - */ - private $dbTables; - - /** - * @param string[] $dbTables - * - * @throws SqlRequestException - */ - public function __construct(array $dbTables) - { - $this->setTables($dbTables); - } - - /** - * @return string[] - */ - public function getTables() - { - return $this->dbTables; - } - - /** - * @param array $tables - * - * @return self - * - * @throws SqlRequestException - */ - private function setTables(array $tables) - { - $filteredTables = array_filter($tables, 'is_string'); - - if ($filteredTables !== $tables) { - throw new SqlRequestException('Invalid database table list provided. Database tables list must contain string values only.'); - } - - $this->dbTables = $tables; - - return $this; - } -} diff --git a/src/Core/Domain/SqlManagement/EditableSqlRequest.php b/src/Core/Domain/SqlManagement/EditableSqlRequest.php deleted file mode 100644 index b0373913..00000000 --- a/src/Core/Domain/SqlManagement/EditableSqlRequest.php +++ /dev/null @@ -1,141 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\ValueObject\SqlRequestId; - -/** - * Class EditableSqlRequest stores information about SqlRequest that can be edited. - */ -class EditableSqlRequest -{ - /** - * @var SqlRequestId - */ - private $sqlRequestId; - - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $sql; - - /** - * @param SqlRequestId $requestSqlId - * @param string $name - * @param string $sql - * - * @throws SqlRequestException - */ - public function __construct( - SqlRequestId $requestSqlId, - $name, - $sql - ) { - $this - ->setSqlRequestId($requestSqlId) - ->setName($name) - ->setSql($sql); - } - - /** - * @return SqlRequestId - */ - public function getSqlRequestId() - { - return $this->sqlRequestId; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return string - */ - public function getSql() - { - return $this->sql; - } - - /** - * @param SqlRequestId $sqlRequestId - * - * @return EditableSqlRequest - */ - private function setSqlRequestId(SqlRequestId $sqlRequestId) - { - $this->sqlRequestId = $sqlRequestId; - - return $this; - } - - /** - * @param string $name - * - * @return EditableSqlRequest - * - * @throws SqlRequestException - */ - private function setName($name) - { - if (empty($name)) { - throw new SqlRequestException('SqlRequest name cannot be empty'); - } - - $this->name = $name; - - return $this; - } - - /** - * @param string $sql - * - * @return EditableSqlRequest - * - * @throws SqlRequestException - */ - private function setSql($sql) - { - if (empty($sql)) { - throw new SqlRequestException('SqlRequest SQL cannot be empty'); - } - - $this->sql = $sql; - - return $this; - } -} diff --git a/src/Core/Domain/SqlManagement/Exception/CannotAddSqlRequestException.php b/src/Core/Domain/SqlManagement/Exception/CannotAddSqlRequestException.php deleted file mode 100644 index 4aeaee30..00000000 --- a/src/Core/Domain/SqlManagement/Exception/CannotAddSqlRequestException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception; - -/** - * Is thrown when new SqlRequest cannot be created - */ -class CannotAddSqlRequestException extends SqlRequestException -{ -} diff --git a/src/Core/Domain/SqlManagement/Exception/CannotDeleteSqlRequestException.php b/src/Core/Domain/SqlManagement/Exception/CannotDeleteSqlRequestException.php deleted file mode 100644 index 9da264bf..00000000 --- a/src/Core/Domain/SqlManagement/Exception/CannotDeleteSqlRequestException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception; - -/** - * Is thrown when SqlRequest cannot be deleted - */ -class CannotDeleteSqlRequestException extends SqlRequestException -{ - /** - * When deleting single SqlRequest - */ - const CANNOT_SINGLE_DELETE = 10; - - /** - * When deleting SqlRequest in bulk action - */ - const CANNOT_BULK_DELETE = 20; -} diff --git a/src/Core/Domain/SqlManagement/Exception/CannotEditSqlRequestException.php b/src/Core/Domain/SqlManagement/Exception/CannotEditSqlRequestException.php deleted file mode 100644 index 74a03d6a..00000000 --- a/src/Core/Domain/SqlManagement/Exception/CannotEditSqlRequestException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception; - -/** - * Is thrown when SqlRequest cannot be edited - */ -class CannotEditSqlRequestException extends SqlRequestException -{ -} diff --git a/src/Core/Domain/SqlManagement/Exception/SqlManagementConstraintException.php b/src/Core/Domain/SqlManagement/Exception/SqlManagementConstraintException.php deleted file mode 100644 index fe6aff3d..00000000 --- a/src/Core/Domain/SqlManagement/Exception/SqlManagementConstraintException.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception; - -/** - * Is thrown when SqlManagement constraints are violated - */ -class SqlManagementConstraintException extends SqlManagementException -{ - /** - * When database table name is invalid - */ - const INVALID_DATABASE_TABLE_NAME = 10; - - /** - * When database table field is invalid - */ - const INVALID_DATABASE_TABLE_FIELD = 20; - - /** - * When database table field name is invalid - */ - const INVALID_DATABASE_TABLE_FIELD_NAME = 30; - - /** - * When database table field type is invalid - */ - const INVALID_DATABASE_TABLE_FIELD_TYPE = 40; -} diff --git a/src/Core/Domain/SqlManagement/Exception/SqlManagementException.php b/src/Core/Domain/SqlManagement/Exception/SqlManagementException.php deleted file mode 100644 index 4f4392c7..00000000 --- a/src/Core/Domain/SqlManagement/Exception/SqlManagementException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Class SqlManagementException base exception of SqlManagement bounded context. - */ -class SqlManagementException extends DomainException -{ -} diff --git a/src/Core/Domain/SqlManagement/Exception/SqlRequestConstraintException.php b/src/Core/Domain/SqlManagement/Exception/SqlRequestConstraintException.php deleted file mode 100644 index e8a30ecf..00000000 --- a/src/Core/Domain/SqlManagement/Exception/SqlRequestConstraintException.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception; - -/** - * Is thrown when SqlRequest constraints are violated - */ -class SqlRequestConstraintException extends SqlRequestException -{ - /** - * When provided name is not valid - */ - const INVALID_NAME = 10; - - /** - * When provided sql query is not valid - */ - const INVALID_SQL_QUERY = 20; - - /** - * When provided sql query format is invalid - */ - const MALFORMED_SQL_QUERY = 30; - - /** - * When empty data is provided for bulk action - */ - const MISSING_BULK_DATA = 40; -} diff --git a/src/Core/Domain/SqlManagement/Exception/SqlRequestException.php b/src/Core/Domain/SqlManagement/Exception/SqlRequestException.php deleted file mode 100644 index 8d95674f..00000000 --- a/src/Core/Domain/SqlManagement/Exception/SqlRequestException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception; - -/** - * Base exception for SqlRequest sub-domain - */ -class SqlRequestException extends SqlManagementException -{ -} diff --git a/src/Core/Domain/SqlManagement/Exception/SqlRequestNotFoundException.php b/src/Core/Domain/SqlManagement/Exception/SqlRequestNotFoundException.php deleted file mode 100644 index 5b518932..00000000 --- a/src/Core/Domain/SqlManagement/Exception/SqlRequestNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception; - -/** - * Is thrown when required SqlRequest cannot be found - */ -class SqlRequestNotFoundException extends SqlRequestException -{ -} diff --git a/src/Core/Domain/SqlManagement/Exception/SqlRequestSettingsConstraintException.php b/src/Core/Domain/SqlManagement/Exception/SqlRequestSettingsConstraintException.php deleted file mode 100644 index 063d59cb..00000000 --- a/src/Core/Domain/SqlManagement/Exception/SqlRequestSettingsConstraintException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception; - -/** - * Class SqlRequestSettingsConstraintException is thrown when invalid settings are supplied. - */ -class SqlRequestSettingsConstraintException extends SqlRequestException -{ - const INVALID_FILE_ENCODING = 10; - const NOT_SUPPORTED_FILE_ENCODING = 20; -} diff --git a/src/Core/Domain/SqlManagement/Query/GetDatabaseTableFieldsList.php b/src/Core/Domain/SqlManagement/Query/GetDatabaseTableFieldsList.php deleted file mode 100644 index 5bde72b0..00000000 --- a/src/Core/Domain/SqlManagement/Query/GetDatabaseTableFieldsList.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlManagementConstraintException; - -/** - * Class GetAttributesForDatabaseTableQuery gets list of attributes for given database table name. - */ -class GetDatabaseTableFieldsList -{ - /** - * @var string - */ - private $tableName; - - /** - * @param string $tableName - * - * @throws SqlManagementConstraintException - */ - public function __construct($tableName) - { - $this->setTableName($tableName); - } - - /** - * @return string - */ - public function getTableName() - { - return $this->tableName; - } - - /** - * @param string $tableName - * - * @return self - * - * @throws SqlManagementConstraintException - */ - public function setTableName($tableName) - { - if (!is_string($tableName) || empty($tableName)) { - throw new SqlManagementConstraintException(sprintf('Invalid database table name %s supplied', var_export($tableName, true)), SqlManagementConstraintException::INVALID_DATABASE_TABLE_NAME); - } - - $this->tableName = $tableName; - - return $this; - } -} diff --git a/src/Core/Domain/SqlManagement/Query/GetDatabaseTablesList.php b/src/Core/Domain/SqlManagement/Query/GetDatabaseTablesList.php deleted file mode 100644 index f1907281..00000000 --- a/src/Core/Domain/SqlManagement/Query/GetDatabaseTablesList.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query; - -/** - * Class GetDatabaseTablesListQuery gets list of database tables. - */ -class GetDatabaseTablesList -{ -} diff --git a/src/Core/Domain/SqlManagement/Query/GetSqlRequestExecutionResult.php b/src/Core/Domain/SqlManagement/Query/GetSqlRequestExecutionResult.php deleted file mode 100644 index c0f0b49f..00000000 --- a/src/Core/Domain/SqlManagement/Query/GetSqlRequestExecutionResult.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\ValueObject\SqlRequestId; - -/** - * Class GetSqlRequestExecutionResultQuery returns the result of executing an SqlRequest query. - */ -class GetSqlRequestExecutionResult -{ - /** - * @var SqlRequestId - */ - private $requestSqlId; - - /** - * @param int $requestSqlId - * - * @throws SqlRequestException - */ - public function __construct($requestSqlId) - { - $this->requestSqlId = new SqlRequestId($requestSqlId); - } - - /** - * @return SqlRequestId - */ - public function getSqlRequestId() - { - return $this->requestSqlId; - } -} diff --git a/src/Core/Domain/SqlManagement/Query/GetSqlRequestForEditing.php b/src/Core/Domain/SqlManagement/Query/GetSqlRequestForEditing.php deleted file mode 100644 index 375000d9..00000000 --- a/src/Core/Domain/SqlManagement/Query/GetSqlRequestForEditing.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\ValueObject\SqlRequestId; - -/** - * Class GetSqlRequestForEditingQuery gets SqlRequest data that can be edited. - */ -class GetSqlRequestForEditing -{ - /** - * @var SqlRequestId - */ - private $requestSqlId; - - /** - * @param $requestSqlId - * - * @throws SqlRequestException - */ - public function __construct($requestSqlId) - { - $this->requestSqlId = new SqlRequestId($requestSqlId); - } - - /** - * @return SqlRequestId - */ - public function getRequestSqlId() - { - return $this->requestSqlId; - } -} diff --git a/src/Core/Domain/SqlManagement/Query/GetSqlRequestSettings.php b/src/Core/Domain/SqlManagement/Query/GetSqlRequestSettings.php deleted file mode 100644 index 9c42e434..00000000 --- a/src/Core/Domain/SqlManagement/Query/GetSqlRequestSettings.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query; - -/** - * Class GetSqlRequestSettingsQuery gets SqlRequest settings. - */ -class GetSqlRequestSettings -{ -} diff --git a/src/Core/Domain/SqlManagement/QueryHandler/GetDatabaseTableFieldsListHandlerInterface.php b/src/Core/Domain/SqlManagement/QueryHandler/GetDatabaseTableFieldsListHandlerInterface.php deleted file mode 100644 index 9ffd1c78..00000000 --- a/src/Core/Domain/SqlManagement/QueryHandler/GetDatabaseTableFieldsListHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\DatabaseTableFields; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetDatabaseTableFieldsList; - -/** - * Interface GetAttributesForDatabaseTableHandlerInterface. - */ -interface GetDatabaseTableFieldsListHandlerInterface -{ - /** - * @param GetDatabaseTableFieldsList $query - * - * @return DatabaseTableFields - */ - public function handle(GetDatabaseTableFieldsList $query); -} diff --git a/src/Core/Domain/SqlManagement/QueryHandler/GetDatabaseTablesListHandlerInterface.php b/src/Core/Domain/SqlManagement/QueryHandler/GetDatabaseTablesListHandlerInterface.php deleted file mode 100644 index ccd2d840..00000000 --- a/src/Core/Domain/SqlManagement/QueryHandler/GetDatabaseTablesListHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\DatabaseTablesList; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetDatabaseTablesList; - -/** - * Interface GetDatabaseTablesListHandlerInterface. - */ -interface GetDatabaseTablesListHandlerInterface -{ - /** - * @param GetDatabaseTablesList $query - * - * @return DatabaseTablesList - */ - public function handle(GetDatabaseTablesList $query); -} diff --git a/src/Core/Domain/SqlManagement/QueryHandler/GetSqlRequestExecutionResultHandlerInterface.php b/src/Core/Domain/SqlManagement/QueryHandler/GetSqlRequestExecutionResultHandlerInterface.php deleted file mode 100644 index 5176ed21..00000000 --- a/src/Core/Domain/SqlManagement/QueryHandler/GetSqlRequestExecutionResultHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetSqlRequestExecutionResult; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\SqlRequestExecutionResult; - -/** - * Interface GetSqlRequestResultForViewingHandlerInterface defines contract for getting SqlRequest SQL query result. - */ -interface GetSqlRequestExecutionResultHandlerInterface -{ - /** - * @param GetSqlRequestExecutionResult $query - * - * @return SqlRequestExecutionResult - */ - public function handle(GetSqlRequestExecutionResult $query); -} diff --git a/src/Core/Domain/SqlManagement/QueryHandler/GetSqlRequestForEditingHandlerInterface.php b/src/Core/Domain/SqlManagement/QueryHandler/GetSqlRequestForEditingHandlerInterface.php deleted file mode 100644 index dbeb7cf6..00000000 --- a/src/Core/Domain/SqlManagement/QueryHandler/GetSqlRequestForEditingHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\EditableSqlRequest; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetSqlRequestForEditing; - -interface GetSqlRequestForEditingHandlerInterface -{ - /** - * @param GetSqlRequestForEditing $query - * - * @return EditableSqlRequest - */ - public function handle(GetSqlRequestForEditing $query); -} diff --git a/src/Core/Domain/SqlManagement/QueryHandler/GetSqlRequestSettingsHandler.php b/src/Core/Domain/SqlManagement/QueryHandler/GetSqlRequestSettingsHandler.php deleted file mode 100644 index 608fb059..00000000 --- a/src/Core/Domain/SqlManagement/QueryHandler/GetSqlRequestSettingsHandler.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\QueryHandler; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetSqlRequestSettings; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\SqlRequestSettings; -use PrestaShop\PrestaShop\Core\Encoding\CharsetEncoding; - -/** - * Class GetSqlRequestSettingsHandler handles query to get SqlRequest settings. - */ -final class GetSqlRequestSettingsHandler implements GetSqlRequestSettingsHandlerInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function handle(GetSqlRequestSettings $query) - { - $fileEncodingIntValue = $this->configuration->get(SqlRequestSettings::FILE_ENCODING); - - return new SqlRequestSettings( - $this->getFileEncoding($fileEncodingIntValue) - ); - } - - /** - * File encodings are saved as integer values in databases. - * - * @param int|null $rawValue - * - * @return string - */ - private function getFileEncoding($rawValue) - { - $valuesMapping = [ - 1 => CharsetEncoding::UTF_8, - 2 => CharsetEncoding::ISO_8859_1, - ]; - - if (isset($valuesMapping[$rawValue])) { - return $valuesMapping[$rawValue]; - } - - return CharsetEncoding::UTF_8; - } -} diff --git a/src/Core/Domain/SqlManagement/QueryHandler/GetSqlRequestSettingsHandlerInterface.php b/src/Core/Domain/SqlManagement/QueryHandler/GetSqlRequestSettingsHandlerInterface.php deleted file mode 100644 index 57537c1d..00000000 --- a/src/Core/Domain/SqlManagement/QueryHandler/GetSqlRequestSettingsHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetSqlRequestSettings; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\SqlRequestSettings; - -/** - * Interface GetSqlRequestSettingsHandlerInterface. - */ -interface GetSqlRequestSettingsHandlerInterface -{ - /** - * @param GetSqlRequestSettings $query - * - * @return SqlRequestSettings - */ - public function handle(GetSqlRequestSettings $query); -} diff --git a/src/Core/Domain/SqlManagement/SqlRequestExecutionResult.php b/src/Core/Domain/SqlManagement/SqlRequestExecutionResult.php deleted file mode 100644 index 89e0b02c..00000000 --- a/src/Core/Domain/SqlManagement/SqlRequestExecutionResult.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement; - -/** - * Class SqlRequestExecutionResult stores result of SqlRequest SQL query execution result. - */ -class SqlRequestExecutionResult -{ - /** - * @var array - */ - private $columns; - - /** - * @var array - */ - private $rows; - - /** - * @param array $columns - * @param array $rows - */ - public function __construct(array $columns, array $rows) - { - $this->columns = $columns; - $this->rows = $rows; - } - - /** - * @return array - */ - public function getColumns() - { - return $this->columns; - } - - /** - * @return array - */ - public function getRows() - { - return $this->rows; - } -} diff --git a/src/Core/Domain/SqlManagement/SqlRequestSettings.php b/src/Core/Domain/SqlManagement/SqlRequestSettings.php deleted file mode 100644 index c738f8c0..00000000 --- a/src/Core/Domain/SqlManagement/SqlRequestSettings.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement; - -/** - * Class SqlRequestSettings stores SqlRequest settings. - */ -class SqlRequestSettings -{ - /** - * Name of the setting for SqlRequest SQL query result file encoding in ps_configuration. - */ - const FILE_ENCODING = 'PS_ENCODING_FILE_MANAGER_SQL'; - - /** - * @var string Encoding in which downloaded SqlRequest SQL query result files will be encoded - */ - private $fileEncoding; - - /** - * @param $fileEncoding - */ - public function __construct($fileEncoding) - { - $this->setFileEncoding($fileEncoding); - } - - /** - * @return string - */ - public function getFileEncoding() - { - return $this->fileEncoding; - } - - /** - * @param string $fileEncoding - */ - private function setFileEncoding($fileEncoding) - { - $this->fileEncoding = $fileEncoding; - } -} diff --git a/src/Core/Domain/SqlManagement/ValueObject/DatabaseTableField.php b/src/Core/Domain/SqlManagement/ValueObject/DatabaseTableField.php deleted file mode 100644 index be0ff104..00000000 --- a/src/Core/Domain/SqlManagement/ValueObject/DatabaseTableField.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlManagementConstraintException; - -/** - * Class DatabaseTableField stores information about single database table field. - */ -class DatabaseTableField -{ - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $type; - - /** - * @param string $name - * @param string $type - * - * @throws SqlManagementConstraintException - */ - public function __construct($name, $type) - { - $this - ->setName($name) - ->setType($type); - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param string $name - * - * @return self - * - * @throws SqlManagementConstraintException - */ - private function setName($name) - { - if (!is_string($name) || empty($name)) { - throw new SqlManagementConstraintException(sprintf('Invalid database table field name %s supplied', var_export($name, true)), SqlManagementConstraintException::INVALID_DATABASE_TABLE_FIELD_NAME); - } - - $this->name = $name; - - return $this; - } - - /** - * @return string - */ - public function getType() - { - return $this->type; - } - - /** - * @param string $type - * - * @return self - * - * @throws SqlManagementConstraintException - */ - private function setType($type) - { - if (!is_string($type) || empty($type)) { - throw new SqlManagementConstraintException(sprintf('Invalid database table field type %s supplied', var_export($type, true)), SqlManagementConstraintException::INVALID_DATABASE_TABLE_FIELD_TYPE); - } - - $this->type = $type; - - return $this; - } -} diff --git a/src/Core/Domain/SqlManagement/ValueObject/SqlRequestId.php b/src/Core/Domain/SqlManagement/ValueObject/SqlRequestId.php deleted file mode 100644 index e284af6d..00000000 --- a/src/Core/Domain/SqlManagement/ValueObject/SqlRequestId.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\SqlManagement\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestException; - -/** - * Class SqlRequestId is SqlRequest identifier. - */ -class SqlRequestId -{ - /** - * @var int - */ - private $value; - - /** - * @param int $requestSqlId - * - * @throws SqlRequestException - */ - public function __construct($requestSqlId) - { - if (!is_numeric($requestSqlId) || $requestSqlId <= 0) { - throw new SqlRequestException(sprintf('Invalid SqlRequest id: %s', var_export($requestSqlId, true))); - } - - $this->value = (int) $requestSqlId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->value; - } -} diff --git a/src/Core/Domain/State/Exception/StateConstraintException.php b/src/Core/Domain/State/Exception/StateConstraintException.php deleted file mode 100644 index 36c09322..00000000 --- a/src/Core/Domain/State/Exception/StateConstraintException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\State\Exception; - -/** - * Is thrown when State constraint is violated - */ -class StateConstraintException extends StateException -{ - const INVALID_ID = 1; -} diff --git a/src/Core/Domain/State/Exception/StateException.php b/src/Core/Domain/State/Exception/StateException.php deleted file mode 100644 index e2ed6b1d..00000000 --- a/src/Core/Domain/State/Exception/StateException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\State\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for state subdomain - */ -class StateException extends DomainException -{ -} diff --git a/src/Core/Domain/State/ValueObject/StateId.php b/src/Core/Domain/State/ValueObject/StateId.php deleted file mode 100644 index e71bbea2..00000000 --- a/src/Core/Domain/State/ValueObject/StateId.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\State\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\State\Exception\StateConstraintException; - -/** - * Provides state id - */ -class StateId -{ - /** - * @var int - */ - private $id; - - /** - * @param int $id - * - * @throws StateConstraintException - */ - public function __construct(int $id) - { - $this->assertPositiveInt($id); - $this->id = $id; - } - - /** - * @return int - */ - public function getValue(): int - { - return $this->id; - } - - /** - * @param int $value - * - * @throws StateConstraintException - */ - private function assertPositiveInt(int $value) - { - if (0 > $value) { - throw new StateConstraintException(sprintf('Invalid state id "%s".', var_export($value, true)), StateConstraintException::INVALID_ID); - } - } -} diff --git a/src/Core/Domain/Supplier/Command/AbstractBulkSupplierCommand.php b/src/Core/Domain/Supplier/Command/AbstractBulkSupplierCommand.php deleted file mode 100644 index 8c0ccafe..00000000 --- a/src/Core/Domain/Supplier/Command/AbstractBulkSupplierCommand.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Command; - -/** - * Class AbstractBulkSupplierCommand is responsible for providing shared logic between all bulk actions - * in brands and suppliers listing. - */ -abstract class AbstractBulkSupplierCommand -{ - /** - * @param array $ids - * - * @return bool - */ - protected function assertIsEmptyOrContainsNonIntegerValues(array $ids) - { - return empty($ids) || $ids !== array_filter($ids, 'is_int'); - } -} diff --git a/src/Core/Domain/Supplier/Command/AddSupplierCommand.php b/src/Core/Domain/Supplier/Command/AddSupplierCommand.php deleted file mode 100644 index e61a4fe0..00000000 --- a/src/Core/Domain/Supplier/Command/AddSupplierCommand.php +++ /dev/null @@ -1,295 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Command; - -/** - * Creates new supplier with provided data - */ -class AddSupplierCommand -{ - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $address; - - /** - * @var string - */ - private $city; - - /** - * @var int|null - */ - private $countryId; - - /** - * @var bool - */ - private $enabled; - - /** - * @var string[] - */ - private $localizedDescriptions; - - /** - * @var string[] - */ - private $localizedMetaTitles; - - /** - * @var string[] - */ - private $localizedMetaDescriptions; - - /** - * @var string[] - */ - private $localizedMetaKeywords; - - /** - * @var array - */ - private $shopAssociation; - - /** - * @var string|null - */ - private $address2; - - /** - * @var string|null - */ - private $postCode; - /** - * @var int|null - */ - private $stateId; - - /** - * @var string|null - */ - private $phone; - - /** - * @var string|null - */ - private $mobilePhone; - - /** - * @var string|null - */ - private $dni; - - /** - * @param string $name - * @param string $address - * @param string $city - * @param int $countryId - * @param bool $enabled - * @param string[] $localizedDescriptions - * @param string[] $localizedMetaTitles - * @param string[] $localizedMetaDescriptions - * @param string[] $localizedMetaKeywords - * @param array $shopAssociation - * @param string|null $address2 - * @param string|null $postCode - * @param int|null $stateId - * @param string|null $phone - * @param string|null $mobilePhone - * @param string $dni - */ - public function __construct( - string $name, - string $address, - string $city, - int $countryId, - bool $enabled, - array $localizedDescriptions, - array $localizedMetaTitles, - array $localizedMetaDescriptions, - array $localizedMetaKeywords, - array $shopAssociation, - ?string $address2 = null, - ?string $postCode = null, - ?int $stateId = null, - ?string $phone = null, - ?string $mobilePhone = null, - ?string $dni = null - ) { - $this->name = $name; - $this->address = $address; - $this->city = $city; - $this->countryId = $countryId; - $this->enabled = $enabled; - $this->localizedDescriptions = $localizedDescriptions; - $this->localizedMetaTitles = $localizedMetaTitles; - $this->localizedMetaDescriptions = $localizedMetaDescriptions; - $this->localizedMetaKeywords = $localizedMetaKeywords; - $this->shopAssociation = $shopAssociation; - $this->address2 = $address2; - $this->postCode = $postCode; - $this->stateId = $stateId; - $this->phone = $phone; - $this->mobilePhone = $mobilePhone; - $this->dni = $dni; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return string - */ - public function getAddress(): string - { - return $this->address; - } - - /** - * @return string - */ - public function getCity(): string - { - return $this->city; - } - - /** - * @return string|null - */ - public function getAddress2(): ?string - { - return $this->address2; - } - - /** - * @return int - */ - public function getCountryId(): ?int - { - return $this->countryId; - } - - /** - * @return string|null - */ - public function getPostCode(): ?string - { - return $this->postCode; - } - - /** - * @return int|null - */ - public function getStateId(): ?int - { - return $this->stateId; - } - - /** - * @return string|null - */ - public function getPhone(): ?string - { - return $this->phone; - } - - /** - * @return string|null - */ - public function getMobilePhone(): ?string - { - return $this->mobilePhone; - } - - /** - * @return string[] - */ - public function getLocalizedDescriptions(): array - { - return $this->localizedDescriptions; - } - - /** - * @return string[] - */ - public function getLocalizedMetaTitles(): array - { - return $this->localizedMetaTitles; - } - - /** - * @return string[] - */ - public function getLocalizedMetaDescriptions(): array - { - return $this->localizedMetaDescriptions; - } - - /** - * @return string[] - */ - public function getLocalizedMetaKeywords(): array - { - return $this->localizedMetaKeywords; - } - - /** - * @return bool - */ - public function isEnabled(): bool - { - return $this->enabled; - } - - /** - * @return array - */ - public function getShopAssociation(): array - { - return $this->shopAssociation; - } - - /** - * @return string|null - */ - public function getDni(): ?string - { - return $this->dni; - } -} diff --git a/src/Core/Domain/Supplier/Command/BulkDeleteSupplierCommand.php b/src/Core/Domain/Supplier/Command/BulkDeleteSupplierCommand.php deleted file mode 100644 index d4428ab3..00000000 --- a/src/Core/Domain/Supplier/Command/BulkDeleteSupplierCommand.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Command; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\ValueObject\SupplierId; - -/** - * Class BulkDeleteSupplierCommand is responsible for deleting multiple suppliers. - */ -class BulkDeleteSupplierCommand extends AbstractBulkSupplierCommand -{ - /** - * @var SupplierId[] - */ - private $supplierIds; - - /** - * @param int[] $supplierIds - * - * @throws SupplierException - * @throws SupplierConstraintException - */ - public function __construct(array $supplierIds) - { - if ($this->assertIsEmptyOrContainsNonIntegerValues($supplierIds)) { - throw new SupplierConstraintException(sprintf('Missing supplier data or array %s contains non integer values for bulk deleting', var_export($supplierIds, true)), SupplierConstraintException::INVALID_BULK_DATA); - } - - $this->setSupplierIds($supplierIds); - } - - /** - * @return SupplierId[] - */ - public function getSupplierIds() - { - return $this->supplierIds; - } - - /** - * @param array $supplierIds - * - * @throws SupplierException - */ - private function setSupplierIds(array $supplierIds) - { - foreach ($supplierIds as $id) { - $this->supplierIds[] = new SupplierId($id); - } - } -} diff --git a/src/Core/Domain/Supplier/Command/BulkDisableSupplierCommand.php b/src/Core/Domain/Supplier/Command/BulkDisableSupplierCommand.php deleted file mode 100644 index 72d3dc60..00000000 --- a/src/Core/Domain/Supplier/Command/BulkDisableSupplierCommand.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Command; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\ValueObject\SupplierId; - -/** - * Class BulkDisableSupplierCommand is responsible for disabling multiple suppliers. - */ -class BulkDisableSupplierCommand extends AbstractBulkSupplierCommand -{ - /** - * @var SupplierId[] - */ - private $supplierIds; - - /** - * @param int[] $supplierIds - * - * @throws SupplierException - * @throws SupplierConstraintException - */ - public function __construct(array $supplierIds) - { - if ($this->assertIsEmptyOrContainsNonIntegerValues($supplierIds)) { - throw new SupplierConstraintException(sprintf('Missing supplier data or array %s contains non integer values for bulk disable', var_export($supplierIds, true)), SupplierConstraintException::INVALID_BULK_DATA); - } - - $this->setSupplierIds($supplierIds); - } - - /** - * @return SupplierId[] - */ - public function getSupplierIds() - { - return $this->supplierIds; - } - - /** - * @param array $supplierIds - * - * @throws SupplierException - */ - private function setSupplierIds(array $supplierIds) - { - foreach ($supplierIds as $id) { - $this->supplierIds[] = new SupplierId($id); - } - } -} diff --git a/src/Core/Domain/Supplier/Command/BulkEnableSupplierCommand.php b/src/Core/Domain/Supplier/Command/BulkEnableSupplierCommand.php deleted file mode 100644 index 2cfae390..00000000 --- a/src/Core/Domain/Supplier/Command/BulkEnableSupplierCommand.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Command; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\ValueObject\SupplierId; - -/** - * Class BulkEnableSupplierCommand is responsible for enabling multiple suppliers. - */ -class BulkEnableSupplierCommand extends AbstractBulkSupplierCommand -{ - /** - * @var SupplierId[] - */ - private $supplierIds; - - /** - * @param int[] $supplierIds - * - * @throws SupplierException - * @throws SupplierConstraintException - */ - public function __construct(array $supplierIds) - { - if ($this->assertIsEmptyOrContainsNonIntegerValues($supplierIds)) { - throw new SupplierConstraintException(sprintf('Missing supplier data or array %s contains non integer values for bulk enable', var_export($supplierIds, true)), SupplierConstraintException::INVALID_BULK_DATA); - } - - $this->setSupplierIds($supplierIds); - } - - /** - * @return SupplierId[] - */ - public function getSupplierIds() - { - return $this->supplierIds; - } - - /** - * @param array $supplierIds - * - * @throws SupplierException - */ - private function setSupplierIds(array $supplierIds) - { - foreach ($supplierIds as $id) { - $this->supplierIds[] = new SupplierId($id); - } - } -} diff --git a/src/Core/Domain/Supplier/Command/DeleteSupplierCommand.php b/src/Core/Domain/Supplier/Command/DeleteSupplierCommand.php deleted file mode 100644 index a012b47e..00000000 --- a/src/Core/Domain/Supplier/Command/DeleteSupplierCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Command; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\ValueObject\SupplierId; - -/** - * Class DeleteSupplierCommand is responsible for deleting the supplier. - */ -class DeleteSupplierCommand -{ - /** - * @var SupplierId - */ - private $supplierId; - - /** - * @param int $supplierId - * - * @throws SupplierException - */ - public function __construct($supplierId) - { - $this->supplierId = new SupplierId($supplierId); - } - - /** - * @return SupplierId - */ - public function getSupplierId() - { - return $this->supplierId; - } -} diff --git a/src/Core/Domain/Supplier/Command/EditSupplierCommand.php b/src/Core/Domain/Supplier/Command/EditSupplierCommand.php deleted file mode 100644 index b39953c9..00000000 --- a/src/Core/Domain/Supplier/Command/EditSupplierCommand.php +++ /dev/null @@ -1,459 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Command; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\ValueObject\SupplierId; - -/** - * Edits supplier with provided data - */ -class EditSupplierCommand -{ - /** - * @var SupplierId - */ - private $supplierId; - - /** - * @var string|null - */ - private $name; - - /** - * @var string[]|null - */ - private $localizedDescriptions; - - /** - * @var string|null - */ - private $address; - - /** - * @var string|null - */ - private $city; - - /** - * @var string|null - */ - private $address2; - - /** - * @var int|null - */ - private $countryId; - - /** - * @var string|null - */ - private $postCode; - - /** - * @var int|null - */ - private $stateId; - - /** - * @var string|null - */ - private $phone; - - /** - * @var string|null - */ - private $mobilePhone; - - /** - * @var string[]|null - */ - private $localizedMetaTitles; - - /** - * @var string[]|null - */ - private $localizedMetaDescriptions; - - /** - * @var string[]|null - */ - private $localizedMetaKeywords; - - /** - * @var bool|null - */ - private $enabled; - - /** - * @var array|null - */ - private $associatedShops; - - /** - * @var string|null - */ - private $dni; - - /** - * @param int $supplierId - * - * @throws SupplierException - */ - public function __construct(int $supplierId) - { - $this->supplierId = new SupplierId($supplierId); - } - - /** - * @return SupplierId - */ - public function getSupplierId(): SupplierId - { - return $this->supplierId; - } - - /** - * @return string|null - */ - public function getName(): ?string - { - return $this->name; - } - - /** - * @param string $name - * - * @return EditSupplierCommand - */ - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - /** - * @return string[]|null - */ - public function getLocalizedDescriptions(): ?array - { - return $this->localizedDescriptions; - } - - /** - * @param string[] $localizedDescriptions - * - * @return EditSupplierCommand - */ - public function setLocalizedDescriptions(array $localizedDescriptions): self - { - $this->localizedDescriptions = $localizedDescriptions; - - return $this; - } - - /** - * @return string|null - */ - public function getAddress(): ?string - { - return $this->address; - } - - /** - * @param string $address - * - * @return EditSupplierCommand - */ - public function setAddress(string $address): self - { - $this->address = $address; - - return $this; - } - - /** - * @return string|null - */ - public function getCity(): ?string - { - return $this->city; - } - - /** - * @param string $city - * - * @return EditSupplierCommand - */ - public function setCity(string $city): self - { - $this->city = $city; - - return $this; - } - - /** - * @return string|null - */ - public function getAddress2(): ?string - { - return $this->address2; - } - - /** - * @param string $address2 - * - * @return EditSupplierCommand - */ - public function setAddress2(string $address2): self - { - $this->address2 = $address2; - - return $this; - } - - /** - * @return int|null - */ - public function getCountryId(): ?int - { - return $this->countryId; - } - - /** - * @param int $countryId - * - * @return EditSupplierCommand - */ - public function setCountryId(int $countryId): self - { - $this->countryId = $countryId; - - return $this; - } - - /** - * @return string|null - */ - public function getPostCode(): ?string - { - return $this->postCode; - } - - /** - * @param string $postCode - * - * @return EditSupplierCommand - */ - public function setPostCode(string $postCode): self - { - $this->postCode = $postCode; - - return $this; - } - - /** - * @return int|null - */ - public function getStateId(): ?int - { - return $this->stateId; - } - - /** - * @param int $stateId - * - * @return EditSupplierCommand - */ - public function setStateId(int $stateId): self - { - $this->stateId = $stateId; - - return $this; - } - - /** - * @return string|null - */ - public function getPhone(): ?string - { - return $this->phone; - } - - /** - * @param string $phone - * - * @return EditSupplierCommand - */ - public function setPhone(string $phone): self - { - $this->phone = $phone; - - return $this; - } - - /** - * @return string|null - */ - public function getMobilePhone(): ?string - { - return $this->mobilePhone; - } - - /** - * @param string $mobilePhone - * - * @return EditSupplierCommand - */ - public function setMobilePhone(string $mobilePhone): self - { - $this->mobilePhone = $mobilePhone; - - return $this; - } - - /** - * @return string[]|null - */ - public function getLocalizedMetaTitles(): ?array - { - return $this->localizedMetaTitles; - } - - /** - * @param string[] $localizedMetaTitles - * - * @return EditSupplierCommand - */ - public function setLocalizedMetaTitles(array $localizedMetaTitles): self - { - $this->localizedMetaTitles = $localizedMetaTitles; - - return $this; - } - - /** - * @return string[]|null - */ - public function getLocalizedMetaDescriptions(): ?array - { - return $this->localizedMetaDescriptions; - } - - /** - * @param string[] $localizedMetaDescriptions - * - * @return EditSupplierCommand - */ - public function setLocalizedMetaDescriptions(array $localizedMetaDescriptions): self - { - $this->localizedMetaDescriptions = $localizedMetaDescriptions; - - return $this; - } - - /** - * @return string[]|null - */ - public function getLocalizedMetaKeywords(): ?array - { - return $this->localizedMetaKeywords; - } - - /** - * @param string[] $localizedMetaKeywords - * - * @return EditSupplierCommand - */ - public function setLocalizedMetaKeywords(array $localizedMetaKeywords): self - { - $this->localizedMetaKeywords = $localizedMetaKeywords; - - return $this; - } - - /** - * @return bool|null - */ - public function isEnabled(): ?bool - { - return $this->enabled; - } - - /** - * @param bool $enabled - * - * @return EditSupplierCommand - */ - public function setEnabled(bool $enabled): self - { - $this->enabled = $enabled; - - return $this; - } - - /** - * @return array|null - */ - public function getAssociatedShops(): ?array - { - return $this->associatedShops; - } - - /** - * @param array $associatedShops - * - * @return EditSupplierCommand - */ - public function setAssociatedShops(array $associatedShops): self - { - $this->associatedShops = $associatedShops; - - return $this; - } - - /** - * @return string|null - */ - public function getDni(): ?string - { - return $this->dni; - } - - /** - * @param string $dni - * - * @return EditSupplierCommand - */ - public function setDni(string $dni): self - { - $this->dni = $dni; - - return $this; - } -} diff --git a/src/Core/Domain/Supplier/Command/ToggleSupplierStatusCommand.php b/src/Core/Domain/Supplier/Command/ToggleSupplierStatusCommand.php deleted file mode 100644 index 539b6d8b..00000000 --- a/src/Core/Domain/Supplier/Command/ToggleSupplierStatusCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Command; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\ValueObject\SupplierId; - -/** - * Class ToggleSupplierStatusCommand is responsible for toggling supplier status. - */ -class ToggleSupplierStatusCommand -{ - /** - * @var SupplierId - */ - private $supplierId; - - /** - * @param int $supplierId - * - * @throws SupplierException - */ - public function __construct($supplierId) - { - $this->supplierId = new SupplierId($supplierId); - } - - /** - * @return SupplierId - */ - public function getSupplierId() - { - return $this->supplierId; - } -} diff --git a/src/Core/Domain/Supplier/CommandHandler/AddSupplierHandlerInterface.php b/src/Core/Domain/Supplier/CommandHandler/AddSupplierHandlerInterface.php deleted file mode 100644 index 03bc1092..00000000 --- a/src/Core/Domain/Supplier/CommandHandler/AddSupplierHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\AddSupplierCommand; -use PrestaShop\PrestaShop\Core\Domain\Supplier\ValueObject\SupplierId; - -/** - * Defines contract for AddSupplierHandler - */ -interface AddSupplierHandlerInterface -{ - /** - * @param AddSupplierCommand $command - * - * @return SupplierId - */ - public function handle(AddSupplierCommand $command); -} diff --git a/src/Core/Domain/Supplier/CommandHandler/BulkDeleteSupplierHandlerInterface.php b/src/Core/Domain/Supplier/CommandHandler/BulkDeleteSupplierHandlerInterface.php deleted file mode 100644 index 0db7dcc6..00000000 --- a/src/Core/Domain/Supplier/CommandHandler/BulkDeleteSupplierHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\BulkDeleteSupplierCommand; - -/** - * Interface BulkDeleteSupplierHandlerInterface defines contract for BulkDeleteSupplierHandler. - */ -interface BulkDeleteSupplierHandlerInterface -{ - /** - * @param BulkDeleteSupplierCommand $command - */ - public function handle(BulkDeleteSupplierCommand $command); -} diff --git a/src/Core/Domain/Supplier/CommandHandler/BulkDisableSupplierHandlerInterface.php b/src/Core/Domain/Supplier/CommandHandler/BulkDisableSupplierHandlerInterface.php deleted file mode 100644 index 378a76de..00000000 --- a/src/Core/Domain/Supplier/CommandHandler/BulkDisableSupplierHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\BulkDisableSupplierCommand; - -/** - * Interface BulkDisableSupplierHandlerInterface defines contract for BulkDisableSupplierHandler. - */ -interface BulkDisableSupplierHandlerInterface -{ - /** - * @param BulkDisableSupplierCommand $command - */ - public function handle(BulkDisableSupplierCommand $command); -} diff --git a/src/Core/Domain/Supplier/CommandHandler/BulkEnableSupplierHandlerInterface.php b/src/Core/Domain/Supplier/CommandHandler/BulkEnableSupplierHandlerInterface.php deleted file mode 100644 index 20146558..00000000 --- a/src/Core/Domain/Supplier/CommandHandler/BulkEnableSupplierHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\BulkEnableSupplierCommand; - -/** - * Interface BulkEnableSupplierHandlerInterface defines contract for BulkEnableSupplierHandler. - */ -interface BulkEnableSupplierHandlerInterface -{ - /** - * @param BulkEnableSupplierCommand $command - */ - public function handle(BulkEnableSupplierCommand $command); -} diff --git a/src/Core/Domain/Supplier/CommandHandler/DeleteSupplierHandlerInterface.php b/src/Core/Domain/Supplier/CommandHandler/DeleteSupplierHandlerInterface.php deleted file mode 100644 index 798a058a..00000000 --- a/src/Core/Domain/Supplier/CommandHandler/DeleteSupplierHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\DeleteSupplierCommand; - -/** - * Interface DeleteSupplierHandlerInterface defines contract for DeleteSupplierHandler. - */ -interface DeleteSupplierHandlerInterface -{ - /** - * @param DeleteSupplierCommand $command - */ - public function handle(DeleteSupplierCommand $command); -} diff --git a/src/Core/Domain/Supplier/CommandHandler/EditSupplierHandlerInterface.php b/src/Core/Domain/Supplier/CommandHandler/EditSupplierHandlerInterface.php deleted file mode 100644 index 36b8c119..00000000 --- a/src/Core/Domain/Supplier/CommandHandler/EditSupplierHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\EditSupplierCommand; - -/** - * Defines contract for EditSupplierHandler - */ -interface EditSupplierHandlerInterface -{ - /** - * @param EditSupplierCommand $command - */ - public function handle(EditSupplierCommand $command); -} diff --git a/src/Core/Domain/Supplier/CommandHandler/ToggleSupplierStatusHandlerInterface.php b/src/Core/Domain/Supplier/CommandHandler/ToggleSupplierStatusHandlerInterface.php deleted file mode 100644 index be1ff53b..00000000 --- a/src/Core/Domain/Supplier/CommandHandler/ToggleSupplierStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\ToggleSupplierStatusCommand; - -/** - * Interface ToggleSupplierStatusHandlerInterface defines contract for ToggleSupplierStatusHandler. - */ -interface ToggleSupplierStatusHandlerInterface -{ - /** - * @param ToggleSupplierStatusCommand $command - */ - public function handle(ToggleSupplierStatusCommand $command); -} diff --git a/src/Core/Domain/Supplier/Exception/CannotDeleteSupplierAddressException.php b/src/Core/Domain/Supplier/Exception/CannotDeleteSupplierAddressException.php deleted file mode 100644 index 99c9b037..00000000 --- a/src/Core/Domain/Supplier/Exception/CannotDeleteSupplierAddressException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Exception; - -/** - * Is thrown when supplier address cannot be deleted - */ -class CannotDeleteSupplierAddressException extends SupplierException -{ -} diff --git a/src/Core/Domain/Supplier/Exception/CannotDeleteSupplierException.php b/src/Core/Domain/Supplier/Exception/CannotDeleteSupplierException.php deleted file mode 100644 index 41dcc686..00000000 --- a/src/Core/Domain/Supplier/Exception/CannotDeleteSupplierException.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Exception; - -/** - * Thrown when fails to delete supplier - */ -class CannotDeleteSupplierException extends SupplierException -{ - /** - * When fails to delete supplier due to existing pending orders of that supplier - */ - const HAS_PENDING_ORDERS = 1; - - /** - * When fails to delete single supplier - */ - const FAILED_DELETE = 2; - - /** - * When fails to delete supplier in bulk action - */ - const FAILED_BULK_DELETE = 3; -} diff --git a/src/Core/Domain/Supplier/Exception/CannotDeleteSupplierProductRelationException.php b/src/Core/Domain/Supplier/Exception/CannotDeleteSupplierProductRelationException.php deleted file mode 100644 index cda7c597..00000000 --- a/src/Core/Domain/Supplier/Exception/CannotDeleteSupplierProductRelationException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Exception; - -/** - * Is thrown when supplier product relation cannot be deleted - */ -class CannotDeleteSupplierProductRelationException extends SupplierException -{ -} diff --git a/src/Core/Domain/Supplier/Exception/CannotToggleSupplierStatusException.php b/src/Core/Domain/Supplier/Exception/CannotToggleSupplierStatusException.php deleted file mode 100644 index f2524280..00000000 --- a/src/Core/Domain/Supplier/Exception/CannotToggleSupplierStatusException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Exception; - -/** - * Is thrown when supplier status cannot be enabled or disabled in toggling action - */ -class CannotToggleSupplierStatusException extends SupplierException -{ -} diff --git a/src/Core/Domain/Supplier/Exception/CannotUpdateSupplierStatusException.php b/src/Core/Domain/Supplier/Exception/CannotUpdateSupplierStatusException.php deleted file mode 100644 index 7e00b4ab..00000000 --- a/src/Core/Domain/Supplier/Exception/CannotUpdateSupplierStatusException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Exception; - -/** - * Is thrown when supplier status cannot be updated - */ -class CannotUpdateSupplierStatusException extends SupplierException -{ -} diff --git a/src/Core/Domain/Supplier/Exception/SupplierConstraintException.php b/src/Core/Domain/Supplier/Exception/SupplierConstraintException.php deleted file mode 100644 index c50cad0b..00000000 --- a/src/Core/Domain/Supplier/Exception/SupplierConstraintException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Exception; - -/** - * Is thrown when supplier constraints are violated - */ -class SupplierConstraintException extends SupplierException -{ - /** - * When invalid data is provided for bulk action - */ - const INVALID_BULK_DATA = 1; -} diff --git a/src/Core/Domain/Supplier/Exception/SupplierException.php b/src/Core/Domain/Supplier/Exception/SupplierException.php deleted file mode 100644 index 4c3f37a6..00000000 --- a/src/Core/Domain/Supplier/Exception/SupplierException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for supplier sub-domain - */ -class SupplierException extends DomainException -{ -} diff --git a/src/Core/Domain/Supplier/Exception/SupplierNotFoundException.php b/src/Core/Domain/Supplier/Exception/SupplierNotFoundException.php deleted file mode 100644 index 81f4621b..00000000 --- a/src/Core/Domain/Supplier/Exception/SupplierNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Exception; - -/** - * Is thrown when required supplier cannot be found - */ -class SupplierNotFoundException extends SupplierException -{ -} diff --git a/src/Core/Domain/Supplier/Query/GetSupplierForEditing.php b/src/Core/Domain/Supplier/Query/GetSupplierForEditing.php deleted file mode 100644 index 620a9a31..00000000 --- a/src/Core/Domain/Supplier/Query/GetSupplierForEditing.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Query; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\ValueObject\SupplierId; - -/** - * Gets supplier for editing in Back Office - */ -class GetSupplierForEditing -{ - /** - * @var SupplierId - */ - private $supplierId; - - /** - * @param int $supplierId - * - * @throws SupplierException - */ - public function __construct(int $supplierId) - { - $this->supplierId = new SupplierId($supplierId); - } - - /** - * @return SupplierId $supplierId - */ - public function getSupplierId(): SupplierId - { - return $this->supplierId; - } -} diff --git a/src/Core/Domain/Supplier/Query/GetSupplierForViewing.php b/src/Core/Domain/Supplier/Query/GetSupplierForViewing.php deleted file mode 100644 index 88f67887..00000000 --- a/src/Core/Domain/Supplier/Query/GetSupplierForViewing.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\Query; - -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\ValueObject\SupplierId; - -/** - * Get supplier information for viewing - */ -class GetSupplierForViewing -{ - /** - * @var SupplierId - */ - private $supplierId; - - /** - * @var LanguageId Language in which supplier is returned - */ - private $languageId; - - /** - * @param int $supplierId - * @param int $languageId - * - * @throws SupplierException - */ - public function __construct($supplierId, $languageId) - { - $this->supplierId = new SupplierId($supplierId); - $this->languageId = new LanguageId($languageId); - } - - /** - * @return SupplierId - */ - public function getSupplierId() - { - return $this->supplierId; - } - - /** - * @return LanguageId - */ - public function getLanguageId() - { - return $this->languageId; - } -} diff --git a/src/Core/Domain/Supplier/QueryHandler/GetSupplierForEditingHandlerInterface.php b/src/Core/Domain/Supplier/QueryHandler/GetSupplierForEditingHandlerInterface.php deleted file mode 100644 index 3e9c9dae..00000000 --- a/src/Core/Domain/Supplier/QueryHandler/GetSupplierForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Query\GetSupplierForEditing; -use PrestaShop\PrestaShop\Core\Domain\Supplier\QueryResult\EditableSupplier; - -/** - * Defines contract for GetSupplierForEditingHandler - */ -interface GetSupplierForEditingHandlerInterface -{ - /** - * @param GetSupplierForEditing $query - * - * @return EditableSupplier - */ - public function handle(GetSupplierForEditing $query); -} diff --git a/src/Core/Domain/Supplier/QueryHandler/GetSupplierForViewingHandlerInterface.php b/src/Core/Domain/Supplier/QueryHandler/GetSupplierForViewingHandlerInterface.php deleted file mode 100644 index f70e5adf..00000000 --- a/src/Core/Domain/Supplier/QueryHandler/GetSupplierForViewingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Query\GetSupplierForViewing; -use PrestaShop\PrestaShop\Core\Domain\Supplier\QueryResult\ViewableSupplier; - -/** - * Interface for service that handles query to get supplier for viewing - */ -interface GetSupplierForViewingHandlerInterface -{ - /** - * @param GetSupplierForViewing $query - * - * @return ViewableSupplier - */ - public function handle(GetSupplierForViewing $query); -} diff --git a/src/Core/Domain/Supplier/QueryResult/EditableSupplier.php b/src/Core/Domain/Supplier/QueryResult/EditableSupplier.php deleted file mode 100644 index 9af94cb3..00000000 --- a/src/Core/Domain/Supplier/QueryResult/EditableSupplier.php +++ /dev/null @@ -1,330 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\ValueObject\SupplierId; - -/** - * Transfers supplier data for editing - */ -class EditableSupplier -{ - /** - * @var SupplierId - */ - private $supplierId; - - /** - * @var string - */ - private $name; - - /** - * @var string[] - */ - private $localizedDescriptions; - - /** - * @var string - */ - private $address; - - /** - * @var string - */ - private $city; - - /** - * @var string - */ - private $address2; - - /** - * @var int - */ - private $countryId; - - /** - * @var string - */ - private $postCode; - - /** - * @var int - */ - private $stateId; - - /** - * @var string - */ - private $phone; - - /** - * @var string - */ - private $mobilePhone; - - /** - * @var array - */ - private $logoImage; - - /** - * @var string[] - */ - private $localizedMetaTitles; - - /** - * @var string[] - */ - private $localizedMetaDescriptions; - - /** - * @var string[] - */ - private $localizedMetaKeywords; - - /** - * @var bool - */ - private $enabled; - - /** - * @var array - */ - private $associatedShops; - - /** - * @var string - */ - private $dni; - - /** - * @param SupplierId $supplierId - * @param string $name - * @param string[] $localizedDescriptions - * @param string $address - * @param string $city - * @param string $address2 - * @param int $countryId - * @param string $postCode - * @param int $stateId - * @param string $phone - * @param string $mobilePhone - * @param string[] $localizedMetaTitles - * @param string[] $localizedMetaDescriptions - * @param string[] $localizedMetaKeywords - * @param bool $enabled - * @param array $associatedShops - * @param string $dni - * @param array|null $logoImage - */ - public function __construct( - SupplierId $supplierId, - string $name, - array $localizedDescriptions, - string $address, - string $city, - string $address2, - int $countryId, - string $postCode, - int $stateId, - string $phone, - string $mobilePhone, - array $localizedMetaTitles, - array $localizedMetaDescriptions, - array $localizedMetaKeywords, - bool $enabled, - array $associatedShops, - string $dni, - ?array $logoImage = null - ) { - $this->supplierId = $supplierId; - $this->name = $name; - $this->localizedDescriptions = $localizedDescriptions; - $this->address = $address; - $this->city = $city; - $this->address2 = $address2; - $this->countryId = $countryId; - $this->postCode = $postCode; - $this->stateId = $stateId; - $this->phone = $phone; - $this->mobilePhone = $mobilePhone; - $this->logoImage = $logoImage; - $this->localizedMetaTitles = $localizedMetaTitles; - $this->localizedMetaDescriptions = $localizedMetaDescriptions; - $this->localizedMetaKeywords = $localizedMetaKeywords; - $this->enabled = $enabled; - $this->dni = $dni; - $this->associatedShops = $associatedShops; - } - - /** - * @return SupplierId - */ - public function getSupplierId(): SupplierId - { - return $this->supplierId; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @return string[] - */ - public function getLocalizedDescriptions(): array - { - return $this->localizedDescriptions; - } - - /** - * @return string - */ - public function getAddress(): string - { - return $this->address; - } - - /** - * @return string - */ - public function getCity(): string - { - return $this->city; - } - - /** - * @return string - */ - public function getAddress2(): string - { - return $this->address2; - } - - /** - * @return int - */ - public function getCountryId(): int - { - return $this->countryId; - } - - /** - * @return string - */ - public function getPostCode(): string - { - return $this->postCode; - } - - /** - * @return int - */ - public function getStateId(): int - { - return $this->stateId; - } - - /** - * @return string - */ - public function getPhone(): string - { - return $this->phone; - } - - /** - * @return string - */ - public function getMobilePhone(): string - { - return $this->mobilePhone; - } - - /** - * @return array|null - */ - public function getLogoImage(): ?array - { - return $this->logoImage; - } - - /** - * @return string[] - */ - public function getLocalizedMetaTitles(): array - { - return $this->localizedMetaTitles; - } - - /** - * @return string[] - */ - public function getLocalizedMetaDescriptions(): array - { - return $this->localizedMetaDescriptions; - } - - /** - * @return string[] - */ - public function getLocalizedMetaKeywords(): array - { - return $this->localizedMetaKeywords; - } - - /** - * @return bool - */ - public function isEnabled(): bool - { - return $this->enabled; - } - - /** - * @return array - */ - public function getAssociatedShops(): array - { - return $this->associatedShops; - } - - /** - * @return string - */ - public function getDni(): string - { - return $this->dni; - } -} diff --git a/src/Core/Domain/Supplier/QueryResult/ViewableSupplier.php b/src/Core/Domain/Supplier/QueryResult/ViewableSupplier.php deleted file mode 100644 index c6e40ae0..00000000 --- a/src/Core/Domain/Supplier/QueryResult/ViewableSupplier.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\QueryResult; - -/** - * Stores query result for getting supplier for viewing - */ -class ViewableSupplier -{ - /** - * @var string - */ - private $name; - - /** - * @var array - */ - private $supplierProducts; - - /** - * @param string $name - * @param array $supplierProducts - */ - public function __construct($name, array $supplierProducts) - { - $this->name = $name; - $this->supplierProducts = $supplierProducts; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return array - */ - public function getSupplierProducts() - { - return $this->supplierProducts; - } -} diff --git a/src/Core/Domain/Supplier/SupplierSettings.php b/src/Core/Domain/Supplier/SupplierSettings.php deleted file mode 100644 index 7aba3d00..00000000 --- a/src/Core/Domain/Supplier/SupplierSettings.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier; - -/** - * Defines settings for supplier - */ -final class SupplierSettings -{ - /** - * Maximum allowed symbols for name - */ - const MAX_NAME_LENGTH = 64; - - /** - * Maximum allowed symbols for meta title - */ - const MAX_META_TITLE_LENGTH = 255; - - /** - * Maximum allowed symbols for meta description - */ - const MAX_META_DESCRIPTION_LENGTH = 512; - - /** - * Maximum allowed symbols for meta keyword - */ - const MAX_META_KEYWORD_LENGTH = 255; -} diff --git a/src/Core/Domain/Supplier/ValueObject/SupplierId.php b/src/Core/Domain/Supplier/ValueObject/SupplierId.php deleted file mode 100644 index 652705d9..00000000 --- a/src/Core/Domain/Supplier/ValueObject/SupplierId.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Supplier\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; - -/** - * Class SupplierId - */ -class SupplierId -{ - /** - * @var int - */ - private $value; - - /** - * @param int $supplierId - * - * @throws SupplierException - */ - public function __construct($supplierId) - { - $this->assertIsIntegerGreaterThanZero($supplierId); - $this->value = $supplierId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->value; - } - - /** - * @param int $supplierId - * - * @throws SupplierException - */ - private function assertIsIntegerGreaterThanZero($supplierId) - { - if (!is_int($supplierId) || 0 >= $supplierId) { - throw new SupplierException(sprintf('Invalid Supplier id: %s', var_export($supplierId, true))); - } - } -} diff --git a/src/Core/Domain/Tax/Command/AddTaxCommand.php b/src/Core/Domain/Tax/Command/AddTaxCommand.php deleted file mode 100644 index 44494c6f..00000000 --- a/src/Core/Domain/Tax/Command/AddTaxCommand.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\Command; - -/** - * Adds new tax - */ -class AddTaxCommand -{ - /** - * @var array - */ - private $localizedNames; - - /** - * @var float - */ - private $rate; - - /** - * @var bool - */ - private $enabled; - - /** - * @param array $localizedNames - * @param float $rate - * @param bool $enabled - */ - public function __construct(array $localizedNames, $rate, $enabled) - { - $this->localizedNames = $localizedNames; - $this->rate = $rate; - $this->enabled = $enabled; - } - - /** - * @return array - */ - public function getLocalizedNames() - { - return $this->localizedNames; - } - - /** - * @return float - */ - public function getRate() - { - return $this->rate; - } - - /** - * @return bool - */ - public function isEnabled() - { - return $this->enabled; - } - - /** - * @param bool $enabled - */ - public function setEnabled($enabled) - { - $this->enabled = $enabled; - } -} diff --git a/src/Core/Domain/Tax/Command/BulkDeleteTaxCommand.php b/src/Core/Domain/Tax/Command/BulkDeleteTaxCommand.php deleted file mode 100644 index 8e7bc391..00000000 --- a/src/Core/Domain/Tax/Command/BulkDeleteTaxCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\Command; - -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxException; -use PrestaShop\PrestaShop\Core\Domain\Tax\ValueObject\TaxId; - -/** - * Deletes taxes on bulk action - */ -class BulkDeleteTaxCommand -{ - /** - * @var TaxId[] - */ - private $taxIds; - - /** - * @param TaxId[] $taxIds - * - * @throws TaxException - */ - public function __construct(array $taxIds) - { - $this->setTaxIds($taxIds); - } - - /** - * @return TaxId[] - */ - public function getTaxIds() - { - return $this->taxIds; - } - - /** - * @param int[] $taxIds - * - * @throws TaxException - */ - private function setTaxIds(array $taxIds) - { - foreach ($taxIds as $taxId) { - $this->taxIds[] = new TaxId((int) $taxId); - } - } -} diff --git a/src/Core/Domain/Tax/Command/BulkToggleTaxStatusCommand.php b/src/Core/Domain/Tax/Command/BulkToggleTaxStatusCommand.php deleted file mode 100644 index 10e0cdb1..00000000 --- a/src/Core/Domain/Tax/Command/BulkToggleTaxStatusCommand.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\Command; - -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxException; -use PrestaShop\PrestaShop\Core\Domain\Tax\ValueObject\TaxId; - -/** - * Toggles taxes status on bulk action - */ -class BulkToggleTaxStatusCommand -{ - /** - * @var bool - */ - private $expectedStatus; - - /** - * @var TaxId[] - */ - private $taxIds; - - /** - * @param int[] $taxIds - * @param bool $expectedStatus - * - * @throws TaxException - */ - public function __construct(array $taxIds, $expectedStatus) - { - $this->assertIsBool($expectedStatus); - $this->setTaxIds($taxIds); - $this->expectedStatus = $expectedStatus; - } - - /** - * @return bool - */ - public function getExpectedStatus() - { - return $this->expectedStatus; - } - - /** - * @return TaxId[] - */ - public function getTaxIds() - { - return $this->taxIds; - } - - /** - * @param array $taxIds - * - * @throws TaxException - */ - private function setTaxIds(array $taxIds) - { - foreach ($taxIds as $taxId) { - $this->taxIds[] = new TaxId((int) $taxId); - } - } - - /** - * Validates that value is of type boolean - * - * @param $value - * - * @throws TaxConstraintException - */ - private function assertIsBool($value) - { - if (!is_bool($value)) { - throw new TaxConstraintException(sprintf('Status must be of type bool, but given %s', var_export($value, true)), TaxConstraintException::INVALID_STATUS); - } - } -} diff --git a/src/Core/Domain/Tax/Command/DeleteTaxCommand.php b/src/Core/Domain/Tax/Command/DeleteTaxCommand.php deleted file mode 100644 index d2bdcf23..00000000 --- a/src/Core/Domain/Tax/Command/DeleteTaxCommand.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\Command; - -use PrestaShop\PrestaShop\Core\Domain\Tax\ValueObject\TaxId; - -/** - * Deletes tax - */ -class DeleteTaxCommand -{ - /** - * @var TaxId - */ - private $taxId; - - /** - * @param int $taxId - * - * @throws \PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxException - */ - public function __construct($taxId) - { - $this->taxId = new TaxId($taxId); - } - - /** - * @return TaxId - */ - public function getTaxId() - { - return $this->taxId; - } -} diff --git a/src/Core/Domain/Tax/Command/EditTaxCommand.php b/src/Core/Domain/Tax/Command/EditTaxCommand.php deleted file mode 100644 index 3915bfe9..00000000 --- a/src/Core/Domain/Tax/Command/EditTaxCommand.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\Command; - -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxException; -use PrestaShop\PrestaShop\Core\Domain\Tax\ValueObject\TaxId; - -/** - * Edits given tax with provided data - */ -class EditTaxCommand -{ - /** - * @var TaxId - */ - private $taxId; - - /** - * @var array|null - */ - private $localizedNames; - - /** - * @var float|null - */ - private $rate; - - /** - * @var bool|null - */ - private $enabled; - - /** - * @param int $taxId - * - * @throws TaxException - */ - public function __construct($taxId) - { - $this->taxId = new TaxId($taxId); - } - - /** - * @return TaxId - */ - public function getTaxId() - { - return $this->taxId; - } - - /** - * @return array|null - */ - public function getLocalizedNames() - { - return $this->localizedNames; - } - - /** - * @param array|null $localizedNames - * - * @return self - */ - public function setLocalizedNames($localizedNames) - { - $this->localizedNames = $localizedNames; - - return $this; - } - - /** - * @return float|null - */ - public function getRate() - { - return $this->rate; - } - - /** - * @param float|null $rate - * - * @return self - */ - public function setRate($rate) - { - $this->rate = $rate; - - return $this; - } - - /** - * @return bool|null - */ - public function isEnabled() - { - return $this->enabled; - } - - /** - * @param bool|null $enabled - * - * @return self - */ - public function setEnabled($enabled) - { - $this->enabled = $enabled; - - return $this; - } -} diff --git a/src/Core/Domain/Tax/Command/ToggleTaxStatusCommand.php b/src/Core/Domain/Tax/Command/ToggleTaxStatusCommand.php deleted file mode 100644 index b1e4bef6..00000000 --- a/src/Core/Domain/Tax/Command/ToggleTaxStatusCommand.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\Command; - -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxException; -use PrestaShop\PrestaShop\Core\Domain\Tax\ValueObject\TaxId; - -/** - * Toggles tax status - */ -class ToggleTaxStatusCommand -{ - /** - * @var bool - */ - private $expectedStatus; - - /** - * @var TaxId - */ - private $taxId; - - /** - * @param string $expectedStatus - * @param int $taxId - * - * @throws TaxException - */ - public function __construct($taxId, $expectedStatus) - { - $this->assertIsBool($expectedStatus); - $this->taxId = new TaxId($taxId); - $this->expectedStatus = $expectedStatus; - } - - /** - * @return bool - */ - public function getExpectedStatus() - { - return $this->expectedStatus; - } - - /** - * @return TaxId - */ - public function getTaxId() - { - return $this->taxId; - } - - /** - * Validates that value is of type boolean - * - * @param $value - * - * @throws TaxConstraintException - */ - private function assertIsBool($value) - { - if (!is_bool($value)) { - throw new TaxConstraintException(sprintf('Status must be of type bool, but given %s', var_export($value, true)), TaxConstraintException::INVALID_STATUS); - } - } -} diff --git a/src/Core/Domain/Tax/CommandHandler/AddTaxHandlerInterface.php b/src/Core/Domain/Tax/CommandHandler/AddTaxHandlerInterface.php deleted file mode 100644 index 4f21f988..00000000 --- a/src/Core/Domain/Tax/CommandHandler/AddTaxHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\AddTaxCommand; - -/** - * Defines contract for AddTaxHandler - */ -interface AddTaxHandlerInterface -{ - /** - * @param AddTaxCommand $command - */ - public function handle(AddTaxCommand $command); -} diff --git a/src/Core/Domain/Tax/CommandHandler/BulkDeleteTaxHandlerInterface.php b/src/Core/Domain/Tax/CommandHandler/BulkDeleteTaxHandlerInterface.php deleted file mode 100644 index 29a9c56b..00000000 --- a/src/Core/Domain/Tax/CommandHandler/BulkDeleteTaxHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\BulkDeleteTaxCommand; - -/** - * Defines contract for BulkDeleteTaxHandler - */ -interface BulkDeleteTaxHandlerInterface -{ - /** - * @param BulkDeleteTaxCommand $command - */ - public function handle(BulkDeleteTaxCommand $command); -} diff --git a/src/Core/Domain/Tax/CommandHandler/BulkToggleTaxStatusHandlerInterface.php b/src/Core/Domain/Tax/CommandHandler/BulkToggleTaxStatusHandlerInterface.php deleted file mode 100644 index a9a291f0..00000000 --- a/src/Core/Domain/Tax/CommandHandler/BulkToggleTaxStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\BulkToggleTaxStatusCommand; - -/** - * Defines contract for BulkToggleTaxStatus - */ -interface BulkToggleTaxStatusHandlerInterface -{ - /** - * @param BulkToggleTaxStatusCommand $command - */ - public function handle(BulkToggleTaxStatusCommand $command); -} diff --git a/src/Core/Domain/Tax/CommandHandler/DeleteTaxHandlerInterface.php b/src/Core/Domain/Tax/CommandHandler/DeleteTaxHandlerInterface.php deleted file mode 100644 index a3b38495..00000000 --- a/src/Core/Domain/Tax/CommandHandler/DeleteTaxHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\DeleteTaxCommand; - -/** - * Defines contract for DeleteTaxHandler - */ -interface DeleteTaxHandlerInterface -{ - /** - * @param DeleteTaxCommand $command - */ - public function handle(DeleteTaxCommand $command); -} diff --git a/src/Core/Domain/Tax/CommandHandler/EditTaxHandlerInterface.php b/src/Core/Domain/Tax/CommandHandler/EditTaxHandlerInterface.php deleted file mode 100644 index 3839be36..00000000 --- a/src/Core/Domain/Tax/CommandHandler/EditTaxHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\EditTaxCommand; - -/** - * Defines contract for EditTaxHandler - */ -interface EditTaxHandlerInterface -{ - /** - * @param EditTaxCommand $command - */ - public function handle(EditTaxCommand $command); -} diff --git a/src/Core/Domain/Tax/CommandHandler/ToggleTaxStatusHandlerInterface.php b/src/Core/Domain/Tax/CommandHandler/ToggleTaxStatusHandlerInterface.php deleted file mode 100644 index 42a156c9..00000000 --- a/src/Core/Domain/Tax/CommandHandler/ToggleTaxStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\ToggleTaxStatusCommand; - -/** - * Defines contract for ToggleTaxStatusHandler - */ -interface ToggleTaxStatusHandlerInterface -{ - /** - * @param ToggleTaxStatusCommand $command - */ - public function handle(ToggleTaxStatusCommand $command); -} diff --git a/src/Core/Domain/Tax/Exception/DeleteTaxException.php b/src/Core/Domain/Tax/Exception/DeleteTaxException.php deleted file mode 100644 index 66268cfe..00000000 --- a/src/Core/Domain/Tax/Exception/DeleteTaxException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\Exception; - -/** - * Is thrown when tax or taxes cannot be deleted - */ -class DeleteTaxException extends TaxException -{ - /** - * When fails to delete single tax - */ - const FAILED_DELETE = 10; - - /** - * When fails to delete taxes on bulk action - */ - const FAILED_BULK_DELETE = 20; -} diff --git a/src/Core/Domain/Tax/Exception/TaxConstraintException.php b/src/Core/Domain/Tax/Exception/TaxConstraintException.php deleted file mode 100644 index 44cac3b7..00000000 --- a/src/Core/Domain/Tax/Exception/TaxConstraintException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\Exception; - -/** - * Is thrown when tax is invalid - */ -class TaxConstraintException extends TaxException -{ - /** - * Thrown when provided tax id value is not valid - */ - const INVALID_ID = 10; - - /** - * Thrown when provided tax status value is not valid - */ - const INVALID_STATUS = 20; -} diff --git a/src/Core/Domain/Tax/Exception/TaxException.php b/src/Core/Domain/Tax/Exception/TaxException.php deleted file mode 100644 index ca658e98..00000000 --- a/src/Core/Domain/Tax/Exception/TaxException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Is base exception for Tax sub-domain - */ -class TaxException extends DomainException -{ -} diff --git a/src/Core/Domain/Tax/Exception/TaxNotFoundException.php b/src/Core/Domain/Tax/Exception/TaxNotFoundException.php deleted file mode 100644 index 8c28a044..00000000 --- a/src/Core/Domain/Tax/Exception/TaxNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\Exception; - -/** - * Is thrown when tax is not found by provided id - */ -class TaxNotFoundException extends TaxException -{ -} diff --git a/src/Core/Domain/Tax/Exception/UpdateTaxException.php b/src/Core/Domain/Tax/Exception/UpdateTaxException.php deleted file mode 100644 index 32926c03..00000000 --- a/src/Core/Domain/Tax/Exception/UpdateTaxException.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\Exception; - -/** - * Is thrown when tax or taxes cannot be updated - */ -class UpdateTaxException extends TaxException -{ - /** - * When fails to update single tax status - */ - const FAILED_UPDATE_STATUS = 10; - - /** - * When fails to update taxes status on bulk action - */ - const FAILED_BULK_UPDATE_STATUS = 20; -} diff --git a/src/Core/Domain/Tax/Query/GetTaxForEditing.php b/src/Core/Domain/Tax/Query/GetTaxForEditing.php deleted file mode 100644 index 3bbda32e..00000000 --- a/src/Core/Domain/Tax/Query/GetTaxForEditing.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\Query; - -use PrestaShop\PrestaShop\Core\Domain\Tax\ValueObject\TaxId; - -/** - * Gets tax for editing in Back Office - */ -class GetTaxForEditing -{ - /** - * @var TaxId - */ - private $taxId; - - /** - * @param int $taxId - */ - public function __construct($taxId) - { - $this->taxId = new TaxId($taxId); - } - - /** - * @return TaxId - */ - public function getTaxId() - { - return $this->taxId; - } -} diff --git a/src/Core/Domain/Tax/QueryHandler/GetTaxForEditingHandlerInterface.php b/src/Core/Domain/Tax/QueryHandler/GetTaxForEditingHandlerInterface.php deleted file mode 100644 index 42d7700c..00000000 --- a/src/Core/Domain/Tax/QueryHandler/GetTaxForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Tax\Query\GetTaxForEditing; -use PrestaShop\PrestaShop\Core\Domain\Tax\QueryResult\EditableTax; - -/** - * Defines contract for service that gets tax for editing - */ -interface GetTaxForEditingHandlerInterface -{ - /** - * @param GetTaxForEditing $query - * - * @return EditableTax - */ - public function handle(GetTaxForEditing $query); -} diff --git a/src/Core/Domain/Tax/QueryResult/EditableTax.php b/src/Core/Domain/Tax/QueryResult/EditableTax.php deleted file mode 100644 index b689f075..00000000 --- a/src/Core/Domain/Tax/QueryResult/EditableTax.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Tax\ValueObject\TaxId; - -/** - * Transfers editable tax data - */ -class EditableTax -{ - /** - * @var TaxId - */ - private $taxId; - - /** - * @var string[] - */ - private $localizedNames; - - /** - * @var float - */ - private $rate; - - /** - * @var bool - */ - private $active; - - /** - * EditableTax constructor. - * - * @param TaxId $taxId - * @param string[] $localizedNames - * @param float $rate - * @param bool $active - */ - public function __construct(TaxId $taxId, array $localizedNames, $rate, $active) - { - $this->taxId = $taxId; - $this->localizedNames = $localizedNames; - $this->rate = $rate; - $this->active = $active; - } - - /** - * @return TaxId - */ - public function getTaxId() - { - return $this->taxId; - } - - /** - * @return string[] - */ - public function getLocalizedNames() - { - return $this->localizedNames; - } - - /** - * @return float - */ - public function getRate() - { - return $this->rate; - } - - /** - * @return bool - */ - public function isActive() - { - return $this->active; - } -} diff --git a/src/Core/Domain/Tax/ValueObject/TaxId.php b/src/Core/Domain/Tax/ValueObject/TaxId.php deleted file mode 100644 index 8be1a67c..00000000 --- a/src/Core/Domain/Tax/ValueObject/TaxId.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Tax\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxConstraintException; - -/** - * Provides tax id data - */ -class TaxId -{ - /** - * @var int - */ - private $taxId; - - /** - * @param int $taxId - * - * @throws TaxConstraintException - */ - public function __construct($taxId) - { - if (!is_int($taxId) || $taxId <= 0) { - throw new TaxConstraintException(sprintf('Invalid Tax id: %s', var_export($taxId, true)), TaxConstraintException::INVALID_ID); - } - - $this->taxId = $taxId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->taxId; - } -} diff --git a/src/Core/Domain/TaxRulesGroup/Command/BulkDeleteTaxRulesGroupCommand.php b/src/Core/Domain/TaxRulesGroup/Command/BulkDeleteTaxRulesGroupCommand.php deleted file mode 100644 index 2d172d03..00000000 --- a/src/Core/Domain/TaxRulesGroup/Command/BulkDeleteTaxRulesGroupCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command; - -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupConstraintException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\ValueObject\TaxRulesGroupId; - -/** - * Command responsible for multiple tax rules groups deletion - */ -class BulkDeleteTaxRulesGroupCommand -{ - /** - * @var TaxRulesGroupId[] - */ - private $taxRulesGroupIds; - - /** - * @param int[] $taxRulesGroupIds - * - * @throws TaxRulesGroupConstraintException - */ - public function __construct(array $taxRulesGroupIds) - { - $this->setTaxRulesGroupIds($taxRulesGroupIds); - } - - /** - * @return TaxRulesGroupId[] - */ - public function getTaxRulesGroupIds(): array - { - return $this->taxRulesGroupIds; - } - - /** - * @param int[] $taxRulesGroupIds - * - * @throws TaxRulesGroupConstraintException - */ - private function setTaxRulesGroupIds(array $taxRulesGroupIds) - { - foreach ($taxRulesGroupIds as $taxRulesGroupId) { - $this->taxRulesGroupIds[] = new TaxRulesGroupId($taxRulesGroupId); - } - } -} diff --git a/src/Core/Domain/TaxRulesGroup/Command/BulkSetTaxRulesGroupStatusCommand.php b/src/Core/Domain/TaxRulesGroup/Command/BulkSetTaxRulesGroupStatusCommand.php deleted file mode 100644 index 646b2cb8..00000000 --- a/src/Core/Domain/TaxRulesGroup/Command/BulkSetTaxRulesGroupStatusCommand.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command; - -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupConstraintException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\ValueObject\TaxRulesGroupId; - -/** - * Command responsible for multiple tax rules groups status setting - */ -class BulkSetTaxRulesGroupStatusCommand -{ - /** - * @var TaxRulesGroupId[] - */ - private $taxRulesGroupIds = []; - - /** - * @var bool - */ - private $expectedStatus; - - /** - * @param array $taxRulesGroupIds - * @param bool $expectedStatus - * - * @throws TaxRulesGroupConstraintException - */ - public function __construct(array $taxRulesGroupIds, bool $expectedStatus) - { - $this->expectedStatus = $expectedStatus; - $this->setTaxRulesGroupIds($taxRulesGroupIds); - } - - /** - * @return bool - */ - public function getExpectedStatus(): bool - { - return $this->expectedStatus; - } - - /** - * @return TaxRulesGroupId[] - */ - public function getTaxRulesGroupIds(): array - { - return $this->taxRulesGroupIds; - } - - /** - * @param int[] $taxRulesGroupIds - * - * @throws TaxRulesGroupConstraintException - */ - private function setTaxRulesGroupIds(array $taxRulesGroupIds) - { - foreach ($taxRulesGroupIds as $taxRulesGroupId) { - $this->taxRulesGroupIds[] = new TaxRulesGroupId($taxRulesGroupId); - } - } -} diff --git a/src/Core/Domain/TaxRulesGroup/Command/DeleteTaxRulesGroupCommand.php b/src/Core/Domain/TaxRulesGroup/Command/DeleteTaxRulesGroupCommand.php deleted file mode 100644 index d4a4a107..00000000 --- a/src/Core/Domain/TaxRulesGroup/Command/DeleteTaxRulesGroupCommand.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command; - -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupConstraintException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\ValueObject\TaxRulesGroupId; - -/** - * Command responsible for single tax rules group deletion - */ -class DeleteTaxRulesGroupCommand -{ - /** - * @var TaxRulesGroupId - */ - private $taxRulesGroupId; - - /** - * @param int $taxRulesGroupId - * - * @throws TaxRulesGroupConstraintException - */ - public function __construct(int $taxRulesGroupId) - { - $this->taxRulesGroupId = new TaxRulesGroupId($taxRulesGroupId); - } - - /** - * @return TaxRulesGroupId - */ - public function getTaxRulesGroupId(): TaxRulesGroupId - { - return $this->taxRulesGroupId; - } -} diff --git a/src/Core/Domain/TaxRulesGroup/Command/SetTaxRulesGroupStatusCommand.php b/src/Core/Domain/TaxRulesGroup/Command/SetTaxRulesGroupStatusCommand.php deleted file mode 100644 index cce73d32..00000000 --- a/src/Core/Domain/TaxRulesGroup/Command/SetTaxRulesGroupStatusCommand.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command; - -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupConstraintException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\ValueObject\TaxRulesGroupId; - -/** - * Command for setting single tax rules group status - */ -class SetTaxRulesGroupStatusCommand -{ - /** - * @var TaxRulesGroupId - */ - private $taxRulesGroupId; - - /** - * @var bool - */ - private $expectedStatus; - - /** - * @param int $taxRulesGroupId - * @param bool $expectedStatus - * - * @throws TaxRulesGroupConstraintException - */ - public function __construct(int $taxRulesGroupId, bool $expectedStatus) - { - $this->expectedStatus = $expectedStatus; - $this->taxRulesGroupId = new TaxRulesGroupId($taxRulesGroupId); - } - - /** - * @return TaxRulesGroupId - */ - public function getTaxRulesGroupId(): TaxRulesGroupId - { - return $this->taxRulesGroupId; - } - - /** - * @return bool - */ - public function getExpectedStatus(): bool - { - return $this->expectedStatus; - } -} diff --git a/src/Core/Domain/TaxRulesGroup/CommandHandler/BulkDeleteTaxRulesGroupHandlerInterface.php b/src/Core/Domain/TaxRulesGroup/CommandHandler/BulkDeleteTaxRulesGroupHandlerInterface.php deleted file mode 100644 index 25436166..00000000 --- a/src/Core/Domain/TaxRulesGroup/CommandHandler/BulkDeleteTaxRulesGroupHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command\BulkDeleteTaxRulesGroupCommand; - -/** - * Defines contract for bulk delete tax rules group handler - */ -interface BulkDeleteTaxRulesGroupHandlerInterface -{ - /** - * @param BulkDeleteTaxRulesGroupCommand $command - */ - public function handle(BulkDeleteTaxRulesGroupCommand $command): void; -} diff --git a/src/Core/Domain/TaxRulesGroup/CommandHandler/BulkToggleTaxRulesGroupStatusHandlerInterface.php b/src/Core/Domain/TaxRulesGroup/CommandHandler/BulkToggleTaxRulesGroupStatusHandlerInterface.php deleted file mode 100644 index 65780477..00000000 --- a/src/Core/Domain/TaxRulesGroup/CommandHandler/BulkToggleTaxRulesGroupStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command\BulkSetTaxRulesGroupStatusCommand; - -/** - * Defines contract for bulk toggle tax rules group status handler - */ -interface BulkToggleTaxRulesGroupStatusHandlerInterface -{ - /** - * @param BulkSetTaxRulesGroupStatusCommand $command - */ - public function handle(BulkSetTaxRulesGroupStatusCommand $command): void; -} diff --git a/src/Core/Domain/TaxRulesGroup/CommandHandler/DeleteTaxRulesGroupHandlerInterface.php b/src/Core/Domain/TaxRulesGroup/CommandHandler/DeleteTaxRulesGroupHandlerInterface.php deleted file mode 100644 index b1c5d797..00000000 --- a/src/Core/Domain/TaxRulesGroup/CommandHandler/DeleteTaxRulesGroupHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command\DeleteTaxRulesGroupCommand; - -/** - * Defines contract for delete tax rules group handler - */ -interface DeleteTaxRulesGroupHandlerInterface -{ - /** - * @param DeleteTaxRulesGroupCommand $command - */ - public function handle(DeleteTaxRulesGroupCommand $command): void; -} diff --git a/src/Core/Domain/TaxRulesGroup/CommandHandler/ToggleTaxRulesGroupStatusHandlerInterface.php b/src/Core/Domain/TaxRulesGroup/CommandHandler/ToggleTaxRulesGroupStatusHandlerInterface.php deleted file mode 100644 index 0a86224b..00000000 --- a/src/Core/Domain/TaxRulesGroup/CommandHandler/ToggleTaxRulesGroupStatusHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command\SetTaxRulesGroupStatusCommand; - -/** - * Defines contract for toggle tax rules group status handler - */ -interface ToggleTaxRulesGroupStatusHandlerInterface -{ - /** - * @param SetTaxRulesGroupStatusCommand $command - */ - public function handle(SetTaxRulesGroupStatusCommand $command): void; -} diff --git a/src/Core/Domain/TaxRulesGroup/Exception/CannotBulkDeleteTaxRulesGroupException.php b/src/Core/Domain/TaxRulesGroup/Exception/CannotBulkDeleteTaxRulesGroupException.php deleted file mode 100644 index b9eb61fa..00000000 --- a/src/Core/Domain/TaxRulesGroup/Exception/CannotBulkDeleteTaxRulesGroupException.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception; - -use Exception; - -/** - * Thrown on failure to delete all selected tax rules groups without errors - */ -class CannotBulkDeleteTaxRulesGroupException extends TaxRulesGroupException -{ - /** - * @var int[] - */ - private $taxRulesGroupsIds; - - public function __construct(array $taxRulesGroupsIds, $message = '', $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - - $this->taxRulesGroupsIds = $taxRulesGroupsIds; - } - - /** - * @return int[] - */ - public function getTaxRulesGroupsIds() - { - return $this->taxRulesGroupsIds; - } -} diff --git a/src/Core/Domain/TaxRulesGroup/Exception/CannotBulkUpdateTaxRulesGroupException.php b/src/Core/Domain/TaxRulesGroup/Exception/CannotBulkUpdateTaxRulesGroupException.php deleted file mode 100644 index 2c3cab81..00000000 --- a/src/Core/Domain/TaxRulesGroup/Exception/CannotBulkUpdateTaxRulesGroupException.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception; - -use Exception; - -/** - * Thrown on failure to bulk update tax rules groups without errors - */ -class CannotBulkUpdateTaxRulesGroupException extends TaxRulesGroupException -{ - /** - * @var int[] - */ - private $taxRulesGroupsIds; - - /** - * @param array $taxRulesGroupsIds - * @param string $message - * @param int $code - * @param Exception|null $previous - */ - public function __construct(array $taxRulesGroupsIds, $message = '', $code = 0, Exception $previous = null) - { - parent::__construct($message, $code, $previous); - - $this->taxRulesGroupsIds = $taxRulesGroupsIds; - } - - /** - * @return int[] - */ - public function getTaxRulesGroupsIds() - { - return $this->taxRulesGroupsIds; - } -} diff --git a/src/Core/Domain/TaxRulesGroup/Exception/CannotDeleteTaxRulesGroupException.php b/src/Core/Domain/TaxRulesGroup/Exception/CannotDeleteTaxRulesGroupException.php deleted file mode 100644 index 88757994..00000000 --- a/src/Core/Domain/TaxRulesGroup/Exception/CannotDeleteTaxRulesGroupException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception; - -/** - * Thrown on failure to delete single tax rules group - */ -class CannotDeleteTaxRulesGroupException extends TaxRulesGroupException -{ -} diff --git a/src/Core/Domain/TaxRulesGroup/Exception/CannotUpdateTaxRulesGroupException.php b/src/Core/Domain/TaxRulesGroup/Exception/CannotUpdateTaxRulesGroupException.php deleted file mode 100644 index a3fe8246..00000000 --- a/src/Core/Domain/TaxRulesGroup/Exception/CannotUpdateTaxRulesGroupException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception; - -/** - * Thrown on failure to update tax rules group - */ -class CannotUpdateTaxRulesGroupException extends TaxRulesGroupException -{ - /** - * Thrown when status toggling fails - */ - public const FAILED_TOGGLE_STATUS = 1; -} diff --git a/src/Core/Domain/TaxRulesGroup/Exception/TaxRulesGroupConstraintException.php b/src/Core/Domain/TaxRulesGroup/Exception/TaxRulesGroupConstraintException.php deleted file mode 100644 index 7aaa8fa3..00000000 --- a/src/Core/Domain/TaxRulesGroup/Exception/TaxRulesGroupConstraintException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception; - -/** - * Thrown when tax rules group constraint is violated - */ -class TaxRulesGroupConstraintException extends TaxRulesGroupException -{ - /** - * Thrown when provided tax rules group id value is not valid - */ - public const INVALID_ID = 1; -} diff --git a/src/Core/Domain/TaxRulesGroup/Exception/TaxRulesGroupException.php b/src/Core/Domain/TaxRulesGroup/Exception/TaxRulesGroupException.php deleted file mode 100644 index 05d51970..00000000 --- a/src/Core/Domain/TaxRulesGroup/Exception/TaxRulesGroupException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for tax rules group subdomain - */ -class TaxRulesGroupException extends DomainException -{ -} diff --git a/src/Core/Domain/TaxRulesGroup/Exception/TaxRulesGroupNotFoundException.php b/src/Core/Domain/TaxRulesGroup/Exception/TaxRulesGroupNotFoundException.php deleted file mode 100644 index f4a5bf21..00000000 --- a/src/Core/Domain/TaxRulesGroup/Exception/TaxRulesGroupNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception; - -/** - * Thrown on failure to find existing tax rules group - */ -class TaxRulesGroupNotFoundException extends TaxRulesGroupException -{ -} diff --git a/src/Core/Domain/TaxRulesGroup/Query/GetTaxRulesGroupForEditing.php b/src/Core/Domain/TaxRulesGroup/Query/GetTaxRulesGroupForEditing.php deleted file mode 100644 index 5b35b5c0..00000000 --- a/src/Core/Domain/TaxRulesGroup/Query/GetTaxRulesGroupForEditing.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Query; - -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupConstraintException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\ValueObject\TaxRulesGroupId; - -/** - * Gets tax rules group for editing in Back Office - */ -class GetTaxRulesGroupForEditing -{ - /** - * @var TaxRulesGroupId - */ - private $taxRulesGroupId; - - /** - * @param int $taxRulesGroupId - * - * @throws TaxRulesGroupConstraintException - */ - public function __construct(int $taxRulesGroupId) - { - $this->taxRulesGroupId = new TaxRulesGroupId($taxRulesGroupId); - } - - /** - * @return TaxRulesGroupId $taxRulesGroupId - */ - public function getTaxRulesGroupId(): TaxRulesGroupId - { - return $this->taxRulesGroupId; - } -} diff --git a/src/Core/Domain/TaxRulesGroup/QueryHandler/GetTaxRulesGroupForEditingHandlerInterface.php b/src/Core/Domain/TaxRulesGroup/QueryHandler/GetTaxRulesGroupForEditingHandlerInterface.php deleted file mode 100644 index 229a61fb..00000000 --- a/src/Core/Domain/TaxRulesGroup/QueryHandler/GetTaxRulesGroupForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Query\GetTaxRulesGroupForEditing; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\QueryResult\EditableTaxRulesGroup; - -/** - * Defines contract for handler providing tax rules group for editing - */ -interface GetTaxRulesGroupForEditingHandlerInterface -{ - /** - * @param GetTaxRulesGroupForEditing $query - * - * @return EditableTaxRulesGroup - */ - public function handle(GetTaxRulesGroupForEditing $query): EditableTaxRulesGroup; -} diff --git a/src/Core/Domain/TaxRulesGroup/QueryResult/EditableTaxRulesGroup.php b/src/Core/Domain/TaxRulesGroup/QueryResult/EditableTaxRulesGroup.php deleted file mode 100644 index 0c62ec31..00000000 --- a/src/Core/Domain/TaxRulesGroup/QueryResult/EditableTaxRulesGroup.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\ValueObject\TaxRulesGroupId; - -/** - * Transfers tax rules group data for editing - */ -class EditableTaxRulesGroup -{ - /** - * @var TaxRulesGroupId - */ - private $taxRulesGroupId; - - /** - * @var bool - */ - private $active; - - /** - * @param TaxRulesGroupId $taxRulesGroupId - * @param bool $active - */ - public function __construct(TaxRulesGroupId $taxRulesGroupId, bool $active) - { - $this->taxRulesGroupId = $taxRulesGroupId; - $this->active = $active; - } - - /** - * @return TaxRulesGroupId - */ - public function getTaxRulesGroupId(): TaxRulesGroupId - { - return $this->taxRulesGroupId; - } - - /** - * @return bool - */ - public function isActive(): bool - { - return $this->active; - } -} diff --git a/src/Core/Domain/TaxRulesGroup/ValueObject/TaxRulesGroupId.php b/src/Core/Domain/TaxRulesGroup/ValueObject/TaxRulesGroupId.php deleted file mode 100644 index 63c9b2eb..00000000 --- a/src/Core/Domain/TaxRulesGroup/ValueObject/TaxRulesGroupId.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupConstraintException; - -/** - * Provide tax rules group id - */ -class TaxRulesGroupId -{ - /** - * @var int - */ - private $id; - - /** - * @param int $id - * - * @throws TaxRulesGroupConstraintException - */ - public function __construct(int $id) - { - $this->assertPositiveInt($id); - $this->id = $id; - } - - /** - * @return int - */ - public function getValue(): int - { - return $this->id; - } - - /** - * @param int $value - * - * @throws TaxRulesGroupConstraintException - */ - private function assertPositiveInt(int $value): void - { - if (0 > $value) { - throw new TaxRulesGroupConstraintException(sprintf('Invalid tax rules group id "%s".', var_export($value, true)), TaxRulesGroupConstraintException::INVALID_ID); - } - } -} diff --git a/src/Core/Domain/Theme/Command/AdaptThemeToRTLLanguagesCommand.php b/src/Core/Domain/Theme/Command/AdaptThemeToRTLLanguagesCommand.php deleted file mode 100644 index a69eaf68..00000000 --- a/src/Core/Domain/Theme/Command/AdaptThemeToRTLLanguagesCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\Command; - -use PrestaShop\PrestaShop\Core\Domain\Theme\ValueObject\ThemeName; - -/** - * Class AdaptThemeToRTLLanguagesCommand adapts given theme to RTL languages. - */ -class AdaptThemeToRTLLanguagesCommand -{ - /** - * @var ThemeName - */ - private $themeName; - - /** - * @param ThemeName $themeName - */ - public function __construct(ThemeName $themeName) - { - $this->themeName = $themeName; - } - - /** - * @return ThemeName - */ - public function getThemeName() - { - return $this->themeName; - } -} diff --git a/src/Core/Domain/Theme/Command/DeleteThemeCommand.php b/src/Core/Domain/Theme/Command/DeleteThemeCommand.php deleted file mode 100644 index ac6459bd..00000000 --- a/src/Core/Domain/Theme/Command/DeleteThemeCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\Command; - -use PrestaShop\PrestaShop\Core\Domain\Theme\ValueObject\ThemeName; - -/** - * Class DeleteThemeCommand deletes given theme. - */ -class DeleteThemeCommand -{ - /** - * @var ThemeName - */ - private $themeName; - - /** - * @param ThemeName $themeName - */ - public function __construct(ThemeName $themeName) - { - $this->themeName = $themeName; - } - - /** - * @return ThemeName - */ - public function getThemeName() - { - return $this->themeName; - } -} diff --git a/src/Core/Domain/Theme/Command/EnableThemeCommand.php b/src/Core/Domain/Theme/Command/EnableThemeCommand.php deleted file mode 100644 index 0e2ef3de..00000000 --- a/src/Core/Domain/Theme/Command/EnableThemeCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\Command; - -use PrestaShop\PrestaShop\Core\Domain\Theme\ValueObject\ThemeName; - -/** - * Class EnableThemeCommand enables given Front Office theme for context's shop. - */ -class EnableThemeCommand -{ - /** - * @var ThemeName - */ - private $themeName; - - /** - * @param ThemeName $themeName - */ - public function __construct(ThemeName $themeName) - { - $this->themeName = $themeName; - } - - /** - * @return ThemeName - */ - public function getThemeName() - { - return $this->themeName; - } -} diff --git a/src/Core/Domain/Theme/Command/ImportThemeCommand.php b/src/Core/Domain/Theme/Command/ImportThemeCommand.php deleted file mode 100644 index d3c3425a..00000000 --- a/src/Core/Domain/Theme/Command/ImportThemeCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\Command; - -use PrestaShop\PrestaShop\Core\Domain\Theme\ValueObject\ThemeImportSource; - -/** - * Class ImportThemeCommand imports theme from given source. - */ -class ImportThemeCommand -{ - /** - * @var ThemeImportSource - */ - private $importSource; - - /** - * @param ThemeImportSource $importSource - */ - public function __construct(ThemeImportSource $importSource) - { - $this->importSource = $importSource; - } - - /** - * @return ThemeImportSource - */ - public function getImportSource() - { - return $this->importSource; - } -} diff --git a/src/Core/Domain/Theme/Command/ResetThemeLayoutsCommand.php b/src/Core/Domain/Theme/Command/ResetThemeLayoutsCommand.php deleted file mode 100644 index ae32e9d4..00000000 --- a/src/Core/Domain/Theme/Command/ResetThemeLayoutsCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\Command; - -use PrestaShop\PrestaShop\Core\Domain\Theme\ValueObject\ThemeName; - -/** - * Class ResetThemeLayoutsCommand resets theme's page layouts to defaults. - */ -class ResetThemeLayoutsCommand -{ - /** - * @var ThemeName - */ - private $themeName; - - /** - * @param ThemeName $themeName - */ - public function __construct(ThemeName $themeName) - { - $this->themeName = $themeName; - } - - /** - * @return ThemeName - */ - public function getThemeName() - { - return $this->themeName; - } -} diff --git a/src/Core/Domain/Theme/CommandHandler/AdaptThemeToRTLLanguagesHandler.php b/src/Core/Domain/Theme/CommandHandler/AdaptThemeToRTLLanguagesHandler.php deleted file mode 100644 index d0a87b0d..00000000 --- a/src/Core/Domain/Theme/CommandHandler/AdaptThemeToRTLLanguagesHandler.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Theme\Command\AdaptThemeToRTLLanguagesCommand; -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\CannotAdaptThemeToRTLLanguagesException; -use PrestaShop\PrestaShop\Core\Localization\RTL\Exception\GenerationException; -use PrestaShop\PrestaShop\Core\Localization\RTL\StyleSheetProcessorFactoryInterface; - -/** - * Class AdaptThemeToRTLLanguagesHandler - */ -final class AdaptThemeToRTLLanguagesHandler implements AdaptThemeToRTLLanguagesHandlerInterface -{ - /** - * @var StyleSheetProcessorFactoryInterface - */ - private $stylesheetProcessorFactory; - - /** - * @param StyleSheetProcessorFactoryInterface $stylesheetProcessorFactory - */ - public function __construct(StyleSheetProcessorFactoryInterface $stylesheetProcessorFactory) - { - $this->stylesheetProcessorFactory = $stylesheetProcessorFactory; - } - - /** - * {@inheritdoc} - */ - public function handle(AdaptThemeToRTLLanguagesCommand $command) - { - $plainThemeName = $command->getThemeName()->getValue(); - - try { - $this->stylesheetProcessorFactory - ->create() - ->setProcessFOThemes([$plainThemeName]) - ->setRegenerate(true) - ->process() - ; - } catch (GenerationException $e) { - throw new CannotAdaptThemeToRTLLanguagesException(sprintf('Cannot adapt "%s" theme to RTL languages.', $plainThemeName), 0, $e); - } - } -} diff --git a/src/Core/Domain/Theme/CommandHandler/AdaptThemeToRTLLanguagesHandlerInterface.php b/src/Core/Domain/Theme/CommandHandler/AdaptThemeToRTLLanguagesHandlerInterface.php deleted file mode 100644 index 5a30cc0a..00000000 --- a/src/Core/Domain/Theme/CommandHandler/AdaptThemeToRTLLanguagesHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Theme\Command\AdaptThemeToRTLLanguagesCommand; - -/** - * Interface AdaptThemeToRTLLanguagesHandlerInterface - */ -interface AdaptThemeToRTLLanguagesHandlerInterface -{ - /** - * @param AdaptThemeToRTLLanguagesCommand $command - */ - public function handle(AdaptThemeToRTLLanguagesCommand $command); -} diff --git a/src/Core/Domain/Theme/CommandHandler/DeleteThemeHandler.php b/src/Core/Domain/Theme/CommandHandler/DeleteThemeHandler.php deleted file mode 100644 index 7bf7a8b0..00000000 --- a/src/Core/Domain/Theme/CommandHandler/DeleteThemeHandler.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler; - -use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeManager; -use PrestaShop\PrestaShop\Core\Domain\Theme\Command\DeleteThemeCommand; -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\CannotDeleteThemeException; - -/** - * Class DeleteThemeHandler - */ -final class DeleteThemeHandler implements DeleteThemeHandlerInterface -{ - /** - * @var ThemeManager - */ - private $themeManager; - - /** - * @param ThemeManager $themeManager - */ - public function __construct(ThemeManager $themeManager) - { - $this->themeManager = $themeManager; - } - - /** - * @param DeleteThemeCommand $command - */ - public function handle(DeleteThemeCommand $command) - { - $plainThemeName = $command->getThemeName()->getValue(); - - if (!$this->themeManager->uninstall($plainThemeName)) { - throw new CannotDeleteThemeException(sprintf('Theme "%s" is used and thus cannot be deleted.', $plainThemeName)); - } - } -} diff --git a/src/Core/Domain/Theme/CommandHandler/DeleteThemeHandlerInterface.php b/src/Core/Domain/Theme/CommandHandler/DeleteThemeHandlerInterface.php deleted file mode 100644 index ca268ae4..00000000 --- a/src/Core/Domain/Theme/CommandHandler/DeleteThemeHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Theme\Command\DeleteThemeCommand; - -/** - * Interface DeleteThemeHandlerInterface - */ -interface DeleteThemeHandlerInterface -{ - /** - * @param DeleteThemeCommand $command - */ - public function handle(DeleteThemeCommand $command); -} diff --git a/src/Core/Domain/Theme/CommandHandler/EnableThemeHandler.php b/src/Core/Domain/Theme/CommandHandler/EnableThemeHandler.php deleted file mode 100644 index 22c550ca..00000000 --- a/src/Core/Domain/Theme/CommandHandler/EnableThemeHandler.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler; - -use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeManager; -use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface; -use PrestaShop\PrestaShop\Core\Domain\Theme\Command\EnableThemeCommand; -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\CannotEnableThemeException; -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\ThemeConstraintException; - -/** - * Class EnableThemeHandler - */ -final class EnableThemeHandler implements EnableThemeHandlerInterface -{ - /** - * @var ThemeManager - */ - private $themeManager; - - /** - * @var CacheClearerInterface - */ - private $smartyCacheClearer; - - /** - * @var bool - */ - private $isSingleShopContext; - - /** - * @param ThemeManager $themeManager - * @param CacheClearerInterface $smartyCacheClearer - * @param $isSingleShopContext - */ - public function __construct( - ThemeManager $themeManager, - CacheClearerInterface $smartyCacheClearer, - $isSingleShopContext - ) { - $this->themeManager = $themeManager; - $this->smartyCacheClearer = $smartyCacheClearer; - $this->isSingleShopContext = $isSingleShopContext; - } - - /** - * {@inheritdoc} - * - * @throws CannotEnableThemeException - * @throws ThemeConstraintException - */ - public function handle(EnableThemeCommand $command) - { - if (!$this->isSingleShopContext) { - throw new ThemeConstraintException('Themes can be changed only in single shop context', ThemeConstraintException::RESTRICTED_ONLY_FOR_SINGLE_SHOP); - } - - $plainThemeName = $command->getThemeName()->getValue(); - - if (!$this->themeManager->enable($plainThemeName)) { - $errors = $this->themeManager->getErrors($plainThemeName); - - if (is_array($errors)) { - $error = reset($errors); - } elseif ($errors) { - $error = $errors; - } else { - // handle bad error usecases - $error = ''; - } - - throw new CannotEnableThemeException($error); - } - - $this->smartyCacheClearer->clear(); - } -} diff --git a/src/Core/Domain/Theme/CommandHandler/EnableThemeHandlerInterface.php b/src/Core/Domain/Theme/CommandHandler/EnableThemeHandlerInterface.php deleted file mode 100644 index 80a0245e..00000000 --- a/src/Core/Domain/Theme/CommandHandler/EnableThemeHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Theme\Command\EnableThemeCommand; - -/** - * Interface EnableThemeHandlerInterface - */ -interface EnableThemeHandlerInterface -{ - /** - * @param EnableThemeCommand $command - */ - public function handle(EnableThemeCommand $command); -} diff --git a/src/Core/Domain/Theme/CommandHandler/ImportThemeHandler.php b/src/Core/Domain/Theme/CommandHandler/ImportThemeHandler.php deleted file mode 100644 index 67fce6be..00000000 --- a/src/Core/Domain/Theme/CommandHandler/ImportThemeHandler.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler; - -use PrestaShop\PrestaShop\Core\Addon\Theme\Exception\ThemeAlreadyExistsException; -use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeManager; -use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeUploaderInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Theme\Command\ImportThemeCommand; -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\ImportedThemeAlreadyExistsException; -use PrestaShop\PrestaShop\Core\Domain\Theme\ValueObject\ThemeImportSource; -use PrestaShop\PrestaShop\Core\Domain\Theme\ValueObject\ThemeName; - -/** - * Class ImportThemeHandler - */ -final class ImportThemeHandler implements ImportThemeHandlerInterface -{ - /** - * @var ThemeUploaderInterface - */ - private $themeUploader; - - /** - * @var ThemeManager - */ - private $themeManager; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ThemeUploaderInterface $themeUploader - * @param ThemeManager $themeManager - * @param ConfigurationInterface $configuration - */ - public function __construct( - ThemeUploaderInterface $themeUploader, - ThemeManager $themeManager, - ConfigurationInterface $configuration - ) { - $this->themeUploader = $themeUploader; - $this->themeManager = $themeManager; - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function handle(ImportThemeCommand $command) - { - $type = $command->getImportSource()->getSourceType(); - $source = $command->getImportSource()->getSource(); - - if (ThemeImportSource::FROM_ARCHIVE === $type) { - $themePath = $this->themeUploader->upload($source); - } elseif (ThemeImportSource::FROM_WEB === $type) { - $themePath = $source; - } elseif (ThemeImportSource::FROM_FTP === $type) { - $themePath = $this->configuration->get('_PS_ALL_THEMES_DIR_') . $source; - } - - try { - $this->themeManager->install($themePath); - } catch (ThemeAlreadyExistsException $e) { - throw new ImportedThemeAlreadyExistsException(new ThemeName($e->getThemeName()), sprintf('Imported theme "%s" already exists.', $e->getThemeName()), 0, $e); - } finally { - if (ThemeImportSource::FROM_ARCHIVE === $type) { - @unlink($themePath); - } - } - } -} diff --git a/src/Core/Domain/Theme/CommandHandler/ImportThemeHandlerInterface.php b/src/Core/Domain/Theme/CommandHandler/ImportThemeHandlerInterface.php deleted file mode 100644 index 756026d4..00000000 --- a/src/Core/Domain/Theme/CommandHandler/ImportThemeHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Theme\Command\ImportThemeCommand; - -/** - * Interface ImportThemeHandlerInterface - */ -interface ImportThemeHandlerInterface -{ - /** - * @param ImportThemeCommand $command - */ - public function handle(ImportThemeCommand $command); -} diff --git a/src/Core/Domain/Theme/CommandHandler/ResetThemeLayoutsHandler.php b/src/Core/Domain/Theme/CommandHandler/ResetThemeLayoutsHandler.php deleted file mode 100644 index 0d7ba525..00000000 --- a/src/Core/Domain/Theme/CommandHandler/ResetThemeLayoutsHandler.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler; - -use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeManager; -use PrestaShop\PrestaShop\Core\Domain\Theme\Command\ResetThemeLayoutsCommand; -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\CannotResetThemeLayoutsException; - -/** - * Class ResetThemeLayoutsHandler - */ -final class ResetThemeLayoutsHandler implements ResetThemeLayoutsHandlerInterface -{ - /** - * @var ThemeManager - */ - private $themeManager; - - /** - * @param ThemeManager $themeManager - */ - public function __construct(ThemeManager $themeManager) - { - $this->themeManager = $themeManager; - } - - /** - * {@inheritdoc} - */ - public function handle(ResetThemeLayoutsCommand $command) - { - if (!$this->themeManager->reset($command->getThemeName()->getValue())) { - throw new CannotResetThemeLayoutsException(sprintf('Cannot reset "%s" theme page layouts.', $command->getThemeName()->getValue())); - } - } -} diff --git a/src/Core/Domain/Theme/CommandHandler/ResetThemeLayoutsHandlerInterface.php b/src/Core/Domain/Theme/CommandHandler/ResetThemeLayoutsHandlerInterface.php deleted file mode 100644 index bfa63d33..00000000 --- a/src/Core/Domain/Theme/CommandHandler/ResetThemeLayoutsHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Theme\Command\ResetThemeLayoutsCommand; - -/** - * Interface ResetThemeLayoutsHandlerInterface - */ -interface ResetThemeLayoutsHandlerInterface -{ - /** - * @param ResetThemeLayoutsCommand $command - */ - public function handle(ResetThemeLayoutsCommand $command); -} diff --git a/src/Core/Domain/Theme/Exception/CannotAdaptThemeToRTLLanguagesException.php b/src/Core/Domain/Theme/Exception/CannotAdaptThemeToRTLLanguagesException.php deleted file mode 100644 index f04ab095..00000000 --- a/src/Core/Domain/Theme/Exception/CannotAdaptThemeToRTLLanguagesException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\Exception; - -/** - * Thrown when fails to adapt to RTL languages - */ -class CannotAdaptThemeToRTLLanguagesException extends ThemeException -{ -} diff --git a/src/Core/Domain/Theme/Exception/CannotDeleteThemeException.php b/src/Core/Domain/Theme/Exception/CannotDeleteThemeException.php deleted file mode 100644 index e4c591e3..00000000 --- a/src/Core/Domain/Theme/Exception/CannotDeleteThemeException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\Exception; - -/** - * Thrown when fails to delete theme - */ -class CannotDeleteThemeException extends ThemeException -{ -} diff --git a/src/Core/Domain/Theme/Exception/CannotEnableThemeException.php b/src/Core/Domain/Theme/Exception/CannotEnableThemeException.php deleted file mode 100644 index 128555f2..00000000 --- a/src/Core/Domain/Theme/Exception/CannotEnableThemeException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\Exception; - -/** - * Thrown when fails to enable theme - */ -class CannotEnableThemeException extends ThemeException -{ -} diff --git a/src/Core/Domain/Theme/Exception/CannotResetThemeLayoutsException.php b/src/Core/Domain/Theme/Exception/CannotResetThemeLayoutsException.php deleted file mode 100644 index cd99ccd6..00000000 --- a/src/Core/Domain/Theme/Exception/CannotResetThemeLayoutsException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\Exception; - -/** - * Thrown when fails to reset theme layout - */ -class CannotResetThemeLayoutsException extends ThemeException -{ -} diff --git a/src/Core/Domain/Theme/Exception/FailedToEnableThemeModuleException.php b/src/Core/Domain/Theme/Exception/FailedToEnableThemeModuleException.php deleted file mode 100644 index 83ea8847..00000000 --- a/src/Core/Domain/Theme/Exception/FailedToEnableThemeModuleException.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\Exception; - -class FailedToEnableThemeModuleException extends ThemeException -{ - /** - * @var string - */ - private $moduleName; - - public function __construct( - $moduleName, - $message = '', - $code = 0, - $previous = null - ) { - parent::__construct($message, $code, $previous); - - $this->moduleName = $moduleName; - } - - /** - * @return string - */ - public function getModuleName() - { - return $this->moduleName; - } -} diff --git a/src/Core/Domain/Theme/Exception/ImportedThemeAlreadyExistsException.php b/src/Core/Domain/Theme/Exception/ImportedThemeAlreadyExistsException.php deleted file mode 100644 index 16ca7a1b..00000000 --- a/src/Core/Domain/Theme/Exception/ImportedThemeAlreadyExistsException.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Theme\ValueObject\ThemeName; - -/** - * Thrown when trying to import already existing theme - */ -class ImportedThemeAlreadyExistsException extends ThemeException -{ - /** - * @var ThemeName - */ - private $themeName; - - /** - * @param ThemeName $themeName - * @param string $message - * @param int $code - * @param null $previous - */ - public function __construct(ThemeName $themeName, $message = '', $code = 0, $previous = null) - { - parent::__construct($message, $code, $previous); - - $this->themeName = $themeName; - } - - /** - * @return ThemeName - */ - public function getThemeName() - { - return $this->themeName; - } -} diff --git a/src/Core/Domain/Theme/Exception/InvalidThemeNameException.php b/src/Core/Domain/Theme/Exception/InvalidThemeNameException.php deleted file mode 100644 index ab3d9fc8..00000000 --- a/src/Core/Domain/Theme/Exception/InvalidThemeNameException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\Exception; - -/** - * Class InvalidThemeNameException is thrown when invalid theme name is provided. - */ -class InvalidThemeNameException extends ThemeException -{ -} diff --git a/src/Core/Domain/Theme/Exception/NotSupportedThemeImportSourceException.php b/src/Core/Domain/Theme/Exception/NotSupportedThemeImportSourceException.php deleted file mode 100644 index 6c9d8637..00000000 --- a/src/Core/Domain/Theme/Exception/NotSupportedThemeImportSourceException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\Exception; - -/** - * Class NotSupportedThemeImportSourceException is thrown when not supported theme import source is being used. - */ -class NotSupportedThemeImportSourceException extends ThemeException -{ -} diff --git a/src/Core/Domain/Theme/Exception/ThemeConstraintException.php b/src/Core/Domain/Theme/Exception/ThemeConstraintException.php deleted file mode 100644 index 105c1ed4..00000000 --- a/src/Core/Domain/Theme/Exception/ThemeConstraintException.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\Exception; - -/** - * Thrown when theme constraints are violated - */ -class ThemeConstraintException extends ThemeException -{ - /** - * When trying to change theme in multi-shop context - */ - const RESTRICTED_ONLY_FOR_SINGLE_SHOP = 1; - - /** - * When trying to upload zip file which does not contain theme.yml configuration file. - */ - const MISSING_CONFIGURATION_FILE = 2; - - /** - * Its either theme has missing required files or some required properties in theme.yml - */ - const INVALID_CONFIGURATION = 3; - - /** - * Some mandatory files are missing. - */ - const INVALID_DATA = 4; -} diff --git a/src/Core/Domain/Theme/Exception/ThemeException.php b/src/Core/Domain/Theme/Exception/ThemeException.php deleted file mode 100644 index 2b5f5613..00000000 --- a/src/Core/Domain/Theme/Exception/ThemeException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Class ThemeException is base exception for theme sub-domain. - */ -class ThemeException extends DomainException -{ -} diff --git a/src/Core/Domain/Theme/ValueObject/ThemeImportSource.php b/src/Core/Domain/Theme/ValueObject/ThemeImportSource.php deleted file mode 100644 index 49ced47e..00000000 --- a/src/Core/Domain/Theme/ValueObject/ThemeImportSource.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\NotSupportedThemeImportSourceException; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Class ThemeImportSource defines available sources from where theme can be imported. - */ -class ThemeImportSource -{ - const FROM_ARCHIVE = 'from_archive'; - const FROM_WEB = 'from_web'; - const FROM_FTP = 'from_ftp'; - - /** - * @var string - */ - private $sourceType; - - /** - * @var UploadedFile|string If import source type is "from archive" - * then $source is uploaded file or path to theme otherwise - */ - private $source; - - /** - * @param UploadedFile $uploadedTheme - * - * @return ThemeImportSource - */ - public static function fromArchive(UploadedFile $uploadedTheme) - { - return new self(self::FROM_ARCHIVE, $uploadedTheme); - } - - /** - * @param string $themeUrl - * - * @return ThemeImportSource - */ - public static function fromWeb($themeUrl) - { - return new self(self::FROM_WEB, $themeUrl); - } - - /** - * @param string $themeFtp - * - * @return ThemeImportSource - */ - public static function fromFtp($themeFtp) - { - return new self(self::FROM_FTP, $themeFtp); - } - - /** - * @param string $sourceType - * @param UploadedFile|string $source - * - * @throws NotSupportedThemeImportSourceException - */ - private function __construct($sourceType, $source) - { - $this->assertSupportedThemeImportSourceTypeSupplied($sourceType); - - $this->sourceType = $sourceType; - $this->source = $source; - } - - /** - * @return string - */ - public function getSourceType() - { - return $this->sourceType; - } - - /** - * @return string|UploadedFile - */ - public function getSource() - { - return $this->source; - } - - /** - * @param string $sourceType - * - * @throws NotSupportedThemeImportSourceException - */ - private function assertSupportedThemeImportSourceTypeSupplied($sourceType) - { - $supportedSources = [self::FROM_ARCHIVE, self::FROM_WEB, self::FROM_FTP]; - - if (!in_array($sourceType, $supportedSources)) { - throw new NotSupportedThemeImportSourceException(sprintf('Not supported %s theme import source type supplied. Supported sources are: "%s"', var_export($sourceType, true), implode(',', $supportedSources))); - } - } -} diff --git a/src/Core/Domain/Theme/ValueObject/ThemeName.php b/src/Core/Domain/Theme/ValueObject/ThemeName.php deleted file mode 100644 index da7e910b..00000000 --- a/src/Core/Domain/Theme/ValueObject/ThemeName.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Theme\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\InvalidThemeNameException; - -/** - * Class ThemeName - */ -class ThemeName -{ - /** - * @var string - */ - private $themeName; - - /** - * @param string $themeName - */ - public function __construct($themeName) - { - $this->assertThemeNameIsNotEmptyString($themeName); - $this->assertThemeNameMatchesPattern($themeName); - - $this->themeName = $themeName; - } - - /** - * @return string - */ - public function getValue() - { - return $this->themeName; - } - - /** - * @param string $themeName - * - * @throws InvalidThemeNameException - */ - private function assertThemeNameIsNotEmptyString($themeName) - { - if (!is_string($themeName) || empty($themeName)) { - throw new InvalidThemeNameException('Theme name cannot be empty.'); - } - } - - /** - * @param string $themeName - * - * @throws InvalidThemeNameException - */ - private function assertThemeNameMatchesPattern($themeName) - { - if (!preg_match('/^[a-zA-Z0-9_.-]+$/', $themeName)) { - throw new InvalidThemeNameException(sprintf('Invalid theme name %s provided.', var_export($themeName, true))); - } - } -} diff --git a/src/Core/Domain/ValueObject/Email.php b/src/Core/Domain/ValueObject/Email.php deleted file mode 100644 index 55de7c04..00000000 --- a/src/Core/Domain/ValueObject/Email.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainConstraintException; - -/** - * Class Email is responsible for providing valid email value. - */ -class Email -{ - /** - * @var int Maximum allowed length for email - */ - const MAX_LENGTH = 255; - - /** - * @var string - */ - private $email; - - /** - * @param string $email - * - * @throws DomainConstraintException - */ - public function __construct($email) - { - $this->assertEmailIsString($email); - $this->assertEmailIsNotEmpty($email); - $this->assertEmailDoesNotExceedAllowedLength($email); - - $this->email = $email; - } - - /** - * @return string - */ - public function getValue() - { - return $this->email; - } - - /** - * Check if given email is the same as current - * - * @param Email $email - * - * @return bool - */ - public function isEqualTo(Email $email) - { - return strtolower($email->getValue()) === strtolower($this->getValue()); - } - - /** - * Check that email is not an empty string - * - * @param $email - * - * @throws DomainConstraintException - */ - public function assertEmailIsNotEmpty($email) - { - if (0 === strlen($email)) { - throw new DomainConstraintException('Email must not be empty', DomainConstraintException::INVALID_EMAIL); - } - } - - /** - * Assert that email length does not exceed allowed value - * - * @param string $email - * - * @throws DomainConstraintException - */ - private function assertEmailDoesNotExceedAllowedLength($email) - { - $email = html_entity_decode($email, ENT_COMPAT, 'UTF-8'); - - $length = function_exists('mb_strlen') ? mb_strlen($email, 'UTF-8') : strlen($email); - if (self::MAX_LENGTH < $length) { - throw new DomainConstraintException(sprintf('Email is too long. Max allowed length is %s', self::MAX_LENGTH), DomainConstraintException::INVALID_EMAIL); - } - } - - /** - * Assert email is of type string - * - * @param string $email - * - * @throws DomainConstraintException - */ - private function assertEmailIsString($email) - { - if (!is_string($email)) { - throw new DomainConstraintException('Email must be of type string', DomainConstraintException::INVALID_EMAIL); - } - } -} diff --git a/src/Core/Domain/ValueObject/Money.php b/src/Core/Domain/ValueObject/Money.php deleted file mode 100644 index fdff9931..00000000 --- a/src/Core/Domain/ValueObject/Money.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\ValueObject; - -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\CurrencyId; -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainConstraintException; - -/** - * An amount of money with currency - */ -class Money -{ - /** - * @var Number - */ - private $amount; - - /** - * @var CurrencyId - */ - private $currencyId; - - /** - * @param Number $amount - * @param CurrencyId $currencyId - * - * @throws DomainConstraintException - */ - public function __construct(Number $amount, CurrencyId $currencyId) - { - if (!$amount->isGreaterOrEqualThanZero()) { - throw new DomainConstraintException(sprintf('Money amount cannot be lower than zero, %f given', $amount), DomainConstraintException::INVALID_MONEY_AMOUNT); - } - - $this->amount = $amount; - $this->currencyId = $currencyId; - } - - /** - * @return Number - */ - public function getAmount(): Number - { - return $this->amount; - } - - /** - * @return CurrencyId - */ - public function getCurrencyId(): CurrencyId - { - return $this->currencyId; - } -} diff --git a/src/Core/Domain/ValueObject/QuerySorting.php b/src/Core/Domain/ValueObject/QuerySorting.php deleted file mode 100644 index c82053db..00000000 --- a/src/Core/Domain/ValueObject/QuerySorting.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Domain\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Exception\InvalidSortingException; - -/** - * Class QuerySorting is responsible for providing valid sorting parameter. - */ -class QuerySorting -{ - public const ASC = 'ASC'; - public const DESC = 'DESC'; - - /** - * @var string - */ - private $sorting; - - /** - * @param string $sorting - * - * @throws InvalidSortingException - */ - public function __construct(string $sorting) - { - $sorting = strtoupper($sorting); - $this->assertSortingSupported($sorting); - - $this->sorting = $sorting; - } - - /** - * @return string - */ - public function getValue(): string - { - return $this->sorting; - } - - /** - * @param string $sorting - * - * @throws InvalidSortingException - */ - private function assertSortingSupported(string $sorting): void - { - if (!in_array($sorting, [self::ASC, self::DESC], true)) { - throw new InvalidSortingException(); - } - } -} diff --git a/src/Core/Domain/ValueObject/Reduction.php b/src/Core/Domain/ValueObject/Reduction.php deleted file mode 100644 index c12861f2..00000000 --- a/src/Core/Domain/ValueObject/Reduction.php +++ /dev/null @@ -1,140 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\ValueObject; - -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainConstraintException; - -/** - * Provides valid reduction values - */ -class Reduction -{ - /** - * For reducing concrete amount of money from price - */ - const TYPE_AMOUNT = 'amount'; - - /** - * For reducing certain percentage calculated from price - */ - const TYPE_PERCENTAGE = 'percentage'; - - /** - * Allowed reduction types - */ - const ALLOWED_TYPES = [ - self::TYPE_AMOUNT, - self::TYPE_PERCENTAGE, - ]; - - /** - * Maximum allowed value for percentage type reduction - */ - const MAX_ALLOWED_PERCENTAGE = 100; - - /** - * @var string - */ - private $type; - - /** - * @var Number - */ - private $value; - - /** - * @param string $type - * @param float $value - * - * @throws DomainConstraintException - */ - public function __construct(string $type, float $value) - { - $this->assertIsAllowedType($type); - $this->assertIsValidValue($type, $value); - $this->type = $type; - $this->value = new Number((string) $value); - } - - /** - * @return string - */ - public function getType(): string - { - return $this->type; - } - - /** - * @return Number - */ - public function getValue(): Number - { - return $this->value; - } - - /** - * @param string $type - * - * @throws DomainConstraintException - */ - private function assertIsAllowedType(string $type) - { - if (!in_array($type, self::ALLOWED_TYPES, true)) { - throw new DomainConstraintException(sprintf('The reduction type "%s" is invalid. Valid types are: "%s", "%s".', $type, self::TYPE_AMOUNT, self::TYPE_PERCENTAGE), DomainConstraintException::INVALID_REDUCTION_TYPE); - } - } - - /** - * @param $type - * @param $value - * - * @throws DomainConstraintException - */ - private function assertIsValidValue(string $type, float $value) - { - if (self::TYPE_PERCENTAGE === $type) { - if (!$this->assertIsNotNegative($value) || self::MAX_ALLOWED_PERCENTAGE < $value) { - throw new DomainConstraintException(sprintf('Invalid reduction percentage "%s". It must be from 0 to %s%%', $value, self::MAX_ALLOWED_PERCENTAGE), DomainConstraintException::INVALID_REDUCTION_PERCENTAGE); - } - } - - if (!$this->assertIsNotNegative($value)) { - throw new DomainConstraintException(sprintf('Invalid reduction amount "%s". It cannot be less than 0', $value), DomainConstraintException::INVALID_REDUCTION_AMOUNT); - } - } - - /** - * @param float $value - * - * @return bool - */ - private function assertIsNotNegative(float $value) - { - return 0 <= $value; - } -} diff --git a/src/Core/Domain/Webservice/Command/AddWebserviceKeyCommand.php b/src/Core/Domain/Webservice/Command/AddWebserviceKeyCommand.php deleted file mode 100644 index 4b329e39..00000000 --- a/src/Core/Domain/Webservice/Command/AddWebserviceKeyCommand.php +++ /dev/null @@ -1,121 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Webservice\Command; - -use PrestaShop\PrestaShop\Core\Domain\Webservice\ValueObject\Key; - -/** - * Adds new webservice key which is used to access PrestaShop's API - */ -class AddWebserviceKeyCommand -{ - /** - * @var Key - */ - private $key; - - /** - * @var string - */ - private $description; - - /** - * @var string - */ - private $status; - - /** - * @var array - */ - private $permissions; - - /** - * @var array - */ - private $associatedShops; - - /** - * @param string $key - * @param string $description - * @param bool $status - * @param array $permissions - * @param int[] $associatedShops - */ - public function __construct( - $key, - $description, - $status, - array $permissions, - array $associatedShops - ) { - $this->key = new Key($key); - $this->description = $description; - $this->status = $status; - $this->permissions = $permissions; - $this->associatedShops = $associatedShops; - } - - /** - * @return Key - */ - public function getKey() - { - return $this->key; - } - - /** - * @return mixed - */ - public function getDescription() - { - return $this->description; - } - - /** - * @return string - */ - public function getStatus() - { - return $this->status; - } - - /** - * @return array - */ - public function getPermissions() - { - return $this->permissions; - } - - /** - * @return array - */ - public function getAssociatedShops() - { - return $this->associatedShops; - } -} diff --git a/src/Core/Domain/Webservice/Command/EditWebserviceKeyCommand.php b/src/Core/Domain/Webservice/Command/EditWebserviceKeyCommand.php deleted file mode 100644 index ab3da3b9..00000000 --- a/src/Core/Domain/Webservice/Command/EditWebserviceKeyCommand.php +++ /dev/null @@ -1,182 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Webservice\Command; - -use PrestaShop\PrestaShop\Core\Domain\Webservice\ValueObject\Key; -use PrestaShop\PrestaShop\Core\Domain\Webservice\ValueObject\WebserviceKeyId; - -/** - * Edits webservice key data - */ -class EditWebserviceKeyCommand -{ - /** - * @var WebserviceKeyId - */ - private $webserviceKeyId; - - /** - * @var Key|null - */ - private $key; - - /** - * @var string|null - */ - private $description; - - /** - * @var bool|null - */ - private $status; - - /** - * @var array|null - */ - private $permissions; - - /** - * @var int[]|null - */ - private $shopAssociation; - - /** - * @param int $webserviceKeyId - */ - public function __construct($webserviceKeyId) - { - $this->webserviceKeyId = new WebserviceKeyId($webserviceKeyId); - } - - /** - * @return WebserviceKeyId - */ - public function getWebserviceKeyId() - { - return $this->webserviceKeyId; - } - - /** - * @return Key|null - */ - public function getKey() - { - return $this->key; - } - - /** - * @param string $key - * - * @return self - */ - public function setKey($key) - { - $this->key = new Key($key); - - return $this; - } - - /** - * @return string|null - */ - public function getDescription() - { - return $this->description; - } - - /** - * @param string $description - * - * @return self - */ - public function setDescription($description) - { - $this->description = $description; - - return $this; - } - - /** - * @return bool|null - */ - public function getStatus() - { - return $this->status; - } - - /** - * @param bool $status - * - * @return self - */ - public function setStatus($status) - { - $this->status = $status; - - return $this; - } - - /** - * @return array|null - */ - public function getPermissions() - { - return $this->permissions; - } - - /** - * @param array $permissions - * - * @return self - */ - public function setPermissions(array $permissions) - { - $this->permissions = $permissions; - - return $this; - } - - /** - * @return int[]|null - */ - public function getShopAssociation() - { - return $this->shopAssociation; - } - - /** - * @param int[] $shopAssociation - * - * @return self - */ - public function setShopAssociation(array $shopAssociation) - { - $this->shopAssociation = $shopAssociation; - - return $this; - } -} diff --git a/src/Core/Domain/Webservice/CommandHandler/AddWebserviceKeyHandlerInterface.php b/src/Core/Domain/Webservice/CommandHandler/AddWebserviceKeyHandlerInterface.php deleted file mode 100644 index e4e0734d..00000000 --- a/src/Core/Domain/Webservice/CommandHandler/AddWebserviceKeyHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Webservice\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Webservice\Command\AddWebserviceKeyCommand; -use PrestaShop\PrestaShop\Core\Domain\Webservice\ValueObject\WebserviceKeyId; - -/** - * Interface for service that handles adding new webservice key - */ -interface AddWebserviceKeyHandlerInterface -{ - /** - * @param AddWebserviceKeyCommand $command - * - * @return WebserviceKeyId - */ - public function handle(AddWebserviceKeyCommand $command); -} diff --git a/src/Core/Domain/Webservice/CommandHandler/EditWebserviceKeyHandlerInterface.php b/src/Core/Domain/Webservice/CommandHandler/EditWebserviceKeyHandlerInterface.php deleted file mode 100644 index 88003013..00000000 --- a/src/Core/Domain/Webservice/CommandHandler/EditWebserviceKeyHandlerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Webservice\CommandHandler; - -use PrestaShop\PrestaShop\Core\Domain\Webservice\Command\EditWebserviceKeyCommand; - -/** - * Interface for service that handles - */ -interface EditWebserviceKeyHandlerInterface -{ - /** - * @param EditWebserviceKeyCommand $command - */ - public function handle(EditWebserviceKeyCommand $command); -} diff --git a/src/Core/Domain/Webservice/Exception/DuplicateWebserviceKeyException.php b/src/Core/Domain/Webservice/Exception/DuplicateWebserviceKeyException.php deleted file mode 100644 index a1bc72da..00000000 --- a/src/Core/Domain/Webservice/Exception/DuplicateWebserviceKeyException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Webservice\Exception; - -/** - * Is thrown when duplicate service key is encountered (e.g. when creating new webservice key which already exists) - */ -class DuplicateWebserviceKeyException extends WebserviceException -{ -} diff --git a/src/Core/Domain/Webservice/Exception/WebserviceConstraintException.php b/src/Core/Domain/Webservice/Exception/WebserviceConstraintException.php deleted file mode 100644 index d62faee7..00000000 --- a/src/Core/Domain/Webservice/Exception/WebserviceConstraintException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Webservice\Exception; - -/** - * Is thrown when some constraint is violated in Webservice subdomain - */ -class WebserviceConstraintException extends WebserviceException -{ - /** - * @var string Code is used when invalid webservice key is encountered - */ - const INVALID_KEY = 1; -} diff --git a/src/Core/Domain/Webservice/Exception/WebserviceException.php b/src/Core/Domain/Webservice/Exception/WebserviceException.php deleted file mode 100644 index b54f602d..00000000 --- a/src/Core/Domain/Webservice/Exception/WebserviceException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Webservice\Exception; - -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Base exception for Webservice subdomain - */ -class WebserviceException extends DomainException -{ -} diff --git a/src/Core/Domain/Webservice/Exception/WebserviceKeyNotFoundException.php b/src/Core/Domain/Webservice/Exception/WebserviceKeyNotFoundException.php deleted file mode 100644 index 904ffe6c..00000000 --- a/src/Core/Domain/Webservice/Exception/WebserviceKeyNotFoundException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Webservice\Exception; - -/** - * Is thrown when webservice key is not found - */ -class WebserviceKeyNotFoundException extends WebserviceException -{ -} diff --git a/src/Core/Domain/Webservice/Query/GetWebserviceKeyForEditing.php b/src/Core/Domain/Webservice/Query/GetWebserviceKeyForEditing.php deleted file mode 100644 index 45130bdd..00000000 --- a/src/Core/Domain/Webservice/Query/GetWebserviceKeyForEditing.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Webservice\Query; - -use PrestaShop\PrestaShop\Core\Domain\Webservice\ValueObject\WebserviceKeyId; - -/** - * Get webservice key data for editing - */ -class GetWebserviceKeyForEditing -{ - /** - * @var WebserviceKeyId - */ - private $webserviceKeyId; - - /** - * @param int $webserviceKeyId - */ - public function __construct($webserviceKeyId) - { - $this->webserviceKeyId = new WebserviceKeyId($webserviceKeyId); - } - - /** - * @return WebserviceKeyId - */ - public function getWebserviceKeyId() - { - return $this->webserviceKeyId; - } -} diff --git a/src/Core/Domain/Webservice/QueryHandler/GetWebserviceKeyForEditingHandlerInterface.php b/src/Core/Domain/Webservice/QueryHandler/GetWebserviceKeyForEditingHandlerInterface.php deleted file mode 100644 index 8ef07f85..00000000 --- a/src/Core/Domain/Webservice/QueryHandler/GetWebserviceKeyForEditingHandlerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Webservice\QueryHandler; - -use PrestaShop\PrestaShop\Core\Domain\Webservice\Query\GetWebserviceKeyForEditing; -use PrestaShop\PrestaShop\Core\Domain\Webservice\QueryResult\EditableWebserviceKey; - -/** - * Interface for service that handles webservice key data retrieving for editing - */ -interface GetWebserviceKeyForEditingHandlerInterface -{ - /** - * @param GetWebserviceKeyForEditing $query - * - * @return EditableWebserviceKey - */ - public function handle(GetWebserviceKeyForEditing $query); -} diff --git a/src/Core/Domain/Webservice/QueryResult/EditableWebserviceKey.php b/src/Core/Domain/Webservice/QueryResult/EditableWebserviceKey.php deleted file mode 100644 index f1768f1a..00000000 --- a/src/Core/Domain/Webservice/QueryResult/EditableWebserviceKey.php +++ /dev/null @@ -1,137 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Webservice\QueryResult; - -use PrestaShop\PrestaShop\Core\Domain\Webservice\ValueObject\WebserviceKeyId; - -/** - * Editable data for webservice key - */ -class EditableWebserviceKey -{ - /** - * @var WebserviceKeyId - */ - private $webserviceKeyId; - - /** - * @var string - */ - private $key; - - /** - * @var string - */ - private $description; - - /** - * @var bool - */ - private $status; - - /** - * @var array - */ - private $resourcePermissions; - - /** - * @var int[] - */ - private $associatedShops; - - /** - * @param WebserviceKeyId $webserviceKeyId - * @param string $key - * @param string $description - * @param bool $status - * @param array $resourcePermissions - * @param array $associatedShops - */ - public function __construct( - WebserviceKeyId $webserviceKeyId, - $key, - $description, - $status, - array $resourcePermissions, - array $associatedShops - ) { - $this->webserviceKeyId = $webserviceKeyId; - $this->key = $key; - $this->description = $description; - $this->status = $status; - $this->resourcePermissions = $resourcePermissions; - $this->associatedShops = $associatedShops; - } - - /** - * @return WebserviceKeyId - */ - public function getWebserviceKeyId() - { - return $this->webserviceKeyId; - } - - /** - * @return string - */ - public function getKey() - { - return $this->key; - } - - /** - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * @return bool - */ - public function getStatus() - { - return $this->status; - } - - /** - * @return array - */ - public function getResourcePermissions() - { - return $this->resourcePermissions; - } - - /** - * @return int[] - */ - public function getAssociatedShops() - { - return $this->associatedShops; - } -} diff --git a/src/Core/Domain/Webservice/ValueObject/Key.php b/src/Core/Domain/Webservice/ValueObject/Key.php deleted file mode 100644 index 0da50bf0..00000000 --- a/src/Core/Domain/Webservice/ValueObject/Key.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Webservice\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Webservice\Exception\WebserviceConstraintException; - -/** - * Encapsulates webservice key value - */ -class Key -{ - /** - * @var string Required length of webservice key - */ - const LENGTH = 32; - - /** - * @var string - */ - private $key; - - /** - * @param string $key - */ - public function __construct($key) - { - $this->assertKeyIsStringAndRequiredLength($key); - - $this->key = $key; - } - - /** - * @return string - */ - public function getValue() - { - return $this->key; - } - - /** - * @param string $key - */ - private function assertKeyIsStringAndRequiredLength($key) - { - if (!is_string($key) || strlen($key) !== self::LENGTH) { - throw new WebserviceConstraintException(sprintf('Webservice key must be string of %d characters length but %s given', self::LENGTH, var_export($key, true)), WebserviceConstraintException::INVALID_KEY); - } - } -} diff --git a/src/Core/Domain/Webservice/ValueObject/Permission.php b/src/Core/Domain/Webservice/ValueObject/Permission.php deleted file mode 100644 index ca510bc4..00000000 --- a/src/Core/Domain/Webservice/ValueObject/Permission.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Webservice\ValueObject; - -/** - * Defines available permissions for Webservice keys - */ -class Permission -{ - /** - * @var string Permission to view resource - */ - const VIEW = 'GET'; - - /** - * @var string Permission to view resource - */ - const FAST_VIEW = 'HEAD'; - - /** - * @var string Permission to modify existing resource - */ - const MODIFY = 'PUT'; - - /** - * @var string Permission to add new resource - */ - const ADD = 'POST'; - - /** - * @var string Permission to delete existing resource - */ - const DELETE = 'DELETE'; -} diff --git a/src/Core/Domain/Webservice/ValueObject/WebserviceKeyId.php b/src/Core/Domain/Webservice/ValueObject/WebserviceKeyId.php deleted file mode 100644 index 3f2edef5..00000000 --- a/src/Core/Domain/Webservice/ValueObject/WebserviceKeyId.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Domain\Webservice\ValueObject; - -use PrestaShop\PrestaShop\Core\Domain\Webservice\Exception\WebserviceConstraintException; - -/** - * Encapsulates webservice key id value - */ -class WebserviceKeyId -{ - /** - * @var int - */ - private $webserviceKeyId; - - /** - * @param int $webserviceKeyId - */ - public function __construct($webserviceKeyId) - { - $this->assertWebserviceKeyIdIsIntegerGreaterThanZero($webserviceKeyId); - - $this->webserviceKeyId = $webserviceKeyId; - } - - /** - * @return int - */ - public function getValue() - { - return $this->webserviceKeyId; - } - - /** - * @param int $webserviceKeyId - */ - private function assertWebserviceKeyIdIsIntegerGreaterThanZero($webserviceKeyId) - { - if (!is_int($webserviceKeyId) || $webserviceKeyId <= 0) { - throw new WebserviceConstraintException(sprintf('Webservice key id must be integer greater than 0, but %s given', var_export($webserviceKeyId, true))); - } - } -} diff --git a/src/Core/Email/EmailConfigurationTesterInterface.php b/src/Core/Email/EmailConfigurationTesterInterface.php deleted file mode 100644 index b0cd136b..00000000 --- a/src/Core/Email/EmailConfigurationTesterInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Email; - -/** - * Interface EmailConfigurationTesterInterface defines contract for email configuration tester. - */ -interface EmailConfigurationTesterInterface -{ - /** - * Test email configuration. - * - * @param array $config - * - * @return bool - */ - public function testConfiguration(array $config); -} diff --git a/src/Core/Email/EmailDataConfigurator.php b/src/Core/Email/EmailDataConfigurator.php deleted file mode 100644 index d580dd8a..00000000 --- a/src/Core/Email/EmailDataConfigurator.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Email; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; - -/** - * Class EmailDataConfigurator is responsible for configuring email data. - */ -final class EmailDataConfigurator implements DataConfigurationInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'send_emails_to' => $this->configuration->get('PS_MAIL_EMAIL_MESSAGE'), - 'mail_method' => (int) $this->configuration->get('PS_MAIL_METHOD'), - 'mail_type' => (int) $this->configuration->get('PS_MAIL_TYPE'), - 'log_emails' => (bool) $this->configuration->get('PS_LOG_EMAILS'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $config) - { - if ($this->validateConfiguration($config)) { - $this->configuration->set('PS_MAIL_EMAIL_MESSAGE', $config['send_emails_to']); - $this->configuration->set('PS_MAIL_METHOD', $config['mail_method']); - $this->configuration->set('PS_MAIL_TYPE', $config['mail_type']); - $this->configuration->set('PS_LOG_EMAILS', $config['log_emails']); - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $config) - { - return isset( - $config['send_emails_to'], - $config['mail_method'], - $config['mail_type'], - $config['log_emails'] - ); - } -} diff --git a/src/Core/Email/EmailLister.php b/src/Core/Email/EmailLister.php deleted file mode 100644 index b6c97c5a..00000000 --- a/src/Core/Email/EmailLister.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Email; - -use PrestaShop\PrestaShop\Core\Foundation\Filesystem\FileSystem; - -class EmailLister -{ - private $filesystem; - - public function __construct(FileSystem $fs) - { - // Register dependencies - $this->filesystem = $fs; - } - - /** - * Return the list of available mails. - * - * @param null $lang - * @param null $dir - * - * @return array|null - */ - public function getAvailableMails($dir) - { - if (!is_dir($dir)) { - return null; - } - - $mail_directory = $this->filesystem->listEntriesRecursively($dir); - $mail_list = []; - - // Remove unwanted .html / .txt / .tpl / .php / . / .. - foreach ($mail_directory as $mail) { - if (strpos($mail->getFilename(), '.') !== false) { - $tmp = explode('.', $mail->getFilename()); - - // Check for filename existence (left part) and if extension is html (right part) - if (($tmp === false || !isset($tmp[0])) || (isset($tmp[1]) && $tmp[1] !== 'html')) { - continue; - } - - $mail_name_no_ext = $tmp[0]; - if (!in_array($mail_name_no_ext, $mail_list)) { - $mail_list[] = $mail_name_no_ext; - } - } - } - - return $mail_list; - } - - /** - * Give in input getAvailableMails(), will output a human readable and proper string name. - * - * @return string - */ - public function getCleanedMailName($mail_name) - { - if (strpos($mail_name, '.') !== false) { - $tmp = explode('.', $mail_name); - - if ($tmp === false || !isset($tmp[0])) { - return $mail_name; - } - - $mail_name = $tmp[0]; - } - - return ucfirst(str_replace(['_', '-'], ' ', $mail_name)); - } -} diff --git a/src/Core/Email/EmailLogEraserInterface.php b/src/Core/Email/EmailLogEraserInterface.php deleted file mode 100644 index 09f36f51..00000000 --- a/src/Core/Email/EmailLogEraserInterface.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Email; - -/** - * Interface EmailLogEraserInterface defines contract for email logs eraser. - */ -interface EmailLogEraserInterface -{ - /** - * Erase given email logs. - * - * @param int[] $mailLogIds - * - * @return array - */ - public function erase(array $mailLogIds); - - /** - * Erase all email logs. - * - * @return bool TRUE if email logs where erased successfully or FALSE otherwise - */ - public function eraseAll(); -} diff --git a/src/Core/Email/MailOption.php b/src/Core/Email/MailOption.php deleted file mode 100644 index 778f6c40..00000000 --- a/src/Core/Email/MailOption.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Email; - -/** - * Class MailMethodOption defines available email sending method options. - */ -final class MailOption -{ - /** - * @var int Option defines that emails should be sent using native mail() function - */ - const METHOD_NATIVE = 1; - - /** - * @var int Option defines that emails should be sent using configured SMTP settings - */ - const METHOD_SMTP = 2; - - /** - * @var int Option defines that emails should not be sent - */ - const METHOD_NONE = 3; - - /** - * @var int Option defines that emails should be sent in HTML format only - */ - const TYPE_HTML = 1; - - /** - * @var int Option defines that emails should be sent in TXT format only - */ - const TYPE_TXT = 2; - - /** - * @var int Option defines that emails should be sent in both HTML and TXT formats - */ - const TYPE_BOTH = 3; - - /** - * Class should not be initialized as its responsibility is to hold mail method options. - */ - private function __construct() - { - } -} diff --git a/src/Core/Email/SmtpDataConfigurator.php b/src/Core/Email/SmtpDataConfigurator.php deleted file mode 100644 index 62b569ce..00000000 --- a/src/Core/Email/SmtpDataConfigurator.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Email; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; - -/** - * Class SmtpDataConfigurator is responsible for configuring SMTP data. - */ -final class SmtpDataConfigurator implements DataConfigurationInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'domain' => $this->configuration->get('PS_MAIL_DOMAIN'), - 'server' => $this->configuration->get('PS_MAIL_SERVER'), - 'username' => $this->configuration->get('PS_MAIL_USER'), - 'password' => $this->configuration->get('PS_MAIL_PASSWD'), - 'encryption' => $this->configuration->get('PS_MAIL_SMTP_ENCRYPTION'), - 'port' => $this->configuration->get('PS_MAIL_SMTP_PORT'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $config) - { - if ($this->validateConfiguration($config)) { - $this->configuration->set('PS_MAIL_DOMAIN', $config['domain']); - $this->configuration->set('PS_MAIL_SERVER', $config['server']); - $this->configuration->set('PS_MAIL_USER', $config['username']); - $this->configuration->set('PS_MAIL_SMTP_ENCRYPTION', $config['encryption']); - $this->configuration->set('PS_MAIL_SMTP_PORT', $config['port']); - - $smtpPassword = (string) $config['password']; - - if ('' !== $smtpPassword || !$this->configuration->get('PS_MAIL_PASSWD')) { - $this->configuration->set('PS_MAIL_PASSWD', $smtpPassword); - } - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $config) - { - return isset( - $config['domain'], - $config['server'], - $config['username'], - $config['encryption'], - $config['port'], - $config['password'] - ); - } -} diff --git a/src/Core/Email/SwiftMailerValidation.php b/src/Core/Email/SwiftMailerValidation.php deleted file mode 100644 index 91fb049a..00000000 --- a/src/Core/Email/SwiftMailerValidation.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Email; - -use Egulias\EmailValidator\EmailLexer; -use Egulias\EmailValidator\Exception\InvalidEmail; -use Egulias\EmailValidator\Validation\EmailValidation; -use PrestaShop\PrestaShop\Core\Exception\NonASCIIInLocalPartException; - -class SwiftMailerValidation implements EmailValidation -{ - /** - * @var InvalidEmail|null - */ - private $error; - - /** - * {@inheritdoc} - */ - public function isValid($email, EmailLexer $emailLexer) - { - if (is_string($email)) { - $parts = explode('@', $email); - if (preg_match('/[^\x00-\x7F]/', $parts[0])) { - $this->error = new NonASCIIInLocalPartException(); - } - } - - return null === $this->error; - } - - /** - * {@inheritdoc} - */ - public function getError() - { - return $this->error; - } - - /** - * {@inheritdoc} - */ - public function getWarnings() - { - return []; - } -} diff --git a/src/Core/Employee/Access/EmployeeFormAccessCheckerInterface.php b/src/Core/Employee/Access/EmployeeFormAccessCheckerInterface.php deleted file mode 100644 index 476a71cc..00000000 --- a/src/Core/Employee/Access/EmployeeFormAccessCheckerInterface.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Employee\Access; - -/** - * Interface EmployeeFormAccessCheckerInterface defines employee form access checker. - */ -interface EmployeeFormAccessCheckerInterface -{ - /** - * Checks if employee has restricted access to the employee form. - * Restricted access usually is used when an employee edits their own account. - * Restricted access means that the employee is restricted from some of - * the fields in the edit form, which would modify his account's accessibility. - * E.g. active status, profile, shop association. - * - * @param int $employeeId - * - * @return bool - */ - public function isRestrictedAccess($employeeId); - - /** - * Check if context employee can access edit form for given employee. - * - * @param int $employeeId - * - * @return bool - */ - public function canAccessEditFormFor($employeeId); - - /** - * Check if context employee can access addons connect form control. - * - * @return bool - */ - public function canAccessAddonsConnect(); -} diff --git a/src/Core/Employee/Access/ProfileAccessChecker.php b/src/Core/Employee/Access/ProfileAccessChecker.php deleted file mode 100644 index 9bb0f2f7..00000000 --- a/src/Core/Employee/Access/ProfileAccessChecker.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Employee\Access; - -use PrestaShop\PrestaShop\Core\Employee\EmployeeDataProviderInterface; - -/** - * Class ProfileAccessChecker checks profile access for employee. - */ -final class ProfileAccessChecker implements ProfileAccessCheckerInterface -{ - /** - * @var EmployeeDataProviderInterface - */ - private $employeeDataProvider; - - /** - * @var int - */ - private $superAdminProfileId; - - /** - * @param EmployeeDataProviderInterface $employeeDataProvider - * @param int $superAdminProfileId - */ - public function __construct( - EmployeeDataProviderInterface $employeeDataProvider, - $superAdminProfileId - ) { - $this->employeeDataProvider = $employeeDataProvider; - $this->superAdminProfileId = $superAdminProfileId; - } - - /** - * {@inheritdoc} - */ - public function canEmployeeAccessProfile($employeeId, $profileId) - { - if ($this->employeeDataProvider->isSuperAdmin($employeeId)) { - return true; - } - - return $profileId !== $this->superAdminProfileId; - } -} diff --git a/src/Core/Employee/Access/ProfileAccessCheckerInterface.php b/src/Core/Employee/Access/ProfileAccessCheckerInterface.php deleted file mode 100644 index 4f8c676f..00000000 --- a/src/Core/Employee/Access/ProfileAccessCheckerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Employee\Access; - -/** - * Interface ProfileAccessCheckerInterface describes a profile access checker. - */ -interface ProfileAccessCheckerInterface -{ - /** - * Checks if given employee can access given profile. - * - * @param int $employeeId - * @param int $profileId - * - * @return bool - */ - public function canEmployeeAccessProfile($employeeId, $profileId); -} diff --git a/src/Core/Employee/AvatarProviderInterface.php b/src/Core/Employee/AvatarProviderInterface.php deleted file mode 100644 index d7861868..00000000 --- a/src/Core/Employee/AvatarProviderInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Employee; - -/** - * Interface AvatarProviderInterface describes employee avatar provider. - */ -interface AvatarProviderInterface -{ - /** - * Get default employee avatar URL. - * - * @return string - */ - public function getDefaultAvatarUrl(); -} diff --git a/src/Core/Employee/ContextEmployeeProviderInterface.php b/src/Core/Employee/ContextEmployeeProviderInterface.php deleted file mode 100644 index d82c1864..00000000 --- a/src/Core/Employee/ContextEmployeeProviderInterface.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Employee; - -/** - * Interface ContextEmployeeProviderInterface describes a context employee provider. - */ -interface ContextEmployeeProviderInterface -{ - /** - * Check if context employee is super admin. - * - * @return bool - */ - public function isSuperAdmin(); - - /** - * Get context employee's ID. - * - * @return int - */ - public function getId(); - - /** - * Get context employee's selected language ID. - * - * @return int - */ - public function getLanguageId(); - - /** - * Get context employee's profile ID. - * - * @return int - */ - public function getProfileId(); - - /** - * Get context employee's data as an array - * - * @return array - */ - public function getData(); -} diff --git a/src/Core/Employee/EmployeeDataProviderInterface.php b/src/Core/Employee/EmployeeDataProviderInterface.php deleted file mode 100644 index 6374e3e8..00000000 --- a/src/Core/Employee/EmployeeDataProviderInterface.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Employee; - -/** - * Interface EmployeeDataProviderInterface describes an employee data provider. - */ -interface EmployeeDataProviderInterface -{ - /** - * Get employee's hashed password by employee's ID. - * - * @param int $employeeId - * - * @return string - */ - public function getEmployeeHashedPassword($employeeId); - - /** - * Checks if employee is a super admin. - * - * @param int $employeeId - * - * @return bool - */ - public function isSuperAdmin($employeeId); -} diff --git a/src/Core/Employee/FormLanguageChangerInterface.php b/src/Core/Employee/FormLanguageChangerInterface.php deleted file mode 100644 index 53d85f4b..00000000 --- a/src/Core/Employee/FormLanguageChangerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Employee; - -/** - * Interface FormLanguageSwitcherInterface describes an employee form language changer. - */ -interface FormLanguageChangerInterface -{ - /** - * Change employee form language to given one and save the selection in the cookies. - * - * @param string $languageIsoCode two letter iso code of the language - */ - public function changeLanguageInCookies($languageIsoCode); -} diff --git a/src/Core/Employee/NavigationMenuTogglerInterface.php b/src/Core/Employee/NavigationMenuTogglerInterface.php deleted file mode 100644 index 79eb8da9..00000000 --- a/src/Core/Employee/NavigationMenuTogglerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Employee; - -/** - * Interface NavigationMenuTogglerInterface describes an employee navigation menu toggler. - */ -interface NavigationMenuTogglerInterface -{ - /** - * Toggle the navigation for employee (collapse/expand) - * - * @param bool $shouldCollapse if true - collapse the navigation, expand it otherwise - */ - public function toggleNavigationMenuInCookies($shouldCollapse); -} diff --git a/src/Core/Encoding/CharsetEncoding.php b/src/Core/Encoding/CharsetEncoding.php deleted file mode 100644 index 79c12167..00000000 --- a/src/Core/Encoding/CharsetEncoding.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Encoding; - -/** - * Class CharsetEncoding defines file chartset encoding constants. - */ -final class CharsetEncoding -{ - const UTF_8 = 'utf-8'; - const ISO_8859_1 = 'iso-8859-1'; - - /** - * This class is not meant to be instantiated as it is used to access encoding constants only. - */ - private function __construct() - { - } -} diff --git a/src/Core/EnvironmentInterface.php b/src/Core/EnvironmentInterface.php deleted file mode 100644 index 294e50f0..00000000 --- a/src/Core/EnvironmentInterface.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core; - -/** - * EnvironmentInterface is used to store/access environment information like the current - * environment name or to know if debug mode is enabled. - */ -interface EnvironmentInterface -{ - /** - * Indicates the current environment (dev|prod|test) - * - * @return string - */ - public function getName(); - - /** - * Indicates if debug mode is enabled - * - * @return bool - */ - public function isDebug(); - - /** - * Indicates the path to the cache directory - * - * @return string - */ - public function getCacheDir(); -} diff --git a/src/Core/Exception/ContainerNotFoundException.php b/src/Core/Exception/ContainerNotFoundException.php deleted file mode 100644 index 4ea82e1b..00000000 --- a/src/Core/Exception/ContainerNotFoundException.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Exception; - -class ContainerNotFoundException extends \Exception -{ -} diff --git a/src/Core/Exception/CoreException.php b/src/Core/Exception/CoreException.php deleted file mode 100644 index aa2ea199..00000000 --- a/src/Core/Exception/CoreException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Exception; - -/** - * Base class for PrestaShop core exceptions - */ -class CoreException extends \Exception -{ -} diff --git a/src/Core/Exception/DatabaseException.php b/src/Core/Exception/DatabaseException.php deleted file mode 100644 index 0f4c2d66..00000000 --- a/src/Core/Exception/DatabaseException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Exception; - -/** - * Class DatabaseException any error linked to the database use this class as a base. - */ -class DatabaseException extends CoreException -{ -} diff --git a/src/Core/Exception/FileNotFoundException.php b/src/Core/Exception/FileNotFoundException.php deleted file mode 100644 index af7f5484..00000000 --- a/src/Core/Exception/FileNotFoundException.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Exception; - -class FileNotFoundException extends CoreException -{ -} diff --git a/src/Core/Exception/IOException.php b/src/Core/Exception/IOException.php deleted file mode 100644 index d21f39ae..00000000 --- a/src/Core/Exception/IOException.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Exception; - -use Throwable; - -/** - * Exception class thrown when a filesystem operation failure happens. - */ -class IOException extends CoreException -{ - private $path; - - /** - * @param string $message - * @param int $code - * @param Throwable $previous - * @param string|null $path - */ - public function __construct($message = '', $code = 0, Throwable $previous = null, $path = null) - { - parent::__construct($message, $code, $previous); - $this->path = $path; - } - - /** - * Returns the associated path for the exception. - * - * @return string|null - */ - public function getPath() - { - return $this->path; - } -} diff --git a/src/Core/Exception/InvalidArgumentException.php b/src/Core/Exception/InvalidArgumentException.php deleted file mode 100644 index 140c58f4..00000000 --- a/src/Core/Exception/InvalidArgumentException.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Exception; - -class InvalidArgumentException extends CoreException -{ -} diff --git a/src/Core/Exception/NonASCIIInLocalPartException.php b/src/Core/Exception/NonASCIIInLocalPartException.php deleted file mode 100644 index 2b73db4c..00000000 --- a/src/Core/Exception/NonASCIIInLocalPartException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Exception; - -use Egulias\EmailValidator\Exception\InvalidEmail; - -/** - * Exception thrown when email local part contains non-ascii characters - */ -class NonASCIIInLocalPartException extends InvalidEmail -{ -} diff --git a/src/Core/Exception/ProductException.php b/src/Core/Exception/ProductException.php deleted file mode 100644 index 2022e4fb..00000000 --- a/src/Core/Exception/ProductException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Exception; - -/** - * Class ProductException used when an error linked to a product occurs. - */ -class ProductException extends TranslatableCoreException -{ -} diff --git a/src/Core/Exception/TranslatableCoreException.php b/src/Core/Exception/TranslatableCoreException.php deleted file mode 100644 index 38bee931..00000000 --- a/src/Core/Exception/TranslatableCoreException.php +++ /dev/null @@ -1,141 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Exception; - -/** - * Class TranslatableCoreException. - */ -class TranslatableCoreException extends CoreException -{ - /** - * @var string - */ - private $key; - - /** - * @var string - */ - private $domain; - - /** - * @var array - */ - private $parameters = []; - - /** - * @param string $key - * @param string $domain - * @param array $parameters - * @param int $code - * @param Throwable|Exception|null $previous - */ - public function __construct( - $key, - $domain, - $parameters = [], - $code = 0, - $previous = null - ) { - parent::__construct($key, $code, $previous); - $this->key = $key; - $this->domain = $domain; - $this->parameters = $parameters; - } - - /** - * @return string - */ - public function getKey() - { - return $this->key; - } - - /** - * @param string $key - * - * @return $this - */ - public function setKey($key) - { - $this->key = $key; - $this->message = $key; - - return $this; - } - - /** - * @return string - */ - public function getDomain() - { - return $this->domain; - } - - /** - * @param string $domain - * - * @return $this - */ - public function setDomain($domain) - { - $this->domain = $domain; - - return $this; - } - - /** - * @return array - */ - public function getParameters() - { - return $this->parameters; - } - - /** - * @param array $parameters - * - * @return $this - */ - public function setParameters(array $parameters) - { - $this->parameters = $parameters; - - return $this; - } - - /** - * @return array - */ - public function toArray() - { - return [ - 'key' => $this->key, - 'domain' => $this->domain, - 'parameters' => $this->parameters, - ]; - } -} diff --git a/src/Core/Exception/TranslatedException.php b/src/Core/Exception/TranslatedException.php deleted file mode 100644 index 2d5be77a..00000000 --- a/src/Core/Exception/TranslatedException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Exception; - -/** - * Used for exceptions which messages are already translated and can be displayed straight to end-user - */ -class TranslatedException extends CoreException -{ -} diff --git a/src/Core/Exception/TypeException.php b/src/Core/Exception/TypeException.php deleted file mode 100644 index ef442cb2..00000000 --- a/src/Core/Exception/TypeException.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Exception; - -/** - * Class InvalidArgumentException is thrown when the provided argument of - * a class method is invalid. - */ -class TypeException extends CoreException -{ -} diff --git a/src/Core/Export/Data/ExportableData.php b/src/Core/Export/Data/ExportableData.php deleted file mode 100644 index baa3a598..00000000 --- a/src/Core/Export/Data/ExportableData.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Export\Data; - -/** - * Class ExportableData stores data that should be written to export file. - */ -final class ExportableData implements ExportableDataInterface -{ - /** - * @var string[] - */ - private $titles; - - /** - * @var array - */ - private $rows; - - /** - * @param string[] $titles - * @param array $rows - */ - public function __construct(array $titles, array $rows) - { - $this->titles = $titles; - $this->rows = $rows; - } - - /** - * {@inheritdoc} - */ - public function getTitles() - { - return $this->titles; - } - - /** - * {@inheritdoc} - */ - public function getRows() - { - return $this->rows; - } -} diff --git a/src/Core/Export/Data/ExportableDataInterface.php b/src/Core/Export/Data/ExportableDataInterface.php deleted file mode 100644 index 19e8b706..00000000 --- a/src/Core/Export/Data/ExportableDataInterface.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Export\Data; - -/** - * Interface ExportableDataInterface. - */ -interface ExportableDataInterface -{ - /** - * Titles data. - * - * @return string[] - */ - public function getTitles(); - - /** - * Rows data. - * - * @return array[] - */ - public function getRows(); -} diff --git a/src/Core/Export/Exception/ExportException.php b/src/Core/Export/Exception/ExportException.php deleted file mode 100644 index 9741def3..00000000 --- a/src/Core/Export/Exception/ExportException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Export\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Base class for PrestaShop core file export exceptions - */ -class ExportException extends CoreException -{ -} diff --git a/src/Core/Export/Exception/FileWritingException.php b/src/Core/Export/Exception/FileWritingException.php deleted file mode 100644 index 72a345c2..00000000 --- a/src/Core/Export/Exception/FileWritingException.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Export\Exception; - -/** - * Is thrown when cannot export due to lacking write permissions - */ -class FileWritingException extends ExportException -{ - /** - * When file cannot be opened for writing - */ - const CANNOT_OPEN_FILE_FOR_WRITING = 10; -} diff --git a/src/Core/Export/ExportDirectory.php b/src/Core/Export/ExportDirectory.php deleted file mode 100644 index a1191d0f..00000000 --- a/src/Core/Export/ExportDirectory.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Export; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; - -/** - * ImportDirectory class is responsible for returning export directory & data related to it. - */ -final class ExportDirectory -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * Get path to import directory. - * - * @return string - */ - public function getDir() - { - return ($this->configuration->get('_PS_HOST_MODE_') ? - $this->configuration->get('_PS_ROOT_DIR_') : - $this->configuration->get('_PS_ADMIN_DIR_')) . DIRECTORY_SEPARATOR . 'export' . DIRECTORY_SEPARATOR; - } - - /** - * Use export directory object as a string. - * - * @return string - */ - public function __toString() - { - return $this->getDir(); - } -} diff --git a/src/Core/Export/FileWriter/ExportCsvFileWriter.php b/src/Core/Export/FileWriter/ExportCsvFileWriter.php deleted file mode 100644 index f223d7a2..00000000 --- a/src/Core/Export/FileWriter/ExportCsvFileWriter.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Export\FileWriter; - -use Exception; -use PrestaShop\PrestaShop\Core\Export\Data\ExportableDataInterface; -use PrestaShop\PrestaShop\Core\Export\Exception\FileWritingException; -use PrestaShop\PrestaShop\Core\Export\ExportDirectory; -use SplFileObject; - -/** - * Class ExportCsvFileWriter writes provided data into CSV file and saves it in export directory. - */ -final class ExportCsvFileWriter implements FileWriterInterface -{ - /** - * @var ExportDirectory - */ - private $exportDirectory; - - /** - * @param ExportDirectory $exportDirectory - */ - public function __construct(ExportDirectory $exportDirectory) - { - $this->exportDirectory = $exportDirectory; - } - - /** - * {@inheritdoc} - * - * @throws FileWritingException - */ - public function write($fileName, ExportableDataInterface $data) - { - $filePath = $this->exportDirectory . $fileName; - - try { - $exportFile = new SplFileObject($filePath, 'w'); - } catch (Exception $e) { - throw new FileWritingException(sprintf('Cannot open export file for writing'), FileWritingException::CANNOT_OPEN_FILE_FOR_WRITING); - } - - $exportFile->fputcsv($data->getTitles(), ';'); - - foreach ($data->getRows() as $row) { - $exportFile->fputcsv($row, ';'); - } - - return $exportFile; - } -} diff --git a/src/Core/Export/FileWriter/FileWriterInterface.php b/src/Core/Export/FileWriter/FileWriterInterface.php deleted file mode 100644 index 1d09c473..00000000 --- a/src/Core/Export/FileWriter/FileWriterInterface.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Export\FileWriter; - -use PrestaShop\PrestaShop\Core\Export\Data\ExportableDataInterface; -use SplFileInfo; - -/** - * Interface FileWriterInterface. - */ -interface FileWriterInterface -{ - /** - * Write data to file. - * - * @param string $fileName - * @param ExportableDataInterface $data - * - * @return SplFileInfo - */ - public function write($fileName, ExportableDataInterface $data); -} diff --git a/src/Core/Feature/FeatureInterface.php b/src/Core/Feature/FeatureInterface.php deleted file mode 100644 index 4dbe8cd6..00000000 --- a/src/Core/Feature/FeatureInterface.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Feature; - -/** - * Defines how we should access to a feature. - */ -interface FeatureInterface -{ - /** - * @return bool - */ - public function isUsed(); - - /** - * @return bool - */ - public function isActive(); - - public function enable(); - - public function disable(); - - /** - * @param $status bool - */ - public function update($status); -} diff --git a/src/Core/Feature/TokenInUrls.php b/src/Core/Feature/TokenInUrls.php deleted file mode 100644 index 3ebf9321..00000000 --- a/src/Core/Feature/TokenInUrls.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -namespace PrestaShop\PrestaShop\Core\Feature; - -/** - * Defines if token in urls are disabled. - */ -final class TokenInUrls -{ - const DISABLED = 'disabled'; - const ENV_VAR = '_TOKEN_'; - - /** - * @return bool - */ - public static function isDisabled() - { - return true; - return getenv(self::ENV_VAR) === self::DISABLED; - } -} diff --git a/src/Core/File/Converter/FileConverterInterface.php b/src/Core/File/Converter/FileConverterInterface.php deleted file mode 100644 index 851c7789..00000000 --- a/src/Core/File/Converter/FileConverterInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\File\Converter; - -use SplFileInfo; - -/** - * Interface FileConverterInterface defines a file converter. - */ -interface FileConverterInterface -{ - /** - * Converts a file to a different format. - * - * @param SplFileInfo $sourceFile file to convert - * - * @return SplFileInfo converted file - */ - public function convert(SplFileInfo $sourceFile); -} diff --git a/src/Core/File/FileFinderInterface.php b/src/Core/File/FileFinderInterface.php deleted file mode 100644 index ad92a63b..00000000 --- a/src/Core/File/FileFinderInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\File; - -/** - * Interface FileFinderInterface defines a file finder. - */ -interface FileFinderInterface -{ - /** - * Finds files. - * - * @return array of file paths - */ - public function find(); -} diff --git a/src/Core/File/InvoiceModelFinder.php b/src/Core/File/InvoiceModelFinder.php deleted file mode 100644 index 1cdeba4c..00000000 --- a/src/Core/File/InvoiceModelFinder.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\File; - -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Finder\Finder; - -/** - * Class InvoiceModelFinder finds invoice model files. - */ -final class InvoiceModelFinder implements FileFinderInterface -{ - /** - * @var array - */ - private $invoiceModelDirectories; - - /** - * @param array $invoiceModelDirectories - */ - public function __construct(array $invoiceModelDirectories) - { - $this->invoiceModelDirectories = $invoiceModelDirectories; - } - - /** - * Finds all invoice model files. - * - * @return array - */ - public function find() - { - $directories = $this->invoiceModelDirectories; - $filesystem = new Filesystem(); - - foreach ($directories as $key => $directory) { - if (!$filesystem->exists($directory)) { - unset($directories[$key]); - } - } - - $finder = new Finder(); - $finder->files() - ->in($directories) - ->name('invoice-*.tpl'); - - $fileNames = []; - - foreach ($finder as $file) { - $fileNames[] = $file->getFilename(); - } - - return $fileNames; - } -} diff --git a/src/Core/Filter/CollectionFilter.php b/src/Core/Filter/CollectionFilter.php deleted file mode 100644 index f03eecf8..00000000 --- a/src/Core/Filter/CollectionFilter.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Filter; - -/** - * Iterates over a collection, filtering each element using a queue of filters. - */ -class CollectionFilter implements FilterInterface -{ - /** - * @var FilterInterface[] - */ - private $filters = []; - - /** - * Sets process queue. - * - * @param FilterInterface[] $filters - * - * @return $this - * - * @throws FilterException - */ - public function queue(array $filters) - { - foreach ($filters as $filter) { - if (!$filter instanceof FilterInterface) { - throw new FilterException(sprintf('The provided filter is not valid filter: "%s"', print_r($filter, true))); - } - } - - $this->filters = $filters; - - return $this; - } - - /** - * Returns the current queue. - * - * @return FilterInterface[] - */ - public function getQueue() - { - return $this->filters; - } - - /** - * Filters the provided subject. - * - * @param array $subject Collection to filter - * - * @return array - * - * @throws FilterException - */ - public function filter($subject) - { - if (!is_array($subject)) { - throw new FilterException(sprintf('Invalid subject: %s', print_r($subject, true))); - } - - foreach ($subject as $k => $value) { - foreach ($this->filters as $filter) { - $value = $filter->filter($value); - } - $subject[$k] = $value; - } - - return $subject; - } -} diff --git a/src/Core/Filter/FilterException.php b/src/Core/Filter/FilterException.php deleted file mode 100644 index 593bb90b..00000000 --- a/src/Core/Filter/FilterException.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Filter; - -class FilterException extends \Exception -{ -} diff --git a/src/Core/Filter/FilterInterface.php b/src/Core/Filter/FilterInterface.php deleted file mode 100644 index 3cd913d2..00000000 --- a/src/Core/Filter/FilterInterface.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Filter; - -interface FilterInterface -{ - /** - * Performs a filter on the subject object. - * - * @param mixed $subject subject to filter - * - * @return mixed filtered subject - */ - public function filter($subject); -} diff --git a/src/Core/Filter/FrontEndObject/CartFilter.php b/src/Core/Filter/FrontEndObject/CartFilter.php deleted file mode 100644 index 9c347f3c..00000000 --- a/src/Core/Filter/FrontEndObject/CartFilter.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Filter\FrontEndObject; - -use PrestaShop\PrestaShop\Core\Filter\HashMapWhitelistFilter; - -/** - * Filters Cart objects that will be sent to the client. - */ -class CartFilter extends HashMapWhitelistFilter -{ - public function __construct($productsFilter) - { - $whitelist = [ - 'discounts', - 'minimalPurchase', - 'minimalPurchaseRequired', - 'products' => $productsFilter, - 'products_count', - 'subtotals', - 'summary_string', - 'totals', - 'vouchers', - ]; - - $this->whitelist($whitelist); - } -} diff --git a/src/Core/Filter/FrontEndObject/ConfigurationFilter.php b/src/Core/Filter/FrontEndObject/ConfigurationFilter.php deleted file mode 100644 index 0f8f904c..00000000 --- a/src/Core/Filter/FrontEndObject/ConfigurationFilter.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Filter\FrontEndObject; - -use PrestaShop\PrestaShop\Core\Filter\HashMapWhitelistFilter; - -/** - * Filters Configuration objects that will be sent to the client. - */ -class ConfigurationFilter extends HashMapWhitelistFilter -{ - public function __construct() - { - $whitelist = [ - 'display_taxes_label', - 'display_prices_tax_incl', - 'is_catalog', - 'opt_in', - 'quantity_discount', - 'return_enabled', - 'show_prices', - 'voucher_enabled', - ]; - - $this->whitelist($whitelist); - } -} diff --git a/src/Core/Filter/FrontEndObject/CustomerFilter.php b/src/Core/Filter/FrontEndObject/CustomerFilter.php deleted file mode 100644 index 1bcf4b1b..00000000 --- a/src/Core/Filter/FrontEndObject/CustomerFilter.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Filter\FrontEndObject; - -use PrestaShop\PrestaShop\Core\Filter\HashMapWhitelistFilter; - -/** - * Filters Customer objects that will be sent to the client. - */ -class CustomerFilter extends HashMapWhitelistFilter -{ - public function __construct() - { - $whitelist = [ - 'addresses', - 'ape', - 'birthday', - 'company', - 'email', - 'firstname', - 'gender' => (new HashMapWhitelistFilter()) - ->whitelist([ - 'type', - 'name', - ]), - 'is_logged', - 'lastname', - 'newsletter', - 'newsletter_date_add', - 'optin', - 'siret', - 'website', - ]; - - $this->whitelist($whitelist); - } -} diff --git a/src/Core/Filter/FrontEndObject/EmbeddedAttributesFilter.php b/src/Core/Filter/FrontEndObject/EmbeddedAttributesFilter.php deleted file mode 100644 index 55ced30c..00000000 --- a/src/Core/Filter/FrontEndObject/EmbeddedAttributesFilter.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Filter\FrontEndObject; - -use PrestaShop\PrestaShop\Core\Filter\HashMapWhitelistFilter; - -/** - * Filters Product EmbeddedAttributes objects that will be sent to the client. - */ -class EmbeddedAttributesFilter extends HashMapWhitelistFilter -{ - public function __construct() - { - $whitelist = [ - 'attributes', - 'available_later', - 'available_now', - 'category', - 'condition', - 'customizable', - 'description_short', - 'ecotax', - 'ecotax_rate', - 'features', - 'id_customization', - 'id_image', - 'id_manufacturer', - 'id_product', - 'id_product_attribute', - 'link_rewrite', - 'minimal_quantity', - 'name', - 'new', - 'on_sale', - 'online_only', - 'pack', - 'price', - 'price_amount', - 'price_without_reduction', - 'quantity', - 'quantity_wanted', - 'rate', - 'reduction', - 'reference', - 'specific_prices', - 'tax_name', - ]; - - $this->whitelist($whitelist); - } -} diff --git a/src/Core/Filter/FrontEndObject/MainFilter.php b/src/Core/Filter/FrontEndObject/MainFilter.php deleted file mode 100644 index a3b91c93..00000000 --- a/src/Core/Filter/FrontEndObject/MainFilter.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Filter\FrontEndObject; - -use PrestaShop\PrestaShop\Core\Filter\CollectionFilter; -use PrestaShop\PrestaShop\Core\Filter\FilterInterface; - -/** - * Filters the main front end object ("prestashop" on your javascript console). - */ -class MainFilter implements FilterInterface -{ - /** - * @var FilterInterface[] filters, indexed by key to filter - */ - private $filters; - - /** - * @param array $filters FilterInterface[] filters, indexed by key to filter - */ - public function __construct(array $filters) - { - $this->filters = $filters; - } - - /** - * {@inheritdoc} - * - * @return array - */ - public function filter($subject) - { - foreach ($this->filters as $key => $filter) { - if (isset($subject[$key]) && $filter instanceof FilterInterface) { - if ($filter instanceof CollectionFilter && !is_array($subject[$key])) { - continue; - } - - $subject[$key] = $filter->filter($subject[$key]); - } - } - - return $subject; - } - - /** - * @return FilterInterface[] filters, indexed by key to filter - */ - public function getFilters() - { - return $this->filters; - } -} diff --git a/src/Core/Filter/FrontEndObject/ProductFilter.php b/src/Core/Filter/FrontEndObject/ProductFilter.php deleted file mode 100644 index 1b4ff64c..00000000 --- a/src/Core/Filter/FrontEndObject/ProductFilter.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Filter\FrontEndObject; - -use PrestaShop\PrestaShop\Core\Filter\HashMapWhitelistFilter; - -/** - * Filters Product objects that will be sent to the client. - */ -class ProductFilter extends HashMapWhitelistFilter -{ - public function __construct() - { - $whitelist = [ - 'add_to_cart_url', - 'allow_oosp', - 'attributes', - 'attributes_small', - 'availability', - 'availability_date', - 'availability_message', - 'available_later', - 'available_now', - 'canonical_url', - 'cart_quantity', - 'category', - 'condition', - 'cover', - 'customizable', - 'customizations', - 'description_short', - 'discount_amount', - 'discount_percentage', - 'discount_percentage_absolute', - 'discount_to_display', - 'discount_type', - 'down_quantity_url', - 'ean13', - 'ecotax', - 'ecotax_attr', - 'ecotax_rate', - 'embedded_attributes' => new EmbeddedAttributesFilter(), - 'flags', - 'has_discount', - 'id', - 'id_customization', - 'id_image', - 'id_manufacturer', - 'id_product', - 'id_product_attribute', - 'images', - 'isbn', - 'labels', - 'legend', - 'link_rewrite', - 'main_variants', - 'manufacturer_name', - 'minimal_quantity', - 'name', - 'new', - 'on_sale', - 'online_only', - 'pack', - 'price', - 'price_amount', - 'price_attribute', - 'price_with_reduction', - 'price_with_reduction_without_tax', - 'price_without_reduction', - 'price_wt', - 'quantity', - 'quantity_discounts', - 'quantity_wanted', - 'rate', - 'reduction', - 'reference', - 'reference_to_display', - 'regular_price', - 'regular_price_amount', - 'remove_from_cart_url', - 'show_availability', - 'show_price', - 'specific_prices', - 'stock_quantity', - 'tax_name', - 'total', - 'total_wt', - 'unit_price', - 'unit_price_full', - 'up_quantity_url', - 'upc', - 'update_quantity_url', - 'url', - 'weight_unit', - 'seo_availability', - ]; - - $this->whitelist($whitelist); - } -} diff --git a/src/Core/Filter/FrontEndObject/SearchResultProductFilter.php b/src/Core/Filter/FrontEndObject/SearchResultProductFilter.php deleted file mode 100644 index 50ce70cf..00000000 --- a/src/Core/Filter/FrontEndObject/SearchResultProductFilter.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Filter\FrontEndObject; - -use PrestaShop\PrestaShop\Core\Filter\HashMapWhitelistFilter; - -/** - * Filters Product objects for search results. - */ -class SearchResultProductFilter extends HashMapWhitelistFilter -{ - public function __construct() - { - $whitelist = [ - 'active', - 'add_to_cart_url', - 'canonical_url', - 'category_name', - 'cover', - 'description_short', - 'discount_amount', - 'discount_percentage', - 'discount_percentage_absolute', - 'discount_to_display', - 'discount_type', - 'has_discount', - 'id_product', - 'labels', - 'link', - 'link_rewrite', - 'main_variants', - 'manufacturer_name', - 'name', - 'position', - 'price', - 'price_amount', - 'rate', - 'reference', - 'regular_price', - 'regular_price_amount', - 'tax_name', - 'unit_price', - 'url', - ]; - - $this->whitelist($whitelist); - } -} diff --git a/src/Core/Filter/FrontEndObject/ShopFilter.php b/src/Core/Filter/FrontEndObject/ShopFilter.php deleted file mode 100644 index 4f7942a1..00000000 --- a/src/Core/Filter/FrontEndObject/ShopFilter.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Filter\FrontEndObject; - -use PrestaShop\PrestaShop\Core\Filter\HashMapWhitelistFilter; - -class ShopFilter extends HashMapWhitelistFilter -{ - public function __construct() - { - $whitelist = [ - 'favicon', - 'logo', - 'name', - 'stores_icon', - ]; - - $this->whitelist($whitelist); - } -} diff --git a/src/Core/Filter/HashMapWhitelistFilter.php b/src/Core/Filter/HashMapWhitelistFilter.php deleted file mode 100644 index 5976951a..00000000 --- a/src/Core/Filter/HashMapWhitelistFilter.php +++ /dev/null @@ -1,210 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Filter; - -use PrestaShop\PrestaShop\Adapter\Presenter\AbstractLazyArray; - -/** - * This class filters associative arrays. - * - * Usage: - * - * ```php - * $map = [ - * 'foo' => 'something', - * 'bar' => null, - * 'baz' => array(), - * ]; - * - * $filter = (new HashMapFilter()) - * ->whitelist( - * ['foo', 'baz'] - * ); - * - * $filtered = $filter->filter(); - * // returns [ 'foo' => something, 'baz' => [] ]; - * ``` - * - * You can also nest filters: - * - * ```php - * $map = [ - * 'foo' => 'something', - * 'bar' => null, - * 'baz' => [true, false, 1, 0] - * ]; - * - * $filter = (new HashMapFilter()) - * ->whitelist([ - * 'foo', - * 'baz' => OnlyTruthyValuesInCollectionFilter() - * ]); - * - * $filtered = $filter->filter(); - * // returns [ 'foo' => something, 'baz' => [ true, 1 ] ]; - * ``` - */ -class HashMapWhitelistFilter implements FilterInterface -{ - /** - * Index of $keyToKeep => true. - * - * @var true[] - */ - protected $whitelistItems = []; - - /** - * Nested filters, indexed by $keyToKeep. - * - * @var FilterInterface[] - */ - protected $filters = []; - - /** - * Adds keys to the whitelist. - * - * This method accepts either: - * - string[] an array of keys to keep - * - FilterInterface[] an array of filters, indexed by keys to keep - * - A mixture of the two - * - * @param string[]|FilterInterface[] $definition - * - * @return $this - */ - public function whitelist($definition) - { - foreach ($definition as $k => $value) { - $this->addWhitelistItem($k, $value); - } - - return $this; - } - - /** - * Removes the provided key from the whitelist. - * - * @param string|int $key - * - * @return $this - * - * @throws FilterException if $key is not scalar - */ - public function removeFromWhitelist($key) - { - if (!is_scalar($key)) { - throw new FilterException(sprintf('Invalid parameter %s', print_r($key, true))); - } - - unset( - $this->whitelistItems[$key], - $this->filters[$key] - ); - - return $this; - } - - /** - * Returns the white list. - * - * @return true[] - */ - public function getWhitelistItems() - { - return $this->whitelistItems; - } - - /** - * Returns the nested filters, indexed by $keyToKeep. - * - * @return FilterInterface[] - */ - public function getFilters() - { - return $this->filters; - } - - /** - * Filters the subject. - * - * @param array $subject - * - * @return array The filtered subject - * - * @throws \RuntimeException - */ - public function filter($subject) - { - // keep whitelisted items - if ($subject instanceof AbstractLazyArray) { - // avoid modifying the original object - $subject = clone $subject; - $subject->intersectKey($this->whitelistItems); - // run nested filters - foreach ($this->filters as $key => $filter) { - if ($subject->offsetExists($key)) { - $filteredValue = $filter->filter($subject->offsetGet($key)); - $subject->offsetSet($key, $filteredValue, true); - } - } - } else { - $subject = array_intersect_key($subject, $this->whitelistItems); - // run nested filters - foreach ($this->filters as $key => $filter) { - if (array_key_exists($key, $subject)) { - $subject[$key] = $filter->filter($subject[$key]); - } - } - } - - return $subject; - } - - /** - * Adds an element to the whitelist. - * - * @param int|string $paramKey - * @param string|FilterInterface $paramValue - * - * @return $this - */ - private function addWhitelistItem($paramKey, $paramValue) - { - $keyToWhitelist = $paramValue; - if ($paramValue instanceof FilterInterface) { - $this->filters[$paramKey] = $paramValue; - - $keyToWhitelist = $paramKey; - } - - // add as key to allow faster search - $this->whitelistItems[$keyToWhitelist] = true; - - return $this; - } -} diff --git a/src/Core/Form/ChoiceProvider/AddressRequiredFieldsChoiceProvider.php b/src/Core/Form/ChoiceProvider/AddressRequiredFieldsChoiceProvider.php deleted file mode 100644 index 279cd270..00000000 --- a/src/Core/Form/ChoiceProvider/AddressRequiredFieldsChoiceProvider.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\RequiredFields; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Provides choices for configuring required fields for address - */ -final class AddressRequiredFieldsChoiceProvider implements FormChoiceProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getChoices() - { - return array_combine(RequiredFields::ALLOWED_REQUIRED_FIELDS, RequiredFields::ALLOWED_REQUIRED_FIELDS); - } -} diff --git a/src/Core/Form/ChoiceProvider/CanonicalRedirectTypeChoiceProvider.php b/src/Core/Form/ChoiceProvider/CanonicalRedirectTypeChoiceProvider.php deleted file mode 100644 index 46c3e717..00000000 --- a/src/Core/Form/ChoiceProvider/CanonicalRedirectTypeChoiceProvider.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class CanonicalRedirectTypeChoiceProvider is responsible for providing choices for - * redirect to the canonical URL form field selection. - */ -final class CanonicalRedirectTypeChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * CanonicalRedirectTypeChoiceProvider constructor. - * - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $noRedirectionMessage = $this->translator->trans( - 'No redirection (you may have duplicate content issues)', - [], - 'Admin.Shopparameters.Feature' - ); - - $movedTemporaryMessage = $this->translator->trans( - '302 Moved Temporarily (recommended while setting up your store)', - [], - 'Admin.Shopparameters.Feature' - ); - - $movedPermanentlyMessage = $this->translator->trans( - '301 Moved Permanently (recommended once you have gone live)', - [], - 'Admin.Shopparameters.Feature' - ); - - return [ - $noRedirectionMessage => 0, - $movedTemporaryMessage => 1, - $movedPermanentlyMessage => 2, - ]; - } -} diff --git a/src/Core/Form/ChoiceProvider/CarrierByReferenceChoiceProvider.php b/src/Core/Form/ChoiceProvider/CarrierByReferenceChoiceProvider.php deleted file mode 100644 index e1d8268d..00000000 --- a/src/Core/Form/ChoiceProvider/CarrierByReferenceChoiceProvider.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Adapter\Carrier\CarrierDataProvider; -use PrestaShop\PrestaShop\Adapter\Entity\Carrier; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class CarrierByReferenceChoiceProvider is responsible for providing carrier choices with value reference. - */ -final class CarrierByReferenceChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var CarrierDataProvider - */ - private $carrierDataProvider; - - /** - * @var int - */ - private $langId; - - /** - * @param CarrierDataProvider $carrierDataProvider - * @param int $langId - */ - public function __construct(CarrierDataProvider $carrierDataProvider, $langId) - { - $this->carrierDataProvider = $carrierDataProvider; - $this->langId = $langId; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $choices = []; - - $carriers = $this->carrierDataProvider->getCarriers( - $this->langId, - false, - false, - false, - null, - Carrier::ALL_CARRIERS - ); - - foreach ($carriers as $carrier) { - $choiceId = $carrier['id_carrier'] . ' - ' . $carrier['name']; - if ($carrier['name']) { - $choiceId .= ' (' . $carrier['delay'] . ')'; - } - - $choices[$choiceId] = $carrier['id_reference']; - } - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/CategoryDeleteModeChoiceProvider.php b/src/Core/Form/ChoiceProvider/CategoryDeleteModeChoiceProvider.php deleted file mode 100644 index baea122a..00000000 --- a/src/Core/Form/ChoiceProvider/CategoryDeleteModeChoiceProvider.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryDeleteMode; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class CategoryDeleteModeChoiceProvider. - */ -final class CategoryDeleteModeChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $associateOnlyLabel = $this->translator->trans( - 'If they have no other category, I want to associate them with the parent category.', - [], - 'Admin.Catalog.Notification' - ); - - $associateAndDisableLabel = sprintf( - '%s %s', - $this->translator->trans( - 'If they have no other category, I want to associate them with the parent category and turn them offline.', - [], - 'Admin.Catalog.Notification' - ), - $this->translator->trans('(Recommended)', [], 'Admin.Catalog.Notification') - ); - - $deleteProductLabel = $this->translator->trans( - 'If they have no other category, I want to delete them as well.', - [], - 'Admin.Catalog.Notification' - ); - - return [ - $associateAndDisableLabel => CategoryDeleteMode::ASSOCIATE_PRODUCTS_WITH_PARENT_AND_DISABLE, - $associateOnlyLabel => CategoryDeleteMode::ASSOCIATE_PRODUCTS_WITH_PARENT_ONLY, - $deleteProductLabel => CategoryDeleteMode::REMOVE_ASSOCIATED_PRODUCTS, - ]; - } -} diff --git a/src/Core/Form/ChoiceProvider/CmsCategoriesChoiceProvider.php b/src/Core/Form/ChoiceProvider/CmsCategoriesChoiceProvider.php deleted file mode 100644 index 62e04ed4..00000000 --- a/src/Core/Form/ChoiceProvider/CmsCategoriesChoiceProvider.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -final class CmsCategoriesChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var array - */ - private $nestedCategories; - - /** - * @param array $nestedCategories - */ - public function __construct(array $nestedCategories) - { - $this->nestedCategories = $nestedCategories; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $choices[] = $this->buildChoiceTree($this->nestedCategories); - - return $choices; - } - - /** - * @param array $category - * - * @return array - */ - private function buildChoiceTree(array $category) - { - $tree = [ - 'id_cms_category' => $category['id_cms_category'], - 'name' => $category['name'], - ]; - - if (isset($category['children'])) { - foreach ($category['children'] as $childCategory) { - $tree['children'][] = $this->buildChoiceTree($childCategory); - } - } - - return $tree; - } -} diff --git a/src/Core/Form/ChoiceProvider/ContactByIdChoiceProvider.php b/src/Core/Form/ChoiceProvider/ContactByIdChoiceProvider.php deleted file mode 100644 index b27a4a01..00000000 --- a/src/Core/Form/ChoiceProvider/ContactByIdChoiceProvider.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShop\PrestaShop\Core\Support\ContactRepositoryInterface; - -/** - * Class ContactByIdChoiceProvider is responsible for providing shop contact choices. - */ -final class ContactByIdChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var ContactRepositoryInterface - */ - private $contactRepository; - - /** - * @var int - */ - private $langId; - - /** - * @param ContactRepositoryInterface $contactRepository - * @param int $langId - */ - public function __construct( - ContactRepositoryInterface $contactRepository, - $langId - ) { - $this->contactRepository = $contactRepository; - $this->langId = $langId; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $choices = []; - $contacts = $this->contactRepository->findAllByLangId($this->langId); - - foreach ($contacts as $contact) { - $choices[$contact['name']] = $contact['id_contact']; - } - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/CountryByIdChoiceProvider.php b/src/Core/Form/ChoiceProvider/CountryByIdChoiceProvider.php deleted file mode 100644 index 9f2e4cda..00000000 --- a/src/Core/Form/ChoiceProvider/CountryByIdChoiceProvider.php +++ /dev/null @@ -1,146 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Adapter\Country\CountryDataProvider; -use PrestaShop\PrestaShop\Core\Form\FormChoiceAttributeProviderInterface; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class CountryByIdChoiceProvider provides country choices with ID values. - */ -final class CountryByIdChoiceProvider implements FormChoiceProviderInterface, FormChoiceAttributeProviderInterface -{ - /** - * @var CountryDataProvider - */ - private $countryDataProvider; - - /** - * @var int - */ - private $langId; - - /** - * @var array - */ - private $countries; - - /** - * @var int[] - */ - private $dniCountriesId; - - /** - * @var int[] - */ - private $postcodeCountriesId; - - /** - * @param int $langId - * @param CountryDataProvider $countryDataProvider - */ - public function __construct( - $langId, - CountryDataProvider $countryDataProvider - ) { - $this->langId = $langId; - $this->countryDataProvider = $countryDataProvider; - } - - /** - * Get currency choices. - * - * @return array - */ - public function getChoices() - { - $countries = $this->getCountries(); - $choices = []; - - foreach ($countries as $country) { - $choices[$country['name']] = $country['id_country']; - } - - return $choices; - } - - /** - * @return array - */ - public function getChoicesAttributes() - { - $countries = $this->getCountries(); - $dniCountriesId = $this->getDniCountriesId(); - $postcodeCountriesId = $this->getPostcodeCountriesId(); - $choicesAttributes = []; - - foreach ($countries as $country) { - if (in_array($country['id_country'], $dniCountriesId)) { - $choicesAttributes[$country['name']]['need_dni'] = 1; - } - if (in_array($country['id_country'], $postcodeCountriesId)) { - $choicesAttributes[$country['name']]['need_postcode'] = 1; - } - } - - return $choicesAttributes; - } - - /** - * @return array - */ - private function getCountries() - { - if (null === $this->countries) { - $this->countries = $this->countryDataProvider->getCountries($this->langId); - } - - return $this->countries; - } - - /** - * @return int[] - */ - private function getDniCountriesId() - { - if (null === $this->dniCountriesId) { - $this->dniCountriesId = $this->countryDataProvider->getCountriesIdWhichNeedDni(); - } - - return $this->dniCountriesId; - } - - private function getPostcodeCountriesId() - { - if (null === $this->postcodeCountriesId) { - $this->postcodeCountriesId = $this->countryDataProvider->getCountriesIdWhichNeedPostcode(); - } - - return $this->postcodeCountriesId; - } -} diff --git a/src/Core/Form/ChoiceProvider/CountryByIsoCodeChoiceProvider.php b/src/Core/Form/ChoiceProvider/CountryByIsoCodeChoiceProvider.php deleted file mode 100644 index 4e9b204e..00000000 --- a/src/Core/Form/ChoiceProvider/CountryByIsoCodeChoiceProvider.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Adapter\Country\CountryDataProvider; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class CountryChoiceProvider is responsible for providing both enabled/disabled country choices with ISO code values. - */ -final class CountryByIsoCodeChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var CountryDataProvider - */ - private $countryDataProvider; - - /** - * @var int - */ - private $langId; - - /** - * @param int $langId - * @param CountryDataProvider $countryDataProvider - */ - public function __construct( - $langId, - CountryDataProvider $countryDataProvider - ) { - $this->countryDataProvider = $countryDataProvider; - $this->langId = $langId; - } - - /** - * Get country choices. - * - * @return array - */ - public function getChoices() - { - $choices = []; - $countries = $this->countryDataProvider->getCountries($this->langId); - - foreach ($countries as $country) { - $choices[$country['name']] = $country['iso_code']; - } - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/CurrencyByIdChoiceProvider.php b/src/Core/Form/ChoiceProvider/CurrencyByIdChoiceProvider.php deleted file mode 100644 index d54fafdd..00000000 --- a/src/Core/Form/ChoiceProvider/CurrencyByIdChoiceProvider.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Adapter\Currency\CurrencyDataProvider; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class CurrencyByIdChoiceProvider provides currency choices with ID values. - */ -final class CurrencyByIdChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var CurrencyDataProvider - */ - private $currencyDataProvider; - - /** - * @param CurrencyDataProvider $currencyDataProvider - */ - public function __construct(CurrencyDataProvider $currencyDataProvider) - { - $this->currencyDataProvider = $currencyDataProvider; - } - - /** - * Get currency choices. - * - * @return array - */ - public function getChoices() - { - $currencies = $this->currencyDataProvider->getCurrencies(false, true, true); - $choices = []; - - foreach ($currencies as $currency) { - $choices[sprintf('%s (%s)', $currency['name'], $currency['iso_code'])] = $currency['id_currency']; - } - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/CurrencyNameByIsoCodeChoiceProvider.php b/src/Core/Form/ChoiceProvider/CurrencyNameByIsoCodeChoiceProvider.php deleted file mode 100644 index a25651a6..00000000 --- a/src/Core/Form/ChoiceProvider/CurrencyNameByIsoCodeChoiceProvider.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShop\PrestaShop\Core\Localization\CLDR\CurrencyData; - -/** - * Class CurrencyNameByIsoCodeChoiceProvider is responsible for retrieving currency names from cldr library. - */ -final class CurrencyNameByIsoCodeChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var CurrencyData[] - */ - private $cldrAllCurrencies; - - /** - * @param CurrencyData[] $cldrAllCurrencies - */ - public function __construct(array $cldrAllCurrencies) - { - $this->cldrAllCurrencies = $cldrAllCurrencies; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $result = []; - foreach ($this->cldrAllCurrencies as $cldrCurrency) { - // filter only on active currency - // we dont need here currencies which were deactivated in all territories - if (!$cldrCurrency->isActive()) { - continue; - } - $currencyNames = $cldrCurrency->getDisplayNames(); - $isoCode = $cldrCurrency->getIsoCode(); - $displayName = sprintf('%s (%s)', $currencyNames['default'], $isoCode); - - $result[$displayName] = $isoCode; - } - ksort($result); - - return $result; - } -} diff --git a/src/Core/Form/ChoiceProvider/CustomerAddressesChoiceProvider.php b/src/Core/Form/ChoiceProvider/CustomerAddressesChoiceProvider.php deleted file mode 100644 index a0ff724f..00000000 --- a/src/Core/Form/ChoiceProvider/CustomerAddressesChoiceProvider.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Adapter\Customer\CustomerDataProvider; -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; - -/** - * Provides choices for configuring required fields for customer - */ -final class CustomerAddressesChoiceProvider implements ConfigurableFormChoiceProviderInterface -{ - /** - * @var CustomerDataProvider - */ - private $customerDataProvider; - - /** - * @var int - */ - private $langId; - - /** - * @param CustomerDataProvider $customerDataProvider - * @param int $langId - */ - public function __construct(CustomerDataProvider $customerDataProvider, int $langId) - { - $this->customerDataProvider = $customerDataProvider; - $this->langId = $langId; - } - - /** - * {@inheritdoc} - */ - public function getChoices(array $options) - { - if (!isset($options['customer_id'])) { - throw new \InvalidArgumentException('Expected a customer_id option, none found'); - } - - $addresses = $this->customerDataProvider->getCustomerAddresses($options['customer_id'], $this->langId); - - $result = []; - foreach ($addresses as $address) { - $description = sprintf( - '%d- %s %s %s %s', - $address['id_address'], - $address['address1'], - $address['address2'] ?: '', - $address['postcode'], - $address['city'] - ); - - $result[$description] = $address['id_address']; - } - - return $result; - } -} diff --git a/src/Core/Form/ChoiceProvider/CustomerDeleteMethodChoiceProvider.php b/src/Core/Form/ChoiceProvider/CustomerDeleteMethodChoiceProvider.php deleted file mode 100644 index 81b046c2..00000000 --- a/src/Core/Form/ChoiceProvider/CustomerDeleteMethodChoiceProvider.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerDeleteMethod; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Provides choices in which customer can be deleted. - */ -final class CustomerDeleteMethodChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $allowRegistrationLabel = $this->translator->trans( - 'I want my customers to be able to register again with the same email address. All data will be removed from the database.', - [], - 'Admin.Orderscustomers.Notification' - ); - - $denyRegistraionLabel = $this->translator->trans( - 'I do not want my customer(s) to register again with the same email address. All selected customer(s) will be removed from this list but their corresponding data will be kept in the database.', - [], - 'Admin.Orderscustomers.Notification' - ); - - return [ - $allowRegistrationLabel => CustomerDeleteMethod::ALLOW_CUSTOMER_REGISTRATION, - $denyRegistraionLabel => CustomerDeleteMethod::DENY_CUSTOMER_REGISTRATION, - ]; - } -} diff --git a/src/Core/Form/ChoiceProvider/CustomerRequiredFieldsChoiceProvider.php b/src/Core/Form/ChoiceProvider/CustomerRequiredFieldsChoiceProvider.php deleted file mode 100644 index 3e1e7cca..00000000 --- a/src/Core/Form/ChoiceProvider/CustomerRequiredFieldsChoiceProvider.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\RequiredField; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Provides choices for configuring required fields for customer - */ -final class CustomerRequiredFieldsChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - return [ - $this->translator->trans('Partner offers', [], 'Admin.Orderscustomers.Feature') => RequiredField::PARTNER_OFFERS, - ]; - } -} diff --git a/src/Core/Form/ChoiceProvider/CustomerServiceOrderMessagesChoiceProvider.php b/src/Core/Form/ChoiceProvider/CustomerServiceOrderMessagesChoiceProvider.php deleted file mode 100644 index 77bf2038..00000000 --- a/src/Core/Form/ChoiceProvider/CustomerServiceOrderMessagesChoiceProvider.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Selects order messages itself. - */ -final class CustomerServiceOrderMessagesChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var array - */ - private $orderMessages; - - public function __construct(array $orderMessages) - { - $this->orderMessages = $orderMessages; - } - - /** - * {@inheritdoc} - */ - public function getChoices(): array - { - $result = []; - - foreach ($this->orderMessages as $orderMessage) { - $result[$orderMessage['id_order_message']] = $orderMessage['message']; - } - - return $result; - } -} diff --git a/src/Core/Form/ChoiceProvider/CustomerServiceOrderMessagesNameChoiceProvider.php b/src/Core/Form/ChoiceProvider/CustomerServiceOrderMessagesNameChoiceProvider.php deleted file mode 100644 index c1609089..00000000 --- a/src/Core/Form/ChoiceProvider/CustomerServiceOrderMessagesNameChoiceProvider.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Gets choices for predefined order message types. - */ -final class CustomerServiceOrderMessagesNameChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var array - */ - private $orderMessages; - - public function __construct(array $orderMessages) - { - $this->orderMessages = $orderMessages; - } - - /** - * {@inheritdoc} - */ - public function getChoices(): array - { - $result = []; - - foreach ($this->orderMessages as $orderMessage) { - $result[$orderMessage['name']] = $orderMessage['id_order_message']; - } - - return $result; - } -} diff --git a/src/Core/Form/ChoiceProvider/DefaultMetaPageNameChoiceProvider.php b/src/Core/Form/ChoiceProvider/DefaultMetaPageNameChoiceProvider.php deleted file mode 100644 index 90942570..00000000 --- a/src/Core/Form/ChoiceProvider/DefaultMetaPageNameChoiceProvider.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShop\PrestaShop\Core\Meta\MetaDataProviderInterface; -use Symfony\Component\HttpFoundation\RequestStack; - -/** - * Class DefaultMetaPageNameChoiceProvider is responsible for providing default page choices in - * Shop parameters -> Traffic & Seo -> Seo & Urls -> form. - */ -final class DefaultMetaPageNameChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var RequestStack - */ - private $requestStack; - - /** - * @var MetaDataProviderInterface - */ - private $dataProvider; - - /** - * DefaultPageChoiceProvider constructor. - * - * @param RequestStack $requestStack - * @param MetaDataProviderInterface $dataProvider - * - * @todo: get rid of request stack by creating new interface. - */ - public function __construct( - RequestStack $requestStack, - MetaDataProviderInterface $dataProvider - ) { - $this->requestStack = $requestStack; - $this->dataProvider = $dataProvider; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $defaultPages = $this->dataProvider->getDefaultMetaPageNamesExcludingFilled(); - $currentPage = $this->getCurrentPage(); - - if (null !== $currentPage) { - $defaultPages[$currentPage] = $currentPage; - asort($defaultPages); - } - - return $defaultPages; - } - - /** - * Gets current page. - * - * @return string|null - */ - private function getCurrentPage() - { - $currentRequest = $this->requestStack->getCurrentRequest(); - - $metaId = null; - if (null !== $currentRequest) { - $metaId = $currentRequest->attributes->get('metaId'); - } - - if ($metaId) { - return $this->dataProvider->getDefaultMetaPageNameById($metaId); - } - - return null; - } -} diff --git a/src/Core/Form/ChoiceProvider/EmailContentTypeChoiceProvider.php b/src/Core/Form/ChoiceProvider/EmailContentTypeChoiceProvider.php deleted file mode 100644 index 22b2d766..00000000 --- a/src/Core/Form/ChoiceProvider/EmailContentTypeChoiceProvider.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class EmailContentTypeChoiceProvider provides email content type choices. - */ -final class EmailContentTypeChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * Get email content type choices. - * - * @return array - */ - public function getChoices() - { - return [ - $this->translator->trans('Subject', [], 'Admin.Global') => 'subject', - $this->translator->trans('Body', [], 'Admin.International.Feature') => 'body', - ]; - } -} diff --git a/src/Core/Form/ChoiceProvider/GroupByIdChoiceProvider.php b/src/Core/Form/ChoiceProvider/GroupByIdChoiceProvider.php deleted file mode 100644 index 701ba395..00000000 --- a/src/Core/Form/ChoiceProvider/GroupByIdChoiceProvider.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Adapter\Group\GroupDataProvider; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class GroupByIdChoiceProvider is responsible for providing customer group choices with Id values. - */ -final class GroupByIdChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var GroupDataProvider - */ - private $groupDataProvider; - - /** - * @var int - */ - private $langId; - - /** - * @param GroupDataProvider $groupDataProvider - * @param int $langId - */ - public function __construct( - GroupDataProvider $groupDataProvider, - $langId - ) { - $this->groupDataProvider = $groupDataProvider; - $this->langId = $langId; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $choices = []; - $groups = $this->groupDataProvider->getGroups($this->langId); - - foreach ($groups as $group) { - $choices[$group['name']] = $group['id_group']; - } - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/ImportEntityFieldChoiceProvider.php b/src/Core/Form/ChoiceProvider/ImportEntityFieldChoiceProvider.php deleted file mode 100644 index 026022cd..00000000 --- a/src/Core/Form/ChoiceProvider/ImportEntityFieldChoiceProvider.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShop\PrestaShop\Core\Import\EntityField\Provider\EntityFieldsProviderFinderInterface; -use PrestaShop\PrestaShop\Core\Import\Exception\NotSupportedImportEntityException; - -/** - * Class ImportEntityFieldChoiceProvider is responsible for providing entity import field choices. - */ -final class ImportEntityFieldChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var EntityFieldsProviderFinderInterface - */ - private $entityFieldsProviderFinder; - - /** - * @var int selected import entity - */ - private $selectedEntity; - - /** - * @param EntityFieldsProviderFinderInterface $entityFieldsProviderFinder - * @param int $selectedEntity - */ - public function __construct( - EntityFieldsProviderFinderInterface $entityFieldsProviderFinder, - $selectedEntity - ) { - $this->entityFieldsProviderFinder = $entityFieldsProviderFinder; - $this->selectedEntity = $selectedEntity; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - try { - $entityFieldCollection = $this->entityFieldsProviderFinder->find($this->selectedEntity)->getCollection(); - } catch (NotSupportedImportEntityException $e) { - return []; - } - - $choices = []; - - foreach ($entityFieldCollection as $entityField) { - $label = $entityField->getLabel(); - - if ($entityField->isRequired()) { - $label .= '*'; - } - - $choices[$label] = $entityField->getName(); - } - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/ImportMatchConfigurationChoiceProvider.php b/src/Core/Form/ChoiceProvider/ImportMatchConfigurationChoiceProvider.php deleted file mode 100644 index 5ecfa2ab..00000000 --- a/src/Core/Form/ChoiceProvider/ImportMatchConfigurationChoiceProvider.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class ImportMatchConfigurationChoiceProvider is responsible for providing choices - * in Advanced parameters -> Import -> Step 2 -> Load a data matching configuration. - */ -final class ImportMatchConfigurationChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var array - */ - private $matchConfigurations; - - /** - * @param array $matchConfigurations - */ - public function __construct(array $matchConfigurations) - { - $this->matchConfigurations = $matchConfigurations; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $choices = []; - - foreach ($this->matchConfigurations as $configuration) { - $choices[$configuration['name']] = $configuration['id_import_match']; - } - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/InvoiceModelByNameChoiceProvider.php b/src/Core/Form/ChoiceProvider/InvoiceModelByNameChoiceProvider.php deleted file mode 100644 index f90a52c5..00000000 --- a/src/Core/Form/ChoiceProvider/InvoiceModelByNameChoiceProvider.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\File\FileFinderInterface; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class InvoiceModelByNameChoiceProvider provides invoice model choices with name values. - */ -final class InvoiceModelByNameChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var FileFinderInterface - */ - private $invoiceModelFinder; - - /** - * @param FileFinderInterface $invoiceModelFinder - */ - public function __construct(FileFinderInterface $invoiceModelFinder) - { - $this->invoiceModelFinder = $invoiceModelFinder; - } - - /** - * Get invoice model choices. - * - * @return array - */ - public function getChoices() - { - $choices = [ - 'invoice' => 'invoice', - ]; - - $invoiceModels = $this->invoiceModelFinder->find(); - - foreach ($invoiceModels as $invoiceModel) { - $modelName = basename($invoiceModel, '.tpl'); - $choices[$modelName] = $modelName; - } - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/LanguageByIdChoiceProvider.php b/src/Core/Form/ChoiceProvider/LanguageByIdChoiceProvider.php deleted file mode 100644 index 89c7a5da..00000000 --- a/src/Core/Form/ChoiceProvider/LanguageByIdChoiceProvider.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Adapter\Language\LanguageDataProvider; -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; - -/** - * Class LanguageByIdChoiceProvider provides active language choices with ID values. - */ -final class LanguageByIdChoiceProvider implements ConfigurableFormChoiceProviderInterface -{ - /** - * @var LanguageDataProvider - */ - private $languageDataProvider; - - /** - * LanguageByIdChoiceProvider constructor. - * - * @param LanguageDataProvider $languageDataProvider - */ - public function __construct(LanguageDataProvider $languageDataProvider) - { - $this->languageDataProvider = $languageDataProvider; - } - - /** - * Get active language choices for form. - * - * @return array - */ - public function getChoices(array $options = []) - { - $choices = []; - $shopId = isset($options['shop_id']) && (int) $options['shop_id'] > 0 ? $options['shop_id'] : false; - foreach ($this->languageDataProvider->getLanguages(true, $shopId) as $language) { - $choices[$language['name']] = $language['id_lang']; - } - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/LanguageChoiceProvider.php b/src/Core/Form/ChoiceProvider/LanguageChoiceProvider.php deleted file mode 100644 index 9fb3a705..00000000 --- a/src/Core/Form/ChoiceProvider/LanguageChoiceProvider.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class LanguageChoiceProvider provides languages choices with ID values. - * - * @todo this class could be merged with \PrestaShop\PrestaShop\Core\Form\ChoiceProvider\LanguageByIdChoiceProvider - * as this class can fully achieve the same behavior as the LanguageByIdChoiceProvider. - * It would break BC though, so couldn't be done at the moment. - */ -final class LanguageChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var array - */ - private $languages; - - /** - * @param array $languages - */ - public function __construct(array $languages) - { - $this->languages = $languages; - } - - /** - * Get active language choices for form. - * - * @return array - */ - public function getChoices() - { - $choices = []; - - foreach ($this->languages as $language) { - $choices[$language['name']] = $language['id_lang']; - } - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/LocalizationPackByIsoCodeChoiceProvider.php b/src/Core/Form/ChoiceProvider/LocalizationPackByIsoCodeChoiceProvider.php deleted file mode 100644 index e2bb4453..00000000 --- a/src/Core/Form/ChoiceProvider/LocalizationPackByIsoCodeChoiceProvider.php +++ /dev/null @@ -1,130 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShop\PrestaShop\Core\Localization\Pack\Loader\LocalizationPackLoaderInterface; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class LocalizationPackByIsoCodeChoiceProvider provides localization pack choices with iso code values. - */ -final class LocalizationPackByIsoCodeChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var LocalizationPackLoaderInterface - */ - private $remoteLocalizationPackLoader; - - /** - * @var LocalizationPackLoaderInterface - */ - private $localLocalizationPackLoader; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param LocalizationPackLoaderInterface $remoteLocalizationPackLoader - * @param LocalizationPackLoaderInterface $localLocalizationPackLoader - * @param ConfigurationInterface $configuration - * @param TranslatorInterface $translator - */ - public function __construct( - LocalizationPackLoaderInterface $remoteLocalizationPackLoader, - LocalizationPackLoaderInterface $localLocalizationPackLoader, - ConfigurationInterface $configuration, - TranslatorInterface $translator - ) { - $this->remoteLocalizationPackLoader = $remoteLocalizationPackLoader; - $this->localLocalizationPackLoader = $localLocalizationPackLoader; - $this->configuration = $configuration; - $this->translator = $translator; - } - - /** - * Get localization pack choices. - * - * @return array - */ - public function getChoices() - { - $localizationPacks = $this->remoteLocalizationPackLoader->getLocalizationPackList(); - if (null === $localizationPacks) { - $localizationPacks = $this->localLocalizationPackLoader->getLocalizationPackList(); - } - - $choices = []; - - if ($localizationPacks) { - foreach ($localizationPacks as $pack) { - $choices[(string) $pack->name] = (string) $pack->iso; - } - } - - $rootDir = $this->configuration->get('_PS_ROOT_DIR_'); - - $finder = (new Finder()) - ->files() - ->depth('0') - ->in($rootDir . '/localization') - ->name('/^([a-z]{2})\.xml$/'); - - foreach ($finder as $file) { - list($iso) = explode('.', $file->getFilename()); - - // if localization pack was not loaded yet and it exists locally - // then add it to choices list - if (!in_array($iso, $choices)) { - $pack = $this->localLocalizationPackLoader->getLocalizationPack($iso); - $packName = $this->translator->trans( - '%s (local)', - [ - (string) $pack['name'], - ], - 'Admin.International.Feature' - ); - - $choices[$packName] = $iso; - } - } - - // sort choices alphabetically - ksort($choices); - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/MailMethodChoiceProvider.php b/src/Core/Form/ChoiceProvider/MailMethodChoiceProvider.php deleted file mode 100644 index 16667663..00000000 --- a/src/Core/Form/ChoiceProvider/MailMethodChoiceProvider.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Email\MailOption; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class MailMethodChoiceProvider provides choices for mail methods. - */ -final class MailMethodChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param ConfigurationInterface $configuration - * @param TranslatorInterface $translator - */ - public function __construct( - ConfigurationInterface $configuration, - TranslatorInterface $translator - ) { - $this->configuration = $configuration; - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $choices = []; - - if (null === $this->configuration->get('_PS_HOST_MODE_')) { - $choices[ - $this->trans('Use /usr/sbin/sendmail (recommended; works in most cases)', [], 'Admin.Advparameters.Feature') - ] = MailOption::METHOD_NATIVE; - } - - $choices[ - $this->trans('Set my own SMTP parameters (for advanced users ONLY)', [], 'Admin.Advparameters.Feature') - ] = MailOption::METHOD_SMTP; - - $choices[ - $this->trans('Never send emails (may be useful for testing purposes)', [], 'Admin.Advparameters.Feature') - ] = MailOption::METHOD_NONE; - - return $choices; - } - - /** - * @param string $key - * @param array $params - * @param string $domain - * - * @return string - */ - private function trans($key, array $params, $domain) - { - return $this->translator->trans($key, $params, $domain); - } -} diff --git a/src/Core/Form/ChoiceProvider/MailThemeChoiceProvider.php b/src/Core/Form/ChoiceProvider/MailThemeChoiceProvider.php deleted file mode 100644 index 1f28d21d..00000000 --- a/src/Core/Form/ChoiceProvider/MailThemeChoiceProvider.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\ThemeCatalogInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\ThemeCollectionInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\ThemeInterface; - -/** - * Class MailThemeChoiceProvider is responsible to provide a list of available mail themes. - */ -class MailThemeChoiceProvider implements FormChoiceProviderInterface -{ - /** @var array */ - private $choices; - - /** @var ThemeCatalogInterface */ - private $themeCatalog; - - /** - * @param ThemeCatalogInterface $themeCatalog - */ - public function __construct(ThemeCatalogInterface $themeCatalog) - { - $this->themeCatalog = $themeCatalog; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - if (null === $this->choices) { - $this->choices = []; - - /** @var ThemeCollectionInterface $collection */ - $collection = $this->themeCatalog->listThemes(); - - /** @var ThemeInterface $theme */ - foreach ($collection as $theme) { - $this->choices[$theme->getName()] = $theme->getName(); - } - } - - return $this->choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/ModuleByNameChoiceProvider.php b/src/Core/Form/ChoiceProvider/ModuleByNameChoiceProvider.php deleted file mode 100644 index 69130ea7..00000000 --- a/src/Core/Form/ChoiceProvider/ModuleByNameChoiceProvider.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Adapter\Module\Module; -use PrestaShop\PrestaShop\Core\Addon\AddonsCollection; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class ModuleByNameChoiceProvider provides module choices with name values. - */ -final class ModuleByNameChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var AddonsCollection collection of installed modules - */ - private $installedModules; - - /** - * @param AddonsCollection $installedModules - */ - public function __construct(AddonsCollection $installedModules) - { - $this->installedModules = $installedModules; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $moduleChoices = []; - - /** @var Module $module */ - foreach ($this->installedModules as $module) { - $moduleChoices[$module->get('displayName')] = $module->get('name'); - } - - return $moduleChoices; - } -} diff --git a/src/Core/Form/ChoiceProvider/ModuleMetaPageNameChoiceProvider.php b/src/Core/Form/ChoiceProvider/ModuleMetaPageNameChoiceProvider.php deleted file mode 100644 index 10fb006c..00000000 --- a/src/Core/Form/ChoiceProvider/ModuleMetaPageNameChoiceProvider.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShop\PrestaShop\Core\Meta\MetaDataProviderInterface; -use Symfony\Component\HttpFoundation\RequestStack; - -/** - * Class ModuleMetaPageNameChoiceProvider is responsible for providing module page choices in - * Shop parameters -> Traffic & Seo -> Seo & Urls -> form. - */ -final class ModuleMetaPageNameChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var RequestStack - */ - private $requestStack; - - /** - * @var MetaDataProviderInterface - */ - private $dataProvider; - - /** - * DefaultPageChoiceProvider constructor. - * - * @param RequestStack $requestStack - * @param MetaDataProviderInterface $dataProvider - */ - public function __construct( - RequestStack $requestStack, - MetaDataProviderInterface $dataProvider - ) { - $this->requestStack = $requestStack; - $this->dataProvider = $dataProvider; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $defaultPages = $this->dataProvider->getNotConfiguredModuleMetaPageNames(); - $currentPage = $this->getCurrentPage(); - - if (null !== $currentPage) { - $defaultPages[str_replace('module-', '', $currentPage)] = $currentPage; - asort($defaultPages); - } - - return $defaultPages; - } - - /** - * Gets current page. - * - * @return string|null - */ - private function getCurrentPage() - { - $currentRequest = $this->requestStack->getCurrentRequest(); - - $metaId = null; - if (null !== $currentRequest) { - $metaId = $currentRequest->attributes->get('metaId'); - } - - if ($metaId) { - return $this->dataProvider->getModuleMetaPageNameById($metaId); - } - - return null; - } -} diff --git a/src/Core/Form/ChoiceProvider/NonInstalledLocalizationChoiceProvider.php b/src/Core/Form/ChoiceProvider/NonInstalledLocalizationChoiceProvider.php deleted file mode 100644 index 88edd741..00000000 --- a/src/Core/Form/ChoiceProvider/NonInstalledLocalizationChoiceProvider.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Adapter\Language\LanguageDataProvider; -use PrestaShop\PrestaShop\Adapter\Language\LanguageValidator; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShop\PrestaShop\Core\Language\LanguageValidatorInterface; - -/** - * Class NonInstalledLocalizationChoiceProvider provides non installed localization choices - * with name keys and iso code values. - */ -final class NonInstalledLocalizationChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var LanguageValidator - */ - private $languageValidator; - - /** - * @var LanguageDataProvider - */ - private $languageProvider; - /** - * @var array - */ - private $languagePackList; - - /** - * @param array $languagePackList - * @param LanguageValidatorInterface $languageValidator - * @param LanguageDataProvider $languageProvider - */ - public function __construct( - array $languagePackList, - LanguageValidatorInterface $languageValidator, - LanguageDataProvider $languageProvider - ) { - $this->languageValidator = $languageValidator; - $this->languageProvider = $languageProvider; - $this->languagePackList = $languagePackList; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $choices = []; - foreach (array_keys($this->languagePackList) as $locale) { - if ($this->languageValidator->isInstalledByLocale($locale)) { - continue; - } - - $languageDetails = $this->languageProvider->getLanguageDetails($locale); - - if (isset($languageDetails['iso_code'], $languageDetails['name'])) { - $choices[$languageDetails['name']] = $languageDetails['iso_code']; - } - } - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/OrderDiscountTypeChoiceProvider.php b/src/Core/Form/ChoiceProvider/OrderDiscountTypeChoiceProvider.php deleted file mode 100644 index 7f65bad0..00000000 --- a/src/Core/Form/ChoiceProvider/OrderDiscountTypeChoiceProvider.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Domain\Order\OrderDiscountType; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -final class OrderDiscountTypeChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - return [ - $this->translator->trans('Percent', [], 'Admin.Global') => OrderDiscountType::DISCOUNT_PERCENT, - $this->translator->trans('Amount', [], 'Admin.Global') => OrderDiscountType::DISCOUNT_AMOUNT, - $this->translator->trans('Free shipping', [], 'Admin.Shipping.Feature') => OrderDiscountType::FREE_SHIPPING, - ]; - } -} diff --git a/src/Core/Form/ChoiceProvider/OrderStateByIdChoiceProvider.php b/src/Core/Form/ChoiceProvider/OrderStateByIdChoiceProvider.php deleted file mode 100644 index a484aa70..00000000 --- a/src/Core/Form/ChoiceProvider/OrderStateByIdChoiceProvider.php +++ /dev/null @@ -1,120 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; -use PrestaShop\PrestaShop\Core\Form\FormChoiceAttributeProviderInterface; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShop\PrestaShop\Core\Order\OrderStateDataProviderInterface; -use PrestaShop\PrestaShop\Core\Util\ColorBrightnessCalculator; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class OrderStateByIdChoiceProvider provides order state choices with ID values. - */ -final class OrderStateByIdChoiceProvider implements FormChoiceProviderInterface, FormChoiceAttributeProviderInterface, ConfigurableFormChoiceProviderInterface -{ - /** - * @var int language ID - */ - private $languageId; - - /** - * @var OrderStateDataProviderInterface - */ - private $orderStateDataProvider; - - /** - * @var ColorBrightnessCalculator - */ - private $colorBrightnessCalculator; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param int $languageId language ID - * @param OrderStateDataProviderInterface $orderStateDataProvider - * @param ColorBrightnessCalculator $colorBrightnessCalculator - * @param TranslatorInterface $translator - */ - public function __construct( - $languageId, - OrderStateDataProviderInterface $orderStateDataProvider, - ColorBrightnessCalculator $colorBrightnessCalculator, - TranslatorInterface $translator - ) { - $this->languageId = $languageId; - $this->orderStateDataProvider = $orderStateDataProvider; - $this->colorBrightnessCalculator = $colorBrightnessCalculator; - $this->translator = $translator; - } - - /** - * Get order state choices. - * - * @param array $options - * - * @return array - */ - public function getChoices(array $options = []) - { - $orderStates = $this->orderStateDataProvider->getOrderStates($this->languageId); - $choices = []; - - foreach ($orderStates as $orderState) { - if ($orderState['deleted'] == 1 && (empty($options['current_state']) || $options['current_state'] != $orderState['id_order_state'])) { - continue; - } - $orderState['name'] .= $orderState['deleted'] == 1 ? ' ' . $this->translator->trans('(deleted)', [], 'Admin.Global') : ''; - $choices[$orderState['name']] = $orderState['id_order_state']; - } - - return $choices; - } - - /** - * Get order state choices attributes. - * - * @return array - */ - public function getChoicesAttributes() - { - $orderStates = $this->orderStateDataProvider->getOrderStates($this->languageId); - $attrs = []; - - foreach ($orderStates as $orderState) { - $orderState['name'] .= $orderState['deleted'] == 1 ? ' ' . $this->translator->trans('(deleted)', [], 'Admin.Global') : ''; - $attrs[$orderState['name']]['data-background-color'] = $orderState['color']; - $attrs[$orderState['name']]['data-is-bright'] = $this->colorBrightnessCalculator->isBright($orderState['color']); - } - - return $attrs; - } -} diff --git a/src/Core/Form/ChoiceProvider/PermissionsChoiceProvider.php b/src/Core/Form/ChoiceProvider/PermissionsChoiceProvider.php deleted file mode 100644 index be6fe8f0..00000000 --- a/src/Core/Form/ChoiceProvider/PermissionsChoiceProvider.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Domain\Webservice\ValueObject\Permission; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Provides webservice key permissions choices - */ -final class PermissionsChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - return [ - $this->translator->trans('All', [], 'Admin.Global') => 'all', - $this->translator->trans('View (GET)', [], 'Admin.Advparameters.Feature') => Permission::VIEW, - $this->translator->trans('Modify (PUT)', [], 'Admin.Advparameters.Feature') => Permission::MODIFY, - $this->translator->trans('Add (POST)', [], 'Admin.Advparameters.Feature') => Permission::ADD, - $this->translator->trans('Delete (DELETE)', [], 'Admin.Advparameters.Feature') => Permission::DELETE, - $this->translator->trans('Fast view (HEAD)', [], 'Admin.Advparameters.Feature') => Permission::FAST_VIEW, - ]; - } -} diff --git a/src/Core/Form/ChoiceProvider/PriceReductionTypeChoiceProvider.php b/src/Core/Form/ChoiceProvider/PriceReductionTypeChoiceProvider.php deleted file mode 100644 index b1e19988..00000000 --- a/src/Core/Form/ChoiceProvider/PriceReductionTypeChoiceProvider.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Reduction; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Provides choices for price reduction types - */ -final class PriceReductionTypeChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - return [ - $this->translator->trans('Amount', [], 'Admin.Global') => Reduction::TYPE_AMOUNT, - $this->translator->trans('Percentage', [], 'Admin.Global') => Reduction::TYPE_PERCENTAGE, - ]; - } -} diff --git a/src/Core/Form/ChoiceProvider/ProfileChoiceProvider.php b/src/Core/Form/ChoiceProvider/ProfileChoiceProvider.php deleted file mode 100644 index 5dd558f9..00000000 --- a/src/Core/Form/ChoiceProvider/ProfileChoiceProvider.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class ProfileChoiceProvider provides employee profile choices. - */ -final class ProfileChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var array - */ - private $profiles; - - /** - * @param array $profiles - */ - public function __construct(array $profiles) - { - $this->profiles = $profiles; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $choices = []; - - foreach ($this->profiles as $profile) { - $choices[$profile['name']] = $profile['id_profile']; - } - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/StatusChoiceProvider.php b/src/Core/Form/ChoiceProvider/StatusChoiceProvider.php deleted file mode 100644 index 8b6fe524..00000000 --- a/src/Core/Form/ChoiceProvider/StatusChoiceProvider.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class StatusChoiceProvider is responsible for providing choices for list statuses filter criteria. - */ -final class StatusChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * StatusChoiceProvider constructor. - * - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - return [ - $this->translator->trans('Yes', [], 'Admin.Global') => 1, - $this->translator->trans('No', [], 'Admin.Global') => 0, - ]; - } -} diff --git a/src/Core/Form/ChoiceProvider/TabChoiceProvider.php b/src/Core/Form/ChoiceProvider/TabChoiceProvider.php deleted file mode 100644 index 94c08d6f..00000000 --- a/src/Core/Form/ChoiceProvider/TabChoiceProvider.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class TabChoiceProvider provides Tab choices with name values. - * - * This class is used for choosing Default page when creating employee - */ -final class TabChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var array - */ - private $tabs; - - /** - * @param array $tabs - */ - public function __construct(array $tabs) - { - $this->tabs = $tabs; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $choices = []; - - foreach ($this->tabs as $tab) { - if (!empty($tab['children'])) { - $choices[$tab['name']] = []; - - foreach ($tab['children'] as $childTab) { - if ($childTab['name']) { - $choices[$tab['name']][$childTab['name']] = $childTab['id_tab']; - } - } - } else { - $choices[$tab['name']] = $tab['id_tab']; - } - } - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/TaxAddressTypeChoiceProvider.php b/src/Core/Form/ChoiceProvider/TaxAddressTypeChoiceProvider.php deleted file mode 100644 index 11d5b601..00000000 --- a/src/Core/Form/ChoiceProvider/TaxAddressTypeChoiceProvider.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Provides address type choices - */ -final class TaxAddressTypeChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * Get choices. - * - * @return array - */ - public function getChoices() - { - return [ - $this->translator->trans('Invoice address', [], 'Admin.International.Feature') => 'id_address_invoice', - $this->translator->trans('Delivery address', [], 'Admin.International.Feature') => 'id_address_delivery', - ]; - } -} diff --git a/src/Core/Form/ChoiceProvider/TaxInclusionChoiceProvider.php b/src/Core/Form/ChoiceProvider/TaxInclusionChoiceProvider.php deleted file mode 100644 index 483e81a0..00000000 --- a/src/Core/Form/ChoiceProvider/TaxInclusionChoiceProvider.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Provides choices for tax inclusion - */ -final class TaxInclusionChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - return [ - $this->translator->trans('Tax included', [], 'Admin.Global') => 1, - $this->translator->trans('Tax excluded', [], 'Admin.Global') => 0, - ]; - } -} diff --git a/src/Core/Form/ChoiceProvider/ThemeByNameChoiceProvider.php b/src/Core/Form/ChoiceProvider/ThemeByNameChoiceProvider.php deleted file mode 100644 index e0bb0522..00000000 --- a/src/Core/Form/ChoiceProvider/ThemeByNameChoiceProvider.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Addon\Theme\Theme; -use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeCollection; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class ThemeByNameChoiceProvider provides theme choices with name values. - */ -final class ThemeByNameChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var ThemeCollection collection of themes - */ - private $themeCollection; - - /** - * @param ThemeCollection $themeCollection - */ - public function __construct(ThemeCollection $themeCollection) - { - $this->themeCollection = $themeCollection; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $themeChoices = []; - - /** @var Theme $theme */ - foreach ($this->themeCollection as $theme) { - $themeChoices[$theme->getName()] = $theme->getName(); - } - - return $themeChoices; - } -} diff --git a/src/Core/Form/ChoiceProvider/ThemeByNameWithEmailsChoiceProvider.php b/src/Core/Form/ChoiceProvider/ThemeByNameWithEmailsChoiceProvider.php deleted file mode 100644 index a5a812f7..00000000 --- a/src/Core/Form/ChoiceProvider/ThemeByNameWithEmailsChoiceProvider.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Addon\Theme\Theme; -use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeCollection; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class ThemeByNameChoiceProvider provides theme choices with name values, but it - * filters themes which haven't overridden any email templates. - */ -final class ThemeByNameWithEmailsChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var ThemeCollection collection of themes - */ - private $themeCollection; - - /** - * @param ThemeCollection $themeCollection - */ - public function __construct(ThemeCollection $themeCollection) - { - $this->themeCollection = $themeCollection; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $themeChoices = []; - - /** @var Theme $theme */ - foreach ($this->themeCollection as $theme) { - $coreMailsFolder = $theme->getDirectory() . '/mails'; - $modulesMailFolder = $theme->getDirectory() . '/modules'; - if (is_dir($coreMailsFolder) || is_dir($modulesMailFolder)) { - $themeChoices[$theme->getName()] = $theme->getName(); - } - } - - return $themeChoices; - } -} diff --git a/src/Core/Form/ChoiceProvider/ThemeChoiceProvider.php b/src/Core/Form/ChoiceProvider/ThemeChoiceProvider.php deleted file mode 100644 index 943b972a..00000000 --- a/src/Core/Form/ChoiceProvider/ThemeChoiceProvider.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeProviderInterface; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class ThemeChoiceProvider provides available themes as choices. - */ -final class ThemeChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var ThemeProviderInterface - */ - private $themeProvider; - - /** - * @param ThemeProviderInterface $themeProvider - */ - public function __construct(ThemeProviderInterface $themeProvider) - { - $this->themeProvider = $themeProvider; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $usedTheme = $this->themeProvider->getCurrentlyUsedTheme(); - $notUsedThemes = $this->themeProvider->getNotUsedThemes(); - - $choices = []; - $choices[$usedTheme->getName()] = $usedTheme->getName(); - - foreach ($notUsedThemes as $theme) { - $choices[$theme->getName()] = $theme->getName(); - } - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/ThemePageLayoutsChoiceProvider.php b/src/Core/Form/ChoiceProvider/ThemePageLayoutsChoiceProvider.php deleted file mode 100644 index c295196d..00000000 --- a/src/Core/Form/ChoiceProvider/ThemePageLayoutsChoiceProvider.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Addon\Theme\Theme; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; - -/** - * Class ThemePageLayoutsChoiceProvider proves page layout choices for given theme. - */ -final class ThemePageLayoutsChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var Theme - */ - private $theme; - - /** - * @param Theme $theme - */ - public function __construct(Theme $theme) - { - $this->theme = $theme; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $choices = []; - - foreach ($this->theme->getAvailableLayouts() as $layoutId => $availableLayout) { - $choices[sprintf('%s - %s', $availableLayout['name'], $availableLayout['description'])] = $layoutId; - } - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/ThemeZipChoiceProvider.php b/src/Core/Form/ChoiceProvider/ThemeZipChoiceProvider.php deleted file mode 100644 index c23e4560..00000000 --- a/src/Core/Form/ChoiceProvider/ThemeZipChoiceProvider.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Finder\SplFileInfo; - -/** - * Class ThemeZipChoiceProvider provides choices for uploaded Front Office theme zips. - */ -final class ThemeZipChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - $themeZipsFinder = (new Finder()) - ->in($this->configuration->get('_PS_ALL_THEMES_DIR_')) - ->files() - ->name('*.zip') - ; - - $themeZips = []; - - /** @var SplFileInfo $themeZip */ - foreach ($themeZipsFinder as $themeZip) { - $themeZips[$themeZip->getFilename()] = $themeZip->getFilename(); - } - - return $themeZips; - } -} diff --git a/src/Core/Form/ChoiceProvider/TimezoneByNameChoiceProvider.php b/src/Core/Form/ChoiceProvider/TimezoneByNameChoiceProvider.php deleted file mode 100644 index 46d0c1dc..00000000 --- a/src/Core/Form/ChoiceProvider/TimezoneByNameChoiceProvider.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShopBundle\Entity\Repository\TimezoneRepository; - -/** - * Class TimezoneByNameChoiceProvider provides timezone choices with name values. - */ -final class TimezoneByNameChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var TimezoneRepository - */ - private $timezoneRepository; - - /** - * @param TimezoneRepository $timezoneRepository - */ - public function __construct(TimezoneRepository $timezoneRepository) - { - $this->timezoneRepository = $timezoneRepository; - } - - /** - * Get timezone choices. - * - * @return array - */ - public function getChoices() - { - $timezones = $this->timezoneRepository->findAll(); - $choices = []; - - foreach ($timezones as $timezone) { - $choices[$timezone['name']] = $timezone['name']; - } - - return $choices; - } -} diff --git a/src/Core/Form/ChoiceProvider/TranslationTypeChoiceProvider.php b/src/Core/Form/ChoiceProvider/TranslationTypeChoiceProvider.php deleted file mode 100644 index 5d434f18..00000000 --- a/src/Core/Form/ChoiceProvider/TranslationTypeChoiceProvider.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\ChoiceProvider; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class TranslationTypeByNameChoiceProvider provides translation type choices. - */ -final class TranslationTypeChoiceProvider implements FormChoiceProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - return [ - $this->translator->trans('Back office translations', [], 'Admin.International.Feature') => 'back', - $this->translator->trans('Themes translations', [], 'Admin.International.Feature') => 'themes', - $this->translator->trans('Installed modules translations', [], 'Admin.International.Feature') => 'modules', - $this->translator->trans('Email translations', [], 'Admin.International.Feature') => 'mails', - $this->translator->trans('Other translations', [], 'Admin.International.Feature') => 'others', - ]; - } -} diff --git a/src/Core/Form/ConfigurableFormChoiceProviderInterface.php b/src/Core/Form/ConfigurableFormChoiceProviderInterface.php deleted file mode 100644 index c6e9d0a2..00000000 --- a/src/Core/Form/ConfigurableFormChoiceProviderInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form; - -/** - * Interface for services that provide configurable form choices (e.g. States choices depending on country). - */ -interface ConfigurableFormChoiceProviderInterface -{ - /** - * @param array $options - * - * @return array - */ - public function getChoices(array $options); -} diff --git a/src/Core/Form/DTO/ShopRestriction.php b/src/Core/Form/DTO/ShopRestriction.php deleted file mode 100644 index a5f40e64..00000000 --- a/src/Core/Form/DTO/ShopRestriction.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\DTO; - -/** - * Shop restriction object holds the shop ids for which restriction is being applied and the fields which are impacted - * by the certain shop restriction. - */ -class ShopRestriction -{ - /** - * @var int[] - */ - private $shopIds; - - /** - * @var ShopRestrictionField[] - */ - private $shopRestrictionFields; - - /** - * @param int[] $shopIds - * @param ShopRestrictionField[] $shopRestrictionFields - */ - public function __construct(array $shopIds, array $shopRestrictionFields) - { - $this->shopIds = $shopIds; - $this->shopRestrictionFields = $shopRestrictionFields; - } - - /** - * @return int[] - */ - public function getShopIds() - { - return $this->shopIds; - } - - /** - * @return ShopRestrictionField[] - */ - public function getShopRestrictionFields() - { - return $this->shopRestrictionFields; - } -} diff --git a/src/Core/Form/DTO/ShopRestrictionField.php b/src/Core/Form/DTO/ShopRestrictionField.php deleted file mode 100644 index 091b3b54..00000000 --- a/src/Core/Form/DTO/ShopRestrictionField.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\DTO; - -/** - * Holds the field name for which the multi-store restriction checkbox has been checked or unchecked and the status if it - * was restricted or not. - */ -class ShopRestrictionField -{ - /** - * @var string - */ - private $fieldName; - - /** - * @var bool - */ - private $isRestrictedToContextShop; - - /** - * @param string $fieldName - * @param bool $isRestrictedToContextShop - */ - public function __construct($fieldName, $isRestrictedToContextShop) - { - $this->fieldName = $fieldName; - $this->isRestrictedToContextShop = $isRestrictedToContextShop; - } - - /** - * @return string - */ - public function getFieldName() - { - return $this->fieldName; - } - - /** - * @return bool - */ - public function isRestrictedToContextShop() - { - return $this->isRestrictedToContextShop; - } -} diff --git a/src/Core/Form/FormChoiceAttributeProviderInterface.php b/src/Core/Form/FormChoiceAttributeProviderInterface.php deleted file mode 100644 index 6bc2eafe..00000000 --- a/src/Core/Form/FormChoiceAttributeProviderInterface.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form; - -/** - * Interface FormChoiceProviderInterface defines contract for choice attribute providers. - */ -interface FormChoiceAttributeProviderInterface -{ - /** - * Get choices attributes. - * return [{choice_value} => [...$attributes]] - * - * @return array - */ - public function getChoicesAttributes(); -} diff --git a/src/Core/Form/FormChoiceProviderInterface.php b/src/Core/Form/FormChoiceProviderInterface.php deleted file mode 100644 index 237ed8ac..00000000 --- a/src/Core/Form/FormChoiceProviderInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form; - -/** - * Interface FormChoiceProviderInterface defines contract for choice providers. - */ -interface FormChoiceProviderInterface -{ - /** - * Get choices. - * - * @return array - */ - public function getChoices(); -} diff --git a/src/Core/Form/FormDataProviderInterface.php b/src/Core/Form/FormDataProviderInterface.php deleted file mode 100644 index ee6c9e6f..00000000 --- a/src/Core/Form/FormDataProviderInterface.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form; - -/** - * Symfony forms data provider. - */ -interface FormDataProviderInterface -{ - /** - * @return array the form data as an associative array - */ - public function getData(); - - /** - * Persists form Data in Database and Filesystem. - * - * @param array $data - * - * @return array $errors if data can't persisted an array of errors messages - * - * @throws UndefinedOptionsException - */ - public function setData(array $data); -} diff --git a/src/Core/Form/FormHandler.php b/src/Core/Form/FormHandler.php deleted file mode 100644 index c708c354..00000000 --- a/src/Core/Form/FormHandler.php +++ /dev/null @@ -1,137 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form; - -use Exception; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\Exception\UndefinedOptionsException; - -/** - * Complete implementation of FormHandlerInterface. - */ -class FormHandler implements FormHandlerInterface -{ - /** - * @var FormBuilderInterface the form builder - */ - protected $formBuilder; - - /** - * @var FormDataProviderInterface the form data provider - */ - protected $formDataProvider; - - /** - * @var HookDispatcherInterface the event dispatcher - */ - protected $hookDispatcher; - - /** - * @var string the hook name - */ - protected $hookName; - - /** - * @var array the list of Form Types - */ - protected $formTypes; - - /** - * @var string the form name - */ - protected $formName; - - /** - * FormHandler constructor. - * - * @param FormBuilderInterface $formBuilder - * @param HookDispatcherInterface $hookDispatcher - * @param FormDataProviderInterface $formDataProvider - * @param array $formTypes - * @param string $hookName - * @param string $formName - */ - public function __construct( - FormBuilderInterface $formBuilder, - HookDispatcherInterface $hookDispatcher, - FormDataProviderInterface $formDataProvider, - array $formTypes, - $hookName, - $formName = 'form' - ) { - $this->formName = $formName; - $this->formBuilder = $formBuilder->getFormFactory()->createNamedBuilder($formName); - $this->hookDispatcher = $hookDispatcher; - $this->formDataProvider = $formDataProvider; - $this->formTypes = $formTypes; - $this->hookName = $hookName; - } - - /** - * {@inheritdoc} - * - * @throws Exception - */ - public function getForm() - { - foreach ($this->formTypes as $formName => $formType) { - $this->formBuilder->add($formName, $formType); - } - - $this->formBuilder->setData($this->formDataProvider->getData()); - $this->hookDispatcher->dispatchWithParameters( - "action{$this->hookName}Form", - [ - 'form_builder' => &$this->formBuilder, - ] - ); - - return $this->formBuilder->getForm(); - } - - /** - * {@inheritdoc} - * - * @throws Exception - * @throws UndefinedOptionsException - */ - public function save(array $data) - { - $errors = $this->formDataProvider->setData($data); - - $this->hookDispatcher->dispatchWithParameters( - "action{$this->hookName}Save", - [ - 'errors' => &$errors, - 'form_data' => &$data, - ] - ); - - return $errors; - } -} diff --git a/src/Core/Form/FormHandlerInterface.php b/src/Core/Form/FormHandlerInterface.php deleted file mode 100644 index 77e284e3..00000000 --- a/src/Core/Form/FormHandlerInterface.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form; - -use Symfony\Component\Form\FormInterface; - -/** - * Manage Symfony forms outside the controllers. - */ -interface FormHandlerInterface -{ - /** - * @return FormInterface - */ - public function getForm(); - - /** - * Describe what need to be done on saving the form: mostly persists the data - * using a form data provider, but it's also the right place to dispatch events/log something. - * - * @param array $data data retrieved from form that need to be persisted in database - * - * @throws \Exception if the data can't be handled - * - * @return array $errors if data can't persisted an array of errors messages - */ - public function save(array $data); -} diff --git a/src/Core/Form/IdentifiableObject/Builder/FormBuilder.php b/src/Core/Form/IdentifiableObject/Builder/FormBuilder.php deleted file mode 100644 index d1db735d..00000000 --- a/src/Core/Form/IdentifiableObject/Builder/FormBuilder.php +++ /dev/null @@ -1,130 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder; - -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\FormDataProviderInterface; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\Form\FormFactoryInterface; -use Symfony\Component\Form\FormInterface; - -/** - * Creates new forms for identifiable objects. - */ -final class FormBuilder implements FormBuilderInterface -{ - /** - * @var FormFactoryInterface - */ - private $formFactory; - - /** - * @var HookDispatcherInterface - */ - private $hookDispatcher; - - /** - * @var FormDataProviderInterface - */ - private $dataProvider; - - /** - * @var string - */ - private $formType; - - /** - * @param FormFactoryInterface $formFactory - * @param HookDispatcherInterface $hookDispatcher - * @param FormDataProviderInterface $dataProvider - * @param string $formType - */ - public function __construct( - FormFactoryInterface $formFactory, - HookDispatcherInterface $hookDispatcher, - FormDataProviderInterface $dataProvider, - $formType - ) { - $this->formFactory = $formFactory; - $this->hookDispatcher = $hookDispatcher; - $this->dataProvider = $dataProvider; - $this->formType = $formType; - } - - /** - * {@inheritdoc} - */ - public function getForm(array $data = [], array $options = []) - { - if (is_array($defaultData = $this->dataProvider->getDefaultData())) { - $data = array_merge($defaultData, $data); - } - - return $this->buildForm( - $this->formType, - $data, - null, - $options - ); - } - - /** - * {@inheritdoc} - */ - public function getFormFor($id, array $data = [], array $options = []) - { - $data = array_merge($this->dataProvider->getData($id), $data); - - return $this->buildForm( - $this->formType, - $data, - $id, - $options - ); - } - - /** - * @param string $formType - * @param array $data - * @param int|null $id - * @param array $options - * - * @return FormInterface - */ - private function buildForm($formType, $data, $id = null, array $options = []) - { - $formBuilder = $this->formFactory->createBuilder($formType, $data, $options); - - $this->hookDispatcher->dispatchWithParameters('action' . Container::camelize($formBuilder->getName()) . 'FormBuilderModifier', [ - 'form_builder' => $formBuilder, - 'data' => &$data, - 'id' => $id, - ]); - - return $formBuilder->getForm(); - } -} diff --git a/src/Core/Form/IdentifiableObject/Builder/FormBuilderFactory.php b/src/Core/Form/IdentifiableObject/Builder/FormBuilderFactory.php deleted file mode 100644 index 26bcb8fe..00000000 --- a/src/Core/Form/IdentifiableObject/Builder/FormBuilderFactory.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder; - -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\FormDataProviderInterface; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use Symfony\Component\Form\FormFactoryInterface; - -/** - * Creates new form builders which are used to get forms for identifiable objects. - */ -final class FormBuilderFactory implements FormBuilderFactoryInterface -{ - /** - * @var FormFactoryInterface - */ - private $formFactory; - - /** - * @var HookDispatcherInterface - */ - private $hookDispatcher; - - /** - * @param FormFactoryInterface $formFactory - * @param HookDispatcherInterface $hookDispatcher - */ - public function __construct( - FormFactoryInterface $formFactory, - HookDispatcherInterface $hookDispatcher - ) { - $this->formFactory = $formFactory; - $this->hookDispatcher = $hookDispatcher; - } - - /** - * {@inheritdoc} - */ - public function create($formType, FormDataProviderInterface $dataProvider) - { - return new FormBuilder( - $this->formFactory, - $this->hookDispatcher, - $dataProvider, - $formType - ); - } -} diff --git a/src/Core/Form/IdentifiableObject/Builder/FormBuilderFactoryInterface.php b/src/Core/Form/IdentifiableObject/Builder/FormBuilderFactoryInterface.php deleted file mode 100644 index 07a2d8ed..00000000 --- a/src/Core/Form/IdentifiableObject/Builder/FormBuilderFactoryInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder; - -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\FormDataProviderInterface; - -/** - * Defines interface for creating form builders. - */ -interface FormBuilderFactoryInterface -{ - /** - * @param string $formType - * @param FormDataProviderInterface $dataProvider - * - * @return FormBuilderInterface - */ - public function create($formType, FormDataProviderInterface $dataProvider); -} diff --git a/src/Core/Form/IdentifiableObject/Builder/FormBuilderInterface.php b/src/Core/Form/IdentifiableObject/Builder/FormBuilderInterface.php deleted file mode 100644 index c0a51865..00000000 --- a/src/Core/Form/IdentifiableObject/Builder/FormBuilderInterface.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder; - -use Symfony\Component\Form\FormInterface; - -/** - * Defines contract for identifiable object form factories. - */ -interface FormBuilderInterface -{ - /** - * Create new form. - * - * @param array $data - * @param array $options - * - * @return FormInterface - */ - public function getForm(array $data = [], array $options = []); - - /** - * Create new form for given object. - * - * @param int $id - * @param array $data - * @param array $options - * - * @return FormInterface - */ - public function getFormFor($id, array $data = [], array $options = []); -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/AddressFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/AddressFormDataHandler.php deleted file mode 100644 index d3ca7263..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/AddressFormDataHandler.php +++ /dev/null @@ -1,175 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Adapter\Customer\CustomerDataProvider; -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\AddCustomerAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\EditCustomerAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; -use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\State\Exception\StateConstraintException; - -/** - * Handles submitted address form data - */ -final class AddressFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @var CustomerDataProvider - */ - private $customerDataProvider; - - /** - * @param CommandBusInterface $commandBus - * @param CustomerDataProvider $customerDataProvider - */ - public function __construct(CommandBusInterface $commandBus, CustomerDataProvider $customerDataProvider) - { - $this->commandBus = $commandBus; - $this->customerDataProvider = $customerDataProvider; - } - - /** - * {@inheritdoc] - * - * @throws CountryConstraintException - * @throws StateConstraintException - */ - public function create(array $data) - { - if (!empty($data['id_customer'])) { - $customerId = $data['id_customer']; - } else { - $customerId = $this->customerDataProvider->getIdByEmail($data['customer_email']); - } - - $addAddressCommand = new AddCustomerAddressCommand( - $customerId, - $data['alias'], - $data['first_name'], - $data['last_name'], - $data['address1'], - $data['city'], - (int) $data['id_country'], - $data['postcode'], - $data['dni'], - $data['company'], - $data['vat_number'], - $data['address2'], - (int) $data['id_state'], - $data['phone'], - $data['phone_mobile'] ?? null, - $data['other'] - ); - - /** @var AddressId $addressId */ - $addressId = $this->commandBus->handle($addAddressCommand); - - return $addressId->getValue(); - } - - /** - * {@inheritdoc} - * - * @throws AddressConstraintException - * @throws CountryConstraintException - * @throws StateConstraintException - */ - public function update($addressId, array $data) - { - $editAddressCommand = new EditCustomerAddressCommand($addressId); - - if (isset($data['alias'])) { - $editAddressCommand->setAddressAlias($data['alias']); - } - - if (isset($data['first_name'])) { - $editAddressCommand->setFirstName($data['first_name']); - } - - if (isset($data['last_name'])) { - $editAddressCommand->setLastName($data['last_name']); - } - - if (isset($data['address1'])) { - $editAddressCommand->setAddress($data['address1']); - } - - if (isset($data['city'])) { - $editAddressCommand->setCity($data['city']); - } - - if (isset($data['id_country'])) { - $editAddressCommand->setCountryId((int) $data['id_country']); - } - - if (isset($data['postcode'])) { - $editAddressCommand->setPostCode($data['postcode']); - } - - if (isset($data['dni'])) { - $editAddressCommand->setDni($data['dni']); - } - - if (isset($data['company'])) { - $editAddressCommand->setCompany($data['company']); - } - - if (isset($data['vat_number'])) { - $editAddressCommand->setVatNumber($data['vat_number']); - } - - if (isset($data['address2'])) { - $editAddressCommand->setAddress2($data['address2']); - } - - if (isset($data['id_state'])) { - $editAddressCommand->setStateId((int) $data['id_state']); - } - - if (isset($data['phone'])) { - $editAddressCommand->setHomePhone($data['phone']); - } - - if (isset($data['phone_mobile'])) { - $editAddressCommand->setMobilePhone($data['phone_mobile']); - } - - if (isset($data['other'])) { - $editAddressCommand->setOther($data['other']); - } - - $this->commandBus->handle($editAddressCommand); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/AttachmentFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/AttachmentFormDataHandler.php deleted file mode 100644 index 91efffab..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/AttachmentFormDataHandler.php +++ /dev/null @@ -1,138 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Command\AddAttachmentCommand; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Command\EditAttachmentCommand; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\ValueObject\AttachmentId; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Creates/updates attachment from data submitted in category form - */ -final class AttachmentFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @param CommandBusInterface $commandBus - */ - public function __construct(CommandBusInterface $commandBus) - { - $this->commandBus = $commandBus; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - $command = $this->createAddAttachmentCommand($data); - - /** @var AttachmentId $attachmentId */ - $attachmentId = $this->commandBus->handle($command); - - return $attachmentId->getValue(); - } - - /** - * {@inheritdoc} - * - * @throws AttachmentConstraintException - */ - public function update($attachmentId, array $data) - { - $attachmentIdObject = new AttachmentId((int) $attachmentId); - - $command = $this->createEditAttachmentCommand($attachmentIdObject, $data); - - $this->commandBus->handle($command); - } - - /** - * Creates edit attachment command from - * - * @param $attachmentId - * @param array $data - * - * @return EditAttachmentCommand - */ - private function createEditAttachmentCommand( - AttachmentId $attachmentId, - array $data - ): EditAttachmentCommand { - /** @var UploadedFile|null $fileObject */ - $fileObject = $data['file']; - - $command = new EditAttachmentCommand($attachmentId); - $command->setLocalizedNames($data['name']); - $command->setLocalizedDescriptions($data['file_description']); - - if ($fileObject instanceof UploadedFile) { - $command->setFileInfo( - $fileObject->getPathname(), - $fileObject->getMimeType(), - $fileObject->getClientOriginalName(), - $fileObject->getSize() - ); - } - - return $command; - } - - /** - * @param array $data - * - * @return AddAttachmentCommand - */ - private function createAddAttachmentCommand(array $data) - { - $addAttachmentCommand = new AddAttachmentCommand( - $data['name'], - $data['file_description'] - ); - - if (isset($data['file']) && $data['file'] !== null) { - /** @var UploadedFile $file */ - $file = $data['file']; - - $addAttachmentCommand->setFileInformation( - $file->getPathname(), - $file->getSize(), - $file->getMimeType(), - $file->getClientOriginalName() - ); - } - - return $addAttachmentCommand; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/CancellationFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/CancellationFormDataHandler.php deleted file mode 100644 index cbff315b..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/CancellationFormDataHandler.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\CancelOrderProductCommand; - -/** - * Class CancellationFormDataHandler - */ -final class CancellationFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @param CommandBusInterface $commandBus - * @param CommandBusInterface $queryBus - */ - public function __construct(CommandBusInterface $commandBus, CommandBusInterface $queryBus) - { - $this->commandBus = $commandBus; - $this->queryBus = $queryBus; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - return; - } - - /** - * {@inheritdoc} - */ - public function update($id, array $data) - { - $cancelledProducts = []; - foreach ($data['products'] as $product) { - if (isset($data['selected_' . $product->getOrderDetailId()]) && $data['selected_' . $product->getOrderDetailId()]) { - $cancelledProducts[$product->getOrderDetailId()] = $data['quantity_' . $product->getOrderDetailId()] ?? 0; - } - } - - $command = new CancelOrderProductCommand( - $cancelledProducts, - $id - ); - - $this->commandBus->handle($command); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/CartAddressFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/CartAddressFormDataHandler.php deleted file mode 100644 index a156a75d..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/CartAddressFormDataHandler.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\EditCartAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Cart\Exception\CartConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidAddressTypeException; -use PrestaShop\PrestaShop\Core\Domain\State\Exception\StateConstraintException; - -class CartAddressFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @param CommandBusInterface $commandBus - */ - public function __construct(CommandBusInterface $commandBus) - { - $this->commandBus = $commandBus; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - // Not used for creation, only edition - } - - /** - * {@inheritdoc} - * - * @throws CartConstraintException - * @throws CountryConstraintException - * @throws StateConstraintException - * @throws InvalidAddressTypeException - */ - public function update($cartId, array $data) - { - $editAddressCommand = new EditCartAddressCommand($cartId, $data['address_type']); - - if (isset($data['alias'])) { - $editAddressCommand->setAddressAlias($data['alias']); - } - - if (isset($data['first_name'])) { - $editAddressCommand->setFirstName($data['first_name']); - } - - if (isset($data['last_name'])) { - $editAddressCommand->setLastName($data['last_name']); - } - - if (isset($data['address1'])) { - $editAddressCommand->setAddress($data['address1']); - } - - if (isset($data['city'])) { - $editAddressCommand->setCity($data['city']); - } - - if (isset($data['id_country'])) { - $editAddressCommand->setCountryId((int) $data['id_country']); - } - - if (isset($data['postcode'])) { - $editAddressCommand->setPostCode($data['postcode']); - } - - if (isset($data['dni'])) { - $editAddressCommand->setDni($data['dni']); - } - - if (isset($data['company'])) { - $editAddressCommand->setCompany($data['company']); - } - - if (isset($data['vat_number'])) { - $editAddressCommand->setVatNumber($data['vat_number']); - } - - if (isset($data['address2'])) { - $editAddressCommand->setAddress2($data['address2']); - } - - if (isset($data['id_state'])) { - $editAddressCommand->setStateId((int) $data['id_state']); - } - - if (isset($data['phone'])) { - $editAddressCommand->setHomePhone($data['phone']); - } - - if (isset($data['phone_mobile'])) { - $editAddressCommand->setMobilePhone($data['phone_mobile']); - } - - if (isset($data['other'])) { - $editAddressCommand->setOther($data['other']); - } - - $this->commandBus->handle($editAddressCommand); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/CatalogPriceRuleFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/CatalogPriceRuleFormDataHandler.php deleted file mode 100644 index 47e2f98b..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/CatalogPriceRuleFormDataHandler.php +++ /dev/null @@ -1,153 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command\AddCatalogPriceRuleCommand; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command\EditCatalogPriceRuleCommand; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CatalogPriceRuleException; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\ValueObject\CatalogPriceRuleId; - -/** - * Handles submitted catalog price rule form data - */ -final class CatalogPriceRuleFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @var bool - */ - private $isMultishopEnabled; - - /** - * @var int - */ - private $contextShopId; - - /** - * @param CommandBusInterface $commandBus - * @param bool $isMultishopEnabled - * @param int $contextShopId - */ - public function __construct( - CommandBusInterface $commandBus, - bool $isMultishopEnabled, - int $contextShopId - ) { - $this->commandBus = $commandBus; - $this->contextShopId = $contextShopId; - $this->isMultishopEnabled = $isMultishopEnabled; - } - - /** - * {@inheritdoc} - */ - public function create(array $data): int - { - if (!$this->isMultishopEnabled) { - $data['id_shop'] = $this->contextShopId; - } - - if ($data['leave_initial_price']) { - $data['price'] = -1; - } - - $command = new AddCatalogPriceRuleCommand( - $data['name'], - (int) $data['id_currency'], - (int) $data['id_country'], - (int) $data['id_group'], - (int) $data['from_quantity'], - $data['reduction']['type'], - (float) $data['reduction']['value'], - (int) $data['id_shop'], - (bool) $data['include_tax'], - (float) $data['price'] - ); - - if ($data['date_range']['from']) { - $command->setDateTimeFrom($data['date_range']['from']); - } - - if ($data['date_range']['to']) { - $command->setDateTimeTo($data['date_range']['to']); - } - - /** @var CatalogPriceRuleId $catalogPriceRuleId */ - $catalogPriceRuleId = $this->commandBus->handle($command); - - return $catalogPriceRuleId->getValue(); - } - - /** - * {@inheritdoc} - * - * @throws CatalogPriceRuleException - */ - public function update($catalogPriceRuleId, array $data) - { - $editCatalogPriceRuleCommand = new EditCatalogPriceRuleCommand((int) $catalogPriceRuleId); - $this->fillCommandWithData($editCatalogPriceRuleCommand, $data); - - $this->commandBus->handle($editCatalogPriceRuleCommand); - } - - /** - * @param EditCatalogPriceRuleCommand $command - * @param array $data - * - * @throws CatalogPriceRuleException - */ - private function fillCommandWithData(EditCatalogPriceRuleCommand $command, array $data) - { - if ($data['leave_initial_price']) { - $data['price'] = -1; - } - - $command->setName($data['name']); - $command->setShopId((int) $data['id_shop']); - $command->setCurrencyId((int) $data['id_currency']); - $command->setCountryId((int) $data['id_country']); - $command->setGroupId((int) $data['id_group']); - $command->setFromQuantity((int) $data['from_quantity']); - $command->setPrice((float) $data['price']); - $command->setIncludeTax((bool) $data['include_tax']); - $command->setReduction($data['reduction']['type'], (float) $data['reduction']['value']); - - if ($data['date_range']['from']) { - $command->setDateTimeFrom($data['date_range']['from']); - } - - if ($data['date_range']['to']) { - $command->setDateTimeTo($data['date_range']['to']); - } - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/CategoryFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/CategoryFormDataHandler.php deleted file mode 100644 index 38b4d182..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/CategoryFormDataHandler.php +++ /dev/null @@ -1,201 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\AddCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\EditCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; -use PrestaShop\PrestaShop\Core\Image\Uploader\ImageUploaderInterface; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Creates/updates category from data submitted in category form - */ -final class CategoryFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @var ImageUploaderInterface - */ - private $categoryCoverUploader; - - /** - * @var ImageUploaderInterface - */ - private $categoryThumbnailUploader; - - /** - * @var ImageUploaderInterface - */ - private $categoryMenuThumbnailUploader; - - /** - * @param CommandBusInterface $commandBus - * @param ImageUploaderInterface $categoryCoverUploader - * @param ImageUploaderInterface $categoryThumbnailUploader - * @param ImageUploaderInterface $categoryMenuThumbnailUploader - */ - public function __construct( - CommandBusInterface $commandBus, - ImageUploaderInterface $categoryCoverUploader, - ImageUploaderInterface $categoryThumbnailUploader, - ImageUploaderInterface $categoryMenuThumbnailUploader - ) { - $this->commandBus = $commandBus; - $this->categoryCoverUploader = $categoryCoverUploader; - $this->categoryThumbnailUploader = $categoryThumbnailUploader; - $this->categoryMenuThumbnailUploader = $categoryMenuThumbnailUploader; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - $command = $this->createAddCategoryCommand($data); - - /** @var CategoryId $categoryId */ - $categoryId = $this->commandBus->handle($command); - - $this->uploadImages( - $categoryId, - $data['cover_image'], - $data['thumbnail_image'], - $data['menu_thumbnail_images'] - ); - - return $categoryId->getValue(); - } - - /** - * {@inheritdoc} - */ - public function update($categoryId, array $data) - { - $command = $this->createEditCategoryCommand($categoryId, $data); - - $this->commandBus->handle($command); - - $categoryId = new CategoryId((int) $categoryId); - - $this->uploadImages( - $categoryId, - $data['cover_image'], - $data['thumbnail_image'], - $data['menu_thumbnail_images'] - ); - } - - /** - * Creates add category command from form data - * - * @param array $data - * - * @return AddCategoryCommand - */ - private function createAddCategoryCommand(array $data) - { - $command = new AddCategoryCommand( - $data['name'], - $data['link_rewrite'], - (bool) $data['active'], - (int) $data['id_parent'] - ); - - $command->setLocalizedDescriptions($data['description']); - $command->setLocalizedMetaTitles($data['meta_title']); - $command->setLocalizedMetaDescriptions($data['meta_description']); - $command->setLocalizedMetaKeywords($data['meta_keyword']); - $command->setAssociatedGroupIds($data['group_association']); - - if (isset($data['shop_association'])) { - $command->setAssociatedShopIds($data['shop_association']); - } - - return $command; - } - - /** - * Creates edit category command from - * - * @param int $categoryId - * @param array $data - * - * @return EditCategoryCommand - */ - private function createEditCategoryCommand($categoryId, array $data) - { - $command = new EditCategoryCommand($categoryId); - $command->setIsActive($data['active']); - $command->setLocalizedLinkRewrites($data['link_rewrite']); - $command->setLocalizedNames($data['name']); - $command->setParentCategoryId($data['id_parent']); - $command->setLocalizedDescriptions($data['description']); - $command->setLocalizedMetaTitles($data['meta_title']); - $command->setLocalizedMetaDescriptions($data['meta_description']); - $command->setLocalizedMetaKeywords($data['meta_keyword']); - $command->setAssociatedGroupIds($data['group_association']); - - if (isset($data['shop_association'])) { - $command->setAssociatedShopIds($data['shop_association']); - } - - return $command; - } - - /** - * @param CategoryId $categoryId - * @param UploadedFile $coverImage - * @param UploadedFile $thumbnailImage - * @param UploadedFile[] $menuThumbnailImages - */ - private function uploadImages( - CategoryId $categoryId, - UploadedFile $coverImage = null, - UploadedFile $thumbnailImage = null, - array $menuThumbnailImages = [] - ) { - if (null !== $coverImage) { - $this->categoryCoverUploader->upload($categoryId->getValue(), $coverImage); - } - - if (null !== $thumbnailImage) { - $this->categoryThumbnailUploader->upload($categoryId->getValue(), $thumbnailImage); - } - - if (!empty($menuThumbnailImages)) { - foreach ($menuThumbnailImages as $menuThumbnail) { - $this->categoryMenuThumbnailUploader->upload($categoryId->getValue(), $menuThumbnail); - } - } - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/CmsPageCategoryFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/CmsPageCategoryFormDataHandler.php deleted file mode 100644 index 4cfa04b2..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/CmsPageCategoryFormDataHandler.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\AddCmsPageCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\EditCmsPageCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * Class CmsPageCategoryFormDataHandler is responsible for creating and updating cms page category form data. - */ -final class CmsPageCategoryFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @param CommandBusInterface $commandBus - */ - public function __construct(CommandBusInterface $commandBus) - { - $this->commandBus = $commandBus; - } - - /** - * {@inheritdoc} - * - * @throws CmsPageCategoryException - */ - public function create(array $data) - { - $addCmsPageCategoryCommand = new AddCmsPageCategoryCommand( - $data['name'], - $data['friendly_url'], - (int) $data['parent_category'], - $data['is_displayed'] - ); - - $addCmsPageCategoryCommand - ->setLocalisedDescription($data['description']) - ->setLocalisedMetaDescription($data['meta_description']) - ->setLocalisedMetaKeywords($data['meta_keywords']) - ->setLocalisedMetaTitle($data['meta_title']) - ->setShopAssociation(is_array($data['shop_association']) ? $data['shop_association'] : []) - ; - - /** @var CmsPageCategoryId $result */ - $result = $this->commandBus->handle($addCmsPageCategoryCommand); - - return $result->getValue(); - } - - /** - * {@inheritdoc} - * - * @throws CmsPageCategoryException - */ - public function update($id, array $data) - { - $editCmsPageCategoryCommand = new EditCmsPageCategoryCommand((int) $id); - - $editCmsPageCategoryCommand - ->setLocalisedName($data['name']) - ->setLocalisedFriendlyUrl($data['friendly_url']) - ->setParentId((int) $data['parent_category']) - ->setIsDisplayed($data['is_displayed']) - ->setLocalisedDescription($data['description']) - ->setLocalisedMetaDescription($data['meta_description']) - ->setLocalisedMetaKeywords($data['meta_keywords']) - ->setLocalisedMetaTitle($data['meta_title']) - ->setShopAssociation(is_array($data['shop_association']) ? $data['shop_association'] : []) - ; - - $this->commandBus->handle($editCmsPageCategoryCommand); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/CmsPageFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/CmsPageFormDataHandler.php deleted file mode 100644 index d7bd7380..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/CmsPageFormDataHandler.php +++ /dev/null @@ -1,117 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\AddCmsPageCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\EditCmsPageCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\ValueObject\CmsPageId; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; - -/** - * {@inheritdoc} - */ -final class CmsPageFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @param CommandBusInterface $commandBus - */ - public function __construct(CommandBusInterface $commandBus) - { - $this->commandBus = $commandBus; - } - - /** - * Create object from form data. - * - * @param array $data - * - * @return int - * - * @throws CmsPageCategoryException - */ - public function create(array $data) - { - /** - * @var CmsPageId - */ - $cmsPageId = $this->commandBus->handle(new AddCmsPageCommand( - (int) $data['page_category_id'], - $data['title'], - $data['meta_title'], - $data['meta_description'], - $data['meta_keyword'], - $data['friendly_url'], - $data['content'], - $data['is_indexed_for_search'], - $data['is_displayed'], - is_array($data['shop_association']) ? $data['shop_association'] : [] - )); - - return $cmsPageId->getValue(); - } - - /** - * {@inheritdoc} - * - * @throws CmsPageException - * @throws CmsPageCategoryException - */ - public function update($cmsPageId, array $data) - { - $editCmsPageCommand = new EditCmsPageCommand((int) $cmsPageId); - $this->fillCommandWithData($editCmsPageCommand, $data); - - $this->commandBus->handle($editCmsPageCommand); - } - - /** - * @param EditCmsPageCommand $command - * @param array $data - * - * @throws CmsPageCategoryException - */ - private function fillCommandWithData(EditCmsPageCommand $command, array $data) - { - $command->setCmsPageCategoryId((int) $data['page_category_id']); - $command->setLocalizedTitle($data['title']); - $command->setLocalizedMetaTitle($data['meta_title']); - $command->setLocalizedMetaDescription($data['meta_description']); - $command->setLocalizedMetaKeyword($data['meta_keyword']); - $command->setLocalizedFriendlyUrl($data['friendly_url']); - $command->setLocalizedContent($data['content']); - $command->setIsIndexedForSearch($data['is_indexed_for_search']); - $command->setIsDisplayed($data['is_displayed']); - $command->setShopAssociation($data['shop_association']); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/ContactFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/ContactFormDataHandler.php deleted file mode 100644 index ce84f18d..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/ContactFormDataHandler.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Contact\Command\AddContactCommand; -use PrestaShop\PrestaShop\Core\Domain\Contact\Command\EditContactCommand; -use PrestaShop\PrestaShop\Core\Domain\Contact\ValueObject\ContactId; -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; - -/** - * Class ContactFormDataHandler is responsible for handling create and update of contact form. - */ -final class ContactFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @param CommandBusInterface $commandBus - */ - public function __construct(CommandBusInterface $commandBus) - { - $this->commandBus = $commandBus; - } - - /** - * {@inheritdoc} - * - * @throws DomainException - */ - public function create(array $data) - { - $addContactCommand = (new AddContactCommand($data['title'], $data['is_messages_saving_enabled'])) - ->setLocalisedDescription($data['description']) - ->setShopAssociation(is_array($data['shop_association']) ? $data['shop_association'] : []) - ; - - if ($data['email']) { - $addContactCommand->setEmail($data['email']); - } - - /** @var ContactId $result */ - $result = $this->commandBus->handle($addContactCommand); - - return $result->getValue(); - } - - /** - * {@inheritdoc} - * - * @throws DomainException - */ - public function update($contactId, array $data) - { - $editContactCommand = (new EditContactCommand((int) $contactId)) - ->setLocalisedTitles($data['title']) - ->setIsMessagesSavingEnabled($data['is_messages_saving_enabled']) - ->setLocalisedDescription($data['description']) - ->setShopAssociation(is_array($data['shop_association']) ? $data['shop_association'] : []) - ; - - if ($data['email']) { - $editContactCommand->setEmail($data['email']); - } - - $this->commandBus->handle($editContactCommand); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/CurrencyFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/CurrencyFormDataHandler.php deleted file mode 100644 index 249df58e..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/CurrencyFormDataHandler.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerInterface; -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\AddCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\AddUnofficialCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\EditCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\EditUnofficialCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\CurrencyId; - -/** - * Class CurrencyFormDataHandler - */ -final class CurrencyFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @var CacheClearerInterface[] - */ - private $cacheClearerCollection; - - /** - * @param CommandBusInterface $commandBus - * @param CacheClearerInterface[] $cacheClearerCollection - */ - public function __construct( - CommandBusInterface $commandBus, - array $cacheClearerCollection - ) { - $this->commandBus = $commandBus; - $this->cacheClearerCollection = $cacheClearerCollection; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - if ($data['unofficial']) { - $command = new AddUnofficialCurrencyCommand( - $data['iso_code'], - (float) $data['exchange_rate'], - $data['active'] - ); - } else { - $command = new AddCurrencyCommand( - $data['iso_code'], - (float) $data['exchange_rate'], - $data['active'] - ); - } - - $command - ->setPrecision((int) $data['precision']) - ->setLocalizedNames($data['names']) - ->setLocalizedSymbols($data['symbols']) - ->setLocalizedTransformations($data['transformations']) - ->setShopIds(is_array($data['shop_association']) ? $data['shop_association'] : []) - ; - - /** @var CurrencyId $currencyId */ - $currencyId = $this->commandBus->handle($command); - $this->clearCache(); - - return $currencyId->getValue(); - } - - /** - * {@inheritdoc} - */ - public function update($id, array $data) - { - if ($data['unofficial']) { - $command = new EditUnofficialCurrencyCommand((int) $id); - $command - ->setIsoCode($data['iso_code']) - ; - } else { - $command = new EditCurrencyCommand((int) $id); - } - - $command - ->setLocalizedNames($data['names']) - ->setLocalizedSymbols($data['symbols']) - ->setLocalizedTransformations($data['transformations']) - ->setExchangeRate((float) $data['exchange_rate']) - ->setPrecision((int) $data['precision']) - ->setIsEnabled($data['active']) - ->setShopIds(is_array($data['shop_association']) ? $data['shop_association'] : []) - ; - - $this->commandBus->handle($command); - $this->clearCache(); - } - - /** - * Clear the cache provided - */ - private function clearCache() - { - foreach ($this->cacheClearerCollection as $cacheClearer) { - $cacheClearer->clear(); - } - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/CustomerFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/CustomerFormDataHandler.php deleted file mode 100644 index 268c989c..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/CustomerFormDataHandler.php +++ /dev/null @@ -1,177 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\AddCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\EditCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\Birthday; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerId; - -/** - * Saves or updates customer data submitted in form - */ -final class CustomerFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $bus; - - /** - * @var int - */ - private $contextShopId; - - /** - * @var bool - */ - private $isB2bFeatureEnabled; - - /** - * @param CommandBusInterface $bus - * @param int $contextShopId - * @param bool $isB2bFeatureEnabled - */ - public function __construct( - CommandBusInterface $bus, - $contextShopId, - $isB2bFeatureEnabled - ) { - $this->bus = $bus; - $this->contextShopId = $contextShopId; - $this->isB2bFeatureEnabled = $isB2bFeatureEnabled; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - $command = $this->buildCustomerAddCommandFromFormData($data); - - /** @var CustomerId $customerId */ - $customerId = $this->bus->handle($command); - - return $customerId->getValue(); - } - - /** - * {@inheritdoc} - */ - public function update($customerId, array $data) - { - $command = $this->buildCustomerEditCommand($customerId, $data); - - $this->bus->handle($command); - } - - /** - * @param array $data - * - * @return AddCustomerCommand - */ - private function buildCustomerAddCommandFromFormData(array $data) - { - $groupIds = array_map(function ($groupId) { - return (int) $groupId; - }, $data['group_ids']); - - $command = new AddCustomerCommand( - $data['first_name'], - $data['last_name'], - $data['email'], - $data['password'], - (int) $data['default_group_id'], - $groupIds, - $this->contextShopId, - (int) $data['gender_id'], - (bool) $data['is_enabled'], - (bool) $data['is_partner_offers_subscribed'], - $data['birthday'] ?: Birthday::EMPTY_BIRTHDAY - ); - - if (!$this->isB2bFeatureEnabled) { - return $command; - } - - $command - ->setCompanyName((string) $data['company_name']) - ->setSiretCode((string) $data['siret_code']) - ->setApeCode((string) $data['ape_code']) - ->setWebsite((string) $data['website']) - ->setAllowedOutstandingAmount((float) $data['allowed_outstanding_amount']) - ->setMaxPaymentDays((int) $data['max_payment_days']) - ->setRiskId((int) $data['risk_id']) - ; - - return $command; - } - - /** - * @param int $customerId - * @param array $data - * - * @return EditCustomerCommand - */ - private function buildCustomerEditCommand($customerId, array $data) - { - $groupIds = array_map(function ($groupId) { - return (int) $groupId; - }, $data['group_ids']); - - $command = (new EditCustomerCommand($customerId)) - ->setGenderId($data['gender_id']) - ->setEmail($data['email']) - ->setFirstName($data['first_name']) - ->setLastName($data['last_name']) - ->setIsEnabled($data['is_enabled']) - ->setIsPartnerOffersSubscribed($data['is_partner_offers_subscribed']) - ->setDefaultGroupId((int) $data['default_group_id']) - ->setGroupIds($groupIds) - ->setBirthday($data['birthday'] ?: Birthday::EMPTY_BIRTHDAY) - ; - - if (null !== $data['password']) { - $command->setPassword($data['password']); - } - - if ($this->isB2bFeatureEnabled) { - $command - ->setCompanyName((string) $data['company_name']) - ->setSiretCode((string) $data['siret_code']) - ->setApeCode((string) $data['ape_code']) - ->setWebsite((string) $data['website']) - ->setAllowedOutstandingAmount((float) $data['allowed_outstanding_amount']) - ->setMaxPaymentDays((int) $data['max_payment_days']) - ->setRiskId((int) $data['risk_id']) - ; - } - - return $command; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/EmployeeFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/EmployeeFormDataHandler.php deleted file mode 100644 index 42143d5c..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/EmployeeFormDataHandler.php +++ /dev/null @@ -1,197 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Crypto\Hashing; -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\AddEmployeeCommand; -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\EditEmployeeCommand; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\EmployeeId; -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\Password; -use PrestaShop\PrestaShop\Core\Employee\Access\EmployeeFormAccessCheckerInterface; -use PrestaShop\PrestaShop\Core\Employee\EmployeeDataProviderInterface; - -/** - * Handles submitted employee form's data. - */ -final class EmployeeFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $bus; - - /** - * @var array - */ - private $defaultShopAssociation; - - /** - * @var int - */ - private $superAdminProfileId; - - /** - * @var EmployeeFormAccessCheckerInterface - */ - private $employeeFormAccessChecker; - - /** - * @var EmployeeDataProviderInterface - */ - private $employeeDataProvider; - - /** - * @var Hashing - */ - private $hashing; - - /** - * @param CommandBusInterface $bus - * @param array $defaultShopAssociation - * @param int $superAdminProfileId - * @param EmployeeFormAccessCheckerInterface $employeeFormAccessChecker - * @param EmployeeDataProviderInterface $employeeDataProvider - * @param Hashing $hashing - */ - public function __construct( - CommandBusInterface $bus, - array $defaultShopAssociation, - $superAdminProfileId, - EmployeeFormAccessCheckerInterface $employeeFormAccessChecker, - EmployeeDataProviderInterface $employeeDataProvider, - Hashing $hashing - ) { - $this->bus = $bus; - $this->defaultShopAssociation = $defaultShopAssociation; - $this->superAdminProfileId = $superAdminProfileId; - $this->employeeFormAccessChecker = $employeeFormAccessChecker; - $this->employeeDataProvider = $employeeDataProvider; - $this->hashing = $hashing; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - // Super admins have access to all shops and that cannot be changed by the user. - if ($data['profile'] == $this->superAdminProfileId) { - $data['shop_association'] = $this->defaultShopAssociation; - } - - /** @var EmployeeId $employeeId */ - $employeeId = $this->bus->handle(new AddEmployeeCommand( - $data['firstname'], - $data['lastname'], - $data['email'], - $data['password'], - $data['default_page'], - $data['language'], - $data['active'], - $data['profile'], - isset($data['shop_association']) ? $data['shop_association'] : $this->defaultShopAssociation - )); - - return $employeeId->getValue(); - } - - /** - * {@inheritdoc} - */ - public function update($id, array $data) - { - $command = (new EditEmployeeCommand($id)) - ->setFirstName($data['firstname']) - ->setLastName($data['lastname']) - ->setEmail($data['email']) - ->setDefaultPageId((int) $data['default_page']) - ->setLanguageId((int) $data['language']) - ->setActive((bool) $data['active']) - ->setProfileId((int) $data['profile']) - ; - - if ($this->employeeFormAccessChecker->isRestrictedAccess((int) $id)) { - if ($this->shouldChangePassword($data)) { - $this->assertPasswordIsSameAsOldPassword( - $data['change_password']['old_password'], - $id - ); - - $command->setPlainPassword($data['change_password']['new_password']); - } - } elseif (isset($data['password'])) { - $command->setPlainPassword($data['password']); - } - - if (isset($data['shop_association'])) { - $shopAssociation = $data['shop_association'] ?: []; - $command->setShopAssociation( - array_map(function ($shopId) { return (int) $shopId; }, $shopAssociation) - ); - } - - $this->bus->handle($command); - } - - /** - * Asserts if given password is the same as employee's password. - * - * @param string $plainPassword - * @param int $employeeId - * - * @throws EmployeeConstraintException - */ - private function assertPasswordIsSameAsOldPassword($plainPassword, $employeeId) - { - $oldPassword = $this->employeeDataProvider->getEmployeeHashedPassword($employeeId); - - if (!$this->hashing->checkHash($plainPassword, $oldPassword)) { - throw new EmployeeConstraintException('Old and new passwords do not match.', EmployeeConstraintException::INCORRECT_PASSWORD); - } - } - - /** - * Checks if all required fields are present in form data for changing the password. - * - * @param array $formData - * - * @return bool - */ - private function shouldChangePassword(array $formData) - { - if (!isset($formData['change_password'])) { - return false; - } - - return - null !== $formData['change_password']['old_password'] && - null !== $formData['change_password']['new_password'] - ; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/FeatureFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/FeatureFormDataHandler.php deleted file mode 100644 index 66195112..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/FeatureFormDataHandler.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Feature\Command\AddFeatureCommand; -use PrestaShop\PrestaShop\Core\Domain\Feature\Command\EditFeatureCommand; -use PrestaShop\PrestaShop\Core\Domain\Feature\ValueObject\FeatureId; - -/** - * Handles data of submitted Feature form. - */ -final class FeatureFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @param CommandBusInterface $commandBus - */ - public function __construct(CommandBusInterface $commandBus) - { - $this->commandBus = $commandBus; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - /** @var FeatureId $featureId */ - $featureId = $this->commandBus->handle(new AddFeatureCommand( - $data['name'], - $data['shop_association'] ?? [] - )); - - return $featureId->getValue(); - } - - /** - * {@inheritdoc} - */ - public function update($id, array $data) - { - $command = new EditFeatureCommand($id); - $command->setLocalizedNames($data['name']); - - if (isset($data['shop_association'])) { - $command->setAssociatedShopIds($data['shop_association']); - } - - $this->commandBus->handle($command); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/FormDataHandlerInterface.php b/src/Core/Form/IdentifiableObject/DataHandler/FormDataHandlerInterface.php deleted file mode 100644 index 84c8e2ef..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/FormDataHandlerInterface.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -/** - * Interface IdentifiableObjectFormDataHandlerInterface. - */ -interface FormDataHandlerInterface -{ - /** - * Create object from form data. - * - * @param array $data - * - * @return mixed ID of identifiable object - */ - public function create(array $data); - - /** - * Update object with form data. - * - * @param int $id - * @param array $data - */ - public function update($id, array $data); -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/LanguageFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/LanguageFormDataHandler.php deleted file mode 100644 index 26e72128..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/LanguageFormDataHandler.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Language\Command\AddLanguageCommand; -use PrestaShop\PrestaShop\Core\Domain\Language\Command\EditLanguageCommand; -use PrestaShop\PrestaShop\Core\Domain\Language\ValueObject\LanguageId; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Handles submitted language form data - */ -final class LanguageFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $bus; - - /** - * @param CommandBusInterface $bus - */ - public function __construct(CommandBusInterface $bus) - { - $this->bus = $bus; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - if (!isset($data['shop_association']) || !$data['shop_association']) { - $data['shop_association'] = []; - } - - /** @var UploadedFile $uploadedFlagImage */ - $uploadedFlagImage = $data['flag_image']; - /** @var UploadedFile $uploadedFlagImage */ - $uploadedNoPictureImage = $data['no_picture_image']; - - /** @var LanguageId $languageId */ - $languageId = $this->bus->handle(new AddLanguageCommand( - $data['name'], - $data['iso_code'], - $data['tag_ietf'], - $data['short_date_format'], - $data['full_date_format'], - $uploadedFlagImage->getPathname(), - $uploadedNoPictureImage->getPathname(), - $data['is_rtl'], - $data['is_active'], - $data['shop_association'] - )); - - return $languageId->getValue(); - } - - /** - * {@inheritdoc} - */ - public function update($languageId, array $data) - { - $command = (new EditLanguageCommand($languageId)) - ->setName((string) $data['name']) - ->setIsoCode((string) $data['iso_code']) - ->setTagIETF((string) $data['tag_ietf']) - ->setShortDateFormat((string) $data['short_date_format']) - ->setFullDateFormat((string) $data['full_date_format']) - ->setIsRtl($data['is_rtl']) - ->setIsActive($data['is_active']) - ; - - if ($data['flag_image'] instanceof UploadedFile) { - $command->setFlagImagePath($data['flag_image']->getPathname()); - } - - if ($data['no_picture_image'] instanceof UploadedFile) { - $command->setNoPictureImagePath($data['no_picture_image']->getPathname()); - } - - if (isset($data['shop_association'])) { - $shopAssociation = $data['shop_association'] ?: []; - $shopAssociation = array_map(function ($shopId) { return (int) $shopId; }, $shopAssociation); - - $command->setShopAssociation($shopAssociation); - } - - $this->bus->handle($command); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/ManufacturerAddressFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/ManufacturerAddressFormDataHandler.php deleted file mode 100644 index c97cbac0..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/ManufacturerAddressFormDataHandler.php +++ /dev/null @@ -1,139 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\AddManufacturerAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\EditManufacturerAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\ValueObject\AddressId; - -/** - * Handles submitted manufacturer address form data - */ -final class ManufacturerAddressFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @param CommandBusInterface $commandBus - */ - public function __construct(CommandBusInterface $commandBus) - { - $this->commandBus = $commandBus; - } - - /** - * {@inheritdoc] - */ - public function create(array $data) - { - /** @var AddressId $addressId */ - $addressId = $this->commandBus->handle(new AddManufacturerAddressCommand( - $data['last_name'], - $data['first_name'], - $data['address'], - $data['id_country'], - $data['city'], - $data['id_manufacturer'], - $data['address2'], - $data['post_code'], - $data['id_state'], - $data['home_phone'], - $data['mobile_phone'], - $data['other'], - $data['dni'] - )); - - return $addressId->getValue(); - } - - /** - * {@inheritdoc} - */ - public function update($addressId, array $data) - { - $command = new EditManufacturerAddressCommand((int) $addressId); - $this->fillCommandWithData($command, $data); - - $this->commandBus->handle($command); - } - - /** - * Fills EditManufacturerAddressCommand with form data - * - * @param EditManufacturerAddressCommand $command - * @param array $data - * - * @throws AddressConstraintException - */ - private function fillCommandWithData(EditManufacturerAddressCommand $command, array $data) - { - if (null !== $data['id_manufacturer']) { - $command->setManufacturerId($data['id_manufacturer']); - } - if (null !== $data['last_name']) { - $command->setLastName($data['last_name']); - } - if (null !== $data['first_name']) { - $command->setFirstName($data['first_name']); - } - if (null !== $data['address']) { - $command->setAddress($data['address']); - } - if (null !== $data['id_country']) { - $command->setCountryId($data['id_country']); - } - if (null !== $data['city']) { - $command->setCity($data['city']); - } - if (null !== $data['address2']) { - $command->setAddress2($data['address2']); - } - if (null !== $data['post_code']) { - $command->setPostCode($data['post_code']); - } - if (null !== $data['id_state']) { - $command->setStateId($data['id_state']); - } - if (null !== $data['home_phone']) { - $command->setHomePhone($data['home_phone']); - } - if (null !== $data['mobile_phone']) { - $command->setMobilePhone($data['mobile_phone']); - } - if (null !== $data['other']) { - $command->setOther($data['other']); - } - if (null !== $data['dni']) { - $command->setDni($data['dni']); - } - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/ManufacturerFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/ManufacturerFormDataHandler.php deleted file mode 100644 index 4cacd737..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/ManufacturerFormDataHandler.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\AddManufacturerCommand; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\EditManufacturerCommand; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\ValueObject\ManufacturerId; -use PrestaShop\PrestaShop\Core\Image\Uploader\ImageUploaderInterface; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Handles submitted manufacturer form data - */ -final class ManufacturerFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $bus; - /** - * @var ImageUploaderInterface - */ - private $imageUploader; - - /** - * @param CommandBusInterface $bus - * @param ImageUploaderInterface $imageUploader - */ - public function __construct( - CommandBusInterface $bus, - ImageUploaderInterface $imageUploader - ) { - $this->bus = $bus; - $this->imageUploader = $imageUploader; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - if (!isset($data['shop_association']) || !$data['shop_association']) { - $data['shop_association'] = []; - } - - /** @var ManufacturerId $manufacturerId */ - $manufacturerId = $this->bus->handle(new AddManufacturerCommand( - $data['name'], - $data['is_enabled'], - $data['short_description'], - $data['description'], - $data['meta_title'], - $data['meta_description'], - $data['meta_keyword'], - $data['shop_association'] - )); - - /** @var UploadedFile $uploadedFlagImage */ - $uploadedLogo = $data['logo']; - - if ($uploadedLogo instanceof UploadedFile) { - $this->imageUploader->upload($manufacturerId->getValue(), $uploadedLogo); - } - - return $manufacturerId->getValue(); - } - - /** - * {@inheritdoc} - */ - public function update($manufacturerId, array $data) - { - /** @var UploadedFile $uploadedFlagImage */ - $uploadedLogo = $data['logo']; - $logo = null; - - if ($uploadedLogo instanceof UploadedFile) { - $this->imageUploader->upload($manufacturerId, $uploadedLogo); - } - - $command = (new EditManufacturerCommand($manufacturerId)) - ->setName((string) $data['name']) - ->setLocalizedShortDescriptions($data['short_description']) - ->setLocalizedDescriptions($data['description']) - ->setLocalizedMetaDescriptions($data['meta_description']) - ->setLocalizedMetaTitles($data['meta_title']) - ->setLocalizedMetaKeywords($data['meta_keyword']) - ->setEnabled((bool) $data['is_enabled']) - ; - - if (isset($data['shop_association'])) { - $shopAssociation = $data['shop_association'] ?: []; - $shopAssociation = array_map(function ($shopId) { return (int) $shopId; }, $shopAssociation); - - $command->setAssociatedShops($shopAssociation); - } - - $this->bus->handle($command); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/MetaFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/MetaFormDataHandler.php deleted file mode 100644 index 54767bd3..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/MetaFormDataHandler.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Meta\Command\AddMetaCommand; -use PrestaShop\PrestaShop\Core\Domain\Meta\Command\EditMetaCommand; -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaException; -use PrestaShop\PrestaShop\Core\Domain\Meta\ValueObject\MetaId; - -/** - * Class MetaFormDataHandler is responsible to handle creation and update logic for meta form. - */ -final class MetaFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @param CommandBusInterface $commandBus - */ - public function __construct(CommandBusInterface $commandBus) - { - $this->commandBus = $commandBus; - } - - /** - * {@inheritdoc} - * - * @throws MetaException - */ - public function create(array $data) - { - $addMetaCommand = (new AddMetaCommand($data['page_name'])) - ->setLocalisedPageTitle($data['page_title']) - ->setLocalisedMetaDescription($data['meta_description']) - ->setLocalisedMetaKeywords($data['meta_keywords']) - ->setLocalisedRewriteUrls($data['url_rewrite']) - ; - - /** @var MetaId $metaId */ - $metaId = $this->commandBus->handle($addMetaCommand); - - return $metaId->getValue(); - } - - /** - * {@inheritdoc} - * - * @throws MetaException - */ - public function update($metaId, array $data) - { - $editMetaCommand = (new EditMetaCommand((int) $metaId)) - ->setPageName($data['page_name']) - ->setLocalisedPageTitles($data['page_title']) - ->setLocalisedMetaDescriptions($data['meta_description']) - ->setLocalisedMetaKeywords($data['meta_keywords']) - ->setLocalisedRewriteUrls($data['url_rewrite']) - ; - - $this->commandBus->handle($editMetaCommand); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/OrderAddressFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/OrderAddressFormDataHandler.php deleted file mode 100644 index 7669df7d..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/OrderAddressFormDataHandler.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\EditOrderAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\InvalidAddressTypeException; -use PrestaShop\PrestaShop\Core\Domain\Order\Exception\OrderException; -use PrestaShop\PrestaShop\Core\Domain\State\Exception\StateConstraintException; - -class OrderAddressFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @param CommandBusInterface $commandBus - */ - public function __construct(CommandBusInterface $commandBus) - { - $this->commandBus = $commandBus; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - // Not used for creation, only edition - } - - /** - * {@inheritdoc} - * - * @throws CountryConstraintException - * @throws StateConstraintException - * @throws InvalidAddressTypeException - * @throws OrderException - */ - public function update($orderId, array $data) - { - $editAddressCommand = new EditOrderAddressCommand($orderId, $data['address_type']); - - if (isset($data['alias'])) { - $editAddressCommand->setAddressAlias($data['alias']); - } - - if (isset($data['first_name'])) { - $editAddressCommand->setFirstName($data['first_name']); - } - - if (isset($data['last_name'])) { - $editAddressCommand->setLastName($data['last_name']); - } - - if (isset($data['address1'])) { - $editAddressCommand->setAddress($data['address1']); - } - - if (isset($data['city'])) { - $editAddressCommand->setCity($data['city']); - } - - if (isset($data['id_country'])) { - $editAddressCommand->setCountryId((int) $data['id_country']); - } - - if (isset($data['postcode'])) { - $editAddressCommand->setPostCode($data['postcode']); - } - - if (isset($data['dni'])) { - $editAddressCommand->setDni($data['dni']); - } - - if (isset($data['company'])) { - $editAddressCommand->setCompany($data['company']); - } - - if (isset($data['vat_number'])) { - $editAddressCommand->setVatNumber($data['vat_number']); - } - - if (isset($data['address2'])) { - $editAddressCommand->setAddress2($data['address2']); - } - - if (isset($data['id_state'])) { - $editAddressCommand->setStateId((int) $data['id_state']); - } - - if (isset($data['phone'])) { - $editAddressCommand->setHomePhone($data['phone']); - } - - if (isset($data['phone_mobile'])) { - $editAddressCommand->setMobilePhone($data['phone_mobile']); - } - - if (isset($data['other'])) { - $editAddressCommand->setOther($data['other']); - } - - $this->commandBus->handle($editAddressCommand); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/OrderMessageFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/OrderMessageFormDataHandler.php deleted file mode 100644 index fd06b1e8..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/OrderMessageFormDataHandler.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command\AddOrderMessageCommand; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command\EditOrderMessageCommand; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\ValueObject\OrderMessageId; - -/** - * Handles data that was submitted with order message form - */ -final class OrderMessageFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @param CommandBusInterface $commandBus - */ - public function __construct(CommandBusInterface $commandBus) - { - $this->commandBus = $commandBus; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - /** @var OrderMessageId $orderMessageId */ - $orderMessageId = $this->commandBus->handle(new AddOrderMessageCommand($data['name'], $data['message'])); - - return $orderMessageId->getValue(); - } - - /** - * {@inheritdoc} - */ - public function update($orderMessageId, array $data) - { - $this->commandBus->handle(new EditOrderMessageCommand($orderMessageId, $data['name'], $data['message'])); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/PartialRefundFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/PartialRefundFormDataHandler.php deleted file mode 100644 index 79af6a8e..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/PartialRefundFormDataHandler.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\IssuePartialRefundCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\VoucherRefundType; - -/** - * Class PartialRefundFormDataHandler - */ -final class PartialRefundFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @param CommandBusInterface $commandBus - */ - public function __construct(CommandBusInterface $commandBus) - { - $this->commandBus = $commandBus; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - return; - } - - /** - * {@inheritdoc} - */ - public function update($id, array $data) - { - $refunds = []; - foreach ($data['products'] as $product) { - $orderDetailId = $product->getOrderDetailId(); - if (!empty($data['quantity_' . $orderDetailId]) || !empty((float) $data['amount_' . $orderDetailId])) { - $refunds[$orderDetailId]['quantity'] = $data['quantity_' . $orderDetailId] ?? 0; - $refunds[$orderDetailId]['amount'] = $data['amount_' . $orderDetailId] ?? 0; - } - } - - $command = new IssuePartialRefundCommand( - $id, - $refunds, - $data['shipping_amount'], - $data['restock'], - $data['credit_slip'], - $data['voucher'], - $data['voucher_refund_type'] ?? VoucherRefundType::PRODUCT_PRICES_EXCLUDING_VOUCHER_REFUND - ); - - $this->commandBus->handle($command); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/ProfileFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/ProfileFormDataHandler.php deleted file mode 100644 index 8f878664..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/ProfileFormDataHandler.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Profile\Command\AddProfileCommand; -use PrestaShop\PrestaShop\Core\Domain\Profile\Command\EditProfileCommand; -use PrestaShop\PrestaShop\Core\Domain\Profile\ValueObject\ProfileId; - -/** - * Saves or updates Profile using form data - */ -final class ProfileFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $bus; - - /** - * @param CommandBusInterface $bus - */ - public function __construct(CommandBusInterface $bus) - { - $this->bus = $bus; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - /** @var ProfileId $profileId */ - $profileId = $this->bus->handle(new AddProfileCommand($data['name'])); - - return $profileId->getValue(); - } - - /** - * {@inheritdoc} - */ - public function update($profileId, array $data) - { - /* @var ProfileId $profileId */ - $this->bus->handle(new EditProfileCommand($profileId, $data['name'])); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/ReturnProductFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/ReturnProductFormDataHandler.php deleted file mode 100644 index 35b18043..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/ReturnProductFormDataHandler.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\IssueReturnProductCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\VoucherRefundType; - -class ReturnProductFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @param CommandBusInterface $commandBus - */ - public function __construct(CommandBusInterface $commandBus) - { - $this->commandBus = $commandBus; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - return; - } - - /** - * {@inheritdoc} - */ - public function update($id, array $data) - { - $refunds = []; - foreach ($data['products'] as $product) { - $orderDetailId = $product->getOrderDetailId(); - if (!isset($data['selected_' . $orderDetailId]) || !(bool) $data['selected_' . $orderDetailId]) { - continue; - } - $refunds[$orderDetailId]['quantity'] = $data['quantity_' . $orderDetailId] ?? 0; - } - - $command = new IssueReturnProductCommand( - $id, - $refunds, - $data['restock'], - $data['shipping'], - $data['credit_slip'], - $data['voucher'], - $data['voucher_refund_type'] ?? VoucherRefundType::PRODUCT_PRICES_EXCLUDING_VOUCHER_REFUND - ); - - $this->commandBus->handle($command); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/RootCategoryFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/RootCategoryFormDataHandler.php deleted file mode 100644 index 99274db2..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/RootCategoryFormDataHandler.php +++ /dev/null @@ -1,189 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\AddRootCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\EditRootCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; -use PrestaShop\PrestaShop\Core\Image\Uploader\ImageUploaderInterface; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Creates/updates root category from data submited in category form - */ -final class RootCategoryFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @var ImageUploaderInterface - */ - private $categoryCoverUploader; - - /** - * @var ImageUploaderInterface - */ - private $categoryThumbnailUploader; - - /** - * @var ImageUploaderInterface - */ - private $categoryMenuThumbnailUploader; - - /** - * @param CommandBusInterface $commandBus - * @param ImageUploaderInterface $categoryCoverUploader - * @param ImageUploaderInterface $categoryThumbnailUploader - * @param ImageUploaderInterface $categoryMenuThumbnailUploader - */ - public function __construct( - CommandBusInterface $commandBus, - ImageUploaderInterface $categoryCoverUploader, - ImageUploaderInterface $categoryThumbnailUploader, - ImageUploaderInterface $categoryMenuThumbnailUploader - ) { - $this->commandBus = $commandBus; - $this->categoryCoverUploader = $categoryCoverUploader; - $this->categoryThumbnailUploader = $categoryThumbnailUploader; - $this->categoryMenuThumbnailUploader = $categoryMenuThumbnailUploader; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - $command = $this->createAddRootCategoryCommand($data); - - /** @var CategoryId $categoryId */ - $categoryId = $this->commandBus->handle($command); - - $this->uploadImages( - $categoryId->getValue(), - $data['cover_image'], - $data['thumbnail_image'], - $data['menu_thumbnail_images'] - ); - - return $categoryId->getValue(); - } - - /** - * {@inheritdoc} - */ - public function update($rootCategoryId, array $data) - { - $command = $this->createEditRootCategoryCommand($rootCategoryId, $data); - - $this->commandBus->handle($command); - - $this->uploadImages( - $rootCategoryId, - $data['cover_image'], - $data['thumbnail_image'], - $data['menu_thumbnail_images'] - ); - } - - /** - * Creates command with form data for adding new root category - * - * @param array $data - * - * @return AddRootCategoryCommand - */ - public function createAddRootCategoryCommand(array $data) - { - $command = new AddRootCategoryCommand( - $data['name'], - $data['link_rewrite'], - $data['active'] - ); - - $command->setLocalizedDescriptions($data['description']); - $command->setLocalizedMetaTitles($data['meta_title']); - $command->setLocalizedMetaDescriptions($data['meta_description']); - $command->setLocalizedMetaKeywords($data['meta_keyword']); - $command->setAssociatedGroupIds($data['group_association']); - $command->setAssociatedShopIds($data['shop_association']); - - return $command; - } - - /** - * @param int $rootCategoryId - * @param array $data - * - * @return EditRootCategoryCommand - */ - private function createEditRootCategoryCommand($rootCategoryId, array $data) - { - $command = new EditRootCategoryCommand($rootCategoryId); - $command->setIsActive($data['active']); - $command->setLocalizedLinkRewrites($data['link_rewrite']); - $command->setLocalizedNames($data['name']); - $command->setLocalizedDescriptions($data['description']); - $command->setLocalizedMetaTitles($data['meta_title']); - $command->setLocalizedMetaDescriptions($data['meta_description']); - $command->setLocalizedMetaKeywords($data['meta_keyword']); - $command->setAssociatedGroupIds($data['group_association']); - $command->setAssociatedShopIds($data['shop_association']); - - return $command; - } - - /** - * @param int $categoryId - * @param UploadedFile $coverImage - * @param UploadedFile $thumbnailImage - * @param UploadedFile[] $menuThumbnailImages - */ - private function uploadImages( - $categoryId, - UploadedFile $coverImage = null, - UploadedFile $thumbnailImage = null, - array $menuThumbnailImages = [] - ) { - if (null !== $coverImage) { - $this->categoryCoverUploader->upload($categoryId, $coverImage); - } - - if (null !== $thumbnailImage) { - $this->categoryThumbnailUploader->upload($categoryId, $thumbnailImage); - } - - if (!empty($menuThumbnailImages)) { - foreach ($menuThumbnailImages as $menuThumbnail) { - $this->categoryMenuThumbnailUploader->upload($categoryId, $menuThumbnail); - } - } - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/SqlRequestFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/SqlRequestFormDataHandler.php deleted file mode 100644 index 88f26acd..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/SqlRequestFormDataHandler.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\AddSqlRequestCommand; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\EditSqlRequestCommand; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\ValueObject\SqlRequestId; - -/** - * Creates or updates SqlRequest objects using form data. - */ -final class SqlRequestFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @param CommandBusInterface $bus - */ - public function __construct(CommandBusInterface $bus) - { - $this->commandBus = $bus; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - /** @var SqlRequestId $sqlRequestId */ - $sqlRequestId = $this->commandBus->handle(new AddSqlRequestCommand($data['name'], $data['sql'])); - - return $sqlRequestId->getValue(); - } - - /** - * {@inheritdoc} - */ - public function update($id, array $data) - { - $sqlRequestId = new SqlRequestId($id); - - $command = (new EditSqlRequestCommand($sqlRequestId)) - ->setName($data['name']) - ->setSql($data['sql']); - - $this->commandBus->handle($command); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/StandardRefundFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/StandardRefundFormDataHandler.php deleted file mode 100644 index 195ca99f..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/StandardRefundFormDataHandler.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Command\IssueStandardRefundCommand; -use PrestaShop\PrestaShop\Core\Domain\Order\VoucherRefundType; - -/** - * Class StandardRefundFormDataHandler - */ -final class StandardRefundFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @param CommandBusInterface $commandBus - */ - public function __construct(CommandBusInterface $commandBus) - { - $this->commandBus = $commandBus; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - return; - } - - /** - * {@inheritdoc} - */ - public function update($id, array $data) - { - $refunds = []; - foreach ($data['products'] as $product) { - $orderDetailId = $product->getOrderDetailId(); - if (!isset($data['selected_' . $orderDetailId]) || !(bool) $data['selected_' . $orderDetailId]) { - continue; - } - $refunds[$orderDetailId]['quantity'] = $data['quantity_' . $orderDetailId] ?? 0; - } - - $command = new IssueStandardRefundCommand( - $id, - $refunds, - $data['shipping'], - $data['credit_slip'], - $data['voucher'], - $data['voucher_refund_type'] ?? VoucherRefundType::PRODUCT_PRICES_EXCLUDING_VOUCHER_REFUND - ); - - $this->commandBus->handle($command); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/SupplierFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/SupplierFormDataHandler.php deleted file mode 100644 index 1dd5e322..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/SupplierFormDataHandler.php +++ /dev/null @@ -1,179 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\AddSupplierCommand; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\EditSupplierCommand; -use PrestaShop\PrestaShop\Core\Domain\Supplier\ValueObject\SupplierId; -use PrestaShop\PrestaShop\Core\Image\Uploader\ImageUploaderInterface; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Handles submitted supplier form data - */ -final class SupplierFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - /** - * @var ImageUploaderInterface - */ - private $imageUploader; - - /** - * @param CommandBusInterface $commandBus - * @param ImageUploaderInterface $imageUploader - */ - public function __construct( - CommandBusInterface $commandBus, - ImageUploaderInterface $imageUploader - ) { - $this->commandBus = $commandBus; - $this->imageUploader = $imageUploader; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - if (!isset($data['shop_association']) || !$data['shop_association']) { - $data['shop_association'] = []; - } - - /** @var SupplierId $supplierId */ - $supplierId = $this->commandBus->handle(new AddSupplierCommand( - $data['name'], - $data['address'], - $data['city'], - (int) $data['id_country'], - (bool) $data['is_enabled'], - $data['description'], - $data['meta_title'], - $data['meta_description'], - $data['meta_keyword'], - $data['shop_association'], - $data['address2'], - $data['post_code'], - isset($data['id_state']) ? (int) $data['id_state'] : null, - $data['phone'], - $data['mobile_phone'], - $data['dni'] - )); - - /** @var UploadedFile $uploadedFlagImage */ - $uploadedLogo = $data['logo']; - - if ($uploadedLogo instanceof UploadedFile) { - $this->imageUploader->upload($supplierId->getValue(), $uploadedLogo); - } - - return $supplierId->getValue(); - } - - /** - * {@inheritdoc} - */ - public function update($supplierId, array $data) - { - /** @var UploadedFile $uploadedFlagImage */ - $uploadedLogo = $data['logo']; - $logo = null; - - if ($uploadedLogo instanceof UploadedFile) { - $this->imageUploader->upload($supplierId, $uploadedLogo); - } - - $command = new EditSupplierCommand($supplierId); - $this->fillCommandWithData($command, $data); - - $this->commandBus->handle($command); - } - - /** - * Fills command with provided data - * - * @param EditSupplierCommand $command - * @param array $data - */ - private function fillCommandWithData(EditSupplierCommand $command, array $data) - { - if (null !== $data['name']) { - $command->setName($data['name']); - } - if (null !== $data['description']) { - $command->setLocalizedDescriptions($data['description']); - } - if (null !== $data['phone']) { - $command->setPhone($data['phone']); - } - if (null !== $data['mobile_phone']) { - $command->setMobilePhone($data['mobile_phone']); - } - if (null !== $data['address']) { - $command->setAddress($data['address']); - } - if (null !== $data['address2']) { - $command->setAddress2($data['address2']); - } - if (null !== $data['post_code']) { - $command->setPostCode($data['post_code']); - } - if (null !== $data['city']) { - $command->setCity($data['city']); - } - if (null !== $data['id_country']) { - $command->setCountryId((int) $data['id_country']); - } - if (null !== $data['meta_title']) { - $command->setLocalizedMetaTitles($data['meta_title']); - } - if (null !== $data['meta_description']) { - $command->setLocalizedMetaDescriptions($data['meta_description']); - } - if (null !== $data['is_enabled']) { - $command->setEnabled((bool) $data['is_enabled']); - } - if (null !== $data['dni']) { - $command->setDni($data['dni']); - } - - if (isset($data['id_state'])) { - $command->setStateId((int) $data['id_state']); - } - - if (isset($data['shop_association'])) { - $shopAssociation = $data['shop_association'] ?: []; - $shopAssociation = array_map(function ($shopId) { return (int) $shopId; }, $shopAssociation); - - $command->setAssociatedShops($shopAssociation); - } - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/TaxFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/TaxFormDataHandler.php deleted file mode 100644 index 8f81eb8d..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/TaxFormDataHandler.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\AddTaxCommand; -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\EditTaxCommand; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxException; -use PrestaShop\PrestaShop\Core\Domain\Tax\ValueObject\TaxId; - -/** - * Handles submitted tax form data - */ -final class TaxFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - public function __construct(CommandBusInterface $commandBus) - { - $this->commandBus = $commandBus; - } - - /** - * Create object from form data. - * - * @param array $data - * - * @return mixed - */ - public function create(array $data) - { - $command = new AddTaxCommand( - $data['name'], - (float) $data['rate'], - (bool) $data['is_enabled'] - ); - - /** @var TaxId $taxId */ - $taxId = $this->commandBus->handle($command); - - return $taxId->getValue(); - } - - /** - * {@inheritdoc} - * - * @throws TaxException - */ - public function update($id, array $data) - { - $command = (new EditTaxCommand($id)) - ->setLocalizedNames($data['name']) - ->setRate((float) $data['rate']) - ->setEnabled((bool) $data['is_enabled']) - ; - - $this->commandBus->handle($command); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataHandler/WebserviceKeyFormDataHandler.php b/src/Core/Form/IdentifiableObject/DataHandler/WebserviceKeyFormDataHandler.php deleted file mode 100644 index 7335031e..00000000 --- a/src/Core/Form/IdentifiableObject/DataHandler/WebserviceKeyFormDataHandler.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Webservice\Command\AddWebserviceKeyCommand; -use PrestaShop\PrestaShop\Core\Domain\Webservice\Command\EditWebserviceKeyCommand; -use PrestaShop\PrestaShop\Core\Domain\Webservice\ValueObject\WebserviceKeyId; - -/** - * Creates/updates webservice key with submited form data - */ -final class WebserviceKeyFormDataHandler implements FormDataHandlerInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @var int - */ - private $contextShopId; - - /** - * @param CommandBusInterface $commandBus - * @param int $contextShopId - */ - public function __construct(CommandBusInterface $commandBus, $contextShopId) - { - $this->commandBus = $commandBus; - $this->contextShopId = $contextShopId; - } - - /** - * {@inheritdoc} - */ - public function create(array $data) - { - if (!isset($data['shop_association'])) { - $data['shop_association'] = [(int) $this->contextShopId]; - } - - /** @var WebserviceKeyId $webserviceKeyId */ - $webserviceKeyId = $this->commandBus->handle(new AddWebserviceKeyCommand( - $data['key'], - $data['description'], - $data['status'], - $data['permissions'], - $data['shop_association'] - )); - - return $webserviceKeyId->getValue(); - } - - /** - * {@inheritdoc} - */ - public function update($weserviceKeyId, array $data) - { - $editCommand = new EditWebserviceKeyCommand($weserviceKeyId); - $editCommand - ->setKey($data['key']) - ->setDescription($data['description']) - ->setStatus($data['status']) - ->setPermissions($data['permissions']) - ; - - if (isset($data['shop_association'])) { - $editCommand->setShopAssociation($data['shop_association']); - } - - $this->commandBus->handle($editCommand); - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/AddressFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/AddressFormDataProvider.php deleted file mode 100644 index d0d345ec..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/AddressFormDataProvider.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\Query\GetCustomerAddressForEditing; -use PrestaShop\PrestaShop\Core\Domain\Address\QueryResult\EditableCustomerAddress; - -/** - * Provides data for address add/edit form - */ -final class AddressFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @var int - */ - private $defaultCountryId; - - /** - * @param CommandBusInterface $queryBus - * @param int $defaultCountryId - */ - public function __construct(CommandBusInterface $queryBus, int $defaultCountryId) - { - $this->queryBus = $queryBus; - $this->defaultCountryId = $defaultCountryId; - } - - /** - * {@inheritdoc} - * - * @throws AddressConstraintException - */ - public function getData($addressId) - { - /** @var EditableCustomerAddress $editableAddress */ - $editableAddress = $this->queryBus->handle(new GetCustomerAddressForEditing((int) $addressId)); - - $data = [ - 'id_customer' => $editableAddress->getCustomerId()->getValue(), - 'customer_email' => $editableAddress->getCustomerEmail(), - 'dni' => $editableAddress->getDni(), - 'alias' => $editableAddress->getAddressAlias(), - 'first_name' => $editableAddress->getFirstName(), - 'last_name' => $editableAddress->getLastName(), - 'company' => $editableAddress->getCompany(), - 'vat_number' => $editableAddress->getVatNumber(), - 'address1' => $editableAddress->getAddress(), - 'address2' => $editableAddress->getAddress2(), - 'city' => $editableAddress->getCity(), - 'postcode' => $editableAddress->getPostCode(), - 'id_country' => $editableAddress->getCountryId()->getValue(), - 'id_state' => $editableAddress->getStateId()->getValue(), - 'phone' => $editableAddress->getHomePhone(), - 'phone_mobile' => $editableAddress->getMobilePhone(), - 'other' => $editableAddress->getOther(), - ]; - - return $data; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - return [ - 'id_country' => $this->defaultCountryId, - ]; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/AttachmentFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/AttachmentFormDataProvider.php deleted file mode 100644 index 0542489f..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/AttachmentFormDataProvider.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Query\GetAttachmentForEditing; -use PrestaShop\PrestaShop\Core\Domain\Attachment\QueryResult\EditableAttachment; - -/** - * Provides data for attachment add/edit forms - */ -final class AttachmentFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @param CommandBusInterface $queryBus - */ - public function __construct(CommandBusInterface $queryBus) - { - $this->queryBus = $queryBus; - } - - /** - * {@inheritdoc} - */ - public function getData($attachmentId) - { - /** @var EditableAttachment $editableAttachment */ - $editableAttachment = $this->queryBus->handle(new GetAttachmentForEditing((int) $attachmentId)); - - $data = [ - 'name' => $editableAttachment->getName(), - 'file_name' => $editableAttachment->getFileName(), - 'file_description' => $editableAttachment->getDescription(), - ]; - - return $data; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - return []; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/CancelProductFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/CancelProductFormDataProvider.php deleted file mode 100644 index aef7fe04..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/CancelProductFormDataProvider.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Currency\CurrencyDataProviderInterface; -use PrestaShop\PrestaShop\Core\Domain\Order\Query\GetOrderForViewing; -use PrestaShop\PrestaShop\Core\Domain\Order\QueryResult\OrderForViewing; -use PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision; - -/** - * Provides data for product cancellation form in order page - */ -final class CancelProductFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @var CurrencyDataProviderInterface - */ - private $currencyDataProvider; - - /** - * @param CommandBusInterface $queryBus - * @param CurrencyDataProviderInterface $currencyDataProvider - */ - public function __construct( - CommandBusInterface $queryBus, - CurrencyDataProviderInterface $currencyDataProvider - ) { - $this->queryBus = $queryBus; - $this->currencyDataProvider = $currencyDataProvider; - } - - /** - * {@inheritdoc} - */ - public function getData($orderId) - { - /** @var OrderForViewing $orderForViewing */ - $orderForViewing = $this->queryBus->handle(new GetOrderForViewing((int) $orderId)); - $computingPrecision = new ComputingPrecision(); - $currency = $this->currencyDataProvider->getCurrencyById($orderForViewing->getCurrencyId()); - - return [ - 'products' => $orderForViewing->getProducts()->getProducts(), - 'taxMethod' => $orderForViewing->getTaxMethod(), - 'precision' => $computingPrecision->getPrecision($currency->precision), - ]; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - return []; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/CatalogPriceRuleFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/CatalogPriceRuleFormDataProvider.php deleted file mode 100644 index e67ca64d..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/CatalogPriceRuleFormDataProvider.php +++ /dev/null @@ -1,108 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Query\GetCatalogPriceRuleForEditing; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\QueryResult\editableCatalogPriceRule; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Reduction; - -/** - * Provides data for catalog price rule add/edit forms - */ -final class CatalogPriceRuleFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @param CommandBusInterface $queryBus - */ - public function __construct(CommandBusInterface $queryBus) - { - $this->queryBus = $queryBus; - } - - /** - * {@inheritdoc} - */ - public function getData($catalogPriceRuleId) - { - /** @var editableCatalogPriceRule $editableCatalogPriceRule */ - $editableCatalogPriceRule = $this->queryBus->handle(new GetCatalogPriceRuleForEditing((int) $catalogPriceRuleId)); - - $dateTimeFormat = 'Y-m-d H:i:s'; - $price = $editableCatalogPriceRule->getPrice(); - $leaveInitialPrice = false; - $from = $editableCatalogPriceRule->getFrom(); - $to = $editableCatalogPriceRule->getTo(); - - if ($price->isLowerOrEqualThanZero()) { - $price = null; - $leaveInitialPrice = true; - } - - $data = [ - 'name' => $editableCatalogPriceRule->getName(), - 'id_shop' => $editableCatalogPriceRule->getShopId(), - 'id_currency' => $editableCatalogPriceRule->getCurrencyId(), - 'id_country' => $editableCatalogPriceRule->getCountryId(), - 'id_group' => $editableCatalogPriceRule->getGroupId(), - 'from_quantity' => $editableCatalogPriceRule->getFromQuantity(), - 'price' => null === $price ? $price : (string) $price, - 'leave_initial_price' => $leaveInitialPrice, - 'date_range' => [ - 'from' => $from ? $from->format($dateTimeFormat) : '', - 'to' => $to ? $to->format($dateTimeFormat) : '', - ], - 'include_tax' => $editableCatalogPriceRule->isTaxIncluded(), - 'reduction' => [ - 'type' => $editableCatalogPriceRule->getReduction()->getType(), - 'value' => (string) $editableCatalogPriceRule->getReduction()->getValue(), - ], - ]; - - return $data; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - return [ - 'from_quantity' => 1, - 'leave_initial_price' => true, - 'reduction' => [ - 'type' => Reduction::TYPE_AMOUNT, - 'value' => 0, - ], - ]; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/CategoryFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/CategoryFormDataProvider.php deleted file mode 100644 index 32cb8d0d..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/CategoryFormDataProvider.php +++ /dev/null @@ -1,117 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Category\Query\GetCategoryForEditing; -use PrestaShop\PrestaShop\Core\Domain\Category\QueryResult\EditableCategory; -use PrestaShop\PrestaShop\Core\Group\Provider\DefaultGroupsProviderInterface; - -/** - * Provides data for category add/edit category forms - */ -final class CategoryFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @var int - */ - private $contextShopId; - - /** - * @var int - */ - private $contextShopRootCategoryId; - - /** - * @var DefaultGroupsProviderInterface - */ - private $defaultGroupsProvider; - - /** - * @param CommandBusInterface $queryBus - * @param int $contextShopId - * @param int $contextShopRootCategoryId - * @param DefaultGroupsProviderInterface $defaultGroupsProvider - */ - public function __construct( - CommandBusInterface $queryBus, - $contextShopId, - $contextShopRootCategoryId, - DefaultGroupsProviderInterface $defaultGroupsProvider - ) { - $this->queryBus = $queryBus; - $this->contextShopId = $contextShopId; - $this->contextShopRootCategoryId = $contextShopRootCategoryId; - $this->defaultGroupsProvider = $defaultGroupsProvider; - } - - /** - * {@inheritdoc} - */ - public function getData($categoryId) - { - /** @var EditableCategory $editableCategory */ - $editableCategory = $this->queryBus->handle(new GetCategoryForEditing($categoryId)); - - return [ - 'name' => $editableCategory->getName(), - 'active' => $editableCategory->isActive(), - 'id_parent' => $editableCategory->getParentId(), - 'description' => $editableCategory->getDescription(), - 'meta_title' => $editableCategory->getMetaTitle(), - 'meta_description' => $editableCategory->getMetaDescription(), - 'meta_keyword' => $editableCategory->getMetaKeywords(), - 'link_rewrite' => $editableCategory->getLinkRewrite(), - 'group_association' => $editableCategory->getGroupAssociationIds(), - 'shop_association' => $editableCategory->getShopAssociationIds(), - ]; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - $defaultGroups = $this->defaultGroupsProvider->getGroups(); - - return [ - 'id_parent' => $this->contextShopRootCategoryId, - 'group_association' => [ - $defaultGroups->getVisitorsGroup()->getId(), - $defaultGroups->getGuestsGroup()->getId(), - $defaultGroups->getCustomersGroup()->getId(), - ], - 'shop_association' => $this->contextShopId, - 'active' => true, - ]; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/CmsPageCategoryFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/CmsPageCategoryFormDataProvider.php deleted file mode 100644 index 13ee3dcf..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/CmsPageCategoryFormDataProvider.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query\GetCmsPageCategoryForEditing; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\QueryResult\EditableCmsPageCategory; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -final class CmsPageCategoryFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @var array - */ - private $contextShopIds; - - /** - * @param CommandBusInterface $queryBus - * @param array $contextShopIds - */ - public function __construct(CommandBusInterface $queryBus, array $contextShopIds) - { - $this->queryBus = $queryBus; - $this->contextShopIds = $contextShopIds; - } - - /** - * {@inheritdoc} - * - * @throws CmsPageCategoryException - */ - public function getData($id) - { - /** @var EditableCmsPageCategory $editableCmsPageCategory */ - $editableCmsPageCategory = $this->queryBus->handle(new GetCmsPageCategoryForEditing($id)); - - return [ - 'name' => $editableCmsPageCategory->getLocalisedName(), - 'is_displayed' => $editableCmsPageCategory->isDisplayed(), - 'parent_category' => $editableCmsPageCategory->getParentId()->getValue(), - 'description' => $editableCmsPageCategory->getLocalisedDescription(), - 'meta_title' => $editableCmsPageCategory->getMetaTitle(), - 'meta_description' => $editableCmsPageCategory->getLocalisedMetaDescription(), - 'meta_keywords' => $editableCmsPageCategory->getLocalisedMetaKeywords(), - 'friendly_url' => $editableCmsPageCategory->getLocalisedFriendlyUrl(), - 'shop_association' => $editableCmsPageCategory->getShopIds(), - ]; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - return [ - 'parent_category' => CmsPageCategoryId::ROOT_CMS_PAGE_CATEGORY_ID, - 'shop_association' => $this->contextShopIds, - 'is_displayed' => true, - ]; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/CmsPageFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/CmsPageFormDataProvider.php deleted file mode 100644 index fde3a4e2..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/CmsPageFormDataProvider.php +++ /dev/null @@ -1,98 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Query\GetCmsPageForEditing; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\QueryResult\EditableCmsPage; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; - -/** - * {@inheritdoc} - */ -class CmsPageFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @var array - */ - private $contextShopIds; - - /** - * @param CommandBusInterface $queryBus - * @param array $contextShopIds - */ - public function __construct(CommandBusInterface $queryBus, array $contextShopIds) - { - $this->queryBus = $queryBus; - $this->contextShopIds = $contextShopIds; - } - - /** - * {@inheritdoc} - * - * @throws CmsPageException - */ - public function getData($cmsPageId) - { - /** @var EditableCmsPage $editableCmsPage */ - $editableCmsPage = $this->queryBus->handle(new GetCmsPageForEditing($cmsPageId)); - - return [ - 'page_category_id' => $editableCmsPage->getCmsPageCategoryId()->getValue(), - 'title' => $editableCmsPage->getLocalizedTitle(), - 'meta_title' => $editableCmsPage->getLocalizedMetaTitle(), - 'meta_description' => $editableCmsPage->getLocalizedMetaDescription(), - 'meta_keyword' => $editableCmsPage->getLocalizedMetaKeyword(), - 'friendly_url' => $editableCmsPage->getLocalizedFriendlyUrl(), - 'content' => $editableCmsPage->getLocalizedContent(), - 'is_indexed_for_search' => $editableCmsPage->isIndexedForSearch(), - 'is_displayed' => $editableCmsPage->isDisplayed(), - 'shop_association' => $editableCmsPage->getShopAssociation(), - ]; - } - - /** - * Get default form data. - * - * @return mixed - */ - public function getDefaultData() - { - return [ - 'page_category_id' => CmsPageCategoryId::ROOT_CMS_PAGE_CATEGORY_ID, - 'shop_association' => $this->contextShopIds, - 'is_indexed_for_search' => false, - 'is_displayed' => false, - ]; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/ContactFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/ContactFormDataProvider.php deleted file mode 100644 index 0ddca683..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/ContactFormDataProvider.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\ContactException; -use PrestaShop\PrestaShop\Core\Domain\Contact\Query\GetContactForEditing; -use PrestaShop\PrestaShop\Core\Domain\Contact\QueryResult\EditableContact; -use Symfony\Component\Form\DataTransformerInterface; - -/** - * Class ContactFormDataProvider is responsible for providing form data for contacts by contact id or by giving default - * values. - */ -final class ContactFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @var array - */ - private $contextShopIds; - - /** - * @var DataTransformerInterface - */ - private $stringArrayToIntegerArrayDataTransformer; - - /** - * @param CommandBusInterface $queryBus - * @param DataTransformerInterface $stringArrayToIntegerArrayDataTransformer - * @param int[] $contextShopIds - */ - public function __construct( - CommandBusInterface $queryBus, - DataTransformerInterface $stringArrayToIntegerArrayDataTransformer, - array $contextShopIds - ) { - $this->queryBus = $queryBus; - $this->contextShopIds = $contextShopIds; - $this->stringArrayToIntegerArrayDataTransformer = $stringArrayToIntegerArrayDataTransformer; - } - - /** - * {@inheritdoc} - * - * @throws ContactException - */ - public function getData($contactId) - { - /** @var EditableContact $editableContact */ - $editableContact = $this->queryBus->handle(new GetContactForEditing($contactId)); - - return [ - 'title' => $editableContact->getLocalisedTitles(), - 'email' => null !== $editableContact->getEmail() ? $editableContact->getEmail()->getValue() : '', - 'is_messages_saving_enabled' => $editableContact->isMessagesSavingEnabled(), - 'description' => $editableContact->getLocalisedDescription(), - 'shop_association' => $editableContact->getShopAssociation(), - ]; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - $shopIds = $this->stringArrayToIntegerArrayDataTransformer->reverseTransform($this->contextShopIds); - - return [ - 'shop_association' => $shopIds, - ]; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/CurrencyFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/CurrencyFormDataProvider.php deleted file mode 100644 index c1962899..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/CurrencyFormDataProvider.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetCurrencyForEditing; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\ExchangeRate; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\Precision; - -/** - * Class CurrencyFormDataProvider - */ -final class CurrencyFormDataProvider implements FormDataProviderInterface -{ - /** - * @var array - */ - private $contextShopIds; - - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @param CommandBusInterface $queryBus - * @param array $contextShopIds - */ - public function __construct(CommandBusInterface $queryBus, array $contextShopIds) - { - $this->contextShopIds = $contextShopIds; - $this->queryBus = $queryBus; - } - - /** - * {@inheritdoc} - */ - public function getData($id) - { - /** @var \PrestaShop\PrestaShop\Core\Domain\Currency\QueryResult\EditableCurrency $result */ - $result = $this->queryBus->handle(new GetCurrencyForEditing((int) $id)); - - return [ - 'id' => $id, - 'iso_code' => $result->getIsoCode(), - 'names' => $result->getNames(), - 'symbols' => $result->getSymbols(), - 'transformations' => $result->getTransformations(), - 'exchange_rate' => $result->getExchangeRate(), - 'precision' => $result->getPrecision(), - 'shop_association' => $result->getAssociatedShopIds(), - 'active' => $result->isEnabled(), - 'unofficial' => $result->isUnofficial(), - ]; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - return [ - 'precision' => Precision::DEFAULT_PRECISION, - 'exchange_rate' => ExchangeRate::DEFAULT_RATE, - 'shop_association' => $this->contextShopIds, - ]; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/CustomerFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/CustomerFormDataProvider.php deleted file mode 100644 index 477e791b..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/CustomerFormDataProvider.php +++ /dev/null @@ -1,141 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerForEditing; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\EditableCustomer; -use PrestaShop\PrestaShop\Core\Group\Provider\DefaultGroupsProviderInterface; - -/** - * Provides data for customer forms - */ -final class CustomerFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var DefaultGroupsProviderInterface - */ - private $defaultGroupsProvider; - - /** - * @var bool - */ - private $isB2bFeatureEnabled; - - /** - * @param CommandBusInterface $queryBus - * @param ConfigurationInterface $configuration - * @param DefaultGroupsProviderInterface $defaultGroupsProvider - * @param bool $isB2bFeatureEnabled - */ - public function __construct( - CommandBusInterface $queryBus, - ConfigurationInterface $configuration, - DefaultGroupsProviderInterface $defaultGroupsProvider, - $isB2bFeatureEnabled - ) { - $this->queryBus = $queryBus; - $this->configuration = $configuration; - $this->defaultGroupsProvider = $defaultGroupsProvider; - $this->isB2bFeatureEnabled = $isB2bFeatureEnabled; - } - - /** - * {@inheritdoc} - */ - public function getData($customerId) - { - /** @var EditableCustomer $editableCustomer */ - $editableCustomer = $this->queryBus->handle(new GetCustomerForEditing((int) $customerId)); - $birthday = $editableCustomer->getBirthday(); - - $data = [ - 'gender_id' => $editableCustomer->getGenderId(), - 'first_name' => $editableCustomer->getFirstName()->getValue(), - 'last_name' => $editableCustomer->getLastName()->getValue(), - 'email' => $editableCustomer->getEmail()->getValue(), - 'birthday' => $birthday->isEmpty() ? null : $birthday->getValue(), - 'is_enabled' => $editableCustomer->isEnabled(), - 'is_partner_offers_subscribed' => $editableCustomer->isPartnerOffersSubscribed(), - 'group_ids' => $editableCustomer->getGroupIds(), - 'default_group_id' => $editableCustomer->getDefaultGroupId(), - ]; - - if ($this->isB2bFeatureEnabled) { - $data = array_merge($data, [ - 'company_name' => $editableCustomer->getCompanyName(), - 'siret_code' => $editableCustomer->getSiretCode(), - 'ape_code' => $editableCustomer->getApeCode(), - 'website' => $editableCustomer->getWebsite(), - 'allowed_outstanding_amount' => $editableCustomer->getAllowedOutstandingAmount(), - 'max_payment_days' => $editableCustomer->getMaxPaymentDays(), - 'risk_id' => $editableCustomer->getRiskId(), - ]); - } - - return $data; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - $defaultGroups = $this->defaultGroupsProvider->getGroups(); - - $data = [ - 'is_enabled' => true, - 'is_partner_offers_subscribed' => false, - 'group_ids' => [ - $defaultGroups->getVisitorsGroup()->getId(), - $defaultGroups->getGuestsGroup()->getId(), - $defaultGroups->getCustomersGroup()->getId(), - ], - 'default_group_id' => (int) $this->configuration->get('PS_CUSTOMER_GROUP'), - ]; - - if ($this->isB2bFeatureEnabled) { - $data = array_merge($data, [ - 'allowed_outstanding_amount' => 0, - 'max_payment_days' => 0, - ]); - } - - return $data; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/EmployeeFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/EmployeeFormDataProvider.php deleted file mode 100644 index 62c33eb9..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/EmployeeFormDataProvider.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Employee\Query\GetEmployeeForEditing; -use PrestaShop\PrestaShop\Core\Domain\Employee\QueryResult\EditableEmployee; - -/** - * Provides data for employee forms. - */ -final class EmployeeFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @var bool - */ - private $isMultistoreFeatureActive; - - /** - * @var array - */ - private $defaultShopAssociation; - - /** - * @param CommandBusInterface $queryBus - * @param bool $isMultistoreFeatureActive - * @param array $defaultShopAssociation - */ - public function __construct( - CommandBusInterface $queryBus, - $isMultistoreFeatureActive, - array $defaultShopAssociation - ) { - $this->queryBus = $queryBus; - $this->isMultistoreFeatureActive = $isMultistoreFeatureActive; - $this->defaultShopAssociation = $defaultShopAssociation; - } - - /** - * {@inheritdoc} - */ - public function getData($employeeId) - { - /** @var EditableEmployee $editableEmployee */ - $editableEmployee = $this->queryBus->handle(new GetEmployeeForEditing((int) $employeeId)); - - return [ - 'firstname' => $editableEmployee->getFirstName()->getValue(), - 'lastname' => $editableEmployee->getLastName()->getValue(), - 'email' => $editableEmployee->getEmail()->getValue(), - 'default_page' => $editableEmployee->getDefaultPageId(), - 'language' => $editableEmployee->getLanguageId(), - 'active' => $editableEmployee->isActive(), - 'profile' => $editableEmployee->getProfileId(), - 'shop_association' => $editableEmployee->getShopAssociation(), - ]; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - $data = [ - 'active' => true, - ]; - - if ($this->isMultistoreFeatureActive) { - $data['shop_association'] = $this->defaultShopAssociation; - } - - return $data; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/FeatureFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/FeatureFormDataProvider.php deleted file mode 100644 index 3c860e8b..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/FeatureFormDataProvider.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Feature\Query\GetFeatureForEditing; -use PrestaShop\PrestaShop\Core\Domain\Feature\QueryResult\EditableFeature; - -/** - * Provides data for feature forms. - */ -final class FeatureFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @var bool - */ - private $isMultistoreFeatureActive; - - /** - * @var array - */ - private $defaultShopAssociation; - - /** - * @param CommandBusInterface $queryBus - * @param bool $isMultistoreFeatureActive - * @param array $defaultShopAssociation - */ - public function __construct( - CommandBusInterface $queryBus, - $isMultistoreFeatureActive, - array $defaultShopAssociation - ) { - $this->queryBus = $queryBus; - $this->isMultistoreFeatureActive = $isMultistoreFeatureActive; - $this->defaultShopAssociation = $defaultShopAssociation; - } - - /** - * {@inheritdoc} - */ - public function getData($id) - { - /** @var EditableFeature $editableFeature */ - $editableFeature = $this->queryBus->handle(new GetFeatureForEditing((int) $id)); - - return [ - 'name' => $editableFeature->getName(), - 'shop_association' => $editableFeature->getShopAssociationIds(), - ]; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - $data = []; - - if ($this->isMultistoreFeatureActive) { - $data['shop_association'] = $this->defaultShopAssociation; - } - - return $data; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/FormDataProviderInterface.php b/src/Core/Form/IdentifiableObject/DataProvider/FormDataProviderInterface.php deleted file mode 100644 index 56feafe4..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/FormDataProviderInterface.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -/** - * Interface for services that provide data form identifiable object forms. - */ -interface FormDataProviderInterface -{ - /** - * Get form data for given object with given id. - * - * @param int $id - * - * @return mixed - */ - public function getData($id); - - /** - * Get default form data. - * - * @return mixed - */ - public function getDefaultData(); -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/LanguageFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/LanguageFormDataProvider.php deleted file mode 100644 index ebdcb204..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/LanguageFormDataProvider.php +++ /dev/null @@ -1,111 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Language\Query\GetLanguageForEditing; -use PrestaShop\PrestaShop\Core\Domain\Language\QueryResult\EditableLanguage; - -/** - * Provides data for language's add/edit forms - */ -final class LanguageFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $bus; - - /** - * @var bool - */ - private $isMultistoreFeatureActive; - - /** - * @var int[] - */ - private $defaultShopAssociation; - - /** - * @param CommandBusInterface $bus - * @param bool $isMultistoreFeatureActive - * @param int[] $defaultShopAssociation - */ - public function __construct( - CommandBusInterface $bus, - $isMultistoreFeatureActive, - array $defaultShopAssociation - ) { - $this->bus = $bus; - $this->isMultistoreFeatureActive = $isMultistoreFeatureActive; - $this->defaultShopAssociation = $defaultShopAssociation; - } - - /** - * {@inheritdoc} - */ - public function getData($languageId) - { - /** @var EditableLanguage $editableLanguage */ - $editableLanguage = $this->bus->handle(new GetLanguageForEditing($languageId)); - - $data = [ - 'name' => $editableLanguage->getName(), - 'iso_code' => $editableLanguage->getIsoCode()->getValue(), - 'tag_ietf' => $editableLanguage->getTagIETF()->getValue(), - 'short_date_format' => $editableLanguage->getShortDateFormat(), - 'full_date_format' => $editableLanguage->getFullDateFormat(), - 'is_rtl' => $editableLanguage->isRtl(), - 'is_active' => $editableLanguage->isActive(), - ]; - - if ($this->isMultistoreFeatureActive) { - $data['shop_association'] = $editableLanguage->getShopAssociation(); - } - - return $data; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - $data = [ - 'short_date_format' => 'Y-m-d', - 'full_date_format' => 'Y-m-d H:i:s', - 'is_rtl' => false, - 'is_active' => true, - ]; - - if ($this->isMultistoreFeatureActive) { - $data['shop_association'] = $this->defaultShopAssociation; - } - - return $data; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/ManufacturerAddressFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/ManufacturerAddressFormDataProvider.php deleted file mode 100644 index 6b7c0fde..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/ManufacturerAddressFormDataProvider.php +++ /dev/null @@ -1,98 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\Query\GetManufacturerAddressForEditing; -use PrestaShop\PrestaShop\Core\Domain\Address\QueryResult\EditableManufacturerAddress; - -/** - * Provides data for address add/edit form - */ -final class ManufacturerAddressFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @var int - */ - private $defaultCountryId; - - /** - * @param CommandBusInterface $queryBus - * @param $defaultCountryId - */ - public function __construct( - CommandBusInterface $queryBus, - $defaultCountryId - ) { - $this->queryBus = $queryBus; - $this->defaultCountryId = $defaultCountryId; - } - - /** - * {@inheritdoc} - * - * @throws AddressConstraintException - */ - public function getData($addressId) - { - /** @var EditableManufacturerAddress $editableAddress */ - $editableAddress = $this->queryBus->handle(new GetManufacturerAddressForEditing((int) $addressId)); - $manufacturerId = $editableAddress->getManufacturerId(); - - return [ - 'id_manufacturer' => $manufacturerId, - 'last_name' => $editableAddress->getLastName(), - 'first_name' => $editableAddress->getFirstName(), - 'address' => $editableAddress->getAddress(), - 'city' => $editableAddress->getCity(), - 'address2' => $editableAddress->getAddress2(), - 'id_country' => $editableAddress->getCountryId(), - 'post_code' => $editableAddress->getPostCode(), - 'id_state' => $editableAddress->getStateId(), - 'home_phone' => $editableAddress->getHomePhone(), - 'mobile_phone' => $editableAddress->getMobilePhone(), - 'other' => $editableAddress->getOther(), - 'dni' => $editableAddress->getDni(), - ]; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - return [ - 'id_country' => $this->defaultCountryId, - ]; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/ManufacturerFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/ManufacturerFormDataProvider.php deleted file mode 100644 index 900c6faf..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/ManufacturerFormDataProvider.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Query\GetManufacturerForEditing; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\QueryResult\EditableManufacturer; - -/** - * Provides data for manufacturers add/edit forms - */ -final class ManufacturerFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $bus; - - /** - * @var bool - */ - private $multistoreEnabled; - - /** - * @var int[] - */ - private $defaultShopAssociation; - - /** - * @param CommandBusInterface $bus - * @param $multistoreEnabled - * @param int[] $defaultShopAssociation - */ - public function __construct( - CommandBusInterface $bus, - $multistoreEnabled, - array $defaultShopAssociation - ) { - $this->bus = $bus; - $this->multistoreEnabled = $multistoreEnabled; - $this->defaultShopAssociation = $defaultShopAssociation; - } - - /** - * {@inheritdoc} - */ - public function getData($manufacturerId) - { - /** @var EditableManufacturer $editableManufacturer */ - $editableManufacturer = $this->bus->handle(new GetManufacturerForEditing((int) $manufacturerId)); - - $data = [ - 'name' => $editableManufacturer->getName(), - 'short_description' => $editableManufacturer->getLocalizedShortDescriptions(), - 'description' => $editableManufacturer->getLocalizedDescriptions(), - 'meta_title' => $editableManufacturer->getLocalizedMetaTitles(), - 'meta_description' => $editableManufacturer->getLocalizedMetaDescriptions(), - 'meta_keyword' => $editableManufacturer->getLocalizedMetaKeywords(), - 'is_enabled' => $editableManufacturer->isEnabled(), - ]; - - if ($this->multistoreEnabled) { - $data['shop_association'] = $editableManufacturer->getAssociatedShops(); - } - - return $data; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - $data['is_enabled'] = true; - - if ($this->multistoreEnabled) { - $data['shop_association'] = $this->defaultShopAssociation; - } - - return $data; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/MetaFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/MetaFormDataProvider.php deleted file mode 100644 index d333277d..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/MetaFormDataProvider.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaException; -use PrestaShop\PrestaShop\Core\Domain\Meta\Query\GetMetaForEditing; -use PrestaShop\PrestaShop\Core\Domain\Meta\QueryResult\EditableMeta; - -/** - * Class MetaFormDataProvider is responsible for providing required data for meta form. - */ -final class MetaFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - public function __construct(CommandBusInterface $queryBus) - { - $this->queryBus = $queryBus; - } - - /** - * {@inheritdoc} - * - * @throws MetaException - */ - public function getData($metaId) - { - /** @var EditableMeta $result */ - $result = $this->queryBus->handle(new GetMetaForEditing((int) $metaId)); - - return [ - 'page_name' => $result->getPageName()->getValue(), - 'page_title' => $result->getLocalisedPageTitles(), - 'meta_description' => $result->getLocalisedMetaDescriptions(), - 'meta_keywords' => $result->getLocalisedMetaKeywords(), - 'url_rewrite' => $result->getLocalisedUrlRewrites(), - ]; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - return null; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/OrderMessageFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/OrderMessageFormDataProvider.php deleted file mode 100644 index 30a1f733..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/OrderMessageFormDataProvider.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Query\GetOrderMessageForEditing; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\QueryResult\EditableOrderMessage; - -/** - * Provides add/edit data for order message form - */ -final class OrderMessageFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @param CommandBusInterface $queryBus - */ - public function __construct(CommandBusInterface $queryBus) - { - $this->queryBus = $queryBus; - } - - /** - * {@inheritdoc} - */ - public function getData($orderMessageId) - { - /** @var EditableOrderMessage $editableOrderMessage */ - $editableOrderMessage = $this->queryBus->handle(new GetOrderMessageForEditing((int) $orderMessageId)); - - return [ - 'name' => $editableOrderMessage->getLocalizedName(), - 'message' => $editableOrderMessage->getLocalizedMessage(), - ]; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - return []; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/ProfileFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/ProfileFormDataProvider.php deleted file mode 100644 index 28366874..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/ProfileFormDataProvider.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Profile\Query\GetProfileForEditing; -use PrestaShop\PrestaShop\Core\Domain\Profile\QueryResult\EditableProfile; - -/** - * Provides data for Profile form - */ -final class ProfileFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @param CommandBusInterface $queryBus - */ - public function __construct(CommandBusInterface $queryBus) - { - $this->queryBus = $queryBus; - } - - /** - * {@inheritdoc} - */ - public function getData($profileId) - { - /** @var EditableProfile $editableProfile */ - $editableProfile = $this->queryBus->handle(new GetProfileForEditing($profileId)); - - return [ - 'name' => $editableProfile->getLocalizedNames(), - ]; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - return []; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/SqlRequestFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/SqlRequestFormDataProvider.php deleted file mode 100644 index bd4da1d0..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/SqlRequestFormDataProvider.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\EditableSqlRequest; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetSqlRequestForEditing; - -/** - * Provides data for SqlRequest forms. - */ -final class SqlRequestFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @param CommandBusInterface $queryBus - */ - public function __construct(CommandBusInterface $queryBus) - { - $this->queryBus = $queryBus; - } - - /** - * {@inheritdoc} - */ - public function getData($id) - { - $getRequestSqlForEditingQuery = new GetSqlRequestForEditing($id); - - /** @var EditableSqlRequest $editableSqlRequest */ - $editableSqlRequest = $this->queryBus->handle($getRequestSqlForEditingQuery); - - return [ - 'id' => $editableSqlRequest->getSqlRequestId()->getValue(), - 'name' => $editableSqlRequest->getName(), - 'sql' => $editableSqlRequest->getSql(), - ]; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - return null; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/SupplierFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/SupplierFormDataProvider.php deleted file mode 100644 index 271b0a90..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/SupplierFormDataProvider.php +++ /dev/null @@ -1,127 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Query\GetSupplierForEditing; -use PrestaShop\PrestaShop\Core\Domain\Supplier\QueryResult\EditableSupplier; - -/** - * Provides data for suppliers add/edit forms - */ -final class SupplierFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @var bool - */ - private $multistoreEnabled; - - /** - * @var int[] - */ - private $defaultShopAssociation; - - /** - * @var int - */ - private $contextCountryId; - - /** - * @param CommandBusInterface $queryBus - * @param $multistoreEnabled - * @param int[] $defaultShopAssociation - * @param int $contextCountryId - */ - public function __construct( - CommandBusInterface $queryBus, - $multistoreEnabled, - array $defaultShopAssociation, - $contextCountryId - ) { - $this->queryBus = $queryBus; - $this->multistoreEnabled = $multistoreEnabled; - $this->defaultShopAssociation = $defaultShopAssociation; - $this->contextCountryId = $contextCountryId; - } - - /** - * {@inheritdoc} - * - * @throws SupplierException - */ - public function getData($supplierId) - { - /** @var EditableSupplier $editableSupplier */ - $editableSupplier = $this->queryBus->handle(new GetSupplierForEditing((int) $supplierId)); - - $data = [ - 'name' => $editableSupplier->getName(), - 'description' => $editableSupplier->getLocalizedDescriptions(), - 'phone' => $editableSupplier->getPhone(), - 'mobile_phone' => $editableSupplier->getMobilePhone(), - 'address' => $editableSupplier->getAddress(), - 'address2' => $editableSupplier->getAddress2(), - 'post_code' => $editableSupplier->getPostCode(), - 'city' => $editableSupplier->getCity(), - 'id_country' => $editableSupplier->getCountryId(), - 'id_state' => $editableSupplier->getStateId(), - 'meta_title' => $editableSupplier->getLocalizedMetaTitles(), - 'meta_description' => $editableSupplier->getLocalizedMetaDescriptions(), - 'meta_keyword' => $editableSupplier->getLocalizedMetaKeywords(), - 'is_enabled' => $editableSupplier->isEnabled(), - 'dni' => $editableSupplier->getDni(), - ]; - - if ($this->multistoreEnabled) { - $data['shop_association'] = $editableSupplier->getAssociatedShops(); - } - - return $data; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - $data['is_enabled'] = false; - $data['id_country'] = $this->contextCountryId; - - if ($this->multistoreEnabled) { - $data['shop_association'] = $this->defaultShopAssociation; - } - - return $data; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/TaxFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/TaxFormDataProvider.php deleted file mode 100644 index 9276802f..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/TaxFormDataProvider.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Tax\Query\GetTaxForEditing; -use PrestaShop\PrestaShop\Core\Domain\Tax\QueryResult\EditableTax; - -/** - * Provides Data for tax add/edit form - */ -final class TaxFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @param CommandBusInterface $queryBus - */ - public function __construct(CommandBusInterface $queryBus) - { - $this->queryBus = $queryBus; - } - - /** - * {@inheritdoc} - */ - public function getData($taxId) - { - /** @var EditableTax $editableTax */ - $editableTax = $this->queryBus->handle(new GetTaxForEditing($taxId)); - - return [ - 'name' => $editableTax->getLocalizedNames(), - 'rate' => $editableTax->getRate(), - 'is_enabled' => $editableTax->isActive(), - ]; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - return [ - 'is_enabled' => false, - ]; - } -} diff --git a/src/Core/Form/IdentifiableObject/DataProvider/WebserviceKeyFormDataProvider.php b/src/Core/Form/IdentifiableObject/DataProvider/WebserviceKeyFormDataProvider.php deleted file mode 100644 index 0782fab8..00000000 --- a/src/Core/Form/IdentifiableObject/DataProvider/WebserviceKeyFormDataProvider.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\Webservice\Query\GetWebserviceKeyForEditing; -use PrestaShop\PrestaShop\Core\Domain\Webservice\QueryResult\EditableWebserviceKey; - -/** - * Provides data for webservice key form - */ -final class WebserviceKeyFormDataProvider implements FormDataProviderInterface -{ - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @var int[] - */ - private $shopIds; - - /** - * @param CommandBusInterface $queryBus - * @param int[] $shopIds - */ - public function __construct(CommandBusInterface $queryBus, array $shopIds) - { - $this->queryBus = $queryBus; - $this->shopIds = $shopIds; - } - - /** - * {@inheritdoc} - */ - public function getData($webserviceKeyId) - { - /** @var EditableWebserviceKey $editableWebserviceKey */ - $editableWebserviceKey = $this->queryBus->handle(new GetWebserviceKeyForEditing($webserviceKeyId)); - - return [ - 'key' => $editableWebserviceKey->getKey(), - 'description' => $editableWebserviceKey->getDescription(), - 'status' => $editableWebserviceKey->getStatus(), - 'permissions' => $this->normalizeResourcePermissions( - $editableWebserviceKey->getResourcePermissions() - ), - 'shop_association' => $editableWebserviceKey->getAssociatedShops(), - ]; - } - - /** - * {@inheritdoc} - */ - public function getDefaultData() - { - return [ - 'status' => true, - 'shop_association' => $this->shopIds, - ]; - } - - /** - * Normalizes resource permissions to be in format that is accepted by form - * - * @param array $resourcePermissions - * - * @return array - */ - private function normalizeResourcePermissions(array $resourcePermissions) - { - $normalizedResourcePermissions = []; - - foreach ($resourcePermissions as $resource => $permissions) { - foreach ($permissions as $permission) { - $normalizedResourcePermissions[$permission][] = $resource; - } - } - - return $normalizedResourcePermissions; - } -} diff --git a/src/Core/Form/IdentifiableObject/Handler/FormHandler.php b/src/Core/Form/IdentifiableObject/Handler/FormHandler.php deleted file mode 100644 index 36d96ed2..00000000 --- a/src/Core/Form/IdentifiableObject/Handler/FormHandler.php +++ /dev/null @@ -1,177 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler; - -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\FormDataHandlerInterface; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\Form\FormError; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Handles identifiable object form and delegates form data saving to data handler. - */ -final class FormHandler implements FormHandlerInterface -{ - /** - * @var FormDataHandlerInterface - */ - private $dataHandler; - - /** - * @var HookDispatcherInterface - */ - private $hookDispatcher; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var bool - */ - private $isDemoModeEnabled; - - /** - * @param FormDataHandlerInterface $dataHandler - * @param HookDispatcherInterface $hookDispatcher - * @param TranslatorInterface $translator - * @param bool $isDemoModeEnabled - */ - public function __construct( - FormDataHandlerInterface $dataHandler, - HookDispatcherInterface $hookDispatcher, - TranslatorInterface $translator, - $isDemoModeEnabled - ) { - $this->dataHandler = $dataHandler; - $this->hookDispatcher = $hookDispatcher; - $this->translator = $translator; - $this->isDemoModeEnabled = $isDemoModeEnabled; - } - - /** - * {@inheritdoc} - */ - public function handle(FormInterface $form) - { - return $this->handleForm($form); - } - - /** - * {@inheritdoc} - */ - public function handleFor($id, FormInterface $form) - { - return $this->handleForm($form, $id); - } - - /** - * @param FormInterface $form - * @param int|null $id - * - * @return FormHandlerResultInterface - */ - private function handleForm(FormInterface $form, $id = null) - { - if (!$form->isSubmitted()) { - return FormHandlerResult::createNotSubmitted(); - } - - if ($this->isDemoModeEnabled) { - $form->addError( - new FormError( - $this->translator->trans('This functionality has been disabled.', [], 'Admin.Notifications.Error') - ) - ); - - return FormHandlerResult::createSubmittedButNotValid(); - } - - if (!$form->isValid()) { - return FormHandlerResult::createSubmittedButNotValid(); - } - - if (null !== $id) { - return $this->handleFormUpdate($form, $id); - } - - return $this->handleFormCreate($form); - } - - /** - * @param FormInterface $form - * @param int $id - * - * @return FormHandlerResultInterface - */ - private function handleFormUpdate(FormInterface $form, $id) - { - $data = $form->getData(); - - $this->hookDispatcher->dispatchWithParameters('actionBeforeUpdate' . Container::camelize($form->getName()) . 'FormHandler', [ - 'form_data' => &$data, - 'id' => $id, - ]); - - $this->dataHandler->update($id, $data); - - $this->hookDispatcher->dispatchWithParameters('actionAfterUpdate' . Container::camelize($form->getName()) . 'FormHandler', [ - 'id' => $id, - 'form_data' => &$data, - ]); - - return FormHandlerResult::createWithId($id); - } - - /** - * @param FormInterface $form - * - * @return FormHandlerResult - */ - private function handleFormCreate(FormInterface $form) - { - $data = $form->getData(); - - $this->hookDispatcher->dispatchWithParameters( - 'actionBeforeCreate' . Container::camelize($form->getName()) . 'FormHandler', [ - 'form_data' => &$data, - ] - ); - - $id = $this->dataHandler->create($data); - - $this->hookDispatcher->dispatchWithParameters('actionAfterCreate' . Container::camelize($form->getName()) . 'FormHandler', [ - 'id' => $id, - 'form_data' => &$data, - ]); - - return FormHandlerResult::createWithId($id); - } -} diff --git a/src/Core/Form/IdentifiableObject/Handler/FormHandlerFactory.php b/src/Core/Form/IdentifiableObject/Handler/FormHandlerFactory.php deleted file mode 100644 index 5d08c96c..00000000 --- a/src/Core/Form/IdentifiableObject/Handler/FormHandlerFactory.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler; - -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\FormDataHandlerInterface; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Creates new form handlers. - */ -final class FormHandlerFactory implements FormHandlerFactoryInterface -{ - /** - * @var HookDispatcherInterface - */ - private $hookDispatcher; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var string - */ - private $isDemoModeEnabled; - - /** - * @param HookDispatcherInterface $hookDispatcher - * @param TranslatorInterface $translator - * @param bool $isDemoModeEnabled - */ - public function __construct( - HookDispatcherInterface $hookDispatcher, - TranslatorInterface $translator, - $isDemoModeEnabled - ) { - $this->hookDispatcher = $hookDispatcher; - $this->translator = $translator; - $this->isDemoModeEnabled = $isDemoModeEnabled; - } - - /** - * {@inheritdoc} - */ - public function create(FormDataHandlerInterface $dataHandler) - { - return new FormHandler( - $dataHandler, - $this->hookDispatcher, - $this->translator, - $this->isDemoModeEnabled - ); - } -} diff --git a/src/Core/Form/IdentifiableObject/Handler/FormHandlerFactoryInterface.php b/src/Core/Form/IdentifiableObject/Handler/FormHandlerFactoryInterface.php deleted file mode 100644 index 27d08405..00000000 --- a/src/Core/Form/IdentifiableObject/Handler/FormHandlerFactoryInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler; - -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\FormDataHandlerInterface; - -/** - * Defines interface for form handler factories. - */ -interface FormHandlerFactoryInterface -{ - /** - * Creates new form handler with given data handler. - * - * @param FormDataHandlerInterface $dataHandler - * - * @return FormHandlerInterface - */ - public function create(FormDataHandlerInterface $dataHandler); -} diff --git a/src/Core/Form/IdentifiableObject/Handler/FormHandlerInterface.php b/src/Core/Form/IdentifiableObject/Handler/FormHandlerInterface.php deleted file mode 100644 index 95a7c0a8..00000000 --- a/src/Core/Form/IdentifiableObject/Handler/FormHandlerInterface.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler; - -use Symfony\Component\Form\FormInterface; - -/** - * Defines interface for handling identifiable object's form. - */ -interface FormHandlerInterface -{ - /** - * Handles form by creating new object. - * - * @param FormInterface $form - * - * @return FormHandlerResultInterface - */ - public function handle(FormInterface $form); - - /** - * Handles form for given object. - * - * @param int $id - * @param FormInterface $form - * - * @return FormHandlerResultInterface - */ - public function handleFor($id, FormInterface $form); -} diff --git a/src/Core/Form/IdentifiableObject/Handler/FormHandlerResult.php b/src/Core/Form/IdentifiableObject/Handler/FormHandlerResult.php deleted file mode 100644 index d9af8e41..00000000 --- a/src/Core/Form/IdentifiableObject/Handler/FormHandlerResult.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler; - -/** - * Stores results for handling forms. - */ -class FormHandlerResult implements FormHandlerResultInterface -{ - /** - * @var bool - */ - private $isValid; - - /** - * @var bool - */ - private $isSubmitted; - - /** - * @var int|null - */ - private $identifiableObjectId; - - /** - * @param int|null $identifiableObjectId ID of identifiable object or null if it does not exist - * @param bool $isSubmitted - * @param bool $isValid - */ - private function __construct($identifiableObjectId, $isSubmitted, $isValid) - { - $this->identifiableObjectId = $identifiableObjectId; - $this->isSubmitted = $isSubmitted; - $this->isValid = $isValid; - } - - /** - * Creates successful form handler result with identifiable object id. - * - * @param int $identifiableObjectId - * - * @return FormHandlerResult - */ - public static function createWithId($identifiableObjectId) - { - return new self( - $identifiableObjectId, - true, - true - ); - } - - /** - * Creates form handler result when form which was provided form handling was not submitted - * - * @return FormHandlerResult - */ - public static function createNotSubmitted() - { - return new self( - null, - false, - false - ); - } - - /** - * Creates result for submitted but not valid form - * - * @return FormHandlerResult - */ - public static function createSubmittedButNotValid() - { - return new self( - null, - true, - false - ); - } - - /** - * @return bool - */ - public function isValid() - { - return $this->isValid; - } - - /** - * @return bool - */ - public function isSubmitted() - { - return $this->isSubmitted; - } - - /** - * @return int|null - */ - public function getIdentifiableObjectId() - { - return $this->identifiableObjectId; - } -} diff --git a/src/Core/Form/IdentifiableObject/Handler/FormHandlerResultInterface.php b/src/Core/Form/IdentifiableObject/Handler/FormHandlerResultInterface.php deleted file mode 100644 index 08f1c3e3..00000000 --- a/src/Core/Form/IdentifiableObject/Handler/FormHandlerResultInterface.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler; - -/** - * Defines interface for form handler result DTO - */ -interface FormHandlerResultInterface -{ - /** - * Check if form is valid and does not contains any errors - * - * @return bool - */ - public function isValid(); - - /** - * Check if form was actually submitted - * - * @return bool - */ - public function isSubmitted(); - - /** - * Get identifiable object id - * - * @return int|null ID of identifiable object or null if it does not exist - */ - public function getIdentifiableObjectId(); -} diff --git a/src/Core/Form/MultiStoreSettingsFormDataProviderInterface.php b/src/Core/Form/MultiStoreSettingsFormDataProviderInterface.php deleted file mode 100644 index 3f004de0..00000000 --- a/src/Core/Form/MultiStoreSettingsFormDataProviderInterface.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Form; - -/** - * Providers additional settings required for multi store form functionality. - */ -interface MultiStoreSettingsFormDataProviderInterface -{ - /** - * Gets data which are used in form data providers. - * - * @return array - they key is the form type field name and the value is true or false. If true, then the multi shop - * checkbox value is selected and otherwise. - */ - public function getData(); -} diff --git a/src/Core/Foundation/Database/DatabaseInterface.php b/src/Core/Foundation/Database/DatabaseInterface.php deleted file mode 100644 index a53c3e34..00000000 --- a/src/Core/Foundation/Database/DatabaseInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\Database; - -interface DatabaseInterface -{ - public function select($sqlString); - - public function escape($unsafeData); -} diff --git a/src/Core/Foundation/Database/EntityDataInconsistencyException.php b/src/Core/Foundation/Database/EntityDataInconsistencyException.php deleted file mode 100644 index 7ec92bd4..00000000 --- a/src/Core/Foundation/Database/EntityDataInconsistencyException.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\Database; - -class EntityDataInconsistencyException extends Exception -{ -} diff --git a/src/Core/Foundation/Database/EntityInterface.php b/src/Core/Foundation/Database/EntityInterface.php deleted file mode 100644 index dd1baa89..00000000 --- a/src/Core/Foundation/Database/EntityInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\Database; - -interface EntityInterface -{ - /** - * Returns the name of the repository class for this entity. - * If unspecified, a generic repository will be used for the entity. - * - * @return string or false value - */ - public static function getRepositoryClassName(); - - public function save(); - - public function delete(); - - public function hydrate(array $keyValueData); -} diff --git a/src/Core/Foundation/Database/EntityManager.php b/src/Core/Foundation/Database/EntityManager.php deleted file mode 100644 index 8d9e7dd0..00000000 --- a/src/Core/Foundation/Database/EntityManager.php +++ /dev/null @@ -1,130 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\Database; - -use PrestaShop\PrestaShop\Adapter\EntityMetaDataRetriever; - -class EntityManager -{ - private $db; - private $configuration; - - private $entityMetaData = []; - - public function __construct( - DatabaseInterface $db, - \PrestaShop\PrestaShop\Core\ConfigurationInterface $configuration - ) { - $this->db = $db; - $this->configuration = $configuration; - } - - /** - * Return current database object used. - * - * @return DatabaseInterface - */ - public function getDatabase() - { - return $this->db; - } - - /** - * Return current repository used. - * - * @param $className - * - * @return mixed - */ - public function getRepository($className) - { - if (is_callable([$className, 'getRepositoryClassName'])) { - $repositoryClass = call_user_func([$className, 'getRepositoryClassName']); - } else { - $repositoryClass = null; - } - - if (!$repositoryClass) { - $repositoryClass = '\\PrestaShop\\PrestaShop\\Core\\Foundation\\Database\\EntityRepository'; - } - - $repository = new $repositoryClass( - $this, - $this->configuration->get('_DB_PREFIX_'), - $this->getEntityMetaData($className) - ); - - return $repository; - } - - /** - * Return entity's meta data. - * - * @param $className - * - * @return mixed - * - * @throws \PrestaShop\PrestaShop\Adapter\CoreException - */ - public function getEntityMetaData($className) - { - if (!array_key_exists($className, $this->entityMetaData)) { - $metaDataRetriever = new EntityMetaDataRetriever(); - $this->entityMetaData[$className] = $metaDataRetriever->getEntityMetaData($className); - } - - return $this->entityMetaData[$className]; - } - - /** - * Flush entity to DB. - * - * @param EntityInterface $entity - * - * @return $this - */ - public function save(EntityInterface $entity) - { - $entity->save(); - - return $this; - } - - /** - * DElete entity from DB. - * - * @param EntityInterface $entity - * - * @return $this - */ - public function delete(EntityInterface $entity) - { - $entity->delete(); - - return $this; - } -} diff --git a/src/Core/Foundation/Database/EntityManager/QueryBuilder.php b/src/Core/Foundation/Database/EntityManager/QueryBuilder.php deleted file mode 100644 index fae82ef3..00000000 --- a/src/Core/Foundation/Database/EntityManager/QueryBuilder.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\Database\EntityManager; - -use PrestaShop\PrestaShop\Core\Foundation\Database\Exception; - -class QueryBuilder -{ - private $db; - - public function __construct(\PrestaShop\PrestaShop\Core\Foundation\Database\DatabaseInterface $db) - { - $this->db = $db; - } - - public function quote($value) - { - $escaped = $this->db->escape($value); - - if (is_string($value)) { - return "'" . $escaped . "'"; - } else { - return $escaped; - } - } - - public function buildWhereConditions($andOrOr, array $conditions) - { - $operator = strtoupper($andOrOr); - - if ($operator !== 'AND' && $operator !== 'OR') { - throw new Exception(sprintf('Invalid operator %s - must be "and" or "or".', $andOrOr)); - } - - $parts = []; - - foreach ($conditions as $key => $value) { - if (is_scalar($value)) { - $parts[] = $key . ' = ' . $this->quote($value); - } else { - $list = []; - foreach ($value as $item) { - $list[] = $this->quote($item); - } - $parts[] = $key . ' IN (' . implode(', ', $list) . ')'; - } - } - - return implode(" $operator ", $parts); - } -} diff --git a/src/Core/Foundation/Database/EntityMetaData.php b/src/Core/Foundation/Database/EntityMetaData.php deleted file mode 100644 index c66646e3..00000000 --- a/src/Core/Foundation/Database/EntityMetaData.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\Database; - -class EntityMetaData -{ - private $tableName; - private $primaryKeyFieldnames; - - public function setTableName($name) - { - $this->tableName = $name; - - return $this; - } - - public function getTableName() - { - return $this->tableName; - } - - public function setPrimaryKeyFieldNames(array $primaryKeyFieldnames) - { - $this->primaryKeyFieldnames = $primaryKeyFieldnames; - - return $this; - } - - public function getPrimaryKeyFieldnames() - { - return $this->primaryKeyFieldnames; - } - - public function setEntityClassName($entityClassName) - { - $this->entityClassName = $entityClassName; - - return $this; - } - - public function getEntityClassName() - { - return $this->entityClassName; - } -} diff --git a/src/Core/Foundation/Database/EntityNotFoundException.php b/src/Core/Foundation/Database/EntityNotFoundException.php deleted file mode 100644 index 1334ae8e..00000000 --- a/src/Core/Foundation/Database/EntityNotFoundException.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\Database; - -class EntityNotFoundException extends Exception -{ -} diff --git a/src/Core/Foundation/Database/EntityRepository.php b/src/Core/Foundation/Database/EntityRepository.php deleted file mode 100644 index 216d740c..00000000 --- a/src/Core/Foundation/Database/EntityRepository.php +++ /dev/null @@ -1,232 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\Database; - -use PrestaShop\PrestaShop\Core\Foundation\Database\EntityManager\QueryBuilder; - -class EntityRepository -{ - protected $entityManager; - protected $db; - protected $tablesPrefix; - protected $entityMetaData; - protected $queryBuilder; - - public function __construct( - EntityManager $entityManager, - $tablesPrefix, - EntityMetaData $entityMetaData - ) { - $this->entityManager = $entityManager; - $this->db = $this->entityManager->getDatabase(); - $this->tablesPrefix = $tablesPrefix; - $this->entityMetaData = $entityMetaData; - $this->queryBuilder = new QueryBuilder($this->db); - } - - public function __call($method, $arguments) - { - if (0 === strpos($method, 'findOneBy')) { - $one = true; - $by = substr($method, 9); - } elseif (0 === strpos($method, 'findBy')) { - $one = false; - $by = substr($method, 6); - } else { - throw new Exception(sprintf('Undefind method %s.', $method)); - } - - if (count($arguments) !== 1) { - throw new Exception(sprintf('Method %s takes exactly one argument.', $method)); - } - - if (!$by) { - $where = $arguments[0]; - } else { - $where = []; - $by = $this->convertToDbFieldName($by); - $where[$by] = $arguments[0]; - } - - return $this->doFind($one, $where); - } - - /** - * Convert a camelCase field name to a snakeCase one - * e.g.: findAllByIdCMS => id_cms. - * - * @param $camel_case_field_name - * - * @return string - */ - private function convertToDbFieldName($camel_case_field_name) - { - return strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $camel_case_field_name)); - } - - /** - * Return ID field name. - * - * @return mixed - * - * @throws Exception - */ - protected function getIdFieldName() - { - $primary = $this->entityMetaData->getPrimaryKeyFieldnames(); - - if (count($primary) === 0) { - throw new Exception(sprintf('No primary key defined in entity `%s`.', $this->entityMetaData->getEntityClassName())); - } elseif (count($primary) > 1) { - throw new Exception(sprintf('Entity `%s` has a composite primary key, which is not supported by entity repositories.', $this->entityMetaData->getEntityClassName())); - } - - return $primary[0]; - } - - /** - * Returns escaped+prefixed current table name. - * - * @return mixed - */ - protected function getTableNameWithPrefix() - { - return $this->db->escape($this->tablesPrefix . $this->entityMetaData->getTableName()); - } - - /** - * Returns escaped DB table prefix. - * - * @return mixed - */ - protected function getPrefix() - { - return $this->db->escape($this->tablesPrefix); - } - - /** - * Return a new empty Entity depending on current Repository selected. - * - * @return mixed - */ - public function getNewEntity() - { - $entityClassName = $this->entityMetaData->getEntityClassName(); - - return new $entityClassName(); - } - - /** - * This function takes an array of database rows as input - * and returns an hydrated entity if there is one row only. - * - * Null is returned when there are no rows, and an exception is thrown - * if there are too many rows. - * - * @param array $rows Database rows - */ - protected function hydrateOne(array $rows) - { - if (count($rows) === 0) { - return null; - } elseif (count($rows) > 1) { - throw new Exception('Too many rows returned.'); - } else { - $data = $rows[0]; - $entity = $this->getNewEntity(); - $entity->hydrate($data); - - return $entity; - } - } - - protected function hydrateMany(array $rows) - { - $entities = []; - foreach ($rows as $row) { - $entity = $this->getNewEntity(); - $entity->hydrate($row); - $entities[] = $entity; - } - - return $entities; - } - - /** - * Constructs and performs 'SELECT' in DB. - * - * @param $one - * @param array $cumulativeConditions - * - * @return array|mixed|null - * - * @throws Exception - */ - private function doFind($one, array $cumulativeConditions) - { - $whereClause = $this->queryBuilder->buildWhereConditions('AND', $cumulativeConditions); - - $sql = 'SELECT * FROM ' . $this->getTableNameWithPrefix() . ' WHERE ' . $whereClause; - - $rows = $this->db->select($sql); - - if ($one) { - return $this->hydrateOne($rows); - } else { - return $this->hydrateMany($rows); - } - } - - /** - * Find one entity in DB. - * - * @param $id - * - * @return array|mixed|null - * - * @throws Exception - */ - public function findOne($id) - { - $conditions = []; - $conditions[$this->getIdFieldName()] = $id; - - return $this->doFind(true, $conditions); - } - - /** - * Find all entities in DB. - * - * @return array - */ - public function findAll() - { - $sql = 'SELECT * FROM ' . $this->getTableNameWithPrefix(); - - return $this->hydrateMany($this->db->select($sql)); - } -} diff --git a/src/Core/Foundation/Database/Exception.php b/src/Core/Foundation/Database/Exception.php deleted file mode 100644 index 5c1f8651..00000000 --- a/src/Core/Foundation/Database/Exception.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\Database; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -class Exception extends CoreException -{ -} diff --git a/src/Core/Foundation/Exception/InvalidVersionException.php b/src/Core/Foundation/Exception/InvalidVersionException.php deleted file mode 100644 index 4ecc25aa..00000000 --- a/src/Core/Foundation/Exception/InvalidVersionException.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * This exception will be thrown if an invalid Shop version name is used - * in the application. - */ -class InvalidVersionException extends CoreException -{ - /** - * Construct. - * - * @param string $version the provided PrestaShop version - */ - public function __construct($version) - { - $message = sprintf( - 'You provided an invalid version string ("%s"). A valid version string ' . - 'must contain numeric characters separated by "." characters, for example "1.7.4.0".', - $version - ); - parent::__construct($message, 0, null); - } -} diff --git a/src/Core/Foundation/Filesystem/Exception.php b/src/Core/Foundation/Filesystem/Exception.php deleted file mode 100644 index cfd9ceab..00000000 --- a/src/Core/Foundation/Filesystem/Exception.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\Filesystem; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -class Exception extends CoreException -{ -} diff --git a/src/Core/Foundation/Filesystem/FileSystem.php b/src/Core/Foundation/Filesystem/FileSystem.php deleted file mode 100644 index 6a998f06..00000000 --- a/src/Core/Foundation/Filesystem/FileSystem.php +++ /dev/null @@ -1,146 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\Filesystem; - -use SplFileInfo; - -class FileSystem -{ - /** - * Default mode for directories - */ - const DEFAULT_MODE_FOLDER = 0755; - - /** - * Default mode for files - */ - const DEFAULT_MODE_FILE = 0644; - - /** - * Replaces directory separators with the system's native one - * and trims the trailing separator. - */ - public function normalizePath($path) - { - return rtrim( - str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $path), - DIRECTORY_SEPARATOR - ); - } - - private function joinTwoPaths($a, $b) - { - return $this->normalizePath($a) . DIRECTORY_SEPARATOR . $this->normalizePath($b); - } - - /** - * Joins an arbitrary number of paths, normalizing them along the way. - */ - public function joinPaths() - { - if (func_num_args() < 2) { - throw new Exception('joinPaths requires at least 2 arguments.'); - } elseif (func_num_args() === 2) { - $arg_O = func_get_arg(0); - $arg_1 = func_get_arg(1); - - return $this->joinTwoPaths($arg_O, $arg_1); - } elseif (func_num_args() > 2) { - $func_args = func_get_args(); - $arg_0 = func_get_arg(0); - - return $this->joinPaths( - $arg_0, - call_user_func_array( - [$this, - 'joinPaths', ], - array_slice($func_args, 1) - ) - ); - } - } - - /** - * Performs a depth first listing of directory entries. - * Throws exception if $path is not a file. - * If $path is a file and not a directory, just gets the file info for it - * and return it in an array. - * - * @return an array of SplFileInfo object indexed by file path - */ - public function listEntriesRecursively($path) - { - if (!file_exists($path)) { - throw new Exception(sprintf('No such file or directory: %s', $path)); - } - - if (!is_dir($path)) { - throw new Exception(sprintf('%s is not a directory', $path)); - } - - $entries = []; - - foreach (scandir($path) as $entry) { - if ($entry === '.' || $entry === '..') { - continue; - } - - $newPath = $this->joinPaths($path, $entry); - $info = new SplFileInfo($newPath); - - $entries[$newPath] = $info; - - if ($info->isDir()) { - $entries = array_merge( - $entries, - $this->listEntriesRecursively($newPath) - ); - } - } - - return $entries; - } - - /** - * Filter used by listFilesRecursively. - */ - private function matchOnlyFiles(SplFileInfo $info) - { - return $info->isFile(); - } - - /** - * Same as listEntriesRecursively but returns only files. - */ - public function listFilesRecursively($path) - { - return array_filter( - $this->listEntriesRecursively($path), - [$this, 'matchOnlyFiles'] - ); - } -} diff --git a/src/Core/Foundation/IoC/Container.php b/src/Core/Foundation/IoC/Container.php deleted file mode 100644 index 8186f285..00000000 --- a/src/Core/Foundation/IoC/Container.php +++ /dev/null @@ -1,168 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\IoC; - -use ReflectionClass; - -class Container -{ - private $bindings = []; - private $instances = []; - private $namespaceAliases = []; - - public function knows($serviceName) - { - return array_key_exists($serviceName, $this->bindings); - } - - private function knowsNamespaceAlias($alias) - { - return array_key_exists($alias, $this->namespaceAliases); - } - - public function bind($serviceName, $constructor, $shared = false) - { - if ($this->knows($serviceName)) { - throw new Exception(sprintf('Cannot bind `%s` again. A service name can only be bound once.', $serviceName)); - } - - $this->bindings[$serviceName] = [ - 'constructor' => $constructor, - 'shared' => $shared, - ]; - - return $this; - } - - public function aliasNamespace($alias, $namespacePrefix) - { - if ($this->knowsNamespaceAlias($alias)) { - throw new Exception(sprintf('Namespace alias `%1$s` already exists and points to `%2$s`', $alias, $this->namespaceAliases[$alias])); - } - - $this->namespaceAliases[$alias] = $namespacePrefix; - - return $this; - } - - public function resolveClassName($className) - { - $colonPos = strpos($className, ':'); - if (0 !== $colonPos && false !== $colonPos) { - $alias = substr($className, 0, $colonPos); - if ($this->knowsNamespaceAlias($alias)) { - $class = ltrim(substr($className, $colonPos + 1), '\\'); - - return $this->namespaceAliases[$alias] . '\\' . $class; - } - } - - return $className; - } - - private function makeInstanceFromClassName($className, array $alreadySeen) - { - $className = $this->resolveClassName($className); - - try { - $refl = new ReflectionClass($className); - } catch (\ReflectionException $re) { - throw new Exception(sprintf('This doesn\'t seem to be a class name: `%s`.', $className)); - } - - $args = []; - - if ($refl->isAbstract()) { - throw new Exception(sprintf('Cannot build abstract class: `%s`.', $className)); - } - - $classConstructor = $refl->getConstructor(); - - if ($classConstructor) { - foreach ($classConstructor->getParameters() as $param) { - $paramClass = $param->getClass(); - if ($paramClass) { - $args[] = $this->doMake($param->getClass()->getName(), $alreadySeen); - } elseif ($param->isDefaultValueAvailable()) { - $args[] = $param->getDefaultValue(); - } else { - throw new Exception(sprintf('Cannot build a `%s`.', $className)); - } - } - } - - if (count($args) > 0) { - return $refl->newInstanceArgs($args); - } else { - // newInstanceArgs with empty array fails in PHP 5.3 when the class - // doesn't have an explicitly defined constructor - return $refl->newInstance(); - } - } - - private function doMake($serviceName, array $alreadySeen = []) - { - if (array_key_exists($serviceName, $alreadySeen)) { - throw new Exception(sprintf('Cyclic dependency detected while building `%s`.', $serviceName)); - } - - $alreadySeen[$serviceName] = true; - - if (!$this->knows($serviceName)) { - $this->bind($serviceName, $serviceName); - } - - $binding = $this->bindings[$serviceName]; - - if ($binding['shared'] && array_key_exists($serviceName, $this->instances)) { - return $this->instances[$serviceName]; - } else { - $constructor = $binding['constructor']; - - if (is_callable($constructor)) { - $service = call_user_func($constructor); - } elseif (!is_string($constructor)) { - // user already provided the value, no need to construct it. - $service = $constructor; - } else { - // assume the $constructor is a class name - $service = $this->makeInstanceFromClassName($constructor, $alreadySeen); - } - - if ($binding['shared']) { - $this->instances[$serviceName] = $service; - } - - return $service; - } - } - - public function make($serviceName) - { - return $this->doMake($serviceName, []); - } -} diff --git a/src/Core/Foundation/IoC/Exception.php b/src/Core/Foundation/IoC/Exception.php deleted file mode 100644 index e8e8f343..00000000 --- a/src/Core/Foundation/IoC/Exception.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\IoC; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -class Exception extends CoreException -{ -} diff --git a/src/Core/Foundation/Templating/PresenterInterface.php b/src/Core/Foundation/Templating/PresenterInterface.php deleted file mode 100644 index 380a23a6..00000000 --- a/src/Core/Foundation/Templating/PresenterInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\Templating; - -interface PresenterInterface -{ - public function present($object); // must return an array -} diff --git a/src/Core/Foundation/Templating/RenderableInterface.php b/src/Core/Foundation/Templating/RenderableInterface.php deleted file mode 100644 index ce5b3379..00000000 --- a/src/Core/Foundation/Templating/RenderableInterface.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\Templating; - -interface RenderableInterface -{ - public function setTemplate($templatePath); - - public function getTemplate(); - - public function render(array $extraParams = []); -} diff --git a/src/Core/Foundation/Templating/RenderableProxy.php b/src/Core/Foundation/Templating/RenderableProxy.php deleted file mode 100644 index 04cb5614..00000000 --- a/src/Core/Foundation/Templating/RenderableProxy.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation\Templating; - -class RenderableProxy -{ - private $renderable; - - public function __construct(RenderableInterface $renderable) - { - $this->renderable = $renderable; - } - - public function setTemplate($templatePath) - { - $this->renderable->setTemplate($templatePath); - - return $this; - } - - public function getTemplate() - { - return $this->renderable->getTemplate(); - } - - public function render(array $extraParams = []) - { - return $this->renderable->render($extraParams); - } -} diff --git a/src/Core/Foundation/Version.php b/src/Core/Foundation/Version.php deleted file mode 100644 index eff74840..00000000 --- a/src/Core/Foundation/Version.php +++ /dev/null @@ -1,394 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Foundation; - -use PrestaShop\PrestaShop\Core\Foundation\Exception\InvalidVersionException; - -/** - * Class responsible of managing the right version of Shop - * for every internal/external services. - */ -class Version -{ - /** - * Full version name. - * - * @var string - */ - private $version; - - /** - * Major version name. - * - * @var string - */ - private $majorVersionString; - - /** - * Major version. - * - * @var int - */ - private $majorVersion; - - /** - * Minor version. - * - * @var int - */ - private $minorVersion; - - /** - * Patch version. - * - * @var int - */ - private $patchVersion; - - /** - * Pre release version, (eg. "dev", "beta"...) - * - * @var string - */ - private $preReleaseVersion; - - /** - * Build metadata (eg. build number) - * - * @var string - */ - private $buildMetadata; - - /** - * Initialize version data. - * - * @param string $version Version - * @param string $majorVersionString Legacy major version in string format (eg. "1.7") - * @param int $majorVersion Major version - * @param int $minorVersion [default=0] Minor version - * @param int $patchVersion [default=0] Patch version - * @param string $preReleaseVersion [default=''] Pre release version (eg. "dev", "beta"...) - * @param string $buildMetadata [default=''] Build metadata (eg. build number) - */ - public function __construct( - $version, - $majorVersionString, - $majorVersion, - $minorVersion = 0, - $patchVersion = 0, - $preReleaseVersion = '', - $buildMetadata = '' - ) { - $this->version = $this->removeLegacyPrefix($version, $majorVersionString); - $this->majorVersionString = $majorVersionString; - $this->majorVersion = $majorVersion; - $this->minorVersion = $minorVersion; - $this->patchVersion = $patchVersion; - $this->preReleaseVersion = $preReleaseVersion; - $this->buildMetadata = $buildMetadata; - } - - /** - * Builds an instance form a version string - * - * @param string $version - * - * @return self - * - * @throws InvalidVersionException If the version is invalid - */ - public static function buildFromString($version) - { - $matches = []; - $regex = '/^([\d]+)(?:\.([\d]+))?(?:\.([\d]+))?(?:\.(?[\d]+))?(?:-(?[0-9A-Za-z-.]+))?(?:\+(?[0-9A-Za-z-.]+))?$/'; - - if (!preg_match($regex, $version, $matches)) { - throw new InvalidVersionException($version); - } - - if (isset($matches['legacy']) && '' !== $matches['legacy']) { - // legacy version like "1.7.5.0" - $major = (int) $matches[2]; - $minor = (int) $matches[3]; - $patch = (int) $matches['legacy']; - $version = substr($version, strpos($version, '.') + 1); - } else { - $major = (int) $matches[1]; - $minor = isset($matches[2]) ? (int) $matches[2] : 0; - $patch = isset($matches[3]) ? (int) $matches[3] : 0; - } - - return new self( - $version, - "1.$major", - $major, - $minor, - $patch, - isset($matches['prerelease']) ? $matches['prerelease'] : '', - isset($matches['build']) ? $matches['build'] : '' - ); - } - - /** - * Returns the current version in legacy format (eg. "1.7.6.0") - * - * @param bool $full [default=false] If true, include pre-release and build metadata (eg. "1.7.6.0-dev+build.1") - * - * @return string - */ - public function getVersion($full = false) - { - $version = '1.' . $this->version; - - if (!$full) { - // remove extra parts - return preg_replace('/[-\+].*/', '', $version); - } - - return $version; - } - - /** - * Returns SemVer compliant version (eg. "7.6.0") - * - * @return string - */ - public function getSemVersion() - { - return $this->version; - } - - /** - * Returns the current major version as a string. - * - * @return string For example "1.7" - */ - public function getMajorVersionString() - { - return $this->majorVersionString; - } - - /** - * Returns the current major version as an integer. - * - * @return int For example 17 - */ - public function getMajorVersion() - { - return $this->majorVersion; - } - - /** - * Returns the current minor version. - * - * @return int - */ - public function getMinorVersion() - { - return $this->minorVersion; - } - - /** - * Returns the current patch version. - * - * @return int - */ - public function getPatchVersion() - { - return $this->patchVersion; - } - - /** - * Returns the current release version. - * - * @deprecated Since 1.7.6.0, use getPatchVersion(); - * - * @return int - */ - public function getReleaseVersion() - { - @trigger_error( - 'getReleaseVersion() is deprecated since version 1.7.6.0 Use getPatchVersion() instead.', - E_USER_DEPRECATED - ); - - return $this->getPatchVersion(); - } - - /** - * Returns the current pre release version (if any) - * - * @return string - */ - public function getPreReleaseVersion() - { - return $this->preReleaseVersion; - } - - /** - * Returns the current build metadata (if any) - * - * @return string - */ - public function getBuildMetadata() - { - return $this->buildMetadata; - } - - /** - * Returns if the current version is greater than the provided version. - * - * @param $version Must be a valid version string, for example "1.7.4.0" - * - * @return bool - * - * @throws InvalidVersionException If the provided version is invalid - */ - public function isGreaterThan($version) - { - return $this->versionCompare($version, '>'); - } - - /** - * Returns if the current version is greater than or equal to the provided version. - * - * @param $version Must be a valid version string, for example "1.7.4.0" - * - * @return bool - * - * @throws InvalidVersionException If the provided version is invalid - */ - public function isGreaterThanOrEqualTo($version) - { - return $this->versionCompare($version, '>='); - } - - /** - * Returns if the current version is less than the provided version. - * - * @param $version Must be a valid version string, for example "1.7.4.0" - * - * @return bool - * - * @throws InvalidVersionException If the provided version is invalid - */ - public function isLessThan($version) - { - return $this->versionCompare($version, '<'); - } - - /** - * Returns if the current version is less than or equal to the provided version. - * - * @param $version Must be a valid version string, for example "1.7.4.0" - * - * @return bool - * - * @throws InvalidVersionException If the provided version is invalid - */ - public function isLessThanOrEqualTo($version) - { - return $this->versionCompare($version, '<='); - } - - /** - * Returns if the current version is equal to the provided version. - * - * @param $version Must be a valid version string, for example "1.7.4.0" - * - * @return bool - * - * @throws InvalidVersionException If the provided version is invalid - */ - public function isEqualTo($version) - { - return $this->versionCompare($version, '='); - } - - /** - * Returns if the current version is not equal to the provided version. - * - * @param $version Must be a valid version string, for example "1.7.4.0" - * - * @return bool - * - * @throws InvalidVersionException If the provided version is invalid - */ - public function isNotEqualTo($version) - { - return $this->versionCompare($version, '!='); - } - - /** - * Returns the semantic version string - */ - public function __toString() - { - return $this->getSemVersion(); - } - - /** - * Compares the current version with the provided version depending on the provided operator. - * It sanitized both version to have a. - * - * @param $version string Must be a valid version string, for example "1.7.4.0" - * @param $operator string Operator for version_compare(), - * allowed values are: <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne - * - * @return bool result of the comparison - * - * @throws InvalidVersionException if the provided version is invalid - */ - private function versionCompare($version, $operator) - { - $otherVersion = self::buildFromString($version); - - $first = $this->getSemVersion(); - $other = $otherVersion->getSemVersion(); - - $result = version_compare($first, $other, $operator); - - return $result; - } - - /** - * Remove legacy 1.x prefix if needed - * - * @param string $version - * @param string $majorVersionString - * - * @return bool|string - */ - private function removeLegacyPrefix($version, $majorVersionString) - { - if ('1.' === substr($version, 0, 2) && substr($version, 0, strlen($majorVersionString)) === $majorVersionString) { - $version = substr($version, 2); - } - - return $version; - } -} diff --git a/src/Core/Geolocation/GeoLite/GeoLiteCityChecker.php b/src/Core/Geolocation/GeoLite/GeoLiteCityChecker.php deleted file mode 100644 index 4674745a..00000000 --- a/src/Core/Geolocation/GeoLite/GeoLiteCityChecker.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Geolocation\GeoLite; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; - -/** - * Class GeoLiteCityChecker is responsible for checking if GeoLiteCity data is available. - */ -final class GeoLiteCityChecker implements GeoLiteCityCheckerInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function isAvailable() - { - $geoIpDir = $this->configuration->get('_PS_GEOIP_DIR_'); - $geoLiteCityFile = $this->configuration->get('_PS_GEOIP_CITY_FILE_'); - - return file_exists($geoIpDir . $geoLiteCityFile); - } -} diff --git a/src/Core/Geolocation/GeoLite/GeoLiteCityCheckerInterface.php b/src/Core/Geolocation/GeoLite/GeoLiteCityCheckerInterface.php deleted file mode 100644 index b85195cc..00000000 --- a/src/Core/Geolocation/GeoLite/GeoLiteCityCheckerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Geolocation\GeoLite; - -/** - * Interface GeoLiteCityInterface defines contract for GeoLiteCity. - */ -interface GeoLiteCityCheckerInterface -{ - /** - * Check if GeoLiteCity data is available in PrestaShop installation. - * - * @return bool - */ - public function isAvailable(); -} diff --git a/src/Core/Grid/Action/AbstractGridAction.php b/src/Core/Grid/Action/AbstractGridAction.php deleted file mode 100644 index a05c1521..00000000 --- a/src/Core/Grid/Action/AbstractGridAction.php +++ /dev/null @@ -1,153 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action; - -use Symfony\Component\OptionsResolver\OptionsResolver; - -abstract class AbstractGridAction implements GridActionInterface -{ - /** - * @var string - */ - private $id; - - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $type; - - /** - * @var string - */ - private $icon; - - /** - * @var array - */ - private $options; - - /** - * @param string $id - */ - public function __construct($id) - { - $this->id = $id; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->name = $name; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getIcon() - { - return $this->icon; - } - - /** - * {@inheritdoc} - */ - public function setIcon($icon) - { - $this->icon = $icon; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setOptions(array $options) - { - $this->resolveOptions($options); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getOptions() - { - if (null === $this->options) { - $this->resolveOptions(); - } - - return $this->options; - } - - /** - * Default bulk action options configuration. You can override it if options are needed. - * - * @param OptionsResolver $resolver - */ - protected function configureOptions(OptionsResolver $resolver) - { - } - - /** - * Resolve action options. - * - * @param array $options - */ - private function resolveOptions(array $options = []) - { - $resolver = new OptionsResolver(); - $this->configureOptions($resolver); - - $this->options = $resolver->resolve($options); - } -} diff --git a/src/Core/Grid/Action/Bulk/AbstractBulkAction.php b/src/Core/Grid/Action/Bulk/AbstractBulkAction.php deleted file mode 100644 index 7ef10587..00000000 --- a/src/Core/Grid/Action/Bulk/AbstractBulkAction.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Bulk; - -use Symfony\Component\OptionsResolver\OptionsResolver; - -abstract class AbstractBulkAction implements BulkActionInterface -{ - /** - * @var string - */ - private $id; - - /** - * @var string - */ - protected $name; - - /** - * @var array - */ - private $options; - - /** - * @param string $id - */ - public function __construct($id) - { - $this->id = $id; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->name = $name; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setOptions(array $options) - { - $this->resolveOptions($options); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getOptions() - { - if (null === $this->options) { - $this->resolveOptions(); - } - - return $this->options; - } - - /** - * Default bulk action options configuration. You can override it if options are needed. - * - * @param OptionsResolver $resolver - */ - protected function configureOptions(OptionsResolver $resolver) - { - } - - /** - * Resolve bulk action options. - * - * @param array $options - */ - private function resolveOptions(array $options = []) - { - $resolver = new OptionsResolver(); - $this->configureOptions($resolver); - - $this->options = $resolver->resolve($options); - } -} diff --git a/src/Core/Grid/Action/Bulk/BulkActionCollection.php b/src/Core/Grid/Action/Bulk/BulkActionCollection.php deleted file mode 100644 index 7281e729..00000000 --- a/src/Core/Grid/Action/Bulk/BulkActionCollection.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Bulk; - -use PrestaShop\PrestaShop\Core\Grid\Collection\AbstractCollection; - -/** - * Class BulkActionCollection holds bulk action collection available for grid. - * - * @property BulkActionInterface[] $items - */ -final class BulkActionCollection extends AbstractCollection implements BulkActionCollectionInterface -{ - /** - * {@inheritdoc} - */ - public function add(BulkActionInterface $bulkAction) - { - $this->items[$bulkAction->getId()] = $bulkAction; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function toArray() - { - $bulkActionsArray = []; - - foreach ($this->items as $bulkAction) { - $bulkActionsArray[] = [ - 'id' => $bulkAction->getId(), - 'name' => $bulkAction->getName(), - 'type' => $bulkAction->getType(), - 'options' => $bulkAction->getOptions(), - ]; - } - - return $bulkActionsArray; - } -} diff --git a/src/Core/Grid/Action/Bulk/BulkActionCollectionInterface.php b/src/Core/Grid/Action/Bulk/BulkActionCollectionInterface.php deleted file mode 100644 index 1fe5fece..00000000 --- a/src/Core/Grid/Action/Bulk/BulkActionCollectionInterface.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Bulk; - -use Iterator; - -/** - * Interface BulkActionCollectionInterface defines bulk actions contract. - */ -interface BulkActionCollectionInterface extends Iterator -{ - /** - * Add bulk action to collection. - * - * @param BulkActionInterface $bulkAction - * - * @return self - */ - public function add(BulkActionInterface $bulkAction); - - /** - * Get bulk actions as array. - * - * @return array - */ - public function toArray(); -} diff --git a/src/Core/Grid/Action/Bulk/BulkActionInterface.php b/src/Core/Grid/Action/Bulk/BulkActionInterface.php deleted file mode 100644 index e35fd0c0..00000000 --- a/src/Core/Grid/Action/Bulk/BulkActionInterface.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Bulk; - -/** - * Interface BulkActionInterface defines contract for single grid bulk action. - */ -interface BulkActionInterface -{ - /** - * Get unique bulk action identifier for grid. - * - * @return string - */ - public function getId(); - - /** - * Get translated bulk action name. - * - * @return string - */ - public function getName(); - - /** - * Get action type. - * - * @return string - */ - public function getType(); - - /** - * Get action options. - * - * @return array - */ - public function getOptions(); - - /** - * Set options for bulk action. - * - * @param array $options - * - * @return self - */ - public function setOptions(array $options); - - /** - * Set bulk action name. - * - * @param string $name - * - * @return self - */ - public function setName($name); -} diff --git a/src/Core/Grid/Action/Bulk/Type/ButtonBulkAction.php b/src/Core/Grid/Action/Bulk/Type/ButtonBulkAction.php deleted file mode 100644 index ccc78caf..00000000 --- a/src/Core/Grid/Action/Bulk/Type/ButtonBulkAction.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\AbstractBulkAction; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class ButtonBulkAction holds data to display a simple button, it allows you to - * set a (required) class and additional (optional) attributes that can then be used - * in javascript. - */ -final class ButtonBulkAction extends AbstractBulkAction -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'button'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'class', - ]) - ->setDefaults([ - 'attributes' => [], - ]) - ->setAllowedTypes('class', 'string') - ->setAllowedTypes('attributes', 'array'); - } -} diff --git a/src/Core/Grid/Action/Bulk/Type/Catalog/Category/DeleteCategoriesBulkAction.php b/src/Core/Grid/Action/Bulk/Type/Catalog/Category/DeleteCategoriesBulkAction.php deleted file mode 100644 index 2272d9ba..00000000 --- a/src/Core/Grid/Action/Bulk/Type/Catalog/Category/DeleteCategoriesBulkAction.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\Catalog\Category; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\AbstractBulkAction; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class DeleteCategoriesBulkAction implements bulk deleting for categories grid. - */ -final class DeleteCategoriesBulkAction extends AbstractBulkAction -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'delete_categories'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'categories_bulk_delete_route', - ]) - ->setAllowedTypes('categories_bulk_delete_route', 'string'); - } -} diff --git a/src/Core/Grid/Action/Bulk/Type/Customer/DeleteCustomersBulkAction.php b/src/Core/Grid/Action/Bulk/Type/Customer/DeleteCustomersBulkAction.php deleted file mode 100644 index 6b39c48c..00000000 --- a/src/Core/Grid/Action/Bulk/Type/Customer/DeleteCustomersBulkAction.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\Customer; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\AbstractBulkAction; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Allows to configure "Delete" customers bulk action. - */ -final class DeleteCustomersBulkAction extends AbstractBulkAction -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'delete_customers'; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'customers_bulk_delete_route', - ]) - ->setAllowedTypes('customers_bulk_delete_route', 'string') - ; - } -} diff --git a/src/Core/Grid/Action/Bulk/Type/ModalFormSubmitBulkAction.php b/src/Core/Grid/Action/Bulk/Type/ModalFormSubmitBulkAction.php deleted file mode 100644 index a07fc34c..00000000 --- a/src/Core/Grid/Action/Bulk/Type/ModalFormSubmitBulkAction.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\AbstractBulkAction; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Bulk actions that submit form in modal - */ -final class ModalFormSubmitBulkAction extends AbstractBulkAction -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'modal_form_submit'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'submit_route', - 'modal_id', - ]) - ->setAllowedTypes('submit_route', 'string') - ->setAllowedTypes('modal_id', 'string') - ; - } -} diff --git a/src/Core/Grid/Action/Bulk/Type/SubmitBulkAction.php b/src/Core/Grid/Action/Bulk/Type/SubmitBulkAction.php deleted file mode 100644 index e4219487..00000000 --- a/src/Core/Grid/Action/Bulk/Type/SubmitBulkAction.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\AbstractBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\ModalOptions; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class BulkAction holds data about single bulk action available in grid. - */ -final class SubmitBulkAction extends AbstractBulkAction -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'submit'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'submit_route', - ]) - ->setDefaults([ - 'confirm_message' => null, - 'modal_options' => null, - 'submit_method' => 'POST', - 'route_params' => [], - ]) - ->setAllowedTypes('submit_route', 'string') - ->setAllowedTypes('confirm_message', ['string', 'null']) - ->setAllowedTypes('modal_options', [ModalOptions::class, 'null']) - ->setAllowedValues('submit_method', ['POST', 'GET']) - ->setAllowedTypes('route_params', 'array'); - } -} diff --git a/src/Core/Grid/Action/GridActionCollection.php b/src/Core/Grid/Action/GridActionCollection.php deleted file mode 100644 index bd34b465..00000000 --- a/src/Core/Grid/Action/GridActionCollection.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action; - -use PrestaShop\PrestaShop\Core\Grid\Collection\AbstractCollection; - -/** - * Class PanelActionCollection is responsible for holding single grid actions. - * - * @property GridActionInterface[] $items - */ -final class GridActionCollection extends AbstractCollection implements GridActionCollectionInterface -{ - /** - * {@inheritdoc} - */ - public function add(GridActionInterface $action) - { - $this->items[$action->getId()] = $action; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function toArray() - { - $actionsArray = []; - - foreach ($this->items as $action) { - $actionsArray[] = [ - 'id' => $action->getId(), - 'name' => $action->getName(), - 'icon' => $action->getIcon(), - 'type' => $action->getType(), - 'options' => $action->getOptions(), - ]; - } - - return $actionsArray; - } -} diff --git a/src/Core/Grid/Action/GridActionCollectionInterface.php b/src/Core/Grid/Action/GridActionCollectionInterface.php deleted file mode 100644 index 1bb818d3..00000000 --- a/src/Core/Grid/Action/GridActionCollectionInterface.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action; - -use Iterator; - -/** - * Interface PanelActionCollectionInterface defines contract for grid action collection. - */ -interface GridActionCollectionInterface extends Iterator -{ - /** - * Add grid action to collection. - * - * @param GridActionInterface $action - * - * @return self - */ - public function add(GridActionInterface $action); - - /** - * Get grid panel actions as array. - * - * @return array - */ - public function toArray(); -} diff --git a/src/Core/Grid/Action/GridActionInterface.php b/src/Core/Grid/Action/GridActionInterface.php deleted file mode 100644 index f3c7967b..00000000 --- a/src/Core/Grid/Action/GridActionInterface.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action; - -/** - * Interface GridActionInterface. - */ -interface GridActionInterface -{ - /** - * Return unique action identifier. - * - * @return string - */ - public function getId(); - - /** - * Returns translated action name. - * - * @return string - */ - public function getName(); - - /** - * Set action name. - * - * @param string $name - * - * @return self - */ - public function setName($name); - - /** - * Returns action icon name. - * - * @return string - */ - public function getIcon(); - - /** - * Set action icon name. - * - * @param string $icon - * - * @return string - */ - public function setIcon($icon); - - /** - * Returns grid action type. - * - * @return string - */ - public function getType(); - - /** - * Get action options. - * - * @return array - */ - public function getOptions(); - - /** - * Set action options. - * - * @param array $options - * - * @return self - */ - public function setOptions(array $options); -} diff --git a/src/Core/Grid/Action/ModalOptions.php b/src/Core/Grid/Action/ModalOptions.php deleted file mode 100644 index 3f90c793..00000000 --- a/src/Core/Grid/Action/ModalOptions.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action; - -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class ModalOptions used to configure modal used in actions like SubmitBulkAction - */ -class ModalOptions -{ - /** - * @var array - */ - private $options; - - /** - * @param array $options - */ - public function __construct(array $options = []) - { - $this->setOptions($options); - } - - /** - * @return array - */ - public function getOptions(): array - { - return $this->options; - } - - /** - * @param array $options - * - * @return ModalOptions - */ - public function setOptions(array $options): ModalOptions - { - $resolver = new OptionsResolver(); - $this->configureOptions($resolver); - - $this->options = $resolver->resolve($options); - - return $this; - } - - /** - * @param OptionsResolver $resolver - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setDefaults([ - 'title' => null, - 'confirm_button_label' => null, - 'confirm_button_class' => 'btn-primary', - 'close_button_label' => null, - ]) - ->setAllowedTypes('title', ['string', 'null']) - ->setAllowedTypes('confirm_button_label', ['string', 'null']) - ->setAllowedTypes('confirm_button_class', 'string') - ; - } -} diff --git a/src/Core/Grid/Action/Row/AbstractRowAction.php b/src/Core/Grid/Action/Row/AbstractRowAction.php deleted file mode 100644 index cddddba1..00000000 --- a/src/Core/Grid/Action/Row/AbstractRowAction.php +++ /dev/null @@ -1,166 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Row; - -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class AbstractRowAction. - */ -abstract class AbstractRowAction implements RowActionInterface -{ - /** - * @var string - */ - private $id; - - /** - * @var string - */ - private $name; - - /** - * @var array|null - */ - private $options; - - /** - * @var string - */ - private $icon; - - /** - * @param string $id - */ - public function __construct($id) - { - $this->id = $id; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function getIcon() - { - return $this->icon; - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->name = $name; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setIcon($icon) - { - $this->icon = $icon; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setOptions(array $options) - { - $this->resolveOptions($options); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getOptions() - { - if (null === $this->options) { - $this->resolveOptions(); - } - - return $this->options; - } - - /** - * {@inheritdoc} - */ - public function isApplicable(array $record) - { - return true; - } - - /** - * Default action options configuration. You can override it if options are needed. - * - * @param OptionsResolver $resolver - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setDefaults([ - 'use_inline_display' => false, - ]) - // if set to true then it displays only icons - ->setAllowedTypes('use_inline_display', 'bool') - ; - } - - /** - * Resolve action options. - * - * @param array $options - */ - private function resolveOptions(array $options = []) - { - $resolver = new OptionsResolver(); - $this->configureOptions($resolver); - - $this->options = $resolver->resolve($options); - } -} diff --git a/src/Core/Grid/Action/Row/AccessibilityChecker/AccessibilityCheckerInterface.php b/src/Core/Grid/Action/Row/AccessibilityChecker/AccessibilityCheckerInterface.php deleted file mode 100644 index ca8b0dab..00000000 --- a/src/Core/Grid/Action/Row/AccessibilityChecker/AccessibilityCheckerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Row\AccessibilityChecker; - -/** - * Interface ApplicabilityCheckerInterface. - */ -interface AccessibilityCheckerInterface -{ - /** - * Check if record is applicable for row action. - * - * @param array $record - * - * @return bool - */ - public function isGranted(array $record); -} diff --git a/src/Core/Grid/Action/Row/AccessibilityChecker/DeleteProfileAccessibilityChecker.php b/src/Core/Grid/Action/Row/AccessibilityChecker/DeleteProfileAccessibilityChecker.php deleted file mode 100644 index 93d10059..00000000 --- a/src/Core/Grid/Action/Row/AccessibilityChecker/DeleteProfileAccessibilityChecker.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Row\AccessibilityChecker; - -/** - * Class DeleteProfileAccessibilityChecker. - * - * @internal - */ -final class DeleteProfileAccessibilityChecker implements AccessibilityCheckerInterface -{ - /** - * @var int - */ - private $superAdminProfileId; - - /** - * @param int $superAdminProfileId - */ - public function __construct($superAdminProfileId) - { - $this->superAdminProfileId = $superAdminProfileId; - } - - /** - * {@inheritdoc} - */ - public function isGranted(array $profile) - { - return $profile['id_profile'] != $this->superAdminProfileId; - } -} diff --git a/src/Core/Grid/Action/Row/AccessibilityChecker/PrintDeliverySlipAccessibilityChecker.php b/src/Core/Grid/Action/Row/AccessibilityChecker/PrintDeliverySlipAccessibilityChecker.php deleted file mode 100644 index edf4ca5a..00000000 --- a/src/Core/Grid/Action/Row/AccessibilityChecker/PrintDeliverySlipAccessibilityChecker.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Row\AccessibilityChecker; - -/** - * Checks if print delivery slip option can be visible in order list. - */ -final class PrintDeliverySlipAccessibilityChecker implements AccessibilityCheckerInterface -{ - /** - * {@inheritdoc} - */ - public function isGranted(array $record) - { - return $record['delivery_number'] ?? null; - } -} diff --git a/src/Core/Grid/Action/Row/AccessibilityChecker/PrintInvoiceAccessibilityChecker.php b/src/Core/Grid/Action/Row/AccessibilityChecker/PrintInvoiceAccessibilityChecker.php deleted file mode 100644 index e2400e90..00000000 --- a/src/Core/Grid/Action/Row/AccessibilityChecker/PrintInvoiceAccessibilityChecker.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Row\AccessibilityChecker; - -/** - * Checks if print invoice option can be visible in order list. - */ -final class PrintInvoiceAccessibilityChecker implements AccessibilityCheckerInterface -{ - /** - * {@inheritdoc} - */ - public function isGranted(array $record) - { - return $record['is_invoice_available'] ?? null; - } -} diff --git a/src/Core/Grid/Action/Row/RowActionCollection.php b/src/Core/Grid/Action/Row/RowActionCollection.php deleted file mode 100644 index 230dcf1d..00000000 --- a/src/Core/Grid/Action/Row/RowActionCollection.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Row; - -use PrestaShop\PrestaShop\Core\Grid\Collection\AbstractCollection; - -/** - * Class RowActionCollection defines contract for grid row action collection. - */ -final class RowActionCollection extends AbstractCollection implements RowActionCollectionInterface -{ - /** - * {@inheritdoc} - */ - public function add(RowActionInterface $action) - { - $this->items[$action->getId()] = $action; - - return $this; - } -} diff --git a/src/Core/Grid/Action/Row/RowActionCollectionInterface.php b/src/Core/Grid/Action/Row/RowActionCollectionInterface.php deleted file mode 100644 index 1befaebd..00000000 --- a/src/Core/Grid/Action/Row/RowActionCollectionInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Row; - -use Iterator; - -/** - * Interface RowActionCollectionInterface defines contract for row actions collection. - */ -interface RowActionCollectionInterface extends Iterator -{ - /** - * Add row action to collection. - * - * @param RowActionInterface $action - * - * @return self - */ - public function add(RowActionInterface $action); -} diff --git a/src/Core/Grid/Action/Row/RowActionInterface.php b/src/Core/Grid/Action/Row/RowActionInterface.php deleted file mode 100644 index f788e3e5..00000000 --- a/src/Core/Grid/Action/Row/RowActionInterface.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Row; - -/** - * Interface RowActionInterface defines contract for grid's row action. - */ -interface RowActionInterface -{ - /** - * Get unique row id for grid row's action. - * - * @return string - */ - public function getId(); - - /** - * Get action type. - * - * @return string - */ - public function getType(); - - /** - * Get translated row action name. - * - * @return string - */ - public function getName(); - - /** - * Set action name. - * - * @param string $name - * - * @return self - */ - public function setName($name); - - /** - * Get row action icon. - * - * @return string - */ - public function getIcon(); - - /** - * Set action icon. - * - * @param string $icon - * - * @return self - */ - public function setIcon($icon); - - /** - * Get action options. - * - * @return array - */ - public function getOptions(); - - /** - * Set action options. - * - * @param array $options - * - * @return self - */ - public function setOptions(array $options); - - /** - * Check if action is applicable for given record. - * - * @param array $record - * - * @return bool - */ - public function isApplicable(array $record); -} diff --git a/src/Core/Grid/Action/Row/Type/Category/DeleteCategoryRowAction.php b/src/Core/Grid/Action/Row/Type/Category/DeleteCategoryRowAction.php deleted file mode 100644 index 4776a199..00000000 --- a/src/Core/Grid/Action/Row/Type/Category/DeleteCategoryRowAction.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\Category; - -use PrestaShop\PrestaShop\Core\Grid\Action\Row\AbstractRowAction; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class DeleteCategoryRowAction adds "Delete" action to row. - */ -final class DeleteCategoryRowAction extends AbstractRowAction -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'delete_category'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - - $resolver - ->setRequired([ - 'category_id_field', - 'category_delete_route', - ]) - ->setAllowedTypes('category_id_field', 'string') - ->setAllowedTypes('category_delete_route', 'string'); - } -} diff --git a/src/Core/Grid/Action/Row/Type/Customer/DeleteCustomerRowAction.php b/src/Core/Grid/Action/Row/Type/Customer/DeleteCustomerRowAction.php deleted file mode 100644 index f098881d..00000000 --- a/src/Core/Grid/Action/Row/Type/Customer/DeleteCustomerRowAction.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\Customer; - -use PrestaShop\PrestaShop\Core\Grid\Action\Row\AbstractRowAction; -use Symfony\Component\OptionsResolver\OptionsResolver; - -final class DeleteCustomerRowAction extends AbstractRowAction -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'delete_customer'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - - $resolver - ->setRequired([ - 'customer_id_field', - 'customer_delete_route', - ]) - ->setAllowedTypes('customer_id_field', 'string') - ->setAllowedTypes('customer_delete_route', 'string') - ; - } -} diff --git a/src/Core/Grid/Action/Row/Type/LinkRowAction.php b/src/Core/Grid/Action/Row/Type/LinkRowAction.php deleted file mode 100644 index 7b15983c..00000000 --- a/src/Core/Grid/Action/Row/Type/LinkRowAction.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Row\Type; - -use PrestaShop\PrestaShop\Core\Grid\Action\Row\AbstractRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\AccessibilityChecker\AccessibilityCheckerInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -final class LinkRowAction extends AbstractRowAction -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'link'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - - $resolver - ->setRequired([ - 'route', - 'route_param_name', - 'route_param_field', - ]) - ->setDefaults([ - 'confirm_message' => '', - 'accessibility_checker' => null, - //pass extra_route_params in case one param is not enough. - //route_param_name and route_param_field becomes redundant, but it cannot be removed due to BC break - 'extra_route_params' => [], - 'clickable_row' => false, - ]) - ->setAllowedTypes('route', 'string') - ->setAllowedTypes('route_param_name', 'string') - ->setAllowedTypes('route_param_field', 'string') - ->setAllowedTypes('extra_route_params', 'array') - ->setAllowedTypes('confirm_message', 'string') - ->setAllowedTypes('accessibility_checker', [AccessibilityCheckerInterface::class, 'callable', 'null']) - ->setAllowedTypes('clickable_row', 'boolean') - ; - } - - /** - * {@inheritdoc} - */ - public function isApplicable(array $record) - { - $accessibilityChecker = $this->getOptions()['accessibility_checker']; - - if ($accessibilityChecker instanceof AccessibilityCheckerInterface) { - return $accessibilityChecker->isGranted($record); - } - - if (is_callable($accessibilityChecker)) { - return call_user_func($accessibilityChecker, $record); - } - - return parent::isApplicable($record); - } -} diff --git a/src/Core/Grid/Action/Row/Type/SubmitRowAction.php b/src/Core/Grid/Action/Row/Type/SubmitRowAction.php deleted file mode 100644 index 1888bd26..00000000 --- a/src/Core/Grid/Action/Row/Type/SubmitRowAction.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Row\Type; - -use PrestaShop\PrestaShop\Core\Grid\Action\Row\AbstractRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\AccessibilityChecker\AccessibilityCheckerInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Defines row action as form submit. - */ -final class SubmitRowAction extends AbstractRowAction -{ - const MESSAGE_TYPE_STATIC = 'static'; // Static confirmation message type is standard confirmation message type - const MESSAGE_TYPE_DYNAMIC = 'dynamic'; // Dynamic confirmation message type enables dynamic confirmation message - - /** - * {@inheritdoc} - */ - public function getType() - { - return 'submit'; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - - $resolver - ->setRequired([ - 'route', - 'route_param_name', - 'route_param_field', - ]) - ->setDefaults([ - 'method' => 'POST', - 'confirm_message' => '', - 'accessibility_checker' => null, - 'confirm_message_type' => self::MESSAGE_TYPE_STATIC, - 'dynamic_message_field' => '', - 'extra_route_params' => [], - ]) - ->setAllowedTypes('route', 'string') - ->setAllowedTypes('route_param_name', 'string') - ->setAllowedTypes('route_param_field', 'string') - ->setAllowedTypes('extra_route_params', 'array') - ->setAllowedTypes('method', 'string') - ->setAllowedTypes('confirm_message', 'string') - ->setAllowedTypes('accessibility_checker', [AccessibilityCheckerInterface::class, 'callable', 'null']) - ->setAllowedTypes('dynamic_message_field', 'string') - ->setAllowedTypes('confirm_message_type', 'string') - ; - } - - /** - * {@inheritdoc} - */ - public function isApplicable(array $record) - { - $accessibilityChecker = $this->getOptions()['accessibility_checker']; - - if ($accessibilityChecker instanceof AccessibilityCheckerInterface) { - return $accessibilityChecker->isGranted($record); - } - - if (is_callable($accessibilityChecker)) { - return call_user_func($accessibilityChecker, $record); - } - - return parent::isApplicable($record); - } -} diff --git a/src/Core/Grid/Action/Type/LinkGridAction.php b/src/Core/Grid/Action/Type/LinkGridAction.php deleted file mode 100644 index d75c118f..00000000 --- a/src/Core/Grid/Action/Type/LinkGridAction.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Type; - -use PrestaShop\PrestaShop\Core\Grid\Action\AbstractGridAction; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class LinkGridAction defines grid action which is link. - */ -final class LinkGridAction extends AbstractGridAction -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'link'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'route', - ]) - ->setDefaults([ - 'route_params' => [], - ]) - ->setAllowedTypes('route', 'string') - ->setAllowedTypes('route_params', 'array'); - } -} diff --git a/src/Core/Grid/Action/Type/SimpleGridAction.php b/src/Core/Grid/Action/Type/SimpleGridAction.php deleted file mode 100644 index ddba106e..00000000 --- a/src/Core/Grid/Action/Type/SimpleGridAction.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Type; - -use PrestaShop\PrestaShop\Core\Grid\Action\AbstractGridAction; - -final class SimpleGridAction extends AbstractGridAction -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'simple'; - } -} diff --git a/src/Core/Grid/Action/Type/SubmitGridAction.php b/src/Core/Grid/Action/Type/SubmitGridAction.php deleted file mode 100644 index 379e73f9..00000000 --- a/src/Core/Grid/Action/Type/SubmitGridAction.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Action\Type; - -use PrestaShop\PrestaShop\Core\Grid\Action\AbstractGridAction; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class SubmitGridAction represents grid action that can be submitted. - */ -final class SubmitGridAction extends AbstractGridAction -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'submit'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'submit_route', - ]) - ->setDefaults([ - 'submit_method' => 'POST', - 'confirm_message' => null, - ]) - ->setAllowedTypes('submit_route', 'string') - ->setAllowedTypes('confirm_message', ['null', 'string']) - ->setAllowedValues('submit_method', ['POST', 'GET']); - } -} diff --git a/src/Core/Grid/Collection/AbstractCollection.php b/src/Core/Grid/Collection/AbstractCollection.php deleted file mode 100644 index 4b695918..00000000 --- a/src/Core/Grid/Collection/AbstractCollection.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Collection; - -use Countable; -use Iterator; - -/** - * Class AbstractCollection is responsible for providing base collection implementation. - */ -abstract class AbstractCollection implements Iterator, Countable -{ - /** - * @var array - */ - protected $items = []; - - /** - * {@inheritdoc} - */ - public function current() - { - return current($this->items); - } - - /** - * {@inheritdoc} - */ - public function next() - { - return next($this->items); - } - - /** - * {@inheritdoc} - */ - public function key() - { - return key($this->items); - } - - /** - * {@inheritdoc} - */ - public function valid() - { - return false !== $this->current(); - } - - /** - * {@inheritdoc} - */ - public function rewind() - { - reset($this->items); - } - - /** - * {@inheritdoc} - */ - public function count() - { - return count($this->items); - } -} diff --git a/src/Core/Grid/Column/AbstractColumn.php b/src/Core/Grid/Column/AbstractColumn.php deleted file mode 100644 index 7cacc686..00000000 --- a/src/Core/Grid/Column/AbstractColumn.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column; - -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class AbtractColumn implements reusable column methods. - */ -abstract class AbstractColumn implements ColumnInterface -{ - /** - * @var string - */ - private $id; - - /** - * @var string - */ - private $name; - - /** - * @var array - */ - private $options; - - /** - * @param string $id - */ - public function __construct($id) - { - $this->id = $id; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function setName($name) - { - $this->name = $name; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setOptions(array $options) - { - $this->resolveOptions($options); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getOptions() - { - if (null === $this->options) { - $this->resolveOptions(); - } - - return $this->options; - } - - /** - * Default column options configuration. You can override or extend it needed options. - * - * @param OptionsResolver $resolver - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setDefaults([ - 'sortable' => true, - 'clickable' => false, - ]) - ->setAllowedTypes('sortable', 'bool') - ->setAllowedTypes('clickable', 'bool'); - } - - /** - * Resolve column options. - * - * @param array $options - */ - private function resolveOptions(array $options = []) - { - $resolver = new OptionsResolver(); - $this->configureOptions($resolver); - - $this->options = $resolver->resolve($options); - } -} diff --git a/src/Core/Grid/Column/ColumnCollection.php b/src/Core/Grid/Column/ColumnCollection.php deleted file mode 100644 index 0c15b5d1..00000000 --- a/src/Core/Grid/Column/ColumnCollection.php +++ /dev/null @@ -1,163 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column; - -use PrestaShop\PrestaShop\Core\Grid\Collection\AbstractCollection; -use PrestaShop\PrestaShop\Core\Grid\Exception\ColumnNotFoundException; - -/** - * Class ColumnCollection holds collection of columns for grid. - * - * @property ColumnInterface[] $items - */ -final class ColumnCollection extends AbstractCollection implements ColumnCollectionInterface -{ - /** - * @internal - */ - const POSITION_AFTER = 'after'; - - /** - * @internal - */ - const POSITION_BEFORE = 'before'; - - /** - * {@inheritdoc} - */ - public function add(ColumnInterface $column) - { - $this->items[$column->getId()] = $column; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function addAfter($id, ColumnInterface $newColumn) - { - $this->insertByPosition($id, $newColumn, self::POSITION_AFTER); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function addBefore($id, ColumnInterface $newColumn) - { - $this->insertByPosition($id, $newColumn, self::POSITION_BEFORE); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function remove($id) - { - if (isset($this->items[$id])) { - unset($this->items[$id]); - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function toArray() - { - $columns = []; - - foreach ($this->items as $item) { - $columns[] = [ - 'id' => $item->getId(), - 'name' => $item->getName(), - 'type' => $item->getType(), - 'options' => $item->getOptions(), - ]; - } - - return $columns; - } - - /** - * Move an existing Column to a specific position. - * - * @param string $id the Column ID original position in the Collection - * @param int $position the Column ID destination position in the Collection - * - * @return self - */ - public function move($id, $position) - { - if (!isset($this->items[$id])) { - throw new ColumnNotFoundException(sprintf('Cannot insert new column into collection. Column with id "%s" was not found.', $id)); - } - - $column = $this->items[$id]; - unset($this->items[$id]); - - $columns = array_slice($this->items, 0, $position, true) + - [$column->getId() => $column] + - array_slice($this->items, $position, null, true); - - $this->items = $columns; - - return $this; - } - - /** - * Insert new column into collection at given position. - * - * @param string $id Existing column id - * @param ColumnInterface $newColumn Column to insert - * @param string $position Position: "before" or "after" - * - * @throws ColumnNotFoundException When column with given $id does not exist - */ - private function insertByPosition($id, ColumnInterface $newColumn, $position) - { - if (!isset($this->items[$id])) { - throw new ColumnNotFoundException(sprintf('Cannot insert new column into collection. Column with id "%s" was not found.', $id)); - } - - $existingColumnKeyPosition = array_search($id, array_keys($this->items)); - - if (self::POSITION_AFTER === $position) { - ++$existingColumnKeyPosition; - } - - $columns = array_slice($this->items, 0, $existingColumnKeyPosition, true) + - [$newColumn->getId() => $newColumn] + - array_slice($this->items, $existingColumnKeyPosition, null, true); - - $this->items = $columns; - } -} diff --git a/src/Core/Grid/Column/ColumnCollectionInterface.php b/src/Core/Grid/Column/ColumnCollectionInterface.php deleted file mode 100644 index d5cfb0f7..00000000 --- a/src/Core/Grid/Column/ColumnCollectionInterface.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column; - -use Countable; -use Iterator; - -/** - * Interface ColumnCollectionInterface defines contract for grid column collection. - */ -interface ColumnCollectionInterface extends Iterator, Countable -{ - /** - * Add column to collection. - * - * @param ColumnInterface $column - * - * @return self - */ - public function add(ColumnInterface $column); - - /** - * Add column after given column. - * - * @param string $id Column id - * @param ColumnInterface $column - * - * @return self - */ - public function addAfter($id, ColumnInterface $column); - - /** - * @param string $id Column id - * @param ColumnInterface $column - * - * @return self - */ - public function addBefore($id, ColumnInterface $column); - - /** - * Remove column from collection. - * - * @param string $id - * - * @return self - */ - public function remove($id); - - /** - * Get columns as array. - * - * @return array - */ - public function toArray(); -} diff --git a/src/Core/Grid/Column/ColumnInterface.php b/src/Core/Grid/Column/ColumnInterface.php deleted file mode 100644 index ee07aea9..00000000 --- a/src/Core/Grid/Column/ColumnInterface.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column; - -/** - * Interface ColumnInterface exposes contract for single column. - */ -interface ColumnInterface -{ - /** - * Get unique column id. - * - * @return string - * @return self - */ - public function getId(); - - /** - * Get column type. - * - * @return string - */ - public function getType(); - - /** - * Get translated column name. - * - * @return string - */ - public function getName(); - - /** - * Translated column name. - * - * @param string $name - * - * @return self - */ - public function setName($name); - - /** - * Get column related options. - * - * @return array - */ - public function getOptions(); - - /** - * Set column options. - * - * @param array $options - * - * @return self - */ - public function setOptions(array $options); -} diff --git a/src/Core/Grid/Column/Type/Attribute/AttributeColorColumn.php b/src/Core/Grid/Column/Type/Attribute/AttributeColorColumn.php deleted file mode 100644 index 4191b705..00000000 --- a/src/Core/Grid/Column/Type/Attribute/AttributeColorColumn.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type\Attribute; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Defines column which renders a block filled with color - */ -final class AttributeColorColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'attribute_color'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - - $resolver - ->setRequired([ - 'field', - ]) - ->setAllowedTypes('field', 'string') - ; - } -} diff --git a/src/Core/Grid/Column/Type/BooleanColumn.php b/src/Core/Grid/Column/Type/BooleanColumn.php deleted file mode 100644 index 7e139b95..00000000 --- a/src/Core/Grid/Column/Type/BooleanColumn.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Boolean column allows adding boolean columns (Yes/No, On/Off and etc) to grid - */ -final class BooleanColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'boolean'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'field', - 'true_name', - 'false_name', - ]) - ->setDefaults([ - 'clickable' => false, - ]) - ->setAllowedTypes('field', 'string') - ->setAllowedTypes('true_name', 'string') - ->setAllowedTypes('true_name', 'string') - ->setAllowedTypes('clickable', 'bool') - ; - } -} diff --git a/src/Core/Grid/Column/Type/Category/CategoryPositionColumn.php b/src/Core/Grid/Column/Type/Category/CategoryPositionColumn.php deleted file mode 100644 index c26a22ae..00000000 --- a/src/Core/Grid/Column/Type/Category/CategoryPositionColumn.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type\Category; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class CategoryPositionColumn. - */ -final class CategoryPositionColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'category_position'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'field', - 'id_field', - 'id_parent_field', - 'update_route', - ]) - ->setDefaults([ - 'sortable' => true, - ]) - ->setAllowedTypes('sortable', 'bool') - ->setAllowedTypes('field', 'string') - ->setAllowedTypes('id_field', 'string') - ->setAllowedTypes('id_parent_field', 'string') - ->setAllowedTypes('update_route', 'string'); - } -} diff --git a/src/Core/Grid/Column/Type/ColorColumn.php b/src/Core/Grid/Column/Type/ColorColumn.php deleted file mode 100644 index f54c7a49..00000000 --- a/src/Core/Grid/Column/Type/ColorColumn.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Column which background color can be configured. - */ -final class ColorColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'color'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - - $resolver - ->setRequired([ - 'field', - 'color_field', - ]) - ; - } -} diff --git a/src/Core/Grid/Column/Type/Common/ActionColumn.php b/src/Core/Grid/Column/Type/Common/ActionColumn.php deleted file mode 100644 index 145b15d7..00000000 --- a/src/Core/Grid/Column/Type/Common/ActionColumn.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type\Common; - -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -final class ActionColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'action'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setDefaults([ - 'actions' => null, - ]) - ->setAllowedTypes('actions', ['null', RowActionCollection::class]); - } -} diff --git a/src/Core/Grid/Column/Type/Common/BadgeColumn.php b/src/Core/Grid/Column/Type/Common/BadgeColumn.php deleted file mode 100644 index 2fffe64c..00000000 --- a/src/Core/Grid/Column/Type/Common/BadgeColumn.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type\Common; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class BadgeColumn displays column with badge. - */ -final class BadgeColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'badge'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - - $resolver - ->setRequired([ - 'field', - ]) - ->setDefaults([ - 'badge_type' => 'success', - 'empty_value' => '', - 'clickable' => true, - ]) - ->setAllowedTypes('field', 'string') - ->setAllowedTypes('empty_value', 'string') - ->setAllowedTypes('clickable', 'bool') - ->setAllowedValues('badge_type', ['success', 'info', 'danger', 'warning']); - } -} diff --git a/src/Core/Grid/Column/Type/Common/BulkActionColumn.php b/src/Core/Grid/Column/Type/Common/BulkActionColumn.php deleted file mode 100644 index df089689..00000000 --- a/src/Core/Grid/Column/Type/Common/BulkActionColumn.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type\Common; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -final class BulkActionColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'bulk_action'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'bulk_field', - ]) - ->setAllowedTypes('bulk_field', 'string'); - } -} diff --git a/src/Core/Grid/Column/Type/Common/ChoiceColumn.php b/src/Core/Grid/Column/Type/Common/ChoiceColumn.php deleted file mode 100644 index 3820ab93..00000000 --- a/src/Core/Grid/Column/Type/Common/ChoiceColumn.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type\Common; - -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Displays choices in the grid. - */ -final class ChoiceColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType(): string - { - return 'choice'; - } - - protected function configureOptions(OptionsResolver $resolver): void - { - parent::configureOptions($resolver); - - $resolver - ->setRequired( - [ - 'choice_provider', - 'field', - 'route', - ] - ) - ->setDefaults([ - 'color_field' => '', - 'record_route_params' => [], - ]) - ->setAllowedTypes('choice_provider', ConfigurableFormChoiceProviderInterface::class) - ->setAllowedTypes('field', ['string', 'int', 'bool']) - ->setAllowedTypes('color_field', 'string') - ->setAllowedTypes('route', 'string') - ->setAllowedTypes('record_route_params', 'array') - ; - } -} diff --git a/src/Core/Grid/Column/Type/Common/DateTimeColumn.php b/src/Core/Grid/Column/Type/Common/DateTimeColumn.php deleted file mode 100644 index b86476c4..00000000 --- a/src/Core/Grid/Column/Type/Common/DateTimeColumn.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type\Common; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -final class DateTimeColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'date_time'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - - $resolver - ->setRequired([ - 'field', - ]) - ->setDefaults([ - 'format' => 'Y-m-d H:i:s', - 'empty_data' => '', - 'clickable' => false, - ]) - ->setAllowedTypes('format', 'string') - ->setAllowedTypes('field', 'string') - ->setAllowedTypes('empty_data', 'string') - ->setAllowedTypes('clickable', 'bool'); - } -} diff --git a/src/Core/Grid/Column/Type/Common/DraggableColumn.php b/src/Core/Grid/Column/Type/Common/DraggableColumn.php deleted file mode 100644 index 5bc1ddf7..00000000 --- a/src/Core/Grid/Column/Type/Common/DraggableColumn.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type\Common; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Is used to add draggable column to grid. - * This column is commonly used with PositionColumn. - */ -final class DraggableColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'draggable'; - } - - /** - * @param OptionsResolver $resolver - */ - protected function configureOptions(OptionsResolver $resolver) - { - } -} diff --git a/src/Core/Grid/Column/Type/Common/IdentifierColumn.php b/src/Core/Grid/Column/Type/Common/IdentifierColumn.php deleted file mode 100644 index 4c2e8bab..00000000 --- a/src/Core/Grid/Column/Type/Common/IdentifierColumn.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type\Common; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\PreviewColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Columns is used as identifier in grid (e.g. Product ID, Category ID & etc) - */ -final class IdentifierColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'identifier'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'identifier_field', - ]) - ->setDefaults([ - 'sortable' => true, - 'with_bulk_field' => false, - 'bulk_field' => null, - 'preview' => null, - 'clickable' => true, - ]) - ->setAllowedTypes('identifier_field', 'string') - ->setAllowedTypes('sortable', 'bool') - ->setAllowedTypes('with_bulk_field', 'bool') - ->setAllowedTypes('bulk_field', ['string', 'null']) - ->setAllowedTypes('clickable', 'bool') - ->setAllowedValues('preview', function ($previewColumn) { - return $previewColumn instanceof PreviewColumn || $previewColumn === null; - }) - ; - } -} diff --git a/src/Core/Grid/Column/Type/Common/ImageColumn.php b/src/Core/Grid/Column/Type/Common/ImageColumn.php deleted file mode 100644 index 4122f2b8..00000000 --- a/src/Core/Grid/Column/Type/Common/ImageColumn.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type\Common; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class ImageColumn renders column as image. - */ -final class ImageColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'image'; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'src_field', - ]) - ->setDefaults([ - 'clickable' => true, - ]) - ->setAllowedTypes('src_field', 'string') - ->setAllowedTypes('clickable', 'bool'); - } -} diff --git a/src/Core/Grid/Column/Type/Common/LinkColumn.php b/src/Core/Grid/Column/Type/Common/LinkColumn.php deleted file mode 100644 index 6e834d83..00000000 --- a/src/Core/Grid/Column/Type/Common/LinkColumn.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type\Common; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class LinkColumn is used to define column which is link to record action (view, edit, add). - */ -final class LinkColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'link'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setDefaults([ - 'sortable' => true, - 'icon' => null, - 'button_template' => false, - 'color_template' => 'primary', - 'clickable' => false, - ]) - ->setRequired([ - 'field', - 'route', - 'route_param_name', - 'route_param_field', - ]) - ->setDefined([ - 'icon', - 'target', - ]) - ->setAllowedTypes('field', ['string', 'null']) - ->setAllowedTypes('icon', ['string', 'null']) - ->setAllowedTypes('target', ['string', 'null']) - ->setAllowedTypes('sortable', 'bool') - ->setAllowedTypes('route', 'string') - ->setAllowedTypes('route_param_name', 'string') - ->setAllowedTypes('route_param_field', 'string') - ->setAllowedTypes('clickable', 'bool') - ->setAllowedValues('color_template', [ - 'primary', - 'secondary', - 'success', - 'danger', - 'warning', - 'info', - ]) - ->setAllowedValues('button_template', [ - false, - 'outline', - 'normal', - ]) - - ; - } -} diff --git a/src/Core/Grid/Column/Type/Common/PositionColumn.php b/src/Core/Grid/Column/Type/Common/PositionColumn.php deleted file mode 100644 index b83ae5c5..00000000 --- a/src/Core/Grid/Column/Type/Common/PositionColumn.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type\Common; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use PrestaShop\PrestaShop\Core\Grid\Position\GridPositionUpdater; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class PositionColumn defines a position column used to sort elements in a grid, - * it is associated to a special template, and works well with the PositionExtension - * javascript extension and the GridPositionUpdater service. - * - * @see admin-dev/themes/new-theme/js/components/grid/extension/position-extension.js - * @see GridPositionUpdater - */ -final class PositionColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'position'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'id_field', - 'position_field', - 'update_route', - ]) - ->setDefaults([ - 'sortable' => true, - 'update_method' => 'GET', - 'record_route_params' => [], - 'clickable' => true, - ]) - ->setAllowedTypes('id_field', 'string') - ->setAllowedTypes('position_field', 'string') - ->setAllowedTypes('update_route', 'string') - ->setAllowedTypes('sortable', 'bool') - ->setAllowedTypes('update_method', 'string') - ->setAllowedTypes('record_route_params', ['array']) - ->setAllowedTypes('clickable', 'bool') - ->setAllowedValues('update_method', ['GET', 'POST']); - } -} diff --git a/src/Core/Grid/Column/Type/Common/ToggleColumn.php b/src/Core/Grid/Column/Type/Common/ToggleColumn.php deleted file mode 100644 index 6cd82faa..00000000 --- a/src/Core/Grid/Column/Type/Common/ToggleColumn.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type\Common; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\Exception\MissingOptionsException; -use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * This Column is used to display booleans. - * - it will display an icon instead of the value - * - if user clicks on it, this triggers a toggle of the boolean value. - */ -final class ToggleColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'toggle'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setDefaults([ - 'sortable' => true, - // @deprecated, use route_param_name option instead - 'route_param_id' => '', - 'route_param_name' => '', - ]) - ->setRequired([ - 'field', - 'primary_field', - 'route', - ]) - ->setAllowedTypes('field', 'string') - ->setAllowedTypes('primary_field', 'string') - ->setAllowedTypes('route', 'string') - ->setAllowedTypes('route_param_name', 'string') - ->setAllowedTypes('sortable', 'bool') - ->setAllowedTypes('route_param_id', 'string') - ; - - $resolver->setNormalizer('route_param_name', static function (Options $options, $value) { - if (!empty($value)) { - return $value; - } - - // Fallback on route_param_id if it's specified - if (!empty($options['route_param_id'])) { - return $options['route_param_id']; - } - - throw new MissingOptionsException(sprintf('Option "%s" is missing for "%s" column options.', 'route_param_name', self::class)); - }); - } -} diff --git a/src/Core/Grid/Column/Type/DataColumn.php b/src/Core/Grid/Column/Type/DataColumn.php deleted file mode 100644 index 9797884e..00000000 --- a/src/Core/Grid/Column/Type/DataColumn.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class Column defines most simple column in the grid that renders raw data. - */ -final class DataColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'data'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - - $resolver - ->setRequired([ - 'field', - ]) - ->setDefaults([ - 'clickable' => true, - ]) - ->setAllowedTypes('field', 'string') - ->setAllowedTypes('clickable', 'bool') - ; - } -} diff --git a/src/Core/Grid/Column/Type/DisableableLinkColumn.php b/src/Core/Grid/Column/Type/DisableableLinkColumn.php deleted file mode 100644 index 88ab38e9..00000000 --- a/src/Core/Grid/Column/Type/DisableableLinkColumn.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\LinkColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -final class DisableableLinkColumn extends AbstractColumn -{ - /** - * @var LinkColumn - */ - private $linkColumn; - - public function __construct($id) - { - parent::__construct($id); - $this->linkColumn = new LinkColumn($id); - } - - /** - * {@inheritdoc} - */ - public function getType() - { - return 'disableable_link'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired(['disabled_field']) - ->setAllowedTypes('disabled_field', ['string', 'null']) - ; - } - - /** - * {@inheritdoc} - */ - public function setOptions(array $options) - { - $disabledOptions = []; - - if (isset($options['disabled_field'])) { - $disabledOptions['disabled_field'] = $options['disabled_field']; - unset($options['disabled_field']); - } - - $this->linkColumn->setOptions($options); - parent::setOptions($disabledOptions); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getOptions() - { - return array_merge($this->linkColumn->getOptions(), parent::getOptions()); - } -} diff --git a/src/Core/Grid/Column/Type/Employee/EmployeeNameWithAvatarColumn.php b/src/Core/Grid/Column/Type/Employee/EmployeeNameWithAvatarColumn.php deleted file mode 100644 index 9384a98c..00000000 --- a/src/Core/Grid/Column/Type/Employee/EmployeeNameWithAvatarColumn.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type\Employee; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -final class EmployeeNameWithAvatarColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'employee_name_with_avatar'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - - $resolver - ->setRequired([ - 'field', - ]) - ->setAllowedTypes('field', 'string'); - } -} diff --git a/src/Core/Grid/Column/Type/LinkGroupColumn.php b/src/Core/Grid/Column/Type/LinkGroupColumn.php deleted file mode 100644 index c5e1ecf6..00000000 --- a/src/Core/Grid/Column/Type/LinkGroupColumn.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Allows adding group of links in single column - */ -final class LinkGroupColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'link_group'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'links', - ]) - ->setAllowedTypes('links', 'array') - ; - } -} diff --git a/src/Core/Grid/Column/Type/OrderPriceColumn.php b/src/Core/Grid/Column/Type/OrderPriceColumn.php deleted file mode 100644 index 44c2bf38..00000000 --- a/src/Core/Grid/Column/Type/OrderPriceColumn.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Displays order price - */ -final class OrderPriceColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'order_price'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - - $resolver - ->setRequired([ - 'field', - 'is_paid_field', - ]) - ->setAllowedTypes('field', 'string') - ->setAllowedTypes('is_paid_field', 'string') - ; - } -} diff --git a/src/Core/Grid/Column/Type/PreviewColumn.php b/src/Core/Grid/Column/Type/PreviewColumn.php deleted file mode 100644 index fdd8c970..00000000 --- a/src/Core/Grid/Column/Type/PreviewColumn.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Allows adding Preview functionality to grid rows - */ -final class PreviewColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'preview'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'icon_expand', - 'icon_collapse', - 'preview_data_route', - ]) - ->setDefined([ - 'preview_route_params', - ]) - ->setAllowedTypes('preview_data_route', 'string') - ->setAllowedTypes('preview_route_params', 'array') - ->setAllowedTypes('icon_expand', 'string') - ->setAllowedTypes('icon_collapse', 'string') - ; - } -} diff --git a/src/Core/Grid/Column/Type/Status/SeverityLevelColumn.php b/src/Core/Grid/Column/Type/Status/SeverityLevelColumn.php deleted file mode 100644 index 2732834a..00000000 --- a/src/Core/Grid/Column/Type/Status/SeverityLevelColumn.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Column\Type\Status; - -use PrestaShop\PrestaShop\Core\Grid\Column\AbstractColumn; -use Symfony\Component\OptionsResolver\OptionsResolver; - -final class SeverityLevelColumn extends AbstractColumn -{ - /** - * {@inheritdoc} - */ - public function getType() - { - return 'severity_level'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - - $resolver - ->setRequired([ - 'field', - ]) - ->setDefaults([ - 'with_message' => false, - ]) - ->setAllowedTypes('with_message', 'bool') - ->setAllowedTypes('field', 'string'); - } -} diff --git a/src/Core/Grid/Data/Factory/AttachmentGridDataFactoryDecorator.php b/src/Core/Grid/Data/Factory/AttachmentGridDataFactoryDecorator.php deleted file mode 100644 index c8664057..00000000 --- a/src/Core/Grid/Data/Factory/AttachmentGridDataFactoryDecorator.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Data\Factory; - -use Doctrine\DBAL\Connection; -use PDO; -use PrestaShop\PrestaShop\Core\Grid\Data\GridData; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollectionInterface; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use PrestaShop\PrestaShop\Core\Util\File\FileSizeConverter; -use PrestaShopBundle\Translation\TranslatorAwareTrait; - -/** - * Decorates attachment grid data factory - */ -final class AttachmentGridDataFactoryDecorator implements GridDataFactoryInterface -{ - use TranslatorAwareTrait; - - /** - * @var GridDataFactoryInterface - */ - private $attachmentDoctrineGridDataFactory; - - /** - * @var int - */ - private $employeeIdLang; - - /** - * @var Connection - */ - private $connection; - - /** - * @var string - */ - private $dbPrefix; - - /** - * @var FileSizeConverter - */ - private $fileSizeConverter; - - /** - * @param GridDataFactoryInterface $attachmentDoctrineGridDataFactory - * @param int $employeeIdLang - * @param Connection $connection - * @param string $dbPrefix - * @param FileSizeConverter $fileSizeConverter - */ - public function __construct( - GridDataFactoryInterface $attachmentDoctrineGridDataFactory, - int $employeeIdLang, - Connection $connection, - string $dbPrefix, - FileSizeConverter $fileSizeConverter - ) { - $this->attachmentDoctrineGridDataFactory = $attachmentDoctrineGridDataFactory; - $this->employeeIdLang = $employeeIdLang; - $this->connection = $connection; - $this->dbPrefix = $dbPrefix; - $this->fileSizeConverter = $fileSizeConverter; - } - - /** - * {@inheritdoc} - */ - public function getData(SearchCriteriaInterface $searchCriteria) - { - $attachmentData = $this->attachmentDoctrineGridDataFactory->getData($searchCriteria); - - $attachmentRecords = $this->applyModifications($attachmentData->getRecords()); - - return new GridData( - $attachmentRecords, - $attachmentData->getRecordsTotal(), - $attachmentData->getQuery() - ); - } - - /** - * @param RecordCollectionInterface $attachments - * - * @return RecordCollection - */ - private function applyModifications(RecordCollectionInterface $attachments): RecordCollection - { - $modifiedAttachments = []; - - foreach ($attachments as $attachment) { - if ((int) $attachment['products'] > 0) { - $productNamesArray = $this->getProductNames($attachment['id_attachment']); - $productNames = implode(', ', $productNamesArray); - $attachment['dynamic_message'] = $this->trans( - 'This file is associated with the following products. Are you sure you want to delete it?', - [], - 'Admin.Catalog.Notification' - ); - $attachment['dynamic_message'] .= PHP_EOL . PHP_EOL . $productNames; - } - - $attachment['file_size'] = $this->fileSizeConverter->convert((int) $attachment['file_size']); - $attachment['products'] .= ' ' . $this->trans('product(s)', [], 'Admin.Catalog.Feature'); - - $modifiedAttachments[] = $attachment; - } - - return new RecordCollection($modifiedAttachments); - } - - /** - * @param string $attachmentId - * - * @return array - */ - private function getProductNames(string $attachmentId): array - { - $qb = $this->connection->createQueryBuilder(); - - $qb->select('DISTINCT pl.`name`') - ->from($this->dbPrefix . 'product_attachment', 'pa') - ->leftJoin( - 'pa', - $this->dbPrefix . 'product_lang', - 'pl', - 'pa.`id_product` = pl.`id_product` AND pl.`id_lang` = :langId' - ) - ->where('pa.`id_attachment` = :attachmentId') - ->setParameter('attachmentId', $attachmentId) - ->setParameter('langId', $this->employeeIdLang); - - return $qb->execute()->fetchAll(PDO::FETCH_COLUMN); - } -} diff --git a/src/Core/Grid/Data/Factory/AttributeGroupGridDataFactory.php b/src/Core/Grid/Data/Factory/AttributeGroupGridDataFactory.php deleted file mode 100644 index 246eb888..00000000 --- a/src/Core/Grid/Data/Factory/AttributeGroupGridDataFactory.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Data\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Data\GridData; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Decorates database records for grid presentation - */ -final class AttributeGroupGridDataFactory implements GridDataFactoryInterface -{ - /** - * @var GridDataFactoryInterface - */ - private $attributeDataFactory; - - /** - * @param GridDataFactoryInterface $attributeDataFactory - */ - public function __construct(GridDataFactoryInterface $attributeDataFactory) - { - $this->attributeDataFactory = $attributeDataFactory; - } - - /** - * {@inheritdoc} - */ - public function getData(SearchCriteriaInterface $searchCriteria) - { - $records = $this->attributeDataFactory->getData($searchCriteria); - $modifiedRecords = $this->modifyRecords($records->getRecords()->all()); - - return new GridData( - new RecordCollection($modifiedRecords), - $records->getRecordsTotal(), - $records->getQuery() - ); - } - - /** - * @param array $records - * - * @return array - */ - private function modifyRecords(array $records): array - { - foreach ($records as &$record) { - if (null === $record['values']) { - $record['values'] = '0'; - } - } - - return $records; - } -} diff --git a/src/Core/Grid/Data/Factory/CatalogPriceRuleGridDataFactory.php b/src/Core/Grid/Data/Factory/CatalogPriceRuleGridDataFactory.php deleted file mode 100644 index feabc309..00000000 --- a/src/Core/Grid/Data/Factory/CatalogPriceRuleGridDataFactory.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Data\Factory; - -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Reduction; -use PrestaShop\PrestaShop\Core\Grid\Data\GridData; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Gets data for catalog price rule grid - */ -final class CatalogPriceRuleGridDataFactory implements GridDataFactoryInterface -{ - /** - * @var GridDataFactoryInterface - */ - private $priceRuleDataFactory; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param GridDataFactoryInterface $priceRuleDataFactory - * @param TranslatorInterface $translator - */ - public function __construct(GridDataFactoryInterface $priceRuleDataFactory, TranslatorInterface $translator) - { - $this->priceRuleDataFactory = $priceRuleDataFactory; - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getData(SearchCriteriaInterface $searchCriteria) - { - $priceRuleData = $this->priceRuleDataFactory->getData($searchCriteria); - - $modifiedRecords = $this->applyModification( - $priceRuleData->getRecords()->all() - ); - - return new GridData( - new RecordCollection($modifiedRecords), - $priceRuleData->getRecordsTotal(), - $priceRuleData->getQuery() - ); - } - - /** - * @param array $priceRules - * - * @return array - */ - private function applyModification(array $priceRules) - { - foreach ($priceRules as &$priceRule) { - foreach ($priceRule as &$value) { - if ($value === null) { - $value = '--'; - } - } - - Reduction::TYPE_AMOUNT === $priceRule['reduction_type'] ? - $priceRule['reduction_type'] = $this->translator->trans('Amount', [], 'Admin.Global') : - $priceRule['reduction_type'] = $this->translator->trans('Percentage', [], 'Admin.Global'); - } - - return $priceRules; - } -} diff --git a/src/Core/Grid/Data/Factory/CategoryDataFactory.php b/src/Core/Grid/Data/Factory/CategoryDataFactory.php deleted file mode 100644 index 57ac69a7..00000000 --- a/src/Core/Grid/Data/Factory/CategoryDataFactory.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Data\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Data\GridData; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class CategoryDataFactory decorates DoctrineGridDataFactory configured for categories to modify category records. - */ -final class CategoryDataFactory implements GridDataFactoryInterface -{ - /** - * @var GridDataFactoryInterface - */ - private $doctrineCategoryDataFactory; - - /** - * @param GridDataFactoryInterface $doctrineCategoryDataFactory - */ - public function __construct(GridDataFactoryInterface $doctrineCategoryDataFactory) - { - $this->doctrineCategoryDataFactory = $doctrineCategoryDataFactory; - } - - /** - * {@inheritdoc} - */ - public function getData(SearchCriteriaInterface $searchCriteria) - { - $data = $this->doctrineCategoryDataFactory->getData($searchCriteria); - - $records = $this->modifyRecords($data->getRecords()->all()); - - return new GridData( - new RecordCollection($records), - $data->getRecordsTotal(), - $data->getQuery() - ); - } - - /** - * Modify category records. - * - * @param array $records - * - * @return array - */ - private function modifyRecords(array $records) - { - foreach ($records as $key => $record) { - $records[$key]['description'] = strip_tags(stripslashes($record['description'])); - } - - return $records; - } -} diff --git a/src/Core/Grid/Data/Factory/CreditSlipGridDataFactory.php b/src/Core/Grid/Data/Factory/CreditSlipGridDataFactory.php deleted file mode 100644 index 2f139ef2..00000000 --- a/src/Core/Grid/Data/Factory/CreditSlipGridDataFactory.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Data\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Data\GridData; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Provides data for credit slip grid - */ -final class CreditSlipGridDataFactory implements GridDataFactoryInterface -{ - /** - * @var GridDataFactoryInterface - */ - private $creditSlipDataFactory; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param GridDataFactoryInterface $creditSlipDataFactory - * @param TranslatorInterface $translator - */ - public function __construct( - GridDataFactoryInterface $creditSlipDataFactory, - TranslatorInterface $translator - ) { - $this->creditSlipDataFactory = $creditSlipDataFactory; - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getData(SearchCriteriaInterface $searchCriteria) - { - $creditSlipData = $this->creditSlipDataFactory->getData($searchCriteria); - - $modifiedRecords = $this->applyModification( - $creditSlipData->getRecords()->all() - ); - - return new GridData( - new RecordCollection($modifiedRecords), - $creditSlipData->getRecordsTotal(), - $creditSlipData->getQuery() - ); - } - - /** - * @param array $creditSlips - * - * @return array - */ - private function applyModification(array $creditSlips) - { - foreach ($creditSlips as $i => $creditSlip) { - $creditSlips[$i]['link_value'] = $this->translator->trans( - 'Download credit slip', [], 'Admin.Orderscustomers.Feature' - ); - } - - return $creditSlips; - } -} diff --git a/src/Core/Grid/Data/Factory/CustomerGridDataFactoryDecorator.php b/src/Core/Grid/Data/Factory/CustomerGridDataFactoryDecorator.php deleted file mode 100644 index e2711003..00000000 --- a/src/Core/Grid/Data/Factory/CustomerGridDataFactoryDecorator.php +++ /dev/null @@ -1,120 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Data\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Data\GridData; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollectionInterface; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use PrestaShop\PrestaShop\Core\Localization\LocaleInterface; - -/** - * Class CustomerGridDataFactoryDecorator decorates data from customer doctrine data factory. - */ -final class CustomerGridDataFactoryDecorator implements GridDataFactoryInterface -{ - /** - * @var GridDataFactoryInterface - */ - private $customerDoctrineGridDataFactory; - - /** - * @var LocaleInterface - */ - private $locale; - - /** - * @var string - */ - private $contextCurrencyIsoCode; - - /** - * @param GridDataFactoryInterface $customerDoctrineGridDataFactory - * @param LocaleInterface $locale - * @param string $contextCurrencyIsoCode - */ - public function __construct( - GridDataFactoryInterface $customerDoctrineGridDataFactory, - LocaleInterface $locale, - $contextCurrencyIsoCode - ) { - $this->customerDoctrineGridDataFactory = $customerDoctrineGridDataFactory; - $this->locale = $locale; - $this->contextCurrencyIsoCode = $contextCurrencyIsoCode; - } - - /** - * {@inheritdoc} - */ - public function getData(SearchCriteriaInterface $searchCriteria) - { - $customerData = $this->customerDoctrineGridDataFactory->getData($searchCriteria); - - $customerRecords = $this->applyModifications($customerData->getRecords()); - - return new GridData( - $customerRecords, - $customerData->getRecordsTotal(), - $customerData->getQuery() - ); - } - - /** - * @param RecordCollectionInterface $customers - * - * @return RecordCollection - */ - private function applyModifications(RecordCollectionInterface $customers) - { - $modifiedCustomers = []; - - foreach ($customers as $customer) { - if (empty($customer['social_title'])) { - $customer['social_title'] = '--'; - } - - if (null === $customer['company']) { - $customer['company'] = '--'; - } - - if (!empty($customer['total_spent'])) { - $customer['total_spent'] = $this->locale->formatPrice( - $customer['total_spent'], - $this->contextCurrencyIsoCode - ); - } - - if (null === $customer['connect']) { - $customer['connect'] = '--'; - } - - $modifiedCustomers[] = $customer; - } - - return new RecordCollection($modifiedCustomers); - } -} diff --git a/src/Core/Grid/Data/Factory/DoctrineGridDataFactory.php b/src/Core/Grid/Data/Factory/DoctrineGridDataFactory.php deleted file mode 100644 index a1204725..00000000 --- a/src/Core/Grid/Data/Factory/DoctrineGridDataFactory.php +++ /dev/null @@ -1,120 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Data\Factory; - -use Doctrine\DBAL\Query\QueryBuilder; -use PDO; -use PrestaShop\PrestaShop\Core\Grid\Data\GridData; -use PrestaShop\PrestaShop\Core\Grid\Query\DoctrineQueryBuilderInterface; -use PrestaShop\PrestaShop\Core\Grid\Query\QueryParserInterface; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use Symfony\Component\DependencyInjection\Container; - -/** - * Class DoctrineGridDataFactory is responsible for returning grid data using Doctrine query builders. - */ -final class DoctrineGridDataFactory implements GridDataFactoryInterface -{ - /** - * @var DoctrineQueryBuilderInterface - */ - private $gridQueryBuilder; - - /** - * @var HookDispatcherInterface - */ - private $hookDispatcher; - - /** - * @var QueryParserInterface - */ - private $queryParser; - - /** - * @var string - */ - private $gridId; - - /** - * @param DoctrineQueryBuilderInterface $gridQueryBuilder - * @param HookDispatcherInterface $hookDispatcher - * @param QueryParserInterface $queryParser - * @param string $gridId - */ - public function __construct( - DoctrineQueryBuilderInterface $gridQueryBuilder, - HookDispatcherInterface $hookDispatcher, - QueryParserInterface $queryParser, - $gridId - ) { - $this->gridQueryBuilder = $gridQueryBuilder; - $this->hookDispatcher = $hookDispatcher; - $this->queryParser = $queryParser; - $this->gridId = $gridId; - } - - /** - * {@inheritdoc} - */ - public function getData(SearchCriteriaInterface $searchCriteria) - { - $searchQueryBuilder = $this->gridQueryBuilder->getSearchQueryBuilder($searchCriteria); - $countQueryBuilder = $this->gridQueryBuilder->getCountQueryBuilder($searchCriteria); - - $this->hookDispatcher->dispatchWithParameters('action' . Container::camelize($this->gridId) . 'GridQueryBuilderModifier', [ - 'search_query_builder' => $searchQueryBuilder, - 'count_query_builder' => $countQueryBuilder, - 'search_criteria' => $searchCriteria, - ]); - - $records = $searchQueryBuilder->execute()->fetchAll(); - $recordsTotal = (int) $countQueryBuilder->execute()->fetch(PDO::FETCH_COLUMN); - - $records = new RecordCollection($records); - - return new GridData( - $records, - $recordsTotal, - $this->getRawQuery($searchQueryBuilder) - ); - } - - /** - * @param QueryBuilder $queryBuilder - * - * @return string - */ - private function getRawQuery(QueryBuilder $queryBuilder) - { - $query = $queryBuilder->getSQL(); - $parameters = $queryBuilder->getParameters(); - - return $this->queryParser->parse($query, $parameters); - } -} diff --git a/src/Core/Grid/Data/Factory/EmptyCategoryGridDataFactory.php b/src/Core/Grid/Data/Factory/EmptyCategoryGridDataFactory.php deleted file mode 100644 index cb3712a5..00000000 --- a/src/Core/Grid/Data/Factory/EmptyCategoryGridDataFactory.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Data\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Data\GridData; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Modifies records from database for empty_category grid - */ -final class EmptyCategoryGridDataFactory implements GridDataFactoryInterface -{ - /** - * @var GridDataFactoryInterface - */ - private $doctrineEmptyCategoryDataFactory; - - /** - * @param GridDataFactoryInterface $doctrineEmptyCategoryDataFactory - */ - public function __construct(GridDataFactoryInterface $doctrineEmptyCategoryDataFactory) - { - $this->doctrineEmptyCategoryDataFactory = $doctrineEmptyCategoryDataFactory; - } - - /** - * {@inheritdoc} - */ - public function getData(SearchCriteriaInterface $searchCriteria) - { - $data = $this->doctrineEmptyCategoryDataFactory->getData($searchCriteria); - - $records = $this->modifyRecords($data->getRecords()->all()); - - return new GridData( - new RecordCollection($records), - $data->getRecordsTotal(), - $data->getQuery() - ); - } - - /** - * Modify empty category records. - * - * @param array $records - * - * @return array - */ - private function modifyRecords(array $records) - { - foreach ($records as $key => $record) { - $records[$key]['description'] = strip_tags(stripslashes($record['description'])); - } - - return $records; - } -} diff --git a/src/Core/Grid/Data/Factory/GridDataFactoryInterface.php b/src/Core/Grid/Data/Factory/GridDataFactoryInterface.php deleted file mode 100644 index 3350ae57..00000000 --- a/src/Core/Grid/Data/Factory/GridDataFactoryInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Data\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Data\GridData; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Interface GridDataFactoryInterface defines contract for grid data factories. - */ -interface GridDataFactoryInterface -{ - /** - * @param SearchCriteriaInterface $searchCriteria - * - * @return GridData - */ - public function getData(SearchCriteriaInterface $searchCriteria); -} diff --git a/src/Core/Grid/Data/Factory/LanguageGridDataFactory.php b/src/Core/Grid/Data/Factory/LanguageGridDataFactory.php deleted file mode 100644 index 7f073978..00000000 --- a/src/Core/Grid/Data/Factory/LanguageGridDataFactory.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Data\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Data\GridData; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use PrestaShop\PrestaShop\Core\Image\ImageProviderInterface; - -/** - * Class LanguageGridDataFactory gets data for languages grid. - */ -final class LanguageGridDataFactory implements GridDataFactoryInterface -{ - /** - * @var GridDataFactoryInterface - */ - private $doctrineLanguageDataFactory; - - /** - * @var ImageProviderInterface - */ - private $languageFlagThumbnailProvider; - - /** - * @param GridDataFactoryInterface $doctrineLanguageDataFactory - * @param ImageProviderInterface $languageFlagThumbnailProvider - */ - public function __construct( - GridDataFactoryInterface $doctrineLanguageDataFactory, - ImageProviderInterface $languageFlagThumbnailProvider - ) { - $this->doctrineLanguageDataFactory = $doctrineLanguageDataFactory; - $this->languageFlagThumbnailProvider = $languageFlagThumbnailProvider; - } - - /** - * {@inheritdoc} - */ - public function getData(SearchCriteriaInterface $searchCriteria) - { - $languageData = $this->doctrineLanguageDataFactory->getData($searchCriteria); - - $modifiedRecords = $this->applyModification( - $languageData->getRecords()->all() - ); - - return new GridData( - new RecordCollection($modifiedRecords), - $languageData->getRecordsTotal(), - $languageData->getQuery() - ); - } - - /** - * @param array $languages - * - * @return array - */ - private function applyModification(array $languages) - { - foreach ($languages as $i => $language) { - $languages[$i]['flag'] = $this->languageFlagThumbnailProvider->getPath($language['id_lang']); - } - - return $languages; - } -} diff --git a/src/Core/Grid/Data/Factory/ManufacturerAddressGridDataFactory.php b/src/Core/Grid/Data/Factory/ManufacturerAddressGridDataFactory.php deleted file mode 100644 index 5525c2b2..00000000 --- a/src/Core/Grid/Data/Factory/ManufacturerAddressGridDataFactory.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Data\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Data\GridData; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Gets data for manufacturer addresses grid - */ -class ManufacturerAddressGridDataFactory implements GridDataFactoryInterface -{ - /** - * @var GridDataFactoryInterface - */ - private $manufacturerAddressDataFactory; - - /** - * @param GridDataFactoryInterface $manufacturerAddressDataFactory - */ - public function __construct(GridDataFactoryInterface $manufacturerAddressDataFactory) - { - $this->manufacturerAddressDataFactory = $manufacturerAddressDataFactory; - } - - /** - * {@inheritdoc} - */ - public function getData(SearchCriteriaInterface $searchCriteria) - { - $addresses = $this->manufacturerAddressDataFactory->getData($searchCriteria); - - $modifiedRecords = $this->applyModification( - $addresses->getRecords()->all() - ); - - return new GridData( - new RecordCollection($modifiedRecords), - $addresses->getRecordsTotal(), - $addresses->getQuery() - ); - } - - /** - * @param array $addresses - * - * @return array - */ - private function applyModification(array $addresses) - { - $modifiedAddresses = []; - foreach ($addresses as $address) { - if (null === $address['name']) { - $address['name'] = '--'; - } - $modifiedAddresses[] = $address; - } - - return $modifiedAddresses; - } -} diff --git a/src/Core/Grid/Data/Factory/ManufacturerGridDataFactory.php b/src/Core/Grid/Data/Factory/ManufacturerGridDataFactory.php deleted file mode 100644 index 5b39bae3..00000000 --- a/src/Core/Grid/Data/Factory/ManufacturerGridDataFactory.php +++ /dev/null @@ -1,98 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Data\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Data\GridData; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use PrestaShop\PrestaShop\Core\Image\ImageProviderInterface; - -/** - * Gets data for manufacturer grid - */ -final class ManufacturerGridDataFactory implements GridDataFactoryInterface -{ - /** - * @var GridDataFactoryInterface - */ - private $manufacturerDataFactory; - - /** - * @var ImageProviderInterface - */ - private $manufacturerLogoThumbnailProvider; - - /** - * @param GridDataFactoryInterface $manufacturerDataFactory - * @param ImageProviderInterface $manufacturerLogoThumbnailProvider - */ - public function __construct( - GridDataFactoryInterface $manufacturerDataFactory, - ImageProviderInterface $manufacturerLogoThumbnailProvider - ) { - $this->manufacturerDataFactory = $manufacturerDataFactory; - $this->manufacturerLogoThumbnailProvider = $manufacturerLogoThumbnailProvider; - } - - /** - * {@inheritdoc} - */ - public function getData(SearchCriteriaInterface $searchCriteria) - { - $manufacturerData = $this->manufacturerDataFactory->getData($searchCriteria); - - $modifiedRecords = $this->applyModification( - $manufacturerData->getRecords()->all() - ); - - return new GridData( - new RecordCollection($modifiedRecords), - $manufacturerData->getRecordsTotal(), - $manufacturerData->getQuery() - ); - } - - /** - * @param array $manufacturers - * - * @return array - */ - private function applyModification(array $manufacturers) - { - foreach ($manufacturers as $i => $manufacturer) { - $manufacturers[$i]['logo'] = $this->manufacturerLogoThumbnailProvider->getPath( - $manufacturer['id_manufacturer'] - ); - - if (null === $manufacturers[$i]['addresses_count']) { - $manufacturers[$i]['addresses_count'] = '--'; - } - } - - return $manufacturers; - } -} diff --git a/src/Core/Grid/Data/Factory/OrderGridDataFactory.php b/src/Core/Grid/Data/Factory/OrderGridDataFactory.php deleted file mode 100644 index 8e2106ea..00000000 --- a/src/Core/Grid/Data/Factory/OrderGridDataFactory.php +++ /dev/null @@ -1,108 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Data\Factory; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Grid\Data\GridData; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use PrestaShop\PrestaShop\Core\Localization\Locale\RepositoryInterface; - -/** - * Decorates DoctrineGridDataFactory configured for orders to modify order records. - */ -final class OrderGridDataFactory implements GridDataFactoryInterface -{ - /** - * @var GridDataFactoryInterface - */ - private $dataFactory; - - /** - * @var RepositoryInterface - */ - private $localeRepository; - - /** - * @var string - */ - private $contextLocale; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param GridDataFactoryInterface $dataFactory - * @param RepositoryInterface $localeRepository - * @param ConfigurationInterface $configuration - * @param string $contextLocale - */ - public function __construct( - GridDataFactoryInterface $dataFactory, - RepositoryInterface $localeRepository, - ConfigurationInterface $configuration, - $contextLocale - ) { - $this->dataFactory = $dataFactory; - $this->localeRepository = $localeRepository; - $this->contextLocale = $contextLocale; - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getData(SearchCriteriaInterface $searchCriteria) - { - $data = $this->dataFactory->getData($searchCriteria); - $records = $data->getRecords()->all(); - - $locale = $this->localeRepository->getLocale($this->contextLocale); - $isInvoicesEnabled = $this->configuration->get('PS_INVOICE'); - - foreach ($records as &$record) { - if (!$record['company']) { - $record['company'] = '--'; - } - - $record['total_paid_tax_incl'] = $locale->formatPrice( - $record['total_paid_tax_incl'], - $record['iso_code'] - ); - - $record['is_invoice_available'] = $isInvoicesEnabled && $record['invoice_number']; - } - - return new GridData( - new RecordCollection($records), - $data->getRecordsTotal(), - $data->getQuery() - ); - } -} diff --git a/src/Core/Grid/Data/Factory/SupplierGridDataFactory.php b/src/Core/Grid/Data/Factory/SupplierGridDataFactory.php deleted file mode 100644 index 21f6b832..00000000 --- a/src/Core/Grid/Data/Factory/SupplierGridDataFactory.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Data\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Data\GridData; -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use PrestaShop\PrestaShop\Core\Image\ImageProviderInterface; - -/** - * Class SupplierGridDataFactory gets data for supplier grid. - */ -final class SupplierGridDataFactory implements GridDataFactoryInterface -{ - /** - * @var GridDataFactoryInterface - */ - private $supplierDataFactory; - - /** - * @var ImageProviderInterface - */ - private $supplierLogoImageProvider; - - /** - * @param GridDataFactoryInterface $supplierDataFactory - * @param ImageProviderInterface $supplierLogoImageProvider - */ - public function __construct( - GridDataFactoryInterface $supplierDataFactory, - ImageProviderInterface $supplierLogoImageProvider - ) { - $this->supplierDataFactory = $supplierDataFactory; - $this->supplierLogoImageProvider = $supplierLogoImageProvider; - } - - /** - * {@inheritdoc} - */ - public function getData(SearchCriteriaInterface $searchCriteria) - { - $supplierData = $this->supplierDataFactory->getData($searchCriteria); - - $modifiedRecords = $this->applyModification( - $supplierData->getRecords()->all() - ); - - return new GridData( - new RecordCollection($modifiedRecords), - $supplierData->getRecordsTotal(), - $supplierData->getQuery() - ); - } - - /** - * @param array $suppliers - * - * @return array - */ - private function applyModification(array $suppliers) - { - foreach ($suppliers as $i => $supplier) { - $suppliers[$i]['logo'] = $this->supplierLogoImageProvider->getPath($supplier['id_supplier']); - } - - return $suppliers; - } -} diff --git a/src/Core/Grid/Data/GridData.php b/src/Core/Grid/Data/GridData.php deleted file mode 100644 index a8705c7a..00000000 --- a/src/Core/Grid/Data/GridData.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Data; - -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollectionInterface; - -/** - * Class GridData is responsible for storing grid data. - */ -final class GridData implements GridDataInterface -{ - /** - * @var array - */ - private $records; - - /** - * @var int - */ - private $recordsTotal; - - /** - * @var string - */ - private $query; - - /** - * @param RecordCollectionInterface $records Filtered & paginated rows data - * @param int $recordsTotal Total number of rows (without pagination) - * @param string $query Query used to get rows - */ - public function __construct(RecordCollectionInterface $records, $recordsTotal, $query = '') - { - $this->records = $records; - $this->recordsTotal = $recordsTotal; - $this->query = $query; - } - - /** - * {@inheritdoc} - */ - public function getRecords() - { - return $this->records; - } - - /** - * {@inheritdoc} - */ - public function getRecordsTotal() - { - return $this->recordsTotal; - } - - /** - * {@inheritdoc} - */ - public function getQuery() - { - return $this->query; - } -} diff --git a/src/Core/Grid/Data/GridDataInterface.php b/src/Core/Grid/Data/GridDataInterface.php deleted file mode 100644 index 86cffcff..00000000 --- a/src/Core/Grid/Data/GridDataInterface.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Data; - -use PrestaShop\PrestaShop\Core\Grid\Record\RecordCollection; - -/** - * Interface GridDataInterface exposes contract for final grid data. - */ -interface GridDataInterface -{ - /** - * Returns final grid rows ready for rendering. - * - * @return RecordCollection - */ - public function getRecords(); - - /** - * Returns total rows in data source. - * - * @return int - */ - public function getRecordsTotal(); - - /** - * Return query which was used to get rows. - * - * @return string - */ - public function getQuery(); -} diff --git a/src/Core/Grid/Definition/Factory/AbstractFilterableGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/AbstractFilterableGridDefinitionFactory.php deleted file mode 100644 index b952e3df..00000000 --- a/src/Core/Grid/Definition/Factory/AbstractFilterableGridDefinitionFactory.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -/** - * Class AbstractFilterableGridDefinitionFactory implements filterable grid definition creation. - */ -abstract class AbstractFilterableGridDefinitionFactory extends AbstractGridDefinitionFactory implements FilterableGridDefinitionFactoryInterface -{ - /** - * {@inheritdoc} - * - * Grid definition already has an internal id used or hooks, that can also be used as an identifier for filters - */ - public function getFilterId(): string - { - return $this->getId(); - } -} diff --git a/src/Core/Grid/Definition/Factory/AbstractGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/AbstractGridDefinitionFactory.php deleted file mode 100644 index 878b9f17..00000000 --- a/src/Core/Grid/Definition/Factory/AbstractGridDefinitionFactory.php +++ /dev/null @@ -1,153 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollectionInterface; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollectionInterface; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollectionInterface; -use PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinition; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollectionInterface; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Event\Dispatcher\NullDispatcher; -use PrestaShopBundle\Translation\TranslatorAwareTrait; -use Symfony\Component\DependencyInjection\Container; - -/** - * Class AbstractGridDefinitionFactory implements grid definition creation. - */ -abstract class AbstractGridDefinitionFactory implements GridDefinitionFactoryInterface -{ - use TranslatorAwareTrait; - - /** - * @var HookDispatcherInterface - */ - protected $hookDispatcher; - - /** - * @param HookDispatcherInterface|null $hookDispatcher - */ - public function __construct(HookDispatcherInterface $hookDispatcher = null) - { - if (null === $hookDispatcher) { - @trigger_error('The $hookDispatcher parameter should not be null, inject your main HookDispatcherInterface service, or NullDispatcher if you don\'t need hooks.', E_USER_DEPRECATED); - } - $this->hookDispatcher = $hookDispatcher ? $hookDispatcher : new NullDispatcher(); - } - - /** - * Set hook dispatcher. - * - * @param HookDispatcherInterface $hookDispatcher - * - * @deprecated - */ - final public function setHookDispatcher(HookDispatcherInterface $hookDispatcher) - { - @trigger_error('The AbstractGridDefinitionFactory::setHookDispatcher method is deprecated as of 1.7.5.1 Please use the constructor instead', E_USER_DEPRECATED); - - $this->hookDispatcher = $hookDispatcher; - } - - /** - * {@inheritdoc} - */ - final public function getDefinition() - { - $definition = new GridDefinition( - $this->getId(), - $this->getName(), - $this->getColumns(), - $this->getFilters(), - $this->getGridActions(), - $this->getBulkActions() - ); - - $this->hookDispatcher->dispatchWithParameters('action' . Container::camelize($definition->getId()) . 'GridDefinitionModifier', [ - 'definition' => $definition, - ]); - - return $definition; - } - - /** - * Get unique grid identifier. - * - * @return string - */ - abstract protected function getId(); - - /** - * Get translated grid name. - * - * @return string - */ - abstract protected function getName(); - - /** - * Get defined columns for grid. - * - * @return ColumnCollectionInterface - */ - abstract protected function getColumns(); - - /** - * Get defined grid actions. - * Override this method to define custom grid actions collection. - * - * @return GridActionCollectionInterface - */ - protected function getGridActions() - { - return new GridActionCollection(); - } - - /** - * Get defined bulk actions. - * Override this method to define custom bulk actions collection. - * - * @return BulkActionCollectionInterface - */ - protected function getBulkActions() - { - return new BulkActionCollection(); - } - - /** - * Get defined filters. - * Override this method to define custom filters collection. - * - * @return FilterCollectionInterface - */ - protected function getFilters() - { - return new FilterCollection(); - } -} diff --git a/src/Core/Grid/Definition/Factory/AddressGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/AddressGridDefinitionFactory.php deleted file mode 100644 index 2454581b..00000000 --- a/src/Core/Grid/Definition/Factory/AddressGridDefinitionFactory.php +++ /dev/null @@ -1,292 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollectionInterface; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollectionInterface; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollectionInterface; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollectionInterface; -use PrestaShopBundle\Form\Admin\Type\CountryChoiceType; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\NumberType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class is responsible for defining 'Sell > Customer > Addresses' grid. - */ -final class AddressGridDefinitionFactory extends AbstractFilterableGridDefinitionFactory -{ - use BulkDeleteActionTrait; - - public const GRID_ID = 'address'; - - /** - * {@inheritdoc} - */ - protected function getId(): string - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName(): string - { - return $this->trans('Addresses', [], 'Admin.Navigation.Menu'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns(): ColumnCollectionInterface - { - $columns = (new ColumnCollection()) - ->add( - (new BulkActionColumn('addresses_bulk')) - ->setOptions([ - 'bulk_field' => 'id_address', - ]) - ) - ->add( - (new DataColumn('id_address')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_address', - ]) - ) - ->add( - (new DataColumn('firstname')) - ->setName($this->trans('First name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'firstname', - ]) - ) - ->add( - (new DataColumn('lastname')) - ->setName($this->trans('Last name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'lastname', - ]) - ) - ->add( - (new DataColumn('address1')) - ->setName($this->trans('Address', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'address1', - ]) - ) - ->add( - (new DataColumn('postcode')) - ->setName($this->trans('Zip/postal code', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'postcode', - ]) - ) - ->add( - (new DataColumn('city')) - ->setName($this->trans('City', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'city', - ]) - )->add( - (new DataColumn('country_name')) - ->setName($this->trans('Country', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'country_name', - ]) - ) - ->add((new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add( - (new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_addresses_edit', - 'route_param_name' => 'addressId', - 'route_param_field' => 'id_address', - ]) - ) - ->add( - (new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - 'route' => 'admin_addresses_delete', - 'route_param_name' => 'addressId', - 'route_param_field' => 'id_address', - ]) - ), - ]) - ) - ; - - return $columns; - } - - /** - * {@inheritdoc} - */ - protected function getFilters(): FilterCollectionInterface - { - $filters = (new FilterCollection()) - ->add( - (new Filter('id_address', NumberType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('id_address') - ) - ->add( - (new Filter('firstname', TextType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search first name', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('firstname') - ) - ->add( - (new Filter('lastname', TextType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search last name', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('lastname') - ) - ->add( - (new Filter('address1', TextType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search address', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('address1') - ) - ->add( - (new Filter('postcode', TextType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search post code', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('postcode') - ) - ->add( - (new Filter('city', TextType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search city', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('city') - ) - ->add( - (new Filter('id_country', CountryChoiceType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('country_name') - ) - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setAssociatedColumn('actions') - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_addresses_index', - ]) - ); - - return $filters; - } - - /** - * {@inheritdoc} - */ - protected function getGridActions(): GridActionCollectionInterface - { - return (new GridActionCollection()) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions(): BulkActionCollectionInterface - { - return (new BulkActionCollection()) - ->add( - $this->buildBulkDeleteAction('admin_addresses_delete_bulk') - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/AttachmentGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/AttachmentGridDefinitionFactory.php deleted file mode 100644 index f8f1c515..00000000 --- a/src/Core/Grid/Definition/Factory/AttachmentGridDefinitionFactory.php +++ /dev/null @@ -1,267 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\NumberType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Defines attachments list grid - */ -final class AttachmentGridDefinitionFactory extends AbstractFilterableGridDefinitionFactory -{ - use BulkDeleteActionTrait; - - public const GRID_ID = 'attachment'; - - /** - * @param HookDispatcherInterface $hookDispatcher - */ - public function __construct(HookDispatcherInterface $hookDispatcher) - { - parent::__construct($hookDispatcher); - } - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Files', [], 'Admin.Navigation.Menu'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - $columns = (new ColumnCollection()) - ->add( - (new BulkActionColumn('files_bulk')) - ->setOptions([ - 'bulk_field' => 'id_attachment', - ]) - ) - ->add( - (new DataColumn('id_attachment')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_attachment', - ]) - ) - ->add( - (new DataColumn('name')) - ->setName($this->trans('Name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - ]) - ) - ->add( - (new DataColumn('file')) - ->setName($this->trans('File', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'file', - ]) - ) - ->add( - (new DataColumn('file_size')) - ->setName($this->trans('Size', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'file_size', - ]) - ) - ->add( - (new DataColumn('products')) - ->setName($this->trans('Products', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'products', - ]) - ) - ->add((new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add( - (new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_attachments_edit', - 'route_param_name' => 'attachmentId', - 'route_param_field' => 'id_attachment', - ]) - ) - ->add( - (new LinkRowAction('view')) - ->setName($this->trans('View', [], 'Admin.Actions')) - ->setIcon('zoom_in') - ->setOptions([ - 'route' => 'admin_attachments_view', - 'route_param_name' => 'attachmentId', - 'route_param_field' => 'id_attachment', - ]) - ) - ->add( - (new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'route' => 'admin_attachments_delete', - 'route_param_name' => 'attachmentId', - 'route_param_field' => 'id_attachment', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - 'confirm_message_type' => SubmitRowAction::MESSAGE_TYPE_DYNAMIC, - 'dynamic_message_field' => 'dynamic_message', - ]) - ), - ]) - ); - - return $columns; - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - $filters = (new FilterCollection()) - ->add( - (new Filter('id_attachment', NumberType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('id_attachment') - ) - ->add( - (new Filter('name', TextType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search file name', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('name') - ) - ->add( - (new Filter('file_size', NumberType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search file size', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('file_size') - ) - ->add( - (new Filter('products', NumberType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Products', [], 'Admin.Catalog.Feature'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('products') - ) - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setAssociatedColumn('actions') - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_attachments_index', - ]) - ); - - return $filters; - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - $this->buildBulkDeleteAction('admin_attachments_delete_bulk') - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/AttributeGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/AttributeGridDefinitionFactory.php deleted file mode 100644 index 97add02c..00000000 --- a/src/Core/Grid/Definition/Factory/AttributeGridDefinitionFactory.php +++ /dev/null @@ -1,295 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\AttributeGroup\AttributeGroupViewDataProviderInterface; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\LinkGridAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Attribute\AttributeColorColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\PositionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Defines grid for attributes group > attributes list - */ -final class AttributeGridDefinitionFactory extends AbstractFilterableGridDefinitionFactory -{ - const GRID_ID = 'attribute'; - - /** - * @var int - */ - private $attributeGroupId; - - /** - * @var AttributeGroupViewDataProviderInterface - */ - private $attributeGroupViewDataProvider; - - /** - * @param HookDispatcherInterface $hookDispatcher - * @param int $attributeGroupId - * @param AttributeGroupViewDataProviderInterface $attributeGroupViewDataProvider - */ - public function __construct( - HookDispatcherInterface $hookDispatcher, - $attributeGroupId, - AttributeGroupViewDataProviderInterface $attributeGroupViewDataProvider - ) { - parent::__construct($hookDispatcher); - $this->attributeGroupId = $attributeGroupId; - $this->attributeGroupViewDataProvider = $attributeGroupViewDataProvider; - } - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->attributeGroupViewDataProvider->getAttributeGroupNameById((int) $this->attributeGroupId); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - $columns = (new ColumnCollection()) - ->add((new BulkActionColumn('bulk')) - ->setOptions([ - 'bulk_field' => 'id_attribute', - ]) - ) - ->add((new DataColumn('id_attribute')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_attribute', - ]) - ) - ->add((new DataColumn('value')) - ->setName($this->trans('Value', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'value', - ]) - ); - - if ($this->attributeGroupViewDataProvider->isColorGroup($this->attributeGroupId)) { - $columns->add((new AttributeColorColumn('color')) - ->setName($this->trans('Color', [], 'Admin.Catalog.Feature')) - ->setOptions([ - 'field' => 'color', - ]) - ); - } - - $columns - ->add((new PositionColumn('position')) - ->setName($this->trans('Position', [], 'Admin.Global')) - ->setOptions([ - 'id_field' => 'id_attribute', - 'position_field' => 'position', - 'update_method' => 'POST', - 'update_route' => 'admin_attributes_update_position', - 'record_route_params' => [ - 'id_attribute_group' => 'attributeGroupId', - ], - ]) - ) - ->add((new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add((new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_attributes_edit', - 'route_param_name' => 'attributeGroupId', - 'route_param_field' => 'id_attribute_group', - 'extra_route_params' => [ - 'attributeId' => 'id_attribute', - ], - ]) - ) - ->add((new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'route' => 'admin_attributes_delete', - 'route_param_name' => 'attributeGroupId', - 'route_param_field' => 'id_attribute_group', - 'extra_route_params' => [ - 'attributeId' => 'id_attribute', - ], - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - ]) - ), - ]) - ); - - return $columns; - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add((new LinkGridAction('import')) - ->setName($this->trans('Import', [], 'Admin.Actions')) - ->setIcon('cloud_upload') - ->setOptions([ - 'route' => 'admin_import', - 'route_params' => [ - 'import_type' => 'attributes', - ], - ]) - ) - ->add((new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add((new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add((new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - $filters = (new FilterCollection()) - ->add((new Filter('id_attribute', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('id_attribute') - ) - ->add((new Filter('value', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search value', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('value') - ) - ->add((new Filter('position', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search position', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('position') - ) - ->add((new Filter('actions', SearchAndResetType::class)) - ->setAssociatedColumn('actions') - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_attributes_index', - 'redirect_route_params' => [ - 'attributeGroupId' => $this->attributeGroupId, - ], - ]) - ->setAssociatedColumn('actions') - ); - - if ($this->attributeGroupViewDataProvider->isColorGroup($this->attributeGroupId)) { - $filters->add((new Filter('color', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search color', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('color') - ); - } - - return $filters; - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - (new SubmitBulkAction('delete_selection')) - ->setName($this->trans('Delete selected', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_attributes_bulk_delete', - 'route_params' => [ - 'attributeGroupId' => $this->attributeGroupId, - ], - 'confirm_message' => $this->trans('Delete selected items?', [], 'Admin.Notifications.Warning'), - ]) - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/AttributeGroupGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/AttributeGroupGridDefinitionFactory.php deleted file mode 100644 index b698951a..00000000 --- a/src/Core/Grid/Definition/Factory/AttributeGroupGridDefinitionFactory.php +++ /dev/null @@ -1,241 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\LinkGridAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\PositionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Defines attribute groups grid - */ -final class AttributeGroupGridDefinitionFactory extends AbstractFilterableGridDefinitionFactory -{ - const GRID_ID = 'attribute_group'; - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Attributes', [], 'Admin.Catalog.Feature'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add((new BulkActionColumn('bulk')) - ->setOptions([ - 'bulk_field' => 'id_attribute_group', - ]) - ) - ->add((new DataColumn('id_attribute_group')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_attribute_group', - ]) - ) - ->add((new DataColumn('name')) - ->setName($this->trans('Name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - ]) - ) - ->add((new DataColumn('values')) - ->setName($this->trans('Values', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'values', - 'sortable' => false, - ]) - ) - ->add((new PositionColumn('position')) - ->setName($this->trans('Position', [], 'Admin.Global')) - ->setOptions([ - 'id_field' => 'id_attribute_group', - 'position_field' => 'position', - 'update_method' => 'POST', - 'update_route' => 'admin_attribute_groups_update_position', - ]) - ) - ->add((new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add((new LinkRowAction('view')) - ->setName($this->trans('View', [], 'Admin.Actions')) - ->setIcon('zoom_in') - ->setOptions([ - 'route' => 'admin_attributes_index', - 'route_param_name' => 'attributeGroupId', - 'route_param_field' => 'id_attribute_group', - ]) - ) - ->add((new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_attribute_groups_edit', - 'route_param_name' => 'attributeGroupId', - 'route_param_field' => 'id_attribute_group', - ]) - ) - ->add((new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'route' => 'admin_attribute_groups_delete', - 'route_param_name' => 'attributeGroupId', - 'route_param_field' => 'id_attribute_group', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - ]) - ), - ]) - ); - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add((new LinkGridAction('import')) - ->setName($this->trans('Import', [], 'Admin.Actions')) - ->setIcon('cloud_upload') - ->setOptions([ - 'route' => 'admin_import', - 'route_params' => [ - 'import_type' => 'attribute_groups', - ], - ]) - ) - ->add((new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add((new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add((new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add((new Filter('id_attribute_group', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('id_attribute_group') - ) - ->add((new Filter('name', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search name', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('name') - ) - ->add((new Filter('position', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search position', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('position') - ) - ->add((new Filter('actions', SearchAndResetType::class)) - ->setAssociatedColumn('actions') - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_attribute_groups_index', - ]) - ->setAssociatedColumn('actions') - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - (new SubmitBulkAction('delete_selection')) - ->setName($this->trans('Delete selected', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_attribute_groups_bulk_delete', - 'confirm_message' => $this->trans('Delete selected items?', [], 'Admin.Notifications.Warning'), - ]) - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/BackupDefinitionFactory.php b/src/Core/Grid/Definition/Factory/BackupDefinitionFactory.php deleted file mode 100644 index 428b250a..00000000 --- a/src/Core/Grid/Definition/Factory/BackupDefinitionFactory.php +++ /dev/null @@ -1,153 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; - -/** - * Class BackupDefinitionFactory is responsible for defining 'Configure > Advanced Parameters > Database > Backup' grid. - */ -final class BackupDefinitionFactory extends AbstractGridDefinitionFactory -{ - /** - * {@inheritdoc} - */ - protected function getId() - { - return 'backup'; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('DB Backup', [], 'Admin.Navigation.Menu'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add( - (new BulkActionColumn('backup_bulk_file_names')) - ->setOptions([ - 'bulk_field' => 'file_name', - ]) - ) - ->add( - (new DataColumn('date')) - ->setName($this->trans('Date', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'date_formatted', - 'sortable' => false, - ]) - ) - ->add( - (new DataColumn('age')) - ->setName($this->trans('Age', [], 'Admin.Advparameters.Feature')) - ->setOptions([ - 'field' => 'age_formatted', - 'sortable' => false, - ]) - ) - ->add( - (new DataColumn('file_name')) - ->setName($this->trans('Filename', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'file_name', - 'sortable' => false, - ]) - ) - ->add( - (new DataColumn('file_size')) - ->setName($this->trans('File size', [], 'Admin.Advparameters.Feature')) - ->setOptions([ - 'field' => 'file_size_formatted', - 'sortable' => false, - ]) - ) - ->add( - (new ActionColumn('actions')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add( - (new LinkRowAction('view')) - ->setIcon('remove_red_eye') - ->setOptions([ - 'route' => 'admin_backups_download_view', - 'route_param_name' => 'downloadFileName', - 'route_param_field' => 'file_name', - 'clickable_row' => true, - ]) - ) - ->add( - (new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'method' => 'DELETE', - 'route' => 'admin_backups_delete', - 'route_param_name' => 'deleteFileName', - 'route_param_field' => 'file_name', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - ]) - ), - ]) - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - (new SubmitBulkAction('delete_backups')) - ->setName($this->trans('Delete selected', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_backups_bulk_delete', - 'confirm_message' => $this->trans('Delete selected items?', [], 'Admin.Notifications.Warning'), - ]) - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/BulkDeleteActionTrait.php b/src/Core/Grid/Definition/Factory/BulkDeleteActionTrait.php deleted file mode 100644 index b68db452..00000000 --- a/src/Core/Grid/Definition/Factory/BulkDeleteActionTrait.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionInterface; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\ModalOptions; - -/** - * Trait to help build the bulk delete action - */ -trait BulkDeleteActionTrait -{ - /** - * @param string $bulkDeleteRouteName - * - * @return BulkActionInterface - */ - protected function buildBulkDeleteAction(string $bulkDeleteRouteName) - { - return (new SubmitBulkAction('delete_selection')) - ->setName($this->trans('Delete selected', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => $bulkDeleteRouteName, - 'confirm_message' => $this->trans('Are you sure you want to delete the selected item(s)?', [], 'Admin.Global'), - 'modal_options' => new ModalOptions([ - 'title' => $this->trans('Delete selection', [], 'Admin.Actions'), - 'confirm_button_label' => $this->trans('Delete', [], 'Admin.Actions'), - 'confirm_button_class' => 'btn-danger', - ]), - ]) - ; - } - - /** - * Shortcut method to translate text. - * - * @param string $id - * @param array $options - * @param string $domain - * - * @return string - */ - abstract protected function trans($id, array $options, $domain); -} diff --git a/src/Core/Grid/Definition/Factory/CatalogPriceRuleGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/CatalogPriceRuleGridDefinitionFactory.php deleted file mode 100644 index a2191f6b..00000000 --- a/src/Core/Grid/Definition/Factory/CatalogPriceRuleGridDefinitionFactory.php +++ /dev/null @@ -1,347 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\DateTimeColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Form\Admin\Type\DateRangeType; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class responsible for providing columns, filters, actions for catalog price rule list. - */ -final class CatalogPriceRuleGridDefinitionFactory extends AbstractGridDefinitionFactory -{ - const GRID_ID = 'catalog_price_rule'; - - public function __construct( - HookDispatcherInterface $hookDispatcher - ) { - parent::__construct($hookDispatcher); - } - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Catalog price rules', [], 'Admin.Catalog.Feature'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add((new BulkActionColumn('bulk')) - ->setOptions([ - 'bulk_field' => 'id_specific_price_rule', - ]) - ) - ->add((new DataColumn('id_specific_price_rule')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_specific_price_rule', - ]) - ) - ->add((new DataColumn('name')) - ->setName($this->trans('Name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - ]) - ) - ->add((new DataColumn('shop')) - ->setName($this->trans('Shop', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'shop', - ]) - ) - ->add((new DataColumn('currency')) - ->setName($this->trans('Currency', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'currency', - ]) - ) - ->add((new DataColumn('country')) - ->setName($this->trans('Country', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'country', - ]) - ) - ->add((new DataColumn('group_name')) - ->setName($this->trans('Group', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'group_name', - ]) - ) - ->add((new DataColumn('from_quantity')) - ->setName($this->trans('From quantity', [], 'Admin.Catalog.Feature')) - ->setOptions([ - 'field' => 'from_quantity', - ]) - ) - ->add((new DataColumn('reduction_type')) - ->setName($this->trans('Reduction type', [], 'Admin.Catalog.Feature')) - ->setOptions([ - 'field' => 'reduction_type', - ]) - ) - ->add((new DataColumn('reduction')) - ->setName($this->trans('Reduction', [], 'Admin.Catalog.Feature')) - ->setOptions([ - 'field' => 'reduction', - ]) - ) - ->add((new DateTimeColumn('date_from')) - ->setName($this->trans('Beginning', [], 'Admin.Catalog.Feature')) - ->setOptions([ - 'format' => 'Y-m-d H:i', - 'field' => 'date_from', - ]) - ) - ->add((new DateTimeColumn('date_to')) - ->setName($this->trans('End', [], 'Admin.Catalog.Feature')) - ->setOptions([ - 'format' => 'Y-m-d H:i', - 'field' => 'date_to', - ]) - ) - ->add((new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add((new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_catalog_price_rules_edit', - 'route_param_name' => 'catalogPriceRuleId', - 'route_param_field' => 'id_specific_price_rule', - ]) - ) - ->add((new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'method' => 'POST', - 'route' => 'admin_catalog_price_rules_delete', - 'route_param_name' => 'catalogPriceRuleId', - 'route_param_field' => 'id_specific_price_rule', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - ]) - ), - ]) - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add((new Filter('id_specific_price_rule', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('ID', [], 'Admin.Global'), - ], - ]) - ->setAssociatedColumn('id_specific_price_rule') - ) - ->add((new Filter('name', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Name', [], 'Admin.Global'), - ], - ]) - ->setAssociatedColumn('name') - ) - ->add((new Filter('shop', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Shop', [], 'Admin.Global'), - ], - ]) - ->setAssociatedColumn('shop') - ) - ->add((new Filter('currency', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Currency', [], 'Admin.Global'), - ], - ]) - ->setAssociatedColumn('currency') - ) - ->add((new Filter('country', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Country', [], 'Admin.Global'), - ], - ]) - ->setAssociatedColumn('country') - ) - ->add((new Filter('group_name', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Group', [], 'Admin.Global'), - ], - ]) - ->setAssociatedColumn('group_name') - ) - ->add((new Filter('from_quantity', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('From quantity', [], 'Admin.Catalog.Feature'), - ], - ]) - ->setAssociatedColumn('from_quantity') - ) - ->add((new Filter('reduction_type', ChoiceType::class)) - ->setTypeOptions([ - 'required' => false, - 'choices' => [ - $this->trans('Percentage', [], 'Admin.Global') => 'percentage', - $this->trans('Amount', [], 'Admin.Global') => 'amount', - ], - ]) - ->setAssociatedColumn('reduction_type') - ) - ->add((new Filter('reduction', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Reduction', [], 'Admin.Catalog.Feature'), - ], - ]) - ->setAssociatedColumn('reduction') - ) - ->add((new Filter('date_from', DateRangeType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Beginning', [], 'Admin.Catalog.Feature'), - ], - 'date_format' => 'YYYY-MM-DD HH:mm:ss', - ]) - ->setAssociatedColumn('date_from') - ) - ->add((new Filter('date_to', DateRangeType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('End', [], 'Admin.Catalog.Feature'), - ], - 'date_format' => 'YYYY-MM-DD HH:mm:ss', - ]) - ->setAssociatedColumn('date_to') - ) - ->add((new Filter('actions', SearchAndResetType::class)) - ->setAssociatedColumn('actions') - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_catalog_price_rules_index', - ]) - ->setAssociatedColumn('actions') - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add((new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add((new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add((new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add((new SubmitBulkAction('delete_selection')) - ->setName($this->trans('Delete selected', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_catalog_price_rules_bulk_delete', - 'confirm_message' => $this->trans('Delete selected items?', [], 'Admin.Notifications.Warning'), - ]) - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/CategoryGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/CategoryGridDefinitionFactory.php deleted file mode 100644 index 40150a71..00000000 --- a/src/Core/Grid/Definition/Factory/CategoryGridDefinitionFactory.php +++ /dev/null @@ -1,369 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\Catalog\Category\DeleteCategoriesBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\AccessibilityChecker\AccessibilityCheckerInterface; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\Category\DeleteCategoryRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\LinkGridAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Category\CategoryPositionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\DraggableColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\IdentifierColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\LinkColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShop\PrestaShop\Core\Multistore\MultistoreContextCheckerInterface; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use PrestaShopBundle\Form\Admin\Type\YesAndNoChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class CategoryGridDefinitionFactory builds Grid definition for Categories listing. - */ -final class CategoryGridDefinitionFactory extends AbstractFilterableGridDefinitionFactory -{ - const GRID_ID = 'category'; - - /** - * @var string - */ - private $resetActionUrl; - - /** - * @var string - */ - private $redirectActionUrl; - - /** - * @var AccessibilityCheckerInterface - */ - private $categoryForViewAccessibilityChecker; - - /** - * @var MultistoreContextCheckerInterface - */ - private $multistoreContextChecker; - - /** - * @param HookDispatcherInterface $hookDispatcher - * @param string $resetActionUrl - * @param string $redirectActionUrl - * @param MultistoreContextCheckerInterface $multistoreContextChecker - * @param AccessibilityCheckerInterface $categoryForViewAccessibilityChecker - */ - public function __construct( - HookDispatcherInterface $hookDispatcher, - $resetActionUrl, - $redirectActionUrl, - MultistoreContextCheckerInterface $multistoreContextChecker, - AccessibilityCheckerInterface $categoryForViewAccessibilityChecker - ) { - parent::__construct($hookDispatcher); - $this->resetActionUrl = $resetActionUrl; - $this->redirectActionUrl = $redirectActionUrl; - $this->categoryForViewAccessibilityChecker = $categoryForViewAccessibilityChecker; - $this->multistoreContextChecker = $multistoreContextChecker; - } - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Categories', [], 'Admin.Global'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - $columns = (new ColumnCollection()) - ->add( - (new IdentifierColumn('id_category')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'identifier_field' => 'id_category', - 'bulk_field' => 'id_category', - 'with_bulk_field' => true, - 'clickable' => false, - ]) - ) - ->add( - (new LinkColumn('name')) - ->setName($this->trans('Name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - 'route' => 'admin_categories_index', - 'route_param_name' => 'categoryId', - 'route_param_field' => 'id_category', - ]) - ) - ->add( - (new DataColumn('description')) - ->setName($this->trans('Description', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'description', - 'sortable' => false, - ]) - ) - ->add( - (new ToggleColumn('active')) - ->setName($this->trans('Displayed', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'active', - 'primary_field' => 'id_category', - 'route' => 'admin_categories_toggle_status', - 'route_param_name' => 'categoryId', - ]) - ) - ->add( - (new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => $this->getRowActions(), - ]) - ); - - if ($this->multistoreContextChecker->isSingleShopContext()) { - $columns - ->addAfter( - 'description', - (new CategoryPositionColumn('position')) - ->setName($this->trans('Position', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'position', - 'id_field' => 'id_category', - 'id_parent_field' => 'id_parent', - 'update_route' => 'admin_categories_update_position', - ]) - ) - ->addBefore('id_category', new DraggableColumn('position_drag')) - ; - } - - return $columns; - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - $filters = (new FilterCollection()) - ->add( - (new Filter('id_category', TextType::class)) - ->setAssociatedColumn('id_category') - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - ]) - ) - ->add( - (new Filter('name', TextType::class)) - ->setAssociatedColumn('name') - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search name', [], 'Admin.Actions'), - ], - ]) - ) - ->add( - (new Filter('description', TextType::class)) - ->setAssociatedColumn('description') - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search description', [], 'Admin.Actions'), - ], - ]) - ) - ->add( - (new Filter('active', YesAndNoChoiceType::class)) - ->setAssociatedColumn('active') - ) - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setAssociatedColumn('actions') - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_categories_index', - ]) - ); - - if ($this->multistoreContextChecker->isSingleShopContext()) { - $filters->add( - (new Filter('position', TextType::class)) - ->setAssociatedColumn('position') - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search position', [], 'Admin.Actions'), - ], - ]) - ); - } - - return $filters; - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new LinkGridAction('import')) - ->setName($this->trans('Import', [], 'Admin.Actions')) - ->setIcon('cloud_upload') - ->setOptions([ - 'route' => 'admin_import', - 'route_params' => [ - 'import_type' => 'categories', - ], - ]) - ) - ->add( - (new LinkGridAction('export')) - ->setName($this->trans('Export', [], 'Admin.Actions')) - ->setIcon('cloud_download') - ->setOptions([ - 'route' => 'admin_categories_export', - ]) - ) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - (new SubmitBulkAction('enable_selection')) - ->setName($this->trans('Enable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_categories_bulk_enable_status', - ]) - ) - ->add( - (new SubmitBulkAction('disable_selection')) - ->setName($this->trans('Disable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_categories_bulk_disable_status', - ]) - ) - ->add( - (new DeleteCategoriesBulkAction('delete_selection')) - ->setName($this->trans('Delete selected', [], 'Admin.Actions')) - ->setOptions([ - 'categories_bulk_delete_route' => 'admin_categories_bulk_delete', - ]) - ); - } - - /** - * @return RowActionCollection - */ - private function getRowActions() - { - return (new RowActionCollection()) - ->add( - (new LinkRowAction('view')) - ->setName($this->trans('View', [], 'Admin.Actions')) - ->setIcon('zoom_in') - ->setOptions([ - 'route' => 'admin_categories_index', - 'route_param_name' => 'categoryId', - 'route_param_field' => 'id_category', - 'accessibility_checker' => $this->categoryForViewAccessibilityChecker, - 'clickable_row' => true, - ]) - ) - ->add( - (new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_categories_edit', - 'route_param_name' => 'categoryId', - 'route_param_field' => 'id_category', - 'clickable_row' => true, // Will only apply if first link action is filtered - ]) - ) - ->add( - (new DeleteCategoryRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'category_id_field' => 'id_category', - 'category_delete_route' => 'admin_categories_delete', - ]) - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/CmsPageCategoryDefinitionFactory.php b/src/Core/Grid/Definition/Factory/CmsPageCategoryDefinitionFactory.php deleted file mode 100644 index 1456a7b6..00000000 --- a/src/Core/Grid/Definition/Factory/CmsPageCategoryDefinitionFactory.php +++ /dev/null @@ -1,360 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\LinkColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\PositionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShop\PrestaShop\Core\Multistore\MultistoreContextCheckerInterface; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use PrestaShopBundle\Form\Admin\Type\YesAndNoChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\HttpFoundation\RequestStack; - -/** - * Class CmsPageCategoryDefinitionFactory builds Grid definition for Cms page category listing. - */ -final class CmsPageCategoryDefinitionFactory extends AbstractFilterableGridDefinitionFactory -{ - use BulkDeleteActionTrait; - - const GRID_ID = 'cms_page_category'; - - /** - * @var int - */ - private $cmsCategoryParentId; - - /** - * @var MultistoreContextCheckerInterface - */ - private $multistoreContextChecker; - - /** - * @var bool - */ - private $isMultiStoreFeatureUsed; - - /** - * @param HookDispatcherInterface $hookDispatcher - * @param RequestStack $requestStack - * @param MultistoreContextCheckerInterface $multistoreContextChecker - * @param bool $isMultiStoreFeatureUsed - */ - public function __construct( - HookDispatcherInterface $hookDispatcher, - RequestStack $requestStack, - MultistoreContextCheckerInterface $multistoreContextChecker, - $isMultiStoreFeatureUsed - ) { - parent::__construct($hookDispatcher); - $this->setCmsPageCategoryParentId($requestStack); - - $this->multistoreContextChecker = $multistoreContextChecker; - $this->isMultiStoreFeatureUsed = $isMultiStoreFeatureUsed; - } - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Categories', [], 'Admin.Navigation.Menu'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - $columnCollection = (new ColumnCollection()) - ->add((new BulkActionColumn('bulk')) - ->setOptions([ - 'bulk_field' => 'id_cms_category', - ]) - ) - ->add((new DataColumn('id_cms_category')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_cms_category', - ]) - ) - ->add((new LinkColumn('name')) - ->setName($this->trans('Name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - 'route' => 'admin_cms_pages_index', - 'route_param_name' => 'id_cms_category', - 'route_param_field' => 'id_cms_category', - ]) - ) - ->add((new DataColumn('description')) - ->setName($this->trans('Description', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'description', - ]) - ) - ->add((new ToggleColumn('active')) - ->setName($this->trans('Displayed', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'active', - 'route' => 'admin_cms_pages_category_toggle', - 'primary_field' => 'id_cms_category', - 'route_param_name' => 'cmsCategoryId', - ]) - ) - ->add((new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add((new LinkRowAction('view')) - ->setName($this->trans('View', [], 'Admin.Actions')) - ->setIcon('zoom_in') - ->setOptions([ - 'route' => 'admin_cms_pages_index', - 'route_param_name' => 'id_cms_category', - 'route_param_field' => 'id_cms_category', - 'clickable_row' => true, - ]) - ) - ->add((new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_cms_pages_category_edit', - 'route_param_name' => 'cmsCategoryId', - 'route_param_field' => 'id_cms_category', - ]) - ) - ->add((new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'method' => 'DELETE', - 'route' => 'admin_cms_pages_category_delete', - 'route_param_name' => 'cmsCategoryId', - 'route_param_field' => 'id_cms_category', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - ]) - ), - ]) - ) - ; - - if ($this->isAllShopContextOrShopFeatureIsNotUsed()) { - $columnCollection - ->addAfter( - 'description', - (new PositionColumn('position')) - ->setName($this->trans('Position', [], 'Admin.Global')) - ->setOptions([ - 'id_field' => 'id_cms_category', - 'position_field' => 'position', - 'update_method' => 'POST', - 'update_route' => 'admin_cms_pages_category_update_position', - 'record_route_params' => [ - 'id_parent' => 'id_cms_category', - ], - ]) - ); - } - - return $columnCollection; - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - $actionsTypeOptions = [ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_cms_pages_index', - ]; - - if ($this->cmsCategoryParentId) { - $actionsTypeOptions['redirect_route_params'] = [ - 'id_cms_category' => $this->cmsCategoryParentId, - ]; - - $actionsTypeOptions['reset_route_params']['id_cms_category'] = $this->cmsCategoryParentId; - } - - $filterCollection = (new FilterCollection()) - ->add((new Filter('id_cms_category', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('ID', [], 'Admin.Global'), - ], - ]) - ->setAssociatedColumn('id_cms_category') - ) - ->add((new Filter('name', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Name', [], 'Admin.Global'), - ], - ]) - ->setAssociatedColumn('name') - ) - ->add((new Filter('description', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Description', [], 'Admin.Global'), - ], - ]) - ->setAssociatedColumn('description') - ) - ->add((new Filter('active', YesAndNoChoiceType::class)) - ->setAssociatedColumn('active') - ) - ->add((new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions($actionsTypeOptions) - ->setAssociatedColumn('actions') - ) - ; - - if ($this->isAllShopContextOrShopFeatureIsNotUsed()) { - $filterCollection - ->add((new Filter('position', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Position', [], 'Admin.Global'), - ], - ]) - ->setAssociatedColumn('position') - ) - ; - } - - return $filterCollection; - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add((new SubmitBulkAction('enable_selection')) - ->setName($this->trans('Enable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_cms_pages_category_bulk_status_enable', - ]) - ) - ->add((new SubmitBulkAction('disable_selection')) - ->setName($this->trans('Disable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_cms_pages_category_bulk_status_disable', - ]) - ) - ->add( - $this->buildBulkDeleteAction('admin_cms_pages_category_delete_bulk') - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add((new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add((new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add((new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ) - ; - } - - /** - * Sets cms page category parent id directly from request attribute. On not found case, it assigns the default one. - * - * @param RequestStack $requestStack - */ - private function setCmsPageCategoryParentId(RequestStack $requestStack) - { - $request = $requestStack->getCurrentRequest(); - - if (null !== $request && $request->query->getInt('id_cms_category')) { - $this->cmsCategoryParentId = $request->query->getInt('id_cms_category'); - } - } - - /** - * This function is required due to in cms_category contains position column - on ideal case cms_category_shop - * should have this column configured instead. - * In such case the condition would be $this->multistoreContextChecker->isSingleShopContext() - * - * @return bool - */ - private function isAllShopContextOrShopFeatureIsNotUsed() - { - return $this->multistoreContextChecker->isAllShopContext() || !$this->isMultiStoreFeatureUsed; - } -} diff --git a/src/Core/Grid/Definition/Factory/CmsPageDefinitionFactory.php b/src/Core/Grid/Definition/Factory/CmsPageDefinitionFactory.php deleted file mode 100644 index b14ca1f3..00000000 --- a/src/Core/Grid/Definition/Factory/CmsPageDefinitionFactory.php +++ /dev/null @@ -1,378 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query\GetCmsPageCategoryNameForListing; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\PositionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShop\PrestaShop\Core\Multistore\MultistoreContextCheckerInterface; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use PrestaShopBundle\Form\Admin\Type\YesAndNoChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\HttpFoundation\RequestStack; - -/** - * Class responsible for providing columns, filters, actions for cms page list. - */ -class CmsPageDefinitionFactory extends AbstractGridDefinitionFactory -{ - use BulkDeleteActionTrait; - - const GRID_ID = 'cms_page'; - - /** - * @var int - */ - private $cmsCategoryParentId; - - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @var RequestStack - */ - private $requestStack; - - /** - * @var MultistoreContextCheckerInterface - */ - private $multistoreContextChecker; - - /** - * @var bool - */ - private $isMultiStoreFeatureUsed; - - public function __construct( - HookDispatcherInterface $hookDispatcher, - CommandBusInterface $queryBus, - RequestStack $requestStack, - MultistoreContextCheckerInterface $multistoreContextChecker, - $isMultiStoreFeatureUsed - ) { - parent::__construct($hookDispatcher); - - $this->queryBus = $queryBus; - $this->requestStack = $requestStack; - - $this->setCmsPageCategoryParentId($requestStack); - $this->multistoreContextChecker = $multistoreContextChecker; - $this->isMultiStoreFeatureUsed = $isMultiStoreFeatureUsed; - } - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - $cmsCategoryName = $this->queryBus->handle(new GetCmsPageCategoryNameForListing()); - - return $this->trans( - 'Pages in category "%name%"', - ['%name%' => $cmsCategoryName], - 'Admin.Design.Feature' - ); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - $columnCollection = (new ColumnCollection()) - ->add((new BulkActionColumn('bulk')) - ->setOptions([ - 'bulk_field' => 'id_cms', - ]) - ) - ->add((new DataColumn('id_cms')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_cms', - ]) - ) - ->add((new DataColumn('link_rewrite')) - ->setName($this->trans('URL', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'link_rewrite', - ]) - ) - ->add((new DataColumn('meta_title')) - ->setName($this->trans('Title', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'meta_title', - ]) - ) - ->add((new DataColumn('head_seo_title')) - ->setName($this->trans('Meta title', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'head_seo_title', - ]) - ) - ->add((new ToggleColumn('active')) - ->setName($this->trans('Displayed', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'active', - 'route' => 'admin_cms_pages_toggle', - 'primary_field' => 'id_cms', - 'route_param_name' => 'cmsId', - ]) - ) - ->add((new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add((new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_cms_pages_edit', - 'route_param_name' => 'cmsPageId', - 'route_param_field' => 'id_cms', - 'clickable_row' => true, - ]) - ) - ->add((new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'method' => 'DELETE', - 'route' => 'admin_cms_pages_delete', - 'route_param_name' => 'cmsId', - 'route_param_field' => 'id_cms', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - ]) - ), - ]) - ) - ; - - if ($this->isAllShopContextOrShopFeatureIsNotUsed()) { - $columnCollection - ->addAfter( - 'head_seo_title', - (new PositionColumn('position')) - ->setName($this->trans('Position', [], 'Admin.Global')) - ->setOptions([ - 'id_field' => 'id_cms', - 'position_field' => 'position', - 'update_method' => 'POST', - 'update_route' => 'admin_cms_pages_update_position', - 'record_route_params' => [ - 'id_cms_category' => 'id_cms_category', - ], - ]) - ); - } - - return $columnCollection; - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - $actionsTypeOptions = [ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_cms_pages_index', - ]; - - if ($this->cmsCategoryParentId) { - $actionsTypeOptions['redirect_route_params'] = [ - 'id_cms_category' => $this->cmsCategoryParentId, - ]; - - $actionsTypeOptions['reset_route_params']['id_cms_category'] = $this->cmsCategoryParentId; - } - - $filterCollection = (new FilterCollection()) - ->add((new Filter('id_cms', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('ID', [], 'Admin.Global'), - ], - ]) - ->setAssociatedColumn('id_cms') - ) - ->add((new Filter('link_rewrite', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('URL', [], 'Admin.Global'), - ], - ]) - ->setAssociatedColumn('link_rewrite') - ) - ->add((new Filter('meta_title', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Title', [], 'Admin.Global'), - ], - ]) - ->setAssociatedColumn('meta_title') - ) - ->add((new Filter('head_seo_title', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Meta title', [], 'Admin.Global'), - ], - ]) - ->setAssociatedColumn('head_seo_title') - ) - ->add((new Filter('active', YesAndNoChoiceType::class)) - ->setAssociatedColumn('active') - ) - ->add((new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions($actionsTypeOptions) - ->setAssociatedColumn('actions') - ) - ; - - if ($this->isAllShopContextOrShopFeatureIsNotUsed()) { - $filterCollection - ->add((new Filter('position', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Position', [], 'Admin.Global'), - ], - ]) - ->setAssociatedColumn('position') - ) - ; - } - - return $filterCollection; - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add((new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add((new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add((new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add((new SubmitBulkAction('enable_selection')) - ->setName($this->trans('Enable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_cms_pages_bulk_enable_status', - ]) - ) - ->add((new SubmitBulkAction('disable_selection')) - ->setName($this->trans('Disable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_cms_pages_bulk_disable_status', - ]) - ) - ->add( - $this->buildBulkDeleteAction('admin_cms_pages_bulk_delete') - ) - ; - } - - /** - * Sets cms page category parent id directly from request attribute. On not found case, it assigns the default one. - * - * @param RequestStack $requestStack - */ - private function setCmsPageCategoryParentId(RequestStack $requestStack) - { - $request = $requestStack->getCurrentRequest(); - - if (null !== $request && $request->query->getInt('id_cms_category')) { - $this->cmsCategoryParentId = $request->query->getInt('id_cms_category'); - } - } - - /** - * This function is required due to in cms_category contains position column - on ideal case cms_category_shop - * should have this column configured instead. - * In such case the condition would be $this->multistoreContextChecker->isSingleShopContext() - * - * @return bool - */ - private function isAllShopContextOrShopFeatureIsNotUsed() - { - return $this->multistoreContextChecker->isAllShopContext() || !$this->isMultiStoreFeatureUsed; - } -} diff --git a/src/Core/Grid/Definition/Factory/ContactGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/ContactGridDefinitionFactory.php deleted file mode 100644 index ccfbe3f8..00000000 --- a/src/Core/Grid/Definition/Factory/ContactGridDefinitionFactory.php +++ /dev/null @@ -1,252 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class ContactGridDefinitionFactory is responsible for creating Contact grid definition. - */ -final class ContactGridDefinitionFactory extends AbstractGridDefinitionFactory -{ - /** - * @var string - */ - private $resetSearchUrl; - - /** - * @var string - */ - private $redirectionUrl; - - /** - * @param HookDispatcherInterface $hookDispatcher - * @param string $resetSearchUrl - * @param string $redirectionUrl - */ - public function __construct( - HookDispatcherInterface $hookDispatcher, - $resetSearchUrl, - $redirectionUrl - ) { - parent::__construct($hookDispatcher); - $this->resetSearchUrl = $resetSearchUrl; - $this->redirectionUrl = $redirectionUrl; - } - - /** - * {@inheritdoc} - */ - protected function getId() - { - return 'contact'; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Contacts', [], 'Admin.Navigation.Menu'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add( - (new BulkActionColumn('bulk')) - ->setOptions([ - 'bulk_field' => 'id_contact', - ]) - ) - ->add( - (new DataColumn('id_contact')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_contact', - ]) - ) - ->add( - (new DataColumn('name')) - ->setName($this->trans('Title', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - ]) - ) - ->add( - (new DataColumn('email')) - ->setName($this->trans('Email address', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'email', - ]) - ) - ->add( - (new DataColumn('description')) - ->setName($this->trans('Description', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'description', - ]) - ) - ->add( - (new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add( - (new LinkRowAction('edit')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_contacts_edit', - 'route_param_name' => 'contactId', - 'route_param_field' => 'id_contact', - 'clickable_row' => true, - ]) - ) - ->add( - (new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'method' => 'POST', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - 'route' => 'admin_contacts_delete', - 'route_param_name' => 'contactId', - 'route_param_field' => 'id_contact', - ]) - ), - ]) - ); - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add( - (new Filter('id_contact', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('id_contact') - ) - ->add( - (new Filter('name', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('name') - ) - ->add( - (new Filter('email', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('email') - ) - ->add( - (new Filter('description', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('description') - ) - - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'attr' => [ - 'data-url' => $this->resetSearchUrl, - 'data-redirect' => $this->redirectionUrl, - ], - ]) - ->setAssociatedColumn('actions') - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - (new SubmitBulkAction('delete_all')) - ->setName($this->trans('Delete selected', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_contacts_delete_bulk', - 'confirm_message' => $this->trans('Delete selected items?', [], 'Admin.Notifications.Warning'), - ]) - ); - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/CreditSlipGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/CreditSlipGridDefinitionFactory.php deleted file mode 100644 index 511f560d..00000000 --- a/src/Core/Grid/Definition/Factory/CreditSlipGridDefinitionFactory.php +++ /dev/null @@ -1,188 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\DateTimeColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\LinkColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Form\Admin\Type\DateRangeType; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Defines grid for credit slip listing - */ -final class CreditSlipGridDefinitionFactory extends AbstractGridDefinitionFactory -{ - const GRID_ID = 'credit_slip'; - - /** - * @var string - */ - private $dateFormat; - - /** - * @param HookDispatcherInterface $hookDispatcher - * @param string $dateFormat The format in which date column values should be shown - */ - public function __construct(HookDispatcherInterface $hookDispatcher, $dateFormat) - { - parent::__construct($hookDispatcher); - $this->dateFormat = $dateFormat; - } - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Credit Slips', [], 'Admin.Navigation.Menu'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add((new DataColumn('id_order_slip')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_order_slip', - ]) - ) - ->add((new DataColumn('id_order')) - ->setName($this->trans('Order ID', [], 'Admin.Orderscustomers.Feature')) - ->setOptions([ - 'field' => 'id_order', - ]) - ) - ->add((new DateTimeColumn('date_add')) - ->setName($this->trans('Date issued', [], 'Admin.Orderscustomers.Feature')) - ->setOptions([ - 'field' => 'date_add', - 'format' => $this->dateFormat, - ]) - ) - ->add( - (new LinkColumn('pdf')) - ->setName($this->trans('PDF', [], 'Admin.Global')) - ->setOptions([ - 'sortable' => false, - 'field' => 'link_value', - 'route' => 'admin_credit_slips_generate_pdf', - 'route_param_name' => 'creditSlipId', - 'route_param_field' => 'id_order_slip', - 'icon' => 'insert_drive_file', - 'button_template' => 'outline', - 'color_template' => 'secondary', - ]) - ) - ->add((new ActionColumn('actions'))); - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add((new Filter('id_credit_slip', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('id_order_slip') - ) - ->add((new Filter('id_order', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search order ID', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('id_order') - ) - ->add((new Filter('date_issued', DateRangeType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('date_add') - ) - ->add((new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_credit_slips_index', - ]) - ->setAssociatedColumn('actions') - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/CurrencyGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/CurrencyGridDefinitionFactory.php deleted file mode 100644 index b499a1a8..00000000 --- a/src/Core/Grid/Definition/Factory/CurrencyGridDefinitionFactory.php +++ /dev/null @@ -1,189 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use PrestaShopBundle\Form\Admin\Type\YesAndNoChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class CurrencyGridDefinitionFactory is responsible for defining definition for currency list located in - * "International -> Localization -> currencies". - */ -final class CurrencyGridDefinitionFactory extends AbstractGridDefinitionFactory -{ - const GRID_ID = 'currency'; - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Currencies', [], 'Admin.Navigation.Menu'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add((new DataColumn('currency')) - ->setName($this->trans('Currency', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'currency', - 'sortable' => false, - ]) - ) - ->add((new DataColumn('symbol')) - ->setName($this->trans('Symbol', [], 'Admin.International.Feature')) - ->setOptions([ - 'field' => 'symbol', - 'sortable' => false, - ]) - ) - ->add((new DataColumn('iso_code')) - ->setName($this->trans('ISO code', [], 'Admin.International.Feature')) - ->setOptions([ - 'field' => 'iso_code', - ]) - ) - ->add((new DataColumn('conversion_rate')) - ->setName($this->trans('Exchange rate', [], 'Admin.International.Feature')) - ->setOptions([ - 'field' => 'conversion_rate', - ]) - ) - ->add((new ToggleColumn('active')) - ->setName($this->trans('Enabled', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'active', - 'primary_field' => 'id_currency', - 'route' => 'admin_currencies_toggle_status', - 'route_param_name' => 'currencyId', - ]) - ) - ->add((new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add((new LinkRowAction('edit')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_currencies_edit', - 'route_param_name' => 'currencyId', - 'route_param_field' => 'id_currency', - 'clickable_row' => true, - ]) - ) - ->add((new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'method' => 'DELETE', - 'route' => 'admin_currencies_delete', - 'route_param_name' => 'currencyId', - 'route_param_field' => 'id_currency', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - ]) - ), - ]) - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add((new Filter('iso_code', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('ISO code', [], 'Admin.International.Feature'), - ], - ]) - ->setAssociatedColumn('iso_code') - ) - ->add((new Filter('active', YesAndNoChoiceType::class)) - ->setTypeOptions([ - 'required' => false, - 'choice_translation_domain' => false, - ]) - ->setAssociatedColumn('active') - ) - ->add((new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_currencies_index', - ]) - ->setAssociatedColumn('actions') - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add((new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ; - } -} diff --git a/src/Core/Grid/Definition/Factory/CustomerGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/CustomerGridDefinitionFactory.php deleted file mode 100644 index dc1167b3..00000000 --- a/src/Core/Grid/Definition/Factory/CustomerGridDefinitionFactory.php +++ /dev/null @@ -1,444 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\Customer\DeleteCustomersBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\Customer\DeleteCustomerRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\LinkGridAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BadgeColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Form\Admin\Type\DateRangeType; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use PrestaShopBundle\Form\Admin\Type\YesAndNoChoiceType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\NumberType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class CustomerGridDefinitionFactory defines customers grid structure. - */ -final class CustomerGridDefinitionFactory extends AbstractGridDefinitionFactory -{ - const GRID_ID = 'customer'; - - /** - * @var bool - */ - private $isB2bFeatureEnabled; - - /** - * @var bool - */ - private $isMultistoreFeatureEnabled; - - /** - * @var array - */ - private $genderChoices; - - /** - * @param HookDispatcherInterface $hookDispatcher - * @param bool $isB2bFeatureEnabled - * @param bool $isMultistoreFeatureEnabled - * @param array $genderChoices - */ - public function __construct( - HookDispatcherInterface $hookDispatcher, - $isB2bFeatureEnabled, - $isMultistoreFeatureEnabled, - array $genderChoices - ) { - parent::__construct($hookDispatcher); - $this->isB2bFeatureEnabled = $isB2bFeatureEnabled; - $this->isMultistoreFeatureEnabled = $isMultistoreFeatureEnabled; - $this->genderChoices = $genderChoices; - } - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Manage your Customers', [], 'Admin.Orderscustomers.Feature'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - $columns = (new ColumnCollection()) - ->add( - (new BulkActionColumn('customers_bulk')) - ->setOptions([ - 'bulk_field' => 'id_customer', - ]) - ) - ->add( - (new DataColumn('id_customer')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_customer', - ]) - ) - ->add( - (new DataColumn('social_title')) - ->setName($this->trans('Social title', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'social_title', - ]) - ) - ->add( - (new DataColumn('firstname')) - ->setName($this->trans('First name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'firstname', - ]) - ) - ->add( - (new DataColumn('lastname')) - ->setName($this->trans('Last name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'lastname', - ]) - ) - ->add( - (new DataColumn('email')) - ->setName($this->trans('Email address', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'email', - ]) - ) - ->add( - (new BadgeColumn('total_spent')) - ->setName($this->trans('Sales', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'total_spent', - 'empty_value' => '--', - ]) - ) - ->add( - (new ToggleColumn('active')) - ->setName($this->trans('Enabled', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'active', - 'primary_field' => 'id_customer', - 'route' => 'admin_customers_toggle_status', - 'route_param_name' => 'customerId', - ]) - ) - ->add( - (new ToggleColumn('newsletter')) - ->setName($this->trans('Newsletter', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'newsletter', - 'primary_field' => 'id_customer', - 'route' => 'admin_customers_toggle_newsletter_subscription', - 'route_param_name' => 'customerId', - ]) - ) - ->add( - (new ToggleColumn('optin')) - ->setName($this->trans('Partner offers', [], 'Admin.Orderscustomers.Feature')) - ->setOptions([ - 'field' => 'optin', - 'primary_field' => 'id_customer', - 'route' => 'admin_customers_toggle_partner_offer_subscription', - 'route_param_name' => 'customerId', - ]) - ) - ->add( - (new DataColumn('date_add')) - ->setName($this->trans('Registration', [], 'Admin.Orderscustomers.Feature')) - ->setOptions([ - 'field' => 'date_add', - ]) - ) - ->add( - (new DataColumn('connect')) - ->setName($this->trans('Last visit', [], 'Admin.Orderscustomers.Feature')) - ->setOptions([ - 'field' => 'connect', - ]) - ) - ->add((new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add( - (new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_customers_edit', - 'route_param_name' => 'customerId', - 'route_param_field' => 'id_customer', - ]) - ) - ->add( - (new LinkRowAction('view')) - ->setName($this->trans('View', [], 'Admin.Actions')) - ->setIcon('zoom_in') - ->setOptions([ - 'route' => 'admin_customers_view', - 'route_param_name' => 'customerId', - 'route_param_field' => 'id_customer', - 'clickable_row' => true, - ]) - ) - ->add((new DeleteCustomerRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'customer_id_field' => 'id_customer', - 'customer_delete_route' => 'admin_customers_delete', - ]) - ), - ]) - ); - - if ($this->isB2bFeatureEnabled) { - $columns->addAfter( - 'email', - (new DataColumn('company')) - ->setName($this->trans('Company', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'company', - ]) - ); - } - - if ($this->isMultistoreFeatureEnabled) { - $columns->addBefore( - 'actions', - (new DataColumn('shop_name')) - ->setName($this->trans('Shop', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'shop_name', - 'sortable' => false, - ]) - ); - } - - return $columns; - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - $filters = (new FilterCollection()) - ->add( - (new Filter('id_customer', NumberType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('id_customer') - ) - ->add( - (new Filter('social_title', ChoiceType::class)) - ->setTypeOptions([ - 'choices' => $this->genderChoices, - 'expanded' => false, - 'multiple' => false, - 'required' => false, - 'choice_translation_domain' => false, - ]) - ->setAssociatedColumn('social_title') - ) - ->add( - (new Filter('firstname', TextType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search first name', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('firstname') - ) - ->add( - (new Filter('lastname', TextType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search last name', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('lastname') - ) - ->add( - (new Filter('email', TextType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search email', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('email') - ) - ->add( - (new Filter('active', YesAndNoChoiceType::class)) - ->setAssociatedColumn('active') - ) - ->add( - (new Filter('newsletter', YesAndNoChoiceType::class)) - ->setAssociatedColumn('newsletter') - ) - ->add( - (new Filter('optin', YesAndNoChoiceType::class)) - ->setAssociatedColumn('optin') - ) - ->add( - (new Filter('date_add', DateRangeType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('date_add') - ) - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_customers_index', - ]) - ->setAssociatedColumn('actions') - ); - - if ($this->isB2bFeatureEnabled) { - $filters->add( - (new Filter('company', TextType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search company', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('company') - ); - } - - return $filters; - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new LinkGridAction('import')) - ->setName($this->trans('Import', [], 'Admin.Actions')) - ->setIcon('cloud_upload') - ->setOptions([ - 'route' => 'admin_import', - 'route_params' => [ - 'import_type' => 'customers', - ], - ]) - ) - ->add( - (new LinkGridAction('export')) - ->setName($this->trans('Export', [], 'Admin.Actions')) - ->setIcon('cloud_download') - ->setOptions([ - 'route' => 'admin_customers_export', - ]) - ) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - (new SubmitBulkAction('enable_selection')) - ->setName($this->trans('Enable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_customers_enable_bulk', - ]) - ) - ->add( - (new SubmitBulkAction('disable_selection')) - ->setName($this->trans('Disable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_customers_disable_bulk', - ]) - ) - ->add((new DeleteCustomersBulkAction('delete_selection')) - ->setName($this->trans('Delete selected', [], 'Admin.Actions')) - ->setOptions([ - 'customers_bulk_delete_route' => 'admin_customers_delete_bulk', - ]) - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/EmailLogsDefinitionFactory.php b/src/Core/Grid/Definition/Factory/EmailLogsDefinitionFactory.php deleted file mode 100644 index 31180efc..00000000 --- a/src/Core/Grid/Definition/Factory/EmailLogsDefinitionFactory.php +++ /dev/null @@ -1,289 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SubmitGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Form\Admin\Type\DateRangeType; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class EmailLogsDefinitionFactory is responsible for creating email logs definition. - */ -final class EmailLogsDefinitionFactory extends AbstractGridDefinitionFactory -{ - /** - * @var string the URL to reset Grid filters - */ - private $resetActionUrl; - - /** - * @var string the URL for redirection - */ - private $redirectionUrl; - - /** - * @var ConfigurableFormChoiceProviderInterface - */ - private $languageChoiceProvider; - - /** - * @param HookDispatcherInterface $hookDispatcher - * @param string $resetActionUrl - * @param string $redirectionUrl - * @param ConfigurableFormChoiceProviderInterface $languageChoiceProvider - */ - public function __construct( - HookDispatcherInterface $hookDispatcher, - $resetActionUrl, - $redirectionUrl, - ConfigurableFormChoiceProviderInterface $languageChoiceProvider - ) { - parent::__construct($hookDispatcher); - $this->resetActionUrl = $resetActionUrl; - $this->redirectionUrl = $redirectionUrl; - $this->languageChoiceProvider = $languageChoiceProvider; - } - - /** - * {@inheritdoc} - */ - protected function getId() - { - return 'email_logs'; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('E-mail', [], 'Admin.Navigation.Menu'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add( - (new BulkActionColumn('delete_email_logs')) - ->setOptions([ - 'bulk_field' => 'id_mail', - ]) - ) - ->add( - (new DataColumn('id_mail')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_mail', - ]) - ) - ->add( - (new DataColumn('recipient')) - ->setName($this->trans('Recipient', [], 'Admin.Advparameters.Feature')) - ->setOptions([ - 'field' => 'recipient', - ]) - ) - ->add( - (new DataColumn('template')) - ->setName($this->trans('Template', [], 'Admin.Advparameters.Feature')) - ->setOptions([ - 'field' => 'template', - ]) - ) - ->add( - (new DataColumn('language')) - ->setName($this->trans('Language', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'language', - ]) - ) - ->add( - (new DataColumn('subject')) - ->setName($this->trans('Subject', [], 'Admin.Advparameters.Feature')) - ->setOptions([ - 'field' => 'subject', - ]) - ) - ->add( - (new DataColumn('date_add')) - ->setName($this->trans('Sent', [], 'Admin.Advparameters.Feature')) - ->setOptions([ - 'field' => 'date_add', - ]) - ) - ->add( - (new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add( - (new LinkRowAction('delete')) - ->setIcon('delete') - ->setOptions([ - 'route' => 'admin_emails_delete', - 'route_param_name' => 'mailId', - 'route_param_field' => 'id_mail', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - ]) - ), - ]) - ); - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add( - (new Filter('id_mail', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('id_mail') - ) - ->add( - (new Filter('recipient', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('recipient') - ) - ->add( - (new Filter('template', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('template') - ) - ->add( - (new Filter('id_lang', ChoiceType::class)) - ->setTypeOptions([ - 'required' => false, - 'choices' => $this->languageChoiceProvider->getChoices(), - 'choice_translation_domain' => false, - ]) - ->setAssociatedColumn('language') - ) - ->add( - (new Filter('subject', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('subject') - ) - ->add( - (new Filter('date_add', DateRangeType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('date_add') - ) - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'attr' => [ - 'data-url' => $this->resetActionUrl, - 'data-redirect' => $this->redirectionUrl, - ], - ]) - ->setAssociatedColumn('actions') - ); - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new SubmitGridAction('delete_all_email_logs')) - ->setName($this->trans('Erase all', [], 'Admin.Advparameters.Feature')) - ->setIcon('delete') - ->setOptions([ - 'submit_route' => 'admin_emails_delete_all', - 'confirm_message' => $this->trans('Are you sure?', [], 'Admin.Notifications.Warning'), - ]) - ) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - (new SubmitBulkAction('delete_email_logs')) - ->setName($this->trans('Delete selected', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_emails_delete_bulk', - 'confirm_message' => $this->trans('Delete selected items?', [], 'Admin.Notifications.Warning'), - ]) - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/EmployeeGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/EmployeeGridDefinitionFactory.php deleted file mode 100644 index e98d65b4..00000000 --- a/src/Core/Grid/Definition/Factory/EmployeeGridDefinitionFactory.php +++ /dev/null @@ -1,323 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Form\Admin\Type\Common\Team\ProfileChoiceType; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use PrestaShopBundle\Form\Admin\Type\YesAndNoChoiceType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\NumberType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class EmployeeGridDefinitionFactory creates grid definition for Employee data. - */ -final class EmployeeGridDefinitionFactory extends AbstractGridDefinitionFactory -{ - /** - * @var string - */ - private $resetUrl; - - /** - * @var string - */ - private $redirectUrl; - - /** - * @param HookDispatcherInterface $hookDispatcher - * @param string $resetUrl - * @param string $redirectUrl - */ - public function __construct( - HookDispatcherInterface $hookDispatcher, - $resetUrl, - $redirectUrl - ) { - parent::__construct($hookDispatcher); - $this->resetUrl = $resetUrl; - $this->redirectUrl = $redirectUrl; - } - - /** - * {@inheritdoc} - */ - protected function getId() - { - return 'employee'; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Employees', [], 'Admin.Advparameters.Feature'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add( - (new BulkActionColumn('employee_bulk')) - ->setOptions([ - 'bulk_field' => 'id_employee', - ]) - ) - ->add( - (new DataColumn('id_employee')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_employee', - ]) - ) - ->add( - (new DataColumn('firstname')) - ->setName($this->trans('First name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'firstname', - ]) - ) - ->add( - (new DataColumn('lastname')) - ->setName($this->trans('Last name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'lastname', - ]) - ) - ->add( - (new DataColumn('email')) - ->setName($this->trans('Email address', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'email', - ]) - ) - ->add( - (new DataColumn('profile')) - ->setName($this->trans('Profile', [], 'Admin.Advparameters.Feature')) - ->setOptions([ - 'field' => 'profile_name', - ]) - ) - ->add( - (new ToggleColumn('active')) - ->setName($this->trans('Active', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'active', - 'primary_field' => 'id_employee', - 'route' => 'admin_employees_toggle_status', - 'route_param_name' => 'employeeId', - ]) - ) - ->add( - (new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add((new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_employees_edit', - 'route_param_name' => 'employeeId', - 'route_param_field' => 'id_employee', - 'clickable_row' => true, - ]) - ) - ->add( - (new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - 'route' => 'admin_employees_delete', - 'route_param_name' => 'employeeId', - 'route_param_field' => 'id_employee', - ]) - ), - ]) - ); - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add( - (new Filter('id_employee', NumberType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('id_employee') - ) - ->add( - (new Filter('firstname', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search first name', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('firstname') - ) - ->add( - (new Filter('lastname', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search last name', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('lastname') - ) - ->add( - (new Filter('email', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search email', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('email') - ) - ->add( - (new Filter('profile', ProfileChoiceType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('profile') - ) - ->add( - (new Filter('active', ChoiceType::class)) - ->setTypeOptions([ - 'choices' => [ - $this->trans('Yes', [], 'Admin.Global') => 1, - $this->trans('No', [], 'Admin.Global') => 0, - ], - 'required' => false, - 'choice_translation_domain' => false, - ]) - ) - ->add((new Filter('active', YesAndNoChoiceType::class)) - ->setAssociatedColumn('active') - ) - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'attr' => [ - 'data-url' => $this->resetUrl, - 'data-redirect' => $this->redirectUrl, - ], - ]) - ->setAssociatedColumn('actions') - ); - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - (new SubmitBulkAction('enable_selection')) - ->setName($this->trans('Enable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_employees_bulk_enable_status', - ]) - ) - ->add( - (new SubmitBulkAction('disable_selection')) - ->setName($this->trans('Disable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_employees_bulk_disable_status', - ]) - ) - ->add( - (new SubmitBulkAction('delete_selection')) - ->setName($this->trans('Delete selected', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_employees_bulk_delete', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - ]) - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/FilterableGridDefinitionFactoryInterface.php b/src/Core/Grid/Definition/Factory/FilterableGridDefinitionFactoryInterface.php deleted file mode 100644 index 6c15ed8f..00000000 --- a/src/Core/Grid/Definition/Factory/FilterableGridDefinitionFactoryInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -/** - * This interface allows to identify the filters associated to a Grid, which is then used - * to scope its parameters in request (thus allowing multi grid on same page) and as a key - * to persist them in database (and of course etch them afterwards). - */ -interface FilterableGridDefinitionFactoryInterface extends GridDefinitionFactoryInterface -{ - /** - * Returns a (unique) id to identify the grid filters, this is used as a key to persist - * (and clear) the Filters associated to the grid. - * - * @return string - */ - public function getFilterId(): string; -} diff --git a/src/Core/Grid/Definition/Factory/GridDefinitionFactoryInterface.php b/src/Core/Grid/Definition/Factory/GridDefinitionFactoryInterface.php deleted file mode 100644 index eacd347e..00000000 --- a/src/Core/Grid/Definition/Factory/GridDefinitionFactoryInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface; - -/** - * Interface GridDefinitionFactoryInterface defines contract for creating grid. - */ -interface GridDefinitionFactoryInterface -{ - /** - * Create new grid definition. - * - * @return GridDefinitionInterface - */ - public function getDefinition(); -} diff --git a/src/Core/Grid/Definition/Factory/LanguageGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/LanguageGridDefinitionFactory.php deleted file mode 100644 index 60580f13..00000000 --- a/src/Core/Grid/Definition/Factory/LanguageGridDefinitionFactory.php +++ /dev/null @@ -1,329 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ImageColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\LinkColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\NumberType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class LanguageGridDefinitionFactory creates definition for languages grid. - */ -final class LanguageGridDefinitionFactory extends AbstractGridDefinitionFactory -{ - use BulkDeleteActionTrait; - - const GRID_ID = 'language'; - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Languages', [], 'Admin.Global'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add( - (new BulkActionColumn('language_bulk')) - ->setOptions([ - 'bulk_field' => 'id_lang', - ]) - ) - ->add( - (new DataColumn('id_lang')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_lang', - ]) - ) - ->add( - (new ImageColumn('flag')) - ->setName($this->trans('Flag', [], 'Admin.International.Feature')) - ->setOptions([ - 'src_field' => 'flag', - ]) - ) - ->add( - (new LinkColumn('name')) - ->setName($this->trans('Name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - 'route' => 'admin_languages_edit', - 'route_param_name' => 'languageId', - 'route_param_field' => 'id_lang', - ]) - ) - ->add( - (new DataColumn('iso_code')) - ->setName($this->trans('ISO code', [], 'Admin.International.Feature')) - ->setOptions([ - 'field' => 'iso_code', - ]) - ) - ->add( - (new DataColumn('language_code')) - ->setName($this->trans('Language code', [], 'Admin.International.Feature')) - ->setOptions([ - 'field' => 'language_code', - ]) - ) - ->add( - (new DataColumn('date_format_lite')) - ->setName($this->trans('Date format', [], 'Admin.International.Feature')) - ->setOptions([ - 'field' => 'date_format_lite', - ]) - ) - ->add( - (new DataColumn('date_format_full')) - ->setName($this->trans('Date format (full)', [], 'Admin.International.Feature')) - ->setOptions([ - 'field' => 'date_format_full', - ]) - ) - ->add( - (new ToggleColumn('active')) - ->setName($this->trans('Enabled', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'active', - 'primary_field' => 'id_lang', - 'route' => 'admin_languages_toggle_status', - 'route_param_name' => 'languageId', - ]) - ) - ->add( - (new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add( - (new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_languages_edit', - 'route_param_name' => 'languageId', - 'route_param_field' => 'id_lang', - 'clickable_row' => true, - ]) - ) - ->add( - (new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - 'route' => 'admin_languages_delete', - 'route_param_name' => 'languageId', - 'route_param_field' => 'id_lang', - ]) - ), - ]) - ); - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add( - (new Filter('id_lang', NumberType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->translator->trans('Search ID', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('id_lang') - ) - ->add( - (new Filter('name', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->translator->trans('Search name', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('name') - ) - ->add( - (new Filter('iso_code', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->translator->trans('Search ISO code', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('iso_code') - ) - ->add( - (new Filter('language_code', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->translator->trans('Search code', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('language_code') - ) - ->add( - (new Filter('date_format_lite', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->translator->trans('Search date format', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('date_format_lite') - ) - ->add( - (new Filter('date_format_full', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->translator->trans('Search date format', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('date_format_full') - ) - ->add( - (new Filter('active', ChoiceType::class)) - ->setTypeOptions([ - 'choices' => [ - $this->trans('Yes', [], 'Admin.Global') => 1, - $this->trans('No', [], 'Admin.Global') => 0, - ], - 'required' => false, - 'choice_translation_domain' => false, - ]) - ->setAssociatedColumn('active') - ) - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_languages_index', - ]) - ->setAssociatedColumn('actions') - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - (new SubmitBulkAction('enable_selection')) - ->setName($this->trans('Enable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_languages_bulk_toggle_status', - 'route_params' => [ - 'status' => 'enable', - ], - ]) - ) - ->add( - (new SubmitBulkAction('disable_selection')) - ->setName($this->trans('Disable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_languages_bulk_toggle_status', - 'route_params' => [ - 'status' => 'disable', - ], - ]) - ) - ->add( - $this->buildBulkDeleteAction('admin_languages_bulk_delete') - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/LogGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/LogGridDefinitionFactory.php deleted file mode 100644 index 9a3b25e5..00000000 --- a/src/Core/Grid/Definition/Factory/LogGridDefinitionFactory.php +++ /dev/null @@ -1,268 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SubmitGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\DateTimeColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Employee\EmployeeNameWithAvatarColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Status\SeverityLevelColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Form\Admin\Type\DateRangeType; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class LogGridDefinitionFactory is responsible for creating new instance of Log grid definition. - */ -final class LogGridDefinitionFactory extends AbstractGridDefinitionFactory -{ - /** - * @var string the URL to reset Grid filters - */ - private $resetActionUrl; - - /** - * @var string the URL for redirection - */ - private $redirectionUrl; - - /** - * LogGridDefinitionFactory constructor. - * - * @param HookDispatcherInterface $hookDispatcher - * @param string $resetActionUrl - * @param string $redirectionUrl - */ - public function __construct( - HookDispatcherInterface $hookDispatcher, - $resetActionUrl, - $redirectionUrl - ) { - parent::__construct($hookDispatcher); - $this->resetActionUrl = $resetActionUrl; - $this->redirectionUrl = $redirectionUrl; - } - - /** - * {@inheritdoc} - */ - protected function getId() - { - return 'logs'; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Logs', [], 'Admin.Navigation.Menu'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add( - (new DataColumn('id_log')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_log', - ]) - ) - ->add( - (new EmployeeNameWithAvatarColumn('employee')) - ->setName($this->trans('Employee', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'employee', - ]) - ) - ->add( - (new SeverityLevelColumn('severity')) - ->setName($this->trans('Severity (1-4)', [], 'Admin.Advparameters.Feature')) - ->setOptions([ - 'with_message' => true, - 'field' => 'severity', - ]) - ) - ->add( - (new DataColumn('message')) - ->setName($this->trans('Message', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'message', - ]) - ) - ->add( - (new DataColumn('object_type')) - ->setName($this->trans('Object type', [], 'Admin.Advparameters.Feature')) - ->setOptions([ - 'field' => 'object_type', - ]) - ) - ->add( - (new DataColumn('object_id')) - ->setName($this->trans('Object ID', [], 'Admin.Advparameters.Feature')) - ->setOptions([ - 'field' => 'object_id', - ]) - ) - ->add( - (new DataColumn('error_code')) - ->setName($this->trans('Error code', [], 'Admin.Advparameters.Feature')) - ->setOptions([ - 'field' => 'error_code', - ]) - ) - ->add( - (new DateTimeColumn('date_add')) - ->setName($this->trans('Date', [], 'Admin.Global')) - ->setOptions([ - 'format' => 'Y-m-d H:i', - 'field' => 'date_add', - ]) - ) - ->add( - (new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ); - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return (new FilterCollection()) - ->add( - (new Filter('id_log', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('id_log') - ) - ->add( - (new Filter('employee', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('employee') - ) - ->add( - (new Filter('severity', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('severity') - ) - ->add( - (new Filter('message', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('message') - ) - ->add( - (new Filter('object_type', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('object_type') - ) - ->add( - (new Filter('object_id', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('object_id') - ) - ->add( - (new Filter('error_code', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('error_code') - ) - ->add( - (new Filter('date_add', DateRangeType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('date_add') - ) - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'attr' => [ - 'data-url' => $this->resetActionUrl, - 'data-redirect' => $this->redirectionUrl, - ], - ]) - ->setAssociatedColumn('actions') - ); - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new SubmitGridAction('delete_all_email_logs')) - ->setName($this->trans('Erase all', [], 'Admin.Advparameters.Feature')) - ->setIcon('delete') - ->setOptions([ - 'submit_route' => 'admin_logs_delete_all', - 'confirm_message' => $this->trans('Are you sure?', [], 'Admin.Notifications.Warning'), - ]) - ) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/ManufacturerAddressGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/ManufacturerAddressGridDefinitionFactory.php deleted file mode 100644 index e0a2bbf8..00000000 --- a/src/Core/Grid/Definition/Factory/ManufacturerAddressGridDefinitionFactory.php +++ /dev/null @@ -1,286 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\LinkGridAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShopBundle\Form\Admin\Type\CountryChoiceType; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class ManufacturerAddressGridDefinitionFactory is responsible for creating Manufacturers address grid definition. - */ -final class ManufacturerAddressGridDefinitionFactory extends AbstractGridDefinitionFactory -{ - use BulkDeleteActionTrait; - - const GRID_ID = 'manufacturer_address'; - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Addresses', [], 'Admin.Catalog.Feature'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add((new BulkActionColumn('bulk')) - ->setOptions([ - 'bulk_field' => 'id_address', - ]) - ) - ->add((new DataColumn('id_address')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_address', - ]) - ) - ->add((new DataColumn('name')) - ->setName($this->trans('Brand', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - ]) - ) - ->add((new DataColumn('firstname')) - ->setName($this->trans('First name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'firstname', - ]) - ) - ->add((new DataColumn('lastname')) - ->setName($this->trans('Last name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'lastname', - ]) - ) - ->add((new DataColumn('postcode')) - ->setName($this->trans('Zip/Postal code', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'postcode', - ]) - ) - ->add((new DataColumn('city')) - ->setName($this->trans('City', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'city', - ]) - ) - ->add((new DataColumn('country')) - ->setName($this->trans('Country', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'country', - ]) - ) - ->add((new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add((new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_manufacturer_addresses_edit', - 'route_param_name' => 'addressId', - 'route_param_field' => 'id_address', - 'clickable_row' => true, - ]) - ) - ->add((new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'route' => 'admin_manufacturer_addresses_delete', - 'route_param_name' => 'addressId', - 'route_param_field' => 'id_address', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - ]) - ), - ]) - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add((new Filter('id_address', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('id_address') - ) - ->add((new Filter('name', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search name', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('name') - ) - ->add((new Filter('firstname', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search first name', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('firstname') - ) - ->add((new Filter('lastname', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search last name', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('lastname') - ) - ->add((new Filter('postcode', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search post code', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('postcode') - ) - ->add((new Filter('city', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search city', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('city') - ) - ->add((new Filter('country', CountryChoiceType::class)) - ->setTypeOptions([ - 'required' => false, - 'choice_translation_domain' => false, - ]) - ->setAssociatedColumn('country') - ) - ->add((new Filter('actions', SearchAndResetType::class)) - ->setAssociatedColumn('actions') - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_manufacturers_index', - ]) - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - $this->buildBulkDeleteAction('admin_manufacturer_addresses_bulk_delete') - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add((new LinkGridAction('import')) - ->setName($this->trans('Import', [], 'Admin.Actions')) - ->setIcon('cloud_upload') - ->setOptions([ - 'route' => 'admin_import', - 'route_params' => [ - 'import_type' => 'manufacturers', - ], - ]) - ) - ->add((new LinkGridAction('export')) - ->setName($this->trans('Export', [], 'Admin.Actions')) - ->setIcon('cloud_download') - ->setOptions([ - 'route' => 'admin_manufacturer_addresses_export', - ]) - ) - ->add((new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add((new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add((new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ) - ; - } -} diff --git a/src/Core/Grid/Definition/Factory/ManufacturerGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/ManufacturerGridDefinitionFactory.php deleted file mode 100644 index e1aaf656..00000000 --- a/src/Core/Grid/Definition/Factory/ManufacturerGridDefinitionFactory.php +++ /dev/null @@ -1,263 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\LinkGridAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ImageColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use PrestaShopBundle\Form\Admin\Type\YesAndNoChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class ManufacturerGridDefinitionFactory is responsible for creating Manufacturers grid definition. - */ -final class ManufacturerGridDefinitionFactory extends AbstractGridDefinitionFactory -{ - use BulkDeleteActionTrait; - - const GRID_ID = 'manufacturer'; - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Brands', [], 'Admin.Catalog.Feature'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add((new BulkActionColumn('bulk')) - ->setOptions([ - 'bulk_field' => 'id_manufacturer', - ]) - ) - ->add((new DataColumn('id_manufacturer')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_manufacturer', - ]) - ) - ->add((new ImageColumn('logo')) - ->setName($this->trans('Logo', [], 'Admin.Global')) - ->setOptions([ - 'src_field' => 'logo', - ]) - ) - ->add((new DataColumn('name')) - ->setName($this->trans('Name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - ]) - ) - ->add((new DataColumn('addresses_count')) - ->setName($this->trans('Addresses', [], 'Admin.Catalog.Feature')) - ->setOptions([ - 'field' => 'addresses_count', - ]) - ) - ->add((new DataColumn('products_count')) - ->setName($this->trans('Products', [], 'Admin.Catalog.Feature')) - ->setOptions([ - 'field' => 'products_count', - ]) - ) - ->add((new ToggleColumn('active')) - ->setName($this->trans('Enabled', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'active', - 'primary_field' => 'id_manufacturer', - 'route' => 'admin_manufacturers_toggle_status', - 'route_param_name' => 'manufacturerId', - ]) - ) - ->add((new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add((new LinkRowAction('view')) - ->setName($this->trans('View', [], 'Admin.Actions')) - ->setIcon('zoom_in') - ->setOptions([ - 'route' => 'admin_manufacturers_view', - 'route_param_name' => 'manufacturerId', - 'route_param_field' => 'id_manufacturer', - 'clickable_row' => true, - ]) - ) - ->add((new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_manufacturers_edit', - 'route_param_name' => 'manufacturerId', - 'route_param_field' => 'id_manufacturer', - ]) - ) - ->add((new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'route' => 'admin_manufacturers_delete', - 'route_param_name' => 'manufacturerId', - 'route_param_field' => 'id_manufacturer', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - ]) - ), - ]) - ); - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add((new LinkGridAction('import')) - ->setName($this->trans('Import', [], 'Admin.Actions')) - ->setIcon('cloud_upload') - ->setOptions([ - 'route' => 'admin_import', - 'route_params' => [ - 'import_type' => 'manufacturers', - ], - ]) - ) - ->add((new LinkGridAction('export')) - ->setName($this->trans('Export', [], 'Admin.Actions')) - ->setIcon('cloud_download') - ->setOptions([ - 'route' => 'admin_manufacturers_export', - ]) - ) - ->add((new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add((new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add((new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add((new Filter('id_manufacturer', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('id_manufacturer') - ) - ->add((new Filter('name', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search name', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('name') - ) - ->add((new Filter('active', YesAndNoChoiceType::class)) - ->setAssociatedColumn('active') - ) - ->add((new Filter('actions', SearchAndResetType::class)) - ->setAssociatedColumn('actions') - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_manufacturers_index', - ]) - ->setAssociatedColumn('actions') - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add((new SubmitBulkAction('enable_selection')) - ->setName($this->trans('Enable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_manufacturers_bulk_enable_status', - ]) - ) - ->add((new SubmitBulkAction('disable_selection')) - ->setName($this->trans('Disable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_manufacturers_bulk_disable_status', - ]) - )->add( - $this->buildBulkDeleteAction('admin_manufacturers_bulk_delete') - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/MerchandiseReturnGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/MerchandiseReturnGridDefinitionFactory.php deleted file mode 100644 index b9083b9d..00000000 --- a/src/Core/Grid/Definition/Factory/MerchandiseReturnGridDefinitionFactory.php +++ /dev/null @@ -1,156 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\ColorColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\DateTimeColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShopBundle\Form\Admin\Type\DateRangeType; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class MerchandiseReturnGridDefinitionFactory builds grid definition for merchandise returns grid. - */ -final class MerchandiseReturnGridDefinitionFactory extends AbstractFilterableGridDefinitionFactory -{ - const GRID_ID = 'merchandise_return'; - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Merchandise Returns', [], 'Admin.Orderscustomers.Feature'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - $columns = (new ColumnCollection()) - ->add( - (new DataColumn('id_order_return')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_order_return', - ]) - ) - ->add( - (new DataColumn('id_order')) - ->setName($this->trans('Order ID', [], 'Admin.Orderscustomers.Feature')) - ->setOptions([ - 'field' => 'id_order', - ]) - ) - ->add( - (new ColorColumn('status')) - ->setName($this->trans('Status', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'status', - 'color_field' => 'color', - ]) - ) - ->add( - (new DateTimeColumn('date_add')) - ->setName($this->trans('Date issued', [], 'Admin.Orderscustomers.Feature')) - ->setOptions([ - 'field' => 'date_add', - ]) - ) - ->add( - (new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ) - ; - - return $columns; - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add((new Filter('id_order_return', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('id_order_return') - ) - ->add((new Filter('id_order', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search order ID', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('id_order') - ) - ->add((new Filter('status', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('status') - ) - ->add((new Filter('date_add', DateRangeType::class)) - ->setTypeOptions([ - 'required' => false, - 'date_format' => 'YYYY-MM-DD', - ]) - ->setAssociatedColumn('date_add') - ) - ->add((new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_merchandise_returns_index', - ]) - ->setAssociatedColumn('actions') - ) - ; - } -} diff --git a/src/Core/Grid/Definition/Factory/MetaGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/MetaGridDefinitionFactory.php deleted file mode 100644 index 7bd26e14..00000000 --- a/src/Core/Grid/Definition/Factory/MetaGridDefinitionFactory.php +++ /dev/null @@ -1,227 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class MetaGridDefinitionFactory is responsible for adding definition for Seo & urls list. - */ -final class MetaGridDefinitionFactory extends AbstractGridDefinitionFactory -{ - /** - * {@inheritdoc} - */ - protected function getId() - { - return 'meta'; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('SEO & URLs', [], 'Admin.Navigation.Menu'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add( - (new BulkActionColumn('bulk')) - ->setOptions([ - 'bulk_field' => 'id_meta', - ]) - ) - ->add( - (new DataColumn('id_meta')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_meta', - ]) - ) - ->add( - (new DataColumn('page')) - ->setName($this->trans('Page', [], 'Admin.Shopparameters.Feature')) - ->setOptions([ - 'field' => 'page', - ]) - ) - ->add( - (new DataColumn('title')) - ->setName($this->trans('Page title', [], 'Admin.Shopparameters.Feature')) - ->setOptions([ - 'field' => 'title', - ]) - ) - ->add( - (new DataColumn('url_rewrite')) - ->setName($this->trans('Friendly URL', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'url_rewrite', - ]) - ) - ->add( - (new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add( - (new LinkRowAction('edit')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_metas_edit', - 'route_param_name' => 'metaId', - 'route_param_field' => 'id_meta', - 'clickable_row' => true, - ]) - ) - ->add( - (new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'method' => 'DELETE', - 'route' => 'admin_metas_delete', - 'route_param_name' => 'metaId', - 'route_param_field' => 'id_meta', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - ]) - ), - ]) - ); - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add( - (new Filter('id_meta', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('id_meta') - ) - ->add( - (new Filter('page', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('page') - ) - ->add( - (new Filter('title', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('title') - ) - ->add( - (new Filter('url_rewrite', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('url_rewrite') - ) - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search', - 'reset_route_params' => [ - 'controller' => 'meta', - 'action' => 'index', - ], - 'redirect_route' => 'admin_metas_index', - ]) - ->setAssociatedColumn('actions') - ); - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - (new SubmitBulkAction('delete_seo_urls')) - ->setName($this->trans('Delete selected', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_metas_delete_bulk', - 'confirm_message' => $this->trans('Delete selected items?', [], 'Admin.Notifications.Warning'), - ]) - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/Monitoring/AbstractProductGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/Monitoring/AbstractProductGridDefinitionFactory.php deleted file mode 100644 index 073618da..00000000 --- a/src/Core/Grid/Definition/Factory/Monitoring/AbstractProductGridDefinitionFactory.php +++ /dev/null @@ -1,202 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring; - -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\IdentifierColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AbstractGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use PrestaShopBundle\Form\Admin\Type\YesAndNoChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Defines reusable grids for product listing in monitoring page - */ -abstract class AbstractProductGridDefinitionFactory extends AbstractGridDefinitionFactory -{ - /** - * {@inheritdoc} - */ - protected function getId() - { - return $this::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add( - (new IdentifierColumn('id_product')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'identifier_field' => 'id_product', - ]) - ) - ->add( - (new DataColumn('reference')) - ->setName($this->trans('Reference', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'reference', - ]) - ) - ->add( - (new DataColumn('name')) - ->setName($this->trans('Name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - ]) - ) - ->add( - (new ToggleColumn('active')) - ->setName($this->trans('Status', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'active', - 'primary_field' => 'id_product', - 'route' => 'admin_product_toggle_status', - 'route_param_name' => 'productId', - ]) - ) - ->add( - (new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => $this->getRowActions(), - ]) - ); - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - $filters = (new FilterCollection()) - ->add( - (new Filter('id_product', TextType::class)) - ->setAssociatedColumn('id_product') - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - ]) - ) - ->add( - (new Filter('reference', TextType::class)) - ->setAssociatedColumn('reference') - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search reference', [], 'Admin.Actions'), - ], - ]) - ) - ->add( - (new Filter('name', TextType::class)) - ->setAssociatedColumn('name') - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search name', [], 'Admin.Actions'), - ], - ]) - ) - ->add( - (new Filter('active', YesAndNoChoiceType::class)) - ->setAssociatedColumn('active') - ) - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setAssociatedColumn('actions') - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => $this::GRID_ID, - ], - 'redirect_route' => 'admin_monitorings_index', - ]) - ->setAssociatedColumn('actions') - ); - - return $filters; - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ); - } - - /** - * @return RowActionCollection - */ - protected function getRowActions() - { - return (new RowActionCollection()) - ->add( - (new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_product_form', - 'route_param_name' => 'id', - 'route_param_field' => 'id_product', - ]) - ) - ->add( - (new LinkRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'route' => 'admin_product_unit_action', - 'route_param_name' => 'id', - 'route_param_field' => 'id_product', - 'extra_route_params' => ['action' => 'delete'], - 'confirm_message' => $this->trans('Delete selected item?', [], 'Admin.Notifications.Warning'), - ]) - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/Monitoring/DisabledProductGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/Monitoring/DisabledProductGridDefinitionFactory.php deleted file mode 100644 index 9ae75b9f..00000000 --- a/src/Core/Grid/Definition/Factory/Monitoring/DisabledProductGridDefinitionFactory.php +++ /dev/null @@ -1,138 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring; - -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\IdentifierColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Builds Grid definition for disabled product grid - */ -final class DisabledProductGridDefinitionFactory extends AbstractProductGridDefinitionFactory -{ - const GRID_ID = 'disabled_product'; - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('List of disabled products', [], 'Admin.Catalog.Feature'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add( - (new IdentifierColumn('id_product')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'identifier_field' => 'id_product', - ]) - ) - ->add( - (new DataColumn('reference')) - ->setName($this->trans('Reference', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'reference', - ]) - ) - ->add( - (new DataColumn('name')) - ->setName($this->trans('Name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - ]) - ) - ->add( - (new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => $this->getRowActions(), - ]) - ); - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add( - (new Filter('id_product', TextType::class)) - ->setAssociatedColumn('id_product') - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - ]) - ) - ->add( - (new Filter('reference', TextType::class)) - ->setAssociatedColumn('reference') - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search reference', [], 'Admin.Actions'), - ], - ]) - ) - ->add( - (new Filter('name', TextType::class)) - ->setAssociatedColumn('name') - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search name', [], 'Admin.Actions'), - ], - ]) - ) - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setAssociatedColumn('actions') - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => $this::GRID_ID, - ], - 'redirect_route' => 'admin_monitorings_index', - ]) - ->setAssociatedColumn('actions') - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/Monitoring/EmptyCategoryGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/Monitoring/EmptyCategoryGridDefinitionFactory.php deleted file mode 100644 index 94a52233..00000000 --- a/src/Core/Grid/Definition/Factory/Monitoring/EmptyCategoryGridDefinitionFactory.php +++ /dev/null @@ -1,218 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring; - -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\Category\DeleteCategoryRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\IdentifierColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AbstractGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use PrestaShopBundle\Form\Admin\Type\YesAndNoChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Builds Grid definition for empty categories listing - */ -final class EmptyCategoryGridDefinitionFactory extends AbstractGridDefinitionFactory -{ - const GRID_ID = 'empty_category'; - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('List of empty categories', [], 'Admin.Catalog.Feature'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add( - (new IdentifierColumn('id_category')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'identifier_field' => 'id_category', - ]) - ) - ->add( - (new DataColumn('name')) - ->setName($this->trans('Name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - ]) - ) - ->add( - (new DataColumn('description')) - ->setName($this->trans('Description', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'description', - ]) - ) - ->add( - (new ToggleColumn('active')) - ->setName($this->trans('Displayed', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'active', - 'primary_field' => 'id_category', - 'route' => 'admin_categories_toggle_status', - 'route_param_name' => 'categoryId', - ]) - ) - ->add( - (new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => $this->getRowActions(), - ]) - ); - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add( - (new Filter('id_category', TextType::class)) - ->setAssociatedColumn('id_category') - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - ]) - ) - ->add( - (new Filter('name', TextType::class)) - ->setAssociatedColumn('name') - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search name', [], 'Admin.Actions'), - ], - ]) - ) - ->add( - (new Filter('description', TextType::class)) - ->setAssociatedColumn('description') - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search description', [], 'Admin.Actions'), - ], - ]) - ) - ->add( - (new Filter('active', YesAndNoChoiceType::class)) - ->setAssociatedColumn('active') - ) - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setAssociatedColumn('actions') - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_monitorings_index', - ]) - ->setAssociatedColumn('actions') - ); - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ); - } - - /** - * @return RowActionCollection - */ - private function getRowActions() - { - return (new RowActionCollection()) - ->add( - (new LinkRowAction('view')) - ->setName($this->trans('View', [], 'Admin.Actions')) - ->setIcon('zoom_in') - ->setOptions([ - 'route' => 'admin_categories_index', //@todo: implement view products of this category - 'route_param_name' => 'id_category', - 'route_param_field' => 'id_category', - ]) - ) - ->add( - (new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_categories_edit', - 'route_param_name' => 'categoryId', - 'route_param_field' => 'id_category', - ]) - ) - ->add( - (new DeleteCategoryRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'category_id_field' => 'id_category', - 'category_delete_route' => 'admin_categories_delete', - ]) - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/Monitoring/NoQtyProductWithCombinationGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/Monitoring/NoQtyProductWithCombinationGridDefinitionFactory.php deleted file mode 100644 index 90879a9e..00000000 --- a/src/Core/Grid/Definition/Factory/Monitoring/NoQtyProductWithCombinationGridDefinitionFactory.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring; - -/** - * Builds Grid definition for product with combination and without quantities grid - */ -final class NoQtyProductWithCombinationGridDefinitionFactory extends AbstractProductGridDefinitionFactory -{ - const GRID_ID = 'no_qty_product_with_combination'; - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans( - 'List of products with combinations but without available quantities for sale', - [], - 'Admin.Catalog.Feature' - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/Monitoring/NoQtyProductWithoutCombinationGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/Monitoring/NoQtyProductWithoutCombinationGridDefinitionFactory.php deleted file mode 100644 index a452f5fd..00000000 --- a/src/Core/Grid/Definition/Factory/Monitoring/NoQtyProductWithoutCombinationGridDefinitionFactory.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring; - -/** - * Builds Grid definition for product without combination and without quantities grid - */ -final class NoQtyProductWithoutCombinationGridDefinitionFactory extends AbstractProductGridDefinitionFactory -{ - const GRID_ID = 'no_qty_product_without_combination'; - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans( - 'List of products without combinations and without available quantities for sale', - [], - 'Admin.Catalog.Feature' - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/Monitoring/ProductWithoutDescriptionGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/Monitoring/ProductWithoutDescriptionGridDefinitionFactory.php deleted file mode 100644 index 3a04624a..00000000 --- a/src/Core/Grid/Definition/Factory/Monitoring/ProductWithoutDescriptionGridDefinitionFactory.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring; - -/** - * Builds Grid definition for product without description grid - */ -final class ProductWithoutDescriptionGridDefinitionFactory extends AbstractProductGridDefinitionFactory -{ - const GRID_ID = 'product_without_description'; - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('List of products without description', [], 'Admin.Catalog.Feature'); - } -} diff --git a/src/Core/Grid/Definition/Factory/Monitoring/ProductWithoutImageGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/Monitoring/ProductWithoutImageGridDefinitionFactory.php deleted file mode 100644 index 1c4cb00a..00000000 --- a/src/Core/Grid/Definition/Factory/Monitoring/ProductWithoutImageGridDefinitionFactory.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring; - -/** - * Builds Grid definition for product without image grid - */ -final class ProductWithoutImageGridDefinitionFactory extends AbstractProductGridDefinitionFactory -{ - const GRID_ID = 'product_without_image'; - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('List of products without images', [], 'Admin.Catalog.Feature'); - } -} diff --git a/src/Core/Grid/Definition/Factory/Monitoring/ProductWithoutPriceGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/Monitoring/ProductWithoutPriceGridDefinitionFactory.php deleted file mode 100644 index 290c3029..00000000 --- a/src/Core/Grid/Definition/Factory/Monitoring/ProductWithoutPriceGridDefinitionFactory.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring; - -/** - * Builds Grid definition for product without price grid - */ -final class ProductWithoutPriceGridDefinitionFactory extends AbstractProductGridDefinitionFactory -{ - const GRID_ID = 'product_without_price'; - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('List of products without price', [], 'Admin.Catalog.Feature'); - } -} diff --git a/src/Core/Grid/Definition/Factory/OrderGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/OrderGridDefinitionFactory.php deleted file mode 100644 index f8082134..00000000 --- a/src/Core/Grid/Definition/Factory/OrderGridDefinitionFactory.php +++ /dev/null @@ -1,505 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Feature\FeatureInterface; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\ButtonBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\ModalFormSubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\AccessibilityChecker\AccessibilityCheckerInterface; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\LinkGridAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\BooleanColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ChoiceColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\DateTimeColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\IdentifierColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DisableableLinkColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\OrderPriceColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\PreviewColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Form\Admin\Type\DateRangeType; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use PrestaShopBundle\Form\Admin\Type\YesAndNoChoiceType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Creates definition for Orders grid - */ -final class OrderGridDefinitionFactory extends AbstractFilterableGridDefinitionFactory -{ - const GRID_ID = 'order'; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var FormChoiceProviderInterface - */ - private $orderCountriesChoiceProvider; - - /** - * @var FormChoiceProviderInterface - */ - private $orderStatusesChoiceProvider; - - /** - * @var string - */ - private $contextDateFormat; - - /** - * @var FeatureInterface - */ - private $multistoreFeature; - /** - * @var FormChoiceProviderInterface - */ - private $orderStatesChoiceProvider; - - /** - * @var AccessibilityCheckerInterface - */ - private $printInvoiceAccessibilityChecker; - - /** - * @var AccessibilityCheckerInterface - */ - private $printDeliverySlipAccessibilityChecker; - - /** - * @param HookDispatcherInterface $dispatcher - * @param ConfigurationInterface $configuration - * @param FormChoiceProviderInterface $orderCountriesChoiceProvider - * @param FormChoiceProviderInterface $orderStatusesChoiceProvider - * @param string $contextDateFormat - * @param FeatureInterface $multistoreFeature - * @param AccessibilityCheckerInterface $printInvoiceAccessibilityChecker - * @param AccessibilityCheckerInterface $printDeliverySlipAccessibilityChecker - * @param FormChoiceProviderInterface $orderStatesChoiceProvider - */ - public function __construct( - HookDispatcherInterface $dispatcher, - ConfigurationInterface $configuration, - FormChoiceProviderInterface $orderCountriesChoiceProvider, - FormChoiceProviderInterface $orderStatusesChoiceProvider, - $contextDateFormat, - FeatureInterface $multistoreFeature, - AccessibilityCheckerInterface $printInvoiceAccessibilityChecker, - AccessibilityCheckerInterface $printDeliverySlipAccessibilityChecker, - FormChoiceProviderInterface $orderStatesChoiceProvider - ) { - parent::__construct($dispatcher); - - $this->configuration = $configuration; - $this->orderCountriesChoiceProvider = $orderCountriesChoiceProvider; - $this->orderStatusesChoiceProvider = $orderStatusesChoiceProvider; - $this->contextDateFormat = $contextDateFormat; - $this->multistoreFeature = $multistoreFeature; - $this->printInvoiceAccessibilityChecker = $printInvoiceAccessibilityChecker; - $this->printDeliverySlipAccessibilityChecker = $printDeliverySlipAccessibilityChecker; - $this->orderStatesChoiceProvider = $orderStatesChoiceProvider; - } - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Orders', [], 'Admin.Navigation.Menu'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - $previewColumn = (new PreviewColumn('preview')) - ->setOptions([ - 'icon_expand' => 'keyboard_arrow_down', - 'icon_collapse' => 'keyboard_arrow_up', - 'preview_data_route' => 'admin_orders_preview', - 'preview_route_params' => [ - 'orderId' => 'id_order', - ], - ]) - ; - - $columns = (new ColumnCollection()) - ->add( - (new BulkActionColumn('orders_bulk')) - ->setOptions([ - 'bulk_field' => 'id_order', - ]) - ) - ->add((new IdentifierColumn('id_order')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'identifier_field' => 'id_order', - 'preview' => $previewColumn, - 'clickable' => false, - ]) - ) - ->add((new DataColumn('reference')) - ->setName($this->trans('Reference', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'reference', - ]) - ) - ->add((new BooleanColumn('new')) - ->setName($this->trans('New client', [], 'Admin.Orderscustomers.Feature')) - ->setOptions([ - 'field' => 'new', - 'true_name' => $this->trans('Yes', [], 'Admin.Global'), - 'false_name' => $this->trans('No', [], 'Admin.Global'), - 'clickable' => true, - ]) - ) - ->add((new DisableableLinkColumn('customer')) - ->setName($this->trans('Customer', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'customer', - 'disabled_field' => 'deleted_customer', - 'route' => 'admin_customers_view', - 'route_param_name' => 'customerId', - 'route_param_field' => 'id_customer', - 'target' => '_blank', - ]) - ) - ->add((new OrderPriceColumn('total_paid_tax_incl')) - ->setName($this->trans('Total', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'total_paid_tax_incl', - 'is_paid_field' => 'paid', - 'clickable' => true, - ]) - ) - ->add((new DataColumn('payment')) - ->setName($this->trans('Payment', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'payment', - ]) - ) - ->add((new ChoiceColumn('osname')) - ->setName($this->trans('Status', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'current_state', - 'route' => 'admin_orders_list_update_status', - 'color_field' => 'color', - 'choice_provider' => $this->orderStatesChoiceProvider, - 'record_route_params' => [ - 'id_order' => 'orderId', - ], - ]) - ) - ->add((new DateTimeColumn('date_add')) - ->setName($this->trans('Date', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'date_add', - 'format' => $this->contextDateFormat, - 'clickable' => true, - ]) - ) - ->add((new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => $this->getRowActions(), - ]) - ) - ; - - if ($this->orderCountriesChoiceProvider->getChoices()) { - $columns->addAfter('new', (new DataColumn('country_name')) - ->setName($this->trans('Delivery', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'country_name', - ]) - ); - } - - if ($this->configuration->get('PS_B2B_ENABLE')) { - $columns->addAfter('customer', (new DataColumn('company')) - ->setName($this->trans('Company', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'company', - ]) - ); - } - - if ($this->multistoreFeature->isUsed()) { - $columns->addBefore('actions', (new DataColumn('shop_name')) - ->setName($this->trans('Shop', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'shop_name', - 'sortable' => false, - ]) - ); - } - - return $columns; - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - $filters = new FilterCollection(); - - $filters - ->add((new Filter('id_order', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('id_order') - ) - ->add((new Filter('reference', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search reference', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('reference') - ) - ->add((new Filter('new', YesAndNoChoiceType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('new') - ) - ->add((new Filter('customer', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search customer', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('customer') - ) - ->add((new Filter('total_paid_tax_incl', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search total', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('total_paid_tax_incl') - ) - ->add((new Filter('payment', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search payment', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('payment') - ) - ->add((new Filter('osname', ChoiceType::class)) - ->setTypeOptions([ - 'required' => false, - 'choices' => $this->orderStatusesChoiceProvider->getChoices(), - 'translation_domain' => false, - ]) - ->setAssociatedColumn('osname') - ) - ->add((new Filter('date_add', DateRangeType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('date_add') - ) - ->add((new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_orders_index', - ]) - ->setAssociatedColumn('actions') - ) - ; - - $orderCountriesChoices = $this->orderCountriesChoiceProvider->getChoices(); - - if (!empty($orderCountriesChoices)) { - $filters->add((new Filter('country_name', ChoiceType::class)) - ->setTypeOptions([ - 'required' => false, - 'choices' => $orderCountriesChoices, - ]) - ->setAssociatedColumn('country_name') - ); - } - - if ($this->configuration->get('PS_B2B_ENABLE')) { - $filters->add((new Filter('company', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search company', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('company') - ); - } - - return $filters; - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new LinkGridAction('export')) - ->setName($this->trans('Export', [], 'Admin.Actions')) - ->setIcon('cloud_download') - ->setOptions([ - 'route' => 'admin_orders_export', - ]) - ) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add((new ModalFormSubmitBulkAction('change_order_status')) - ->setName($this->trans('Change Order Status', [], 'Admin.Orderscustomers.Feature')) - ->setOptions([ - 'submit_route' => 'admin_orders_change_orders_status', - 'modal_id' => 'changeOrdersStatusModal', - ]) - ) - ->add((new ButtonBulkAction('open_tabs')) - ->setName($this->trans('Open in new tabs', [], 'Admin.Orderscustomers.Feature')) - ->setOptions([ - 'class' => 'open_tabs', - 'attributes' => [ - 'data-route' => 'admin_orders_view', - 'data-route-param-name' => 'orderId', - 'data-tabs-blocked-message' => $this->trans( - 'It looks like you have exceeded the number of tabs allowed. Check your browser settings to open multiple tabs.', - [], - 'Admin.Orderscustomers.Feature' - ), - ], - ]) - ) - ; - } - - /** - * @return RowActionCollection - */ - private function getRowActions(): RowActionCollection - { - return (new RowActionCollection()) - ->add( - (new LinkRowAction('print_invoice')) - ->setName($this->trans('View invoice', [], 'Admin.Orderscustomers.Feature')) - ->setIcon('receipt') - ->setOptions([ - 'accessibility_checker' => $this->printInvoiceAccessibilityChecker, - 'route' => 'admin_orders_generate_invoice_pdf', - 'route_param_name' => 'orderId', - 'route_param_field' => 'id_order', - 'use_inline_display' => true, - ]) - ) - ->add( - (new LinkRowAction('print_delivery_slip')) - ->setName($this->trans('View delivery slip', [], 'Admin.Orderscustomers.Feature')) - ->setIcon('local_shipping') - ->setOptions([ - 'accessibility_checker' => $this->printDeliverySlipAccessibilityChecker, - 'route' => 'admin_orders_generate_delivery_slip_pdf', - 'route_param_name' => 'orderId', - 'route_param_field' => 'id_order', - 'use_inline_display' => true, - ]) - ) - ->add( - (new LinkRowAction('view')) - ->setName($this->trans('View', [], 'Admin.Actions')) - ->setIcon('zoom_in') - ->setOptions([ - 'route' => 'admin_orders_view', - 'route_param_name' => 'orderId', - 'route_param_field' => 'id_order', - 'use_inline_display' => true, - 'clickable_row' => true, - ]) - ) - ; - } -} diff --git a/src/Core/Grid/Definition/Factory/OrderMessageGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/OrderMessageGridDefinitionFactory.php deleted file mode 100644 index f414d240..00000000 --- a/src/Core/Grid/Definition/Factory/OrderMessageGridDefinitionFactory.php +++ /dev/null @@ -1,210 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Creates definition for order message grid - */ -final class OrderMessageGridDefinitionFactory extends AbstractFilterableGridDefinitionFactory -{ - use BulkDeleteActionTrait; - - public const GRID_ID = 'order_message'; - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Order messages', [], 'Admin.Orderscustomers.Feature'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add( - (new BulkActionColumn('order_messages_bulk')) - ->setOptions([ - 'bulk_field' => 'id_order_message', - ]) - ) - ->add((new DataColumn('id_order_message')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_order_message', - ]) - ) - ->add((new DataColumn('name')) - ->setName($this->trans('Name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - ]) - ) - ->add((new DataColumn('message')) - ->setName($this->trans('Message', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'message', - ]) - ) - ->add((new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add( - (new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_order_messages_edit', - 'route_param_name' => 'orderMessageId', - 'route_param_field' => 'id_order_message', - ]) - ) - ->add((new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'route' => 'admin_order_messages_delete', - 'route_param_name' => 'orderMessageId', - 'route_param_field' => 'id_order_message', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - ]) - ), - ]) - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add((new Filter('id_order_message', TextType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('id_order_message') - ) - ->add((new Filter('name', TextType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search name', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('name') - ) - ->add((new Filter('message', TextType::class)) - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Search message', [], 'Admin.Actions'), - ], - 'required' => false, - ]) - ->setAssociatedColumn('message') - ) - ->add((new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_order_messages_index', - ]) - ->setAssociatedColumn('actions')) - ; - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - $this->buildBulkDeleteAction('admin_order_messages_bulk_delete') - ); - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/ProfileGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/ProfileGridDefinitionFactory.php deleted file mode 100644 index 961b8e46..00000000 --- a/src/Core/Grid/Definition/Factory/ProfileGridDefinitionFactory.php +++ /dev/null @@ -1,230 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\AccessibilityChecker\AccessibilityCheckerInterface; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class ProfilesGridDefinitionFactory responsible for creating Profiles grid definition. - */ -final class ProfileGridDefinitionFactory extends AbstractGridDefinitionFactory -{ - /** - * @var string - */ - private $resetActionUrl; - - /** - * @var string - */ - private $redirectionUrl; - - /** - * @var AccessibilityCheckerInterface - */ - private $deleteProfileAccessibilityChecker; - - /** - * @param HookDispatcherInterface $hookDispatcher - * @param string $resetActionUrl - * @param string $redirectionUrl - * @param AccessibilityCheckerInterface $deleteProfileAccessibilityChecker - */ - public function __construct( - HookDispatcherInterface $hookDispatcher, - $resetActionUrl, - $redirectionUrl, - AccessibilityCheckerInterface $deleteProfileAccessibilityChecker - ) { - parent::__construct($hookDispatcher); - $this->resetActionUrl = $resetActionUrl; - $this->redirectionUrl = $redirectionUrl; - $this->deleteProfileAccessibilityChecker = $deleteProfileAccessibilityChecker; - } - - /** - * {@inheritdoc} - */ - protected function getId() - { - return 'profile'; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Profiles', [], 'Admin.Navigation.Menu'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add((new BulkActionColumn('bulk')) - ->setOptions([ - 'bulk_field' => 'id_profile', - ]) - ) - ->add((new DataColumn('id_profile')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_profile', - ]) - ) - ->add((new DataColumn('name')) - ->setName($this->trans('Name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - ]) - ) - ->add((new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add((new LinkRowAction('edit')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_profiles_edit', - 'route_param_name' => 'profileId', - 'route_param_field' => 'id_profile', - 'clickable_row' => true, - ]) - ) - ->add((new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'route' => 'admin_profiles_delete', - 'route_param_name' => 'profileId', - 'route_param_field' => 'id_profile', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - 'accessibility_checker' => $this->deleteProfileAccessibilityChecker, - ]) - ), - ]) - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add((new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add((new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add((new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add((new Filter('id_profile', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'size' => 'small', - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('id_profile') - ) - ->add((new Filter('name', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search name', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('name') - ) - ->add((new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'attr' => [ - 'data-url' => $this->resetActionUrl, - 'data-redirect' => $this->redirectionUrl, - ], - ]) - ->setAssociatedColumn('actions') - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add((new SubmitBulkAction('bulk_delete_profiles')) - ->setName($this->trans('Delete selected', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_profiles_bulk_delete', - 'confirm_message' => $this->trans('Delete selected items?', [], 'Admin.Notifications.Warning'), - ]) - ) - ; - } -} diff --git a/src/Core/Grid/Definition/Factory/RequestSqlGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/RequestSqlGridDefinitionFactory.php deleted file mode 100644 index 0ed6da50..00000000 --- a/src/Core/Grid/Definition/Factory/RequestSqlGridDefinitionFactory.php +++ /dev/null @@ -1,252 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class RequestSqlGridDefinitionFactory is responsible for creating RequestSql grid definition. - */ -final class RequestSqlGridDefinitionFactory extends AbstractGridDefinitionFactory -{ - /** - * @var string - */ - private $resetSearchUrl; - - /** - * @var string - */ - private $redirectionUrl; - - /** - * @param HookDispatcherInterface $hookDispatcher - * @param string $resetSearchUrl - * @param string $redirectionUrl - */ - public function __construct( - HookDispatcherInterface $hookDispatcher, - $resetSearchUrl, - $redirectionUrl - ) { - parent::__construct($hookDispatcher); - $this->resetSearchUrl = $resetSearchUrl; - $this->redirectionUrl = $redirectionUrl; - } - - /** - * {@inheritdoc} - */ - protected function getId() - { - return 'sql_request'; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('SQL Manager', [], 'Admin.Navigation.Menu'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add( - (new BulkActionColumn('bulk')) - ->setOptions([ - 'bulk_field' => 'id_request_sql', - ]) - ) - ->add( - (new DataColumn('id_request_sql')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_request_sql', - ]) - ) - ->add( - (new DataColumn('name')) - ->setName($this->trans('SQL query Name', [], 'Admin.Advparameters.Feature')) - ->setOptions([ - 'field' => 'name', - ]) - ) - ->add( - (new DataColumn('sql')) - ->setName($this->trans('SQL query', [], 'Admin.Advparameters.Feature')) - ->setOptions([ - 'field' => 'sql', - ]) - ) - ->add( - (new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add( - (new LinkRowAction('export')) - ->setIcon('cloud_download') - ->setOptions([ - 'route' => 'admin_sql_requests_export', - 'route_param_name' => 'sqlRequestId', - 'route_param_field' => 'id_request_sql', - ]) - ) - ->add( - (new LinkRowAction('view')) - ->setName($this->trans('View', [], 'Admin.Global')) - ->setIcon('remove_red_eye') - ->setOptions([ - 'route' => 'admin_sql_requests_view', - 'route_param_name' => 'sqlRequestId', - 'route_param_field' => 'id_request_sql', - 'clickable_row' => true, - ]) - ) - ->add( - (new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Global')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_sql_requests_edit', - 'route_param_name' => 'sqlRequestId', - 'route_param_field' => 'id_request_sql', - ]) - ) - ->add( - (new LinkRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'confirm_message' => $this->trans('Delete selected item?', [], 'Admin.Notifications.Warning'), - 'route' => 'admin_sql_requests_delete', - 'route_param_name' => 'sqlRequestId', - 'route_param_field' => 'id_request_sql', - ]) - ), - ]) - ); - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return (new FilterCollection()) - ->add( - (new Filter('id_request_sql', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('id_request_sql') - ) - ->add( - (new Filter('name', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('name') - ) - ->add( - (new Filter('sql', TextType::class)) - ->setTypeOptions([ - 'required' => false, - ]) - ->setAssociatedColumn('sql') - ) - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'attr' => [ - 'data-url' => $this->resetSearchUrl, - 'data-redirect' => $this->redirectionUrl, - ], - ]) - ->setAssociatedColumn('actions') - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - (new SubmitBulkAction('delete_all')) - ->setName($this->trans('Delete selected', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_sql_requests_delete_bulk', - 'submit_method' => 'POST', - 'confirm_message' => $this->trans('Delete selected items?', [], 'Admin.Notifications.Warning'), - ]) - ); - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/SupplierGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/SupplierGridDefinitionFactory.php deleted file mode 100644 index 2f4f51e5..00000000 --- a/src/Core/Grid/Definition/Factory/SupplierGridDefinitionFactory.php +++ /dev/null @@ -1,281 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\LinkGridAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ImageColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\LinkColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use PrestaShopBundle\Form\Admin\Type\YesAndNoChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class SupplierGridDefinitionFactory creates definition for supplier grid. - */ -final class SupplierGridDefinitionFactory extends AbstractFilterableGridDefinitionFactory -{ - /** - * @var string - */ - public const GRID_ID = 'supplier'; - - use BulkDeleteActionTrait; - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Suppliers', [], 'Admin.Navigation.Menu'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add((new BulkActionColumn('bulk')) - ->setOptions([ - 'bulk_field' => 'id_supplier', - ]) - ) - ->add((new DataColumn('id_supplier')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_supplier', - ]) - ) - ->add((new ImageColumn('logo')) - ->setName($this->trans('Logo', [], 'Admin.Global')) - ->setOptions([ - 'src_field' => 'logo', - ]) - ) - ->add((new LinkColumn('name')) - ->setName($this->trans('Name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - 'route' => 'admin_suppliers_edit', - 'route_param_name' => 'supplierId', - 'route_param_field' => 'id_supplier', - ]) - ) - ->add((new DataColumn('products_count')) - ->setName($this->trans('Number of products', [], 'Admin.Catalog.Feature')) - ->setOptions([ - 'field' => 'products_count', - ]) - ) - ->add((new ToggleColumn('active')) - ->setName($this->trans('Enabled', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'active', - 'primary_field' => 'id_supplier', - 'route' => 'admin_suppliers_toggle_status', - 'route_param_name' => 'supplierId', - ]) - ) - ->add((new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add((new LinkRowAction('view')) - ->setName($this->trans('View', [], 'Admin.Actions')) - ->setIcon('zoom_in') - ->setOptions([ - 'route' => 'admin_suppliers_view', - 'route_param_name' => 'supplierId', - 'route_param_field' => 'id_supplier', - 'clickable_row' => true, - ]) - ) - ->add((new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_suppliers_edit', - 'route_param_name' => 'supplierId', - 'route_param_field' => 'id_supplier', - ]) - ) - ->add((new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'method' => 'DELETE', - 'route' => 'admin_suppliers_delete', - 'route_param_name' => 'supplierId', - 'route_param_field' => 'id_supplier', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - ]) - ), - ]) - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add((new Filter('id_supplier', TextType::class)) - ->setAssociatedColumn('id_supplier') - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('ID', [], 'Admin.Global'), - ], - 'required' => false, - ]) - ) - ->add((new Filter('name', TextType::class)) - ->setAssociatedColumn('name') - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Name', [], 'Admin.Global'), - ], - 'required' => false, - ]) - ) - ->add((new Filter('products_count', TextType::class)) - ->setAssociatedColumn('products_count') - ->setTypeOptions([ - 'attr' => [ - 'placeholder' => $this->trans('Number of products', [], 'Admin.Catalog.Feature'), - ], - 'required' => false, - ]) - ) - ->add((new Filter('active', YesAndNoChoiceType::class)) - ->setAssociatedColumn('active') - ->setTypeOptions([ - 'required' => false, - ]) - ) - ->add((new Filter('actions', SearchAndResetType::class)) - ->setAssociatedColumn('actions') - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search_by_filter_id', - 'reset_route_params' => [ - 'filterId' => self::GRID_ID, - ], - 'redirect_route' => 'admin_suppliers_index', - ]) - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add((new SubmitBulkAction('suppliers_enable_selection')) - ->setName($this->trans('Enable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_suppliers_bulk_enable', - ]) - ) - ->add((new SubmitBulkAction('suppliers_disable_selection')) - ->setName($this->trans('Disable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_suppliers_bulk_disable', - ]) - ) - ->add( - $this->buildBulkDeleteAction('admin_suppliers_bulk_delete') - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add((new LinkGridAction('import')) - ->setName($this->trans('Import', [], 'Admin.Actions')) - ->setIcon('cloud_upload') - ->setOptions([ - 'route' => 'admin_import', - 'route_params' => [ - 'import_type' => 'suppliers', - ], - ]) - ) - ->add((new LinkGridAction('export')) - ->setName($this->trans('Export', [], 'Admin.Actions')) - ->setIcon('cloud_download') - ->setOptions([ - 'route' => 'admin_suppliers_export', - ]) - ) - ->add((new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add((new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add((new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ) - ; - } -} diff --git a/src/Core/Grid/Definition/Factory/TaxGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/TaxGridDefinitionFactory.php deleted file mode 100644 index cbc8d955..00000000 --- a/src/Core/Grid/Definition/Factory/TaxGridDefinitionFactory.php +++ /dev/null @@ -1,252 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use PrestaShopBundle\Form\Admin\Type\YesAndNoChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class TaxGridDefinitionFactory is responsible for creating Tax grid definition. - */ -final class TaxGridDefinitionFactory extends AbstractGridDefinitionFactory -{ - use BulkDeleteActionTrait; - - /** - * {@inheritdoc} - */ - protected function getId() - { - return 'tax'; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Taxes', [], 'Admin.Global'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add( - (new BulkActionColumn('bulk')) - ->setOptions([ - 'bulk_field' => 'id_tax', - ]) - ) - ->add( - (new DataColumn('id_tax')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_tax', - ]) - ) - ->add( - (new DataColumn('name')) - ->setName($this->trans('Name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - ]) - ) - ->add( - (new DataColumn('rate')) - ->setName($this->trans('Rate', [], 'Admin.International.Feature')) - ->setOptions([ - 'field' => 'rate', - ]) - ) - ->add((new ToggleColumn('active')) - ->setName($this->trans('Enabled', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'active', - 'primary_field' => 'id_tax', - 'route' => 'admin_taxes_toggle_status', - 'route_param_name' => 'taxId', - ]) - ) - ->add( - (new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add( - (new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_taxes_edit', - 'route_param_name' => 'taxId', - 'route_param_field' => 'id_tax', - 'clickable_row' => true, - ]) - ) - ->add( - (new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - 'route' => 'admin_taxes_delete', - 'route_param_name' => 'taxId', - 'route_param_field' => 'id_tax', - ]) - ), - ]) - ) - ; - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return (new FilterCollection()) - ->add( - (new Filter('id_tax', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('id_tax') - ) - ->add( - (new Filter('name', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search name', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('name') - ) - ->add( - (new Filter('rate', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search rate', [], 'Admin.International.Feature'), - ], - ]) - ->setAssociatedColumn('rate') - ) - ->add((new Filter('active', YesAndNoChoiceType::class)) - ->setTypeOptions([ - 'required' => false, - 'choice_translation_domain' => false, - ]) - ->setAssociatedColumn('active') - ) - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search', - 'reset_route_params' => [ - 'controller' => 'tax', - 'action' => 'index', - ], - 'redirect_route' => 'admin_taxes_index', - ]) - ->setAssociatedColumn('actions') - ); - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - (new SubmitBulkAction('enable_selection')) - ->setName($this->trans('Enable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_taxes_bulk_enable_status', - ]) - ) - ->add( - (new SubmitBulkAction('disable_selection')) - ->setName($this->trans('Disable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_taxes_bulk_disable_status', - ]) - ) - ->add( - $this->buildBulkDeleteAction('admin_taxes_bulk_delete') - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/TaxRulesGroupGridDefinitionFactory.php b/src/Core/Grid/Definition/Factory/TaxRulesGroupGridDefinitionFactory.php deleted file mode 100644 index 6ecbbf6b..00000000 --- a/src/Core/Grid/Definition/Factory/TaxRulesGroupGridDefinitionFactory.php +++ /dev/null @@ -1,238 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use PrestaShopBundle\Form\Admin\Type\YesAndNoChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Defines tax rules groups grid - */ -final class TaxRulesGroupGridDefinitionFactory extends AbstractFilterableGridDefinitionFactory -{ - public const GRID_ID = 'tax_rules_group'; - - /** - * {@inheritdoc} - */ - protected function getId() - { - return self::GRID_ID; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Tax Rules', [], 'Admin.Navigation.Menu'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add( - (new BulkActionColumn('bulk')) - ->setOptions([ - 'bulk_field' => 'id_tax_rules_group', - ]) - ) - ->add( - (new DataColumn('id_tax_rules_group')) - ->setName($this->trans('ID', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'id_tax_rules_group', - ]) - ) - ->add( - (new DataColumn('name')) - ->setName($this->trans('Name', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'name', - ]) - ) - ->add((new ToggleColumn('active')) - ->setName($this->trans('Enabled', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'active', - 'primary_field' => 'id_tax_rules_group', - 'route' => 'admin_tax_rules_groups_toggle_status', - 'route_param_name' => 'taxRulesGroupId', - ]) - ) - ->add( - (new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add( - (new LinkRowAction('edit')) - ->setName($this->trans('Edit', [], 'Admin.Actions')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_tax_rules_groups_edit', - 'route_param_name' => 'taxRulesGroupId', - 'route_param_field' => 'id_tax_rules_group', - ]) - ) - ->add( - (new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - 'route' => 'admin_tax_rules_groups_delete', - 'route_param_name' => 'taxRulesGroupId', - 'route_param_field' => 'id_tax_rules_group', - ]) - ), - ]) - ); - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return (new FilterCollection()) - ->add( - (new Filter('id_tax_rules_group', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search ID', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('id_tax_rules_group') - ) - ->add( - (new Filter('name', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search name', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('name') - ) - ->add((new Filter('active', YesAndNoChoiceType::class)) - ->setTypeOptions([ - 'required' => false, - 'choice_translation_domain' => false, - ]) - ->setAssociatedColumn('active') - ) - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'reset_route' => 'admin_common_reset_search', - 'reset_route_params' => [ - 'controller' => 'taxRulesGroup', - 'action' => 'index', - ], - 'redirect_route' => 'admin_tax_rules_groups_index', - ]) - ->setAssociatedColumn('actions') - ); - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - (new SubmitBulkAction('enable_selection')) - ->setName($this->trans('Enable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_tax_rules_groups_bulk_enable_status', - ]) - ) - ->add( - (new SubmitBulkAction('disable_selection')) - ->setName($this->trans('Disable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_tax_rules_groups_bulk_disable_status', - ]) - ) - ->add( - (new SubmitBulkAction('delete_selection')) - ->setName($this->trans('Delete selected', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_tax_rules_groups_bulk_delete', - 'confirm_message' => $this->trans('Delete selected items?', [], 'Admin.Notifications.Warning'), - ]) - ); - } -} diff --git a/src/Core/Grid/Definition/Factory/WebserviceKeyDefinitionFactory.php b/src/Core/Grid/Definition/Factory/WebserviceKeyDefinitionFactory.php deleted file mode 100644 index 011a0665..00000000 --- a/src/Core/Grid/Definition/Factory/WebserviceKeyDefinitionFactory.php +++ /dev/null @@ -1,275 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\Type\SubmitBulkAction; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\RowActionCollection; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\SubmitRowAction; -use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\BulkActionColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn; -use PrestaShop\PrestaShop\Core\Grid\Filter\Filter; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollection; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Form\Admin\Type\SearchAndResetType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Class WebserviceKeyDefinitionFactory is responsible for creating grid definition for Webservice grid. - */ -final class WebserviceKeyDefinitionFactory extends AbstractGridDefinitionFactory -{ - /** - * @var array - */ - private $statusChoices; - - /** - * @var string - */ - private $resetActionUrl; - - /** - * @var string - */ - private $redirectionUrl; - - /** - * WebserviceKeyDefinitionFactory constructor. - * - * @param HookDispatcherInterface $hookDispatcher - * @param array $statusChoices - * @param $resetActionUrl - * @param $redirectionUrl - */ - public function __construct( - HookDispatcherInterface $hookDispatcher, - array $statusChoices, - $resetActionUrl, - $redirectionUrl - ) { - parent::__construct($hookDispatcher); - $this->statusChoices = $statusChoices; - $this->resetActionUrl = $resetActionUrl; - $this->redirectionUrl = $redirectionUrl; - } - - /** - * {@inheritdoc} - */ - protected function getId() - { - return 'webservice_key'; - } - - /** - * {@inheritdoc} - */ - protected function getName() - { - return $this->trans('Webservice', [], 'Admin.Navigation.Menu'); - } - - /** - * {@inheritdoc} - */ - protected function getColumns() - { - return (new ColumnCollection()) - ->add( - (new BulkActionColumn('bulk_action')) - ->setOptions([ - 'bulk_field' => 'id_webservice_account', - ]) - ) - ->add( - (new DataColumn('key')) - ->setName($this->trans('Key', [], 'Admin.Advparameters.Feature')) - ->setOptions([ - 'field' => 'key', - ]) - ) - ->add( - (new DataColumn('description')) - ->setName($this->trans('Key description', [], 'Admin.Advparameters.Feature')) - ->setOptions([ - 'field' => 'description', - 'sortable' => false, - ]) - ) - ->add( - (new ToggleColumn('active')) - ->setName($this->trans('Enabled', [], 'Admin.Global')) - ->setOptions([ - 'field' => 'active', - 'primary_field' => 'id_webservice_account', - 'route' => 'admin_webservice_keys_toggle_status', - 'route_param_name' => 'webserviceKeyId', - ]) - ) - ->add( - (new ActionColumn('actions')) - ->setName($this->trans('Actions', [], 'Admin.Global')) - ->setOptions([ - 'actions' => (new RowActionCollection()) - ->add( - (new LinkRowAction('edit')) - ->setIcon('edit') - ->setOptions([ - 'route' => 'admin_webservice_keys_edit', - 'route_param_name' => 'webserviceKeyId', - 'route_param_field' => 'id_webservice_account', - 'clickable_row' => true, - ]) - ) - ->add( - (new SubmitRowAction('delete')) - ->setName($this->trans('Delete', [], 'Admin.Actions')) - ->setIcon('delete') - ->setOptions([ - 'method' => 'DELETE', - 'route' => 'admin_webservice_keys_delete', - 'route_param_name' => 'webserviceKeyId', - 'route_param_field' => 'id_webservice_account', - 'confirm_message' => $this->trans( - 'Delete selected item?', - [], - 'Admin.Notifications.Warning' - ), - ]) - ), - ]) - ); - } - - /** - * {@inheritdoc} - */ - protected function getFilters() - { - return (new FilterCollection()) - ->add( - (new Filter('key', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search key', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('key') - ) - ->add( - (new Filter('description', TextType::class)) - ->setTypeOptions([ - 'required' => false, - 'attr' => [ - 'placeholder' => $this->trans('Search description', [], 'Admin.Actions'), - ], - ]) - ->setAssociatedColumn('description') - ) - ->add( - (new Filter('active', ChoiceType::class)) - ->setTypeOptions([ - 'required' => false, - 'choices' => $this->statusChoices, - 'choice_translation_domain' => false, - ]) - ->setAssociatedColumn('active') - ) - ->add( - (new Filter('actions', SearchAndResetType::class)) - ->setTypeOptions([ - 'attr' => [ - 'data-url' => $this->resetActionUrl, - 'data-redirect' => $this->redirectionUrl, - ], - ]) - ->setAssociatedColumn('actions') - ); - } - - /** - * {@inheritdoc} - */ - protected function getGridActions() - { - return (new GridActionCollection()) - ->add( - (new SimpleGridAction('common_refresh_list')) - ->setName($this->trans('Refresh list', [], 'Admin.Advparameters.Feature')) - ->setIcon('refresh') - ) - ->add( - (new SimpleGridAction('common_show_query')) - ->setName($this->trans('Show SQL query', [], 'Admin.Actions')) - ->setIcon('code') - ) - ->add( - (new SimpleGridAction('common_export_sql_manager')) - ->setName($this->trans('Export to SQL Manager', [], 'Admin.Actions')) - ->setIcon('storage') - ); - } - - /** - * {@inheritdoc} - */ - protected function getBulkActions() - { - return (new BulkActionCollection()) - ->add( - (new SubmitBulkAction('webservice_enable_selection')) - ->setName($this->trans('Enable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_webservice_keys_bulk_enable', - ]) - ) - ->add( - (new SubmitBulkAction('webservice_disable_selection')) - ->setName($this->trans('Disable selection', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_webservice_keys_bulk_disable', - ]) - ) - ->add( - (new SubmitBulkAction('delete_webservice')) - ->setName($this->trans('Delete selected', [], 'Admin.Actions')) - ->setOptions([ - 'submit_route' => 'admin_webservice_keys_bulk_delete', - 'confirm_message' => $this->trans('Delete selected items?', [], 'Admin.Notifications.Warning'), - ]) - ); - } -} diff --git a/src/Core/Grid/Definition/GridDefinition.php b/src/Core/Grid/Definition/GridDefinition.php deleted file mode 100644 index a5fe7fb7..00000000 --- a/src/Core/Grid/Definition/GridDefinition.php +++ /dev/null @@ -1,186 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollectionInterface; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollectionInterface; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollectionInterface; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnInterface; -use PrestaShop\PrestaShop\Core\Grid\Exception\InvalidDataException; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollectionInterface; - -/** - * Class Definition is responsible for storing grid definition (columns, row actions & etc.). - */ -final class GridDefinition implements GridDefinitionInterface -{ - /** - * @var string Unique grid identifier - */ - private $id; - - /** - * @var string Grid name - */ - private $name; - - /** - * @var ColumnInterface[] - */ - private $columns; - - /** - * @var GridActionCollectionInterface - */ - private $gridActions; - - /** - * @var BulkActionCollectionInterface - */ - private $bulkActions; - - /** - * @var FilterCollectionInterface - */ - private $filters; - - /** - * @param string $id Unique grid identifier - * @param string $name - * @param ColumnCollectionInterface $columns - * @param FilterCollectionInterface $filters - * @param GridActionCollectionInterface $gridActions - * @param BulkActionCollectionInterface $bulkActions - */ - public function __construct( - $id, - $name, - ColumnCollectionInterface $columns, - FilterCollectionInterface $filters, - GridActionCollectionInterface $gridActions, - BulkActionCollectionInterface $bulkActions - ) { - $this->id = $id; - $this->name = $name; - $this->columns = $columns; - $this->filters = $filters; - $this->gridActions = $gridActions; - $this->bulkActions = $bulkActions; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function getColumns() - { - return $this->columns; - } - - /** - * {@inheritdoc} - */ - public function getBulkActions() - { - return $this->bulkActions; - } - - /** - * {@inheritdoc} - */ - public function getGridActions() - { - return $this->gridActions; - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return $this->filters; - } - - /** - * @param string $name - */ - public function setName($name) - { - if (!is_string($name)) { - throw new InvalidDataException('Definition name should be a string.'); - } - - $this->name = $name; - } - - /** - * @param ColumnCollectionInterface $columns - */ - public function setColumns($columns) - { - $this->columns = $columns; - } - - /** - * @param GridActionCollectionInterface $gridActions - */ - public function setGridActions(GridActionCollectionInterface $gridActions) - { - $this->gridActions = $gridActions; - } - - /** - * @param BulkActionCollectionInterface $bulkActions - */ - public function setBulkActions(BulkActionCollectionInterface $bulkActions) - { - $this->bulkActions = $bulkActions; - } - - /** - * @param FilterCollectionInterface $filters - */ - public function setFilters(FilterCollectionInterface $filters) - { - $this->filters = $filters; - } -} diff --git a/src/Core/Grid/Definition/GridDefinitionInterface.php b/src/Core/Grid/Definition/GridDefinitionInterface.php deleted file mode 100644 index 0493f106..00000000 --- a/src/Core/Grid/Definition/GridDefinitionInterface.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Definition; - -use PrestaShop\PrestaShop\Core\Grid\Action\Bulk\BulkActionCollectionInterface; -use PrestaShop\PrestaShop\Core\Grid\Action\GridActionCollectionInterface; -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollectionInterface; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterCollectionInterface; - -/** - * Interface GridDefinitionInterface defines contract for grid definition. - */ -interface GridDefinitionInterface -{ - /** - * Get unique grid identifier. - * - * @return string - */ - public function getId(); - - /** - * Get grid name. - * - * @return string - */ - public function getName(); - - /** - * Get grid columns. - * - * @return ColumnCollectionInterface - */ - public function getColumns(); - - /** - * @return BulkActionCollectionInterface - */ - public function getBulkActions(); - - /** - * Get grid actions. - * - * @return GridActionCollectionInterface - */ - public function getGridActions(); - - /** - * Get filters. - * - * @return FilterCollectionInterface - */ - public function getFilters(); -} diff --git a/src/Core/Grid/Exception/ColumnNotFoundException.php b/src/Core/Grid/Exception/ColumnNotFoundException.php deleted file mode 100644 index ba607885..00000000 --- a/src/Core/Grid/Exception/ColumnNotFoundException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Exception; - -use Exception; - -class ColumnNotFoundException extends Exception implements ExceptionInterface -{ -} diff --git a/src/Core/Grid/Exception/ExceptionInterface.php b/src/Core/Grid/Exception/ExceptionInterface.php deleted file mode 100644 index 965cda08..00000000 --- a/src/Core/Grid/Exception/ExceptionInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Exception; - -/** - * Interface ExceptionInterface is implemented by all grid exceptions. - */ -interface ExceptionInterface -{ -} diff --git a/src/Core/Grid/Exception/InvalidActionDataException.php b/src/Core/Grid/Exception/InvalidActionDataException.php deleted file mode 100644 index 3ef05777..00000000 --- a/src/Core/Grid/Exception/InvalidActionDataException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Exception; - -use Exception; - -class InvalidActionDataException extends Exception implements ExceptionInterface -{ -} diff --git a/src/Core/Grid/Exception/InvalidColumnDataException.php b/src/Core/Grid/Exception/InvalidColumnDataException.php deleted file mode 100644 index f4b21648..00000000 --- a/src/Core/Grid/Exception/InvalidColumnDataException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Exception; - -use Exception; - -class InvalidColumnDataException extends Exception implements ExceptionInterface -{ -} diff --git a/src/Core/Grid/Exception/InvalidDataException.php b/src/Core/Grid/Exception/InvalidDataException.php deleted file mode 100644 index 0c533893..00000000 --- a/src/Core/Grid/Exception/InvalidDataException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Exception; - -use Exception; - -class InvalidDataException extends Exception implements ExceptionInterface -{ -} diff --git a/src/Core/Grid/Exception/MissingColumnInRowException.php b/src/Core/Grid/Exception/MissingColumnInRowException.php deleted file mode 100644 index 4b435b92..00000000 --- a/src/Core/Grid/Exception/MissingColumnInRowException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Exception; - -use LogicException; - -/** - * Class MissingColumnInRowException. - */ -class MissingColumnInRowException extends LogicException implements ExceptionInterface -{ -} diff --git a/src/Core/Grid/Exception/UnsupportedParameterException.php b/src/Core/Grid/Exception/UnsupportedParameterException.php deleted file mode 100644 index 1c84c85e..00000000 --- a/src/Core/Grid/Exception/UnsupportedParameterException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Exception; - -use Exception; - -class UnsupportedParameterException extends Exception implements ExceptionInterface -{ -} diff --git a/src/Core/Grid/Factory/CategoryGridFactoryDecorator.php b/src/Core/Grid/Factory/CategoryGridFactoryDecorator.php deleted file mode 100644 index fdf6c3f8..00000000 --- a/src/Core/Grid/Factory/CategoryGridFactoryDecorator.php +++ /dev/null @@ -1,152 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterInterface; -use PrestaShop\PrestaShop\Core\Grid\Filter\GridFilterFormFactoryInterface; -use PrestaShop\PrestaShop\Core\Grid\Grid; -use PrestaShop\PrestaShop\Core\Grid\GridFactoryInterface; -use PrestaShop\PrestaShop\Core\Grid\GridInterface; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use Symfony\Component\Form\FormInterface; - -/** - * Decorates Category grid factory - */ -final class CategoryGridFactoryDecorator implements GridFactoryInterface -{ - /** - * @var GridFactoryInterface - */ - private $categoryGridFactory; - - /** - * @var GridFilterFormFactoryInterface - */ - private $filterFormFactory; - - /** - * @param GridFactoryInterface $categoryGridFactory - * @param GridFilterFormFactoryInterface $filterFormFactory optional - * - * $filterFormFactory is optional in order to comply with SemVer - */ - public function __construct( - GridFactoryInterface $categoryGridFactory, - GridFilterFormFactoryInterface $filterFormFactory = null - ) { - $this->categoryGridFactory = $categoryGridFactory; - $this->filterFormFactory = $filterFormFactory; - } - - /** - * {@inheritdoc} - */ - public function getGrid(SearchCriteriaInterface $searchCriteria) - { - $categoryGrid = $this->categoryGridFactory->getGrid($searchCriteria); - - $this->removePositionDragColumnIfEligible($searchCriteria, $categoryGrid); - - $filters = $searchCriteria->getFilters(); - if ($this->isHomeCategory($filters) && ($this->filterFormFactory !== null)) { - return $categoryGrid; - } - - $this->injectCategoryIdIntoSearchTypeOptions($categoryGrid, $filters); - - $filterForm = $this->rebuildFilterForm($searchCriteria, $categoryGrid); - - return new Grid( - $categoryGrid->getDefinition(), - $categoryGrid->getData(), - $searchCriteria, - $filterForm - ); - } - - /** - * @param array $filters - * - * @return bool - */ - private function isHomeCategory(array $filters) - { - return isset($filters['is_home_category']) - && $filters['is_home_category'] === true; - } - - /** - * Position can only be changed when grid is - * ordered by "position" in "asc" way. - * - * @param SearchCriteriaInterface $searchCriteria - * @param GridInterface $categoryGrid - */ - private function removePositionDragColumnIfEligible( - SearchCriteriaInterface $searchCriteria, - $categoryGrid - ) { - if ('position' !== $searchCriteria->getOrderBy() || - 'asc' !== $searchCriteria->getOrderWay()) { - $categoryGrid->getDefinition() - ->getColumns() - ->remove('position_drag'); - } - } - - /** - * @param GridInterface $categoryGrid - * @param array $filters - */ - private function injectCategoryIdIntoSearchTypeOptions($categoryGrid, array $filters) - { - /** @var FilterInterface $actionsFilter */ - $actionsFilter = $categoryGrid->getDefinition() - ->getFilters()->get('actions'); - - $typeOptions = $actionsFilter->getTypeOptions(); - $typeOptions['redirect_route_params'] = ['categoryId' => $filters['id_category_parent']]; - $actionsFilter->setTypeOptions($typeOptions); - } - - /** - * @param SearchCriteriaInterface $searchCriteria - * @param GridInterface $categoryGrid - * - * @return FormInterface - */ - private function rebuildFilterForm( - SearchCriteriaInterface $searchCriteria, - GridInterface $categoryGrid) - { - $filterForm = $this->filterFormFactory->create($categoryGrid->getDefinition()); - $filterForm->setData($searchCriteria->getFilters()); - - return $filterForm; - } -} diff --git a/src/Core/Grid/Filter/CategoryFilterFormFactory.php b/src/Core/Grid/Filter/CategoryFilterFormFactory.php deleted file mode 100644 index 5d540cbe..00000000 --- a/src/Core/Grid/Filter/CategoryFilterFormFactory.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Filter; - -use PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface; -use Symfony\Component\Form\Extension\Core\Type\FormType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; - -/** - * Class CategoryFilterFormFactory decorates original filter factory to add custom submit action. - */ -final class CategoryFilterFormFactory implements GridFilterFormFactoryInterface -{ - /** - * @var GridFilterFormFactoryInterface - */ - private $formFactory; - - /** - * @var UrlGeneratorInterface - */ - private $urlGenerator; - - /** - * @var RequestStack - */ - private $requestStack; - - /** - * @param GridFilterFormFactoryInterface $formFactory - * @param UrlGeneratorInterface $urlGenerator - * @param RequestStack $requestStack - */ - public function __construct( - GridFilterFormFactoryInterface $formFactory, - UrlGeneratorInterface $urlGenerator, - RequestStack $requestStack - ) { - $this->formFactory = $formFactory; - $this->urlGenerator = $urlGenerator; - $this->requestStack = $requestStack; - } - - /** - * {@inheritdoc} - */ - public function create(GridDefinitionInterface $definition) - { - $categoryFilterForm = $this->formFactory->create($definition); - - $newCategoryFormBuilder = $categoryFilterForm->getConfig()->getFormFactory()->createNamedBuilder( - $definition->getId(), - FormType::class - ); - - /** @var FormInterface $categoryFormItem */ - foreach ($categoryFilterForm as $categoryFormItem) { - $newCategoryFormBuilder->add( - $categoryFormItem->getName(), - get_class($categoryFormItem->getConfig()->getType()->getInnerType()), - $categoryFormItem->getConfig()->getOptions() - ); - } - - $queryParams = []; - $request = $this->requestStack->getCurrentRequest(); - - if ((null !== $request) && ($request->attributes->has('categoryId'))) { - $queryParams['categoryId'] = $request->attributes->get('categoryId'); - } - - $newCategoryFormBuilder->setAction( - $this->urlGenerator->generate('admin_categories_search', $queryParams) - ); - - return $newCategoryFormBuilder->getForm(); - } -} diff --git a/src/Core/Grid/Filter/CmsPageFilterFormFactory.php b/src/Core/Grid/Filter/CmsPageFilterFormFactory.php deleted file mode 100644 index 4a5f98bd..00000000 --- a/src/Core/Grid/Filter/CmsPageFilterFormFactory.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Filter; - -use PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface; -use Symfony\Component\Form\Extension\Core\Type\FormType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; - -/** - * Class CmsPageCategoryFilterFormFactory is responsible for changing form action to the custom one. - */ -final class CmsPageFilterFormFactory implements GridFilterFormFactoryInterface -{ - /** - * @var GridFilterFormFactoryInterface - */ - private $formFactory; - - /** - * @var UrlGeneratorInterface - */ - private $urlGenerator; - - /** - * @var RequestStack - */ - private $requestStack; - - /** - * @param GridFilterFormFactoryInterface $formFactory - * @param UrlGeneratorInterface $urlGenerator - * @param RequestStack $requestStack - */ - public function __construct( - GridFilterFormFactoryInterface $formFactory, - UrlGeneratorInterface $urlGenerator, - RequestStack $requestStack - ) { - $this->formFactory = $formFactory; - $this->urlGenerator = $urlGenerator; - $this->requestStack = $requestStack; - } - - /** - * {@inheritdoc} - */ - public function create(GridDefinitionInterface $definition) - { - $cmsPageCategoryFilterForm = $this->formFactory->create($definition); - - $newCmsPageCategoryFormBuilder = $cmsPageCategoryFilterForm->getConfig()->getFormFactory()->createNamedBuilder( - $definition->getId(), - FormType::class - ); - - /** @var FormInterface $categoryFormItem */ - foreach ($cmsPageCategoryFilterForm as $categoryFormItem) { - $newCmsPageCategoryFormBuilder->add( - $categoryFormItem->getName(), - get_class($categoryFormItem->getConfig()->getType()->getInnerType()), - $categoryFormItem->getConfig()->getOptions() - ); - } - - $request = $this->requestStack->getCurrentRequest(); - - if (null !== $request) { - $newActionUrl = $this->urlGenerator->generate('admin_cms_pages_search', [ - 'id_cms_category' => $request->query->getInt('id_cms_category'), - ]); - - $newCmsPageCategoryFormBuilder->setAction($newActionUrl); - } - - return $newCmsPageCategoryFormBuilder->getForm(); - } -} diff --git a/src/Core/Grid/Filter/Filter.php b/src/Core/Grid/Filter/Filter.php deleted file mode 100644 index ef408273..00000000 --- a/src/Core/Grid/Filter/Filter.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Filter; - -/** - * Class Filter defines single filter for grid. - */ -final class Filter implements FilterInterface -{ - /** - * @var string Fully qualified filter type class name - */ - private $type; - - /** - * @var array Filter type options - */ - private $typeOptions = []; - - /** - * @var string Filter name - */ - private $name; - - /** - * @var string|null Column ID if filter is associated with columns - */ - private $column; - - /** - * @param string $name - * @param string $filterFormType - */ - public function __construct($name, $filterFormType) - { - $this->type = $filterFormType; - $this->name = $name; - } - - /** - * {@inheritdoc} - */ - public function getType() - { - return $this->type; - } - - /** - * {@inheritdoc} - */ - public function setTypeOptions(array $filterTypeOptions) - { - $this->typeOptions = $filterTypeOptions; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getTypeOptions() - { - return $this->typeOptions; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function setAssociatedColumn($columnId) - { - $this->column = $columnId; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getAssociatedColumn() - { - return $this->column; - } -} diff --git a/src/Core/Grid/Filter/FilterCollection.php b/src/Core/Grid/Filter/FilterCollection.php deleted file mode 100644 index 4dab9657..00000000 --- a/src/Core/Grid/Filter/FilterCollection.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Filter; - -/** - * Class FilterCollection manages filters collection for grid. - */ -final class FilterCollection implements FilterCollectionInterface -{ - /** - * @var FilterInterface[] - */ - private $filters = []; - - /** - * {@inheritdoc} - */ - public function add(FilterInterface $filter) - { - $this->filters[$filter->getName()] = $filter; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function remove($filterName) - { - if (isset($this->filters[$filterName])) { - unset($this->filters[$filterName]); - } - - return $this; - } - - /** - * @param string $filterName - * - * @return FilterInterface|null return null if no filter with given filter name - */ - public function get($filterName) - { - if (isset($this->filters[$filterName])) { - return $this->filters[$filterName]; - } - - return null; - } - - /** - * {@inheritdoc} - */ - public function all() - { - return $this->filters; - } -} diff --git a/src/Core/Grid/Filter/FilterCollectionInterface.php b/src/Core/Grid/Filter/FilterCollectionInterface.php deleted file mode 100644 index eef92f9e..00000000 --- a/src/Core/Grid/Filter/FilterCollectionInterface.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Filter; - -/** - * Interface FilterCollectionInterface defines contract for grid filters. - */ -interface FilterCollectionInterface -{ - /** - * Add filter to collection. - * - * @param FilterInterface $filter - * - * @return self - */ - public function add(FilterInterface $filter); - - /** - * Remove filter from collection. - * - * @param string $filterName - * - * @return self - */ - public function remove($filterName); - - /** - * Get all filters. - * - * @return FilterInterface[] - */ - public function all(); -} diff --git a/src/Core/Grid/Filter/FilterFormFactoryFormActionDecorator.php b/src/Core/Grid/Filter/FilterFormFactoryFormActionDecorator.php deleted file mode 100644 index 1f3dd3ff..00000000 --- a/src/Core/Grid/Filter/FilterFormFactoryFormActionDecorator.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Filter; - -use PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface; -use Symfony\Component\Form\Extension\Core\Type\FormType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; - -/** - * Decorates grid filter form action. - */ -final class FilterFormFactoryFormActionDecorator implements GridFilterFormFactoryInterface -{ - /** - * @var GridFilterFormFactoryInterface - */ - private $delegate; - - /** - * @var UrlGeneratorInterface - */ - private $urlGenerator; - - /** - * @var string - */ - private $formActionRoute; - - /** - * @param GridFilterFormFactoryInterface $delegate - * @param UrlGeneratorInterface $urlGenerator - * @param string $formActionRoute will change the form action of filters form to this - */ - public function __construct( - GridFilterFormFactoryInterface $delegate, - UrlGeneratorInterface $urlGenerator, - string $formActionRoute - ) { - $this->delegate = $delegate; - $this->urlGenerator = $urlGenerator; - $this->formActionRoute = $formActionRoute; - } - - /** - * {@inheritdoc} - */ - public function create(GridDefinitionInterface $definition) - { - $filterForm = $this->delegate->create($definition); - - $formBuilder = $filterForm->getConfig()->getFormFactory()->createNamedBuilder( - $definition->getId(), - FormType::class - ); - - /** @var FormInterface $formItem */ - foreach ($filterForm as $formItem) { - $formBuilder->add( - $formItem->getName(), - get_class($formItem->getConfig()->getType()->getInnerType()), - $formItem->getConfig()->getOptions() - ); - } - - $formBuilder->setAction( - $this->urlGenerator->generate($this->formActionRoute) - ); - - return $formBuilder->getForm(); - } -} diff --git a/src/Core/Grid/Filter/FilterInterface.php b/src/Core/Grid/Filter/FilterInterface.php deleted file mode 100644 index cd89fa61..00000000 --- a/src/Core/Grid/Filter/FilterInterface.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Filter; - -/** - * Interface FilterInterface defines contract for grid filter. - */ -interface FilterInterface -{ - /** - * Get filter type to use. - * - * @return string Fully qualified filter type class name - */ - public function getType(); - - /** - * Get filter name. - * - * @return string - */ - public function getName(); - - /** - * Set filter type options. - * - * @param array $filterTypeOptions - * - * @return self - */ - public function setTypeOptions(array $filterTypeOptions); - - /** - * Get filter type options. - * - * @return array - */ - public function getTypeOptions(); - - /** - * Set column ID if filter is associated with column. - * - * @param string $columnId - * - * @return self - */ - public function setAssociatedColumn($columnId); - - /** - * Get associated column. - * - * @return string|null - */ - public function getAssociatedColumn(); -} diff --git a/src/Core/Grid/Filter/GridFilterFormFactory.php b/src/Core/Grid/Filter/GridFilterFormFactory.php deleted file mode 100644 index 1d95216a..00000000 --- a/src/Core/Grid/Filter/GridFilterFormFactory.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Filter; - -use PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Event\Dispatcher\NullDispatcher; -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\Form\Extension\Core\Type\FormType; -use Symfony\Component\Form\FormFactoryInterface; - -/** - * Class FilterFormFactory is responsible for creating grid filter form. - */ -final class GridFilterFormFactory implements GridFilterFormFactoryInterface -{ - /** - * @var FormFactoryInterface - */ - private $formFactory; - - /** - * @var HookDispatcherInterface - */ - private $hookDispatcher; - - /** - * @param FormFactoryInterface $formFactory - * @param HookDispatcherInterface|null $hookDispatcher - */ - public function __construct( - FormFactoryInterface $formFactory, - HookDispatcherInterface $hookDispatcher = null - ) { - $this->formFactory = $formFactory; - - if (null === $hookDispatcher) { - @trigger_error('The $hookDispatcher parameter should not be null, inject your main HookDispatcherInterface service, or NullDispatcher if you don\'t need hooks.', E_USER_DEPRECATED); - } - $this->hookDispatcher = $hookDispatcher ? $hookDispatcher : new NullDispatcher(); - } - - /** - * {@inheritdoc} - */ - public function create(GridDefinitionInterface $definition) - { - $formBuilder = $this->formFactory->createNamedBuilder( - $definition->getId(), - FormType::class - ); - - /** @var FilterInterface $filter */ - foreach ($definition->getFilters()->all() as $filter) { - $formBuilder->add( - $filter->getName(), - $filter->getType(), - $filter->getTypeOptions() - ); - } - - $this->hookDispatcher->dispatchWithParameters('action' . Container::camelize($definition->getId()) . 'GridFilterFormModifier', [ - 'filter_form_builder' => $formBuilder, - ]); - - return $formBuilder->getForm(); - } -} diff --git a/src/Core/Grid/Filter/GridFilterFormFactoryInterface.php b/src/Core/Grid/Filter/GridFilterFormFactoryInterface.php deleted file mode 100644 index ce48947a..00000000 --- a/src/Core/Grid/Filter/GridFilterFormFactoryInterface.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Filter; - -use PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface; -use Symfony\Component\Form\FormInterface; - -/** - * Interface FilterFormFactoryInterface. - */ -interface GridFilterFormFactoryInterface -{ - /** - * Create filters form for grid definition. - * - * @param GridDefinitionInterface $definition - * - * @return FormInterface - */ - public function create(GridDefinitionInterface $definition); -} diff --git a/src/Core/Grid/Grid.php b/src/Core/Grid/Grid.php deleted file mode 100644 index d89efbc8..00000000 --- a/src/Core/Grid/Grid.php +++ /dev/null @@ -1,108 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid; - -use PrestaShop\PrestaShop\Core\Grid\Data\GridDataInterface; -use PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use Symfony\Component\Form\FormInterface; - -/** - * Class Grid is responsible for holding final Grid data. - */ -final class Grid implements GridInterface -{ - /** - * @var GridDefinitionInterface - */ - private $definition; - - /** - * @var GridDataInterface - */ - private $data; - - /** - * @var SearchCriteriaInterface - */ - private $searchCriteria; - - /** - * @var FormInterface - */ - private $filtersForm; - - /** - * @param GridDefinitionInterface $definition - * @param GridDataInterface $data - * @param SearchCriteriaInterface $searchCriteria - * @param FormInterface $filtersForm - */ - public function __construct( - GridDefinitionInterface $definition, - GridDataInterface $data, - SearchCriteriaInterface $searchCriteria, - FormInterface $filtersForm - ) { - $this->definition = $definition; - $this->data = $data; - $this->searchCriteria = $searchCriteria; - $this->filtersForm = $filtersForm; - } - - /** - * {@inheritdoc} - */ - public function getDefinition() - { - return $this->definition; - } - - /** - * {@inheritdoc} - */ - public function getSearchCriteria() - { - return $this->searchCriteria; - } - - /** - * {@inheritdoc} - */ - public function getData() - { - return $this->data; - } - - /** - * {@inheritdoc} - */ - public function getFilterForm() - { - return $this->filtersForm; - } -} diff --git a/src/Core/Grid/GridFactory.php b/src/Core/Grid/GridFactory.php deleted file mode 100644 index a5a13486..00000000 --- a/src/Core/Grid/GridFactory.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid; - -use PrestaShop\PrestaShop\Core\Grid\Data\Factory\GridDataFactoryInterface; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\GridDefinitionFactoryInterface; -use PrestaShop\PrestaShop\Core\Grid\Filter\GridFilterFormFactoryInterface; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShopBundle\Event\Dispatcher\NullDispatcher; -use Symfony\Component\DependencyInjection\Container; - -/** - * Class GridFactory is responsible for creating final Grid instance. - */ -final class GridFactory implements GridFactoryInterface -{ - /** - * @var GridDefinitionFactoryInterface - */ - private $definitionFactory; - - /** - * @var GridDataFactoryInterface - */ - private $dataFactory; - - /** - * @var GridFilterFormFactoryInterface - */ - private $filterFormFactory; - - /** - * @var HookDispatcherInterface - */ - private $hookDispatcher; - - /** - * @param GridDefinitionFactoryInterface $definitionFactory - * @param GridDataFactoryInterface $dataFactory - * @param GridFilterFormFactoryInterface $filterFormFactory - * @param HookDispatcherInterface|null $hookDispatcher - */ - public function __construct( - GridDefinitionFactoryInterface $definitionFactory, - GridDataFactoryInterface $dataFactory, - GridFilterFormFactoryInterface $filterFormFactory, - HookDispatcherInterface $hookDispatcher = null - ) { - $this->definitionFactory = $definitionFactory; - $this->dataFactory = $dataFactory; - $this->filterFormFactory = $filterFormFactory; - - if (null === $hookDispatcher) { - @trigger_error('The $hookDispatcher parameter should not be null, inject your main HookDispatcherInterface service, or NullDispatcher if you don\'t need hooks.', E_USER_DEPRECATED); - } - $this->hookDispatcher = $hookDispatcher ? $hookDispatcher : new NullDispatcher(); - } - - /** - * {@inheritdoc} - */ - public function getGrid(SearchCriteriaInterface $searchCriteria) - { - $definition = $this->definitionFactory->getDefinition(); - $data = $this->dataFactory->getData($searchCriteria); - - $this->hookDispatcher->dispatchWithParameters('action' . Container::camelize($definition->getId()) . 'GridDataModifier', [ - 'data' => &$data, - ]); - - $filterForm = $this->filterFormFactory->create($definition); - $filterForm->setData($searchCriteria->getFilters()); - - return new Grid( - $definition, - $data, - $searchCriteria, - $filterForm - ); - } -} diff --git a/src/Core/Grid/GridFactoryInterface.php b/src/Core/Grid/GridFactoryInterface.php deleted file mode 100644 index 8f45dfb3..00000000 --- a/src/Core/Grid/GridFactoryInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid; - -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Interface GridFactoryInterface exposes contract for grid factory which is responsible for creating Grid instances. - */ -interface GridFactoryInterface -{ - /** - * Create grid with filtered data. - * - * @param SearchCriteriaInterface $searchCriteria - * - * @return GridInterface - */ - public function getGrid(SearchCriteriaInterface $searchCriteria); -} diff --git a/src/Core/Grid/GridInterface.php b/src/Core/Grid/GridInterface.php deleted file mode 100644 index 68d366ce..00000000 --- a/src/Core/Grid/GridInterface.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid; - -use PrestaShop\PrestaShop\Core\Grid\Data\GridDataInterface; -use PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use Symfony\Component\Form\FormInterface; - -/** - * Interface GridInterface defines contract for grid. - */ -interface GridInterface -{ - /** - * Get grid definition. - * - * @return GridDefinitionInterface - */ - public function getDefinition(); - - /** - * Get grid data. - * - * @return GridDataInterface - */ - public function getData(); - - /** - * Get grid data search criteria. - * - * @return SearchCriteriaInterface - */ - public function getSearchCriteria(); - - /** - * Get grid filter form. - * - * @return FormInterface - */ - public function getFilterForm(); -} diff --git a/src/Core/Grid/Position/Exception/PositionDataException.php b/src/Core/Grid/Position/Exception/PositionDataException.php deleted file mode 100644 index 304ac1fc..00000000 --- a/src/Core/Grid/Position/Exception/PositionDataException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position\Exception; - -/** - * Class PositionDataException, used by the PositionDataHandler. - */ -class PositionDataException extends PositionException -{ -} diff --git a/src/Core/Grid/Position/Exception/PositionException.php b/src/Core/Grid/Position/Exception/PositionException.php deleted file mode 100644 index bcab057c..00000000 --- a/src/Core/Grid/Position/Exception/PositionException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position\Exception; - -use PrestaShop\PrestaShop\Core\Exception\TranslatableCoreException; - -/** - * Class PositionException used by the GridPositionUpdater component. - */ -class PositionException extends TranslatableCoreException -{ -} diff --git a/src/Core/Grid/Position/Exception/PositionUpdateException.php b/src/Core/Grid/Position/Exception/PositionUpdateException.php deleted file mode 100644 index dd23a009..00000000 --- a/src/Core/Grid/Position/Exception/PositionUpdateException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position\Exception; - -/** - * Class PositionUpdateException throw by GridPositionUpdater. - */ -class PositionUpdateException extends PositionException -{ -} diff --git a/src/Core/Grid/Position/GridPositionUpdater.php b/src/Core/Grid/Position/GridPositionUpdater.php deleted file mode 100644 index 3f15456f..00000000 --- a/src/Core/Grid/Position/GridPositionUpdater.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position; - -use PrestaShop\PrestaShop\Core\Grid\Position\UpdateHandler\PositionUpdateHandlerInterface; - -/** - * Class GridPositionUpdater, this class is responsible for updating the position of items - * of a grid using the information from a PositionUpdateInterface object. - */ -final class GridPositionUpdater implements GridPositionUpdaterInterface -{ - /** - * @var PositionUpdateHandlerInterface - */ - private $updateHandler; - - /** - * @param PositionUpdateHandlerInterface $updateHandler - */ - public function __construct(PositionUpdateHandlerInterface $updateHandler) - { - $this->updateHandler = $updateHandler; - } - - /** - * {@inheritdoc} - */ - public function update(PositionUpdateInterface $positionUpdate) - { - $newPositions = $this->getNewPositions($positionUpdate); - $this->sortByPositionValue($newPositions); - $this->updateHandler->updatePositions($positionUpdate->getPositionDefinition(), $newPositions); - } - - /** - * @param PositionUpdateInterface $positionUpdate - * - * @return array - */ - private function getNewPositions(PositionUpdateInterface $positionUpdate) - { - $positions = $this->updateHandler->getCurrentPositions($positionUpdate->getPositionDefinition(), $positionUpdate->getParentId()); - - /** @var PositionModificationInterface $rowModification */ - foreach ($positionUpdate->getPositionModificationCollection() as $rowModification) { - $positions[$rowModification->getId()] = $rowModification->getNewPosition(); - } - - return $positions; - } - - /** - * @param $positions - */ - private function sortByPositionValue(&$positions) - { - asort($positions); - } -} diff --git a/src/Core/Grid/Position/GridPositionUpdaterInterface.php b/src/Core/Grid/Position/GridPositionUpdaterInterface.php deleted file mode 100644 index 9f00dc3e..00000000 --- a/src/Core/Grid/Position/GridPositionUpdaterInterface.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position; - -use PrestaShop\PrestaShop\Core\Grid\Position\Exception\PositionUpdateException; - -/** - * Interface GridPositionUpdaterInterface, this interface is responsible for updating the position of items - * of a grid using the information from a PositionUpdateInterface object. - */ -interface GridPositionUpdaterInterface -{ - /** - * Updates a grid based on the data in PositionUpdateInterface composed - * of the PositionDefinitionInterface allowing to build the query, the - * new positions and optionally a parentId - * Throws a PositionUpdateException if something went wrong. - * - * @param PositionUpdateInterface $positionUpdate - * - * @throws PositionUpdateException - */ - public function update(PositionUpdateInterface $positionUpdate); -} diff --git a/src/Core/Grid/Position/PositionDefinition.php b/src/Core/Grid/Position/PositionDefinition.php deleted file mode 100644 index 0b55dee7..00000000 --- a/src/Core/Grid/Position/PositionDefinition.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position; - -/** - * Class PositionDefinition used to define a position relationship, see - * PositionDefinitionInterface for more details. - */ -final class PositionDefinition implements PositionDefinitionInterface -{ - /** - * @var string - */ - private $table; - - /** - * @var string - */ - private $idField; - - /** - * @var string - */ - private $positionField; - - /** - * @var string|null - */ - private $parentIdField; - - /** - * @param string $table - * @param string $idField - * @param string $positionField - * @param string|null $parentIdField - */ - public function __construct( - $table, - $idField, - $positionField, - $parentIdField = null - ) { - $this->table = $table; - $this->idField = $idField; - $this->positionField = $positionField; - $this->parentIdField = $parentIdField; - } - - /** - * {@inheritdoc} - */ - public function getTable() - { - return $this->table; - } - - /** - * {@inheritdoc} - */ - public function getIdField() - { - return $this->idField; - } - - /** - * {@inheritdoc} - */ - public function getPositionField() - { - return $this->positionField; - } - - /** - * {@inheritdoc} - */ - public function getParentIdField() - { - return $this->parentIdField; - } -} diff --git a/src/Core/Grid/Position/PositionDefinitionInterface.php b/src/Core/Grid/Position/PositionDefinitionInterface.php deleted file mode 100644 index d32729f4..00000000 --- a/src/Core/Grid/Position/PositionDefinitionInterface.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position; - -/** - * Interface PositionDefinitionInterface used to define a position relationship, - * contains information about the database storing the position. - */ -interface PositionDefinitionInterface -{ - /** - * The name of the table containing the position. - * - * @return string - */ - public function getTable(); - - /** - * The name of the ID field in the row containing position. - * - * @return string - */ - public function getIdField(); - - /** - * The name of the position field in the row containing position. - * - * @return string - */ - public function getPositionField(); - - /** - * The name of the parent ID field in the row containing position, it - * is used to compute the positions in the parent scope. - * It is optional as the position may be bound to the table scope only. - * - * @return string|null - */ - public function getParentIdField(); -} diff --git a/src/Core/Grid/Position/PositionModification.php b/src/Core/Grid/Position/PositionModification.php deleted file mode 100644 index db3b4483..00000000 --- a/src/Core/Grid/Position/PositionModification.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position; - -/** - * Class PositionModification contains the modification for a - * designated row. - */ -final class PositionModification implements PositionModificationInterface -{ - /** - * @var string|int - */ - private $id; - - /** - * @var int - */ - private $oldPosition; - - /** - * @var int - */ - private $newPosition; - - /** - * @param string|int $id - * @param int $oldPosition - * @param int $newPosition - */ - public function __construct( - $id, - $oldPosition, - $newPosition - ) { - $this->id = $id; - $this->oldPosition = $oldPosition; - $this->newPosition = $newPosition; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->id; - } - - /** - * {@inheritdoc} - */ - public function getOldPosition() - { - return $this->oldPosition; - } - - /** - * {@inheritdoc} - */ - public function getNewPosition() - { - return $this->newPosition; - } -} diff --git a/src/Core/Grid/Position/PositionModificationCollection.php b/src/Core/Grid/Position/PositionModificationCollection.php deleted file mode 100644 index 1c3565ca..00000000 --- a/src/Core/Grid/Position/PositionModificationCollection.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position; - -use PrestaShop\PrestaShop\Core\Grid\Collection\AbstractCollection; - -/** - * Class PositionModificationCollection holds collection of row modifications for grid. - * - * @property PositionModificationInterface[] $items - */ -final class PositionModificationCollection extends AbstractCollection implements PositionModificationCollectionInterface -{ - /** - * {@inheritdoc} - */ - public function add(PositionModificationInterface $positionModification) - { - $this->items[$positionModification->getId()] = $positionModification; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function remove(PositionModificationInterface $positionModification) - { - if (isset($this->items[$positionModification->getId()])) { - unset($this->items[$positionModification->getId()]); - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function toArray() - { - $positionModifications = []; - - /** @var PositionModificationInterface $item */ - foreach ($this->items as $item) { - $positionModifications[] = [ - 'id' => $item->getId(), - 'oldPosition' => $item->getOldPosition(), - 'newPosition' => $item->getNewPosition(), - ]; - } - - return $positionModifications; - } -} diff --git a/src/Core/Grid/Position/PositionModificationCollectionInterface.php b/src/Core/Grid/Position/PositionModificationCollectionInterface.php deleted file mode 100644 index 2ffa03bc..00000000 --- a/src/Core/Grid/Position/PositionModificationCollectionInterface.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position; - -use Countable; -use Iterator; - -/** - * Interface PositionModificationCollectionInterface defines contract for grid RowModificationInterface collection. - */ -interface PositionModificationCollectionInterface extends Iterator, Countable -{ - /** - * Add rowModification to collection. - * - * @param PositionModificationInterface $positionModification - * - * @return self - */ - public function add(PositionModificationInterface $positionModification); - - /** - * Remove positionModification from collection. - * - * @param PositionModificationInterface $positionModification - * - * @return self - */ - public function remove(PositionModificationInterface $positionModification); - - /** - * Get positionModifications as array. - * - * @return array - */ - public function toArray(); -} diff --git a/src/Core/Grid/Position/PositionModificationInterface.php b/src/Core/Grid/Position/PositionModificationInterface.php deleted file mode 100644 index b1a01280..00000000 --- a/src/Core/Grid/Position/PositionModificationInterface.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position; - -/** - * Interface PositionModificationInterface contains the modification for a - * designated row. - */ -interface PositionModificationInterface -{ - /** - * The row id allowing to match it. - * - * @return string|int - */ - public function getId(); - - /** - * The former row position. - * - * @return int - */ - public function getOldPosition(); - - /** - * The new row position. - * - * @return int - */ - public function getNewPosition(); -} diff --git a/src/Core/Grid/Position/PositionUpdate.php b/src/Core/Grid/Position/PositionUpdate.php deleted file mode 100644 index c03d20bd..00000000 --- a/src/Core/Grid/Position/PositionUpdate.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position; - -/** - * Class PositionUpdate contains the modifications needed - * to update the grid positions. - */ -final class PositionUpdate implements PositionUpdateInterface -{ - /** - * @var PositionDefinitionInterface - */ - private $positionDefinition; - - /** - * @var PositionModificationCollectionInterface - */ - private $positionModificationCollection; - - /** - * @var string|null - */ - private $parentId; - - /** - * @param PositionModificationCollectionInterface $positionModificationCollection - * @param PositionDefinitionInterface $positionDefinition - * @param string|null $parentId - */ - public function __construct( - PositionModificationCollectionInterface $positionModificationCollection, - PositionDefinitionInterface $positionDefinition, - $parentId = null - ) { - $this->positionDefinition = $positionDefinition; - $this->positionModificationCollection = $positionModificationCollection; - $this->parentId = $parentId; - } - - /** - * {@inheritdoc} - */ - public function getPositionDefinition() - { - return $this->positionDefinition; - } - - /** - * {@inheritdoc} - */ - public function getPositionModificationCollection() - { - return $this->positionModificationCollection; - } - - /** - * {@inheritdoc} - */ - public function getParentId() - { - return $this->parentId; - } -} diff --git a/src/Core/Grid/Position/PositionUpdateFactory.php b/src/Core/Grid/Position/PositionUpdateFactory.php deleted file mode 100644 index f1abddd2..00000000 --- a/src/Core/Grid/Position/PositionUpdateFactory.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position; - -use PrestaShop\PrestaShop\Core\Grid\Position\Exception\PositionDataException; - -/** - * Class PositionUpdateFactory is a basic implementation of the PositionUpdateFactoryInterface, - * it transforms the provided array data into a PositionUpdate object. - */ -final class PositionUpdateFactory implements PositionUpdateFactoryInterface -{ - const POSITION_KEY = 'Invalid position %i data, missing %s field.'; - - /** - * @var string - */ - private $positionsField; - - /** - * @var string - */ - private $rowIdField; - - /** - * @var string - */ - private $oldPositionField; - - /** - * @var string - */ - private $newPositionField; - - /** - * @var string - */ - private $parentIdField; - - /** - * @param string $positionsField - * @param string $rowIdField - * @param string $oldPositionField - * @param string $newPositionField - * @param string $parentIdField - */ - public function __construct( - $positionsField, - $rowIdField, - $oldPositionField, - $newPositionField, - $parentIdField - ) { - $this->positionsField = $positionsField; - $this->rowIdField = $rowIdField; - $this->oldPositionField = $oldPositionField; - $this->newPositionField = $newPositionField; - $this->parentIdField = $parentIdField; - } - - /** - * {@inheritdoc} - */ - public function buildPositionUpdate(array $data, PositionDefinition $positionDefinition) - { - $this->validateData($data, $positionDefinition); - - $updates = new PositionModificationCollection(); - foreach ($data[$this->positionsField] as $index => $position) { - $this->validatePositionData($position, $index); - - $updates->add(new PositionModification( - $position[$this->rowIdField], - $position[$this->oldPositionField], - $position[$this->newPositionField] - )); - } - - $positionUpdate = new PositionUpdate( - $updates, - $positionDefinition, - isset($data[$this->parentIdField]) ? $data[$this->parentIdField] : null - ); - - return $positionUpdate; - } - - /** - * @param array $data - * @param PositionDefinition $positionDefinition - * - * @throws PositionDataException - */ - private function validateData(array $data, PositionDefinition $positionDefinition) - { - if (empty($data[$this->positionsField])) { - throw new PositionDataException('Missing ' . $this->positionsField . ' in your data.', 'Admin.Notifications.Failure'); - } - - if (null !== $positionDefinition->getParentIdField() && empty($data[$this->parentIdField])) { - throw new PositionDataException('Missing ' . $this->parentIdField . ' in your data.', 'Admin.Notifications.Failure'); - } - } - - /** - * Validate the position format, throw a PositionDataException if is not correct. - * - * @param array $position - * @param int $index - * - * @throws PositionDataException - */ - private function validatePositionData(array $position, $index) - { - if (!isset($position[$this->rowIdField])) { - throw new PositionDataException(self::POSITION_KEY, 'Admin.Notifications.Failure', [$index, $this->rowIdField]); - } - if (!isset($position[$this->oldPositionField])) { - throw new PositionDataException(self::POSITION_KEY, 'Admin.Notifications.Failure', [$index, $this->oldPositionField]); - } - if (!isset($position[$this->newPositionField])) { - throw new PositionDataException(self::POSITION_KEY, 'Admin.Notifications.Failure', [$index, $this->newPositionField]); - } - } -} diff --git a/src/Core/Grid/Position/PositionUpdateFactoryInterface.php b/src/Core/Grid/Position/PositionUpdateFactoryInterface.php deleted file mode 100644 index 37a75888..00000000 --- a/src/Core/Grid/Position/PositionUpdateFactoryInterface.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position; - -use PrestaShop\PrestaShop\Core\Grid\Position\Exception\PositionDataException; - -/** - * Interface PositionUpdateFactoryInterface is used to interpret the provided - * data array and transform it in a fully filled PositionUpdate object. - */ -interface PositionUpdateFactoryInterface -{ - /** - * Transform the provided data into a PositionUpdate. - * - * @param array $data - * @param PositionDefinition $positionDefinition - * - * @return PositionUpdate - * - * @throws PositionDataException - */ - public function buildPositionUpdate(array $data, PositionDefinition $positionDefinition); -} diff --git a/src/Core/Grid/Position/PositionUpdateInterface.php b/src/Core/Grid/Position/PositionUpdateInterface.php deleted file mode 100644 index d9d792a3..00000000 --- a/src/Core/Grid/Position/PositionUpdateInterface.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position; - -/** - * Interface PositionUpdateInterface contains the modifications needed - * to update the grid positions. - */ -interface PositionUpdateInterface -{ - /** - * The PositionDefinition defines the position relationship and - * allows to be build the database request. - * - * @return PositionDefinitionInterface - */ - public function getPositionDefinition(); - - /** - * A collection of modifications for each modified rows. - * - * @return PositionModificationCollectionInterface - */ - public function getPositionModificationCollection(); - - /** - * If the PositionDefinition needs a parent and has defined a - * parentIdField then this field contains its value. - * - * @return string|null - */ - public function getParentId(); -} diff --git a/src/Core/Grid/Position/UpdateHandler/DoctrinePositionUpdateHandler.php b/src/Core/Grid/Position/UpdateHandler/DoctrinePositionUpdateHandler.php deleted file mode 100644 index dc346abb..00000000 --- a/src/Core/Grid/Position/UpdateHandler/DoctrinePositionUpdateHandler.php +++ /dev/null @@ -1,120 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position\UpdateHandler; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\ConnectionException; -use Doctrine\DBAL\Statement; -use PrestaShop\PrestaShop\Core\Grid\Position\Exception\PositionUpdateException; -use PrestaShop\PrestaShop\Core\Grid\Position\PositionDefinitionInterface; - -/** - * Class DoctrinePositionUpdateHandler updates the grid positions using a Doctrine - * Connection. - */ -final class DoctrinePositionUpdateHandler implements PositionUpdateHandlerInterface -{ - /** - * @var Connection - */ - private $connection; - - /** - * @var string - */ - private $dbPrefix; - - /** - * @param Connection $connection - * @param string $dbPrefix - */ - public function __construct( - Connection $connection, - $dbPrefix - ) { - $this->connection = $connection; - $this->dbPrefix = $dbPrefix; - } - - /** - * {@inheritdoc} - */ - public function getCurrentPositions(PositionDefinitionInterface $positionDefinition, $parentId = null) - { - $qb = $this->connection->createQueryBuilder(); - $qb - ->from($this->dbPrefix . $positionDefinition->getTable(), 't') - ->select('t.' . $positionDefinition->getIdField() . ', t.' . $positionDefinition->getPositionField()) - ->addOrderBy('t.' . $positionDefinition->getPositionField(), 'ASC'); - - if (null !== $parentId && null !== $positionDefinition->getParentIdField()) { - $qb - ->andWhere('t.' . $positionDefinition->getParentIdField() . ' = :parentId') - ->setParameter('parentId', $parentId); - } - - $positions = $qb->execute()->fetchAll(); - $currentPositions = []; - foreach ($positions as $position) { - $positionId = $position[$positionDefinition->getIdField()]; - $currentPositions[$positionId] = $position[$positionDefinition->getPositionField()]; - } - - return $currentPositions; - } - - /** - * {@inheritdoc} - */ - public function updatePositions(PositionDefinitionInterface $positionDefinition, array $newPositions) - { - try { - $this->connection->beginTransaction(); - $positionIndex = 0; - foreach ($newPositions as $rowId => $newPosition) { - $qb = $this->connection->createQueryBuilder(); - $qb - ->update($this->dbPrefix . $positionDefinition->getTable()) - ->set($positionDefinition->getPositionField(), ':position') - ->andWhere($positionDefinition->getIdField() . ' = :rowId') - ->setParameter('rowId', $rowId) - ->setParameter('position', $positionIndex); - - $statement = $qb->execute(); - if ($statement instanceof Statement && $statement->errorCode()) { - throw new PositionUpdateException('Could not update #%i', 'Admin.Catalog.Notification', [$rowId]); - } - ++$positionIndex; - } - $this->connection->commit(); - } catch (ConnectionException $e) { - $this->connection->rollBack(); - - throw new PositionUpdateException('Could not update.', 'Admin.Catalog.Notification'); - } - } -} diff --git a/src/Core/Grid/Position/UpdateHandler/PositionUpdateHandlerInterface.php b/src/Core/Grid/Position/UpdateHandler/PositionUpdateHandlerInterface.php deleted file mode 100644 index be42f008..00000000 --- a/src/Core/Grid/Position/UpdateHandler/PositionUpdateHandlerInterface.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Position\UpdateHandler; - -use PrestaShop\PrestaShop\Core\Grid\Position\Exception\PositionUpdateException; -use PrestaShop\PrestaShop\Core\Grid\Position\PositionDefinitionInterface; - -/** - * Interface PositionUpdateHandlerInterface is used by GridPositionUpdater to - * manipulate the data, handling the manipulation in this interface allows the - * GridPositionUpdater to adapt more easily to different databases or any other - * persistence solutions. - */ -interface PositionUpdateHandlerInterface -{ - /** - * Returns the complete list of positions based on the PositionDefinitionInterface - * The expected return is an associative array with row IDs used as keys and positions - * as values. - * - * ex: $currentPositions = [ - * 1 => 0, - * 4 => 1, - * 42 => 2, - * 3 => 3 - * ]; - * - * @param string|int $parentId - * @param PositionDefinitionInterface $positionDefinition - * - * @return array - */ - public function getCurrentPositions(PositionDefinitionInterface $positionDefinition, $parentId = null); - - /** - * This method is used to update the new positions previously fetched through getCurrentPositions which - * have been updated by the GridPositionUpdater, hence the $newPositions has the same format as the one - * returned by getCurrentPositions, except of course the positions are likely to have changed. - * - * ex: $newPositions = [ - * 1 => 3, - * 4 => 1, - * 42 => 2, - * 3 => 3 - * ]; - * - * Throws a PositionUpdateException if something went wrong. - * - * @param PositionDefinitionInterface $positionDefinition - * @param array $newPositions - * - * @throws PositionUpdateException - */ - public function updatePositions(PositionDefinitionInterface $positionDefinition, array $newPositions); -} diff --git a/src/Core/Grid/Presenter/GridPresenter.php b/src/Core/Grid/Presenter/GridPresenter.php deleted file mode 100644 index b1dc4f36..00000000 --- a/src/Core/Grid/Presenter/GridPresenter.php +++ /dev/null @@ -1,170 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Presenter; - -use PrestaShop\PrestaShop\Core\Grid\Column\ColumnInterface; -use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\PositionColumn; -use PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface; -use PrestaShop\PrestaShop\Core\Grid\Filter\FilterInterface; -use PrestaShop\PrestaShop\Core\Grid\GridInterface; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShop\PrestaShop\Core\Search\Filters; -use Symfony\Component\DependencyInjection\Container; - -/** - * Class GridPresenter is responsible for presenting grid. - */ -final class GridPresenter implements GridPresenterInterface -{ - /** - * @var HookDispatcherInterface - */ - private $hookDispatcher; - - public function __construct(HookDispatcherInterface $hookDispatcher) - { - $this->hookDispatcher = $hookDispatcher; - } - - /** - * {@inheritdoc} - */ - public function present(GridInterface $grid) - { - $filterForm = $grid->getFilterForm(); - - $definition = $grid->getDefinition(); - $searchCriteria = $grid->getSearchCriteria(); - $data = $grid->getData(); - $presentedGrid = [ - 'id' => $definition->getId(), - 'name' => $definition->getName(), - 'filter_form' => $filterForm->createView(), - 'form_prefix' => '', - 'columns' => $this->getColumns($grid), - 'column_filters' => $this->getColumnFilters($definition), - 'actions' => [ - 'grid' => $definition->getGridActions()->toArray(), - 'bulk' => $definition->getBulkActions()->toArray(), - ], - 'data' => [ - 'records' => $data->getRecords(), - 'records_total' => $data->getRecordsTotal(), - 'query' => $data->getQuery(), - ], - 'pagination' => [ - 'offset' => $searchCriteria->getOffset(), - 'limit' => $searchCriteria->getLimit(), - ], - 'sorting' => [ - 'order_by' => $searchCriteria->getOrderBy(), - 'order_way' => $searchCriteria->getOrderWay(), - ], - 'filters' => $searchCriteria->getFilters(), - 'attributes' => [ - 'is_empty_state' => empty($filterForm->getData()) && $data->getRecords()->count() === 0, - ], - ]; - - if ($searchCriteria instanceof Filters) { - $presentedGrid['form_prefix'] = $searchCriteria->getFilterId(); - } - - $this->hookDispatcher->dispatchWithParameters('action' . Container::camelize($definition->getId()) . 'GridPresenterModifier', [ - 'presented_grid' => &$presentedGrid, - ]); - - return $presentedGrid; - } - - /** - * Returns the columns formatted as array, adds an additional position handle - * column when needed. - * - * @param GridInterface $grid - * - * @return array - */ - private function getColumns(GridInterface $grid) - { - $columns = $grid->getDefinition()->getColumns()->toArray(); - - $positionColumn = $this->getOrderingPosition($grid); - if (null !== $positionColumn) { - array_unshift($columns, [ - 'id' => $positionColumn->getId() . '_handle', - 'name' => $positionColumn->getName(), - 'type' => 'position_handle', - 'options' => $positionColumn->getOptions(), - ]); - } - - return $columns; - } - - /** - * @param GridInterface $grid - * - * @return ColumnInterface|null - */ - public function getOrderingPosition(GridInterface $grid) - { - $searchCriteria = $grid->getSearchCriteria(); - /** @var ColumnInterface $column */ - foreach ($grid->getDefinition()->getColumns() as $column) { - if ($column instanceof PositionColumn && - strtolower($column->getId()) == strtolower($searchCriteria->getOrderBy()) && - 'asc' == strtolower($searchCriteria->getOrderWay()) - ) { - return $column; - } - } - - return null; - } - - /** - * Get filters that have associated columns. - * - * @param GridDefinitionInterface $definition - * - * @return array - */ - private function getColumnFilters(GridDefinitionInterface $definition) - { - $columnFiltersMapping = []; - - /** @var FilterInterface $filter */ - foreach ($definition->getFilters()->all() as $filter) { - if (null !== $associatedColumn = $filter->getAssociatedColumn()) { - $columnFiltersMapping[$associatedColumn][] = $filter->getName(); - } - } - - return $columnFiltersMapping; - } -} diff --git a/src/Core/Grid/Presenter/GridPresenterInterface.php b/src/Core/Grid/Presenter/GridPresenterInterface.php deleted file mode 100644 index 118471c1..00000000 --- a/src/Core/Grid/Presenter/GridPresenterInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Presenter; - -use PrestaShop\PrestaShop\Core\Grid\GridInterface; - -/** - * Interface GridPresenterInterface defines contract for grid presenter. - */ -interface GridPresenterInterface -{ - /** - * Present grid as plain array. - * - * @param GridInterface $grid - * - * @return array - */ - public function present(GridInterface $grid); -} diff --git a/src/Core/Grid/Query/AbstractDoctrineQueryBuilder.php b/src/Core/Grid/Query/AbstractDoctrineQueryBuilder.php deleted file mode 100644 index 019cb8e4..00000000 --- a/src/Core/Grid/Query/AbstractDoctrineQueryBuilder.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; - -/** - * Class AbstractDoctrineQueryBuilder provides most common dependencies of doctrine query builders. - */ -abstract class AbstractDoctrineQueryBuilder implements DoctrineQueryBuilderInterface -{ - /** - * @var Connection - */ - protected $connection; - - /** - * @var string - */ - protected $dbPrefix; - - /** - * @param Connection $connection - * @param $dbPrefix - */ - public function __construct(Connection $connection, $dbPrefix) - { - $this->connection = $connection; - $this->dbPrefix = $dbPrefix; - } -} diff --git a/src/Core/Grid/Query/AddressQueryBuilder.php b/src/Core/Grid/Query/AddressQueryBuilder.php deleted file mode 100644 index 3cce6195..00000000 --- a/src/Core/Grid/Query/AddressQueryBuilder.php +++ /dev/null @@ -1,184 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Builds search & count queries for address grid. - */ -final class AddressQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @var int - */ - private $contextLangId; - - /** - * @var int[] - */ - private $contextShopIds; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param int $contextLangId - * @param array $contextShopIds - */ - public function __construct( - Connection $connection, - string $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - int $contextLangId, - array $contextShopIds - ) { - parent::__construct($connection, $dbPrefix); - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->contextLangId = $contextLangId; - $this->contextShopIds = $contextShopIds; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria): QueryBuilder - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - - $qb - ->select('a.`id_address`, a.`firstname`, a.`lastname`, a.`address1`, a.`postcode`, a.`city`') - ->addSelect('cl.`name` as country_name') - ; - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb) - ; - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria): QueryBuilder - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()) - ->select('COUNT(DISTINCT a.`id_address`)') - ; - - return $qb; - } - - /** - * Gets query builder with the common sql used for displaying addresses list and applying filter actions. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters): QueryBuilder - { - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'address', 'a') - ->where('a.`id_customer` != 0') - ->andWhere('a.`deleted` = 0'); - - $qb->leftJoin( - 'a', - $this->dbPrefix . 'country', - 'c', - 'a.`id_country` = c.`id_country`' - ); - - $qb->leftJoin( - 'c', - $this->dbPrefix . 'country_lang', - 'cl', - 'c.`id_country` = cl.`id_country` AND cl.`id_lang` = :idLang' - ); - - $qb->leftJoin( - 'a', - $this->dbPrefix . 'customer', - 'customer', - 'a.`id_customer` = customer.`id_customer`' - ); - - $qb->andWhere('customer.id_shop IN (:context_shop_ids)') - ->setParameter('context_shop_ids', $this->contextShopIds, Connection::PARAM_INT_ARRAY) - ->setParameter('idLang', $this->contextLangId); - - $this->applyFilters($qb, $filters); - - return $qb; - } - - /** - * Apply filters to address query builder. - * - * @param array $filters - * @param QueryBuilder $qb - */ - private function applyFilters(QueryBuilder $qb, array $filters) - { - $allowedFiltersMap = [ - 'id_address' => 'a.id_address', - 'firstname' => 'a.firstname', - 'lastname' => 'a.lastname', - 'address1' => 'a.address1', - 'postcode' => 'a.postcode', - 'city' => 'a.city', - 'id_country' => 'cl.id_country', - ]; - - foreach ($filters as $filterName => $value) { - if (!array_key_exists($filterName, $allowedFiltersMap) || empty($value)) { - continue; - } - - if ('id_country' === $filterName) { - $qb->andWhere($allowedFiltersMap[$filterName] . ' = :' . $filterName) - ->setParameter($filterName, $value); - - continue; - } - - $qb->andWhere($allowedFiltersMap[$filterName] . ' LIKE :' . $filterName) - ->setParameter($filterName, '%' . $value . '%'); - } - } -} diff --git a/src/Core/Grid/Query/AttachmentQueryBuilder.php b/src/Core/Grid/Query/AttachmentQueryBuilder.php deleted file mode 100644 index 93937eae..00000000 --- a/src/Core/Grid/Query/AttachmentQueryBuilder.php +++ /dev/null @@ -1,174 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Attachment query builder builds search & count data for attachment grid. - */ -final class AttachmentQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @var int - */ - private $employeeIdLang; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param string $employeeIdLang - */ - public function __construct( - Connection $connection, - string $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - string $employeeIdLang - ) { - parent::__construct($connection, $dbPrefix); - - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->employeeIdLang = $employeeIdLang; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria): QueryBuilder - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - - $qb - ->select('a.`id_attachment`, al.`name`, a.`file`, a.`file_size`') - ->addSelect('COALESCE(virtual_product_attachment.`product_count`, 0) AS products') - ; - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb) - ; - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria): QueryBuilder - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()) - ->select('COUNT(DISTINCT a.`id_attachment`)') - ; - - return $qb; - } - - /** - * Gets query builder with the common sql used for displaying webservice list and applying filter actions. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters): QueryBuilder - { - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'attachment', 'a') - ->leftJoin( - 'a', - $this->dbPrefix . 'attachment_lang', - 'al', - 'a.`id_attachment` = al.`id_attachment`' - ); - - $productCountQb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'product_attachment', 'pa') - ->select('pa.`id_attachment`, COUNT(*) as product_count') - ->groupBy('id_attachment'); - - $qb->leftJoin('a', - '(' . $productCountQb->getSQL() . ')', - 'virtual_product_attachment', - 'a.`id_attachment` = virtual_product_attachment.`id_attachment`'); - - $qb->andWhere('al.`id_lang` = :employee_id_lang'); - $qb->setParameter('employee_id_lang', $this->employeeIdLang); - $this->applyFilters($qb, $filters); - - return $qb; - } - - /** - * Apply filters to attachments query builder. - * - * @param array $filters - * @param QueryBuilder $qb - */ - private function applyFilters(QueryBuilder $qb, array $filters) - { - $allowedFiltersMap = [ - 'id_attachment' => 'a.id_attachment', - 'name' => 'al.name', - 'file_size' => 'a.file_size', - 'products' => 'virtual_product_attachment.product_count', - ]; - - foreach ($filters as $filterName => $value) { - if (!array_key_exists($filterName, $allowedFiltersMap)) { - continue; - } - - if ('id_attachment' === $filterName) { - $qb->andWhere($allowedFiltersMap[$filterName] . ' = :' . $filterName); - $qb->setParameter($filterName, $value); - - continue; - } - - if ('products' === $filterName && $value === '0') { - $qb->andWhere($allowedFiltersMap[$filterName] . ' IS NULL'); - - $qb->setParameter($filterName, $value); - - continue; - } - - $qb->andWhere($allowedFiltersMap[$filterName] . ' LIKE :' . $filterName) - ->setParameter($filterName, '%' . $value . '%'); - } - } -} diff --git a/src/Core/Grid/Query/AttributeGroupQueryBuilder.php b/src/Core/Grid/Query/AttributeGroupQueryBuilder.php deleted file mode 100644 index e445d384..00000000 --- a/src/Core/Grid/Query/AttributeGroupQueryBuilder.php +++ /dev/null @@ -1,209 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use PrestaShop\PrestaShop\Core\Multistore\MultistoreContextCheckerInterface; - -/** - * Provides sql for attributes group list - */ -final class AttributeGroupQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var int - */ - private $contextLangId; - - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @var MultistoreContextCheckerInterface - */ - private $multistoreContextChecker; - - /** - * @var int[] - */ - private $contextShopIds; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param int $contextLangId - * @param MultistoreContextCheckerInterface $multistoreContextChecker - * @param int[] $contextShopIds - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - $contextLangId, - MultistoreContextCheckerInterface $multistoreContextChecker, - array $contextShopIds - ) { - parent::__construct($connection, $dbPrefix); - $this->contextLangId = $contextLangId; - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->multistoreContextChecker = $multistoreContextChecker; - $this->contextShopIds = $contextShopIds; - } - - /** - * Get query that searches grid rows. - * - * @param SearchCriteriaInterface|null $searchCriteria - * - * @return QueryBuilder - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()) - ->select('DISTINCT ag.id_attribute_group, agl.name, ag.position, acount.values'); - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb); - - return $qb; - } - - /** - * Get query that counts grid rows. - * - * @param SearchCriteriaInterface|null $searchCriteria - * - * @return QueryBuilder - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - $qb->select('COUNT(DISTINCT ag.id_attribute_group)'); - - return $qb; - } - - /** - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters) - { - $subQuery = $this->connection->createQueryBuilder() - ->select('COUNT(DISTINCT a.id_attribute) AS `values`, a.id_attribute_group') - ->from($this->dbPrefix . 'attribute', 'a') - ->groupBy('a.id_attribute_group'); - - if (!$this->multistoreContextChecker->isAllShopContext()) { - $subQuery->andWhere('attrShop.id_shop IN (:contextShopIds)'); - } - - $subQuery->leftJoin( - 'a', - $this->dbPrefix . 'attribute_shop', - 'attrShop', - 'a.id_attribute = attrShop.id_attribute' - ); - - $qb = $this->connection->createQueryBuilder() - ->from($this->dbPrefix . 'attribute_group', 'ag') - ->leftJoin( - 'ag', - '(' . $subQuery->getSQL() . ')', - 'acount', - 'acount.id_attribute_group = ag.id_attribute_group' - ) - ->setParameter('contextLangId', $this->contextLangId) - ->setParameter('contextShopIds', $this->contextShopIds, Connection::PARAM_INT_ARRAY); - - $qb->leftJoin( - 'ag', - $this->dbPrefix . 'attribute_group_lang', - 'agl', - 'agl.id_attribute_group = ag.id_attribute_group AND agl.id_lang = :contextLangId' - ); - - $qb->leftJoin( - 'ag', - $this->dbPrefix . 'attribute_group_shop', - 'ags', - 'ag.id_attribute_group = ags.id_attribute_group' - ); - $qb->andWhere('ags.id_shop IN (:contextShopIds)'); - - $this->applyFilters($filters, $qb); - - return $qb; - } - - /** - * @param array $filters - * @param QueryBuilder $qb - */ - private function applyFilters(array $filters, QueryBuilder $qb) - { - $allowedFiltersMap = [ - 'id_attribute_group' => 'ag.id_attribute_group', - 'name' => 'agl.name', - 'position' => 'ag.position', - ]; - - foreach ($filters as $filterName => $value) { - if (!array_key_exists($filterName, $allowedFiltersMap)) { - continue; - } - - if ('name' === $filterName) { - $qb->andWhere($allowedFiltersMap[$filterName] . ' LIKE :' . $filterName) - ->setParameter($filterName, '%' . $value . '%'); - continue; - } - - if ('position' === $filterName) { - // When filtering by position, - // value must be decreased by 1, - // since position value in database starts at 0, - // but for user display positions are increased by 1. - if (is_numeric($value)) { - --$value; - } else { - $value = null; - } - } - - $qb->andWhere($allowedFiltersMap[$filterName] . ' = :' . $filterName) - ->setParameter($filterName, $value); - } - } -} diff --git a/src/Core/Grid/Query/AttributeQueryBuilder.php b/src/Core/Grid/Query/AttributeQueryBuilder.php deleted file mode 100644 index 1ff8f3b4..00000000 --- a/src/Core/Grid/Query/AttributeQueryBuilder.php +++ /dev/null @@ -1,208 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use PrestaShop\PrestaShop\Core\Multistore\MultistoreContextCheckerInterface; - -/** - * Provides sql for attributes group > attribute list - */ -final class AttributeQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @var int - */ - private $contextLangId; - - /** - * @var int - */ - private $attributeGroupId; - - /** - * @var MultistoreContextCheckerInterface - */ - private $multistoreContextChecker; - - /** - * @var int[] - */ - private $contextShopIds; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param int $contextLangId - * @param int $attributeGroupId - * @param MultistoreContextCheckerInterface $multistoreContextChecker - * @param int[] $contextShopIds - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - $contextLangId, - $attributeGroupId, - MultistoreContextCheckerInterface $multistoreContextChecker, - $contextShopIds - ) { - parent::__construct($connection, $dbPrefix); - $this->contextLangId = $contextLangId; - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->attributeGroupId = $attributeGroupId; - $this->multistoreContextChecker = $multistoreContextChecker; - $this->contextShopIds = $contextShopIds; - } - - /** - * Get query that searches grid rows. - * - * @param SearchCriteriaInterface|null $searchCriteria - * - * @return QueryBuilder - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()) - ->select('DISTINCT a.id_attribute, a.color, a.id_attribute_group, al.name AS value, a.position'); - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb); - - return $qb; - } - - /** - * Get query that counts grid rows. - * - * @param SearchCriteriaInterface|null $searchCriteria - * - * @return QueryBuilder - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - $qb->select('COUNT(DISTINCT a.`id_attribute`)'); - - return $qb; - } - - /** - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters) - { - $qb = $this->connection->createQueryBuilder() - ->from($this->dbPrefix . 'attribute', 'a') - ->setParameter('contextLangId', $this->contextLangId) - ->setParameter('attributeGroupId', $this->attributeGroupId) - ->setParameter('contextShopIds', $this->contextShopIds, Connection::PARAM_INT_ARRAY) - ->andWhere('al.id_lang = :contextLangId') - ->andWhere('ag.id_attribute_group = :attributeGroupId'); - - if (!$this->multistoreContextChecker->isAllShopContext()) { - $qb->andWhere('ashop.id_shop IN (:contextShopIds)'); - } - - $qb->leftJoin( - 'a', - $this->dbPrefix . 'attribute_shop', - 'ashop', - 'a.id_attribute = ashop.id_attribute' - ); - - $qb->leftJoin( - 'a', - $this->dbPrefix . 'attribute_group', - 'ag', - 'a.id_attribute_group = ag.id_attribute_group'); - - $qb->leftJoin( - 'a', - $this->dbPrefix . 'attribute_lang', - 'al', - 'a.id_attribute = al.id_attribute' - ); - - $this->applyFilters($filters, $qb); - - return $qb; - } - - /** - * @param array $filters - * @param QueryBuilder $qb - */ - private function applyFilters(array $filters, QueryBuilder $qb) - { - $allowedFiltersMap = [ - 'id_attribute' => 'a.id_attribute', - 'value' => 'al.name', - 'position' => 'a.position', - 'color' => 'a.color', - ]; - - foreach ($filters as $filterName => $value) { - if (!array_key_exists($filterName, $allowedFiltersMap)) { - continue; - } - - if ('value' === $filterName || 'color' === $filterName) { - $qb->andWhere($allowedFiltersMap[$filterName] . ' LIKE :' . $filterName) - ->setParameter($filterName, '%' . $value . '%'); - continue; - } - - if ('position' === $filterName) { - // When filtering by position, - // value must be decreased by 1, - // since position value in database starts at 0, - // but for user display positions are increased by 1. - if (is_numeric($value)) { - --$value; - } else { - $value = null; - } - } - - $qb->andWhere('a.`' . $filterName . '` = :' . $filterName) - ->setParameter($filterName, $value); - } - } -} diff --git a/src/Core/Grid/Query/CatalogPriceRuleQueryBuilder.php b/src/Core/Grid/Query/CatalogPriceRuleQueryBuilder.php deleted file mode 100644 index fde4e538..00000000 --- a/src/Core/Grid/Query/CatalogPriceRuleQueryBuilder.php +++ /dev/null @@ -1,210 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Builds query for catalog price rule list - */ -final class CatalogPriceRuleQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @var array - */ - private $contextShopIds; - - /** - * @var int - */ - private $contextIdLang; - - /** - * @param Connection $connection - * @param $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param array $contextShopIds - * @param int $contextIdLang - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - array $contextShopIds, - $contextIdLang - ) { - parent::__construct($connection, $dbPrefix); - - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->contextShopIds = $contextShopIds; - $this->contextIdLang = $contextIdLang; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - - $qb->select( - 'pr.id_specific_price_rule, - pr.name, - pr.from_quantity, - pr.reduction, - pr.reduction_type, - pr.from date_from, - pr.to date_to, - pr_shop.name shop, - pr_currency.name currency, - pr_country.name country, - pr_group.name group_name' - ); - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb) - ; - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()) - ->select('COUNT(DISTINCT pr.`id_specific_price_rule`)') - ; - - return $qb; - } - - /** - * Gets query builder with the common sql for catalog price rule listing. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters) - { - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'specific_price_rule', 'pr') - ->leftJoin( - 'pr', - $this->dbPrefix . 'shop', - 'pr_shop', - 'pr_shop.`id_shop` = pr.`id_shop` AND pr.`id_shop` IN (:contextShopIds)' - ) - ->leftJoin( - 'pr', - $this->dbPrefix . 'currency_lang', - 'pr_currency', - 'pr_currency.`id_currency` = pr.`id_currency` AND pr_currency.`id_lang` = :contextLangId' - ) - ->leftJoin( - 'pr', - $this->dbPrefix . 'country_lang', - 'pr_country', - 'pr_country.`id_country` = pr.`id_country` AND pr_country.`id_lang` = :contextLangId' - ) - ->leftJoin( - 'pr', - $this->dbPrefix . 'group_lang', - 'pr_group', - 'pr_group.`id_group` = pr.`id_group` AND pr_group.`id_lang` = :contextLangId' - ) - ; - - $this->applyFilters($qb, $filters); - $qb->setParameter('contextLangId', $this->contextIdLang); - $qb->setParameter('contextShopIds', $this->contextShopIds, Connection::PARAM_INT_ARRAY); - - return $qb; - } - - /** - * @param QueryBuilder $qb - * @param array $filters - */ - private function applyFilters(QueryBuilder $qb, array $filters) - { - $allowedFiltersAliasMap = [ - 'id_specific_price_rule' => 'pr.id_specific_price_rule', - 'name' => 'pr.name', - 'from_quantity' => 'pr.from_quantity', - 'reduction' => 'pr.reduction', - 'reduction_type' => 'pr.reduction_type', - 'date_from' => 'pr.from', - 'date_to' => 'pr.to', - 'shop' => 'pr_shop.name', - 'currency' => 'pr_currency.name', - 'country' => 'pr_country.name', - 'group_name' => 'pr_group.name', - ]; - - $exactMatchFilters = ['id_specific_price_rule', 'from_quantity', 'reduction', 'reduction_type']; - - foreach ($filters as $filterName => $value) { - if (!array_key_exists($filterName, $allowedFiltersAliasMap)) { - return; - } - - if (in_array($filterName, $exactMatchFilters, true)) { - $qb->andWhere($allowedFiltersAliasMap[$filterName] . ' = :' . $filterName); - $qb->setParameter($filterName, $value); - - continue; - } - - if ('date_from' === $filterName || 'date_to' === $filterName) { - if (isset($value['from'])) { - $qb->andWhere($allowedFiltersAliasMap[$filterName] . ' >= :' . $filterName . '_from'); - $qb->setParameter($filterName . '_from', $value['from']); - } - if (isset($value['to'])) { - $qb->andWhere($allowedFiltersAliasMap[$filterName] . ' <= :' . $filterName . '_to'); - $qb->setParameter($filterName . '_to', $value['to']); - } - - continue; - } - - $qb->andWhere($allowedFiltersAliasMap[$filterName] . ' LIKE :' . $filterName); - $qb->setParameter($filterName, "%$value%"); - } - } -} diff --git a/src/Core/Grid/Query/CategoryQueryBuilder.php b/src/Core/Grid/Query/CategoryQueryBuilder.php deleted file mode 100644 index 5768b1e0..00000000 --- a/src/Core/Grid/Query/CategoryQueryBuilder.php +++ /dev/null @@ -1,242 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Feature\FeatureInterface; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use PrestaShop\PrestaShop\Core\Multistore\MultistoreContextCheckerInterface; - -/** - * Class CategoryQueryBuilder builds search & count queries for categories grid. - */ -final class CategoryQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var int - */ - private $contextLangId; - - /** - * @var int - */ - private $contextShopId; - - /** - * @var int|null - * - * Can be null for backward-compatibility - */ - private $rootCategoryId; - - /** - * @var DoctrineSearchCriteriaApplicator - */ - private $searchCriteriaApplicator; - - /** - * @var MultistoreContextCheckerInterface - */ - private $multistoreContextChecker; - - /** - * @var FeatureInterface - */ - private $multistoreFeature; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicator $searchCriteriaApplicator - * @param int $contextLangId - * @param int $contextShopId - * @param MultistoreContextCheckerInterface $multistoreContextChecker - * @param FeatureInterface $multistoreFeature - * @param int|null $rootCategoryId - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicator $searchCriteriaApplicator, - $contextLangId, - $contextShopId, - MultistoreContextCheckerInterface $multistoreContextChecker, - FeatureInterface $multistoreFeature, - $rootCategoryId = null - ) { - parent::__construct($connection, $dbPrefix); - - $this->contextLangId = $contextLangId; - $this->contextShopId = $contextShopId; - $this->rootCategoryId = $rootCategoryId; - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->multistoreContextChecker = $multistoreContextChecker; - $this->multistoreFeature = $multistoreFeature; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - $qb->select('c.id_category, c.id_parent, c.active, cl.name, cl.description, cs.position'); - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb); - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - $qb->select('COUNT(c.id_category)'); - - return $qb; - } - - /** - * Get generic query builder. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters) - { - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'category', 'c') - ->setParameter('context_lang_id', $this->contextLangId) - ->setParameter('context_shop_id', $this->contextShopId); - - $qb->leftJoin( - 'c', - $this->dbPrefix . 'category_lang', - 'cl', - $this->multistoreFeature->isUsed() && $this->multistoreContextChecker->isSingleShopContext() ? - 'c.id_category = cl.id_category AND cl.id_lang = :context_lang_id AND cl.id_shop = :context_shop_id' : - 'c.id_category = cl.id_category AND cl.id_lang = :context_lang_id AND cl.id_shop = c.id_shop_default' - ); - - $qb->leftJoin( - 'c', - $this->dbPrefix . 'category_shop', - 'cs', - $this->multistoreContextChecker->isSingleShopContext() ? - 'c.id_category = cs.id_category AND cs.id_shop = :context_shop_id' : - 'c.id_category = cs.id_category AND cs.id_shop = c.id_shop_default' - ); - - foreach ($filters as $filterName => $filterValue) { - if ('id_category' === $filterName) { - $qb->andWhere("c.id_category = :$filterName"); - $qb->setParameter($filterName, $filterValue); - - continue; - } - - // exclude root category from search results - if ($this->rootCategoryId !== null) { - $qb->andWhere('c.id_category != :root_category_id'); - $qb->setParameter('root_category_id', $this->rootCategoryId); - } - - if ('name' === $filterName) { - $qb->andWhere("cl.name LIKE :$filterName"); - $qb->setParameter($filterName, '%' . $filterValue . '%'); - - continue; - } - - if ('description' === $filterName) { - $qb->andWhere("cl.description LIKE :$filterName"); - $qb->setParameter($filterName, '%' . $filterValue . '%'); - - continue; - } - - if ('position' === $filterName) { - // When filtering by position, - // value must be decreased by 1, - // since position value in database starts at 0, - // but for user display positions are increased by 1. - if (is_numeric($filterValue)) { - --$filterValue; - } else { - $filterValue = null; - } - - $qb->andWhere("cs.position = :$filterName"); - $qb->setParameter($filterName, $filterValue); - - continue; - } - - if ('active' === $filterName) { - $qb->andWhere("c.active = :$filterName"); - $qb->setParameter($filterName, $filterValue); - - continue; - } - - if ('id_category_parent' === $filterName) { - if ($this->isSearchRequestOnHomeCategory($filters)) { - continue; - } - - $qb->andWhere("c.id_parent = :$filterName"); - $qb->setParameter($filterName, $filterValue); - - continue; - } - } - - if ($this->multistoreFeature->isUsed() && $this->multistoreContextChecker->isSingleShopContext()) { - $qb->andWhere('cs.id_shop = :context_shop_id'); - } - - return $qb; - } - - /** - * @param array $filters - * - * @return bool - */ - private function isSearchRequestOnHomeCategory(array $filters) - { - return isset($filters['is_home_category'], $filters['is_search_request']) - && $filters['is_home_category'] === true && $filters['is_search_request'] === true; - } -} diff --git a/src/Core/Grid/Query/CmsPageCategoryQueryBuilder.php b/src/Core/Grid/Query/CmsPageCategoryQueryBuilder.php deleted file mode 100644 index 092ecaca..00000000 --- a/src/Core/Grid/Query/CmsPageCategoryQueryBuilder.php +++ /dev/null @@ -1,220 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class CmsPageCategoryQueryBuilder builds search & count queries for cms page categories grid. - */ -final class CmsPageCategoryQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @var array - */ - private $contextShopIds; - - /** - * @var int - */ - private $contextIdLang; - - /** - * @param Connection $connection - * @param $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param array $contextShopIds - * @param int $contextIdLang - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - array $contextShopIds, - $contextIdLang - ) { - parent::__construct($connection, $dbPrefix); - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->contextShopIds = $contextShopIds; - $this->contextIdLang = $contextIdLang; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - - $qb - ->select('cc.`id_cms_category`, cc.`id_parent`, cc.`active`, cc.`position`, ccl.`name`, ccl.`description`') - ->groupBy('cc.`id_cms_category`') - ->orderBy( - $this->getModifiedOrderBy($searchCriteria->getOrderBy()), - $searchCriteria->getOrderWay() - ) - ; - - $this->searchCriteriaApplicator->applyPagination($searchCriteria, $qb); - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()) - ->select('COUNT(DISTINCT cc.`id_cms_category`)') - ; - - return $qb; - } - - /** - * Gets query builder. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters) - { - $availableFilters = [ - 'id_cms_category_parent', - 'id_cms_category', - 'active', - 'position', - 'name', - 'description', - ]; - - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'cms_category', 'cc') - ->leftJoin( - 'cc', - $this->dbPrefix . 'cms_category_lang', - 'ccl', - 'ccl.`id_cms_category` = cc.`id_cms_category`' - ) - ->innerJoin( - 'cc', - $this->dbPrefix . 'cms_category_shop', - 'ccs', - 'ccs.`id_cms_category` = cc.`id_cms_category`' - ) - ; - - $qb->andWhere('ccl.`id_lang` = :contextLangId'); - $qb->andWhere('ccl.`id_shop` IN (:contextShopIds)'); - $qb->andWhere('ccs.`id_shop` IN (:contextShopIds)'); - - $qb->setParameter('contextLangId', $this->contextIdLang); - $qb->setParameter('contextShopIds', $this->contextShopIds, Connection::PARAM_INT_ARRAY); - - foreach ($filters as $filterName => $value) { - if (!in_array($filterName, $availableFilters, true)) { - continue; - } - - if ('id_cms_category_parent' === $filterName) { - $qb->andWhere('cc.`id_parent` = :id_cms_category_parent'); - $qb->setParameter('id_cms_category_parent', $value); - - continue; - } - - if (in_array($filterName, ['id_cms_category', 'active'], true)) { - $qb->andWhere('cc.`' . $filterName . '` = :' . $filterName); - $qb->setParameter($filterName, $value); - - continue; - } - - if ('position' === $filterName) { - $modifiedPositionFilter = $this->getModifiedPositionFilter($value); - $qb->andWhere('cc.`' . $filterName . '` = :' . $filterName); - $qb->setParameter($filterName, $modifiedPositionFilter); - - continue; - } - - $qb->andWhere('ccl.`' . $filterName . '` LIKE :' . $filterName); - $qb->setParameter($filterName, '%' . $value . '%'); - } - - return $qb; - } - - /** - * Gets modified order by by having prefix appended. - * - * @param string $orderBy - * - * @return string - */ - private function getModifiedOrderBy($orderBy) - { - if ('id_cms_category' === $orderBy) { - $orderBy = 'cc.`id_cms_category`'; - } - - return $orderBy; - } - - /** - * Gets modified position filter value. This is required due to in database position filter index starts from 0 and - * for the customer which wants to filter results the value starts from 1 instead. - * - * @param $positionFilterValue - * - * @return int|null - if null is returned then no results are found since position field does not hold null values - */ - private function getModifiedPositionFilter($positionFilterValue) - { - if (!is_numeric($positionFilterValue)) { - return null; - } - - $reducedByOneFilterValue = $positionFilterValue - 1; - - if (0 > $reducedByOneFilterValue) { - return null; - } - - return $reducedByOneFilterValue; - } -} diff --git a/src/Core/Grid/Query/CmsPageQueryBuilder.php b/src/Core/Grid/Query/CmsPageQueryBuilder.php deleted file mode 100644 index 79b8ce24..00000000 --- a/src/Core/Grid/Query/CmsPageQueryBuilder.php +++ /dev/null @@ -1,202 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class responsible for providing sql which is needed to render cms page list. - */ -final class CmsPageQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @var array - */ - private $contextShopIds; - - /** - * @var int - */ - private $contextIdLang; - - /** - * @param Connection $connection - * @param $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param array $contextShopIds - * @param int $contextIdLang - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - array $contextShopIds, - $contextIdLang - ) { - parent::__construct($connection, $dbPrefix); - - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->contextShopIds = $contextShopIds; - $this->contextIdLang = $contextIdLang; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - - $qb - ->select('c.`id_cms`, cl.`link_rewrite`, c.`active`, c.`position`, cl.`meta_title`, cl.`head_seo_title`') - ->addSelect('c.`id_cms_category`') - ->groupBy('c.`id_cms`') - ; - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb) - ; - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()) - ->select('COUNT(DISTINCT c.`id_cms`)') - ; - - return $qb; - } - - /** - * Gets query builder with the common sql for cms page listing. - * - * @param array $filters - * - * @return \Doctrine\DBAL\Query\QueryBuilder - */ - private function getQueryBuilder(array $filters) - { - $availableFilters = [ - 'id_cms_category_parent', - 'id_cms', - 'link_rewrite', - 'meta_title', - 'head_seo_title', - 'position', - 'active', - ]; - - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'cms', 'c') - ->leftJoin( - 'c', - $this->dbPrefix . 'cms_lang', - 'cl', - 'cl.`id_cms` = c.`id_cms`' - ) - ->innerJoin( - 'c', - $this->dbPrefix . 'cms_shop', - 'cs', - 'cs.`id_cms` = c.`id_cms`' - ) - ; - - $qb->andWhere('cl.`id_lang` = :contextLangId'); - $qb->andWhere('cl.`id_shop` IN (:contextShopIds)'); - $qb->andWhere('cs.`id_shop` IN (:contextShopIds)'); - - $qb->setParameter('contextLangId', $this->contextIdLang); - $qb->setParameter('contextShopIds', $this->contextShopIds, Connection::PARAM_INT_ARRAY); - - foreach ($filters as $filterName => $value) { - if (!in_array($filterName, $availableFilters, true)) { - continue; - } - - if ('id_cms_category_parent' === $filterName) { - $qb->andWhere('c.`id_cms_category` = :id_cms_category_parent'); - $qb->setParameter('id_cms_category_parent', $value); - - continue; - } - - if (in_array($filterName, ['id_cms', 'active'], true)) { - $qb->andWhere('c.`' . $filterName . '` = :' . $filterName); - $qb->setParameter($filterName, $value); - - continue; - } - - if ('position' === $filterName) { - $modifiedPositionFilter = $this->getModifiedPositionFilter($value); - $qb->andWhere('c.`' . $filterName . '` = :' . $filterName); - $qb->setParameter($filterName, $modifiedPositionFilter); - continue; - } - - $qb->andWhere('cl.`' . $filterName . '` LIKE :' . $filterName); - $qb->setParameter($filterName, '%' . $value . '%'); - } - - return $qb; - } - - /** - * Gets modified position filter value. This is required due to in database position filter index starts from 0 and - * for the customer which wants to filter results the value starts from 1 instead. - * - * @param $positionFilterValue - * - * @return int|null - if null is returned then no results are found since position field does not hold null values - */ - private function getModifiedPositionFilter($positionFilterValue) - { - if (!is_numeric($positionFilterValue)) { - return null; - } - $reducedByOneFilterValue = $positionFilterValue - 1; - if (0 > $reducedByOneFilterValue) { - return null; - } - - return $reducedByOneFilterValue; - } -} diff --git a/src/Core/Grid/Query/ContactQueryBuilder.php b/src/Core/Grid/Query/ContactQueryBuilder.php deleted file mode 100644 index 7776eaca..00000000 --- a/src/Core/Grid/Query/ContactQueryBuilder.php +++ /dev/null @@ -1,146 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class ContactsQueryBuilder is responsible for building queries for Contacts grid data. - */ -final class ContactQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @var int - */ - private $languageId; - - /** - * @var array - */ - private $contextShopsIds; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param int $languageId - * @param array $contextShopsIds - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - $languageId, - array $contextShopsIds - ) { - parent::__construct($connection, $dbPrefix); - - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->languageId = $languageId; - $this->contextShopsIds = $contextShopsIds; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - $qb - ->select('c.id_contact, c.email, cl.name, cl.description') - ->groupBy('c.id_contact'); - - $this->searchCriteriaApplicator - ->applySorting($searchCriteria, $qb) - ->applyPagination($searchCriteria, $qb); - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()) - ->select('COUNT(DISTINCT c.id_contact)'); - - return $qb; - } - - /** - * Get generic query builder. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters) - { - $allowedFilters = [ - 'id_contact', - 'name', - 'email', - 'description', - ]; - - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'contact', 'c') - ->innerJoin('c', $this->dbPrefix . 'contact_lang', 'cl', 'c.id_contact = cl.id_contact') - ->innerJoin('c', $this->dbPrefix . 'contact_shop', 'cs', 'c.id_contact = cs.id_contact') - ->andWhere('cl.`id_lang`= :language') - ->andWhere('cs.`id_shop` IN (:shops)') - ->setParameter('language', $this->languageId) - ->setParameter('shops', $this->contextShopsIds, Connection::PARAM_INT_ARRAY); - - foreach ($filters as $name => $value) { - if (!in_array($name, $allowedFilters, true)) { - continue; - } - - if ('id_contact' === $name) { - $qb->andWhere('c.`id_contact` = :' . $name); - $qb->setParameter($name, $value); - - continue; - } - - $qb->andWhere("$name LIKE :$name"); - $qb->setParameter($name, '%' . $value . '%'); - } - - return $qb; - } -} diff --git a/src/Core/Grid/Query/CreditSlipQueryBuilder.php b/src/Core/Grid/Query/CreditSlipQueryBuilder.php deleted file mode 100644 index 00e6ecdd..00000000 --- a/src/Core/Grid/Query/CreditSlipQueryBuilder.php +++ /dev/null @@ -1,161 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class responsible for providing sql for credit slip list - */ -final class CreditSlipQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @var array - */ - private $contextShopIds; - - /** - * @param Connection $connection - * @param $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param array $contextShopIds - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - array $contextShopIds - ) { - parent::__construct($connection, $dbPrefix); - - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->contextShopIds = $contextShopIds; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - - $qb - ->select('slip.id_order_slip, slip.id_order, slip.date_add') - ->groupBy('slip.id_order_slip') - ; - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb) - ; - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()) - ->select('COUNT(DISTINCT slip.`id_order_slip`)') - ; - - return $qb; - } - - /** - * Gets query builder with the common sql for credit slip listing. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters) - { - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'order_slip', 'slip') - ->leftJoin( - 'slip', - $this->dbPrefix . 'orders', - 'orders', - 'slip.id_order = orders.id_order' - ) - ; - $qb->andWhere('orders.id_shop IN (:contextShopIds)'); - $qb->setParameter('contextShopIds', $this->contextShopIds, Connection::PARAM_INT_ARRAY); - $this->applyFilters($qb, $filters); - - return $qb; - } - - /** - * @param QueryBuilder $qb - * @param array $filters - */ - private function applyFilters(QueryBuilder $qb, array $filters) - { - $availableFiltersMap = [ - 'id_credit_slip' => 'slip.id_order_slip', - 'id_order' => 'slip.id_order', - 'date_issued' => 'slip.date_add', - ]; - - foreach ($filters as $filterName => $value) { - if (!array_key_exists($filterName, $availableFiltersMap)) { - continue; - } - - if ('id_credit_slip' === $filterName || 'id_order' === $filterName) { - $qb->andWhere($availableFiltersMap[$filterName] . "= :$filterName"); - $qb->setParameter($filterName, $value); - - continue; - } - - if ('date_issued' === $filterName) { - if (isset($value['from'])) { - $qb->andWhere($availableFiltersMap[$filterName] . ' >= :date_from'); - $qb->setParameter('date_from', sprintf('%s 0:0:0', $value['from'])); - } - if (isset($value['to'])) { - $qb->andWhere($availableFiltersMap[$filterName] . ' <= :date_to'); - $qb->setParameter('date_to', sprintf('%s 23:59:59', $value['to'])); - } - continue; - } - } - } -} diff --git a/src/Core/Grid/Query/CurrencyQueryBuilder.php b/src/Core/Grid/Query/CurrencyQueryBuilder.php deleted file mode 100644 index d867866c..00000000 --- a/src/Core/Grid/Query/CurrencyQueryBuilder.php +++ /dev/null @@ -1,161 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PDO; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class CurrencyQueryBuilder builds search & count queries for currencies grid. - */ -final class CurrencyQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @var array - */ - private $contextShopIds; - - /** - * @var int - */ - private $contextLangId; - - /** - * @param Connection $connection - * @param $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param array $contextShopIds - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - array $contextShopIds, - $contextLangId - ) { - parent::__construct($connection, $dbPrefix); - - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->contextShopIds = $contextShopIds; - $this->contextLangId = $contextLangId; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - - $qb - ->select('c.`id_currency`, c.`iso_code`, cs.`conversion_rate`, c.`active`, c.`modified`, c.`unofficial`, cl.`name`, cl.`symbol`') - ->groupBy('c.`id_currency`') - ; - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb) - ; - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()) - ->select('COUNT(DISTINCT c.`id_currency`)') - ; - - return $qb; - } - - /** - * Gets query builder with the common sql used for displaying webservice list and applying filter actions. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters) - { - $allowedFilters = [ - 'iso_code', - 'active', - ]; - - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'currency', 'c') - ->innerJoin( - 'c', - $this->dbPrefix . 'currency_shop', - 'cs', - 'c.`id_currency` = cs.`id_currency`' - ) - ->innerJoin( - 'c', - $this->dbPrefix . 'currency_lang', - 'cl', - 'c.`id_currency` = cl.`id_currency`' - ) - ; - $qb->andWhere('cs.`id_shop` IN (:shops)'); - $qb->andWhere('cl.`id_lang` = :lang'); - $qb->andWhere('c.`deleted` = 0'); - - $qb->setParameter('shops', $this->contextShopIds, Connection::PARAM_INT_ARRAY); - $qb->setParameter('lang', $this->contextLangId, PDO::PARAM_INT); - - foreach ($filters as $filterName => $value) { - if (!in_array($filterName, $allowedFilters, true)) { - continue; - } - - if ('active' === $filterName) { - $qb->andWhere('c.`active` = :active'); - $qb->setParameter('active', $value); - - continue; - } - - $qb->andWhere('c.`' . $filterName . '` LIKE :' . $filterName); - $qb->setParameter($filterName, '%' . $value . '%'); - } - - return $qb; - } -} diff --git a/src/Core/Grid/Query/CustomerQueryBuilder.php b/src/Core/Grid/Query/CustomerQueryBuilder.php deleted file mode 100644 index 1a25dad8..00000000 --- a/src/Core/Grid/Query/CustomerQueryBuilder.php +++ /dev/null @@ -1,270 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class CustomerQueryBuilder builds queries to fetch data for customers grid. - */ -final class CustomerQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var int - */ - private $contextLangId; - - /** - * @var int[] - */ - private $contextShopIds; - - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $criteriaApplicator; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $criteriaApplicator - * @param int $contextLangId - * @param int[] $contextShopIds - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $criteriaApplicator, - $contextLangId, - array $contextShopIds - ) { - parent::__construct($connection, $dbPrefix); - - $this->contextLangId = $contextLangId; - $this->contextShopIds = $contextShopIds; - $this->criteriaApplicator = $criteriaApplicator; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $searchQueryBuilder = $this->getCustomerQueryBuilder($searchCriteria) - ->select('c.id_customer, c.firstname, c.lastname, c.email, c.active, c.newsletter, c.optin') - ->addSelect('c.date_add, gl.name as social_title, s.name as shop_name, c.company'); - - $this->appendTotalSpentQuery($searchQueryBuilder); - $this->appendLastVisitQuery($searchQueryBuilder); - $this->applySorting($searchQueryBuilder, $searchCriteria); - - $this->criteriaApplicator->applyPagination( - $searchCriteria, - $searchQueryBuilder - ); - - return $searchQueryBuilder; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $countQueryBuilder = $this->getCustomerQueryBuilder($searchCriteria) - ->select('COUNT(*)'); - - return $countQueryBuilder; - } - - /** - * @param SearchCriteriaInterface $searchCriteria - * - * @return QueryBuilder - */ - private function getCustomerQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $queryBuilder = $this->connection->createQueryBuilder() - ->from($this->dbPrefix . 'customer', 'c') - ->leftJoin( - 'c', - $this->dbPrefix . 'gender_lang', - 'gl', - 'c.id_gender = gl.id_gender AND gl.id_lang = :context_lang_id' - ) - ->leftJoin( - 'c', - $this->dbPrefix . 'shop', - 's', - 'c.id_shop = s.id_shop' - ) - ->where('c.deleted = 0') - ->andWhere('c.id_shop IN (:context_shop_ids)') - ->setParameter('context_shop_ids', $this->contextShopIds, Connection::PARAM_INT_ARRAY) - ->setParameter('context_lang_id', $this->contextLangId); - - $this->applyFilters($searchCriteria->getFilters(), $queryBuilder); - - return $queryBuilder; - } - - /** - * @param QueryBuilder $queryBuilder - */ - private function appendTotalSpentQuery(QueryBuilder $queryBuilder) - { - $totalSpentQueryBuilder = $this->connection->createQueryBuilder() - ->select('SUM(total_paid_real / conversion_rate)') - ->from($this->dbPrefix . 'orders', 'o') - ->where('o.id_customer = c.id_customer') - ->andWhere('o.id_shop IN (:context_shop_ids)') - ->andWhere('o.valid = 1') - ->setParameter('context_shop_ids', $this->contextShopIds, Connection::PARAM_INT_ARRAY); - - $queryBuilder->addSelect('(' . $totalSpentQueryBuilder->getSQL() . ') as total_spent'); - } - - /** - * Append "last visit" column to customers query builder. - * - * @param QueryBuilder $queryBuilder - */ - private function appendLastVisitQuery(QueryBuilder $queryBuilder) - { - $lastVisitQueryBuilder = $this->connection->createQueryBuilder() - ->select('con.date_add') - ->from($this->dbPrefix . 'guest', 'g') - ->leftJoin('g', $this->dbPrefix . 'connections', 'con', 'con.id_guest = g.id_guest') - ->where('g.id_customer = c.id_customer') - ->orderBy('con.date_add', 'DESC') - ->setMaxResults(1); - - $queryBuilder->addSelect('(' . $lastVisitQueryBuilder->getSQL() . ') as connect'); - } - - /** - * Apply filters to customers query builder. - * - * @param array $filters - * @param QueryBuilder $qb - */ - private function applyFilters(array $filters, QueryBuilder $qb) - { - $allowedFilters = [ - 'id_customer', - 'social_title', - 'firstname', - 'lastname', - 'email', - 'active', - 'newsletter', - 'optin', - 'date_add', - 'company', - ]; - - foreach ($filters as $filterName => $filterValue) { - if (!in_array($filterName, $allowedFilters)) { - continue; - } - - if (in_array($filterName, ['active', 'newsletter', 'optin', 'id_customer'])) { - $qb->andWhere('c.`' . $filterName . '` = :' . $filterName); - $qb->setParameter($filterName, $filterValue); - - continue; - } - - if ('social_title' === $filterName) { - $qb->andWhere('gl.id_gender = :' . $filterName); - $qb->setParameter($filterName, $filterValue); - - continue; - } - - if ('date_add' === $filterName) { - $qb->andWhere('c.date_add >= :date_from AND c.date_add <= :date_to'); - $qb->setParameter('date_from', sprintf('%s 0:0:0', $filterValue['from'])); - $qb->setParameter('date_to', sprintf('%s 23:59:59', $filterValue['to'])); - - if (isset($filterValue['from'])) { - $qb->andWhere('c.date_add >= :date_from'); - $qb->setParameter('date_from', sprintf('%s 0:0:0', $filterValue['from'])); - } - - if (isset($filterValue['to'])) { - $qb->andWhere('c.date_add <= :date_to'); - $qb->setParameter('date_to', sprintf('%s 23:59:59', $filterValue['to'])); - } - - continue; - } - - $qb->andWhere('`' . $filterName . '` LIKE :' . $filterName); - $qb->setParameter($filterName, '%' . $filterValue . '%'); - } - } - - /** - * Apply sorting so search query builder for customers. - * - * @param QueryBuilder $searchQueryBuilder - * @param SearchCriteriaInterface $searchCriteria - */ - private function applySorting(QueryBuilder $searchQueryBuilder, SearchCriteriaInterface $searchCriteria) - { - switch ($searchCriteria->getOrderBy()) { - case 'id_customer': - case 'firstname': - case 'lastname': - case 'email': - case 'date_add': - case 'company': - case 'active': - case 'newsletter': - case 'optin': - $orderBy = 'c.' . $searchCriteria->getOrderBy(); - - break; - case 'social_title': - $orderBy = 'gl.name'; - - break; - case 'connect': - case 'total_spent': - $orderBy = $searchCriteria->getOrderBy(); - - break; - default: - return; - } - - $searchQueryBuilder->orderBy($orderBy, $searchCriteria->getOrderWay()); - } -} diff --git a/src/Core/Grid/Query/DoctrineQueryBuilderInterface.php b/src/Core/Grid/Query/DoctrineQueryBuilderInterface.php deleted file mode 100644 index 7c359118..00000000 --- a/src/Core/Grid/Query/DoctrineQueryBuilderInterface.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class DoctrineQueryBuilderInterface defines contract to retrieve Doctrine query builders needed to get grid data. - */ -interface DoctrineQueryBuilderInterface -{ - /** - * Get query that searches grid rows. - * - * @param SearchCriteriaInterface|null $searchCriteria - * - * @return QueryBuilder - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria); - - /** - * Get query that counts grid rows. - * - * @param SearchCriteriaInterface|null $searchCriteria - * - * @return QueryBuilder - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria); -} diff --git a/src/Core/Grid/Query/DoctrineQueryParser.php b/src/Core/Grid/Query/DoctrineQueryParser.php deleted file mode 100644 index 0e0fd4eb..00000000 --- a/src/Core/Grid/Query/DoctrineQueryParser.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use PrestaShop\PrestaShop\Core\Grid\Exception\UnsupportedParameterException; - -/** - * This class offers a DBAL implementation of Query parser. - */ -final class DoctrineQueryParser implements QueryParserInterface -{ - /** - * {@inheritdoc} - */ - public function parse($query, array $queryParameters) - { - $values = []; - foreach ($queryParameters as $key => $value) { - if (!is_string($key)) { - throw new UnsupportedParameterException('Only named parameters are supported in prepared queries.'); - } - $values[':' . $key] = $this->parseValue($value); - } - - return strtr($query, $values); - } - - /** - * @param mixed $value the parameter value - * - * @return string the partial raw parameter - * - * @throws UnsupportedParameterException - */ - private function parseValue($value) - { - if (is_string($value)) { - return $this->parseStringParameter($value); - } - - if (is_numeric($value)) { - return $this->parseNumericParameter($value); - } - - if (is_array($value)) { - return $this->parseArrayParameter($value); - } - - if (is_bool($value)) { - return $this->parseBooleanParameter($value); - } - - if ($value === null) { - return 'NULL'; - } - - throw new UnsupportedParameterException('Unsupported value type: ' . gettype($value)); - } - - /** - * @param string $value - * - * @return string - */ - private function parseStringParameter($value) - { - return "'" . addslashes($value) . "'"; - } - - /** - * @param int|float $value - * - * @return int|float - */ - private function parseNumericParameter($value) - { - return $value; - } - - /** - * @param array $value - * - * @return string - */ - private function parseArrayParameter(array $value) - { - return "'" . implode("', '", array_map('addslashes', $value)) . "'"; - } - - /** - * @param bool $value - * - * @return string - */ - private function parseBooleanParameter($value) - { - return $value ? 'TRUE' : 'FALSE'; - } -} diff --git a/src/Core/Grid/Query/DoctrineSearchCriteriaApplicator.php b/src/Core/Grid/Query/DoctrineSearchCriteriaApplicator.php deleted file mode 100644 index 21cfad70..00000000 --- a/src/Core/Grid/Query/DoctrineSearchCriteriaApplicator.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class DoctrineSearchCriteriaApplicator applies search criteria to doctrine query builder. - */ -final class DoctrineSearchCriteriaApplicator implements DoctrineSearchCriteriaApplicatorInterface -{ - /** - * {@inheritdoc} - */ - public function applyPagination(SearchCriteriaInterface $searchCriteria, QueryBuilder $queryBuilder) - { - if (null !== $searchCriteria->getLimit()) { - $queryBuilder->setMaxResults($searchCriteria->getLimit()); - } - - if (null !== $searchCriteria->getOffset()) { - $queryBuilder->setFirstResult($searchCriteria->getOffset()); - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function applySorting(SearchCriteriaInterface $searchCriteria, QueryBuilder $queryBuilder) - { - if (null !== $searchCriteria->getOrderBy() && null !== $searchCriteria->getOrderWay()) { - $queryBuilder->orderBy( - $searchCriteria->getOrderBy(), - $searchCriteria->getOrderWay() - ); - } - - return $this; - } -} diff --git a/src/Core/Grid/Query/DoctrineSearchCriteriaApplicatorInterface.php b/src/Core/Grid/Query/DoctrineSearchCriteriaApplicatorInterface.php deleted file mode 100644 index f987d39a..00000000 --- a/src/Core/Grid/Query/DoctrineSearchCriteriaApplicatorInterface.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Interface DoctrineSearchCriteriaApplicatorInterface contract for doctrine query builder applicator. - */ -interface DoctrineSearchCriteriaApplicatorInterface -{ - /** - * Apply pagination on query builder. - * - * @param SearchCriteriaInterface $searchCriteria - * @param QueryBuilder $queryBuilder - * - * @return self - */ - public function applyPagination(SearchCriteriaInterface $searchCriteria, QueryBuilder $queryBuilder); - - /** - * Apply sorting on query builder. - * - * @param SearchCriteriaInterface $searchCriteria - * @param QueryBuilder $queryBuilder - * - * @return self - */ - public function applySorting(SearchCriteriaInterface $searchCriteria, QueryBuilder $queryBuilder); -} diff --git a/src/Core/Grid/Query/EmailLogsQueryBuilder.php b/src/Core/Grid/Query/EmailLogsQueryBuilder.php deleted file mode 100644 index a170c909..00000000 --- a/src/Core/Grid/Query/EmailLogsQueryBuilder.php +++ /dev/null @@ -1,126 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class EmailLogsQueryBuilder is responsible for building queries for email logs grid data. - */ -final class EmailLogsQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - ) { - parent::__construct($connection, $dbPrefix); - - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - $qb->select('m.*, l.name AS language'); - - $this->searchCriteriaApplicator - ->applySorting($searchCriteria, $qb) - ->applyPagination($searchCriteria, $qb); - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - $qb->select('COUNT(m.id_mail)'); - - return $qb; - } - - /** - * Get generic query builder. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters) - { - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'mail', 'm') - ->leftJoin('m', $this->dbPrefix . 'lang', 'l', 'm.id_lang = l.id_lang'); - - foreach ($filters as $name => $value) { - if ('id_lang' === $name) { - $qb->andWhere("l.id_lang = :$name"); - $qb->setParameter($name, $value); - - continue; - } - - if ('date_add' === $name) { - if (isset($value['from'])) { - $qb->andWhere('m.date_add >= :date_from'); - $qb->setParameter('date_from', sprintf('%s %s', $value['from'], '0:0:0')); - } - - if (isset($value['to'])) { - $qb->andWhere('m.date_add <= :date_to'); - $qb->setParameter('date_to', sprintf('%s %s', $value['to'], '23:59:59')); - } - - continue; - } - - $qb->andWhere("$name LIKE :$name"); - $qb->setParameter($name, '%' . $value . '%'); - } - - return $qb; - } -} diff --git a/src/Core/Grid/Query/EmployeeQueryBuilder.php b/src/Core/Grid/Query/EmployeeQueryBuilder.php deleted file mode 100644 index 99afd1fe..00000000 --- a/src/Core/Grid/Query/EmployeeQueryBuilder.php +++ /dev/null @@ -1,192 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class EmployeeQueryBuilder builds queries for Employees grid. - */ -final class EmployeeQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @var string - */ - private $contextIdLang; - - /** - * @var int[] - */ - private $contextShopIds; - - /** - * @param Connection $connection - * @param $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param string $contextIdLang - * @param int[] $contextShopIds - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - $contextIdLang, - array $contextShopIds - ) { - parent::__construct($connection, $dbPrefix); - - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->contextIdLang = $contextIdLang; - $this->contextShopIds = $contextShopIds; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $searchQueryBuilder = $this->getEmployeeQueryBuilder($searchCriteria) - ->select('e.*, pl.name as profile_name'); - - $this->searchCriteriaApplicator->applyPagination($searchCriteria, $searchQueryBuilder); - $this->applySorting($searchCriteria, $searchQueryBuilder); - - return $searchQueryBuilder; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $countQueryBuilder = $this->getEmployeeQueryBuilder($searchCriteria) - ->select('COUNT(e.id_profile)'); - - return $countQueryBuilder; - } - - /** - * @param SearchCriteriaInterface $searchCriteria - * - * @return QueryBuilder - */ - private function getEmployeeQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $sub = $this->connection->createQueryBuilder() - ->select(1) - ->from($this->dbPrefix . 'employee_shop', 'es') - ->where('e.id_employee = es.id_employee') - ->andWhere('es.id_shop IN (:context_shop_ids)'); - - $qb = $this->connection->createQueryBuilder() - ->from($this->dbPrefix . 'employee', 'e') - ->leftJoin( - 'e', - $this->dbPrefix . 'profile_lang', - 'pl', - 'e.id_profile = pl.id_profile AND pl.id_lang = ' . (int) $this->contextIdLang - ) - ->andWhere('EXISTS (' . $sub->getSQL() . ')') - ->setParameter('context_shop_ids', $this->contextShopIds, Connection::PARAM_INT_ARRAY); - - $this->applyFilters($qb, $searchCriteria->getFilters()); - - return $qb; - } - - /** - * Apply filters for Query builder. - * - * @param QueryBuilder $queryBuilder - * @param array $filters - */ - private function applyFilters(QueryBuilder $queryBuilder, array $filters) - { - $allowedFilters = [ - 'id_employee', - 'firstname', - 'lastname', - 'email', - 'profile', - 'active', - ]; - - foreach ($filters as $filterName => $filterValue) { - if (!in_array($filterName, $allowedFilters)) { - continue; - } - - if ('id_employee' === $filterName) { - $queryBuilder->andWhere('e.id_employee = :' . $filterName); - $queryBuilder->setParameter($filterName, $filterValue); - - continue; - } - - if ('profile' === $filterName) { - $queryBuilder->andWhere('pl.id_profile = :id_profile'); - $queryBuilder->setParameter('id_profile', $filterValue); - - continue; - } - - if ('active' === $filterName) { - $queryBuilder->andWhere('e.active = :active'); - $queryBuilder->setParameter('active', $filterValue); - - continue; - } - - $queryBuilder->andWhere("`$filterName` LIKE :$filterName"); - $queryBuilder->setParameter($filterName, '%' . $filterValue . '%'); - } - } - - /** - * @param SearchCriteriaInterface $searchCriteria - * @param QueryBuilder $queryBuilder - */ - private function applySorting(SearchCriteriaInterface $searchCriteria, QueryBuilder $queryBuilder) - { - if ($searchCriteria->getOrderBy() && $searchCriteria->getOrderWay()) { - $orderBy = $searchCriteria->getOrderBy(); - - if ('profile' === $orderBy) { - $orderBy = 'pl.name'; - } - - $queryBuilder->orderBy($orderBy, $searchCriteria->getOrderWay()); - } - } -} diff --git a/src/Core/Grid/Query/Filter/DoctrineFilterApplicator.php b/src/Core/Grid/Query/Filter/DoctrineFilterApplicator.php deleted file mode 100644 index 8cbd5daa..00000000 --- a/src/Core/Grid/Query/Filter/DoctrineFilterApplicator.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query\Filter; - -use Doctrine\DBAL\Query\QueryBuilder; - -final class DoctrineFilterApplicator implements DoctrineFilterApplicatorInterface -{ - /** - * {@inheritdoc} - */ - public function apply(QueryBuilder $qb, SqlFilters $filters, array $filterValues) - { - if (empty($filterValues)) { - return; - } - - foreach ($filters->getFilters() as $filter) { - $sqlField = $filter['sql_field']; - $filterName = $filter['filter_name']; - - if (!isset($filterValues[$filterName])) { - continue; - } - - $value = $filterValues[$filterName]; - - switch ($filter['comparison']) { - case SqlFilters::WHERE_STRICT: - $qb->andWhere("$sqlField = :$filterName"); - $qb->setParameter($filterName, $value); - - break; - case SqlFilters::WHERE_LIKE: - $qb->andWhere("$sqlField LIKE :$filterName"); - $qb->setParameter($filterName, '%' . $value . '%'); - - break; - case SqlFilters::HAVING_LIKE: - $qb->andHaving("$sqlField LIKE :$filterName"); - $qb->setParameter($filterName, '%' . $value . '%'); - - break; - case SqlFilters::WHERE_DATE: - if (isset($value['from'])) { - $name = sprintf('%s_from', $filterName); - - $qb->andWhere("$sqlField >= :$name"); - $qb->setParameter($name, sprintf('%s %s', $value['from'], '0:0:0')); - } - - if (isset($value['to'])) { - $name = sprintf('%s_to', $filterName); - - $qb->andWhere("$sqlField <= :$name"); - $qb->setParameter($name, sprintf('%s %s', $value['to'], '23:59:59')); - } - - break; - } - } - } -} diff --git a/src/Core/Grid/Query/Filter/DoctrineFilterApplicatorInterface.php b/src/Core/Grid/Query/Filter/DoctrineFilterApplicatorInterface.php deleted file mode 100644 index 65866a46..00000000 --- a/src/Core/Grid/Query/Filter/DoctrineFilterApplicatorInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query\Filter; - -use Doctrine\DBAL\Query\QueryBuilder; - -/** - * Interface for service that applies filters for Doctrine query builder - */ -interface DoctrineFilterApplicatorInterface -{ - /** - * @param QueryBuilder $qb - * @param SqlFilters $filters - * @param array $filterValues - */ - public function apply(QueryBuilder $qb, SqlFilters $filters, array $filterValues); -} diff --git a/src/Core/Grid/Query/Filter/SqlFilters.php b/src/Core/Grid/Query/Filter/SqlFilters.php deleted file mode 100644 index 01c5c6d6..00000000 --- a/src/Core/Grid/Query/Filter/SqlFilters.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query\Filter; - -/** - * Stores filters to be applied on SQL query - */ -final class SqlFilters -{ - const WHERE_STRICT = 1; - const WHERE_LIKE = 2; - const HAVING_LIKE = 3; - const WHERE_DATE = 4; - - /** @var array */ - private $filters = []; - - /** - * @param string $filterName - * @param string $sqlField - * @param int $comparison - * - * @return self - */ - public function addFilter($filterName, $sqlField, $comparison = self::WHERE_STRICT) - { - $this->filters[] = [ - 'filter_name' => $filterName, - 'sql_field' => $sqlField, - 'comparison' => $comparison, - ]; - - return $this; - } - - /** - * @return array - */ - public function getFilters() - { - return $this->filters; - } -} diff --git a/src/Core/Grid/Query/LanguageQueryBuilder.php b/src/Core/Grid/Query/LanguageQueryBuilder.php deleted file mode 100644 index bc45b2d1..00000000 --- a/src/Core/Grid/Query/LanguageQueryBuilder.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class LanguageQueryBuilder provides query builders for languages grid. - */ -final class LanguageQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - ) { - parent::__construct($connection, $dbPrefix); - - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $builder = $this->getLanguageQueryBuilder($searchCriteria) - ->select('l.*'); - - $this->searchCriteriaApplicator - ->applySorting($searchCriteria, $builder) - ->applyPagination($searchCriteria, $builder); - - return $builder; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - return $this->getLanguageQueryBuilder($searchCriteria)->select('COUNT(id_lang)'); - } - - /** - * @param SearchCriteriaInterface $searchCriteria - * - * @return QueryBuilder - */ - private function getLanguageQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $builder = $this->connection->createQueryBuilder() - ->from($this->dbPrefix . 'lang', 'l'); - - $this->applyFilters($builder, $searchCriteria); - - return $builder; - } - - /** - * @param QueryBuilder $builder - * @param SearchCriteriaInterface $searchCriteria - */ - private function applyFilters(QueryBuilder $builder, SearchCriteriaInterface $searchCriteria) - { - $allowedFilters = [ - 'id_lang', - 'name', - 'iso_code', - 'language_code', - 'date_format_lite', - 'date_format_full', - 'active', - ]; - - foreach ($searchCriteria->getFilters() as $filterName => $filterValue) { - if (!in_array($filterName, $allowedFilters)) { - continue; - } - - if (in_array($filterName, ['id_lang', 'active'])) { - $builder->andWhere($filterName . ' = :' . $filterName); - $builder->setParameter($filterName, $filterValue); - - continue; - } - - $builder->andWhere($filterName . ' LIKE :' . $filterName); - $builder->setParameter($filterName, '%' . $filterValue . '%'); - } - } -} diff --git a/src/Core/Grid/Query/ManufacturerAddressQueryBuilder.php b/src/Core/Grid/Query/ManufacturerAddressQueryBuilder.php deleted file mode 100644 index 3ad95568..00000000 --- a/src/Core/Grid/Query/ManufacturerAddressQueryBuilder.php +++ /dev/null @@ -1,164 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class ManufacturerAddressQueryBuilder is responsible for building queries for manufacturers addresses grid data. - */ -final class ManufacturerAddressQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @var int - */ - private $contextLangId; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param int $contextLangId - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - $contextLangId - ) { - parent::__construct($connection, $dbPrefix); - - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->contextLangId = $contextLangId; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilderByFilters($searchCriteria->getFilters()); - $qb->select('a.id_address, m.name, a.firstname, a.lastname, a.postcode, a.city, cl.name as country'); - - $this->searchCriteriaApplicator - ->applySorting($searchCriteria, $qb) - ->applyPagination($searchCriteria, $qb) - ; - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilderByFilters($searchCriteria->getFilters()); - $qb->select('COUNT(DISTINCT a.`id_address`)'); - - return $qb; - } - - /** - * Gets query builder with common sql needed for manufacturer addresses grid. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilderByFilters(array $filters) - { - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'address', 'a') - ->leftJoin( - 'a', - $this->dbPrefix . 'country_lang', - 'cl', - 'cl.id_country = a.id_country AND cl.id_lang = :lang' - ) - ->setParameter('lang', $this->contextLangId) - ->leftJoin( - 'a', - $this->dbPrefix . 'manufacturer', - 'm', 'm.id_manufacturer = a.id_manufacturer' - ) - ->andWhere('a.id_customer = 0') - ->andWhere('a.id_supplier = 0') - ->andWhere('a.id_warehouse = 0') - ->andWhere('a.deleted = 0') - ; - $this->applyFilters($qb, $filters); - - return $qb; - } - - /** - * @param QueryBuilder $qb - * @param array $filters - */ - private function applyFilters(QueryBuilder $qb, array $filters) - { - $allowedFiltersMap = [ - 'id_address' => 'a.id_address', - 'name' => 'm.name', - 'firstname' => 'a.firstname', - 'lastname' => 'a.lastname', - 'postcode' => 'a.postcode', - 'city' => 'a.city', - 'country' => 'a.id_country', - ]; - $exactMatchingFilters = ['id_address', 'country']; - - foreach ($filters as $filterName => $value) { - if (!array_key_exists($filterName, $allowedFiltersMap)) { - continue; - } - - if (in_array($filterName, $exactMatchingFilters, true)) { - if (empty($value)) { - continue; - } - - $qb->andWhere($allowedFiltersMap[$filterName] . " = :$filterName") - ->setParameter($filterName, $value); - - continue; - } - - $qb->andWhere($allowedFiltersMap[$filterName] . " LIKE :$filterName") - ->setParameter($filterName, '%' . $value . '%'); - } - } -} diff --git a/src/Core/Grid/Query/ManufacturerQueryBuilder.php b/src/Core/Grid/Query/ManufacturerQueryBuilder.php deleted file mode 100644 index a08bf9b8..00000000 --- a/src/Core/Grid/Query/ManufacturerQueryBuilder.php +++ /dev/null @@ -1,153 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class ManufacturerQueryBuilder is responsible for building queries for manufacturers grid data. - */ -final class ManufacturerQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - /** - * @var int[] - */ - private $contextShopIds; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param array $contextShopIds - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - array $contextShopIds - ) { - parent::__construct($connection, $dbPrefix); - - $this->contextShopIds = $contextShopIds; - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $addressesQb = $this->connection->createQueryBuilder(); - $addressesQb->select('COUNT(a.`id_manufacturer`) AS `addresses_count`') - ->from($this->dbPrefix . 'address', 'a') - ->where('m.`id_manufacturer` = a.`id_manufacturer`') - ->andWhere('a.`deleted` = 0') - ->groupBy('a.`id_manufacturer`') - ; - - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - $qb - ->select('m.`id_manufacturer`, m.`name`, m.`active`') - ->addSelect('COUNT(p.`id_product`) AS `products_count`') - ->addSelect('(' . $addressesQb->getSQL() . ') AS addresses_count') - ->groupBy('m.`id_manufacturer`') - ; - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb) - ; - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - $qb->select('COUNT(DISTINCT m.`id_manufacturer`)'); - - return $qb; - } - - /** - * Get generic query builder. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters) - { - $allowedFilters = ['id_manufacturer', 'name', 'active']; - - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'manufacturer', 'm') - ->innerJoin( - 'm', - $this->dbPrefix . 'manufacturer_shop', - 'ms', - 'ms.`id_manufacturer` = m.`id_manufacturer`' - ) - ->leftJoin( - 'm', - $this->dbPrefix . 'product', - 'p', - 'm.`id_manufacturer` = p.`id_manufacturer`' - ) - ; - - foreach ($filters as $filterName => $value) { - if (!in_array($filterName, $allowedFilters, true)) { - continue; - } - - if ('name' === $filterName) { - $qb->andWhere('m.`name` LIKE :' . $filterName) - ->setParameter($filterName, '%' . $value . '%'); - continue; - } - $qb->andWhere('m.`' . $filterName . '` = :' . $filterName) - ->setParameter($filterName, $value); - } - - $qb->andWhere('ms.`id_shop` IN (:contextShopIds)'); - - $qb->setParameter('contextShopIds', $this->contextShopIds, Connection::PARAM_INT_ARRAY); - - return $qb; - } -} diff --git a/src/Core/Grid/Query/MerchandiseReturnQueryBuilder.php b/src/Core/Grid/Query/MerchandiseReturnQueryBuilder.php deleted file mode 100644 index b4b13d96..00000000 --- a/src/Core/Grid/Query/MerchandiseReturnQueryBuilder.php +++ /dev/null @@ -1,187 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class MerchandiseReturnQueryBuilder builds queries for merchandise returns grid data. - */ -final class MerchandiseReturnQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var int - */ - private $contextLanguageId; - - /** - * @var array - */ - private $contextShopIds; - - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @param Connection $connection - * @param $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param int $contextLanguageId - * @param array $contextShopIds - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - int $contextLanguageId, - array $contextShopIds - ) { - parent::__construct($connection, $dbPrefix); - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->contextLanguageId = $contextLanguageId; - $this->contextShopIds = $contextShopIds; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getMerchandiseReturnQueryBuilder($searchCriteria); - $qb - ->select('r.id_order_return, r.id_order, r.date_add, orsl.name status, ors.color') - ->groupBy('r.id_order_return'); - - $this->searchCriteriaApplicator - ->applySorting($searchCriteria, $qb) - ->applyPagination($searchCriteria, $qb); - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - return $this->getMerchandiseReturnQueryBuilder($searchCriteria) - ->select('COUNT(r.id_order_return)'); - } - - /** - * @param SearchCriteriaInterface $searchCriteria - * - * @return QueryBuilder - */ - private function getMerchandiseReturnQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $queryBuilder = $this->connection->createQueryBuilder() - ->from($this->dbPrefix . 'order_return', 'r') - ->leftJoin( - 'r', - $this->dbPrefix . 'order_return_state', - 'ors', - 'r.state = ors.id_order_return_state' - ) - ->leftJoin( - 'r', - $this->dbPrefix . 'order_return_state_lang', - 'orsl', - 'orsl.id_order_return_state = r.state AND orsl.id_lang = :context_language_id' - ) - ->setParameter('context_language_id', $this->contextLanguageId) - ->leftJoin( - 'r', - $this->dbPrefix . 'orders', - 'o', - 'o.id_order = r.id_order' - ) - ->andWhere('o.id_shop IN (:context_shop_ids)') - ->setParameter('context_shop_ids', $this->contextShopIds, Connection::PARAM_INT_ARRAY); - - $this->applyFilters($searchCriteria->getFilters(), $queryBuilder); - - return $queryBuilder; - } - - /** - * Apply filters to merchandise returns query builder. - * - * @param array $filters - * @param QueryBuilder $qb - */ - private function applyFilters(array $filters, QueryBuilder $qb) - { - $allowedFilters = [ - 'id_order_return', - 'id_order', - 'status', - 'date_add', - ]; - - foreach ($filters as $filterName => $filterValue) { - if (!in_array($filterName, $allowedFilters)) { - continue; - } - - if ('id_order' === $filterName) { - $qb->andWhere('o.`' . $filterName . '` LIKE :' . $filterName); - $qb->setParameter($filterName, '%' . $filterValue . '%'); - - continue; - } - - if ('status' === $filterName) { - $qb->andWhere('orsl.`name` LIKE :' . $filterName); - $qb->setParameter($filterName, '%' . $filterValue . '%'); - - continue; - } - - if ('date_add' === $filterName) { - if (isset($filterValue['from'])) { - $qb->andWhere('r.date_add >= :date_from'); - $qb->setParameter('date_from', sprintf('%s 0:0:0', $filterValue['from'])); - } - - if (isset($filterValue['to'])) { - $qb->andWhere('r.date_add <= :date_to'); - $qb->setParameter('date_to', sprintf('%s 23:59:59', $filterValue['to'])); - } - - continue; - } - - $qb->andWhere('`' . $filterName . '` LIKE :' . $filterName); - $qb->setParameter($filterName, '%' . $filterValue . '%'); - } - } -} diff --git a/src/Core/Grid/Query/MetaQueryBuilder.php b/src/Core/Grid/Query/MetaQueryBuilder.php deleted file mode 100644 index 4d1424a2..00000000 --- a/src/Core/Grid/Query/MetaQueryBuilder.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class MetaQueryBuilder is responsible for providing data for seo & urls list. - */ -final class MetaQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var int - */ - private $contextIdLang; - - /** - * @var int - */ - private $contextIdShop; - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * MetaQueryBuilder constructor. - * - * @param Connection $connection - * @param $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param int $contextIdLang - * @param int $contextIdShop - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - $contextIdLang, - $contextIdShop - ) { - parent::__construct($connection, $dbPrefix); - $this->contextIdLang = $contextIdLang; - $this->contextIdShop = $contextIdShop; - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - $qb->select('m.`id_meta`, m.`page`, l.`title`, l.`url_rewrite`'); - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb); - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - $qb->select('COUNT(m.`id_meta`)'); - - return $qb; - } - - /** - * Gets query builder with common sql for meta table. - * - * @param array $filters - * - * @return \Doctrine\DBAL\Query\QueryBuilder - */ - private function getQueryBuilder(array $filters) - { - $availableFilters = [ - 'id_meta', - 'page', - 'title', - 'url_rewrite', - ]; - - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'meta', 'm') - ->innerJoin( - 'm', - $this->dbPrefix . 'meta_lang', - 'l', - 'm.`id_meta` = l.`id_meta`' - ); - - $qb->andWhere('l.`id_lang` = :id_lang'); - $qb->andWhere('l.`id_shop` = :id_shop'); - - $qb->setParameters([ - 'id_lang' => $this->contextIdLang, - 'id_shop' => $this->contextIdShop, - ]); - - $qb->andWhere('m.`configurable`=1'); - - foreach ($filters as $name => $value) { - if (!in_array($name, $availableFilters, true)) { - continue; - } - - if ('id_meta' === $name) { - $qb->andWhere('m.`id_meta` = :' . $name); - $qb->setParameter($name, $value); - - continue; - } - - if ('page' === $name) { - $qb->andWhere('m.`page` LIKE :' . $name); - $qb->setParameter($name, '%' . $value . '%'); - - continue; - } - - $qb->andWhere('l.`' . $name . '` LIKE :' . $name); - $qb->setParameter($name, '%' . $value . '%'); - } - - return $qb; - } -} diff --git a/src/Core/Grid/Query/Monitoring/AbstractProductQueryBuilder.php b/src/Core/Grid/Query/Monitoring/AbstractProductQueryBuilder.php deleted file mode 100644 index a536c664..00000000 --- a/src/Core/Grid/Query/Monitoring/AbstractProductQueryBuilder.php +++ /dev/null @@ -1,179 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query\Monitoring; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Query\AbstractDoctrineQueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Query\DoctrineSearchCriteriaApplicator; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use PrestaShop\PrestaShop\Core\Multistore\MultistoreContextCheckerInterface; - -/** - * Provides reusable queries for lists of monitoring products - */ -abstract class AbstractProductQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var Connection - */ - protected $connection; - - /** - * @var string - */ - protected $dbPrefix; - - /** - * @var int - */ - protected $contextLangId; - - /** - * @var int - */ - protected $contextShopId; - - /** - * @var DoctrineSearchCriteriaApplicator - */ - protected $searchCriteriaApplicator; - - /** - * @var MultistoreContextCheckerInterface - */ - protected $multistoreContextChecker; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicator $searchCriteriaApplicator - * @param int $contextLangId - * @param int $contextShopId - * @param MultistoreContextCheckerInterface $multistoreContextChecker - */ - public function __construct( - Connection $connection, - $dbPrefix, - $contextLangId, - $contextShopId, - DoctrineSearchCriteriaApplicator $searchCriteriaApplicator, - MultistoreContextCheckerInterface $multistoreContextChecker - ) { - parent::__construct($connection, $dbPrefix); - $this->contextLangId = $contextLangId; - $this->contextShopId = $contextShopId; - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->multistoreContextChecker = $multistoreContextChecker; - } - - /** - * Provides commonly reusable query for monitoring products lists - * - * @param SearchCriteriaInterface $searchCriteria - * - * @return QueryBuilder - */ - protected function getProductsCommonQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $isSingleShopContext = $this->multistoreContextChecker->isSingleShopContext(); - - $qb = $this->connection - ->createQueryBuilder() - ->select(['p.id_product', 'p.reference', 'p.active', 'pl.name']) - ->from($this->dbPrefix . 'product', 'p') - ->setParameter('context_lang_id', $this->contextLangId) - ->setParameter('context_shop_id', $this->contextShopId); - - $qb->leftJoin( - 'p', - $this->dbPrefix . 'product_lang', - 'pl', - $isSingleShopContext ? - 'p.id_product = pl.id_product AND pl.id_lang = :context_lang_id AND pl.id_shop = :context_shop_id' : - 'p.id_product = pl.id_product AND pl.id_lang = :context_lang_id AND pl.id_shop = p.id_shop_default' - ); - - $qb->leftJoin( - 'p', - $this->dbPrefix . 'product_shop', - 'ps', - $isSingleShopContext ? - 'p.id_product = ps.id_product AND ps.id_shop = :context_shop_id' : - 'p.id_product = ps.id_product AND ps.id_shop = p.id_shop_default' - ); - - if ($isSingleShopContext) { - $qb->andWhere('ps.id_shop = :context_shop_id'); - } - - $this->applyFilters($qb, $searchCriteria->getFilters()); - - return $qb; - } - - /** - * @param QueryBuilder $qb - * @param array $filters - */ - private function applyFilters(QueryBuilder $qb, array $filters) - { - $allowedFilters = ['id_product', 'reference', 'name', 'active']; - - foreach ($filters as $filterName => $filterValue) { - if (!in_array($filterName, $allowedFilters, true)) { - continue; - } - - if ('id_product' === $filterName) { - $qb->andWhere("p.id_product = :$filterName"); - $qb->setParameter($filterName, $filterValue); - - continue; - } - - if ('reference' === $filterName) { - $qb->andWhere("p.reference LIKE :$filterName"); - $qb->setParameter($filterName, '%' . $filterValue . '%'); - - continue; - } - - if ('name' === $filterName) { - $qb->andWhere("pl.name LIKE :$filterName"); - $qb->setParameter($filterName, '%' . $filterValue . '%'); - - continue; - } - - if ('active' === $filterName) { - $qb->andWhere("p.active = :$filterName"); - $qb->setParameter($filterName, $filterValue); - } - } - } -} diff --git a/src/Core/Grid/Query/Monitoring/DisabledProductQueryBuilder.php b/src/Core/Grid/Query/Monitoring/DisabledProductQueryBuilder.php deleted file mode 100644 index c9167f41..00000000 --- a/src/Core/Grid/Query/Monitoring/DisabledProductQueryBuilder.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query\Monitoring; - -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Builds query for disabled product list data - */ -final class DisabledProductQueryBuilder extends AbstractProductQueryBuilder -{ - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria); - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb); - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria); - $qb->select('COUNT(DISTINCT p.id_product)'); - - return $qb; - } - - /** - * Get generic query builder. - * - * @param SearchCriteriaInterface $searchCriteria - * - * @return QueryBuilder - */ - private function getQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getProductsCommonQueryBuilder($searchCriteria); - $qb->andWhere('ps.active = 0'); - - if ($this->multistoreContextChecker->isSingleShopContext()) { - $qb->andWhere('ps.id_shop = :context_shop_id') - ->setParameter('context_shop_id', $this->contextShopId); - } - - return $qb; - } -} diff --git a/src/Core/Grid/Query/Monitoring/EmptyCategoryQueryBuilder.php b/src/Core/Grid/Query/Monitoring/EmptyCategoryQueryBuilder.php deleted file mode 100644 index 2140e066..00000000 --- a/src/Core/Grid/Query/Monitoring/EmptyCategoryQueryBuilder.php +++ /dev/null @@ -1,199 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query\Monitoring; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Query\AbstractDoctrineQueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Query\DoctrineSearchCriteriaApplicator; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use PrestaShop\PrestaShop\Core\Multistore\MultistoreContextCheckerInterface; - -/** - * Builds queries for empty category list data - */ -final class EmptyCategoryQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var int - */ - private $contextLangId; - - /** - * @var int - */ - private $contextShopId; - - /** - * @var DoctrineSearchCriteriaApplicator - */ - private $searchCriteriaApplicator; - - /** - * @var MultistoreContextCheckerInterface - */ - private $multistoreContextChecker; - - /** - * @var int - */ - private $rootCategoryId; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicator $searchCriteriaApplicator - * @param int $contextLangId - * @param int $contextShopId - * @param MultistoreContextCheckerInterface $multistoreContextChecker - * @param $rootCategoryId - */ - public function __construct( - Connection $connection, - $dbPrefix, - $contextLangId, - $contextShopId, - DoctrineSearchCriteriaApplicator $searchCriteriaApplicator, - MultistoreContextCheckerInterface $multistoreContextChecker, - $rootCategoryId - ) { - parent::__construct($connection, $dbPrefix); - $this->contextLangId = $contextLangId; - $this->contextShopId = $contextShopId; - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->multistoreContextChecker = $multistoreContextChecker; - $this->rootCategoryId = $rootCategoryId; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - $qb->select('c.id_category, c.active, cl.name, cl.description'); - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb); - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - $qb->select('COUNT(c.id_category)'); - - return $qb; - } - - /** - * Get generic query builder. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters) - { - $isSingleShopContext = $this->multistoreContextChecker->isSingleShopContext(); - - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'category', 'c') - ->setParameter('context_lang_id', $this->contextLangId) - ->setParameter('context_shop_id', $this->contextShopId) - ->setParameter('root_category_id', $this->rootCategoryId); - - $qb->leftJoin( - 'c', - $this->dbPrefix . 'category_lang', - 'cl', - $isSingleShopContext ? - 'c.id_category = cl.id_category AND cl.id_lang = :context_lang_id AND cl.id_shop = :context_shop_id' : - 'c.id_category = cl.id_category AND cl.id_lang = :context_lang_id AND cl.id_shop = c.id_shop_default' - ); - - $qb->leftJoin( - 'c', - $this->dbPrefix . 'category_shop', - 'cs', - $isSingleShopContext ? - 'c.id_category = cs.id_category AND cs.id_shop = :context_shop_id' : - 'c.id_category = cs.id_category AND cs.id_shop = c.id_shop_default' - ); - - $qb->leftJoin( - 'c', - $this->dbPrefix . 'category_product', - 'cp', - 'c.`id_category` = cp.id_category' - ); - - $subSelect = $this->connection->createQueryBuilder() - ->select('1') - ->from($this->dbPrefix . 'category_product', 'cp') - ->andWhere('c.id_category = cp.id_category') - ; - - $qb->andWhere('NOT EXISTS(' . $subSelect->getSQL() . ')'); - $qb->andWhere('c.id_category != :root_category_id'); - - if ($isSingleShopContext) { - $qb->andWhere('cs.id_shop = :context_shop_id'); - } - - $allowedFiltersAliasMap = [ - 'id_category' => 'c.id_category', - 'active' => 'c.active', - 'name' => 'cl.name', - 'description' => 'cl.description', - ]; - - foreach ($filters as $filterName => $filterValue) { - if (!array_key_exists($filterName, $allowedFiltersAliasMap)) { - continue; - } - - if ('active' === $filterName || 'id_category' === $filterName) { - $qb->andWhere($allowedFiltersAliasMap[$filterName] . " = :$filterName"); - $qb->setParameter($filterName, $filterValue); - - continue; - } - - $qb->andWhere($allowedFiltersAliasMap[$filterName] . " LIKE :$filterName"); - $qb->setParameter($filterName, '%' . $filterValue . '%'); - } - - return $qb; - } -} diff --git a/src/Core/Grid/Query/Monitoring/NoQtyProductWithCombinationQueryBuilder.php b/src/Core/Grid/Query/Monitoring/NoQtyProductWithCombinationQueryBuilder.php deleted file mode 100644 index 67332ad2..00000000 --- a/src/Core/Grid/Query/Monitoring/NoQtyProductWithCombinationQueryBuilder.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query\Monitoring; - -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Builds query for product with combination but without quantities list data - */ -final class NoQtyProductWithCombinationQueryBuilder extends AbstractProductQueryBuilder -{ - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria); - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb); - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria); - $qb->select('COUNT(DISTINCT p.id_product)'); - - return $qb; - } - - /** - * Gets generic query builder - * - * @param SearchCriteriaInterface $searchCriteria - * - * @return QueryBuilder - */ - private function getQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getProductsCommonQueryBuilder($searchCriteria); - - $attrSubQuery = $this->connection->createQueryBuilder() - ->select(1) - ->from($this->dbPrefix . 'product_attribute', 'pa') - ->andWhere('pa.id_product = p.id_product'); - - $subQuery = $this->connection->createQueryBuilder()->select(1); - $subQuery - ->from($this->dbPrefix . 'stock_available', 'stock') - ->andWhere('p.id_product = stock.id_product') - ->andWhere('EXISTS(' . $attrSubQuery->getSQL() . ')') - ->andWhere('IFNULL(stock.quantity, 0) <= 0'); - - if ($this->multistoreContextChecker->isSingleShopContext()) { - $attrSubQuery->andWhere('stock.id_shop = :context_shop_id') - ->setParameter('context_shop_id', $this->contextShopId); - } - - $qb->andWhere('EXISTS(' . $subQuery->getSQL() . ')'); - - return $qb; - } -} diff --git a/src/Core/Grid/Query/Monitoring/NoQtyProductWithoutCombinationQueryBuilder.php b/src/Core/Grid/Query/Monitoring/NoQtyProductWithoutCombinationQueryBuilder.php deleted file mode 100644 index 97862cd2..00000000 --- a/src/Core/Grid/Query/Monitoring/NoQtyProductWithoutCombinationQueryBuilder.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query\Monitoring; - -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Builds query for product without combination and without quantities list data - */ -final class NoQtyProductWithoutCombinationQueryBuilder extends AbstractProductQueryBuilder -{ - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria); - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb); - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria); - $qb->select('COUNT(DISTINCT p.id_product)'); - - return $qb; - } - - /** - * Get generic query builder. - * - * @param SearchCriteriaInterface $searchCriteria - * - * @return QueryBuilder - */ - private function getQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getProductsCommonQueryBuilder($searchCriteria); - - $attrSubQuery = $this->connection->createQueryBuilder() - ->select(1) - ->from($this->dbPrefix . 'product_attribute', 'pa') - ->andWhere('pa.id_product = p.id_product'); - - $subQuery = $this->connection->createQueryBuilder(); - $subQuery->select(1) - ->from($this->dbPrefix . 'stock_available', 'stock') - ->andWhere('p.id_product = stock.id_product') - ->andWhere('NOT EXISTS(' . $attrSubQuery->getSQL() . ')') - ->andWhere('IFNULL(stock.quantity, 0) <= 0'); - - if ($this->multistoreContextChecker->isSingleShopContext()) { - $subQuery->andWhere('stock.id_shop = :context_shop_id') - ->setParameter('context_shop_id', $this->contextShopId); - } - - $qb->andWhere('EXISTS(' . $subQuery->getSQL() . ')'); - - return $qb; - } -} diff --git a/src/Core/Grid/Query/Monitoring/ProductWithoutDescriptionQueryBuilder.php b/src/Core/Grid/Query/Monitoring/ProductWithoutDescriptionQueryBuilder.php deleted file mode 100644 index 38866b55..00000000 --- a/src/Core/Grid/Query/Monitoring/ProductWithoutDescriptionQueryBuilder.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query\Monitoring; - -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Builds query for product without description list data - */ -final class ProductWithoutDescriptionQueryBuilder extends AbstractProductQueryBuilder -{ - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria); - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb); - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria); - $qb->select('COUNT(DISTINCT p.id_product)'); - - return $qb; - } - - /** - * Get generic query builder. - * - * @param SearchCriteriaInterface $searchCriteria - * - * @return QueryBuilder - */ - private function getQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getProductsCommonQueryBuilder($searchCriteria); - $qb->andWhere('pl.description IS NULL OR pl.description = ""') - ->andWhere('pl.description_short IS NULL OR pl.description_short = ""'); - - return $qb; - } -} diff --git a/src/Core/Grid/Query/Monitoring/ProductWithoutImageQueryBuilder.php b/src/Core/Grid/Query/Monitoring/ProductWithoutImageQueryBuilder.php deleted file mode 100644 index 4741053a..00000000 --- a/src/Core/Grid/Query/Monitoring/ProductWithoutImageQueryBuilder.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query\Monitoring; - -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Builds query for product without image list data - */ -final class ProductWithoutImageQueryBuilder extends AbstractProductQueryBuilder -{ - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria); - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb); - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria); - $qb->select('COUNT(DISTINCT p.id_product)'); - - return $qb; - } - - /** - * Get generic query builder. - * - * @param SearchCriteriaInterface $searchCriteria - * - * @return QueryBuilder - */ - private function getQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getProductsCommonQueryBuilder($searchCriteria); - - $imageSubQuery = $this->connection->createQueryBuilder() - ->select(1) - ->from($this->dbPrefix . 'image_shop', 'img') - ->andWhere('p.id_product = img.id_product'); - - if ($this->multistoreContextChecker->isSingleShopContext()) { - $imageSubQuery->andWhere('img.id_shop = :context_shop_id'); - } else { - $imageSubQuery->andWhere('img.id_shop = p.id_shop_default'); - } - - $qb->andWhere('NOT EXISTS(' . $imageSubQuery->getSQL() . ')'); - - return $qb; - } -} diff --git a/src/Core/Grid/Query/Monitoring/ProductWithoutPriceQueryBuilder.php b/src/Core/Grid/Query/Monitoring/ProductWithoutPriceQueryBuilder.php deleted file mode 100644 index bdffb500..00000000 --- a/src/Core/Grid/Query/Monitoring/ProductWithoutPriceQueryBuilder.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query\Monitoring; - -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Builds query for product without price list data - */ -final class ProductWithoutPriceQueryBuilder extends AbstractProductQueryBuilder -{ - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria); - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb); - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria); - $qb->select('COUNT(DISTINCT p.id_product)'); - - return $qb; - } - - /** - * Get generic query builder. - * - * @param SearchCriteriaInterface $searchCriteria - * - * @return QueryBuilder - */ - private function getQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getProductsCommonQueryBuilder($searchCriteria); - - $specPriceSubQuery = $this->connection->createQueryBuilder() - ->select(1) - ->from($this->dbPrefix . 'specific_price', 'sp') - ->andWhere('p.id_product = sp.id_product'); - - if ($this->multistoreContextChecker->isSingleShopContext()) { - $specPriceSubQuery->andWhere('sp.id_shop = :context_shop_id') - ->setParameter('context_shop_id', $this->contextShopId); - } - - $qb->andWhere('p.price = 0') - ->andWhere('p.wholesale_price = 0') - ->andWhere('NOT EXISTS(' . $specPriceSubQuery->getSQL() . ')'); - - return $qb; - } -} diff --git a/src/Core/Grid/Query/OrderMessageQueryBuilder.php b/src/Core/Grid/Query/OrderMessageQueryBuilder.php deleted file mode 100644 index bc3a342d..00000000 --- a/src/Core/Grid/Query/OrderMessageQueryBuilder.php +++ /dev/null @@ -1,143 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Query\Filter\DoctrineFilterApplicatorInterface; -use PrestaShop\PrestaShop\Core\Grid\Query\Filter\SqlFilters; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Builds search & count queries for Order message grid - */ -final class OrderMessageQueryBuilder implements DoctrineQueryBuilderInterface -{ - /** - * @var Connection - */ - private $connection; - - /** - * @var string - */ - private $dbPrefix; - - /** - * @var int - */ - private $contextLanguageId; - - /** - * @var DoctrineFilterApplicatorInterface - */ - private $doctrineFilterApplicator; - - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $doctrineSearchCriteriaApplicator; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param int $contextLanguageId - * @param DoctrineFilterApplicatorInterface $doctrineFilterApplicator - * @param DoctrineSearchCriteriaApplicatorInterface $doctrineSearchCriteriaApplicator - */ - public function __construct( - Connection $connection, - string $dbPrefix, - int $contextLanguageId, - DoctrineFilterApplicatorInterface $doctrineFilterApplicator, - DoctrineSearchCriteriaApplicatorInterface $doctrineSearchCriteriaApplicator - ) { - $this->connection = $connection; - $this->dbPrefix = $dbPrefix; - $this->contextLanguageId = $contextLanguageId; - $this->doctrineFilterApplicator = $doctrineFilterApplicator; - $this->doctrineSearchCriteriaApplicator = $doctrineSearchCriteriaApplicator; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->buildBaseQuery($searchCriteria); - $qb->select('om.id_order_message, oml.name, oml.message'); - - $this->doctrineSearchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb) - ; - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->buildBaseQuery($searchCriteria); - $qb->select('COUNT(om.id_order_message)'); - - return $qb; - } - - /** - * @param SearchCriteriaInterface $criteria - * - * @return QueryBuilder - */ - private function buildBaseQuery(SearchCriteriaInterface $criteria): QueryBuilder - { - $qb = $this->connection->createQueryBuilder(); - - $qb - ->from($this->dbPrefix . 'order_message', 'om') - ->leftJoin( - 'om', - $this->dbPrefix . 'order_message_lang', - 'oml', - 'oml.id_order_message = om.id_order_message AND oml.id_lang = :context_lang_id' - ) - ->setParameter('context_lang_id', $this->contextLanguageId) - ; - - $sqlFilters = (new SqlFilters()) - ->addFilter('id_order_message', 'om.id_order_message', SqlFilters::WHERE_LIKE) - ->addFilter('name', 'oml.name', SqlFilters::WHERE_LIKE) - ->addFilter('message', 'oml.message', SqlFilters::WHERE_LIKE) - ; - - $this->doctrineFilterApplicator->apply($qb, $sqlFilters, $criteria->getFilters()); - - return $qb; - } -} diff --git a/src/Core/Grid/Query/OrderQueryBuilder.php b/src/Core/Grid/Query/OrderQueryBuilder.php deleted file mode 100644 index c273fd75..00000000 --- a/src/Core/Grid/Query/OrderQueryBuilder.php +++ /dev/null @@ -1,316 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PDO; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Builds SQL queries using Doctrine for retrieving data for orders grid - */ -final class OrderQueryBuilder implements DoctrineQueryBuilderInterface -{ - /** - * @var Connection - */ - protected $connection; - - /** - * @var string - */ - protected $dbPrefix; - - /** - * @var int - */ - private $contextLangId; - - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $criteriaApplicator; - /** - * @var array - */ - private $contextShopIds; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $criteriaApplicator - * @param int $contextLangId - * @param int[] $contextShopIds - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $criteriaApplicator, - $contextLangId, - array $contextShopIds - ) { - $this->connection = $connection; - $this->dbPrefix = $dbPrefix; - $this->contextLangId = $contextLangId; - $this->criteriaApplicator = $criteriaApplicator; - $this->contextShopIds = $contextShopIds; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this - ->getBaseQueryBuilder($searchCriteria->getFilters()) - ->addSelect($this->getCustomerField() . ' AS `customer`') - ->addSelect('o.id_order, o.reference, o.total_paid_tax_incl, os.paid, osl.name AS osname') - ->addSelect('o.id_currency, cur.iso_code') - ->addSelect('o.current_state, o.id_customer') - ->addSelect('cu.`id_customer` IS NULL as `deleted_customer`') - ->addSelect('os.color, o.payment, s.name AS shop_name') - ->addSelect('o.date_add, cu.company, cl.name AS country_name, o.invoice_number, o.delivery_number') - ; - - $this->addNewCustomerField($qb); - - $this->applySorting($qb, $searchCriteria); - - $qb = $this->applyNewCustomerFilter($qb, $searchCriteria->getFilters()); - - $this->criteriaApplicator - ->applyPagination($searchCriteria, $qb) - ; - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getBaseQueryBuilder($searchCriteria->getFilters()); - if (isset($searchCriteria->getFilters()['new'])) { - $this->addNewCustomerField($qb->addSelect('o.id_order as o_id_order')); - $qb = $this->applyNewCustomerFilter($qb, $searchCriteria->getFilters()); - $qb->select('count(o_id_order)'); - } else { - $qb->select('count(o.id_order)'); - } - - return $qb; - } - - /** - * @param array $filters - * - * @return QueryBuilder - */ - private function getBaseQueryBuilder(array $filters) - { - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'orders', 'o') - ->leftJoin('o', $this->dbPrefix . 'customer', 'cu', 'o.id_customer = cu.id_customer') - ->leftJoin('o', $this->dbPrefix . 'currency', 'cur', 'o.id_currency = cur.id_currency') - ->innerJoin('o', $this->dbPrefix . 'address', 'a', 'o.id_address_delivery = a.id_address') - ->innerJoin('a', $this->dbPrefix . 'country', 'c', 'a.id_country = c.id_country') - ->innerJoin( - 'c', - $this->dbPrefix . 'country_lang', - 'cl', - 'c.id_country = cl.id_country AND cl.id_lang = :context_lang_id' - ) - ->leftJoin('o', $this->dbPrefix . 'order_state', 'os', 'o.current_state = os.id_order_state') - ->leftJoin( - 'os', - $this->dbPrefix . 'order_state_lang', - 'osl', - 'os.id_order_state = osl.id_order_state AND osl.id_lang = :context_lang_id' - ) - ->leftJoin('o', $this->dbPrefix . 'shop', 's', 'o.id_shop = s.id_shop') - ->andWhere('o.`id_shop` IN (:context_shop_ids)') - ->setParameter('context_lang_id', $this->contextLangId, PDO::PARAM_INT) - ->setParameter('context_shop_ids', $this->contextShopIds, Connection::PARAM_INT_ARRAY) - ; - - $strictComparisonFilters = [ - 'id_order' => 'o.id_order', - 'country_name' => 'c.id_country', - 'total_paid_tax_incl' => 'o.total_paid_tax_incl', - 'osname' => 'os.id_order_state', - ]; - - $likeComparisonFilters = [ - 'reference' => 'o.`reference`', - 'company' => 'cu.`company`', - 'payment' => 'o.`payment`', - 'customer' => $this->getCustomerField(), - ]; - - $havingLikeComparisonFilters = []; - - $dateComparisonFilters = [ - 'date_add' => 'o.`date_add`', - ]; - - foreach ($filters as $filterName => $filterValue) { - if (isset($strictComparisonFilters[$filterName])) { - $alias = $strictComparisonFilters[$filterName]; - - $qb->andWhere("$alias = :$filterName"); - $qb->setParameter($filterName, $filterValue); - - continue; - } - - if (isset($likeComparisonFilters[$filterName])) { - $alias = $likeComparisonFilters[$filterName]; - - $qb->andWhere("$alias LIKE :$filterName"); - $qb->setParameter($filterName, '%' . $filterValue . '%'); - - continue; - } - - if (isset($havingLikeComparisonFilters[$filterName])) { - $alias = $havingLikeComparisonFilters[$filterName]; - - $qb->andHaving("$alias LIKE :$filterName"); - $qb->setParameter($filterName, '%' . $filterValue . '%'); - - continue; - } - - if (isset($dateComparisonFilters[$filterName])) { - $alias = $dateComparisonFilters[$filterName]; - - if (isset($filterValue['from'])) { - $name = sprintf('%s_from', $filterName); - - $qb->andWhere("$alias >= :$name"); - $qb->setParameter($name, sprintf('%s %s', $filterValue['from'], '0:0:0')); - } - - if (isset($filterValue['to'])) { - $name = sprintf('%s_to', $filterName); - - $qb->andWhere("$alias <= :$name"); - $qb->setParameter($name, sprintf('%s %s', $filterValue['to'], '23:59:59')); - } - - continue; - } - } - - return $qb; - } - - /** - * @param QueryBuilder $qb - */ - private function addNewCustomerField(QueryBuilder $qb) - { - $newCustomerSubSelect = $this->connection - ->createQueryBuilder() - ->select('so.id_order') - ->from($this->dbPrefix . 'orders', 'so') - ->where('so.id_customer = o.id_customer') - ->andWhere('so.id_order < o.id_order') - ->setMaxResults(1) - ; - - $qb->addSelect('IF ((' . $newCustomerSubSelect->getSQL() . ') > 0, 0, 1) AS new'); - } - - /** - * @return string - */ - private function getCustomerField() - { - return 'CONCAT(LEFT(cu.`firstname`, 1), \'. \', cu.`lastname`)'; - } - - /** - * @param QueryBuilder $qb - * @param array $filters - * - * @return QueryBuilder - */ - private function applyNewCustomerFilter(QueryBuilder $qb, array $filters) - { - if (!isset($filters['new'])) { - return $qb; - } - - $builder = $this->connection - ->createQueryBuilder() - ->select('*') - ->from('(' . $qb->getSQL() . ') tmp_table') - ->andWhere('new = :new') - ->setParameter('new', $filters['new']) - ; - - foreach ($qb->getParameters() as $name => $previousParam) { - $builder->setParameter( - $name, - $previousParam, - is_array($previousParam) ? Connection::PARAM_INT_ARRAY : null - ); - } - - return $builder; - } - - /** - * @param QueryBuilder $qb - * @param SearchCriteriaInterface $criteria - */ - private function applySorting(QueryBuilder $qb, SearchCriteriaInterface $criteria) - { - $sortableFields = [ - 'id_order' => 'o.id_order', - 'country_name' => 'c.id_country', - 'total_paid_tax_incl' => 'o.total_paid_tax_incl', - 'reference' => 'o.`reference`', - 'company' => 'cu.`company`', - 'payment' => 'o.`payment`', - 'customer' => 'customer', - 'osname' => 'osl.name', - 'date_add' => 'o.`date_add`', - ]; - - if (isset($sortableFields[$criteria->getOrderBy()])) { - $qb->orderBy( - $sortableFields[$criteria->getOrderBy()], - $criteria->getOrderWay() - ); - } - } -} diff --git a/src/Core/Grid/Query/ProfileQueryBuilder.php b/src/Core/Grid/Query/ProfileQueryBuilder.php deleted file mode 100644 index fe853bca..00000000 --- a/src/Core/Grid/Query/ProfileQueryBuilder.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class ProfilesQueryBuilder is responsible for building queries for profiles grid data. - */ -final class ProfileQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @var int - */ - private $languageId; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param $contextLanguageId - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - $contextLanguageId - ) { - parent::__construct($connection, $dbPrefix); - - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->languageId = $contextLanguageId; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()) - ->select('p.id_profile, pl.name') - ; - - $this->searchCriteriaApplicator - ->applySorting($searchCriteria, $qb) - ->applyPagination($searchCriteria, $qb); - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()) - ->select('COUNT(p.id_profile)') - ; - - return $qb; - } - - /** - * Get generic query builder. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters) - { - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'profile', 'p') - ->innerJoin('p', $this->dbPrefix . 'profile_lang', 'pl', 'p.id_profile = pl.id_profile') - ->andWhere('pl.id_lang = :language') - ->setParameter('language', $this->languageId) - ; - - $allowedFilters = [ - 'id_profile', - 'name', - ]; - - foreach ($filters as $name => $value) { - if (!in_array($name, $allowedFilters, true)) { - continue; - } - - if ('id_profile' === $name) { - $qb->andWhere("p.id_profile = :$name"); - $qb->setParameter($name, $value); - - continue; - } - - $qb->andWhere("$name LIKE :$name"); - $qb->setParameter($name, '%' . $value . '%'); - } - - return $qb; - } -} diff --git a/src/Core/Grid/Query/QueryParserInterface.php b/src/Core/Grid/Query/QueryParserInterface.php deleted file mode 100644 index a2de7333..00000000 --- a/src/Core/Grid/Query/QueryParserInterface.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -/** - * Returns the executable query from a prepared one. - */ -interface QueryParserInterface -{ - /** - * @param string $query the prepared query - * @param array $queryParameters the query parameters - * - * @return string - */ - public function parse($query, array $queryParameters); -} diff --git a/src/Core/Grid/Query/SupplierQueryBuilder.php b/src/Core/Grid/Query/SupplierQueryBuilder.php deleted file mode 100644 index a910d88d..00000000 --- a/src/Core/Grid/Query/SupplierQueryBuilder.php +++ /dev/null @@ -1,246 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class SupplierQueryBuilder builds search & count queries for suppliers grid. - */ -final class SupplierQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var int - */ - private $contextLangId; - - /** - * @var array - */ - private $contextShopIds; - - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param int $contextLangId - * @param array $contextShopIds - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - $contextLangId, - array $contextShopIds - ) { - parent::__construct($connection, $dbPrefix); - - $this->contextLangId = $contextLangId; - $this->contextShopIds = $contextShopIds; - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $filters = $searchCriteria->getFilters(); - $isCountFilter = array_key_exists('products_count', $filters); - - if ($isCountFilter) { - $qb = $this->getQueryBuilderByProductsCount($filters); - $qb->select('*'); - $this->applyFilters($qb, $filters, 'subQuery'); - $this->applyListQueryParameters($qb); - } else { - $qb = $this->getQueryBuilder(); - $this->applyListQuerySelection($qb); - $this->applyListQueryParameters($qb); - $this->applyFilters($qb, $filters, 's'); - } - - $this->searchCriteriaApplicator - ->applySorting($searchCriteria, $qb) - ->applyPagination($searchCriteria, $qb) - ; - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $filters = $searchCriteria->getFilters(); - $isCountFilter = array_key_exists('products_count', $filters); - - if ($isCountFilter) { - $alias = 'subQuery'; - $qb = $this->getQueryBuilderByProductsCount($filters); - $this->applyFilters($qb, $filters, $alias); - $this->applyListQueryParameters($qb); - } else { - $qb = $this->getQueryBuilder(); - $this->applyListQueryParameters($qb); - $this->applyFilters($qb, $filters, 's'); - $alias = 's'; - } - - $qb->select('COUNT(DISTINCT ' . $alias . '.`id_supplier`)'); - - return $qb; - } - - /** - * Get generic query builder. - * - * @return QueryBuilder - */ - private function getQueryBuilder() - { - return $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'supplier', 's') - ->innerJoin( - 's', - $this->dbPrefix . 'supplier_lang', - 'sl', - 'sl.`id_supplier` = s.`id_supplier`' - ) - ->innerJoin( - 's', - $this->dbPrefix . 'supplier_shop', - 'ss', - 'ss.`id_supplier` = s.`id_supplier`' - ) - ->leftJoin( - 's', - $this->dbPrefix . 'product_supplier', - 'ps', - 'ps.`id_supplier` = s.`id_supplier`' - ) - ->andWhere('sl.`id_lang` = :contextLangId') - ->andWhere('ss.`id_shop` IN (:contextShopIds)') - ; - } - - /** - * Gets query builder by product count which uses the main query as the sub-query in FROM condition. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilderByProductsCount(array $filters) - { - $subQuery = $this->getQueryBuilder(); - $this->applyListQuerySelection($subQuery); - - $alias = 'subQuery'; - - $qb = $this->connection - ->createQueryBuilder() - ->from( - '(' . $subQuery->getSQL() . ')', - $alias - ) - ->where('subQuery.`products_count` = :productsCountFilter') - ; - - $qb->setParameter('productsCountFilter', $filters['products_count']); - - return $qb; - } - - /** - * Adds select and group by statements. - * - * @param QueryBuilder $qb - */ - private function applyListQuerySelection(QueryBuilder $qb) - { - $qb - ->select('s.`id_supplier`, s.`name`, s.`active`') - ->addSelect('COUNT(DISTINCT ps.`id_product`) AS `products_count`') - ->groupBy('s.`id_supplier`') - ; - } - - /** - * Sets the parameters which are used in the queries. - * - * @param QueryBuilder $qb - */ - private function applyListQueryParameters(QueryBuilder $qb) - { - $qb - ->setParameter('contextLangId', $this->contextLangId) - ->setParameter('contextShopIds', $this->contextShopIds, Connection::PARAM_INT_ARRAY) - ; - } - - /** - * Adds filter restrictions. - * - * @param QueryBuilder $qb - * @param array $filters - * @param string $alias - */ - private function applyFilters(QueryBuilder $qb, array $filters, $alias) - { - $availableFilters = [ - 'id_supplier', - 'name', - 'active', - ]; - - foreach ($filters as $filterName => $value) { - if (!in_array($filterName, $availableFilters, true)) { - continue; - } - - if (in_array($filterName, ['id_supplier', 'active'], true)) { - $qb->andWhere($alias . '.`' . $filterName . '` = :' . $filterName); - $qb->setParameter($filterName, $value); - - continue; - } - - $qb->andWhere($alias . '.`name` LIKE :' . $filterName); - $qb->setParameter($filterName, '%' . $value . '%'); - } - } -} diff --git a/src/Core/Grid/Query/TaxQueryBuilder.php b/src/Core/Grid/Query/TaxQueryBuilder.php deleted file mode 100644 index 3c784f81..00000000 --- a/src/Core/Grid/Query/TaxQueryBuilder.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class TaxQueryBuilder builds search & count queries for taxes grid. - */ -final class TaxQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @var int - */ - private $employeeIdLang; - - /** - * @param Connection $connection - * @param $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param $employeeIdLang - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - $employeeIdLang - ) { - parent::__construct($connection, $dbPrefix); - - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->employeeIdLang = $employeeIdLang; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - - $qb - ->select('t.`id_tax`, tl.`name`, t.`rate`, t.`active`') - ; - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb) - ; - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()) - ->select('COUNT(DISTINCT t.`id_tax`)') - ; - - return $qb; - } - - /** - * Gets query builder with the common sql used for displaying webservice list and applying filter actions. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters) - { - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'tax', 't') - ->leftJoin( - 't', - $this->dbPrefix . 'tax_lang', - 'tl', - 't.`id_tax` = tl.`id_tax`' - ); - $qb->andWhere('tl.`id_lang` = :employee_id_lang'); - $qb->andWhere('t.`deleted` = 0'); - - $qb->setParameter('employee_id_lang', $this->employeeIdLang); - $this->applyFilters($qb, $filters); - - return $qb; - } - - private function applyFilters(QueryBuilder $qb, array $filters) - { - $allowedFiltersMap = [ - 'id_tax' => 't.id_tax', - 'name' => 'tl.name', - 'rate' => 't.rate', - 'active' => 't.active', - ]; - - foreach ($filters as $filterName => $value) { - if (!array_key_exists($filterName, $allowedFiltersMap)) { - continue; - } - - if ('active' === $filterName || 'id_tax' === $filterName) { - $qb->andWhere($allowedFiltersMap[$filterName] . ' = :' . $filterName); - $qb->setParameter($filterName, $value); - - continue; - } - - $qb->andWhere($allowedFiltersMap[$filterName] . ' LIKE :' . $filterName) - ->setParameter($filterName, '%' . $value . '%'); - } - } -} diff --git a/src/Core/Grid/Query/TaxRulesGroupQueryBuilder.php b/src/Core/Grid/Query/TaxRulesGroupQueryBuilder.php deleted file mode 100644 index f483a70e..00000000 --- a/src/Core/Grid/Query/TaxRulesGroupQueryBuilder.php +++ /dev/null @@ -1,155 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Query builder builds search & count queries for tax rules group grid. - */ -class TaxRulesGroupQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var array - */ - private $contextShopIds; - - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @param Connection $connection - * @param string $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param array $contextShopIds - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - array $contextShopIds - ) { - parent::__construct($connection, $dbPrefix); - - $this->contextShopIds = $contextShopIds; - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - - $qb - ->select('trg.`id_tax_rules_group`, trg.`name`, trg.`active`') - ; - - $this->searchCriteriaApplicator - ->applyPagination($searchCriteria, $qb) - ->applySorting($searchCriteria, $qb) - ; - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()) - ->select('COUNT(DISTINCT trg.`id_tax_rules_group`)') - ; - - return $qb; - } - - /** - * Gets query builder with the common sql used for displaying tax rule groups list and applying filter actions. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters): QueryBuilder - { - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'tax_rules_group', 'trg') - ->leftJoin( - 'trg', - $this->dbPrefix . 'tax_rules_group_shop', - 'trgs', - 'trg.`id_tax_rules_group` = trgs.`id_tax_rules_group`' - ); - - $qb->andWhere('trgs.`id_shop` IN (:contextShopIds)') - ->andWhere('trg.`deleted` = 0') - ->setParameter('contextShopIds', $this->contextShopIds, Connection::PARAM_INT_ARRAY); - - $this->applyFilters($qb, $filters); - - return $qb; - } - - /** - * Tax rule groups list filtering - * - * @param QueryBuilder $qb - * @param array $filters - */ - private function applyFilters(QueryBuilder $qb, array $filters): void - { - $allowedFiltersMap = [ - 'id_tax_rules_group' => 'trg.id_tax_rules_group', - 'name' => 'trg.name', - 'active' => 'trg.active', - ]; - - foreach ($filters as $filterName => $value) { - if (!array_key_exists($filterName, $allowedFiltersMap)) { - continue; - } - - if ('name' === $filterName) { - $qb->andWhere($allowedFiltersMap[$filterName] . ' LIKE :' . $filterName) - ->setParameter($filterName, '%' . $value . '%'); - - continue; - } - - $qb->andWhere($allowedFiltersMap[$filterName] . ' = :' . $filterName) - ->setParameter($filterName, $value); - } - } -} diff --git a/src/Core/Grid/Query/WebserviceKeyQueryBuilder.php b/src/Core/Grid/Query/WebserviceKeyQueryBuilder.php deleted file mode 100644 index 0100dfa1..00000000 --- a/src/Core/Grid/Query/WebserviceKeyQueryBuilder.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Query; - -use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Query\QueryBuilder; -use PrestaShop\PrestaShop\Core\Grid\Query\Filter\DoctrineFilterApplicatorInterface; -use PrestaShop\PrestaShop\Core\Grid\Query\Filter\SqlFilters; -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Class WebserviceKeyQueryBuilder is responsible for providing data for webservice accounts list. - */ -final class WebserviceKeyQueryBuilder extends AbstractDoctrineQueryBuilder -{ - /** - * @var DoctrineSearchCriteriaApplicatorInterface - */ - private $searchCriteriaApplicator; - - /** - * @var array - */ - private $contextShopIds; - - /** - * @var DoctrineFilterApplicatorInterface - */ - private $doctrineFilterApplicator; - - /** - * WebserviceKeyQueryBuilder constructor. - * - * @param Connection $connection - * @param $dbPrefix - * @param DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator - * @param array $contextShopIds - * @param DoctrineFilterApplicatorInterface $doctrineFilterApplicator - */ - public function __construct( - Connection $connection, - $dbPrefix, - DoctrineSearchCriteriaApplicatorInterface $searchCriteriaApplicator, - array $contextShopIds, - DoctrineFilterApplicatorInterface $doctrineFilterApplicator - ) { - parent::__construct($connection, $dbPrefix); - $this->searchCriteriaApplicator = $searchCriteriaApplicator; - $this->contextShopIds = $contextShopIds; - $this->connection = $connection; - $this->doctrineFilterApplicator = $doctrineFilterApplicator; - } - - /** - * {@inheritdoc} - */ - public function getSearchQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()); - $qb->select('wa.`id_webservice_account`, wa.`key`, wa.`description`, wa.`active`') - ->orderBy( - $this->getModifiedOrderBy($searchCriteria->getOrderBy()), - $searchCriteria->getOrderWay() - ) - ->groupBy('wa.`id_webservice_account`'); - - $this->searchCriteriaApplicator->applyPagination($searchCriteria, $qb); - - return $qb; - } - - /** - * {@inheritdoc} - */ - public function getCountQueryBuilder(SearchCriteriaInterface $searchCriteria) - { - $qb = $this->getQueryBuilder($searchCriteria->getFilters()) - ->select('COUNT(DISTINCT wa.`id_webservice_account`)'); - - return $qb; - } - - /** - * Gets query builder with the common sql used for displaying webservice list and applying filter actions. - * - * @param array $filters - * - * @return QueryBuilder - */ - private function getQueryBuilder(array $filters) - { - $qb = $this->connection - ->createQueryBuilder() - ->from($this->dbPrefix . 'webservice_account', 'wa') - ->innerJoin( - 'wa', - $this->dbPrefix . 'webservice_account_shop', - 'was', - 'was.`id_webservice_account` = wa.`id_webservice_account`' - ) - ->andWhere('was.`id_shop` IN (:shops)') - ->setParameter('shops', $this->contextShopIds, Connection::PARAM_INT_ARRAY) - ; - - $sqlFilters = (new SqlFilters()) - ->addFilter('key', 'wa.key', SqlFilters::WHERE_LIKE) - ->addFilter('active', 'wa.active', SqlFilters::WHERE_STRICT) - ->addFilter('description', 'wa.description', SqlFilters::WHERE_LIKE) - ; - - $this->doctrineFilterApplicator->apply($qb, $sqlFilters, $filters); - - return $qb; - } - - /** - * Gets modified order by which includes an alias for reserved keyword. - * - * @param string $orderBy - original order by value - * - * @return string - */ - private function getModifiedOrderBy($orderBy) - { - return 'wa.`' . $orderBy . '`'; - } -} diff --git a/src/Core/Grid/Record/RecordCollection.php b/src/Core/Grid/Record/RecordCollection.php deleted file mode 100644 index ec651032..00000000 --- a/src/Core/Grid/Record/RecordCollection.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Record; - -use PrestaShop\PrestaShop\Core\Grid\Collection\AbstractCollection; - -/** - * Class RecordCollection is a wrapper around rows from database. - */ -final class RecordCollection extends AbstractCollection implements RecordCollectionInterface -{ - /** - * @param array $records Raw records data - */ - public function __construct(array $records = []) - { - $this->items = $records; - } - - /** - * {@inheritdoc} - */ - public function all() - { - return $this->items; - } -} diff --git a/src/Core/Grid/Record/RecordCollectionInterface.php b/src/Core/Grid/Record/RecordCollectionInterface.php deleted file mode 100644 index 7b105c89..00000000 --- a/src/Core/Grid/Record/RecordCollectionInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Record; - -use Countable; -use Iterator; - -/** - * Interface RecordCollectionInterface defines interface for raw rows wrapper. - */ -interface RecordCollectionInterface extends Countable, Iterator -{ - /** - * Get raw rows. - * - * @return array - */ - public function all(); -} diff --git a/src/Core/Grid/Search/Factory/DecoratedSearchCriteriaFactory.php b/src/Core/Grid/Search/Factory/DecoratedSearchCriteriaFactory.php deleted file mode 100644 index 1580611e..00000000 --- a/src/Core/Grid/Search/Factory/DecoratedSearchCriteriaFactory.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Search\Factory; - -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; - -/** - * Interface DecoratedSearchCriteriaFactory defines contract for decorated search criteria factory. - */ -interface DecoratedSearchCriteriaFactory -{ - /** - * Create new search criteria. - * - * @param SearchCriteriaInterface $searchCriteria - * - * @return SearchCriteriaInterface - */ - public function createFrom(SearchCriteriaInterface $searchCriteria); -} diff --git a/src/Core/Grid/Search/SearchCriteria.php b/src/Core/Grid/Search/SearchCriteria.php deleted file mode 100644 index 7911c353..00000000 --- a/src/Core/Grid/Search/SearchCriteria.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Search; - -/** - * Class SearchCriteria stores search criteria for grid data. - */ -final class SearchCriteria implements SearchCriteriaInterface -{ - /** - * @var array - */ - private $filters; - - /** - * @var string|null - */ - private $orderBy; - - /** - * @var string|null - */ - private $orderWay; - - /** - * @var string|null - */ - private $offset; - - /** - * @var string|null - */ - private $limit; - - /** - * @param array $filters - * @param string|null $orderBy - * @param string|null $orderWay - * @param string|null $offset - * @param string|null $limit - */ - public function __construct(array $filters = [], $orderBy = null, $orderWay = null, $offset = null, $limit = null) - { - $this->filters = $filters; - $this->orderBy = $orderBy; - $this->orderWay = $orderWay; - $this->offset = $offset; - $this->limit = $limit; - } - - /** - * {@inheritdoc} - */ - public function getOrderBy() - { - return $this->orderBy; - } - - /** - * {@inheritdoc} - */ - public function getOrderWay() - { - return $this->orderWay; - } - - /** - * {@inheritdoc} - */ - public function getOffset() - { - return $this->offset; - } - - /** - * {@inheritdoc} - */ - public function getLimit() - { - return $this->limit; - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return $this->filters; - } -} diff --git a/src/Core/Grid/Search/SearchCriteriaInterface.php b/src/Core/Grid/Search/SearchCriteriaInterface.php deleted file mode 100644 index 8633044e..00000000 --- a/src/Core/Grid/Search/SearchCriteriaInterface.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Grid\Search; - -/** - * Interface SearchCriteriaInterface. - */ -interface SearchCriteriaInterface -{ - /** - * @return string|null Return order by or null to disable ordering - */ - public function getOrderBy(); - - /** - * @return string|null Return order by or null to disable ordering - */ - public function getOrderWay(); - - /** - * @return int|null Return offset or null to disable offset - */ - public function getOffset(); - - /** - * @return int|null Return limit or null to disable limiting - */ - public function getLimit(); - - /** - * @return array Return filters - */ - public function getFilters(); -} diff --git a/src/Core/Group/Provider/DefaultGroup.php b/src/Core/Group/Provider/DefaultGroup.php deleted file mode 100644 index 3d11e2f8..00000000 --- a/src/Core/Group/Provider/DefaultGroup.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Group\Provider; - -/** - * Stores information for default group - */ -class DefaultGroup -{ - /** - * @var int - */ - private $groupId; - - /** - * @var string - */ - private $name; - - /** - * @param int $groupId - * @param string $name - */ - public function __construct($groupId, $name) - { - $this->groupId = $groupId; - $this->name = $name; - } - - /** - * @return int - */ - public function getId() - { - return $this->groupId; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } -} diff --git a/src/Core/Group/Provider/DefaultGroups.php b/src/Core/Group/Provider/DefaultGroups.php deleted file mode 100644 index 8c48c531..00000000 --- a/src/Core/Group/Provider/DefaultGroups.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Group\Provider; - -/** - * Stores default group options - */ -class DefaultGroups -{ - /** - * @var DefaultGroup - */ - private $visitorsGroup; - - /** - * @var DefaultGroup - */ - private $guestsGroup; - - /** - * @var DefaultGroup - */ - private $customersGroup; - - /** - * @param DefaultGroup $visitorsGroup - * @param DefaultGroup $guestsGroup - * @param DefaultGroup $customersGroup - */ - public function __construct(DefaultGroup $visitorsGroup, DefaultGroup $guestsGroup, DefaultGroup $customersGroup) - { - $this->visitorsGroup = $visitorsGroup; - $this->guestsGroup = $guestsGroup; - $this->customersGroup = $customersGroup; - } - - /** - * Get default visitors group - * - * @return DefaultGroup - */ - public function getVisitorsGroup() - { - return $this->visitorsGroup; - } - - /** - * Get default guests group - * - * @return DefaultGroup - */ - public function getGuestsGroup() - { - return $this->guestsGroup; - } - - /** - * Get customers group - * - * @return DefaultGroup - */ - public function getCustomersGroup() - { - return $this->customersGroup; - } - - /** - * Get default groups - * - * @return DefaultGroup[] - */ - public function getGroups() - { - return [ - $this->getVisitorsGroup(), - $this->getGuestsGroup(), - $this->getCustomersGroup(), - ]; - } -} diff --git a/src/Core/Group/Provider/DefaultGroupsProviderInterface.php b/src/Core/Group/Provider/DefaultGroupsProviderInterface.php deleted file mode 100644 index f5932786..00000000 --- a/src/Core/Group/Provider/DefaultGroupsProviderInterface.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Group\Provider; - -/** - * Interface for service that retrieves default customer group options - */ -interface DefaultGroupsProviderInterface -{ - /** - * @return DefaultGroups - */ - public function getGroups(); -} diff --git a/src/Core/Hook/Generator/HookDescriptionGenerator.php b/src/Core/Hook/Generator/HookDescriptionGenerator.php deleted file mode 100644 index 0b994e9d..00000000 --- a/src/Core/Hook/Generator/HookDescriptionGenerator.php +++ /dev/null @@ -1,161 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Hook\Generator; - -use PrestaShop\PrestaShop\Core\Hook\HookDescription; -use PrestaShop\PrestaShop\Core\Util\String\StringModifierInterface; -use PrestaShop\PrestaShop\Core\Util\String\StringValidatorInterface; - -/** - * Generates description for hook names. - */ -final class HookDescriptionGenerator implements HookDescriptionGeneratorInterface -{ - /** - * @var array - */ - private $hookDescriptions; - - /** - * @var StringValidatorInterface - */ - private $stringValidator; - - /** - * @var StringModifierInterface - */ - private $stringModifier; - - /** - * @param array $hookDescriptions - * @param StringValidatorInterface $stringValidator - * @param StringModifierInterface $stringModifier - */ - public function __construct( - array $hookDescriptions, - StringValidatorInterface $stringValidator, - StringModifierInterface $stringModifier - ) { - $this->hookDescriptions = $hookDescriptions; - $this->stringValidator = $stringValidator; - $this->stringModifier = $stringModifier; - } - - /** - * {@inheritdoc} - */ - public function generate($hookName) - { - foreach ($this->hookDescriptions as $hookPlaceholder => $hookDescription) { - $prefix = isset($hookDescription['prefix']) ? $hookDescription['prefix'] : ''; - $suffix = isset($hookDescription['suffix']) ? $hookDescription['suffix'] : ''; - - if ($this->stringValidator->startsWithAndEndsWith($hookName, $prefix, $suffix) && - !$this->stringValidator->doesContainsWhiteSpaces($hookName) - ) { - $hookId = $this->extractHookId($hookName, $prefix, $suffix); - - return new HookDescription( - $hookName, - $this->getTextWithHookId($hookDescription['title'], $hookId), - $this->getTextWithHookId($hookDescription['description'], $hookId) - ); - } - } - - return new HookDescription( - $hookName, - '', - '' - ); - } - - /** - * Removes from hook name id prefix and suffix. - * - * @param string $hookName - * @param string $prefix - * @param string $suffix - * - * @return string - */ - private function extractHookId($hookName, $prefix, $suffix) - { - return str_replace([$prefix, $suffix], '', $hookName); - } - - /** - * Gets text with replaced hook id. - * - * @param string $description - * @param string $hookId - * - * @return string - */ - private function getTextWithHookId($description, $hookId) - { - if (!$this->doesHookDescriptionContainsPlaceholder($description)) { - return $description; - } - - $hookIdSplitByCamelCase = $this->stringModifier->splitByCamelCase($hookId); - - $isPlaceholderAsFirstValueInString = $this->doesPlaceholderIsTheFirstElementOfTheDescription($description); - - if ($isPlaceholderAsFirstValueInString) { - $hookIdSplitByCamelCase = ucfirst($hookIdSplitByCamelCase); - } else { - $hookIdSplitByCamelCase = strtolower($hookIdSplitByCamelCase); - } - - return sprintf($description, $hookIdSplitByCamelCase); - } - - /** - * Checks if hook description contains placeholder value. - * - * @param string $description - * - * @return bool - */ - private function doesHookDescriptionContainsPlaceholder($description) - { - return false !== strpos($description, '%s'); - } - - /** - * Checks if placeholder is the first element of the string. - * - * @param string $description - * - * @return bool - */ - private function doesPlaceholderIsTheFirstElementOfTheDescription($description) - { - return 0 === strncmp($description, '%s', 2); - } -} diff --git a/src/Core/Hook/Generator/HookDescriptionGeneratorInterface.php b/src/Core/Hook/Generator/HookDescriptionGeneratorInterface.php deleted file mode 100644 index b98702d3..00000000 --- a/src/Core/Hook/Generator/HookDescriptionGeneratorInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Hook\Generator; - -use PrestaShop\PrestaShop\Core\Hook\HookDescription; - -/** - * Defines contract for generating description for hook names. - */ -interface HookDescriptionGeneratorInterface -{ - /** - * @param string $hookName - * - * @return HookDescription - */ - public function generate($hookName); -} diff --git a/src/Core/Hook/Hook.php b/src/Core/Hook/Hook.php deleted file mode 100644 index 566b2c33..00000000 --- a/src/Core/Hook/Hook.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Hook; - -/** - * Class Hook defines hook. - */ -final class Hook implements HookInterface -{ - /** - * @var string - */ - private $name; - - /** - * @var array - */ - private $parameters; - - /** - * @param string $name - * @param array $parameters - */ - public function __construct($name, array $parameters = []) - { - $this->name = $name; - $this->parameters = $parameters; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function getParameters() - { - return $this->parameters; - } -} diff --git a/src/Core/Hook/HookDescription.php b/src/Core/Hook/HookDescription.php deleted file mode 100644 index 673f4afc..00000000 --- a/src/Core/Hook/HookDescription.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Hook; - -/** - * Class holds descriptive information about the hook. - */ -final class HookDescription -{ - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $title; - - /** - * @var string - */ - private $description; - - /** - * @param string $name - * @param string $title - * @param string $description - */ - public function __construct($name, $title, $description) - { - $this->name = $name; - $this->title = $title; - $this->description = $description; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * @return string - */ - public function getDescription() - { - return $this->description; - } -} diff --git a/src/Core/Hook/HookDispatcher.php b/src/Core/Hook/HookDispatcher.php deleted file mode 100644 index 697f2a2a..00000000 --- a/src/Core/Hook/HookDispatcher.php +++ /dev/null @@ -1,159 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Hook; - -use PrestaShop\PrestaShop\Adapter\Hook\HookDispatcher as HookDispatcherAdapter; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * Class HookDispatcher is responsible for dispatching hooks. - */ -final class HookDispatcher implements HookDispatcherInterface -{ - /** - * @var HookDispatcherAdapter - */ - private $hookDispatcherAdapter; - - /** - * @param HookDispatcherAdapter $hookDispatcherAdapter - */ - public function __construct(HookDispatcherAdapter $hookDispatcherAdapter) - { - $this->hookDispatcherAdapter = $hookDispatcherAdapter; - } - - /** - * {@inheritdoc} - */ - public function dispatchHook(HookInterface $hook) - { - $this->hookDispatcherAdapter->dispatchForParameters( - $hook->getName(), - $hook->getParameters() - ); - } - - /** - * {@inheritdoc} - */ - public function dispatchWithParameters($hookName, array $hookParameters = []) - { - $this->dispatchHook(new Hook($hookName, $hookParameters)); - } - - /** - * {@inheritdoc} - */ - public function dispatchRendering(HookInterface $hook) - { - $event = $this->hookDispatcherAdapter->renderForParameters( - $hook->getName(), - $hook->getParameters() - ); - - $content = $event->getContent(); - array_walk($content, function (&$partialContent) { - $partialContent = empty($partialContent) ? '' : current($partialContent); - }); - - return new RenderedHook($hook, $content); - } - - /** - * {@inheritdoc} - */ - public function dispatchRenderingWithParameters($hookName, array $hookParameters = []) - { - return $this->dispatchRendering(new Hook($hookName, $hookParameters)); - } - - /** - * {@inheritdoc} - */ - public function dispatch($eventName, Event $event = null) - { - return $this->hookDispatcherAdapter->dispatch($eventName, $event); - } - - /** - * {@inheritdoc} - */ - public function addListener($eventName, $listener, $priority = 0) - { - $this->hookDispatcherAdapter->addListener($eventName, $listener, $priority); - } - - /** - * {@inheritdoc} - */ - public function addSubscriber(EventSubscriberInterface $subscriber) - { - $this->hookDispatcherAdapter->addSubscriber($subscriber); - } - - /** - * {@inheritdoc} - */ - public function removeListener($eventName, $listener) - { - $this->hookDispatcherAdapter->removeListener($eventName, $listener); - } - - /** - * {@inheritdoc} - */ - public function removeSubscriber(EventSubscriberInterface $subscriber) - { - $this->hookDispatcherAdapter->removeSubscriber($subscriber); - } - - /** - * {@inheritdoc} - */ - public function getListeners($eventName = null) - { - return $this->hookDispatcherAdapter->getListeners($eventName); - } - - /** - * {@inheritdoc} - */ - public function getListenerPriority($eventName, $listener) - { - return $this->hookDispatcherAdapter->getListenerPriority($eventName, $listener); - } - - /** - * {@inheritdoc} - */ - public function hasListeners($eventName = null) - { - return $this->hookDispatcherAdapter->hasListeners($eventName); - } -} diff --git a/src/Core/Hook/HookDispatcherAwareTrait.php b/src/Core/Hook/HookDispatcherAwareTrait.php deleted file mode 100644 index 27f84917..00000000 --- a/src/Core/Hook/HookDispatcherAwareTrait.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Hook; - -/** - * Trait EventDispatcherAwareTrait. - * - * @deprecated - */ -trait HookDispatcherAwareTrait -{ - /** - * @var HookDispatcherInterface - */ - protected $hookDispatcher; - - /** - * Set hook dispatcher. - * - * @param HookDispatcherInterface $hookDispatcher - */ - public function setHookDispatcher(HookDispatcherInterface $hookDispatcher) - { - @trigger_error('HookDispatcherAwareTrait is deprecated as of 1.7.5.1 and will be removed in the next major version. If you need to inject HookDispatcherInterface use the constructor not setter injection.', E_USER_DEPRECATED); - - $this->hookDispatcher = $hookDispatcher; - } -} diff --git a/src/Core/Hook/HookDispatcherInterface.php b/src/Core/Hook/HookDispatcherInterface.php deleted file mode 100644 index bb9f445d..00000000 --- a/src/Core/Hook/HookDispatcherInterface.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Hook; - -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * Interface HookDispatcherInterface defines contract for hook dispatcher - * Extends EventDispatcherInterface for compatibility with the Event Dispatcher component. - */ -interface HookDispatcherInterface extends EventDispatcherInterface -{ - /** - * Dispatch given hook. - * - * @param HookInterface $hook - */ - public function dispatchHook(HookInterface $hook); - - /** - * Dispatch hook with raw parameters. - * - * @param string $hookName - * @param array $hookParameters - */ - public function dispatchWithParameters($hookName, array $hookParameters = []); - - /** - * Dispatch rendering hook. - * - * @param HookInterface $hook - * - * @return RenderedHookInterface - */ - public function dispatchRendering(HookInterface $hook); - - /** - * Dispatch rendering hook with parameters. - * - * @param string $hookName - * @param array $hookParameters - * - * @return RenderedHookInterface - */ - public function dispatchRenderingWithParameters($hookName, array $hookParameters = []); -} diff --git a/src/Core/Hook/HookInterface.php b/src/Core/Hook/HookInterface.php deleted file mode 100644 index e4220971..00000000 --- a/src/Core/Hook/HookInterface.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Hook; - -/** - * Interface HookInterface defines contract for hook. - */ -interface HookInterface -{ - /** - * Get hook name. - * - * @return string - */ - public function getName(); - - /** - * Get hook parameters. - * - * @return array - */ - public function getParameters(); -} diff --git a/src/Core/Hook/Provider/GridDefinitionHookByServiceIdsProvider.php b/src/Core/Hook/Provider/GridDefinitionHookByServiceIdsProvider.php deleted file mode 100644 index fa860e04..00000000 --- a/src/Core/Hook/Provider/GridDefinitionHookByServiceIdsProvider.php +++ /dev/null @@ -1,154 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Hook\Provider; - -use Exception; -use Generator; -use Logger; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\GridDefinitionFactoryInterface; -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Provides hooks list by calling service ids from the container. - */ -final class GridDefinitionHookByServiceIdsProvider implements HookByServiceIdsProviderInterface -{ - const HOOK_PREFIX = 'action'; - const GRID_DEFINITION_HOOK_SUFFIX = 'GridDefinitionModifier'; - const GRID_QUERY_BUILDER_HOOK_SUFFIX = 'GridQueryBuilderModifier'; - const GRID_DATA_HOOK_SUFFIX = 'GridDataModifier'; - const GRID_FILTER_FORM_SUFFIX = 'GridFilterFormModifier'; - const GRID_PRESENTER_SUFFIX = 'GridPresenterModifier'; - - /** - * @var ContainerInterface - */ - private $container; - - /** - * @param ContainerInterface $container - */ - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - /** - * {@inheritdoc} - */ - public function getHookNames(array $gridDefinitionServiceIds) - { - /** @var Generator $gridDefinitionIds */ - $gridDefinitionIds = $this->getGridDefinitionIds($gridDefinitionServiceIds); - - $gridDefinitionHookNames = []; - $gridQueryBuilderHookNames = []; - $gridDataHookNames = []; - $gridFilterFormHookNames = []; - $gridPresenterHookNames = []; - - foreach ($gridDefinitionIds as $gridDefinitionId) { - $gridDefinitionHookNames[] = $this->formatHookName( - self::HOOK_PREFIX, - $gridDefinitionId, - self::GRID_DEFINITION_HOOK_SUFFIX - ); - - $gridQueryBuilderHookNames[] = $this->formatHookName( - self::HOOK_PREFIX, - $gridDefinitionId, - self::GRID_QUERY_BUILDER_HOOK_SUFFIX - ); - - $gridDataHookNames[] = $this->formatHookName( - self::HOOK_PREFIX, - $gridDefinitionId, - self::GRID_DATA_HOOK_SUFFIX - ); - - $gridFilterFormHookNames[] = $this->formatHookName( - self::HOOK_PREFIX, - $gridDefinitionId, - self::GRID_FILTER_FORM_SUFFIX - ); - - $gridPresenterHookNames[] = $this->formatHookName( - self::HOOK_PREFIX, - $gridDefinitionId, - self::GRID_PRESENTER_SUFFIX - ); - } - - return array_merge( - $gridDefinitionHookNames, - $gridQueryBuilderHookNames, - $gridDataHookNames, - $gridFilterFormHookNames, - $gridPresenterHookNames - ); - } - - /** - * Gets grid definition ids which are used in a grid hook formation. - * - * @param array $gridDefinitionServiceIds - * - * @return Generator - */ - private function getGridDefinitionIds(array $gridDefinitionServiceIds) - { - foreach ($gridDefinitionServiceIds as $serviceId) { - try { - $service = $this->container->get($serviceId); - if (!$service instanceof GridDefinitionFactoryInterface) { - continue; - } - $definition = $service->getDefinition(); - $definitionId = $definition->getId(); - $camelizedDefinitionId = Container::camelize($definitionId); - yield $camelizedDefinitionId; - } catch (Exception $e) { - Logger::addLog(sprintf('Error while loading service: %s . Error: %s', $serviceId, $e)); - } - } - } - - /** - * Formats hook names. - * - * @param string $hookStartsWith - * @param string $hookId - * @param string $hookEndsWidth - * - * @return string - */ - private function formatHookName($hookStartsWith, $hookId, $hookEndsWidth) - { - return $hookStartsWith . $hookId . $hookEndsWidth; - } -} diff --git a/src/Core/Hook/Provider/HookByFormTypeProviderInterface.php b/src/Core/Hook/Provider/HookByFormTypeProviderInterface.php deleted file mode 100644 index 1b748f09..00000000 --- a/src/Core/Hook/Provider/HookByFormTypeProviderInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Hook\Provider; - -/** - * Defines contract for providing hooks from form types. - */ -interface HookByFormTypeProviderInterface -{ - /** - * @param string[] $formTypes - * - * @return string[] - */ - public function getHookNames(array $formTypes); -} diff --git a/src/Core/Hook/Provider/HookByServiceIdsProviderInterface.php b/src/Core/Hook/Provider/HookByServiceIdsProviderInterface.php deleted file mode 100644 index 18e5d33c..00000000 --- a/src/Core/Hook/Provider/HookByServiceIdsProviderInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Hook\Provider; - -/** - * Defines contract for providing hooks by using service ids. - */ -interface HookByServiceIdsProviderInterface -{ - /** - * @param string[] $gridDefinitionServiceIds - * - * @return string[] - */ - public function getHookNames(array $gridDefinitionServiceIds); -} diff --git a/src/Core/Hook/Provider/IdentifiableObjectHookByFormTypeProvider.php b/src/Core/Hook/Provider/IdentifiableObjectHookByFormTypeProvider.php deleted file mode 100644 index 27373783..00000000 --- a/src/Core/Hook/Provider/IdentifiableObjectHookByFormTypeProvider.php +++ /dev/null @@ -1,154 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Hook\Provider; - -use Exception; -use Generator; -use Logger; -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\DependencyInjection\Definition; -use Symfony\Component\Form\FormFactoryInterface; -use Symfony\Component\Form\FormRegistryInterface; -use Throwable; - -/** - * Gets hook names by identifiable object form types. - */ -final class IdentifiableObjectHookByFormTypeProvider implements HookByFormTypeProviderInterface -{ - const FORM_TYPE_POSITION_IN_CONSTRUCTOR_OF_FORM_BUILDER = 0; - - const FORM_BUILDER_HOOK_PREFIX = 'action'; - const FORM_BUILDER_HOOK_SUFFIX = 'FormBuilderModifier'; - - const FORM_HANDLER_UPDATE_BEFORE_PREFIX = 'actionBeforeUpdate'; - const FORM_HANDLER_UPDATE_AFTER_PREFIX = 'actionAfterUpdate'; - const FORM_HANDLER_CREATE_BEFORE_PREFIX = 'actionBeforeCreate'; - const FORM_HANDLER_CREATE_AFTER_PREFIX = 'actionAfterCreate'; - const FORM_HANDLER_SUFFIX = 'FormHandler'; - - /** - * @var FormRegistryInterface - */ - private $formFactory; - - /** - * @param FormFactoryInterface $formFactory - */ - public function __construct(FormFactoryInterface $formFactory) - { - $this->formFactory = $formFactory; - } - - /** - * {@inheritdoc} - */ - public function getHookNames(array $formTypes) - { - $formNames = $this->getFormNames($formTypes); - - $formBuilderHookNames = []; - $formHandlerBeforeUpdateHookNames = []; - $formHandlerAfterUpdateHookNames = []; - $formHandlerBeforeCreateHookNames = []; - $formHandlerAfterCreateHookNames = []; - - foreach ($formNames as $formName) { - $formBuilderHookNames[] = $this->formatHookName( - self::FORM_BUILDER_HOOK_PREFIX, - $formName, - self::FORM_BUILDER_HOOK_SUFFIX - ); - - $formHandlerBeforeUpdateHookNames[] = $this->formatHookName( - self::FORM_HANDLER_UPDATE_BEFORE_PREFIX, - $formName, - self::FORM_HANDLER_SUFFIX - ); - - $formHandlerAfterUpdateHookNames[] = $this->formatHookName( - self::FORM_HANDLER_UPDATE_AFTER_PREFIX, - $formName, - self::FORM_HANDLER_SUFFIX - ); - - $formHandlerBeforeCreateHookNames[] = $this->formatHookName( - self::FORM_HANDLER_CREATE_BEFORE_PREFIX, - $formName, - self::FORM_HANDLER_SUFFIX - ); - - $formHandlerAfterCreateHookNames[] = $this->formatHookName( - self::FORM_HANDLER_CREATE_AFTER_PREFIX, - $formName, - self::FORM_HANDLER_SUFFIX - ); - } - - return array_merge( - $formBuilderHookNames, - $formHandlerBeforeUpdateHookNames, - $formHandlerAfterUpdateHookNames, - $formHandlerBeforeCreateHookNames, - $formHandlerAfterCreateHookNames - ); - } - - /** - * Gets form names which are used when generating hooks. - * - * @param Definition[] $formTypes - * - * @return Generator - */ - private function getFormNames(array $formTypes) - { - foreach ($formTypes as $formType) { - try { - yield $this->formFactory->createBuilder($formType)->getName(); - } catch (Exception $e) { - Logger::addLog(sprintf('Error while loading formType: %s . Error: %s', $formType, $e)); - } catch (Throwable $e) { - Logger::addLog(sprintf('Invalid argument exception: %s . Error: %s', $formType, $e)); - } - } - } - - /** - * Formats hook names. - * - * @param string $hookStartsWith - * @param string $hookId - * @param string $hookEndsWidth - * - * @return string - */ - private function formatHookName($hookStartsWith, $hookId, $hookEndsWidth) - { - return $hookStartsWith . Container::camelize($hookId) . $hookEndsWidth; - } -} diff --git a/src/Core/Hook/RenderedHook.php b/src/Core/Hook/RenderedHook.php deleted file mode 100644 index 86f4bb71..00000000 --- a/src/Core/Hook/RenderedHook.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Hook; - -/** - * Class RenderingHook defines rendered hook. - */ -final class RenderedHook implements RenderedHookInterface -{ - /** - * @var HookInterface - */ - private $hook; - - /** - * @var array ['module_name' => 'rendered_content', ...] - */ - private $content; - - /** - * @param HookInterface $hook - * @param array $content - */ - public function __construct(HookInterface $hook, array $content = []) - { - $this->hook = $hook; - $this->content = $content; - } - - /** - * {@inheritdoc} - */ - public function getHook() - { - return $this->hook; - } - - /** - * {@inheritdoc} - */ - public function getContent() - { - return $this->content; - } - - /** - * {@inheritdoc} - */ - public function outputContent() - { - return implode('', $this->content); - } -} diff --git a/src/Core/Hook/RenderedHookInterface.php b/src/Core/Hook/RenderedHookInterface.php deleted file mode 100644 index 3332a412..00000000 --- a/src/Core/Hook/RenderedHookInterface.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Hook; - -/** - * Interface RenderedHookInterface defines contract for rendered hook. - */ -interface RenderedHookInterface -{ - /** - * Get rendered hook. - * - * @return HookInterface - */ - public function getHook(); - - /** - * Get rendered content. - * - * @return array - */ - public function getContent(); - - /** - * Returns displayable content. - * - * @return string - */ - public function outputContent(); -} diff --git a/src/Core/Image/Deleter/ImageFileDeleter.php b/src/Core/Image/Deleter/ImageFileDeleter.php deleted file mode 100644 index 133281c4..00000000 --- a/src/Core/Image/Deleter/ImageFileDeleter.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Image\Deleter; - -/** - * Class ImageFileDeleter is responsible for deleting image files. - */ -final class ImageFileDeleter implements ImageFileDeleterInterface -{ - /** - * {@inheritdoc} - */ - public function deleteFromPath($path, $recursively = false, $deleteSubdirectories = false, $format = 'jpg') - { - if (!$path || !$format || !is_dir($path)) { - return false; - } - - foreach (scandir($path, SCANDIR_SORT_NONE) as $file) { - $pattern = '/^[0-9]+(\-(.*))?\.' . $format . '$/'; - - if ($recursively && is_dir($path . $file) && (preg_match('/^[0-9]$/', $file))) { - // Recursion - $this->deleteFromPath($path . $file . '/', $recursively, $deleteSubdirectories, $format); - } - - // Delete the file by regex pattern - $this->deleteByPattern($pattern, $path, $file); - - // Delete fileType file if it exists in the same directory. - if (file_exists($path . 'fileType')) { - unlink($path . 'fileType'); - } - } - - // Can we remove the image folder? - if ($deleteSubdirectories && is_numeric(basename($path))) { - $removeFolder = true; - foreach (scandir($path, SCANDIR_SORT_NONE) as $file) { - if (($file != '.' && $file != '..' && $file != 'index.php')) { - $removeFolder = false; - break; - } - } - - if ($removeFolder) { - // we're only removing index.php if it's a folder we want to delete - if (file_exists($path . 'index.php')) { - unlink($path . 'index.php'); - } - rmdir($path); - } - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function deleteAllImages($path, $format = 'jpg') - { - foreach (scandir($path, SCANDIR_SORT_NONE) as $file) { - $this->deleteByPattern( - '/(.*)\.' . $format . '$/', - $path, - $file - ); - } - } - - /** - * Delete images by given regex pattern from given path. - * - * @param string $pattern regex pattern - * @param string $path file directory path - * @param string $filename - */ - private function deleteByPattern($pattern, $path, $filename) - { - if (preg_match($pattern, $filename)) { - unlink($path . $filename); - } - } -} diff --git a/src/Core/Image/Deleter/ImageFileDeleterInterface.php b/src/Core/Image/Deleter/ImageFileDeleterInterface.php deleted file mode 100644 index 8078b9be..00000000 --- a/src/Core/Image/Deleter/ImageFileDeleterInterface.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Image\Deleter; - -/** - * Interface ImageFileDeleterInterface describes an image file deleter. - */ -interface ImageFileDeleterInterface -{ - /** - * Recursively deletes all images in the given path and removes empty folders. - * - * @param string $path images directory - * @param bool $recursively if true deletes images from subdirectories - * @param bool $deleteSubdirectories if true deletes the subdirectories as well - * @param string $format image format - * - * @return bool - */ - public function deleteFromPath($path, $recursively = false, $deleteSubdirectories = false, $format = 'jpg'); - - /** - * Delete all images from given path. - * - * @param string $path - * @param string $format - */ - public function deleteAllImages($path, $format = 'jpg'); -} diff --git a/src/Core/Image/ImageProviderInterface.php b/src/Core/Image/ImageProviderInterface.php deleted file mode 100644 index 58ad4cb4..00000000 --- a/src/Core/Image/ImageProviderInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Image; - -/** - * Interface ThumbnailProviderInterface. - */ -interface ImageProviderInterface -{ - /** - * Get thumbnail image path. - * - * @param int $imageId - * - * @return string Path to thumbnail - */ - public function getPath($imageId); -} diff --git a/src/Core/Image/ImageTypeRepository.php b/src/Core/Image/ImageTypeRepository.php deleted file mode 100644 index f9c31c6d..00000000 --- a/src/Core/Image/ImageTypeRepository.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Image; - -use Db; -use Shop; - -class ImageTypeRepository -{ - private $shop; - private $db; - private $db_prefix; - - public function __construct( - Shop $shop, - Db $db - ) { - $this->shop = $shop; - $this->db = $db; - $this->db_prefix = $db->getPrefix(); - } - - public function setTypes(array $types) - { - $this->removeAllTypes(); - foreach ($types as $name => $data) { - $this->createType( - $name, - $data['width'], - $data['height'], - $data['scope'] - ); - } - - return $this; - } - - public function createType($name, $width, $height, array $scope) - { - $data = [ - 'name' => $this->db->escape($name), - 'width' => $this->db->escape($width), - 'height' => $this->db->escape($height), - ]; - - foreach ($this->getScopeList() as $scope_item) { - if (in_array($scope_item, $scope)) { - $data[$scope_item] = 1; - } else { - $data[$scope_item] = 0; - } - } - - $this->db->insert('image_type', $data); - - return $this->getIdByName($name); - } - - public function getScopeList() - { - return ['products', 'categories', 'manufacturers', 'suppliers', 'stores']; - } - - public function getIdByName($name) - { - $escaped_name = $this->db->escape($name); - - $id_image_type = $this->db->getValue( - "SELECT id_image_type FROM {$this->db_prefix}image_type WHERE name = '$escaped_name'" - ); - - return (int) $id_image_type; - } - - protected function removeAllTypes() - { - Db::getInstance()->execute( - "TRUNCATE TABLE {$this->db_prefix}image_type" - ); - } -} diff --git a/src/Core/Image/Parser/ImageTagSourceParser.php b/src/Core/Image/Parser/ImageTagSourceParser.php deleted file mode 100644 index 943d276a..00000000 --- a/src/Core/Image/Parser/ImageTagSourceParser.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Image\Parser; - -/** - * Class ImageTagPathParser parses "src" attribute of given image tag and prefixed it with shop's uri. - * - * This service helps retrieving image path from image tag generated by legacy ImageManager::thumbnail() method - * so image can be displayed in new pages. - */ -final class ImageTagSourceParser implements ImageTagSourceParserInterface -{ - /** - * @var string - */ - private $shopRootUri; - - /** - * @param string $shopRootUri - */ - public function __construct($shopRootUri) - { - $this->shopRootUri = $shopRootUri; - } - - /** - * {@inheritdoc} - */ - public function parse($imageTag) - { - $replacement = 'src="/'; - $imageTag = preg_replace('/src="(\.\.\/|\.\/)+/', $replacement, $imageTag); - - if (null === $imageTag) { - return null; - } - - preg_match('/src="\/([^"]+)"/', $imageTag, $path); - - if (empty($path[1])) { - return null; - } - - return sprintf('/%s', $path[1]); - } -} diff --git a/src/Core/Image/Parser/ImageTagSourceParserInterface.php b/src/Core/Image/Parser/ImageTagSourceParserInterface.php deleted file mode 100644 index ef3ea708..00000000 --- a/src/Core/Image/Parser/ImageTagSourceParserInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Image\Parser; - -/** - * Interface ImageTagSourceParserInterface is contract for image "src" attribute parser. - */ -interface ImageTagSourceParserInterface -{ - /** - * @param string $imageTag Example '' - * - * @return string Parsed "src" attribute - */ - public function parse($imageTag); -} diff --git a/src/Core/Image/Uploader/Exception/ImageOptimizationException.php b/src/Core/Image/Uploader/Exception/ImageOptimizationException.php deleted file mode 100644 index 8c42ab19..00000000 --- a/src/Core/Image/Uploader/Exception/ImageOptimizationException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Image\Uploader\Exception; - -/** - * Class ImageOptimizationException is thrown when resizing, cutting or optimizing image fails. - */ -class ImageOptimizationException extends \Exception -{ -} diff --git a/src/Core/Image/Uploader/Exception/ImageUploadException.php b/src/Core/Image/Uploader/Exception/ImageUploadException.php deleted file mode 100644 index d26e7ad1..00000000 --- a/src/Core/Image/Uploader/Exception/ImageUploadException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Image\Uploader\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -class ImageUploadException extends CoreException -{ -} diff --git a/src/Core/Image/Uploader/Exception/MemoryLimitException.php b/src/Core/Image/Uploader/Exception/MemoryLimitException.php deleted file mode 100644 index 95f1cf92..00000000 --- a/src/Core/Image/Uploader/Exception/MemoryLimitException.php +++ /dev/null @@ -1,33 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Image\Uploader\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -class MemoryLimitException extends CoreException -{ -} diff --git a/src/Core/Image/Uploader/Exception/UploadedImageConstraintException.php b/src/Core/Image/Uploader/Exception/UploadedImageConstraintException.php deleted file mode 100644 index c8adb331..00000000 --- a/src/Core/Image/Uploader/Exception/UploadedImageConstraintException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Image\Uploader\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -class UploadedImageConstraintException extends CoreException -{ - const EXCEEDED_SIZE = 1; - const UNRECOGNIZED_FORMAT = 2; - const UNKNOWN_ERROR = 4; -} diff --git a/src/Core/Image/Uploader/ImageUploaderInterface.php b/src/Core/Image/Uploader/ImageUploaderInterface.php deleted file mode 100644 index 08dec114..00000000 --- a/src/Core/Image/Uploader/ImageUploaderInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Image\Uploader; - -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * Interface ImageUploaderInterface is contract for entity (e.g. Category, Product & etc.) image uploader. - */ -interface ImageUploaderInterface -{ - /** - * Upload entity image. - * - * @param int $entityId - * @param UploadedFile $uploadedImage - */ - public function upload($entityId, UploadedFile $uploadedImage); -} diff --git a/src/Core/Import/Access/ImportAccessChecker.php b/src/Core/Import/Access/ImportAccessChecker.php deleted file mode 100644 index 3e08479b..00000000 --- a/src/Core/Import/Access/ImportAccessChecker.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Access; - -use PrestaShop\PrestaShop\Core\Employee\ContextEmployeeProviderInterface; - -/** - * Class ImportAccessChecker is responsible for checking import access. - */ -final class ImportAccessChecker implements ImportAccessCheckerInterface -{ - /** - * @var ContextEmployeeProviderInterface - */ - private $contextEmployeeProvider; - - /** - * @param ContextEmployeeProviderInterface $contextEmployeeProvider - */ - public function __construct(ContextEmployeeProviderInterface $contextEmployeeProvider) - { - $this->contextEmployeeProvider = $contextEmployeeProvider; - } - - /** - * {@inheritdoc} - */ - public function canTruncateData() - { - return $this->contextEmployeeProvider->isSuperAdmin(); - } -} diff --git a/src/Core/Import/Access/ImportAccessCheckerInterface.php b/src/Core/Import/Access/ImportAccessCheckerInterface.php deleted file mode 100644 index e00f69de..00000000 --- a/src/Core/Import/Access/ImportAccessCheckerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Access; - -/** - * Interface ImportAccessCheckerInterface checks import access. - */ -interface ImportAccessCheckerInterface -{ - /** - * Checks if data truncation is allowed. - * - * @return bool - */ - public function canTruncateData(); -} diff --git a/src/Core/Import/Configuration/ImportConfig.php b/src/Core/Import/Configuration/ImportConfig.php deleted file mode 100644 index 44457978..00000000 --- a/src/Core/Import/Configuration/ImportConfig.php +++ /dev/null @@ -1,215 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Configuration; - -/** - * Class ImportConfig defines import configuration. - */ -final class ImportConfig implements ImportConfigInterface -{ - /** - * @var string - */ - private $fileName; - - /** - * @var int - */ - private $entityType; - - /** - * @var string - */ - private $languageIso; - - /** - * @var string - */ - private $separator; - - /** - * @var string - */ - private $multipleValueSeparator; - - /** - * @var bool - */ - private $truncate; - - /** - * @var bool - */ - private $skipThumbnailRegeneration; - - /** - * @var bool - */ - private $matchReferences; - - /** - * @var bool - */ - private $forceIds; - - /** - * @var bool - */ - private $sendEmail; - - /** - * @var int - */ - private $skipRows; - - /** - * @param string $fileName - * @param int $entityType - * @param string $languageIso - * @param string $separator - * @param string $multipleValueSeparator - * @param bool $truncate - * @param bool $skipThumbnailRegeneration - * @param bool $matchReferences - * @param bool $forceIds - * @param bool $sendEmail - * @param int $skipRows - */ - public function __construct( - $fileName, - $entityType, - $languageIso, - $separator, - $multipleValueSeparator, - $truncate, - $skipThumbnailRegeneration, - $matchReferences, - $forceIds, - $sendEmail, - $skipRows = 0 - ) { - $this->fileName = $fileName; - $this->entityType = $entityType; - $this->languageIso = $languageIso; - $this->separator = $separator; - $this->multipleValueSeparator = $multipleValueSeparator; - $this->truncate = $truncate; - $this->skipThumbnailRegeneration = $skipThumbnailRegeneration; - $this->matchReferences = $matchReferences; - $this->forceIds = $forceIds; - $this->sendEmail = $sendEmail; - $this->skipRows = $skipRows; - } - - /** - * {@inheritdoc} - */ - public function getFileName() - { - return $this->fileName; - } - - /** - * {@inheritdoc} - */ - public function getEntityType() - { - return $this->entityType; - } - - /** - * {@inheritdoc} - */ - public function getLanguageIso() - { - return $this->languageIso; - } - - /** - * {@inheritdoc} - */ - public function getSeparator() - { - return $this->separator; - } - - /** - * {@inheritdoc} - */ - public function getMultipleValueSeparator() - { - return $this->multipleValueSeparator; - } - - /** - * {@inheritdoc} - */ - public function truncate() - { - return $this->truncate; - } - - /** - * {@inheritdoc} - */ - public function skipThumbnailRegeneration() - { - return $this->skipThumbnailRegeneration; - } - - /** - * {@inheritdoc} - */ - public function matchReferences() - { - return $this->matchReferences; - } - - /** - * {@inheritdoc} - */ - public function forceIds() - { - return $this->forceIds; - } - - /** - * {@inheritdoc} - */ - public function sendEmail() - { - return $this->sendEmail; - } - - /** - * {@inheritdoc} - */ - public function getNumberOfRowsToSkip() - { - return $this->skipRows; - } -} diff --git a/src/Core/Import/Configuration/ImportConfigFactory.php b/src/Core/Import/Configuration/ImportConfigFactory.php deleted file mode 100644 index 2588e6e5..00000000 --- a/src/Core/Import/Configuration/ImportConfigFactory.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Configuration; - -use PrestaShop\PrestaShop\Core\Import\ImportSettings; -use Symfony\Component\HttpFoundation\Request; - -/** - * Class ImportConfigFactory describes an import configuration factory. - */ -final class ImportConfigFactory implements ImportConfigFactoryInterface -{ - /** - * {@inheritdoc} - */ - public function buildFromRequest(Request $request) - { - $separator = $request->request->get( - 'separator', - $request->getSession()->get('separator', ImportSettings::DEFAULT_SEPARATOR) - ); - - $multivalueSeparator = $request->request->get( - 'multiple_value_separator', - $request->getSession()->get('multiple_value_separator', ImportSettings::DEFAULT_MULTIVALUE_SEPARATOR) - ); - - return new ImportConfig( - $request->request->get('csv', $request->getSession()->get('csv')), - $request->request->getInt('entity', $request->getSession()->get('entity', 0)), - $request->request->get('iso_lang', $request->getSession()->get('iso_lang')), - $separator, - $multivalueSeparator, - $request->request->getBoolean('truncate', $request->getSession()->get('truncate', false)), - $request->request->getBoolean('regenerate', $request->getSession()->get('regenerate', false)), - $request->request->getBoolean('match_ref', $request->getSession()->get('match_ref', false)), - $request->request->getBoolean('forceIDs', $request->getSession()->get('forceIDs', false)), - $request->request->getBoolean('sendemail', $request->getSession()->get('sendemail', true)), - $request->request->getInt('skip', 0) - ); - } -} diff --git a/src/Core/Import/Configuration/ImportConfigFactoryInterface.php b/src/Core/Import/Configuration/ImportConfigFactoryInterface.php deleted file mode 100644 index e8e4a388..00000000 --- a/src/Core/Import/Configuration/ImportConfigFactoryInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Configuration; - -use Symfony\Component\HttpFoundation\Request; - -/** - * Interface ImportConfigFactoryInterface defines an import configuration factory. - */ -interface ImportConfigFactoryInterface -{ - /** - * Build import configuration VO out of form data. - * - * @param Request $request - * - * @return ImportConfigInterface - */ - public function buildFromRequest(Request $request); -} diff --git a/src/Core/Import/Configuration/ImportConfigInterface.php b/src/Core/Import/Configuration/ImportConfigInterface.php deleted file mode 100644 index 89dc5081..00000000 --- a/src/Core/Import/Configuration/ImportConfigInterface.php +++ /dev/null @@ -1,112 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Configuration; - -/** - * Interface ImportConfigInterface describes an import configuration VO. - */ -interface ImportConfigInterface -{ - /** - * Get the import file name. - * - * @return string - */ - public function getFileName(); - - /** - * Get the import entity type. - * - * @see constants defined in \PrestaShop\PrestaShop\Core\Import\Entity for available types. - * - * @return int - */ - public function getEntityType(); - - /** - * Get import language ISO code. - * - * @return string - */ - public function getLanguageIso(); - - /** - * Get import file's separator. - * - * @return string - */ - public function getSeparator(); - - /** - * Get import file's multiple value separator. - * - * @return string - */ - public function getMultipleValueSeparator(); - - /** - * Should the entity data be truncated before import. - * - * @return bool - */ - public function truncate(); - - /** - * Should skip the thumbnail regeneration after import. - * - * @return bool - */ - public function skipThumbnailRegeneration(); - - /** - * Should the product reference be used as import primary key. - * - * @return bool - */ - public function matchReferences(); - - /** - * Should the IDs from import file be used as-is. - * - * @return bool - */ - public function forceIds(); - - /** - * Should the system send a confirmation email when the import operation completes. - * - * @return bool - */ - public function sendEmail(); - - /** - * Get number of rows to skip from the beginning of import file. - * - * @return int - */ - public function getNumberOfRowsToSkip(); -} diff --git a/src/Core/Import/Configuration/ImportRuntimeConfig.php b/src/Core/Import/Configuration/ImportRuntimeConfig.php deleted file mode 100644 index ba1f1ae1..00000000 --- a/src/Core/Import/Configuration/ImportRuntimeConfig.php +++ /dev/null @@ -1,257 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Configuration; - -/** - * Class ImportRuntimeConfig defines import runtime configuration. - */ -final class ImportRuntimeConfig implements ImportRuntimeConfigInterface -{ - /** - * @var bool - */ - private $shouldValidateData; - - /** - * @var int - */ - private $offset; - - /** - * @var int - */ - private $limit; - - /** - * @var array import entity fields mapping - */ - private $entityFields; - - /** - * @var array - */ - private $sharedData = []; - - /** - * @var int - */ - private $stepIndex; - - /** - * @var int - */ - private $processedRows = 0; - - /** - * @var int request size in bytes - */ - private $requestSize; - - /** - * @var int post size limit in bytes - */ - private $postSizeLimit; - - /** - * @var int total number of rows to be imported - */ - private $totalNumberOfRows; - - /** - * @var array - */ - private $notices; - - /** - * @var array - */ - private $warnings; - - /** - * @var array - */ - private $errors; - - /** - * @param bool $shouldValidateData - * @param int $offset - * @param int $limit - * @param array $sharedData - * @param array $entityFields - */ - public function __construct( - $shouldValidateData, - $offset, - $limit, - array $sharedData, - array $entityFields - ) { - $this->shouldValidateData = $shouldValidateData; - $this->offset = $offset; - $this->limit = $limit; - $this->entityFields = $entityFields; - $this->sharedData = $sharedData; - } - - /** - * {@inheritdoc} - */ - public function shouldValidateData() - { - return $this->shouldValidateData; - } - - /** - * {@inheritdoc} - */ - public function getOffset() - { - return $this->offset; - } - - /** - * {@inheritdoc} - */ - public function getLimit() - { - return $this->limit; - } - - /** - * {@inheritdoc} - */ - public function getEntityFields() - { - return $this->entityFields; - } - - /** - * {@inheritdoc} - */ - public function getSharedData() - { - return $this->sharedData; - } - - /** - * {@inheritdoc} - */ - public function addSharedDataItem($key, $value) - { - $this->sharedData[$key] = $value; - } - - /** - * {@inheritdoc} - */ - public function isFinished() - { - return $this->processedRows < $this->limit; - } - - /** - * {@inheritdoc} - */ - public function setNumberOfProcessedRows($number) - { - $this->processedRows = $number; - } - - /** - * {@inheritdoc} - */ - public function getNumberOfProcessedRows() - { - return $this->processedRows; - } - - /** - * {@inheritdoc} - */ - public function setRequestSizeInBytes($size) - { - $this->requestSize = $size; - } - - /** - * {@inheritdoc} - */ - public function setPostSizeLimitInBytes($size) - { - $this->postSizeLimit = $size; - } - - /** - * {@inheritdoc} - */ - public function setTotalNumberOfRows($number) - { - $this->totalNumberOfRows = $number; - } - - /** - * {@inheritdoc} - */ - public function setNotices(array $notices) - { - $this->notices = $notices; - } - - /** - * {@inheritdoc} - */ - public function setWarnings(array $warnings) - { - $this->warnings = $warnings; - } - - /** - * {@inheritdoc} - */ - public function setErrors(array $errors) - { - $this->errors = $errors; - } - - /** - * {@inheritdoc} - */ - public function toArray() - { - return [ - 'crossStepsVariables' => $this->sharedData, - 'doneCount' => $this->processedRows + $this->offset, - 'isFinished' => $this->isFinished(), - 'nextPostSize' => $this->requestSize, - 'postSizeLimit' => $this->postSizeLimit, - 'totalCount' => $this->totalNumberOfRows, - 'notices' => $this->notices, - 'warnings' => $this->warnings, - 'errors' => $this->errors, - ]; - } -} diff --git a/src/Core/Import/Configuration/ImportRuntimeConfigFactory.php b/src/Core/Import/Configuration/ImportRuntimeConfigFactory.php deleted file mode 100644 index cc3c5ce5..00000000 --- a/src/Core/Import/Configuration/ImportRuntimeConfigFactory.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Configuration; - -use Symfony\Component\HttpFoundation\Request; - -/** - * Class ImportRuntimeConfigFactory is responsible for building import runtime config. - */ -final class ImportRuntimeConfigFactory implements ImportRuntimeConfigFactoryInterface -{ - /** - * {@inheritdoc} - */ - public function buildFromRequest(Request $request) - { - $sharedData = $request->request->get('crossStepsVars', []); - - return new ImportRuntimeConfig( - $request->request->getBoolean('validateOnly'), - $request->request->getInt('offset'), - $request->request->getInt('limit'), - json_decode($sharedData, true), - $request->request->get('type_value', []) - ); - } -} diff --git a/src/Core/Import/Configuration/ImportRuntimeConfigFactoryInterface.php b/src/Core/Import/Configuration/ImportRuntimeConfigFactoryInterface.php deleted file mode 100644 index 668ba108..00000000 --- a/src/Core/Import/Configuration/ImportRuntimeConfigFactoryInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Configuration; - -use Symfony\Component\HttpFoundation\Request; - -/** - * Interface ImportRuntimeConfigFactoryInterface describes an import runtime config factory. - */ -interface ImportRuntimeConfigFactoryInterface -{ - /** - * Build runtime config object out of request. - * - * @param Request $request - * - * @return ImportRuntimeConfigInterface - */ - public function buildFromRequest(Request $request); -} diff --git a/src/Core/Import/Configuration/ImportRuntimeConfigInterface.php b/src/Core/Import/Configuration/ImportRuntimeConfigInterface.php deleted file mode 100644 index 778e147f..00000000 --- a/src/Core/Import/Configuration/ImportRuntimeConfigInterface.php +++ /dev/null @@ -1,156 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Configuration; - -/** - * Interface ImportRuntimeConfigInterface describes import runtime configuration. - * Since import is a multi-process operation, this configuration can change - * during each import process. - */ -interface ImportRuntimeConfigInterface -{ - /** - * Checks if import should validate the data instead of importing it. - * - * @return bool - */ - public function shouldValidateData(); - - /** - * Get current import offset. - * Works similarly to SQL offset. - * - * @return int - */ - public function getOffset(); - - /** - * Get current import limit. - * Similar to SQL limit. - * - * @return int - */ - public function getLimit(); - - /** - * Get the data, that is shared between import processes. - * - * @return array - */ - public function getSharedData(); - - /** - * Add a shared data item. - * - * @param string $key - * @param mixed $value - */ - public function addSharedDataItem($key, $value); - - /** - * Get import entity fields. - * - * @return array - */ - public function getEntityFields(); - - /** - * Get number of rows processed in current import iteration. - * - * @return int - */ - public function getNumberOfProcessedRows(); - - /** - * Check if the import is completely finished. - * - * @return bool - */ - public function isFinished(); - - /** - * Set number of rows processed during import process runtime. - * - * @param int $number - */ - public function setNumberOfProcessedRows($number); - - /** - * Set request size in bytes. - * - * @param int $size - */ - public function setRequestSizeInBytes($size); - - /** - * Set post size limit in bytes. - * - * @param int $size - */ - public function setPostSizeLimitInBytes($size); - - /** - * Set the total number of rows to be imported. - * - * @param $number - */ - public function setTotalNumberOfRows($number); - - /** - * Set notices that occurred during the import process. - * - * @param array $notices - * - * @return array - */ - public function setNotices(array $notices); - - /** - * Set warnings that occurred during the import process. - * - * @param array $warnings - * - * @return array - */ - public function setWarnings(array $warnings); - - /** - * Set errors that occurred during the import process. - * - * @param array $errors - * - * @return array - */ - public function setErrors(array $errors); - - /** - * Convert object to an array. - * - * @return array - */ - public function toArray(); -} diff --git a/src/Core/Import/CsvValueSeparatorNormalizer.php b/src/Core/Import/CsvValueSeparatorNormalizer.php deleted file mode 100644 index 126d2869..00000000 --- a/src/Core/Import/CsvValueSeparatorNormalizer.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import; - -/** - * Class CsvValueSeparatorNormalizer normalizes import separator before usage. - */ -final class CsvValueSeparatorNormalizer implements StringNormalizerInterface -{ - /** - * {@inheritdoc} - */ - public function normalize($value) - { - $value = trim($value); - $value = substr($value, 0, 1); - - return $value ?: ImportSettings::DEFAULT_SEPARATOR; - } -} diff --git a/src/Core/Import/Entity.php b/src/Core/Import/Entity.php deleted file mode 100644 index 3d0df9ea..00000000 --- a/src/Core/Import/Entity.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import; - -use PrestaShop\PrestaShop\Core\Import\Exception\NotSupportedImportTypeException; - -/** - * Class Entity defines available import entities. - */ -final class Entity -{ - const TYPE_CATEGORIES = 0; - const TYPE_PRODUCTS = 1; - const TYPE_COMBINATIONS = 2; - const TYPE_CUSTOMERS = 3; - const TYPE_ADDRESSES = 4; - const TYPE_MANUFACTURERS = 5; - const TYPE_SUPPLIERS = 6; - const TYPE_ALIAS = 7; - const TYPE_STORE_CONTACTS = 8; - - const AVAILABLE_TYPES = [ - 'categories' => self::TYPE_CATEGORIES, - 'products' => self::TYPE_PRODUCTS, - 'combinations' => self::TYPE_COMBINATIONS, - 'customers' => self::TYPE_CUSTOMERS, - 'addresses' => self::TYPE_ADDRESSES, - 'manufacturers' => self::TYPE_MANUFACTURERS, - 'suppliers' => self::TYPE_SUPPLIERS, - 'alias' => self::TYPE_ALIAS, - 'contacts' => self::TYPE_STORE_CONTACTS, - ]; - - /** - * Get import entity type from name. - * - * @param string $importType - * - * @return string - */ - public static function getFromName($importType) - { - if (array_key_exists($importType, self::AVAILABLE_TYPES)) { - return self::AVAILABLE_TYPES[$importType]; - } - - throw new NotSupportedImportTypeException(sprintf('Import type with name "%s" is not supported.', $importType)); - } - - /** - * Class is not supposed to be initialized. - */ - private function __construct() - { - } -} diff --git a/src/Core/Import/Entity/ImportEntityDeleterInterface.php b/src/Core/Import/Entity/ImportEntityDeleterInterface.php deleted file mode 100644 index ebc54f9c..00000000 --- a/src/Core/Import/Entity/ImportEntityDeleterInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Entity; - -/** - * Interface ImportEntityDeleterInterface describes an import entity deleter. - */ -interface ImportEntityDeleterInterface -{ - /** - * Delete all import entity data for given import entity type. - * - * @param int $importEntity - */ - public function deleteAll($importEntity); -} diff --git a/src/Core/Import/EntityField/EntityField.php b/src/Core/Import/EntityField/EntityField.php deleted file mode 100644 index 9eb73aa1..00000000 --- a/src/Core/Import/EntityField/EntityField.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\EntityField; - -/** - * Class EntityField defines an entity field. - */ -final class EntityField implements EntityFieldInterface -{ - /** - * @var string - */ - private $name; - - /** - * @var string - */ - private $label; - - /** - * @var string - */ - private $description; - - /** - * @var bool - */ - private $required; - - /** - * @param string $name - * @param string $label - * @param string $description - * @param bool $required - */ - public function __construct($name, $label, $description = '', $required = false) - { - $this->name = $name; - $this->label = $label; - $this->description = $description; - $this->required = $required; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * Get field's label. - * - * @return string - */ - public function getLabel() - { - return $this->label; - } - - /** - * Get field's description. - * - * @return string - */ - public function getDescription() - { - return $this->description; - } - - /** - * {@inheritdoc} - */ - public function isRequired() - { - return $this->required; - } -} diff --git a/src/Core/Import/EntityField/EntityFieldCollection.php b/src/Core/Import/EntityField/EntityFieldCollection.php deleted file mode 100644 index c1ecb315..00000000 --- a/src/Core/Import/EntityField/EntityFieldCollection.php +++ /dev/null @@ -1,148 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\EntityField; - -use ArrayIterator; - -/** - * Class EntityFieldCollection defines an entity field collection. - */ -final class EntityFieldCollection implements EntityFieldCollectionInterface -{ - /** - * @var array - */ - private $entityFields = []; - - /** - * {@inheritdoc} - */ - public function addEntityField(EntityFieldInterface $entityField) - { - $this->entityFields[] = $entityField; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getRequiredFields() - { - $requiredFields = []; - - /** @var EntityFieldInterface $entityField */ - foreach ($this->entityFields as $entityField) { - if ($entityField->isRequired()) { - $requiredFields[] = $entityField->getName(); - } - } - - return $requiredFields; - } - - /** - * {@inheritdoc} - */ - public function toArray() - { - $array = []; - - /** @var EntityFieldInterface $entityField */ - foreach ($this->entityFields as $entityField) { - $array[] = [ - 'label' => $entityField->getLabel(), - 'description' => $entityField->getDescription(), - 'required' => $entityField->isRequired(), - ]; - } - - return $array; - } - - /** - * {@inheritdoc} - */ - public static function createFromArray(array $entityFields) - { - $collection = new self(); - - foreach ($entityFields as $entityField) { - $collection->addEntityField($entityField); - } - - return $collection; - } - - /** - * {@inheritdoc} - */ - public function offsetExists($offset) - { - return array_key_exists($offset, $this->entityFields); - } - - /** - * {@inheritdoc} - */ - public function offsetGet($offset) - { - return $this->entityFields[$offset]; - } - - /** - * {@inheritdoc} - */ - public function offsetSet($offset, $value) - { - $this->entityFields[$offset] = $value; - } - - /** - * {@inheritdoc} - */ - public function offsetUnset($offset) - { - unset($this->entityFields[$offset]); - } - - /** - * {@inheritdoc} - */ - public function getIterator() - { - return new ArrayIterator($this->entityFields); - } - - /** - * {@inheritdoc} - */ - public function count() - { - return count($this->entityFields); - } -} diff --git a/src/Core/Import/EntityField/EntityFieldCollectionInterface.php b/src/Core/Import/EntityField/EntityFieldCollectionInterface.php deleted file mode 100644 index 36d29911..00000000 --- a/src/Core/Import/EntityField/EntityFieldCollectionInterface.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\EntityField; - -use ArrayAccess; -use Countable; -use IteratorAggregate; - -/** - * Interface EntityFieldCollectionInterface describes a collection of entity fields. - */ -interface EntityFieldCollectionInterface extends ArrayAccess, Countable, IteratorAggregate -{ - /** - * Add an entity field to the collection. - * - * @param EntityFieldInterface $entityField - * - * @return self - */ - public function addEntityField(EntityFieldInterface $entityField); - - /** - * Get required fields from the collection. - * - * @return array - */ - public function getRequiredFields(); - - /** - * Creates a collection from array of entity fields. - * - * @param array $entityFields array of objects implementing EntityFieldInterface - * - * @return self - */ - public static function createFromArray(array $entityFields); - - /** - * Converts the collection to array. - * - * @return array - */ - public function toArray(); -} diff --git a/src/Core/Import/EntityField/EntityFieldInterface.php b/src/Core/Import/EntityField/EntityFieldInterface.php deleted file mode 100644 index f1854c9e..00000000 --- a/src/Core/Import/EntityField/EntityFieldInterface.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\EntityField; - -/** - * Interface EntityFieldInterface describes an entity field. - */ -interface EntityFieldInterface -{ - /** - * Get field's name. - * - * @return string - */ - public function getName(); - - /** - * Get field's label. - * - * @return string - */ - public function getLabel(); - - /** - * Get field's description. - * - * @return string - */ - public function getDescription(); - - /** - * Checks if the field is required. - * - * @return bool - */ - public function isRequired(); -} diff --git a/src/Core/Import/EntityField/Provider/AddressFieldsProvider.php b/src/Core/Import/EntityField/Provider/AddressFieldsProvider.php deleted file mode 100644 index 120ab228..00000000 --- a/src/Core/Import/EntityField/Provider/AddressFieldsProvider.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\EntityField\Provider; - -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityField; -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityFieldCollection; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class AddressFieldsProvider defines an address fields provider. - */ -final class AddressFieldsProvider implements EntityFieldsProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getCollection() - { - $fields = [ - new EntityField('id', $this->trans('ID', 'Admin.Global')), - new EntityField('alias', $this->trans('Alias', 'Admin.Shopparameters.Feature'), '', true), - new EntityField('active', $this->trans('Active (0/1)', 'Admin.Advparameters.Feature')), - new EntityField('customer_email', $this->trans('Customer email', 'Admin.Advparameters.Feature'), '', true), - new EntityField('id_customer', $this->trans('Customer ID', 'Admin.Advparameters.Feature')), - new EntityField('manufacturer', $this->trans('Brand', 'Admin.Global')), - new EntityField('supplier', $this->trans('Supplier', 'Admin.Global')), - new EntityField('company', $this->trans('Company', 'Admin.Global')), - new EntityField('lastname', $this->trans('Last name', 'Admin.Global'), '', true), - new EntityField('firstname', $this->trans('First name', 'Admin.Global'), '', true), - new EntityField('address1', $this->trans('Address', 'Admin.Global'), '', true), - new EntityField('address2', $this->trans('Address (2)', 'Admin.Global')), - new EntityField('postcode', $this->trans('Zip/postal code', 'Admin.Global'), '', true), - new EntityField('city', $this->trans('City', 'Admin.Global'), '', true), - new EntityField('country', $this->trans('Country', 'Admin.Global'), '', true), - new EntityField('state', $this->trans('State', 'Admin.Global')), - new EntityField('other', $this->trans('Other', 'Admin.Global')), - new EntityField('phone', $this->trans('Phone', 'Admin.Global')), - new EntityField('phone_mobile', $this->trans('Mobile Phone', 'Admin.Global')), - new EntityField('vat_number', $this->trans('VAT number', 'Admin.Orderscustomers.Feature')), - new EntityField('dni', $this->trans('Identification number', 'Admin.Orderscustomers.Feature')), - ]; - - return EntityFieldCollection::createFromArray($fields); - } - - /** - * A shorter name method for translations. - * - * @param string $id translation ID - * @param string $domain translation domain - * - * @return string - */ - private function trans($id, $domain = 'Admin.Advparameters.Feature') - { - return $this->translator->trans($id, [], $domain); - } -} diff --git a/src/Core/Import/EntityField/Provider/AliasFieldsProvider.php b/src/Core/Import/EntityField/Provider/AliasFieldsProvider.php deleted file mode 100644 index 4008104b..00000000 --- a/src/Core/Import/EntityField/Provider/AliasFieldsProvider.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\EntityField\Provider; - -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityField; -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityFieldCollection; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class AliasFieldsProvider defines an alias fields provider. - */ -final class AliasFieldsProvider implements EntityFieldsProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getCollection() - { - $fields = [ - new EntityField('id', $this->trans('ID', 'Admin.Global')), - new EntityField('alias', $this->trans('Alias', 'Admin.Shopparameters.Feature'), '', true), - new EntityField('search', $this->trans('Search', 'Admin.Shopparameters.Feature'), '', true), - new EntityField('active', $this->trans('Active', 'Admin.Global')), - ]; - - return EntityFieldCollection::createFromArray($fields); - } - - /** - * A shorter name method for translations. - * - * @param string $id translation ID - * @param string $domain translation domain - * - * @return string - */ - private function trans($id, $domain = 'Admin.Advparameters.Feature') - { - return $this->translator->trans($id, [], $domain); - } -} diff --git a/src/Core/Import/EntityField/Provider/CategoryFieldsProvider.php b/src/Core/Import/EntityField/Provider/CategoryFieldsProvider.php deleted file mode 100644 index 6205d1ce..00000000 --- a/src/Core/Import/EntityField/Provider/CategoryFieldsProvider.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\EntityField\Provider; - -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityField; -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityFieldCollection; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class CategoryFieldsProvider defines a category fields provider. - */ -final class CategoryFieldsProvider implements EntityFieldsProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getCollection() - { - $fields = [ - new EntityField('id', $this->trans('ID', 'Admin.Global')), - new EntityField('active', $this->trans('Active (0/1)', 'Admin.Advparameters.Feature')), - new EntityField('name', $this->trans('Name', 'Admin.Global')), - new EntityField('parent', $this->trans('Parent category', 'Admin.Catalog.Feature')), - new EntityField( - 'is_root_category', - $this->trans('Root category (0/1)', 'Admin.Advparameters.Feature'), - $this->trans('A category root is where a category tree can begin. This is used with multistore.', 'Admin.Advparameters.Help') - ), - new EntityField('description', $this->trans('Description', 'Admin.Global')), - new EntityField('meta_title', $this->trans('Meta title', 'Admin.Global')), - new EntityField('meta_keywords', $this->trans('Meta keywords', 'Admin.Global')), - new EntityField('meta_description', $this->trans('Meta description', 'Admin.Global')), - new EntityField('link_rewrite', $this->trans('Rewritten URL', 'Admin.Shopparameters.Feature')), - new EntityField('image', $this->trans('Image URL', 'Admin.Advparameters.Feature')), - new EntityField( - 'shop', - $this->trans('ID / Name of shop', 'Admin.Advparameters.Feature'), - $this->trans('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.', 'Admin.Advparameters.Help') - ), - ]; - - return EntityFieldCollection::createFromArray($fields); - } - - /** - * A shorter name method for translations. - * - * @param string $id translation ID - * @param string $domain translation domain - * - * @return string - */ - private function trans($id, $domain = 'Admin.Advparameters.Feature') - { - return $this->translator->trans($id, [], $domain); - } -} diff --git a/src/Core/Import/EntityField/Provider/CombinationFieldsProvider.php b/src/Core/Import/EntityField/Provider/CombinationFieldsProvider.php deleted file mode 100644 index 12b1af56..00000000 --- a/src/Core/Import/EntityField/Provider/CombinationFieldsProvider.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\EntityField\Provider; - -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityField; -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityFieldCollection; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class CombinationFieldsProvider defines a combination fields provider. - */ -final class CombinationFieldsProvider implements EntityFieldsProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getCollection() - { - $fields = [ - new EntityField('id_product', $this->trans('Product ID', 'Admin.Advparameters.Feature')), - new EntityField('product_reference', $this->trans('Product reference', 'Admin.Advparameters.Feature')), - new EntityField('group', $this->trans('Attribute (Name:Type:Position)', 'Admin.Advparameters.Feature'), '', true), - new EntityField('attribute', $this->trans('Value (Value:Position)', 'Admin.Advparameters.Feature'), '', true), - new EntityField('supplier_reference', $this->trans('Supplier reference', 'Admin.Advparameters.Feature')), - new EntityField('reference', $this->trans('Reference', 'Admin.Global')), - new EntityField('ean13', $this->trans('EAN13', 'Admin.Advparameters.Feature')), - new EntityField('upc', $this->trans('UPC', 'Admin.Advparameters.Feature')), - new EntityField('mpn', $this->trans('MPN', 'Admin.Catalog.Feature')), - new EntityField('wholesale_price', $this->trans('Cost price', 'Admin.Catalog.Feature')), - new EntityField('price', $this->trans('Impact on price', 'Admin.Catalog.Feature')), - new EntityField('ecotax', $this->trans('Ecotax', 'Admin.Catalog.Feature')), - new EntityField('quantity', $this->trans('Quantity', 'Admin.Global')), - new EntityField('minimal_quantity', $this->trans('Minimal quantity', 'Admin.Advparameters.Feature')), - new EntityField('low_stock_threshold', $this->trans('Low stock level', 'Admin.Catalog.Feature')), - new EntityField( - 'low_stock_alert', - $this->trans('Send me an email when the quantity is under this level', 'Admin.Catalog.Feature') - ), - new EntityField('weight', $this->trans('Impact on weight', 'Admin.Catalog.Feature')), - new EntityField('default_on', $this->trans('Default (0 = No, 1 = Yes)', 'Admin.Advparameters.Feature')), - new EntityField('available_date', $this->trans('Combination availability date', 'Admin.Advparameters.Feature')), - new EntityField('image_position', $this->trans('Choose among product images by position (1,2,3...)', 'Admin.Advparameters.Feature')), - new EntityField('image_url', $this->trans('Image URLs (x,y,z...)', 'Admin.Advparameters.Feature')), - new EntityField('image_alt', $this->trans('Image alt texts (x,y,z...)', 'Admin.Advparameters.Feature')), - new EntityField( - 'shop', - $this->trans('ID / Name of shop', 'Admin.Advparameters.Feature'), - $this->trans('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.', 'Admin.Advparameters.Help') - ), - new EntityField( - 'advanced_stock_management', - $this->trans('Advanced Stock Management', 'Admin.Advparameters.Feature'), - $this->trans('Enable Advanced Stock Management on product (0 = No, 1 = Yes)', 'Admin.Advparameters.Help') - ), - new EntityField( - 'depends_on_stock', - $this->trans('Depends on stock', 'Admin.Advparameters.Feature'), - $this->trans('0 = Use quantity set in product, 1 = Use quantity from warehouse.', 'Admin.Advparameters.Help') - ), - new EntityField( - 'warehouse', - $this->trans('Warehouse', 'Admin.Advparameters.Feature'), - $this->trans('ID of the warehouse to set as storage.', 'Admin.Advparameters.Help') - ), - ]; - - return EntityFieldCollection::createFromArray($fields); - } - - /** - * A shorter name method for translations. - * - * @param string $id translation ID - * @param string $domain translation domain - * - * @return string - */ - private function trans($id, $domain = 'Admin.Advparameters.Feature') - { - return $this->translator->trans($id, [], $domain); - } -} diff --git a/src/Core/Import/EntityField/Provider/CustomerFieldsProvider.php b/src/Core/Import/EntityField/Provider/CustomerFieldsProvider.php deleted file mode 100644 index c265604c..00000000 --- a/src/Core/Import/EntityField/Provider/CustomerFieldsProvider.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\EntityField\Provider; - -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityField; -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityFieldCollection; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class CustomerFieldsProvider defines a customer fields provider. - */ -final class CustomerFieldsProvider implements EntityFieldsProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getCollection() - { - $fields = [ - new EntityField('id', $this->trans('ID', 'Admin.Global')), - new EntityField('active', $this->trans('Active (0/1)', 'Admin.Advparameters.Feature')), - new EntityField('id_gender', $this->trans('Titles ID (Mr = 1, Ms = 2, else 0)', 'Admin.Advparameters.Feature')), - new EntityField('email', $this->trans('Email', 'Admin.Global'), '', true), - new EntityField('passwd', $this->trans('Password', 'Admin.Global'), '', true), - new EntityField('birthday', $this->trans('Birth date (yyyy-mm-dd)', 'Admin.Advparameters.Feature')), - new EntityField('lastname', $this->trans('Last name', 'Admin.Global'), '', true), - new EntityField('firstname', $this->trans('First name', 'Admin.Global'), '', true), - new EntityField('newsletter', $this->trans('Newsletter (0/1)', 'Admin.Advparameters.Feature')), - new EntityField('optin', $this->trans('Partner offers (0/1)', 'Admin.Advparameters.Feature')), - new EntityField('date_add', $this->trans('Registration date (yyyy-mm-dd)', 'Admin.Advparameters.Feature')), - new EntityField('group', $this->trans('Groups (x,y,z...)', 'Admin.Advparameters.Feature')), - new EntityField('id_default_group', $this->trans('Default group ID', 'Admin.Advparameters.Feature')), - new EntityField( - 'id_shop', - $this->trans('ID / Name of shop', 'Admin.Advparameters.Feature'), - $this->trans('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.', 'Admin.Advparameters.Help') - ), - ]; - - return EntityFieldCollection::createFromArray($fields); - } - - /** - * A shorter name method for translations. - * - * @param string $id translation ID - * @param string $domain translation domain - * - * @return string - */ - private function trans($id, $domain = 'Admin.Advparameters.Feature') - { - return $this->translator->trans($id, [], $domain); - } -} diff --git a/src/Core/Import/EntityField/Provider/EntityFieldsProviderFinder.php b/src/Core/Import/EntityField/Provider/EntityFieldsProviderFinder.php deleted file mode 100644 index 25796905..00000000 --- a/src/Core/Import/EntityField/Provider/EntityFieldsProviderFinder.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\EntityField\Provider; - -use PrestaShop\PrestaShop\Core\Import\Exception\NotSupportedImportEntityException; - -/** - * Class EntityFieldsProviderFinder defines an entity fields provider finder. - */ -final class EntityFieldsProviderFinder implements EntityFieldsProviderFinderInterface -{ - /** - * @var array of entity fields providers - */ - private $entityFieldsProviders; - - /** - * @param array $entityFieldsProviders - */ - public function __construct(array $entityFieldsProviders) - { - $this->entityFieldsProviders = $entityFieldsProviders; - } - - /** - * {@inheritdoc} - */ - public function find($importEntity) - { - if (!isset($this->entityFieldsProviders[$importEntity])) { - throw new NotSupportedImportEntityException("Entity fields provider does not exist for entity $importEntity."); - } - - return $this->entityFieldsProviders[$importEntity]; - } -} diff --git a/src/Core/Import/EntityField/Provider/EntityFieldsProviderFinderInterface.php b/src/Core/Import/EntityField/Provider/EntityFieldsProviderFinderInterface.php deleted file mode 100644 index 5aefc1ae..00000000 --- a/src/Core/Import/EntityField/Provider/EntityFieldsProviderFinderInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\EntityField\Provider; - -/** - * Interface EntityFieldsProviderFinderInterface describes an entity fields finder. - */ -interface EntityFieldsProviderFinderInterface -{ - /** - * Find the appropriate entity fields provider. - * - * @param int $importEntity import entity ID (@see PrestaShop\PrestaShop\Core\Import\Entity) - * - * @return EntityFieldsProviderInterface - */ - public function find($importEntity); -} diff --git a/src/Core/Import/EntityField/Provider/EntityFieldsProviderInterface.php b/src/Core/Import/EntityField/Provider/EntityFieldsProviderInterface.php deleted file mode 100644 index c86ab17d..00000000 --- a/src/Core/Import/EntityField/Provider/EntityFieldsProviderInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\EntityField\Provider; - -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityFieldCollectionInterface; - -/** - * Interface EntityFieldsProviderInterface defines a provider of entity fields. - */ -interface EntityFieldsProviderInterface -{ - /** - * Get entity field as a collection. - * - * @return EntityFieldCollectionInterface - */ - public function getCollection(); -} diff --git a/src/Core/Import/EntityField/Provider/ProductFieldsProvider.php b/src/Core/Import/EntityField/Provider/ProductFieldsProvider.php deleted file mode 100644 index 979ecf97..00000000 --- a/src/Core/Import/EntityField/Provider/ProductFieldsProvider.php +++ /dev/null @@ -1,193 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\EntityField\Provider; - -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityField; -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityFieldCollection; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class ProductFieldsProvider defines a product fields provider. - */ -final class ProductFieldsProvider implements EntityFieldsProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getCollection() - { - $fields = [ - new EntityField('id', $this->trans('ID', 'Admin.Global')), - new EntityField('active', $this->trans('Active (0/1)', 'Admin.Advparameters.Feature')), - new EntityField('name', $this->trans('Name', 'Admin.Global')), - new EntityField('category', $this->trans('Categories (x,y,z...)', 'Admin.Advparameters.Feature')), - new EntityField('price_tex', $this->trans('Price tax excluded', 'Admin.Advparameters.Feature')), - new EntityField('price_tin', $this->trans('Price tax included', 'Admin.Advparameters.Feature')), - new EntityField('id_tax_rules_group', $this->trans('Tax rule ID', 'Admin.Advparameters.Feature')), - new EntityField('wholesale_price', $this->trans('Cost price', 'Admin.Catalog.Feature')), - new EntityField('on_sale', $this->trans('On sale (0/1)', 'Admin.Advparameters.Feature')), - new EntityField('reduction_price', $this->trans('Discount amount', 'Admin.Advparameters.Feature')), - new EntityField('reduction_percent', $this->trans('Discount percent', 'Admin.Advparameters.Feature')), - new EntityField('reduction_from', $this->trans('Discount from (yyyy-mm-dd)', 'Admin.Advparameters.Feature')), - new EntityField('reduction_to', $this->trans('Discount to (yyyy-mm-dd)', 'Admin.Advparameters.Feature')), - new EntityField('reference', $this->trans('Reference #', 'Admin.Advparameters.Feature')), - new EntityField('supplier_reference', $this->trans('Supplier reference #', 'Admin.Advparameters.Feature')), - new EntityField('supplier', $this->trans('Supplier', 'Admin.Global')), - new EntityField('manufacturer', $this->trans('Brand', 'Admin.Global')), - new EntityField('ean13', $this->trans('EAN13', 'Admin.Advparameters.Feature')), - new EntityField('upc', $this->trans('UPC', 'Admin.Advparameters.Feature')), - new EntityField('mpn', $this->trans('MPN', 'Admin.Catalog.Feature')), - new EntityField('ecotax', $this->trans('Ecotax', 'Admin.Catalog.Feature')), - new EntityField('width', $this->trans('Width', 'Admin.Global')), - new EntityField('height', $this->trans('Height', 'Admin.Global')), - new EntityField('depth', $this->trans('Depth', 'Admin.Global')), - new EntityField('weight', $this->trans('Weight', 'Admin.Global')), - new EntityField( - 'delivery_in_stock', - $this->trans('Delivery time of in-stock products:', 'Admin.Catalog.Feature') - ), - new EntityField( - 'delivery_out_stock', - $this->trans('Delivery time of out-of-stock products with allowed orders:', 'Admin.Advparameters.Feature') - ), - new EntityField('quantity', $this->trans('Quantity', 'Admin.Global')), - new EntityField('minimal_quantity', $this->trans('Minimal quantity', 'Admin.Advparameters.Feature')), - new EntityField('low_stock_threshold', $this->trans('Low stock level', 'Admin.Catalog.Feature')), - new EntityField( - 'low_stock_alert', - $this->trans('Send me an email when the quantity is under this level', 'Admin.Catalog.Feature') - ), - new EntityField('visibility', $this->trans('Visibility', 'Admin.Catalog.Feature')), - new EntityField('additional_shipping_cost', $this->trans('Additional shipping cost', 'Admin.Advparameters.Feature')), - new EntityField('unity', $this->trans('Unit for the price per unit', 'Admin.Advparameters.Feature')), - new EntityField('unit_price', $this->trans('Price per unit', 'Admin.Advparameters.Feature')), - new EntityField('description_short', $this->trans('Summary', 'Admin.Catalog.Feature')), - new EntityField('description', $this->trans('Description', 'Admin.Global')), - new EntityField('tags', $this->trans('Tags (x,y,z...)', 'Admin.Advparameters.Feature')), - new EntityField('meta_title', $this->trans('Meta title', 'Admin.Global')), - new EntityField('meta_keywords', $this->trans('Meta keywords', 'Admin.Global')), - new EntityField('meta_description', $this->trans('Meta description', 'Admin.Global')), - new EntityField('link_rewrite', $this->trans('Rewritten URL', 'Admin.Advparameters.Feature')), - new EntityField('available_now', $this->trans('Label when in stock', 'Admin.Catalog.Feature')), - new EntityField('available_later', $this->trans('Label when backorder allowed', 'Admin.Advparameters.Feature')), - new EntityField('available_for_order', $this->trans('Available for order (0 = No, 1 = Yes)', 'Admin.Advparameters.Feature')), - new EntityField('available_date', $this->trans('Product availability date', 'Admin.Advparameters.Feature')), - new EntityField('date_add', $this->trans('Product creation date', 'Admin.Advparameters.Feature')), - new EntityField('show_price', $this->trans('Show price (0 = No, 1 = Yes)', 'Admin.Advparameters.Feature')), - new EntityField('image', $this->trans('Image URLs (x,y,z...)', 'Admin.Advparameters.Feature')), - new EntityField('image_alt', $this->trans('Image alt texts (x,y,z...)', 'Admin.Advparameters.Feature')), - new EntityField('delete_existing_images', $this->trans('Delete existing images (0 = No, 1 = Yes)', 'Admin.Advparameters.Feature')), - new EntityField('features', $this->trans('Feature (Name:Value:Position:Customized)', 'Admin.Advparameters.Feature')), - new EntityField('online_only', $this->trans('Available online only (0 = No, 1 = Yes)', 'Admin.Advparameters.Feature')), - new EntityField('condition', $this->trans('Condition', 'Admin.Catalog.Feature')), - new EntityField('customizable', $this->trans('Customizable (0 = No, 1 = Yes)', 'Admin.Advparameters.Feature')), - new EntityField('uploadable_files', $this->trans('Uploadable files (0 = No, 1 = Yes)', 'Admin.Advparameters.Feature')), - new EntityField('text_fields', $this->trans('Text fields (0 = No, 1 = Yes)', 'Admin.Advparameters.Feature')), - new EntityField('out_of_stock', $this->trans('Action when out of stock', 'Admin.Advparameters.Feature')), - new EntityField('is_virtual', $this->trans('Virtual product (0 = No, 1 = Yes)', 'Admin.Advparameters.Feature')), - new EntityField('file_url', $this->trans('File URL', 'Admin.Advparameters.Feature')), - new EntityField( - 'nb_downloadable', - $this->trans('Number of allowed downloads', 'Admin.Catalog.Feature'), - $this->trans( - 'Number of days this file can be accessed by customers. Set to zero for unlimited access.', - 'Admin.Catalog.Help' - ) - ), - new EntityField('date_expiration', $this->trans('Expiration date (yyyy-mm-dd)', 'Admin.Advparameters.Feature')), - new EntityField( - 'nb_days_accessible', - $this->trans('Number of days', 'Admin.Advparameters.Feature'), - $this->trans( - 'Number of days this file can be accessed by customers. Set to zero for unlimited access.', - 'Admin.Catalog.Help' - ) - ), - new EntityField( - 'shop', - $this->trans('ID / Name of shop', 'Admin.Advparameters.Feature'), - $this->trans( - 'Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.', - 'Admin.Advparameters.Help' - ) - ), - new EntityField( - 'advanced_stock_management', - $this->trans('Advanced Stock Management', 'Admin.Advparameters.Feature'), - $this->trans( - 'Enable Advanced Stock Management on product (0 = No, 1 = Yes).', - 'Admin.Advparameters.Help' - ) - ), - new EntityField( - 'depends_on_stock', - $this->trans('Depends on stock', 'Admin.Advparameters.Feature'), - $this->trans( - '0 = Use quantity set in product, 1 = Use quantity from warehouse.', - 'Admin.Advparameters.Help' - ) - ), - new EntityField( - 'warehouse', - $this->trans('Warehouse', 'Admin.Advparameters.Feature'), - $this->trans( - 'ID of the warehouse to set as storage.', - 'Admin.Advparameters.Help' - ) - ), - new EntityField('accessories', $this->trans('Accessories (x,y,z...)', 'Admin.Advparameters.Feature')), - ]; - - return EntityFieldCollection::createFromArray($fields); - } - - /** - * A shorter name method for translations. - * - * @param string $id translation ID - * @param string $domain translation domain - * - * @return string - */ - private function trans($id, $domain = 'Admin.Advparameters.Feature') - { - return $this->translator->trans($id, [], $domain); - } -} diff --git a/src/Core/Import/EntityField/Provider/StoreContactFieldsProvider.php b/src/Core/Import/EntityField/Provider/StoreContactFieldsProvider.php deleted file mode 100644 index ed0474ba..00000000 --- a/src/Core/Import/EntityField/Provider/StoreContactFieldsProvider.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\EntityField\Provider; - -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityField; -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityFieldCollection; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class StoreContactFieldCollectionFactory defines a store contact fields provider. - */ -final class StoreContactFieldsProvider implements EntityFieldsProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getCollection() - { - $fields = [ - new EntityField('id', $this->trans('ID', 'Admin.Global')), - new EntityField('active', $this->trans('Active (0/1)', 'Admin.Advparameters.Feature')), - new EntityField('name', $this->trans('Name', 'Admin.Global')), - new EntityField('address1', $this->trans('Address', 'Admin.Global'), '', true), - new EntityField('address2', $this->trans('Address (2)', 'Admin.Advparameters.Feature')), - new EntityField('postcode', $this->trans('Zip/postal code', 'Admin.Global')), - new EntityField('state', $this->trans('State', 'Admin.Global')), - new EntityField('city', $this->trans('City', 'Admin.Global'), '', true), - new EntityField('country', $this->trans('Country', 'Admin.Global'), '', true), - new EntityField('latitude', $this->trans('Latitude', 'Admin.Advparameters.Feature'), '', true), - new EntityField('longitude', $this->trans('Longitude', 'Admin.Advparameters.Feature'), '', true), - new EntityField('phone', $this->trans('Phone', 'Admin.Global')), - new EntityField('fax', $this->trans('Fax', 'Admin.Global')), - new EntityField('email', $this->trans('Email address', 'Admin.Global')), - new EntityField('note', $this->trans('Note', 'Admin.Global')), - new EntityField('hours', $this->trans('Hours (x,y,z...)', 'Admin.Advparameters.Feature')), - new EntityField('image', $this->trans('Image URL', 'Admin.Advparameters.Feature')), - new EntityField( - 'shop', - $this->trans('ID / Name of shop', 'Admin.Advparameters.Feature'), - $this->trans('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.', 'Admin.Advparameters.Help') - ), - ]; - - return EntityFieldCollection::createFromArray($fields); - } - - /** - * A shorter name method for translations. - * - * @param string $id translation ID - * @param string $domain translation domain - * - * @return string - */ - private function trans($id, $domain = 'Admin.Advparameters.Feature') - { - return $this->translator->trans($id, [], $domain); - } -} diff --git a/src/Core/Import/EntityField/Provider/SupplierFieldsProvider.php b/src/Core/Import/EntityField/Provider/SupplierFieldsProvider.php deleted file mode 100644 index b6a82088..00000000 --- a/src/Core/Import/EntityField/Provider/SupplierFieldsProvider.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\EntityField\Provider; - -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityField; -use PrestaShop\PrestaShop\Core\Import\EntityField\EntityFieldCollection; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class SupplierFieldsProvider defines a supplier fields provider. - */ -final class SupplierFieldsProvider implements EntityFieldsProviderInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function getCollection() - { - $fields = [ - new EntityField('id', $this->trans('ID', 'Admin.Global')), - new EntityField('active', $this->trans('Active (0/1)', 'Admin.Advparameters.Feature')), - new EntityField('name', $this->trans('Name', 'Admin.Global')), - new EntityField('description', $this->trans('Description', 'Admin.Global')), - new EntityField('short_description', $this->trans('Short description', 'Admin.Catalog.Feature')), - new EntityField('meta_title', $this->trans('Meta title', 'Admin.Global')), - new EntityField('meta_keywords', $this->trans('Meta keywords', 'Admin.Global')), - new EntityField('meta_description', $this->trans('Meta description', 'Admin.Global')), - new EntityField('image', $this->trans('Image URL', 'Admin.Advparameters.Feature')), - new EntityField( - 'shop', - $this->trans('ID / Name of group shop', 'Admin.Advparameters.Feature'), - $this->trans('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.', 'Admin.Advparameters.Help') - ), - ]; - - return EntityFieldCollection::createFromArray($fields); - } - - /** - * A shorter name method for translations. - * - * @param string $id translation ID - * @param string $domain translation domain - * - * @return string - */ - private function trans($id, $domain = 'Admin.Advparameters.Feature') - { - return $this->translator->trans($id, [], $domain); - } -} diff --git a/src/Core/Import/Exception/EmptyDataRowException.php b/src/Core/Import/Exception/EmptyDataRowException.php deleted file mode 100644 index 4308b4d8..00000000 --- a/src/Core/Import/Exception/EmptyDataRowException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Exception; - -/** - * Class EmptyDataRowException thrown when the import handler finds an empty data row. - */ -class EmptyDataRowException extends InvalidDataRowException -{ -} diff --git a/src/Core/Import/Exception/ImportException.php b/src/Core/Import/Exception/ImportException.php deleted file mode 100644 index a753ee86..00000000 --- a/src/Core/Import/Exception/ImportException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Class ImportException is extended by all import exceptions. - */ -class ImportException extends CoreException -{ -} diff --git a/src/Core/Import/Exception/InvalidDataRowException.php b/src/Core/Import/Exception/InvalidDataRowException.php deleted file mode 100644 index bdb7098d..00000000 --- a/src/Core/Import/Exception/InvalidDataRowException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Exception; - -/** - * Class InvalidDataRowException thrown when import handler encounters an invalid data row. - */ -class InvalidDataRowException extends ImportException -{ -} diff --git a/src/Core/Import/Exception/NotSupportedImportEntityException.php b/src/Core/Import/Exception/NotSupportedImportEntityException.php deleted file mode 100644 index 2ed4480c..00000000 --- a/src/Core/Import/Exception/NotSupportedImportEntityException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Exception; - -/** - * Class NotSupportedImportEntityException is thrown when not supported import entity is provided. - */ -class NotSupportedImportEntityException extends ImportException -{ -} diff --git a/src/Core/Import/Exception/NotSupportedImportTypeException.php b/src/Core/Import/Exception/NotSupportedImportTypeException.php deleted file mode 100644 index 6e1867f2..00000000 --- a/src/Core/Import/Exception/NotSupportedImportTypeException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Exception; - -/** - * Class NotSupportedImportTypeException is thrown when no supported import type is provided. - */ -class NotSupportedImportTypeException extends ImportException -{ -} diff --git a/src/Core/Import/Exception/SkippedIterationException.php b/src/Core/Import/Exception/SkippedIterationException.php deleted file mode 100644 index 45d2946b..00000000 --- a/src/Core/Import/Exception/SkippedIterationException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Exception; - -/** - * Class SkippedIterationException thrown when an import iteration is skipped. - */ -class SkippedIterationException extends ImportException -{ -} diff --git a/src/Core/Import/Exception/UnavailableImportFileException.php b/src/Core/Import/Exception/UnavailableImportFileException.php deleted file mode 100644 index ac4de276..00000000 --- a/src/Core/Import/Exception/UnavailableImportFileException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Exception; - -/** - * Class UnavailableImportFileException thrown when import file is not available. - */ -class UnavailableImportFileException extends ImportException -{ -} diff --git a/src/Core/Import/Exception/UnreadableFileException.php b/src/Core/Import/Exception/UnreadableFileException.php deleted file mode 100644 index 8659a13e..00000000 --- a/src/Core/Import/Exception/UnreadableFileException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Exception; - -/** - * Class UnreadableFileException is thrown when the import file cannot be read. - */ -class UnreadableFileException extends ImportException -{ -} diff --git a/src/Core/Import/File/CsvFileReader.php b/src/Core/Import/File/CsvFileReader.php deleted file mode 100644 index fa279b24..00000000 --- a/src/Core/Import/File/CsvFileReader.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File; - -use PrestaShop\PrestaShop\Core\Import\Exception\UnreadableFileException; -use PrestaShop\PrestaShop\Core\Import\File\DataRow\DataRow; -use SplFileInfo; - -/** - * Class CsvFileReader defines a CSV file reader. - */ -final class CsvFileReader implements FileReaderInterface -{ - /** - * @var string the data delimiter in the CSV row - */ - private $delimiter; - - /** - * @var int - */ - private $length; - - /** - * @var string - */ - private $enclosure; - - /** - * @var string - */ - private $escape; - - /** - * @var FileOpenerInterface - */ - private $fileOpener; - - /** - * @param FileOpenerInterface $fileOpener - * @param string $delimiter - * @param int $length - * @param string $enclosure - * @param string $escape - */ - public function __construct( - FileOpenerInterface $fileOpener, - $delimiter = ';', - $length = 0, - $enclosure = '"', - $escape = '\\' - ) { - $this->delimiter = $delimiter; - $this->length = $length; - $this->enclosure = $enclosure; - $this->escape = $escape; - $this->fileOpener = $fileOpener; - } - - /** - * {@inheritdoc} - */ - public function read(SplFileInfo $file) - { - if (!$file->isReadable()) { - throw new UnreadableFileException(); - } - - $convertToUtf8 = !mb_check_encoding(file_get_contents($file), 'UTF-8'); - $handle = $this->fileOpener->open($file); - - while ($row = fgetcsv($handle, $this->length, $this->delimiter, $this->enclosure, $this->escape)) { - if ($convertToUtf8) { - $row = array_map('utf8_encode', $row); - } - - yield DataRow::createFromArray($row); - } - - fclose($handle); - } -} diff --git a/src/Core/Import/File/DataCell/DataCell.php b/src/Core/Import/File/DataCell/DataCell.php deleted file mode 100644 index 62b0d719..00000000 --- a/src/Core/Import/File/DataCell/DataCell.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File\DataCell; - -/** - * Class DataCell defines a data cell of imported file. - */ -final class DataCell implements DataCellInterface -{ - /** - * @var string key of the data - */ - private $key; - - /** - * @var string data value - */ - private $value; - - /** - * @param string $key - * @param string $value - */ - public function __construct($key, $value) - { - $this->key = $key; - $this->value = $value; - } - - /** - * {@inheritdoc} - */ - public function getValue() - { - return $this->value; - } - - /** - * {@inheritdoc} - */ - public function getKey() - { - return $this->key; - } -} diff --git a/src/Core/Import/File/DataCell/DataCellInterface.php b/src/Core/Import/File/DataCell/DataCellInterface.php deleted file mode 100644 index 845b4963..00000000 --- a/src/Core/Import/File/DataCell/DataCellInterface.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File\DataCell; - -/** - * Interface DataCellInterface describes a data cell from imported file. - */ -interface DataCellInterface -{ - /** - * Get the value of the cell. - * - * @return string - */ - public function getValue(); - - /** - * Get the key of the cell. - * - * @return string - */ - public function getKey(); -} diff --git a/src/Core/Import/File/DataCell/EmptyDataCell.php b/src/Core/Import/File/DataCell/EmptyDataCell.php deleted file mode 100644 index df877861..00000000 --- a/src/Core/Import/File/DataCell/EmptyDataCell.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File\DataCell; - -/** - * Class EmptyDataCell defines an empty data cell. - */ -final class EmptyDataCell implements DataCellInterface -{ - /** - * {@inheritdoc} - */ - public function getValue() - { - return ''; - } - - /** - * {@inheritdoc} - */ - public function getKey() - { - return ''; - } -} diff --git a/src/Core/Import/File/DataRow/DataRow.php b/src/Core/Import/File/DataRow/DataRow.php deleted file mode 100644 index 9c9c6924..00000000 --- a/src/Core/Import/File/DataRow/DataRow.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File\DataRow; - -use ArrayIterator; -use PrestaShop\PrestaShop\Core\Import\File\DataCell\DataCell; -use PrestaShop\PrestaShop\Core\Import\File\DataCell\DataCellInterface; - -/** - * Class DataRow defines a basic data row of imported file. - */ -final class DataRow implements DataRowInterface -{ - /** - * @var DataCellInterface[] - */ - private $cells = []; - - /** - * {@inheritdoc} - */ - public function addCell(DataCellInterface $cell) - { - $this->cells[] = $cell; - - return $this; - } - - /** - * {@inheritdoc} - */ - public static function createFromArray(array $data) - { - $row = new self(); - - foreach ($data as $key => $value) { - $row->addCell(new DataCell($key, $value)); - } - - return $row; - } - - /** - * {@inheritdoc} - */ - public function offsetExists($offset) - { - return array_key_exists($offset, $this->cells); - } - - /** - * {@inheritdoc} - */ - public function offsetGet($offset) - { - return $this->cells[$offset]; - } - - /** - * {@inheritdoc} - */ - public function offsetSet($offset, $value) - { - $this->cells[$offset] = $value; - } - - /** - * {@inheritdoc} - */ - public function offsetUnset($offset) - { - unset($this->cells[$offset]); - } - - /** - * {@inheritdoc} - */ - public function getIterator() - { - return new ArrayIterator($this->cells); - } - - /** - * {@inheritdoc} - */ - public function count() - { - return count($this->cells); - } - - /** - * {@inheritdoc} - */ - public function isEmpty() - { - if (0 === count($this->cells)) { - return true; - } - - foreach ($this->cells as $cell) { - // If at least one cell is not empty - the row is not empty. - if ('' !== $cell->getValue()) { - return false; - } - } - - return true; - } -} diff --git a/src/Core/Import/File/DataRow/DataRowCollection.php b/src/Core/Import/File/DataRow/DataRowCollection.php deleted file mode 100644 index fa78b69e..00000000 --- a/src/Core/Import/File/DataRow/DataRowCollection.php +++ /dev/null @@ -1,108 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File\DataRow; - -use ArrayIterator; - -/** - * Class DataRowCollection defines a collection of data rows. - */ -final class DataRowCollection implements DataRowCollectionInterface -{ - /** - * @var array of DataRowInterface objects - */ - private $dataRows = []; - - /** - * {@inheritdoc} - */ - public function addDataRow(DataRowInterface $dataRow) - { - $this->dataRows[] = $dataRow; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function offsetExists($offset) - { - return array_key_exists($offset, $this->dataRows); - } - - /** - * {@inheritdoc} - */ - public function offsetGet($offset) - { - if (!$this->offsetExists($offset)) { - return null; - } - - return $this->dataRows[$offset]; - } - - /** - * {@inheritdoc} - */ - public function offsetSet($offset, $value) - { - $this->dataRows[$offset] = $value; - } - - /** - * {@inheritdoc} - */ - public function offsetUnset($offset) - { - unset($this->dataRows[$offset]); - } - - /** - * {@inheritdoc} - */ - public function getIterator() - { - return new ArrayIterator($this->dataRows); - } - - /** - * {@inheritdoc} - */ - public function getLargestRowSize() - { - $maxSize = 0; - - foreach ($this->dataRows as $dataRow) { - $maxSize = max($maxSize, count($dataRow)); - } - - return $maxSize; - } -} diff --git a/src/Core/Import/File/DataRow/DataRowCollectionInterface.php b/src/Core/Import/File/DataRow/DataRowCollectionInterface.php deleted file mode 100644 index 23af846d..00000000 --- a/src/Core/Import/File/DataRow/DataRowCollectionInterface.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File\DataRow; - -use ArrayAccess; -use IteratorAggregate; - -/** - * Interface DataRowCollectionInterface describes a collection of data rows. - */ -interface DataRowCollectionInterface extends ArrayAccess, IteratorAggregate -{ - /** - * Add a data row to this collection. - * - * @param DataRowInterface $dataRow - * - * @return self - */ - public function addDataRow(DataRowInterface $dataRow); - - /** - * Get the number of cells in the largest row of collection. - * - * @return int - */ - public function getLargestRowSize(); -} diff --git a/src/Core/Import/File/DataRow/DataRowCollectionPresenter.php b/src/Core/Import/File/DataRow/DataRowCollectionPresenter.php deleted file mode 100644 index f4fba730..00000000 --- a/src/Core/Import/File/DataRow/DataRowCollectionPresenter.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File\DataRow; - -use PrestaShop\PrestaShop\Core\Import\File\DataCell\EmptyDataCell; - -/** - * Class DataRowCollectionPresenter presents a data row collection. - */ -final class DataRowCollectionPresenter implements DataRowCollectionPresenterInterface -{ - /** - * @var DataRowPresenterInterface - */ - private $dataRowPresenter; - - /** - * @param DataRowPresenterInterface $dataRowPresenter - */ - public function __construct(DataRowPresenterInterface $dataRowPresenter) - { - $this->dataRowPresenter = $dataRowPresenter; - } - - /** - * {@inheritdoc} - */ - public function present(DataRowCollectionInterface $dataRowCollection) - { - $presentedCollection = [ - 'rows' => [], - 'row_size' => $dataRowCollection->getLargestRowSize(), - ]; - - /** @var DataRowInterface $dataRow */ - foreach ($dataRowCollection as $dataRow) { - $this->normalizeDataRow($dataRow, $dataRowCollection->getLargestRowSize()); - $presentedCollection['rows'][] = $this->dataRowPresenter->present($dataRow); - } - - return $presentedCollection; - } - - /** - * Normalize the data row by adding empty data cells until the expected row size is reached. - * This allows all rows to be equal in size. - * - * @param DataRowInterface $dataRow - * @param int $expectedRowSize number of columns this row will reach - */ - private function normalizeDataRow(DataRowInterface $dataRow, $expectedRowSize) - { - while (count($dataRow) < $expectedRowSize) { - $dataRow->addCell(new EmptyDataCell()); - } - } -} diff --git a/src/Core/Import/File/DataRow/DataRowCollectionPresenterInterface.php b/src/Core/Import/File/DataRow/DataRowCollectionPresenterInterface.php deleted file mode 100644 index 683985ea..00000000 --- a/src/Core/Import/File/DataRow/DataRowCollectionPresenterInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File\DataRow; - -/** - * Interface DataRowCollectionPresenterInterface describes a data row collection presenter. - */ -interface DataRowCollectionPresenterInterface -{ - /** - * Present a data row collection into array. - * - * @param DataRowCollectionInterface $dataRowCollection - * - * @return array - */ - public function present(DataRowCollectionInterface $dataRowCollection); -} diff --git a/src/Core/Import/File/DataRow/DataRowInterface.php b/src/Core/Import/File/DataRow/DataRowInterface.php deleted file mode 100644 index 4de74ed1..00000000 --- a/src/Core/Import/File/DataRow/DataRowInterface.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File\DataRow; - -use ArrayAccess; -use Countable; -use IteratorAggregate; -use PrestaShop\PrestaShop\Core\Import\File\DataCell\DataCellInterface; - -/** - * Interface DataRowInterface describes a data row from imported file. - */ -interface DataRowInterface extends ArrayAccess, IteratorAggregate, Countable -{ - /** - * Add a cell to this row. - * - * @param DataCellInterface $cell - * - * @return self - */ - public function addCell(DataCellInterface $cell); - - /** - * Create a data row from given array. - * - * @param array $data - * - * @return self - */ - public static function createFromArray(array $data); - - /** - * @param mixed $offset - * - * @return DataCellInterface - */ - public function offsetGet($offset); - - /** - * Check if the row is empty. - * - * @return bool - */ - public function isEmpty(); -} diff --git a/src/Core/Import/File/DataRow/DataRowPresenter.php b/src/Core/Import/File/DataRow/DataRowPresenter.php deleted file mode 100644 index 10d26282..00000000 --- a/src/Core/Import/File/DataRow/DataRowPresenter.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File\DataRow; - -use PrestaShop\PrestaShop\Core\Import\File\DataCell\DataCellInterface; - -/** - * Class DataRowPresenter defines a data row presenter. - */ -final class DataRowPresenter implements DataRowPresenterInterface -{ - /** - * {@inheritdoc} - */ - public function present(DataRowInterface $dataRow) - { - $presentedRow = []; - - /** @var DataCellInterface $dataCell */ - foreach ($dataRow as $dataCell) { - $presentedRow[] = [ - 'value' => $dataCell->getValue(), - ]; - } - - return $presentedRow; - } -} diff --git a/src/Core/Import/File/DataRow/DataRowPresenterInterface.php b/src/Core/Import/File/DataRow/DataRowPresenterInterface.php deleted file mode 100644 index 81f18a4e..00000000 --- a/src/Core/Import/File/DataRow/DataRowPresenterInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File\DataRow; - -/** - * Interface DataRowPresenterInterface describes a data row presenter. - */ -interface DataRowPresenterInterface -{ - /** - * Present a data row. - * - * @param DataRowInterface $dataRow - * - * @return array - */ - public function present(DataRowInterface $dataRow); -} diff --git a/src/Core/Import/File/DataRow/Factory/DataRowCollectionFactory.php b/src/Core/Import/File/DataRow/Factory/DataRowCollectionFactory.php deleted file mode 100644 index 9fd2a117..00000000 --- a/src/Core/Import/File/DataRow/Factory/DataRowCollectionFactory.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File\DataRow\Factory; - -use PrestaShop\PrestaShop\Core\Import\File\DataRow\DataRowCollection; -use PrestaShop\PrestaShop\Core\Import\File\FileReaderInterface; -use SplFileInfo; - -/** - * Class DataRowCollectionFactory defines a data row collection factory. - */ -final class DataRowCollectionFactory implements DataRowCollectionFactoryInterface -{ - /** - * @var FileReaderInterface - */ - private $fileReader; - - /** - * @param FileReaderInterface $fileReader - */ - public function __construct(FileReaderInterface $fileReader) - { - $this->fileReader = $fileReader; - } - - /** - * {@inheritdoc} - */ - public function buildFromFile(SplFileInfo $file, $maxRowsInCollection = null) - { - $dataRowCollection = new DataRowCollection(); - $rowIndex = 0; - - foreach ($this->fileReader->read($file) as $dataRow) { - if (null !== $maxRowsInCollection && $rowIndex >= $maxRowsInCollection) { - break; - } - - $dataRowCollection->addDataRow($dataRow); - ++$rowIndex; - } - - return $dataRowCollection; - } -} diff --git a/src/Core/Import/File/DataRow/Factory/DataRowCollectionFactoryInterface.php b/src/Core/Import/File/DataRow/Factory/DataRowCollectionFactoryInterface.php deleted file mode 100644 index 634f64c0..00000000 --- a/src/Core/Import/File/DataRow/Factory/DataRowCollectionFactoryInterface.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File\DataRow\Factory; - -use PrestaShop\PrestaShop\Core\Import\File\DataRow\DataRowCollectionInterface; -use SplFileInfo; - -/** - * Interface DataRowCollectionFactoryInterface describes a data row collection factory. - */ -interface DataRowCollectionFactoryInterface -{ - /** - * Builds a data row collection. - * - * @param SplFileInfo $file - * @param int $maxRowsInCollection maximum number of rows this collection can have. Unlimited if not provided. - * - * @return DataRowCollectionInterface - */ - public function buildFromFile(SplFileInfo $file, $maxRowsInCollection = null); -} diff --git a/src/Core/Import/File/FileFinder.php b/src/Core/Import/File/FileFinder.php deleted file mode 100644 index 4ef48285..00000000 --- a/src/Core/Import/File/FileFinder.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File; - -use PrestaShop\PrestaShop\Core\Import\ImportDirectory; -use Symfony\Component\Finder\Finder; - -/** - * Class responsible for finding import files. - */ -final class FileFinder -{ - /** - * @var ImportDirectory - */ - private $importDirectory; - - public function __construct(ImportDirectory $importDirectory) - { - $this->importDirectory = $importDirectory; - } - - /** - * Get import file names in import directory. - * - * @return array|string[] - */ - public function getImportFileNames() - { - if (!$this->importDirectory->isReadable()) { - return []; - } - - $finder = new Finder(); - $finder - ->files() - ->in($this->importDirectory->getDir()) - ->notName('/^index\.php/i'); - - $fileNames = []; - - foreach ($finder as $file) { - $fileNames[] = $file->getFilename(); - } - - return $fileNames; - } -} diff --git a/src/Core/Import/File/FileOpenerInterface.php b/src/Core/Import/File/FileOpenerInterface.php deleted file mode 100644 index f3fc6f75..00000000 --- a/src/Core/Import/File/FileOpenerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File; - -use SplFileInfo; - -/** - * Interface FileOpenerInterface describes an import file opener. - */ -interface FileOpenerInterface -{ - /** - * @param SplFileInfo $file - * - * @return mixed file handle - */ - public function open(SplFileInfo $file); -} diff --git a/src/Core/Import/File/FileReaderInterface.php b/src/Core/Import/File/FileReaderInterface.php deleted file mode 100644 index e157b5ee..00000000 --- a/src/Core/Import/File/FileReaderInterface.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File; - -use Generator; -use PrestaShop\PrestaShop\Core\Import\Exception\UnreadableFileException; -use SplFileInfo; - -/** - * Interface FileReaderInterface describes a file reader. - */ -interface FileReaderInterface -{ - /** - * Read the file. - * - * @param SplFileInfo $file - * - * @return Generator - * - * @throws UnreadableFileException - */ - public function read(SplFileInfo $file); -} diff --git a/src/Core/Import/File/FileRemoval.php b/src/Core/Import/File/FileRemoval.php deleted file mode 100644 index 12cb5d11..00000000 --- a/src/Core/Import/File/FileRemoval.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File; - -use PrestaShop\PrestaShop\Core\Import\ImportDirectory; -use Symfony\Component\Filesystem\Filesystem; - -/** - * FileRemoval is responsible for deleting import files. - */ -final class FileRemoval -{ - /** - * @var ImportDirectory - */ - private $importDirectory; - - public function __construct(ImportDirectory $importDirectory) - { - $this->importDirectory = $importDirectory; - } - - /** - * Remove file from import directory. - * - * @param $filename - */ - public function remove($filename) - { - $fs = new Filesystem(); - $fs->remove($this->importDirectory . $filename); - } -} diff --git a/src/Core/Import/File/FileUploader.php b/src/Core/Import/File/FileUploader.php deleted file mode 100644 index 73341f60..00000000 --- a/src/Core/Import/File/FileUploader.php +++ /dev/null @@ -1,139 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\File; - -use PrestaShop\PrestaShop\Core\Import\ImportDirectory; -use PrestaShopBundle\Exception\FileUploadException; -use Symfony\Component\HttpFoundation\File\Exception\FileException; -use Symfony\Component\HttpFoundation\File\File; -use Symfony\Component\HttpFoundation\File\UploadedFile; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * FileUploader is responsible for uploading import files to import directory. - */ -final class FileUploader -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ImportDirectory - */ - private $importDirectory; - - /** - * @param TranslatorInterface $translator - * @param ImportDirectory $importDirectory - */ - public function __construct( - TranslatorInterface $translator, - ImportDirectory $importDirectory - ) { - $this->translator = $translator; - $this->importDirectory = $importDirectory; - } - - /** - * Handle import file uploading to admin import/ directory. - * - * @param UploadedFile $uploadedFile - * - * @return File - * - * @throws FileUploadException - */ - public function upload(UploadedFile $uploadedFile) - { - if ($error = $this->validateUploadedFile($uploadedFile)) { - throw new FileUploadException($error); - } - - $uploadedFileName = sprintf( - '%s-%s', - date('YmdHis'), - $uploadedFile->getClientOriginalName() - ); - - try { - $file = $uploadedFile->move( - $this->importDirectory, - $uploadedFileName - ); - } catch (FileException $e) { - $error = $this->translator->trans('An error occurred while uploading / copying the file.', [], 'Admin.Advparameters.Notification'); - - throw new FileUploadException($error); - } - - return $file; - } - - /** - * Check if uploaded file is valid. - * - * @param UploadedFile $uploadedFile - * - * @return string|false Returns error string on error or FALSE otherwise - */ - protected function validateUploadedFile(UploadedFile $uploadedFile) - { - $error = false; - - switch ($uploadedFile->getError()) { - case UPLOAD_ERR_INI_SIZE: - $error = $this->translator->trans('The uploaded file exceeds the upload_max_filesize directive in php.ini. If your server configuration allows it, you may add a directive in your .htaccess.', [], 'Admin.Advparameters.Notification'); - - break; - case UPLOAD_ERR_FORM_SIZE: - $message = $this->translator->trans('The uploaded file exceeds the post_max_size directive in php.ini. If your server configuration allows it, you may add a directive in your .htaccess, for example:', [], 'Admin.Advparameters.Notification'); - $error = sprintf('%s %s', $message, 'php_value post_max_size 20M'); - - break; - case UPLOAD_ERR_PARTIAL: - $error = $this->translator->trans('The uploaded file was only partially uploaded.', [], 'Admin.Advparameters.Notification'); - - break; - case UPLOAD_ERR_NO_FILE: - $error = $this->translator->trans('No file was uploaded.', [], 'Admin.Advparameters.Notification'); - - break; - } - - if ($error) { - return $error; - } - - if (!preg_match('#([^\.]*?)\.(csv|xls[xt]?|o[dt]s)$#is', $uploadedFile->getClientOriginalName())) { - $error = $this->translator->trans('The extension of your file should be .csv.', [], 'Admin.Advparameters.Notification'); - } - - return $error; - } -} diff --git a/src/Core/Import/Handler/ImportHandlerFinderInterface.php b/src/Core/Import/Handler/ImportHandlerFinderInterface.php deleted file mode 100644 index 40d20c59..00000000 --- a/src/Core/Import/Handler/ImportHandlerFinderInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Handler; - -/** - * Interface ImportHandlerFinderInterface describes an import handler finder. - */ -interface ImportHandlerFinderInterface -{ - /** - * Find the proper import handler for given entity type. - * - * @param $importEntityType - * - * @return ImportHandlerInterface - */ - public function find($importEntityType); -} diff --git a/src/Core/Import/Handler/ImportHandlerInterface.php b/src/Core/Import/Handler/ImportHandlerInterface.php deleted file mode 100644 index d509ca12..00000000 --- a/src/Core/Import/Handler/ImportHandlerInterface.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Handler; - -use PrestaShop\PrestaShop\Core\Import\Configuration\ImportConfigInterface; -use PrestaShop\PrestaShop\Core\Import\Configuration\ImportRuntimeConfigInterface; -use PrestaShop\PrestaShop\Core\Import\Exception\EmptyDataRowException; -use PrestaShop\PrestaShop\Core\Import\File\DataRow\DataRowInterface; - -/** - * Interface ImportHandlerInterface describes an import handler. - */ -interface ImportHandlerInterface -{ - /** - * Executed before import process is started. - * - * @param ImportConfigInterface $importConfig - * @param ImportRuntimeConfigInterface $runtimeConfig - */ - public function setUp(ImportConfigInterface $importConfig, ImportRuntimeConfigInterface $runtimeConfig); - - /** - * Imports one data row. - * - * @param ImportConfigInterface $importConfig - * @param ImportRuntimeConfigInterface $runtimeConfig - * @param DataRowInterface $dataRow - * - * @throws EmptyDataRowException - */ - public function importRow( - ImportConfigInterface $importConfig, - ImportRuntimeConfigInterface $runtimeConfig, - DataRowInterface $dataRow - ); - - /** - * Executed when the import process is completed. - * - * @param ImportConfigInterface $importConfig - * @param ImportRuntimeConfigInterface $runtimeConfig - */ - public function tearDown(ImportConfigInterface $importConfig, ImportRuntimeConfigInterface $runtimeConfig); - - /** - * Get warning messages that occurred during import. - * - * @return array - */ - public function getWarnings(); - - /** - * Get error messages that occurred during import. - * - * @return array - */ - public function getErrors(); - - /** - * Get notice messages that occurred during import. - * - * @return array - */ - public function getNotices(); - - /** - * Check whether this import handler supports given entity type. - * - * @param int $importEntityType - * - * @return bool - */ - public function supports($importEntityType); -} diff --git a/src/Core/Import/ImportDirectory.php b/src/Core/Import/ImportDirectory.php deleted file mode 100644 index 89a70fd0..00000000 --- a/src/Core/Import/ImportDirectory.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use Symfony\Component\Filesystem\Filesystem; - -/** - * ImportDirectory class is responsible for returning import directory & data related to it. - */ -final class ImportDirectory -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * Get path to import directory. - * - * @return string - */ - public function getDir() - { - return ($this->configuration->get('_PS_HOST_MODE_') ? - $this->configuration->get('_PS_ROOT_DIR_') : - $this->configuration->get('_PS_ADMIN_DIR_')) . DIRECTORY_SEPARATOR . 'import' . DIRECTORY_SEPARATOR; - } - - /** - * Check if import directory exists. - * - * @return bool - */ - public function exists() - { - return (new Filesystem())->exists($this->getDir()); - } - - /** - * Check if import directory is writable. - * - * @return bool - */ - public function isWritable() - { - return is_writable($this->getDir()); - } - - /** - * Check if import directory is readable. - * - * @return bool - */ - public function isReadable() - { - return is_readable($this->getDir()); - } - - /** - * Use import directory object as a string. - * - * @return string - */ - public function __toString() - { - return $this->getDir(); - } -} diff --git a/src/Core/Import/ImportSettings.php b/src/Core/Import/ImportSettings.php deleted file mode 100644 index c19834a6..00000000 --- a/src/Core/Import/ImportSettings.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import; - -/** - * Class ImportSettings provides import constants to be used in import pages. - */ -final class ImportSettings -{ - /** - * Default value separator. - */ - const DEFAULT_SEPARATOR = ';'; - - /** - * Default multiple value separator. - */ - const DEFAULT_MULTIVALUE_SEPARATOR = ','; - - /** - * Maximum number of columns that are visible in the import matches configuration page. - */ - const MAX_VISIBLE_COLUMNS = 6; - - /** - * Maximum number of rows that are visible in the import matces configuration page. - */ - const MAX_VISIBLE_ROWS = 10; - - /** - * This class cannot be instantiated. - */ - private function __construct() - { - } -} diff --git a/src/Core/Import/Importer.php b/src/Core/Import/Importer.php deleted file mode 100644 index 7316e621..00000000 --- a/src/Core/Import/Importer.php +++ /dev/null @@ -1,238 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import; - -use PrestaShop\PrestaShop\Core\Configuration\IniConfiguration; -use PrestaShop\PrestaShop\Core\Import\Access\ImportAccessCheckerInterface; -use PrestaShop\PrestaShop\Core\Import\Configuration\ImportConfigInterface; -use PrestaShop\PrestaShop\Core\Import\Configuration\ImportRuntimeConfigInterface; -use PrestaShop\PrestaShop\Core\Import\Entity\ImportEntityDeleterInterface; -use PrestaShop\PrestaShop\Core\Import\Exception\InvalidDataRowException; -use PrestaShop\PrestaShop\Core\Import\Exception\SkippedIterationException; -use PrestaShop\PrestaShop\Core\Import\File\FileReaderInterface; -use PrestaShop\PrestaShop\Core\Import\Handler\ImportHandlerInterface; -use SplFileInfo; - -/** - * Class Importer is responsible for data import. - */ -final class Importer implements ImporterInterface -{ - /** - * @var ImportEntityDeleterInterface - */ - private $entityDeleter; - - /** - * @var ImportAccessCheckerInterface - */ - private $accessChecker; - - /** - * @var FileReaderInterface - */ - private $fileReader; - - /** - * @var ImportDirectory - */ - private $importDir; - - /** - * @var IniConfiguration - */ - private $iniConfiguration; - - /** - * @param ImportAccessCheckerInterface $accessChecker - * @param ImportEntityDeleterInterface $entityDeleter - * @param FileReaderInterface $fileReader - * @param ImportDirectory $importDir - * @param IniConfiguration $iniConfiguration - */ - public function __construct( - ImportAccessCheckerInterface $accessChecker, - ImportEntityDeleterInterface $entityDeleter, - FileReaderInterface $fileReader, - ImportDirectory $importDir, - IniConfiguration $iniConfiguration - ) { - $this->entityDeleter = $entityDeleter; - $this->accessChecker = $accessChecker; - $this->fileReader = $fileReader; - $this->importDir = $importDir; - $this->iniConfiguration = $iniConfiguration; - } - - /** - * {@inheritdoc} - */ - public function import( - ImportConfigInterface $importConfig, - ImportRuntimeConfigInterface $runtimeConfig, - ImportHandlerInterface $importHandler - ) { - $this->setUp($importHandler, $importConfig, $runtimeConfig); - - $importFile = new SplFileInfo($this->importDir . $importConfig->getFileName()); - - // Current row index - $rowIndex = 0; - - // Number of rows processed during import process. - $processedRows = 0; - - // Total number of importable rows in the whole file. - $totalNumberOfRows = 0; - - $skipRows = $importConfig->getNumberOfRowsToSkip() + $runtimeConfig->getOffset(); - $limit = $runtimeConfig->getLimit() + $skipRows; - $isFirstIteration = $this->isFirstIteration($runtimeConfig); - - foreach ($this->fileReader->read($importFile) as $dataRow) { - if ($isFirstIteration) { - ++$totalNumberOfRows; - } - - // Skip rows until the correct row is reached. - if ($rowIndex < $skipRows) { - ++$rowIndex; - continue; - } - - // If import process limit is reached - stop importing the rows. - if ($rowIndex >= $limit) { - // On the first iteration we need to continue counting the number of rows - if ($isFirstIteration) { - continue; - } - break; - } - - try { - // Import one row - $importHandler->importRow( - $importConfig, - $runtimeConfig, - $dataRow - ); - } catch (InvalidDataRowException $e) { - continue; - } catch (SkippedIterationException $e) { - continue; - } finally { - ++$processedRows; - ++$rowIndex; - } - } - - // Calculate total number of rows only in the first import iteration. - if ($isFirstIteration && $runtimeConfig->shouldValidateData()) { - $runtimeConfig->setTotalNumberOfRows($totalNumberOfRows - $skipRows); - } - - $runtimeConfig->setNumberOfProcessedRows($processedRows); - - $this->tearDown($importHandler, $importConfig, $runtimeConfig); - } - - /** - * Checks if data should be truncated. - * Data should be truncated only when it's not validation step - * and it's the first batch of the first process of the import. - * - * @param ImportConfigInterface $importConfig - * @param ImportRuntimeConfigInterface $runtimeConfig - * - * @return bool - */ - public function shouldTruncateData( - ImportConfigInterface $importConfig, - ImportRuntimeConfigInterface $runtimeConfig - ) { - return - $importConfig->truncate() && - !$runtimeConfig->shouldValidateData() && - $this->isFirstIteration($runtimeConfig) - ; - } - - /** - * Checks if current import iteration is the first. - * - * @param ImportRuntimeConfigInterface $runtimeConfig - * - * @return bool - */ - private function isFirstIteration(ImportRuntimeConfigInterface $runtimeConfig) - { - return 0 === $runtimeConfig->getOffset(); - } - - /** - * Set the import process up. - * - * @param ImportHandlerInterface $importHandler - * @param ImportConfigInterface $importConfig - * @param ImportRuntimeConfigInterface $runtimeConfig - */ - private function setUp( - ImportHandlerInterface $importHandler, - ImportConfigInterface $importConfig, - ImportRuntimeConfigInterface $runtimeConfig - ) { - if ($this->shouldTruncateData($importConfig, $runtimeConfig) && $this->accessChecker->canTruncateData()) { - $this->entityDeleter->deleteAll($importConfig->getEntityType()); - } - - $importHandler->setUp($importConfig, $runtimeConfig); - } - - /** - * Tear the import process down. - * - * @param ImportHandlerInterface $importHandler - * @param ImportConfigInterface $importConfig - * @param ImportRuntimeConfigInterface $runtimeConfig - */ - private function tearDown( - ImportHandlerInterface $importHandler, - ImportConfigInterface $importConfig, - ImportRuntimeConfigInterface $runtimeConfig - ) { - $importHandler->tearDown($importConfig, $runtimeConfig); - - // Calculating shared data size and adding some extra bytes for other values. - $runtimeConfig->setRequestSizeInBytes( - mb_strlen(json_encode($runtimeConfig->getSharedData())) + 1024 * 64 - ); - $runtimeConfig->setPostSizeLimitInBytes($this->iniConfiguration->getUploadMaxSizeInBytes()); - $runtimeConfig->setNotices($importHandler->getNotices()); - $runtimeConfig->setWarnings($importHandler->getWarnings()); - $runtimeConfig->setErrors($importHandler->getErrors()); - } -} diff --git a/src/Core/Import/ImporterInterface.php b/src/Core/Import/ImporterInterface.php deleted file mode 100644 index 293af782..00000000 --- a/src/Core/Import/ImporterInterface.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import; - -use PrestaShop\PrestaShop\Core\Import\Configuration\ImportConfigInterface; -use PrestaShop\PrestaShop\Core\Import\Configuration\ImportRuntimeConfigInterface; -use PrestaShop\PrestaShop\Core\Import\Handler\ImportHandlerInterface; - -/** - * Interface ImporterInterface describes an import processing unit. - */ -interface ImporterInterface -{ - /** - * Process the import. - * - * @param ImportConfigInterface $importConfig - * @param ImportRuntimeConfigInterface $runtimeConfig - * @param ImportHandlerInterface $importHandler - * - * @return - */ - public function import( - ImportConfigInterface $importConfig, - ImportRuntimeConfigInterface $runtimeConfig, - ImportHandlerInterface $importHandler - ); -} diff --git a/src/Core/Import/Sample/SampleFileProvider.php b/src/Core/Import/Sample/SampleFileProvider.php deleted file mode 100644 index 1f40689d..00000000 --- a/src/Core/Import/Sample/SampleFileProvider.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Sample; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; -use Symfony\Component\HttpFoundation\File\File; - -/** - * Class SampleFileProvider is responsible for providing sample import files. - */ -final class SampleFileProvider implements SampleFileProviderInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getFile($sampleFileName) - { - $path = $this->configuration->get('_PS_ROOT_DIR_') . - DIRECTORY_SEPARATOR . - 'docs' . - DIRECTORY_SEPARATOR . - 'csv_import' . - DIRECTORY_SEPARATOR; - - try { - $sampleFile = new File($path . $sampleFileName . '.csv'); - } catch (FileNotFoundException $e) { - return null; - } - - return $sampleFile; - } -} diff --git a/src/Core/Import/Sample/SampleFileProviderInterface.php b/src/Core/Import/Sample/SampleFileProviderInterface.php deleted file mode 100644 index 0243531b..00000000 --- a/src/Core/Import/Sample/SampleFileProviderInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Sample; - -use Symfony\Component\HttpFoundation\File\File; - -/** - * Interface SampleFileProviderInterface defines contract for sample import file provider. - */ -interface SampleFileProviderInterface -{ - /** - * Get sample import file. - * - * @param string $sampleFileName - * - * @return File|null File if files was found or null otherwise - */ - public function getFile($sampleFileName); -} diff --git a/src/Core/Import/StringNormalizerInterface.php b/src/Core/Import/StringNormalizerInterface.php deleted file mode 100644 index 116f9d9f..00000000 --- a/src/Core/Import/StringNormalizerInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import; - -/** - * Interface StringNormalizerInterface describes a string normalizer. - */ -interface StringNormalizerInterface -{ - /** - * Normalizes a string value. - * - * @param string $value - * - * @return string normalized string - */ - public function normalize($value); -} diff --git a/src/Core/Import/Validator/ImportRequestValidator.php b/src/Core/Import/Validator/ImportRequestValidator.php deleted file mode 100644 index 7a92d8dc..00000000 --- a/src/Core/Import/Validator/ImportRequestValidator.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Validator; - -use PrestaShop\PrestaShop\Core\Import\Exception\UnavailableImportFileException; -use Symfony\Component\HttpFoundation\Request; - -/** - * Class ImportRequestValidator is responsible for validating import request. - */ -final class ImportRequestValidator implements ImportRequestValidatorInterface -{ - /** - * {@inheritdoc} - */ - public function validate(Request $request) - { - if (!$request->request->has('csv')) { - throw new UnavailableImportFileException(); - } - } -} diff --git a/src/Core/Import/Validator/ImportRequestValidatorInterface.php b/src/Core/Import/Validator/ImportRequestValidatorInterface.php deleted file mode 100644 index a451a661..00000000 --- a/src/Core/Import/Validator/ImportRequestValidatorInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Import\Validator; - -use Symfony\Component\HttpFoundation\Request; - -/** - * Interface ImportRequestValidatorInterface describes a request validator for import process. - */ -interface ImportRequestValidatorInterface -{ - /** - * Validate a request for import. - * - * @param Request $request - */ - public function validate(Request $request); -} diff --git a/src/Core/Kpi/Exception/InvalidArgumentException.php b/src/Core/Kpi/Exception/InvalidArgumentException.php deleted file mode 100644 index 45491546..00000000 --- a/src/Core/Kpi/Exception/InvalidArgumentException.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Kpi\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Will be thrown if Kpi factory arguments are invalid. - */ -final class InvalidArgumentException extends CoreException -{ - /** - * @param mixed $kpi - * - * @return InvalidArgumentException - */ - public static function invalidKpi($kpi) - { - $exceptionMessage = sprintf( - 'Kpi must be an instance of KpiInterface, got `%s`.', - gettype($kpi) - ); - - return new self($exceptionMessage); - } - - /** - * @param mixed $identifier - * - * @return InvalidArgumentException - */ - public static function invalidIdentifier($identifier) - { - $exceptionMessage = sprintf( - 'Identifier must be a string, got `%s`.', - gettype($identifier) - ); - - return new self($exceptionMessage); - } -} diff --git a/src/Core/Kpi/KpiInterface.php b/src/Core/Kpi/KpiInterface.php deleted file mode 100644 index 56d40350..00000000 --- a/src/Core/Kpi/KpiInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Kpi; - -/** - * Interface KpiInterface describes a KPI. - */ -interface KpiInterface extends RenderableKpi -{ -} diff --git a/src/Core/Kpi/RenderableKpi.php b/src/Core/Kpi/RenderableKpi.php deleted file mode 100644 index 718cb66d..00000000 --- a/src/Core/Kpi/RenderableKpi.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Kpi; - -/** - * Interface RenderableKpi describes a renderable KPI. - */ -interface RenderableKpi -{ - /** - * Renders the KPI's view. - * - * @return string - */ - public function render(); -} diff --git a/src/Core/Kpi/Row/HookableKpiRowFactory.php b/src/Core/Kpi/Row/HookableKpiRowFactory.php deleted file mode 100644 index 21af7c4b..00000000 --- a/src/Core/Kpi/Row/HookableKpiRowFactory.php +++ /dev/null @@ -1,148 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Kpi\Row; - -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShop\PrestaShop\Core\Kpi\Exception\InvalidArgumentException; -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; - -/** - * Class KpiRowFactory builds a KPI row, able to dispatch a hook. - */ -final class HookableKpiRowFactory implements KpiRowFactoryInterface -{ - /** - * @var KpiInterface[] the list of KPIs to display - */ - private $kpis; - - /** - * @var HookDispatcherInterface the Hook Dispatcher - */ - private $hookDispatcher; - - /** - * @var string used to make the hook selectable - */ - private $identifier; - - /** - * @var array - */ - private $options = []; - - /** - * @param KpiInterface[] $kpis - * @param HookDispatcherInterface $hookDispatcher - * @param string $identifier - */ - public function __construct( - array $kpis, - HookDispatcherInterface $hookDispatcher, - $identifier - ) { - if ($this->validateKpis($kpis) && $this->validateIdentifier($identifier)) { - $this->kpis = $kpis; - $this->hookDispatcher = $hookDispatcher; - $this->identifier = $identifier; - } - } - - /** - * {@inheritdoc} - */ - public function build() - { - $kpiRow = new KpiRow($this->options); - - $this->hookDispatcher->dispatchWithParameters($this->getHookName($this->identifier), [ - 'kpis' => &$this->kpis, - ]); - - if ($this->validateKpis($this->kpis)) { - foreach ($this->kpis as $kpi) { - $kpiRow->addKpi($kpi); - } - - return $kpiRow; - } - } - - /** - * Set options for kpi row - * - * @param array $options - */ - public function setOptions(array $options) - { - $this->options = $options; - } - - /** - * @param array $kpis - * - * @return bool true if valid, else throw an exception - * - * @throws InvalidArgumentException - */ - private function validateKpis(array $kpis) - { - foreach ($kpis as $kpi) { - if (!$kpi instanceof KpiInterface) { - throw InvalidArgumentException::invalidKpi($kpi); - } - } - - return true; - } - - /** - * @param mixed $identifier - * - * @return bool true if valid, else throw an exception - * - * @throws InvalidArgumentException - */ - private function validateIdentifier($identifier) - { - if (!is_string($identifier)) { - throw InvalidArgumentException::invalidIdentifier($identifier); - } - - return true; - } - - /** - * @param string $identifier - * - * @return string - */ - private function getHookName($identifier) - { - return 'action' . ucfirst($identifier) . 'KpiRowModifier'; - } -} diff --git a/src/Core/Kpi/Row/KpiRow.php b/src/Core/Kpi/Row/KpiRow.php deleted file mode 100644 index 2d5bb73b..00000000 --- a/src/Core/Kpi/Row/KpiRow.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Kpi\Row; - -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; - -/** - * Class KpiRow defines a row of KPIs. - */ -final class KpiRow implements KpiRowInterface -{ - /** - * @var bool - */ - private $allowRefresh = true; - - /** - * @var array[KpiInterface] - */ - private $kpis = []; - - /** - * @var array - */ - private $options; - - /** - * @param array $options - */ - public function __construct(array $options = []) - { - $this->options = $options; - } - - /** - * {@inheritdoc} - */ - public function addKpi(KpiInterface $kpi) - { - // setOptions() is optional & not part of interface to avoid BC break - if (method_exists($kpi, 'setOptions')) { - $kpi->setOptions($this->options); - } - - $this->kpis[] = $kpi; - } - - /** - * @return array[KpiInterface] - */ - public function getKpis() - { - return $this->kpis; - } - - /** - * @param bool $allowRefresh - */ - public function setAllowRefresh($allowRefresh) - { - $this->allowRefresh = $allowRefresh; - } - - /** - * @return bool - */ - public function isRefreshAllowed() - { - return $this->allowRefresh; - } - - /** - * @return array - */ - public function getOptions() - { - return $this->options; - } -} diff --git a/src/Core/Kpi/Row/KpiRowFactory.php b/src/Core/Kpi/Row/KpiRowFactory.php deleted file mode 100644 index ab5bc022..00000000 --- a/src/Core/Kpi/Row/KpiRowFactory.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Kpi\Row; - -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; - -/** - * Class KpiRowFactory builds a KPI row. - * - * @deprecated since 1.7.6, will be removed in the next major version, use HookableKpiRowFactory instead. - */ -final class KpiRowFactory implements KpiRowFactoryInterface -{ - /** - * @var KpiInterface[] - */ - private $kpis; - - /** - * @param KpiInterface ...$kpis - */ - public function __construct(KpiInterface ...$kpis) - { - @trigger_error( - 'Using `KpiRowFactory` class is deprecated and will be removed in the next major,' . - 'use HookableKpiRowFactory instead', - E_USER_DEPRECATED - ); - - $this->kpis = $kpis; - } - - /** - * {@inheritdoc} - */ - public function build() - { - $kpiRow = new KpiRow(); - - foreach ($this->kpis as $kpi) { - $kpiRow->addKpi($kpi); - } - - return $kpiRow; - } -} diff --git a/src/Core/Kpi/Row/KpiRowFactoryInterface.php b/src/Core/Kpi/Row/KpiRowFactoryInterface.php deleted file mode 100644 index 1040acad..00000000 --- a/src/Core/Kpi/Row/KpiRowFactoryInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Kpi\Row; - -/** - * Interface KpiRowFactoryInterface describes a KPI row factory. - */ -interface KpiRowFactoryInterface -{ - /** - * Builds a KPI row. - * - * @return KpiRowInterface - */ - public function build(); -} diff --git a/src/Core/Kpi/Row/KpiRowInterface.php b/src/Core/Kpi/Row/KpiRowInterface.php deleted file mode 100644 index 7558fd7b..00000000 --- a/src/Core/Kpi/Row/KpiRowInterface.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Kpi\Row; - -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; - -/** - * Interface KpiRowInterface describes a KPI row. - */ -interface KpiRowInterface -{ - /** - * Add a KPI to this row. - * - * @param KpiInterface $kpi - */ - public function addKpi(KpiInterface $kpi); - - /** - * @return array[KpiInterface] - */ - public function getKpis(); - - /** - * @param bool $allowRefresh - */ - public function setAllowRefresh($allowRefresh); - - /** - * @return bool - */ - public function isRefreshAllowed(); - - /** - * @return array - */ - public function getOptions(); -} diff --git a/src/Core/Kpi/Row/KpiRowPresenter.php b/src/Core/Kpi/Row/KpiRowPresenter.php deleted file mode 100644 index 076b9a71..00000000 --- a/src/Core/Kpi/Row/KpiRowPresenter.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Kpi\Row; - -use PrestaShop\PrestaShop\Core\Kpi\KpiInterface; - -/** - * Class KpiRowPresenter presents a KPI row. - */ -final class KpiRowPresenter implements KpiRowPresenterInterface -{ - /** - * {@inheritdoc} - */ - public function present(KpiRowInterface $kpiRow) - { - $renderedKpis = []; - - /** @var KpiInterface $kpi */ - foreach ($kpiRow->getKpis() as $kpi) { - $renderedKpis[] = $kpi->render($kpiRow->getOptions()); - } - - return [ - 'kpis' => $renderedKpis, - 'allowRefresh' => $kpiRow->isRefreshAllowed(), - ]; - } -} diff --git a/src/Core/Kpi/Row/KpiRowPresenterInterface.php b/src/Core/Kpi/Row/KpiRowPresenterInterface.php deleted file mode 100644 index 8ee01553..00000000 --- a/src/Core/Kpi/Row/KpiRowPresenterInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Kpi\Row; - -/** - * Interface KpiRowPresenterInterface describes a KPI row presenter. - */ -interface KpiRowPresenterInterface -{ - /** - * @param KpiRowInterface $kpiRow - * - * @return array - */ - public function present(KpiRowInterface $kpiRow); -} diff --git a/src/Core/Language/Copier/LanguageCopierConfig.php b/src/Core/Language/Copier/LanguageCopierConfig.php deleted file mode 100644 index 1dc75283..00000000 --- a/src/Core/Language/Copier/LanguageCopierConfig.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Language\Copier; - -/** - * Class LanguageCopierConfig provides configuration for language copier. - */ -final class LanguageCopierConfig implements LanguageCopierConfigInterface -{ - /** - * @var string the theme name from which the language will be copied - */ - private $themeFrom; - - /** - * @var string the language iso code, which will be copied from - */ - private $languageFrom; - - /** - * @var string the theme name to which the language will be copied - */ - private $themeTo; - - /** - * @var string the language iso code, which will be copied to - */ - private $languageTo; - - /** - * @param string $themeFrom - * @param string $languageFrom - * @param string $themeTo - * @param string $languageTo - */ - public function __construct($themeFrom, $languageFrom, $themeTo, $languageTo) - { - $this->themeFrom = $themeFrom; - $this->languageFrom = $languageFrom; - $this->themeTo = $themeTo; - $this->languageTo = $languageTo; - } - - /** - * {@inheritdoc} - */ - public function getThemeFrom() - { - return $this->themeFrom; - } - - /** - * {@inheritdoc} - */ - public function getLanguageFrom() - { - return $this->languageFrom; - } - - /** - * {@inheritdoc} - */ - public function getThemeTo() - { - return $this->themeTo; - } - - /** - * {@inheritdoc} - */ - public function getLanguageTo() - { - return $this->languageTo; - } -} diff --git a/src/Core/Language/Copier/LanguageCopierConfigInterface.php b/src/Core/Language/Copier/LanguageCopierConfigInterface.php deleted file mode 100644 index 454b66ed..00000000 --- a/src/Core/Language/Copier/LanguageCopierConfigInterface.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Language\Copier; - -/** - * Interface LanguageCopierConfigInterface defines configuration, required for copying a language. - */ -interface LanguageCopierConfigInterface -{ - /** - * Get the theme name that language will be copied from. - * - * @return string - */ - public function getThemeFrom(); - - /** - * Get the language name to copy from. - * - * @return string - */ - public function getLanguageFrom(); - - /** - * Get the theme name that language will be copied to. - * - * @return string - */ - public function getThemeTo(); - - /** - * Get the language name to copy to. - * - * @return string - */ - public function getLanguageTo(); -} diff --git a/src/Core/Language/Copier/LanguageCopierInterface.php b/src/Core/Language/Copier/LanguageCopierInterface.php deleted file mode 100644 index 3fe9cc34..00000000 --- a/src/Core/Language/Copier/LanguageCopierInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Language\Copier; - -/** - * Interface LanguageCopierInterface defines a language copier. - */ -interface LanguageCopierInterface -{ - /** - * Copies a language with given config. - * - * @param LanguageCopierConfigInterface $config - * - * @return array of errors if any occurred, empty array otherwise - */ - public function copy(LanguageCopierConfigInterface $config); -} diff --git a/src/Core/Language/LanguageActivatorInterface.php b/src/Core/Language/LanguageActivatorInterface.php deleted file mode 100644 index a924e91a..00000000 --- a/src/Core/Language/LanguageActivatorInterface.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Language; - -/** - * Interface LanguageActivatorInterface defines contract for language activator. - */ -interface LanguageActivatorInterface -{ - /** - * Activate language. - * - * @param int $langId - */ - public function enable($langId); - - /** - * Deactivate language. - * - * @param int $langId - */ - public function disable($langId); -} diff --git a/src/Core/Language/LanguageDefaultFontsCatalog.php b/src/Core/Language/LanguageDefaultFontsCatalog.php deleted file mode 100644 index 36ca1746..00000000 --- a/src/Core/Language/LanguageDefaultFontsCatalog.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Language; - -/** - * Class LanguageDefaultFontsCatalog is used for languages that need a specific font to display their - * characters. This class is a catalog referencing which languages need special fonts and associate - * the appropriate font to each language. - */ -class LanguageDefaultFontsCatalog -{ - /** - * This is a non exhaustive list of language which need a specific font - * so that their characters are correctly displayed. - * - * @var array - */ - private $languageDefaultFonts = [ - 'fa' => 'Tahoma', - 'ar' => 'Tahoma', - ]; - - /** - * @param array|null $languageDefaultFonts - */ - public function __construct(array $languageDefaultFonts = null) - { - if (null !== $languageDefaultFonts) { - $this->languageDefaultFonts = $languageDefaultFonts; - } - } - - /** - * @param LanguageInterface $language - * - * @return string - */ - public function getDefaultFontByLanguage(LanguageInterface $language) - { - $isoCode = $language->getIsoCode(); - if (isset($this->languageDefaultFonts[$isoCode])) { - return $this->languageDefaultFonts[$isoCode]; - } - - return ''; - } -} diff --git a/src/Core/Language/LanguageInterface.php b/src/Core/Language/LanguageInterface.php deleted file mode 100644 index ebdbe1ad..00000000 --- a/src/Core/Language/LanguageInterface.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Language; - -/** - * Interface LanguageInterface defines a language object (iso code, locale, - * if it is an RTL language, ...) - */ -interface LanguageInterface -{ - /** - * Database id - * - * @return string - */ - public function getId(); - - /** - * Explicit name of the language - * - * @return string - */ - public function getName(); - - /** - * 2-letter iso code - * - * @return string - */ - public function getIsoCode(); - - /** - * 5-letter iso code - * - * @return string - */ - public function getLocale(); - - /** - * 5-letter iso code - * - * @return string - */ - public function getLanguageCode(); - - /** - * Is the language RTL (read from right to left) - * - * @return bool - */ - public function isRTL(); -} diff --git a/src/Core/Language/LanguageRepositoryInterface.php b/src/Core/Language/LanguageRepositoryInterface.php deleted file mode 100644 index a85adcb6..00000000 --- a/src/Core/Language/LanguageRepositoryInterface.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Language; - -/** - * Interface LanguageRepositoryInterface allows to fetch a LanguageInterface - * via different methods. - */ -interface LanguageRepositoryInterface -{ - /** - * Returns a LanguageInterface whose locale matches the provided one. - * - * @param string $locale - * - * @return LanguageInterface - */ - public function getOneByLocale($locale); - - /** - * Returns a LanguageInterface which isoCode matches the provided one. - * - * @param string $isoCode - * - * @return LanguageInterface - */ - public function getOneByIsoCode($isoCode); - - /** - * Returns a LanguageInterface whose locale matches the provided one, - * if no one is found try matching by isoCode (splitting the locale if - * necessary). - * - * @param string $locale - * - * @return LanguageInterface - */ - public function getOneByLocaleOrIsoCode($locale); -} diff --git a/src/Core/Language/LanguageValidatorInterface.php b/src/Core/Language/LanguageValidatorInterface.php deleted file mode 100644 index 5a50c48b..00000000 --- a/src/Core/Language/LanguageValidatorInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Language; - -/** - * Interface LanguageValidatorInterface defines contract for LanguageValidator. - */ -interface LanguageValidatorInterface -{ - /** - * Checks if language is installed by comparing locale. - * - * @param string $locale - * - * @return bool - */ - public function isInstalledByLocale($locale); -} diff --git a/src/Core/Language/Pack/Import/LanguagePackImporterInterface.php b/src/Core/Language/Pack/Import/LanguagePackImporterInterface.php deleted file mode 100644 index c001a1d7..00000000 --- a/src/Core/Language/Pack/Import/LanguagePackImporterInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Language\Pack\Import; - -/** - * Interface LanguagePackImporterInterface contract for language importer. - */ -interface LanguagePackImporterInterface -{ - /** - * Imports language pack. - * - * @param string $isoCode - * - * @return array - returns array with error messages or an empty array on success case - */ - public function import($isoCode); -} diff --git a/src/Core/Language/Pack/LanguagePackInstallerInterface.php b/src/Core/Language/Pack/LanguagePackInstallerInterface.php deleted file mode 100644 index 8315dd38..00000000 --- a/src/Core/Language/Pack/LanguagePackInstallerInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Language\Pack; - -/** - * Interface LanguagePackInstallerInterface defines contract for language pack installer. - */ -interface LanguagePackInstallerInterface -{ - /** - * Downloads and installs language pack data. - * - * @param string $iso -3166-2 alpha-2 format code - * - * @return array - if not empty then it contains errors. In another case the function - * has been executed successfully - */ - public function downloadAndInstallLanguagePack($iso); -} diff --git a/src/Core/Language/Pack/Loader/LanguagePackLoaderInterface.php b/src/Core/Language/Pack/Loader/LanguagePackLoaderInterface.php deleted file mode 100644 index b5180e91..00000000 --- a/src/Core/Language/Pack/Loader/LanguagePackLoaderInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Language\Pack\Loader; - -/** - * Interface LanguagePackLoaderInterface defines contract for language pack loader. - */ -interface LanguagePackLoaderInterface -{ - /** - * Gets language pack data. - * - * @return array - array key is the language locale and the value is language name - */ - public function getLanguagePackList(); -} diff --git a/src/Core/Language/Pack/Loader/RemoteLanguagePackLoader.php b/src/Core/Language/Pack/Loader/RemoteLanguagePackLoader.php deleted file mode 100644 index 8aec17f2..00000000 --- a/src/Core/Language/Pack/Loader/RemoteLanguagePackLoader.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Language\Pack\Loader; - -use PrestaShop\PrestaShop\Core\Foundation\Version; - -/** - * Class RemoteLanguagePackLoader is responsible for retrieving language pack data from remote host. - */ -final class RemoteLanguagePackLoader implements LanguagePackLoaderInterface -{ - /** - * The link from which available languages are retrieved. - */ - const PACK_LINK = 'http://i18n.prestashop.com/translations/%ps_version%/available_languages.json'; - - /** - * @var Version - */ - private $version; - - /** - * @param Version $version - */ - public function __construct(Version $version) - { - $this->version = $version; - } - - /** - * {@inheritdoc} - */ - public function getLanguagePackList() - { - $normalizedLink = str_replace('%ps_version%', $this->version->getVersion(), self::PACK_LINK); - $jsonResponse = file_get_contents($normalizedLink); - - $result = []; - if ($jsonResponse) { - $result = json_decode($jsonResponse, true); - } - - return $result; - } -} diff --git a/src/Core/Language/RTL/InstalledLanguageCheckerInterface.php b/src/Core/Language/RTL/InstalledLanguageCheckerInterface.php deleted file mode 100644 index 6ac2c826..00000000 --- a/src/Core/Language/RTL/InstalledLanguageCheckerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Language\RTL; - -/** - * Interface InstalledRtlLanguageCheckerInterface - */ -interface InstalledLanguageCheckerInterface -{ - /** - * Check if there are at least one RTL language installed in shop. - * - * @return bool - */ - public function isInstalledRtlLanguage(); -} diff --git a/src/Core/Localization/CLDR/ComputingPrecision.php b/src/Core/Localization/CLDR/ComputingPrecision.php deleted file mode 100644 index fb173163..00000000 --- a/src/Core/Localization/CLDR/ComputingPrecision.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR; - -/** - * {@inheritdoc} - */ -final class ComputingPrecision implements ComputingPrecisionInterface -{ - const MULTIPLIER = 1; - const MINIMAL_VALUE = 0; - - /** - * {@inheritdoc} - */ - public function getPrecision(int $displayPrecision) - { - // the MULTIPLIER attribute is set to 1 for now, so that it matches display precision - $computingPrecision = $displayPrecision * self::MULTIPLIER; - - return ($computingPrecision < self::MINIMAL_VALUE) ? self::MINIMAL_VALUE : $computingPrecision; - } -} diff --git a/src/Core/Localization/CLDR/ComputingPrecisionInterface.php b/src/Core/Localization/CLDR/ComputingPrecisionInterface.php deleted file mode 100644 index bfd052c1..00000000 --- a/src/Core/Localization/CLDR/ComputingPrecisionInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR; - -/** - * Will calculate the computing precision (fraction digits number used for computations) that should - * be used for a given display precision. - */ -interface ComputingPrecisionInterface -{ - /** - * Number of decimal digits to take into account when computing values - * for a given display precision - * - * @var int - * - * @return int - */ - public function getPrecision(int $displayPrecision); -} diff --git a/src/Core/Localization/CLDR/Currency.php b/src/Core/Localization/CLDR/Currency.php deleted file mode 100644 index 23d97928..00000000 --- a/src/Core/Localization/CLDR/Currency.php +++ /dev/null @@ -1,171 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR; - -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; - -/** - * CLDR Currency entity. This is an immutable data object. - * - * This class represents the immutable object of CLDR data for a specific currency, translated in a given language. - * It is the only data object visible and handleable by "outside" code (meaning non-CLDR code). - * CLDR Locale objects aggregate multiple CLDR Currency instances (available currencies), and return this class when - * asked for a given currency. - */ -final class Currency implements CurrencyInterface -{ - /** - * Alphabetic ISO 4217 currency code. - * - * @var string - */ - private $isoCode; - - /** - * Numeric ISO 4217 currency code. - * - * @var string - */ - private $numericIsoCode; - - /** - * Number of decimal digits to display for a price in this currency. - * - * @var int - */ - private $decimalDigits; - - /** - * Possible names depending on count context. - * - * e.g.: "Used currency is dollar" (default), "I need one dollar" (one), "I need five dollars" (other) - * [ - * 'default' => 'dollar', - * 'one' => 'dollar', - * 'other' => 'dollars', - * ] - * - * @var string[] - */ - private $displayNames; - - /** - * Possible symbols (PrestaShop is using narrow). - * - * e.g.: - * [ - * 'default' => 'US$', - * 'narrow' => '$', - * ] - * - * @var string[] - */ - private $symbols; - - public function __construct(CurrencyData $currencyData) - { - $this->isoCode = $currencyData->getIsoCode(); - $this->numericIsoCode = $currencyData->getNumericIsoCode(); - $this->decimalDigits = $currencyData->getDecimalDigits(); - $this->displayNames = $currencyData->getDisplayNames(); - $this->symbols = $currencyData->getSymbols(); - } - - /** - * Get the ISO code of this currency. - * - * @return string - * The currency's ISO 4217 code - */ - public function getIsoCode() - { - return $this->isoCode; - } - - /** - * Get the numeric ISO code of this currency. - * - * @return string The currency's ISO 4217 numeric code - */ - public function getNumericIsoCode() - { - return $this->numericIsoCode; - } - - /** - * Get the number of decimal digits to display when formatting a price with this currency. - * - * @return int The number of decimal digits to display - */ - public function getDecimalDigits() - { - return $this->decimalDigits; - } - - /** - * Get the display name for the passed count context. - * - * @param string $countContext - * The count context - * "default" = talking about the currency (e.g.: "used currency is Euro") - * "one" = talking about one unit of this currency (e.g.: "one euro") - * "other" = talking about several units of this currency (e.g.: "ten euros") - * - * @return string The wanted display name - */ - public function getDisplayName($countContext = CurrencyInterface::DISPLAY_NAME_COUNT_DEFAULT) - { - if (!in_array($countContext, [CurrencyInterface::DISPLAY_NAME_COUNT_DEFAULT, CurrencyInterface::DISPLAY_NAME_COUNT_ONE, CurrencyInterface::DISPLAY_NAME_COUNT_OTHER])) { - throw new LocalizationException(sprintf('Unknown display name: "%s"', print_r($countContext, true))); - } - - return $this->displayNames[$countContext]; - } - - /** - * Get the symbol of this currency. Narrow symbol is returned by default. - * - * @param string $type Possible value: "default" ("$") and "narrow" ("US$") - * - * @return string The currency's symbol - * - * @throws LocalizationException When an invalid symbol type is passed - */ - public function getSymbol($type = CurrencyInterface::SYMBOL_TYPE_NARROW) - { - if (!in_array($type, [CurrencyInterface::SYMBOL_TYPE_NARROW, CurrencyInterface::SYMBOL_TYPE_DEFAULT])) { - throw new LocalizationException(sprintf('Unknown symbol type: "%s"', print_r($type, true))); - } - - if (isset($this->symbols[$type])) { - return $this->symbols[$type]; - } - - return $this->symbols[CurrencyInterface::SYMBOL_TYPE_DEFAULT]; - } -} diff --git a/src/Core/Localization/CLDR/CurrencyData.php b/src/Core/Localization/CLDR/CurrencyData.php deleted file mode 100644 index bb47a700..00000000 --- a/src/Core/Localization/CLDR/CurrencyData.php +++ /dev/null @@ -1,248 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR; - -/** - * The CurrencyData class is the exact representation of Currency's data structure inside CLDR xml data files. - * - * This class is only used internally, it is mutable and overridable until fully built. It can then be used as - * an intermediary data bag to build a real CLDR Currency (immutable) object. - */ -class CurrencyData -{ - /** - * Alphabetic ISO 4217 currency code. - * - * @var string - */ - protected $isoCode; - - /** - * Numeric ISO 4217 currency code. - * - * @var string - */ - protected $numericIsoCode; - - /** - * Number of decimal digits to display for a price in this currency. - * - * @var int - */ - protected $decimalDigits; - - /** - * Possible names depending on count context. - * - * e.g.: "Used currency is dollar" (default), "I need one dollar" (one), "I need five dollars" (other) - * [ - * 'default' => 'dollar', - * 'one' => 'dollar', - * 'other' => 'dollars', - * ] - * - * @var string[] - */ - protected $displayNames; - - /** - * Possible symbols (PrestaShop is using narrow). - * - * e.g.: - * [ - * 'default' => 'US$', - * 'narrow' => '$', - * ] - * - * @var string[] - */ - protected $symbols; - - /** - * Is the currency used somewhere, or was it deactivated in all territories - * - * @var bool|null - */ - protected $active; - - /** - * Override this object's data with another CurrencyData object. - * - * @param CurrencyData $currencyData - * Currency data to use for the override - * - * @return $this - * Fluent interface - */ - public function overrideWith(CurrencyData $currencyData) - { - if (null !== $currencyData->getIsoCode()) { - $this->setIsoCode($currencyData->getIsoCode()); - } - - if (null !== $currencyData->getNumericIsoCode()) { - $this->setNumericIsoCode($currencyData->getNumericIsoCode()); - } - - if (null !== $currencyData->isActive()) { - $this->setActive($currencyData->isActive()); - } - - if (null !== $currencyData->getDecimalDigits()) { - $this->setDecimalDigits($currencyData->getDecimalDigits()); - } - - if (null !== $currencyData->getDisplayNames()) { - $this->displayNames = array_merge($this->displayNames ?? [], $currencyData->getDisplayNames()); - } - - if (null !== $currencyData->getSymbols()) { - $this->symbols = array_merge($this->symbols ?? [], $currencyData->getSymbols()); - } - - return $this; - } - - /** - * @return string - */ - public function getIsoCode() - { - return $this->isoCode; - } - - /** - * @param string $isoCode - * - * @return CurrencyData - */ - public function setIsoCode($isoCode) - { - $this->isoCode = $isoCode; - - return $this; - } - - /** - * @return string - */ - public function getNumericIsoCode() - { - return $this->numericIsoCode; - } - - /** - * @param string $numericIsoCode - * - * @return CurrencyData - */ - public function setNumericIsoCode($numericIsoCode) - { - $this->numericIsoCode = $numericIsoCode; - - return $this; - } - - /** - * @return int - */ - public function getDecimalDigits() - { - return $this->decimalDigits; - } - - /** - * @param int $decimalDigits - * - * @return CurrencyData - */ - public function setDecimalDigits($decimalDigits) - { - $this->decimalDigits = $decimalDigits; - - return $this; - } - - /** - * @return string[] - */ - public function getDisplayNames() - { - return $this->displayNames; - } - - /** - * @param string[] $displayNames - * - * @return CurrencyData - */ - public function setDisplayNames($displayNames) - { - $this->displayNames = $displayNames; - - return $this; - } - - /** - * @return string[] - */ - public function getSymbols() - { - return $this->symbols; - } - - /** - * @param string[] $symbols - * - * @return CurrencyData - */ - public function setSymbols($symbols) - { - $this->symbols = $symbols; - - return $this; - } - - /** - * is currency still active in some territory - * - * @return bool|null - */ - public function isActive() - { - return $this->active; - } - - /** - * @param bool $active - */ - public function setActive($active) - { - $this->active = (bool) $active; - } -} diff --git a/src/Core/Localization/CLDR/CurrencyDataLayerInterface.php b/src/Core/Localization/CLDR/CurrencyDataLayerInterface.php deleted file mode 100644 index 5aeb82fe..00000000 --- a/src/Core/Localization/CLDR/CurrencyDataLayerInterface.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR; - -/** - * CLDR Currency data layer classes interface. - * - * Describes the behavior of CldrCurrencyDataLayer classes - */ -interface CurrencyDataLayerInterface -{ - /** - * Read Currency by currency code. - * - * @param string $currencyCode - * The currency code (ISO 4217) - * - * @return CurrencyData - * The searched CLDR currency data - */ - public function read($currencyCode); - - /** - * Write a currency data object into the data source. - * - * @param string $currencyCode - * The currency code (ISO 4217) - * @param CurrencyData $currencyData - * The currency data to write - * - * @return CurrencyData - * The currency data to be written by the upper data layer - */ - public function write($currencyCode, $currencyData); - - /** - * Set the lower layer. - * When reading data, if nothing is found then it will try to read in the lower data layer - * When writing data, the data will also be written in the lower data layer. - * - * @param currencyDataLayerInterface $lowerLayer - * The lower data layer - * - * @return self - */ - public function setLowerLayer(CurrencyDataLayerInterface $lowerLayer); -} diff --git a/src/Core/Localization/CLDR/CurrencyInterface.php b/src/Core/Localization/CLDR/CurrencyInterface.php deleted file mode 100644 index f7e53d20..00000000 --- a/src/Core/Localization/CLDR/CurrencyInterface.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR\DataLayer; - -use PrestaShop\PrestaShop\Core\Data\Layer\AbstractDataLayer; -use PrestaShop\PrestaShop\Core\Data\Layer\DataLayerException; -use PrestaShop\PrestaShop\Core\Localization\CLDR\CurrencyData; -use PrestaShop\PrestaShop\Core\Localization\CLDR\CurrencyDataLayerInterface; -use PrestaShop\PrestaShop\Core\Localization\Currency\LocalizedCurrencyId; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use Symfony\Component\Cache\Adapter\AdapterInterface; - -/** - * CurrencyCache CLDR data layer. - * - * This currency data layer reads and writes CLDR CurrencyData from a cache adapter - */ -final class CurrencyCache extends AbstractDataLayer implements CurrencyDataLayerInterface -{ - /** - * Symfony Cache component adapter. - * - * Provides cached CurrencyData objects - * Implements PSR-6: Cache Interface (@see http://www.php-fig.org/psr/psr-6/) - * - * @var AdapterInterface - */ - protected $cache; - - public function __construct(AdapterInterface $cache) - { - $this->cache = $cache; - } - - /** - * {@inheritdoc} - */ - public function setLowerLayer(CurrencyDataLayerInterface $lowerLayer) - { - $this->lowerDataLayer = $lowerLayer; - - return $this; - } - - /** - * Actually read a CLDR CurrencyData object into the current layer. - * - * Might be a file access, cache read, DB select... - * - * @param mixed $currencyCode - * The CLDR CurrencyData object identifier - * - * @return CurrencyData|null - * The wanted CLDR CurrencyData object (null if not found) - */ - protected function doRead($currencyCode) - { - $cacheItem = $this->cache->getItem($currencyCode); - - return $cacheItem->isHit() - ? $cacheItem->get() - : null; - } - - /** - * {@inheritdoc} - */ - public function write($id, $data) - { - if (!($data instanceof CurrencyData)) { - throw new LocalizationException('$data must be an instance of ' . CurrencyData::class); - } - - return parent::write($id, $data); - } - - /** - * Actually write a CLDR CurrencyData object into the current layer. - * - * Might be a file edit, cache update, DB insert/update... - * - * @param LocalizedCurrencyId $currencyDataId - * The data object identifier - * @param CurrencyData $data - * The data object to be written - * - * @throws DataLayerException - * When write fails - */ - protected function doWrite($currencyDataId, $data) - { - $cacheItem = $this->cache->getItem((string) $currencyDataId); - $cacheItem->set($data); - - $saved = $this->cache->save($cacheItem); - - if (!$saved) { - throw new DataLayerException('Unable to persist data in cache data layer'); - } - } -} diff --git a/src/Core/Localization/CLDR/DataLayer/LocaleCache.php b/src/Core/Localization/CLDR/DataLayer/LocaleCache.php deleted file mode 100644 index 6f945be0..00000000 --- a/src/Core/Localization/CLDR/DataLayer/LocaleCache.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR\DataLayer; - -use PrestaShop\PrestaShop\Core\Data\Layer\AbstractDataLayer; -use PrestaShop\PrestaShop\Core\Data\Layer\DataLayerException; -use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleData; -use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleDataLayerInterface as CldrLocaleDataLayerInterface; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use Symfony\Component\Cache\Adapter\AdapterInterface; - -/** - * LocaleCache CLDR data layer. - * - * This locale data layer reads and writes CLDR LocaleData from a cache adapter - */ -class LocaleCache extends AbstractDataLayer implements CldrLocaleDataLayerInterface -{ - /** - * Symfony Cache component adapter. - * - * Provides cached LocaleData objects - * Implements PSR-6: Cache Interface (@see http://www.php-fig.org/psr/psr-6/) - * - * @var AdapterInterface - */ - protected $cache; - - public function __construct(AdapterInterface $cache) - { - $this->cache = $cache; - } - - /** - * {@inheritdoc} - */ - public function setLowerLayer(CldrLocaleDataLayerInterface $lowerLayer) - { - $this->lowerDataLayer = $lowerLayer; - - return $this; - } - - /** - * Actually read a CLDR LocaleData object into the current layer. - * - * Data is read from passed cache adapter - * - * @param string $localeCode - * The CLDR LocaleData object identifier - * - * @return LocaleData|null - * The wanted CLDR LocaleData object (null if not found) - */ - protected function doRead($localeCode) - { - $cacheItem = $this->cache->getItem($localeCode); - - return $cacheItem->isHit() - ? $cacheItem->get() - : null; - } - - /** - * {@inheritdoc} - */ - public function write($id, $data) - { - if (!($data instanceof LocaleData)) { - throw new LocalizationException('$data must be an instance of ' . LocaleData::class); - } - - return parent::write($id, $data); - } - - /** - * Actually write a LocaleData object into the current layer. - * - * Might be a file edit, cache update, DB insert/update... - * - * @param mixed $localeCode - * The LocaleData object identifier - * @param LocaleData $data - * The CLDR LocaleData object to be written - * - * @throws DataLayerException - * When write fails - */ - protected function doWrite($localeCode, $data) - { - $cacheItem = $this->cache->getItem($localeCode); - $cacheItem->set($data); - - $saved = $this->cache->save($cacheItem); - - if (!$saved) { - throw new DataLayerException('Unable to persist data in cache data layer'); - } - } -} diff --git a/src/Core/Localization/CLDR/DataLayer/LocaleReference.php b/src/Core/Localization/CLDR/DataLayer/LocaleReference.php deleted file mode 100644 index c08eebb6..00000000 --- a/src/Core/Localization/CLDR/DataLayer/LocaleReference.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR\DataLayer; - -use PrestaShop\PrestaShop\Core\Data\Layer\AbstractDataLayer; -use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleData; -use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleDataLayerInterface as CldrLocaleDataLayerInterface; -use PrestaShop\PrestaShop\Core\Localization\CLDR\ReaderInterface; - -/** - * Locale reference data layer. - * - * Provides reference (CLDR) data for locale, number specification, currencies... - * Data comes from CLDR official data files, and is read only. - */ -class LocaleReference extends AbstractDataLayer implements CldrLocaleDataLayerInterface -{ - /** - * CLDR files reader. - * - * Provides LocaleData objects - * - * @var ReaderInterface - */ - protected $reader; - - public function __construct(ReaderInterface $reader) - { - $this->reader = $reader; - } - - /** - * {@inheritdoc} - */ - public function setLowerLayer(CldrLocaleDataLayerInterface $lowerLayer) - { - $this->lowerDataLayer = $lowerLayer; - - return $this; - } - - /** - * Actually read a CLDR LocaleData object into the current layer. - * - * Data is read from official CLDR file (via the CLDR files reader) - * - * @param string $localeCode - * The CLDR LocaleData object identifier - * - * @return LocaleData|null - * The wanted CLDR LocaleData object (null if not found) - */ - protected function doRead($localeCode) - { - return $this->reader->readLocaleData($localeCode); - } - - /** - * CLDR files are read only. Nothing can be written there. - * - * @param string $localeCode - * The CLDR LocaleData object identifier - * @param LocaleData $data - * The CLDR LocaleData object to be written - */ - protected function doWrite($localeCode, $data) - { - // Nothing. - } -} diff --git a/src/Core/Localization/CLDR/Locale.php b/src/Core/Localization/CLDR/Locale.php deleted file mode 100644 index db0d7bce..00000000 --- a/src/Core/Localization/CLDR/Locale.php +++ /dev/null @@ -1,320 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR; - -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; - -/** - * CLDR Locale entity. This is an immutable data object. - * - * This class represents the immutable object of CLDR data for a specific locale, translated in a given language. - * It is the only data object visible and handleable by "outside" code (meaning non-CLDR code). - */ -final class Locale implements LocaleInterface -{ - /** - * The locale code for this data (either language code or IETF tag). - * - * @var string - */ - protected $localeCode; - - /** - * List of available numbering systems - * Array of strings (codes). - * - * @var string[] - */ - protected $numberingSystems; - - /** - * Default numbering system. - * - * @var string - */ - protected $defaultNumberingSystem; - - /** - * Used to suppress groupings below a certain value. - * - * 1 -> grouping starts at 4 figures integers (1,000 and more) - * 2 -> grouping starts at 5 figures integers (10,000 and more) - * - * @var int - */ - protected $minimumGroupingDigits; - - /** - * Collection of all available symbols list (by numbering system). - * - * @var NumberSymbolsData[] - */ - protected $numberSymbols; - - /** - * Collection of all available decimal patterns (by numbering system) - * Array of strings (patterns). - * - * @var string[] - */ - protected $decimalPatterns; - - /** - * Collection of all available percent patterns (by numbering system) - * Array of strings (patterns). - * - * @var string[] - */ - protected $percentPatterns; - - /** - * Collection of all available currency patterns (by numbering system) - * Array of strings (patterns). - * - * @var string[] - */ - protected $currencyPatterns; - - /** - * All currencies, by ISO code. - * - * @var CurrencyData[] - */ - protected $currencies; - - public function __construct(LocaleData $localeData) - { - $this->localeCode = $localeData->getLocaleCode(); - $this->numberingSystems = $localeData->getNumberingSystems(); - $this->defaultNumberingSystem = $localeData->getDefaultNumberingSystem(); - $this->minimumGroupingDigits = $localeData->getMinimumGroupingDigits(); - $this->numberSymbols = $localeData->getNumberSymbols(); - $this->decimalPatterns = $localeData->getDecimalPatterns(); - $this->percentPatterns = $localeData->getPercentPatterns(); - $this->currencyPatterns = $localeData->getCurrencyPatterns(); - $this->currencies = $localeData->getCurrencies(); - } - - /** - * Get the code of this Locale (simplified IETF notation). - * - * @return string - * The locale code - */ - public function getLocaleCode() - { - return $this->localeCode; - } - - /** - * Get all available numbering systems for this locale. - * - * @return string[] - */ - public function getNumberingSystems() - { - return $this->numberingSystems; - } - - /** - * Get the default numbering system for this locale. - * - * @return string - */ - public function getDefaultNumberingSystem() - { - return $this->defaultNumberingSystem; - } - - /** - * Get the minimum grouping digits number when formatting numbers for this locale. - * - * @return int - */ - public function getMinimumGroupingDigits() - { - return $this->minimumGroupingDigits; - } - - /** - * Get all available number symbols lists, by numbering system. - * - * @return NumberSymbolsData[] - * All number symbols lists (by numbering system) - */ - public function getAllNumberSymbols() - { - return $this->numberSymbols; - } - - /** - * Get the number symbols to use for a given numbering system. - * - * @param string|null $numberingSystem - * The numbering system of the wanted symbols set. - * If null, the default numbering system of this locale will be used. - * - * @return NumberSymbolsData - * The wanted number symbols - * - * @throws LocalizationException - * When passed $numberingSystem is invalid - */ - public function getNumberSymbolsByNumberingSystem($numberingSystem = null) - { - if (null === $numberingSystem) { - $numberingSystem = $this->getDefaultNumberingSystem(); - } - if (!isset($this->getAllNumberSymbols()[$numberingSystem])) { - throw new LocalizationException('Invalid numbering system: ' . $numberingSystem); - } - - return $this->getAllNumberSymbols()[$numberingSystem]; - } - - /** - * Get the pattern to use when formatting a decimal number (for a given numbering system). - * - * @param string|null $numberingSystem - * The numbering system of the wanted symbols set. - * If null, the default numbering system of this locale will be used. - * - * @return string - * The decimal pattern - * - * @throws LocalizationException - * When passed numbering system is invalid - */ - public function getDecimalPattern($numberingSystem = null) - { - if (null === $numberingSystem) { - $numberingSystem = $this->getDefaultNumberingSystem(); - } - if (!isset($this->decimalPatterns[$numberingSystem])) { - throw new LocalizationException('No decimal pattern found for numbering system: ' . $numberingSystem); - } - - return $this->decimalPatterns[$numberingSystem]; - } - - /** - * Get the pattern to use when formatting a percentage (for a given numbering system). - * - * @param string|null $numberingSystem - * The numbering system of the wanted symbols set. - * If null, the default numbering system of this locale will be used. - * - * @return string - * The percent pattern - * - * @throws LocalizationException - * When passed numbering system is invalid - */ - public function getPercentPattern($numberingSystem = null) - { - if (null === $numberingSystem) { - $numberingSystem = $this->getDefaultNumberingSystem(); - } - if (!isset($this->percentPatterns[$numberingSystem])) { - throw new LocalizationException('No percent pattern found for numbering system: ' . $numberingSystem); - } - - return $this->percentPatterns[$numberingSystem]; - } - - /** - * Get the pattern to use when formatting a price (for a given numbering system). - * - * @param string|null $numberingSystem - * The numbering system of the wanted symbols set. - * If null, the default numbering system of this locale will be used. - * - * @return string - * The currency pattern - * - * @throws LocalizationException - * When passed numbering system is invalid - */ - public function getCurrencyPattern($numberingSystem = null) - { - if (null === $numberingSystem) { - $numberingSystem = $this->getDefaultNumberingSystem(); - } - if (!isset($this->currencyPatterns[$numberingSystem])) { - throw new LocalizationException('No currency pattern found for numbering system: ' . $numberingSystem); - } - - return $this->currencyPatterns[$numberingSystem]; - } - - /** - * Get a given CLDR Currency. - * - * @param string $currencyCode An ISO 4217 currency code - * - * @return CurrencyInterface|null The wanted CLDR Currency. Null if this currency is not available for this locale. - */ - public function getCurrency($currencyCode) - { - $currencyData = $this->getCurrencyData($currencyCode); - if (!empty($currencyData)) { - return new Currency($currencyData); - } - - return null; - } - - /** - * Get CLDR data of a given currency. - * - * @param string $currencyCode - * An ISO 4217 currency code - * - * @return CurrencyData|null - * The wanted currency data. Null if this currency is not available for this locale. - */ - public function getCurrencyData($currencyCode) - { - if (!empty($this->currencies[$currencyCode])) { - return $this->currencies[$currencyCode]; - } - - return null; - } - - /** - * Get CLDR data of all currencies. - * - * @return currencyData[] - * Data of all currencies - */ - public function getAllCurrencies() - { - return $this->currencies; - } -} diff --git a/src/Core/Localization/CLDR/LocaleData.php b/src/Core/Localization/CLDR/LocaleData.php deleted file mode 100644 index 9fa133dc..00000000 --- a/src/Core/Localization/CLDR/LocaleData.php +++ /dev/null @@ -1,371 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR; - -/** - * The LocaleData class is the exact representation of Locale's data structure inside CLDR xml data files. - * - * This class is only used internally, it is mutable and overridable until fully built. It can then be used as - * an intermediary data bag to build a real CLDR Locale (immutable) object. - */ -class LocaleData -{ - /** - * The locale code for this data (either language code or IETF tag). - * e.G.: 'fr', 'fr-FR'... - * - * @var string - */ - protected $localeCode; - - /** - * List of available numbering systems - * Array of strings (codes). - * - * @var string[] - */ - protected $numberingSystems; - - /** - * Default numbering system. - * - * @var string - */ - protected $defaultNumberingSystem; - - /** - * Used to suppress groupings below a certain value. - * - * 1 -> grouping starts at 4 figures integers (1,000 and more) - * 2 -> grouping starts at 5 figures integers (10,000 and more) - * - * @var int - */ - protected $minimumGroupingDigits; - - /** - * Collection of all available symbols list (by numbering system). - * - * @var NumberSymbolsData[] - */ - protected $numberSymbols; - - /** - * Collection of all available decimal patterns (by numbering system) - * Array of strings (patterns). - * - * @var string[] - */ - protected $decimalPatterns; - - /** - * Collection of all available percent patterns (by numbering system) - * Array of strings (patterns). - * - * @var string[] - */ - protected $percentPatterns; - - /** - * Collection of all available currency patterns (by numbering system) - * Array of strings (patterns). - * - * @var string[] - */ - protected $currencyPatterns; - - /** - * All currencies, by ISO code. - * - * @var CurrencyData[] - */ - protected $currencies; - - /** - * Override this object's data with another LocaleData object. - * - * @param LocaleData $localeData Locale data to use for the override - * - * @return $this Fluent interface - */ - public function overrideWith(LocaleData $localeData) - { - if (null !== $localeData->getLocaleCode()) { - $this->setLocaleCode($localeData->getLocaleCode()); - } - - if (null !== $localeData->getNumberingSystems()) { - if (null === $this->numberingSystems) { - $this->numberingSystems = []; - } - $this->numberingSystems = array_merge($this->numberingSystems, $localeData->getNumberingSystems()); - } - - if (null !== $localeData->getDefaultNumberingSystem()) { - $this->setDefaultNumberingSystem($localeData->getDefaultNumberingSystem()); - } - - if (null !== $localeData->getMinimumGroupingDigits()) { - $this->setMinimumGroupingDigits($localeData->getMinimumGroupingDigits()); - } - - if (null !== $localeData->getNumberSymbols()) { - foreach ($localeData->getNumberSymbols() as $numberingSystem => $symbolsData) { - if (!isset($this->numberSymbols[$numberingSystem])) { - $this->numberSymbols[$numberingSystem] = $symbolsData; - - continue; - } - $this->numberSymbols[$numberingSystem]->overrideWith($symbolsData); - } - } - - if (null !== $localeData->getDecimalPatterns()) { - $this->setDecimalPatterns($localeData->getDecimalPatterns()); - } - - if (null !== $localeData->getPercentPatterns()) { - $this->setPercentPatterns($localeData->getPercentPatterns()); - } - - if (null !== $localeData->getCurrencyPatterns()) { - if (null === $this->currencyPatterns) { - $this->currencyPatterns = []; - } - $this->currencyPatterns = array_merge($this->currencyPatterns, $localeData->getCurrencyPatterns()); - } - - if (null !== $localeData->getCurrencies()) { - foreach ($localeData->getCurrencies() as $code => $currencyData) { - if (!isset($this->currencies[$code])) { - $this->currencies[$code] = $currencyData; - continue; - } - $this->currencies[$code]->overrideWith($currencyData); - } - } - - return $this; - } - - /** - * @return string - */ - public function getLocaleCode() - { - return $this->localeCode; - } - - /** - * @param string $localeCode - * - * @return LocaleData - */ - public function setLocaleCode($localeCode) - { - $this->localeCode = $localeCode; - - return $this; - } - - /** - * @return string[] - */ - public function getNumberingSystems() - { - return $this->numberingSystems; - } - - /** - * @param string[] $numberingSystems - * - * @return LocaleData - */ - public function setNumberingSystems($numberingSystems) - { - $this->numberingSystems = $numberingSystems; - - return $this; - } - - /** - * @return string - */ - public function getDefaultNumberingSystem() - { - return $this->defaultNumberingSystem; - } - - /** - * @param string $defaultNumberingSystem - * - * @return LocaleData - */ - public function setDefaultNumberingSystem($defaultNumberingSystem) - { - $this->defaultNumberingSystem = $defaultNumberingSystem; - - return $this; - } - - /** - * @return int - */ - public function getMinimumGroupingDigits() - { - return $this->minimumGroupingDigits; - } - - /** - * @param int $minimumGroupingDigits - * - * @return LocaleData - */ - public function setMinimumGroupingDigits($minimumGroupingDigits) - { - $this->minimumGroupingDigits = $minimumGroupingDigits; - - return $this; - } - - /** - * @return \PrestaShop\PrestaShop\Core\Localization\CLDR\NumberSymbolsData[] - */ - public function getNumberSymbols() - { - return $this->numberSymbols; - } - - /** - * @param \PrestaShop\PrestaShop\Core\Localization\CLDR\NumberSymbolsData[] $numberSymbols - * - * @return LocaleData - */ - public function setNumberSymbols($numberSymbols) - { - $this->numberSymbols = $numberSymbols; - - return $this; - } - - /** - * @return string[] - */ - public function getDecimalPatterns() - { - return $this->decimalPatterns; - } - - /** - * @param string[] $decimalPatterns - * - * @return LocaleData - */ - public function setDecimalPatterns($decimalPatterns) - { - $this->decimalPatterns = $decimalPatterns; - - return $this; - } - - /** - * @return string[] - */ - public function getPercentPatterns() - { - return $this->percentPatterns; - } - - /** - * @param string[] $percentPatterns - * - * @return LocaleData - */ - public function setPercentPatterns($percentPatterns) - { - $this->percentPatterns = $percentPatterns; - - return $this; - } - - /** - * @return string[] - */ - public function getCurrencyPatterns() - { - return $this->currencyPatterns; - } - - /** - * @param string[] $currencyPatterns - * - * @return LocaleData - */ - public function setCurrencyPatterns($currencyPatterns) - { - $this->currencyPatterns = $currencyPatterns; - - return $this; - } - - /** - * @return CurrencyData[] - */ - public function getCurrencies() - { - return $this->currencies; - } - - /** - * @param string $currencyIsoCode - * - * @return CurrencyData|null - */ - public function getCurrencyByIsoCode($currencyIsoCode) - { - foreach ($this->getCurrencies() as $currencyData) { - if ($currencyData->getIsoCode() == $currencyIsoCode) { - return $currencyData; - } - } - - return null; - } - - /** - * @param CurrencyData[] $currencies - * - * @return LocaleData - */ - public function setCurrencies($currencies) - { - $this->currencies = $currencies; - - return $this; - } -} diff --git a/src/Core/Localization/CLDR/LocaleDataLayerInterface.php b/src/Core/Localization/CLDR/LocaleDataLayerInterface.php deleted file mode 100644 index 0a734db1..00000000 --- a/src/Core/Localization/CLDR/LocaleDataLayerInterface.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR; - -/** - * CLDR Locale data layer classes interface. - * - * Describes the behavior of CldrLocaleDataLayer classes - */ -interface LocaleDataLayerInterface -{ - /** - * Read CLDR locale data by locale code. - * - * @param string $localeCode - * The locale code (simplified IETF tag syntax) - * Combination of ISO 639-1 (2-letters language code) and ISO 3166-2 (2-letters region code) - * eg: fr-FR, en-US - * - * @return LocaleData - * The searched locale's CLDR data - */ - public function read($localeCode); - - /** - * Write a locale's CLDR data object into the data source. - * - * @param string $localeCode - * The locale code (simplified IETF tag syntax) - * Combination of ISO 639-1 (2-letters language code) and ISO 3166-2 (2-letters region code) - * eg: fr-FR, en-US - * @param LocaleData $localeData - * The locale's CLDR data to write - * - * @return LocaleData - * The locale's CLDR data to be written by the upper data layer - */ - public function write($localeCode, $localeData); - - /** - * Set the lower layer. - * When reading data, if nothing is found then it will try to read in the lower data layer - * When writing data, the data will also be written in the lower data layer. - * - * @param localeDataLayerInterface $lowerLayer - * The lower data layer - * - * @return self - */ - public function setLowerLayer(LocaleDataLayerInterface $lowerLayer); -} diff --git a/src/Core/Localization/CLDR/LocaleDataSource.php b/src/Core/Localization/CLDR/LocaleDataSource.php deleted file mode 100644 index 9f302d61..00000000 --- a/src/Core/Localization/CLDR/LocaleDataSource.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR; - -use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleDataLayerInterface as CldrLocaleDataLayerInterface; - -/** - * LocaleDataSource provides CLDR LocaleData objects. - * - * This class uses Locale data layers as middlewares stack to read CLDR data. - */ -class LocaleDataSource -{ - /** - * @var CldrLocaleDataLayerInterface - */ - private $topLayer; - - /** - * LocaleDataSource constructor needs a CldrLocaleDataLayerInterface layer object. - * This top layer might be chained with lower layers and will be the entry point of this middleware stack. - * - * @param CldrLocaleDataLayerInterface $topLayer - */ - public function __construct(CldrLocaleDataLayerInterface $topLayer) - { - $this->topLayer = $topLayer; - } - - /** - * @param string $localeCode - * - * @return LocaleData - */ - public function getLocaleData($localeCode) - { - return $this->topLayer->read($localeCode); - } -} diff --git a/src/Core/Localization/CLDR/LocaleInterface.php b/src/Core/Localization/CLDR/LocaleInterface.php deleted file mode 100644 index 84b95697..00000000 --- a/src/Core/Localization/CLDR/LocaleInterface.php +++ /dev/null @@ -1,164 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR; - -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; - -/** - * CLDR Locale entity. This is an immutable data object. - * - * This class represents the immutable object of CLDR data for a specific locale, translated in a given language. - * It is the only data object visible and handleable by "outside" code (meaning non-CLDR code). - */ -interface LocaleInterface -{ - /** - * Get the code of this Locale (simplified IETF notation). - * - * @return string - * The locale code - */ - public function getLocaleCode(); - - /** - * Get all available numbering systems for this locale. - * - * @return string[] - */ - public function getNumberingSystems(); - - /** - * Get the default numbering system for this locale. - * - * @return string - */ - public function getDefaultNumberingSystem(); - - /** - * Get the minimum grouping digits number when formatting numbers for this locale. - * - * @return int - */ - public function getMinimumGroupingDigits(); - - /** - * Get all available number symbols lists, by numbering system. - * - * @return NumberSymbolsData[] - * All number symbols lists (by numbering system) - */ - public function getAllNumberSymbols(); - - /** - * Get the number symbols to use for a given numbering system. - * - * @param string|null $numberingSystem - * The numbering system of the wanted symbols set. - * If null, the default numbering system of this locale will be used. - * - * @return NumberSymbolsData - * The wanted number symbols - * - * @throws LocalizationException - * When passed $numberingSystem is invalid - */ - public function getNumberSymbolsByNumberingSystem($numberingSystem = null); - - /** - * Get the pattern to use when formatting a decimal number (for a given numbering system). - * - * @param string|null $numberingSystem - * The numbering system of the wanted symbols set. - * If null, the default numbering system of this locale will be used. - * - * @return string - * The decimal pattern - * - * @throws LocalizationException - * When passed numbering system is invalid - */ - public function getDecimalPattern($numberingSystem = null); - - /** - * Get the pattern to use when formatting a percentage (for a given numbering system). - * - * @param string|null $numberingSystem - * The numbering system of the wanted symbols set. - * If null, the default numbering system of this locale will be used. - * - * @return string - * The percent pattern - * - * @throws LocalizationException - * When passed numbering system is invalid - */ - public function getPercentPattern($numberingSystem = null); - - /** - * Get the pattern to use when formatting a price (for a given numbering system). - * - * @param string|null $numberingSystem - * The numbering system of the wanted symbols set. - * If null, the default numbering system of this locale will be used. - * - * @return string - * The currency pattern - * - * @throws LocalizationException - * When passed numbering system is invalid - */ - public function getCurrencyPattern($numberingSystem = null); - - /** - * Get a given CLDR Currency. - * - * @param string $currencyCode An ISO 4217 currency code - * - * @return CurrencyInterface|null The wanted CLDR Currency. Null if this currency is not available for this locale. - */ - public function getCurrency($currencyCode); - - /** - * Get CLDR data of a given currency. - * - * @param string $currencyCode - * An ISO 4217 currency code - * - * @return CurrencyData|null - * The wanted currency data. Null if this currency is not available for this locale. - */ - public function getCurrencyData($currencyCode); - - /** - * Get CLDR data of all currencies. - * - * @return currencyData[] - * Data of all currencies - */ - public function getAllCurrencies(); -} diff --git a/src/Core/Localization/CLDR/LocaleRepository.php b/src/Core/Localization/CLDR/LocaleRepository.php deleted file mode 100644 index 1bafdf02..00000000 --- a/src/Core/Localization/CLDR/LocaleRepository.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR; - -use PrestaShop\PrestaShop\Core\Localization\CLDR\Locale as CldrLocale; - -/** - * CLDR Locale Repository. - * - * Provides CLDR Locale objects - */ -class LocaleRepository -{ - /** - * @var LocaleDataSource - */ - protected $dataSource; - - public function __construct(LocaleDataSource $dataSource) - { - $this->dataSource = $dataSource; - } - - /** - * Get a CLDR Locale by simplified IETF tag. - * - * @param string $localeCode - * e.g.: fr-FR, en-US... - * - * @return CldrLocale|null - * A CldrLocale object. Null if not found - */ - public function getLocale($localeCode) - { - $localeData = $this->dataSource->getLocaleData($localeCode); - - if (null === $localeData) { - return null; - } - - return new CldrLocale($localeData); - } -} diff --git a/src/Core/Localization/CLDR/NumberSymbolsData.php b/src/Core/Localization/CLDR/NumberSymbolsData.php deleted file mode 100644 index 5bff453f..00000000 --- a/src/Core/Localization/CLDR/NumberSymbolsData.php +++ /dev/null @@ -1,504 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR; - -/** - * Number's symbols data object. Regroups all symbols used when formatting a number - * (decimal separator, thousands separator, etc.). - */ -class NumberSymbolsData -{ - /** - * Decimal separator character. - * - * Separates the integer and fractional part of the number. - * - * @var string - */ - protected $decimal; - - /** - * Digits group separator character. - * - * separates clusters of integer digits to make large numbers more legible; commonly used for thousands(grouping - * size 3, e.g. "100,000,000") or in some locales, ten-thousands (grouping size 4, e.g. "1,0000,0000"). - * - * @var string - */ - protected $group; - - /** - * List elements separator character. - * - * Symbol used to separate numbers in a list intended to represent structured data such as an array. - * - * @var string - */ - protected $list; - - /** - * Percent sign character. - * - * Used to indicate a percentage (1/100th) amount. - * - * @var string - */ - protected $percentSign; - - /** - * Minus sign character. - * - * Symbol used to denote negative value. - * - * @var string - */ - protected $minusSign; - - /** - * Plus sign character. - * - * Symbol used to denote positive value. - * It can be used to produce modified patterns, so that 3.12 is formatted as "+3.12", for example. - * - * @var string - */ - protected $plusSign; - - /** - * Exponential character. - * - * Symbol separating the mantissa and exponent values. - * - * @var string - */ - protected $exponential; - - /** - * Superscripting exponent character. - * - * Used in numbers to show a format like "1.23 × 10^4" - * (exponential character is a shortcut for "× 10^n" notation) - * - * @var string - */ - protected $superscriptingExponent; - - /** - * Permille sign character. - * - * Used to define them as a per-mille (1/1000th) amount. - * - * @var string - */ - protected $perMille; - - /** - * The infinity sign. Corresponds to the IEEE infinity bit pattern. - * - * @var string - */ - protected $infinity; - - /** - * The NaN (Not A Number) sign. Corresponds to the IEEE NaN bit pattern. - * - * @var string - */ - protected $nan; - - /** - * Separator used in date-time formatting. - * - * eg.: ":" => 20:00:00 (latn) - * eg.: "," => 20,00,00 (arab) - * - * @var string - */ - protected $timeSeparator; - - /** - * Will be set when decimal separator is different when formatting a price. - * - * @var string - */ - protected $currencyDecimal; - - /** - * Will be set when digits grouping is different when formatting a price. - * - * @var string - */ - protected $currencyGroup; - - /** - * Override this object's symbols with another NumberSymbolsData object. - * - * @param NumberSymbolsData $symbolsData Symbols to use for the override - * - * @return $this Fluent interface - */ - public function overrideWith(NumberSymbolsData $symbolsData) - { - if (null !== $symbolsData->getDecimal()) { - $this->setDecimal($symbolsData->getDecimal()); - } - - if (null !== $symbolsData->getGroup()) { - $this->setGroup($symbolsData->getGroup()); - } - - if (null !== $symbolsData->getList()) { - $this->setList($symbolsData->getList()); - } - - if (null !== $symbolsData->getPercentSign()) { - $this->setPercentSign($symbolsData->getPercentSign()); - } - - if (null !== $symbolsData->getMinusSign()) { - $this->setMinusSign($symbolsData->getMinusSign()); - } - - if (null !== $symbolsData->getPlusSign()) { - $this->setPlusSign($symbolsData->getPlusSign()); - } - - if (null !== $symbolsData->getExponential()) { - $this->setExponential($symbolsData->getExponential()); - } - - if (null !== $symbolsData->getSuperscriptingExponent()) { - $this->setSuperscriptingExponent($symbolsData->getSuperscriptingExponent()); - } - - if (null !== $symbolsData->getPerMille()) { - $this->setPerMille($symbolsData->getPerMille()); - } - - if (null !== $symbolsData->getInfinity()) { - $this->setInfinity($symbolsData->getInfinity()); - } - - if (null !== $symbolsData->getNan()) { - $this->setNan($symbolsData->getNan()); - } - - if (null !== $symbolsData->getTimeSeparator()) { - $this->setTimeSeparator($symbolsData->getTimeSeparator()); - } - - if (null !== $symbolsData->getCurrencyDecimal()) { - $this->setCurrencyDecimal($symbolsData->getCurrencyDecimal()); - } - - if (null !== $symbolsData->getCurrencyGroup()) { - $this->setCurrencyGroup($symbolsData->getCurrencyGroup()); - } - - return $this; - } - - /** - * @return string - */ - public function getDecimal() - { - return $this->decimal; - } - - /** - * @param string $decimal - * - * @return NumberSymbolsData - */ - public function setDecimal($decimal) - { - $this->decimal = $decimal; - - return $this; - } - - /** - * @return string - */ - public function getGroup() - { - return $this->group; - } - - /** - * @param string $group - * - * @return NumberSymbolsData - */ - public function setGroup($group) - { - $this->group = $group; - - return $this; - } - - /** - * @return string - */ - public function getList() - { - return $this->list; - } - - /** - * @param string $list - * - * @return NumberSymbolsData - */ - public function setList($list) - { - $this->list = $list; - - return $this; - } - - /** - * @return string - */ - public function getPercentSign() - { - return $this->percentSign; - } - - /** - * @param string $percentSign - * - * @return NumberSymbolsData - */ - public function setPercentSign($percentSign) - { - $this->percentSign = $percentSign; - - return $this; - } - - /** - * @return string - */ - public function getMinusSign() - { - return $this->minusSign; - } - - /** - * @param string $minusSign - * - * @return NumberSymbolsData - */ - public function setMinusSign($minusSign) - { - $this->minusSign = $minusSign; - - return $this; - } - - /** - * @return string - */ - public function getPlusSign() - { - return $this->plusSign; - } - - /** - * @param string $plusSign - * - * @return NumberSymbolsData - */ - public function setPlusSign($plusSign) - { - $this->plusSign = $plusSign; - - return $this; - } - - /** - * @return string - */ - public function getExponential() - { - return $this->exponential; - } - - /** - * @param string $exponential - * - * @return NumberSymbolsData - */ - public function setExponential($exponential) - { - $this->exponential = $exponential; - - return $this; - } - - /** - * @return string - */ - public function getSuperscriptingExponent() - { - return $this->superscriptingExponent; - } - - /** - * @param string $superscriptingExponent - * - * @return NumberSymbolsData - */ - public function setSuperscriptingExponent($superscriptingExponent) - { - $this->superscriptingExponent = $superscriptingExponent; - - return $this; - } - - /** - * @return string - */ - public function getPerMille() - { - return $this->perMille; - } - - /** - * @param string $perMille - * - * @return NumberSymbolsData - */ - public function setPerMille($perMille) - { - $this->perMille = $perMille; - - return $this; - } - - /** - * @return string - */ - public function getInfinity() - { - return $this->infinity; - } - - /** - * @param string $infinity - * - * @return NumberSymbolsData - */ - public function setInfinity($infinity) - { - $this->infinity = $infinity; - - return $this; - } - - /** - * @return string - */ - public function getNan() - { - return $this->nan; - } - - /** - * @param string $nan - * - * @return NumberSymbolsData - */ - public function setNan($nan) - { - $this->nan = $nan; - - return $this; - } - - /** - * @return string - */ - public function getTimeSeparator() - { - return $this->timeSeparator; - } - - /** - * @param string $timeSeparator - * - * @return NumberSymbolsData - */ - public function setTimeSeparator($timeSeparator) - { - $this->timeSeparator = $timeSeparator; - - return $this; - } - - /** - * @return string - */ - public function getCurrencyDecimal() - { - return $this->currencyDecimal; - } - - /** - * @param string $currencyDecimal - * - * @return NumberSymbolsData - */ - public function setCurrencyDecimal($currencyDecimal) - { - $this->currencyDecimal = $currencyDecimal; - - return $this; - } - - /** - * @return string - */ - public function getCurrencyGroup() - { - return $this->currencyGroup; - } - - /** - * @param string $currencyGroup - * - * @return NumberSymbolsData - */ - public function setCurrencyGroup($currencyGroup) - { - $this->currencyGroup = $currencyGroup; - - return $this; - } -} diff --git a/src/Core/Localization/CLDR/Reader.php b/src/Core/Localization/CLDR/Reader.php deleted file mode 100644 index 9040f05f..00000000 --- a/src/Core/Localization/CLDR/Reader.php +++ /dev/null @@ -1,670 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR; - -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationFileNotFoundException; -use SimpleXMLElement; - -/** - * CLDR files reader class. - * - * This class provides CLDR LocaleData objects built with data coming from official CLDR xml data files. - */ -class Reader implements ReaderInterface -{ - const CLDR_ROOT = 'localization/CLDR/'; - const CLDR_MAIN = 'localization/CLDR/core/common/main/'; - const CLDR_SUPPLEMENTAL = 'localization/CLDR/core/common/supplemental/'; - - const CLDR_ROOT_LOCALE = 'root'; - - const SUPPL_DATA_CURRENCY = 'currencyData'; - const SUPPL_DATA_LANGUAGE = 'languageData'; - const SUPPL_DATA_NUMBERING = 'numberingSystems'; - const SUPPL_DATA_PARENT_LOCALES = 'parentLocales'; // For specific locales hierarchy - - const DEFAULT_CURRENCY_DIGITS = 2; - - const CURRENCY_CODE_TEST = 'XTS'; - - /** - * delay after currency deactivation to prevent currency add by list - */ - const CURRENCY_ACTIVE_DELAY = 365; - - protected $mainXml = []; - - /** - * Supplemental data for all locales. - * Contains data about parent locales, currencies, languages... - * - * @var SimplexmlElement - */ - protected $supplementalXml; - - /** - * Additional data about numbering systems - * Mainly used for digits (they depend on numbering system). - * - * @var SimpleXMLElement - */ - protected $numberingSystemsXml; - - /** - * Read locale data by locale code. - * - * @param $localeCode - * The locale code (simplified IETF tag syntax) - * Combination of ISO 639-1 (2-letters language code) and ISO 3166-2 (2-letters region code) - * eg: fr-FR, en-US - * The underscore notation is also accepted (fr_FR, en_US...) - * - * @return LocaleData - * A LocaleData object - * - * @throws LocalizationException - * When the locale code is unknown or invalid - */ - public function readLocaleData($localeCode) - { - // CLDR filenames use a different notation from IETF. - $localeCode = str_replace('-', '_', $localeCode); - - $this->validateLocaleCodeForFilenames($localeCode); - $this->initSupplementalData(); - - $finalData = new LocaleData(); - $lookup = $this->getLookup($localeCode); - foreach ($lookup as $thisLocaleCode) { - try { - $partialData = $this->getLocaleData($thisLocaleCode); - $finalData = $finalData->overrideWith($partialData); - } catch (LocalizationFileNotFoundException $e) { - // Sometimes a file can be missing. - // Example for Chinese : zh_CN.xml doesn't exist. There is only a zh.xml file. - // That's why we can't let this exception bubble up. - continue; - } - } - - return $finalData; - } - - /** - * Validate a locale code. - * - * If the passed code doesn't respect the CLDR files naming style, an exception will be raised - * e.g.: "fr_FR" and "en_001" are valid - * - * @param $localeCode - * Locale code to be validated - * - * @throws LocalizationException - * When locale code is invalid - */ - protected function validateLocaleCodeForFilenames($localeCode) - { - if (!preg_match('#^[a-zA-Z0-9]+(_[a-zA-Z0-9]+)*$#', $localeCode)) { - throw new LocalizationException(sprintf('Invalid locale code: "%s"', $localeCode)); - } - } - - /** - * Initialize supplemental CLDR data. - */ - protected function initSupplementalData() - { - // Supplemental data about currencies, languages and parent locales - if (!isset($this->supplementalXml)) { - $supplementalPath = realpath( - _PS_ROOT_DIR_ . '/' - . self::CLDR_SUPPLEMENTAL - . 'supplementalData.xml' - ); - $this->supplementalXml = simplexml_load_file($supplementalPath); - } - - // This file contains special digits for non-occidental numbering systems - if (!isset($this->numberingSystemsXml)) { - $numberingSystemsPath = realpath( - _PS_ROOT_DIR_ . '/' - . self::CLDR_SUPPLEMENTAL - . 'numberingSystems.xml' - ); - $this->numberingSystemsXml = simplexml_load_file($numberingSystemsPath); - } - } - - /** - * Build lookup files stack for a given locale code. - * - * @param $localeCode - * The given locale code (simplified IETF notation) - * - * @return array - * The lookup - * ['root', , $localeCode] - * - * @throws LocalizationException - * When locale code is invalid or unknown - * - * @see http://www.unicode.org/reports/tr35/tr35.html#Lookup - */ - protected function getLookup($localeCode) - { - $lookup = [$localeCode]; - - while ($localeCode = $this->getParentLocale($localeCode)) { - array_unshift($lookup, $localeCode); - } - - return $lookup; - } - - /** - * Get the parent locale for a given locale code. - * - * @param $localeCode - * CLDR filenames' style locale code (with underscores) - * eg.: en, fr, en_GB, fr_FR... - * - * @return string|null - * The parent locale code (CLDR filenames' style). Null if no parent. - * - * @throws LocalizationException - */ - protected function getParentLocale($localeCode) - { - // root is the... root of all CLDR locales' data. Then no parent. - if (self::CLDR_ROOT_LOCALE == $localeCode) { - return null; - } - - // The special case from supplemental data - foreach ($this->supplementalXml->parentLocales->parentLocale as $data) { - $locales = explode(' ', $data['locales']); - if (in_array($localeCode, $locales)) { - return $data['parent']; - } - } - - // The common case with truncation - $pos = strrpos($localeCode, '_'); - if (false !== $pos) { - $parent = substr($localeCode, 0, $pos); - if (false === $parent) { - throw new LocalizationException(sprintf('Invalid locale code: "%s"', $localeCode)); - } - - return $parent; - } - - // The "top level" case. When only language code is left in $localeCode: 'en', 'fr'... then parent is "root". - return self::CLDR_ROOT_LOCALE; - } - - /** - * Get CLDR official xml data for a given locale tag. - * - * The locale tag can be either an IETF tag (en-GB) or a simple language code (en) - * - * @param string $localeCode - * The locale code - * - * @return SimplexmlElement - * The locale data - * - * @throws LocalizationFileNotFoundException - * If this locale code has no corresponding xml file - */ - protected function getMainXmlData($localeCode) - { - return simplexml_load_file($this->mainPath($localeCode . '.xml')); - } - - /** - * Get the real path for CLDR main data folder - * If a filename is provided, it will be added at the end of the path. - * - * @param string $filename (Optional) The filename to be added to the path - * - * @return string The realpath of CLDR main data folder - * - * @throws LocalizationFileNotFoundException - */ - protected function mainPath($filename = '') - { - $path = realpath(_PS_ROOT_DIR_ . '/' . self::CLDR_MAIN . ($filename ? $filename : '')); - if (false === $path) { - throw new LocalizationFileNotFoundException("The file $filename does not exist"); - } - - return $path; - } - - /** - * Extracts locale data from CLDR xml data. - * XML data will be mapped in a LocaleData object. - * - * @param string $localeTag The wanted locale. Can be either a language code (e.g.: fr) of an IETF tag (e.g.: en-US) - * - * @return LocaleData - */ - protected function getLocaleData($localeTag) - { - $xmlData = $this->getMainXmlData($localeTag); - - $supplementalData = ['digits' => $this->getDigitsData()]; - - return $this->mapLocaleData($xmlData, $supplementalData); - } - - /** - * Maps locale data from SimplexmlElement to a LocaleData object. - * - * @param SimplexmlElement $xmlLocaleData - * XML locale data - * @param array $supplementalData - * Supplemental locale data - * - * @return LocaleData - * The mapped locale data - * - * @todo use $supplementalData for non-occidental digits - * - * @see http://cldr.unicode.org/development/development-process/design-proposals/resolution-of-cldr-files - */ - protected function mapLocaleData(SimpleXMLElement $xmlLocaleData, $supplementalData) - { - $localeData = new LocaleData(); - - // Geo - if (isset($xmlLocaleData->identity->language)) { - $localeData->setLocaleCode((string) $xmlLocaleData->identity->language['type']); - } - if (isset($xmlLocaleData->identity->territory)) { - $localeData->setLocaleCode( - $localeData->getLocaleCode() . '-' . $xmlLocaleData->identity->territory['type'] - ); - } - - // Numbers - $numbersData = $xmlLocaleData->numbers; - // Default numbering system. - if (isset($numbersData->defaultNumberingSystem)) { - $localeData->setDefaultNumberingSystem((string) $numbersData->defaultNumberingSystem); - } - // Minimum grouping digits value defines when we should start grouping digits. - // 1 => we start grouping at 4 figures numbers (1,000+) (most frequent) - // 2 => we start grouping at 5 figures numbers (10,000+) - if (isset($numbersData->minimumGroupingDigits)) { - $localeData->setMinimumGroupingDigits((int) $numbersData->minimumGroupingDigits); - } - // Complete numbering systems list with the "others" available for this locale. - // Possible other systems are "native", "traditional" and "finance". - // @see http://www.unicode.org/reports/tr35/tr35-numbers.html#otherNumberingSystems - if (isset($numbersData->otherNumberingSystems)) { - $numberingSystems = []; - foreach ($numbersData->otherNumberingSystems->children() as $system) { - /* @var $system SimplexmlElement */ - $numberingSystems[$system->getName()] = (string) $system; - } - $localeData->setNumberingSystems($numberingSystems); - } - // Symbols (by numbering system) - if (isset($numbersData->symbols)) { - $numberSymbols = $localeData->getNumberSymbols(); - /** @var SimpleXMLElement $symbolsNode */ - foreach ($numbersData->symbols as $symbolsNode) { - if (!isset($symbolsNode['numberSystem'])) { - continue; - } - $thisNumberingSystem = (string) $symbolsNode['numberSystem']; - - // Copying data from another node when relevant (alias) - if (isset($symbolsNode->alias)) { - // @see /localization/CLDR/core/common/main/root.xml - $results = $symbolsNode->xpath($symbolsNode->alias['path']); - if (empty($results)) { - continue; - } - $symbolsNode = $results[0]; - } - - $symbolsList = new NumberSymbolsData(); - if (isset($symbolsNode->decimal)) { - $symbolsList->setDecimal((string) $symbolsNode->decimal); - } - if (isset($symbolsNode->group)) { - $symbolsList->setGroup((string) $symbolsNode->group); - } - if (isset($symbolsNode->list)) { - $symbolsList->setList((string) $symbolsNode->list); - } - if (isset($symbolsNode->percentSign)) { - $symbolsList->setPercentSign((string) $symbolsNode->percentSign); - } - if (isset($symbolsNode->minusSign)) { - $symbolsList->setMinusSign((string) $symbolsNode->minusSign); - } - if (isset($symbolsNode->plusSign)) { - $symbolsList->setPlusSign((string) $symbolsNode->plusSign); - } - if (isset($symbolsNode->exponential)) { - $symbolsList->setExponential((string) $symbolsNode->exponential); - } - if (isset($symbolsNode->superscriptingExponent)) { - $symbolsList->setSuperscriptingExponent((string) $symbolsNode->superscriptingExponent); - } - if (isset($symbolsNode->perMille)) { - $symbolsList->setPerMille((string) $symbolsNode->perMille); - } - if (isset($symbolsNode->infinity)) { - $symbolsList->setInfinity((string) $symbolsNode->infinity); - } - if (isset($symbolsNode->nan)) { - $symbolsList->setNan((string) $symbolsNode->nan); - } - if (isset($symbolsNode->timeSeparator)) { - $symbolsList->setTimeSeparator((string) $symbolsNode->timeSeparator); - } - if (isset($symbolsNode->currencyDecimal)) { - $symbolsList->setCurrencyDecimal((string) $symbolsNode->currencyDecimal); - } - if (isset($symbolsNode->currencyGroup)) { - $symbolsList->setCurrencyGroup((string) $symbolsNode->currencyGroup); - } - - $numberSymbols[$thisNumberingSystem] = $symbolsList; - } - $localeData->setNumberSymbols($numberSymbols); - } - // Decimal patterns (by numbering system) - if (isset($numbersData->decimalFormats)) { - $decimalPatterns = $localeData->getDecimalPatterns(); - /** @var SimplexmlElement $format */ - foreach ($numbersData->decimalFormats as $format) { - /** @var SimplexmlElement $format */ - $numberSystem = (string) $format['numberSystem']; - $patternResult = $format->xpath('decimalFormatLength[not(@type)]/decimalFormat/pattern'); - if (isset($patternResult[0])) { - $decimalPatterns[$numberSystem] = (string) $patternResult[0]; - } - } - // Aliases nodes are in root.xml only. They avoid duplicated data. - // We browse aliases after all regular patterns have been defined, and duplicate data for target number - // systems. - foreach ($numbersData->decimalFormats as $format) { - /** @var SimplexmlElement $format */ - $numberSystem = (string) $format['numberSystem']; - // If alias is set, we just copy data from another numbering system: - $alias = $format->alias; - if ($alias - && preg_match( - "#^\.\.\/decimalFormats\[@numberSystem='([^)]+)'\]$#", - (string) $alias['path'], - $matches - ) - ) { - $aliasNumSys = $matches[1]; - $decimalPatterns[$numberSystem] = $decimalPatterns[$aliasNumSys]; - - continue; - } - } - $localeData->setDecimalPatterns($decimalPatterns); - } - // Percent patterns (by numbering system) - if (isset($numbersData->percentFormats)) { - $percentPatterns = $localeData->getPercentPatterns(); - foreach ($numbersData->percentFormats as $format) { - $numberSystem = (string) $format['numberSystem']; - $patternResult = $format->xpath('percentFormatLength/percentFormat/pattern'); - if (isset($patternResult[0])) { - $percentPatterns[$numberSystem] = (string) $patternResult[0]; - } - } - // Aliases nodes are in root.xml only. They avoid duplicated data. - // We browse aliases after all regular patterns have been defined, and duplicate data for target number - // systems. - foreach ($numbersData->percentFormats as $format) { - /** @var SimplexmlElement $format */ - $numberSystem = (string) $format['numberSystem']; - // If alias is set, we just copy data from another numbering system: - $alias = $format->alias; - if ($alias - && preg_match( - "#^\.\.\/percentFormats\[@numberSystem='([^)]+)'\]$#", - (string) $alias['path'], - $matches - ) - ) { - $aliasNumSys = $matches[1]; - $percentPatterns[$numberSystem] = $percentPatterns[$aliasNumSys]; - - continue; - } - } - $localeData->setPercentPatterns($percentPatterns); - } - // Currency patterns (by numbering system) - if (isset($numbersData->currencyFormats)) { - $currencyPatterns = $localeData->getCurrencyPatterns(); - foreach ($numbersData->currencyFormats as $format) { - /** @var SimplexmlElement $format */ - $numberSystem = (string) $format['numberSystem']; - $patternResult = $format->xpath( - 'currencyFormatLength[not(@*)]/currencyFormat[@type="standard"]/pattern' - ); - if (isset($patternResult[0])) { - $currencyPatterns[$numberSystem] = (string) $patternResult[0]; - } - } - // Aliases nodes are in root.xml only. They avoid duplicated data. - // We browse aliases after all regular patterns have been defined, and duplicate data for target number - // systems. - foreach ($numbersData->currencyFormats as $format) { - /** @var SimplexmlElement $format */ - $numberSystem = (string) $format['numberSystem']; - // If alias is set, we just copy data from another numbering system: - $alias = $format->alias; - if ($alias - && preg_match( - "#^\.\.\/currencyFormats\[@numberSystem='([^)]+)'\]$#", - (string) $alias['path'], - $matches - ) - ) { - $aliasNumSys = $matches[1]; - $currencyPatterns[$numberSystem] = $currencyPatterns[$aliasNumSys]; - - continue; - } - } - $localeData->setCurrencyPatterns($currencyPatterns); - } - - // Currencies - $currenciesData = $numbersData->currencies; - $currencyActiveDateThreshold = time() - self::CURRENCY_ACTIVE_DELAY * 86400; - if (isset($currenciesData->currency)) { - $currencies = $localeData->getCurrencies(); - foreach ($currenciesData->currency as $currencyNode) { - $currencyCode = (string) $currencyNode['type']; - if ($currencyCode == self::CURRENCY_CODE_TEST) { - // dont store test currency - continue; - } - - $currencyData = new CurrencyData(); - $currencyData->setIsoCode($currencyCode); - - // check if currency is still active in one territory - $currencyDates = $this->supplementalXml->supplementalData->xpath('//region/currency[@iso4217="' . $currencyCode . '"]'); - if (!empty($currencyDates) && $this->isCurrencyActiveSomewhere($currencyDates, $currencyActiveDateThreshold)) { - $currencyData->setActive(true); - } else { - // no territory with dates means currency was never used - $currencyData->setActive(false); - } - - // Symbols - $symbols = $currencyData->getSymbols(); - foreach ($currencyNode->symbol as $symbolNode) { - $type = (string) $symbolNode['alt']; - if (empty($type)) { - $type = 'default'; - } - $symbols[$type] = (string) $symbolNode; - } - $currencyData->setSymbols($symbols); - - // Names - $displayNames = $currencyData->getDisplayNames(); - foreach ($currencyNode->displayName as $nameNode) { - $countContext = 'default'; - if (!empty($nameNode['count'])) { - $countContext = (string) $nameNode['count']; - } - $displayNames[$countContext] = (string) $nameNode; - } - $currencyData->setDisplayNames($displayNames); - - // Supplemental (fraction digits and numeric iso code) - $codesMapping = $this->supplementalXml->supplementalData->xpath( - '//codeMappings/currencyCodes[@type="' . $currencyCode . '"]' - ); - - if (!empty($codesMapping)) { - /** @var SimplexmlElement $codesMapping */ - $codesMapping = $codesMapping[0]; - $numericIsoCode = (string) $codesMapping->attributes()->numeric; - if (strlen($numericIsoCode) < 3) { - $numericIsoCode = str_pad($numericIsoCode, 3, '0', STR_PAD_LEFT); - } - $currencyData->setNumericIsoCode($numericIsoCode); - } - - $fractionsData = $this->supplementalXml->supplementalData->xpath( - '//currencyData/fractions/info[@iso4217="' . $currencyCode . '"]' - ); - - if (empty($fractionsData)) { - $fractionsData = $this->supplementalXml->supplementalData->xpath( - '//currencyData/fractions/info[@iso4217="DEFAULT"]' - ); - } - - if (!empty($fractionsData)) { - /** @var SimplexmlElement $fractionsData */ - $fractionsData = $fractionsData[0]; - $currencyData->setDecimalDigits((int) (string) $fractionsData->attributes()->digits); - } - - $currencies[$currencyCode] = $currencyData; - } - $localeData->setCurrencies($currencies); - } - - return $localeData; - } - - /** - * Extract all existing digits sets from supplemental xml data. - * - * @return array - * eg.: - * [ - * 'latn' => '0123456789', - * 'arab' => '٠١٢٣٤٥٦٧٨٩', - * 'fullwide' => '0123456789', - * ] - */ - protected function getDigitsData() - { - $digitsSets = []; - $results = $this->numberingSystemsXml->numberingSystems->xpath('//numberingSystem[@type="numeric"]'); - foreach ($results as $numberingSystem) { - $systemId = (string) $numberingSystem['id']; - $digits = (string) $numberingSystem['digits']; - $digitsSets[$systemId] = $digits; - } - - return $digitsSets; - } - - /** - * @param string $currencyCode currency iso code - * @param SimpleXMLElement $supplementalData xml bloc from CLDR - * @param int $currencyActiveDateThreshold timestamp after which currency should be used - * - * @return bool - */ - protected function shouldCurrencyBeReturned($currencyCode, SimplexmlElement $supplementalData, $currencyActiveDateThreshold) - { - // dont store test currency - if ($currencyCode == self::CURRENCY_CODE_TEST) { - return false; - } - // check if currency is still active in one territory - $currencyDates = $supplementalData->xpath('//region/currency[@iso4217="' . $currencyCode . '"]'); - if (empty($currencyDates)) { - // no territory with dates means currency was never used - return false; - } - - return $this->isCurrencyActiveSomewhere($currencyDates, $currencyActiveDateThreshold); - } - - /** - * check if currency is still in use in some territory - * - * @param array $currencyDates - * @param int $currencyActiveDateThreshold timestamp after which currency should be used - * - * @return bool - */ - protected function isCurrencyActiveSomewhere(array $currencyDates, $currencyActiveDateThreshold) - { - foreach ($currencyDates as $currencyDate) { - if (empty($currencyDate->attributes()->to)) { - // no date "to": currency is active in some territory - return true; - } - - // date "to" given: check if currency was active in near past to propose it - $dateTo = \DateTime::createFromFormat('Y-m-d', $currencyDate->attributes()->to); - if (false !== $dateTo && $dateTo->getTimestamp() > $currencyActiveDateThreshold) { - return true; - } - } - - return false; - } -} diff --git a/src/Core/Localization/CLDR/ReaderInterface.php b/src/Core/Localization/CLDR/ReaderInterface.php deleted file mode 100644 index 69216a81..00000000 --- a/src/Core/Localization/CLDR/ReaderInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\CLDR; - -interface ReaderInterface -{ - /** - * Read locale data by locale code. - * - * @param $localeCode - * The locale code (simplified IETF tag syntax) - * Combination of ISO 639-1 (2-letters language code) and ISO 3166-2 (2-letters region code) - * eg: fr-FR, en-US - * - * @return LocaleData - * A LocaleData object - */ - public function readLocaleData($localeCode); -} diff --git a/src/Core/Localization/Currency.php b/src/Core/Localization/Currency.php deleted file mode 100644 index e1f2bc8f..00000000 --- a/src/Core/Localization/Currency.php +++ /dev/null @@ -1,222 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization; - -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; - -/** - * The Currency class is used to feed callers with currency-related data. - * - * For instance, the LocaleRepository uses currency data to build Price specifications - */ -class Currency implements CurrencyInterface -{ - /** - * Is this currency active ? - * - * @var bool - */ - protected $isActive; - - /** - * Conversion rate of this currency against the default shop's currency. - * - * Price in currency A * currency A's conversion rate = price in default currency - * - * Example: - * Given the Euro as default shop's currency, - * If 1 dollar = 1.31 euros, - * Then conversion rate for Dollar will be 1.31 - * - * @var float - */ - protected $conversionRate; - - /** - * Currency's alphabetic ISO code (ISO 4217). - * - * @see https://www.iso.org/iso-4217-currency-codes.html - * - * @var string - */ - protected $isoCode; - - /** - * Currency's numeric ISO code (ISO 4217). - * - * @see https://www.iso.org/iso-4217-currency-codes.html - * - * @var string - */ - protected $numericIsoCode; - - /** - * Currency's symbols, by locale code. - * - * eg.: $symbolsUSD = [ - * 'en-US' => '$', - * 'es-CO' => 'US$', // In Colombia, colombian peso's symbol is "$". They have to differentiate foreign dollars. - * ] - * - * @var string[] - */ - protected $symbols; - - /** - * Number of decimal digits to use with this currency. - * - * @var int - */ - protected $precision; - - /** - * the currency's name, by locale code. - * - * @var string[] - */ - protected $names; - - /** - * Currency's patterns, by locale code. - * - * eg.: $patternsUSD = [ - * 'fr-FR' => '#,##0.00 ¤', - * 'en-EN' => '¤#,##0.00', - * ] - * - * @var string[] - */ - protected $patterns; - - /** - * @param bool $isActive Is this currency active ? - * @param float $conversionRate Conversion rate of this currency against the default shop's currency - * @param string $isoCode Currency's alphabetic ISO code (ISO 4217) - * @param int $numericIsoCode Currency's numeric ISO code (ISO 4217) - * @param string[] $symbols Currency's symbols, by locale code - * @param int $precision Number of decimal digits to use with this currency - * @param string[] $names the currency's name, by locale code - * @param string[] $patterns the currency's pattern, by locale code - */ - public function __construct( - $isActive, - $conversionRate, - $isoCode, - $numericIsoCode, - $symbols, - $precision, - $names, - $patterns = [] - ) { - $this->isActive = $isActive; - $this->conversionRate = $conversionRate; - $this->isoCode = $isoCode; - $this->numericIsoCode = $numericIsoCode; - $this->symbols = $symbols; - $this->precision = $precision; - $this->names = $names; - $this->patterns = $patterns; - } - - /** - * {@inheritdoc} - */ - public function isActive() - { - return $this->isActive; - } - - /** - * {@inheritdoc} - */ - public function getConversionRate() - { - return $this->conversionRate; - } - - /** - * {@inheritdoc} - */ - public function getIsoCode() - { - return $this->isoCode; - } - - /** - * {@inheritdoc} - */ - public function getNumericIsoCode() - { - return $this->numericIsoCode; - } - - /** - * {@inheritdoc} - * - * @throws LocalizationException - */ - public function getSymbol($localeCode) - { - if (!isset($this->symbols[$localeCode])) { - throw new LocalizationException('Unknown locale code: ' . $localeCode); - } - - return $this->symbols[$localeCode]; - } - - /** - * {@inheritdoc} - */ - public function getDecimalPrecision() - { - return $this->precision; - } - - /** - * {@inheritdoc} - * - * @throws LocalizationException - */ - public function getName($localeCode) - { - if (!isset($this->names[$localeCode])) { - throw new LocalizationException('Unknown locale code: ' . $localeCode); - } - - return $this->names[$localeCode]; - } - - /** - * @param string $localeCode - * - * @return string - */ - public function getPattern($localeCode) - { - return $this->patterns[$localeCode] ?? ''; - } -} diff --git a/src/Core/Localization/Currency/CurrencyCollection.php b/src/Core/Localization/Currency/CurrencyCollection.php deleted file mode 100644 index 6083565f..00000000 --- a/src/Core/Localization/Currency/CurrencyCollection.php +++ /dev/null @@ -1,159 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Currency; - -use ArrayIterator; -use Countable; -use IteratorAggregate; -use PrestaShop\PrestaShop\Core\Localization\Currency; - -class CurrencyCollection implements IteratorAggregate, Countable -{ - protected $currencies = []; - - /** - * Gets the current CurrencyCollection as an Iterator that includes all currencies. - * - * It implements \IteratorAggregate. - * - * @return Currency[] (needed for auto-completion) - * An ArrayIterator object for iterating over currencies - */ - public function getIterator() - { - /** @var Currency[] $iterator (needed for auto-completion) */ - $iterator = new ArrayIterator($this->currencies); - - return $iterator; - } - - /** - * Gets the number of Currencies in this collection. - * - * @return int - * The number of currencies - */ - public function count() - { - return count($this->currencies); - } - - /** - * Adds a currency at the end of the collection. - * - * @param currency $currency - * The currency to add - * - * @return CurrencyCollection - * Fluent interface - */ - public function add(Currency $currency) - { - $this->currencies[$currency->getIsoCode()] = $currency; - - return $this; - } - - /** - * Returns all currencies in this collection. - * - * @return Currency[] - * An array of currencies - */ - public function all() - { - return $this->currencies; - } - - /** - * Gets a currency by ISO code. - * - * @param string $isoCode - * The currency code (alphabetic ISO 4217 code) - * - * @return Currency|null - * A Currency instance or null when not found - */ - public function get($isoCode) - { - return isset($this->currencies[$isoCode]) - ? $this->currencies[$isoCode] - : null; - } - - /** - * Removes a currency or an array of currencies by iso code from the collection. - * - * @param string|string[] $isoCode - * The currency ISO code or an array of currency ISO codes - * - * @return CurrencyCollection - * Fluent interface - */ - public function remove($isoCode) - { - foreach ((array) $isoCode as $c) { - unset($this->currencies[$c]); - } - - return $this; - } - - /** - * Adds a currency collection at the end of the current set by appending all - * currencies of the added collection. - * - * @param CurrencyCollection $collection The CurrencyCollection to append at the end of the current one - * - * @return CurrencyCollection Fluent interface - */ - public function addCollection(CurrencyCollection $collection) - { - // we need to remove all currencies with the same codes first because just replacing them - // would not place the new currency at the end of the merged array - foreach ($collection->all() as $isoCode => $currency) { - unset($this->currencies[$isoCode]); - $this->currencies[$isoCode] = $currency; - } - - return $this; - } - - /** - * Clear the collection, removing all contained currencies. - * - * @return CurrencyCollection - * Fluent interface - */ - public function clear() - { - $this->currencies = []; - - return $this; - } -} diff --git a/src/Core/Localization/Currency/CurrencyData.php b/src/Core/Localization/Currency/CurrencyData.php deleted file mode 100644 index eb7b38c9..00000000 --- a/src/Core/Localization/Currency/CurrencyData.php +++ /dev/null @@ -1,283 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Currency; - -/** - * Localization Currency data object. - * - * This class is only used internally, it is mutable and overridable until fully built. It can then be used as - * an intermediary data bag to build a real Localization/Currency (immutable) object. - */ -class CurrencyData -{ - /** - * Is this currency active ? - * - * @var bool - */ - protected $isActive; - - /** - * Conversion rate of this currency against the default shop's currency. - * - * Price in currency A * currency A's conversion rate = price in default currency - * - * Example: - * Given the Euro as default shop's currency, - * If 1 dollar = 1.31 euros, - * Then conversion rate for Dollar will be 1.31 - * - * @var float - */ - protected $conversionRate; - - /** - * Currency's alphabetic ISO code (ISO 4217). - * - * @see https://www.iso.org/iso-4217-currency-codes.html - * - * @var string - */ - protected $isoCode; - - /** - * Currency's numeric ISO code (ISO 4217). - * - * @see https://www.iso.org/iso-4217-currency-codes.html - * - * @var string - */ - protected $numericIsoCode; - - /** - * Currency's symbols, by locale code. - * - * eg.: $symbolsUSD = [ - * 'en-US' => '$', - * 'es-CO' => 'US$', // In Colombia, colombian peso's symbol is "$". They have to differentiate foreign dollars. - * ] - * - * @var string[] - */ - protected $symbols; - - /** - * Number of decimal digits to use with this currency. - * - * @var int - */ - protected $precision; - - /** - * the currency's name, by locale code. - * - * @var string[] - */ - protected $names; - - /** - * Currency's patterns, by locale code. - * - * eg.: $patternsUSD = [ - * 'fr-FR' => '#,##0.00 ¤', - * 'en-EN' => '¤#,##0.00', - * ] - * - * @var string[] - */ - protected $patterns; - - public function overrideWith(CurrencyData $currencyData) - { - if ($currencyData->isActive() !== null) { - $this->isActive = $currencyData->isActive(); - } - - if ($currencyData->getConversionRate() !== null) { - $this->conversionRate = $currencyData->getConversionRate(); - } - - if ($currencyData->getIsoCode() !== null) { - $this->isoCode = $currencyData->getIsoCode(); - } - - if ($currencyData->getNumericIsoCode() !== null) { - $this->numericIsoCode = $currencyData->getNumericIsoCode(); - } - - if ($currencyData->getSymbols() !== null) { - $this->symbols = array_merge($this->symbols ?? [], $currencyData->getSymbols()); - } - - if ($currencyData->getPrecision() !== null) { - $this->precision = $currencyData->getPrecision(); - } - - if ($currencyData->getNames() !== null) { - $this->names = array_merge($this->names ?? [], $currencyData->getNames()); - } - - if ($currencyData->getPatterns() !== null) { - $this->patterns = array_merge($this->patterns ?? [], $currencyData->getPatterns()); - } - - return $this; - } - - /** - * @return bool - */ - public function isActive() - { - return $this->isActive; - } - - /** - * @param bool $isActive - */ - public function setIsActive($isActive) - { - $this->isActive = $isActive; - } - - /** - * @return float - */ - public function getConversionRate() - { - return $this->conversionRate; - } - - /** - * @param float $conversionRate - */ - public function setConversionRate($conversionRate) - { - $this->conversionRate = $conversionRate; - } - - /** - * @return string - */ - public function getIsoCode() - { - return $this->isoCode; - } - - /** - * @param string $isoCode - */ - public function setIsoCode($isoCode) - { - $this->isoCode = $isoCode; - } - - /** - * @return string - */ - public function getNumericIsoCode() - { - return $this->numericIsoCode; - } - - /** - * @param string $numericIsoCode - */ - public function setNumericIsoCode($numericIsoCode) - { - $this->numericIsoCode = $numericIsoCode; - } - - /** - * @return string[] - */ - public function getSymbols() - { - return $this->symbols; - } - - /** - * @param string[] $symbols - */ - public function setSymbols($symbols) - { - $this->symbols = $symbols; - } - - /** - * @return int - */ - public function getPrecision() - { - return $this->precision; - } - - /** - * @param int $precision - */ - public function setPrecision($precision) - { - $this->precision = $precision; - } - - /** - * @return string[] - */ - public function getNames() - { - return $this->names; - } - - /** - * @param string[] $names - */ - public function setNames($names) - { - $this->names = $names; - } - - /** - * Currency patterns, indexed by locale code - * - * @return string[]|null - */ - public function getPatterns(): ?array - { - return $this->patterns; - } - - /** - * Currency patterns, indexed by locale code - * - * @param string[] $patterns - */ - public function setPatterns(array $patterns) - { - $this->patterns = $patterns; - } -} diff --git a/src/Core/Localization/Currency/CurrencyDataLayerInterface.php b/src/Core/Localization/Currency/CurrencyDataLayerInterface.php deleted file mode 100644 index 0061a9d2..00000000 --- a/src/Core/Localization/Currency/CurrencyDataLayerInterface.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Currency; - -/** - * Currency data layer classes interface. - * - * Describes the behavior of CurrencyDataLayer classes - */ -interface CurrencyDataLayerInterface -{ - /** - * Read Currency data by currency code. - * - * @param string $currencyCode - * The currency code (ISO 4217) - * - * @return CurrencyData - * The searched currency data - */ - public function read($currencyCode); - - /** - * Write a Currency object into the data source. - * - * @param string $currencyCode - * The currency code (ISO 4217) - * @param CurrencyData $currencyData - * The currency data to write - * - * @return CurrencyData - * The currency data to be written by the upper data layer - */ - public function write($currencyCode, $currencyData); - - /** - * Set the lower layer. - * When reading data, if nothing is found then it will try to read in the lower data layer - * When writing data, the data will also be written in the lower data layer. - * - * @param currencyDataLayerInterface $lowerLayer - * The lower data layer - * - * @return self - * Fluent interface - */ - public function setLowerLayer(CurrencyDataLayerInterface $lowerLayer); -} diff --git a/src/Core/Localization/Currency/CurrencyDataSource.php b/src/Core/Localization/Currency/CurrencyDataSource.php deleted file mode 100644 index ecb2734d..00000000 --- a/src/Core/Localization/Currency/CurrencyDataSource.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Currency; - -use PrestaShop\PrestaShop\Core\Localization\Currency\DataLayer\CurrencyInstalled as CurrencyInstalledDataLayer; - -/** - * Localization CurrencyData source - * Uses a stack of middleware data layers to read / write CurrencyData objects. - */ -class CurrencyDataSource implements DataSourceInterface -{ - /** - * The top layer of the middleware stack. - * - * @var CurrencyDataLayerInterface - */ - protected $topLayer; - - /** - * @var CurrencyInstalledDataLayer - */ - protected $installedDataLayer; - - /** - * CurrencyDataSource constructor needs CurrencyDataLayer objects. - * This top layer might be chained with lower layers and will be the entry point of this middleware stack. - * - * @param CurrencyDataLayerInterface $topLayer - * @param CurrencyInstalledDataLayer $installedDataLayer - */ - public function __construct(CurrencyDataLayerInterface $topLayer, CurrencyInstalledDataLayer $installedDataLayer) - { - $this->topLayer = $topLayer; - $this->installedDataLayer = $installedDataLayer; - } - - /** - * {@inheritdoc} - */ - public function getLocalizedCurrencyData(LocalizedCurrencyId $localizedCurrencyId) - { - return $this->topLayer->read($localizedCurrencyId); - } - - /** - * Is this currency available ? - * (an available currency is not deleted AND is active). - * - * @param $currencyCode - * - * @return bool - * True if currency is available - */ - public function isCurrencyAvailable($currencyCode) - { - return $this->installedDataLayer->isAvailable($currencyCode); - } - - /** - * {@inheritdoc} - */ - public function getAvailableCurrenciesData($localeCode) - { - return $this->formatCurrenciesData($this->installedDataLayer->getAvailableCurrencyCodes(), $localeCode); - } - - /** - * {@inheritdoc} - */ - public function getAllInstalledCurrenciesData($localeCode) - { - return $this->formatCurrenciesData($this->installedDataLayer->getAllInstalledCurrencyIsoCodes(), $localeCode); - } - - /** - * @param array $currencyCodes - * @param string $localeCode - * - * @return array - */ - private function formatCurrenciesData(array $currencyCodes, $localeCode) - { - $currenciesData = []; - foreach ($currencyCodes as $currencyCode) { - $currenciesData[] = $this->getLocalizedCurrencyData(new LocalizedCurrencyId($currencyCode, $localeCode)); - } - - return $currenciesData; - } -} diff --git a/src/Core/Localization/Currency/DataLayer/CurrencyCache.php b/src/Core/Localization/Currency/DataLayer/CurrencyCache.php deleted file mode 100644 index ceeb6fc7..00000000 --- a/src/Core/Localization/Currency/DataLayer/CurrencyCache.php +++ /dev/null @@ -1,129 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Currency\DataLayer; - -use PrestaShop\PrestaShop\Core\Data\Layer\AbstractDataLayer; -use PrestaShop\PrestaShop\Core\Data\Layer\DataLayerException; -use PrestaShop\PrestaShop\Core\Localization\Currency\CurrencyData as CurrencyData; -use PrestaShop\PrestaShop\Core\Localization\Currency\CurrencyDataLayerInterface as CurrencyDataLayerInterface; -use PrestaShop\PrestaShop\Core\Localization\Currency\LocalizedCurrencyId; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use Symfony\Component\Cache\Adapter\AdapterInterface; - -/** - * Localization/CurrencyCache data layer. - * - * This currency data layer reads and writes Localization/CurrencyData from a cache adapter - */ -class CurrencyCache extends AbstractDataLayer implements CurrencyDataLayerInterface -{ - /** - * Symfony Cache component adapter. - * - * Provides cached CurrencyData objects - * Implements PSR-6: Cache Interface (@see http://www.php-fig.org/psr/psr-6/) - * - * @var AdapterInterface - */ - private $cache; - - public function __construct(AdapterInterface $cache) - { - $this->cache = $cache; - } - - /** - * {@inheritdoc} - */ - public function setLowerLayer(CurrencyDataLayerInterface $lowerLayer) - { - $this->lowerDataLayer = $lowerLayer; - - return $this; - } - - /** - * Actually read a CurrencyData object into the current layer. - * - * Might be a file access, cache read, DB select... - * - * @param LocalizedCurrencyId $currencyDataId - * The CurrencyData object identifier (currency code + locale code) - * - * @return CurrencyData|null - * The wanted CurrencyData object (null if not found) - * - * @throws LocalizationException - * When $currencyDataId is invalid - * @throws \Psr\Cache\InvalidArgumentException - */ - protected function doRead($currencyDataId) - { - if (!$currencyDataId instanceof LocalizedCurrencyId) { - throw new LocalizationException('$currencyDataId must be a CurrencyDataIdentifier object'); - } - - $cacheItem = $this->cache->getItem((string) $currencyDataId); - - return $cacheItem->isHit() - ? $cacheItem->get() - : null; - } - - /** - * Actually write a CurrencyData object into the current layer. - * - * Might be a file edit, cache update, DB insert/update... - * - * @param LocalizedCurrencyId $currencyDataId - * The data object identifier - * @param CurrencyData $currencyData - * The data object to be written - * - * @throws DataLayerException - * When write fails - * @throws LocalizationException - * When $currencyDataId is invalid - * @throws \Psr\Cache\InvalidArgumentException - */ - protected function doWrite($currencyDataId, $currencyData) - { - if (!$currencyDataId instanceof LocalizedCurrencyId) { - throw new LocalizationException('$currencyDataId must be a CurrencyDataIdentifier object'); - } - - $cacheItem = $this->cache->getItem((string) $currencyDataId); - $cacheItem->set($currencyData); - - $saved = $this->cache->save($cacheItem); - - if (!$saved) { - throw new DataLayerException('Unable to persist data in cache data layer'); - } - } -} diff --git a/src/Core/Localization/Currency/DataLayer/CurrencyDatabase.php b/src/Core/Localization/Currency/DataLayer/CurrencyDatabase.php deleted file mode 100644 index 0ae86beb..00000000 --- a/src/Core/Localization/Currency/DataLayer/CurrencyDatabase.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Currency\DataLayer; - -use Language; -use PrestaShop\PrestaShop\Core\Currency\CurrencyDataProviderInterface; -use PrestaShop\PrestaShop\Core\Data\Layer\AbstractDataLayer; -use PrestaShop\PrestaShop\Core\Data\Layer\DataLayerException; -use PrestaShop\PrestaShop\Core\Localization\Currency\CurrencyData; -use PrestaShop\PrestaShop\Core\Localization\Currency\CurrencyDataLayerInterface; -use PrestaShop\PrestaShop\Core\Localization\Currency\LocalizedCurrencyId; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; - -/** - * Currency Database data layer. - * - * Provides and persists currency data from/into database - */ -class CurrencyDatabase extends AbstractDataLayer implements CurrencyDataLayerInterface -{ - /** - * @var CurrencyDataProviderInterface - */ - protected $dataProvider; - - /** - * This layer must be ready only, displaying a price should not change the database data - * - * @var bool - */ - protected $isWritable = false; - - /** - * @param CurrencyDataProviderInterface $dataProvider - */ - public function __construct( - CurrencyDataProviderInterface $dataProvider - ) { - $this->dataProvider = $dataProvider; - } - - /** - * Set the lower layer. - * When reading data, if nothing is found then it will try to read in the lower data layer - * When writing data, the data will also be written in the lower data layer. - * - * @param currencyDataLayerInterface $lowerLayer - * The lower data layer - * - * @return self - */ - public function setLowerLayer(CurrencyDataLayerInterface $lowerLayer) - { - $this->lowerDataLayer = $lowerLayer; - - return $this; - } - - /** - * Actually read a data object into the current layer. - * - * Data is read into database - * - * @param LocalizedCurrencyId $currencyDataId - * The CurrencyData object identifier (currency code + locale code) - * - * @return CurrencyData|null - * The wanted CurrencyData object (null if not found) - * - * @throws LocalizationException - * When $currencyDataId is invalid - */ - protected function doRead($currencyDataId) - { - if (!$currencyDataId instanceof LocalizedCurrencyId) { - throw new LocalizationException('First parameter must be an instance of ' . LocalizedCurrencyId::class); - } - - $localeCode = $currencyDataId->getLocaleCode(); - $currencyCode = $currencyDataId->getCurrencyCode(); - $currencyEntity = $this->dataProvider->getCurrencyByIsoCodeAndLocale($currencyCode, $localeCode); - - if (null === $currencyEntity) { - return null; - } - - $currencyData = new CurrencyData(); - $currencyData->setIsoCode($currencyEntity->iso_code); - $currencyData->setNumericIsoCode($currencyEntity->numeric_iso_code); - $currencyData->setPrecision($currencyEntity->precision); - $currencyData->setNames([$localeCode => $currencyEntity->name]); - $currencyData->setSymbols([$localeCode => $currencyEntity->symbol]); - - $idLang = Language::getIdByLocale($localeCode, true); - $currencyPattern = $currencyEntity->getPattern($idLang); - if (!empty($currencyPattern)) { - $currencyData->setPatterns([$localeCode => $currencyEntity->getPattern($idLang)]); - } - - return $currencyData; - } - - /** - * Actually write a data object into the current layer - * Here, this is a DB insert/update... - * - * @param LocalizedCurrencyId $currencyDataId - * The CurrencyData object identifier (currency code + locale code) - * @param CurrencyData $currencyData - * The data object to be written - * - * @throws DataLayerException - * If something goes wrong when trying to write into DB - * @throws LocalizationException - * When $currencyDataId is invalid - */ - protected function doWrite($currencyDataId, $currencyData) - { - // We should not save anything in this layer. The CLDR or its Repository nor any of its layers - // should modify the database. This could override customization added by the user with default - // CLDR values. Any changes on the database must be managed through the backoffice and the appropriate - // commands/handlers - } -} diff --git a/src/Core/Localization/Currency/DataLayer/CurrencyInstalled.php b/src/Core/Localization/Currency/DataLayer/CurrencyInstalled.php deleted file mode 100644 index 3def6b5b..00000000 --- a/src/Core/Localization/Currency/DataLayer/CurrencyInstalled.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Currency\DataLayer; - -use Currency; -use PrestaShop\PrestaShop\Core\Currency\CurrencyDataProviderInterface; - -/** - * Installed Currencies data layer. - * - * Provides currencies' installation info - */ -class CurrencyInstalled -{ - /** - * This adapter will provide data from DB / ORM about Currency (via legacy entity). - * - * @var CurrencyDataProviderInterface - */ - protected $dataProvider; - - public function __construct(CurrencyDataProviderInterface $dataProvider) - { - $this->dataProvider = $dataProvider; - } - - /** - * Check if a currency is currently available (not deleted + active). - * - * @param $currencyCode - * The said currency ISO code - * - * @return bool - * True if this currency is available - */ - public function isAvailable($currencyCode) - { - $currency = $this->dataProvider->getCurrencyByIsoCode($currencyCode); - - if ($currency instanceof Currency) { - return (bool) $currency->active; - } - - return false; - } - - /** - * Get all available (not deleted + active) currencies' ISO codes. - * - * @return string[] - */ - public function getAvailableCurrencyCodes() - { - $currencies = $this->dataProvider->findAll(); - $currencyIsoCodes = array_column($currencies, 'iso_code'); - - return $currencyIsoCodes; - } - - /** - * Get all the available currencies' ISO codes (present in database no matter if it's deleted or active). - * - * @return string[] - */ - public function getAllInstalledCurrencyIsoCodes() - { - $currencies = $this->dataProvider->findAllInstalled(); - $currencyIsoCodes = array_column($currencies, 'iso_code'); - - return $currencyIsoCodes; - } -} diff --git a/src/Core/Localization/Currency/DataLayer/CurrencyReference.php b/src/Core/Localization/Currency/DataLayer/CurrencyReference.php deleted file mode 100644 index 8640c03b..00000000 --- a/src/Core/Localization/Currency/DataLayer/CurrencyReference.php +++ /dev/null @@ -1,127 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Currency\DataLayer; - -use PrestaShop\PrestaShop\Core\Data\Layer\AbstractDataLayer; -use PrestaShop\PrestaShop\Core\Localization\CLDR\CurrencyInterface as CldrCurrency; -use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleRepository as CldrLocaleRepository; -use PrestaShop\PrestaShop\Core\Localization\Currency\CurrencyData as CurrencyData; -use PrestaShop\PrestaShop\Core\Localization\Currency\CurrencyDataLayerInterface; -use PrestaShop\PrestaShop\Core\Localization\Currency\LocalizedCurrencyId; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; - -/** - * Localization/CurrencyReference data layer. - * - * Provides reference data for currencies... - * Data comes from CLDR official data files, and is read only. - */ -class CurrencyReference extends AbstractDataLayer implements CurrencyDataLayerInterface -{ - /** - * CLDR locale repository. - * - * Provides LocaleData objects - * - * @var CldrLocaleRepository - */ - protected $cldrLocaleRepository; - - public function __construct(CldrLocaleRepository $cldrLocaleRepository) - { - $this->cldrLocaleRepository = $cldrLocaleRepository; - $this->isWritable = false; - } - - /** - * {@inheritdoc} - */ - public function setLowerLayer(CurrencyDataLayerInterface $lowerLayer) - { - $this->lowerDataLayer = $lowerLayer; - - return $this; - } - - /** - * Actually read a CurrencyData object into the current layer. - * - * Data is read from official CLDR files (via the CLDR LocaleRepository) - * - * @param LocalizedCurrencyId $currencyDataId - * The CurrencyData object identifier - * - * @return CurrencyData|null - * The wanted CurrencyData object (null if not found) - * - * @throws LocalizationException - * In case of invalid $currencyDataId - * Also in case of invalid type asked for symbol (but use a constant, so it is very unlikely...) - */ - protected function doRead($currencyDataId) - { - if (!$currencyDataId instanceof LocalizedCurrencyId) { - throw new LocalizationException('$currencyDataId must be a CurrencyDataIdentifier object'); - } - - $localeCode = $currencyDataId->getLocaleCode(); - $cldrLocale = $this->cldrLocaleRepository->getLocale($localeCode); - - if (empty($cldrLocale)) { - return null; - } - - $cldrCurrency = $cldrLocale->getCurrency($currencyDataId->getCurrencyCode()); - - if (empty($cldrCurrency)) { - return null; - } - - $currencyData = new CurrencyData(); - $currencyData->setIsoCode($cldrCurrency->getIsoCode()); - $currencyData->setNumericIsoCode($cldrCurrency->getNumericIsoCode()); - $currencyData->setSymbols([$localeCode => $cldrCurrency->getSymbol(CldrCurrency::SYMBOL_TYPE_NARROW)]); - $currencyData->setPrecision($cldrCurrency->getDecimalDigits()); - $currencyData->setNames([$localeCode => $cldrCurrency->getDisplayName()]); - - return $currencyData; - } - - /** - * CLDR files are read only. Nothing can be written there. - * - * @param LocalizedCurrencyId $currencyDataId - * The LocaleData object identifier - * @param CurrencyData $currencyData - * The CurrencyData object to be written - */ - protected function doWrite($currencyDataId, $currencyData) - { - // Nothing. - } -} diff --git a/src/Core/Localization/Currency/DataSourceInterface.php b/src/Core/Localization/Currency/DataSourceInterface.php deleted file mode 100644 index 2ec24db9..00000000 --- a/src/Core/Localization/Currency/DataSourceInterface.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Currency; - -/** - * Currency data repository interface. - * - * Describes the behavior of currency DataRepository classes - */ -interface DataSourceInterface -{ - /** - * Get complete currency data by currency code, in a given language. - * - * @param LocalizedCurrencyId $localizedCurrencyId - * The currency data identifier (currency code + locale code) - * - * @return CurrencyData - * The currency data - */ - public function getLocalizedCurrencyData(LocalizedCurrencyId $localizedCurrencyId); - - /** - * Is this currency available ? - * (an available currency is not deleted AND is active). - * - * @param $currencyCode - * - * @return bool - * True if currency is available - */ - public function isCurrencyAvailable($currencyCode); - - /** - * Get all the available (installed + active) currencies' data. - * - * @param string $localeCode - * Data will be translated in this language - * - * @return CurrencyData[] - * The available currencies' data - */ - public function getAvailableCurrenciesData($localeCode); - - /** - * Get all installed currencies' data in database (regardless of their active or soft deleted status). - * - * @param string $localeCode - * Data will be translated in this language - * - * @return CurrencyData[] - * The installed currencies' database data - */ - public function getAllInstalledCurrenciesData($localeCode); -} diff --git a/src/Core/Localization/Currency/LocalizedCurrencyId.php b/src/Core/Localization/Currency/LocalizedCurrencyId.php deleted file mode 100644 index c3c60698..00000000 --- a/src/Core/Localization/Currency/LocalizedCurrencyId.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Currency; - -/** - * Value-object representing an identifier for a currency, "translated" in a given locale (language + region). - */ -class LocalizedCurrencyId -{ - /** - * ISO 4217 code of the currency. - * - * @var string - */ - private $currencyCode; - - /** - * CurrencyData's data is translated in this locale. - * IETF tag (e.g.: fr-FR, en-US...). - * - * @var string - */ - private $localeCode; - - /** - * @param string $currencyCode - * ISO 4217 currency code - * @param $localeCode - * IETF tag (e.g.: fr-FR, en-US...) - */ - public function __construct($currencyCode, $localeCode) - { - $this->currencyCode = $currencyCode; - $this->localeCode = $localeCode; - } - - public function __toString() - { - return $this->currencyCode . '-' . $this->localeCode; - } - - /** - * @return string - */ - public function getCurrencyCode() - { - return $this->currencyCode; - } - - /** - * @return string - */ - public function getLocaleCode() - { - return $this->localeCode; - } -} diff --git a/src/Core/Localization/Currency/PatternTransformer.php b/src/Core/Localization/Currency/PatternTransformer.php deleted file mode 100644 index d666c771..00000000 --- a/src/Core/Localization/Currency/PatternTransformer.php +++ /dev/null @@ -1,147 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Currency; - -use PrestaShop\PrestaShop\Core\Exception\InvalidArgumentException; - -/** - * Transform a currency pattern by moving the symbol position, with or without - * a separation space (no-break space). - */ -class PatternTransformer -{ - const NO_BREAK_SPACE = "\u{00A0}"; - const RTL_CHARACTER = "\u{200F}"; - const REGULAR_SPACE = ' '; - const CURRENCY_SYMBOL = '¤'; - - const TYPE_LEFT_SYMBOL_WITH_SPACE = 'leftWithSpace'; - const TYPE_LEFT_SYMBOL_WITHOUT_SPACE = 'leftWithoutSpace'; - const TYPE_RIGHT_SYMBOL_WITH_SPACE = 'rightWithSpace'; - const TYPE_RIGHT_SYMBOL_WITHOUT_SPACE = 'rightWithoutSpace'; - - const ALLOWED_TRANSFORMATIONS = [ - self::TYPE_LEFT_SYMBOL_WITH_SPACE, - self::TYPE_LEFT_SYMBOL_WITHOUT_SPACE, - self::TYPE_RIGHT_SYMBOL_WITH_SPACE, - self::TYPE_RIGHT_SYMBOL_WITHOUT_SPACE, - ]; - - const CHARACTERS_TO_TRIM = - self::CURRENCY_SYMBOL . - self::NO_BREAK_SPACE . - self::REGULAR_SPACE . - self::RTL_CHARACTER - ; - - const TRANSFORM_DICTIONARY = [ - self::TYPE_LEFT_SYMBOL_WITH_SPACE => '$rtl$currencySymbol$nbsp$pattern', - self::TYPE_LEFT_SYMBOL_WITHOUT_SPACE => '$rtl$currencySymbol$pattern', - self::TYPE_RIGHT_SYMBOL_WITH_SPACE => '$rtl$pattern$nbsp$currencySymbol', - self::TYPE_RIGHT_SYMBOL_WITHOUT_SPACE => '$rtl$pattern$currencySymbol', - ]; - - /** - * @param string $currencyPattern - * @param string $transformationType - * - * @return string - * - * @throws InvalidArgumentException - */ - public function transform(string $currencyPattern, string $transformationType): string - { - if (!in_array($transformationType, self::ALLOWED_TRANSFORMATIONS)) { - throw new InvalidArgumentException(sprintf('Invalid transformation type "%s", allowed transformations are: %s', $transformationType, implode(',', self::ALLOWED_TRANSFORMATIONS))); - } - - $transformedPatterns = []; - $currencyPatterns = explode(';', $currencyPattern); - foreach ($currencyPatterns as $pattern) { - $transformedPatterns[] = $this->transformPattern($pattern, $transformationType); - } - - return implode(';', $transformedPatterns); - } - - /** - * @param string $currencyPattern - * - * @return string - */ - public function getTransformationType(string $currencyPattern) - { - $patterns = explode(';', $currencyPattern); - $pattern = str_replace(self::RTL_CHARACTER, '', $patterns[0]); - - $regexpList = [ - self::TYPE_LEFT_SYMBOL_WITH_SPACE => '/^¤[ ' . self::NO_BREAK_SPACE . ']+.+/', - self::TYPE_LEFT_SYMBOL_WITHOUT_SPACE => '/^¤[^ ' . self::NO_BREAK_SPACE . ']+/', - self::TYPE_RIGHT_SYMBOL_WITH_SPACE => '/.+[ ' . self::NO_BREAK_SPACE . ']+¤$/', - self::TYPE_RIGHT_SYMBOL_WITHOUT_SPACE => '/[^ ' . self::NO_BREAK_SPACE . ']+¤$/', - ]; - foreach ($regexpList as $type => $regexp) { - if (preg_match($regexp, $pattern)) { - return $type; - } - } - - return ''; - } - - /** - * @param string $basePattern - * @param string $transformationType - * - * @return string - */ - private function transformPattern(string $basePattern, string $transformationType) - { - $rtlCharacter = $this->getRtlCharacter($basePattern); - $trimmedPattern = trim($basePattern, self::CHARACTERS_TO_TRIM); - - return strtr( - self::TRANSFORM_DICTIONARY[$transformationType], - [ - '$rtl' => $rtlCharacter, - '$currencySymbol' => self::CURRENCY_SYMBOL, - '$nbsp' => self::NO_BREAK_SPACE, - '$pattern' => $trimmedPattern, - ] - ); - } - - /** - * @param string $currencyPattern - * - * @return string - */ - private function getRtlCharacter(string $currencyPattern): string - { - return (false !== strpos($currencyPattern, self::RTL_CHARACTER)) ? self::RTL_CHARACTER : ''; - } -} diff --git a/src/Core/Localization/Currency/Repository.php b/src/Core/Localization/Currency/Repository.php deleted file mode 100644 index 274e3d8b..00000000 --- a/src/Core/Localization/Currency/Repository.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Currency; - -use PrestaShop\PrestaShop\Core\Localization\Currency; -use PrestaShop\PrestaShop\Core\Localization\Currency\DataSourceInterface as CurrencyDataSourceInterface; -use PrestaShop\PrestaShop\Core\Localization\Currency\RepositoryInterface as CurrencyRepositoryInterface; - -/** - * Currency repository class. - * - * Used to get Localization/Currency instances (by currency code for example) - */ -class Repository implements CurrencyRepositoryInterface -{ - /** - * Available currencies, indexed by ISO code. - * Lazy loaded. - * - * @var Currency[] - */ - protected $currencies; - - /** - * @var CurrencyDataSourceInterface - */ - protected $dataSource; - - public function __construct(CurrencyDataSourceInterface $dataSource) - { - $this->dataSource = $dataSource; - } - - /** - * {@inheritdoc} - */ - public function getCurrency($currencyCode, $localeCode) - { - if (!isset($this->currencies[$currencyCode])) { - $data = $this->dataSource->getLocalizedCurrencyData( - new LocalizedCurrencyId($currencyCode, $localeCode) - ); - - $this->currencies[$currencyCode] = $this->createCurrencyFromData($data); - } - - return $this->currencies[$currencyCode]; - } - - /** - * {@inheritdoc} - */ - public function getAvailableCurrencies($localeCode) - { - return $this->createCurrenciesFromData($this->dataSource->getAvailableCurrenciesData($localeCode)); - } - - /** - * {@inheritdoc} - */ - public function getAllInstalledCurrencies($localeCode) - { - return $this->createCurrenciesFromData($this->dataSource->getAllInstalledCurrenciesData($localeCode)); - } - - /** - * @param array $currenciesData - * - * @return CurrencyCollection - */ - private function createCurrenciesFromData(array $currenciesData) - { - $currencies = new CurrencyCollection(); - /** @var CurrencyData $currencyDatum */ - foreach ($currenciesData as $currencyDatum) { - $currencies->add($this->createCurrencyFromData($currencyDatum)); - } - - return $currencies; - } - - /** - * @param CurrencyData $currencyData - * - * @return Currency - */ - private function createCurrencyFromData(CurrencyData $currencyData) - { - return new Currency( - $currencyData->isActive(), - $currencyData->getConversionRate(), - $currencyData->getIsoCode(), - $currencyData->getNumericIsoCode(), - $currencyData->getSymbols(), - $currencyData->getPrecision(), - $currencyData->getNames(), - $currencyData->getPatterns() - ); - } -} diff --git a/src/Core/Localization/Currency/RepositoryInterface.php b/src/Core/Localization/Currency/RepositoryInterface.php deleted file mode 100644 index 69b1ae00..00000000 --- a/src/Core/Localization/Currency/RepositoryInterface.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Currency; - -use PrestaShop\PrestaShop\Core\Localization\Currency; - -/** - * Currency repository interface. - * - * Describes the behavior of Currency Repository classes - */ -interface RepositoryInterface -{ - /** - * Get a Currency instance by ISO code. - * - * @param string $currencyCode - * Wanted currency's ISO code - * Must be an alphabetic ISO 4217 currency code - * @param string $localeCode - * Currency data will be translated in this language - * - * @return Currency - * The wanted Currency instance - */ - public function getCurrency($currencyCode, $localeCode); - - /** - * Get all the available currencies (installed + active). - * - * @param string $localeCode - * IETF tag. Data will be translated in this language - * - * @return CurrencyCollection - * The available currencies - */ - public function getAvailableCurrencies($localeCode); - - /** - * Get all the installed currencies in database (regardless of their active or soft deleted status). - * - * @param string $localeCode - * IETF tag. Data will be translated in this language - * - * @return CurrencyCollection - * The installed currencies in database - */ - public function getAllInstalledCurrencies($localeCode); -} diff --git a/src/Core/Localization/CurrencyInterface.php b/src/Core/Localization/CurrencyInterface.php deleted file mode 100644 index 73967c52..00000000 --- a/src/Core/Localization/CurrencyInterface.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization; - -/** - * Currency entities interface. - * - * Describes the behavior of currency classes - */ -interface CurrencyInterface -{ - /** - * Check if this currency is active. - * - * @return bool - * true if currency is active - */ - public function isActive(); - - /** - * Get the conversion rate (exchange rate) of this currency against the shop's default currency. - * - * Price in currency A * currency A's conversion rate = price in default currency - * - * Example: - * Given the Euro as default shop's currency, - * If 1 dollar = 1.31 euros, - * Then conversion rate for Dollar will be 1.31 - * - * @return float - * The conversion rate of this currency - */ - public function getConversionRate(); - - /** - * Get the alphabetic ISO code of this currency. - * - * @see https://www.iso.org/iso-4217-currency-codes.html - * - * @return string - */ - public function getIsoCode(); - - /** - * Get the numeric ISO code of this currency. - * - * @see https://www.iso.org/iso-4217-currency-codes.html - * - * @return int - */ - public function getNumericIsoCode(); - - /** - * Get the currency symbol for a given locale code. - * - * @param string $localeCode - * The locale code (simplified IETF tag syntax) - * Combination of ISO 639-1 (2-letters language code) and ISO 3166-2 (2-letters region code) - * eg: fr-FR, en-US - * - * @see https://en.wikipedia.org/wiki/IETF_language_tag - * @see https://www.w3.org/International/articles/language-tags - * - * @return string - * The currency symbol for this locale - */ - public function getSymbol($localeCode); - - /** - * Get the number of decimal digits to use with this currency. - * - * Example: Euro's decimal precision is 2 (1 234,56 EUR) - * Example: Colombian peso's decimal precision is 0 (1 235 COP) - * - * @return int - */ - public function getDecimalPrecision(); - - /** - * Get the currency's name for a given locale code. - * - * @param string $localeCode - * The locale code (simplified IETF tag syntax) - * Combination of ISO 639-1 (2-letters language code) and ISO 3166-2 (2-letters region code) - * eg: fr-FR, en-US - * - * @see https://en.wikipedia.org/wiki/IETF_language_tag - * @see https://www.w3.org/International/articles/language-tags - * - * @return string - * The currency's name for this locale - */ - public function getName($localeCode); -} diff --git a/src/Core/Localization/Exception/LocalizationException.php b/src/Core/Localization/Exception/LocalizationException.php deleted file mode 100644 index f946537d..00000000 --- a/src/Core/Localization/Exception/LocalizationException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Base class for core localization exceptions - */ -class LocalizationException extends CoreException -{ -} diff --git a/src/Core/Localization/Exception/LocalizationFileNotFoundException.php b/src/Core/Localization/Exception/LocalizationFileNotFoundException.php deleted file mode 100644 index 3163d30e..00000000 --- a/src/Core/Localization/Exception/LocalizationFileNotFoundException.php +++ /dev/null @@ -1,31 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Exception; - -class LocalizationFileNotFoundException extends LocalizationException -{ -} diff --git a/src/Core/Localization/Locale.php b/src/Core/Localization/Locale.php deleted file mode 100644 index 1cfc94eb..00000000 --- a/src/Core/Localization/Locale.php +++ /dev/null @@ -1,185 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization; - -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShop\PrestaShop\Core\Localization\Number\Formatter as NumberFormatter; -use PrestaShop\PrestaShop\Core\Localization\Specification\Number as NumberSpecification; -use PrestaShop\PrestaShop\Core\Localization\Specification\NumberCollection as PriceSpecificationMap; -use PrestaShop\PrestaShop\Core\Localization\Specification\Price as PriceSpecification; - -/** - * Locale entity. - * - * This is the main CLDR entry point. For example, Locale is used to format numbers, prices, percentages. - * To build a Locale instance, use the Locale repository. - */ -class Locale implements LocaleInterface -{ - /** - * Latin numbering system is the "occidental" numbering system. Number digits are 0123456789. - * This is the default numbering system in PrestaShop, even for arabian or asian languages, until we - * provide a way to configure this in admin. - */ - const NUMBERING_SYSTEM_LATIN = 'latn'; - - /** - * The locale code (simplified IETF tag syntax) - * Combination of ISO 639-1 (2-letters language code) and ISO 3166-2 (2-letters region code) - * eg: fr-FR, en-US. - * - * @var string - */ - protected $code; - - /** - * Number formatter. - * Used to format raw numbers in this locale context. - * - * @var NumberFormatter - */ - protected $numberFormatter; - - /** - * Number formatting specification. - * - * @var NumberSpecification - */ - protected $numberSpecification; - - /** - * Price formatting specifications collection (one spec per currency). - * - * @var PriceSpecificationMap - */ - protected $priceSpecifications; - - /** - * Locale constructor. - * - * @param string $localeCode - * The locale code (simplified IETF tag syntax) - * Combination of ISO 639-1 (2-letters language code) and ISO 3166-2 (2-letters region code) - * eg: fr-FR, en-US - * @param NumberSpecification $numberSpecification - * Number specification used when formatting a number - * @param PriceSpecificationMap $priceSpecifications - * Collection of Price specifications (one per installed currency) - * @param NumberFormatter $formatter - * This number formatter will use stored number / price specs - */ - public function __construct( - $localeCode, - NumberSpecification $numberSpecification, - PriceSpecificationMap $priceSpecifications, - NumberFormatter $formatter - ) { - $this->code = (string) $localeCode; - $this->numberSpecification = $numberSpecification; - $this->priceSpecifications = $priceSpecifications; - $this->numberFormatter = $formatter; - } - - /** - * Get this locale's code (simplified IETF tag syntax) - * Combination of ISO 639-1 (2-letters language code) and ISO 3166-2 (2-letters region code) - * eg: fr-FR, en-US. - * - * @return string - */ - public function getCode() - { - return $this->code; - } - - /** - * Format a number according to locale rules. - * - * @param int|float|string $number - * The number to be formatted - * - * @return string - * The formatted number - * - * @throws Exception\LocalizationException - */ - public function formatNumber($number) - { - return $this->numberFormatter->format( - $number, - $this->numberSpecification - ); - } - - /** - * Format a number as a price. - * - * @param int|float|string $number - * Number to be formatted as a price - * @param string $currencyCode - * Currency of the price - * - * @return string The formatted price - * - * @throws Exception\LocalizationException - */ - public function formatPrice($number, $currencyCode) - { - return $this->numberFormatter->format( - $number, - $this->getPriceSpecification($currencyCode) - ); - } - - /** - * Get price specification - * - * @param string $currencyCode Currency of the price - * - * @return PriceSpecification - */ - public function getPriceSpecification($currencyCode) - { - $currencyCode = (string) $currencyCode; - $priceSpec = $this->priceSpecifications->get($currencyCode); - if (null === $priceSpec) { - throw new LocalizationException('Price specification not found for currency: "' . $currencyCode . '"'); - } - - return $priceSpec; - } - - /** - * Get number specification - * - * @return NumberSpecification - */ - public function getNumberSpecification() - { - return $this->numberSpecification; - } -} diff --git a/src/Core/Localization/Locale/Repository.php b/src/Core/Localization/Locale/Repository.php deleted file mode 100644 index 74191fa7..00000000 --- a/src/Core/Localization/Locale/Repository.php +++ /dev/null @@ -1,246 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Locale; - -use PrestaShop\Decimal\Operation\Rounding; -use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleRepository as CldrLocaleRepository; -use PrestaShop\PrestaShop\Core\Localization\Currency\RepositoryInterface as CurrencyRepositoryInterface; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShop\PrestaShop\Core\Localization\Locale; -use PrestaShop\PrestaShop\Core\Localization\Number\Formatter as NumberFormatter; -use PrestaShop\PrestaShop\Core\Localization\Specification\Factory as SpecificationFactory; -use PrestaShop\PrestaShop\Core\Localization\Specification\Number as NumberSpecification; -use PrestaShop\PrestaShop\Core\Localization\Specification\NumberCollection as PriceSpecificationMap; -use PrestaShop\PrestaShop\Core\Localization\Specification\Price as PriceSpecification; - -/** - * Locale repository. - * - * Used to get locale instances. - * This repository manages all dependencies needed to create a complete Localization/Locale instance - */ -class Repository implements RepositoryInterface -{ - /** - * Max number of digits to use in the fraction part of a decimal number - * This is a default value. - */ - const MAX_FRACTION_DIGITS = 3; - - /** - * Repository used to retrieve low level CLDR locale objects. - * - * @var CldrLocaleRepository - */ - protected $cldrLocaleRepository; - - /** - * Repository used to retrieve Currency objects. - * - * @var CurrencyRepositoryInterface - */ - protected $currencyRepository; - - /** - * Rounding mode to use when formatting numbers - * Possible values are listed in PrestaShop\Decimal\Operation\Rounding::ROUND_* constants. - * - * @var string - */ - protected $roundingMode; - - /** - * Numbering system to use when formatting numbers. - * Default value: "latn". - * - * @see http://cldr.unicode.org/translation/numbering-systems - * - * @var string - */ - protected $numberingSystem; - - /** - * Currency display type - * Default is "symbol". But sometimes you may want to display the currency code instead. - * Possible values: PrestaShop\PrestaShop\Core\Localization\Specification\Price::CURRENCY_DISPLAY_*. - * - * @var string - */ - protected $currencyDisplayType; - - /** - * Already instantiated Locale objects. - * - * @var Locale[] - */ - protected $locales; - - /** - * Should we group digits in a number's integer part ? - * - * @var bool - */ - protected $numberGroupingUsed; - - /** - * Max number of digits to display in a number's decimal part. - * - * @var int - */ - protected $maxFractionDigits; - - /** - * @var SpecificationFactory - */ - protected $specificationFactory; - - public function __construct( - CldrLocaleRepository $cldrLocaleRepository, - CurrencyRepositoryInterface $currencyRepository, - $roundingMode = Rounding::ROUND_HALF_UP, - $numberingSystem = Locale::NUMBERING_SYSTEM_LATIN, - $currencyDisplayType = PriceSpecification::CURRENCY_DISPLAY_SYMBOL, - $groupingUsed = true, - $maxFractionDigits = self::MAX_FRACTION_DIGITS - ) { - $this->cldrLocaleRepository = $cldrLocaleRepository; - $this->currencyRepository = $currencyRepository; - $this->roundingMode = $roundingMode; - $this->numberingSystem = $numberingSystem; - $this->currencyDisplayType = $currencyDisplayType; - $this->numberGroupingUsed = $groupingUsed; - $this->maxFractionDigits = $maxFractionDigits; - $this->specificationFactory = new SpecificationFactory(); - } - - /** - * {@inheritdoc} - */ - public function getLocale($localeCode) - { - if (!isset($this->locales[$localeCode])) { - $this->locales[$localeCode] = new Locale( - $localeCode, - $this->getNumberSpecification($localeCode), - $this->getPriceSpecifications($localeCode), - new NumberFormatter($this->roundingMode, $this->numberingSystem) - ); - } - - return $this->locales[$localeCode]; - } - - /** - * Get the Number specification for a given locale. - * - * @param string $localeCode - * The locale code (simplified IETF tag syntax) - * Combination of ISO 639-1 (2-letters language code) and ISO 3166-2 (2-letters region code) - * eg: fr-FR, en-US - * - * @return NumberSpecification - * A Number specification - * - * @throws LocalizationException - */ - protected function getNumberSpecification($localeCode) - { - $cldrLocale = $this->cldrLocaleRepository->getLocale($localeCode); - - if (null === $cldrLocale) { - throw new LocalizationException('CLDR locale not found for locale code "' . $localeCode . '"'); - } - - return $this->specificationFactory->buildNumberSpecification( - $cldrLocale, - $this->maxFractionDigits, - $this->numberGroupingUsed - ); - } - - /** - * Get all the Price specifications for a given locale. - * Each installed currency has its own Price specification. - * - * @param string $localeCode - * The locale code (simplified IETF tag syntax) - * Combination of ISO 639-1 (2-letters language code) and ISO 3166-2 (2-letters region code) - * eg: fr-FR, en-US - * - * @return PriceSpecificationMap - * All installed currencies' Price specifications - * - * @throws LocalizationException - */ - protected function getPriceSpecifications($localeCode) - { - $cldrLocale = $this->cldrLocaleRepository->getLocale($localeCode); - if (null === $cldrLocale) { - throw new LocalizationException('CLDR locale not found for locale code "' . $localeCode . '"'); - } - - $currencies = $this->currencyRepository->getAllInstalledCurrencies($localeCode); - - $priceSpecifications = new PriceSpecificationMap(); - foreach ($currencies as $currency) { - // Build the spec - $thisPriceSpecification = (new SpecificationFactory())->buildPriceSpecification( - $localeCode, - $cldrLocale, - $currency, - $this->numberGroupingUsed, - $this->currencyDisplayType, - (int) $currency->getDecimalPrecision() - ); - - // Add the spec to the collection - $priceSpecifications->add( - $thisPriceSpecification->getCurrencyCode(), - $thisPriceSpecification - ); - } - - return $priceSpecifications; - } - - /** - * @return bool - */ - public function isNumberGroupingUsed() - { - return $this->numberGroupingUsed; - } - - /** - * @return string - */ - public function getCurrencyDisplayType() - { - return $this->currencyDisplayType; - } -} diff --git a/src/Core/Localization/Locale/RepositoryInterface.php b/src/Core/Localization/Locale/RepositoryInterface.php deleted file mode 100644 index 1c1f08ac..00000000 --- a/src/Core/Localization/Locale/RepositoryInterface.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Locale; - -use PrestaShop\PrestaShop\Core\Localization\Locale; - -interface RepositoryInterface -{ - /** - * Get a Locale instance by locale code. - * - * @param string $localeCode - * The locale code (simplified IETF tag syntax) - * Combination of ISO 639-1 (2-letters language code) and ISO 3166-2 (2-letters region code) - * eg: fr-FR, en-US - * - * @return Locale - * A Locale instance - */ - public function getLocale($localeCode); -} diff --git a/src/Core/Localization/LocaleInterface.php b/src/Core/Localization/LocaleInterface.php deleted file mode 100644 index 2530ad28..00000000 --- a/src/Core/Localization/LocaleInterface.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization; - -/** - * Locale entity interface. - * - * Describes the behavior of locale classes - */ -interface LocaleInterface -{ - /** - * Format a number according to locale rules. - * - * @param int|float|string $number The number to be formatted - * - * @return string The formatted number - */ - public function formatNumber($number); - - /** - * Format a number as a price. - * - * @param int|float|string $number Number to be formatted as a price - * @param string $currencyCode Currency of the price - * - * @return string The formatted price - */ - public function formatPrice($number, $currencyCode); -} diff --git a/src/Core/Localization/Number/Formatter.php b/src/Core/Localization/Number/Formatter.php deleted file mode 100644 index 9ef12aeb..00000000 --- a/src/Core/Localization/Number/Formatter.php +++ /dev/null @@ -1,403 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Number; - -use InvalidArgumentException as SPLInvalidArgumentException; -use PrestaShop\Decimal\Number as DecimalNumber; -use PrestaShop\Decimal\Operation\Rounding; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShop\PrestaShop\Core\Localization\Specification\NumberInterface as NumberSpecification; -use PrestaShop\PrestaShop\Core\Localization\Specification\Price as PriceSpecification; - -/** - * Formats a number (raw, price, percentage) according to passed specifications. - */ -class Formatter -{ - /** - * These placeholders are used in CLDR number formatting templates. - * They are meant to be replaced by the correct localized symbols in the number formatting process. - */ - const CURRENCY_SYMBOL_PLACEHOLDER = '¤'; - const DECIMAL_SEPARATOR_PLACEHOLDER = '.'; - const GROUP_SEPARATOR_PLACEHOLDER = ','; - const MINUS_SIGN_PLACEHOLDER = '-'; - const PERCENT_SYMBOL_PLACEHOLDER = '%'; - const PLUS_SIGN_PLACEHOLDER = '+'; - - /** - * @var string The wanted rounding mode when formatting numbers. - * Cf. PrestaShop\Decimal\Operation\Rounding::ROUND_* values - */ - protected $roundingMode; - - /** - * @var string Numbering system to use when formatting numbers - * - * @see http://cldr.unicode.org/translation/numbering-systems - */ - protected $numberingSystem; - - /** - * Number specification to be used when formatting a number. - * - * @var NumberSpecification - */ - protected $numberSpecification; - - /** - * Create a number formatter instance. - * - * @param int $roundingMode - * The wanted rounding mode when formatting numbers - * Cf. PrestaShop\Decimal\Operation\Rounding::ROUND_* values - * @param string $numberingSystem - * Numbering system to use when formatting numbers. @see http://cldr.unicode.org/translation/numbering-systems - */ - public function __construct($roundingMode, $numberingSystem) - { - $this->roundingMode = $roundingMode; - $this->numberingSystem = $numberingSystem; - } - - /** - * Formats the passed number according to specifications. - * - * @param int|float|string $number - * The number to format - * @param NumberSpecification $specification - * Number specification to be used (can be a number spec, a price spec, a percentage spec) - * - * @return string - * The formatted number - * You should use this this value for display, without modifying it - * - * @throws LocalizationException - */ - public function format($number, NumberSpecification $specification) - { - $this->numberSpecification = $specification; - - try { - $decimalNumber = $this->prepareNumber($number); - } catch (SPLInvalidArgumentException $e) { - throw new LocalizationException('Invalid $number parameter: ' . $e->getMessage(), 0, $e); - } - - /* - * We need to work on the absolute value first. - * Then the CLDR pattern will add the sign if relevant (at the end). - */ - $isNegative = $decimalNumber->isNegative(); - $decimalNumber = $decimalNumber->toPositive(); - - list($majorDigits, $minorDigits) = $this->extractMajorMinorDigits($decimalNumber); - $majorDigits = $this->splitMajorGroups($majorDigits); - $minorDigits = $this->adjustMinorDigitsZeroes($minorDigits); - - // Assemble the final number - $formattedNumber = $majorDigits; - if ($minorDigits) { - $formattedNumber .= self::DECIMAL_SEPARATOR_PLACEHOLDER . $minorDigits; - } - - // Get the good CLDR formatting pattern. Sign is important here ! - $pattern = $this->getCldrPattern($isNegative); - $formattedNumber = $this->addPlaceholders($formattedNumber, $pattern); - $formattedNumber = $this->localizeNumber($formattedNumber); - - $formattedNumber = $this->performSpecificReplacements($formattedNumber); - - return $formattedNumber; - } - - /** - * Prepares a basic number (either a string, an integer or a float) to be formatted. - * - * @param $number - * The number to be prepared - * - * @return DecimalNumber - * The prepared number - */ - protected function prepareNumber($number) - { - $decimalNumber = new DecimalNumber((string) $number); - $precision = $this->numberSpecification->getMaxFractionDigits(); - $roundedNumber = (new Rounding())->compute( - $decimalNumber, - $precision, - $this->roundingMode - ); - - return $roundedNumber; - } - - /** - * Get $number's major and minor digits. - * - * Major digits are the "integer" part (before decimal separator), minor digits are the fractional part - * Result will be an array of exactly 2 items: [$majorDigits, $minorDigits] - * - * Usage example: - * list($majorDigits, $minorDigits) = $this->getMajorMinorDigits($decimalNumber); - * - * @param DecimalNumber $number - * - * @return string[] - */ - protected function extractMajorMinorDigits(DecimalNumber $number) - { - // Get the number's major and minor digits. - $majorDigits = $number->getIntegerPart(); - $minorDigits = $number->getFractionalPart(); - $minorDigits = ('0' === $minorDigits) ? '' : $minorDigits; - - return [$majorDigits, $minorDigits]; - } - - /** - * Splits major digits into groups. - * - * e.g.: Given the major digits "1234567", and major group size - * configured to 3 digits, the result would be "1 234 567" - * - * @param $majorDigits - * The major digits to be grouped - * - * @return string - * The grouped major digits - */ - protected function splitMajorGroups($majorDigits) - { - if ($this->numberSpecification->isGroupingUsed()) { - // Reverse the major digits, since they are grouped from the right. - $majorDigits = array_reverse(str_split($majorDigits)); - // Group the major digits. - $groups = []; - $groups[] = array_splice($majorDigits, 0, $this->numberSpecification->getPrimaryGroupSize()); - while (!empty($majorDigits)) { - $groups[] = array_splice($majorDigits, 0, $this->numberSpecification->getSecondaryGroupSize()); - } - // Reverse back the digits and the groups - $groups = array_reverse($groups); - foreach ($groups as &$group) { - $group = implode('', array_reverse($group)); - } - // Reconstruct the major digits. - $majorDigits = implode(self::GROUP_SEPARATOR_PLACEHOLDER, $groups); - } - - return $majorDigits; - } - - /** - * Adds or remove trailing zeroes, depending on specified min and max fraction digits numbers. - * - * @param string $minorDigits - * Digits to be adjusted with (trimmed or padded) zeroes - * - * @return string - * The adjusted minor digits - */ - protected function adjustMinorDigitsZeroes($minorDigits) - { - if (strlen($minorDigits) < $this->numberSpecification->getMinFractionDigits()) { - // Re-add needed zeroes - $minorDigits = str_pad( - $minorDigits, - $this->numberSpecification->getMinFractionDigits(), - '0' - ); - } - - if (strlen($minorDigits) > $this->numberSpecification->getMaxFractionDigits()) { - // Strip any trailing zeroes. - $minorDigits = rtrim($minorDigits, '0'); - } - - return $minorDigits; - } - - /** - * Get the CLDR formatting pattern. - * - * @see http://cldr.unicode.org/translation/number-patterns - * - * @param bool $isNegative - * If true, the negative pattern will be returned instead of the positive one - * - * @return string - * The CLDR formatting pattern - */ - protected function getCldrPattern($isNegative) - { - if ((bool) $isNegative) { - return $this->numberSpecification->getNegativePattern(); - } - - return $this->numberSpecification->getPositivePattern(); - } - - /** - * Localize the passed number. - * - * If needed, occidental ("latn") digits are replaced with the relevant - * ones (for instance with arab digits). - * Symbol placeholders will also be replaced by the real symbols (configured - * in number specification) - * - * @param string $number - * The number to be processed - * - * @return string - * The number after digits and symbols replacement - */ - protected function localizeNumber($number) - { - // If locale uses non-latin digits - $number = $this->replaceDigits($number); - - // Placeholders become real localized symbols - $number = $this->replaceSymbols($number); - - return $number; - } - - /** - * Replace latin digits with relevant numbering system's digits. - * - * @param string $number - * The number to process - * - * @return string - * The number with replaced digits - */ - protected function replaceDigits($number) - { - // TODO use digits set from the locale (cf. /localization/CLDR/core/common/supplemental/numberingSystems.xml) - return $number; - } - - /** - * Replace placeholder number symbols with relevant numbering system's symbols. - * - * @param string $number - * The number to process - * - * @return string - * The number with replaced symbols - */ - protected function replaceSymbols($number) - { - $symbols = $this->numberSpecification->getSymbolsByNumberingSystem($this->numberingSystem); - $replacements = [ - self::DECIMAL_SEPARATOR_PLACEHOLDER => $symbols->getDecimal(), - self::GROUP_SEPARATOR_PLACEHOLDER => $symbols->getGroup(), - self::MINUS_SIGN_PLACEHOLDER => $symbols->getMinusSign(), - self::PERCENT_SYMBOL_PLACEHOLDER => $symbols->getPercentSign(), - self::PLUS_SIGN_PLACEHOLDER => $symbols->getPlusSign(), - ]; - - return strtr($number, $replacements); - } - - /** - * Add missing placeholders to the number using the passed CLDR pattern. - * - * Missing placeholders can be the percent sign, currency symbol, etc. - * - * e.g. with a currency CLDR pattern: - * - Passed number (partially formatted): 1,234.567 - * - Returned number: 1,234.567 ¤ - * ("¤" symbol is the currency symbol placeholder) - * - * @see http://cldr.unicode.org/translation/number-patterns - * - * @param $formattedNumber - * Number to process - * @param $pattern - * CLDR formatting pattern to use - * - * @return string - */ - protected function addPlaceholders($formattedNumber, $pattern) - { - /* - * Regex groups explanation: - * # : literal "#" character. Once. - * (,#+)* : any other "#" characters group, separated by ",". Zero to infinity times. - * 0 : literal "0" character. Once. - * (\.[0#]+)* : any combination of "0" and "#" characters groups, separated by '.'. Zero to infinity times. - */ - $formattedNumber = preg_replace('/#?(,#+)*0(\.[0#]+)*/', $formattedNumber, $pattern); - - return $formattedNumber; - } - - /** - * Perform some more specific replacements. - * - * Specific replacements are needed when number specification is extended. - * For instance, prices have an extended number specification in order to - * add currency symbol to the formatted number. - * - * @param string $formattedNumber - * - * @return mixed - */ - public function performSpecificReplacements($formattedNumber) - { - $formattedNumber = $this->tryCurrencyReplacement($formattedNumber); - - return $formattedNumber; - } - - /** - * Try to replace currency placeholder by actual currency. - * - * Placeholder will be replaced either by the symbol or the ISO code, depending on price specification - * - * @param $formattedNumber - * The number to format - * - * @return string - * The number after currency replacement - */ - protected function tryCurrencyReplacement($formattedNumber) - { - if ($this->numberSpecification instanceof PriceSpecification) { - $currency = PriceSpecification::CURRENCY_DISPLAY_CODE == $this->numberSpecification->getCurrencyDisplay() - ? $this->numberSpecification->getCurrencyCode() - : $this->numberSpecification->getCurrencySymbol(); - - $formattedNumber = str_replace(self::CURRENCY_SYMBOL_PLACEHOLDER, $currency, $formattedNumber); - } - - return $formattedNumber; - } -} diff --git a/src/Core/Localization/Pack/Factory/LocalizationPackFactory.php b/src/Core/Localization/Pack/Factory/LocalizationPackFactory.php deleted file mode 100644 index 024e16cc..00000000 --- a/src/Core/Localization/Pack/Factory/LocalizationPackFactory.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Pack\Factory; - -use PrestaShop\PrestaShop\Adapter\Entity\LocalizationPack; - -/** - * Class LocalizationPackFactory is responsible for creating localization pack instances. - */ -final class LocalizationPackFactory implements LocalizationPackFactoryInterface -{ - /** - * {@inheritdoc} - */ - public function createNew() - { - return new LocalizationPack(); - } -} diff --git a/src/Core/Localization/Pack/Factory/LocalizationPackFactoryInterface.php b/src/Core/Localization/Pack/Factory/LocalizationPackFactoryInterface.php deleted file mode 100644 index 016c8416..00000000 --- a/src/Core/Localization/Pack/Factory/LocalizationPackFactoryInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Pack\Factory; - -use PrestaShop\PrestaShop\Adapter\Entity\LocalizationPack; - -/** - * Interface LocalizationPackFactoryInterface defines contract for localization pack factory. - */ -interface LocalizationPackFactoryInterface -{ - /** - * Creates new localization pack. - * - * @return LocalizationPack - */ - public function createNew(); -} diff --git a/src/Core/Localization/Pack/Import/LocalizationPackImportConfig.php b/src/Core/Localization/Pack/Import/LocalizationPackImportConfig.php deleted file mode 100644 index 674e5c00..00000000 --- a/src/Core/Localization/Pack/Import/LocalizationPackImportConfig.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Pack\Import; - -/** - * Class LocalizationPackImportConfig is value object which is responsible - * for storing localization pack configuration for import. - */ -final class LocalizationPackImportConfig implements LocalizationPackImportConfigInterface -{ - /** - * @var string - */ - private $countryIso; - - /** - * @var array - */ - private $contentToImport; - - /** - * @var bool - */ - private $downloadPackData; - - /** - * @param string $countryIso Country ISO code - * @param array $contentToImport Content that should be impoerted (e.g states, taxes & etc) - * @param bool $downloadPackData Whether pack data should be downloaded from prestashop.com server - */ - public function __construct($countryIso, array $contentToImport, $downloadPackData) - { - $this->countryIso = (string) $countryIso; - $this->contentToImport = $contentToImport; - $this->downloadPackData = (bool) $downloadPackData; - } - - /** - * Get country ISO code. - * - * @return string - */ - public function getCountryIsoCode() - { - return $this->countryIso; - } - - /** - * Get content to import. - * - * @return array - */ - public function getContentToImport() - { - return $this->contentToImport; - } - - /** - * Whether pack data should be downloaded. - * - * @return bool - */ - public function shouldDownloadPackData() - { - return $this->downloadPackData; - } -} diff --git a/src/Core/Localization/Pack/Import/LocalizationPackImportConfigInterface.php b/src/Core/Localization/Pack/Import/LocalizationPackImportConfigInterface.php deleted file mode 100644 index c183e6e1..00000000 --- a/src/Core/Localization/Pack/Import/LocalizationPackImportConfigInterface.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Pack\Import; - -/** - * Interface LocalizationPackImportConfigInterface defines. - */ -interface LocalizationPackImportConfigInterface -{ - /** - * Available content to import. - */ - const CONTENT_STATES = 'states'; - const CONTENT_TAXES = 'taxes'; - const CONTENT_CURRENCIES = 'currencies'; - const CONTENT_LANGUAGES = 'languages'; - const CONTENT_UNITS = 'units'; - const CONTENT_GROUPS = 'groups'; - - /** - * Get country ISO code. - * - * @return string - */ - public function getCountryIsoCode(); - - /** - * Get content to import. - * - * @return array - */ - public function getContentToImport(); - - /** - * Whether pack data should be downloaded. - * - * @return bool - */ - public function shouldDownloadPackData(); -} diff --git a/src/Core/Localization/Pack/Import/LocalizationPackImporter.php b/src/Core/Localization/Pack/Import/LocalizationPackImporter.php deleted file mode 100644 index cb1c13d0..00000000 --- a/src/Core/Localization/Pack/Import/LocalizationPackImporter.php +++ /dev/null @@ -1,181 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Pack\Import; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Localization\Pack\Factory\LocalizationPackFactoryInterface; -use PrestaShop\PrestaShop\Core\Localization\Pack\Loader\LocalizationPackLoaderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class LocalizationPackImporter is responsible for importing localization pack. - */ -final class LocalizationPackImporter implements LocalizationPackImporterInterface -{ - /** - * @var LocalizationPackLoaderInterface - */ - private $remoteLocalizationPackLoader; - - /** - * @var LocalizationPackLoaderInterface - */ - private $localLocalizationPackLoader; - - /** - * @var LocalizationPackFactoryInterface - */ - private $localizationPackFactory; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param LocalizationPackLoaderInterface $remoteLocalizationPackLoader - * @param LocalizationPackLoaderInterface $localLocalizationPackLoader - * @param LocalizationPackFactoryInterface $localizationPackFactory - * @param TranslatorInterface $translator - * @param ConfigurationInterface $configuration - */ - public function __construct( - LocalizationPackLoaderInterface $remoteLocalizationPackLoader, - LocalizationPackLoaderInterface $localLocalizationPackLoader, - LocalizationPackFactoryInterface $localizationPackFactory, - TranslatorInterface $translator, - ConfigurationInterface $configuration - ) { - $this->remoteLocalizationPackLoader = $remoteLocalizationPackLoader; - $this->localLocalizationPackLoader = $localLocalizationPackLoader; - $this->localizationPackFactory = $localizationPackFactory; - $this->translator = $translator; - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function import(LocalizationPackImportConfig $config) - { - $errors = $this->checkConfig($config); - if (!empty($errors)) { - return $errors; - } - - $pack = null; - - if ($config->shouldDownloadPackData() || $this->configuration->get('_PS_HOST_MODE_')) { - $pack = $this->remoteLocalizationPackLoader->getLocalizationPack( - $config->getCountryIsoCode() - ); - } - - if (null === $pack) { - $pack = $this->localLocalizationPackLoader->getLocalizationPack( - $config->getCountryIsoCode() - ); - - if (null === $pack) { - $error = $this->trans('Cannot load the localization pack.', 'Admin.International.Notification'); - - return [$error]; - } - } - - $localizationPack = $this->localizationPackFactory->createNew(); - - $localizationPack->loadLocalisationPack( - $pack, - $config->getContentToImport(), - false, - $config->getCountryIsoCode() - ); - - return $localizationPack->getErrors(); - } - - /** - * Check if configuration is valid. - * - * @param LocalizationPackImportConfig $config - * - * @return array Errors if any - */ - private function checkConfig(LocalizationPackImportConfig $config) - { - if (empty($config->getCountryIsoCode())) { - $error = $this->trans('Invalid selection', 'Admin.Notifications.Error'); - - return [$error]; - } - - if (empty($config->getContentToImport())) { - $error = $this->trans('Please select at least one item to import.', 'Admin.International.Notification'); - - return [$error]; - } - - $contentItems = [ - LocalizationPackImportConfigInterface::CONTENT_STATES, - LocalizationPackImportConfigInterface::CONTENT_TAXES, - LocalizationPackImportConfigInterface::CONTENT_CURRENCIES, - LocalizationPackImportConfigInterface::CONTENT_LANGUAGES, - LocalizationPackImportConfigInterface::CONTENT_UNITS, - LocalizationPackImportConfigInterface::CONTENT_GROUPS, - ]; - - foreach ($config->getContentToImport() as $contentItem) { - if (!in_array($contentItem, $contentItems)) { - $error = $this->trans('Invalid selection', 'Admin.Notifications.Error'); - - return [$error]; - } - } - - return []; - } - - /** - * Translate message. - * - * @param string $message - * @param string $domain - * @param array $params - * - * @return string - */ - private function trans($message, $domain, array $params = []) - { - return $this->translator->trans($message, $params, $domain); - } -} diff --git a/src/Core/Localization/Pack/Import/LocalizationPackImporterInterface.php b/src/Core/Localization/Pack/Import/LocalizationPackImporterInterface.php deleted file mode 100644 index 34a4e029..00000000 --- a/src/Core/Localization/Pack/Import/LocalizationPackImporterInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Pack\Import; - -/** - * Interface LocalizationPackImporterInterface defines contract for localization importer. - */ -interface LocalizationPackImporterInterface -{ - /** - * Import localization pack. - * - * @param LocalizationPackImportConfig $config - * - * @return array Returns errors if any or empty array otherwise - */ - public function import(LocalizationPackImportConfig $config); -} diff --git a/src/Core/Localization/Pack/Loader/AbstractLocalizationPackLoader.php b/src/Core/Localization/Pack/Loader/AbstractLocalizationPackLoader.php deleted file mode 100644 index a152744d..00000000 --- a/src/Core/Localization/Pack/Loader/AbstractLocalizationPackLoader.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Pack\Loader; - -use ErrorException; -use SimpleXMLElement; - -/** - * Class AbstractLocalizationPackLoader is abstract localization pack loader that implements XML loading from file. - */ -abstract class AbstractLocalizationPackLoader implements LocalizationPackLoaderInterface -{ - /** - * Loads XML from local or remote file. - * - * @param string $file - * - * @return SimpleXMLElement|null - */ - protected function loadXml($file) - { - try { - $xml = simplexml_load_file($file); - } catch (ErrorException $e) { - return null; - } - - return false === $xml ? null : $xml; - } -} diff --git a/src/Core/Localization/Pack/Loader/LocalLocalizationPackLoader.php b/src/Core/Localization/Pack/Loader/LocalLocalizationPackLoader.php deleted file mode 100644 index e7d985f5..00000000 --- a/src/Core/Localization/Pack/Loader/LocalLocalizationPackLoader.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Pack\Loader; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; - -/** - * Class LocalLocalizationPackLoader is responsible for loading localization pack data from local host. - */ -final class LocalLocalizationPackLoader extends AbstractLocalizationPackLoader -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getLocalizationPackList() - { - $rootDir = $this->configuration->get('_PS_ROOT_DIR_'); - - $localizationFile = sprintf('%s/localization/localization.xml', $rootDir); - if (!file_exists($localizationFile)) { - return null; - } - - return $this->loadXml($localizationFile); - } - - /** - * {@inheritdoc} - */ - public function getLocalizationPack($countryIso) - { - $rootDir = $this->configuration->get('_PS_HOST_MODE_') ? - $this->configuration->get('_PS_CORE_DIR_') : - $this->configuration->get('_PS_ROOT_DIR_'); - - $localizationPackFile = sprintf('%s/localization/%s.xml', $rootDir, $countryIso); - if (!file_exists($localizationPackFile)) { - return null; - } - - return $this->loadXml($localizationPackFile); - } -} diff --git a/src/Core/Localization/Pack/Loader/LocalizationPackLoaderInterface.php b/src/Core/Localization/Pack/Loader/LocalizationPackLoaderInterface.php deleted file mode 100644 index 0c0723ca..00000000 --- a/src/Core/Localization/Pack/Loader/LocalizationPackLoaderInterface.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Pack\Loader; - -use SimpleXMLElement; - -/** - * Interface LocalizationPackLoaderInterface defines contract for localization pack loaders. - */ -interface LocalizationPackLoaderInterface -{ - /** - * Get localization packs list. - * - * @return SimpleXMLElement|null SimpleXMLElement with localization packs data or null if packs are not available - */ - public function getLocalizationPackList(); - - /** - * Get single localization pack data. - * - * @param string $countryIso Country ISO Alpha-2 code - * - * @return SimpleXMLElement|null - */ - public function getLocalizationPack($countryIso); -} diff --git a/src/Core/Localization/Pack/Loader/RemoteLocalizationPackLoader.php b/src/Core/Localization/Pack/Loader/RemoteLocalizationPackLoader.php deleted file mode 100644 index 6d451db3..00000000 --- a/src/Core/Localization/Pack/Loader/RemoteLocalizationPackLoader.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Pack\Loader; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Foundation\Version; - -/** - * Class RemoteLocalizationPackLoader is responsible for loading localization pack data from prestashop.com. - */ -final class RemoteLocalizationPackLoader extends AbstractLocalizationPackLoader -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var Version - */ - private $version; - - /** - * @param ConfigurationInterface $configuration - * @param Version $version - */ - public function __construct(ConfigurationInterface $configuration, Version $version) - { - $this->configuration = $configuration; - $this->version = $version; - } - - /** - * {@inheritdoc} - */ - public function getLocalizationPackList() - { - $apiUrl = $this->configuration->get('_PS_API_URL_'); - - $xmlLocalizationPacks = $this->loadXml($apiUrl . '/rss/localization.xml'); - if (!$xmlLocalizationPacks) { - return null; - } - - return $xmlLocalizationPacks; - } - - /** - * {@inheritdoc} - */ - public function getLocalizationPack($countryIso) - { - $apiUrl = $this->configuration->get('_PS_API_URL_'); - $localizationPackUrl = sprintf('%s/localization/%s/%s.xml', $apiUrl, $this->version->getMajorVersion(), $countryIso); - - $pack = $this->loadXml($localizationPackUrl); - if (false === $pack) { - return null; - } - - return $pack; - } -} diff --git a/src/Core/Localization/RTL/Exception/GenerationException.php b/src/Core/Localization/RTL/Exception/GenerationException.php deleted file mode 100644 index 10bd107e..00000000 --- a/src/Core/Localization/RTL/Exception/GenerationException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\RTL\Exception; - -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; - -/** - * Is thrown when unable to generate RTL files - */ -class GenerationException extends LocalizationException -{ -} diff --git a/src/Core/Localization/RTL/Processor.php b/src/Core/Localization/RTL/Processor.php deleted file mode 100644 index 674b7b5e..00000000 --- a/src/Core/Localization/RTL/Processor.php +++ /dev/null @@ -1,242 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\RTL; - -use PrestaShop\PrestaShop\Adapter\Entity\Language; -use PrestaShop\PrestaShop\Core\Localization\RTL\Exception\GenerationException; - -/** - * Processes stylesheets by transforming them to RTL. - */ -class Processor -{ - /** - * @var string Installed language 2-letter ISO code - */ - private $languageCode = ''; - - /** - * @var bool Indicates if the BO theme should be processed - */ - private $processBOTheme = false; - - /** - * @var string[] Names of the FO themes to process - */ - private $processFOThemes = []; - - /** - * @var array Indicates additional paths to process - */ - private $processPaths = []; - - /** - * @var bool Indicates if this is performed during install - */ - private $isInstall = false; - - /** - * @var bool Indicates if the RTL files should be generated even if they already exist - */ - private $regenerate = false; - - /** - * @var string[] Path to the default modules to process - */ - private $defaultModulesToProcess = []; - - /** - * @var bool Indicates if the default modules should be processed - */ - private $processDefaultModules = false; - - /** - * @var string Path to PrestaShop's admin directory - */ - private $adminDir = ''; - - /** - * @var string Path to the themes directory - */ - private $themesDir = ''; - - /** - * Processor constructor. - * - * @param string $adminDir Path to PrestaShop's admin directory - * @param string $themesDir Path to the FO themes directory - * @param string[] $defaultModulesToProcess Path to the default modules to process - */ - public function __construct($adminDir, $themesDir, array $defaultModulesToProcess) - { - $this->adminDir = $adminDir; - $this->themesDir = $themesDir; - $this->defaultModulesToProcess = $defaultModulesToProcess; - } - - /** - * Specifies the installed language 2-letter ISO code. - * - * @param string $languageCode - * - * @return Processor - */ - public function setLanguageCode($languageCode) - { - $this->languageCode = $languageCode; - - return $this; - } - - /** - * Specifies if the BO theme should be processed. - * - * @param bool $processBOTheme - * - * @return Processor - */ - public function setProcessBOTheme($processBOTheme) - { - $this->processBOTheme = $processBOTheme; - - return $this; - } - - /** - * Specifies the names of the FO themes to process. - * - * @param string[] $processFOThemes - * - * @return Processor - */ - public function setProcessFOThemes(array $processFOThemes) - { - $this->processFOThemes = $processFOThemes; - - return $this; - } - - /** - * Specifies additional paths to process. - * - * @param string[] $processPaths - * - * @return Processor - */ - public function setProcessPaths(array $processPaths) - { - $this->processPaths = $processPaths; - - return $this; - } - - /** - * Specifies if this is performed during install. - * - * @param bool $isInstall - * - * @return Processor - */ - public function setIsInstall($isInstall) - { - $this->isInstall = $isInstall; - - return $this; - } - - /** - * Specifies if the RTL files should be generated even if they already exist. - * - * @param bool $regenerate - * - * @return Processor - */ - public function setRegenerate($regenerate) - { - $this->regenerate = $regenerate; - - return $this; - } - - /** - * Specifies if the default modules should be processed. - * - * @param bool $processDefaultModules - * - * @return Processor - */ - public function setProcessDefaultModules($processDefaultModules) - { - $this->processDefaultModules = $processDefaultModules; - - return $this; - } - - /** - * @throws Exception\GenerationException - * @throws \Exception - */ - public function process() - { - if ($this->languageCode) { - $lang_pack = Language::getLangDetails($this->languageCode); - if (!$lang_pack['is_rtl']) { - return; - } - } - - $generator = new StylesheetGenerator(); - // generate stylesheets for BO themes - if ($this->processBOTheme) { - if (!is_dir($this->adminDir)) { - throw new GenerationException("Cannot generate BO themes: \"{$this->adminDir}\" is not a directory"); - } - - $generator->generateInDirectory($this->adminDir . DIRECTORY_SEPARATOR . 'themes'); - } - - // generate stylesheets for BO themes - if ($this->processFOThemes) { - foreach ($this->processFOThemes as $themeName) { - $generator->generateInDirectory($this->themesDir . DIRECTORY_SEPARATOR . $themeName); - } - } - - // generate stylesheets for default modules - if ($this->processDefaultModules) { - $this->processPaths = array_merge($this->processPaths, $this->defaultModulesToProcess); - } - - if (!empty($this->processPaths)) { - foreach ($this->processPaths as $path) { - if (!empty($path) && is_dir($path)) { - $generator->generateInDirectory($path); - } - } - } - } -} diff --git a/src/Core/Localization/RTL/StyleSheetProcessorFactory.php b/src/Core/Localization/RTL/StyleSheetProcessorFactory.php deleted file mode 100644 index d6e51c70..00000000 --- a/src/Core/Localization/RTL/StyleSheetProcessorFactory.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\RTL; - -use PrestaShop\PrestaShop\Core\ConfigurationInterface; - -/** - * Class StyleSheetProcessorFactory - */ -final class StyleSheetProcessorFactory implements StyleSheetProcessorFactoryInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function create() - { - $rootDir = $this->configuration->get('_PS_ROOT_DIR_'); - $moduleDir = $this->configuration->get('_PS_MODULE_DIR_'); - - if (null === $adminDir = $this->configuration->get('_PS_ADMIN_DIR_')) { - $adminDir = $rootDir . DIRECTORY_SEPARATOR . 'admin'; - $adminDir = is_dir($adminDir) ? $adminDir : ($adminDir . '-dev'); - } - - $themesDir = $this->configuration->get('_PS_ROOT_DIR_') . DIRECTORY_SEPARATOR . 'themes'; - - // @todo: improve modules configuration - // see: https://github.com/PrestaShop/PrestaShop/pull/11169#discussion_r231824489 - $modulesToProcess = [ - $moduleDir . 'gamification', - $moduleDir . 'welcome', - $moduleDir . 'cronjobs', - ]; - - return new Processor( - $adminDir, - $themesDir, - $modulesToProcess - ); - } -} diff --git a/src/Core/Localization/RTL/StyleSheetProcessorFactoryInterface.php b/src/Core/Localization/RTL/StyleSheetProcessorFactoryInterface.php deleted file mode 100644 index f171795a..00000000 --- a/src/Core/Localization/RTL/StyleSheetProcessorFactoryInterface.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\RTL; - -/** - * Interface StyleSheetProcessorFactoryInterface creates RTL stylesheet processor. - */ -interface StyleSheetProcessorFactoryInterface -{ - /** - * @return Processor - */ - public function create(); -} diff --git a/src/Core/Localization/RTL/StylesheetGenerator.php b/src/Core/Localization/RTL/StylesheetGenerator.php deleted file mode 100644 index 87e521c3..00000000 --- a/src/Core/Localization/RTL/StylesheetGenerator.php +++ /dev/null @@ -1,232 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\RTL; - -use CSSJanus; -use PrestaShop\PrestaShop\Core\Foundation\Filesystem\FileSystem; -use PrestaShop\PrestaShop\Core\Localization\RTL\Exception\GenerationException; -use Tools; - -/** - * Creates RTL versions of LTR CSS files. - * - * This class creates new files based on the original ones by using CSSJanus first, - * then applying an optional .rtlfix file, if one with the same name as the processed file is found. - * - * Inspired by "Localize Fixture" from Mahdi Shad @ iPresta - * - * @see https://github.com/iPresta/localize-fixture - */ -class StylesheetGenerator -{ - /** - * Default file type to look up. - */ - const DEFAULT_FILE_TYPE = 'css'; - - /** - * Default suffix to use for RTL transformed files. - */ - const DEFAULT_RTL_SUFFIX = '_rtl'; - - /** - * Extension of RTL fix files. - */ - const RTLFIX_EXTENSION = 'rtlfix'; - - /** - * @var string - */ - private $fileType; - - /** - * @var string - */ - private $rtlSuffix; - - /** - * @param string $fileType [default='css'] File type (CSS or SCSS) - * @param string $rtlSuffix [default='_rtl'] Suffix to add to transformed RTL files - */ - public function __construct($fileType = self::DEFAULT_FILE_TYPE, $rtlSuffix = self::DEFAULT_RTL_SUFFIX) - { - $this->fileType = $fileType; - $this->rtlSuffix = $rtlSuffix; - } - - /** - * Creates an RTL version of all the files in the selected path recursively. - * - * @param string $directory Path to process. All CSS files in this directory will be processed. - * @param bool $regenerate [default=false] Indicates if RTL files should be re-generated even if they exist - * - * @throws GenerationException - */ - public function generateInDirectory($directory, $regenerate = false) - { - $allFiles = $this->getFilesInDirectory($directory); - - foreach ($allFiles as $file) { - if ($this->shouldProcessFile($directory . '/' . $file, $regenerate)) { - $this->processFile($directory . '/' . $file); - } - } - } - - /** - * Indicates if a file should be processed or not. - * - * @param string $file File path - * @param bool $regenerate Indicates if RTL files should be re-generated even if they exist - * - * @return bool - */ - private function shouldProcessFile($file, $regenerate) - { - return - strpos($file, '/node_modules/') === false - // does not end with .rtlfix - && substr(rtrim($file, '.' . $this->fileType), -4) !== $this->rtlSuffix - // RTL file does not exist or we are regenerating them - && ($regenerate || !file_exists($this->getRtlFileName($file))); - } - - /** - * Creates an RTL version of a file. - * - * @param string $filePath Path to the file to process - * - * @throws GenerationException - */ - private function processFile($filePath) - { - $content = file_get_contents($filePath); - - if ($content === false) { - throw new GenerationException(sprintf('Unable to read from CSS file: %s', $filePath)); - } - - $rendered = CSSJanus::transform($content); - - if (strlen($rendered) === 0 && strlen($content) !== 0) { - throw new GenerationException(sprintf('Failed to generate RTL CSS from file: %s', $filePath)); - } - - $content = $this->appendRtlFixIfNecessary( - $rendered, - $filePath - ); - - $this->saveFile($content, $filePath); - } - - /** - * Creates a list of all files of the required type in the provided directory recursively. - * - * @param string $directory Directory to scan - * - * @return string[] Array of file paths, relative to the provided directory - */ - private function getFilesInDirectory($directory) - { - return Tools::scandir($directory, $this->fileType, '', true); - } - - /** - * Removes the file extension from path. - * - * @param string $filePath Path to a file - * - * @return string - */ - private function getFilePathWithoutExtension($filePath) - { - $path = pathinfo($filePath); - - return $path['dirname'] . '/' . $path['filename']; - } - - /** - * Returns the full path for the RTL filename corresponding to the provided base filename. - * - * @param string $baseFileName Base file name - * - * @return string RTL filename - */ - private function getRtlFileName($baseFileName) - { - return $this->getFilePathWithoutExtension($baseFileName) . $this->rtlSuffix . '.' . $this->fileType; - } - - /** - * Appends the content of an .rtlfix file to $content. - * - * @param string $content Base content - * @param string $baseFile Path to the processed file - * - * @return string Content with RTL fix applied - * - * @throws GenerationException If unable to read from .rtlfix file - */ - private function appendRtlFixIfNecessary($content, $baseFile) - { - $filePath = $this->getFilePathWithoutExtension($baseFile); - - $rtlFixFilePath = $filePath . '.' . self::RTLFIX_EXTENSION; - - if (file_exists($rtlFixFilePath)) { - $rtlFixContent = file_get_contents($rtlFixFilePath); - - if ($rtlFixContent === false) { - throw new GenerationException(sprintf('Failed to read from file: %s', $rtlFixFilePath)); - } - - return $content . PHP_EOL . $rtlFixContent; - } - - return $content; - } - - /** - * Saves $content the appropriate file based on the name of the original file. - * - * @param string $content Content to save - * @param string $baseFile Name of the original file - * - * @throws GenerationException If unable to write to file - */ - private function saveFile($content, $baseFile) - { - $rtlFilePath = $this->getRtlFileName($baseFile); - - if (false === file_put_contents($rtlFilePath, $content)) { - throw new GenerationException(sprintf('Unable to write file to: %s', $rtlFilePath)); - } - - @chmod($rtlFilePath, FileSystem::DEFAULT_MODE_FILE); - } -} diff --git a/src/Core/Localization/Specification/Factory.php b/src/Core/Localization/Specification/Factory.php deleted file mode 100644 index b923ba22..00000000 --- a/src/Core/Localization/Specification/Factory.php +++ /dev/null @@ -1,284 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Specification; - -use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleInterface as CldrLocaleInterface; -use PrestaShop\PrestaShop\Core\Localization\CLDR\NumberSymbolsData; -use PrestaShop\PrestaShop\Core\Localization\Currency; -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShop\PrestaShop\Core\Localization\Specification\Number as NumberSpecification; -use PrestaShop\PrestaShop\Core\Localization\Specification\Price as PriceSpecification; - -/** - * Number specification factory. - * Builds Number, Price or Percentage specifications objects. - * - * Uses a CLDR Locale instance to extract relevant data needed to build a specification object - */ -class Factory -{ - /** - * Build a Number specification from a CLDR Locale object. - * - * @param CldrLocaleInterface $cldrLocale - * This CldrLocale object is a low level data object extracted from CLDR data source - * @param int $maxFractionDigits - * Max number of digits to display in a number's decimal part - * @param bool $numberGroupingUsed - * Should we group digits in a number's integer part ? - * - * @return NumberSpecification - * - * @throws LocalizationException - */ - public function buildNumberSpecification(CldrLocaleInterface $cldrLocale, $maxFractionDigits, $numberGroupingUsed) - { - $decimalPattern = $cldrLocale->getDecimalPattern(); - $numbersSymbols = $cldrLocale->getAllNumberSymbols(); - // Use positive pattern to retrieve information - $positivePattern = $this->getPositivePattern($decimalPattern); - - return new NumberSpecification( - $positivePattern, - $this->getNegativePattern($decimalPattern), - $this->computeNumberSymbolLists($numbersSymbols), - $maxFractionDigits, - $this->getMinFractionDigits($positivePattern), - $numberGroupingUsed, - $this->getPrimaryGroupSize($positivePattern), - $this->getSecondaryGroupSize($positivePattern) - ); - } - - /** - * Build a Price specification from a CLDR Locale object and a Currency object. - * - * @param string $localeCode - * The concerned locale - * @param CldrLocaleInterface $cldrLocale - * This CldrLocale object is a low level data object extracted from CLDR data source - * It contains data about the concerned locale - * @param Currency $currency - * This Currency object brings missing specification to format a number as a price - * @param bool $numberGroupingUsed - * Should we group digits when formatting prices ? - * @param $currencyDisplayType - * Type of display for currency symbol (symbol or ISO code) - * @param int $maxFractionDigits|null - * The decimal precision of the price - * - * @return PriceSpecification - * - * @throws LocalizationException - */ - public function buildPriceSpecification( - $localeCode, - CldrLocaleInterface $cldrLocale, - Currency $currency, - $numberGroupingUsed, - $currencyDisplayType, - ?int $maxFractionDigits = null - ) { - $currencyPattern = $currency->getPattern($localeCode) ?: $cldrLocale->getCurrencyPattern(); - $numbersSymbols = $cldrLocale->getAllNumberSymbols(); - // Use positive pattern to retrieve information - $positivePattern = $this->getPositivePattern($currencyPattern); - - return new PriceSpecification( - $positivePattern, - $this->getNegativePattern($currencyPattern), - $this->computeNumberSymbolLists($numbersSymbols), - $maxFractionDigits ?? $this->getMaxFractionDigits($positivePattern), - $this->getMinFractionDigits($positivePattern), - $numberGroupingUsed && $this->getPrimaryGroupSize($positivePattern) > 1, - $this->getPrimaryGroupSize($positivePattern), - $this->getSecondaryGroupSize($positivePattern), - $currencyDisplayType, - $currency->getSymbol($localeCode), - $currency->getIsoCode() - ); - } - - /** - * Extract the positive pattern from a CLDR formatting pattern - * Works with any formatting pattern (number, price, percentage). - * - * @param string $pattern - * The CLDR pattern - * - * @return string - * The extracted positive pattern - */ - protected function getPositivePattern($pattern) - { - $patterns = explode(';', $pattern); - - return isset($patterns[0]) ? $patterns[0] : ''; - } - - /** - * Extract the negative pattern from a CLDR formatting pattern - * Works with any formatting pattern (number, price, percentage). - * - * @param string $pattern - * The CLDR pattern - * - * @return string - * The extracted negative pattern - */ - protected function getNegativePattern($pattern) - { - $patterns = explode(';', $pattern); - - return isset($patterns[1]) - ? $patterns[1] - : '-' . $patterns[0]; - } - - /** - * Convert a list of CLDR number symbols data into a list of NumberSymbolList objects. - * - * @param NumberSymbolsData[] $allNumberSymbolsData - * All the CLDR number symbols data indexed by numbering system - * - * @return NumberSymbolList[] - * - * @throws LocalizationException - * If passed data is invalid - */ - protected function computeNumberSymbolLists($allNumberSymbolsData) - { - $symbolsLists = []; - foreach ($allNumberSymbolsData as $numberingSystem => $numberSymbolsData) { - $symbolsLists[$numberingSystem] = $this->getNumberSymbolList($numberSymbolsData); - } - - return $symbolsLists; - } - - /** - * Get a NumberSymbolList object from a CLDR NumberSymbolsData object. - * - * @param NumberSymbolsData $symbolsData Data that will be used to build the NumberSymbolList object - * - * @return NumberSymbolList An immutable NumberSymbolList object - * - * @throws LocalizationException If passed data is invalid - */ - protected function getNumberSymbolList(NumberSymbolsData $symbolsData) - { - return new NumberSymbolList( - $symbolsData->getDecimal(), - $symbolsData->getGroup(), - $symbolsData->getList(), - $symbolsData->getPercentSign(), - $symbolsData->getMinusSign(), - $symbolsData->getPlusSign(), - $symbolsData->getExponential(), - $symbolsData->getSuperscriptingExponent(), - $symbolsData->getPerMille(), - $symbolsData->getInfinity(), - $symbolsData->getNan() - ); - } - - /** - * Extract the min number of fraction digits from a number pattern (decimal, currency, percentage). - * - * @param string $pattern - * The formatting pattern to use for extraction - * - * @return int - * The min number of fraction digits to display in the final number - */ - protected function getMinFractionDigits($pattern) - { - $dotPos = (int) strpos($pattern, '.'); - - return substr_count($pattern, '0', $dotPos); - } - - /** - * Extract the max number of fraction digits from a number pattern (decimal, currency, percentage). - * - * @param string $pattern The formatting pattern to use for extraction (eg 0.00##) - * - * @return int The max number of fraction digits to display in the final number - */ - protected function getMaxFractionDigits($pattern) - { - $dotPos = (int) strpos($pattern, '.'); - - return strlen(substr($pattern, $dotPos + 1)); - } - - /** - * Get the primary digits group size from a number formatting pattern. - * - * @param string $pattern - * The CLDR number formatting pattern (e.g.: #,##0.###) - * - * @return int - * The primary group size of the passed pattern - */ - protected function getPrimaryGroupSize($pattern) - { - $groups = $this->getPatternGroups($pattern); - $nbGroups = count($groups); - - return strlen($groups[$nbGroups - 1]); - } - - /** - * Get the secondary digits group size from a number formatting pattern - * e.g.: with #,##0.### => No secondary group. Will return primary group size. - * e.g.: with #,##,##0.### => Secondary group size is 2, primary group size is 3. - * - * @param string $pattern The CLDR number formatting pattern - * - * @return int The secondary group size of the passed pattern - */ - protected function getSecondaryGroupSize($pattern) - { - $groups = $this->getPatternGroups($pattern); - $nbGroups = count($groups); - - if ($nbGroups > 2) { - return strlen($groups[$nbGroups - 2]); - } - - return strlen($groups[$nbGroups - 1]); - } - - protected function getPatternGroups($pattern) - { - $parts = explode('.', $pattern); - $integerPart = $parts[0]; - - return explode(',', $integerPart); - } -} diff --git a/src/Core/Localization/Specification/Number.php b/src/Core/Localization/Specification/Number.php deleted file mode 100644 index 5b9f04d1..00000000 --- a/src/Core/Localization/Specification/Number.php +++ /dev/null @@ -1,345 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Specification; - -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; - -/** - * Number specification class. - * - * Regroups rules and data used when formatting a decimal number in a given locale and a given numbering system - * (latin, arab, ...). - */ -class Number implements NumberInterface -{ - /** - * Number specification constructor. - * - * @param string $positivePattern - * CLDR formatting pattern for positive amounts - * @param string $negativePattern - * CLDR formatting pattern for negative amounts - * @param NumberSymbolList[] $symbols - * List of available number symbols lists (NumberSymbolList objects) - * Each list is indexed by numbering system - * @param int $maxFractionDigits - * Maximum number of digits after decimal separator - * @param int $minFractionDigits - * Minimum number of digits after decimal separator - * @param bool $groupingUsed - * Is digits grouping used ? - * @param int $primaryGroupSize - * Size of primary digits group in the number - * @param int $secondaryGroupSize - * Size of secondary digits group in the number - * - * @throws LocalizationException - */ - public function __construct( - $positivePattern, - $negativePattern, - $symbols, - $maxFractionDigits, - $minFractionDigits, - $groupingUsed, - $primaryGroupSize, - $secondaryGroupSize - ) { - $this->positivePattern = $positivePattern; - $this->negativePattern = $negativePattern; - $this->symbols = $symbols; - - if ($maxFractionDigits < $minFractionDigits) { - $minFractionDigits = $maxFractionDigits; - } - $this->maxFractionDigits = $maxFractionDigits; - $this->minFractionDigits = $minFractionDigits; - - $this->groupingUsed = $groupingUsed; - $this->primaryGroupSize = $primaryGroupSize; - $this->secondaryGroupSize = $secondaryGroupSize; - - $this->validateData(); - } - - /** - * Positive number pattern. - * - * Unicode's CLDR specific syntax. Describes how to format a positive number. - * eg: #,##0.### (decimal) - * eg: #,##0.##0 % (percentage) - * eg: #,##0.00 ¤ (price) - * - * @var string - */ - protected $positivePattern; - - /** - * Negative number pattern. - * - * Unicode's CLDR specific syntax. Describes how to format a negative number. - * eg: -#,##0.### (decimal) - * eg: -#,##0.##0 % (percentage) - * eg: -#,##0.00 ¤ (price) - * - * @var string - */ - protected $negativePattern; - - /** - * List of available number symbols lists (NumberSymbolList objects) - * Each list is indexed by numbering system. - * - * @var NumberSymbolList[] - */ - protected $symbols; - - /** - * Maximum number of digits after decimal separator (rounding if needed). - * - * @var int - */ - protected $maxFractionDigits; - - /** - * Minimum number of digits after decimal separator (fill with "0" if needed). - * - * @var int - */ - protected $minFractionDigits; - - /** - * Is digits grouping used ? - * eg: if yes -> "9 999 999". If no => "9999999". - * - * @var bool - */ - protected $groupingUsed; - - /** - * Size of primary digits group in the number - * e.g.: 999 is the primary group in this number: 1 234 999.567. - * - * @var int - */ - protected $primaryGroupSize; - - /** - * Size of secondary digits groups in the number - * eg: 999 is a secondary group in this number: 123 999 456.789 - * eg: another secondary group (still 999): 999 123 456.789. - * - * @var int - */ - protected $secondaryGroupSize; - - /** - * Get all specified symbols lists, indexed by available numbering system. - * - * Each item of the result is a NumberSymbolList - * - * @return NumberSymbolList[] - */ - public function getAllSymbols() - { - return $this->symbols; - } - - /** - * Get the specified symbols list for a given numbering system. - * - * @param string $numberingSystem - * Numbering system to use when formatting numbers. @see http://cldr.unicode.org/translation/numbering-systems - * - * @return NumberSymbolList - * - * @throws LocalizationException - */ - public function getSymbolsByNumberingSystem($numberingSystem = NumberInterface::NUMBERING_SYSTEM_LATIN) - { - if (!isset($this->symbols[$numberingSystem])) { - throw new LocalizationException('Unknown or invalid numbering system'); - } - - return $this->symbols[$numberingSystem]; - } - - /** - * Get the formatting rules for this number (when positive). - * - * This pattern uses the Unicode CLDR number pattern syntax - * - * @return string - */ - public function getPositivePattern() - { - return $this->positivePattern; - } - - /** - * Get the formatting rules for this number (when negative). - * - * This pattern uses the Unicode CLDR number pattern syntax - * - * @return string - */ - public function getNegativePattern() - { - return $this->negativePattern; - } - - /** - * Get the maximum number of digits after decimal separator (rounding if needed). - * - * @return int - */ - public function getMaxFractionDigits() - { - return $this->maxFractionDigits; - } - - /** - * Get the minimum number of digits after decimal separator (fill with "0" if needed). - * - * @return int - */ - public function getMinFractionDigits() - { - return $this->minFractionDigits; - } - - /** - * Get the "grouping" flag. This flag defines if digits grouping should be used when formatting this number. - * - * @return bool - */ - public function isGroupingUsed() - { - return $this->groupingUsed; - } - - /** - * Get the size of primary digits group in the number. - * - * @return int - */ - public function getPrimaryGroupSize() - { - return $this->primaryGroupSize; - } - - /** - * Get the size of secondary digits groups in the number. - * - * @return int - */ - public function getSecondaryGroupSize() - { - return $this->secondaryGroupSize; - } - - /** - * Data (attributes) validation. - * - * @throws LocalizationException - */ - protected function validateData() - { - if (!isset($this->positivePattern) - || !is_string($this->positivePattern) - ) { - throw new LocalizationException('Invalid positivePattern'); - } - - if (!isset($this->negativePattern) - || !is_string($this->negativePattern) - ) { - throw new LocalizationException('Invalid negativePattern'); - } - - if (!isset($this->symbols) - || !(is_array($this->symbols)) - ) { - throw new LocalizationException('Invalid symbols'); - } - - foreach ($this->symbols as $symbolList) { - if (!$symbolList instanceof NumberSymbolList) { - throw new LocalizationException('Symbol lists must be instances of NumberSymbolList'); - } - } - - if (!isset($this->maxFractionDigits) - || !is_int($this->maxFractionDigits) - ) { - throw new LocalizationException('Invalid maxFractionDigits'); - } - - if (!isset($this->minFractionDigits) - || !is_int($this->minFractionDigits) - ) { - throw new LocalizationException('Invalid minFractionDigits'); - } - - if (!isset($this->groupingUsed) - || !is_bool($this->groupingUsed) - ) { - throw new LocalizationException('Invalid groupingUsed'); - } - - if (!isset($this->primaryGroupSize) - || !is_int($this->primaryGroupSize) - ) { - throw new LocalizationException('Invalid primaryGroupSize'); - } - - if (!isset($this->secondaryGroupSize) - || !is_int($this->secondaryGroupSize) - ) { - throw new LocalizationException('Invalid secondaryGroupSize'); - } - } - - /** - * To array function - * - * @return array - */ - public function toArray() - { - return [ - 'numberSymbols' => $this->getSymbolsByNumberingSystem()->toArray(), - 'positivePattern' => $this->getPositivePattern(), - 'negativePattern' => $this->getNegativePattern(), - 'maxFractionDigits' => $this->getMaxFractionDigits(), - 'minFractionDigits' => $this->getMinFractionDigits(), - 'groupingUsed' => $this->isGroupingUsed(), - 'primaryGroupSize' => $this->getPrimaryGroupSize(), - 'secondaryGroupSize' => $this->getSecondaryGroupSize(), - ]; - } -} diff --git a/src/Core/Localization/Specification/NumberCollection.php b/src/Core/Localization/Specification/NumberCollection.php deleted file mode 100644 index b32a2323..00000000 --- a/src/Core/Localization/Specification/NumberCollection.php +++ /dev/null @@ -1,148 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Specification; - -use ArrayIterator; -use Countable; -use IteratorAggregate; -use PrestaShop\PrestaShop\Core\Localization\Specification\NumberInterface as NumberSpecificationInterface; - -/** - * Number specifications collection - * Contains a list of Number specification items (all implementing NumberInterface). - */ -class NumberCollection implements IteratorAggregate, Countable -{ - /** - * The Number specification items. - * - * @var NumberSpecificationInterface[] - */ - protected $numberSpecifications = []; - - /** - * Gets the current NumberCollection as an Iterator that includes all Number specification items. - * - * It implements \IteratorAggregate. - * - * @return ArrayIterator|NumberSpecificationInterface[] - * An ArrayIterator object for iterating over Number specification items - */ - public function getIterator() - { - return new ArrayIterator($this->numberSpecifications); - } - - /** - * Gets the number of Number specification items in this collection. - * - * @return int - * The number of Number specification items - */ - public function count() - { - return count($this->numberSpecifications); - } - - /** - * Adds a Number specification item at the end of the collection. - * - * @param int|string $index - * The item index - * @param numberSpecificationInterface $numberSpecification - * The Number specification item to add - * - * @return NumberCollection - * Fluent interface - */ - public function add($index, NumberSpecificationInterface $numberSpecification) - { - $this->numberSpecifications[$index] = $numberSpecification; - - return $this; - } - - /** - * Returns all Number specification items in this collection. - * - * @return NumberSpecificationInterface[] - * An array of Number specification items - */ - public function all() - { - return $this->numberSpecifications; - } - - /** - * Gets a Number specification item by index. - * - * @param int|string $index - * The Number specification item index into this collection - * (@see NumberCollection::add()) - * - * @return NumberSpecificationInterface|null - * A Number specification instance or null when not found - */ - public function get($index) - { - return isset($this->numberSpecifications[$index]) - ? $this->numberSpecifications[$index] - : null; - } - - /** - * Removes a Number specification item or an array of Number specification items by index from the collection. - * - * @param int|string|int[]|string[]|array $index - * The Number specification item index or an array of Number specification item indexes - * - * @return NumberCollection - * Fluent interface - */ - public function remove($index) - { - foreach ((array) $index as $i) { - unset($this->numberSpecifications[$i]); - } - - return $this; - } - - /** - * Clear the collection, removing all contained Number specification items. - * - * @return NumberCollection - * Fluent interface - */ - public function clear() - { - $this->numberSpecifications = []; - - return $this; - } -} diff --git a/src/Core/Localization/Specification/NumberInterface.php b/src/Core/Localization/Specification/NumberInterface.php deleted file mode 100644 index fd695b15..00000000 --- a/src/Core/Localization/Specification/NumberInterface.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Specification; - -/** - * Number specification interface. - * - * Regroups rules and data used when formatting a decimal number in a given locale and a given numbering system - * (latin, arab, ...). - */ -interface NumberInterface -{ - /** - * Latin numbering system is the "occidental" numbering system. Number digits are 0123456789. - * This is the default numbering system in PrestaShop, even for arabian or asian languages, until we - * provide a way to configure this in admin. - */ - const NUMBERING_SYSTEM_LATIN = 'latn'; - - /** - * Get all specified symbols lists, indexed by available numbering system. - * - * Each item of the result is a NumberSymbolList - * - * @return NumberSymbolList[] - */ - public function getAllSymbols(); - - /** - * Get the specified symbols list for a given numbering system. - * - * @param string $numberingSystem - * Numbering system to use when formatting numbers. @see http://cldr.unicode.org/translation/numbering-systems - * - * @return NumberSymbolList - */ - public function getSymbolsByNumberingSystem($numberingSystem = NumberInterface::NUMBERING_SYSTEM_LATIN); - - /** - * Get the formatting rules for this number (when positive). - * - * This pattern uses the Unicode CLDR number pattern syntax - * - * @return string - */ - public function getPositivePattern(); - - /** - * Get the formatting rules for this number (when negative). - * - * This pattern uses the Unicode CLDR number pattern syntax - * - * @return string - */ - public function getNegativePattern(); - - /** - * Get the maximum number of digits after decimal separator (rounding if needed). - * - * @return int - */ - public function getMaxFractionDigits(); - - /** - * Get the minimum number of digits after decimal separator (fill with "0" if needed). - * - * @return int - */ - public function getMinFractionDigits(); - - /** - * Get the "grouping" flag. This flag defines if digits grouping should be used when formatting this number. - * - * @return bool - */ - public function isGroupingUsed(); - - /** - * Get the size of primary digits group in the number. - * - * @return int - */ - public function getPrimaryGroupSize(); - - /** - * Get the size of secondary digits groups in the number. - * - * @return int - */ - public function getSecondaryGroupSize(); -} diff --git a/src/Core/Localization/Specification/NumberSymbolList.php b/src/Core/Localization/Specification/NumberSymbolList.php deleted file mode 100644 index 12e0324e..00000000 --- a/src/Core/Localization/Specification/NumberSymbolList.php +++ /dev/null @@ -1,400 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Specification; - -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; - -/** - * Number's symbols data object. Regroups all symbols used when formatting a number - * (decimal separator, thousands separator, etc.). - */ -class NumberSymbolList -{ - /** - * Decimal separator character. - * - * Separates the integer and fractional part of the number. - * - * @var string - */ - protected $decimal; - - /** - * Digits group separator character. - * - * separates clusters of integer digits to make large numbers more legible; commonly used for thousands(grouping - * size 3, e.g. "100,000,000") or in some locales, ten-thousands (grouping size 4, e.g. "1,0000,0000"). - * - * @var string - */ - protected $group; - - /** - * List elements separator character. - * - * Symbol used to separate numbers in a list intended to represent structured data such as an array. - * - * @var string - */ - protected $list; - - /** - * Percent sign character. - * - * Used to indicate a percentage (1/100th) amount. - * - * @var string - */ - protected $percentSign; - - /** - * Minus sign character. - * - * Symbol used to denote negative value. - * - * @var string - */ - protected $minusSign; - - /** - * Plus sign character. - * - * Symbol used to denote positive value. - * It can be used to produce modified patterns, so that 3.12 is formatted as "+3.12", for example. - * - * @var string - */ - protected $plusSign; - - /** - * Exponential character. - * - * Symbol separating the mantissa and exponent values. - * - * @var string - */ - protected $exponential; - - /** - * Superscripting exponent character. - * - * Used in numbers to show a format like "1.23 × 10^4" - * (exponential character is a shortcut for "× 10^n" notation) - * - * @var string - */ - protected $superscriptingExponent; - - /** - * Permille sign character. - * - * Used to define them as a per-mille (1/1000th) amount. - * - * @var string - */ - protected $perMille; - - /** - * The infinity sign. Corresponds to the IEEE infinity bit pattern. - * - * @var string - */ - protected $infinity; - - /** - * The NaN (Not A Number) sign. Corresponds to the IEEE NaN bit pattern. - * - * @var string - */ - protected $nan; - - /** - * NumberSymbolList constructor. - * - * @param string $decimal - * Decimal separator character - * @param string $group - * Digits group separator character - * @param string $list - * List elements separator character - * @param string $percentSign - * Percent sign character - * @param string $minusSign - * Minus sign character - * @param string $plusSign - * Plus sign character - * @param string $exponential - * Exponential character - * @param string $superscriptingExponent - * Superscripting exponent character - * @param string $perMille - * Permille sign character - * @param string $infinity - * The infinity sign. Corresponds to the IEEE infinity bit pattern. - * @param string $nan - * The NaN (Not A Number) sign. Corresponds to the IEEE NaN bit pattern. - * - * @throws LocalizationException - */ - public function __construct( - $decimal, - $group, - $list, - $percentSign, - $minusSign, - $plusSign, - $exponential, - $superscriptingExponent, - $perMille, - $infinity, - $nan - ) { - $this->decimal = $decimal; - $this->group = $group; - $this->list = $list; - $this->percentSign = $percentSign; - $this->minusSign = $minusSign; - $this->plusSign = $plusSign; - $this->exponential = $exponential; - $this->superscriptingExponent = $superscriptingExponent; - $this->perMille = $perMille; - $this->infinity = $infinity; - $this->nan = $nan; - - $this->validateData(); - } - - /** - * Get the decimal separator. - * - * @return string - */ - public function getDecimal() - { - return $this->decimal; - } - - /** - * Get the digit groups separator. - * - * @return string - */ - public function getGroup() - { - return $this->group; - } - - /** - * Get the list elements separator. - * - * @return string - */ - public function getList() - { - return $this->list; - } - - /** - * Get the percent sign. - * - * @return string - */ - public function getPercentSign() - { - return $this->percentSign; - } - - /** - * Get the minus sign. - * - * @return string - */ - public function getMinusSign() - { - return $this->minusSign; - } - - /** - * Get the plus sign. - * - * @return string - */ - public function getPlusSign() - { - return $this->plusSign; - } - - /** - * Get the exponential character. - * - * @return string - */ - public function getExponential() - { - return $this->exponential; - } - - /** - * Get the exponent character. - * - * @return string - */ - public function getSuperscriptingExponent() - { - return $this->superscriptingExponent; - } - - /** - * Gert the per mille symbol (often "‰"). - * - * @see https://en.wikipedia.org/wiki/Per_mille - * - * @return string - */ - public function getPerMille() - { - return $this->perMille; - } - - /** - * Get the infinity symbol (often "∞"). - * - * @see https://en.wikipedia.org/wiki/Infinity_symbol - * - * @return string - */ - public function getInfinity() - { - return $this->infinity; - } - - /** - * Get the NaN (not a number) sign. - * - * @return string - */ - public function getNan() - { - return $this->nan; - } - - /** - * Symbols list validation. - * - * @throws LocalizationException - */ - protected function validateData() - { - if (!isset($this->decimal) - || !is_string($this->decimal) - ) { - throw new LocalizationException('Invalid decimal : ' . print_r($this->decimal, true)); - } - - if (!isset($this->group) - || !is_string($this->group) - ) { - throw new LocalizationException('Invalid group : ' . print_r($this->group, true)); - } - - if (!isset($this->list) - || !is_string($this->list) - ) { - throw new LocalizationException('Invalid symbols list : ' . print_r($this->list, true)); - } - - if (!isset($this->percentSign) - || !is_string($this->percentSign) - ) { - throw new LocalizationException('Invalid percentSign : ' . print_r($this->percentSign, true)); - } - - if (!isset($this->minusSign) - || !is_string($this->minusSign) - ) { - throw new LocalizationException('Invalid minusSign : ' . print_r($this->minusSign, true)); - } - - if (!isset($this->plusSign) - || !is_string($this->plusSign) - ) { - throw new LocalizationException('Invalid plusSign : ' . print_r($this->plusSign, true)); - } - - if (!isset($this->exponential) - || !is_string($this->exponential) - ) { - throw new LocalizationException('Invalid exponential : ' . print_r($this->exponential, true)); - } - - if (!isset($this->superscriptingExponent) - || !is_string($this->superscriptingExponent) - ) { - throw new LocalizationException('Invalid superscriptingExponent : ' . print_r($this->superscriptingExponent, true)); - } - - if (!isset($this->perMille) - || !is_string($this->perMille) - ) { - throw new LocalizationException('Invalid perMille : ' . print_r($this->perMille, true)); - } - - if (!isset($this->infinity) - || !is_string($this->infinity) - ) { - throw new LocalizationException('Invalid infinity : ' . print_r($this->infinity, true)); - } - - if (!isset($this->nan) - || !is_string($this->nan) - ) { - throw new LocalizationException('Invalid nan : ' . print_r($this->nan, true)); - } - } - - /** - * To array function - * - * @return array - */ - public function toArray() - { - return [ - $this->getDecimal(), - $this->getGroup(), - $this->getList(), - $this->getPercentSign(), - $this->getMinusSign(), - $this->getPlusSign(), - $this->getExponential(), - $this->getSuperscriptingExponent(), - $this->getPerMille(), - $this->getInfinity(), - $this->getNaN(), - ]; - } -} diff --git a/src/Core/Localization/Specification/Percentage.php b/src/Core/Localization/Specification/Percentage.php deleted file mode 100644 index 7d54f4f3..00000000 --- a/src/Core/Localization/Specification/Percentage.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Specification; - -use PrestaShop\PrestaShop\Core\Localization\Specification\Number as NumberSpecification; - -/** - * Percentage specification class. - * - * Regroups specific rules and data used when formatting a percentage number in a given locale and a given numbering - * system (latin, arab, ...). - */ -class Percentage extends NumberSpecification -{ -} diff --git a/src/Core/Localization/Specification/Price.php b/src/Core/Localization/Specification/Price.php deleted file mode 100644 index 099b4634..00000000 --- a/src/Core/Localization/Specification/Price.php +++ /dev/null @@ -1,190 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Localization\Specification; - -use PrestaShop\PrestaShop\Core\Localization\Exception\LocalizationException; -use PrestaShop\PrestaShop\Core\Localization\Specification\Number as NumberSpecification; - -/** - * Price number specification class - * Regroups specific rules and data used when formatting a price in a given locale and a given numbering system - * (latin, arab, ...). - */ -class Price extends NumberSpecification -{ - /** - * Currency display option: symbol notation. - */ - const CURRENCY_DISPLAY_SYMBOL = 'symbol'; - - /** - * Currency display option: ISO code notation. - */ - const CURRENCY_DISPLAY_CODE = 'code'; - - /** - * Type of display for currency symbol - * cf. self::CURRENCY_DISPLAY_SYMBOL and self::CURRENCY_DISPLAY_CODE constants. - * - * @var string - */ - protected $currencyDisplay; - - /** - * @var string The currency symbol - * eg : € - */ - protected $currencySymbol; - - /** - * @var string The currency code - * eg : EUR - */ - protected $currencyCode; - - /** - * Price specification constructor. - * - * @param string $positivePattern - * CLDR formatting pattern for positive amounts - * @param string $negativePattern - * CLDR formatting pattern for negative amounts - * @param NumberSymbolList[] $symbols - * List of available number symbols lists (NumberSymbolList objects) - * Each list is indexed by numbering system - * @param int $maxFractionDigits - * Maximum number of digits after decimal separator - * @param int $minFractionDigits - * Minimum number of digits after decimal separator - * @param bool $groupingUsed - * Is digits grouping used ? - * @param int $primaryGroupSize - * Size of primary digits group in the number - * @param int $secondaryGroupSize - * Size of secondary digits group in the number - * @param string $currencyDisplay - * Type of display for currency symbol - * @param string $currencySymbol - * Currency symbol of this price (eg. : €) - * @param $currencyCode - * Currency code of this price (e.g.: EUR) - * - * @throws LocalizationException - */ - public function __construct( - $positivePattern, - $negativePattern, - $symbols, - $maxFractionDigits, - $minFractionDigits, - $groupingUsed, - $primaryGroupSize, - $secondaryGroupSize, - $currencyDisplay, - $currencySymbol, - $currencyCode - ) { - $this->currencyDisplay = $currencyDisplay; - $this->currencySymbol = $currencySymbol; - $this->currencyCode = $currencyCode; - - parent::__construct( - $positivePattern, - $negativePattern, - $symbols, - $maxFractionDigits, - $minFractionDigits, - $groupingUsed, - $primaryGroupSize, - $secondaryGroupSize - ); - } - - /** - * Get type of display for currency symbol. - * - * @return string - */ - public function getCurrencyDisplay() - { - return $this->currencyDisplay; - } - - /** - * Get the currency symbol - * e.g.: €. - * - * @return string - */ - public function getCurrencySymbol() - { - return $this->currencySymbol; - } - - /** - * Get the currency ISO code - * e.g.: EUR. - * - * @return string - */ - public function getCurrencyCode() - { - return $this->currencyCode; - } - - /** - * Data (attributes) validation. - * - * @throws LocalizationException - */ - protected function validateData() - { - parent::validateData(); - - if (!isset($this->currencyDisplay) - || !in_array($this->currencyDisplay, [self::CURRENCY_DISPLAY_CODE, self::CURRENCY_DISPLAY_SYMBOL]) - ) { - throw new LocalizationException('Invalid currencyDisplay'); - } - } - - /** - * To array function - * - * @return array - */ - public function toArray() - { - return array_merge( - [ - 'currencyCode' => $this->getCurrencyCode(), - 'currencySymbol' => $this->getCurrencySymbol(), - ], - parent::toArray() - ); - } -} diff --git a/src/Core/MailTemplate/FolderThemeCatalog.php b/src/Core/MailTemplate/FolderThemeCatalog.php deleted file mode 100644 index e164e5f3..00000000 --- a/src/Core/MailTemplate/FolderThemeCatalog.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate; - -use PrestaShop\PrestaShop\Core\Exception\FileNotFoundException; -use PrestaShop\PrestaShop\Core\Exception\InvalidArgumentException; -use PrestaShop\PrestaShop\Core\Exception\TypeException; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Finder\SplFileInfo; - -/** - * This is a basic mail layouts catalog, not a lot of intelligence it is based - * simply on existing files on the $mailThemesFolder (no database, or config files). - */ -final class FolderThemeCatalog implements ThemeCatalogInterface -{ - /** @var string */ - private $mailThemesFolder; - - /** @var HookDispatcherInterface */ - private $hookDispatcher; - - /** @var FolderThemeScanner */ - private $scanner; - - /** - * @param string $mailThemesFolder - * @param FolderThemeScanner $scanner - * @param HookDispatcherInterface $hookDispatcher - */ - public function __construct( - $mailThemesFolder, - FolderThemeScanner $scanner, - HookDispatcherInterface $hookDispatcher - ) { - $this->mailThemesFolder = $mailThemesFolder; - $this->scanner = $scanner; - $this->hookDispatcher = $hookDispatcher; - } - - /** - * Returns the list of found themes (non empty folders, in the mail themes - * folder). - * - * @throws FileNotFoundException - * @throws TypeException - * - * @return ThemeCollectionInterface - */ - public function listThemes() - { - $this->checkThemesFolder(); - - $finder = new Finder(); - $finder->sortByName(); - $finder->directories()->in($this->mailThemesFolder)->depth(0); - $mailThemes = new ThemeCollection(); - /** @var SplFileInfo $mailThemeFolder */ - foreach ($finder as $mailThemeFolder) { - $mailTheme = $this->scanner->scan($mailThemeFolder->getRealPath()); - if ($mailTheme->getLayouts()->count() > 0) { - $mailThemes[] = $mailTheme; - } - } - - //This hook allows you to add/remove a mail theme - $this->hookDispatcher->dispatchWithParameters( - ThemeCatalogInterface::LIST_MAIL_THEMES_HOOK, - ['mailThemes' => $mailThemes] - ); - - return $mailThemes; - } - - /** - * @param string $theme - * - * @throws FileNotFoundException - * @throws InvalidArgumentException - * @throws TypeException - * - * @return ThemeInterface - */ - public function getByName($theme) - { - /** @var ThemeCollectionInterface $availableThemes */ - $availableThemes = $this->listThemes(); - $themeNames = []; - /** @var ThemeInterface $availableTheme */ - foreach ($availableThemes as $availableTheme) { - if ($theme === $availableTheme->getName()) { - return $availableTheme; - } - $themeNames[] = $availableTheme->getName(); - } - - throw new InvalidArgumentException(sprintf('Invalid requested theme "%s", only available themes are: %s', $theme, implode(', ', $themeNames))); - } - - /** - * @throws FileNotFoundException - */ - private function checkThemesFolder() - { - if (!is_dir($this->mailThemesFolder)) { - throw new FileNotFoundException(sprintf('Invalid mail themes folder "%s": no such directory', $this->mailThemesFolder)); - } - } -} diff --git a/src/Core/MailTemplate/FolderThemeScanner.php b/src/Core/MailTemplate/FolderThemeScanner.php deleted file mode 100644 index c8e92bd5..00000000 --- a/src/Core/MailTemplate/FolderThemeScanner.php +++ /dev/null @@ -1,184 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate; - -use PrestaShop\PrestaShop\Core\Exception\FileNotFoundException; -use PrestaShop\PrestaShop\Core\Exception\TypeException; -use PrestaShop\PrestaShop\Core\MailTemplate\Layout\Layout; -use PrestaShop\PrestaShop\Core\MailTemplate\Layout\LayoutCollection; -use PrestaShop\PrestaShop\Core\MailTemplate\Layout\LayoutCollectionInterface; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Finder\SplFileInfo; - -/** - * Class FolderThemeScanner is used to scan a mail theme folder, it returns a ThemeInterface with all - * its layouts. - */ -final class FolderThemeScanner -{ - /** - * @param string $mailThemeFolder - * - * @return ThemeInterface|null - * - * @throws FileNotFoundException - * @throws TypeException - */ - public function scan($mailThemeFolder) - { - $this->checkThemeFolder($mailThemeFolder); - - $mailTheme = new Theme(basename($mailThemeFolder)); - - $finder = new Finder(); - $finder->files()->in($mailThemeFolder); - if ($finder->count() > 0) { - $mailTheme->setLayouts($this->findThemeLayouts($mailThemeFolder)); - } - - return $mailTheme; - } - - /** - * @param string $mailThemeFolder - * - * @throws TypeException - * - * @return LayoutCollectionInterface - */ - private function findThemeLayouts($mailThemeFolder) - { - $mailThemeLayouts = new LayoutCollection(); - $this->addCoreLayouts($mailThemeLayouts, $mailThemeFolder); - $this->addModulesLayouts($mailThemeLayouts, $mailThemeFolder); - - return $mailThemeLayouts; - } - - /** - * @param LayoutCollectionInterface $collection - * @param string $mailThemeFolder - */ - private function addCoreLayouts(LayoutCollectionInterface $collection, $mailThemeFolder) - { - $coreLayoutsFolder = implode(DIRECTORY_SEPARATOR, [ - $mailThemeFolder, - MailTemplateInterface::CORE_CATEGORY, - ]); - if (!is_dir($coreLayoutsFolder)) { - return; - } - - $this->addLayoutsFromFolder($collection, $coreLayoutsFolder); - } - - /** - * @param LayoutCollectionInterface $collection - * @param string $mailThemeFolder - */ - private function addModulesLayouts(LayoutCollectionInterface $collection, $mailThemeFolder) - { - $moduleLayoutsFolder = implode(DIRECTORY_SEPARATOR, [ - $mailThemeFolder, - MailTemplateInterface::MODULES_CATEGORY, - ]); - if (!is_dir($moduleLayoutsFolder)) { - return; - } - - $moduleFinder = new Finder(); - $moduleFinder->directories()->in($moduleLayoutsFolder)->depth(0); - - /* @var SplFileInfo $moduleFolder */ - foreach ($moduleFinder as $moduleFolder) { - $this->addLayoutsFromFolder($collection, $moduleFolder->getRealPath(), $moduleFolder->getFilename()); - } - } - - /** - * @param LayoutCollectionInterface $collection - * @param string $folder - * @param string $moduleName - */ - private function addLayoutsFromFolder( - LayoutCollectionInterface $collection, - $folder, - $moduleName = '' - ) { - $layoutFiles = []; - $finder = new Finder(); - $finder->files()->in($folder)->sortByName(); - /** @var SplFileInfo $fileInfo */ - foreach ($finder as $fileInfo) { - //Get filename without any extension (ex: account.html.twig -> account) - $layoutName = preg_replace('/\..+/', '', $fileInfo->getBasename()); - if (!isset($layoutFiles[$layoutName])) { - $layoutFiles[$layoutName] = [ - MailTemplateInterface::HTML_TYPE => '', - MailTemplateInterface::TXT_TYPE => '', - ]; - } - $templateType = $this->getTemplateType($fileInfo); - $layoutFiles[$layoutName][$templateType] = $fileInfo->getRealPath(); - } - - foreach ($layoutFiles as $layoutName => $layouts) { - $collection->add(new Layout( - $layoutName, - $layouts[MailTemplateInterface::HTML_TYPE], - $layouts[MailTemplateInterface::TXT_TYPE], - $moduleName - )); - } - } - - /** - * @param SplFileInfo $fileInfo - * - * @return string - */ - private function getTemplateType(SplFileInfo $fileInfo) - { - $ext = !empty($fileInfo->getExtension()) ? '.' . $fileInfo->getExtension() : ''; - $htmlTypeRegexp = sprintf('/.+\.%s%s/', MailTemplateInterface::HTML_TYPE, $ext); - if (preg_match($htmlTypeRegexp, $fileInfo->getFilename())) { - return MailTemplateInterface::HTML_TYPE; - } - - return MailTemplateInterface::TXT_TYPE; - } - - /** - * @throws FileNotFoundException - */ - private function checkThemeFolder($mailThemeFolder) - { - if (!is_dir($mailThemeFolder)) { - throw new FileNotFoundException(sprintf('Invalid mail theme folder "%s": no such directory', $mailThemeFolder)); - } - } -} diff --git a/src/Core/MailTemplate/Layout/Layout.php b/src/Core/MailTemplate/Layout/Layout.php deleted file mode 100644 index 6c807733..00000000 --- a/src/Core/MailTemplate/Layout/Layout.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate\Layout; - -/** - * Class MailLayout is the default implementation of MailLayoutInterface, - * it is a simple immutable data container with no logic. It contains the - * basic info about a mail layout which is used to generate a MailTemplate. - */ -class Layout implements LayoutInterface -{ - /** @var string */ - private $name; - - /** @var string */ - private $htmlPath; - - /** @var string */ - private $txtPath; - - /** @var string */ - private $moduleName; - - /** - * @param string $name Name of the layout to describe its purpose - * @param string $htmlPath Absolute path of the html layout file - * @param string $txtPath Absolute path of the txt layout file - * @param string $moduleName Which module this layout is associated to (if any) - */ - public function __construct( - $name, - $htmlPath, - $txtPath, - $moduleName = '' - ) { - $this->name = $name; - $this->htmlPath = $htmlPath; - $this->txtPath = $txtPath; - $this->moduleName = $moduleName; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @return string - */ - public function getHtmlPath() - { - return $this->htmlPath; - } - - /** - * @return string - */ - public function getTxtPath() - { - return $this->txtPath; - } - - /** - * @return string - */ - public function getModuleName() - { - return $this->moduleName; - } -} diff --git a/src/Core/MailTemplate/Layout/LayoutCollection.php b/src/Core/MailTemplate/Layout/LayoutCollection.php deleted file mode 100644 index ab35c088..00000000 --- a/src/Core/MailTemplate/Layout/LayoutCollection.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate\Layout; - -use PrestaShop\PrestaShop\Core\Data\AbstractTypedCollection; - -class LayoutCollection extends AbstractTypedCollection implements LayoutCollectionInterface -{ - /** - * {@inheritdoc} - */ - protected function getType() - { - return LayoutInterface::class; - } - - /** - * {@inheritdoc} - */ - public function merge(LayoutCollectionInterface $collection) - { - /** @var LayoutInterface $newLayout */ - foreach ($collection as $newLayout) { - if (null !== ($oldLayout = $this->getLayout($newLayout->getName(), $newLayout->getModuleName()))) { - $this->replace($oldLayout, $newLayout); - } else { - $this->add($newLayout); - } - } - } - - /** - * {@inheritdoc} - */ - public function replace(LayoutInterface $oldLayout, LayoutInterface $newLayout) - { - if (!$this->contains($oldLayout)) { - return false; - } - - $oldLayoutIndex = $this->indexOf($oldLayout); - $this->offsetSet($oldLayoutIndex, $newLayout); - - return $this->contains($newLayout); - } - - /** - * {@inheritdoc} - */ - public function getLayout($layoutName, $moduleName) - { - /** @var LayoutInterface $layout */ - foreach ($this as $layout) { - if ($layoutName === $layout->getName() && $moduleName === $layout->getModuleName()) { - return $layout; - } - } - - return null; - } -} diff --git a/src/Core/MailTemplate/Layout/LayoutCollectionInterface.php b/src/Core/MailTemplate/Layout/LayoutCollectionInterface.php deleted file mode 100644 index 6f71e26b..00000000 --- a/src/Core/MailTemplate/Layout/LayoutCollectionInterface.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate\Layout; - -/** - * Interface MailLayoutCollectionInterface contains a list of layouts used to generate - * mail templates. Modules can add/remove their own layouts to this collection through - * the hook: - * ThemeCatalogInterface::LIST_MAIL_THEMES_HOOK = actionListMailThemes - */ -interface LayoutCollectionInterface extends \IteratorAggregate, \Countable -{ - /** - * @param LayoutInterface $layout - * - * @return bool - */ - public function contains($layout); - - /** - * @param LayoutInterface $layout - */ - public function add($layout); - - /** - * @param LayoutInterface $layout - */ - public function remove($layout); - - /** - * @param LayoutInterface $oldLayout - * @param LayoutInterface $newLayout - * - * @return bool - */ - public function replace(LayoutInterface $oldLayout, LayoutInterface $newLayout); - - /** - * @param string $layoutName - * @param string $moduleName - * - * @return LayoutInterface|null - */ - public function getLayout($layoutName, $moduleName); - - /** - * @param LayoutCollectionInterface $collection - */ - public function merge(LayoutCollectionInterface $collection); -} diff --git a/src/Core/MailTemplate/Layout/LayoutInterface.php b/src/Core/MailTemplate/Layout/LayoutInterface.php deleted file mode 100644 index 65337825..00000000 --- a/src/Core/MailTemplate/Layout/LayoutInterface.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate\Layout; - -/** - * Interface LayoutInterface is used to contain the basic info about a mail layout. - */ -interface LayoutInterface -{ - /** - * Name of the layout to describe its purpose - * - * @return string - */ - public function getName(); - - /** - * Absolute path of the html layout file - * - * @return string - */ - public function getHtmlPath(); - - /** - * Absolute path of the html layout file - * - * @return string - */ - public function getTxtPath(); - - /** - * Which module this layout is associated to (if any) - * - * @return string|null - */ - public function getModuleName(); -} diff --git a/src/Core/MailTemplate/Layout/LayoutVariablesBuilder.php b/src/Core/MailTemplate/Layout/LayoutVariablesBuilder.php deleted file mode 100644 index e61aee69..00000000 --- a/src/Core/MailTemplate/Layout/LayoutVariablesBuilder.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate\Layout; - -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShop\PrestaShop\Core\Language\LanguageDefaultFontsCatalog; -use PrestaShop\PrestaShop\Core\Language\LanguageInterface; - -/** - * MailLayoutVariablesBuilder is a basic implementation of MailLayoutVariablesBuilderInterface - * - it formats the variables for template - * - it is able to inject default fonts for specified languages - * - it includes default variables (set in the constructor) - * - it dispatches a hook to allow overriding its output - */ -class LayoutVariablesBuilder implements LayoutVariablesBuilderInterface -{ - /** @var array */ - private $defaultVariables; - - /** @var HookDispatcherInterface */ - private $hookDispatcher; - - /** - * @var LanguageDefaultFontsCatalog - */ - private $languageDefaultFonts; - - /** - * @param HookDispatcherInterface $hookDispatcher - * @param LanguageDefaultFontsCatalog $languageDefaultFonts - * @param array $defaultVariables - */ - public function __construct( - HookDispatcherInterface $hookDispatcher, - LanguageDefaultFontsCatalog $languageDefaultFonts, - array $defaultVariables = [] - ) { - $this->hookDispatcher = $hookDispatcher; - $this->languageDefaultFonts = $languageDefaultFonts; - $this->defaultVariables = $defaultVariables; - } - - /** - * {@inheritdoc} - */ - public function buildVariables(LayoutInterface $mailLayout, LanguageInterface $language) - { - $languageDefaultFont = $this->languageDefaultFonts->getDefaultFontByLanguage($language); - if (!empty($languageDefaultFont)) { - $languageDefaultFont .= ','; - } - - $mailLayoutVariables = array_merge($this->defaultVariables, [ - 'languageIsRTL' => $language->isRTL(), - 'languageDefaultFont' => $languageDefaultFont, - 'templateName' => $mailLayout->getName(), - 'templateModuleName' => $mailLayout->getModuleName(), - 'locale' => $language->getLocale(), - ]); - - //This hook allows to change the variables of a layout - $this->hookDispatcher->dispatchWithParameters( - LayoutVariablesBuilderInterface::BUILD_MAIL_LAYOUT_VARIABLES_HOOK, - [ - 'mailLayout' => $mailLayout, - 'mailLayoutVariables' => &$mailLayoutVariables, - ] - ); - - return $mailLayoutVariables; - } -} diff --git a/src/Core/MailTemplate/Layout/LayoutVariablesBuilderInterface.php b/src/Core/MailTemplate/Layout/LayoutVariablesBuilderInterface.php deleted file mode 100644 index 6180abb4..00000000 --- a/src/Core/MailTemplate/Layout/LayoutVariablesBuilderInterface.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate\Layout; - -use PrestaShop\PrestaShop\Core\Language\LanguageInterface; - -/** - * LayoutVariablesBuilderInterface is used by the MailTemplateRendererInterface - * to render the mails, it returns an array of generic layout variables like: - * - templateModuleName: name of the associated module - * - languageIsRTL: is the language read from Right To Left - * - locale: the locale in which the template is generated - * - emailPublicWebRoot: public mail root for assets - */ -interface LayoutVariablesBuilderInterface -{ - const BUILD_MAIL_LAYOUT_VARIABLES_HOOK = 'actionBuildMailLayoutVariables'; - - /** - * @param LayoutInterface $layout - * @param LanguageInterface $language - * - * @return array - */ - public function buildVariables(LayoutInterface $layout, LanguageInterface $language); -} diff --git a/src/Core/MailTemplate/MailTemplateGenerator.php b/src/Core/MailTemplate/MailTemplateGenerator.php deleted file mode 100644 index 61491e96..00000000 --- a/src/Core/MailTemplate/MailTemplateGenerator.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate; - -use PrestaShop\PrestaShop\Core\Exception\FileNotFoundException; -use PrestaShop\PrestaShop\Core\Language\LanguageInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\Layout\LayoutCollectionInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\Layout\LayoutInterface; -use Psr\Log\LoggerAwareTrait; -use Psr\Log\LoggerInterface; -use Psr\Log\NullLogger; -use Symfony\Component\Filesystem\Filesystem; - -/** - * Class MailTemplateGenerator iterates through the layouts in the provided theme, - * it uses the Renderer to display them (with the requested LanguageInterface) and - * then export them as template files in the specified output folder. - */ -class MailTemplateGenerator -{ - use LoggerAwareTrait; - - /** @var MailTemplateRendererInterface */ - private $renderer; - - /** @var Filesystem */ - private $fileSystem; - - /** - * @param MailTemplateRendererInterface $renderer - * @param LoggerInterface|null $logger - */ - public function __construct( - MailTemplateRendererInterface $renderer, - LoggerInterface $logger = null - ) { - $this->renderer = $renderer; - $this->logger = null !== $logger ? $logger : new NullLogger(); - $this->fileSystem = new Filesystem(); - } - - /** - * @param ThemeInterface $theme - * @param LanguageInterface $language - * @param string $coreOutputFolder - * @param string $modulesOutputFolder - * @param bool $overwriteTemplates [default=false] - * - * @throws FileNotFoundException - */ - public function generateTemplates( - ThemeInterface $theme, - LanguageInterface $language, - $coreOutputFolder, - $modulesOutputFolder, - $overwriteTemplates = false - ) { - if (!is_dir($coreOutputFolder)) { - throw new FileNotFoundException(sprintf('Invalid core output folder "%s"', $coreOutputFolder)); - } - - if (!is_dir($modulesOutputFolder)) { - throw new FileNotFoundException(sprintf('Invalid modules output folder "%s"', $modulesOutputFolder)); - } - - $this->logger->info(sprintf('Exporting mail with theme %s for language %s', $theme->getName(), $language->getName())); - $this->logger->info(sprintf('Core output folder: %s', $coreOutputFolder)); - $this->logger->info(sprintf('Modules output folder: %s', $modulesOutputFolder)); - - /** @var LayoutCollectionInterface $layouts */ - $layouts = $theme->getLayouts(); - /** @var LayoutInterface $layout */ - foreach ($layouts as $layout) { - if (!empty($layout->getModuleName())) { - $outputFolder = implode(DIRECTORY_SEPARATOR, [$modulesOutputFolder, $layout->getModuleName(), 'mails', $language->getIsoCode()]); - } else { - $outputFolder = implode(DIRECTORY_SEPARATOR, [$coreOutputFolder, $language->getIsoCode()]); - } - - //Generate HTML template - $htmlTemplatePath = $this->generateTemplatePath($layout, MailTemplateInterface::HTML_TYPE, $outputFolder); - if (!$this->fileSystem->exists($htmlTemplatePath) || $overwriteTemplates) { - $generatedTemplate = $this->renderer->renderHtml($layout, $language); - $this->fileSystem->dumpFile($htmlTemplatePath, $generatedTemplate); - $this->logger->info(sprintf('Generate html template %s at %s', $layout->getName(), $htmlTemplatePath)); - } - - //Generate TXT template - $txtTemplatePath = $this->generateTemplatePath($layout, MailTemplateInterface::TXT_TYPE, $outputFolder); - if (!$this->fileSystem->exists($txtTemplatePath) || $overwriteTemplates) { - $generatedTemplate = $this->renderer->renderTxt($layout, $language); - $this->fileSystem->dumpFile($txtTemplatePath, $generatedTemplate); - $this->logger->info(sprintf('Generate txt template %s at %s', $layout->getName(), $txtTemplatePath)); - } - } - } - - /** - * @param LayoutInterface $layout - * @param string $templateType - * @param string $outputFolder - * - * @return string - */ - private function generateTemplatePath(LayoutInterface $layout, $templateType, $outputFolder) - { - return implode(DIRECTORY_SEPARATOR, [$outputFolder, $layout->getName()]) . '.' . $templateType; - } -} diff --git a/src/Core/MailTemplate/MailTemplateInterface.php b/src/Core/MailTemplate/MailTemplateInterface.php deleted file mode 100644 index dbcb2830..00000000 --- a/src/Core/MailTemplate/MailTemplateInterface.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate; - -/** - * Interface MailTemplateInterface describe a mail template. A mail template - * is a static file (in html or txt format) used by the Mail class to send - * transactional emails. - */ -interface MailTemplateInterface -{ - const CORE_CATEGORY = 'core'; - const MODULES_CATEGORY = 'modules'; - - const HTML_TYPE = 'html'; - const TXT_TYPE = 'txt'; - - /** - * Whether the template is used by the core or modules - * - * @return string - */ - public function getCategory(); - - /** - * Whether the template is an html or txt type - * - * @return string - */ - public function getType(); - - /** - * Returns the absolute path to the template file. - * - * @return string - */ - public function getPath(); -} diff --git a/src/Core/MailTemplate/MailTemplateRendererInterface.php b/src/Core/MailTemplate/MailTemplateRendererInterface.php deleted file mode 100644 index 8e9ddbfb..00000000 --- a/src/Core/MailTemplate/MailTemplateRendererInterface.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate; - -use PrestaShop\PrestaShop\Core\Language\LanguageInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\Layout\LayoutInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\Transformation\TransformationInterface; - -/** - * MailTemplateRendererInterface is used to render a specific MailLayoutInterface - * with the specified LanguageInterface. - */ -interface MailTemplateRendererInterface -{ - const GET_MAIL_LAYOUT_TRANSFORMATIONS = 'actionGetMailLayoutTransformations'; - - /** - * @param LayoutInterface $layout - * @param LanguageInterface $language - * - * @return string - */ - public function renderTxt(LayoutInterface $layout, LanguageInterface $language); - - /** - * @param LayoutInterface $layout - * @param LanguageInterface $language - * - * @return string - */ - public function renderHtml(LayoutInterface $layout, LanguageInterface $language); - - /** - * Adds a transformer to the renderer, when template is rendered all transformers - * matching its type (html or txt) are applied to the output content. - * - * @param TransformationInterface $transformer - * - * @return $this - */ - public function addTransformation(TransformationInterface $transformer); -} diff --git a/src/Core/MailTemplate/MailThemeConfiguration.php b/src/Core/MailTemplate/MailThemeConfiguration.php deleted file mode 100644 index dfe5d70d..00000000 --- a/src/Core/MailTemplate/MailThemeConfiguration.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Exception\CoreException; -use PrestaShop\PrestaShop\Core\Exception\InvalidArgumentException; - -/** - * Class MailThemeConfiguration is used to save Mail Theme settings - * in "Design > Mail Theme" page. - */ -final class MailThemeConfiguration implements DataConfigurationInterface -{ - /** @var ConfigurationInterface */ - private $configuration; - - /** @var ThemeCatalogInterface */ - private $themeCatalog; - - /** - * @param ConfigurationInterface $configuration - * @param ThemeCatalogInterface $themeCatalog - */ - public function __construct( - ConfigurationInterface $configuration, - ThemeCatalogInterface $themeCatalog - ) { - $this->configuration = $configuration; - $this->themeCatalog = $themeCatalog; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'defaultTheme' => $this->configuration->get('PS_MAIL_THEME'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - $errors = []; - - try { - $this->validateConfiguration($configuration); - $this->configuration->set('PS_MAIL_THEME', $configuration['defaultTheme']); - } catch (CoreException $e) { - $errors[] = $e->getMessage(); - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - if (empty($configuration['defaultTheme'])) { - throw new InvalidArgumentException('Default theme can not be empty'); - } - - return null !== $this->themeCatalog->getByName($configuration['defaultTheme']); - } -} diff --git a/src/Core/MailTemplate/Theme.php b/src/Core/MailTemplate/Theme.php deleted file mode 100644 index 1bc9c387..00000000 --- a/src/Core/MailTemplate/Theme.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate; - -use PrestaShop\PrestaShop\Core\MailTemplate\Layout\LayoutCollection; -use PrestaShop\PrestaShop\Core\MailTemplate\Layout\LayoutCollectionInterface; - -/** - * Class MailTheme basic immutable implementation of MailThemeInterface. - */ -class Theme implements ThemeInterface -{ - /** @var string */ - private $name; - - /** - * @var LayoutCollectionInterface - */ - private $layouts; - - /** - * @param string $name - */ - public function __construct($name) - { - $this->name = $name; - $this->layouts = new LayoutCollection(); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * @return LayoutCollectionInterface - */ - public function getLayouts() - { - return $this->layouts; - } - - /** - * @param LayoutCollectionInterface $layouts - * - * @return $this - */ - public function setLayouts($layouts) - { - $this->layouts = $layouts; - - return $this; - } -} diff --git a/src/Core/MailTemplate/ThemeCatalogInterface.php b/src/Core/MailTemplate/ThemeCatalogInterface.php deleted file mode 100644 index a5187702..00000000 --- a/src/Core/MailTemplate/ThemeCatalogInterface.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate; - -use PrestaShop\PrestaShop\Core\Exception\InvalidArgumentException; - -/** - * Interface ThemeCatalogInterface is used to list the available themes to generate - * mail templates, each one containing its own layouts. Layouts are divided in two - * categories "core" and "modules" layouts. You can change the themes collection or - * modify a theme's layout collection via the hook: - * ThemeCatalogInterface::LIST_MAIL_THEMES_HOOK = actionListMailThemes - */ -interface ThemeCatalogInterface -{ - const LIST_MAIL_THEMES_HOOK = 'actionListMailThemes'; - - /** - * Returns the list of existing themes. - * - * @return ThemeCollectionInterface - */ - public function listThemes(); - - /** - * @param string $theme - * - * @throws InvalidArgumentException - * - * @return ThemeInterface - */ - public function getByName($theme); -} diff --git a/src/Core/MailTemplate/ThemeCollection.php b/src/Core/MailTemplate/ThemeCollection.php deleted file mode 100644 index fb78f11a..00000000 --- a/src/Core/MailTemplate/ThemeCollection.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate; - -use PrestaShop\PrestaShop\Core\Data\AbstractTypedCollection; - -/** - * Class MailThemeCollection is a collection of MailThemeInterface elements. - */ -class ThemeCollection extends AbstractTypedCollection implements ThemeCollectionInterface -{ - /** - * {@inheritdoc} - */ - protected function getType() - { - return ThemeInterface::class; - } - - /** - * @param string $themeName - * - * @return ThemeInterface|null - */ - public function getByName($themeName) - { - return $this->filter(function (ThemeInterface $theme) use ($themeName) { - return $themeName === $theme->getName(); - })->first(); - } -} diff --git a/src/Core/MailTemplate/ThemeCollectionInterface.php b/src/Core/MailTemplate/ThemeCollectionInterface.php deleted file mode 100644 index f8d26f00..00000000 --- a/src/Core/MailTemplate/ThemeCollectionInterface.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate; - -/** - * Interface ThemeCollectionInterface contains a list of themes to - * generate mail templates. Modules can add/remove their own through the hook: - * ThemeCatalogInterface::LIST_MAIL_THEMES_HOOK = actionListMailThemes - */ -interface ThemeCollectionInterface extends \IteratorAggregate, \Countable -{ - /** - * @param ThemeInterface $theme - * - * @return bool - */ - public function contains($theme); - - /** - * @param ThemeInterface $theme - */ - public function add($theme); - - /** - * @param ThemeInterface $theme - */ - public function remove($theme); - - /** - * @param string $themeName - * - * @return ThemeInterface|null - */ - public function getByName($themeName); -} diff --git a/src/Core/MailTemplate/ThemeInterface.php b/src/Core/MailTemplate/ThemeInterface.php deleted file mode 100644 index 5e8603f3..00000000 --- a/src/Core/MailTemplate/ThemeInterface.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate; - -use PrestaShop\PrestaShop\Core\MailTemplate\Layout\LayoutCollectionInterface; - -/** - * Interface MailThemeInterface is used to define mail templates - * themes. It is very simple for now (only a name) but it could evolve in - * the future (include a config, a parent theme, ...) - */ -interface ThemeInterface -{ - /** - * @return string - */ - public function getName(); - - /** - * @return LayoutCollectionInterface - */ - public function getLayouts(); -} diff --git a/src/Core/MailTemplate/Transformation/AbstractTransformation.php b/src/Core/MailTemplate/Transformation/AbstractTransformation.php deleted file mode 100644 index 05c4d453..00000000 --- a/src/Core/MailTemplate/Transformation/AbstractTransformation.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate\Transformation; - -use PrestaShop\PrestaShop\Core\Exception\InvalidArgumentException; -use PrestaShop\PrestaShop\Core\Language\LanguageInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\MailTemplateInterface; - -/** - * Class AbstractTransformation is a basic abstract class for TransformationInterface - */ -abstract class AbstractTransformation implements TransformationInterface -{ - /** @var LanguageInterface */ - protected $language; - - /** @var string */ - protected $type; - - /** - * @param string $type - * - * @throws InvalidArgumentException - */ - public function __construct($type) - { - $availableTypes = [ - MailTemplateInterface::HTML_TYPE, - MailTemplateInterface::TXT_TYPE, - ]; - if (!in_array($type, $availableTypes)) { - throw new InvalidArgumentException(sprintf('Invalid type %s, available types are: %s', $type, implode(', ', $availableTypes))); - } - - $this->type = $type; - } - - /** - * {@inheritdoc} - */ - public function getType() - { - return $this->type; - } - - /** - * {@inheritdoc} - */ - public function setLanguage(LanguageInterface $language) - { - $this->language = $language; - - return $this; - } -} diff --git a/src/Core/MailTemplate/Transformation/CSSInlineTransformation.php b/src/Core/MailTemplate/Transformation/CSSInlineTransformation.php deleted file mode 100644 index 878fe0e5..00000000 --- a/src/Core/MailTemplate/Transformation/CSSInlineTransformation.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate\Transformation; - -use DOMAttr; -use DOMElement; -use Pelago\Emogrifier; -use Pelago\Emogrifier\HtmlProcessor\CssToAttributeConverter; -use PrestaShop\PrestaShop\Core\MailTemplate\MailTemplateInterface; -use Symfony\Component\DomCrawler\Crawler; -use TijsVerkoyen\CssToInlineStyles\CssToInlineStyles; - -/** - * Class CSSInlineTransformation applies a transformation on html templates, it downloads - * each css files integrated in the template, and then applies them on the html inline-style. - * This is used for some mail readers which don't load css styles but can interpret them when - * set inline. - */ -class CSSInlineTransformation extends AbstractTransformation -{ - public function __construct() - { - parent::__construct(MailTemplateInterface::HTML_TYPE); - } - - /** - * {@inheritdoc} - */ - public function apply($templateContent, array $templateVariables) - { - if (MailTemplateInterface::HTML_TYPE != $this->type) { - return $templateContent; - } - - /** - * For unknown reason Emogrifier modifies href attribute with variables written - * like this {shop_url} so we temporarily change them to @shop_url@ - */ - $templateContent = preg_replace('/\{(\w+)\}/', '@\1@', $templateContent); - - $cssContent = $this->getCssContent($templateContent); - - $cssToInlineStyles = new CssToInlineStyles(); - $templateContent = $cssToInlineStyles->convert($templateContent, $cssContent); - - $converter = CssToAttributeConverter::fromHtml($templateContent); - $templateContent = $converter->convertCssToVisualAttributes()->render(); - - return preg_replace('/@(\w+)@/', '{\1}', $templateContent); - } - - /** - * @param string $templateContent - * - * @return string - */ - private function getCssContent($templateContent) - { - $crawler = new Crawler($templateContent); - $cssTags = $crawler->filter('link[type="text/css"]'); - $cssUrls = []; - /** @var DOMElement $cssTag */ - foreach ($cssTags as $cssTag) { - /** @var DOMAttr $hrefAttr */ - if ($hrefAttr = $cssTag->attributes->getNamedItem('href')) { - $cssUrls[] = $hrefAttr->nodeValue; - } - } - $cssContents = ''; - foreach ($cssUrls as $cssUrl) { - $cssContent = @file_get_contents($cssUrl); - if (!empty($cssContent)) { - $cssContents .= $cssContent; - } - } - - return $cssContents; - } -} diff --git a/src/Core/MailTemplate/Transformation/HTMLToTextTransformation.php b/src/Core/MailTemplate/Transformation/HTMLToTextTransformation.php deleted file mode 100644 index 688128ed..00000000 --- a/src/Core/MailTemplate/Transformation/HTMLToTextTransformation.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate\Transformation; - -use Html2Text\Html2Text; -use PrestaShop\PrestaShop\Core\MailTemplate\MailTemplateInterface; - -/** - * HTMLTextifyTransformation is used to remove any HTML tags from the template. It - * is especially useful when no txt layout is defined and the renderer uses the html - * layout as a base. This transformation then removes any html tags but keep the raw - * information. - */ -class HTMLToTextTransformation extends AbstractTransformation -{ - public function __construct() - { - parent::__construct(MailTemplateInterface::TXT_TYPE); - } - - /** - * {@inheritdoc} - */ - public function apply($templateContent, array $templateVariables) - { - $templateContent = Html2Text::convert($templateContent, true); - if (PHP_EOL != $templateContent[strlen($templateContent) - 1]) { - $templateContent .= PHP_EOL; - } - - return $templateContent; - } -} diff --git a/src/Core/MailTemplate/Transformation/MailVariablesTransformation.php b/src/Core/MailTemplate/Transformation/MailVariablesTransformation.php deleted file mode 100644 index 70d9752e..00000000 --- a/src/Core/MailTemplate/Transformation/MailVariablesTransformation.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate\Transformation; - -use PrestaShop\PrestaShop\Core\Exception\InvalidArgumentException; - -/** - * Class MailVariablesTransformation is used only for preview, it replaces the - * variables present in the mail templates (this replacement is usually performed - * by the Mail class in real behavior). - * You can set the variables using the actionBuildMailLayoutVariables and setting - * them in the `templateVars` key, or simply via the constructor. - */ -class MailVariablesTransformation extends AbstractTransformation -{ - /** - * @var array - */ - private $replaceVariables; - - /** - * @param string $type - * @param array $replaceVariables - * - * @throws InvalidArgumentException - */ - public function __construct($type, array $replaceVariables = []) - { - parent::__construct($type); - $this->replaceVariables = $replaceVariables; - } - - /** - * {@inheritdoc} - */ - public function apply($templateContent, array $templateVariables) - { - $replaceVariables = $this->replaceVariables; - if (!empty($templateVariables['templateVars'])) { - $replaceVariables = array_merge_recursive( - $replaceVariables, - $templateVariables['templateVars'] - ); - } - if (!empty($replaceVariables)) { - $templateContent = strtr($templateContent, $replaceVariables); - } - - return $templateContent; - } -} diff --git a/src/Core/MailTemplate/Transformation/TransformationCollection.php b/src/Core/MailTemplate/Transformation/TransformationCollection.php deleted file mode 100644 index 453de93c..00000000 --- a/src/Core/MailTemplate/Transformation/TransformationCollection.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate\Transformation; - -use PrestaShop\PrestaShop\Core\Data\AbstractTypedCollection; - -class TransformationCollection extends AbstractTypedCollection implements TransformationCollectionInterface -{ - /** - * {@inheritdoc} - */ - protected function getType() - { - return TransformationInterface::class; - } -} diff --git a/src/Core/MailTemplate/Transformation/TransformationCollectionInterface.php b/src/Core/MailTemplate/Transformation/TransformationCollectionInterface.php deleted file mode 100644 index 72861691..00000000 --- a/src/Core/MailTemplate/Transformation/TransformationCollectionInterface.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate\Transformation; - -/** - * TransformationCollectionInterface contains a list of transformations applied - * on mail templates when they are generated. - */ -interface TransformationCollectionInterface extends \IteratorAggregate, \Countable -{ - /** - * @param TransformationInterface $transformation - * - * @return bool - */ - public function contains($transformation); - - /** - * @param TransformationInterface $transformation - */ - public function add($transformation); - - /** - * @param TransformationInterface $transformation - */ - public function remove($transformation); -} diff --git a/src/Core/MailTemplate/Transformation/TransformationInterface.php b/src/Core/MailTemplate/Transformation/TransformationInterface.php deleted file mode 100644 index 5bf5bacc..00000000 --- a/src/Core/MailTemplate/Transformation/TransformationInterface.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MailTemplate\Transformation; - -use PrestaShop\PrestaShop\Core\Language\LanguageInterface; - -/** - * TransformationInterface is used by the MailTemplateRendererInterface to apply a - * transformation on the generated template (textify html, inline css, add a css or - * an image per language). - */ -interface TransformationInterface -{ - /** - * @param string $templateContent - * @param array $templateVariables - * - * @return string - */ - public function apply($templateContent, array $templateVariables); - - /** - * Returns the type of templates this transformation is associated with, - * either html or txt, so that the renderer knows if it has to be applied - * or not - * - * @return string - */ - public function getType(); - - /** - * @param LanguageInterface $language - * - * @return $this - */ - public function setLanguage(LanguageInterface $language); -} diff --git a/src/Core/MerchandiseReturn/Configuration/MerchandiseReturnOptionsConfiguration.php b/src/Core/MerchandiseReturn/Configuration/MerchandiseReturnOptionsConfiguration.php deleted file mode 100644 index ebd6e6f8..00000000 --- a/src/Core/MerchandiseReturn/Configuration/MerchandiseReturnOptionsConfiguration.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\MerchandiseReturn\Configuration; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; - -/** - * Provides data configuration for merchandise returns options form - */ -final class MerchandiseReturnOptionsConfiguration implements DataConfigurationInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'enable_order_return' => (bool) $this->configuration->get('PS_ORDER_RETURN'), - 'order_return_period_in_days' => (int) $this->configuration->get('PS_ORDER_RETURN_NB_DAYS'), - 'order_return_prefix' => $this->configuration->get('PS_RETURN_PREFIX'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - $errors = []; - - if (!$this->validateConfiguration($configuration)) { - $errors[] = [ - 'key' => 'Invalid configuration', - 'parameters' => [], - 'domain' => 'Admin.Notifications.Warning', - ]; - } else { - $this->configuration->set('PS_ORDER_RETURN', $configuration['enable_order_return']); - $this->configuration->set('PS_ORDER_RETURN_NB_DAYS', $configuration['order_return_period_in_days']); - $this->configuration->set('PS_RETURN_PREFIX', $configuration['order_return_prefix']); - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset($configuration['enable_order_return']); - } -} diff --git a/src/Core/Meta/MetaDataProviderInterface.php b/src/Core/Meta/MetaDataProviderInterface.php deleted file mode 100644 index 182c6c59..00000000 --- a/src/Core/Meta/MetaDataProviderInterface.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Meta; - -/** - * Interface MetaDataProviderInterface defines contract fot MetaDataProvider. - */ -interface MetaDataProviderInterface -{ - /** - * Gets id by page. - * - * @param string $pageName - * - * @return int - */ - public function getIdByPage($pageName); - - /** - * Gets default page by meta id. - * - * @param int $metaId - * - * @return string|null - */ - public function getDefaultMetaPageNameById($metaId); - - /** - * Gets module page by meta id. - * - * @param int $metaId - * - * @return string|null - */ - public function getModuleMetaPageNameById($metaId); - - /** - * Gets default pages which are not configured in Seo & urls page. - * - * @return array - */ - public function getDefaultMetaPageNamesExcludingFilled(); - - /** - * Gets module pages which are not configured in Seo & urls page. - * - * @return array - */ - public function getNotConfiguredModuleMetaPageNames(); -} diff --git a/src/Core/Module/Configuration/PaymentRestrictionsConfigurator.php b/src/Core/Module/Configuration/PaymentRestrictionsConfigurator.php deleted file mode 100644 index 9694ecb3..00000000 --- a/src/Core/Module/Configuration/PaymentRestrictionsConfigurator.php +++ /dev/null @@ -1,202 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Module\Configuration; - -use Doctrine\DBAL\Connection; -use PrestaShop\PrestaShop\Core\Module\DataProvider\PaymentModuleListProviderInterface; - -/** - * Class PaymentRestrictionsConfigurator is responsible for configuring restrictions for payment modules. - */ -final class PaymentRestrictionsConfigurator implements PaymentRestrictionsConfiguratorInterface -{ - /** - * @var Connection - */ - private $connection; - - /** - * @var string - */ - private $databasePrefix; - - /** - * @var int - */ - private $shopId; - - /** - * @var PaymentModuleListProviderInterface - */ - private $paymentModuleProvider; - - /** - * @param Connection $connection - * @param string $databasePrefix - * @param int $shopId - * @param PaymentModuleListProviderInterface $paymentModuleProvider - */ - public function __construct( - Connection $connection, - $databasePrefix, - $shopId, - PaymentModuleListProviderInterface $paymentModuleProvider - ) { - $this->connection = $connection; - $this->databasePrefix = $databasePrefix; - $this->shopId = $shopId; - $this->paymentModuleProvider = $paymentModuleProvider; - } - - /** - * {@inheritdoc} - */ - public function configureCurrencyRestrictions(array $currencyRestrictions) - { - $this->configureRestrictions('currency', $currencyRestrictions); - } - - /** - * {@inheritdoc} - */ - public function configureCountryRestrictions(array $countryRestrictions) - { - $this->configureRestrictions('country', $countryRestrictions); - } - - /** - * {@inheritdoc} - */ - public function configureGroupRestrictions(array $groupRestrictions) - { - $this->configureRestrictions('group', $groupRestrictions); - } - - /** - * {@inheritdoc} - */ - public function configureCarrierRestrictions(array $carrierRestrictions) - { - $this->configureRestrictions('carrier', $carrierRestrictions); - } - - /** - * @param string $restrictionType - * @param array $restrictions - */ - private function configureRestrictions($restrictionType, array $restrictions) - { - list($moduleIds, $newConfiguration) = $this->parseRestrictionData($restrictions); - - $this->clearCurrentConfiguration($restrictionType, $moduleIds); - $this->insertNewConfiguration($restrictionType, $newConfiguration); - } - - /** - * Clear current configuration for given restriction type. - * - * @param string $restrictionType - * @param int[] $moduleIds - * - * @return int - */ - private function clearCurrentConfiguration($restrictionType, array $moduleIds) - { - $clearSql = ' - DELETE FROM ' . $this->getTableNameForRestriction($restrictionType) . ' - WHERE id_shop = ' . (int) $this->shopId . ' AND id_module IN (' . implode(',', array_map('intval', $moduleIds)) . ') - '; - - return $this->connection->executeUpdate($clearSql); - } - - /** - * Insert new configuration for given restriction type. - * - * @param string $restrictionType - * @param array $newConfiguration - */ - private function insertNewConfiguration($restrictionType, $newConfiguration) - { - if (!empty($newConfiguration)) { - $fieldName = 'carrier' === $restrictionType ? 'reference' : $restrictionType; - - $this->connection->executeUpdate(' - INSERT INTO `' . $this->getTableNameForRestriction($restrictionType) . '` - (`id_module`, `id_shop`, `id_' . $fieldName . '`) - VALUES ' . implode(',', $newConfiguration)); - } - } - - /** - * Get table name for module restrictions. - * - * @param string $restrictionType - * - * @return string - */ - private function getTableNameForRestriction($restrictionType) - { - return $this->databasePrefix . 'module_' . $restrictionType; - } - - /** - * Parse data from restrictions. - * - * @param array $restrictions - * - * @return array - */ - private function parseRestrictionData(array $restrictions) - { - $moduleIds = []; - $insertValues = []; - - $paymentModules = $this->paymentModuleProvider->getPaymentModuleList(); - - foreach ($restrictions as $moduleName => $restriction) { - if (isset($paymentModules[$moduleName])) { - $moduleId = $paymentModules[$moduleName]->database->get('id'); - - $moduleIds[] = $moduleId; - - if (!is_array($restriction)) { - $restriction = [$restriction]; - } - - foreach ($restriction as $restrictionValues) { - $insertValues[] = '(' . (int) $moduleId . ', ' . (int) $this->shopId . ', ' . (int) $restrictionValues . ')'; - } - } - } - - return [ - $moduleIds, - $insertValues, - ]; - } -} diff --git a/src/Core/Module/Configuration/PaymentRestrictionsConfiguratorInterface.php b/src/Core/Module/Configuration/PaymentRestrictionsConfiguratorInterface.php deleted file mode 100644 index ffe24d5f..00000000 --- a/src/Core/Module/Configuration/PaymentRestrictionsConfiguratorInterface.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Module\Configuration; - -/** - * Interface PaymentRestrictionsConfigurator defines contract for payment module restrications configurator. - */ -interface PaymentRestrictionsConfiguratorInterface -{ - /** - * Configure payment module restrictions for currencies. - * - * @param array $currencyRestrictions - * - * @return bool - */ - public function configureCurrencyRestrictions(array $currencyRestrictions); - - /** - * Configure payment module restrictions for countries. - * - * @param array $countryRestrictions - * - * @return bool - */ - public function configureCountryRestrictions(array $countryRestrictions); - - /** - * Configure payment module restrictions for customer groups. - * - * @param array $groupRestrictions - * - * @return bool - */ - public function configureGroupRestrictions(array $groupRestrictions); - - /** - * Configure payment module restrictions for carriers. - * - * @param array $groupRestrictions - * - * @return bool - */ - public function configureCarrierRestrictions(array $groupRestrictions); -} diff --git a/src/Core/Module/DataProvider/PaymentModuleListProviderInterface.php b/src/Core/Module/DataProvider/PaymentModuleListProviderInterface.php deleted file mode 100644 index 6287383f..00000000 --- a/src/Core/Module/DataProvider/PaymentModuleListProviderInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Module\DataProvider; - -/** - * Interface PaymentModuleProviderInterface defines contract for payment module list provider. - */ -interface PaymentModuleListProviderInterface -{ - /** - * Get payment module data. - * - * @return array - */ - public function getPaymentModuleList(); -} diff --git a/src/Core/Module/DataProvider/TabModuleListProviderInterface.php b/src/Core/Module/DataProvider/TabModuleListProviderInterface.php deleted file mode 100644 index d2b74585..00000000 --- a/src/Core/Module/DataProvider/TabModuleListProviderInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Module\DataProvider; - -/** - * Interface TabModuleListProviderInterface defines contract for tab module provider. - */ -interface TabModuleListProviderInterface -{ - /** - * Get tab modules. - * - * @param string $tabClassName - * - * @return array - */ - public function getTabModules($tabClassName); -} diff --git a/src/Core/Module/Exception/ModuleErrorException.php b/src/Core/Module/Exception/ModuleErrorException.php deleted file mode 100644 index 37b7c1b7..00000000 --- a/src/Core/Module/Exception/ModuleErrorException.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Module\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Default module error implementation - * The message of this exception will be displayed to the end-user - * - * You can use it in a module hooked on a Symfony page - */ -class ModuleErrorException extends CoreException implements ModuleErrorInterface -{ -} diff --git a/src/Core/Module/Exception/ModuleErrorInterface.php b/src/Core/Module/Exception/ModuleErrorInterface.php deleted file mode 100644 index 0549d2b6..00000000 --- a/src/Core/Module/Exception/ModuleErrorInterface.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Module\Exception; - -/** - * If an exception that implements this ModuleErrorInterface - * is thrown, its message will be displayed to the end-user - */ -interface ModuleErrorInterface -{ -} diff --git a/src/Core/Module/HookConfigurator.php b/src/Core/Module/HookConfigurator.php deleted file mode 100644 index 2bc5a84e..00000000 --- a/src/Core/Module/HookConfigurator.php +++ /dev/null @@ -1,118 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Module; - -class HookConfigurator -{ - private $hookRepository; - - public function __construct(HookRepository $hookRepository) - { - $this->hookRepository = $hookRepository; - } - - /** - * $hooks is a hook configuration description - * as found in theme.yml, - * it has a format like: - * [ - * "someHookName" => [ - * null, - * "blockstuff", - * "othermodule" - * ], - * "someOtherHookName" => [ - * null, - * "blockmenu" => [ - * "except_pages" => ["category", "product"] - * ] - * ] - * ]. - */ - public function getThemeHooksConfiguration(array $hooks) - { - $hooks = array_filter($hooks, 'is_array'); - $uniqueModuleList = $this->getUniqueModuleToHookList($hooks); - $currentHooks = $this->hookRepository->getDisplayHooksWithModules(); - - foreach ($currentHooks as $hookName => $moduleList) { - foreach ($moduleList as $key => $value) { - if (in_array($value, $uniqueModuleList)) { - unset($currentHooks[$hookName][$key]); - } - } - } - - foreach ($hooks as $hookName => $modules) { - $firstNullValueFound = true; - $existing = isset($currentHooks[$hookName]) ? - $currentHooks[$hookName] : - []; - $currentHooks[$hookName] = []; - foreach ($modules as $key => $module) { - if ($module === null && $firstNullValueFound) { - $firstNullValueFound = false; - foreach ($existing as $m) { - $currentHooks[$hookName][] = $m; - } - } elseif (is_array($module)) { - $currentHooks[$hookName][$key] = $module; - } elseif ($module !== null) { - $currentHooks[$hookName][] = $module; - } - } - } - - return $currentHooks; - } - - public function setHooksConfiguration(array $hooks) - { - $this->hookRepository->persistHooksConfiguration( - $this->getThemeHooksConfiguration($hooks) - ); - - return $this; - } - - public function addHook($name, $title, $description) - { - $this->hookRepository->createHook($name, $title, $description); - - return $this; - } - - private function getUniqueModuleToHookList(array $hooks) - { - $list = []; - foreach ($hooks as $modules) { - $list = array_merge($list, $modules); - } - - return $list; - } -} diff --git a/src/Core/Module/HookRepository.php b/src/Core/Module/HookRepository.php deleted file mode 100644 index 3c23ac6d..00000000 --- a/src/Core/Module/HookRepository.php +++ /dev/null @@ -1,262 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Module; - -use Db; -use Exception; -use PrestaShop\PrestaShop\Adapter\Hook\HookInformationProvider; -use Shop; - -class HookRepository -{ - private $hookInfo; - private $shop; - private $db; - private $db_prefix; - - public function __construct( - HookInformationProvider $hookInfo, - Shop $shop, - Db $db - ) { - $this->hookInfo = $hookInfo; - $this->shop = $shop; - $this->db = $db; - $this->db_prefix = $db->getPrefix(); - } - - public function getIdByName($hook_name) - { - $escaped_hook_name = $this->db->escape($hook_name); - - $id_hook = $this->db->getValue( - "SELECT id_hook FROM {$this->db_prefix}hook WHERE name = '$escaped_hook_name'" - ); - - return (int) $id_hook; - } - - public function createHook($hook_name, $title = '', $description = '', $position = 1) - { - $this->db->insert('hook', [ - 'name' => $this->db->escape($hook_name), - 'title' => $this->db->escape($title), - 'description' => $this->db->escape($description), - 'position' => $this->db->escape($position), - ], false, true, Db::REPLACE); - - return $this->getIdByName($hook_name); - } - - private function getIdModule($module_name) - { - $escaped_module_name = $this->db->escape($module_name); - - $id_module = $this->db->getValue( - "SELECT id_module FROM {$this->db_prefix}module WHERE name = '$escaped_module_name'" - ); - - return (int) $id_module; - } - - public function unHookModulesFromHook($hook_name) - { - $id_hook = $this->getIdByName($hook_name); - $id_shop = (int) $this->shop->id; - - $this->db->execute("DELETE FROM {$this->db_prefix}hook_module - WHERE id_hook = $id_hook AND id_shop = $id_shop - "); - - $this->db->execute("DELETE FROM {$this->db_prefix}hook_module_exceptions - WHERE id_hook = $id_hook AND id_shop = $id_shop - "); - - return $this; - } - - /** - * Saves hook settings for a list of hooks. - * The $hooks array should have this format: - * [ - * "hookName" => [ - * "module1", - * "module2", - * "module3" => [ - * "except_pages" => [ - * "page1", - * "page2", - * "page3" - * ] - * ] - * ] - * ] - * Only hooks present as keys in the $hooks array are affected and all changes - * are only done for the shop this Repository belongs to. - */ - public function persistHooksConfiguration(array $hooks) - { - foreach ($hooks as $hook_name => $module_names) { - $id_hook = $this->getIdByName($hook_name); - if (!$id_hook) { - $id_hook = $this->createHook($hook_name); - } - if (!$id_hook) { - throw new Exception(sprintf('Could not create hook `%1$s`.', $hook_name)); - } - - $this->unHookModulesFromHook($hook_name); - - $position = 0; - foreach ($module_names as $key => $module) { - if (is_array($module)) { - $module_name = key($module); - $extra_data = current($module); - } else { - $module_name = $module; - $extra_data = []; - } - - ++$position; - $id_module = $this->getIdModule($module_name); - if (!$id_module) { - continue; - } - - $row = [ - 'id_module' => $id_module, - 'id_shop' => (int) $this->shop->id, - 'id_hook' => $id_hook, - 'position' => $position, - ]; - - $this->db->insert('hook_module', $row); - - if (!empty($extra_data['except_pages'])) { - $this->setModuleHookExceptions( - $id_module, - $id_hook, - $extra_data['except_pages'] - ); - } - } - } - - return $this; - } - - private function setModuleHookExceptions($id_module, $id_hook, array $pages) - { - $id_shop = (int) $this->shop->id; - $id_module = (int) $id_module; - $id_hook = (int) $id_hook; - - $this->db->execute("DELETE FROM {$this->db_prefix}hook_module_exceptions - WHERE id_shop = $id_shop - AND id_module = $id_module - AND id_hook = $id_hook - "); - - foreach ($pages as $page) { - $this->db->insert('hook_module_exceptions', [ - 'id_shop' => $id_shop, - 'id_module' => $id_module, - 'id_hook' => $id_hook, - 'file_name' => $page, - ]); - } - - return $this; - } - - private function getModuleHookExceptions($id_module, $id_hook) - { - $id_shop = (int) $this->shop->id; - $id_module = (int) $id_module; - $id_hook = (int) $id_hook; - - $rows = $this->db->executeS("SELECT file_name - FROM {$this->db_prefix}hook_module_exceptions - WHERE id_shop = $id_shop - AND id_module = $id_module - AND id_hook = $id_hook - ORDER BY file_name ASC - "); - - return array_map(function ($row) { - return $row['file_name']; - }, $rows); - } - - public function getHooksWithModules() - { - $id_shop = (int) $this->shop->id; - - $sql = "SELECT h.name as hook_name, h.id_hook, m.name as module_name, m.id_module - FROM {$this->db_prefix}hook_module hm - INNER JOIN {$this->db_prefix}hook h - ON h.id_hook = hm.id_hook - INNER JOIN {$this->db_prefix}module m - ON m.id_module = hm.id_module - WHERE hm.id_shop = $id_shop - ORDER BY h.name ASC, hm.position ASC - "; - - $rows = $this->db->executeS($sql); - - $hooks = []; - - foreach ($rows as $row) { - $exceptions = $this->getModuleHookExceptions( - $row['id_module'], - $row['id_hook'] - ); - - if (empty($exceptions)) { - $hooks[$row['hook_name']][] = $row['module_name']; - } else { - $hooks[$row['hook_name']][$row['module_name']] = [ - 'except_pages' => $exceptions, - ]; - } - } - - return $hooks; - } - - public function getDisplayHooksWithModules() - { - $hooks = []; - foreach ($this->getHooksWithModules() as $hook_name => $modules) { - if ($this->hookInfo->isDisplayHookName($hook_name)) { - $hooks[$hook_name] = $modules; - } - } - - return $hooks; - } -} diff --git a/src/Core/Module/ModuleInterface.php b/src/Core/Module/ModuleInterface.php deleted file mode 100644 index eb654dba..00000000 --- a/src/Core/Module/ModuleInterface.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Module; - -/** - * Define what should be a module. - * Note:We don't typeHint on old Module class to not create hard dependency with Legacy. - */ -interface ModuleInterface -{ -} diff --git a/src/Core/Module/WidgetInterface.php b/src/Core/Module/WidgetInterface.php deleted file mode 100644 index 7e65768b..00000000 --- a/src/Core/Module/WidgetInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Module; - -interface WidgetInterface -{ - public function renderWidget($hookName, array $configuration); - - public function getWidgetVariables($hookName, array $configuration); -} diff --git a/src/Core/Multistore/MultistoreConfig.php b/src/Core/Multistore/MultistoreConfig.php deleted file mode 100644 index 22c99b84..00000000 --- a/src/Core/Multistore/MultistoreConfig.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Multistore; - -/** - * Class MultistoreConfig. - */ -class MultistoreConfig -{ - /** - * Name of configuration for Multistore feature status in ps_configuration table. - */ - const FEATURE_STATUS = 'PS_MULTISHOP_FEATURE_ACTIVE'; -} diff --git a/src/Core/Multistore/MultistoreContextCheckerInterface.php b/src/Core/Multistore/MultistoreContextCheckerInterface.php deleted file mode 100644 index f1e70a85..00000000 --- a/src/Core/Multistore/MultistoreContextCheckerInterface.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Multistore; - -/** - * Interface MultistoreContextCheckerInterface. - */ -interface MultistoreContextCheckerInterface -{ - /** - * Check if current shop is in single store context. - * - * @return bool - */ - public function isAllShopContext(); - - /** - * Check if current shop is in "Group" shop context. - * - * @return bool - */ - public function isGroupShopContext(); - - /** - * Check if current shop is in "Single" shop context. - * - * @return bool - */ - public function isSingleShopContext(); -} diff --git a/src/Core/Order/InvoiceInterface.php b/src/Core/Order/InvoiceInterface.php deleted file mode 100644 index 364fd780..00000000 --- a/src/Core/Order/InvoiceInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Order; - -interface InvoiceInterface -{ - /** - * Return collection of Invoice. - * - * @param string $dateFrom Date From - * @param string $dateTo Date To - * - * @return array[InvoiceLegacy] - */ - public static function getByDeliveryDateInterval($dateFrom, $dateTo); -} diff --git a/src/Core/Order/OrderInvoiceDataProviderInterface.php b/src/Core/Order/OrderInvoiceDataProviderInterface.php deleted file mode 100644 index bcef91e3..00000000 --- a/src/Core/Order/OrderInvoiceDataProviderInterface.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Order; - -use DateTimeInterface; - -/** - * Interface OrderInvoiceDataProviderInterface defines OrderInvoice data provider. - */ -interface OrderInvoiceDataProviderInterface -{ - /** - * Returns all the order invoices that match the date interval. - * - * @param DateTimeInterface $dateFrom - * @param DateTimeInterface $dateTo - * - * @return array collection of OrderInvoice objects - */ - public function getByDateInterval(DateTimeInterface $dateFrom, DateTimeInterface $dateTo); - - /** - * Returns all the order invoices by given status. - * - * @param int $orderStateId - * - * @return array collection of OrderInvoice objects - */ - public function getByStatus($orderStateId); - - /** - * Returns the next available invoice number. - * - * @return int - */ - public function getNextInvoiceNumber(); -} diff --git a/src/Core/Order/OrderSiblingProviderInterface.php b/src/Core/Order/OrderSiblingProviderInterface.php deleted file mode 100644 index cd95b817..00000000 --- a/src/Core/Order/OrderSiblingProviderInterface.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Order; - -interface OrderSiblingProviderInterface -{ - /** - * @param int $orderId - * - * @return int returns previous order id or 0 if it does not exist - */ - public function getNextOrderId(int $orderId): int; - - /** - * @param int $orderId - * - * @return int returns next order id or 0 if it does not exist - */ - public function getPreviousOrderId(int $orderId): int; -} diff --git a/src/Core/Order/OrderStateDataProviderInterface.php b/src/Core/Order/OrderStateDataProviderInterface.php deleted file mode 100644 index bd77f29f..00000000 --- a/src/Core/Order/OrderStateDataProviderInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Order; - -/** - * Interface OrderStateDataProviderInterface defines OrderState data provider. - */ -interface OrderStateDataProviderInterface -{ - /** - * Get order states in given language. - * - * @param int $languageId - * - * @return array - */ - public function getOrderStates($languageId); -} diff --git a/src/Core/PDF/Exception/MissingDataException.php b/src/Core/PDF/Exception/MissingDataException.php deleted file mode 100644 index a2eaba4a..00000000 --- a/src/Core/PDF/Exception/MissingDataException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\PDF\Exception; - -/** - * Thrown when required data for pdf generating is missing - */ -class MissingDataException extends PdfException -{ -} diff --git a/src/Core/PDF/Exception/PdfException.php b/src/Core/PDF/Exception/PdfException.php deleted file mode 100644 index 480e36fa..00000000 --- a/src/Core/PDF/Exception/PdfException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\PDF\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Base exception for PDF generation related exceptions - */ -class PdfException extends CoreException -{ -} diff --git a/src/Core/PDF/PDFGeneratorInterface.php b/src/Core/PDF/PDFGeneratorInterface.php deleted file mode 100644 index 6af1fad0..00000000 --- a/src/Core/PDF/PDFGeneratorInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\PDF; - -/** - * Interface PDFGeneratorInterface defines a PDF generator. - */ -interface PDFGeneratorInterface -{ - /** - * Generates PDF out of given object and template using legacy generator. - * - * @param array $objectCollection collection of objects - */ - public function generatePDF(array $objectCollection); -} diff --git a/src/Core/PDF/PDFTemplateTypeProviderInterface.php b/src/Core/PDF/PDFTemplateTypeProviderInterface.php deleted file mode 100644 index e3adb796..00000000 --- a/src/Core/PDF/PDFTemplateTypeProviderInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\PDF; - -/** - * Interface PDFDataProviderInterface describes a PDF template type provider. - */ -interface PDFTemplateTypeProviderInterface -{ - /** - * Gets PDF template type. - * - * @return string - */ - public function getPDFTemplateType(); -} diff --git a/src/Core/Payment/PaymentModulePreferencesConfiguration.php b/src/Core/Payment/PaymentModulePreferencesConfiguration.php deleted file mode 100644 index 44616f36..00000000 --- a/src/Core/Payment/PaymentModulePreferencesConfiguration.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Payment; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\Module\Configuration\PaymentRestrictionsConfiguratorInterface; -use PrestaShop\PrestaShop\Core\Module\DataProvider\PaymentModuleListProviderInterface; - -/** - * Class PaymentModulePreferencesConfiguration is responsible for configuring payment module restrictions. - */ -final class PaymentModulePreferencesConfiguration implements DataConfigurationInterface -{ - /** - * @var PaymentModuleListProviderInterface - */ - private $paymentModuleProvider; - - /** - * @var PaymentRestrictionsConfiguratorInterface - */ - private $paymentRestrictionsConfigurator; - - /** - * @param PaymentModuleListProviderInterface $paymentModuleProvider - * @param PaymentRestrictionsConfiguratorInterface $paymentRestrictionsConfigurator - */ - public function __construct( - PaymentModuleListProviderInterface $paymentModuleProvider, - PaymentRestrictionsConfiguratorInterface $paymentRestrictionsConfigurator - ) { - $this->paymentModuleProvider = $paymentModuleProvider; - $this->paymentRestrictionsConfigurator = $paymentRestrictionsConfigurator; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - $config = []; - $paymentModules = $this->paymentModuleProvider->getPaymentModuleList(); - - foreach ($paymentModules as $paymentModule) { - $config['currency_restrictions'][$paymentModule->get('name')] = $paymentModule->get('currencies'); - $config['country_restrictions'][$paymentModule->get('name')] = $paymentModule->get('countries'); - $config['group_restrictions'][$paymentModule->get('name')] = $paymentModule->get('groups'); - $config['carrier_restrictions'][$paymentModule->get('name')] = $paymentModule->get('carriers'); - } - - return $config; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $config) - { - $errors = []; - - if ($this->validateConfiguration($config)) { - $this->paymentRestrictionsConfigurator->configureCurrencyRestrictions($config['currency_restrictions']); - $this->paymentRestrictionsConfigurator->configureCountryRestrictions($config['country_restrictions']); - $this->paymentRestrictionsConfigurator->configureGroupRestrictions($config['group_restrictions']); - $this->paymentRestrictionsConfigurator->configureCarrierRestrictions($config['carrier_restrictions']); - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $config) - { - return isset( - $config['currency_restrictions'], - $config['country_restrictions'], - $config['group_restrictions'], - $config['carrier_restrictions'] - ); - } -} diff --git a/src/Core/Payment/PaymentOption.php b/src/Core/Payment/PaymentOption.php deleted file mode 100644 index 298065ff..00000000 --- a/src/Core/Payment/PaymentOption.php +++ /dev/null @@ -1,374 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Payment; - -use PrestaShopBundle\Service\Hook\HookContentClassInterface; - -/** - * We define 4 types of payment options:. - * - * - the "offline" kind: simple URL to call + information to display (e.g. bankwire, cheque) - * - the "external" kind: simple URL to call, but payment processed on PSP's website (e.g. simple paypal) - * - the "embedded" kind: you write your credit card info in a form that is on your site and not inside an iframe (e.g. stripe) - * - the "iframe" kind: payment form is displayed on your website but inside an iframe (e.g. atos) - */ -class PaymentOption implements HookContentClassInterface -{ - /** - * This text will be displayed - * in the payment option selection widget. - * - * @var string - */ - private $callToActionText; - - /** - * Additional information to display to the customer. - * This is free HTML, and may be used by modules such as - * bankwire to display to which account the bank transfer should be made. - * - * @var string - */ - private $additionalInformation; - - /** - * The URL to a picture to display in the - * payment option selection widget. - * - * @var string - */ - private $logo; - - /** - * The URL to which the request to process the - * payment must be made. - * - * @var string - */ - private $action; - - /** - * An associative array of additional parameters to use when sending - * the request to $action, - * e.g. if $action is "http://payment-provider.example.com/process", - * $method is "GET" - * and $inputs is ['customerName' => 'bob'] - * then the request will be made to: - * "http://payment-provider.example.com/process?customerName=bob". - * - * @var array - */ - private $inputs; - - /** - * Custom HTML to display e.g. a form where - * you write your credit card number. - * The HTML MUST NOT contain a submit button, as - * the Core will submit the form. - * - * @var string - */ - private $form; - - /** - * Custom HTML containing an iframe with the - * payment confirmation widget for modules like ATOS. - * - * @var string - */ - private $iframe; - - /** - * For internal reasons, the name of the module - * that provided this option. - * Is this still necessary? - * - * @var string - */ - private $moduleName; - - /** - * Was the module form generated by binaries ? - * - * @var bool - */ - private $binary; - - /** - * Return Call to Action Text. - * - * @return string - */ - public function getCallToActionText() - { - return $this->callToActionText; - } - - /** - * Set Call To Action Text. - * - * @param $callToActionText - * - * @return $this - */ - public function setCallToActionText($callToActionText) - { - $this->callToActionText = $callToActionText; - - return $this; - } - - /** - * Return Additional Information. - * - * @return string - */ - public function getAdditionalInformation() - { - return $this->additionalInformation; - } - - /** - * Set Additional Information. - * - * @param $additionalInformation - * - * @return $this - */ - public function setAdditionalInformation($additionalInformation) - { - $this->additionalInformation = $additionalInformation; - - return $this; - } - - /** - * Return logo path. - * - * @return string - */ - public function getLogo() - { - return $this->logo; - } - - /** - * Set logo path. - * - * @param $logo - * - * @return $this - */ - public function setLogo($logo) - { - $this->logo = $logo; - - return $this; - } - - /** - * Return action to perform (POST/GET). - * - * @return string - */ - public function getAction() - { - return $this->action; - } - - /** - * Set action to be performed by this option. - * - * @param $action - * - * @return $this - */ - public function setAction($action) - { - $this->action = $action; - - return $this; - } - - /** - * Return inputs contained in this payment option. - * - * @return mixed - */ - public function getInputs() - { - return $this->inputs; - } - - /** - * Set inputs for this payment option. - * - * @param $inputs - * - * @return $this - */ - public function setInputs($inputs) - { - $this->inputs = $inputs; - - return $this; - } - - /** - * Get payment option form. - * - * @return mixed - */ - public function getForm() - { - return $this->form; - } - - /** - * Set payment option form. - * - * @param $form - * - * @return $this - */ - public function setForm($form) - { - $this->form = $form; - - return $this; - } - - /** - * Get related module name to this payment option. - * - * @return string - */ - public function getModuleName() - { - return $this->moduleName; - } - - /** - * Set related module name to this payment option. - * - * @param $moduleName - * - * @return $this - */ - public function setModuleName($moduleName) - { - $this->moduleName = $moduleName; - - return $this; - } - - /** - * Was the module form generated by - * binaries ? - * - * @return bool - */ - public function isBinary() - { - return $this->binary; - } - - /** - * Set if the form was generated by binaries. - * - * @param $binary - * - * @return $this - */ - public function setBinary($binary) - { - $this->binary = $binary; - - return $this; - } - - public function toArray() - { - return [ - 'module_name' => $this->moduleName, - 'binary' => $this->binary, - 'action' => $this->action, - 'form' => $this->form, - 'inputs' => $this->inputs, - 'logo' => $this->logo, - 'additionalInformation' => $this->additionalInformation, - 'call_to_action_text' => $this->callToActionText, - ]; - } - - /** - * Legacy options were specified this way: - * - either an array with a top level property 'cta_text' and then the other properties - * - or a numerically indexed array or arrays as described above. - * - * Since this was a mess, this method is provided to convert them. - * It takes as input a legacy option (in either form) and always - * returns an array of instances of PrestaShop\PrestaShop\Core\Payment\PaymentOption - */ - public static function convertLegacyOption(array $legacyOption) - { - if (!$legacyOption) { - return; - } - - if (array_key_exists('cta_text', $legacyOption)) { - $legacyOption = [$legacyOption]; - } - - $newOptions = []; - - $defaults = [ - 'additionalInformation' => null, - 'action' => null, - 'form' => null, - 'method' => null, - 'inputs' => [], - 'logo' => null, - ]; - - foreach ($legacyOption as $option) { - $option = array_merge($defaults, $option); - - $newOption = new self(); - $newOption->setCallToActionText($option['cta_text']) - ->setAdditionalInformation($option['additionalInformation']) - ->setAction($option['action']) - ->setForm($option['form']) - ->setInputs($option['inputs']) - ->setLogo($option['logo']); - - $newOptions[] = $newOption; - } - - return $newOptions; - } -} diff --git a/src/Core/Payment/PaymentOptionFormDecorator.php b/src/Core/Payment/PaymentOptionFormDecorator.php deleted file mode 100644 index f429f06d..00000000 --- a/src/Core/Payment/PaymentOptionFormDecorator.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Payment; - -use DOMDocument; - -class PaymentOptionFormDecorator -{ - public function addHiddenSubmitButton($formHTML, $optionId) - { - $doc = new DOMDocument(); - $doc->encoding = 'UTF-8'; - - $doc->loadHTML('' . $formHTML); - - $forms = $doc->getElementsByTagName('form'); - if ($forms->length !== 1) { - return false; - } - - $hiddenSubmitButton = $doc->createElement('button'); - - $styleAttr = $doc->createAttribute('style'); - $styleAttr->value = 'display:none'; - - $idAttr = $doc->createAttribute('id'); - $idAttr->value = 'pay-with-' . $optionId; - - $typeAttr = $doc->createAttribute('type'); - $typeAttr->value = 'submit'; - - $hiddenSubmitButton->appendChild($styleAttr); - $hiddenSubmitButton->appendChild($idAttr); - $hiddenSubmitButton->appendChild($typeAttr); - - $forms->item(0)->appendChild($hiddenSubmitButton); - - $body = $doc->getElementsByTagName('body')->item(0); - $html = ''; - - foreach ($body->childNodes as $node) { - $html .= $doc->saveHTML($node); - } - - return $html; - } -} diff --git a/src/Core/Product/ProductAdminDrawer.php b/src/Core/Product/ProductAdminDrawer.php deleted file mode 100644 index afb029ec..00000000 --- a/src/Core/Product/ProductAdminDrawer.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product; - -use PrestaShopBundle\Service\Hook\HookContentClassInterface; - -class ProductAdminDrawer implements HookContentClassInterface -{ - /** - * Material icon reference to display above the title. - * - * @var string - */ - protected $icon; - - /** - * ID suffix to add in the generated DOM element. - * - * @var string - */ - protected $id; - - /** - * Destination of the link. - * - * @var string - */ - protected $link; - - /** - * Title of the button. Should be short. - * - * @var string - */ - protected $title; - - public function __construct(array $data = []) - { - if (!empty($data['icon'])) { - $this->setIcon($data['icon']); - } - if (!empty($data['id'])) { - $this->setId($data['id']); - } - if (!empty($data['link'])) { - $this->setLink($data['link']); - } - if (!empty($data['title'])) { - $this->setTitle($data['title']); - } - } - - public function getIcon() - { - return $this->icon; - } - - public function getId() - { - return $this->id; - } - - public function getLink() - { - return $this->link; - } - - public function getTitle() - { - return $this->title; - } - - public function setIcon($icon) - { - $this->icon = $icon; - - return $this; - } - - public function setId($id) - { - $this->id = $id; - - return $this; - } - - public function setLink($link) - { - $this->link = $link; - - return $this; - } - - public function setTitle($title) - { - $this->title = $title; - - return $this; - } - - public function toArray() - { - return [ - 'icon' => $this->icon, - 'id' => $this->id, - 'link' => $this->link, - 'title' => $this->title, - ]; - } -} diff --git a/src/Core/Product/ProductCsvExporter.php b/src/Core/Product/ProductCsvExporter.php deleted file mode 100644 index 9720a6cf..00000000 --- a/src/Core/Product/ProductCsvExporter.php +++ /dev/null @@ -1,112 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product; - -use PrestaShopBundle\Component\CsvResponse; -use PrestaShopBundle\Service\DataProvider\Admin\ProductInterface as ProductDataProviderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Used to export list of Products in CSV in the Product list page. - * For internal use only. - */ -final class ProductCsvExporter implements ProductExporterInterface -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ProductDataProviderInterface - */ - private $productProvider; - - public function __construct(TranslatorInterface $translator, ProductDataProviderInterface $productProvider) - { - $this->translator = $translator; - $this->productProvider = $productProvider; - } - - /** - * In this specific case, we don't need to pass a products list. - * - * @param array $products - * - * @return CsvResponse - * - * @throws \InvalidArgumentException - * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException - */ - public function export(array $products = []) - { - $productProvider = $this->productProvider; - $persistedFilterParameters = $productProvider->getPersistedFilterParameters(); - $orderBy = $persistedFilterParameters['last_orderBy']; - $sortOrder = $persistedFilterParameters['last_sortOrder']; - - // prepare callback to fetch data from DB - $dataCallback = function ($offset, $limit) use ($productProvider, $orderBy, $sortOrder) { - return $productProvider->getCatalogProductList($offset, $limit, $orderBy, $sortOrder, [], true, false); - }; - - $headersData = [ - 'id_product' => 'Product ID', - 'image_link' => $this->trans('Image', 'Admin.Global'), - 'name' => $this->trans('Name', 'Admin.Global'), - 'reference' => $this->trans('Reference', 'Admin.Global'), - 'name_category' => $this->trans('Category', 'Admin.Global'), - 'price' => $this->trans('Price (tax excl.)', 'Admin.Catalog.Feature'), - 'price_final' => $this->trans('Price (tax incl.)', 'Admin.Catalog.Feature'), - 'sav_quantity' => $this->trans('Quantity', 'Admin.Global'), - 'badge_danger' => $this->trans('Status', 'Admin.Global'), - 'position' => $this->trans('Position', 'Admin.Global'), - ]; - - return (new CsvResponse()) - ->setData($dataCallback) - ->setHeadersData($headersData) - ->setModeType(CsvResponse::MODE_OFFSET) - ->setLimit(5000) - ->setFileName('product_' . date('Y-m-d_His') . '.csv'); - } - - /** - * Translator helper. - * - * @param $key - * @param $domain - * - * @return string - * - * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException - */ - private function trans($key, $domain) - { - return $this->translator->trans($key, [], $domain); - } -} diff --git a/src/Core/Product/ProductExporterInterface.php b/src/Core/Product/ProductExporterInterface.php deleted file mode 100644 index 5dc39228..00000000 --- a/src/Core/Product/ProductExporterInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product; - -use Symfony\Component\HttpFoundation\Response; - -/** - * Allow the export of a list of products. - */ -interface ProductExporterInterface -{ - /** - * @param array $products - * - * @return Response - */ - public function export(array $products); -} diff --git a/src/Core/Product/ProductExtraContent.php b/src/Core/Product/ProductExtraContent.php deleted file mode 100644 index b9935376..00000000 --- a/src/Core/Product/ProductExtraContent.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product; - -use PrestaShopBundle\Service\Hook\HookContentClassInterface; - -class ProductExtraContent implements HookContentClassInterface -{ - /** - * Title of the content. This can be used in the template - * e.g as a tab name or an anchor. - * - * @var string - */ - private $title; - - /** - * Content in HTML to display. - * This is the main attribute of this class. - * - * @var string - */ - private $content; - - /** - * For some reason, you may need to have a class on the div generated, - * or to be able to set an anchor. - * - * @var array - */ - private $attr = [ - 'id' => '', - 'class' => '', - ]; - - public function getTitle() - { - return $this->title; - } - - public function getContent() - { - return $this->content; - } - - public function getAttr() - { - return $this->attr; - } - - public function setTitle($title) - { - $this->title = $title; - - return $this; - } - - public function setContent($content) - { - $this->content = $content; - - return $this; - } - - public function addAttr($attr) - { - $this->attr = array_merge($this->attr, $attr); - - return $this; - } - - public function setAttr($attr) - { - // We declare default values for if and class which - // could be mandatory in the template - $this->attr = array_merge([ - 'id' => '', - 'class' => '', - ], $attr); - - return $this; - } - - public function toArray() - { - return [ - 'title' => $this->title, - 'content' => $this->content, - 'attr' => $this->attr, - ]; - } -} diff --git a/src/Core/Product/ProductExtraContentFinder.php b/src/Core/Product/ProductExtraContentFinder.php deleted file mode 100644 index f42d592d..00000000 --- a/src/Core/Product/ProductExtraContentFinder.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product; - -use PrestaShopBundle\Service\Hook\HookFinder; - -/** - * This class gets the extra content to display on the product page - * from the modules hooked on displayProductExtraContent. - */ -class ProductExtraContentFinder extends HookFinder -{ - protected $hookName = 'displayProductExtraContent'; - protected $expectedInstanceClasses = ['PrestaShop\PrestaShop\Core\Product\ProductExtraContent']; - - /** - * Execute hook to get all addionnal product content, and check if valid - * (not empty and only instances of class ProductExtraContent). - * - * @return array - * - * @throws \Exception - */ - public function find() - { - // Check first that we have a product to send as params - if (!array_key_exists('product', $this->params) || !$this->params['product'] instanceof \Product) { - throw new \Exception('Required product param not found.'); - } - - return parent::find(); - } -} diff --git a/src/Core/Product/ProductInterface.php b/src/Core/Product/ProductInterface.php deleted file mode 100644 index d83a0b8c..00000000 --- a/src/Core/Product/ProductInterface.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product; - -interface ProductInterface -{ - const REDIRECT_TYPE_CATEGORY_MOVED_PERMANENTLY = '301-category'; - const REDIRECT_TYPE_CATEGORY_FOUND = '302-category'; - const REDIRECT_TYPE_PRODUCT_MOVED_PERMANENTLY = '301-product'; - const REDIRECT_TYPE_PRODUCT_FOUND = '302-product'; - const REDIRECT_TYPE_NOT_FOUND = '404'; -} diff --git a/src/Core/Product/ProductListingPresenter.php b/src/Core/Product/ProductListingPresenter.php deleted file mode 100644 index a9b6a158..00000000 --- a/src/Core/Product/ProductListingPresenter.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product; - -/** - * @deprecated since 1.7.4.0 - * @see \PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductListingPresenter - * - * Class ProductListingPresenter - */ -class ProductListingPresenter extends \PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductListingPresenter -{ -} diff --git a/src/Core/Product/ProductPresentationSettings.php b/src/Core/Product/ProductPresentationSettings.php deleted file mode 100644 index 99d3eb3b..00000000 --- a/src/Core/Product/ProductPresentationSettings.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product; - -class ProductPresentationSettings -{ - public $catalog_mode; - public $catalog_mode_with_prices; - public $restricted_country_mode; - public $include_taxes; - public $allow_add_variant_to_cart_from_listing; - public $stock_management_enabled; - public $showPrices; - public $lastRemainingItems; - - public function shouldShowPrice() - { - return $this->showPrices && (!$this->catalog_mode || $this->catalog_mode_with_prices); - } -} diff --git a/src/Core/Product/ProductPresenter.php b/src/Core/Product/ProductPresenter.php deleted file mode 100644 index c39643ed..00000000 --- a/src/Core/Product/ProductPresenter.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product; - -/** - * @deprecated since 1.7.4.0 - * @see \PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductPresenter - * - * Class ProductPresenter - */ -class ProductPresenter extends \PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductPresenter -{ -} diff --git a/src/Core/Product/Search/Exception/InvalidSortOrderDirectionException.php b/src/Core/Product/Search/Exception/InvalidSortOrderDirectionException.php deleted file mode 100644 index 24173dfa..00000000 --- a/src/Core/Product/Search/Exception/InvalidSortOrderDirectionException.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product\Search\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Thrown when sort order direction is not valid - */ -class InvalidSortOrderDirectionException extends CoreException -{ - /** - * @param string $direction the invalid direction - */ - public function __construct($direction) - { - $message = sprintf( - 'Invalid SortOrder direction `%s`. Expecting one of: `ASC`, `DESC`, or `RANDOM`.', - $direction - ); - - parent::__construct($message, 0, null); - } -} diff --git a/src/Core/Product/Search/Facet.php b/src/Core/Product/Search/Facet.php deleted file mode 100644 index 94d7c533..00000000 --- a/src/Core/Product/Search/Facet.php +++ /dev/null @@ -1,233 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product\Search; - -/** - * We call a facet a set of filters combined with logical operators. - */ -class Facet -{ - /** - * @var string the facet label - */ - private $label = ''; - - /** - * @var string the facet type - */ - private $type = ''; - - /** - * @var bool if true, the facet is displayed - */ - private $displayed = true; - - /** - * @var array the facet properties - */ - private $properties = []; - - /** - * @var array the facet filters - */ - private $filters = []; - - /** - * @var bool if true, allows the multiple selection - */ - private $multipleSelectionAllowed = true; - - /** - * @var string the widget type - */ - private $widgetType = 'radio'; - - /** - * @return array an array representation of the facet - */ - public function toArray() - { - return [ - 'label' => $this->label, - 'displayed' => $this->displayed, - 'type' => $this->type, - 'properties' => $this->properties, - 'filters' => array_map(function (Filter $filter) { - return $filter->toArray(); - }, $this->filters), - 'multipleSelectionAllowed' => $this->multipleSelectionAllowed, - 'widgetType' => $this->widgetType, - ]; - } - - /** - * @param string $label the facet label - * - * @return $this - */ - public function setLabel($label) - { - $this->label = $label; - - return $this; - } - - /** - * @return string the facet label - */ - public function getLabel() - { - return $this->label; - } - - /** - * @param string $type the facet type - * - * @return $this - */ - public function setType($type) - { - $this->type = $type; - - return $this; - } - - /** - * @return string the facet type - */ - public function getType() - { - return $this->type; - } - - /** - * @param string $name the facet property name - * @param mixed $value the facet property value - * - * @return $this - */ - public function setProperty($name, $value) - { - $this->properties[$name] = $value; - - return $this; - } - - /** - * @param string $name the facet property name - * - * @return mixed|null - */ - public function getProperty($name) - { - if (!array_key_exists($name, $this->properties)) { - return null; - } - - return $this->properties[$name]; - } - - /** - * @param Filter $filter the facet filter - * - * @return $this - */ - public function addFilter(Filter $filter) - { - $this->filters[] = $filter; - - return $this; - } - - /** - * @return array the list of facet filters - */ - public function getFilters() - { - return $this->filters; - } - - /** - * @param bool $isAllowed allows/disallows the multiple selection - * - * @return $this - */ - public function setMultipleSelectionAllowed($isAllowed = true) - { - $this->multipleSelectionAllowed = $isAllowed; - - return $this; - } - - /** - * @return bool returns true if multiple selection is allowed - */ - public function isMultipleSelectionAllowed() - { - return $this->multipleSelectionAllowed; - } - - /** - * @param bool $displayed sets the display of the facet - * - * @return $this - */ - public function setDisplayed($displayed = true) - { - $this->displayed = $displayed; - - return $this; - } - - /** - * @return bool returns true if the facet is displayed - */ - public function isDisplayed() - { - return $this->displayed; - } - - /** - * @param string $widgetType sets the widget type of the facet - * - * @return $this - */ - public function setWidgetType($widgetType) - { - $this->widgetType = $widgetType; - - return $this; - } - - /** - * @return string returns the facet widget type - */ - public function getWidgetType() - { - return $this->widgetType; - } -} diff --git a/src/Core/Product/Search/FacetCollection.php b/src/Core/Product/Search/FacetCollection.php deleted file mode 100644 index 56fe02f7..00000000 --- a/src/Core/Product/Search/FacetCollection.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product\Search; - -/** - * Stores a list of facets. - */ -class FacetCollection -{ - /** - * @var array the list of facets - */ - private $facets = []; - - /** - * @param Facet $facet the facet to add - * - * @return $this - */ - public function addFacet(Facet $facet) - { - $this->facets[] = $facet; - - return $this; - } - - /** - * @param array $facets the facets to add - * - * @return $this - */ - public function setFacets(array $facets) - { - $this->facets = []; - foreach ($facets as $facet) { - $this->addFacet($facet); - } - - return $this; - } - - /** - * @return array returns the list of facets - */ - public function getFacets() - { - return $this->facets; - } -} diff --git a/src/Core/Product/Search/FacetsRendererInterface.php b/src/Core/Product/Search/FacetsRendererInterface.php deleted file mode 100644 index 2d619955..00000000 --- a/src/Core/Product/Search/FacetsRendererInterface.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product\Search; - -/** - * Define how we render facets and active filters. - */ -interface FacetsRendererInterface -{ - /** - * @param ProductSearchContext $context - * @param ProductSearchResult $result - * - * @return string HTML content is expected here - */ - public function renderFacets( - ProductSearchContext $context, - ProductSearchResult $result - ); - - /** - * @param ProductSearchContext $context - * @param ProductSearchResult $result - * - * @return string HTML content is expected here - */ - public function renderActiveFilters( - ProductSearchContext $context, - ProductSearchResult $result - ); -} diff --git a/src/Core/Product/Search/Filter.php b/src/Core/Product/Search/Filter.php deleted file mode 100644 index f5368668..00000000 --- a/src/Core/Product/Search/Filter.php +++ /dev/null @@ -1,254 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product\Search; - -class Filter -{ - /** - * @var string the filter label - */ - private $label = ''; - - /** - * @var string internal type, used by query logic - */ - private $type = ''; - - /** - * @var bool whether or not the filter is used in the query - */ - private $active = false; - - /** - * @var bool whether or not the filter is displayed - */ - private $displayed = true; - - /** - * @var array the filter properties - */ - private $properties = []; - - /** - * @var int the filter magnitude - */ - private $magnitude = 0; - - /** - * @var mixed the filter value - */ - private $value; - - /** - * @var array the filter next encoded facets - */ - private $nextEncodedFacets = []; - - /** - * @return array an array representation of the filter - */ - public function toArray() - { - return [ - 'label' => $this->label, - 'type' => $this->type, - 'active' => $this->active, - 'displayed' => $this->displayed, - 'properties' => $this->properties, - 'magnitude' => $this->magnitude, - 'value' => $this->value, - 'nextEncodedFacets' => $this->nextEncodedFacets, - ]; - } - - /** - * @param string $label the filter label - * - * @return $this - */ - public function setLabel($label) - { - $this->label = $label; - - return $this; - } - - /** - * @return string the filter label - */ - public function getLabel() - { - return $this->label; - } - - /** - * @param string $type the filter type - * - * @return $this - */ - public function setType($type) - { - $this->type = $type; - - return $this; - } - - /** - * @return string the filter type - */ - public function getType() - { - return $this->type; - } - - /** - * @param string $name the filter property name - * @param mixed $value the filter property value - * - * @return $this - */ - public function setProperty($name, $value) - { - $this->properties[$name] = $value; - - return $this; - } - - /** - * @param string $name the filter property name - * - * @return mixed|null - */ - public function getProperty($name) - { - if (!array_key_exists($name, $this->properties)) { - return null; - } - - return $this->properties[$name]; - } - - /** - * @param $value - * - * @return $this - */ - public function setValue($value) - { - $this->value = $value; - - return $this; - } - - /** - * @return mixed - */ - public function getValue() - { - return $this->value; - } - - /** - * @param int $magnitude the filter magnitude - * - * @return $this - */ - public function setMagnitude($magnitude) - { - $this->magnitude = (int) $magnitude; - - return $this; - } - - /** - * @return int the filter magnitude - */ - public function getMagnitude() - { - return $this->magnitude; - } - - /** - * @param bool $active sets the activation of the filter - * - * @return $this - */ - public function setActive($active = true) - { - $this->active = $active; - - return $this; - } - - /** - * @return bool returns true if the filter is active - */ - public function isActive() - { - return $this->active; - } - - /** - * @param bool $displayed sets the display of the filter - * - * @return $this - */ - public function setDisplayed($displayed = true) - { - $this->displayed = $displayed; - - return $this; - } - - /** - * @return bool returns true if the filter is displayed - */ - public function isDisplayed() - { - return $this->displayed; - } - - /** - * @param $nextEncodedFacets - * - * @return $this - */ - public function setNextEncodedFacets($nextEncodedFacets) - { - $this->nextEncodedFacets = $nextEncodedFacets; - - return $this; - } - - /** - * @return array - */ - public function getNextEncodedFacets() - { - return $this->nextEncodedFacets; - } -} diff --git a/src/Core/Product/Search/Pagination.php b/src/Core/Product/Search/Pagination.php deleted file mode 100644 index cbf6258b..00000000 --- a/src/Core/Product/Search/Pagination.php +++ /dev/null @@ -1,173 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product\Search; - -class Pagination -{ - /** - * @var int the total number of pages for this query - */ - private $pagesCount; - - /** - * @var int the index of the returned page - */ - private $page; - - /** - * @param int $pagesCount - * - * @return $this - */ - public function setPagesCount($pagesCount) - { - if (!is_int($pagesCount)) { - trigger_error(sprintf('Integer value is expected, got `%s`', gettype($pagesCount)), E_USER_NOTICE); - $pagesCount = (int) $pagesCount; - } - - $this->pagesCount = $pagesCount; - - return $this; - } - - /** - * @return int - */ - public function getPagesCount() - { - return $this->pagesCount; - } - - /** - * @param int $page - * - * @return $this - */ - public function setPage($page) - { - if (!is_int($page)) { - trigger_error(sprintf('Integer value is expected, got `%s`', gettype($page)), E_USER_NOTICE); - $page = (int) $page; - } - - $this->page = $page; - - return $this; - } - - /** - * @return int - */ - public function getPage() - { - return $this->page; - } - - /** - * @param $page - * @param string $type - * - * @return array - */ - private function buildPageLink($page, $type = 'page') - { - $current = $page === $this->getPage(); - - return [ - 'type' => $type, - 'page' => $page, - 'clickable' => !$current, - 'current' => $type === 'page' ? $current : false, - ]; - } - - /** - * @return array - */ - private function buildSpacer() - { - return [ - 'type' => 'spacer', - 'page' => null, - 'clickable' => false, - 'current' => false, - ]; - } - - /** - * @return array - */ - public function buildLinks() - { - $links = []; - - $addPageLink = function ($page) use (&$links) { - static $lastPage = null; - - if ($page < 1 || $page > $this->getPagesCount()) { - return; - } - - if (null !== $lastPage && $page > $lastPage + 1) { - $links[] = $this->buildSpacer(); - } - - if ($page !== $lastPage) { - $links[] = $this->buildPageLink($page); - } - - $lastPage = $page; - }; - - $boundaryContextLength = 1; - $pageContextLength = 3; - - $links[] = $this->buildPageLink(max(1, $this->getPage() - 1), 'previous'); - - for ($i = 0; $i < $boundaryContextLength; ++$i) { - $addPageLink(1 + $i); - } - - $start = max(1, $this->getPage() - (int) floor(($pageContextLength - 1) / 2)); - if ($start + $pageContextLength > $this->getPagesCount()) { - $start = $this->getPagesCount() - $pageContextLength + 1; - } - - for ($i = 0; $i < $pageContextLength; ++$i) { - $addPageLink($start + $i); - } - - for ($i = 0; $i < $boundaryContextLength; ++$i) { - $addPageLink($this->getPagesCount() - $boundaryContextLength + 1 + $i); - } - - $links[] = $this->buildPageLink(min($this->getPagesCount(), $this->getPage() + 1), 'next'); - - return $links; - } -} diff --git a/src/Core/Product/Search/ProductSearchContext.php b/src/Core/Product/Search/ProductSearchContext.php deleted file mode 100644 index f9904f8d..00000000 --- a/src/Core/Product/Search/ProductSearchContext.php +++ /dev/null @@ -1,142 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product\Search; - -use Context; - -class ProductSearchContext -{ - /** - * @var int the Shop id - */ - private $idShop; - - /** - * @var int the Language id - */ - private $idLang; - - /** - * @var int the Currency id - */ - private $idCurrency; - - /** - * @var int the Customer id - */ - private $idCustomer; - - public function __construct(Context $context = null) - { - if ($context) { - $this->idShop = $context->shop->id; - $this->idLang = $context->language->id; - $this->idCurrency = $context->currency->id; - $this->idCustomer = $context->customer->id; - } - } - - /** - * @param int $idShop - * - * @return $this - */ - public function setIdShop($idShop) - { - $this->idShop = $idShop; - - return $this; - } - - /** - * @return int the Product Search Shop id - */ - public function getIdShop() - { - return $this->idShop; - } - - /** - * @param int $idLang - * - * @return $this - */ - public function setIdLang($idLang) - { - $this->idLang = $idLang; - - return $this; - } - - /** - * @return int the Product Search Language id - */ - public function getIdLang() - { - return $this->idLang; - } - - /** - * @param int $idCurrency - * - * @return $this - */ - public function setIdCurrency($idCurrency) - { - $this->idCurrency = $idCurrency; - - return $this; - } - - /** - * @return int the Product Search Currency id - */ - public function getIdCurrency() - { - return $this->idCurrency; - } - - /** - * @param int $idCustomer - * - * @return $this - */ - public function setIdCustomer($idCustomer) - { - $this->idCustomer = $idCustomer; - - return $this; - } - - /** - * @return int the Product Search Customer id - */ - public function getIdCustomer() - { - return $this->idCustomer; - } -} diff --git a/src/Core/Product/Search/ProductSearchProviderInterface.php b/src/Core/Product/Search/ProductSearchProviderInterface.php deleted file mode 100644 index fefc5853..00000000 --- a/src/Core/Product/Search/ProductSearchProviderInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product\Search; - -/** - * Will define the query to execute in order to retrieve the list of products. - */ -interface ProductSearchProviderInterface -{ - /** - * @param ProductSearchContext $context - * @param ProductSearchQuery $query - * - * @return ProductSearchResult - */ - public function runQuery( - ProductSearchContext $context, - ProductSearchQuery $query - ); -} diff --git a/src/Core/Product/Search/ProductSearchQuery.php b/src/Core/Product/Search/ProductSearchQuery.php deleted file mode 100644 index f0b19925..00000000 --- a/src/Core/Product/Search/ProductSearchQuery.php +++ /dev/null @@ -1,294 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product\Search; - -/** - * Define the Product Query to execute according the the encoded facets. - */ -class ProductSearchQuery -{ - /** - * @var string - */ - private $queryType; - - /** - * @var int - */ - private $idCategory; - - /** - * @var int - */ - private $idManufacturer; - - /** - * @var int - */ - private $idSupplier; - - /** - * @var string - */ - private $searchString; - - /** - * @var string - */ - private $searchTag; - - /** - * @var array - */ - private $encodedFacets; - - /** - * A default that is multiple of 2, 3 and 4 should be OK for - * many layouts. - * - * @var int 12 is the best number ever - */ - private $resultsPerPage = 12; - - /** - * @var int - */ - private $page = 1; - - /** - * @var SortOrder - */ - private $sortOrder; - - /** - * ProductSearchQuery constructor. - */ - public function __construct() - { - $this->setSortOrder(new SortOrder('product', 'name', 'ASC')); - } - - /** - * @param string $queryType - * - * @return $this - */ - public function setQueryType($queryType) - { - $this->queryType = $queryType; - - return $this; - } - - /** - * @return string - */ - public function getQueryType() - { - return $this->queryType; - } - - /** - * @param $idCategory - * - * @return $this - */ - public function setIdCategory($idCategory) - { - $this->idCategory = $idCategory; - - return $this; - } - - /** - * @return int - */ - public function getIdCategory() - { - return $this->idCategory; - } - - /** - * @param $idManufacturer - * - * @return $this - */ - public function setIdManufacturer($idManufacturer) - { - $this->idManufacturer = $idManufacturer; - - return $this; - } - - /** - * @return int - */ - public function getIdManufacturer() - { - return $this->idManufacturer; - } - - /** - * @param $idSupplier - * - * @return $this - */ - public function setIdSupplier($idSupplier) - { - $this->idSupplier = $idSupplier; - - return $this; - } - - /** - * @return int - */ - public function getIdSupplier() - { - return $this->idSupplier; - } - - /** - * @param $resultsPerPage - * - * @return $this - */ - public function setResultsPerPage($resultsPerPage) - { - $this->resultsPerPage = (int) $resultsPerPage; - - return $this; - } - - /** - * @return int - */ - public function getResultsPerPage() - { - return $this->resultsPerPage; - } - - /** - * @param $page - * - * @return $this - */ - public function setPage($page) - { - $this->page = (int) $page; - - return $this; - } - - /** - * @return int - */ - public function getPage() - { - return $this->page; - } - - /** - * @param SortOrder $sortOrder - * - * @return $this - */ - public function setSortOrder(SortOrder $sortOrder) - { - $this->sortOrder = $sortOrder; - - return $this; - } - - /** - * @return SortOrder - */ - public function getSortOrder() - { - return $this->sortOrder; - } - - /** - * @param $searchString - * - * @return $this - */ - public function setSearchString($searchString) - { - $this->searchString = $searchString; - - return $this; - } - - /** - * @return string - */ - public function getSearchString() - { - return $this->searchString; - } - - /** - * @param $searchTag - * - * @return $this - */ - public function setSearchTag($searchTag) - { - $this->searchTag = $searchTag; - - return $this; - } - - /** - * @return string - */ - public function getSearchTag() - { - return $this->searchTag; - } - - /** - * @param array $encodedFacets - * - * @return $this - */ - public function setEncodedFacets($encodedFacets) - { - $this->encodedFacets = $encodedFacets; - - return $this; - } - - /** - * @return array - */ - public function getEncodedFacets() - { - return $this->encodedFacets; - } -} diff --git a/src/Core/Product/Search/ProductSearchResult.php b/src/Core/Product/Search/ProductSearchResult.php deleted file mode 100644 index 0ce02353..00000000 --- a/src/Core/Product/Search/ProductSearchResult.php +++ /dev/null @@ -1,191 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product\Search; - -class ProductSearchResult -{ - /** - * @var array - */ - private $products = []; - /** - * @var - */ - private $totalProductsCount; - /** - * @var - */ - private $facetCollection; - /** - * @var - */ - private $encodedFacets; - /** - * @var array - */ - private $availableSortOrders = []; - /** - * @var - */ - private $currentSortOrder; - - /** - * @param array $products - * - * @return $this - */ - public function setProducts(array $products) - { - $this->products = $products; - - return $this; - } - - /** - * @return array - */ - public function getProducts() - { - return $this->products; - } - - /** - * @param $totalProductsCount - * - * @return $this - */ - public function setTotalProductsCount($totalProductsCount) - { - $this->totalProductsCount = $totalProductsCount; - - return $this; - } - - /** - * @return mixed - */ - public function getTotalProductsCount() - { - return $this->totalProductsCount; - } - - /** - * @param FacetCollection $facetCollection - * - * @return $this - */ - public function setFacetCollection(FacetCollection $facetCollection) - { - $this->facetCollection = $facetCollection; - - return $this; - } - - /** - * @return FacetCollection - */ - public function getFacetCollection() - { - return $this->facetCollection; - } - - /** - * @param $encodedFacets - * - * @return $this - */ - public function setEncodedFacets($encodedFacets) - { - $this->encodedFacets = $encodedFacets; - - return $this; - } - - /** - * @return mixed - */ - public function getEncodedFacets() - { - return $this->encodedFacets; - } - - /** - * @param SortOrder $sortOrder - * - * @return $this - */ - public function addAvailableSortOrder(SortOrder $sortOrder) - { - $this->availableSortOrders[] = $sortOrder; - - return $this; - } - - /** - * @return array - */ - public function getAvailableSortOrders() - { - return $this->availableSortOrders; - } - - /** - * @param array $sortOrders - * - * @return $this - */ - public function setAvailableSortOrders(array $sortOrders) - { - $this->availableSortOrders = []; - - foreach ($sortOrders as $sortOrder) { - $this->addAvailableSortOrder($sortOrder); - } - - return $this; - } - - /** - * @param SortOrder $currentSortOrder - * - * @return $this - */ - public function setCurrentSortOrder(SortOrder $currentSortOrder) - { - $this->currentSortOrder = $currentSortOrder; - - return $this; - } - - /** - * @return mixed - */ - public function getCurrentSortOrder() - { - return $this->currentSortOrder; - } -} diff --git a/src/Core/Product/Search/SortOrder.php b/src/Core/Product/Search/SortOrder.php deleted file mode 100644 index 3f126d21..00000000 --- a/src/Core/Product/Search/SortOrder.php +++ /dev/null @@ -1,260 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product\Search; - -use PrestaShop\PrestaShop\Core\Product\Search\Exception\InvalidSortOrderDirectionException; - -/** - * This class define in which order the list of products will be sorted. - */ -class SortOrder -{ - /** - * @var string the SortOrder entity - */ - private $entity; - /** - * @var string the SortOrder field - */ - private $field; - /** - * @var string the SortOrder direction - */ - private $direction; - /** - * @var string string The SortOrder label - */ - private $label; - - /** - * SortOrder constructor. - * - * @param string $entity the SortOrder entity - * @param string $field the SortOrder field - * @param string $direction the SortOrder direction - * - * @throws Exception - */ - public function __construct($entity, $field, $direction = 'asc') - { - $this - ->setEntity($entity) - ->setField($field) - ->setDirection($direction); - } - - /** - * Will returns a new Sort Order with random direction. - * - * @return SortOrder - * - * @throws Exception - */ - public static function random() - { - return new static('', '', 'random'); - } - - /** - * @return bool if true, the Sort Order direction is random - */ - public function isRandom() - { - return $this->getDirection() === 'random'; - } - - /** - * @return array the array representation of a Sort Order - */ - public function toArray() - { - return [ - 'entity' => $this->entity, - 'field' => $this->field, - 'direction' => $this->direction, - 'label' => $this->label, - 'urlParameter' => $this->toString(), - ]; - } - - /** - * @return string the string representation of a Sort Order - */ - public function toString() - { - return "{$this->entity}.{$this->field}.{$this->direction}"; - } - - /** - * Creates a new Sort Order from string of this kind: {entity}.{field}.{direction}. - * - * @param string $sortOrderConfiguration the Sort Order configuration string - * - * @return SortOrder - * - * @throws Exception - */ - public static function newFromString($sortOrderConfiguration) - { - list($entity, $field, $direction) = explode('.', $sortOrderConfiguration); - - return new static($entity, $field, $direction); - } - - /** - * @param string $label the Sort Order label - * - * @return $this - */ - public function setLabel($label) - { - $this->label = $label; - - return $this; - } - - /** - * @return string the Sort Order label - */ - public function getLabel() - { - return $this->label; - } - - /** - * @param string $entity the Sort Order entity - * - * @return $this - */ - public function setEntity($entity) - { - $this->entity = $entity; - - return $this; - } - - /** - * @return string the Sort Order entity - */ - public function getEntity() - { - return $this->entity; - } - - /** - * @param string $field the Sort Order field - * - * @return $this - */ - public function setField($field) - { - $this->field = $field; - - return $this; - } - - /** - * @return string the Sort Order field - */ - public function getField() - { - return $this->field; - } - - /** - * @param string $direction - * - * @return string - * - * @throws Exception - */ - public function setDirection($direction) - { - $formattedDirection = strtolower($direction); - if (!in_array($formattedDirection, ['asc', 'desc', 'random'])) { - throw new InvalidSortOrderDirectionException($direction); - } - - $this->direction = $formattedDirection; - - return $this->direction; - } - - /** - * @return string the Sort Order direction - */ - public function getDirection() - { - return $this->direction; - } - - /** - * @return string returns the order way using legacy prefix - */ - private function getLegacyPrefix() - { - if ($this->entity === 'product') { - if ($this->field === 'name') { - return 'pl.'; - } elseif ($this->field === 'position') { - return 'cp.'; - } elseif ($this->field === 'manufacturer_name') { - $this->setField('name'); - - return 'm.'; - } else { - return 'p.'; - } - } elseif ($this->entity === 'manufacturer') { - return 'm.'; - } - } - - /** - * @param bool $prefix if true, relies on legacy prefix - * - * @return string - */ - public function toLegacyOrderBy($prefix = false) - { - if ($prefix) { - return $this->getLegacyPrefix() . $this->field; - } elseif ($this->entity === 'manufacturer' && $this->field === 'name') { - return 'manufacturer_name'; - } else { - return $this->field; - } - } - - /** - * @return string the legacy order way - */ - public function toLegacyOrderWay() - { - return $this->getDirection(); - } -} diff --git a/src/Core/Product/Search/SortOrderFactory.php b/src/Core/Product/Search/SortOrderFactory.php deleted file mode 100644 index 26e412a3..00000000 --- a/src/Core/Product/Search/SortOrderFactory.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product\Search; - -use Symfony\Component\Translation\TranslatorInterface; - -/** - * This class is not a factory but a provider of default Sort Orders. - * - * @deprecated since 1.7.6 and to be removed in the next major: use SortOrdersCollection:getDefaults instead. - */ -class SortOrderFactory -{ - /** - * @var TranslatorInterface the translator - */ - private $translator; - - public function __construct(TranslatorInterface $translator) - { - @trigger_error( - 'This class is deprecated since 1.7.6, use SortOrdersCollection::getDefaults instead.', - E_USER_DEPRECATED - ); - $this->translator = $translator; - } - - /** - * @return array - * - * @throws \Exception - */ - public function getDefaultSortOrders() - { - return (new SortOrdersCollection($this->translator))->getDefaults(); - } -} diff --git a/src/Core/Product/Search/SortOrdersCollection.php b/src/Core/Product/Search/SortOrdersCollection.php deleted file mode 100644 index f1beebd6..00000000 --- a/src/Core/Product/Search/SortOrdersCollection.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product\Search; - -use Symfony\Component\Translation\TranslatorInterface; - -/** - * This class provide the list of default Sort Orders. - */ -final class SortOrdersCollection -{ - /** - * @var TranslatorInterface the translator - */ - private $translator; - - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * @return array - * - * @throws \Exception - */ - public function getDefaults() - { - return [ - (new SortOrder('product', 'position', 'desc'))->setLabel( - $this->translator->trans('Relevance', [], 'Shop.Theme.Catalog') - ), - (new SortOrder('product', 'name', 'asc'))->setLabel( - $this->translator->trans('Name, A to Z', [], 'Shop.Theme.Catalog') - ), - (new SortOrder('product', 'name', 'desc'))->setLabel( - $this->translator->trans('Name, Z to A', [], 'Shop.Theme.Catalog') - ), - (new SortOrder('product', 'price', 'asc'))->setLabel( - $this->translator->trans('Price, low to high', [], 'Shop.Theme.Catalog') - ), - (new SortOrder('product', 'price', 'desc'))->setLabel( - $this->translator->trans('Price, high to low', [], 'Shop.Theme.Catalog') - ), - ]; - } -} diff --git a/src/Core/Product/Search/URLFragmentSerializer.php b/src/Core/Product/Search/URLFragmentSerializer.php deleted file mode 100644 index 8ebe5f8c..00000000 --- a/src/Core/Product/Search/URLFragmentSerializer.php +++ /dev/null @@ -1,131 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Product\Search; - -/** - * This class is a serializer for URL fragments. - */ -class URLFragmentSerializer -{ - /** - * @param array $fragment - * - * @return string - */ - public function serialize(array $fragment) - { - $parts = []; - foreach ($fragment as $key => $values) { - array_unshift($values, $key); - $parts[] = $this->serializeListOfStrings('-', '-', $values); - } - - return $this->serializeListOfStrings('/', '/', $parts); - } - - /** - * @param string $string - * - * @return array - */ - public function unserialize($string) - { - $fragment = []; - $parts = $this->unserializeListOfStrings('/', '/', $string); - foreach ($parts as $part) { - $values = $this->unserializeListOfStrings('-', '-', $part); - $key = array_shift($values); - $fragment[$key] = $values; - } - - return $fragment; - } - - /** - * @param string $separator the string separator - * @param string $escape the string escape - * @param array $list - * - * @return string - */ - private function serializeListOfStrings($separator, $escape, array $list) - { - return implode($separator, array_map(function ($item) use ($separator, $escape) { - return str_replace($separator, $escape . $separator, $item); - }, $list)); - } - - /** - * @param string $separator the string separator - * @param string $escape the string escape - * @param string $string the UTF8 string - * - * @return array - */ - private function unserializeListOfStrings($separator, $escape, $string) - { - $list = []; - $currentString = ''; - $escaping = false; - - // get UTF-8 chars, inspired from http://stackoverflow.com/questions/9438158/split-utf8-string-into-array-of-chars - $arrayOfCharacters = []; - preg_match_all('/./u', $string, $arrayOfCharacters); - $characters = $arrayOfCharacters[0]; - - foreach ($characters as $character) { - if ($escaping) { - if ($character === $separator || $character === $escape) { - $currentString .= $character; - } else { - $list[] = $currentString; - $currentString = $character; - } - $escaping = false; - } else { - if ($character === $escape) { - $escaping = true; - } elseif ($character === $separator) { - $list[] = $currentString; - $currentString = ''; - } else { - $currentString .= $character; - } - } - } - - if ($escaping) { - $currentString .= $escape; - } - - if ('' !== $currentString) { - $list[] = $currentString; - } - - return $list; - } -} diff --git a/src/Core/Proxy/CachedFileFinderProxy.php b/src/Core/Proxy/CachedFileFinderProxy.php deleted file mode 100644 index 7e910a2c..00000000 --- a/src/Core/Proxy/CachedFileFinderProxy.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Proxy; - -use PrestaShop\PrestaShop\Core\File\FileFinderInterface; - -/** - * Class CachedFileFinderProxy is a local cache proxy of file finder. - */ -final class CachedFileFinderProxy implements FileFinderInterface -{ - /** - * @var FileFinderInterface - */ - private $delegate; - - /** - * @var array - */ - private $filesCache; - - /** - * @param FileFinderInterface $delegate instance of file finder - */ - public function __construct(FileFinderInterface $delegate) - { - $this->delegate = $delegate; - } - - /** - * {@inheritdoc} - */ - public function find() - { - if (null === $this->filesCache) { - $this->filesCache = $this->delegate->find(); - } - - return $this->filesCache; - } -} diff --git a/src/Core/Repository/RepositoryInterface.php b/src/Core/Repository/RepositoryInterface.php deleted file mode 100644 index 7b1fdb24..00000000 --- a/src/Core/Repository/RepositoryInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Repository; - -/** - * Define the contract to access entities. - * - * A repository should only contains methods for querying the data. - */ -interface RepositoryInterface -{ - /** - * Returns the complete list of items. - * - * @return array - */ - public function findAll(); -} diff --git a/src/Core/Routing/EntityLinkBuilderFactory.php b/src/Core/Routing/EntityLinkBuilderFactory.php deleted file mode 100644 index 4dcd044c..00000000 --- a/src/Core/Routing/EntityLinkBuilderFactory.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Routing; - -use PrestaShop\PrestaShop\Core\Routing\Exception\BuilderNotFoundException; - -/** - * Class EntityLinkBuilderFactory is able to return the builder for an entity. - */ -class EntityLinkBuilderFactory -{ - /** - * @var EntityLinkBuilderInterface[] - */ - private $builders; - - /** - * @param array $builders - */ - public function __construct(array $builders) - { - $this->builders = $builders; - } - - /** - * @param string $entity - * - * @return EntityLinkBuilderInterface - * - * @throws BuilderNotFoundException - */ - public function getBuilderFor($entity) - { - foreach ($this->builders as $builder) { - if ($builder->canBuild($entity)) { - return $builder; - } - } - - throw new BuilderNotFoundException(sprintf('Can not find a builder for entity %s', $entity)); - } -} diff --git a/src/Core/Routing/EntityLinkBuilderInterface.php b/src/Core/Routing/EntityLinkBuilderInterface.php deleted file mode 100644 index 35166e3c..00000000 --- a/src/Core/Routing/EntityLinkBuilderInterface.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Routing; - -/** - * Interface EntityLinkBuilderInterface is able to build links for entities, like - * edit or view link. Each interface is able to say if it can manage a certain type - * of entity. - */ -interface EntityLinkBuilderInterface -{ - /** - * @param string $entity - * @param array $parameters - * - * @return string - */ - public function getViewLink($entity, array $parameters); - - /** - * @param string $entity - * @param array $parameters - * - * @return string - */ - public function getEditLink($entity, array $parameters); - - /** - * @param string $entity - * - * @return bool - */ - public function canBuild($entity); -} diff --git a/src/Core/Routing/Exception/BuilderNotFoundException.php b/src/Core/Routing/Exception/BuilderNotFoundException.php deleted file mode 100644 index 9204a8a5..00000000 --- a/src/Core/Routing/Exception/BuilderNotFoundException.php +++ /dev/null @@ -1,37 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Routing\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Class BuilderNotFoundException thrown when the factory can't find a builder - * matching with an entity. - */ -class BuilderNotFoundException extends CoreException -{ -} diff --git a/src/Core/Search/Builder/AbstractFiltersBuilder.php b/src/Core/Search/Builder/AbstractFiltersBuilder.php deleted file mode 100644 index 3a23e40a..00000000 --- a/src/Core/Search/Builder/AbstractFiltersBuilder.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Builder; - -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Basic abstract class for FiltersBuilder classes, able to store the filters_id - * from the config. - */ -abstract class AbstractFiltersBuilder implements FiltersBuilderInterface -{ - /** @var string */ - protected $filterId; - - /** - * {@inheritdoc} - */ - public function setConfig(array $config) - { - $this->filterId = isset($config['filter_id']) ? $config['filter_id'] : ''; - - return $this; - } - - /** - * {@inheritdoc} - */ - abstract public function buildFilters(Filters $filters = null); - - /** - * @param Filters|null $filters - * - * @return string - */ - protected function getFilterId(Filters $filters = null) - { - if (null === $filters) { - return $this->filterId; - } - - return $filters->getFilterId(); - } -} diff --git a/src/Core/Search/Builder/AbstractRepositoryFiltersBuilder.php b/src/Core/Search/Builder/AbstractRepositoryFiltersBuilder.php deleted file mode 100644 index 9bd3f7ec..00000000 --- a/src/Core/Search/Builder/AbstractRepositoryFiltersBuilder.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Builder; - -use PrestaShop\PrestaShop\Core\Employee\ContextEmployeeProviderInterface; -use PrestaShop\PrestaShop\Core\Search\ControllerAction; -use PrestaShopBundle\Entity\Repository\AdminFilterRepository; -use Symfony\Component\HttpFoundation\Request; - -/** - * Basic abstract class for filters related to the database, whether they need to persist - * or search for filters. It is created with all the necessary services and configuration - * including the context (employee + shop), and it can extract the filters matching from - * the config or the request (either via filter_id or via controller/action matching). - */ -abstract class AbstractRepositoryFiltersBuilder extends AbstractFiltersBuilder -{ - /** @var AdminFilterRepository */ - protected $adminFilterRepository; - - /** @var ContextEmployeeProviderInterface */ - protected $employeeProvider; - - /** @var int */ - protected $shopId; - - /** @var string */ - protected $controller; - - /** @var string */ - protected $action; - - /** - * @param AdminFilterRepository $adminFilterRepository - * @param ContextEmployeeProviderInterface $employeeProvider - * @param int $shopId - */ - public function __construct( - AdminFilterRepository $adminFilterRepository, - ContextEmployeeProviderInterface $employeeProvider, - $shopId - ) { - $this->adminFilterRepository = $adminFilterRepository; - $this->employeeProvider = $employeeProvider; - $this->shopId = $shopId; - } - - /** - * {@inheritdoc} - */ - public function setConfig(array $config) - { - $defaultController = $defaultAction = ''; - if (isset($config['request']) && $config['request'] instanceof Request) { - $request = $config['request']; - list($defaultController, $defaultAction) = ControllerAction::fromString($request->get('_controller')); - } - - $this->controller = isset($config['controller']) ? $config['controller'] : $defaultController; - $this->action = isset($config['action']) ? $config['action'] : $defaultAction; - - return parent::setConfig($config); - } -} diff --git a/src/Core/Search/Builder/ChainedFiltersBuilder.php b/src/Core/Search/Builder/ChainedFiltersBuilder.php deleted file mode 100644 index 9ec4535f..00000000 --- a/src/Core/Search/Builder/ChainedFiltersBuilder.php +++ /dev/null @@ -1,85 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Builder; - -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * This builder is used to compose other builders, it iterates through its builders - * set the config for all of them (each one can pick its own parameters), and when - * building iterates through them overriding the same Filters instance step by step. - * - * This allows to split every Filters building into separate classes and then compose - * them based on your needs. - */ -final class ChainedFiltersBuilder extends AbstractFiltersBuilder -{ - /** @var FiltersBuilderCollection */ - private $builders; - - /** - * @param array $builders Array of FiltersBuilderInterface - * - * @throws \PrestaShop\PrestaShop\Core\Exception\TypeException - */ - public function __construct(array $builders = []) - { - $this->builders = new FiltersBuilderCollection($builders); - } - - /** - * {@inheritdoc} - */ - public function setConfig(array $config) - { - parent::setConfig($config); - - /** @var FiltersBuilderInterface $builder */ - foreach ($this->builders as $builder) { - $builder->setConfig($config); - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function buildFilters(Filters $filters = null) - { - if (empty($this->builders)) { - return $filters; - } - - /** @var FiltersBuilderInterface $builder */ - foreach ($this->builders as $builder) { - $filters = $builder->buildFilters($filters); - } - - return $filters; - } -} diff --git a/src/Core/Search/Builder/ClassFiltersBuilder.php b/src/Core/Search/Builder/ClassFiltersBuilder.php deleted file mode 100644 index 0fd6eb1e..00000000 --- a/src/Core/Search/Builder/ClassFiltersBuilder.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Builder; - -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * This builder instantiate a filters object of the specified type using - * its default values for creation. - */ -final class ClassFiltersBuilder extends AbstractFiltersBuilder -{ - /** @var string */ - private $filtersClass; - - /** - * {@inheritdoc} - */ - public function setConfig(array $config) - { - if (isset($config['filters_class'])) { - $this->filtersClass = $config['filters_class']; - } - - return parent::setConfig($config); - } - - /** - * Build the filters with the class defined by filtersClass - * - * @param Filters|null $filters - * - * @return Filters - */ - public function buildFilters(Filters $filters = null) - { - if (null === $this->filtersClass) { - return $filters; - } - - /** @var array $defaultParameters */ - $defaultParameters = call_user_func([$this->filtersClass, 'getDefaults']); - if (null !== $filters) { - /** @var Filters $typedFilters */ - $typedFilters = new $this->filtersClass($filters->all(), $filters->getFilterId()); - $typedFilters->add($defaultParameters); - } else { - $typedFilters = new $this->filtersClass($defaultParameters, $this->filterId); - } - - return $typedFilters; - } -} diff --git a/src/Core/Search/Builder/EventFiltersBuilder.php b/src/Core/Search/Builder/EventFiltersBuilder.php deleted file mode 100644 index e2b0afab..00000000 --- a/src/Core/Search/Builder/EventFiltersBuilder.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Builder; - -use PrestaShop\PrestaShop\Core\Search\Filters; -use PrestaShopBundle\Event\FilterSearchCriteriaEvent; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * This builder is used to allow modification of the built filters via - * a symfony event prestashop.search_criteria.filter (used to change the - * generic building process in some edge cases) - * - * @see FilterCategorySearchCriteriaListener - */ -final class EventFiltersBuilder extends AbstractFiltersBuilder -{ - /** @var EventDispatcherInterface */ - private $dispatcher; - - /** - * @param EventDispatcherInterface $dispatcher - */ - public function __construct(EventDispatcherInterface $dispatcher) - { - $this->dispatcher = $dispatcher; - } - - /** - * {@inheritdoc} - */ - public function buildFilters(Filters $filters = null) - { - $filterSearchParametersEvent = new FilterSearchCriteriaEvent($filters); - $this->dispatcher->dispatch(FilterSearchCriteriaEvent::NAME, $filterSearchParametersEvent); - - return $filterSearchParametersEvent->getSearchCriteria(); - } -} diff --git a/src/Core/Search/Builder/FiltersBuilderCollection.php b/src/Core/Search/Builder/FiltersBuilderCollection.php deleted file mode 100644 index 695a3d3e..00000000 --- a/src/Core/Search/Builder/FiltersBuilderCollection.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Builder; - -use PrestaShop\PrestaShop\Core\Data\AbstractTypedCollection; - -/** - * Collection of FiltersBuilderInterface. - */ -final class FiltersBuilderCollection extends AbstractTypedCollection -{ - /** - * {@inheritdoc} - */ - protected function getType() - { - return FiltersBuilderInterface::class; - } -} diff --git a/src/Core/Search/Builder/FiltersBuilderInterface.php b/src/Core/Search/Builder/FiltersBuilderInterface.php deleted file mode 100644 index 0d6d52a1..00000000 --- a/src/Core/Search/Builder/FiltersBuilderInterface.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Builder; - -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Interface for filters builders, each builder needs a config which is provided - * through the setConfig method which MUST be called before calling buildFilters. - * - * As the builders are called one after the other they may be provided with an - * existing filters instance that they need to override, if not they simply create - * a new Filters instance. - */ -interface FiltersBuilderInterface -{ - const FILTER_TYPES = [ - 'limit', - 'offset', - 'orderBy', - 'sortOrder', - 'filters', - ]; - - /** - * Allows to set a config through an associative array, this method should - * be called before buildFilters, it returns the builder for convenience so - * you can chain both calls (e.g: $builder->setConfig($config)->buildFilters()) - * - * @param array $config - * - * @return $this - */ - public function setConfig(array $config); - - /** - * This method is called to build the filters, the filters parameter is used if - * you want to override a pre existing filter. All builders should keep that in - * mind as they can be used consecutively with other builders and must not drop - * existing values carelessly. - * - * @param Filters|null $filters - * - * @return Filters - */ - public function buildFilters(Filters $filters = null); -} diff --git a/src/Core/Search/Builder/PersistFiltersBuilder.php b/src/Core/Search/Builder/PersistFiltersBuilder.php deleted file mode 100644 index a76a022e..00000000 --- a/src/Core/Search/Builder/PersistFiltersBuilder.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Builder; - -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * This builder does not modify the filters but instead saves them in database for - * each Employee, thus it can then be found by the RepositoryFiltersBuilder. - */ -final class PersistFiltersBuilder extends AbstractRepositoryFiltersBuilder -{ - /** - * @param Filters|null $filters - * - * @return Filters - * - * @throws \Doctrine\ORM\OptimisticLockException - */ - public function buildFilters(Filters $filters = null) - { - if (null === $filters || !$this->employeeProvider->getId() || !$this->shopId) { - return $filters; - } - - $filterId = $this->getFilterId($filters); - if (empty($filterId) && (empty($this->controller) || empty($this->action))) { - return $filters; - } - - $filtersToSave = $filters->all(); - unset($filtersToSave['offset']); - - if (!empty($filterId)) { - $this->adminFilterRepository->createOrUpdateByEmployeeAndFilterId( - $this->employeeProvider->getId(), - $this->shopId, - $filtersToSave, - $filterId - ); - } else { - $this->adminFilterRepository->createOrUpdateByEmployeeAndRouteParams( - $this->employeeProvider->getId(), - $this->shopId, - $filtersToSave, - $this->controller, - $this->action - ); - } - - return $filters; - } -} diff --git a/src/Core/Search/Builder/RepositoryFiltersBuilder.php b/src/Core/Search/Builder/RepositoryFiltersBuilder.php deleted file mode 100644 index e895f384..00000000 --- a/src/Core/Search/Builder/RepositoryFiltersBuilder.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Builder; - -use PrestaShop\PrestaShop\Core\Search\Filters; -use PrestaShopBundle\Entity\AdminFilter; - -/** - * This builder is able to get the employee saved filter: - * - thanks to filterId if one has been specified (either in the config or by the Filters sub class) - * - thanks to controller/action matching from the request - */ -final class RepositoryFiltersBuilder extends AbstractRepositoryFiltersBuilder -{ - /** - * {@inheritdoc} - */ - public function buildFilters(Filters $filters = null) - { - if (!$this->employeeProvider->getId() || !$this->shopId) { - return $filters; - } - - $filterId = $this->getFilterId($filters); - $parameters = $this->getParametersFromRepository($filterId); - - if (null !== $filters) { - $filters->add($parameters); - } else { - $filters = new Filters($parameters, $filterId); - } - - return $filters; - } - - /** - * @param string $filterId - * - * @return array - */ - private function getParametersFromRepository($filterId) - { - if (empty($filterId) && (empty($this->controller) || empty($this->action))) { - return []; - } - - if (!empty($filterId)) { - /** @var AdminFilter $adminFilter */ - $adminFilter = $this->adminFilterRepository->findByEmployeeAndFilterId( - $this->employeeProvider->getId(), - $this->shopId, - $filterId - ); - } else { - /** @var AdminFilter $adminFilter */ - $adminFilter = $this->adminFilterRepository->findByEmployeeAndRouteParams( - $this->employeeProvider->getId(), - $this->shopId, - $this->controller, - $this->action - ); - } - - if (!$adminFilter) { - return []; - } - - return json_decode($adminFilter->getFilter(), true); - } -} diff --git a/src/Core/Search/Builder/RequestFiltersBuilder.php b/src/Core/Search/Builder/RequestFiltersBuilder.php deleted file mode 100644 index 5001b050..00000000 --- a/src/Core/Search/Builder/RequestFiltersBuilder.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Builder; - -use PrestaShop\PrestaShop\Core\Search\Filters; -use Symfony\Component\HttpFoundation\Request; - -/** - * This builder builds a Filters instance from the request, it is able to fetch the - * parameters from both GET and POST requests. If the built filter has a filterId - * it filters the request parameters in a scope (e.g: ?language[limit]=10 instead of - * ?limit=10) - * The filterId can be set - * - from the builder config - * - from the provided filter which class has a default filterId - * - from the provided filter which has been manually instantiated with a filterId - */ -final class RequestFiltersBuilder extends AbstractFiltersBuilder -{ - /** @var Request */ - private $request; - - /** - * {@inheritdoc} - */ - public function setConfig(array $config) - { - $this->request = isset($config['request']) ? $config['request'] : null; - - return parent::setConfig($config); - } - - /** - * {@inheritdoc} - */ - public function buildFilters(Filters $filters = null) - { - if (null === $this->request) { - return $filters; - } - - $filterId = $this->getFilterId($filters); - $queryParams = $this->request->query->all(); - $requestParams = $this->request->request->all(); - - //If filters have a filterId then parameters are sent in a namespace (eg: grid_id[limit]=10 instead of limit=10) - if (!empty($filterId)) { - $queryParams = isset($queryParams[$filterId]) ? $queryParams[$filterId] : []; - $requestParams = isset($requestParams[$filterId]) ? $requestParams[$filterId] : []; - } - - $parameters = []; - foreach (self::FILTER_TYPES as $type) { - if (isset($queryParams[$type])) { - $parameters[$type] = $queryParams[$type]; - } elseif (isset($requestParams[$type])) { - $parameters[$type] = $requestParams[$type]; - } - } - - if (null !== $filters) { - $filters->add($parameters); - } else { - $filters = new Filters($parameters, $filterId); - } - - return $filters; - } -} diff --git a/src/Core/Search/ControllerAction.php b/src/Core/Search/ControllerAction.php deleted file mode 100644 index d5346862..00000000 --- a/src/Core/Search/ControllerAction.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search; - -/** - * Utility class to extract information from modern controller FQCN. - */ -final class ControllerAction -{ - /** - * Retrieve the Controller's action and name from a FQCN notation of Symfony controller. - * This function expects a string like MyNamespace\Foo\FooController::bazAction. - * - * @param string $controller - * - * @return array - */ - public static function fromString($controller) - { - return [ - self::getControllerName($controller), - self::getActionName($controller), - ]; - } - - /** - * Get current controller name. - * - * @param string $controller the full controller name - * - * @return string - */ - private static function getControllerName($controller) - { - preg_match('~(\w+)Controller(?:::(?:\w+)Action)?$~', $controller, $matches); - - return !empty($matches) ? strtolower($matches[1]) : 'N/A'; - } - - /** - * Get current action name. - * - * @param string $controller the full controller name - * - * @return string - */ - private static function getActionName($controller) - { - preg_match('~::(\w+)Action$~', $controller, $matches); - - return !empty($matches) ? strtolower($matches[1]) : 'N/A'; - } -} diff --git a/src/Core/Search/Filters.php b/src/Core/Search/Filters.php deleted file mode 100644 index b8221461..00000000 --- a/src/Core/Search/Filters.php +++ /dev/null @@ -1,140 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search; - -use PrestaShop\PrestaShop\Core\Grid\Search\SearchCriteriaInterface; -use Symfony\Component\HttpFoundation\ParameterBag; - -/** - * This class is responsible of managing filters of Listing pages. - */ -class Filters extends ParameterBag implements SearchCriteriaInterface -{ - /** @var string */ - protected $filterId = ''; - - /** - * @param array $filters - * @param string $filterId - */ - public function __construct(array $filters = [], $filterId = '') - { - parent::__construct($filters); - $this->filterId = !empty($filterId) ? $filterId : $this->filterId; - } - - /** - * @return Filters - */ - public static function buildDefaults() - { - return new static(static::getDefaults()); - } - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 10, - 'offset' => 0, - 'orderBy' => null, - 'sortOrder' => null, - 'filters' => [], - ]; - } - - /** - * {@inheritdoc} - */ - public function getOrderBy() - { - return $this->get('orderBy'); - } - - /** - * {@inheritdoc} - */ - public function getOrderWay() - { - return $this->get('sortOrder'); - } - - /** - * {@inheritdoc} - */ - public function getOffset() - { - return $this->get('offset'); - } - - /** - * {@inheritdoc} - */ - public function getLimit() - { - return $this->get('limit'); - } - - /** - * @param array $parameters - */ - public function addFilter(array $parameters = []) - { - $filters = array_replace($this->getFilters(), $parameters); - $this->set('filters', $filters); - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return $this->get('filters'); - } - - /** - * @return string - */ - public function getFilterId() - { - return $this->filterId; - } - - /** - * @param string $filterId - * - * @return $this - */ - public function setFilterId($filterId) - { - $this->filterId = $filterId; - - return $this; - } -} diff --git a/src/Core/Search/Filters/AddressFilters.php b/src/Core/Search/Filters/AddressFilters.php deleted file mode 100644 index 79c7493e..00000000 --- a/src/Core/Search/Filters/AddressFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AddressGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Default addresses list filters - */ -final class AddressFilters extends Filters -{ - /** @var string */ - protected $filterId = AddressGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults(): array - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'id_address', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/AttachmentFilters.php b/src/Core/Search/Filters/AttachmentFilters.php deleted file mode 100644 index a3159d19..00000000 --- a/src/Core/Search/Filters/AttachmentFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AttachmentGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Defines default filters for Attachments grid. - */ -final class AttachmentFilters extends Filters -{ - /** @var string */ - protected $filterId = AttachmentGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'id_attachment', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/AttributeFilters.php b/src/Core/Search/Filters/AttributeFilters.php deleted file mode 100644 index 1af7c93f..00000000 --- a/src/Core/Search/Filters/AttributeFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AttributeGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Responsible for providing filter values for attribute groups > attributes grid. - */ -final class AttributeFilters extends Filters -{ - /** @var string */ - protected $filterId = AttributeGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'id_attribute', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/AttributeGroupFilters.php b/src/Core/Search/Filters/AttributeGroupFilters.php deleted file mode 100644 index 7139323c..00000000 --- a/src/Core/Search/Filters/AttributeGroupFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AttributeGroupGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Responsible for providing filter values for attribute groups list - */ -final class AttributeGroupFilters extends Filters -{ - /** @var string */ - protected $filterId = AttributeGroupGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'position', - 'sortOrder' => 'desc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/BackupFilters.php b/src/Core/Search/Filters/BackupFilters.php deleted file mode 100644 index 67e7a13c..00000000 --- a/src/Core/Search/Filters/BackupFilters.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Class BackupFilters defines filters for 'Configure > Advanced Parameters > Database > Backup' listing. - */ -final class BackupFilters extends Filters -{ - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 20, - 'offset' => 0, - 'orderBy' => null, - 'sortOrder' => null, - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/CatalogPriceRuleFilters.php b/src/Core/Search/Filters/CatalogPriceRuleFilters.php deleted file mode 100644 index 39f516eb..00000000 --- a/src/Core/Search/Filters/CatalogPriceRuleFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CatalogPriceRuleGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Responsible for providing default filters for catalog price rule grid. - */ -final class CatalogPriceRuleFilters extends Filters -{ - /** @var string */ - protected $filterId = CatalogPriceRuleGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'id_specific_price_rule', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/CategoryFilters.php b/src/Core/Search/Filters/CategoryFilters.php deleted file mode 100644 index f68267e0..00000000 --- a/src/Core/Search/Filters/CategoryFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CategoryGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Class CategoryFilters defines default filters for Category grid. - */ -final class CategoryFilters extends Filters -{ - /** @var string */ - protected $filterId = CategoryGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'position', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/CmsPageCategoryFilters.php b/src/Core/Search/Filters/CmsPageCategoryFilters.php deleted file mode 100644 index 72f55db4..00000000 --- a/src/Core/Search/Filters/CmsPageCategoryFilters.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CmsPageCategoryDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Class CmsPageCategoryFilters defines default filters for cms page category grid. - */ -final class CmsPageCategoryFilters extends Filters -{ - protected $filterId = CmsPageCategoryDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'position', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/CmsPageFilters.php b/src/Core/Search/Filters/CmsPageFilters.php deleted file mode 100644 index 260c524e..00000000 --- a/src/Core/Search/Filters/CmsPageFilters.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CmsPageDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -final class CmsPageFilters extends Filters -{ - protected $filterId = CmsPageDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'position', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/ContactFilters.php b/src/Core/Search/Filters/ContactFilters.php deleted file mode 100644 index 1c2bbb3c..00000000 --- a/src/Core/Search/Filters/ContactFilters.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Class ContactFilters is responsible for providing default filter values for Contacts list. - */ -final class ContactFilters extends Filters -{ - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 10, - 'offset' => 0, - 'orderBy' => 'id_contact', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/CreditSlipFilters.php b/src/Core/Search/Filters/CreditSlipFilters.php deleted file mode 100644 index e2606553..00000000 --- a/src/Core/Search/Filters/CreditSlipFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CreditSlipGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Provides default filters for credit slip list - */ -final class CreditSlipFilters extends Filters -{ - /** @var string */ - protected $filterId = CreditSlipGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'id_order_slip', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/CurrencyFilters.php b/src/Core/Search/Filters/CurrencyFilters.php deleted file mode 100644 index ac46954b..00000000 --- a/src/Core/Search/Filters/CurrencyFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CurrencyGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Class CurrencyFilters is responsible for providing default filters for currency grid. - */ -final class CurrencyFilters extends Filters -{ - /** @var string */ - protected $filterId = CurrencyGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'id_currency', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/CustomerFilters.php b/src/Core/Search/Filters/CustomerFilters.php deleted file mode 100644 index fd277aae..00000000 --- a/src/Core/Search/Filters/CustomerFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CustomerGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Class CustomerFilters provides default filters for customers grid. - */ -final class CustomerFilters extends Filters -{ - /** @var string */ - protected $filterId = CustomerGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'date_add', - 'sortOrder' => 'DESC', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/EmailLogsFilter.php b/src/Core/Search/Filters/EmailLogsFilter.php deleted file mode 100644 index 4104f74c..00000000 --- a/src/Core/Search/Filters/EmailLogsFilter.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Class EmailLogsFilter defines default filters for Email logs grid. - */ -final class EmailLogsFilter extends Filters -{ - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'id_mail', - 'sortOrder' => 'desc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/EmployeeFilters.php b/src/Core/Search/Filters/EmployeeFilters.php deleted file mode 100644 index 75d707a3..00000000 --- a/src/Core/Search/Filters/EmployeeFilters.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Class EmployeeFilters holds search criteria for Employee grid. - */ -final class EmployeeFilters extends Filters -{ - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'id_employee', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/LanguageFilters.php b/src/Core/Search/Filters/LanguageFilters.php deleted file mode 100644 index 049e0789..00000000 --- a/src/Core/Search/Filters/LanguageFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\LanguageGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Class LanguageFilters define default filters used for languages filtering. - */ -final class LanguageFilters extends Filters -{ - /** @var string */ - protected $filterId = LanguageGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'id_lang', - 'sortOrder' => 'ASC', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/LogsFilters.php b/src/Core/Search/Filters/LogsFilters.php deleted file mode 100644 index 14d85653..00000000 --- a/src/Core/Search/Filters/LogsFilters.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * This class manage the defaults values for user request filters - * of page Configure > Advanced Parameters > Logs. - */ -final class LogsFilters extends Filters -{ - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 10, - 'offset' => 0, - 'orderBy' => 'id_log', - 'sortOrder' => 'desc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/ManufacturerAddressFilters.php b/src/Core/Search/Filters/ManufacturerAddressFilters.php deleted file mode 100644 index e82c6930..00000000 --- a/src/Core/Search/Filters/ManufacturerAddressFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\ManufacturerAddressGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Class ManufacturerAddressFilters is responsible for providing filter values for manufacturer address grid. - */ -final class ManufacturerAddressFilters extends Filters -{ - /** @var string */ - protected $filterId = ManufacturerAddressGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 10, - 'offset' => 0, - 'orderBy' => 'id_address', - 'sortOrder' => 'desc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/ManufacturerFilters.php b/src/Core/Search/Filters/ManufacturerFilters.php deleted file mode 100644 index a1a948fb..00000000 --- a/src/Core/Search/Filters/ManufacturerFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\ManufacturerGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Class ManufacturerFilters is responsible for providing filter values for manufacturer grid. - */ -final class ManufacturerFilters extends Filters -{ - /** @var string */ - protected $filterId = ManufacturerGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 10, - 'offset' => 0, - 'orderBy' => 'name', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/MerchandiseReturnFilters.php b/src/Core/Search/Filters/MerchandiseReturnFilters.php deleted file mode 100644 index f4cc97ac..00000000 --- a/src/Core/Search/Filters/MerchandiseReturnFilters.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\MerchandiseReturnGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Provides default filters for merchandise returns grid. - */ -final class MerchandiseReturnFilters extends Filters -{ - protected $filterId = MerchandiseReturnGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'id_order_return', - 'sortOrder' => 'ASC', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/MetaFilters.php b/src/Core/Search/Filters/MetaFilters.php deleted file mode 100644 index 67a95040..00000000 --- a/src/Core/Search/Filters/MetaFilters.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Class MetaFilters is responsible for providing default filter values for Seo & urls list. - */ -final class MetaFilters extends Filters -{ - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'id_meta', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/Monitoring/DisabledProductFilters.php b/src/Core/Search/Filters/Monitoring/DisabledProductFilters.php deleted file mode 100644 index 6c893634..00000000 --- a/src/Core/Search/Filters/Monitoring/DisabledProductFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters\Monitoring; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\DisabledProductGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Defines default filters for product with combination grid. - */ -final class DisabledProductFilters extends Filters -{ - /** @var string */ - protected $filterId = DisabledProductGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 20, - 'offset' => 0, - 'orderBy' => 'name', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/Monitoring/EmptyCategoryFilters.php b/src/Core/Search/Filters/Monitoring/EmptyCategoryFilters.php deleted file mode 100644 index 73607839..00000000 --- a/src/Core/Search/Filters/Monitoring/EmptyCategoryFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters\Monitoring; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\EmptyCategoryGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Defines default filters for empty category grid. - */ -final class EmptyCategoryFilters extends Filters -{ - /** @var string */ - protected $filterId = EmptyCategoryGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 20, - 'offset' => 0, - 'orderBy' => 'name', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/Monitoring/NoQtyProductWithCombinationFilters.php b/src/Core/Search/Filters/Monitoring/NoQtyProductWithCombinationFilters.php deleted file mode 100644 index b02c2568..00000000 --- a/src/Core/Search/Filters/Monitoring/NoQtyProductWithCombinationFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters\Monitoring; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\NoQtyProductWithCombinationGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Defines default filters for product with combination grid. - */ -final class NoQtyProductWithCombinationFilters extends Filters -{ - /** @var string */ - protected $filterId = NoQtyProductWithCombinationGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 20, - 'offset' => 0, - 'orderBy' => 'name', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/Monitoring/NoQtyProductWithoutCombinationFilters.php b/src/Core/Search/Filters/Monitoring/NoQtyProductWithoutCombinationFilters.php deleted file mode 100644 index 954d0f7c..00000000 --- a/src/Core/Search/Filters/Monitoring/NoQtyProductWithoutCombinationFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters\Monitoring; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\NoQtyProductWithoutCombinationGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Defines default filters for product with combination grid. - */ -final class NoQtyProductWithoutCombinationFilters extends Filters -{ - /** @var string */ - protected $filterId = NoQtyProductWithoutCombinationGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 20, - 'offset' => 0, - 'orderBy' => 'name', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/Monitoring/ProductWithoutDescriptionFilters.php b/src/Core/Search/Filters/Monitoring/ProductWithoutDescriptionFilters.php deleted file mode 100644 index 031c8d59..00000000 --- a/src/Core/Search/Filters/Monitoring/ProductWithoutDescriptionFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters\Monitoring; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\ProductWithoutDescriptionGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Defines default filters for product without description grid. - */ -final class ProductWithoutDescriptionFilters extends Filters -{ - /** @var string */ - protected $filterId = ProductWithoutDescriptionGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 20, - 'offset' => 0, - 'orderBy' => 'name', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/Monitoring/ProductWithoutImageFilters.php b/src/Core/Search/Filters/Monitoring/ProductWithoutImageFilters.php deleted file mode 100644 index d9ef11ff..00000000 --- a/src/Core/Search/Filters/Monitoring/ProductWithoutImageFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters\Monitoring; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\ProductWithoutImageGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Defines default filters for product without image grid. - */ -final class ProductWithoutImageFilters extends Filters -{ - /** @var string */ - protected $filterId = ProductWithoutImageGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 20, - 'offset' => 0, - 'orderBy' => 'name', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/Monitoring/ProductWithoutPriceFilters.php b/src/Core/Search/Filters/Monitoring/ProductWithoutPriceFilters.php deleted file mode 100644 index 9d74cfd9..00000000 --- a/src/Core/Search/Filters/Monitoring/ProductWithoutPriceFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters\Monitoring; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\ProductWithoutPriceGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Defines default filters for product without price grid. - */ -final class ProductWithoutPriceFilters extends Filters -{ - /** @var string */ - protected $filterId = ProductWithoutPriceGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 20, - 'offset' => 0, - 'orderBy' => 'name', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/OrderFilters.php b/src/Core/Search/Filters/OrderFilters.php deleted file mode 100644 index 0d1de207..00000000 --- a/src/Core/Search/Filters/OrderFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\OrderGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Stores filters for Order grid - */ -final class OrderFilters extends Filters -{ - /** @var string */ - protected $filterId = OrderGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'id_order', - 'sortOrder' => 'DESC', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/OrderMessageFilters.php b/src/Core/Search/Filters/OrderMessageFilters.php deleted file mode 100644 index 4eabd307..00000000 --- a/src/Core/Search/Filters/OrderMessageFilters.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\OrderMessageGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Defines filters for order message grid - */ -final class OrderMessageFilters extends Filters -{ - /** @var string */ - protected $filterId = OrderMessageGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'id_order_message', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/ProfileFilters.php b/src/Core/Search/Filters/ProfileFilters.php deleted file mode 100644 index 07e17720..00000000 --- a/src/Core/Search/Filters/ProfileFilters.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Class ProfilesFilters is responsible for providing default filter values for Profiles grid. - */ -final class ProfileFilters extends Filters -{ - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 10, - 'offset' => 0, - 'orderBy' => 'id_profile', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/RequestSqlFilters.php b/src/Core/Search/Filters/RequestSqlFilters.php deleted file mode 100644 index b04265bd..00000000 --- a/src/Core/Search/Filters/RequestSqlFilters.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Search\Filters; - -class RequestSqlFilters extends Filters -{ - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 10, - 'offset' => 0, - 'orderBy' => 'id_request_sql', - 'sortOrder' => 'desc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/SupplierFilters.php b/src/Core/Search/Filters/SupplierFilters.php deleted file mode 100644 index 599e200b..00000000 --- a/src/Core/Search/Filters/SupplierFilters.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\SupplierGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Class SupplierFilters defines default filters for Suppliers grid. - */ -final class SupplierFilters extends Filters -{ - /** - * @var string - */ - protected $filterId = SupplierGridDefinitionFactory::GRID_ID; - - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'name', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/TaxFilters.php b/src/Core/Search/Filters/TaxFilters.php deleted file mode 100644 index 40f4ecd9..00000000 --- a/src/Core/Search/Filters/TaxFilters.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Provides default filters for taxes grid. - */ -final class TaxFilters extends Filters -{ - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'id_tax', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/TaxRulesGroupFilters.php b/src/Core/Search/Filters/TaxRulesGroupFilters.php deleted file mode 100644 index fc05a7bd..00000000 --- a/src/Core/Search/Filters/TaxRulesGroupFilters.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Provides default filters for tax rule groups grid. - */ -final class TaxRulesGroupFilters extends Filters -{ - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'id_tax_rules_group', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/Filters/WebserviceKeyFilters.php b/src/Core/Search/Filters/WebserviceKeyFilters.php deleted file mode 100644 index dab930a0..00000000 --- a/src/Core/Search/Filters/WebserviceKeyFilters.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search\Filters; - -use PrestaShop\PrestaShop\Core\Search\Filters; - -/** - * Class WebserviceKeyFilters is responsible for providing default values for webservice account list. - */ -final class WebserviceKeyFilters extends Filters -{ - /** - * {@inheritdoc} - */ - public static function getDefaults() - { - return [ - 'limit' => 50, - 'offset' => 0, - 'orderBy' => 'id_webservice_account', - 'sortOrder' => 'asc', - 'filters' => [], - ]; - } -} diff --git a/src/Core/Search/SearchParameters.php b/src/Core/Search/SearchParameters.php deleted file mode 100644 index 54617724..00000000 --- a/src/Core/Search/SearchParameters.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Search; - -use PrestaShopBundle\Entity\AdminFilter; -use PrestaShopBundle\Entity\Repository\AdminFilterRepository; -use Symfony\Component\HttpFoundation\Request; - -/** - * Retrieve filters parameters if any from the User request. - * - * @deprecated Use FiltersBuilderInterface instead - */ -final class SearchParameters implements SearchParametersInterface -{ - /** - * @var AdminFilterRepository - */ - private $adminFilterRepository; - - public function __construct(AdminFilterRepository $adminFilterRepository) - { - $this->adminFilterRepository = $adminFilterRepository; - } - - /** - * {@inheritdoc} - */ - public function getFiltersFromRequest(Request $request, $filterClass) - { - $queryParams = $request->query->all(); - $requestParams = $request->request->all(); - - $parameters = []; - foreach (self::FILTER_TYPES as $type) { - if (isset($queryParams[$type])) { - $parameters[$type] = $queryParams[$type]; - } elseif (isset($requestParams[$type])) { - $parameters[$type] = $requestParams[$type]; - } - } - - return new $filterClass($parameters); - } - - /** - * {@inheritdoc} - */ - public function getFiltersFromRepository($employeeId, $shopId, $controller, $action, $filterClass) - { - /** @var AdminFilter $adminFilter */ - $adminFilter = $this->adminFilterRepository->findByEmployeeAndRouteParams( - $employeeId, - $shopId, - $controller, - $action - ); - - $parameters = null !== $adminFilter ? json_decode($adminFilter->getFilter(), true) : []; - - return new $filterClass($parameters); - } -} diff --git a/src/Core/Search/SearchParametersInterface.php b/src/Core/Search/SearchParametersInterface.php deleted file mode 100644 index 2e7dc588..00000000 --- a/src/Core/Search/SearchParametersInterface.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Security; - -use PrestaShop\PrestaShop\Core\Exception\FileNotFoundException; -use PrestaShop\PrestaShop\Core\Exception\IOException; - -/** - * Interface used to protect a folder (via htaccess file, index.php redirection file, ...) - */ -interface FolderGuardInterface -{ - /** - * @param string $folderPath - * - * @throws IOException - * @throws FileNotFoundException - */ - public function protectFolder($folderPath); -} diff --git a/src/Core/Security/HtaccessFolderGuard.php b/src/Core/Security/HtaccessFolderGuard.php deleted file mode 100644 index 3df7fe93..00000000 --- a/src/Core/Security/HtaccessFolderGuard.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Security; - -use PrestaShop\PrestaShop\Core\Exception\FileNotFoundException; -use PrestaShop\PrestaShop\Core\Exception\IOException; - -/** - * Class HtaccessFolderGuard protects a designated folder by inserting an htaccess file in it - * which prevents access from an external call. - */ -class HtaccessFolderGuard implements FolderGuardInterface -{ - /** - * @var string - */ - private $htaccessContent; - - /** - * @param string $htaccessTemplatePath - * - * @throws FileNotFoundException - */ - public function __construct($htaccessTemplatePath) - { - if (!file_exists($htaccessTemplatePath)) { - throw new FileNotFoundException(sprintf('Could not find file %s', $htaccessTemplatePath)); - } - $this->htaccessContent = file_get_contents($htaccessTemplatePath); - } - - /** - * {@inheritdoc} - */ - public function protectFolder($folderPath) - { - if (!is_dir($folderPath)) { - throw new FileNotFoundException(sprintf('Cannot protect nonexistent folder %s', $folderPath)); - } - - $htaccessPath = $folderPath . DIRECTORY_SEPARATOR . '.htaccess'; - if (!file_exists($htaccessPath)) { - if (!is_writable($folderPath)) { - throw new IOException('Could not write into module folder', 0, null, $folderPath); - } - - file_put_contents($htaccessPath, $this->htaccessContent); - } - } -} diff --git a/src/Core/Session/SessionInterface.php b/src/Core/Session/SessionInterface.php deleted file mode 100644 index de9d4d64..00000000 --- a/src/Core/Session/SessionInterface.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Session; - -/** - * SessionInterface is used to store/access to the session token used by customers and employees - */ -interface SessionInterface -{ - /** - * Returns session id - * - * @return int - */ - public function getId(); - - /** - * Set session user id - * - * @param int $id - * - * @return void - */ - public function setUserId($id); - - /** - * Returns session user id - * - * @return int - */ - public function getUserId(); - - /** - * Set session token - * - * @param string $string - * - * @return void - */ - public function setToken($string); - - /** - * Returns session token - * - * @return string - */ - public function getToken(); - - /** - * Adds current object to the database. - */ - public function add(); - - /** - * Deletes current object from database. - */ - public function delete(); -} diff --git a/src/Core/Shop/LogoUploader.php b/src/Core/Shop/LogoUploader.php deleted file mode 100644 index 20b82999..00000000 --- a/src/Core/Shop/LogoUploader.php +++ /dev/null @@ -1,203 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Shop; - -use Configuration; -use Context; -use ImageManager; -use PrestaShopException; -use Shop; -use Tools; - -/** - * Class LogoUploader used to manage upload of Shop logos and favicon. - */ -class LogoUploader -{ - /** @var the shop */ - private $shop; - - /** - * @var array - */ - private $errors = []; - - public function __construct(Shop $shop) - { - $this->shop = $shop; - } - - public function updateHeader() - { - $this->update('PS_LOGO', 'logo'); - } - - public function updateMail() - { - $this->update('PS_LOGO_MAIL', 'logo_mail'); - } - - public function updateInvoice() - { - $this->update('PS_LOGO_INVOICE', 'logo_invoice'); - } - - public function updateFavicon() - { - $shopId = (int) $this->shop->id; - if ($shopId == Configuration::get('PS_SHOP_DEFAULT')) { - $this->uploadIco('PS_FAVICON', _PS_IMG_DIR_ . 'favicon.ico'); - } - if ($this->uploadIco('PS_FAVICON', _PS_IMG_DIR_ . 'favicon-' . $shopId . '.ico')) { - Configuration::updateValue('PS_FAVICON', 'favicon-' . $shopId . '.ico'); - } - - Configuration::updateGlobalValue('PS_FAVICON', 'favicon.ico'); - } - - /** - * Generic function which allows logo upload. - * - * @param $fieldName - * @param $logoPrefix - * @param $files[] the array of files to avoid use $_POST - * - * @return bool - * - * @throws PrestaShopException in case of upload failure - */ - public function update($fieldName, $logoPrefix, array $files = []) - { - $files = empty($files) ? $_FILES : $files; - - if (isset($files[$fieldName]['tmp_name'], $files[$fieldName]['tmp_name'], $files[$fieldName]['size'])) { - if ($error = ImageManager::validateUpload($files[$fieldName], Tools::getMaxUploadSize())) { - throw new PrestaShopException($error); - } - $tmpName = tempnam(_PS_TMP_IMG_DIR_, 'PS'); - - if (!$tmpName || !move_uploaded_file($files[$fieldName]['tmp_name'], $tmpName)) { - throw new PrestaShopException(sprintf('%Upload of temporary file to %s has failed.', $tmpName)); - } - - $fileExtension = ($fieldName == 'PS_STORES_ICON') ? '.gif' : '.jpg'; - $logoName = $this->getLogoName($logoPrefix, $fileExtension); - - if ($fieldName == 'PS_STORES_ICON') { - if (!@ImageManager::resize($tmpName, _PS_IMG_DIR_ . $logoName, null, null, 'gif', true)) { - throw new PrestaShopException(sprintf('An error occurred while attempting to copy shop icon %s.', $logoName)); - } - } else { - if (!@ImageManager::resize($tmpName, _PS_IMG_DIR_ . $logoName)) { - throw new PrestaShopException(sprintf('An error occurred while attempting to copy shop logo %s.', $logoName)); - } - } - - $idShop = $this->shop->id; - $idShopGroup = null; - - if (!count($this->errors) && @filemtime(_PS_IMG_DIR_ . Configuration::get($fieldName))) { - if (Shop::isFeatureActive()) { - $this->updateInMultiShopContext($idShop, $idShopGroup, $fieldName); - } else { - @unlink(_PS_IMG_DIR_ . Configuration::get($fieldName)); - } - } - - Configuration::updateValue($fieldName, $logoName, false, $idShopGroup, $idShop); - unlink($tmpName); - - return true; - } - - return false; - } - - private function updateInMultiShopContext(&$idShop, &$idShopGroup, $fieldName) - { - if (Shop::getContext() == Shop::CONTEXT_SHOP) { - $idShop = Shop::getContextShopID(); - $idShopGroup = Shop::getContextShopGroupID(); - Shop::setContext(Shop::CONTEXT_ALL); - $logoAll = Configuration::get($fieldName); - Shop::setContext(Shop::CONTEXT_GROUP); - $logoGroup = Configuration::get($fieldName); - Shop::setContext(Shop::CONTEXT_SHOP); - $logoShop = Configuration::get($fieldName); - if ($logoAll != $logoShop && $logoGroup != $logoShop && $logoShop != false) { - @unlink(_PS_IMG_DIR_ . Configuration::get($fieldName)); - } - } elseif (Shop::getContext() == Shop::CONTEXT_GROUP) { - $idShopGroup = Shop::getContextShopGroupID(); - Shop::setContext(Shop::CONTEXT_ALL); - $logoAll = Configuration::get($fieldName); - Shop::setContext(Shop::CONTEXT_GROUP); - if ($logoAll != Configuration::get($fieldName)) { - @unlink(_PS_IMG_DIR_ . Configuration::get($fieldName)); - } - } - } - - public function uploadIco($name, $destination, $files = []) - { - $files = empty($files) ? $_FILES : $files; - - if (isset($files[$name]['tmp_name']) && !empty($files[$name]['tmp_name'])) { - if ($error = ImageManager::validateIconUpload($files[$name])) { - throw new PrestaShopException($error); - } elseif (!copy($_FILES[$name]['tmp_name'], $destination)) { - throw new PrestaShopException(Context::getContext()->getTranslator()->trans('An error occurred while uploading the favicon: cannot copy file "%s" to folder "%s".', [$files[$name]['tmp_name'], $destination], 'Admin.Design.Notification')); - } - } - - return !count($this->errors); - } - - private function getLogoName($logoPrefix, $fileExtension) - { - $shopId = $this->shop->id; - $shopName = $this->shop->name; - - $logoName = Tools::link_rewrite($shopName) - . '-' - . $logoPrefix - . '-' - . (int) Configuration::get('PS_IMG_UPDATE_TIME') - . (int) $shopId . $fileExtension; - - if ($this->shop->getContext() == Shop::CONTEXT_ALL - || $shopId == 0 - || Shop::isFeatureActive() == false - ) { - $logoName = Tools::link_rewrite($shopName) - . '-' - . $logoPrefix . '-' . (int) Configuration::get('PS_IMG_UPDATE_TIME') . $fileExtension; - } - - return $logoName; - } -} diff --git a/src/Core/Shop/ShopContextInterface.php b/src/Core/Shop/ShopContextInterface.php deleted file mode 100644 index adbac93d..00000000 --- a/src/Core/Shop/ShopContextInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Shop; - -/** - * Interface ShopContextInterface - */ -interface ShopContextInterface -{ - /** - * Get name for context shop. - * - * @return string - */ - public function getShopName(); -} diff --git a/src/Core/Shop/Url/UrlProviderInterface.php b/src/Core/Shop/Url/UrlProviderInterface.php deleted file mode 100644 index 10293681..00000000 --- a/src/Core/Shop/Url/UrlProviderInterface.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Shop\Url; - -/** - * Interface UrlProviderInterface - */ -interface UrlProviderInterface -{ - /** - * @return string - */ - public function getUrl(); -} diff --git a/src/Core/SqlManager/Configuration/SqlRequestConfiguration.php b/src/Core/SqlManager/Configuration/SqlRequestConfiguration.php deleted file mode 100644 index 7f65ea36..00000000 --- a/src/Core/SqlManager/Configuration/SqlRequestConfiguration.php +++ /dev/null @@ -1,132 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\SqlManager\Configuration; - -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\SaveSqlRequestSettingsCommand; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestSettingsConstraintException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetSqlRequestSettings; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\SqlRequestSettings; - -/** - * Class RequestSqlConfiguration is responsible for RequestSql configuration. - */ -final class SqlRequestConfiguration implements DataConfigurationInterface -{ - /** - * @var CommandBusInterface - */ - private $commandBus; - - /** - * @var CommandBusInterface - */ - private $queryBus; - - /** - * @param CommandBusInterface $commandBus - * @param CommandBusInterface $queryBus - */ - public function __construct( - CommandBusInterface $commandBus, - CommandBusInterface $queryBus - ) { - $this->commandBus = $commandBus; - $this->queryBus = $queryBus; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - /** @var SqlRequestSettings $sqlRequestSettings */ - $sqlRequestSettings = $this->queryBus->handle(new GetSqlRequestSettings()); - - return [ - 'default_file_encoding' => $sqlRequestSettings->getFileEncoding(), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - $errors = []; - - if ($this->validateConfiguration($configuration)) { - try { - $command = new SaveSqlRequestSettingsCommand( - $configuration['default_file_encoding'] - ); - - $this->commandBus->handle($command); - } catch (SqlRequestSettingsConstraintException $e) { - $errors = $this->handleUpdateException($e); - } - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset($configuration['default_file_encoding']); - } - - /** - * Handle exception when configuration update fails. - * - * @param SqlRequestSettingsConstraintException $e - * - * @return array Array of errors - */ - private function handleUpdateException(SqlRequestSettingsConstraintException $e) - { - $code = $e->getCode(); - - $errorMessages = [ - SqlRequestSettingsConstraintException::INVALID_FILE_ENCODING => [ - 'key' => 'The %s field is invalid.', - 'parameters' => ['default_file_encoding'], - 'domain' => 'Admin.Notifications.Error', - ], - SqlRequestSettingsConstraintException::NOT_SUPPORTED_FILE_ENCODING => [ - 'key' => 'The %s field is invalid.', - 'parameters' => ['default_file_encoding'], - 'domain' => 'Admin.Notifications.Error', - ], - ]; - - return $errorMessages[$code]; - } -} diff --git a/src/Core/SqlManager/Exporter/SqlRequestExporter.php b/src/Core/SqlManager/Exporter/SqlRequestExporter.php deleted file mode 100644 index c5fef12e..00000000 --- a/src/Core/SqlManager/Exporter/SqlRequestExporter.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\SqlManager\Exporter; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\SqlRequestExecutionResult; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\ValueObject\SqlRequestId; -use PrestaShop\PrestaShop\Core\Export\Data\ExportableData; -use PrestaShop\PrestaShop\Core\Export\FileWriter\FileWriterInterface; - -/** - * Class SqlRequestExporter exports SqlRequest query execution result into CSV file under export directory. - */ -final class SqlRequestExporter implements SqlRequestExporterInterface -{ - /** - * @var FileWriterInterface - */ - private $csvFileWriter; - - /** - * @param FileWriterInterface $csvFileWriter - */ - public function __construct(FileWriterInterface $csvFileWriter) - { - $this->csvFileWriter = $csvFileWriter; - } - - /** - * {@inheritdoc} - */ - public function exportToFile(SqlRequestId $sqlRequestId, SqlRequestExecutionResult $result) - { - $exportData = new ExportableData( - $result->getColumns(), - $result->getRows() - ); - - $exportFileName = sprintf('request_sql_%s.csv', $sqlRequestId->getValue()); - - return $this->csvFileWriter->write($exportFileName, $exportData); - } -} diff --git a/src/Core/SqlManager/Exporter/SqlRequestExporterInterface.php b/src/Core/SqlManager/Exporter/SqlRequestExporterInterface.php deleted file mode 100644 index 37a453a6..00000000 --- a/src/Core/SqlManager/Exporter/SqlRequestExporterInterface.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\SqlManager\Exporter; - -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\SqlRequestExecutionResult; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\ValueObject\SqlRequestId; -use SplFileInfo; - -/** - * Interface SqlRequestExporterInterface defines contract for SqlRequest exporter. - */ -interface SqlRequestExporterInterface -{ - /** - * Export SqlRequest query execution result to file. - * - * @param SqlRequestId $sqlRequestId - * @param SqlRequestExecutionResult $sqlRequestExecutionResult - * - * @return SplFileInfo - */ - public function exportToFile(SqlRequestId $sqlRequestId, SqlRequestExecutionResult $sqlRequestExecutionResult); -} diff --git a/src/Core/Stock/StockManager.php b/src/Core/Stock/StockManager.php deleted file mode 100644 index c9d5dea7..00000000 --- a/src/Core/Stock/StockManager.php +++ /dev/null @@ -1,419 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -namespace PrestaShop\PrestaShop\Core\Stock; - -use Access; -use Combination; -use Configuration; -use Context; -use DateTime; -use Employee; -use Mail; -use Pack; -use PrestaShop\PrestaShop\Adapter\LegacyContext as ContextAdapter; -use PrestaShop\PrestaShop\Adapter\Product\ProductDataProvider; -use PrestaShop\PrestaShop\Adapter\ServiceLocator; -use PrestaShop\PrestaShop\Adapter\SymfonyContainer; -use PrestaShopBundle\Entity\StockMvt; -use Product; -use StockAvailable; - -/** - * Class StockManager Refactored features about product stocks. - */ -class StockManager -{ - /** - * This will update a Pack quantity and will decrease the quantity of containing Products if needed. - * - * @param Product $product A product pack object to update its quantity - * @param StockAvailable $stock_available the stock of the product to fix with correct quantity - * @param int $delta_quantity The movement of the stock (negative for a decrease) - * @param int|null $id_shop Optional shop ID - */ - public function updatePackQuantity($product, $stock_available, $delta_quantity, $id_shop = null) - { - /** @TODO We should call the needed classes with the Symfony dependency injection instead of the Homemade Service Locator */ - $serviceLocator = new ServiceLocator(); - $configuration = $serviceLocator::get('\\PrestaShop\\PrestaShop\\Core\\ConfigurationInterface'); - - if ($product->pack_stock_type == Pack::STOCK_TYPE_PRODUCTS_ONLY - || $product->pack_stock_type == Pack::STOCK_TYPE_PACK_BOTH - || ($product->pack_stock_type == Pack::STOCK_TYPE_DEFAULT - && $configuration->get('PS_PACK_STOCK_TYPE') > 0) - ) { - $packItemsManager = $serviceLocator::get('\\PrestaShop\\PrestaShop\\Adapter\\Product\\PackItemsManager'); - $stockManager = $serviceLocator::get('\\PrestaShop\\PrestaShop\\Adapter\\StockManager'); - $cacheManager = $serviceLocator::get('\\PrestaShop\\PrestaShop\\Adapter\\CacheManager'); - - $products_pack = $packItemsManager->getPackItems($product); - foreach ($products_pack as $product_pack) { - $productStockAvailable = $stockManager->getStockAvailableByProduct($product_pack, $product_pack->id_pack_product_attribute, $id_shop); - $productStockAvailable->quantity = $productStockAvailable->quantity + ($delta_quantity * $product_pack->pack_quantity); - $productStockAvailable->update(); - - $cacheManager->clean('StockAvailable::getQuantityAvailableByProduct_' . (int) $product_pack->id . '*'); - } - } - - $stock_available->quantity = $stock_available->quantity + $delta_quantity; - - if ($product->pack_stock_type == Pack::STOCK_TYPE_PACK_ONLY - || $product->pack_stock_type == Pack::STOCK_TYPE_PACK_BOTH - || ( - $product->pack_stock_type == Pack::STOCK_TYPE_DEFAULT - && ($configuration->get('PS_PACK_STOCK_TYPE') == Pack::STOCK_TYPE_PACK_ONLY - || $configuration->get('PS_PACK_STOCK_TYPE') == Pack::STOCK_TYPE_PACK_BOTH) - ) - ) { - $stock_available->update(); - } - } - - /** - * This will decrease (if needed) Packs containing this product - * (with the right declination) if there is not enough product in stocks. - * - * @param Product $product A product object to update its quantity - * @param int $id_product_attribute The product attribute to update - * @param StockAvailable $stock_available the stock of the product to fix with correct quantity - * @param int|null $id_shop Optional shop ID - */ - public function updatePacksQuantityContainingProduct($product, $id_product_attribute, $stock_available, $id_shop = null) - { - /** @TODO We should call the needed classes with the Symfony dependency injection instead of the Homemade Service Locator */ - $serviceLocator = new ServiceLocator(); - - $configuration = $serviceLocator::get('\\PrestaShop\\PrestaShop\\Core\\ConfigurationInterface'); - $packItemsManager = $serviceLocator::get('\\PrestaShop\\PrestaShop\\Adapter\\Product\\PackItemsManager'); - $stockManager = $serviceLocator::get('\\PrestaShop\\PrestaShop\\Adapter\\StockManager'); - $cacheManager = $serviceLocator::get('\\PrestaShop\\PrestaShop\\Adapter\\CacheManager'); - - $packs = $packItemsManager->getPacksContainingItem($product, $id_product_attribute); - foreach ($packs as $pack) { - // Decrease stocks of the pack only if pack is in linked stock mode (option called 'Decrement both') - if (!((int) $pack->pack_stock_type == Pack::STOCK_TYPE_PACK_BOTH) - && !((int) $pack->pack_stock_type == Pack::STOCK_TYPE_DEFAULT - && $configuration->get('PS_PACK_STOCK_TYPE') == Pack::STOCK_TYPE_PACK_BOTH) - ) { - continue; - } - - // Decrease stocks of the pack only if there is not enough items to make the actual pack stocks. - - // How many packs can be made with the remaining product stocks - $quantity_by_pack = $pack->pack_item_quantity; - $max_pack_quantity = max(array(0, floor($stock_available->quantity / $quantity_by_pack))); - - $stock_available_pack = $stockManager->getStockAvailableByProduct($pack, null, $id_shop); - if ($stock_available_pack->quantity > $max_pack_quantity) { - $stock_available_pack->quantity = $max_pack_quantity; - $stock_available_pack->update(); - - $cacheManager->clean('StockAvailable::getQuantityAvailableByProduct_' . (int) $pack->id . '*'); - } - } - } - - /** - * Will update Product available stock int he given declinaison. If product is a Pack, could decrease the sub products. - * If Product is contained in a Pack, Pack could be decreased or not (only if sub product stocks become not sufficient). - * - * @param Product $product The product to update its stockAvailable - * @param int $id_product_attribute The declinaison to update (null if not) - * @param int $delta_quantity The quantity change (positive or negative) - * @param int|null $id_shop Optional - * @param bool $add_movement Optional - * @param array $params Optional - */ - public function updateQuantity($product, $id_product_attribute, $delta_quantity, $id_shop = null, $add_movement = false, $params = array()) - { - /** @TODO We should call the needed classes with the Symfony dependency injection instead of the Homemade Service Locator */ - $serviceLocator = new ServiceLocator(); - $stockManager = $serviceLocator::get('\\PrestaShop\\PrestaShop\\Adapter\\StockManager'); - $packItemsManager = $serviceLocator::get('\\PrestaShop\\PrestaShop\\Adapter\\Product\\PackItemsManager'); - $cacheManager = $serviceLocator::get('\\PrestaShop\\PrestaShop\\Adapter\\CacheManager'); - $hookManager = $serviceLocator::get('\\PrestaShop\\PrestaShop\\Adapter\\HookManager'); - - $stockAvailable = $stockManager->getStockAvailableByProduct($product, $id_product_attribute, $id_shop); - - // Update quantity of the pack products - if ($packItemsManager->isPack($product)) { - // The product is a pack - $this->updatePackQuantity($product, $stockAvailable, $delta_quantity, $id_shop); - } else { - // The product is not a pack - $stockAvailable->quantity = $stockAvailable->quantity + $delta_quantity; - $stockAvailable->update(); - - // Decrease case only: the stock of linked packs should be decreased too. - if ($delta_quantity < 0) { - // The product is not a pack, but the product combination is part of a pack (use of isPacked, not isPack) - if ($packItemsManager->isPacked($product, $id_product_attribute)) { - $this->updatePacksQuantityContainingProduct($product, $id_product_attribute, $stockAvailable, $id_shop); - } - } - } - - // Prepare movement and save it - if (true === $add_movement && 0 != $delta_quantity) { - $this->saveMovement($product->id, $id_product_attribute, $delta_quantity, $params); - } - - $hookManager->exec( - 'actionUpdateQuantity', - array( - 'id_product' => $product->id, - 'id_product_attribute' => $id_product_attribute, - 'quantity' => $stockAvailable->quantity, - ) - ); - - if ($this->checkIfMustSendLowStockAlert($product, $id_product_attribute, $stockAvailable->quantity)) { - $this->sendLowStockAlert($product, $id_product_attribute, $stockAvailable->quantity); - } - - $cacheManager->clean('StockAvailable::getQuantityAvailableByProduct_' . (int) $product->id . '*'); - } - - /** - * @param Product $product - * @param int $id_product_attribute - * @param int $newQuantity - * - * @return bool - */ - protected function checkIfMustSendLowStockAlert($product, $id_product_attribute, $newQuantity) - { - if (!Configuration::get('PS_STOCK_MANAGEMENT')) { - return false; - } - - // Do not send mail if multiples product are created / imported. - if (defined('PS_MASS_PRODUCT_CREATION')) { - return false; - } - - $productHasAttributes = $product->hasAttributes(); - if ($productHasAttributes && $id_product_attribute) { - $combination = new Combination($id_product_attribute); - - return $this->isCombinationQuantityUnderAlertThreshold($combination, $newQuantity); - } elseif (!$productHasAttributes && !$id_product_attribute) { - return $this->isProductQuantityUnderAlertThreshold($product, $newQuantity); - } - - return false; - } - - /** - * @param Product $product - * @param int $newQuantity - * - * @return bool - */ - protected function isProductQuantityUnderAlertThreshold($product, $newQuantity) - { - // low_stock_threshold empty to disable (can be negative, null or zero) - if ($product->low_stock_alert - && $product->low_stock_threshold !== '' - && $product->low_stock_threshold !== null - && $newQuantity <= (int) $product->low_stock_threshold - ) { - return true; - } - - return false; - } - - /** - * @param Combination $combination - * @param int $newQuantity - * - * @return bool - */ - protected function isCombinationQuantityUnderAlertThreshold(Combination $combination, $newQuantity) - { - // low_stock_threshold empty to disable (can be negative, null or zero) - if ($combination->low_stock_alert - && $combination->low_stock_threshold !== '' - && $combination->low_stock_threshold !== null - && $newQuantity <= (int) $combination->low_stock_threshold - ) { - return true; - } - - return false; - } - - /** - * @param Product $product - * @param int $id_product_attribute - * @param int $newQuantity - * - * @throws \Exception - * @throws \PrestaShopException - */ - protected function sendLowStockAlert($product, $id_product_attribute, $newQuantity) - { - $context = Context::getContext(); - $idShop = (int) $context->shop->id; - $idLang = (int) $context->language->id; - $configuration = Configuration::getMultiple( - array( - 'MA_LAST_QTIES', - 'PS_STOCK_MANAGEMENT', - 'PS_SHOP_EMAIL', - 'PS_SHOP_NAME', - ), - null, - null, - $idShop - ); - $productName = Product::getProductName($product->id, $id_product_attribute, $idLang); - if ($id_product_attribute) { - $combination = new Combination($id_product_attribute); - $lowStockThreshold = $combination->low_stock_threshold; - } else { - $lowStockThreshold = $product->low_stock_threshold; - } - $templateVars = array( - '{qty}' => $newQuantity, - '{last_qty}' => $lowStockThreshold, - '{product}' => $productName, - ); - // get emails on employees who have right to run stock page - $emails = array(); - $employees = Employee::getEmployees(); - foreach ($employees as $employeeData) { - $employee = new Employee($employeeData['id_employee']); - if (Access::isGranted('ROLE_MOD_TAB_ADMINSTOCKMANAGEMENT_READ', $employee->id_profile)) { - $emails[] = $employee->email; - } - } - // Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients - foreach ($emails as $email) { - Mail::Send( - $idLang, - 'productoutofstock', - Mail::l('Niski stan magazynowy produktu', $idLang), - $templateVars, - $email, - null, - (string) $configuration['PS_SHOP_EMAIL'], - (string) $configuration['PS_SHOP_NAME'], - null, - null, - dirname(__FILE__) . '/mails/', - false, - $idShop - ); - } - } - - /** - * Public method to save a Movement. - * - * @param $productId - * @param $productAttributeId - * @param $deltaQuantity - * @param array $params - * - * @return bool - */ - public function saveMovement($productId, $productAttributeId, $deltaQuantity, $params = array()) - { - if ($deltaQuantity != 0) { - $stockMvt = $this->prepareMovement($productId, $productAttributeId, $deltaQuantity, $params); - - if ($stockMvt) { - $sfContainer = SymfonyContainer::getInstance(); - if (null !== $sfContainer) { - $stockMvtRepository = $sfContainer->get('prestashop.core.api.stock_movement.repository'); - - return $stockMvtRepository->saveStockMvt($stockMvt); - } - } - } - - return false; - } - - /** - * Prepare a Movement for registration. - * - * @param $productId - * @param $productAttributeId - * @param $deltaQuantity - * @param array $params - * - * @return bool|StockMvt - */ - private function prepareMovement($productId, $productAttributeId, $deltaQuantity, $params = array()) - { - $product = (new ProductDataProvider())->getProductInstance($productId); - - if ($product->id) { - $stockManager = ServiceLocator::get('\\PrestaShop\\PrestaShop\\Adapter\\StockManager'); - $stockAvailable = $stockManager->getStockAvailableByProduct($product, $productAttributeId); - - if ($stockAvailable->id) { - $stockMvt = new StockMvt(); - - $stockMvt->setIdStock((int) $stockAvailable->id); - - if (!empty($params['id_order'])) { - $stockMvt->setIdOrder((int) $params['id_order']); - } - - if (!empty($params['id_stock_mvt_reason'])) { - $stockMvt->setIdStockMvtReason((int) $params['id_stock_mvt_reason']); - } - - if (!empty($params['id_supply_order'])) { - $stockMvt->setIdSupplyOrder((int) $params['id_supply_order']); - } - - $stockMvt->setSign($deltaQuantity >= 1 ? 1 : -1); - $stockMvt->setPhysicalQuantity(abs($deltaQuantity)); - - $stockMvt->setDateAdd(new DateTime()); - - $employee = (new ContextAdapter())->getContext()->employee; - if (!empty($employee)) { - $stockMvt->setIdEmployee($employee->id); - $stockMvt->setEmployeeFirstname($employee->firstname); - $stockMvt->setEmployeeLastname($employee->lastname); - } - - return $stockMvt; - } - } - - return false; - } -} diff --git a/src/Core/String/CharacterCleaner.php b/src/Core/String/CharacterCleaner.php deleted file mode 100644 index c74a0e88..00000000 --- a/src/Core/String/CharacterCleaner.php +++ /dev/null @@ -1,46 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\String; - -class CharacterCleaner -{ - /** - * Delete unicode class from regular expression patterns. - * - * @param string $pattern - * - * @return string pattern - */ - public function cleanNonUnicodeSupport($pattern) - { - if (!defined('PREG_BAD_UTF8_OFFSET')) { - return $pattern; - } - - return preg_replace('/\\\[px]\{[a-z]{1,2}\}|(\/[a-z]*)u([a-z]*)$/i', '$1$2', $pattern); - } -} diff --git a/src/Core/Support/ContactRepositoryInterface.php b/src/Core/Support/ContactRepositoryInterface.php deleted file mode 100644 index e9f857cb..00000000 --- a/src/Core/Support/ContactRepositoryInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Support; - -/** - * Interface ContactRepositoryInterface defines contract for shop contact repository. - */ -interface ContactRepositoryInterface -{ - /** - * Get shop contacts. - * - * @param int $langId Language ID in which contacts should be returned - * - * @return array - */ - public function findAllByLangId($langId); -} diff --git a/src/Core/Tax/Ecotax/ProductEcotaxResetterInterface.php b/src/Core/Tax/Ecotax/ProductEcotaxResetterInterface.php deleted file mode 100644 index 2d47c674..00000000 --- a/src/Core/Tax/Ecotax/ProductEcotaxResetterInterface.php +++ /dev/null @@ -1,38 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Tax\Ecotax; - -/** - * Resets Ecotax for products - */ -interface ProductEcotaxResetterInterface -{ - /** - * Resets ecotax for all products - */ - public function reset(); -} diff --git a/src/Core/Tax/TaxOptionsConfiguration.php b/src/Core/Tax/TaxOptionsConfiguration.php deleted file mode 100644 index f693918d..00000000 --- a/src/Core/Tax/TaxOptionsConfiguration.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Tax; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Tax\Ecotax\ProductEcotaxResetterInterface; - -/** - * Handles configuration data for tax options. - */ -final class TaxOptionsConfiguration implements DataConfigurationInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - /** - * @var ProductEcotaxResetterInterface - */ - private $productEcotaxResetter; - - /** - * @param ConfigurationInterface $configuration - * @param ProductEcotaxResetterInterface $productEcotaxResetter - */ - public function __construct( - ConfigurationInterface $configuration, - ProductEcotaxResetterInterface $productEcotaxResetter - ) { - $this->configuration = $configuration; - $this->productEcotaxResetter = $productEcotaxResetter; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'enable_tax' => (bool) $this->configuration->get('PS_TAX'), - 'display_tax_in_cart' => (bool) $this->configuration->get('PS_TAX_DISPLAY'), - 'tax_address_type' => $this->configuration->get('PS_TAX_ADDRESS_TYPE'), - 'use_eco_tax' => (bool) $this->configuration->get('PS_USE_ECOTAX'), - 'eco_tax_rule_group' => $this->configuration->get('PS_ECOTAX_TAX_RULES_GROUP_ID'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_TAX', (bool) $configuration['enable_tax']); - $this->configuration->set('PS_TAX_DISPLAY', (bool) $configuration['display_tax_in_cart']); - $this->configuration->set('PS_TAX_ADDRESS_TYPE', $configuration['tax_address_type']); - $this->updateEcotax($configuration['use_eco_tax']); - - if ($configuration['use_eco_tax'] && isset($configuration['eco_tax_rule_group'])) { - $this->configuration->set('PS_ECOTAX_TAX_RULES_GROUP_ID', $configuration['eco_tax_rule_group']); - } - - if (false === $configuration['enable_tax']) { - $this->configuration->set('PS_TAX_DISPLAY', false); - } - } - - return []; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['enable_tax'], - $configuration['tax_address_type'], - $configuration['use_eco_tax'] - ); - } - - /** - * Responsible for ecotax update - * - * @param bool $isEnabled - */ - private function updateEcotax($isEnabled) - { - $wasEnabled = (bool) $this->configuration->get('PS_USE_ECOTAX'); - - if (!$isEnabled && $wasEnabled !== $isEnabled) { - $this->productEcotaxResetter->reset(); - } - $this->configuration->set('PS_USE_ECOTAX', $isEnabled); - } -} diff --git a/src/Core/Team/Employee/Configuration/EmployeeOptionsConfiguration.php b/src/Core/Team/Employee/Configuration/EmployeeOptionsConfiguration.php deleted file mode 100644 index 8e172164..00000000 --- a/src/Core/Team/Employee/Configuration/EmployeeOptionsConfiguration.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Team\Employee\Configuration; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; - -/** - * Class EmployeeOptionsConfiguration handles configuration data for employee options. - */ -final class EmployeeOptionsConfiguration implements DataConfigurationInterface -{ - /** - * @var ConfigurationInterface - */ - private $configuration; - - /** - * @var OptionsCheckerInterface - */ - private $optionsChecker; - - /** - * @param ConfigurationInterface $configuration - */ - public function __construct(ConfigurationInterface $configuration, OptionsCheckerInterface $optionsChecker) - { - $this->configuration = $configuration; - $this->optionsChecker = $optionsChecker; - } - - /** - * {@inheritdoc} - */ - public function getConfiguration() - { - return [ - 'password_change_time' => (int) $this->configuration->get('PS_PASSWD_TIME_BACK'), - 'allow_employee_specific_language' => (int) $this->configuration->get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG'), - ]; - } - - /** - * {@inheritdoc} - */ - public function updateConfiguration(array $configuration) - { - $errors = []; - - if (!$this->optionsChecker->canBeChanged()) { - $errors[] = [ - 'key' => 'You cannot change the value of this configuration field in the context of this shop.', - 'parameters' => [], - 'domain' => 'Admin.Notifications.Warning', - ]; - - return $errors; - } - - if ($this->validateConfiguration($configuration)) { - $this->configuration->set('PS_PASSWD_TIME_BACK', (int) $configuration['password_change_time']); - $this->configuration->set( - 'PS_BO_ALLOW_EMPLOYEE_FORM_LANG', - (bool) $configuration['allow_employee_specific_language'] - ); - } - - return $errors; - } - - /** - * {@inheritdoc} - */ - public function validateConfiguration(array $configuration) - { - return isset( - $configuration['password_change_time'], - $configuration['allow_employee_specific_language'] - ); - } -} diff --git a/src/Core/Team/Employee/Configuration/OptionsChecker.php b/src/Core/Team/Employee/Configuration/OptionsChecker.php deleted file mode 100644 index 60dcdfe8..00000000 --- a/src/Core/Team/Employee/Configuration/OptionsChecker.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Team\Employee\Configuration; - -use PrestaShop\PrestaShop\Core\Feature\FeatureInterface; -use PrestaShop\PrestaShop\Core\Multistore\MultistoreContextCheckerInterface; - -/** - * Class OptionsChecker checks if employee options can be changed depending on current shop context. - */ -final class OptionsChecker implements OptionsCheckerInterface -{ - /** - * @var FeatureInterface - */ - private $multistoreFeature; - - /** - * @var MultistoreContextCheckerInterface - */ - private $multistoreContextChecker; - - /** - * @param FeatureInterface $multistoreFeature - * @param MultistoreContextCheckerInterface $multistoreContextChecker - */ - public function __construct( - FeatureInterface $multistoreFeature, - MultistoreContextCheckerInterface $multistoreContextChecker - ) { - $this->multistoreFeature = $multistoreFeature; - $this->multistoreContextChecker = $multistoreContextChecker; - } - - /** - * {@inheritdoc} - */ - public function canBeChanged() - { - if (!$this->multistoreFeature->isUsed() - && $this->multistoreContextChecker->isSingleShopContext() - ) { - return true; - } - - return $this->multistoreContextChecker->isAllShopContext(); - } -} diff --git a/src/Core/Team/Employee/Configuration/OptionsCheckerInterface.php b/src/Core/Team/Employee/Configuration/OptionsCheckerInterface.php deleted file mode 100644 index fbb451bb..00000000 --- a/src/Core/Team/Employee/Configuration/OptionsCheckerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Team\Employee\Configuration; - -/** - * Interface OptionsCheckerInterface. - */ -interface OptionsCheckerInterface -{ - /** - * Check if employee options can be changed. - * - * @return bool - */ - public function canBeChanged(); -} diff --git a/src/Core/Translation/Locale/Converter.php b/src/Core/Translation/Locale/Converter.php deleted file mode 100644 index eeefd043..00000000 --- a/src/Core/Translation/Locale/Converter.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Translation\Locale; - -/** - * Helper to manipulate the locales (IETF language tag) specific to PrestaShop - * - * @doc https://en.wikipedia.org/wiki/IETF_language_tag#Syntax_of_language_tags - */ -final class Converter -{ - /** - * @var string the path to the JSON file responsible of mapping between lang and locale - */ - private $translationsMappingFile; - - /** - * @param string $translationsMappingFile - */ - public function __construct($translationsMappingFile) - { - $this->translationsMappingFile = $translationsMappingFile; - } - - /** - * @var string the locale (like "fr-FR") - * - * @return string|bool the legacy PrestaShop locale (like "fr") - */ - public function toLegacyLocale($locale) - { - return array_search($locale, $this->getLangToLocalesMapping()); - } - - /** - * @param string $legacyLocale the legacy PrestaShop locale - * - * @return string|bool the locale - */ - public function toLanguageTag($legacyLocale) - { - $mappingLocales = $this->getLangToLocalesMapping(); - - return isset($mappingLocales[$legacyLocale]) ? $mappingLocales[$legacyLocale] : false; - } - - /** - * Get the PrestaShop locale from real locale (like "fr-FR") - * - * @return string The PrestaShop locale (like "fr_FR") - */ - public static function toPrestaShopLocale($locale) - { - return str_replace('-', '_', $locale); - } - - /** - * Extracted from TranslationService class - * - * @return mixed - * - * @throws Exception - */ - private function getLangToLocalesMapping() - { - $legacyToStandardLocalesJson = file_get_contents($this->translationsMappingFile); - $legacyToStandardLocales = json_decode($legacyToStandardLocalesJson, true); - - $jsonLastErrorCode = json_last_error(); - if (JSON_ERROR_NONE !== $jsonLastErrorCode) { - throw new Exception('The legacy to standard locales JSON could not be decoded', $jsonLastErrorCode); - } - - return $legacyToStandardLocales; - } -} diff --git a/src/Core/Util/ArabicToLatinDigitConverter.php b/src/Core/Util/ArabicToLatinDigitConverter.php deleted file mode 100644 index 6e6d9b85..00000000 --- a/src/Core/Util/ArabicToLatinDigitConverter.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Util; - -/** - * Utility class to convert arabic/persian digits to latin digits - */ -class ArabicToLatinDigitConverter -{ - public const ARABIC = 1; - - public const PERSIAN = 2; - - private const TRANSLATION_TABLE = [ - // arabic numbers - '٠' => '0', - '١' => '1', - '٢' => '2', - '٣' => '3', - '٤' => '4', - '٥' => '5', - '٦' => '6', - '٧' => '7', - '٨' => '8', - '٩' => '9', - // persian numbers (NOT the same UTF codes!) - '۰' => '0', - '۱' => '1', - '۲' => '2', - '۳' => '3', - '۴' => '4', - '۵' => '5', - '۶' => '6', - '۷' => '7', - '۸' => '8', - '۹' => '9', - ]; - - /** - * Convert from arabic/persian digits to latin digits - * - * @param string $str - * - * @return string - */ - public function convert(string $str): string - { - return strtr($str, self::TRANSLATION_TABLE); - } - - /** - * Convert from latin digits to arabic or persian digits - * - * @param string $str - * @param int $lang - * - * @return string - */ - public function reverseConvert(string $str, int $lang = self::ARABIC): string - { - $table = array_slice(self::TRANSLATION_TABLE, $lang === self::ARABIC ? 0 : 10, 10, true); - - return strtr($str, array_flip($table)); - } -} diff --git a/src/Core/Util/BoolParser.php b/src/Core/Util/BoolParser.php deleted file mode 100644 index ea090f61..00000000 --- a/src/Core/Util/BoolParser.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Util; - -class BoolParser -{ - /** - * @param string|int $value - * - * @return bool - */ - public static function castToBool($value) - { - if (is_bool($value)) { - return $value; - } - if (is_numeric($value)) { - return (bool) $value; // 0 => false; all other true - } - - return strtolower($value) !== 'false'; - } -} diff --git a/src/Core/Util/ColorBrightnessCalculator.php b/src/Core/Util/ColorBrightnessCalculator.php deleted file mode 100644 index 41bd2e29..00000000 --- a/src/Core/Util/ColorBrightnessCalculator.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Util; - -/** - * Calculates color brightness - */ -final class ColorBrightnessCalculator -{ - /** - * Minimum color value after which it's considered bright - */ - public const BRIGHT_COLOR_MIN = 130; - - /** - * @param string $hexColor - * - * @return bool - */ - public function isBright($hexColor) - { - return $this->calculate($hexColor) >= self::BRIGHT_COLOR_MIN; - } - - /** - * @param $hexColor - * - * @return float|int - */ - private function calculate($hexColor) - { - if (strtolower($hexColor) === 'transparent') { - return self::BRIGHT_COLOR_MIN; - } - - $hexColor = str_replace('#', '', $hexColor); - - if (strlen($hexColor) === 3) { - $hexColor .= $hexColor; - } - - $r = hexdec(substr($hexColor, 0, 2)); - $g = hexdec(substr($hexColor, 2, 2)); - $b = hexdec(substr($hexColor, 4, 2)); - - return (($r * 299) + ($g * 587) + ($b * 114)) / 1000; - } -} diff --git a/src/Core/Util/DateTime/DateTime.php b/src/Core/Util/DateTime/DateTime.php deleted file mode 100644 index d71eb88b..00000000 --- a/src/Core/Util/DateTime/DateTime.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Util\DateTime; - -use RuntimeException; - -/** - * Defines reusable values for DateTime - */ -final class DateTime -{ - /** - * DateTime value which should be considered same as null - */ - const NULL_VALUE = '0000-00-00 00:00:00'; - - /** - * This class only defines constants and has no reason to be initialized - */ - public function __construct() - { - throw new RuntimeException(sprintf('This class purpose is to define constants only. You might have mistaken it with "%s"', \DateTime::class)); - } -} diff --git a/src/Core/Util/DateTime/TimeDefinition.php b/src/Core/Util/DateTime/TimeDefinition.php deleted file mode 100644 index 47a71245..00000000 --- a/src/Core/Util/DateTime/TimeDefinition.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Util\DateTime; - -/** - * Class TimeDefinition defines common time intervals in different formats. - */ -final class TimeDefinition -{ - const HOUR_IN_SECONDS = 3600; - const DAY_IN_SECONDS = 86400; - - /** - * Object is not suppose to be initialized as it's responsibility is to define time constants. - */ - private function __construct() - { - } -} diff --git a/src/Core/Util/File/FileSizeConverter.php b/src/Core/Util/File/FileSizeConverter.php deleted file mode 100644 index 6ea27694..00000000 --- a/src/Core/Util/File/FileSizeConverter.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Util\File; - -/** - * Converts int value to formatted file size value - */ -class FileSizeConverter -{ - /** - * @param int $bytes - * @param int $precision - * - * @return string - */ - public function convert(int $bytes, int $precision = 2): string - { - $units = ['B', 'kB', 'MB', 'GB', 'TB']; - $bytes = max($bytes, 0); - $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); - $pow = min($pow, count($units) - 1); - - if ($bytes >= 1024) { - $bytes /= pow(1024, $pow); - $bytes = number_format(round($bytes, $precision), 2, '.', ''); - } - - return $bytes . $units[$pow]; - } -} diff --git a/src/Core/Util/File/YamlParser.php b/src/Core/Util/File/YamlParser.php deleted file mode 100644 index 2ed0337a..00000000 --- a/src/Core/Util/File/YamlParser.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Util\File; - -use InvalidArgumentException; -use RuntimeException; -use Symfony\Component\Config\ConfigCache; -use Symfony\Component\Config\Resource\FileResource; -use Symfony\Component\Yaml\Exception\ParseException; -use Symfony\Component\Yaml\Yaml; - -/** - * This class adds a cache layer on top of the standard Yaml parser for improved performance - */ -final class YamlParser -{ - /** - * @var string - */ - private $cacheDir; - - /** - * @var bool - */ - private $useCache; - - /** - * YamlParser constructor. - * - * @param string $cacheDir - * @param bool $useCache - */ - public function __construct($cacheDir, $useCache = true) - { - $this->cacheDir = $cacheDir; - $this->useCache = $useCache; - } - - /** - * Parse a YAML File and return the result - * - * @param string $sourceFile - * @param bool $forceRefresh - * - * @return mixed The YAML converted to a PHP value - * - * @throws InvalidArgumentException - * @throws RuntimeException - * @throws ParseException - */ - public function parse($sourceFile, $forceRefresh = false) - { - if (!$this->useCache) { - return Yaml::parseFile($sourceFile); - } - - $phpConfigFile = $this->getCacheFile($sourceFile); - // we set the debug flag to true to force the cache freshness check - $configCache = new ConfigCache($phpConfigFile, true); - if (!$forceRefresh && $configCache->isFresh()) { - return require $phpConfigFile; - } - - $config = Yaml::parseFile($sourceFile); - $resources = [ - new FileResource($sourceFile), - ]; - $configCache->write('cacheDir, - md5($sourceFile) - ); - } -} diff --git a/src/Core/Util/HelperCard/DocumentationLinkProvider.php b/src/Core/Util/HelperCard/DocumentationLinkProvider.php deleted file mode 100644 index 622c64a3..00000000 --- a/src/Core/Util/HelperCard/DocumentationLinkProvider.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Util\HelperCard; - -/** - * Class HelperCardDocumentationLinkProvider provides documentation links for helper cards. - */ -final class DocumentationLinkProvider implements DocumentationLinkProviderInterface -{ - /** - * @var string - */ - private $contextLangIsoCode; - - /** - * @var array - */ - private $documentationLinks; - - /** - * @param string $contextLangIsoCode - * @param array $documentationLinks - */ - public function __construct( - $contextLangIsoCode, - array $documentationLinks - ) { - $this->contextLangIsoCode = $contextLangIsoCode; - $this->documentationLinks = $documentationLinks; - } - - /** - * {@inheritdoc} - */ - public function getLink($cardType) - { - if (isset($this->documentationLinks[$cardType])) { - $cardLinks = $this->documentationLinks[$cardType]; - - if (isset($cardLinks[$this->contextLangIsoCode])) { - return $cardLinks[$this->contextLangIsoCode]; - } - - if (isset($cardLinks['_fallback'])) { - return $cardLinks['_fallback']; - } - } - - throw new HelperCardDocumentationDoesNotExistException(sprintf('Documentation for helper card "%s" does not exist', $cardType)); - } -} diff --git a/src/Core/Util/HelperCard/DocumentationLinkProviderInterface.php b/src/Core/Util/HelperCard/DocumentationLinkProviderInterface.php deleted file mode 100644 index 3ff4beeb..00000000 --- a/src/Core/Util/HelperCard/DocumentationLinkProviderInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Util\HelperCard; - -/** - * Interface DocumentationLinkProviderInterface - */ -interface DocumentationLinkProviderInterface -{ - /** - * @param string $cardType - * - * @return string Link for documentation - */ - public function getLink($cardType); -} diff --git a/src/Core/Util/HelperCard/HelperCardDocumentationDoesNotExistException.php b/src/Core/Util/HelperCard/HelperCardDocumentationDoesNotExistException.php deleted file mode 100644 index 3c4b8164..00000000 --- a/src/Core/Util/HelperCard/HelperCardDocumentationDoesNotExistException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Util\HelperCard; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Class HelperCardDocumentationDoesNotExistException - */ -class HelperCardDocumentationDoesNotExistException extends CoreException -{ -} diff --git a/src/Core/Util/InternationalizedDomainNameConverter.php b/src/Core/Util/InternationalizedDomainNameConverter.php deleted file mode 100644 index d913964b..00000000 --- a/src/Core/Util/InternationalizedDomainNameConverter.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShop\PrestaShop\Core\Util; - -class InternationalizedDomainNameConverter -{ - /** - * Convert the host part of the email from punycode to utf8 (e.g,. email@xn--e1aybc.xn--p1ai -> email@тест.рф) - * - * @param string $email - * - * @return string - */ - public function emailToUtf8(string $email): string - { - $parts = explode('@', $email); - if (count($parts) !== 2) { - return $email; - } - - return $parts[0] . '@' . idn_to_utf8($parts[1], 0, INTL_IDNA_VARIANT_UTS46); - } -} diff --git a/src/Core/Util/String/StringModifier.php b/src/Core/Util/String/StringModifier.php deleted file mode 100644 index 3fa494c0..00000000 --- a/src/Core/Util/String/StringModifier.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Util\String; - -/** - * This class defines reusable methods for strings modifications. - */ -final class StringModifier implements StringModifierInterface -{ - /** - * {@inheritdoc} - */ - public function splitByCamelCase($string) - { - $regex = '/(?)(?<=[a-z])(?=[A-Z]) | (?<=[A-Z])(?=[A-Z][a-z])/x'; - - $splitString = preg_split($regex, $string); - - return implode(' ', $splitString); - } -} diff --git a/src/Core/Util/String/StringModifierInterface.php b/src/Core/Util/String/StringModifierInterface.php deleted file mode 100644 index 0bb50154..00000000 --- a/src/Core/Util/String/StringModifierInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Util\String; - -/** - * Defines reusable methods for strings modifications. - */ -interface StringModifierInterface -{ - /** - * @param $string - * - * @return string - */ - public function splitByCamelCase($string); -} diff --git a/src/Core/Util/String/StringValidator.php b/src/Core/Util/String/StringValidator.php deleted file mode 100644 index b252069e..00000000 --- a/src/Core/Util/String/StringValidator.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Util\String; - -/** - * This class defines reusable methods for checking strings under certain conditions. - */ -final class StringValidator implements StringValidatorInterface -{ - /** - * {@inheritdoc} - */ - public function startsWith($string, $prefix) - { - return strpos($string, $prefix) === 0; - } - - /** - * {@inheritdoc} - */ - public function endsWith($string, $suffix) - { - $length = strlen($suffix); - - if (0 === $length) { - return false; - } - - return substr($string, -$length) === $suffix; - } - - /** - * {@inheritdoc} - */ - public function startsWithAndEndsWith($string, $prefix, $suffix) - { - return $this->startsWith($string, $prefix) && $this->endsWith($string, $suffix); - } - - /** - * {@inheritdoc} - */ - public function doesContainsWhiteSpaces($string) - { - return preg_match('/\s/', $string); - } -} diff --git a/src/Core/Util/String/StringValidatorInterface.php b/src/Core/Util/String/StringValidatorInterface.php deleted file mode 100644 index 9bdb3cda..00000000 --- a/src/Core/Util/String/StringValidatorInterface.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Util\String; - -/** - * Defines reusable methods for checking strings under certain conditions. - */ -interface StringValidatorInterface -{ - /** - * @param string $string - * @param string $prefix - * - * @return bool - */ - public function startsWith($string, $prefix); - - /** - * @param string $string - * @param string $suffix - * - * @return bool - */ - public function endsWith($string, $suffix); - - /** - * @param string $string - * @param string $prefix - * @param string $suffix - * - * @return bool - */ - public function startsWithAndEndsWith($string, $prefix, $suffix); - - /** - * @param string $string - * - * @return bool - */ - public function doesContainsWhiteSpaces($string); -} diff --git a/src/Core/Util/Url/BackUrlProvider.php b/src/Core/Util/Url/BackUrlProvider.php deleted file mode 100644 index 87cff697..00000000 --- a/src/Core/Util/Url/BackUrlProvider.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Util\Url; - -use Symfony\Component\HttpFoundation\Request; - -/** - * gets back url. - */ -class BackUrlProvider -{ - /** - * @param Request $request - * - * @return string - */ - public function getBackUrl(Request $request) - { - $backUrl = $request->query->get('back'); - - return urldecode($backUrl); - } -} diff --git a/src/Core/Util/Url/UrlFileChecker.php b/src/Core/Util/Url/UrlFileChecker.php deleted file mode 100644 index 5a10affa..00000000 --- a/src/Core/Util/Url/UrlFileChecker.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Util\Url; - -/** - * Class UrlFileChecker - */ -final class UrlFileChecker implements UrlFileCheckerInterface -{ - /** - * @var string - */ - private $fileDir; - - /** - * @param string $fileDir - */ - public function __construct($fileDir) - { - $this->fileDir = $fileDir; - } - - /** - * @return bool - */ - public function isHtaccessFileWritable() - { - return $this->isFileWritable('.htaccess'); - } - - /** - * @return bool - */ - public function isRobotsFileWritable() - { - return $this->isFileWritable('robots.txt'); - } - - /** - * @param string $fileName - * - * @return bool - */ - private function isFileWritable($fileName) - { - $filePath = $this->fileDir . DIRECTORY_SEPARATOR . $fileName; - - if (file_exists($filePath)) { - return is_writable($filePath); - } - - return is_writable($this->fileDir); - } -} diff --git a/src/Core/Util/Url/UrlFileCheckerInterface.php b/src/Core/Util/Url/UrlFileCheckerInterface.php deleted file mode 100644 index 3622e5d0..00000000 --- a/src/Core/Util/Url/UrlFileCheckerInterface.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Util\Url; - -/** - * Interface UrlFileCheckerInterface defines contract for UrlFileChecker. - */ -interface UrlFileCheckerInterface -{ - /** - * Check if .htaccess file for Front Office is writable. - * - * @return bool - */ - public function isHtaccessFileWritable(); - - /** - * Check if robots.txt file for Front Office is writable. - * - * @return bool - */ - public function isRobotsFileWritable(); -} diff --git a/src/Core/Validation/Validator.php b/src/Core/Validation/Validator.php deleted file mode 100644 index b57a7ca5..00000000 --- a/src/Core/Validation/Validator.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Validation; - -use PrestaShop\PrestaShop\Adapter\Validate; - -/** - * Class Validator is responsible for validating data. - */ -final class Validator implements ValidatorInterface -{ - /** - * @var Validate - */ - private $validate; - - /** - * @param Validate $validate - */ - public function __construct(Validate $validate) - { - $this->validate = $validate; - } - - /** - * {@inheritdoc} - */ - public function isCleanHtml($html, array $options = []) - { - $defaultOptions = [ - 'allow_iframe' => false, - ]; - $options = array_merge($defaultOptions, $options); - - return $this->validate->isCleanHtml($html, $options['allow_iframe']); - } - - /** - * {@inheritdoc} - */ - public function isModuleName($name) - { - return $this->validate->isModuleName($name); - } -} diff --git a/src/Core/Validation/ValidatorInterface.php b/src/Core/Validation/ValidatorInterface.php deleted file mode 100644 index 5d40f807..00000000 --- a/src/Core/Validation/ValidatorInterface.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Validation; - -interface ValidatorInterface -{ - /** - * Check if HTML is clean. - * - * @param string $html - * @param array $options - * - * @return bool - */ - public function isCleanHtml($html, array $options = []); - - /** - * Check if Module name is valid. - * - * @param string $name - * - * @return bool - */ - public function isModuleName($name); -} diff --git a/src/Core/Webservice/ServerRequirementsChecker.php b/src/Core/Webservice/ServerRequirementsChecker.php deleted file mode 100644 index 75892702..00000000 --- a/src/Core/Webservice/ServerRequirementsChecker.php +++ /dev/null @@ -1,173 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Webservice; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\Hosting\HostingInformation; -use PrestaShop\PrestaShop\Core\Configuration\PhpExtensionCheckerInterface; -use RuntimeException; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Looks at server configuration in order to check if PrestaShop's Webservice feature can be enabled. - */ -final class ServerRequirementsChecker implements ServerRequirementsCheckerInterface -{ - const ISSUE_APACHE_MOD_AUTH_BASIC_NOT_AVAILABLE = 'issue_apache_mod_auth_basic_not_available'; - const ISSUE_APACHE_MOD_AUTH_REWRITE_NOT_AVAILABLE = 'issue_apache_mod_auth_rewrite_not_available'; - const ISSUE_EXT_SIMPLEXML_NOT_AVAILABLE = 'issue_ext_simplexml_not_available'; - const ISSUE_HTTPS_NOT_AVAILABLE = 'issue_https_not_available'; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var Configuration - */ - private $configuration; - - /** - * @var HostingInformation - */ - private $hostingInformation; - - /** - * @var PhpExtensionCheckerInterface - */ - private $phpExtensionChecker; - - /** - * @param TranslatorInterface $translator - * @param Configuration $configuration - * @param HostingInformation $hostingInformation - * @param PhpExtensionCheckerInterface $phpExtensionChecker - */ - public function __construct( - TranslatorInterface $translator, - Configuration $configuration, - HostingInformation $hostingInformation, - PhpExtensionCheckerInterface $phpExtensionChecker - ) { - $this->translator = $translator; - $this->configuration = $configuration; - $this->hostingInformation = $hostingInformation; - $this->phpExtensionChecker = $phpExtensionChecker; - } - - /** - * Analyses the server configuration (apache configuration and php settings) - * to check whether PrestaShop Webservice can be used or not. - * - * @return array empty if no errors - */ - public function checkForErrors() - { - $issues = $this->lookForIssues(); - - if (empty($issues)) { - return []; - } - - $allWarningMessages = $this->getWarningMessages(); - $selectedWarningMessages = []; - - foreach ($issues as $issue) { - if (false === array_key_exists($issue, $allWarningMessages)) { - throw new RuntimeException(sprintf('Unexpected configuration issue "%s"', $issue)); - } - - $selectedWarningMessages[] = $allWarningMessages[$issue]; - } - - return $selectedWarningMessages; - } - - /** - * @return string[] - */ - private function lookForIssues() - { - $issues = []; - - if (!$this->phpExtensionChecker->loaded('SimpleXML')) { - $issues[] = self::ISSUE_EXT_SIMPLEXML_NOT_AVAILABLE; - } - - if (false === $this->configuration->getBoolean('PS_SSL_ENABLED')) { - $issues[] = self::ISSUE_HTTPS_NOT_AVAILABLE; - } - - if (false === strpos($this->hostingInformation->getServerInformation()['version'], 'Apache')) { - return $issues; - } - - if (function_exists('apache_get_modules')) { - $apache_modules = apache_get_modules(); - - if (false === in_array('mod_auth_basic', $apache_modules)) { - $issues[] = self::ISSUE_APACHE_MOD_AUTH_BASIC_NOT_AVAILABLE; - } - - if (false === in_array('mod_rewrite', $apache_modules)) { - $issues[] = self::ISSUE_APACHE_MOD_AUTH_REWRITE_NOT_AVAILABLE; - } - } - - return $issues; - } - - /** - * @return string[] - */ - private function getWarningMessages() - { - return [ - self::ISSUE_APACHE_MOD_AUTH_BASIC_NOT_AVAILABLE => $this->translator->trans( - 'Please activate the \'mod_rewrite\' Apache module to allow the PrestaShop webservice.', - [], - 'Admin.Advparameters.Notification' - ), - self::ISSUE_APACHE_MOD_AUTH_REWRITE_NOT_AVAILABLE => $this->translator->trans( - 'We could not check to see if basic authentication and rewrite extensions have been activated. Please manually check if they\'ve been activated in order to use the PrestaShop webservice.', - [], - 'Admin.Advparameters.Notification' - ), - self::ISSUE_EXT_SIMPLEXML_NOT_AVAILABLE => $this->translator->trans( - 'Please activate the \'SimpleXML\' PHP extension to allow testing of PrestaShop\'s webservice.', - [], - 'Admin.Advparameters.Notification' - ), - self::ISSUE_HTTPS_NOT_AVAILABLE => $this->translator->trans( - 'It is preferable to use SSL (https:) for webservice calls, as it avoids the "man in the middle" type security issues.', - [], - 'Admin.Advparameters.Notification' - ), - ]; - } -} diff --git a/src/Core/Webservice/ServerRequirementsCheckerInterface.php b/src/Core/Webservice/ServerRequirementsCheckerInterface.php deleted file mode 100644 index cb46eea9..00000000 --- a/src/Core/Webservice/ServerRequirementsCheckerInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShop\PrestaShop\Core\Webservice; - -/** - * Interface ServerRequirementsCheckerInterface. - */ -interface ServerRequirementsCheckerInterface -{ - /** - * Check if server meets requirements to support Webservice feature. - * - * @return array Errors if any - */ - public function checkForErrors(); -} diff --git a/src/PrestaShopBundle/Api/QueryParamsCollection.php b/src/PrestaShopBundle/Api/QueryParamsCollection.php deleted file mode 100644 index 98729134..00000000 --- a/src/PrestaShopBundle/Api/QueryParamsCollection.php +++ /dev/null @@ -1,740 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Api; - -use Doctrine\Common\Util\Inflector; -use PrestaShopBundle\Exception\InvalidPaginationParamsException; -use Symfony\Component\HttpFoundation\Request; - -abstract class QueryParamsCollection -{ - const SQL_PARAM_FIRST_RESULT = 'first_result'; - - const SQL_PARAM_MAX_RESULTS = 'max_results'; - - const SQL_CLAUSE_WHERE = 'where'; - - const SQL_CLAUSE_HAVING = 'having'; - - /** - * @var array - */ - protected $queryParams = []; - - protected $defaultPageIndex = 1; - - protected $defaultPageSize = 100; - - /** - * @return array - */ - public function getQueryParams() - { - return $this->queryParams; - } - - /** - * @return int - */ - public function getDefaultPageIndex() - { - return $this->defaultPageIndex; - } - - /** - * @return int - */ - public function getDefaultPageSize() - { - return $this->defaultPageSize; - } - - /** - * @param $pageSize int - * - * @return $this - */ - public function setPageSize($pageSize) - { - $this->queryParams['page_size'] = (int) $pageSize; - - return $this; - } - - /** - * @param $pageIndex int - * - * @return $this - */ - public function setPageIndex($pageIndex) - { - $this->queryParams['page_index'] = (int) $pageIndex; - - return $this; - } - - /** - * @param Request $request - * - * @return $this - */ - public function fromRequest(Request $request) - { - $queryParams = $request->query->all(); - - $queryParams = $this->excludeUnknownParams($queryParams); - $queryParams = $this->parsePaginationParams($queryParams); - $queryParams = $this->parseOrderParams($queryParams); - $this->queryParams = $this->parseFilterParams($queryParams, $request); - - return $this; - } - - /** - * @param $queryParams - * - * @return mixed - */ - protected function excludeUnknownParams(array $queryParams) - { - $queryParamsNames = array_keys($queryParams); - array_walk($queryParamsNames, function ($name) use (&$queryParams) { - $validParams = array_merge( - $this->getValidPaginationParams(), - $this->getValidOrderParams(), - $this->getValidFilterParams() - ); - - if (!in_array($name, $validParams)) { - unset($queryParams[$name]); - } - }); - - return $queryParams; - } - - /** - * @param array $queryParams - * @param Request $request - * - * @return array - */ - protected function parseFilterParams(array $queryParams, Request $request) - { - $allParameters = array_merge( - $request->attributes->all(), - $request->query->all() - ); - - $filters = array_filter(array_keys($allParameters), function ($filter) { - return in_array($filter, $this->getValidFilterParams()); - }); - - $filterParams = []; - array_walk($filters, function ($filter) use ($allParameters, &$filterParams) { - if (is_array($allParameters[$filter])) { - $allParameters[$filter] = array_filter($allParameters[$filter], function ($value) { - return is_int($value) || (is_string($value) && strlen(trim($value)) > 0); - }); - } - - $filterParams[$filter] = $allParameters[$filter]; - if (is_array($filterParams[$filter]) && count($filterParams[$filter]) === 0) { - unset($filterParams[$filter]); - } - }); - - $queryParams['filter'] = $filterParams; - - return $queryParams; - } - - /** - * @return array - */ - abstract protected function getValidFilterParams(); - - /** - * @param array $queryParams - * - * @return array - */ - protected function parsePaginationParams(array $queryParams) - { - if (!array_key_exists('page_index', $queryParams)) { - $queryParams['page_index'] = $this->getDefaultPageIndex(); - } - - if (!array_key_exists('page_size', $queryParams)) { - $queryParams['page_size'] = $this->getDefaultPageSize(); - } - - $queryParams['page_size'] = (int) $queryParams['page_size']; - $queryParams['page_index'] = (int) $queryParams['page_index']; - - if ( - $queryParams['page_size'] > $this->getDefaultPageSize() || - $queryParams['page_size'] < 1 - ) { - throw new InvalidPaginationParamsException(sprintf('A page size should be an integer greater than 1 and fewer than %s', $this->getDefaultPageSize())); - } - - if ($queryParams['page_index'] < 1) { - throw new InvalidPaginationParamsException(); - } - - return $queryParams; - } - - /** - * @return array - */ - protected function getValidPaginationParams() - { - return [ - 'page_size', - 'page_index', - 'order', - ]; - } - - /** - * @param array $queryParams - * - * @return array|mixed - */ - protected function parseOrderParams(array $queryParams) - { - if (!array_key_exists('order', $queryParams)) { - $queryParams = $this->setDefaultOrderParam($queryParams); - } - - if (!is_array($queryParams['order'])) { - $queryParams['order'] = (array) $queryParams['order']; - } - - foreach ($queryParams['order'] as $key => &$order) { - $order = strtolower($order); - $filterColumn = $this->removeDirection($order); - - if (!in_array($filterColumn, $this->getValidOrderParams())) { - unset($queryParams['order'][$key]); - } - } - - if (empty($queryParams['order'])) { - $queryParams = $this->setDefaultOrderParam($queryParams); - } - - return $queryParams; - } - - /** - * @return array - */ - abstract protected function getValidOrderParams(); - - /** - * @param $queryParams - * - * @return mixed - */ - abstract protected function setDefaultOrderParam($queryParams); - - /** - * @param $subject - * - * @return mixed - */ - protected function removeDirection($subject) - { - $subject = str_replace(' asc', '', $subject); - - return str_replace(' desc', '', $subject); - } - - /** - * @return string - */ - public function getSqlOrder() - { - $implodableOrder = []; - - foreach ($this->queryParams['order'] as $order) { - $descendingOrder = false !== strpos($order, 'desc'); - $filterColumn = $this->removeDirection($order); - - $orderFiltered = '{' . $filterColumn . '}'; - - if ($descendingOrder) { - $orderFiltered = $orderFiltered . ' DESC'; - } - - $implodableOrder[] = $orderFiltered; - } - - return 'ORDER BY ' . implode(', ', $implodableOrder) . ' '; - } - - /** - * @return array - */ - public function getSqlFilters() - { - $whereFilters = []; - - foreach ($this->queryParams['filter'] as $column => $value) { - $whereFilters = $this->appendSqlFilter($value, $column, $whereFilters); - } - - $filters = [ - self::SQL_CLAUSE_WHERE => implode("\n", $whereFilters), - ]; - - $filters = $this->appendSqlSearchFilter($filters); - - return $filters; - } - - /** - * @return bool - */ - protected function hasSearchFilter() - { - return array_key_exists('keywords', $this->queryParams['filter']); - } - - /** - * @param $value - * @param $column - * @param array $filters - * - * @return array - */ - protected function appendSqlFilter($value, $column, array $filters) - { - $column = Inflector::tableize($column); - - if ('attributes' === $column) { - return $this->appendSqlAttributesFilter($filters, $value); - } - - if ('features' === $column) { - return $this->appendSqlFeaturesFilter($filters, $value); - } - - if ('keywords' === $column) { - return $filters; - } - - if ('category_id' === $column) { - return $this->appendSqlCategoryFilter($filters); - } - - if ('date_add' === $column) { - return $this->appendSqlDateAddFilter($filters, $value); - } - - if ('active' === $column) { - return $this->appendSqlActiveFilter($filters, $value); - } - - if (!is_array($value)) { - $filters[] = sprintf('AND {%s} = :%s', $column, $column); - - return $filters; - } - - $placeholders = array_map(function ($index) use ($column) { - return ':' . $column . '_' . $index; - }, array_keys($value)); - - $filters[] = sprintf('AND {%s} IN (%s)', $column, implode(',', $placeholders)); - - return $filters; - } - - /** - * @return array - */ - public function getSqlParams() - { - return array_merge( - $this->getSqlPaginationParams(), - $this->getSqlFiltersParams() - ); - } - - /** - * @return array - */ - public function getSqlPaginationParams() - { - $maxResult = $this->queryParams['page_size']; - $pageIndex = $this->queryParams['page_index']; - $firstResult = ($pageIndex - 1) * $maxResult; - - return [ - self::SQL_PARAM_MAX_RESULTS => (int) $maxResult, - self::SQL_PARAM_FIRST_RESULT => (int) $firstResult, - ]; - } - - /** - * @return array - */ - private function getSqlFiltersParams() - { - $sqlParams = []; - - if (count($this->queryParams['filter']) === 0) { - return $sqlParams; - } - - foreach ($this->queryParams['filter'] as $column => $value) { - $sqlParams = $this->appendSqlFilterParams($column, $value, $sqlParams); - } - - return $sqlParams; - } - - /** - * @param $column - * @param $value - * @param $sqlParams - * - * @return mixed - */ - protected function appendSqlFilterParams($column, $value, $sqlParams) - { - $column = Inflector::tableize($column); - - if ('attributes' === $column) { - return $this->appendSqlAttributesFilterParam($value, $sqlParams); - } - - if ('features' === $column) { - return $this->appendSqlFeaturesFilterParam($value, $sqlParams); - } - - if ('keywords' === $column) { - return $this->appendSqlSearchFilterParam($value, $sqlParams); - } - - if ('category_id' === $column) { - return $this->appendSqlCategoryFilterParam($value, $sqlParams); - } - - if ('date_add' === $column) { - return $this->appendSqlDateAddFilterParam($value, $sqlParams); - } - - if ('active' === $column) { - return $this->appendSqlActiveFilterParam($value, $sqlParams); - } - - if (!is_array($value)) { - $sqlParams[$column] = (int) $value; - - return $sqlParams; - } - - array_map(function ($index, $value) use (&$sqlParams, $column) { - $sqlParams[$column . '_' . $index] = (int) $value; - }, array_keys($value), $value); - - return $sqlParams; - } - - /** - * @param array $filters - * - * @return array - */ - protected function appendSqlCategoryFilter(array $filters) - { - $filters[] = 'AND EXISTS(SELECT 1 FROM {table_prefix}category_product cp - WHERE cp.id_product=p.id_product AND FIND_IN_SET(cp.id_category, :categories_ids))'; - - return $filters; - } - - /** - * @param $value - * @param $sqlParams - * - * @return mixed - */ - protected function appendSqlCategoryFilterParam($value, $sqlParams) - { - if (!is_array($value)) { - $value = [$value]; - } - - $value = array_map('intval', $value); - $sqlParams[':categories_ids'] = implode(',', $value); - - return $sqlParams; - } - - /** - * @param array $filters - * @param dateAdd - * - * @return array - */ - protected function appendSqlDateAddFilter(array $filters, $dateAdd) - { - if (!is_array($dateAdd)) { - $dateAdd = [$dateAdd]; - } - - if (array_key_exists('sup', $dateAdd)) { - $search = ($this->isTimestamp($dateAdd['sup']) ? 'UNIX_TIMESTAMP(%s)' : '%s'); - $filters[] = sprintf('AND ' . $search . ' >= %s', '{date_add}', ':date_add_sup'); - } - if (array_key_exists('inf', $dateAdd)) { - $search = ($this->isTimestamp($dateAdd['inf']) ? 'UNIX_TIMESTAMP(%s)' : '%s'); - $filters[] = sprintf('AND ' . $search . ' <= %s', '{date_add}', ':date_add_inf'); - } - - return $filters; - } - - /** - * @param $value - * @param $sqlParams - * - * @return mixed - */ - protected function appendSqlDateAddFilterParam($value, $sqlParams) - { - if (!is_array($value)) { - $value = [$value]; - } - - if (array_key_exists('sup', $value)) { - $sqlParams[':date_add_sup'] = $value['sup']; - } - if (array_key_exists('inf', $value)) { - $sqlParams[':date_add_inf'] = $value['inf']; - } - - return $sqlParams; - } - - /** - * @param array $filters - * @param active - * - * @return array - */ - protected function appendSqlActiveFilter(array $filters, $active) - { - if (in_array($active, ['0', '1'])) { - $filters[] = sprintf('AND %s = %s', '{active}', ':active'); - } - - return $filters; - } - - /** - * @param $value - * @param $sqlParams - * - * @return mixed - */ - protected function appendSqlActiveFilterParam($value, $sqlParams) - { - if (in_array($value, ['0', '1'])) { - $sqlParams[':active'] = $value; - } - - return $sqlParams; - } - - /** - * @param array $filters - * @param $attributes - * - * @return array - */ - protected function appendSqlAttributesFilter(array $filters, $attributes) - { - if (!is_array($attributes)) { - $attributes = [$attributes]; - } - - $attributesKeys = array_keys($attributes); - array_walk($attributesKeys, function ($key) use (&$filters) { - $filters[] = sprintf('AND EXISTS(SELECT 1 - FROM {table_prefix}product_attribute_combination pac - LEFT JOIN {table_prefix}attribute a ON ( - pac.id_attribute = a.id_attribute - ) - WHERE pac.id_product_attribute=pa.id_product_attribute - AND a.id_attribute=:attribute_id_%d - AND a.id_attribute_group=:attribute_group_id_%d)', $key, $key); - }); - - return $filters; - } - - /** - * @param array $value - * @param $sqlParams - * - * @return array - */ - protected function appendSqlAttributesFilterParam($value, $sqlParams) - { - if (!is_array($value)) { - $value = [$value]; - } - - array_map(function ($index, $value) use (&$sqlParams) { - list($idAttributeGroup, $idAttribute) = explode(':', $value); - $sqlParams['attribute_id_' . $index] = (string) $idAttribute; - $sqlParams['attribute_group_id_' . $index] = (string) $idAttributeGroup; - }, range(0, count($value) - 1), $value); - - return $sqlParams; - } - - /** - * @param array $filters - * @param $attributes - * - * @return array - */ - protected function appendSqlFeaturesFilter(array $filters, $attributes) - { - if (!is_array($attributes)) { - $attributes = [$attributes]; - } - - $attributesKeys = array_keys($attributes); - array_walk($attributesKeys, function ($key) use (&$filters) { - $filters[] = sprintf('AND EXISTS(SELECT 1 - FROM {table_prefix}feature_product fp - LEFT JOIN {table_prefix}feature f ON ( - fp.id_feature = f.id_feature - ) - LEFT JOIN {table_prefix}feature_shop fs ON ( - fs.id_shop = :shop_id AND - fs.id_feature = f.id_feature - ) - LEFT JOIN {table_prefix}feature_value fv ON ( - f.id_feature = fv.id_feature AND - fp.id_feature_value = fv.id_feature_value - ) - WHERE fv.custom = 0 AND fp.id_product=p.id_product - AND fp.id_feature=:feature_id_%d - AND fp.id_feature_value=:feature_value_id_%d)', $key, $key); - }); - - return $filters; - } - - /** - * @param array $value - * @param $sqlParams - * - * @return array - */ - protected function appendSqlFeaturesFilterParam($value, $sqlParams) - { - if (!is_array($value)) { - $value = [$value]; - } - - array_map(function ($index, $value) use (&$sqlParams) { - list($idFeature, $idFeatureValue) = explode(':', $value); - $sqlParams['feature_id_' . $index] = (string) $idFeature; - $sqlParams['feature_value_id_' . $index] = (string) $idFeatureValue; - }, range(0, count($value) - 1), $value); - - return $sqlParams; - } - - /** - * @param $filters - * - * @return mixed - */ - protected function appendSqlSearchFilter($filters) - { - if (!$this->hasSearchFilter()) { - return $filters; - } - - if (!is_array($this->queryParams['filter']['keywords'])) { - $this->queryParams['filter']['keywords'] = (array) $this->queryParams['filter']['keywords']; - } - - $parts = array_map(function ($index) { - return sprintf( - 'AND (' . - '{supplier_name} LIKE :keyword_%d OR ' . - '{product_reference} LIKE :keyword_%d OR ' . - '{product_name} LIKE :keyword_%d OR ' . - '{combination_name} LIKE :keyword_%d' . - ')', - $index, - $index, - $index, - $index - ); - }, range(0, count($this->queryParams['filter']['keywords']) - 1)); - - $filters[self::SQL_CLAUSE_HAVING] = implode("\n", $parts); - - return $filters; - } - - protected function appendSqlSearchFilterParam($value, $sqlParams) - { - if (!is_array($value)) { - $value = [$value]; - } - - array_map(function ($index, $value) use (&$sqlParams) { - $sqlParams['keyword_' . $index] = (string) ('%' . $value . '%'); - }, range(0, count($value) - 1), $value); - - return $sqlParams; - } - - protected function isTimestamp($timestamp) - { - $check = (is_int($timestamp) || is_float($timestamp)) ? $timestamp : (string) (int) $timestamp; - - return ($check === $timestamp) - && ((int) $timestamp <= PHP_INT_MAX) - && ((int) $timestamp >= ~PHP_INT_MAX); - } -} diff --git a/src/PrestaShopBundle/Api/QueryStockMovementParamsCollection.php b/src/PrestaShopBundle/Api/QueryStockMovementParamsCollection.php deleted file mode 100644 index c40304e8..00000000 --- a/src/PrestaShopBundle/Api/QueryStockMovementParamsCollection.php +++ /dev/null @@ -1,73 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Api; - -class QueryStockMovementParamsCollection extends QueryStockParamsCollection -{ - /** - * @return array - */ - protected function getValidFilterParams() - { - return [ - 'productId', - 'supplier_id', - 'category_id', - 'keywords', - 'attributes', - 'features', - 'date_add', - 'id_employee', - 'id_stock_mvt_reason', - ]; - } - - /** - * @return array - */ - protected function getValidOrderParams() - { - return [ - 'product', - 'reference', - 'date_add', - 'id_stock_mvt', - ]; - } - - /** - * @param $queryParams - * - * @return mixed - */ - protected function setDefaultOrderParam($queryParams) - { - $queryParams['order'] = ['id_stock_mvt DESC']; - - return $queryParams; - } -} diff --git a/src/PrestaShopBundle/Api/QueryStockParamsCollection.php b/src/PrestaShopBundle/Api/QueryStockParamsCollection.php deleted file mode 100644 index 8c75300a..00000000 --- a/src/PrestaShopBundle/Api/QueryStockParamsCollection.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Api; - -class QueryStockParamsCollection extends QueryParamsCollection -{ - /** - * @param array $queryParams - * - * @return array|mixed - */ - protected function parseOrderParams(array $queryParams) - { - $queryParams = parent::parseOrderParams($queryParams); - - if (array_key_exists('low_stock', $queryParams) && 1 == $queryParams['low_stock']) { - array_unshift($queryParams['order'], 'product_low_stock_alert desc'); - } - - return $queryParams; - } - - /** - * @return array - */ - protected function getValidFilterParams() - { - return [ - 'productId', - 'supplier_id', - 'category_id', - 'keywords', - 'attributes', - 'features', - 'active', - ]; - } - - /** - * @return array - */ - protected function getValidOrderParams() - { - return [ - 'product', - 'reference', - 'supplier', - 'available_quantity', - 'physical_quantity', - 'active', - 'low_stock', - ]; - } - - /** - * @param $queryParams - * - * @return mixed - */ - protected function setDefaultOrderParam($queryParams) - { - $queryParams['order'] = ['product DESC']; - - return $queryParams; - } -} diff --git a/src/PrestaShopBundle/Api/QueryTranslationParamsCollection.php b/src/PrestaShopBundle/Api/QueryTranslationParamsCollection.php deleted file mode 100644 index 21d4495d..00000000 --- a/src/PrestaShopBundle/Api/QueryTranslationParamsCollection.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Api; - -class QueryTranslationParamsCollection extends QueryParamsCollection -{ - protected $defaultPageIndex = 1; - - protected $defaultPageSize = 20; - - /** - * @return array - */ - protected function getValidFilterParams() - { - return []; - } - - /** - * @return array - */ - protected function getValidOrderParams() - { - return []; - } - - /** - * @param $queryParams - * - * @return mixed - */ - protected function setDefaultOrderParam($queryParams) - { - $queryParams['order'] = ['unknown']; - - return $queryParams; - } -} diff --git a/src/PrestaShopBundle/Api/Stock/Movement.php b/src/PrestaShopBundle/Api/Stock/Movement.php deleted file mode 100644 index 5032db49..00000000 --- a/src/PrestaShopBundle/Api/Stock/Movement.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Api\Stock; - -use PrestaShopBundle\Entity\ProductIdentity; - -class Movement -{ - /** - * @var ProductIdentity - */ - private $productIdentity; - - /** - * @var int - */ - private $delta; - - public function __construct(ProductIdentity $productIdentity, $delta) - { - $this->productIdentity = $productIdentity; - $this->delta = (int) $delta; - } - - /** - * @return ProductIdentity - */ - public function getProductIdentity() - { - return $this->productIdentity; - } - - /** - * @return int - */ - public function getDelta() - { - return $this->delta; - } -} diff --git a/src/PrestaShopBundle/Api/Stock/MovementsCollection.php b/src/PrestaShopBundle/Api/Stock/MovementsCollection.php deleted file mode 100644 index d638f3cd..00000000 --- a/src/PrestaShopBundle/Api/Stock/MovementsCollection.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Api\Stock; - -use PrestaShopBundle\Entity\ProductIdentity; - -class MovementsCollection -{ - private $movements = []; - - /** - * @param array $stockMovementsParams - * - * @return $this - */ - public function fromArray(array $stockMovementsParams) - { - $movements = []; - - array_walk($stockMovementsParams, function ($item) use (&$movements) { - $combinationId = 0; - - if ($item['delta'] != 0) { - if (array_key_exists('combination_id', $item)) { - $combinationId = $item['combination_id']; - } - - $productIdentity = ProductIdentity::fromArray([ - 'product_id' => $item['product_id'], - 'combination_id' => $combinationId, - ]); - - $movements[] = new Movement($productIdentity, $item['delta']); - } - }); - - $this->movements = $movements; - - return $this; - } - - /** - * @param callable $callback - * - * @return array - */ - public function map(callable $callback) - { - return array_map($callback, $this->movements); - } -} diff --git a/src/PrestaShopBundle/Cache/CacheWarmer.php b/src/PrestaShopBundle/Cache/CacheWarmer.php deleted file mode 100644 index b18b3058..00000000 --- a/src/PrestaShopBundle/Cache/CacheWarmer.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Cache; - -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; - -class CacheWarmer implements CacheWarmerInterface -{ - private $fileSystem; - - public function __construct(FileSystem $fileSystem) - { - $this->fileSystem = $fileSystem; - } - - public function warmUp($cacheDir) - { - $legacyDirs = [ - $cacheDir . DIRECTORY_SEPARATOR . 'cachefs', - $cacheDir . DIRECTORY_SEPARATOR . 'purifier', - $cacheDir . DIRECTORY_SEPARATOR . 'push', - $cacheDir . DIRECTORY_SEPARATOR . 'sandbox', - $cacheDir . DIRECTORY_SEPARATOR . 'tcpdf', - ]; - - $this->fileSystem->mkdir($legacyDirs); - } - - public function isOptional() - { - return false; - } -} diff --git a/src/PrestaShopBundle/Cache/Factory/CacheSubscriberFactory.php b/src/PrestaShopBundle/Cache/Factory/CacheSubscriberFactory.php deleted file mode 100644 index d4ae95ce..00000000 --- a/src/PrestaShopBundle/Cache/Factory/CacheSubscriberFactory.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Cache\Factory; - -use GuzzleHttp\Message\Request; -use GuzzleHttp\Subscriber\Cache\CacheStorageInterface; -use GuzzleHttp\Subscriber\Cache\CacheSubscriber; - -/** - * Instanciate a CacheSubscriber for Guzzle - */ -final class CacheSubscriberFactory -{ - /** - * @param CacheStorageInterface $storage - * - * @return CacheSubscriber - */ - public function create(CacheStorageInterface $storage) - { - return new CacheSubscriber($storage, function (Request $request) { return true; }); - } -} diff --git a/src/PrestaShopBundle/Cache/LocalizationWarmer.php b/src/PrestaShopBundle/Cache/LocalizationWarmer.php deleted file mode 100644 index 68cd6174..00000000 --- a/src/PrestaShopBundle/Cache/LocalizationWarmer.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Cache; - -use Symfony\Component\Filesystem\Exception\IOExceptionInterface; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface; - -class LocalizationWarmer implements CacheWarmerInterface -{ - private $version; - private $country; - - public function __construct($version, $country) - { - $this->version = $version; - $this->country = $country; - } - - public function warmUp($cacheDir) - { - $fs = new Filesystem(); - - if (is_dir($cacheDir)) { - try { - $fs->mkdir($cacheDir); - } catch (IOExceptionInterface $e) { - //@todo: log - } - } - - $path_cache_file = $cacheDir . $this->version . $this->country . '.xml'; - - if (is_file($path_cache_file)) { - $localization_file_content = file_get_contents($path_cache_file); - } else { - $localization_file = _PS_ROOT_DIR_ . '/localization/default.xml'; - - if (file_exists(_PS_ROOT_DIR_ . '/localization/' . $this->country . '.xml')) { - $localization_file = _PS_ROOT_DIR_ . '/localization/' . $this->country . '.xml'; - } - - $localization_file_content = file_get_contents($localization_file); - - try { - $fs->dumpFile($path_cache_file, $localization_file_content); - } catch (IOExceptionInterface $e) { - //@todo: log - } - } - - return $localization_file_content; - } - - public function isOptional() - { - return false; - } -} diff --git a/src/PrestaShopBundle/Cache/ModuleTemplateCacheWarmer.php b/src/PrestaShopBundle/Cache/ModuleTemplateCacheWarmer.php deleted file mode 100644 index 5516ea84..00000000 --- a/src/PrestaShopBundle/Cache/ModuleTemplateCacheWarmer.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Cache; - -use Psr\Container\ContainerInterface; -use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface; -use Symfony\Bundle\TwigBundle\CacheWarmer\TemplateCacheCacheWarmer; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Templating\TemplateReference; -use Twig\Error\Error; - -/** - * Generates the Twig cache for all paths, with a specific filter for given namespace - */ -class ModuleTemplateCacheWarmer extends TemplateCacheCacheWarmer -{ - private $paths; - - /** - * {@inheritdoc} - */ - public function __construct(ContainerInterface $container, TemplateFinderInterface $finder = null, $paths = []) - { - $this->paths = []; - $keyToRemove = array_search('Modules', $paths); - // If the key was found, move it in a new array - if (false !== $keyToRemove) { - $exceptionPath = $paths[$keyToRemove]; - unset($paths[$keyToRemove]); - $this->paths = [$keyToRemove => $exceptionPath]; - } - parent::__construct($container, $finder, $paths); - } - - /** - * {@inheritdoc} - */ - public function warmUp($cacheDir) - { - // Default behavior for all folder except Modules - parent::warmUp($cacheDir); - - $twig = $this->container->get('twig'); - $templates = []; - - foreach ($this->paths as $path => $namespace) { - $templates = array_merge($templates, $this->findTemplatesInFolder($namespace, $path)); - } - - foreach ($templates as $template) { - if ('twig' !== $template->get('engine')) { - continue; - } - - try { - $twig->loadTemplate($template); - } catch (Error $e) { - // problem during compilation, give up - } - } - } - - /** - * Find templates from *.twig files in the given directory. - * - * @param string $namespace The namespace for these templates - * @param string $dir The folder where to look for templates - * - * @return array An array of templates of type TemplateReferenceInterface - */ - private function findTemplatesInFolder($namespace, $dir) - { - if (!is_dir($dir)) { - return []; - } - - $templates = []; - $finder = new Finder(); - - foreach ($finder->files()->followLinks()->name('*.twig')->in($dir) as $file) { - $name = $file->getRelativePathname(); - $templates[] = new TemplateReference( - $namespace ? sprintf('@%s/%s', $namespace, $name) : $name, - 'twig' - ); - } - - return $templates; - } -} diff --git a/src/PrestaShopBundle/Command/AppendConfigurationFileHooksListCommand.php b/src/PrestaShopBundle/Command/AppendConfigurationFileHooksListCommand.php deleted file mode 100644 index aab62d6a..00000000 --- a/src/PrestaShopBundle/Command/AppendConfigurationFileHooksListCommand.php +++ /dev/null @@ -1,242 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Command; - -use Employee; -use Exception; -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use PrestaShop\PrestaShop\Core\Hook\HookDescription; -use SimpleXMLElement; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\Finder\Finder; - -/** - * This command is used for appending the hook names in the configuration file. - */ -class AppendConfigurationFileHooksListCommand extends ContainerAwareCommand -{ - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('prestashop:update:configuration-file-hooks-listing') - ->setDescription('Appends configuration file hooks list') - ; - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $container = $this->getContainer(); - - $this->initContext(); - - $io = new SymfonyStyle($input, $output); - - if (!in_array($container->getParameter('kernel.environment'), ['dev', 'test'])) { - $io->warning('Dev or test environment is required to fully list all the hooks'); - - return; - } - - $hookNames = $this->getHookNames(); - $hookDescriptions = $this->getHookDescriptions($hookNames); - - try { - $addedHooks = $this->appendHooksInConfigurationFile($hookDescriptions); - } catch (Exception $e) { - $io->error($e->getMessage()); - } - - if (!empty($addedHooks)) { - $io->title('Hooks added to configuration file'); - $io->note(sprintf('Total hooks added: %s', count($addedHooks))); - - return; - } - - $io->note('No new hooks have been added to configuration file'); - } - - /** - * Initialize PrestaShop Context - */ - private function initContext() - { - /** @var LegacyContext $legacyContext */ - $legacyContext = $this->getContainer()->get('prestashop.adapter.legacy.context'); - //We need to have an employee or the listing hooks don't work - //see LegacyHookSubscriber - if (!$legacyContext->getContext()->employee) { - //Even a non existing employee is fine - $legacyContext->getContext()->employee = new Employee(); - } - } - - /** - * Gets all hooks names which need to be appended. - * - * @return string[] - */ - private function getHookNames() - { - $container = $this->getContainer(); - - $gridServiceIds = $container->getParameter('prestashop.core.grid.definition.service_ids'); - $optionsFormHookNames = $container->getParameter('prestashop.hook.option_form_hook_names'); - $identifiableObjectFormTypes = $container->getParameter('prestashop.core.form.identifiable_object.form_types'); - - $gridDefinitionHooksProvider = $container->get( - 'prestashop.core.hook.provider.grid_definition_hook_by_service_ids_provider' - ); - - $identifiableObjectFormTypeProvider = $container->get( - 'prestashop.core.hook.provider.identifiable_object_hook_by_form_type_provider' - ); - - $gridDefinitionHookNames = $gridDefinitionHooksProvider->getHookNames($gridServiceIds); - - $identifiableObjectHookNames = $identifiableObjectFormTypeProvider->getHookNames($identifiableObjectFormTypes); - - return array_merge( - $identifiableObjectHookNames, - $optionsFormHookNames, - $gridDefinitionHookNames - ); - } - - /** - * Appends given hooks in the configuration file. - * - * @param HookDescription[] $hookDescriptions - * - * @return array - * - * @throws Exception - */ - private function appendHooksInConfigurationFile(array $hookDescriptions) - { - $hookConfigurationFileLocation = $this->getContainer()->get('kernel')->getRootDir() . '/../install-dev/data/xml/'; - $hookFileName = 'hook.xml'; - $fullFilePath = $hookConfigurationFileLocation . $hookFileName; - - $filesFinder = new Finder(); - $filesFinder - ->files() - ->in($hookConfigurationFileLocation) - ->name($hookFileName) - ; - - $hookFileContent = null; - - foreach ($filesFinder as $fileInfo) { - $hookFileContent = $fileInfo->getContents(); - - break; - } - - if (!$hookFileContent) { - throw new Exception(sprintf('File %s has not been found', $fullFilePath)); - } - - $xmlFileContent = new SimpleXMLElement($hookFileContent); - - if (!isset($xmlFileContent->entities, $xmlFileContent->entities->hook)) { - return []; - } - - $existingHookNames = $this->filterExistingHookNames($xmlFileContent->entities->hook); - - $addedHooks = []; - foreach ($hookDescriptions as $hookDescription) { - if (in_array($hookDescription->getName(), $existingHookNames)) { - continue; - } - - $hook = $xmlFileContent->entities->addChild('hook'); - - $hook->addAttribute('id', $hookDescription->getName()); - $hook->addChild('name', $hookDescription->getName()); - $hook->addChild('title', $hookDescription->getTitle()); - $hook->addChild('description', $hookDescription->getDescription()); - - $addedHooks[] = $hookDescription; - } - - if (!$xmlFileContent->saveXML($fullFilePath)) { - throw new Exception(sprintf('Failed to save new xml content to file %s', $fullFilePath)); - } - - return $addedHooks; - } - - /** - * Gets existing hook names which are already defined in the file. - * - * @param SimpleXMLElement $hooksFromXmlFile - * - * @return array - */ - private function filterExistingHookNames(SimpleXMLElement $hooksFromXmlFile) - { - $hookNames = []; - foreach ($hooksFromXmlFile as $hook) { - if (!isset($hook->name)) { - continue; - } - - $hookNames[] = $hook->name->__toString(); - } - - return $hookNames; - } - - /** - * Gets hook descriptions - * - * @param array $hookNames - * - * @return HookDescription[] - */ - private function getHookDescriptions(array $hookNames) - { - $descriptionGenerator = $this->getContainer()->get('prestashop.core.hook.generator.hook_description_generator'); - - $descriptions = []; - foreach ($hookNames as $hookName) { - $hookDescription = $descriptionGenerator->generate($hookName); - - $descriptions[] = $hookDescription; - } - - return $descriptions; - } -} diff --git a/src/PrestaShopBundle/Command/AppendHooksListForSqlUpgradeFileCommand.php b/src/PrestaShopBundle/Command/AppendHooksListForSqlUpgradeFileCommand.php deleted file mode 100644 index 8f916677..00000000 --- a/src/PrestaShopBundle/Command/AppendHooksListForSqlUpgradeFileCommand.php +++ /dev/null @@ -1,268 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Command; - -use Employee; -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use PrestaShop\PrestaShop\Core\Hook\HookDescription; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\Filesystem\Exception\FileNotFoundException; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Finder\SplFileInfo; - -/** - * Appends sql upgrade file with the sql which can be used to create new hooks. - */ -class AppendHooksListForSqlUpgradeFileCommand extends ContainerAwareCommand -{ - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('prestashop:update:sql-upgrade-file-hooks-listing') - ->setDescription( - 'Adds sql to sql upgrade file which contains hook insert opeartion' - ) - ->addArgument( - 'ps-version', - InputArgument::REQUIRED, - 'The prestashop version for which sql upgrade file will be searched' - ) - ; - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $container = $this->getContainer(); - - $this->initContext(); - - $io = new SymfonyStyle($input, $output); - - if (!in_array($container->getParameter('kernel.environment'), ['dev', 'test'])) { - $io->warning('Dev or test environment is required to fully list all the hooks'); - - return; - } - - $hookNames = $this->getHookNames(); - $hookNames = $this->getWithoutRegisteredHooks($hookNames); - - if (empty($hookNames)) { - $io->note('No hooks found.'); - - return; - } - - $hookDescriptions = $this->getHookDescriptions($hookNames); - - try { - $sqlUpgradeFile = $this->getSqlUpgradeFileByPrestaShopVersion($input->getArgument('ps-version')); - } catch (FileNotFoundException $exception) { - $io->error($exception->getMessage()); - - return; - } - - $sqlInsertStatement = $this->getSqlInsertStatement($hookDescriptions); - - $this->appendSqlToFile($sqlUpgradeFile->getFileInfo()->getPathName(), $sqlInsertStatement); - - $io->success( - sprintf( - 'All %s hooks have been listed to file %s', - count($hookNames), - $sqlUpgradeFile->getFileInfo()->getPathName() - ) - ); - } - - /** - * Initialize PrestaShop Context - */ - private function initContext() - { - /** @var LegacyContext $legacyContext */ - $legacyContext = $this->getContainer()->get('prestashop.adapter.legacy.context'); - //We need to have an employee or the listing hooks don't work - //see LegacyHookSubscriber - if (!$legacyContext->getContext()->employee) { - //Even a non existing employee is fine - $legacyContext->getContext()->employee = new Employee(); - } - } - - /** - * Gets all hooks names which need to be appended. - * - * @return string[] - */ - private function getHookNames() - { - $container = $this->getContainer(); - - $gridServiceIds = $container->getParameter('prestashop.core.grid.definition.service_ids'); - $optionsFormHookNames = $container->getParameter('prestashop.hook.option_form_hook_names'); - $identifiableObjectFormTypes = $container->getParameter('prestashop.core.form.identifiable_object.form_types'); - - $gridDefinitionHooksProvider = $container->get( - 'prestashop.core.hook.provider.grid_definition_hook_by_service_ids_provider' - ); - - $identifiableObjectFormTypeProvider = $container->get( - 'prestashop.core.hook.provider.identifiable_object_hook_by_form_type_provider' - ); - - $gridDefinitionHookNames = $gridDefinitionHooksProvider->getHookNames($gridServiceIds); - - $identifiableObjectHookNames = $identifiableObjectFormTypeProvider->getHookNames($identifiableObjectFormTypes); - - return array_merge( - $identifiableObjectHookNames, - $optionsFormHookNames, - $gridDefinitionHookNames - ); - } - - /** - * Gets sql upgrade file by PrestaShop version. - * - * @param string $version - * - * @return SplFileInfo - */ - private function getSqlUpgradeFileByPrestaShopVersion($version) - { - $sqlUpgradeFilesLocation = $this->getContainer()->get('kernel')->getRootDir() . '/../install-dev/upgrade/sql/'; - $sqlUpgradeFile = $version . '.sql'; - - $filesFinder = new Finder(); - $filesFinder - ->files() - ->in($sqlUpgradeFilesLocation) - ->name($sqlUpgradeFile) - ; - - $filesCount = $filesFinder->count(); - - if (1 !== $filesCount) { - throw new FileNotFoundException(sprintf('Expected to find 1 file but %s files found with name %s', $filesFinder->count(), $sqlUpgradeFile)); - } - - foreach ($filesFinder as $sqlInfo) { - return $sqlInfo; - } - - return null; - } - - /** - * Gets sql insert statement. - * - * @param HookDescription[] $hookDescriptions - * - * @return string - */ - private function getSqlInsertStatement(array $hookDescriptions) - { - $valuesToInsert = []; - foreach ($hookDescriptions as $hookDescription) { - $valuesToInsert[] = sprintf( - '(NULL,"%s","%s","%s","1")', - pSQL($hookDescription->getName()), - pSQL($hookDescription->getTitle()), - pSQL($hookDescription->getDescription()) - ); - } - - if (empty($valuesToInsert)) { - return ''; - } - - return sprintf( - 'INSERT IGNORE INTO `PREFIX_hook` (`id_hook`, `name`, `title`, `description`, `position`) VALUES %s;', - implode(',', $valuesToInsert) - ); - } - - /** - * Appends new content to the given file. - * - * @param string $pathToFile - * @param string $content - */ - private function appendSqlToFile($pathToFile, $content) - { - $fileSystem = new FileSystem(); - - $fileSystem->appendToFile($pathToFile, $content); - } - - /** - * Filters out already registered hooks. - * - * @param array $hookNames - * - * @return array - */ - private function getWithoutRegisteredHooks(array $hookNames) - { - $hooksProvider = $this->getContainer()->get('prestashop.adapter.legacy.hook'); - $registeredHooks = $hooksProvider->getHooks(); - $registeredHookNames = array_column($registeredHooks, 'name'); - - return array_diff($hookNames, $registeredHookNames); - } - - /** - * Gets hook descriptions - * - * @param array $hookNames - * - * @return HookDescription[] - */ - private function getHookDescriptions(array $hookNames) - { - $descriptionGenerator = $this->getContainer()->get('prestashop.core.hook.generator.hook_description_generator'); - - $descriptions = []; - foreach ($hookNames as $hookName) { - $hookDescription = $descriptionGenerator->generate($hookName); - - $descriptions[] = $hookDescription; - } - - return $descriptions; - } -} diff --git a/src/PrestaShopBundle/Command/CheckTranslationDuplicatesCommand.php b/src/PrestaShopBundle/Command/CheckTranslationDuplicatesCommand.php deleted file mode 100644 index 11e7df13..00000000 --- a/src/PrestaShopBundle/Command/CheckTranslationDuplicatesCommand.php +++ /dev/null @@ -1,121 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Command; - -use PrestaShopBundle\Translation\PrestaShopTranslatorTrait; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; -use Symfony\Component\Console\Helper\ProgressBar; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; - -class CheckTranslationDuplicatesCommand extends ContainerAwareCommand -{ - protected function configure() - { - $this - ->setName('prestashop:translation:find-duplicates') - ->setDescription('Find duplicates of your translations'); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - // Get dependancies - $translator = $this->getContainer()->get('translator'); - $catalogue = $translator->getCatalogue()->all(); - - // Init progress bar - $progress = new ProgressBar($output, count($catalogue, true)); - $progress->start(); - $progress->setRedrawFrequency(20); - - $duplicates = []; - - foreach ($catalogue as $domain => $messages) { - $nbOfMessages = count($messages); - // In order to use a for() loop, we need integers as keys - $messages = array_keys($messages); - - // We compare strings from the same array, so we have two for() loops - for ($i = 0; $i < $nbOfMessages; ++$i) { - for ($j = ($i + 1); $j < $nbOfMessages; ++$j) { - if ($this->check($messages[$i], $messages[$j])) { - $duplicates[$domain][] = [$i => $messages[$i], $j => $messages[$j]]; - } - } - $progress->advance(); - } - } - - $progress->finish(); - $output->writeln(''); - - // If we have duplicates to fix, let's display them and return their count. - // This will allow us to add the command in the tests. - if (count($duplicates)) { - $output->writeln('Duplicates found:'); - dump($duplicates); - - return count($duplicates, true); - } - - $output->writeln('Awww yisss! There is no duplicate in your translator catalog.'); - - return 0; - } - - /** - * We consider strings as equals if they have the same value after params cleanup. - * - * @param string $message1 - * @param string $message2 - * - * @return bool - */ - protected function check($message1, $message2) - { - return $this->removeParams($message1) == $this->removeParams($message2); - } - - /** - * This function replaces all parameters with a ~ in a string to translate. - * This allow the algorithm to check if the strings are the same once the parameters made generic - * i.e: Error when disabling module %module% ==> Error when disabling module ~. - * - * @param string $message - * - * @return string with replaced parameters - */ - protected function removeParams($message) - { - // Remove PrestaShop arguments %% - $message = preg_replace(PrestaShopTranslatorTrait::$regexClassicParams, '~', $message); - // Remove all related sprintf arguments - $message = preg_replace(PrestaShopTranslatorTrait::$regexSprintfParams, '~', $message); - - return $message; - } -} diff --git a/src/PrestaShopBundle/Command/ExportThemeCommand.php b/src/PrestaShopBundle/Command/ExportThemeCommand.php deleted file mode 100644 index 4e133a02..00000000 --- a/src/PrestaShopBundle/Command/ExportThemeCommand.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Command; - -\Smarty_Autoloader::register(); - -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; - -class ExportThemeCommand extends ContainerAwareCommand -{ - protected function configure() - { - $this - ->setName('prestashop:theme:export') - ->setDescription('Create zip to distribute theme with its dependencies') - ->addArgument('theme', InputArgument::REQUIRED, 'Theme to export directory name.'); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $repository = $this->getContainer()->get('prestashop.core.addon.theme.repository'); - $theme = $repository->getInstanceByName($input->getArgument('theme')); - - $themeExporter = $this->getContainer()->get('prestashop.core.addon.theme.exporter'); - $path = $themeExporter->export($theme); - - $formatter = $this->getHelper('formatter'); - $translator = $this->getContainer()->get('translator'); - $successMsg = $translator->trans( - 'Your theme has been correctly exported: %path%', - ['%path%' => $path], - 'Admin.Design.Notification' - ); - $formattedBlock = $formatter->formatBlock($successMsg, 'info', true); - $output->writeln($formattedBlock); - } -} diff --git a/src/PrestaShopBundle/Command/GenerateMailTemplatesCommand.php b/src/PrestaShopBundle/Command/GenerateMailTemplatesCommand.php deleted file mode 100644 index c7c02352..00000000 --- a/src/PrestaShopBundle/Command/GenerateMailTemplatesCommand.php +++ /dev/null @@ -1,108 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Command; - -use Employee; -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\MailTemplate\Command\GenerateThemeMailTemplatesCommand; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Output\OutputInterface; - -class GenerateMailTemplatesCommand extends ContainerAwareCommand -{ - protected function configure() - { - $this - ->setName('prestashop:mail:generate') - ->setDescription('Generate mail templates for a specified theme') - ->addArgument('theme', InputArgument::REQUIRED, 'Theme to use for mail templates.') - ->addArgument('locale', InputArgument::REQUIRED, 'Which locale to use for the templates.') - ->addArgument('coreOutputFolder', InputArgument::OPTIONAL, 'Output folder to export core templates.') - ->addArgument('modulesOutputFolder', InputArgument::OPTIONAL, 'Output folder to export modules templates (by default same as core).') - ->addOption('overwrite', 'o', InputOption::VALUE_OPTIONAL, 'Overwrite existing templates', false) - ; - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int|void|null - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $themeName = $input->getArgument('theme'); - $coreOutputFolder = $input->getArgument('coreOutputFolder'); - if (!empty($coreOutputFolder) && file_exists($coreOutputFolder)) { - $coreOutputFolder = realpath($coreOutputFolder); - } - $modulesOutputFolder = $input->getArgument('modulesOutputFolder'); - if (!empty($modulesOutputFolder) && file_exists($modulesOutputFolder)) { - $modulesOutputFolder = realpath($modulesOutputFolder); - } else { - $modulesOutputFolder = $coreOutputFolder; - } - $overwrite = false !== $input->getOption('overwrite'); - - $this->initContext(); - - $locale = $input->getArgument('locale'); - - $output->writeln(sprintf('Exporting mail with theme %s for language %s', $themeName, $locale)); - - /** @var GenerateThemeMailTemplatesCommand $generateCommand */ - $generateCommand = new GenerateThemeMailTemplatesCommand( - $themeName, - $locale, - $overwrite, - $coreOutputFolder ?: '', - $modulesOutputFolder ?: '' - ); - /** @var CommandBusInterface $commandBus */ - $commandBus = $this->getContainer()->get('prestashop.core.command_bus'); - $commandBus->handle($generateCommand); - } - - /** - * Initialize PrestaShop Context - */ - private function initContext() - { - /** @var LegacyContext $legacyContext */ - $legacyContext = $this->getContainer()->get('prestashop.adapter.legacy.context'); - //We need to have an employee or the module hooks don't work - //see LegacyHookSubscriber - if (!$legacyContext->getContext()->employee) { - //Even a non existing employee is fine - $legacyContext->getContext()->employee = new Employee(42); - } - } -} diff --git a/src/PrestaShopBundle/Command/LegacyLinkLinterCommand.php b/src/PrestaShopBundle/Command/LegacyLinkLinterCommand.php deleted file mode 100644 index 96dc4665..00000000 --- a/src/PrestaShopBundle/Command/LegacyLinkLinterCommand.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Command; - -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Style\SymfonyStyle; - -/** - * Checks if all admin routes are configured with _legacy_link - */ -class LegacyLinkLinterCommand extends ContainerAwareCommand -{ - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('prestashop:linter:legacy-link') - ->setDescription('Checks if _legacy_link is configured in BackOffice routes'); - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $unconfiguredRoutes = $this->getUnconfiguredRoutes(); - $io = new SymfonyStyle($input, $output); - - if (!empty($unconfiguredRoutes)) { - $io->warning(sprintf( - '%s routes are not configured with _legacy_link:', - count($unconfiguredRoutes) - )); - $io->listing($unconfiguredRoutes); - - return; - } - - $io->success('There is no routes without _legacy_link settings'); - } - - /** - * Returns routes that are missing _legacy_link configuration - * - * @return array - */ - private function getUnconfiguredRoutes() - { - $legacyLinkLinter = $this->getContainer()->get('prestashop.bundle.routing.linter.legacy_link_linter'); - $adminRouteProvider = $this->getContainer()->get('prestashop.bundle.routing.linter.admin_route_provider'); - $routes = $adminRouteProvider->getRoutes(); - $unconfiguredRoutes = []; - - foreach ($routes as $routeName => $route) { - if (true === $legacyLinkLinter->lint('_legacy_link', $route)) { - continue; - } - $unconfiguredRoutes[] = $routeName; - } - - return $unconfiguredRoutes; - } -} diff --git a/src/PrestaShopBundle/Command/ListCommandsAndQueriesCommand.php b/src/PrestaShopBundle/Command/ListCommandsAndQueriesCommand.php deleted file mode 100644 index 0f96e6a6..00000000 --- a/src/PrestaShopBundle/Command/ListCommandsAndQueriesCommand.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Command; - -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; -use Symfony\Component\Console\Formatter\OutputFormatterStyle; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; - -/** - * Lists all commands and queries definitions - */ -class ListCommandsAndQueriesCommand extends ContainerAwareCommand -{ - /** - * {@inheritdoc} - */ - public function configure() - { - $this - ->setName('prestashop:list:commands-and-queries') - ->setDescription('Lists available CQRS commands and queries') - ; - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $commands = $this->getContainer()->getParameter('prestashop.commands_and_queries'); - $commandDefinitionParser = $this->getContainer()->get('prestashop.core.provider.command_definition_provider'); - - $outputStyle = new OutputFormatterStyle('blue', null); - $output->getFormatter()->setStyle('blue', $outputStyle); - - foreach ($commands as $key => $commandName) { - $commandDefinition = $commandDefinitionParser->parseDefinition($commandName); - - $output->writeln(++$key . '.'); - $output->writeln('Class: ' . $commandDefinition->getClassName() . ''); - $output->writeln('Type: ' . $commandDefinition->getCommandType() . ''); - $output->writeln('' . $commandDefinition->getDescription() . ''); - $output->writeln(''); - } - } -} diff --git a/src/PrestaShopBundle/Command/ModuleCommand.php b/src/PrestaShopBundle/Command/ModuleCommand.php deleted file mode 100644 index 544ca133..00000000 --- a/src/PrestaShopBundle/Command/ModuleCommand.php +++ /dev/null @@ -1,196 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Command; - -use Employee; -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; - -class ModuleCommand extends ContainerAwareCommand -{ - private $allowedActions = [ - 'install', - 'uninstall', - 'enable', - 'disable', - 'enable_mobile', - 'disable_mobile', - 'reset', - 'upgrade', - 'configure', - ]; - - /** - * @var \Symfony\Component\Console\Helper\FormatterHelper - */ - protected $formatter; - - /** - * @var \PrestaShopBundle\Translation\Translator - */ - protected $translator; - - /** - * @var \Symfony\Component\Console\Input\Input - */ - protected $input; - - /** - * @var \Symfony\Component\Console\Output\Output - */ - protected $output; - - protected function configure() - { - $this - ->setName('prestashop:module') - ->setDescription('Manage your modules via command line') - ->addArgument('action', InputArgument::REQUIRED, sprintf('Action to execute (Allowed actions: %s).', implode(' / ', $this->allowedActions))) - ->addArgument('module name', InputArgument::REQUIRED, 'Module on which the action will be executed') - ->addArgument('file path', InputArgument::OPTIONAL, 'YML file path for configuration'); - } - - protected function init(InputInterface $input, OutputInterface $output) - { - $this->formatter = $this->getHelper('formatter'); - $this->translator = $this->getContainer()->get('translator'); - $this->input = $input; - $this->output = $output; - /** @var LegacyContext $legacyContext */ - $legacyContext = $this->getContainer()->get('prestashop.adapter.legacy.context'); - //We need to have an employee or the module hooks don't work - //see LegacyHookSubscriber - if (!$legacyContext->getContext()->employee) { - //Even a non existing employee is fine - $legacyContext->getContext()->employee = new Employee(42); - } - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $this->init($input, $output); - - $moduleName = $input->getArgument('module name'); - $action = $input->getArgument('action'); - $file = $input->getArgument('file path'); - - if (!in_array($action, $this->allowedActions)) { - $this->displayMessage( - $this->translator->trans( - 'Unknown module action. It must be one of these values: %actions%', - ['%actions%' => implode(' / ', $this->allowedActions)], - 'Admin.Modules.Notification' - ), - 'error' - ); - - return; - } - - if ($action === 'configure') { - $this->executeConfigureModuleAction($moduleName, $file); - } else { - $this->executeGenericModuleAction($action, $moduleName); - } - } - - protected function executeConfigureModuleAction($moduleName, $file = null) - { - $moduleSelfConfigurator = $this->getContainer()->get('prestashop.adapter.module.self_configurator'); - $moduleSelfConfigurator->module($moduleName); - if ($file) { - $moduleSelfConfigurator->file($file); - } - - // Check if validation passed and exit in case of errors - $errors = $moduleSelfConfigurator->validate(); - if (!empty($errors)) { - // Display errors as a list - $errors = array_map(function ($val) { return '- ' . $val; }, $errors); - // And add a default message at the top - array_unshift($errors, $this->translator->trans( - 'Validation of configuration details failed:', - [], - 'Admin.Modules.Notification' - )); - $this->displayMessage($errors, 'error'); - - return; - } - - // Actual configuration - $moduleSelfConfigurator->configure(); - $this->displayMessage( - $this->translator->trans('Configuration successfully applied.', [], 'Admin.Modules.Notification'), - 'info' - ); - } - - protected function executeGenericModuleAction($action, $moduleName) - { - /** - * @var \PrestaShop\PrestaShop\Core\Addon\Module\ModuleManager - */ - $moduleManager = $this->getContainer()->get('prestashop.module.manager'); - if ($moduleManager->{$action}($moduleName)) { - $this->displayMessage( - $this->translator->trans( - '%action% action on module %module% succeeded.', - [ - '%action%' => ucfirst(str_replace('_', ' ', $action)), - '%module%' => $moduleName, ], - 'Admin.Modules.Notification' - ) - ); - - return; - } - - $error = $moduleManager->getError($moduleName); - $this->displayMessage( - $this->translator->trans( - 'Cannot %action% module %module%. %error_details%', - [ - '%action%' => str_replace('_', ' ', $action), - '%module%' => $moduleName, - '%error_details%' => $error, ], - 'Admin.Modules.Notification' - ), - 'error' - ); - } - - protected function displayMessage($message, $type = 'info') - { - $this->output->writeln( - $this->formatter->formatBlock($message, $type, true) - ); - } -} diff --git a/src/PrestaShopBundle/Command/NamingConventionLinterCommand.php b/src/PrestaShopBundle/Command/NamingConventionLinterCommand.php deleted file mode 100644 index 9b5df97b..00000000 --- a/src/PrestaShopBundle/Command/NamingConventionLinterCommand.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Command; - -use PrestaShopBundle\Routing\Linter\Exception\LinterException; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\Routing\Route; - -/** - * Runs naming conventions linter in the CLI - */ -final class NamingConventionLinterCommand extends ContainerAwareCommand -{ - /** - * {@inheritdoc} - */ - public function configure() - { - $this - ->setName('prestashop:linter:naming-convention') - ->setDescription('Checks if Back Office routes and controllers follow naming convention.') - ; - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $adminRouteProvider = $this->getContainer()->get('prestashop.bundle.routing.linter.admin_route_provider'); - $namingConventionLinter = $this->getContainer() - ->get('prestashop.bundle.routing.linter.naming_convention_linter'); - - $ioTableheaders = ['Invalid routes', 'Valid routes suggestions']; - $ioTableRows = []; - /** @var Route $route */ - foreach ($adminRouteProvider->getRoutes() as $routeName => $route) { - try { - $namingConventionLinter->lint($routeName, $route); - } catch (LinterException $e) { - $ioTableRows[] = [$routeName, $e->getExpectedRouteName()]; - } - } - - $io = new SymfonyStyle($input, $output); - - if (!empty($ioTableRows)) { - $io->title('PrestaShop routes follow admin_{resources}_{action} naming convention structure'); - $io->warning(sprintf( - '%s routes are not following naming conventions:', - count($ioTableRows) - )); - $io->table($ioTableheaders, $ioTableRows); - - return 1; - } - - $io->success('Admin routes and controllers follow naming conventions.'); - - return 0; - } -} diff --git a/src/PrestaShopBundle/Command/SecurityAnnotationLinterCommand.php b/src/PrestaShopBundle/Command/SecurityAnnotationLinterCommand.php deleted file mode 100644 index 79393d4e..00000000 --- a/src/PrestaShopBundle/Command/SecurityAnnotationLinterCommand.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Command; - -use PrestaShopBundle\Routing\Linter\Exception\LinterException; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Style\SymfonyStyle; -use Symfony\Component\Routing\Route; - -/** - * Checks if all admin routes have @AdminSecurity configured - */ -final class SecurityAnnotationLinterCommand extends ContainerAwareCommand -{ - /** - * {@inheritdoc} - */ - public function configure() - { - $this - ->setName('prestashop:linter:security-annotation') - ->setDescription('Checks if Back Office route controllers has configured Security annotations.') - ; - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $adminRouteProvider = $this->getContainer()->get('prestashop.bundle.routing.linter.admin_route_provider'); - $securityAnnotationLinter = $this->getContainer() - ->get('prestashop.bundle.routing.linter.security_annotation_linter'); - - $notConfiguredRoutes = []; - - /** @var Route $route */ - foreach ($adminRouteProvider->getRoutes() as $routeName => $route) { - try { - $securityAnnotationLinter->lint($routeName, $route); - } catch (LinterException $e) { - $notConfiguredRoutes[] = $routeName; - } - } - - $io = new SymfonyStyle($input, $output); - - if (!empty($notConfiguredRoutes)) { - $io->warning(sprintf( - '%s routes are not configured with @AdminSecurity annotation:', - count($notConfiguredRoutes) - )); - $io->listing($notConfiguredRoutes); - - return; - } - - $io->success('Admin routes has @AdminSecurity configured.'); - } -} diff --git a/src/PrestaShopBundle/Command/ThemeEnablerCommand.php b/src/PrestaShopBundle/Command/ThemeEnablerCommand.php deleted file mode 100644 index 746d631a..00000000 --- a/src/PrestaShopBundle/Command/ThemeEnablerCommand.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Command; - -use Context; -use Employee; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Style\SymfonyStyle; - -final class ThemeEnablerCommand extends ContainerAwareCommand -{ - /** - * @var bool using CLI, the user must be allowed to enable themes - */ - const USER_ALLOWED_TO_ENABLE = true; - - /** - * @var int if the activation of the theme fails, return the right code - */ - const RETURN_CODE_FAILED = 1; - - /** - * {@inheritdoc} - */ - protected function init(InputInterface $input, OutputInterface $output) - { - Context::getContext()->employee = new Employee(); - } - - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('prestashop:theme:enable') - ->setDescription('Manage your themes via command line') - ->addArgument('theme', InputArgument::REQUIRED, 'Module on which the action will be executed') - ; - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new SymfonyStyle($input, $output); - $theme = $input->getArgument('theme'); - $this->init($input, $output); - - $activationSuccess = $this->getContainer() - ->get('prestashop.core.addon.theme.theme_manager') - ->enable( - $theme, - self::USER_ALLOWED_TO_ENABLE - ) - ; - - if (false === $activationSuccess) { - $io->error(sprintf('The selected theme "%s" is invalid', $theme)); - - return self::RETURN_CODE_FAILED; - } - - $io->success(sprintf('Theme "%s" enabled with success.', $theme)); - } -} diff --git a/src/PrestaShopBundle/Command/UpdateEUTaxruleGroupsCommand.php b/src/PrestaShopBundle/Command/UpdateEUTaxruleGroupsCommand.php deleted file mode 100644 index d110f792..00000000 --- a/src/PrestaShopBundle/Command/UpdateEUTaxruleGroupsCommand.php +++ /dev/null @@ -1,242 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Command; - -use DOMDocument; -use SimpleXMLElement; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; - -/** - * This script will update the tax rule groups for virtual products from all EU localization packs. - * All it needs is that the correct tax in each localization pack is marked with `eu-tax-group="virtual"`. - **. - * - * 1) - * Parse all files under /localization, - * looking for elements that have the attribute eu-tax-group="virtual". - * - * Store the list of files (`$euLocalizationFiles`) where such taxes have been found, - * in a next step we'll store the new tax group in each of them. - * - * 2) - * Remove all taxRulesGroup's that have the attribute eu-tax-group="virtual". - * - * 3) - * Build a new taxRulesGroup containing all the taxes found in the first step. - * - * 4) - * Inject the new taxRulesGroup into all packs of `$euLocalizationFiles`, not forgetting - * to also inject the required taxes. - * - * Warning: do not duplicate the tax with attribute eu-tax-group="virtual" of the pack being updated. - * - * Mark the injected group with the attributes eu-tax-group="virtual" and auto-generated="1" - * Mark the injected taxes witth the attributes from-eu-tax-group="virtual" and auto-generated="1" - * - * Clean things up by removing all the previous taxes that had the attributes eu-tax-group="virtual" and auto-generated="1" - */ -class UpdateEUTaxruleGroupsCommand extends ContainerAwareCommand -{ - /** - * @var OutputInterface - */ - private $output; - - protected function configure() - { - $this - ->setName('prestashop:taxes:update-eu-tax-rule-groups') - ->setDescription('Update EU Tax rule groups'); - } - - public function execute(InputInterface $input, OutputInterface $output) - { - /* Tweak */ - $this->output = $output; - - $localizationPacksRoot = $this->getContainer()->getParameter('kernel.root_dir') . '/../localization'; - - if (!$localizationPacksRoot) { - return $output->writeln("Could not find the folder containing the localization files (should be 'localization' at the root of the PrestaShop folder)"); - } - - $euLocalizationFiles = []; - - foreach (scandir($localizationPacksRoot, SCANDIR_SORT_ASCENDING) as $entry) { - if (!preg_match('/\.xml$/', $entry)) { - continue; - } - - $localizationPackFile = $localizationPacksRoot . DIRECTORY_SEPARATOR . $entry; - - $localizationPack = @simplexml_load_file($localizationPackFile); - - // Some packs do not have taxes - if (!$localizationPack || !$localizationPack->taxes->tax) { - continue; - } - - foreach ($localizationPack->taxes->tax as $tax) { - if ((string) $tax['eu-tax-group'] === 'virtual') { - if (!isset($euLocalizationFiles[$localizationPackFile])) { - $euLocalizationFiles[$localizationPackFile] = [ - 'virtualTax' => $tax, - 'pack' => $localizationPack, - 'iso_code_country' => basename($entry, '.xml'), - ]; - } else { - return $output->writeln("Too many taxes with eu-tax-group=\"virtual\" found in `$localizationPackFile`."); - } - } - } - } - - foreach ($euLocalizationFiles as $path => $file) { - $nodesToKill = []; - - // Get max tax id, and list of nodes to kill - $taxId = 0; - foreach ($file['pack']->taxes->tax as $tax) { - if ((string) $tax['auto-generated'] === '1' && (string) $tax['from-eu-tax-group'] === 'virtual') { - $nodesToKill[] = $tax; - } else { - // We only count the ids of the taxes we're not going to remove! - $taxId = max($taxId, (int) $tax['id']); - } - } - - foreach ($file['pack']->taxes->taxRulesGroup as $trg) { - if ((string) $trg['auto-generated'] === '1' && (string) $trg['eu-tax-group'] === 'virtual') { - $nodesToKill[] = $trg; - } - } - - // This is the first tax id we're allowed to use. - ++$taxId; - - // Prepare new taxRulesGroup - - $taxRulesGroup = $file['pack']->taxes->addChild('taxRulesGroup'); - $taxRulesGroup->addAttribute('name', 'EU VAT For Virtual Products'); - $taxRulesGroup->addAttribute('auto-generated', '1'); - $taxRulesGroup->addAttribute('eu-tax-group', 'virtual'); - - $this->addTaxRule($taxRulesGroup, $file['virtualTax'], $file['iso_code_country']); - - foreach ($euLocalizationFiles as $foreignPath => $foreignFile) { - if ($foreignPath === $path) { - // We already added the tax that belongs to this pack - continue; - } - - $tax = $this->addTax($file['pack']->taxes, $foreignFile['virtualTax'], [ - 'id' => (string) $taxId, - 'auto-generated' => '1', - 'from-eu-tax-group' => 'virtual', - ], ['eu-tax-group']); - - $this->addTaxRule($taxRulesGroup, $tax, $foreignFile['iso_code_country']); - - ++$taxId; - } - - foreach ($nodesToKill as $node) { - unset($node[0]); - } - - $dom = new DOMDocument('1.0'); - $dom->preserveWhiteSpace = false; - $dom->formatOutput = true; - $dom->loadXML($file['pack']->asXML()); - file_put_contents($path, $dom->saveXML()); - } - - $nUpdated = count($euLocalizationFiles); - - $output->writeln("Updated the virtual tax groups for $nUpdated localization files"); - } - - protected function addTax(SimpleXMLElement $taxes, SimpleXMLElement $tax, array $attributesToUpdate = [], array $attributesToRemove = []) - { - $newTax = new SimpleXMLElement(''); - - $taxRulesGroups = $taxes->xpath('//taxRulesGroup[1]'); - $insertBefore = $taxRulesGroups[0]; - - if (!$insertBefore) { - return $this->output->writeln("Could not find any `taxRulesGroup`, don't know where to append the tax."); - } - - /** - * Add the `tax` node before the first `taxRulesGroup`. - * Yes, the dom API is beautiful. - */ - $dom = dom_import_simplexml($taxes); - - $new = $dom->insertBefore( - $dom->ownerDocument->importNode(dom_import_simplexml($newTax)), - dom_import_simplexml($insertBefore) - ); - - $newTax = simplexml_import_dom($new); - - $newAttributes = []; - - foreach ($tax->attributes() as $attribute) { - $name = $attribute->getName(); - - // This attribute seems to cause trouble, skip it. - if ($name === 'account_number' || in_array($name, $attributesToRemove)) { - continue; - } - - $value = (string) $attribute; - - $newAttributes[$name] = $value; - } - - $newAttributes = array_merge($newAttributes, $attributesToUpdate); - - foreach ($newAttributes as $name => $value) { - $newTax->addAttribute($name, $value); - } - - return $newTax; - } - - protected function addTaxRule(SimpleXMLElement $taxRulesGroup, SimpleXMLElement $tax, $iso_code_country) - { - $taxRule = $taxRulesGroup->addChild('taxRule'); - - $taxRule->addAttribute('iso_code_country', $iso_code_country); - $taxRule->addAttribute('id_tax', (string) $tax['id']); - - return $taxRule; - } -} diff --git a/src/PrestaShopBundle/Command/UpdateLicensesCommand.php b/src/PrestaShopBundle/Command/UpdateLicensesCommand.php deleted file mode 100644 index 6a1d5d96..00000000 --- a/src/PrestaShopBundle/Command/UpdateLicensesCommand.php +++ /dev/null @@ -1,376 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Command; - -use PhpParser\ParserFactory; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Helper\ProgressBar; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Finder\SplFileInfo; - -class UpdateLicensesCommand extends Command -{ - private $text = '/** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the {licenseName} - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * {licenseLink} - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license {licenseLink} {licenseName} - */'; - - /** - * @var string - */ - private $license; - - private $aflLicense = [ - 'themes/classic/', - 'themes/StarterTheme/', - 'modules/', - ]; - - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('prestashop:licenses:update') - ->setDescription('Rewrite your licenses to be up-to-date'); - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $this->text = str_replace('{currentYear}', date('Y'), $this->text); - - $extensions = [ - 'php', - 'js', - 'css', - 'tpl', - 'html.twig', - 'json', - 'vue', - ]; - - foreach ($extensions as $extension) { - $this->findAndCheckExtension($output, $extension); - } - } - - /** - * @param OutputInterface $output - * @param string $ext - */ - private function findAndCheckExtension(OutputInterface $output, $ext) - { - $finder = new Finder(); - $finder - ->files() - ->name('*.' . $ext) - ->in(_PS_ROOT_DIR_) - ->exclude([ - // versioning folders - '.git', - '.github', - '.composer', - // admin folders - 'admin-dev/filemanager', - 'admin-dev/themes/default/public/', - 'admin-dev/themes/new-theme/public/', - // js dependencies - 'js/tiny_mce', - 'js/jquery', - 'js/cropper', - // mails folder - 'mails/themes/classic/', - 'mails/themes/modern/', - // tools dependencies - 'tools/htmlpurifier', - // dependencies - 'vendor', - 'node_modules', - // themes assets - 'themes/classic/assets/', - 'themes/starterTheme/assets/', - // tests folders - 'tests/Resources/modules/', - 'tests/Resources/themes/', - 'tests/Resources/translations/', - 'tests/resources/ModulesOverrideInstallUninstallTest/', - 'tests-legacy/PrestaShopBundle/Twig/Fixtures/', - 'tests-legacy/resources/', - 'tests/E2E/', - 'tests/Unit/Resources/assets/', - 'tests/UI/', - ]) - ->ignoreDotFiles(false); - $parser = (new ParserFactory())->create(ParserFactory::PREFER_PHP7); - - $output->writeln('Updating license in ' . strtoupper($ext) . ' files ...'); - $progress = new ProgressBar($output, count($finder)); - $progress->start(); - $progress->setRedrawFrequency(20); - - $filesToIgnore = [ - 'composer.json', - 'package.json', - 'admin-dev/themes/default/css/font.css', - 'admin-dev/themes/new-theme/package.json', - 'tools/build/Library/InstallUnpacker/content/js-runner.js', - 'themes/classic/_dev/package.json', - 'tools/build/composer.json', - ]; - - foreach ($finder as $file) { - $this->license = $this->text; - $this->makeGoodLicense($file); - - if (in_array($file->getRelativePathName(), $filesToIgnore)) { - continue; - } - - switch ($file->getExtension()) { - case 'php': - try { - $nodes = $parser->parse($file->getContents()); - if (count($nodes)) { - $this->addLicenseToNode($nodes[0], $file); - } - } catch (\PhpParser\Error $exception) { - $output->writeln('Syntax error on file ' . $file->getRelativePathname() . '. Continue ...'); - } - - break; - case 'js': - case 'css': - $this->addLicenseToFile($file); - - break; - case 'tpl': - $this->addLicenseToSmartyTemplate($file); - - break; - case 'twig': - $this->addLicenseToTwigTemplate($file); - - break; - case 'json': - $this->addLicenseToJsonFile($file); - - break; - case 'vue': - $this->addLicenseToHtmlFile($file); - - break; - } - $progress->advance(); - } - - $progress->finish(); - $output->writeln(''); - } - - /** - * @param SplFileInfo $file - */ - private function makeGoodLicense(SplFileInfo $file) - { - if ($this->isAFLLicense($file->getRelativePathname())) { - $this->makeAFLLicense(); - } else { - $this->makeOSLLicense(); - } - } - - /** - * @param $fileName - * - * @return bool - */ - private function isAFLLicense($fileName) - { - foreach ($this->aflLicense as $afl) { - if (0 === strpos($fileName, $afl)) { - return true; - } - } - - return false; - } - - /** - * Replace for OSL licenses. - */ - private function makeOSLLicense() - { - $this->license = str_replace('{licenseName}', 'Open Software License (OSL 3.0)', $this->license); - $this->license = str_replace('{licenseLink}', 'https://opensource.org/licenses/OSL-3.0', $this->license); - } - - /** - * Replace for AFL licenses. - */ - private function makeAFLLicense() - { - $this->license = str_replace('{licenseName}', 'Academic Free License 3.0 (AFL-3.0)', $this->license); - $this->license = str_replace('{licenseLink}', 'https://opensource.org/licenses/AFL-3.0', $this->license); - } - - /** - * @param SplFileInfo $file - * @param string $startDelimiter - * @param string $endDelimiter - */ - private function addLicenseToFile($file, $startDelimiter = '\/', $endDelimiter = '\/') - { - $content = $file->getContents(); - // Regular expression found thanks to Stephen Ostermiller's Blog. http://blog.ostermiller.org/find-comment - $regex = '%' . $startDelimiter . '\*([^*]|[\r\n]|(\*+([^*' . $endDelimiter . ']|[\r\n])))*\*+' . $endDelimiter . '%'; - $matches = []; - $text = $this->license; - if ($startDelimiter != '\/') { - $text = $startDelimiter . ltrim($text, '/'); - } - if ($endDelimiter != '\/') { - $text = rtrim($text, '/') . $endDelimiter; - } - - // Try to find an existing license - preg_match($regex, $content, $matches); - - if (count($matches)) { - // Found - Replace it if prestashop one - foreach ($matches as $match) { - if (stripos($match, 'prestashop') !== false) { - $content = str_replace($match, $text, $content); - } - } - } else { - // Not found - Add it at the beginning of the file - $content = $text . "\n" . $content; - } - - file_put_contents($file->getRelativePathname(), $content); - } - - /** - * @param $node - * @param SplFileInfo $file - */ - private function addLicenseToNode($node, SplFileInfo $file) - { - if (!$node->hasAttribute('comments')) { - $needle = 'license . "\n"; - $haystack = $file->getContents(); - - $pos = strpos($haystack, $needle); - // Important, if the getRelativePathname(), $newstring); - } - - return; - } - - $comments = $node->getAttribute('comments'); - foreach ($comments as $comment) { - if ($comment instanceof \PhpParser\Comment - && strpos($comment->getText(), 'prestashop') !== false) { - file_put_contents($file->getRelativePathname(), str_replace($comment->getText(), $this->license, $file->getContents())); - } - } - } - - /** - * @param SplFileInfo $file - */ - private function addLicenseToSmartyTemplate(SplFileInfo $file) - { - $this->addLicenseToFile($file, '{', '}'); - } - - /** - * @param SplFileInfo $file - */ - private function addLicenseToTwigTemplate(SplFileInfo $file) - { - if (strrpos($file->getRelativePathName(), 'html.twig') !== false) { - $this->addLicenseToFile($file, '{#', '#}'); - } - } - - /** - * @param SplFileInfo $file - */ - private function addLicenseToHtmlFile(SplFileInfo $file) - { - $this->addLicenseToFile($file, ''); - } - - /** - * @param SplFileInfo $file - * - * @return bool - */ - private function addLicenseToJsonFile(SplFileInfo $file) - { - if (!in_array($file->getFilename(), ['composer.json', 'package.json'])) { - return false; - } - - $content = (array) json_decode($file->getContents()); - $content['author'] = 'PrestaShop'; - $content['license'] = $this->isAFLLicense($file->getRelativePathname()) ? 'AFL-3.0' : 'OSL-3.0'; - - return file_put_contents($file->getRelativePathname(), json_encode($content, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT)); - } -} diff --git a/src/PrestaShopBundle/Command/UpdateSchemaCommand.php b/src/PrestaShopBundle/Command/UpdateSchemaCommand.php deleted file mode 100644 index 3bf6bc82..00000000 --- a/src/PrestaShopBundle/Command/UpdateSchemaCommand.php +++ /dev/null @@ -1,224 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Command; - -use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\Tools\SchemaTool; -use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; - -class UpdateSchemaCommand extends ContainerAwareCommand -{ - /** - * @var EntityManagerInterface - */ - private $em; - - private $metadata; - - private $dbName; - - private $dbPrefix; - - protected function configure() - { - $this - ->setName('prestashop:schema:update-without-foreign') - ->setDescription('Update the database'); - } - - /** - * @param InputInterface $input - * @param OutputInterface $output - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - $container = $this->getContainer(); - - $this->dbName = $container->getParameter('database_name'); - $this->dbPrefix = $container->getParameter('database_prefix'); - - $this->em = $container->get('doctrine')->getManager(); - $this->metadata = $this->em->getMetadataFactory()->getAllMetadata(); - - $conn = $this->em->getConnection(); - $conn->beginTransaction(); - - $output->writeln('Updating database schema...'); - $sqls = 0; - - // First drop any existing FK - $query = $conn->query( - 'SELECT CONSTRAINT_NAME, TABLE_NAME - FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS - WHERE CONSTRAINT_TYPE = "FOREIGN KEY" - AND TABLE_SCHEMA = "' . $this->dbName . '" - AND TABLE_NAME LIKE "' . $this->dbPrefix . '%" ' - ); - - $results = $query->fetchAll(); - foreach ($results as $result) { - $drop = 'ALTER TABLE ' . $result['TABLE_NAME'] . ' DROP FOREIGN KEY ' . $result['CONSTRAINT_NAME']; - $output->writeln('Executing: ' . $drop); - $conn->executeQuery($drop); - ++$sqls; - } - - $schemaTool = new SchemaTool($this->em); - $updateSchemaSql = $schemaTool->getUpdateSchemaSql($this->metadata, false); - - $removedTables = []; - $dropForeignKeyQueries = []; - - // Remove the DROP TABLE - foreach ($updateSchemaSql as $key => $sql) { - $matches = []; - if (preg_match('/DROP TABLE (.+?)$/', $sql, $matches)) { - unset($updateSchemaSql[$key]); - $removedTables[] = $matches[1]; - } - } - - // Then remove the ALTER TABLE on removed tables - foreach ($updateSchemaSql as $key => $sql) { - $matches = []; - if (preg_match('/ALTER TABLE (.+?) /', $sql, $matches)) { - $alteredTables = $matches[1]; - if (in_array($alteredTables, $removedTables)) { - unset($updateSchemaSql[$key]); - } - } - } - - // Remove duplicated DROP FOREIGN KEY - foreach ($updateSchemaSql as $key => $sql) { - if (preg_match('/ DROP FOREIGN KEY /', $sql)) { - $hashedSql = md5($sql); - if (in_array($hashedSql, $dropForeignKeyQueries)) { - unset($updateSchemaSql[$key]); - } else { - $dropForeignKeyQueries[] = $hashedSql; - } - } - } - - // Remove ADD CONSTRAINT - foreach ($updateSchemaSql as $key => $sql) { - if (preg_match('/ ADD CONSTRAINT /', $sql)) { - unset($updateSchemaSql[$key]); - } - } - - $constraints = []; - - // Move DROP FOREIGN KEY at the beginning of the sql list - foreach ($updateSchemaSql as $key => $sql) { - if (preg_match('/ DROP FOREIGN KEY /', $sql)) { - $constraints[] = $sql; - unset($updateSchemaSql[$key]); - } - } - - foreach ($constraints as $constraint) { - array_unshift($updateSchemaSql, $constraint); - } - - // Put back DEFAULT fields, since it cannot be described in the ORM model - foreach ($updateSchemaSql as $key => $sql) { - $matches = []; - if (preg_match('/ALTER TABLE (.+?) /', $sql, $matches)) { - $tableName = $matches[1]; - $matches = []; - if (preg_match_all('/([^\s,]*?) CHANGE (.+?) (.+?)(,|$)/', $sql, $matches)) { - foreach ($matches[2] as $matchKey => $fieldName) { - // remove table name - $matches[0][$matchKey] = preg_replace( - '/(.+?) CHANGE/', - ' CHANGE', - $matches[0][$matchKey] - ); - // remove quote - $originalFieldName = $fieldName; - $fieldName = str_replace('`', '', $fieldName); - // get old default value - $query = $conn->query('SHOW FULL COLUMNS FROM ' . $tableName . ' WHERE Field="' . $fieldName . '"'); - $results = $query->fetchAll(); - $oldDefaultValue = $results[0]['Default']; - $extra = $results[0]['Extra']; - if ($oldDefaultValue !== null - && strpos($oldDefaultValue, 'CURRENT_TIMESTAMP') === false) { - $oldDefaultValue = "'" . $oldDefaultValue . "'"; - } - if ($oldDefaultValue === null) { - $oldDefaultValue = 'NULL'; - } - // set the old default value - if (!($results[0]['Null'] == 'NO' && $results[0]['Default'] === null) - && !($oldDefaultValue === 'NULL' - && strpos($matches[0][$matchKey], 'NOT NULL') !== false) - && (strpos($matches[0][$matchKey], 'BLOB') === false) - && (strpos($matches[0][$matchKey], 'TEXT') === false) - ) { - if (preg_match('/DEFAULT/', $matches[0][$matchKey])) { - $matches[0][$matchKey] = - preg_replace('/DEFAULT (.+?)(,|$)/', 'DEFAULT ' . - $oldDefaultValue . '$2' . ' ' . $extra, $matches[0][$matchKey]); - } else { - $matches[0][$matchKey] = - preg_replace('/(.+?)(,|$)/uis', '$1 DEFAULT ' . - $oldDefaultValue . ' ' . $extra . '$2', $matches[0][$matchKey]); - } - } - $updateSchemaSql[$key] = preg_replace( - '/ CHANGE ' . $originalFieldName . ' (.+?)(,|$)/uis', - $matches[0][$matchKey], - $updateSchemaSql[$key] - ); - } - } - } - } - - $sqls += count($updateSchemaSql); - // Now execute the queries! - foreach ($updateSchemaSql as $sql) { - try { - $output->writeln('Executing: ' . $sql); - $conn->executeQuery($sql); - } catch (\Exception $e) { - $conn->rollBack(); - - throw($e); - } - } - $conn->commit(); - - $pluralization = (1 > $sqls) ? 'query was' : 'queries were'; - $output->writeln(sprintf('Database schema updated successfully! "%s" %s executed', $sqls, $pluralization)); - } -} diff --git a/src/PrestaShopBundle/Component/CsvResponse.php b/src/PrestaShopBundle/Component/CsvResponse.php deleted file mode 100644 index e1ab6cfa..00000000 --- a/src/PrestaShopBundle/Component/CsvResponse.php +++ /dev/null @@ -1,297 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Component; - -use Symfony\Component\HttpFoundation\ResponseHeaderBag; -use Symfony\Component\HttpFoundation\StreamedResponse; - -class CsvResponse extends StreamedResponse -{ - // Mode used to paginate page per page, 1/100, 2/100, 3/000, etc - const MODE_PAGINATION = 1; - - // Mode used to paginate by offset, 1/100, 100/100, 200/100, etc (like MySql limit) - const MODE_OFFSET = 2; - - /** - * @var array() CSV content - */ - private $data; - - /** - * @var string Export filename - */ - private $fileName; - - /** - * @var array - */ - private $headersData = []; - - /** - * @var int, self::MODE_PAGINATION by default - */ - private $modeType = self::MODE_PAGINATION; - - /** - * @var int|null - */ - private $start = null; - - /** - * @var int Default limit - */ - private $limit = 1000; - - /** - * Constructor. - * - * @param callable|null $callback A valid PHP callback or null to set it later - * @param int $status The response status code - * @param array $headers An array of response headers - */ - public function __construct($callback = null, $status = 200, $headers = []) - { - parent::__construct($callback, $status, $headers); - - if (null === $callback) { - $this->setCallback([$this, 'processData']); - } - - $this->setFileName('export_' . date('Y-m-d_His') . '.csv'); - $this->headers->set('Content-Type', 'text/csv; charset=utf-8'); - } - - /** - * @param array|callable $data - * - * @return $this - */ - public function setData($data) - { - $this->data = $data; - - return $this; - } - - /** - * @param array $headersData - * - * @return $this - */ - public function setHeadersData(array $headersData) - { - $this->headersData = $headersData; - - return $this; - } - - /** - * @param $modeType int - * - * @return $this - */ - public function setModeType($modeType) - { - $this->modeType = (int) $modeType; - - return $this; - } - - /** - * @param $start int - * - * @return $this - */ - public function setStart($start) - { - $this->start = (int) $start; - - return $this; - } - - /** - * @param $limit int - * - * @return $this - */ - public function setLimit($limit) - { - $this->limit = (int) $limit; - - return $this; - } - - /** - * @param string $fileName - * - * @return $this - * - * @throws \InvalidArgumentException - */ - public function setFileName($fileName) - { - $this->fileName = $fileName; - - $disposition = $this->headers->makeDisposition( - ResponseHeaderBag::DISPOSITION_ATTACHMENT, - $this->fileName - ); - $this->headers->set('Content-Disposition', $disposition); - - return $this; - } - - /** - * Callback function for StreamedResponse. - * - * @throws \LogicException - */ - public function processData() - { - $this->initStart(); - - if (is_array($this->data)) { - $this->processDataArray(); - - return; - } - - if (is_callable($this->data)) { - $this->processDataCallback(); - - return; - } - - throw new \LogicException('The data must be an array or a valid PHP callable function.'); - } - - /** - * Process to data export if $this->data is an array. - */ - private function processDataArray() - { - $handle = tmpfile(); - fputcsv($handle, $this->headersData, ';'); - - foreach ($this->data as $line) { - fputcsv($handle, $line, ';'); - } - - $this->dumpFile($handle); - } - - /** - * Process to data export if $this->data is a callable function. - */ - private function processDataCallback() - { - $handle = tmpfile(); - fputcsv($handle, $this->headersData, ';'); - - do { - $data = call_user_func_array($this->data, [$this->start, $this->limit]); - - $count = count($data); - if ($count === 0) { - break; - } - - foreach ($data as $line) { - $lineData = []; - - foreach (array_keys($this->headersData) as $column) { - if (array_key_exists($column, $line)) { - $lineData[] = $line[$column]; - } - } - - fputcsv($handle, $lineData, ';'); - } - - $this->incrementData(); - } while ($count === $this->limit); - - $this->dumpFile($handle); - } - - /** - * Just init $this->start if it is null. - */ - private function initStart() - { - if (null !== $this->start) { - return; - } - - if (self::MODE_PAGINATION === $this->modeType) { - $this->setStart(1); - } - - if (self::MODE_OFFSET === $this->modeType) { - $this->setStart(0); - } - } - - /** - * Increment the start data for the process. - * - * @throws \LogicException - */ - private function incrementData() - { - if (self::MODE_PAGINATION === $this->modeType) { - $this->setStart($this->start + 1); - - return; - } - - if (self::MODE_OFFSET === $this->modeType) { - $this->setStart($this->start + $this->limit); - - return; - } - - throw new \LogicException('The modeType is not a valid value.'); - } - - /** - * @param $handle, file pointer - */ - private function dumpFile($handle) - { - fseek($handle, 0); - - while (!feof($handle)) { - $buffer = fread($handle, 1024); - echo $buffer; - flush(); - } - - fclose($handle); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/AddonsController.php b/src/PrestaShopBundle/Controller/Admin/AddonsController.php deleted file mode 100644 index 9101a8ae..00000000 --- a/src/PrestaShopBundle/Controller/Admin/AddonsController.php +++ /dev/null @@ -1,121 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin; - -use Configuration; -use Exception; -use PhpEncryption; -use Symfony\Component\HttpFoundation\Cookie; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; - -class AddonsController extends FrameworkBundleAdminController -{ - /** - * Controller responsible of the authentication on PrestaShop Addons. - * - * @param Request $request - * - * @return JsonResponse - */ - public function loginAction(Request $request) - { - $addonsProvider = $this->get('prestashop.core.admin.data_provider.addons_interface'); - $modulesProvider = $this->get('prestashop.core.admin.data_provider.module_interface'); - $response = new JsonResponse(); - - // Parameters needed in order to authenticate the merchant : login and password - $params = [ - 'format' => 'json', - 'username_addons' => $request->request->get('username_addons', null), - 'password_addons' => $request->request->get('password_addons', null), - ]; - - try { - $json = $addonsProvider->request('check_customer', $params); - - Configuration::updateValue('PS_LOGGED_ON_ADDONS', 1); - - $phpEncryption = new PhpEncryption(_NEW_COOKIE_KEY_); - - $response->headers->setCookie( - new Cookie('username_addons', $phpEncryption->encrypt($params['username_addons'])) - ); - $response->headers->setCookie( - new Cookie('password_addons', $phpEncryption->encrypt($params['password_addons'])) - ); - $response->headers->setCookie(new Cookie('is_contributor', (int) $json->is_contributor)); - - $response->setData(['success' => 1, 'message' => '']); - $modulesProvider->clearCatalogCache(); - } catch (Exception $e) { - $response->setData([ - 'success' => 0, - 'message' => $this->trans( - 'PrestaShop was unable to log in to Addons. Please check your credentials and your Internet connection.', - 'Admin.Notifications.Error' - ), - ]); - } - - return $response; - } - - /** - * Controller responsible of the authentication on PrestaShop Addons. - * - * @param Request $request - * - * @return JsonResponse - */ - public function logoutAction(Request $request) - { - $modulesProvider = $this->get('prestashop.core.admin.data_provider.module_interface'); - $modulesProvider->clearCatalogCache(); - - if ($request->isXmlHttpRequest()) { - $response = new JsonResponse(); - $response->setData([ - 'success' => 1, - 'message' => '', - ]); - } else { - if ($request->server->get('HTTP_REFERER')) { - $url = $request->server->get('HTTP_REFERER'); - } else { - $url = $this->redirect($this->generateUrl('admin_module_catalog')); - } - $response = new RedirectResponse($url); - } - $response->headers->clearCookie('username_addons'); - $response->headers->clearCookie('password_addons'); - $response->headers->clearCookie('is_contributor'); - - return $response; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/AttachementProductController.php b/src/PrestaShopBundle/Controller/Admin/AttachementProductController.php deleted file mode 100644 index 6d0e750d..00000000 --- a/src/PrestaShopBundle/Controller/Admin/AttachementProductController.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin; - -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Request; - -/** - * Admin controller for product attachments (in /product/form page). - */ -class AttachementProductController extends FrameworkBundleAdminController -{ - /** - * Manage form add product attachment. - * - * @AdminSecurity("is_granted(['create', 'update'], 'ADMINPRODUCTS_')") - * - * @param int $idProduct - * @param Request $request - * - * @return JsonResponse - */ - public function addAction($idProduct, Request $request) - { - $response = new JsonResponse(); - $legacyContext = $this->get('prestashop.adapter.legacy.context'); - $adminProductWrapper = $this->get('prestashop.adapter.admin.wrapper.product'); - $productAdapter = $this->get('prestashop.adapter.data_provider.product'); - - //get product - $product = $productAdapter->getProduct((int) $idProduct); - - if (!$product || !$request->isXmlHttpRequest()) { - return $response; - } - - $form = $this->createForm( - 'PrestaShopBundle\Form\Admin\Product\ProductAttachement', - null, - ['csrf_protection' => false] - ); - - $form->handleRequest($request); - - if ($form->isValid()) { - $data = $form->getData(); - $res = $adminProductWrapper->processAddAttachment($product, $data, $legacyContext->getLanguages()); - if ($res) { - $res->real_name = $data['name']; - $response->setData($res); - } - } else { - $response->setStatusCode(400); - $response->setData($this->getFormErrorsForJS($form)); - } - - return $response; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/AttributeController.php b/src/PrestaShopBundle/Controller/Admin/AttributeController.php deleted file mode 100644 index 0096d637..00000000 --- a/src/PrestaShopBundle/Controller/Admin/AttributeController.php +++ /dev/null @@ -1,329 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin; - -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Product; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Request; - -/** - * Admin controller for the attribute / attribute group. - */ -class AttributeController extends FrameworkBundleAdminController -{ - /** - * get All Attributes as json. - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @return JsonResponse - */ - public function getAllAttributesAction() - { - $response = new JsonResponse(); - $locales = $this->get('prestashop.adapter.legacy.context')->getLanguages(); - $attributes = $this->get('prestashop.adapter.data_provider.attribute')->getAttributes($locales[0]['id_lang'], true); - - $dataGroupAttributes = []; - $data = []; - foreach ($attributes as $attribute) { - /* Construct attribute group selector. Ex : Color : All */ - $dataGroupAttributes[$attribute['id_attribute_group']] = [ - 'value' => 'group-' . $attribute['id_attribute_group'], - 'label' => $attribute['public_name'] . ' : ' . $this->trans('All', 'Admin.Global'), - 'data' => [ - 'id_group' => $attribute['id_attribute_group'], - 'name' => $attribute['public_name'], - ], - ]; - - $data[] = [ - 'value' => $attribute['id_attribute'], - 'label' => $attribute['public_name'] . ' : ' . $attribute['name'], - 'data' => [ - 'id_group' => $attribute['id_attribute_group'], - 'name' => $attribute['name'], - ], - ]; - } - - $data = array_merge($dataGroupAttributes, $data); - - $response->setData($data); - - return $response; - } - - /** - * Attributes generator. - * - * @AdminSecurity("is_granted(['create', 'update'], request.get('_legacy_controller'))") - * - * @param Request $request The request - * - * @return JsonResponse - */ - public function attributesGeneratorAction(Request $request) - { - $response = new JsonResponse(); - $locales = $this->get('prestashop.adapter.legacy.context')->getLanguages(); - $options = $request->get('options'); - $idProduct = isset($request->get('form')['id_product']) ? $request->get('form')['id_product'] : null; - - //get product - $productAdapter = $this->get('prestashop.adapter.data_provider.product'); - $product = $productAdapter->getProduct((int) $idProduct); - - if (!is_object($product) || empty($product->id) || empty($options) || !is_array($options)) { - $response->setStatusCode(400); - - return $response; - } - - //store exisiting product combinations - $existingCombinationsIds = array_map(function ($o) { - return $o['id_product_attribute']; - }, $product->getAttributeCombinations(1, false)); - - //get clean attributes ids - $newOptions = []; - foreach ($options as $idGroup => $attributes) { - foreach ($attributes as $attribute) { - //If attribute is a group attribute, replace group data by all attributes group - if (false !== strpos($attribute, 'group')) { - $allGroupAttributes = $this->get('prestashop.adapter.data_provider.attribute')->getAttributeIdsByGroup((int) $idGroup, true); - foreach ($allGroupAttributes as $groupAttribute) { - $newOptions[$idGroup][$groupAttribute] = $groupAttribute; - } - } else { - $newOptions[$idGroup][$attribute] = $attribute; - } - } - } - - //create attributes - $this->get('prestashop.adapter.admin.controller.attribute_generator')->processGenerate($product, $newOptions); - - //get all product combinations - $allCombinations = $product->getAttributeCombinations(1, false); - - $allCombinationsIds = array_map(function ($o) { - return $o['id_product_attribute']; - }, $allCombinations); - - //get new created combinations Ids - $newCombinationIds = array_diff($allCombinationsIds, $existingCombinationsIds); - - $attributes = $product->sortCombinationByAttributePosition($newCombinationIds, $locales[0]['id_lang']); - $this->ensureProductHasDefaultCombination($product, $attributes); - - $response = new JsonResponse(); - $combinationDataProvider = $this->get('prestashop.adapter.data_provider.combination'); - $result = [ - 'ids_product_attribute' => [], - 'form' => '', - ]; - - foreach ($attributes as $attribute) { - foreach ($attribute as $combination) { - $form = $this->get('form.factory') - ->createNamed( - 'combination_' . $combination['id_product_attribute'], - 'PrestaShopBundle\Form\Admin\Product\ProductCombination', - $combinationDataProvider->getFormCombination($combination['id_product_attribute']) - ); - $result['form'] .= $this->renderView( - '@Product/ProductPage/Forms/form_combination.html.twig', - [ - 'form' => $form->createView(), - ] - ); - $result['ids_product_attribute'][] = $combination['id_product_attribute']; - } - } - - return $response->create($result); - } - - /** - * @param Product $product - * @param array $combinations - */ - public function ensureProductHasDefaultCombination(Product $product, array $combinations) - { - if (count($combinations)) { - $defaultProductAttributeId = $product->getDefaultIdProductAttribute(); - if (!$defaultProductAttributeId) { - /* - * Combinations indexed by position, then attribute id - * ex: $combinations = [ - * 3 => [ //4th position attribute - * 45 => [ //product_attribute id - * ] - * ] - * ] - */ - $firstPosition = array_keys($combinations)[0]; - if (!empty($combinations[$firstPosition])) { - $firstAttributeId = array_keys($combinations[$firstPosition])[0]; - $product->setDefaultAttribute($firstAttributeId); - } - } - } - } - - /** - * Delete a product attribute. - * - * @AdminSecurity("is_granted(['delete'], request.get('_legacy_controller'))") - * - * @param int $idProduct The product ID - * @param Request $request The request - * - * @return JsonResponse - */ - public function deleteAttributeAction($idProduct, Request $request) - { - $response = new JsonResponse(); - - if (!$request->isXmlHttpRequest()) { - return $response; - } - - $legacyResponse = false; - - if ($request->request->has('attribute-ids')) { - $attributeIds = $request->request->get('attribute-ids'); - foreach ($attributeIds as $attributeId) { - $legacyResponse = $this->get('prestashop.adapter.admin.controller.attribute_generator') - ->ajaxProcessDeleteProductAttribute($attributeId, $idProduct); - } - - if ($legacyResponse['status'] == 'error') { - $response->setStatusCode(400); - } - - $response->setData(['message' => $legacyResponse['message']]); - } - - return $response; - } - - /** - * Delete all product attributes. - * - * @AdminSecurity("is_granted(['delete'], request.get('_legacy_controller'))") - * - * @param int $idProduct The product ID - * @param Request $request The request - * - * @return JsonResponse - */ - public function deleteAllAttributeAction($idProduct, Request $request) - { - $attributeAdapter = $this->get('prestashop.adapter.data_provider.attribute'); - $response = new JsonResponse(); - - //get all attribute for a product - $combinations = $attributeAdapter->getProductCombinations($idProduct); - - if (!$combinations || !$request->isXmlHttpRequest()) { - return $response; - } - - $res = false; - - foreach ($combinations as $combination) { - $res = $this->get('prestashop.adapter.admin.controller.attribute_generator') - ->ajaxProcessDeleteProductAttribute($combination['id_product_attribute'], $idProduct); - - if ($res['status'] == 'error') { - $response->setStatusCode(400); - - break; - } - } - - $response->setData(['message' => $res['message']]); - - return $response; - } - - /** - * get the images form for a product combinations. - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @param int $idProduct The product id - * @param Request $request The request - * - * @return JsonResponse - */ - public function getFormImagesAction($idProduct, Request $request) - { - $response = new JsonResponse(); - $productAdapter = $this->get('prestashop.adapter.data_provider.product'); - $attributeAdapter = $this->get('prestashop.adapter.data_provider.attribute'); - $locales = $this->get('prestashop.adapter.legacy.context')->getLanguages(); - - //get product - $product = $productAdapter->getProduct((int) $idProduct); - - //get product images - $productImages = $productAdapter->getImages($idProduct, $locales[0]['id_lang']); - - if (!$request->isXmlHttpRequest() || !is_object($product) || empty($product->id)) { - $response->setStatusCode(400); - - return $response; - } - - $data = []; - $combinations = $attributeAdapter->getProductCombinations($idProduct); - foreach ($combinations as $combination) { - //get combination images - $combinationImages = array_map(function ($o) { - return $o['id']; - }, $attributeAdapter->getImages($combination['id_product_attribute'])); - - $newProductImages = $productImages; - foreach ($newProductImages as $k => $image) { - $newProductImages[$k]['id_image_attr'] = false; - if (in_array($image['id'], $combinationImages)) { - $newProductImages[$k]['id_image_attr'] = true; - } - } - - $data[$combination['id_product_attribute']] = $newProductImages; - } - - $response->setData($data); - - return $response; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/CategoryController.php b/src/PrestaShopBundle/Controller/Admin/CategoryController.php deleted file mode 100644 index fb374ba3..00000000 --- a/src/PrestaShopBundle/Controller/Admin/CategoryController.php +++ /dev/null @@ -1,163 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin; - -use PrestaShop\PrestaShop\Core\Domain\Category\Command\AddCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryException; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryId; -use PrestaShop\PrestaShop\Core\Domain\Product\Command\AssignProductToCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\CannotAssignProductToCategoryException; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductException; -use PrestaShopBundle\Form\Admin\Category\SimpleCategory; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; - -/** - * Admin controller for the Category pages. - */ -class CategoryController extends FrameworkBundleAdminController -{ - /** - * Process Ajax Form to add a simple category (name and parent category). - * - * @param Request $request - * - * @return string - */ - public function addSimpleCategoryFormAction(Request $request) - { - $response = new JsonResponse(); - $commandBus = $this->get('prestashop.core.command_bus'); - $tools = $this->get('prestashop.adapter.tools'); - $shopContext = $this->get('prestashop.adapter.shop.context'); - $shopList = $shopContext->getShops(false, true); - $currentIdShop = $shopContext->getContextShopID(); - $defaultLanguageId = $this->get('prestashop.adapter.legacy.configuration')->getInt('PS_LANG_DEFAULT'); - - $form = $this->createFormBuilder() - ->add('category', SimpleCategory::class) - ->getForm(); - - $form->handleRequest($request); - - if ($form->isValid()) { - $data = $form->getData(); - - $localizedName = [ - $defaultLanguageId => $data['category']['name'], - ]; - - $command = new AddCategoryCommand( - $localizedName, - [$defaultLanguageId => $tools->linkRewrite($data['category']['name'])], - true, - (int) $data['category']['id_parent'] - ); - - $command->setAssociatedShopIds($currentIdShop ? [$currentIdShop => $currentIdShop] : $shopList); - - try { - /** @var CategoryId $categoryId */ - $categoryId = $commandBus->handle($command); - - if ($categoryId->getValue()) { - $response->setData( - [ - 'category' => [ - 'id' => $categoryId->getValue(), - 'id_parent' => $data['category']['id_parent'], - 'name' => $localizedName, - ], - ] - ); - if ($request->query->has('id_product')) { - $assignProductToCategoryCommand = new AssignProductToCategoryCommand( - $categoryId->getValue(), - $request->query->get('id_product') - ); - $commandBus->handle($assignProductToCategoryCommand); - } - } - } catch (CategoryException $e) { - // TODO: do some frontend work to display this error message from ajax query - $response->setStatusCode(Response::HTTP_BAD_REQUEST); - $response->setData(['error' => $this->getErrorMessageForException($e, $this->getErrorMessages($data['category']['name']))]); - } catch (ProductException $e) { - // TODO: do some frontend work to display this error message from ajax query - $response->setStatusCode(Response::HTTP_BAD_REQUEST); - $response->setData(['error' => $this->getErrorMessageForException($e, $this->getErrorMessages($data['category']['name']))]); - } - } else { - $response->setStatusCode(Response::HTTP_BAD_REQUEST); - $response->setData($this->getFormErrorsForJS($form)); - } - - return $response; - } - - /** - * Get Categories formatted like ajax_product_file.php. - * - * @param $limit - * @param Request $request - * - * @return JsonResponse - */ - public function getAjaxCategoriesAction($limit, Request $request) - { - if (!$request->isXmlHttpRequest()) { - throw new NotFoundHttpException('Should be ajax request.'); - } - - return new JsonResponse( - $this->get('prestashop.adapter.data_provider.category')->getAjaxCategories($request->get('query'), $limit, true) - ); - } - - /** - * @param string $categoryName - * - * @return array - */ - private function getErrorMessages(string $categoryName): array - { - return [ - CategoryException::class => $this->trans( - 'Category "%s" could not be created.', - 'Admin.Notifications.Error', - [$categoryName] - ), - CannotAssignProductToCategoryException::class => $this->trans( - 'This product could not be assigned to category "%s".', - 'Admin.Notifications.Error', - [$categoryName] - ), - ]; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/CombinationController.php b/src/PrestaShopBundle/Controller/Admin/CombinationController.php deleted file mode 100644 index 87e6cfb0..00000000 --- a/src/PrestaShopBundle/Controller/Admin/CombinationController.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin; - -use PrestaShopBundle\Form\Admin\Product\ProductCombination; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Response; - -class CombinationController extends FrameworkBundleAdminController -{ - /** - * Generate combination - * - * @AdminSecurity("is_granted(['create', 'update'], 'ADMINPRODUCTS_')") - * - * @return Response - */ - public function generateCombinationFormAction($combinationIds) - { - $response = new Response(); - - $combinationIds = explode('-', $combinationIds); - if ($combinationIds === false || count($combinationIds) == 0) { - return $response; - } - - $combinationDataProvider = $this->get('prestashop.adapter.data_provider.combination'); - $combinations = $combinationDataProvider->getFormCombinations($combinationIds, (int) $this->getContext()->language->id); - - $formFactory = $this->get('form.factory'); - foreach ($combinations as $combinationId => $combination) { - $forms[] = $formFactory->createNamed( - "combination_$combinationId", - ProductCombination::class, - $combination - )->createView(); - } - - return $response->setContent($this->renderView( - '@Product/ProductPage/Forms/form_combination_collection.html.twig', - [ - 'combinationForms' => $forms, - ] - )); - } - - /** - * Get all Combinations for a product. - * - * @AdminSecurity("is_granted(['read'], 'ADMINPRODUCTS_')") - * - * @param int $idProduct The product id - * - * @return JsonResponse - */ - public function getProductCombinationsAction($idProduct) - { - $response = new JsonResponse(); - - //get product - $productAdapter = $this->get('prestashop.adapter.data_provider.product'); - $product = $productAdapter->getProduct((int) $idProduct); - - //get combinations - - $modelMapper = $this->get('prestashop.adapter.admin.model.product'); - - $combinations = $modelMapper->getAttributesResume($product); - - $combinationList = []; - - if (is_array($combinations)) { - foreach ($combinations as $combination) { - $combinationList[] = ['id' => $combination['id_product_attribute'], 'name' => $combination['attribute_designation']]; - } - } - - $response->setData($combinationList); - - return $response; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/CommonController.php b/src/PrestaShopBundle/Controller/Admin/CommonController.php deleted file mode 100644 index d810c71a..00000000 --- a/src/PrestaShopBundle/Controller/Admin/CommonController.php +++ /dev/null @@ -1,404 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin; - -use Context; -use PrestaShop\PrestaShop\Adapter\Module\AdminModuleDataProvider; -use PrestaShop\PrestaShop\Core\Addon\AddonsCollection; -use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder; -use PrestaShop\PrestaShop\Core\Domain\Notification\Command\UpdateEmployeeNotificationLastElementCommand; -use PrestaShop\PrestaShop\Core\Domain\Notification\Query\GetNotificationLastElements; -use PrestaShop\PrestaShop\Core\Domain\Notification\QueryResult\NotificationsResults; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AbstractGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\FilterableGridDefinitionFactoryInterface; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\GridDefinitionFactoryInterface; -use PrestaShop\PrestaShop\Core\Kpi\Row\KpiRowInterface; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Service\DataProvider\Admin\RecommendedModules; -use PrestaShopBundle\Service\Grid\ControllerResponseBuilder; -use PrestaShopBundle\Service\Grid\ResponseBuilder; -use ReflectionClass; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Admin controller for the common actions across the whole admin interface. - */ -class CommonController extends FrameworkBundleAdminController -{ - /** - * Get a summary of recent events on the shop. - * This includes: - * - Created orders - * - Registered customers - * - New messages. - * - * @return JsonResponse - */ - public function notificationsAction() - { - $employeeId = Context::getContext()->employee->id; - /** @var NotificationsResults $elements */ - $elements = $this->getQueryBus()->handle(new GetNotificationLastElements($employeeId)); - - return new JsonResponse($elements->getNotificationsResultsForJS()); - } - - /** - * Update the last time a notification type has been seen. - * - * @param Request $request - * - * @throws TypeException - */ - public function notificationsAckAction(Request $request) - { - $type = $request->request->get('type'); - $this->getCommandBus()->handle(new UpdateEmployeeNotificationLastElementCommand($type)); - - return new JsonResponse(true); - } - - /** - * This will allow you to retrieve an HTML code with a ready and linked paginator. - * - * To be able to use this paginator, the current route must have these standard parameters: - * - offset - * - limit - * Both will be automatically manipulated by the paginator. - * The navigator links (previous/next page...) will never tranfer POST and/or GET parameters - * (only route parameters that are in the URL). - * - * You must add a JS file to the list of JS for view rendering: pagination.js - * - * The final way to render a paginator is the following: - * {% render controller('PrestaShopBundle\\Controller\\Admin\\CommonController::paginationAction', - * {'limit': limit, 'offset': offset, 'total': product_count, 'caller_parameters': pagination_parameters}) %} - * - * @Template("@PrestaShop/Admin/Common/pagination.html.twig") - * - * @param Request $request - * @param int $limit - * @param int $offset - * @param int $total - * @param string $view full|quicknav To change default template used to render the content - * @param string $prefix Indicates the params prefix (eg: ?limit=10&offset=20 -> ?scope[limit]=10&scope[offset]=20) - * - * @return array|Response - */ - public function paginationAction(Request $request, $limit = 10, $offset = 0, $total = 0, $view = 'full', $prefix = '') - { - $offsetParam = empty($prefix) ? 'offset' : sprintf('%s[offset]', $prefix); - $limitParam = empty($prefix) ? 'limit' : sprintf('%s[limit]', $prefix); - - $limit = max($limit, 10); - - $currentPage = floor($offset / $limit) + 1; - $pageCount = ceil($total / $limit); - $from = $offset; - $to = $offset + $limit - 1; - - // urls from route - $callerParameters = $request->attributes->get('caller_parameters', []); - foreach ($callerParameters as $k => $v) { - if (strpos($k, '_') === 0) { - unset($callerParameters[$k]); - } - } - $callerParameters += ['_route' => false]; - $routeName = $request->attributes->get('caller_route', $callerParameters['_route']); - $nextPageUrl = (!$routeName || ($offset + $limit >= $total)) ? false : $this->generateUrl($routeName, array_merge( - $callerParameters, - [ - $offsetParam => min($total - 1, $offset + $limit), - $limitParam => $limit, - ] - )); - - $previousPageUrl = (!$routeName || ($offset == 0)) ? false : $this->generateUrl($routeName, array_merge( - $callerParameters, - [ - $offsetParam => max(0, $offset - $limit), - $limitParam => $limit, - ] - )); - $firstPageUrl = (!$routeName || ($offset == 0)) ? false : $this->generateUrl($routeName, array_merge( - $callerParameters, - [ - $offsetParam => 0, - $limitParam => $limit, - ] - )); - $lastPageUrl = (!$routeName || ($offset + $limit >= $total)) ? false : $this->generateUrl($routeName, array_merge( - $callerParameters, - [ - $offsetParam => ($pageCount - 1) * $limit, - $limitParam => $limit, - ] - )); - $changeLimitUrl = (!$routeName) ? false : $this->generateUrl($routeName, array_merge( - $callerParameters, - [ - $offsetParam => 0, - $limitParam => '_limit', - ] - )); - $jumpPageUrl = (!$routeName) ? false : $this->generateUrl($routeName, array_merge( - $callerParameters, - [ - $offsetParam => 999999, - $limitParam => $limit, - ] - )); - $limitChoices = $request->attributes->get('limit_choices', [10, 20, 50, 100]); - - // Template vars injection - $vars = [ - 'limit' => $limit, - 'changeLimitUrl' => $changeLimitUrl, - 'first_url' => $firstPageUrl, - 'previous_url' => $previousPageUrl, - 'from' => $from, - 'to' => $to, - 'total' => $total, - 'current_page' => $currentPage, - 'page_count' => $pageCount, - 'next_url' => $nextPageUrl, - 'last_url' => $lastPageUrl, - 'jump_page_url' => $jumpPageUrl, - 'limit_choices' => $limitChoices, - ]; - if ($view != 'full') { - return $this->render('@PrestaShop/Admin/Common/pagination_' . $view . '.html.twig', $vars); - } - - return $vars; - } - - /** - * This will allow you to retrieve an HTML code with a list of recommended modules depending on the domain. - * - * @Template("@PrestaShop/Admin/Common/recommendedModules.html.twig") - * - * @param string $domain - * @param int $limit - * @param int $randomize - * - * @return array Template vars - */ - public function recommendedModulesAction($domain, $limit = 0, $randomize = 0) - { - $recommendedModules = $this->get('prestashop.data_provider.modules.recommended'); - /** @var $recommendedModules RecommendedModules */ - $moduleIdList = $recommendedModules->getRecommendedModuleIdList($domain, ($randomize == 1)); - - $modulesProvider = $this->get('prestashop.core.admin.data_provider.module_interface'); - /** @var $modulesProvider AdminModuleDataProvider */ - $modulesRepository = ModuleManagerBuilder::getInstance()->buildRepository(); - - $modules = []; - foreach ($moduleIdList as $id) { - try { - $module = $modulesRepository->getModule($id); - } catch (\Exception $e) { - continue; - } - $modules[] = $module; - } - - if ($randomize == 1) { - shuffle($modules); - } - - $modules = $recommendedModules->filterInstalledAndBadModules($modules); - $collection = AddonsCollection::createFrom($modules); - $modules = $modulesProvider->generateAddonsUrls($collection); - - return [ - 'domain' => $domain, - 'modules' => array_slice($modules, 0, $limit, true), - ]; - } - - /** - * Render a right sidebar with content from an URL. - * - * @param $url - * @param string $title - * @param string $footer - * - * @return Response - */ - public function renderSidebarAction($url, $title = '', $footer = '') - { - $tools = $this->get('prestashop.adapter.tools'); - - return $this->render('@PrestaShop/Admin/Common/_partials/_sidebar.html.twig', [ - 'footer' => $tools->purifyHTML($footer), - 'title' => $title, - 'url' => urldecode($url), - ]); - } - - /** - * Renders a KPI row. - * - * @param KpiRowInterface $kpiRow - * - * @return Response - */ - public function renderKpiRowAction(KpiRowInterface $kpiRow) - { - $presenter = $this->get('prestashop.core.kpi_row.presenter'); - - return $this->render('@PrestaShop/Admin/Common/Kpi/kpi_row.html.twig', [ - 'kpiRow' => $presenter->present($kpiRow), - ]); - } - - /** - * @param string $controller - * @param string $action - * @param string $filterId - * - * @return JsonResponse - * - * @throws \Doctrine\ORM\OptimisticLockException - */ - public function resetSearchAction($controller = '', $action = '', $filterId = '') - { - $adminFiltersRepository = $this->get('prestashop.core.admin.admin_filter.repository'); - $employeeId = $this->getUser()->getId(); - $shopId = $this->getContext()->shop->id; - - // for compatibility when $controller and $action are used - if (!empty($controller) && !empty($action)) { - $adminFilter = $adminFiltersRepository->findByEmployeeAndRouteParams( - $employeeId, $shopId, $controller, $action - ); - } - - if (!empty($filterId)) { - $adminFilter = $adminFiltersRepository->findByEmployeeAndFilterId($employeeId, $shopId, $filterId); - } - - if (isset($adminFilter)) { - $adminFiltersRepository->unsetFilters($adminFilter); - } - - return new JsonResponse(); - } - - /** - * Specific action to render a specific field twice. - * - * @param $formName the form name - * @param $formType the form type FQCN - * @param $fieldName the field name - * @param $fieldData the field data - * - * @return Response - */ - public function renderFieldAction($formName, $formType, $fieldName, $fieldData) - { - $formData = [ - $formName => [ - $fieldName => $fieldData, - ], - ]; - - $form = $this->createFormBuilder($formData); - $form->add($formName, $formType); - - return $this->render('@PrestaShop/Admin/Common/_partials/_form_field.html.twig', [ - 'form' => $form->getForm()->get($formName)->get($fieldName)->createView(), - 'formId' => $formName . '_' . $fieldName . '_rendered', - ]); - } - - /** - * Process Grid search. - * - * @param Request $request - * @param string $gridDefinitionFactoryServiceId - * @param string $redirectRoute - * @param array $redirectQueryParamsToKeep - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @return RedirectResponse - */ - public function searchGridAction( - Request $request, - $gridDefinitionFactoryServiceId, - $redirectRoute, - array $redirectQueryParamsToKeep = [] - ) { - /** @var GridDefinitionFactoryInterface $definitionFactory */ - $definitionFactory = $this->get($gridDefinitionFactoryServiceId); - - $filterId = null; - - if ($definitionFactory instanceof FilterableGridDefinitionFactoryInterface) { - $filterId = $definitionFactory->getFilterId(); - } elseif ($definitionFactory instanceof AbstractGridDefinitionFactory) { - // for backward compatibility for AbstractGridDefinitionFactory - // using ::GRID_ID (that has been replaced by AbstractFilterableGridDefinitionFactory) - $reflect = new ReflectionClass($definitionFactory); - if (array_key_exists('GRID_ID', $reflect->getConstants())) { - $filterId = $definitionFactory::GRID_ID; - } - } - - if (null !== $filterId) { - /** @var ResponseBuilder $responseBuilder */ - $responseBuilder = $this->get('prestashop.bundle.grid.response_builder'); - - return $responseBuilder->buildSearchResponse( - $definitionFactory, - $request, - $filterId, - $redirectRoute, - $redirectQueryParamsToKeep - ); - } - - // Legacy grid definition which use controller/action as filter keys (and no scope for parameters) - /** @var ControllerResponseBuilder $responseBuilder */ - $controllerResponseBuilder = $this->get('prestashop.bundle.grid.controller_response_builder'); - - return $controllerResponseBuilder->buildSearchResponse( - $definitionFactory, - $request, - $redirectRoute, - $redirectQueryParamsToKeep - ); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/AdministrationController.php b/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/AdministrationController.php deleted file mode 100644 index 90fa8d8f..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/AdministrationController.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\AdvancedParameters; - -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible of "Configure > Advanced Parameters > Administration" page display. - */ -class AdministrationController extends FrameworkBundleAdminController -{ - const CONTROLLER_NAME = 'AdminAdminPreferences'; - - /** - * Show Administration page. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message="Access denied.") - * - * @param FormInterface $form - * - * @return Response - */ - public function indexAction(FormInterface $form = null) - { - $form = null === $form ? $this->get('prestashop.adapter.administration.form_handler')->getForm() : $form; - - return $this->render('@PrestaShop/Admin/Configure/AdvancedParameters/administration.html.twig', [ - 'layoutHeaderToolbarBtn' => [], - 'layoutTitle' => $this->trans('Administration', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'requireBulkActions' => false, - 'showContentHeader' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink('AdminAdminPreferences'), - 'requireFilterStatus' => false, - 'form' => $form->createView(), - ]); - } - - /** - * Process the Administration configuration form. - * - * @AdminSecurity("is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", message="You do not have permission to update this.", redirectRoute="admin_administration") - * @DemoRestricted(redirectRoute="admin_administration") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function processFormAction(Request $request) - { - $this->dispatchHook('actionAdminAdminPreferencesControllerPostProcessBefore', ['controller' => $this]); - - $form = $this->get('prestashop.adapter.administration.form_handler')->getForm(); - $form->handleRequest($request); - - if ($form->isSubmitted()) { - $data = $form->getData(); - - $saveErrors = $this->get('prestashop.adapter.administration.form_handler')->save($data); - - if (0 === count($saveErrors)) { - $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_administration'); - } - - $this->flashErrors($saveErrors); - } - - return $this->redirectToRoute('admin_administration'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/BackupController.php b/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/BackupController.php deleted file mode 100644 index 0138f9f7..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/BackupController.php +++ /dev/null @@ -1,300 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\AdvancedParameters; - -use PrestaShop\PrestaShop\Adapter\Backup\Backup; -use PrestaShop\PrestaShop\Core\Backup\Exception\BackupException; -use PrestaShop\PrestaShop\Core\Backup\Exception\DirectoryIsNotWritableException; -use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface; -use PrestaShop\PrestaShop\Core\Search\Filters\BackupFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\HttpFoundation\BinaryFileResponse; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class BackupController is responsible of "Configure > Advanced Parameters > Database > Backup" page. - */ -class BackupController extends FrameworkBundleAdminController -{ - /** - * Show backup page. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * @param BackupFilters $filters - * - * @return Response - */ - public function indexAction(Request $request, BackupFilters $filters) - { - $backupForm = $this->getBackupFormHandler()->getForm(); - $configuration = $this->get('prestashop.adapter.legacy.configuration'); - - $hasDownloadFile = false; - $downloadFile = null; - - if ($request->query->has('download_filename')) { - $hasDownloadFile = true; - $backup = new Backup($request->query->get('download_filename')); - $downloadFile = [ - 'url' => $backup->getUrl(), - 'size' => number_format($backup->getSize() * 0.000001, 2, '.', ''), - ]; - } - - $backupsGridFactory = $this->get('prestashop.core.grid.factory.backup'); - $backupGrid = $backupsGridFactory->getGrid($filters); - - return $this->render('@PrestaShop/Admin/Configure/AdvancedParameters/Backup/index.html.twig', [ - 'backupGrid' => $this->presentGrid($backupGrid), - 'backupForm' => $backupForm->createView(), - 'isHostMode' => $configuration->get('_PS_HOST_MODE_'), - 'dbPrefix' => $configuration->get('_DB_PREFIX_'), - 'hasDownloadFile' => $hasDownloadFile, - 'downloadFile' => $downloadFile, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - ]); - } - - /** - * Show file download view. - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * @DemoRestricted(redirectRoute="admin_backups_index") - * - * @param Request $request - * @param string $downloadFileName - * - * @return Response - */ - public function downloadViewAction(Request $request, $downloadFileName) - { - $backup = new Backup($downloadFileName); - - return $this->render('@PrestaShop/Admin/Configure/AdvancedParameters/Backup/download_view.html.twig', [ - 'downloadFile' => [ - 'url' => $backup->getUrl(), - 'size' => $backup->getSize(), - ], - 'layoutTitle' => $this->trans('View', 'Admin.Actions'), - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - ]); - } - - /** - * Return a backup content as a download. - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller')~'_')") - * @DemoRestricted(redirectRoute="admin_backup") - * - * @param string $downloadFileName - * - * @return BinaryFileResponse - */ - public function downloadContentAction($downloadFileName) - { - $backup = new Backup($downloadFileName); - - return new BinaryFileResponse($backup->getFilePath()); - } - - /** - * Process backup options saving. - * - * @AdminSecurity("is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))") - * @DemoRestricted(redirectRoute="admin_backups_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function saveOptionsAction(Request $request) - { - $backupFormHandler = $this->getBackupFormHandler(); - - $backupForm = $backupFormHandler->getForm(); - $backupForm->handleRequest($request); - - if ($backupForm->isSubmitted()) { - $errors = $backupFormHandler->save($backupForm->getData()); - - if (!empty($errors)) { - $this->flashErrors($errors); - } else { - $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success')); - } - } - - return $this->redirectToRoute('admin_backups_index'); - } - - /** - * Create new backup. - * - * @AdminSecurity("is_granted(['create'], request.get('_legacy_controller'))") - * @DemoRestricted(redirectRoute="admin_backups_index") - * - * @return RedirectResponse - */ - public function createAction() - { - try { - $backupCreator = $this->get('prestashop.adapter.backup.database_creator'); - $backup = $backupCreator->createBackup(); - - $this->addFlash( - 'success', - $this->trans( - 'It appears the backup was successful, however you must download and carefully verify the backup file before proceeding.', - 'Admin.Advparameters.Notification' - ) - ); - - return $this->redirectToRoute('admin_backups_index', ['download_filename' => $backup->getFileName()]); - } catch (DirectoryIsNotWritableException $e) { - $this->addFlash( - 'error', - $this->trans( - 'The "Backups" directory located in the admin directory must be writable (CHMOD 755 / 777).', - 'Admin.Advparameters.Notification' - ) - ); - } catch (BackupException $e) { - $this->addFlash('error', $this->trans('The backup file does not exist', 'Admin.Advparameters.Notification')); - } - - return $this->redirectToRoute('admin_backups_index'); - } - - /** - * Process backup file deletion. - * - * @AdminSecurity("is_granted(['delete'], request.get('_legacy_controller'))") - * @DemoRestricted(redirectRoute="admin_backups_index") - * - * @param string $deleteFileName - * - * @return RedirectResponse - */ - public function deleteAction($deleteFileName) - { - $backup = new Backup($deleteFileName); - $backupRemover = $this->get('prestashop.adapter.backup.backup_remover'); - - if (!$backupRemover->remove($backup)) { - $this->addFlash( - 'error', - sprintf( - '%s "%s"', - $this->trans('Error deleting', 'Admin.Advparameters.Notification'), - $backup->getFileName() - ) - ); - - return $this->redirectToRoute('admin_backups_index'); - } - - $this->addFlash('success', $this->trans('Successful deletion.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_backups_index'); - } - - /** - * Process bulk backup deletion. - * - * @AdminSecurity("is_granted(['delete'], request.get('_legacy_controller'))") - * @DemoRestricted(redirectRoute="admin_backups_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkDeleteAction(Request $request) - { - $backupsToDelete = $request->request->get('backup_backup_bulk_file_names', []); - - if (empty($backupsToDelete)) { - $this->addFlash( - 'error', - $this->trans('You must select at least one element to delete.', 'Admin.Notifications.Error') - ); - - return $this->redirectToRoute('admin_backups_index'); - } - - $backupRemover = $this->get('prestashop.adapter.backup.backup_remover'); - $failedBackups = []; - - foreach ($backupsToDelete as $backupFileName) { - $backup = new Backup($backupFileName); - - if (!$backupRemover->remove($backup)) { - $failedBackups[] = $backup->getFileName(); - } - } - - if (!empty($failedBackups)) { - $this->addFlash( - 'error', - $this->trans('An error occurred while deleting this selection.', 'Admin.Notifications.Error') - ); - - foreach ($failedBackups as $backupFileName) { - $this->addFlash( - 'error', - $this->trans('Can\'t delete #%id%', 'Admin.Notifications.Error', ['%id%' => $backupFileName]) - ); - } - - return $this->redirectToRoute('admin_backups_index'); - } - - $this->addFlash( - 'success', - $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success') - ); - - return $this->redirectToRoute('admin_backups_index'); - } - - /** - * Get backup form handler. - * - * @return FormHandlerInterface - */ - protected function getBackupFormHandler() - { - return $this->get('prestashop.admin.backup.form_handler'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/EmailController.php b/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/EmailController.php deleted file mode 100644 index 9d0b7cd1..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/EmailController.php +++ /dev/null @@ -1,276 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\AdvancedParameters; - -use PrestaShop\PrestaShop\Core\Email\MailOption; -use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface; -use PrestaShop\PrestaShop\Core\Search\Filters\EmailLogsFilter; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Email\TestEmailSendingType; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use PrestaShopBundle\Security\Voter\PageVoter; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class EmailController is responsible for handling "Configure > Advanced Parameters > E-mail" page. - */ -class EmailController extends FrameworkBundleAdminController -{ - /** - * Show email configuration page. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message="Access denied.") - * - * @param Request $request - * @param EmailLogsFilter $filters - * - * @return Response - */ - public function indexAction(Request $request, EmailLogsFilter $filters) - { - $configuration = $this->get('prestashop.adapter.legacy.configuration'); - - $emailConfigurationForm = $this->getEmailConfigurationFormHandler()->getForm(); - $extensionChecker = $this->get('prestashop.core.configuration.php_extension_checker'); - - $testEmailSendingForm = $this->createForm(TestEmailSendingType::class, [ - 'send_email_to' => $configuration->get('PS_SHOP_EMAIL'), - ]); - - $isEmailLogsEnabled = $configuration->get('PS_LOG_EMAILS'); - - $presentedEmailLogsGrid = null; - - if ($isEmailLogsEnabled) { - $emailLogsGridFactory = $this->get('prestashop.core.grid.factory.email_logs'); - $emailLogsGrid = $emailLogsGridFactory->getGrid($filters); - $presentedEmailLogsGrid = $this->presentGrid($emailLogsGrid); - } - - return $this->render('@PrestaShop/Admin/Configure/AdvancedParameters/Email/index.html.twig', [ - 'emailConfigurationForm' => $emailConfigurationForm->createView(), - 'isOpenSslExtensionLoaded' => $extensionChecker->loaded('openssl'), - 'smtpMailMethod' => MailOption::METHOD_SMTP, - 'testEmailSendingForm' => $testEmailSendingForm->createView(), - 'emailLogsGrid' => $presentedEmailLogsGrid, - 'isEmailLogsEnabled' => $isEmailLogsEnabled, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - ]); - } - - /** - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message="Access denied.") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function searchAction(Request $request) - { - $definitionFactory = $this->get('prestashop.core.grid.definition.factory.email_logs'); - $emailLogsDefinition = $definitionFactory->getDefinition(); - - $gridFilterFormFactory = $this->get('prestashop.core.grid.filter.form_factory'); - $filtersForm = $gridFilterFormFactory->create($emailLogsDefinition); - $filtersForm->handleRequest($request); - - $filters = []; - - if ($filtersForm->isSubmitted()) { - $filters = $filtersForm->getData(); - } - - return $this->redirectToRoute('admin_emails_index', ['filters' => $filters]); - } - - /** - * Process email configuration saving. - * - * @DemoRestricted(redirectRoute="admin_emails_index") - * @AdminSecurity("is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", message="Access denied.") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function saveOptionsAction(Request $request) - { - $formHandler = $this->getEmailConfigurationFormHandler(); - $emailConfigurationForm = $formHandler->getForm(); - $emailConfigurationForm->handleRequest($request); - - if ($emailConfigurationForm->isSubmitted()) { - $errors = $formHandler->save($emailConfigurationForm->getData()); - - if (!empty($errors)) { - $this->flashErrors($errors); - } else { - $this->addFlash( - 'success', - $this->trans('The settings have been successfully updated.', 'Admin.Notifications.Success') - ); - } - } - - return $this->redirectToRoute('admin_emails_index'); - } - - /** - * Delete selected email logs. - * - * @DemoRestricted(redirectRoute="admin_emails_index") - * @AdminSecurity("is_granted(['delete'], request.get('_legacy_controller'))", message="Access denied.") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function deleteBulkAction(Request $request) - { - $mailLogsToDelete = $request->request->get('email_logs_delete_email_logs'); - - $mailLogsEraser = $this->get('prestashop.adapter.email.email_log_eraser'); - $errors = $mailLogsEraser->erase($mailLogsToDelete); - - if (!empty($errors)) { - $this->flashErrors($errors); - } else { - $this->addFlash( - 'success', - $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success') - ); - } - - return $this->redirectToRoute('admin_emails_index'); - } - - /** - * Delete all email logs. - * - * @DemoRestricted(redirectRoute="admin_emails_index") - * @AdminSecurity("is_granted(['delete'], request.get('_legacy_controller'))", message="Access denied.") - * - * @return RedirectResponse - */ - public function deleteAllAction() - { - $mailLogsEraser = $this->get('prestashop.adapter.email.email_log_eraser'); - - if ($mailLogsEraser->eraseAll()) { - $this->addFlash('success', $this->trans('Successful deletion', 'Admin.Notifications.Success')); - } - - return $this->redirectToRoute('admin_emails_index'); - } - - /** - * Delete single email log. - * - * @DemoRestricted(redirectRoute="admin_emails_index") - * @AdminSecurity("is_granted(['delete'], request.get('_legacy_controller'))", message="Access denied.") - * - * @param int $mailId - * - * @return RedirectResponse - */ - public function deleteAction($mailId) - { - $mailLogsEraser = $this->get('prestashop.adapter.email.email_log_eraser'); - $errors = $mailLogsEraser->erase([$mailId]); - - if (!empty($errors)) { - $this->flashErrors($errors); - } else { - $this->addFlash( - 'success', - $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success') - ); - } - - return $this->redirectToRoute('admin_emails_index'); - } - - /** - * Processes test email sending. - * - * @param Request $request - * - * @return Response - */ - public function sendTestAction(Request $request) - { - if ($this->isDemoModeEnabled()) { - return $this->json([ - 'errors' => [ - $this->getDemoModeErrorMessage(), - ], - ]); - } - - if (!in_array( - $this->authorizationLevel($request->attributes->get('_legacy_controller')), - [ - PageVoter::LEVEL_READ, - PageVoter::LEVEL_UPDATE, - PageVoter::LEVEL_CREATE, - PageVoter::LEVEL_DELETE, - ] - )) { - return $this->json([ - 'errors' => [ - $this->trans('Access denied.', 'Admin.Notifications.Error'), - ], - ]); - } - - $testEmailSendingForm = $this->createForm(TestEmailSendingType::class); - $testEmailSendingForm->handleRequest($request); - - $result = []; - - if ($testEmailSendingForm->isSubmitted()) { - $emailConfigurationTester = $this->get('prestashop.adapter.email.email_configuration_tester'); - $result['errors'] = $emailConfigurationTester->testConfiguration($testEmailSendingForm->getData()); - } - - return $this->json($result); - } - - /** - * Get email configuration form handler. - * - * @return FormHandlerInterface - */ - protected function getEmailConfigurationFormHandler() - { - return $this->get('prestashop.admin.email_configuration.form_handler'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/EmployeeController.php b/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/EmployeeController.php deleted file mode 100644 index c6ba3413..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/EmployeeController.php +++ /dev/null @@ -1,562 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\AdvancedParameters; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\BulkDeleteEmployeeCommand; -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\BulkUpdateEmployeeStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\DeleteEmployeeCommand; -use PrestaShop\PrestaShop\Core\Domain\Employee\Command\ToggleEmployeeStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\AdminEmployeeException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\CannotDeleteEmployeeException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmailAlreadyUsedException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeCannotChangeItselfException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\EmployeeNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\InvalidEmployeeIdException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\InvalidProfileException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Exception\MissingShopAssociationException; -use PrestaShop\PrestaShop\Core\Domain\Employee\Query\GetEmployeeForEditing; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Query\GetShowcaseCardIsClosed; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\ValueObject\ShowcaseCard; -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilderInterface; -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler; -use PrestaShop\PrestaShop\Core\Search\Filters\EmployeeFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use PrestaShopBundle\Security\Voter\PageVoter; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class EmployeeController handles pages under "Configure > Advanced Parameters > Team > Employees". - */ -class EmployeeController extends FrameworkBundleAdminController -{ - /** - * Show employees list & options page. - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @param Request $request - * @param EmployeeFilters $filters - * - * @return Response - */ - public function indexAction(Request $request, EmployeeFilters $filters) - { - $employeeOptionsFormHandler = $this->get('prestashop.admin.employee_options.form_handler'); - $employeeOptionsForm = $employeeOptionsFormHandler->getForm(); - - $employeeOptionsChecker = $this->get('prestashop.core.team.employee.configuration.options_checker'); - - $employeeGridFactory = $this->get('prestashop.core.grid.factory.employee'); - $employeeGrid = $employeeGridFactory->getGrid($filters); - - $helperCardDocumentationLinkProvider = - $this->get('prestashop.core.util.helper_card.documentation_link_provider'); - - $showcaseCardIsClosed = $this->getQueryBus()->handle( - new GetShowcaseCardIsClosed((int) $this->getContext()->employee->id, ShowcaseCard::EMPLOYEES_CARD) - ); - - return $this->render('@PrestaShop/Admin/Configure/AdvancedParameters/Employee/index.html.twig', [ - 'employeeOptionsForm' => $employeeOptionsForm->createView(), - 'canOptionsBeChanged' => $employeeOptionsChecker->canBeChanged(), - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'employeeGrid' => $this->presentGrid($employeeGrid), - 'helperCardDocumentationLink' => $helperCardDocumentationLinkProvider->getLink('team'), - 'showcaseCardName' => ShowcaseCard::EMPLOYEES_CARD, - 'isShowcaseCardClosed' => $showcaseCardIsClosed, - ]); - } - - /** - * Save employee options. - * - * @DemoRestricted(redirectRoute="admin_employees_index") - * @AdminSecurity("is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function saveOptionsAction(Request $request) - { - $employeeOptionsFormHandler = $this->get('prestashop.admin.employee_options.form_handler'); - $employeeOptionsForm = $employeeOptionsFormHandler->getForm(); - $employeeOptionsForm->handleRequest($request); - - if ($employeeOptionsForm->isSubmitted()) { - $errors = $employeeOptionsFormHandler->save($employeeOptionsForm->getData()); - - if (!empty($errors)) { - $this->flashErrors($errors); - - return $this->redirectToRoute('admin_employees_index'); - } - - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - } - - return $this->redirectToRoute('admin_employees_index'); - } - - /** - * Toggle given employee status. - * - * @DemoRestricted(redirectRoute="admin_employees_index") - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute="admin_employees_index") - * - * @param int $employeeId - * - * @return RedirectResponse - */ - public function toggleStatusAction($employeeId) - { - try { - $this->getCommandBus()->handle(new ToggleEmployeeStatusCommand((int) $employeeId)); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (EmployeeException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_employees_index'); - } - - /** - * Bulk enables employee status action. - * - * @DemoRestricted(redirectRoute="admin_employees_index") - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkStatusEnableAction(Request $request) - { - $employeeIds = $request->request->get('employee_employee_bulk'); - - try { - $this->getCommandBus()->handle( - new BulkUpdateEmployeeStatusCommand($employeeIds, true) - ); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (EmployeeException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_employees_index'); - } - - /** - * Bulk disables employee status action. - * - * @DemoRestricted(redirectRoute="admin_employees_index") - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkStatusDisableAction(Request $request) - { - $employeeIds = $request->request->get('employee_employee_bulk'); - - try { - $this->getCommandBus()->handle( - new BulkUpdateEmployeeStatusCommand($employeeIds, false) - ); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (EmployeeException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_employees_index'); - } - - /** - * Delete employee. - * - * @DemoRestricted(redirectRoute="admin_employees_index") - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))") - * - * @param int $employeeId - * - * @return RedirectResponse - */ - public function deleteAction($employeeId) - { - try { - $this->getCommandBus()->handle(new DeleteEmployeeCommand((int) $employeeId)); - - $this->addFlash('success', $this->trans('Successful deletion.', 'Admin.Notifications.Success')); - } catch (EmployeeException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_employees_index'); - } - - /** - * Delete employees in bulk actions. - * - * @DemoRestricted(redirectRoute="admin_employees_index") - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkDeleteAction(Request $request) - { - $employeeIds = $request->request->get('employee_employee_bulk'); - - try { - $this->getCommandBus()->handle(new BulkDeleteEmployeeCommand($employeeIds)); - - $this->addFlash( - 'success', - $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success') - ); - } catch (EmployeeException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_employees_index'); - } - - /** - * Show employee creation form page and handle it's submit. - * - * @DemoRestricted(redirectRoute="admin_employees_index") - * @AdminSecurity("is_granted('create', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request) - { - $employeeForm = $this->getEmployeeFormBuilder()->getForm(); - $employeeForm->handleRequest($request); - - try { - $result = $this->getEmployeeFormHandler()->handle($employeeForm); - - if (null !== $result->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_employees_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - $templateVars = [ - 'employeeForm' => $employeeForm->createView(), - 'showAddonsConnectButton' => false, - 'enableSidebar' => true, - ]; - - return $this->render( - '@PrestaShop/Admin/Configure/AdvancedParameters/Employee/create.html.twig', - $templateVars + $this->getFormTemplateVariables($request) - ); - } - - /** - * Show Employee edit page. - * - * @DemoRestricted(redirectRoute="admin_employees_index") - * - * @param int $employeeId - * @param Request $request - * - * @return Response - */ - public function editAction($employeeId, Request $request) - { - $contextEmployeeProvider = $this->get('prestashop.adapter.data_provider.employee'); - - // If employee is editing his own profile - he doesn't need to have access to the edit form. - if ($contextEmployeeProvider->getId() != $employeeId) { - if (!$this->isGranted(PageVoter::UPDATE, $request->get('_legacy_controller'))) { - $this->addFlash( - 'error', - $this->trans( - 'You do not have permission to update this.', - 'Admin.Notifications.Error' - ) - ); - - return $this->redirectToRoute('admin_employees_index'); - } - } - - $formAccessChecker = $this->get('prestashop.adapter.employee.form_access_checker'); - - if (!$formAccessChecker->canAccessEditFormFor($employeeId)) { - $this->addFlash( - 'error', - $this->trans('You cannot edit the SuperAdmin profile.', 'Admin.Advparameters.Notification') - ); - - return $this->redirectToRoute('admin_employees_index'); - } - - $isRestrictedAccess = $formAccessChecker->isRestrictedAccess((int) $employeeId); - $canAccessAddonsConnect = $formAccessChecker->canAccessAddonsConnect(); - - try { - $employeeForm = $this->getEmployeeFormBuilder()->getFormFor((int) $employeeId, [], [ - 'is_restricted_access' => $isRestrictedAccess, - 'is_for_editing' => true, - 'show_addons_connect_button' => $canAccessAddonsConnect, - ]); - - $employeeForm->handleRequest($request); - $result = $this->getEmployeeFormHandler()->handleFor((int) $employeeId, $employeeForm); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_employees_edit', [ - 'employeeId' => $result->getIdentifiableObjectId(), - ]); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - try { - $editableEmployee = $this->getQueryBus()->handle(new GetEmployeeForEditing((int) $employeeId)); - } catch (EmployeeNotFoundException $e) { - return $this->redirectToRoute('admin_employees_index'); - } - - $templateVars = [ - 'employeeForm' => $employeeForm->createView(), - 'isRestrictedAccess' => $isRestrictedAccess, - 'showAddonsConnectButton' => $canAccessAddonsConnect, - 'editableEmployee' => $editableEmployee, - ]; - - return $this->render( - '@PrestaShop/Admin/Configure/AdvancedParameters/Employee/edit.html.twig', - $templateVars + $this->getFormTemplateVariables($request) - ); - } - - /** - * Change navigation menu status for employee. - * - * @param Request $request - * - * @return Response - */ - public function toggleNavigationMenuAction(Request $request) - { - $navigationToggler = $this->get('prestashop.adapter.employee.navigation_menu_toggler'); - $navigationToggler->toggleNavigationMenuInCookies($request->request->getBoolean('shouldCollapse')); - - return new Response('', Response::HTTP_NO_CONTENT); - } - - /** - * Change employee form language. - * - * @param Request $request - * - * @return Response - */ - public function changeFormLanguageAction(Request $request) - { - $configuration = $this->get('prestashop.adapter.legacy.configuration'); - - if ($configuration->getBoolean('PS_BO_ALLOW_EMPLOYEE_FORM_LANG')) { - $languageChanger = $this->get('prestashop.adapter.employee.form_language_changer'); - $languageChanger->changeLanguageInCookies($request->request->get('language_iso_code')); - } - - return new Response('', Response::HTTP_NO_CONTENT); - } - - /** - * Get tabs which are accessible for given profile. - * - * @AdminSecurity( - * "is_granted(['update'], request.get('_legacy_controller'))", - * redirectRoute="admin_employees_index" - * ) - * - * @param Request $request - * - * @return JsonResponse - */ - public function getAccessibleTabsAction(Request $request) - { - $profileId = $request->query->get('profileId'); - $tabsDataProvider = $this->get('prestashop.adapter.data_provider.tab'); - $contextEmployeeProvider = $this->get('prestashop.adapter.data_provider.employee'); - - return $this->json( - $tabsDataProvider->getViewableTabs($profileId, $contextEmployeeProvider->getLanguageId()) - ); - } - - /** - * @return FormBuilderInterface - */ - protected function getEmployeeFormBuilder() - { - return $this->get('prestashop.core.form.identifiable_object.builder.employee_form_builder'); - } - - /** - * @return FormHandler - */ - protected function getEmployeeFormHandler() - { - return $this->get('prestashop.core.form.identifiable_object.handler.employee_form_handler'); - } - - /** - * Get human readable error messages. - * - * @param Exception $e - * - * @return array - */ - protected function getErrorMessages(Exception $e) - { - return [ - InvalidEmployeeIdException::class => $this->trans( - 'The object cannot be loaded (the identifier is missing or invalid)', - 'Admin.Notifications.Error' - ), - EmployeeNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - AdminEmployeeException::class => [ - AdminEmployeeException::CANNOT_CHANGE_LAST_ADMIN => $this->trans( - 'You cannot disable or delete the administrator account.', - 'Admin.Advparameters.Notification' - ), - ], - EmployeeCannotChangeItselfException::class => [ - EmployeeCannotChangeItselfException::CANNOT_CHANGE_STATUS => $this->trans( - 'You cannot disable or delete your own account.', - 'Admin.Advparameters.Notification' - ), - ], - CannotDeleteEmployeeException::class => $this->trans( - 'Can\'t delete #%id%', - 'Admin.Notifications.Error', - [ - '%id%' => $e instanceof CannotDeleteEmployeeException ? $e->getEmployeeId()->getValue() : 0, - ] - ), - MissingShopAssociationException::class => $this->trans( - 'The employee must be associated with at least one shop.', - 'Admin.Advparameters.Notification' - ), - InvalidProfileException::class => $this->trans( - 'The provided profile is invalid', - 'Admin.Advparameters.Notification' - ), - EmailAlreadyUsedException::class => sprintf( - '%s %s', - $this->trans( - 'An account already exists for this email address:', - 'Admin.Orderscustomers.Notification' - ), - $e instanceof EmailAlreadyUsedException ? $e->getEmail() : '' - ), - EmployeeConstraintException::class => [ - EmployeeConstraintException::INVALID_EMAIL => $this->trans( - 'The %s field is invalid.', - 'Admin.Notifications.Error', - [sprintf('"%s"', $this->trans('Email', 'Admin.Global'))] - ), - EmployeeConstraintException::INVALID_FIRST_NAME => $this->trans( - 'The %s field is invalid.', - 'Admin.Notifications.Error', - [sprintf('"%s"', $this->trans('First name', 'Admin.Global'))] - ), - EmployeeConstraintException::INVALID_LAST_NAME => $this->trans( - 'The %s field is invalid.', - 'Admin.Notifications.Error', - [sprintf('"%s"', $this->trans('Last name', 'Admin.Global'))] - ), - EmployeeConstraintException::INCORRECT_PASSWORD => $this->trans( - 'Your current password is invalid.', - 'Admin.Advparameters.Notification' - ), - ], - ]; - } - - /** - * Get template variables that are same between create and edit forms. - * - * @param Request $request - * - * @return array - */ - private function getFormTemplateVariables(Request $request) - { - $configuration = $this->get('prestashop.adapter.legacy.configuration'); - - return [ - 'level' => $this->authorizationLevel($request->attributes->get('_legacy_controller')), - 'requireAddonsSearch' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'superAdminProfileId' => $configuration->get('_PS_ADMIN_PROFILE_'), - 'getTabsUrl' => $this->generateUrl('admin_employees_get_tabs'), - 'errorMessage' => $this->trans('You need permission to add this.', 'Admin.Notifications.Error'), - ]; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/ImportController.php b/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/ImportController.php deleted file mode 100644 index b9942e68..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/ImportController.php +++ /dev/null @@ -1,417 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\AdvancedParameters; - -use PrestaShop\PrestaShop\Core\Import\Exception\NotSupportedImportEntityException; -use PrestaShop\PrestaShop\Core\Import\Exception\UnavailableImportFileException; -use PrestaShop\PrestaShop\Core\Import\ImportDirectory; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Exception\FileUploadException; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use PrestaShopBundle\Security\Voter\PageVoter; -use Symfony\Component\HttpFoundation\BinaryFileResponse; -use Symfony\Component\HttpFoundation\File\UploadedFile; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\ResponseHeaderBag; - -/** - * Responsible of "Configure > Advanced Parameters > Import" page display. - */ -class ImportController extends FrameworkBundleAdminController -{ - /** - * Show import form & handle forwarding to legacy controller. - * - * @param Request $request - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @return array|RedirectResponse|Response - */ - public function importAction(Request $request) - { - $legacyController = $request->attributes->get('_legacy_controller'); - - $importDir = $this->get('prestashop.core.import.dir'); - - if (!$this->checkImportDirectory($importDir)) { - return $this->render( - '@PrestaShop/Admin/Configure/AdvancedParameters/ImportPage/import.html.twig', - $this->getTemplateParams($request) - ); - } - - $formHandler = $this->get('prestashop.admin.import.form_handler'); - $finder = $this->get('prestashop.core.import.file_finder'); - $iniConfiguration = $this->get('prestashop.core.configuration.ini_configuration'); - $importConfigFactory = $this->get('prestashop.core.import.config_factory'); - - $importConfig = $importConfigFactory->buildFromRequest($request); - $form = $formHandler->getForm($importConfig); - $form->handleRequest($request); - - if ($form->isSubmitted()) { - if (!$this->checkImportFormSubmitPermissions($legacyController)) { - return $this->redirectToRoute('admin_import'); - } - - $data = $form->getData(); - - if (!$errors = $formHandler->save($data)) { - // WIP import page 2 redirect - /*return $this->redirectToRoute( - 'admin_import_data_configuration_index', - [], - Response::HTTP_TEMPORARY_REDIRECT - );*/ - return $this->forwardRequestToLegacyResponse($request); - } - - $this->flashErrors($errors); - } - - $params = [ - 'importForm' => $form->createView(), - 'importFileUploadUrl' => $this->generateUrl('admin_import_file_upload'), - 'importFileNames' => $finder->getImportFileNames(), - 'importDirectory' => $importDir->getDir(), - 'maxFileUploadSize' => $iniConfiguration->getPostMaxSizeInBytes(), - ]; - - return $this->render( - '@PrestaShop/Admin/Configure/AdvancedParameters/ImportPage/import.html.twig', - $this->getTemplateParams($request) + $params - ); - } - - /** - * Handle import file upload via AJAX, sending authorization errors in JSON. - * - * @param Request $request - * - * @return JsonResponse - */ - public function uploadAction(Request $request) - { - $legacyController = $request->attributes->get('_legacy_controller'); - - if ($this->isDemoModeEnabled()) { - return $this->json([ - 'error' => $this->trans('This functionality has been disabled.', 'Admin.Notifications.Error'), - ]); - } - - if (!in_array($this->authorizationLevel($legacyController), [ - PageVoter::LEVEL_CREATE, - PageVoter::LEVEL_UPDATE, - PageVoter::LEVEL_DELETE, - ])) { - return $this->json([ - 'error' => $this->trans('You do not have permission to update this.', 'Admin.Notifications.Error'), - ]); - } - - $uploadedFile = $request->files->get('file'); - if (!$uploadedFile instanceof UploadedFile) { - return $this->json([ - 'error' => $this->trans('No file was uploaded.', 'Admin.Advparameters.Notification'), - ]); - } - - try { - $fileUploader = $this->get('prestashop.core.import.file_uploader'); - $file = $fileUploader->upload($uploadedFile); - } catch (FileUploadException $e) { - return $this->json(['error' => $e->getMessage()]); - } - - $response['file'] = [ - 'name' => $file->getFilename(), - 'size' => $file->getSize(), - ]; - - return $this->json($response); - } - - /** - * Delete import file. - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", message="You do not have permission to update this.", redirectRoute="admin_import") - * @DemoRestricted(redirectRoute="admin_import") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function deleteAction(Request $request) - { - $filename = $request->query->get('filename', $request->query->get('csvfilename')); - if ($filename) { - $fileRemoval = $this->get('prestashop.core.import.file_removal'); - $fileRemoval->remove($filename); - } - - return $this->redirectToRoute('admin_import'); - } - - /** - * Download import file from history. - * - * @AdminSecurity("is_granted(['read','update', 'create','delete'], request.get('_legacy_controller'))", message="You do not have permission to update this.", redirectRoute="admin_import") - * @DemoRestricted(redirectRoute="admin_import") - * - * @param Request $request - * - * @return Response - */ - public function downloadAction(Request $request) - { - if ($filename = $request->query->get('filename')) { - $importDirectory = $this->get('prestashop.core.import.dir'); - - $response = new BinaryFileResponse($importDirectory . $filename); - $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename); - - return $response; - } - - return $this->redirectToRoute('admin_import'); - } - - /** - * Download import sample file. - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))", redirectRoute="admin_import") - * - * @param $sampleName - * - * @return Response - */ - public function downloadSampleAction($sampleName) - { - $sampleFileProvider = $this->get('prestashop.core.import.sample.file_provider'); - $sampleFile = $sampleFileProvider->getFile($sampleName); - - if (null === $sampleFile) { - return $this->redirectToRoute('admin_import'); - } - - $response = new BinaryFileResponse($sampleFile->getPathname()); - $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $sampleFile->getFilename()); - - return $response; - } - - /** - * Get available entity fields. - * - * @AdminSecurity( - * "is_granted('read', request.get('_legacy_controller'))", - * redirectRoute="admin_import" - * ) - * - * @param Request $request - * - * @return JsonResponse - */ - public function getAvailableEntityFieldsAction(Request $request) - { - $fieldsProviderFinder = $this->get('prestashop.core.import.fields_provider_finder'); - try { - $fieldsProvider = $fieldsProviderFinder->find($request->get('entity')); - $fieldsCollection = $fieldsProvider->getCollection(); - $entityFields = $fieldsCollection->toArray(); - } catch (NotSupportedImportEntityException $e) { - $entityFields = []; - } - - return $this->json($entityFields); - } - - /** - * Process the import. - * - * @AdminSecurity("is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", redirectRoute="admin_import") - * @DemoRestricted(redirectRoute="admin_import") - * - * @param Request $request - * - * @return JsonResponse - */ - public function processImportAction(Request $request) - { - $errors = []; - $requestValidator = $this->get('prestashop.core.import.request_validator'); - - try { - $requestValidator->validate($request); - } catch (UnavailableImportFileException $e) { - $errors[] = $this->trans('To proceed, please upload a file first.', 'Admin.Advparameters.Notification'); - } - - if (!empty($errors)) { - return $this->json([ - 'errors' => $errors, - 'isFinished' => true, - ]); - } - - $importer = $this->get('prestashop.core.import.importer'); - $importConfigFactory = $this->get('prestashop.core.import.config_factory'); - $runtimeConfigFactory = $this->get('prestashop.core.import.runtime_config_factory'); - $importHandlerFinder = $this->get('prestashop.adapter.import.handler_finder'); - - $importConfig = $importConfigFactory->buildFromRequest($request); - $runtimeConfig = $runtimeConfigFactory->buildFromRequest($request); - - $importer->import( - $importConfig, - $runtimeConfig, - $importHandlerFinder->find($importConfig->getEntityType()) - ); - - return $this->json($runtimeConfig->toArray()); - } - - /** - * Get generic template parameters. - * - * @param Request $request - * - * @return array - */ - protected function getTemplateParams(Request $request) - { - $legacyController = $request->attributes->get('_legacy_controller'); - - return [ - 'layoutHeaderToolbarBtn' => [], - 'layoutTitle' => $this->get('translator')->trans('Import', [], 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'requireBulkActions' => false, - 'showContentHeader' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($legacyController), - ]; - } - - /** - * Checks permissions of import form in step 1. - * - * @param $legacyController - * - * @return bool - */ - private function checkImportFormSubmitPermissions($legacyController) - { - if ($this->isDemoModeEnabled()) { - $this->addFlash( - 'error', - $this->trans( - 'This functionality has been disabled.', - 'Admin.Notifications.Error' - ) - ); - - return false; - } - - if (!in_array($this->authorizationLevel($legacyController), [ - PageVoter::LEVEL_CREATE, - PageVoter::LEVEL_UPDATE, - PageVoter::LEVEL_DELETE, - ])) { - $this->addFlash( - 'error', - $this->trans( - 'You do not have permission to update this.', - 'Admin.Notifications.Error' - ) - ); - - return false; - } - - return true; - } - - /** - * Check if the import directory exists and is accessible. - * - * @param ImportDirectory $importDir - * - * @return array|bool - */ - private function checkImportDirectory(ImportDirectory $importDir) - { - if (!$importDir->exists()) { - $this->addFlash( - 'error', - $this->trans( - 'The import directory doesn\'t exist. Please check your file path.', - 'Admin.Advparameters.Notification' - ) - ); - - return false; - } - - if (!$importDir->isWritable()) { - $this->addFlash( - 'warning', - $this->trans( - 'The import directory must be writable (CHMOD 755 / 777).', - 'Admin.Advparameters.Notification' - ) - ); - } - - return true; - } - - /** - * Forwards submitted form data to legacy import page. - * To be removed in 1.7.7 version. - * - * @param Request $request - * - * @return RedirectResponse - */ - private function forwardRequestToLegacyResponse(Request $request) - { - $legacyController = $request->attributes->get('_legacy_controller'); - $legacyContext = $this->get('prestashop.adapter.legacy.context'); - - $legacyImportUrl = $legacyContext->getLegacyAdminLink($legacyController); - - return $this->redirect($legacyImportUrl, Response::HTTP_TEMPORARY_REDIRECT); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/ImportDataConfigurationController.php b/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/ImportDataConfigurationController.php deleted file mode 100644 index 5dcaa7d8..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/ImportDataConfigurationController.php +++ /dev/null @@ -1,171 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\AdvancedParameters; - -use PrestaShop\PrestaShop\Core\Import\Exception\UnreadableFileException; -use PrestaShop\PrestaShop\Core\Import\ImportSettings; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use SplFileInfo; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible of "Configure > Advanced Parameters > Import" step 2 page display. - */ -class ImportDataConfigurationController extends FrameworkBundleAdminController -{ - /** - * Shows import data page where the configuration of importable data and the final step of import is handled. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * @DemoRestricted(redirectRoute="admin_import") - * - * @param Request $request - * - * @return RedirectResponse|Response - */ - public function indexAction(Request $request) - { - $importDirectory = $this->get('prestashop.core.import.dir'); - $dataRowCollectionFactory = $this->get('prestashop.core.import.factory.data_row.collection_factory'); - $dataRowCollectionPresenter = $this->get('prestashop.core.import.data_row.collection_presenter'); - $entityFieldsProviderFinder = $this->get('prestashop.core.import.fields_provider_finder'); - $formHandler = $this->get('prestashop.admin.import_data_configuration.form_handler'); - $importConfigFactory = $this->get('prestashop.core.import.config_factory'); - - $importFile = new SplFileInfo($importDirectory . $request->getSession()->get('csv')); - $importConfig = $importConfigFactory->buildFromRequest($request); - $form = $formHandler->getForm($importConfig); - - try { - $dataRowCollection = $dataRowCollectionFactory->buildFromFile( - $importFile, - ImportSettings::MAX_VISIBLE_ROWS - ); - } catch (UnreadableFileException $e) { - $this->addFlash( - 'error', - $this->trans('The import file cannot be read.', 'Admin.Advparameters.Notification') - ); - - return $this->redirectToRoute('admin_import'); - } - - $presentedDataRowCollection = $dataRowCollectionPresenter->present($dataRowCollection); - $entityFieldsProvider = $entityFieldsProviderFinder->find($importConfig->getEntityType()); - - return $this->render( - '@PrestaShop/Admin/Configure/AdvancedParameters/ImportDataConfiguration/index.html.twig', - [ - 'importDataConfigurationForm' => $form->createView(), - 'dataRowCollection' => $presentedDataRowCollection, - 'maxVisibleColumns' => ImportSettings::MAX_VISIBLE_COLUMNS, - 'showPagingArrows' => $presentedDataRowCollection['row_size'] > ImportSettings::MAX_VISIBLE_COLUMNS, - 'requiredFields' => $entityFieldsProvider->getCollection()->getRequiredFields(), - ] - ); - } - - /** - * Create import data match configuration. - * - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message="You do not have permission to update this.", redirectRoute="admin_import") - * @DemoRestricted(redirectRoute="admin_import") - * - * @param Request $request - * - * @return JsonResponse - */ - public function createAction(Request $request) - { - $formHandler = $this->get('prestashop.admin.import_data_configuration.form_handler'); - $importConfigFactory = $this->get('prestashop.core.import.config_factory'); - - $importConfig = $importConfigFactory->buildFromRequest($request); - $form = $formHandler->getForm($importConfig); - $form->setData([ - 'match_name' => $request->request->get('match_name'), - 'skip' => $request->request->get('skip'), - 'type_value' => $request->request->get('type_value'), - ]); - - $errors = $formHandler->save($form->getData()); - $matches = []; - - if (!$errors) { - $importMatchRepository = $this->get('prestashop.core.admin.import_match.repository'); - $matches = $importMatchRepository->findAll(); - } - - return $this->json([ - 'errors' => $errors, - 'matches' => $matches, - ]); - } - - /** - * Delete import data match configuration. - * - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message="You do not have permission to update this.", redirectRoute="admin_import") - * @DemoRestricted(redirectRoute="admin_import") - * - * @param Request $request - * - * @return JsonResponse - */ - public function deleteAction(Request $request) - { - $importMatchRepository = $this->get('prestashop.core.admin.import_match.repository'); - $importMatchRepository->deleteById($request->get('import_match_id')); - - return $this->json([]); - } - - /** - * Get import data match configuration. - * - * @AdminSecurity( - * "is_granted('read', request.get('_legacy_controller'))", - * redirectRoute="admin_import" - * ) - * - * @param Request $request - * - * @return JsonResponse - */ - public function getAction(Request $request) - { - $importMatchRepository = $this->get('prestashop.core.admin.import_match.repository'); - $importMatch = $importMatchRepository->findOneById($request->get('import_match_id')); - - return $this->json($importMatch); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/LogsController.php b/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/LogsController.php deleted file mode 100644 index 5636d372..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/LogsController.php +++ /dev/null @@ -1,167 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\AdvancedParameters; - -use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface; -use PrestaShop\PrestaShop\Core\Search\Filters\LogsFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Entity\Repository\LogRepository; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible of "Configure > Advanced Parameters > Logs" page display. - */ -class LogsController extends FrameworkBundleAdminController -{ - /** - * @var string the controller name for routing - */ - const CONTROLLER_NAME = 'AdminLogs'; - - /** - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message="Access denied.") - * - * @param LogsFilters $filters the list of filters from the request - * - * @return Response - */ - public function indexAction(LogsFilters $filters) - { - $gridLogFactory = $this->get('prestashop.core.grid.log_factory'); - $grid = $gridLogFactory->getGrid($filters); - - $logsByEmailForm = $this->getFormHandler()->getForm(); - - return $this->render('@PrestaShop/Admin/Configure/AdvancedParameters/LogsPage/index.html.twig', [ - 'layoutHeaderToolbarBtn' => [], - 'layoutTitle' => $this->trans('Logs', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'requireBulkActions' => false, - 'showContentHeader' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink('AdminLogs'), - 'logsByEmailForm' => $logsByEmailForm->createView(), - 'grid' => $this->presentGrid($grid), - ]); - } - - /** - * @AdminSecurity("is_granted(['read', 'update', 'create', 'delete'], request.get('_legacy_controller'))", message="You do not have permission to update this.", redirectRoute="admin_logs_index") - * @DemoRestricted(redirectRoute="admin_logs_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function searchAction(Request $request) - { - $definitionFactory = $this->get('prestashop.core.grid.definition.factory.logs'); - $logsDefinition = $definitionFactory->getDefinition(); - - $gridFilterFormFactory = $this->get('prestashop.core.grid.filter.form_factory'); - $searchParametersForm = $gridFilterFormFactory->create($logsDefinition); - - $searchParametersForm->handleRequest($request); - $filters = []; - - $this->dispatchHook('actionAdminLogsControllerPostProcessBefore', ['controller' => $this]); - - if ($searchParametersForm->isSubmitted()) { - $filters = $searchParametersForm->getData(); - } - - return $this->redirectToRoute('admin_logs_index', ['filters' => $filters]); - } - - /** - * @AdminSecurity("is_granted(['update', 'create','delete'], request.get('_legacy_controller'))", message="You do not have permission to update this.", redirectRoute="admin_logs_index") - * @DemoRestricted(redirectRoute="admin_logs_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function saveSettingsAction(Request $request) - { - $logsByEmailForm = $this->getFormHandler()->getForm(); - $logsByEmailForm->handleRequest($request); - - $this->dispatchHook('actionAdminLogsControllerPostProcessBefore', ['controller' => $this]); - - if ($logsByEmailForm->isSubmitted()) { - $data = $logsByEmailForm->getData(); - - $saveErrors = $this->getFormHandler()->save($data); - - if (0 === count($saveErrors)) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_logs_index'); - } - - $this->flashErrors($saveErrors); - } - - return $this->redirectToRoute('admin_logs_index'); - } - - /** - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", message="You do not have permission to update this.", redirectRoute="admin_logs_index") - * - * @return RedirectResponse - * - * @throws \Doctrine\DBAL\Exception\InvalidArgumentException - */ - public function deleteAllAction() - { - $this->getLogRepository()->deleteAll(); - - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_logs_index'); - } - - /** - * @return FormHandlerInterface the form handler to set the severity level - */ - private function getFormHandler() - { - return $this->get('prestashop.adapter.logs.form_handler'); - } - - /** - * @return LogRepository the repository to retrieve logs from database - */ - private function getLogRepository() - { - return $this->get('prestashop.core.admin.log.repository'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/MemcacheServerController.php b/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/MemcacheServerController.php deleted file mode 100644 index 0118ba66..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/MemcacheServerController.php +++ /dev/null @@ -1,194 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\AdvancedParameters; - -use PrestaShop\PrestaShop\Adapter\Cache\MemcacheServerManager; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use PrestaShopBundle\Security\Voter\PageVoter; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible of "Configure > Advanced Parameters > Performance" servers block management. - */ -class MemcacheServerController extends FrameworkBundleAdminController -{ - const CONTROLLER_NAME = 'AdminPerformance'; - - /** - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message="Access denied.") - * - * @return JsonResponse - */ - public function listAction() - { - return new JsonResponse($this->getMemcacheManager()->getServers()); - } - - /** - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message="Access denied.") - * @DemoRestricted(redirectRoute="admin_servers_test") - * - * @param Request $request - * - * @return JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse - */ - public function testAction(Request $request) - { - $queryValues = $request->query; - - if ($queryValues->has('server_ip') && $queryValues->has('server_port')) { - $isValid = $this->getMemcacheManager() - ->testConfiguration( - $queryValues->get('server_ip'), - $queryValues->getInt('server_port') - ); - - return new JsonResponse(['test' => $isValid]); - } - - return new JsonResponse(['errors' => 'error'], Response::HTTP_BAD_REQUEST); - } - - /** - * @AdminSecurity("is_granted('create', request.get('_legacy_controller'))", message="Access denied.") - * @DemoRestricted(redirectRoute="admin_servers_test") - * - * @param Request $request - * - * @return JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse - */ - public function addAction(Request $request) - { - if (!in_array( - $this->authorizationLevel($this::CONTROLLER_NAME), - [ - PageVoter::LEVEL_READ, - PageVoter::LEVEL_UPDATE, - PageVoter::LEVEL_CREATE, - PageVoter::LEVEL_DELETE, - ] - )) { - return new JsonResponse( - [ - 'errors' => [ - $this->trans('You do not have permission to create this.', 'Admin.Notifications.Error'), - ], - ], - Response::HTTP_BAD_REQUEST - ); - } - - $postValues = $request->request; - - if ($postValues->has('server_ip') - && $postValues->has('server_port') - && $postValues->has('server_weight') - && $this->getMemcacheManager()->testConfiguration( - $postValues->get('server_ip'), - $postValues->getInt('server_port') - ) - ) { - $server = $this->getMemcacheManager() - ->addServer( - $postValues->get('server_ip'), - $postValues->getInt('server_port'), - $postValues->get('server_weight') - ); - - return new JsonResponse($server, 201); - } - - return new JsonResponse( - [ - 'errors' => [ - $this->trans('The Memcached server cannot be added.', 'Admin.Advparameters.Notification'), - ], - ], - Response::HTTP_BAD_REQUEST - ); - } - - /** - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", message="Access denied.") - * @DemoRestricted(redirectRoute="admin_servers_test") - * - * @param Request $request - * - * @return JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse - */ - public function deleteAction(Request $request) - { - if (!in_array( - $this->authorizationLevel($this::CONTROLLER_NAME), - [ - PageVoter::LEVEL_READ, - PageVoter::LEVEL_UPDATE, - PageVoter::LEVEL_CREATE, - PageVoter::LEVEL_DELETE, - ] - )) { - return new JsonResponse( - [ - 'errors' => [ - $this->trans('You do not have permission to delete this.', 'Admin.Notifications.Error'), - ], - ], - Response::HTTP_BAD_REQUEST - ); - } - - if ($request->request->has('server_id')) { - $this->getMemcacheManager()->deleteServer($request->request->get('server_id')); - - return new JsonResponse([], Response::HTTP_NO_CONTENT); - } - - return new JsonResponse( - [ - 'errors' => [ - $this->trans( - 'There was an error when attempting to delete the Memcached server.', - 'Admin.Advparameters.Notification' - ), - ], - ], - Response::HTTP_BAD_REQUEST - ); - } - - /** - * @return MemcacheServerManager - */ - private function getMemcacheManager() - { - return $this->get('prestashop.adapter.memcache_server.manager'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/PerformanceController.php b/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/PerformanceController.php deleted file mode 100644 index 8ec42565..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/PerformanceController.php +++ /dev/null @@ -1,127 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\AdvancedParameters; - -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible of "Configure > Advanced Parameters > Performance" page display. - */ -class PerformanceController extends FrameworkBundleAdminController -{ - const CONTROLLER_NAME = 'AdminPerformance'; - - /** - * Displays the Performance main page. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message="Access denied.") - * - * @param FormInterface $form - * - * @return Response - */ - public function indexAction(FormInterface $form = null): Response - { - $toolbarButtons = [ - 'clear_cache' => [ - 'href' => $this->generateUrl('admin_clear_cache'), - 'desc' => $this->trans('Clear cache', 'Admin.Advparameters.Feature'), - 'icon' => 'delete', - ], - ]; - - $form = null === $form ? $this->get('prestashop.adapter.performance.form_handler')->getForm() : $form; - - return $this->render('@PrestaShop/Admin/Configure/AdvancedParameters/performance.html.twig', [ - 'layoutHeaderToolbarBtn' => $toolbarButtons, - 'layoutTitle' => $this->trans('Performance', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'requireBulkActions' => false, - 'showContentHeader' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink('AdminPerformance'), - 'requireFilterStatus' => false, - 'form' => $form->createView(), - 'servers' => $this->get('prestashop.adapter.memcache_server.manager')->getServers(), - ]); - } - - /** - * Process the Performance configuration form. - * - * @AdminSecurity("is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", message="You do not have permission to update this.") - * @DemoRestricted(redirectRoute="admin_performance") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function processFormAction(Request $request) - { - $this->dispatchHook('actionAdminPerformanceControllerPostProcessBefore', ['controller' => $this]); - $form = $this->get('prestashop.adapter.performance.form_handler')->getForm(); - $form->handleRequest($request); - - if ($form->isSubmitted()) { - $data = $form->getData(); - - $saveErrors = $this->get('prestashop.adapter.performance.form_handler')->save($data); - - if (0 === count($saveErrors)) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_performance'); - } - - $this->flashErrors($saveErrors); - } - - return $this->redirectToRoute('admin_performance'); - } - - /** - * @AdminSecurity("is_granted(['delete'], request.get('_legacy_controller'))", - * message="You do not have permission to update this.", - * redirectRoute="admin_performance" - * ) - * - * @return RedirectResponse - */ - public function clearCacheAction() - { - $this->get('prestashop.core.cache.clearer.cache_clearer_chain')->clear(); - $this->addFlash('success', $this->trans('All caches cleared successfully', 'Admin.Advparameters.Notification')); - - return $this->redirectToRoute('admin_performance'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/ProfileController.php b/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/ProfileController.php deleted file mode 100644 index f05574d2..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/ProfileController.php +++ /dev/null @@ -1,300 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\AdvancedParameters; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Profile\Command\BulkDeleteProfileCommand; -use PrestaShop\PrestaShop\Core\Domain\Profile\Command\DeleteProfileCommand; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\CannotDeleteSuperAdminProfileException; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\FailedToDeleteProfileException; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\ProfileConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\ProfileException; -use PrestaShop\PrestaShop\Core\Domain\Profile\Exception\ProfileNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Profile\ProfileSettings; -use PrestaShop\PrestaShop\Core\Domain\Profile\Query\GetProfileForEditing; -use PrestaShop\PrestaShop\Core\Domain\Profile\QueryResult\EditableProfile; -use PrestaShop\PrestaShop\Core\Search\Filters\ProfileFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class ProfilesController is responsible for displaying the - * "Configure > Advanced parameters > Team > Profiles" page. - */ -class ProfileController extends FrameworkBundleAdminController -{ - /** - * Show profiles listing page. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param ProfileFilters $filters - * - * @return Response - */ - public function indexAction(ProfileFilters $filters) - { - $profilesGridFactory = $this->get('prestashop.core.grid.factory.profiles'); - - return $this->render( - '@PrestaShop/Admin/Configure/AdvancedParameters/Profiles/index.html.twig', - [ - 'layoutHeaderToolbarBtn' => [ - 'add' => [ - 'href' => $this->generateUrl('admin_profiles_create'), - 'desc' => $this->trans('Add new profile', 'Admin.Advparameters.Feature'), - 'icon' => 'add_circle_outline', - ], - ], - 'help_link' => $this->generateSidebarLink('AdminProfiles'), - 'enableSidebar' => true, - 'layoutTitle' => $this->trans('Profiles', 'Admin.Navigation.Menu'), - 'grid' => $this->presentGrid($profilesGridFactory->getGrid($filters)), - ] - ); - } - - /** - * Used for applying filtering actions. - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function searchAction(Request $request) - { - $definitionFactory = $this->get('prestashop.core.grid.definition.factory.profile'); - $definitionFactory = $definitionFactory->getDefinition(); - - $gridFilterFormFactory = $this->get('prestashop.core.grid.filter.form_factory'); - $searchParametersForm = $gridFilterFormFactory->create($definitionFactory); - $searchParametersForm->handleRequest($request); - - $filters = []; - - if ($searchParametersForm->isSubmitted()) { - $filters = $searchParametersForm->getData(); - } - - return $this->redirectToRoute('admin_profiles_index', ['filters' => $filters]); - } - - /** - * Show profile's create page - * - * @AdminSecurity("is_granted('create', request.get('_legacy_controller'))") - * @DemoRestricted(redirectRoute="admin_profiles_index") - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request) - { - $form = $this->get('prestashop.core.form.identifiable_object.builder.profile_form_builder')->getForm(); - $form->handleRequest($request); - - try { - $formHandler = $this->get('prestashop.core.form.identifiable_object.handler.profile_form_handler'); - $handlerResult = $formHandler->handle($form); - - if (null !== $handlerResult->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_profiles_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->render('@PrestaShop/Admin/Configure/AdvancedParameters/Profiles/create.html.twig', [ - 'profileForm' => $form->createView(), - 'layoutTitle' => $this->trans('Add new profile', 'Admin.Advparameters.Feature'), - 'help_link' => $this->generateSidebarLink('AdminProfiles'), - 'enableSidebar' => true, - ]); - } - - /** - * Shows profile edit form. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * message="You do not have permission to edit this." - * ) - * @DemoRestricted(redirectRoute="admin_profiles_index") - * - * @param int $profileId - * @param Request $request - * - * @return Response - */ - public function editAction($profileId, Request $request) - { - $formHandler = $this->get('prestashop.core.form.identifiable_object.handler.profile_form_handler'); - $formBuilder = $this->get('prestashop.core.form.identifiable_object.builder.profile_form_builder'); - - try { - $form = $formBuilder->getFormFor((int) $profileId); - $form->handleRequest($request); - - $handlerResult = $formHandler->handleFor((int) $profileId, $form); - - if ($handlerResult->isSubmitted() && $handlerResult->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_profiles_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - - if ($e instanceof ProfileNotFoundException) { - return $this->redirectToRoute('admin_profiles_index'); - } - } - - /** @var EditableProfile $editableProfiler */ - $editableProfiler = $this->getQueryBus()->handle(new GetProfileForEditing((int) $profileId)); - - return $this->render('@PrestaShop/Admin/Configure/AdvancedParameters/Profiles/edit.html.twig', [ - 'profileForm' => $form->createView(), - 'layoutTitle' => $this->trans( - 'Edit: %value%', - 'Admin.Catalog.Feature', - [ - '%value%' => $editableProfiler->getLocalizedNames()[$this->getContextLangId()], - ] - ), - 'help_link' => $this->generateSidebarLink('AdminProfiles'), - 'enableSidebar' => true, - ]); - } - - /** - * Delete a profile. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller')~'_')", - * message="You do not have permission to edit this." - * ) - * @DemoRestricted(redirectRoute="admin_profiles_index") - * - * @param int $profileId - * - * @return RedirectResponse - */ - public function deleteAction($profileId) - { - try { - $deleteProfileCommand = new DeleteProfileCommand($profileId); - - $this->getCommandBus()->handle($deleteProfileCommand); - - $this->addFlash('success', $this->trans('Successful deletion', 'Admin.Notifications.Success')); - } catch (ProfileException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_profiles_index'); - } - - /** - * Bulk delete profiles. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller')~'_')", - * message="You do not have permission to edit this." - * ) - * @DemoRestricted(redirectRoute="admin_profiles_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkDeleteAction(Request $request) - { - $profileIds = $request->request->get('profile_bulk'); - - try { - $deleteProfilesCommand = new BulkDeleteProfileCommand($profileIds); - - $this->getCommandBus()->handle($deleteProfilesCommand); - - $this->addFlash('success', $this->trans('Successful deletion', 'Admin.Notifications.Success')); - } catch (ProfileException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_profiles_index'); - } - - /** - * Get human readable error for exception. - * - * @return array - */ - protected function getErrorMessages() - { - return [ - ProfileConstraintException::class => [ - ProfileConstraintException::INVALID_NAME => $this->trans( - 'This field cannot be longer than %limit% characters (incl. HTML tags)', - 'Admin.Notifications.Error', - ['%limit%' => ProfileSettings::NAME_MAX_LENGTH] - ), - ], - ProfileNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - CannotDeleteSuperAdminProfileException::class => $this->trans( - 'For security reasons, you cannot delete the Administrator\'s profile.', - 'Admin.Advparameters.Notification' - ), - FailedToDeleteProfileException::class => [ - FailedToDeleteProfileException::UNEXPECTED_ERROR => $this->trans( - 'An error occurred while deleting the object.', - 'Admin.Notifications.Error' - ), - FailedToDeleteProfileException::PROFILE_IS_ASSIGNED_TO_EMPLOYEE => $this->trans( - 'Profile(s) assigned to employee cannot be deleted', - 'Admin.Notifications.Error' - ), - FailedToDeleteProfileException::PROFILE_IS_ASSIGNED_TO_CONTEXT_EMPLOYEE => $this->trans( - 'You cannot delete your own profile', - 'Admin.Notifications.Error' - ), - ], - ]; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/SqlManagerController.php b/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/SqlManagerController.php deleted file mode 100644 index f9fea315..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/SqlManagerController.php +++ /dev/null @@ -1,594 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\AdvancedParameters; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\BulkDeleteSqlRequestCommand; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\DeleteSqlRequestCommand; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\DatabaseTableFields; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\DatabaseTablesList; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\CannotDeleteSqlRequestException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Exception\SqlRequestNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetDatabaseTableFieldsList; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetDatabaseTablesList; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetSqlRequestExecutionResult; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetSqlRequestSettings; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\SqlRequestExecutionResult; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\SqlRequestSettings; -use PrestaShop\PrestaShop\Core\Domain\SqlManagement\ValueObject\SqlRequestId; -use PrestaShop\PrestaShop\Core\Export\Exception\FileWritingException; -use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface; -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilderInterface; -use PrestaShop\PrestaShop\Core\Search\Filters\RequestSqlFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\HttpFoundation\BinaryFileResponse; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpFoundation\ResponseHeaderBag; - -/** - * Responsible of "Configure > Advanced Parameters > Database -> SQL Manager" page. - */ -class SqlManagerController extends FrameworkBundleAdminController -{ - /** - * Show list of saved SQL's. - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @param Request $request - * @param RequestSqlFilters $filters - * - * @return Response - */ - public function indexAction(Request $request, RequestSqlFilters $filters) - { - // handle "Export to SQL manager" action from legacy pages - if ($request->query->has('addrequest_sql')) { - return $this->forward('PrestaShopBundle:Admin\Configure\AdvancedParameters\RequestSql:create'); - } - - $gridLogFactory = $this->get('prestashop.core.grid.factory.request_sql'); - $grid = $gridLogFactory->getGrid($filters); - - $gridPresenter = $this->get('prestashop.core.grid.presenter.grid_presenter'); - $presentedGrid = $gridPresenter->present($grid); - - $settingsForm = $this->getSettingsFormHandler()->getForm(); - - return $this->render('@PrestaShop/Admin/Configure/AdvancedParameters/RequestSql/index.html.twig', [ - 'layoutHeaderToolbarBtn' => [ - 'add' => [ - 'href' => $this->generateUrl('admin_sql_requests_create'), - 'desc' => $this->trans('Add new SQL query', 'Admin.Advparameters.Feature'), - 'icon' => 'add_circle_outline', - ], - ], - 'layoutTitle' => $this->trans('SQL Manager', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'requestSqlSettingsForm' => $settingsForm->createView(), - 'requestSqlGrid' => $presentedGrid, - ]); - } - - /** - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))", redirectRoute="admin_sql_requests_index") - * @DemoRestricted(redirectRoute="admin_sql_requests_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function searchAction(Request $request) - { - $definitionFactory = $this->get('prestashop.core.grid.definition.factory.request_sql'); - $emailLogsDefinition = $definitionFactory->getDefinition(); - - $gridFilterFormFactory = $this->get('prestashop.core.grid.filter.form_factory'); - $filtersForm = $gridFilterFormFactory->create($emailLogsDefinition); - $filtersForm->handleRequest($request); - - $filters = []; - - if ($filtersForm->isSubmitted()) { - $filters = $filtersForm->getData(); - } - - return $this->redirectToRoute('admin_sql_requests_index', ['filters' => $filters]); - } - - /** - * Process Request SQL settings save. - * - * @DemoRestricted(redirectRoute="admin_sql_requests_index") - * @AdminSecurity( - * "is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", - * redirectRoute="admin_sql_requests_index" - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function processFormAction(Request $request) - { - $handler = $this->getSettingsFormHandler(); - $settingForm = $handler->getForm(); - $settingForm->handleRequest($request); - - if ($settingForm->isSubmitted()) { - if (!$errors = $handler->save($settingForm->getData())) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - } else { - $this->flashErrors($errors); - } - } - - return $this->redirectToRoute('admin_sql_requests_index'); - } - - /** - * Show Request SQL create page. - * - * @AdminSecurity( - * "is_granted(['create'], request.get('_legacy_controller'))", - * message="You do not have permission to create this.", - * redirectRoute="admin_sql_requests_index" - * ) - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request) - { - $data = $this->getSqlRequestDataFromRequest($request); - - $sqlRequestForm = $this->getSqlRequestFormBuilder()->getForm($data); - $sqlRequestForm->handleRequest($request); - - $result = $this->getSqlRequestFormHandler()->handle($sqlRequestForm); - - if (null !== $result->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_sql_requests_index'); - } - - return $this->render('@PrestaShop/Admin/Configure/AdvancedParameters/RequestSql/create.html.twig', [ - 'layoutTitle' => $this->trans('SQL Manager', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'requestSqlForm' => $sqlRequestForm->createView(), - 'dbTableNames' => $this->getDatabaseTables(), - ]); - } - - /** - * Show Request SQL edit page. - * - * @DemoRestricted(redirectRoute="admin_sql_requests_index") - * @AdminSecurity( - * "is_granted(['update'], request.get('_legacy_controller'))", - * message="You do not have permission to edit this.", - * redirectRoute="admin_sql_requests_index" - * ) - * - * @param int $sqlRequestId - * @param Request $request - * - * @return Response - */ - public function editAction($sqlRequestId, Request $request) - { - try { - $sqlRequestForm = $this->getSqlRequestFormBuilder()->getFormFor($sqlRequestId); - $sqlRequestForm->handleRequest($request); - - $result = $this->getSqlRequestFormHandler()->handleFor($sqlRequestId, $sqlRequestForm); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_sql_requests_index'); - } - } catch (SqlRequestNotFoundException $e) { - $this->addFlash( - 'error', - $this->trans('The object cannot be loaded (or found)', 'Admin.Notifications.Error') - ); - - return $this->redirectToRoute('admin_sql_requests_index'); - } - - return $this->render('@PrestaShop/Admin/Configure/AdvancedParameters/RequestSql/edit.html.twig', [ - 'layoutTitle' => $this->trans('SQL Manager', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'requestSqlForm' => $sqlRequestForm->createView(), - 'dbTableNames' => $this->getDatabaseTables(), - ]); - } - - /** - * Delete selected Request SQL. - * - * @AdminSecurity( - * "is_granted(['delete'], request.get('_legacy_controller'))", - * message="You do not have permission to delete this.", - * redirectRoute="admin_sql_requests_index" - * ) - * @DemoRestricted(redirectRoute="admin_sql_requests_index") - * - * @param int $sqlRequestId ID of selected Request SQL - * - * @return RedirectResponse - */ - public function deleteAction($sqlRequestId) - { - try { - $deleteSqlRequestCommand = new DeleteSqlRequestCommand( - new SqlRequestId($sqlRequestId) - ); - - $this->getCommandBus()->handle($deleteSqlRequestCommand); - - $this->addFlash('success', $this->trans('Successful deletion', 'Admin.Notifications.Success')); - } catch (SqlRequestException $e) { - $this->addFlash('error', $this->handleDeleteException($e)); - } - - return $this->redirectToRoute('admin_sql_requests_index'); - } - - /** - * Process bulk action delete of RequestSql's. - * - * @AdminSecurity( - * "is_granted(['delete'], request.get('_legacy_controller'))", - * message="You do not have permission to delete this.", - * redirectRoute="admin_sql_requests_index" - * ) - * @DemoRestricted(redirectRoute="admin_sql_requests_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function deleteBulkAction(Request $request) - { - try { - $requestSqlIds = $request->request->get('sql_request_bulk'); - $bulkDeleteSqlRequestCommand = new BulkDeleteSqlRequestCommand($requestSqlIds); - - $this->getCommandBus()->handle($bulkDeleteSqlRequestCommand); - - $this->addFlash( - 'success', - $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success') - ); - } catch (SqlRequestException $e) { - $this->addFlash('error', $this->handleDeleteException($e)); - } - - return $this->redirectToRoute('admin_sql_requests_index'); - } - - /** - * View Request SQL query data. - * - * @AdminSecurity( - * "is_granted(['read'], request.get('_legacy_controller'))", - * message="You do not have permission to view this.", - * redirectRoute="admin_sql_requests_index" - * ) - * - * @param Request $request - * @param int $sqlRequestId - * - * @return Response - */ - public function viewAction(Request $request, $sqlRequestId) - { - try { - $query = new GetSqlRequestExecutionResult($sqlRequestId); - - $sqlRequestExecutionResult = $this->getQueryBus()->handle($query); - } catch (SqlRequestException $e) { - $this->addFlash('error', $this->handleViewException($e)); - - return $this->redirectToRoute('admin_sql_requests_index'); - } - - return $this->render('@PrestaShop/Admin/Configure/AdvancedParameters/RequestSql/view.html.twig', [ - 'layoutHeaderToolbarBtn' => [], - 'layoutTitle' => $this->trans('SQL Manager', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'sqlRequestResult' => $sqlRequestExecutionResult, - ]); - } - - /** - * Export Request SQL data. - * - * @AdminSecurity( - * "is_granted(['read'], request.get('_legacy_controller'))", - * redirectRoute="admin_sql_requests_index" - * ) - * @DemoRestricted(redirectRoute="admin_sql_requests_index") - * - * @param int $sqlRequestId Request SQL id - * - * @return RedirectResponse|BinaryFileResponse - */ - public function exportAction($sqlRequestId) - { - $requestSqlExporter = $this->get('prestashop.core.sql_manager.exporter.sql_request_exporter'); - - try { - $query = new GetSqlRequestExecutionResult($sqlRequestId); - /** @var SqlRequestExecutionResult $sqlRequestExecutionResult */ - $sqlRequestExecutionResult = $this->getQueryBus()->handle($query); - - $exportedFile = $requestSqlExporter->exportToFile( - $query->getSqlRequestId(), - $sqlRequestExecutionResult - ); - - /** @var SqlRequestSettings $sqlRequestSettings */ - $sqlRequestSettings = $this->getQueryBus()->handle(new GetSqlRequestSettings()); - } catch (SqlRequestException $e) { - $this->addFlash('error', $this->handleExportException($e)); - - return $this->redirectToRoute('admin_sql_requests_index'); - } - - $response = new BinaryFileResponse($exportedFile->getPathname()); - $response->setCharset($sqlRequestSettings->getFileEncoding()); - $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $exportedFile->getFilename()); - - return $response; - } - - /** - * Get MySQL table columns data. - * - * @AdminSecurity( - * "is_granted(['read'], request.get('_legacy_controller'))", - * redirectRoute="admin_sql_requests_index" - * ) - * - * @param string $mySqlTableName Database table name - * - * @return JsonResponse - */ - public function ajaxTableColumnsAction($mySqlTableName) - { - $query = new GetDatabaseTableFieldsList($mySqlTableName); - /** @var DatabaseTableFields $databaseFields */ - $databaseFields = $this->getQueryBus()->handle($query); - - return $this->json(['columns' => $databaseFields->getFields()]); - } - - /** - * Get request sql repository. - * - * @return \PrestaShopBundle\Entity\Repository\RequestSqlRepository - */ - protected function getRepository() - { - return $this->get('prestashop.core.admin.request_sql.repository'); - } - - /** - * Get Request SQL settings form handler. - * - * @return FormHandlerInterface - */ - protected function getSettingsFormHandler() - { - return $this->get('prestashop.admin.request_sql_settings.form_handler'); - } - - /** - * @return \PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandlerInterface - */ - protected function getSqlRequestFormHandler() - { - return $this->get('prestashop.core.form.identifiable_object.sql_request_form_handler'); - } - - /** - * @return FormBuilderInterface - */ - protected function getSqlRequestFormBuilder() - { - return $this->get('prestashop.core.form.builder.sql_request_form_builder'); - } - - /** - * When "Export to SQL Manager" feature is used, - * it adds "name" and "sql" to request's POST data - * which is used as default form data - * when creating SqlRequest. - * - * @param Request $request - * - * @return array - */ - protected function getSqlRequestDataFromRequest(Request $request) - { - if ($request->request->has('sql') || $request->request->has('name')) { - return [ - 'sql' => $request->request->get('sql'), - 'name' => $request->request->get('name'), - ]; - } - - return []; - } - - /** - * Get human readable error for exception. - * - * @param SqlRequestException $e - * - * @return string Error message - */ - protected function handleDeleteException(SqlRequestException $e) - { - $code = $e->getCode(); - $type = get_class($e); - - $exceptionMessages = [ - SqlRequestNotFoundException::class => $this->trans('The object cannot be loaded (or found)', 'Admin.Notifications.Error'), - SqlRequestException::class => $this->trans('An error occurred while deleting the object.', 'Admin.Notifications.Error'), - ]; - - $deleteExceptionMessages = [ - CannotDeleteSqlRequestException::CANNOT_SINGLE_DELETE => $this->trans('An error occurred while deleting the object.', 'Admin.Notifications.Error'), - CannotDeleteSqlRequestException::CANNOT_BULK_DELETE => $this->trans('An error occurred while deleting this selection.', 'Admin.Notifications.Error'), - ]; - - if (CannotDeleteSqlRequestException::class === $type - && isset($deleteExceptionMessages[$code]) - ) { - return $deleteExceptionMessages[$code]; - } - - if (isset($exceptionMessages[$type])) { - return $exceptionMessages[$type]; - } - - return $this->getFallbackErrorMessage($type, $code); - } - - /** - * Get error message when exception occurs on View action. - * - * @param SqlRequestException $e - * - * @return string - */ - protected function handleViewException(SqlRequestException $e) - { - $type = get_class($e); - - $exceptionMessages = [ - SqlRequestNotFoundException::class => $this->trans('The object cannot be loaded (or found)', 'Admin.Notifications.Error'), - ]; - - if (isset($exceptionMessages[$type])) { - return $exceptionMessages[$type]; - } - - return $this->getFallbackErrorMessage($type, $e->getCode()); - } - - /** - * @param Exception $e - * - * @return string Error message - */ - protected function handleExportException(Exception $e) - { - $type = get_class($e); - - if ($e instanceof FileWritingException) { - return $this->handleApplicationExportException($e); - } - - if ($e instanceof SqlRequestException) { - return $this->handleDomainExportException($e); - } - - return $this->getFallbackErrorMessage($type, $e->getCode()); - } - - /** - * @param FileWritingException $e - * - * @return string Error message - */ - protected function handleApplicationExportException(FileWritingException $e) - { - $code = $e->getCode(); - - $applicationErrors = [ - FileWritingException::CANNOT_OPEN_FILE_FOR_WRITING => $this->trans('Cannot open export file for writing', 'Admin.Notifications.Error'), - ]; - - if (isset($applicationErrors[$code])) { - return $applicationErrors[$code]; - } - - return $this->getFallbackErrorMessage(get_class($e), $code); - } - - /** - * @param SqlRequestException $e - * - * @return string - */ - protected function handleDomainExportException(SqlRequestException $e) - { - $type = get_class($e); - - $domainErrors = [ - SqlRequestNotFoundException::class => $this->trans('The object cannot be loaded (or found)', 'Admin.Notifications.Error'), - ]; - - if (isset($domainErrors[$type])) { - return $domainErrors[$type]; - } - - return $this->getFallbackErrorMessage($type, $e->getCode()); - } - - /** - * @return string[] Array of database tables - */ - protected function getDatabaseTables() - { - /** @var DatabaseTablesList $databaseTablesList */ - $databaseTablesList = $this->getQueryBus()->handle(new GetDatabaseTablesList()); - - return $databaseTablesList->getTables(); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/SystemInformationController.php b/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/SystemInformationController.php deleted file mode 100644 index b09962c6..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/SystemInformationController.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\AdvancedParameters; - -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Request; - -/** - * Responsible of "Configure > Advanced Parameters > Information" page display. - */ -class SystemInformationController extends FrameworkBundleAdminController -{ - /** - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message="Access denied.") - * @Template("@PrestaShop/Admin/Configure/AdvancedParameters/system_information.html.twig") - * - * @param Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ - public function indexAction(Request $request) - { - $legacyController = $request->get('_legacy_controller'); - $requirementsSummary = $this->getRequirementsChecker()->getSummary(); - $systemInformationSummary = $this->getSystemInformation()->getSummary(); - - return [ - 'layoutHeaderToolbarBtn' => [], - 'layoutTitle' => $this->trans('Information', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'requireBulkActions' => false, - 'showContentHeader' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($legacyController), - 'requireFilterStatus' => false, - 'errorMessage' => 'ok', - 'system' => $systemInformationSummary, - 'requirements' => $requirementsSummary, - 'userAgent' => $request->headers->get('User-Agent'), - ]; - } - - /** - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message="Access denied.") - * - * @return JsonResponse - */ - public function displayCheckFilesAction() - { - return new JsonResponse($this->getRequiredFilesChecker()->getListOfUpdatedFiles()); - } - - /** - * @return \PrestaShop\PrestaShop\Adapter\System\SystemInformation - */ - private function getSystemInformation() - { - return $this->get('prestashop.adapter.system_information'); - } - - /** - * @return \PrestaShop\PrestaShop\Adapter\Requirement\CheckRequirements - */ - private function getRequirementsChecker() - { - return $this->get('prestashop.adapter.check_requirements'); - } - - /** - * @return \PrestaShop\PrestaShop\Adapter\Requirement\CheckMissingOrUpdatedFiles - */ - private function getRequiredFilesChecker() - { - return $this->get('prestashop.adapter.check_missing_files'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/WebserviceController.php b/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/WebserviceController.php deleted file mode 100644 index 3c683fd8..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/AdvancedParameters/WebserviceController.php +++ /dev/null @@ -1,365 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\AdvancedParameters; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Webservice\Exception\DuplicateWebserviceKeyException; -use PrestaShop\PrestaShop\Core\Domain\Webservice\Exception\WebserviceConstraintException; -use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface; -use PrestaShop\PrestaShop\Core\Search\Filters\WebserviceKeyFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible of "Configure > Advanced Parameters > Webservice" page. - * - * @todo: add unit tests - */ -class WebserviceController extends FrameworkBundleAdminController -{ - /** - * Displays the Webservice main page. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param WebserviceKeyFilters $filters - filters for webservice list - * @param Request $request - * - * @return Response - */ - public function indexAction(WebserviceKeyFilters $filters, Request $request) - { - $form = $this->getFormHandler()->getForm(); - $gridWebserviceFactory = $this->get('prestashop.core.grid.factory.webservice_key'); - $grid = $gridWebserviceFactory->getGrid($filters); - - $gridPresenter = $this->get('prestashop.core.grid.presenter.grid_presenter'); - $presentedGrid = $gridPresenter->present($grid); - - $configurationWarnings = $this->lookForWarnings(); - - return $this->render( - '@PrestaShop/Admin/Configure/AdvancedParameters/Webservice/index.html.twig', - [ - 'help_link' => $this->generateSidebarLink($request->get('_legacy_controller')), - 'form' => $form->createView(), - 'grid' => $presentedGrid, - 'configurationWarnings' => $configurationWarnings, - ] - ); - } - - /** - * Shows Webservice Key form and handles its submit - * - * @AdminSecurity("is_granted('create', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request) - { - $formHandler = $this->get('prestashop.core.form.identifiable_object.handler.webservice_key_form_handler'); - $formBuilder = $this->get('prestashop.core.form.identifiable_object.builder.webservice_key_form_builder'); - - $form = $formBuilder->getForm(); - $form->handleRequest($request); - - try { - $result = $formHandler->handle($form); - - if (null !== $result->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_webservice_keys_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->render( - '@PrestaShop/Admin/Configure/AdvancedParameters/Webservice/create.html.twig', - [ - 'webserviceKeyForm' => $form->createView(), - ] - ); - } - - /** - * Redirects to webservice account form where existing webservice account record can be edited. - * - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))") - * - * @param int $webserviceKeyId - * @param Request $request - * - * @return Response - */ - public function editAction($webserviceKeyId, Request $request) - { - $formHandler = $this->get('prestashop.core.form.identifiable_object.handler.webservice_key_form_handler'); - $formBuilder = $this->get('prestashop.core.form.identifiable_object.builder.webservice_key_form_builder'); - - $form = $formBuilder->getFormFor((int) $webserviceKeyId); - $form->handleRequest($request); - - try { - $result = $formHandler->handleFor((int) $webserviceKeyId, $form); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_webservice_keys_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->render( - '@PrestaShop/Admin/Configure/AdvancedParameters/Webservice/edit.html.twig', - [ - 'webserviceKeyForm' => $form->createView(), - ] - ); - } - - /** - * Searches for specific records. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function searchAction(Request $request) - { - $definitionFactory = $this->get('prestashop.core.grid.definition.factory.webservice_key'); - $webserviceDefinition = $definitionFactory->getDefinition(); - - $gridFilterFormFactory = $this->get('prestashop.core.grid.filter.form_factory'); - $searchParametersForm = $gridFilterFormFactory->create($webserviceDefinition); - - $searchParametersForm->handleRequest($request); - $filters = []; - - if ($searchParametersForm->isSubmitted()) { - $filters = $searchParametersForm->getData(); - } - - return $this->redirectToRoute('admin_webservice_keys_index', ['filters' => $filters]); - } - - /** - * Deletes single record. - * - * @DemoRestricted(redirectRoute="admin_webservice_keys_index") - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", message="You do not have permission to delete this.") - * - * @param int $webserviceKeyId - * - * @return RedirectResponse - */ - public function deleteAction($webserviceKeyId) - { - $webserviceEraser = $this->get('prestashop.adapter.webservice.webservice_key_eraser'); - $errors = $webserviceEraser->erase([$webserviceKeyId]); - - if (!empty($errors)) { - $this->flashErrors($errors); - } else { - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } - - return $this->redirectToRoute('admin_webservice_keys_index'); - } - - /** - * Deletes selected records. - * - * @DemoRestricted(redirectRoute="admin_webservice_keys_index") - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", message="You do not have permission to delete this.") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkDeleteAction(Request $request) - { - $webserviceToDelete = $request->request->get('webservice_key_bulk_action'); - - $webserviceEraser = $this->get('prestashop.adapter.webservice.webservice_key_eraser'); - $errors = $webserviceEraser->erase($webserviceToDelete); - - if (!empty($errors)) { - $this->flashErrors($errors); - } else { - $this->addFlash( - 'success', - $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success') - ); - } - - return $this->redirectToRoute('admin_webservice_keys_index'); - } - - /** - * Enables status for selected rows. - * - * @DemoRestricted(redirectRoute="admin_webservice_keys_index") - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message="You do not have permission to edit this.") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkEnableAction(Request $request) - { - $webserviceToEnable = $request->request->get('webservice_key_bulk_action'); - $statusModifier = $this->get('prestashop.adapter.webservice.webservice_key_status_modifier'); - - $statusModifier->setStatus($webserviceToEnable, 1); - - return $this->redirectToRoute('admin_webservice_keys_index'); - } - - /** - * Disables status for selected rows. - * - * @DemoRestricted(redirectRoute="admin_webservice_keys_index") - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message="You do not have permission to edit this.") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkDisableAction(Request $request) - { - $webserviceToEnable = $request->request->get('webservice_key_bulk_action'); - $statusModifier = $this->get('prestashop.adapter.webservice.webservice_key_status_modifier'); - - $statusModifier->setStatus($webserviceToEnable, 0); - - return $this->redirectToRoute('admin_webservice_keys_index'); - } - - /** - * Toggles webservice account status. - * - * @DemoRestricted(redirectRoute="admin_webservice_keys_index") - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message="You do not have permission to edit this.") - * - * @param int $webserviceKeyId - * - * @return RedirectResponse - */ - public function toggleStatusAction($webserviceKeyId) - { - $statusModifier = $this->get('prestashop.adapter.webservice.webservice_key_status_modifier'); - $errors = $statusModifier->toggleStatus($webserviceKeyId); - - if (!empty($errors)) { - $this->flashErrors($errors); - } else { - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } - - return $this->redirectToRoute('admin_webservice_keys_index'); - } - - /** - * Process the Webservice configuration form. - * - * @DemoRestricted(redirectRoute="admin_webservice_keys_index") - * @AdminSecurity("is_granted(['create', 'update', 'delete'], request.get('_legacy_controller'))", message="You do not have permission to edit this.") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function saveSettingsAction(Request $request) - { - $this->dispatchHook('actionAdminAdminWebserviceControllerPostProcessBefore', ['controller' => $this]); - - $form = $this->getFormHandler()->getForm(); - $form->handleRequest($request); - - if ($form->isSubmitted()) { - $saveErrors = $this->getFormHandler()->save($form->getData()); - - if (0 === count($saveErrors)) { - $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success')); - } else { - $this->flashErrors($saveErrors); - } - } - - return $this->redirectToRoute('admin_webservice_keys_index'); - } - - /** - * @return FormHandlerInterface - */ - private function getFormHandler() - { - return $this->get('prestashop.adapter.webservice.form_handler'); - } - - /** - * @return string[] - */ - private function lookForWarnings() - { - $configurationChecker = $this->get('prestashop.core.webservice.server_requirements_checker'); - - return $configurationChecker->checkForErrors(); - } - - /** - * @return array - */ - private function getErrorMessages() - { - return [ - WebserviceConstraintException::class => [ - WebserviceConstraintException::INVALID_KEY => $this->trans('Key length must be 32 character long.', 'Admin.Advparameters.Notification'), - ], - DuplicateWebserviceKeyException::class => $this->trans('This key already exists.', 'Admin.Advparameters.Notification'), - ]; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/ContactsController.php b/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/ContactsController.php deleted file mode 100644 index 451347d1..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/ContactsController.php +++ /dev/null @@ -1,321 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\ShopParameters; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\ContactConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Contact\Exception\ContactNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainConstraintException; -use PrestaShop\PrestaShop\Core\Search\Filters\ContactFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * ContactsController is responsible for actions and rendering - * of "Shop Parameters > Contact > Contacts" page. - */ -class ContactsController extends FrameworkBundleAdminController -{ - /** - * Shows page content. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * @param ContactFilters $filters - * - * @return Response - */ - public function indexAction(Request $request, ContactFilters $filters) - { - $contactGridFactory = $this->get('prestashop.core.grid.factory.contacts'); - $contactGrid = $contactGridFactory->getGrid($filters); - - return $this->render( - '@PrestaShop/Admin/Configure/ShopParameters/Contact/Contacts/index.html.twig', - [ - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - 'layoutTitle' => $this->trans('Contacts', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'layoutHeaderToolbarBtn' => [ - 'add' => [ - 'desc' => $this->trans('Add new contact', 'Admin.Shopparameters.Feature'), - 'icon' => 'add_circle_outline', - 'href' => $this->generateUrl('admin_contacts_create'), - ], - ], - 'contactGrid' => $this->presentGrid($contactGrid), - ] - ); - } - - /** - * Grid search action. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function searchAction(Request $request) - { - $gridDefinitionFactory = $this->get('prestashop.core.grid.definition.factory.contacts'); - $contactsGridDefinition = $gridDefinitionFactory->getDefinition(); - - $gridFilterFormFactory = $this->get('prestashop.core.grid.filter.form_factory'); - $filtersForm = $gridFilterFormFactory->create($contactsGridDefinition); - $filtersForm->handleRequest($request); - - $filters = []; - - if ($filtersForm->isSubmitted()) { - $filters = $filtersForm->getData(); - } - - return $this->redirectToRoute('admin_contacts_index', ['filters' => $filters]); - } - - /** - * Display the Contact creation form. - * - * @AdminSecurity( - * "is_granted('create', request.get('_legacy_controller'))", - * redirectRoute="admin_contacts_index", - * message="You do not have permission to add this." - * ) - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request) - { - $contactFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.contact_form_builder'); - $contactForm = $contactFormBuilder->getForm(); - $contactForm->handleRequest($request); - - try { - $contactFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.contact_form_handler'); - $result = $contactFormHandler->handle($contactForm); - - if (null !== $result->getIdentifiableObjectId()) { - $this->addFlash( - 'success', - $this->trans('Successful creation.', 'Admin.Notifications.Success') - ); - - return $this->redirectToRoute('admin_contacts_index'); - } - } catch (Exception $exception) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($exception, $this->getErrorMessages($exception)) - ); - } - - return $this->render('@PrestaShop/Admin/Configure/ShopParameters/Contact/Contacts/create.html.twig', [ - 'contactForm' => $contactForm->createView(), - ]); - } - - /** - * Display the contact edit form. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_contacts_index", - * message="You do not have permission to edit this." - * ) - * - * @param int $contactId - * @param Request $request - * - * @return Response - */ - public function editAction($contactId, Request $request) - { - $contactFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.contact_form_builder'); - $contactForm = $contactFormBuilder->getFormFor((int) $contactId); - - $contactForm->handleRequest($request); - - try { - $contactFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.contact_form_handler'); - $result = $contactFormHandler->handleFor((int) $contactId, $contactForm); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_contacts_index'); - } - } catch (Exception $exception) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($exception, $this->getErrorMessages($exception)) - ); - } - - return $this->render('@PrestaShop/Admin/Configure/ShopParameters/Contact/Contacts/edit.html.twig', [ - 'contactForm' => $contactForm->createView(), - ]); - } - - /** - * Delete a contact. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_contacts_index", - * message="You do not have permission to delete this." - * ) - * - * @DemoRestricted(redirectRoute="admin_contacts_index") - * - * @param int $contactId - * - * @return RedirectResponse - */ - public function deleteAction($contactId) - { - $contactDeleter = $this->get('prestashop.adapter.contact.deleter'); - - if ($errors = $contactDeleter->delete([$contactId])) { - $this->flashErrors($errors); - } else { - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } - - return $this->redirectToRoute('admin_contacts_index'); - } - - /** - * Bulk delete contacts. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_contacts_index", - * message="You do not have permission to delete this." - * ) - * - * @DemoRestricted(redirectRoute="admin_contacts_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function deleteBulkAction(Request $request) - { - $contactIds = $request->request->get('contact_bulk'); - $contactDeleter = $this->get('prestashop.adapter.contact.deleter'); - - if ($errors = $contactDeleter->delete($contactIds)) { - $this->flashErrors($errors); - } else { - $this->addFlash( - 'success', - $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success') - ); - } - - return $this->redirectToRoute('admin_contacts_index'); - } - - /** - * @param Exception $e - * - * @return array - */ - private function getErrorMessages(Exception $e) - { - return [ - ContactNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - ContactConstraintException::class => [ - ContactConstraintException::INVALID_SHOP_ASSOCIATION => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf( - '"%s"', - $this->trans('Shop association', 'Admin.Global') - ), - ] - ), - ContactConstraintException::INVALID_TITLE => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf( - '"%s"', - $this->trans('Title', 'Admin.Global') - ), - ] - ), - ContactConstraintException::MISSING_TITLE_FOR_DEFAULT_LANGUAGE => $this->trans( - 'The field %field_name% is required at least in your default language.', - 'Admin.Notifications.Error', - [ - '%field_name%' => $this->trans('Title', 'Admin.Global'), - ] - ), - ContactConstraintException::INVALID_DESCRIPTION => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf( - '"%s"', - $this->trans('Description', 'Admin.Global') - ), - ] - ), - ], - DomainConstraintException::class => [ - DomainConstraintException::INVALID_EMAIL => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf( - '"%s"', - $this->trans('Email address', 'Admin.Global') - ), - ] - ), - ], - ]; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/CustomerPreferencesController.php b/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/CustomerPreferencesController.php deleted file mode 100644 index 2c90db1b..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/CustomerPreferencesController.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\ShopParameters; - -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; - -/** - * Controller responsible of "Configure > Shop Parameters > Customer Settings" page. - */ -class CustomerPreferencesController extends FrameworkBundleAdminController -{ - /** - * Show customer preferences page. - * - * @Template("@PrestaShop/Admin/Configure/ShopParameters/customer_preferences.html.twig") - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message="Access denied.") - * - * @param Request $request - * - * @return array Template parameters - */ - public function indexAction(Request $request) - { - $legacyController = $request->attributes->get('_legacy_controller'); - - $form = $this->get('prestashop.admin.customer_preferences.form_handler')->getForm(); - - return [ - 'layoutTitle' => $this->trans('Customers', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($legacyController), - 'form' => $form->createView(), - ]; - } - - /** - * Process the Customer Preferences configuration form. - * - * @AdminSecurity("is_granted(['update', 'create','delete'], request.get('_legacy_controller'))", message="You do not have permission to update this.", redirectRoute="admin_customer_preferences") - * @DemoRestricted(redirectRoute="admin_customer_preferences") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function processAction(Request $request) - { - $formHandler = $this->get('prestashop.admin.customer_preferences.form_handler'); - - $form = $formHandler->getForm(); - $form->handleRequest($request); - - if ($form->isSubmitted()) { - $data = $form->getData(); - - if ($errors = $formHandler->save($data)) { - $this->flashErrors($errors); - - return $this->redirectToRoute('admin_customer_preferences'); - } - - $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success')); - } - - return $this->redirectToRoute('admin_customer_preferences'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/MaintenanceController.php b/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/MaintenanceController.php deleted file mode 100644 index 7754fc12..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/MaintenanceController.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\ShopParameters; - -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible of "Configure > Shop Parameters > General > Maintenance" page. - */ -class MaintenanceController extends FrameworkBundleAdminController -{ - const CONTROLLER_NAME = 'AdminMaintenance'; - - /** - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * @param FormInterface $form - * - * @return Response - */ - public function indexAction(Request $request, FormInterface $form = null) - { - if (null === $form) { - $form = $this->get('prestashop.adapter.maintenance.form_handler')->getForm(); - } - - return $this->render('@PrestaShop/Admin/Configure/ShopParameters/maintenance.html.twig', [ - 'layoutHeaderToolbarBtn' => [], - 'layoutTitle' => $this->trans('Maintenance', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'requireBulkActions' => false, - 'showContentHeader' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink('AdminMaintenance'), - 'requireFilterStatus' => false, - 'form' => $form->createView(), - 'currentIp' => $request->getClientIp(), - ]); - } - - /** - * @param Request $request - * - * @AdminSecurity("is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", - * message="You do not have permission to edit this.", - * redirectRoute="admin_maintenance") - * @DemoRestricted(redirectRoute="admin_maintenance") - * - * @return RedirectResponse - */ - public function processFormAction(Request $request) - { - $redirectResponse = $this->redirectToRoute('admin_maintenance'); - - $this->dispatchHook('actionAdminMaintenanceControllerPostProcessBefore', ['controller' => $this]); - $form = $this->get('prestashop.adapter.maintenance.form_handler')->getForm(); - $form->handleRequest($request); - - if (!$form->isSubmitted()) { - return $redirectResponse; - } - - $data = $form->getData(); - $saveErrors = $this->get('prestashop.adapter.maintenance.form_handler')->save($data); - - if (0 === count($saveErrors)) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $redirectResponse; - } - - $this->flashErrors($saveErrors); - - return $redirectResponse; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/MetaController.php b/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/MetaController.php deleted file mode 100644 index 534d89c7..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/MetaController.php +++ /dev/null @@ -1,477 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\ShopParameters; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Meta\Exception\MetaNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Query\GetShowcaseCardIsClosed; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\ValueObject\ShowcaseCard; -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilderInterface; -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandlerInterface; -use PrestaShop\PrestaShop\Core\Search\Filters\MetaFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class MetaController is responsible for page display and all actions used in Configure -> Shop parameters -> - * Traffic & Seo -> Seo & Urls tab. - */ -class MetaController extends FrameworkBundleAdminController -{ - /** - * Shows index Meta page. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param MetaFilters $filters - * - * @return Response - */ - public function indexAction(MetaFilters $filters, Request $request) - { - $seoUrlsGridFactory = $this->get('prestashop.core.grid.factory.meta'); - - $context = $this->get('prestashop.adapter.shop.context'); - - $isShopContext = $context->isShopContext(); - $isShopFeatureActive = $this->get('prestashop.adapter.multistore_feature')->isActive(); - - $isGridDisplayed = !($isShopFeatureActive && !$isShopContext); - - $presentedGrid = null; - if ($isGridDisplayed) { - $grid = $seoUrlsGridFactory->getGrid($filters); - - $gridPresenter = $this->get('prestashop.core.grid.presenter.grid_presenter'); - $presentedGrid = $gridPresenter->present($grid); - } - - $metaForm = $this->get('prestashop.admin.meta_settings.form_handler')->getForm(); - - $tools = $this->get('prestashop.adapter.tools'); - - $urlFileChecker = $this->get('prestashop.core.util.url.url_file_checker'); - - $hostingInformation = $this->get('prestashop.adapter.hosting_information'); - - $defaultRoutesProvider = $this->get('prestashop.adapter.data_provider.default_route'); - - $helperBlockLinkProvider = $this->get('prestashop.core.util.helper_card.documentation_link_provider'); - $metaDataProvider = $this->get('prestashop.adapter.meta.data_provider'); - - $showcaseCardIsClosed = $this->getQueryBus()->handle( - new GetShowcaseCardIsClosed((int) $this->getContext()->employee->id, ShowcaseCard::SEO_URLS_CARD) - ); - - return $this->render('@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/index.html.twig', [ - 'layoutHeaderToolbarBtn' => [ - 'add' => [ - 'href' => $this->generateUrl('admin_metas_create'), - 'desc' => $this->trans('Add a new page', 'Admin.Shopparameters.Feature'), - 'icon' => 'add_circle_outline', - ], - ], - 'grid' => $presentedGrid, - 'metaForm' => $metaForm->createView(), - 'robotsForm' => $this->createFormBuilder()->getForm()->createView(), - 'routeKeywords' => $defaultRoutesProvider->getKeywords(), - 'isGridDisplayed' => $isGridDisplayed, - 'isModRewriteActive' => $tools->isModRewriteActive(), - 'isShopContext' => $isShopContext, - 'isHtaccessFileValid' => $urlFileChecker->isHtaccessFileWritable(), - 'isRobotsTextFileValid' => $urlFileChecker->isRobotsFileWritable(), - 'isShopFeatureActive' => $isShopFeatureActive, - 'isHostMode' => $hostingInformation->isHostMode(), - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'helperDocLink' => $helperBlockLinkProvider->getLink('meta'), - 'indexPageId' => $metaDataProvider->getIdByPage('index'), - 'metaShowcaseCardName' => ShowcaseCard::SEO_URLS_CARD, - 'showcaseCardIsClosed' => $showcaseCardIsClosed, - ] - ); - } - - /** - * Used for applying filtering actions. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * @DemoRestricted(redirectRoute="admin_metas_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function searchAction(Request $request) - { - $definitionFactory = $this->get('prestashop.core.grid.definition.factory.meta'); - $definitionFactory = $definitionFactory->getDefinition(); - - $gridFilterFormFactory = $this->get('prestashop.core.grid.filter.form_factory'); - $searchParametersForm = $gridFilterFormFactory->create($definitionFactory); - $searchParametersForm->handleRequest($request); - - $filters = []; - if ($searchParametersForm->isSubmitted()) { - $filters = $searchParametersForm->getData(); - } - - return $this->redirectToRoute('admin_metas_index', ['filters' => $filters]); - } - - /** - * Points to the form where new record of meta list can be created. - * - * @AdminSecurity("is_granted('create', request.get('_legacy_controller'))", message="You do not have permission to add this.") - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request) - { - $data = []; - $metaForm = $this->getMetaFormBuilder()->getForm($data); - $metaForm->handleRequest($request); - - try { - $result = $this->getMetaFormHandler()->handle($metaForm); - - if (null !== $result->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_metas_index'); - } - } catch (Exception $exception) { - $this->addFlash('error', $this->handleException($exception)); - } - - return $this->render('@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/create.html.twig', [ - 'meta_form' => $metaForm->createView(), - ] - ); - } - - /** - * Redirects to page where list record can be edited. - * - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message="You do not have permission to edit this.") - * - * @param int $metaId - * @param Request $request - * - * @return Response - */ - public function editAction($metaId, Request $request) - { - try { - $metaForm = $this->getMetaFormBuilder()->getFormFor($metaId); - $metaForm->handleRequest($request); - - $result = $this->getMetaFormHandler()->handleFor($metaId, $metaForm); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_metas_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->handleException($e)); - - return $this->redirectToRoute('admin_metas_index'); - } - - return $this->render('@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/edit.html.twig', [ - 'meta_form' => $metaForm->createView(), - ] - ); - } - - /** - * Removes single element from meta list. - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", message="You do not have permission to delete this.") - * @DemoRestricted(redirectRoute="admin_metas_index") - * - * @param int $metaId - * - * @return RedirectResponse - */ - public function deleteAction($metaId) - { - $metaEraser = $this->get('prestashop.adapter.meta.meta_eraser'); - $errors = $metaEraser->erase([$metaId]); - - if (!empty($errors)) { - $this->flashErrors($errors); - } else { - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } - - return $this->redirectToRoute('admin_metas_index'); - } - - /** - * Removes multiple records from meta list. - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", message="You do not have permission to delete this.") - * @DemoRestricted(redirectRoute="admin_metas_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function deleteBulkAction(Request $request) - { - $metaToDelete = $request->request->get('meta_bulk'); - - $metaEraser = $this->get('prestashop.adapter.meta.meta_eraser'); - $errors = $metaEraser->erase($metaToDelete); - - if (!empty($errors)) { - $this->flashErrors($errors); - } else { - $this->addFlash( - 'success', - $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success') - ); - } - - return $this->redirectToRoute('admin_metas_index'); - } - - /** - * Submits settings forms. - * - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message="You do not have permission to edit this.") - * @DemoRestricted(redirectRoute="admin_metas_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function saveOptionsAction(Request $request) - { - $formHandler = $this->get('prestashop.admin.meta_settings.form_handler'); - $configurationForm = $formHandler->getForm(); - - $configurationForm->handleRequest($request); - - if ($configurationForm->isSubmitted()) { - $errors = $formHandler->save($configurationForm->getData()); - - if (!empty($errors)) { - $this->flashErrors($errors); - } else { - $this->addFlash( - 'success', - $this->trans('The settings have been successfully updated.', 'Admin.Notifications.Success') - ); - } - } - - return $this->redirectToRoute('admin_metas_index'); - } - - /** - * Generates robots.txt file for Front Office. - * - * @AdminSecurity("is_granted(['create', 'update', 'delete'], request.get('_legacy_controller'))") - * @DemoRestricted(redirectRoute="admin_metas_index") - * - * @return RedirectResponse - */ - public function generateRobotsFileAction() - { - $robotsTextFileGenerator = $this->get('prestashop.adapter.file.robots_text_file_generator'); - - $rootDir = $this->get('prestashop.adapter.legacy.configuration')->get('_PS_ROOT_DIR_'); - - if (!$robotsTextFileGenerator->generateFile()) { - $this->addFlash( - 'error', - $this->trans( - 'Cannot write into file: %filename%. Please check write permissions.', - 'Admin.Notifications.Error', - [ - '%filename%' => $rootDir . '/robots.txt', - ] - ) - ); - - return $this->redirectToRoute('admin_metas_index'); - } - - $this->addFlash( - 'success', - $this->trans('Successful update.', 'Admin.Notifications.Success') - ); - - return $this->redirectToRoute('admin_metas_index'); - } - - /** - * Gets form builder. - * - * @return FormBuilderInterface - */ - private function getMetaFormBuilder() - { - return $this->get('prestashop.core.form.builder.meta_form_builder'); - } - - /** - * @return FormHandlerInterface - */ - private function getMetaFormHandler() - { - return $this->get('prestashop.core.form.identifiable_object.meta_form_handler'); - } - - /** - * Handles exception by its type and status code or by its type only and returns error message. - * - * @param Exception $exception - * - * @return string - * - * @todo use FrameworkAdminBundleController::getErrorMessageForException() instead - */ - private function handleException(Exception $exception) - { - if (0 !== $exception->getCode()) { - return $this->getExceptionByClassAndErrorCode($exception); - } - - return $this->getExceptionByType($exception); - } - - /** - * Gets exception by class and error code. - * - * @param Exception $exception - * - * @return string - */ - private function getExceptionByClassAndErrorCode(Exception $exception) - { - $exceptionDictionary = [ - MetaConstraintException::class => [ - MetaConstraintException::INVALID_URL_REWRITE => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf( - '"%s"', - $this->trans('Rewritten URL', 'Admin.Shopparameters.Feature') - ), - ] - ), - MetaConstraintException::INVALID_PAGE_NAME => $this->trans( - 'The %s field is required.', - 'Admin.Notifications.Error', - [ - sprintf( - '"%s"', - $this->trans('Page name', 'Admin.Shopparameters.Feature') - ), - ] - ), - MetaConstraintException::INVALID_PAGE_TITLE => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf( - '"%s"', - $this->trans('Page title', 'Admin.Shopparameters.Feature') - ), - ] - ), - MetaConstraintException::INVALID_META_DESCRIPTION => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf( - '"%s"', - $this->trans('Meta description', 'Admin.Global') - ), - ] - ), - MetaConstraintException::INVALID_META_KEYWORDS => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf( - '"%s"', - $this->trans('Meta keywords', 'Admin.Global') - ), - ] - ), - ], - ]; - - $exceptionClass = get_class($exception); - $exceptionCode = $exception->getCode(); - if (isset($exceptionDictionary[$exceptionClass][$exceptionCode])) { - return $exceptionDictionary[$exceptionClass][$exceptionCode]; - } - - return $this->getFallbackErrorMessage($exceptionClass, $exceptionCode); - } - - /** - * Gets exception by class type. - * - * @param Exception $exception - * - * @return string - */ - private function getExceptionByType(Exception $exception) - { - $exceptionDictionary = [ - MetaNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - ]; - - $exceptionClass = get_class($exception); - if (isset($exceptionDictionary[$exceptionClass])) { - return $exceptionDictionary[$exceptionClass]; - } - - return $this->getFallbackErrorMessage($exceptionClass, $exception->getCode()); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/OrderPreferencesController.php b/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/OrderPreferencesController.php deleted file mode 100644 index 84c44846..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/OrderPreferencesController.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\ShopParameters; - -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Controller responsible of "Configure > Shop Parameters > Order Settings" page. - */ -class OrderPreferencesController extends FrameworkBundleAdminController -{ - /** - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return Response - */ - public function indexAction(Request $request) - { - $legacyController = $request->attributes->get('_legacy_controller'); - - $form = $this->get('prestashop.admin.order_preferences.form_handler')->getForm(); - - return $this->render('@PrestaShop/Admin/Configure/ShopParameters/OrderPreferences/order_preferences.html.twig', [ - 'layoutTitle' => $this->trans('Order settings', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($legacyController), - 'form' => $form->createView(), - 'isMultishippingEnabled' => $this->configuration->getBoolean('PS_ALLOW_MULTISHIPPING'), - 'isAtcpShipWrapEnabled' => $this->configuration->getBoolean('PS_ATCP_SHIPWRAP'), - ]); - } - - /** - * @AdminSecurity("is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", - * message="You do not have permission to edit this.", - * redirectRoute="admin_order_preferences") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function processAction(Request $request) - { - $formHandler = $this->get('prestashop.admin.order_preferences.form_handler'); - - $form = $formHandler->getForm(); - $form->handleRequest($request); - - if ($form->isSubmitted()) { - if ($errors = $formHandler->save($form->getData())) { - $this->flashErrors($errors); - } else { - $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success')); - } - } - - return $this->redirectToRoute('admin_order_preferences'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/PreferencesController.php b/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/PreferencesController.php deleted file mode 100644 index 4e22e9f3..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/PreferencesController.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\ShopParameters; - -use Doctrine\ORM\EntityManager; -use PrestaShop\PrestaShop\Adapter\Tools; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Entity\Repository\TabRepository; -use PrestaShopBundle\Entity\Tab; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible of "Configure > Shop Parameters > General" page. - */ -class PreferencesController extends FrameworkBundleAdminController -{ - const CONTROLLER_NAME = 'AdminPreferences'; - - /** - * @param Request $request - * @param FormInterface|null $form - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @return Response - * - * @throws \LogicException - */ - public function indexAction(Request $request, FormInterface $form = null) - { - if (null === $form) { - $form = $this->get('prestashop.adapter.preferences.form_handler')->getForm(); - } - - /** @var Tools $toolsAdapter */ - $toolsAdapter = $this->get('prestashop.adapter.tools'); - - // SSL URI is used for the merchant to check if he has SSL enabled - $sslUri = 'https://' . $toolsAdapter->getShopDomainSsl() . $request->getRequestUri(); - - return $this->render('@PrestaShop/Admin/Configure/ShopParameters/preferences.html.twig', [ - 'layoutHeaderToolbarBtn' => [], - 'layoutTitle' => $this->get('translator')->trans('Preferences', [], 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'requireBulkActions' => false, - 'showContentHeader' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink('AdminPreferences'), - 'requireFilterStatus' => false, - 'form' => $form->createView(), - 'isSslEnabled' => $this->configuration->get('PS_SSL_ENABLED'), - 'sslUri' => $sslUri, - ]); - } - - /** - * @param Request $request - * - * @AdminSecurity("is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", - * message="You do not have permission to update this.", - * redirectRoute="admin_preferences") - * - * @DemoRestricted(redirectRoute="admin_preferences") - * - * @return \Symfony\Component\HttpFoundation\RedirectResponse - * - * @throws \LogicException - */ - public function processFormAction(Request $request) - { - $this->dispatchHook('actionAdminPreferencesControllerPostProcessBefore', ['controller' => $this]); - - /** @var FormInterface $form */ - $form = $this->get('prestashop.adapter.preferences.form_handler')->getForm(); - $form->handleRequest($request); - - if (!$form->isSubmitted()) { - return $this->redirectToRoute('admin_preferences'); - } - - $data = $form->getData(); - $saveErrors = $this->get('prestashop.adapter.preferences.form_handler')->save($data); - - if (0 === count($saveErrors)) { - /** @var EntityManager $em */ - $em = $this->get('doctrine.orm.entity_manager'); - - /** @var TabRepository $tabRepository */ - $tabRepository = $em->getRepository(Tab::class); - - $tabRepository->changeStatusByClassName( - 'AdminShopGroup', - (bool) $this->configuration->get('PS_MULTISHOP_FEATURE_ACTIVE') - ); - - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_preferences'); - } - - $this->flashErrors($saveErrors); - - return $this->redirectToRoute('admin_preferences'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/ProductPreferencesController.php b/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/ProductPreferencesController.php deleted file mode 100644 index 66d1afca..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/ShopParameters/ProductPreferencesController.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure\ShopParameters; - -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible of "Configure > Shop Parameters > Product Settings" page. - */ -class ProductPreferencesController extends FrameworkBundleAdminController -{ - /** - * @param Request $request - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @return Response - */ - public function indexAction(Request $request) - { - $legacyController = $request->attributes->get('_legacy_controller'); - - $form = $this->get('prestashop.admin.product_preferences.form_handler')->getForm(); - - return $this->render('@PrestaShop/Admin/Configure/ShopParameters/product_preferences.html.twig', [ - 'layoutHeaderToolbarBtn' => [], - 'layoutTitle' => $this->trans('Product Settings', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'requireBulkAction' => false, - 'showContentHeader' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($legacyController), - 'requireFilterStatus' => false, - 'form' => $form->createView(), - ]); - } - - /** - * Process product preferences form. - * - * @AdminSecurity("is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", - * message="You do not have permission to update this.", - * redirectRoute="admin_product_preferences" - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function processAction(Request $request) - { - $formHandler = $this->get('prestashop.admin.product_preferences.form_handler'); - - $form = $formHandler->getForm(); - $form->handleRequest($request); - - if ($form->isSubmitted()) { - $data = $form->getData(); - - $errors = $formHandler->save($data); - - if (0 === count($errors)) { - $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success')); - } else { - $this->flashErrors($errors); - } - } - - return $this->redirectToRoute('admin_product_preferences'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Configure/ShowcaseCardController.php b/src/PrestaShopBundle/Controller/Admin/Configure/ShowcaseCardController.php deleted file mode 100644 index b19256d6..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Configure/ShowcaseCardController.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Configure; - -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Command\CloseShowcaseCardCommand; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Exception\InvalidShowcaseCardNameException; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\ValueObject\ShowcaseCard; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * @todo Move this to API - */ -class ShowcaseCardController extends FrameworkBundleAdminController -{ - /** - * Saves the user preference of closing the showcase card. - * - * This action should be performed via POST, and expects two parameters: - * - int $close=1 - * - string $name Name of the showcase card to close - * - * @see ShowcaseCard - * - * @AdminSecurity("is_granted(['create', 'update'], 'CONFIGURE')") - * @DemoRestricted(redirectRoute="admin_metas_index") - * - * @return JsonResponse - */ - public function closeShowcaseCardAction(Request $request) - { - // check prerequisites - if (!$request->isMethod('post') || !$request->request->get('close')) { - return $this->json( - [ - 'success' => false, - 'message' => '', - ], - Response::HTTP_BAD_REQUEST - ); - } - - try { - $employeeId = $this->getContext()->employee->id; - $closeShowcaseCard = new CloseShowcaseCardCommand($employeeId, $request->request->get('name')); - $this->getCommandBus()->handle($closeShowcaseCard); - - return $this->json( - [ - 'success' => true, - 'message' => '', - ] - ); - } catch (\Exception $e) { - return $this->json( - [ - 'success' => false, - 'message' => $e->getMessage(), - ], - ($e instanceof InvalidShowcaseCardNameException) ? Response::HTTP_BAD_REQUEST : Response::HTTP_INTERNAL_SERVER_ERROR - ); - } - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/ErrorController.php b/src/PrestaShopBundle/Controller/Admin/ErrorController.php deleted file mode 100644 index f9593d15..00000000 --- a/src/PrestaShopBundle/Controller/Admin/ErrorController.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin; - -use PrestaShop\PrestaShop\Core\Domain\Configuration\Command\SwitchDebugModeCommand; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; - -/** - * Manages Error pages (e.g. 500) - */ -class ErrorController extends FrameworkBundleAdminController -{ - /** - * Enables debug mode from error page (500 for example) - * - * @AdminSecurity("is_granted(['update', 'create', 'delete'], 'AdminPerformance')") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function enableDebugModeAction(Request $request) - { - $this->getCommandBus()->handle(new SwitchDebugModeCommand(true)); - - return $this->redirect( - $request->request->get('_redirect_url') - ); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/FeatureController.php b/src/PrestaShopBundle/Controller/Admin/FeatureController.php deleted file mode 100644 index ed476994..00000000 --- a/src/PrestaShopBundle/Controller/Admin/FeatureController.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin; - -use Symfony\Component\HttpFoundation\JsonResponse; - -/** - * Admin controller for the Feature pages. - */ -class FeatureController extends FrameworkBundleAdminController -{ - /** - * Get all values for a given feature. - * - * @param int $idFeature The feature Id - * - * @return JsonResponse features list - */ - public function getFeatureValuesAction($idFeature) - { - $response = new JsonResponse(); - $locales = $this->get('prestashop.adapter.legacy.context')->getLanguages(); - $data = []; - - if ($idFeature == 0) { - return $response; - } - - $featuresValues = $this->get('prestashop.adapter.data_provider.feature')->getFeatureValuesWithLang($locales[0]['id_lang'], $idFeature); - - if (count($featuresValues) !== 0) { - $data['0'] = [ - 'id' => 0, - 'value' => $this->trans('Choose a value', 'Admin.Catalog.Feature'), - ]; - } - - foreach ($featuresValues as $featureValue) { - if (isset($featureValue['custom']) && $featureValue['custom'] == 1) { - continue; - } - $data[] = [ - 'id' => $featureValue['id_feature_value'], - 'value' => $featureValue['value'], - ]; - } - - $response->setData($data); - - return $response; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/FrameworkBundleAdminController.php b/src/PrestaShopBundle/Controller/Admin/FrameworkBundleAdminController.php deleted file mode 100644 index de28b13d..00000000 --- a/src/PrestaShopBundle/Controller/Admin/FrameworkBundleAdminController.php +++ /dev/null @@ -1,529 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin; - -use Exception; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\Shop\Context; -use PrestaShop\PrestaShop\Core\ConfigurationInterface; -use PrestaShop\PrestaShop\Core\Grid\GridInterface; -use PrestaShop\PrestaShop\Core\Localization\Locale; -use PrestaShop\PrestaShop\Core\Localization\Locale\Repository as LocaleRepository; -use PrestaShop\PrestaShop\Core\Module\Exception\ModuleErrorInterface; -use PrestaShopBundle\Security\Voter\PageVoter; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; -use Symfony\Component\Form\Form; -use Symfony\Component\Form\FormError; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Response; - -/** - * Extends The Symfony framework bundle controller to add common functions for PrestaShop needs. - */ -class FrameworkBundleAdminController extends Controller -{ - const PRESTASHOP_CORE_CONTROLLERS_TAG = 'prestashop.core.controllers'; - - /** - * @var ConfigurationInterface|Configuration - */ - protected $configuration; - - /** - * @var string|null - */ - protected $layoutTitle; - - /** - * Constructor. - */ - public function __construct() - { - $this->configuration = new Configuration(); - } - - /** - * @Template - * - * @return array Template vars - */ - public function overviewAction() - { - return [ - 'is_shop_context' => (new Context())->isShopContext(), - 'layoutTitle' => empty($this->layoutTitle) ? '' : $this->trans($this->layoutTitle, 'Admin.Navigation.Menu'), - ]; - } - - /** - * Returns form errors for JS implementation. - * - * Parse all errors mapped by id html field - * - * @param Form $form The form - * - * @return array[array[string]] Errors - * - * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException - */ - public function getFormErrorsForJS(Form $form) - { - $errors = []; - - if (empty($form)) { - return $errors; - } - - $translator = $this->get('translator'); - - foreach ($form->getErrors(true) as $error) { - if (!$error->getCause()) { - $formId = 'bubbling_errors'; - } else { - $formId = str_replace( - ['.', 'children[', ']', '_data'], - ['_', '', '', ''], - $error->getCause()->getPropertyPath() - ); - } - - if ($error->getMessagePluralization()) { - $errors[$formId][] = $translator->transChoice( - $error->getMessageTemplate(), - $error->getMessagePluralization(), - $error->getMessageParameters(), - 'form_error' - ); - } else { - $errors[$formId][] = $translator->trans( - $error->getMessageTemplate(), - $error->getMessageParameters(), - 'form_error' - ); - } - } - - return $errors; - } - - /** - * Creates a HookEvent, sets its parameters, and dispatches it. - * - * Wrapper to: @see HookDispatcher::dispatchWithParameters() - * - * @param string $hookName The hook name - * @param array $parameters The hook parameters - */ - protected function dispatchHook($hookName, array $parameters) - { - $this->get('prestashop.core.hook.dispatcher')->dispatchWithParameters($hookName, $parameters); - } - - /** - * Creates a RenderingHookEvent, sets its parameters, and dispatches it. Returns the event with the response(s). - * - * Wrapper to: @see HookDispatcher::renderForParameters() - * - * @param string $hookName The hook name - * @param array $parameters The hook parameters - * - * @return array The responses of hooks - * - * @throws Exception - */ - protected function renderHook($hookName, array $parameters) - { - return $this->get('prestashop.core.hook.dispatcher')->renderForParameters($hookName, $parameters)->getContent(); - } - - /** - * Generates a documentation link. - * - * @param string $section Legacy controller name - * @param bool|string $title Help title - * - * @return string - */ - protected function generateSidebarLink($section, $title = false) - { - $version = $this->get('prestashop.core.foundation.version')->getVersion(); - $legacyContext = $this->get('prestashop.adapter.legacy.context'); - - if (empty($title)) { - $title = $this->trans('Help', 'Admin.Global'); - } - - $docLink = urlencode('https://help.prestashop.com/' . $legacyContext->getEmployeeLanguageIso() . '/doc/' - . $section . '?version=' . $version . '&country=' . $legacyContext->getEmployeeLanguageIso()); - - return $this->generateUrl('admin_common_sidebar', [ - 'url' => $docLink, - 'title' => $title, - ]); - } - - /** - * Get the old but still useful context. - * - * @return \Context - */ - protected function getContext() - { - return $this->get('prestashop.adapter.legacy.context')->getContext(); - } - - /** - * Get the locale based on the context - * - * @return Locale - */ - protected function getContextLocale(): Locale - { - $locale = $this->getContext()->getCurrentLocale(); - if (null !== $locale) { - return $locale; - } - - /** @var LocaleRepository $localeRepository */ - $localeRepository = $this->get('prestashop.core.localization.locale.repository'); - $locale = $localeRepository->getLocale( - $this->getContext()->language->getLocale() - ); - - return $locale; - } - - /** - * @param $lang - * - * @return mixed - */ - protected function langToLocale($lang) - { - return $this->get('prestashop.service.translation')->langToLocale($lang); - } - - /** - * @return bool - */ - protected function isDemoModeEnabled() - { - return $this->get('prestashop.adapter.legacy.configuration')->get('_PS_MODE_DEMO_'); - } - - /** - * @return string - */ - protected function getDemoModeErrorMessage() - { - return $this->trans('This functionality has been disabled.', 'Admin.Notifications.Error'); - } - - /** - * Checks if the attributes are granted against the current authentication token and optionally supplied object. - * - * @param string $controller name of the controller to valide access - * - * @return int - * - * @throws \LogicException - */ - protected function authorizationLevel($controller) - { - if ($this->isGranted(PageVoter::DELETE, $controller . '_')) { - return PageVoter::LEVEL_DELETE; - } - - if ($this->isGranted(PageVoter::CREATE, $controller . '_')) { - return PageVoter::LEVEL_CREATE; - } - - if ($this->isGranted(PageVoter::UPDATE, $controller . '_')) { - return PageVoter::LEVEL_UPDATE; - } - - if ($this->isGranted(PageVoter::READ, $controller . '_')) { - return PageVoter::LEVEL_READ; - } - - return 0; - } - - /** - * Get the translated chain from key. - * - * @param string $key the key to be translated - * @param string $domain the domain to be selected - * @param array $parameters Optional, pass parameters if needed (uncommon) - * - * @return string - */ - protected function trans($key, $domain, array $parameters = []) - { - return $this->get('translator')->trans($key, $parameters, $domain); - } - - /** - * Return errors as flash error messages. - * - * @param array $errorMessages - * - * @throws \LogicException - */ - protected function flashErrors(array $errorMessages) - { - foreach ($errorMessages as $error) { - $message = is_array($error) ? $this->trans($error['key'], $error['domain'], $error['parameters']) : $error; - $this->addFlash('error', $message); - } - } - - /** - * Redirect employee to default page. - * - * @return RedirectResponse - */ - protected function redirectToDefaultPage() - { - $legacyContext = $this->get('prestashop.adapter.legacy.context'); - $defaultTab = $legacyContext->getDefaultEmployeeTab(); - - return $this->redirect($legacyContext->getAdminLink($defaultTab)); - } - - /** - * Check if the connected user is granted to actions on a specific object. - * - * @param $action - * @param $object - * @param string $suffix - * - * @return bool - * - * @throws \LogicException - */ - protected function actionIsAllowed($action, $object = '', $suffix = '') - { - return ( - $action === 'delete' . $suffix && $this->isGranted(PageVoter::DELETE, $object) - ) || ( - ($action === 'activate' . $suffix || $action === 'deactivate' . $suffix) && - $this->isGranted(PageVoter::UPDATE, $object) - ) || ( - ($action === 'duplicate' . $suffix) && - ($this->isGranted(PageVoter::UPDATE, $object) || $this->isGranted(PageVoter::CREATE, $object)) - ); - } - - /** - * Display a message about permissions failure according to an action. - * - * @param $action - * @param string $suffix - * - * @return string - * - * @throws Exception - */ - protected function getForbiddenActionMessage($action, $suffix = '') - { - if ($action === 'delete' . $suffix) { - return $this->trans('You do not have permission to delete this.', 'Admin.Notifications.Error'); - } - - if ($action === 'deactivate' . $suffix || $action === 'activate' . $suffix) { - return $this->trans('You do not have permission to edit this.', 'Admin.Notifications.Error'); - } - - if ($action === 'duplicate' . $suffix) { - return $this->trans('You do not have permission to add this.', 'Admin.Notifications.Error'); - } - - throw new Exception(sprintf('Invalid action (%s)', $action . $suffix)); - } - - /** - * Get fallback error message when something unexpected happens. - * - * @param string $type - * @param string $code - * @param string $message - * - * @return string - */ - protected function getFallbackErrorMessage($type, $code, $message = '') - { - $isDebug = $this->get('kernel')->isDebug(); - if ($isDebug && !empty($message)) { - return $this->trans( - 'An unexpected error occurred. [%type% code %code%]: %message%', - 'Admin.Notifications.Error', - [ - '%type%' => $type, - '%code%' => $code, - '%message%' => $message, - ] - ); - } - - return $this->trans( - 'An unexpected error occurred. [%type% code %code%]', - 'Admin.Notifications.Error', - [ - '%type%' => $type, - '%code%' => $code, - ] - ); - } - - /** - * Get Admin URI from PrestaShop 1.6 Back Office. - * - * @param string $controller the old Controller name - * @param bool $withToken whether we add token or not - * @param array $params url parameters - * - * @return string the page URI (with token) - */ - protected function getAdminLink($controller, array $params, $withToken = true) - { - return $this->get('prestashop.adapter.legacy.context')->getAdminLink($controller, $withToken, $params); - } - - /** - * Present provided grid. - * - * @param GridInterface $grid - * - * @return array - */ - protected function presentGrid(GridInterface $grid) - { - return $this->get('prestashop.core.grid.presenter.grid_presenter')->present($grid); - } - - /** - * Get commands bus to execute commands. - * - * @return \PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface - */ - protected function getCommandBus() - { - return $this->get('prestashop.core.command_bus'); - } - - /** - * Get query bus to execute queries. - * - * @return \PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface - */ - protected function getQueryBus() - { - return $this->get('prestashop.core.query_bus'); - } - - /** - * @param array $errors - * @param int $httpStatusCode - * - * @return JsonResponse - */ - protected function returnErrorJsonResponse(array $errors, $httpStatusCode) - { - $response = new JsonResponse(); - $response->setStatusCode($httpStatusCode); - $response->setData($errors); - - return $response; - } - - /** - * @return int - */ - protected function getContextLangId() - { - return $this->getContext()->language->id; - } - - /** - * @return int - */ - protected function getContextShopId() - { - return $this->getContext()->shop->id; - } - - /** - * @param FormInterface $form - */ - protected function addFlashFormErrors(FormInterface $form) - { - /** @var FormError $formError */ - foreach ($form->getErrors(true) as $formError) { - $this->addFlash('error', $formError->getMessage()); - } - } - - /** - * Get error by exception from given messages - * - * @param Exception $e - * @param array $messages - * - * @return string - */ - protected function getErrorMessageForException(Exception $e, array $messages) - { - if ($e instanceof ModuleErrorInterface) { - return $e->getMessage(); - } - - $exceptionType = get_class($e); - $exceptionCode = $e->getCode(); - - if (isset($messages[$exceptionType])) { - $message = $messages[$exceptionType]; - - if (is_string($message)) { - return $message; - } - - if (is_array($message) && isset($message[$exceptionCode])) { - return $message[$exceptionCode]; - } - } - - return $this->getFallbackErrorMessage( - $exceptionType, - $exceptionCode, - $e->getMessage() - ); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/Design/CmsPageController.php b/src/PrestaShopBundle/Controller/Admin/Improve/Design/CmsPageController.php deleted file mode 100644 index dd0dcd2a..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/Design/CmsPageController.php +++ /dev/null @@ -1,1201 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\Design; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\BulkDeleteCmsPageCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\BulkDisableCmsPageCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\BulkEnableCmsPageCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\DeleteCmsPageCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\ToggleCmsPageStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CannotDeleteCmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CannotDisableCmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CannotEnableCmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CannotToggleCmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Exception\CmsPageNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Query\GetCmsCategoryIdForRedirection; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\Query\GetCmsPageForEditing; -use PrestaShop\PrestaShop\Core\Domain\CmsPage\QueryResult\EditableCmsPage; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\BulkDeleteCmsPageCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\BulkDisableCmsPageCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\BulkEnableCmsPageCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\DeleteCmsPageCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\ToggleCmsPageCategoryStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CannotDeleteCmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CannotToggleCmsPageCategoryStatusException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Exception\CmsPageCategoryNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query\GetCmsPageParentCategoryIdForRedirection; -use PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\ValueObject\CmsPageCategoryId; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Query\GetShowcaseCardIsClosed; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\ValueObject\ShowcaseCard; -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilderInterface; -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandlerInterface; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CmsPageCategoryDefinitionFactory; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CmsPageDefinitionFactory; -use PrestaShop\PrestaShop\Core\Grid\Position\Exception\PositionDataException; -use PrestaShop\PrestaShop\Core\Grid\Position\Exception\PositionUpdateException; -use PrestaShop\PrestaShop\Core\Search\Filters\CmsPageCategoryFilters; -use PrestaShop\PrestaShop\Core\Search\Filters\CmsPageFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use PrestaShopBundle\Service\Grid\ResponseBuilder; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class CmsPageController is responsible for handling the logic in "Improve -> Design -> pages" page. - */ -class CmsPageController extends FrameworkBundleAdminController -{ - /** - * Responsible for displaying page content. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param CmsPageCategoryFilters $categoryFilters - * @param CmsPageFilters $cmsFilters - * @param Request $request - * - * @return Response - */ - public function indexAction(CmsPageCategoryFilters $categoryFilters, CmsPageFilters $cmsFilters, Request $request) - { - $cmsCategoryParentId = (int) $categoryFilters->getFilters()['id_cms_category_parent']; - $viewData = []; - - try { - $viewData = $this - ->get('prestashop.core.cms_page.data_provider.cms_page_view') - ->getView($cmsCategoryParentId) - ; - } catch (Exception $exception) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($exception, $this->getErrorMessages()) - ); - - if ($exception instanceof CmsPageCategoryNotFoundException) { - return $this->redirectToRoute('admin_cms_pages_index'); - } - } - - $cmsCategoryGridFactory = $this->get('prestashop.core.grid.factory.cms_page_category'); - $cmsCategoryGrid = $cmsCategoryGridFactory->getGrid($categoryFilters); - - $cmsGridFactory = $this->get('prestashop.core.grid.factory.cms_page'); - $cmsGrid = $cmsGridFactory->getGrid($cmsFilters); - - $gridPresenter = $this->get('prestashop.core.grid.presenter.grid_presenter'); - - $showcaseCardIsClosed = $this->getQueryBus()->handle( - new GetShowcaseCardIsClosed( - (int) $this->getContext()->employee->id, - ShowcaseCard::CMS_PAGES_CARD - ) - ); - - $helperBlockLinkProvider = $this->get('prestashop.core.util.helper_card.documentation_link_provider'); - - return $this->render( - '@PrestaShop/Admin/Improve/Design/Cms/index.html.twig', - [ - 'cmsCategoryGrid' => $gridPresenter->present($cmsCategoryGrid), - 'cmsGrid' => $gridPresenter->present($cmsGrid), - 'cmsPageView' => $viewData, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'helperDocLink' => $helperBlockLinkProvider->getLink('cms_pages'), - 'cmsPageShowcaseCardName' => ShowcaseCard::CMS_PAGES_CARD, - 'showcaseCardIsClosed' => $showcaseCardIsClosed, - ] - ); - } - - /** - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function searchAction(Request $request) - { - $gridDefinitionFactory = 'prestashop.core.grid.definition.factory.cms_page_category'; - $filterId = CmsPageCategoryDefinitionFactory::GRID_ID; - if ($request->request->has(CmsPageDefinitionFactory::GRID_ID)) { - $gridDefinitionFactory = 'prestashop.core.grid.definition.factory.cms_page'; - $filterId = CmsPageDefinitionFactory::GRID_ID; - } - - /** @var ResponseBuilder $responseBuilder */ - $responseBuilder = $this->get('prestashop.bundle.grid.response_builder'); - - return $responseBuilder->buildSearchResponse( - $this->get($gridDefinitionFactory), - $request, - $filterId, - 'admin_cms_pages_index', - [ - 'id_cms_category', - ] - ); - } - - /** - * Creates cms page - * - * @AdminSecurity( - * "is_granted('create', request.get('_legacy_controller'))", - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"}, - * message="You do not have permission to add this." - * ) - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request) - { - $formBuilder = $this->getCmsPageFormBuilder(); - $categoryParentId = $request->query->get('id_cms_category'); - $formData = []; - if ($categoryParentId) { - $formData['page_category_id'] = $categoryParentId; - } - $form = $formBuilder->getForm($formData, [ - 'cms_preview_url' => $this->get('prestashop.adapter.shop.url.cms_provider')->getUrl(0, '{friendy-url}'), - ]); - $form->handleRequest($request); - - try { - $result = $this->getCmsPageFormHandler()->handle($form); - $cmsPageId = $result->getIdentifiableObjectId(); - - if (null !== $cmsPageId) { - $this->addFlash( - 'success', - $this->trans('Successful creation.', 'Admin.Notifications.Success') - ); - if (!$request->request->has('save-and-preview')) { - return $this->redirectToParentIndexPageByCmsPageId($cmsPageId); - } - - return $this->redirectToRoute('admin_cms_pages_edit', [ - 'cmsPageId' => $cmsPageId, - 'open_preview' => 1, - ]); - } - } catch (Exception $e) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($e, $this->getErrorMessages()) - ); - } - - return $this->render( - 'PrestaShopBundle:Admin/Improve/Design/Cms:add.html.twig', - [ - 'cmsPageForm' => $form->createView(), - 'cmsCategoryParentId' => $categoryParentId, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - ] - ); - } - - /** - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"}, - * message="You do not have permission to edit this." - * ) - * - * @param Request $request - * @param $cmsPageId - * - * @return Response - */ - public function editAction(Request $request, $cmsPageId) - { - $cmsPageId = (int) $cmsPageId; - - try { - /** @var EditableCmsPage $editableCmsPage */ - $editableCmsPage = $this->getQueryBus()->handle(new GetCmsPageForEditing($cmsPageId)); - $previewUrl = $editableCmsPage->getPreviewUrl(); - - $form = $this->getCmsPageFormBuilder()->getFormFor($cmsPageId, [], [ - 'action' => $this->generateUrl('admin_cms_pages_edit', [ - 'cmsPageId' => $cmsPageId, - ]), - 'cms_preview_url' => $this->get('prestashop.adapter.shop.url.cms_provider') - ->getUrl($cmsPageId, '{friendy-url}'), - ]); - $form->handleRequest($request); - } catch (Exception $e) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($e, $this->getErrorMessages()) - ); - - return $this->redirectToRoute('admin_cms_pages_index'); - } - - try { - $result = $this->getCmsPageFormHandler()->handleFor($cmsPageId, $form); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash( - 'success', - $this->trans('Successful update.', 'Admin.Notifications.Success') - ); - - if ($request->request->has('save-and-preview')) { - return $this->redirectToRoute('admin_cms_pages_edit', [ - 'cmsPageId' => $cmsPageId, - 'open_preview' => 1, - ]); - } - - return $this->redirectToParentIndexPageByCmsPageId($cmsPageId); - } - } catch (Exception $e) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($e, $this->getErrorMessages()) - ); - } - - return $this->render( - '@PrestaShop/Admin/Improve/Design/Cms/edit.html.twig', - [ - 'cmsPageForm' => $form->createView(), - 'cmsCategoryParentId' => $request->get('id_cms_category'), - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'previewUrl' => $previewUrl, - ] - ); - } - - /** - * Displays cms category page form and handles create new cms page category logic. - * - * @AdminSecurity( - * "is_granted('create', request.get('_legacy_controller'))", - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"}, - * message="You do not have permission to add this." - * ) - * - * @param Request $request - * - * @return Response - */ - public function createCmsCategoryAction(Request $request) - { - $cmsPageCategoryFormBuilder = $this->getCmsPageCategoryFormBuilder(); - $cmsPageCategoryForm = $cmsPageCategoryFormBuilder->getForm(); - - $cmsPageCategoryForm->handleRequest($request); - - try { - $result = $this->getCmsPageCategoryFormHandler()->handle($cmsPageCategoryForm); - - if (null !== $result->getIdentifiableObjectId()) { - $this->addFlash( - 'success', - $this->trans('Successful creation.', 'Admin.Notifications.Success') - ); - - return $this->redirectToIndexPageById($result->getIdentifiableObjectId()); - } - } catch (Exception $exception) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($exception, $this->getErrorMessages()) - ); - } - - return $this->render( - '@PrestaShop/Admin/Improve/Design/Cms/create_category.html.twig', - [ - 'cmsPageCategoryForm' => $cmsPageCategoryForm->createView(), - ] - ); - } - - /** - * Displays cms category page form and handles update cms page category logic. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"}, - * message="You do not have permission to edit this." - * ) - * - * @param int $cmsCategoryId - * @param Request $request - * - * @return Response - */ - public function editCmsCategoryAction($cmsCategoryId, Request $request) - { - $cmsPageCategoryFormBuilder = $this->getCmsPageCategoryFormBuilder(); - $cmsCategoryParentId = null; - - try { - $cmsPageCategoryForm = $cmsPageCategoryFormBuilder->getFormFor((int) $cmsCategoryId); - $cmsPageCategoryForm->handleRequest($request); - $result = $this->getCmsPageCategoryFormHandler()->handleFor((int) $cmsCategoryId, $cmsPageCategoryForm); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToIndexPageById($result->getIdentifiableObjectId()); - } - $cmsCategoryParentId = $this->getParentCategoryId((int) $cmsCategoryId)->getValue(); - } catch (Exception $exception) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($exception, $this->getErrorMessages()) - ); - - if ($exception instanceof CmsPageCategoryNotFoundException) { - return $this->redirectToParentIndexPage((int) $cmsCategoryId); - } - } - - return $this->render( - '@PrestaShop/Admin/Improve/Design/Cms/edit_category.html.twig', - [ - 'cmsPageCategoryForm' => $cmsPageCategoryForm->createView(), - 'cmsCategoryParentId' => $cmsCategoryParentId, - ] - ); - } - - /** - * Deletes cms page category and all its children categories. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"}, - * message="You do not have permission to delete this." - * ) - * @DemoRestricted( - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"} - * ) - * - * @param int $cmsCategoryId - * - * @return RedirectResponse - */ - public function deleteCmsCategoryAction($cmsCategoryId) - { - try { - $this->getCommandBus()->handle( - new DeleteCmsPageCategoryCommand((int) $cmsCategoryId) - ); - - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (Exception $exception) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($exception, $this->getErrorMessages()) - ); - } - - return $this->redirectToParentIndexPage((int) $cmsCategoryId); - } - - /** - * Deletes multiple cms page categories. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"}, - * message="You do not have permission to delete this." - * ) - * @DemoRestricted( - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"} - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function deleteBulkCmsCategoryAction(Request $request) - { - $cmsCategoriesToDelete = $request->request->get('cms_page_category_bulk'); - - try { - $cmsCategoriesToDelete = array_map(function ($item) { return (int) $item; }, $cmsCategoriesToDelete); - - $this->getCommandBus()->handle( - new BulkDeleteCmsPageCategoryCommand($cmsCategoriesToDelete) - ); - - $this->addFlash( - 'success', - $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success') - ); - } catch (Exception $exception) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($exception, $this->getErrorMessages()) - ); - } - - return $this->redirectToParentIndexPageByCategoryBulkIds($cmsCategoriesToDelete); - } - - /** - * Updates cms page category position. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"}, - * message="You do not have permission to edit this." - * ) - * @DemoRestricted( - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"} - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function updateCmsCategoryPositionAction(Request $request) - { - $cmsCategoryParentId = $request->query->getInt('id_cms_category') ?: - CmsPageCategoryId::ROOT_CMS_PAGE_CATEGORY_ID - ; - - $positionsData = [ - 'positions' => $request->request->get('positions'), - 'parentId' => $cmsCategoryParentId, - ]; - - $positionDefinition = $this->get('prestashop.core.grid.cms_page_category.position_definition'); - - $positionUpdateFactory = $this->get('prestashop.core.grid.position.position_update_factory'); - - try { - $positionUpdate = $positionUpdateFactory->buildPositionUpdate($positionsData, $positionDefinition); - } catch (PositionDataException $e) { - $errors = [$e->toArray()]; - $this->flashErrors($errors); - - return $this->redirectToIndexPageById($cmsCategoryParentId); - } - - $updater = $this->get('prestashop.core.grid.position.doctrine_grid_position_updater'); - - try { - $updater->update($positionUpdate); - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - } catch (PositionUpdateException $e) { - $errors = [$e->toArray()]; - $this->flashErrors($errors); - } - - return $this->redirectToIndexPageById($cmsCategoryParentId); - } - - /** - * Updates cms page listing position. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"}, - * message="You do not have permission to edit this." - * ) - * @DemoRestricted( - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"} - * ) - * - * @return RedirectResponse - */ - public function updateCmsPositionAction(Request $request) - { - $cmsCategoryParentId = $request->query->getInt('id_cms_category') ?: - CmsPageCategoryId::ROOT_CMS_PAGE_CATEGORY_ID - ; - - $positionsData = [ - 'positions' => $request->request->get('positions'), - 'parentId' => $cmsCategoryParentId, - ]; - - $positionDefinition = $this->get('prestashop.core.grid.cms_page.position_definition'); - $positionUpdateFactory = $this->get('prestashop.core.grid.position.position_update_factory'); - - try { - $positionUpdate = $positionUpdateFactory->buildPositionUpdate($positionsData, $positionDefinition); - } catch (PositionDataException $e) { - $errors = [$e->toArray()]; - $this->flashErrors($errors); - - return $this->redirectToParentIndexPage($cmsCategoryParentId); - } - - $updater = $this->get('prestashop.core.grid.position.doctrine_grid_position_updater'); - - try { - $updater->update($positionUpdate); - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - } catch (PositionUpdateException $e) { - $errors = [$e->toArray()]; - $this->flashErrors($errors); - } - - return $this->redirectToIndexPageById($cmsCategoryParentId); - } - - /** - * Toggles cms page category status. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"}, - * message="You do not have permission to edit this." - * ) - * @DemoRestricted( - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"} - * ) - * - * @param int $cmsCategoryId - * - * @return RedirectResponse - */ - public function toggleCmsCategoryAction($cmsCategoryId) - { - try { - $this->getCommandBus()->handle( - new ToggleCmsPageCategoryStatusCommand((int) $cmsCategoryId) - ); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (Exception $exception) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($exception, $this->getErrorMessages()) - ); - } - - return $this->redirectToParentIndexPage((int) $cmsCategoryId); - } - - /** - * Changes multiple cms page category statuses to enabled. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"}, - * message="You do not have permission to edit this." - * ) - * @DemoRestricted( - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"} - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkCmsPageCategoryStatusEnableAction(Request $request) - { - $cmsCategoriesToEnable = $request->request->get('cms_page_category_bulk'); - $cmsCategoryParentId = null; - try { - $cmsCategoriesToEnable = array_map(function ($item) { return (int) $item; }, $cmsCategoriesToEnable); - - $this->getCommandBus()->handle( - new BulkEnableCmsPageCategoryCommand($cmsCategoriesToEnable) - ); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (Exception $exception) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($exception, $this->getErrorMessages()) - ); - } - - return $this->redirectToParentIndexPageByCategoryBulkIds($cmsCategoriesToEnable); - } - - /** - * Changes multiple cms page category statuses to disabled. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"}, - * message="You do not have permission to edit this." - * ) - * @DemoRestricted( - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"} - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkCmsPageCategoryStatusDisableAction(Request $request) - { - $cmsCategoriesToDisable = $request->request->get('cms_page_category_bulk'); - try { - $cmsCategoriesToDisable = array_map( - function ($item) { - return (int) $item; - }, - $cmsCategoriesToDisable - ); - $this->getCommandBus()->handle( - new BulkDisableCmsPageCategoryCommand($cmsCategoriesToDisable) - ); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (Exception $exception) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($exception, $this->getErrorMessages()) - ); - } - - return $this->redirectToParentIndexPageByCategoryBulkIds($cmsCategoriesToDisable); - } - - /** - * Toggles cms page listing status. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"}, - * message="You do not have permission to edit this." - * ) - * @DemoRestricted( - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"} - * ) - * - * @param int $cmsId - * - * @return RedirectResponse - */ - public function toggleCmsAction($cmsId) - { - try { - $this->getCommandBus()->handle(new ToggleCmsPageStatusCommand((int) $cmsId)); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (Exception $exception) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($exception, $this->getErrorMessages()) - ); - } - - return $this->redirectToParentIndexPageByCmsPageId($cmsId); - } - - /** - * Disables multiple cms pages. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"}, - * message="You do not have permission to edit this." - * ) - * @DemoRestricted( - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"} - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkDisableCmsPageStatusAction(Request $request) - { - $cmsPagesToDisable = $request->request->get('cms_page_bulk'); - - try { - $cmsPagesToDisable = array_map(function ($item) { return (int) $item; }, $cmsPagesToDisable); - - $this->getCommandBus()->handle( - new BulkDisableCmsPageCommand($cmsPagesToDisable) - ); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (Exception $exception) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($exception, $this->getErrorMessages()) - ); - } - - return $this->redirectToParentIndexPageByBulkIds($cmsPagesToDisable); - } - - /** - * Enables multiple cms pages. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"}, - * message="You do not have permission to edit this." - * ) - * @DemoRestricted( - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"} - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkEnableCmsPageStatusAction(Request $request) - { - $cmsPagesToDisable = $request->request->get('cms_page_bulk'); - - try { - $cmsPagesToDisable = array_map( - function ($item) { - return (int) $item; - }, - $cmsPagesToDisable - ); - - $this->getCommandBus()->handle( - new BulkEnableCmsPageCommand($cmsPagesToDisable) - ); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (Exception $exception) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($exception, $this->getErrorMessages()) - ); - } - - return $this->redirectToParentIndexPageByBulkIds($cmsPagesToDisable); - } - - /** - * Deletes multiple cms pages. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"}, - * message="You do not have permission to delete this." - * ) - * @DemoRestricted( - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"} - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkDeleteCmsPageAction(Request $request) - { - $cmsPagesToDisable = $request->request->get('cms_page_bulk'); - - $redirectResponse = $this->redirectToParentIndexPageByBulkIds($cmsPagesToDisable); - - try { - $cmsPagesToDisable = array_map( - function ($item) { - return (int) $item; - }, - $cmsPagesToDisable - ); - - $this->getCommandBus()->handle( - new BulkDeleteCmsPageCommand($cmsPagesToDisable) - ); - - $this->addFlash( - 'success', - $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success') - ); - } catch (Exception $exception) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($exception, $this->getErrorMessages()) - ); - } - - return $redirectResponse; - } - - /** - * Deletes cms page by given id. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"}, - * message="You do not have permission to delete this." - * ) - * @DemoRestricted( - * redirectRoute="admin_cms_pages_index", - * redirectQueryParamsToKeep={"id_cms_category"} - * ) - * - * @param int $cmsId - * - * @return RedirectResponse - */ - public function deleteCmsAction($cmsId) - { - $redirectResponse = $this->redirectToParentIndexPageByCmsPageId($cmsId); - - try { - $this->getCommandBus()->handle(new DeleteCmsPageCommand((int) $cmsId)); - - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (Exception $exception) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($exception, $this->getErrorMessages()) - ); - } - - return $redirectResponse; - } - - /** - * Gets cms page category form builder. - * - * @return FormBuilderInterface - */ - private function getCmsPageCategoryFormBuilder() - { - return $this->get('prestashop.core.form.identifiable_object.builder.cms_page_category_form_builder'); - } - - /** - * @return FormHandlerInterface - */ - private function getCmsPageCategoryFormHandler() - { - return $this->get('prestashop.core.form.identifiable_object.handler.cms_page_category_form_handler'); - } - - /** - * This function is used for redirecting to the specific cms page category page. It uses bulk action ids which - * share the same parent cms category in all cases. - * - * @param array $cmsPageCategoryIds - * - * @return RedirectResponse - */ - private function redirectToParentIndexPageByCategoryBulkIds(array $cmsPageCategoryIds) - { - if (empty($cmsPageCategoryIds)) { - return $this->redirectToRoute('admin_cms_pages_index'); - } - - return $this->redirectToParentIndexPage((int) $cmsPageCategoryIds[0]); - } - - /** - * This function is used for redirecting to the specific cms page category page. - * - * @param array $cmsPageIds - * - * @return RedirectResponse - */ - private function redirectToParentIndexPageByBulkIds(array $cmsPageIds) - { - if (empty($cmsPageIds)) { - return $this->redirectToRoute('admin_cms_pages_index'); - } - - return $this->redirectToParentIndexPageByCmsPageId($cmsPageIds[0]); - } - - /** - * This function is used for redirecting to the specific cms page category page. - * - * @param int $cmsPageCategoryId - * - * @return RedirectResponse - */ - private function redirectToParentIndexPage($cmsPageCategoryId) - { - try { - $cmsPageCategoryParentId = $this->getParentCategoryId($cmsPageCategoryId)->getValue(); - } catch (CmsPageCategoryException $e) { - $cmsPageCategoryParentId = CmsPageCategoryId::ROOT_CMS_PAGE_CATEGORY_ID; - } - - return $this->redirectToIndexPageById($cmsPageCategoryParentId); - } - - /** - * @param int $cmsPageId - * - * @return RedirectResponse - */ - private function redirectToParentIndexPageByCmsPageId($cmsPageId) - { - try { - $cmsCategoryId = $this->getQueryBus()->handle(new GetCmsCategoryIdForRedirection((int) $cmsPageId))->getValue(); - } catch (CmsPageException $e) { - $cmsCategoryId = CmsPageCategoryId::ROOT_CMS_PAGE_CATEGORY_ID; - } - - return $this->redirectToIndexPageById($cmsCategoryId); - } - - /** - * Redirects to index page by given id. - * - * @param $cmsPageCategoryId - * - * @return RedirectResponse - */ - private function redirectToIndexPageById($cmsPageCategoryId) - { - $routeParameters = []; - - if ($cmsPageCategoryId !== CmsPageCategoryId::ROOT_CMS_PAGE_CATEGORY_ID) { - $routeParameters = [ - 'id_cms_category' => $cmsPageCategoryId, - ]; - } - - return $this->redirectToRoute('admin_cms_pages_index', $routeParameters); - } - - /** - * Gets parent id according to the given child - * - * @param int $cmsPageCategoryChildId - * - * @return CmsPageCategoryId - * - * @throws CmsPageCategoryException - */ - private function getParentCategoryId($cmsPageCategoryChildId) - { - /** @var CmsPageCategoryId $cmsPageCategoryParentId */ - $cmsPageCategoryParentId = $this->getQueryBus()->handle( - new GetCmsPageParentCategoryIdForRedirection($cmsPageCategoryChildId) - ); - - return $cmsPageCategoryParentId; - } - - /** - * @return FormBuilderInterface - */ - private function getCmsPageFormBuilder() - { - return $this->get('prestashop.core.form.identifiable_object.builder.cms_page_form_builder'); - } - - /** - * @return FormHandlerInterface - */ - private function getCmsPageFormHandler() - { - return $this->get('prestashop.core.form.identifiable_object.handler.cms_page_form_handler'); - } - - /** - * Provides translatable error messages for exceptions - * - * @return array - */ - private function getErrorMessages() - { - return [ - CmsPageNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - CannotToggleCmsPageException::class => $this->trans( - 'An error occurred while updating the status.', - 'Admin.Notifications.Error' - ), - CannotDisableCmsPageException::class => $this->trans( - 'An error occurred while updating the status.', - 'Admin.Notifications.Error' - ), - CannotEnableCmsPageException::class => $this->trans( - 'An error occurred while updating the status.', - 'Admin.Notifications.Error' - ), - CannotDeleteCmsPageException::class => [ - CannotDeleteCmsPageException::FAILED_BULK_DELETE => $this->trans( - 'An error occurred while deleting this selection.', - 'Admin.Notifications.Error' - ), - CannotDeleteCmsPageException::FAILED_DELETE => $this->trans( - 'An error occurred while deleting the object.', - 'Admin.Notifications.Error' - ), - ], - CmsPageCategoryConstraintException::class => [ - CmsPageCategoryConstraintException::INVALID_BULK_DATA => $this->trans( - 'You must select at least one element to delete.', - 'Admin.Notifications.Error' - ), - CmsPageCategoryConstraintException::CANNOT_MOVE_CATEGORY_TO_PARENT => $this->trans('The page Category cannot be moved here.', 'Admin.Design.Notification'), - CmsPageCategoryConstraintException::MISSING_DEFAULT_LANGUAGE_FOR_NAME => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf('"%s"', $this->trans('Name', 'Admin.Global')), - ] - ), - CmsPageCategoryConstraintException::MISSING_DEFAULT_LANGUAGE_FOR_FRIENDLY_URL => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf('"%s"', $this->trans('Friendly URL', 'Admin.Global')), - ] - ), - CmsPageCategoryConstraintException::INVALID_CATEGORY_NAME => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf('"%s"', $this->trans('Name', 'Admin.Global')), - ] - ), - CmsPageCategoryConstraintException::INVALID_LINK_REWRITE => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf('"%s"', $this->trans('Friendly URL', 'Admin.Global')), - ] - ), - CmsPageCategoryConstraintException::INVALID_META_TITLE => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf('"%s"', $this->trans('Meta title', 'Admin.Global')), - ] - ), - CmsPageCategoryConstraintException::INVALID_DESCRIPTION => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf('"%s"', $this->trans('Description', 'Admin.Global')), - ] - ), - CmsPageCategoryConstraintException::INVALID_META_DESCRIPTION => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf('"%s"', $this->trans('Meta description', 'Admin.Global')), - ] - ), - CmsPageCategoryConstraintException::INVALID_META_KEYWORDS => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf('"%s"', $this->trans('Meta keywords', 'Admin.Global')), - ] - ), - ], - CmsPageCategoryNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - CannotToggleCmsPageCategoryStatusException::class => $this->trans( - 'An error occurred while updating the status.', - 'Admin.Notifications.Error' - ), - CannotDeleteCmsPageCategoryException::class => [ - CannotDeleteCmsPageCategoryException::FAILED_BULK_DELETE => $this->trans( - 'An error occurred while deleting this selection.', - 'Admin.Notifications.Error' - ), - CannotDeleteCmsPageCategoryException::FAILED_DELETE => $this->trans( - 'An error occurred while deleting the object.', - 'Admin.Notifications.Error' - ), - ], - ]; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/Design/MailThemeController.php b/src/PrestaShopBundle/Controller/Admin/Improve/Design/MailThemeController.php deleted file mode 100644 index fd42c2a3..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/Design/MailThemeController.php +++ /dev/null @@ -1,548 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\Design; - -use Mail; -use PrestaShop\PrestaShop\Adapter\MailTemplate\MailPreviewVariablesBuilder; -use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; -use PrestaShop\PrestaShop\Core\Domain\MailTemplate\Command\GenerateThemeMailTemplatesCommand; -use PrestaShop\PrestaShop\Core\Employee\ContextEmployeeProviderInterface; -use PrestaShop\PrestaShop\Core\Exception\CoreException; -use PrestaShop\PrestaShop\Core\Exception\FileNotFoundException; -use PrestaShop\PrestaShop\Core\Exception\InvalidArgumentException; -use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface; -use PrestaShop\PrestaShop\Core\Language\LanguageInterface; -use PrestaShop\PrestaShop\Core\Language\LanguageRepositoryInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\Layout\LayoutInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\MailTemplateInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\MailTemplateRendererInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\ThemeCatalogInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\ThemeInterface; -use PrestaShop\PrestaShop\Core\MailTemplate\Transformation\MailVariablesTransformation; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Form\Admin\Improve\Design\MailTheme\GenerateMailsType; -use PrestaShopBundle\Form\Admin\Improve\Design\MailTheme\TranslateMailsBodyType; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Service\TranslationService; -use Symfony\Component\Form\Form; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; - -/** - * Class MailThemeController manages mail theme generation, you can define the shop - * mail theme, and regenerate mail in a specific language. - * - * Accessible via "Design > Mail Theme" - */ -class MailThemeController extends FrameworkBundleAdminController -{ - /** - * Show mail theme settings and generation page. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return Response - */ - public function indexAction(Request $request) - { - $legacyController = $request->attributes->get('_legacy_controller'); - $generateThemeMailsForm = $this->createForm(GenerateMailsType::class); - $translateMailsBodyForm = $this->createForm(TranslateMailsBodyType::class); - /** @var ThemeCatalogInterface $themeCatalog */ - $themeCatalog = $this->get('prestashop.core.mail_template.theme_catalog'); - $mailThemes = $themeCatalog->listThemes(); - - return $this->render('@PrestaShop/Admin/Improve/Design/MailTheme/index.html.twig', [ - 'layoutHeaderToolbarBtn' => [], - 'layoutTitle' => $this->trans('Email Theme', 'Admin.Navigation.Menu'), - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($legacyController), - 'mailThemeConfigurationForm' => $this->getMailThemeFormHandler()->getForm()->createView(), - 'generateMailsForm' => $generateThemeMailsForm->createView(), - 'translateMailsBodyForm' => $translateMailsBodyForm->createView(), - 'mailThemes' => $mailThemes, - ]); - } - - /** - * Manage generation form post and generate mails. - * - * @AdminSecurity("is_granted('create', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return Response - */ - public function generateMailsAction(Request $request) - { - $generateThemeMailsForm = $this->createForm(GenerateMailsType::class); - $generateThemeMailsForm->handleRequest($request); - - if ($generateThemeMailsForm->isSubmitted()) { - if (!$generateThemeMailsForm->isValid()) { - $this->flashErrors($this->getFormErrorsForJS($generateThemeMailsForm)); - - return $this->redirectToRoute('admin_mail_theme_index'); - } - - $data = $generateThemeMailsForm->getData(); - try { - $coreMailsFolder = ''; - $modulesMailFolder = ''; - //Overwrite theme folder if selected - if (!empty($data['theme'])) { - $themeFolder = $this->getParameter('themes_dir') . '/' . $data['theme']; - if (is_dir($themeFolder . '/mails')) { - $coreMailsFolder = $themeFolder . '/mails'; - } - if (is_dir($themeFolder . '/modules')) { - $modulesMailFolder = $themeFolder . '/modules'; - } - } - - $generateCommand = new GenerateThemeMailTemplatesCommand( - $data['mailTheme'], - $data['language'], - $data['overwrite'], - $coreMailsFolder, - $modulesMailFolder - ); - - /** @var CommandBusInterface $commandBus */ - $commandBus = $this->get('prestashop.core.command_bus'); - $commandBus->handle($generateCommand); - - if ($data['overwrite']) { - $this->addFlash( - 'success', - $this->trans( - 'Successfully overwrote email templates for theme %s with locale %s', - 'Admin.Notifications.Success', - [ - $data['mailTheme'], - $data['language'], - ] - ) - ); - } else { - $this->addFlash( - 'success', - $this->trans( - 'Successfully generated email templates for theme %s with locale %s', - 'Admin.Notifications.Success', - [ - $data['mailTheme'], - $data['language'], - ] - ) - ); - } - } catch (CoreException $e) { - $this->flashErrors([ - $this->trans( - sprintf( - 'Cannot generate email templates for theme %s with locale %s', - $data['mailTheme'], - $data['language'] - ), - 'Admin.Notifications.Error' - ), - $e->getMessage(), - ]); - } - } - - return $this->redirectToRoute('admin_mail_theme_index'); - } - - /** - * Save mail theme configuration - * - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return Response - * - * @throws \Exception - */ - public function saveConfigurationAction(Request $request) - { - /** @var FormHandlerInterface $formHandler */ - $formHandler = $this->getMailThemeFormHandler(); - /** @var Form $form */ - $form = $formHandler->getForm()->handleRequest($request); - - if ($form->isSubmitted()) { - if (!$form->isValid()) { - $this->flashErrors($this->getFormErrorsForJS($form)); - - return $this->redirectToRoute('admin_mail_theme_index'); - } - - $errors = $formHandler->save($form->getData()); - if (empty($errors)) { - $this->addFlash( - 'success', - $this->trans( - 'Email theme configuration saved successfully', - 'Admin.Notifications.Success' - ) - ); - } else { - $this->flashErrors($errors); - } - } - - return $this->redirectToRoute('admin_mail_theme_index'); - } - - /** - * Preview the list of layouts for a defined theme - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * @param string $theme - * - * @return Response - * - * @throws InvalidArgumentException - */ - public function previewThemeAction(Request $request, $theme) - { - $legacyController = $request->attributes->get('_legacy_controller'); - - /** @var ThemeCatalogInterface $themeCatalog */ - $themeCatalog = $this->get('prestashop.core.mail_template.theme_catalog'); - /** @var ThemeInterface $mailTheme */ - $mailTheme = $themeCatalog->getByName($theme); - - return $this->render('@PrestaShop/Admin/Improve/Design/MailTheme/preview.html.twig', [ - 'layoutHeaderToolbarBtn' => [], - 'layoutTitle' => $this->trans('Preview Theme %s', 'Admin.Design.Feature', [$mailTheme->getName()]), - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($legacyController), - 'mailTheme' => $mailTheme, - ]); - } - - /** - * This action allows to send a test mail of a specific email template, however the Mail - * class used to send emails is not modular enough to allow sending templates on the fly. - * This would require either: - * - a little modification of the Mail class to add an easy way to send a template content (rather than its name) - * - a full refacto of the Mail class which wouldn't be coupled to static files any more - * - * These modifications will be performed in a future release so for now we can only send test emails - * with the current email theme using generated static files. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param string $theme - * @param string $layout - * @param string $locale - * @param string $module - * - * @return Response - * - * @throws InvalidArgumentException - */ - public function sendTestMailAction($theme, $layout, $locale, $module = '') - { - if ($this->configuration->get('PS_MAIL_THEME') !== $theme) { - $this->addFlash( - 'error', - $this->trans( - 'Cannot send test email for theme %theme% because it is not your current theme', - 'Admin.Notifications.Error', - [ - '%theme%' => $theme, - ] - ) - ); - - return $this->redirectToRoute('admin_mail_theme_preview', ['theme' => $theme]); - } - - /** @var ContextEmployeeProviderInterface $employeeProvider */ - $employeeProvider = $this->get('prestashop.adapter.data_provider.employee'); - $employeeData = $employeeProvider->getData(); - - /** @var LanguageRepositoryInterface $languageRepository */ - $languageRepository = $this->get('prestashop.core.admin.lang.repository'); - /** @var LanguageInterface $language */ - $language = $languageRepository->getOneByLocaleOrIsoCode($locale); - if (null === $language) { - throw new InvalidArgumentException(sprintf('Cannot find Language with locale or isoCode %s', $locale)); - } - - if (empty($module)) { - $templatePath = _PS_MAIL_DIR_; - } else { - $templatePath = _PS_MODULE_DIR_ . $module . '/mails/'; - } - - /** @var MailPreviewVariablesBuilder $variableBuilder */ - $variablesBuilder = $this->get('prestashop.adapter.mail_template.preview_variables_builder'); - $mailLayout = $this->getMailLayout($theme, $layout, $module); - $mailVariables = $variablesBuilder->buildTemplateVariables($mailLayout); - - $mailSent = Mail::send( - $language->getId(), - $layout, - $this->trans('Test email %template%', 'Admin.Design.Feature', ['%template%' => $layout]), - $mailVariables, - $employeeData['email'], - $employeeData['firstname'] . ' ' . $employeeData['lastname'], - $employeeData['email'], - $employeeData['firstname'] . ' ' . $employeeData['lastname'], - null, - null, - $templatePath - ); - - if ($mailSent) { - $this->addFlash( - 'success', - $this->trans( - 'Test email for layout %layout% was successfully sent to %email%', - 'Admin.Notifications.Success', - [ - '%layout%' => $layout, - '%email%' => $employeeData['email'], - ] - ) - ); - } else { - $this->addFlash( - 'error', - $this->trans( - 'Cannot send test email for layout %layout%', - 'Admin.Notifications.Error', - [ - '%layout%' => $layout, - ] - ) - ); - } - - return $this->redirectToRoute('admin_mail_theme_preview', ['theme' => $theme]); - } - - /** - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * message="You do not have permission to update this." - * ) - * - * @param Request $request - * - * @return \Symfony\Component\HttpFoundation\RedirectResponse - */ - public function translateBodyAction(Request $request) - { - $translateMailsBodyForm = $this->createForm(TranslateMailsBodyType::class); - $translateMailsBodyForm->handleRequest($request); - - if (!$translateMailsBodyForm->isSubmitted() || !$translateMailsBodyForm->isValid()) { - $this->addFlash( - 'error', - $this->trans( - 'Cannot translate emails body content', - 'Admin.Notifications.Error' - ) - ); - - return $this->redirectToRoute('admin_mail_theme_index'); - } - - $translateData = $translateMailsBodyForm->getData(); - $language = $translateData['language']; - /** @var TranslationService $translationService */ - $translationService = $this->get('prestashop.service.translation'); - $locale = $translationService->langToLocale($language); - - return $this->redirectToRoute('admin_international_translation_overview', [ - 'lang' => $language, - 'locale' => $locale, - 'type' => 'mails_body', - ]); - } - - /** - * Preview a mail layout from a defined theme - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param string $theme - * @param string $layout - * @param string $type - * @param string $locale - * @param string $module - * - * @return Response - * - * @throws FileNotFoundException - * @throws InvalidArgumentException - */ - public function previewLayoutAction($theme, $layout, $type, $locale, $module = '') - { - $renderedLayout = $this->renderLayout($theme, $layout, $type, $locale, $module); - - return new Response($renderedLayout); - } - - /** - * Display the raw source of a theme layout (mainly useful for developers/integrators) - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param string $theme - * @param string $layout - * @param string $type - * @param string $locale - * @param string $module - * - * @return Response - * - * @throws FileNotFoundException - * @throws InvalidArgumentException - */ - public function rawLayoutAction($theme, $layout, $type, $locale, $module = '') - { - $renderedLayout = $this->renderLayout($theme, $layout, $type, $locale, $module); - - $response = new Response($renderedLayout, Response::HTTP_OK, [ - 'Content-Type' => 'text/plain', - ]); - - return $response; - } - - /** - * Dynamically display an email template, this is usually used by the MailGenerator but this action - * allows to display preview before generating the file (handy when you are developing an email theme) - * - * @param string $themeName - * @param string $layoutName - * @param string $type - * @param string $locale - * @param string $module - * - * @return string - * - * @throws FileNotFoundException - * @throws InvalidArgumentException - */ - private function renderLayout($themeName, $layoutName, $type, $locale = '', $module = '') - { - $layout = $this->getMailLayout($themeName, $layoutName, $module); - - /** @var LanguageRepositoryInterface $languageRepository */ - $languageRepository = $this->get('prestashop.core.admin.lang.repository'); - if (empty($locale)) { - $locale = $this->getContext()->language->locale; - } - /** @var LanguageInterface $language */ - $language = $languageRepository->getOneByLocaleOrIsoCode($locale); - if (null === $language) { - throw new InvalidArgumentException(sprintf('Cannot find Language with locale or isoCode %s', $locale)); - } - - /** @var MailPreviewVariablesBuilder $variableBuilder */ - $variablesBuilder = $this->get('prestashop.adapter.mail_template.preview_variables_builder'); - $mailLayoutVariables = $variablesBuilder->buildTemplateVariables($layout); - - /** @var MailTemplateRendererInterface $renderer */ - $renderer = $this->get('prestashop.core.mail_template.mail_template_renderer'); - //Special case for preview, we fill the mail variables - $renderer->addTransformation(new MailVariablesTransformation(MailTemplateInterface::HTML_TYPE, $mailLayoutVariables)); - $renderer->addTransformation(new MailVariablesTransformation(MailTemplateInterface::TXT_TYPE, $mailLayoutVariables)); - - switch ($type) { - case MailTemplateInterface::HTML_TYPE: - $renderedLayout = $renderer->renderHtml($layout, $language); - break; - case MailTemplateInterface::TXT_TYPE: - $renderedLayout = $renderer->renderTxt($layout, $language); - break; - default: - throw new NotFoundHttpException(sprintf('Requested type %s is not managed, please use one of these: %s', $type, implode(',', [MailTemplateInterface::HTML_TYPE, MailTemplateInterface::TXT_TYPE]))); - break; - } - - return $renderedLayout; - } - - /** - * @param string $themeName - * @param string $layoutName - * @param string $module - * - * @return LayoutInterface - * - * @throws FileNotFoundException - * @throws InvalidArgumentException - */ - private function getMailLayout($themeName, $layoutName, $module) - { - /** @var ThemeCatalogInterface $themeCatalog */ - $themeCatalog = $this->get('prestashop.core.mail_template.theme_catalog'); - /** @var ThemeInterface $theme */ - $theme = $themeCatalog->getByName($themeName); - - /** @var LayoutInterface $layout */ - $layout = null; - /* @var LayoutInterface $layoutInterface */ - foreach ($theme->getLayouts() as $layoutInterface) { - if ($layoutInterface->getName() == $layoutName - && $layoutInterface->getModuleName() == $module - ) { - $layout = $layoutInterface; - break; - } - } - - if (null === $layout) { - throw new FileNotFoundException(sprintf('Cannot find layout %s%s in theme %s', empty($module) ? '' : $module . ':', $layoutName, $themeName)); - } - - return $layout; - } - - /** - * @return FormHandlerInterface - */ - private function getMailThemeFormHandler() - { - return $this->get('prestashop.admin.mail_theme.form_handler'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/Design/PositionsController.php b/src/PrestaShopBundle/Controller/Admin/Improve/Design/PositionsController.php deleted file mode 100644 index d5f6903f..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/Design/PositionsController.php +++ /dev/null @@ -1,234 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\Design; - -use Hook; -use PrestaShop\PrestaShop\Adapter\Module\Module; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Configuration modules positions "Improve > Design > Positions". - */ -class PositionsController extends FrameworkBundleAdminController -{ - /** - * @var int - */ - protected $selectedModule = null; - - /** - * Display hooks positions. - * - * @Template("@PrestaShop/Admin/Improve/Design/positions.html.twig") - * @AdminSecurity("is_granted(['read', 'update', 'create', 'delete'], request.get('_legacy_controller')~'_')", message="Access denied.") - * - * @param Request $request - * - * @return Response - */ - public function indexAction(Request $request) - { - $moduleAdapter = $this->get('prestashop.adapter.legacy.module'); - $hookProvider = $this->get('prestashop.adapter.legacy.hook'); - $installedModules = $moduleAdapter->getModulesInstalled(); - - $selectedModule = $request->get('show_modules'); - if ($selectedModule && (string) $selectedModule != 'all') { - $this->selectedModule = (int) $selectedModule; - } - - $this->manageLegacyFlashes($request->query->get('conf')); - - $modules = []; - foreach ($installedModules as $installedModule) { - if ($module = $moduleAdapter->getInstanceById($installedModule['id_module'])) { - // We want to be able to sort modules by display name - $modules[(int) $module->id] = $module; - } - } - - $hooks = $hookProvider->getHooks(); - foreach ($hooks as $key => $hook) { - $hooks[$key]['modules'] = $hookProvider->getModulesFromHook( - $hook['id_hook'], - $this->selectedModule - ); - // No module found, no need to continue - if (!is_array($hooks[$key]['modules'])) { - unset($hooks[$key]); - - continue; - } - - foreach ($hooks[$key]['modules'] as $index => $module) { - if (empty($modules[(int) $module['id_module']])) { - unset($hooks[$key]['modules'][$index]); - } - } - - $hooks[$key]['modules_count'] = count($hooks[$key]['modules']); - // No module remaining after the check, no need to continue - if ($hooks[$key]['modules_count'] === 0) { - unset($hooks[$key]); - - continue; - } - - $hooks[$key]['position'] = $hookProvider->isDisplayHookName($hook['name']); - } - - $legacyContextService = $this->get('prestashop.adapter.legacy.context'); - $saveUrlParams = [ - 'addToHook' => '', - ]; - if ($this->selectedModule) { - $saveUrlParams['show_modules'] = $this->selectedModule; - } - $saveUrl = $legacyContextService->getAdminLink('AdminModulesPositions', true, $saveUrlParams); - - return [ - 'layoutHeaderToolbarBtn' => [ - 'save' => [ - 'href' => $saveUrl, - 'desc' => $this->trans('Transplant a module', 'Admin.Design.Feature'), - ], - ], - 'selectedModule' => $this->selectedModule, - 'layoutTitle' => $this->trans('Positions', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => false, - 'requireBulkActions' => false, - 'requireFilterStatus' => false, - 'showContentHeader' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink('AdminModulesPositions'), - 'hooks' => $hooks, - 'modules' => $modules, - 'canMove' => $this->get('prestashop.adapter.shop.context')->isSingleShopContext(), - ]; - } - - /** - * Unhook module. - * - * @AdminSecurity("is_granted(['delete'], request.get('_legacy_controller')~'_')", message="Access denied.") - * - * @param Request $request - * - * @return Response - */ - public function unhookAction(Request $request) - { - $validateAdapter = $this->get('prestashop.adapter.validate'); - $unhooks = $request->request->get('unhooks'); - $context = null; - if (empty($unhooks)) { - $moduleId = $request->query->get('moduleId'); - $hookId = $request->query->get('hookId'); - $unhooks = [sprintf('%d_%d', $hookId, $moduleId)]; - $context = $this->get('prestashop.adapter.shop.context')->getContextListShopID(); - } - - $errors = []; - foreach ($unhooks as $unhook) { - $explode = explode('_', $unhook); - $hookId = (int) isset($explode[0]) ? $explode[0] : 0; - $moduleId = (int) isset($explode[1]) ? $explode[1] : 0; - $module = $this->get('prestashop.adapter.legacy.module')->getInstanceById($moduleId); - $hook = new Hook($hookId); - - if (!$module) { - $errors[] = $this->trans( - 'This module cannot be loaded.', - 'Admin.Modules.Notification' - ); - - continue; - } - - if (!$validateAdapter->isLoadedObject($hook)) { - $errors[] = $this->trans( - 'Hook cannot be loaded.', - 'Admin.Modules.Notification' - ); - - continue; - } - - if (!$module->unregisterHook($hookId, $context) || !$module->unregisterExceptions($hookId, $context)) { - $errors[] = $this->trans( - 'An error occurred while deleting the module from its hook.', - 'Admin.Modules.Notification' - ); - } - } - - if (!empty($errors)) { - $this->flashErrors($errors); - } else { - $this->addFlash( - 'success', - $this->trans( - 'The module was successfully removed from the hook.', - 'Admin.Modules.Notification' - ) - ); - } - - return $this->redirect( - $this->generateUrl('admin_modules_positions') - ); - } - - /** - * Manage legacy flashes, this code must be removed - * when legacy edit will be migrated. - * - * @param int $messageId The message id from legacy context - */ - private function manageLegacyFlashes($messageId) - { - if (empty($messageId)) { - return; - } - - $messages = [ - 16 => $this->trans('The module transplanted successfully to the hook.', 'Admin.Modules.Notification'), - 17 => $this->trans('The module was successfully removed from the hook.', 'Admin.Modules.Notification'), - ]; - - if (isset($messages[$messageId])) { - $this->addFlash( - 'success', - $messages[$messageId] - ); - } - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/Design/ThemeCatalogController.php b/src/PrestaShopBundle/Controller/Admin/Improve/Design/ThemeCatalogController.php deleted file mode 100644 index d95b2d35..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/Design/ThemeCatalogController.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\Design; - -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\Request; - -/** - * Displays themes from Addons under "Improve > Design > Themes Catalog". - */ -class ThemeCatalogController extends FrameworkBundleAdminController -{ - /** - * Displays themes from Addons under "Improve > Design > Themes Catalog". - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ - public function indexAction(Request $request) - { - $pageContent = file_get_contents($this->getAddonsUrl($request)); - - return $this->render('@PrestaShop/Admin/Improve/Design/ThemesCatalogPage/addons_store.html.twig', [ - 'pageContent' => $pageContent, - 'layoutHeaderToolbarBtn' => [], - 'layoutTitle' => $this->trans('Themes Catalog', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'requireBulkActions' => false, - 'showContentHeader' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink('AdminThemesCatalog'), - 'requireFilterStatus' => false, - ]); - } - - /** - * @param Request $request - * - * @return string - */ - private function getAddonsUrl(Request $request) - { - $psVersion = $this->get('prestashop.core.foundation.version')->getVersion(); - $parent_domain = $request->getSchemeAndHttpHost(); - $context = $this->getContext(); - $currencyCode = $context->currency->iso_code; - $languageCode = $context->language->iso_code; - $countryCode = $context->country->iso_code; - $activity = $this->get('prestashop.adapter.legacy.configuration')->getInt('PS_SHOP_ACTIVITY'); - - return "https://addons.prestashop.com/iframe/search-1.7.php?psVersion=$psVersion" - . "&isoLang=$languageCode" - . "&isoCurrency=$currencyCode" - . "&isoCountry=$countryCode" - . "&activity=$activity" - . "&parentUrl=$parent_domain" - . '&onlyThemes=1'; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/Design/ThemeController.php b/src/PrestaShopBundle/Controller/Admin/Improve/Design/ThemeController.php deleted file mode 100644 index 5ff6821c..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/Design/ThemeController.php +++ /dev/null @@ -1,606 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\Design; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; -use PrestaShop\PrestaShop\Core\Domain\Exception\FileUploadException; -use PrestaShop\PrestaShop\Core\Domain\Meta\Query\GetPagesForLayoutCustomization; -use PrestaShop\PrestaShop\Core\Domain\Meta\QueryResult\LayoutCustomizationPage; -use PrestaShop\PrestaShop\Core\Domain\Shop\DTO\ShopLogoSettings; -use PrestaShop\PrestaShop\Core\Domain\Shop\Exception\NotSupportedFaviconExtensionException; -use PrestaShop\PrestaShop\Core\Domain\Shop\Exception\NotSupportedLogoImageExtensionException; -use PrestaShop\PrestaShop\Core\Domain\Shop\Query\GetLogosPaths; -use PrestaShop\PrestaShop\Core\Domain\Shop\QueryResult\LogosPaths; -use PrestaShop\PrestaShop\Core\Domain\Theme\Command\AdaptThemeToRTLLanguagesCommand; -use PrestaShop\PrestaShop\Core\Domain\Theme\Command\DeleteThemeCommand; -use PrestaShop\PrestaShop\Core\Domain\Theme\Command\EnableThemeCommand; -use PrestaShop\PrestaShop\Core\Domain\Theme\Command\ImportThemeCommand; -use PrestaShop\PrestaShop\Core\Domain\Theme\Command\ResetThemeLayoutsCommand; -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\CannotAdaptThemeToRTLLanguagesException; -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\CannotDeleteThemeException; -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\CannotEnableThemeException; -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\FailedToEnableThemeModuleException; -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\ImportedThemeAlreadyExistsException; -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\ThemeConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Theme\Exception\ThemeException; -use PrestaShop\PrestaShop\Core\Domain\Theme\ValueObject\ThemeImportSource; -use PrestaShop\PrestaShop\Core\Domain\Theme\ValueObject\ThemeName; -use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController as AbstractAdminController; -use PrestaShopBundle\Form\Admin\Improve\Design\Theme\AdaptThemeToRTLLanguagesType; -use PrestaShopBundle\Form\Admin\Improve\Design\Theme\ImportThemeType; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use PrestaShopBundle\Security\Voter\PageVoter; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\File\UploadedFile; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class ThemeController manages "Improve > Design > Theme & Logo" pages. - */ -class ThemeController extends AbstractAdminController -{ - /** - * Show main themes page. - * - * @AdminSecurity( - * "is_granted('read', request.get('_legacy_controller'))", - * message="You do not have permission to edit this." - * ) - * - * @param Request $request - * - * @return Response - */ - public function indexAction(Request $request) - { - $isHostMode = $this->get('prestashop.adapter.hosting_information')->isHostMode(); - $isoCode = strtoupper($this->get('prestashop.adapter.legacy.context')->getLanguage()->iso_code); - - $themeCatalogUrl = sprintf( - '%s?%s', - 'https://addons.prestashop.com/en/3-templates-prestashop', - http_build_query([ - 'utm_source' => 'back-office', - 'utm_medium' => 'theme-button', - 'utm_campaign' => 'back-office-' . $isoCode, - 'utm_content' => $isHostMode ? 'cloud' : 'download', - ]) - ); - - $themeProvider = $this->get('prestashop.core.addon.theme.theme_provider'); - $installedRtlLanguageChecker = $this->get('prestashop.adapter.language.rtl.installed_language_checker'); - /** @var LogosPaths $logoProvider */ - $logoProvider = $this->getQueryBus()->handle(new GetLogosPaths()); - - return $this->render('@PrestaShop/Admin/Improve/Design/Theme/index.html.twig', [ - 'themeCatalogUrl' => $themeCatalogUrl, - 'baseShopUrl' => $this->get('prestashop.adapter.shop.url.base_url_provider')->getUrl(), - 'shopLogosForm' => $this->getLogosUploadForm()->createView(), - 'headerLogoPath' => $logoProvider->getHeaderLogoPath(), - 'mailLogoPath' => $logoProvider->getMailLogoPath(), - 'invoiceLogoPath' => $logoProvider->getInvoiceLogoPath(), - 'faviconPath' => $logoProvider->getFaviconPath(), - 'currentlyUsedTheme' => $themeProvider->getCurrentlyUsedTheme(), - 'notUsedThemes' => $themeProvider->getNotUsedThemes(), - 'isDevModeOn' => $this->get('prestashop.adapter.legacy.configuration')->get('_PS_MODE_DEV_'), - 'isSingleShopContext' => $this->get('prestashop.adapter.shop.context')->isSingleShopContext(), - 'isMultiShopFeatureUsed' => $this->get('prestashop.adapter.multistore_feature')->isUsed(), - 'adaptThemeToRtlLanguagesForm' => $this->getAdaptThemeToRtlLanguageForm()->createView(), - 'isInstalledRtlLanguage' => $installedRtlLanguageChecker->isInstalledRtlLanguage(), - 'shopName' => $this->get('prestashop.adapter.shop.context')->getShopName(), - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - ]); - } - - /** - * Upload shop logos. - * - * @AdminSecurity("is_granted(['update'], request.get('_legacy_controller'))", redirectRoute="admin_themes_index") - * @DemoRestricted(redirectRoute="admin_themes_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function uploadLogosAction(Request $request) - { - $logosUploadForm = $this->getLogosUploadForm(); - $logosUploadForm->handleRequest($request); - - if ($logosUploadForm->isSubmitted()) { - $data = $logosUploadForm->getData(); - try { - $this->getShopLogosFormHandler()->save($data['shop_logos']); - - $this->addFlash( - 'success', - $this->trans('The settings have been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (DomainException $e) { - $this->addFlash( - 'error', - $this->getErrorMessageForException( - $e, - $this->getLogoUploadErrorMessages($e) - ) - ); - } - } - - return $this->redirectToRoute('admin_themes_index'); - } - - /** - * Export current theme. - * - * @AdminSecurity( - * "is_granted('create', request.get('_legacy_controller'))", - * redirectRoute="admin_themes_index", - * message="You do not have permission to view this." - * ) - * @DemoRestricted(redirectRoute="admin_themes_index") - * - * @return RedirectResponse - */ - public function exportAction() - { - $themeProvider = $this->get('prestashop.core.addon.theme.theme_provider'); - $exporter = $this->get('prestashop.core.addon.theme.exporter'); - - $path = $exporter->export($themeProvider->getCurrentlyUsedTheme()); - - $this->addFlash( - 'success', - $this->trans( - 'Your theme has been correctly exported: %path%', - 'Admin.Notifications.Success', - ['%path%' => $path] - ) - ); - - return $this->redirectToRoute('admin_themes_index'); - } - - /** - * Import new theme. - * - * @AdminSecurity( - * "is_granted('create', request.get('_legacy_controller'))", - * redirectRoute="admin_themes_index", - * message="You do not have permission to add this." - * ) - * @DemoRestricted(redirectRoute="admin_themes_index") - * - * @param Request $request - * - * @return Response - */ - public function importAction(Request $request) - { - $importThemeForm = $this->createForm(ImportThemeType::class); - $importThemeForm->handleRequest($request); - - if ($importThemeForm->isSubmitted() && $importThemeForm->isValid()) { - $data = $importThemeForm->getData(); - $importSource = null; - - try { - if ($data['import_from_computer']) { - $importSource = ThemeImportSource::fromArchive($data['import_from_computer']); - } elseif ($data['import_from_web']) { - $importSource = ThemeImportSource::fromWeb($data['import_from_web']); - } elseif ($data['import_from_ftp']) { - $importSource = ThemeImportSource::fromFtp($data['import_from_ftp']); - } - - if (null === $importSource) { - $this->addFlash( - 'warning', - $this->trans('Please select theme\'s import source.', 'Admin.Notifications.Warning') - ); - - return $this->redirectToRoute('admin_themes_import'); - } - - $this->getCommandBus()->handle(new ImportThemeCommand($importSource)); - - return $this->redirectToRoute('admin_themes_index'); - } catch (ThemeException $e) { - $this->addFlash( - 'error', - $this->getErrorMessageForException( - $e, - $this->handleImportThemeException($e) - ) - ); - - return $this->redirectToRoute('admin_themes_import'); - } - } - - return $this->render('@PrestaShop/Admin/Improve/Design/Theme/import.html.twig', [ - 'importThemeForm' => $importThemeForm->createView(), - ]); - } - - /** - * Enable selected theme. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_themes_index", - * message="You do not have permission to edit this." - * ) - * @DemoRestricted(redirectRoute="admin_themes_index") - * - * @param string $themeName - * - * @return RedirectResponse - */ - public function enableAction($themeName) - { - try { - $this->getCommandBus()->handle(new EnableThemeCommand(new ThemeName($themeName))); - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - } catch (ThemeException $e) { - $this->addFlash( - 'error', - $this->getErrorMessageForException( - $e, - $this->handleEnableThemeException($e) - ) - ); - - return $this->redirectToRoute('admin_themes_index'); - } - - return $this->redirectToRoute('admin_themes_index'); - } - - /** - * Delete selected theme. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_themes_index", - * message="You do not have permission to delete this." - * ) - * @DemoRestricted(redirectRoute="admin_themes_index") - * - * @param string $themeName - * - * @return RedirectResponse - */ - public function deleteAction($themeName) - { - try { - $this->getCommandBus()->handle(new DeleteThemeCommand(new ThemeName($themeName))); - - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (ThemeException $e) { - $this->addFlash('error', $this->handleDeleteThemeException($e)); - - return $this->redirectToRoute('admin_themes_index'); - } - - return $this->redirectToRoute('admin_themes_index'); - } - - /** - * Adapts selected theme to RTL languages. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_themes_index", - * message="You do not have permission to edit this." - * ) - * @DemoRestricted(redirectRoute="admin_themes_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function adaptToRTLLanguagesAction(Request $request) - { - $form = $this->getAdaptThemeToRtlLanguageForm(); - $form->handleRequest($request); - - if (!$form->isSubmitted()) { - return $this->redirectToRoute('admin_themes_index'); - } - - $data = $form->getData(); - - if (!$data['generate_rtl_css']) { - return $this->redirectToRoute('admin_themes_index'); - } - - try { - $this->getCommandBus()->handle(new AdaptThemeToRTLLanguagesCommand( - new ThemeName($data['theme_to_adapt']) - )); - - $this->addFlash( - 'success', - $this->trans('Your RTL stylesheets has been generated successfully', 'Admin.Design.Notification') - ); - } catch (ThemeException $e) { - $this->addFlash('error', $this->handleAdaptThemeToRTLLanguagesException($e)); - } - - return $this->redirectToRoute('admin_themes_index'); - } - - /** - * Reset theme's page layouts. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_themes_index", - * message="You do not have permission to edit this." - * ) - * @DemoRestricted(redirectRoute="admin_themes_index") - * - * @param string $themeName - * - * @return RedirectResponse - */ - public function resetLayoutsAction($themeName) - { - $this->getCommandBus()->handle(new ResetThemeLayoutsCommand(new ThemeName($themeName))); - - $this->addFlash('success', $this->trans( - 'Your theme has been correctly reset to its default settings. You may want to regenerate your images. See the Improve > Design > Images Settings screen for the \'%regenerate_label%\' button.', - 'Admin.Design.Notification', - [ - '%regenerate_label%' => $this->trans('Regenerate thumbnails', 'Admin.Design.Feature'), - ] - )); - - return $this->redirectToRoute('admin_themes_index'); - } - - /** - * Show Front Office theme's pages layout customization. - * - * @param Request $request - * - * @return Response - */ - public function customizeLayoutsAction(Request $request) - { - $canCustomizeLayout = $this->canCustomizePageLayouts($request); - - if (!$canCustomizeLayout) { - $this->addFlash( - 'error', - $this->trans('You do not have permission to edit this.', 'Admin.Notifications.Error') - ); - } - - /** @var LayoutCustomizationPage[] $pages */ - $pages = $this->getQueryBus()->handle(new GetPagesForLayoutCustomization()); - - $pageLayoutCustomizationFormFactory = - $this->get('prestashop.bundle.form.admin.improve.design.theme.page_layout_customization_form_factory'); - $pageLayoutCustomizationForm = $pageLayoutCustomizationFormFactory->create($pages); - $pageLayoutCustomizationForm->handleRequest($request); - - if ($canCustomizeLayout && $pageLayoutCustomizationForm->isSubmitted()) { - if ($this->isDemoModeEnabled()) { - $this->addFlash('error', $this->getDemoModeErrorMessage()); - - return $this->redirectToRoute('admin_theme_customize_layouts'); - } - - $themePageLayoutsCustomizer = $this->get('prestashop.core.addon.theme.theme.page_layouts_customizer'); - $themePageLayoutsCustomizer->customize($pageLayoutCustomizationForm->getData()['layouts']); - - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_themes_index'); - } - - return $this->render('@PrestaShop/Admin/Improve/Design/Theme/customize_page_layouts.html.twig', [ - 'pageLayoutCustomizationForm' => $pageLayoutCustomizationForm->createView(), - 'pages' => $pages, - ]); - } - - /** - * @param Request $request - * - * @return bool - */ - protected function canCustomizePageLayouts(Request $request) - { - return !$this->isDemoModeEnabled() && - $this->isGranted(PageVoter::UPDATE, $request->attributes->get('_legacy_controller')); - } - - /** - * @return FormInterface - * - * @throws Exception - */ - protected function getLogosUploadForm() - { - return $this->getShopLogosFormHandler()->getForm(); - } - - /** - * @return FormInterface - */ - protected function getAdaptThemeToRtlLanguageForm() - { - return $this->createForm(AdaptThemeToRTLLanguagesType::class); - } - - /** - * @return FormHandlerInterface - */ - private function getShopLogosFormHandler() - { - return $this->get('prestashop.admin.shop_logos_settings.form_handler'); - } - - /** - * @param Exception $e - * - * @return array - */ - private function handleImportThemeException(Exception $e) - { - return [ - ImportedThemeAlreadyExistsException::class => $this->trans( - 'There is already a theme %theme_name% in your themes folder. Remove it if you want to continue.', - 'Admin.Design.Notification', - [ - '%theme_name%' => $e instanceof ImportedThemeAlreadyExistsException ? $e->getThemeName()->getValue() : '', - ] - ), - ]; - } - - /** - * @param ThemeException $e - * - * @return array - */ - private function handleEnableThemeException(ThemeException $e) - { - return [ - CannotEnableThemeException::class => $e->getMessage(), - ThemeConstraintException::class => [ - ThemeConstraintException::RESTRICTED_ONLY_FOR_SINGLE_SHOP => $this->trans( - 'You must select a shop from the above list if you wish to choose a theme.', - 'Admin.Design.Help' - ), - ], - FailedToEnableThemeModuleException::class => $this->trans( - 'Cannot %action% module %module%. %error_details%', - 'Admin.Modules.Notification', - [ - '%action%' => strtolower($this->trans('Install', 'Admin.Actions')), - '%module%' => ($e instanceof FailedToEnableThemeModuleException) ? $e->getModuleName() : '', - '%error_details%' => $e->getMessage(), - ] - ), - ]; - } - - /** - * @param ThemeException $e - * - * @return string - */ - private function handleDeleteThemeException(ThemeException $e) - { - $type = get_class($e); - - $errorMessages = [ - CannotDeleteThemeException::class => $this->trans( - 'Failed to delete theme. Make sure you have permissions and theme is not used.', - 'Admin.Design.Notification' - ), - ]; - - if (isset($errorMessages[$type])) { - return $errorMessages[$type]; - } - - return $this->getFallbackErrorMessage($type, $e->getCode()); - } - - /** - * @param ThemeException $e - * - * @return string - */ - private function handleAdaptThemeToRTLLanguagesException(ThemeException $e) - { - $type = get_class($e); - - $errorMessages = [ - CannotAdaptThemeToRTLLanguagesException::class => $this->trans('Cannot adapt theme to RTL languages.', 'Admin.Design.Notification'), - ]; - - if (isset($errorMessages[$type])) { - return $errorMessages[$type]; - } - - return $this->getFallbackErrorMessage($type, $e->getCode()); - } - - /** - * Gets exception or exception and its code error mapping. - * - * @param DomainException $exception - * - * @return array - */ - private function getLogoUploadErrorMessages(DomainException $exception) - { - $availableLogoFormatsImploded = implode(', .', ShopLogoSettings::AVAILABLE_LOGO_IMAGE_EXTENSIONS); - $availableIconFormat = ShopLogoSettings::AVAILABLE_ICON_IMAGE_EXTENSION; - - $logoImageFormatError = $this->trans( - 'Image format not recognized, allowed format(s) is(are): .%s', - 'Admin.Notifications.Error', - [$availableLogoFormatsImploded] - ); - - $iconFormatError = $this->trans( - 'Image format not recognized, allowed format(s) is(are): .%s', - 'Admin.Notifications.Error', - [$availableIconFormat] - ); - - return [ - NotSupportedLogoImageExtensionException::class => $logoImageFormatError, - NotSupportedFaviconExtensionException::class => $iconFormatError, - FileUploadException::class => [ - UPLOAD_ERR_INI_SIZE => $this->trans( - 'File too large (limit of %s bytes).', - 'Admin.Notifications.Error', - [ - UploadedFile::getMaxFilesize(), - ] - ), - ], - ]; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/CurrencyController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/CurrencyController.php deleted file mode 100644 index eac6736d..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/International/CurrencyController.php +++ /dev/null @@ -1,567 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\International; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\DeleteCurrencyCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\RefreshExchangeRatesCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\Command\ToggleCurrencyStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\AutomateExchangeRatesUpdateException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotDeleteDefaultCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotDisableDefaultCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotRefreshExchangeRatesException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CannotToggleCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\CurrencyNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\DefaultCurrencyInMultiShopException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\ExchangeRateNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Exception\InvalidUnofficialCurrencyException; -use PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetCurrencyExchangeRate; -use PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetReferenceCurrency; -use PrestaShop\PrestaShop\Core\Domain\Currency\QueryResult\ExchangeRate as ExchangeRateResult; -use PrestaShop\PrestaShop\Core\Domain\Currency\QueryResult\ReferenceCurrency; -use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\ExchangeRate; -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilderInterface; -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandlerInterface; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CurrencyGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Language\LanguageInterface; -use PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision; -use PrestaShop\PrestaShop\Core\Localization\CLDR\Currency; -use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleRepository as CldrLocaleRepository; -use PrestaShop\PrestaShop\Core\Localization\Currency\PatternTransformer; -use PrestaShop\PrestaShop\Core\Localization\Locale\Repository as LocaleRepository; -use PrestaShop\PrestaShop\Core\Search\Filters\CurrencyFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Entity\Repository\LangRepository; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use PrestaShopBundle\Security\Voter\PageVoter; -use PrestaShopBundle\Service\Grid\ResponseBuilder; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class CurrencyController is responsible for handling "Improve -> International -> Localization -> Currencies" page. - */ -class CurrencyController extends FrameworkBundleAdminController -{ - /** - * Show currency page. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param CurrencyFilters $filters - * @param Request $request - * - * @return Response - */ - public function indexAction(CurrencyFilters $filters, Request $request) - { - $currencyGridFactory = $this->get('prestashop.core.grid.factory.currency'); - $currencyGrid = $currencyGridFactory->getGrid($filters); - - $settingsForm = $this->getSettingsFormHandler()->getForm(); - - return $this->render('@PrestaShop/Admin/Improve/International/Currency/index.html.twig', [ - 'currencyGrid' => $this->presentGrid($currencyGrid), - 'currencySettingsForm' => $settingsForm->createView(), - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - ]); - } - - /** - * Provides filters functionality. - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function searchAction(Request $request) - { - /** @var ResponseBuilder $responseBuilder */ - $responseBuilder = $this->get('prestashop.bundle.grid.response_builder'); - - return $responseBuilder->buildSearchResponse( - $this->get('prestashop.core.grid.definition.factory.currency'), - $request, - CurrencyGridDefinitionFactory::GRID_ID, - 'admin_currencies_index' - ); - } - - /** - * Displays and handles currency form. - * - * @AdminSecurity( - * "is_granted('create', request.get('_legacy_controller'))", - * redirectRoute="admin_currencies_index", - * message="You need permission to create this." - * ) - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request) - { - $multiStoreFeature = $this->get('prestashop.adapter.multistore_feature'); - - $currencyForm = $this->getCurrencyFormBuilder()->getForm(); - $currencyForm->handleRequest($request); - - try { - $result = $this->getCurrencyFormHandler()->handle($currencyForm); - if (null !== $result->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_currencies_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->render('@PrestaShop/Admin/Improve/International/Currency/create.html.twig', [ - 'isShopFeatureEnabled' => $multiStoreFeature->isUsed(), - 'currencyForm' => $currencyForm->createView(), - ]); - } - - /** - * Displays currency form. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_currencies_index", - * message="You need permission to edit this." - * ) - * - * @param int $currencyId - * @param Request $request - * - * @return Response - */ - public function editAction($currencyId, Request $request) - { - $multiStoreFeature = $this->get('prestashop.adapter.multistore_feature'); - $currencyForm = $this->getCurrencyFormBuilder()->getFormFor($currencyId); - - try { - $currencyForm->handleRequest($request); - - $result = $this->getCurrencyFormHandler()->handleFor($currencyId, $currencyForm); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_currencies_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->render('@PrestaShop/Admin/Improve/International/Currency/edit.html.twig', [ - 'isShopFeatureEnabled' => $multiStoreFeature->isUsed(), - 'currencyForm' => null !== $currencyForm ? $currencyForm->createView() : null, - 'languages' => $this->getLanguagesData($currencyForm->getData()['iso_code']), - ]); - } - - /** - * @param string $currencyIsoCode - * - * @return array - */ - private function getLanguagesData(string $currencyIsoCode) - { - /** @var LangRepository $langRepository */ - $langRepository = $this->get('prestashop.core.admin.lang.repository'); - $languages = $langRepository->findAll(); - /** @var LocaleRepository $localeRepository */ - $localeRepository = $this->get('prestashop.core.localization.locale.repository'); - /** @var CldrLocaleRepository $cldrLocaleRepository */ - $cldrLocaleRepository = $this->get('prestashop.core.localization.cldr.locale_repository'); - - $languagesData = []; - /** @var LanguageInterface $language */ - foreach ($languages as $language) { - $locale = $localeRepository->getLocale($language->getLocale()); - $cldrLocale = $cldrLocaleRepository->getLocale($language->getLocale()); - $cldrCurrency = $cldrLocale->getCurrency($currencyIsoCode); - $priceSpecification = $locale->getPriceSpecification($currencyIsoCode); - - $transformer = new PatternTransformer(); - $transformations = []; - foreach (PatternTransformer::ALLOWED_TRANSFORMATIONS as $transformationType) { - $transformations[$transformationType] = $transformer->transform( - $cldrLocale->getCurrencyPattern(), - $transformationType - ); - } - - $languagesData[] = [ - 'id' => $language->getId(), - 'name' => $language->getName(), - 'currencyPattern' => $cldrLocale->getCurrencyPattern(), - 'currencySymbol' => null !== $cldrCurrency ? $cldrCurrency->getSymbol() : $currencyIsoCode, - 'priceSpecification' => $priceSpecification->toArray(), - 'transformations' => $transformations, - ]; - } - - return $languagesData; - } - - /** - * Deletes currency. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_currencies_index", - * message="You need permission to delete this." - * ) - * @DemoRestricted(redirectRoute="admin_currencies_index") - * - * @param int $currencyId - * - * @return RedirectResponse - */ - public function deleteAction($currencyId) - { - try { - $this->getCommandBus()->handle(new DeleteCurrencyCommand((int) $currencyId)); - } catch (CurrencyException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - - return $this->redirectToRoute('admin_currencies_index'); - } - - $this->addFlash('success', $this->trans('Successful deletion.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_currencies_index'); - } - - /** - * Get the data for a currency (from CLDR) - * - * @param string $currencyIsoCode - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * @DemoRestricted(redirectRoute="admin_currencies_index") - * - * @return JsonResponse - */ - public function getReferenceDataAction($currencyIsoCode) - { - try { - /** @var ReferenceCurrency $referenceCurrency */ - $referenceCurrency = $this->getQueryBus()->handle(new GetReferenceCurrency($currencyIsoCode)); - } catch (CurrencyException $e) { - return new JsonResponse([ - 'error' => $this->trans( - 'Cannot find reference data for currency %isoCode%', - 'Admin.International.Feature', - [ - '%isoCode%' => $currencyIsoCode, - ] - ), - ], 404); - } - - try { - /** @var ExchangeRateResult $exchangeRate */ - $exchangeRate = $this->getQueryBus()->handle(new GetCurrencyExchangeRate($currencyIsoCode)); - $computingPrecision = new ComputingPrecision(); - $exchangeRateValue = $exchangeRate->getValue()->round($computingPrecision->getPrecision(2)); - } catch (ExchangeRateNotFoundException $e) { - $exchangeRateValue = ExchangeRate::DEFAULT_RATE; - } - - return new JsonResponse([ - 'isoCode' => $referenceCurrency->getIsoCode(), - 'numericIsoCode' => $referenceCurrency->getNumericIsoCode(), - 'precision' => $referenceCurrency->getPrecision(), - 'names' => $referenceCurrency->getNames(), - 'symbols' => $referenceCurrency->getSymbols(), - 'patterns' => $referenceCurrency->getPatterns(), - 'exchangeRate' => $exchangeRateValue, - ]); - } - - /** - * Toggles status. - * - * @param int $currencyId - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_currencies_index", - * message="You need permission to edit this." - * ) - * @DemoRestricted(redirectRoute="admin_currencies_index") - * - * @return RedirectResponse - */ - public function toggleStatusAction($currencyId) - { - try { - $this->getCommandBus()->handle(new ToggleCurrencyStatusCommand((int) $currencyId)); - } catch (CurrencyException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - - return $this->redirectToRoute('admin_currencies_index'); - } - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - - return $this->redirectToRoute('admin_currencies_index'); - } - - /** - * Refresh exchange rates. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_currencies_index", - * message="You need permission to edit this." - * ) - * @DemoRestricted(redirectRoute="admin_currencies_index") - * - * @return RedirectResponse - */ - public function refreshExchangeRatesAction() - { - try { - $this->getCommandBus()->handle(new RefreshExchangeRatesCommand()); - - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - } catch (CannotRefreshExchangeRatesException $exception) { - $this->addFlash('error', $exception->getMessage()); - } - - return $this->redirectToRoute('admin_currencies_index'); - } - - /** - * Handles ajax request which updates live exchange rates. - * - * @param Request $request - * - * @return JsonResponse - */ - public function updateLiveExchangeRatesAction(Request $request) - { - if ($this->isDemoModeEnabled()) { - return $this->json([ - 'status' => false, - 'message' => $this->getDemoModeErrorMessage(), - ], - Response::HTTP_UNAUTHORIZED - ); - } - - $authLevel = $this->authorizationLevel($request->attributes->get('_legacy_controller')); - - if (!in_array($authLevel, [PageVoter::LEVEL_UPDATE, PageVoter::LEVEL_DELETE])) { - return $this->json([ - 'status' => false, - 'message' => $this->trans( - 'You need permission to edit this.', - 'Admin.Notifications.Error' - ), - ], - Response::HTTP_UNAUTHORIZED - ); - } - - $settingsFormHandler = $this->getSettingsFormHandler(); - $settingsForm = $settingsFormHandler->getForm(); - - $settingsForm->handleRequest($request); - - $response = [ - 'status' => false, - 'message' => $this->trans('Unexpected error occurred.', 'Admin.Notifications.Error'), - ]; - $statusCode = Response::HTTP_BAD_REQUEST; - - if ($settingsForm->isSubmitted()) { - try { - $settingsFormHandler->save($settingsForm->getData()); - $response = [ - 'status' => true, - 'message' => $this->trans( - 'The status has been successfully updated.', - 'Admin.Notifications.Success' - ), - ]; - $statusCode = Response::HTTP_OK; - } catch (CurrencyException $e) { - $response['message'] = $this->getErrorMessageForException($e, $this->getErrorMessages($e)); - } - } - - return $this->json($response, $statusCode); - } - - /** - * Gets form builder. - * - * @return FormBuilderInterface - */ - private function getCurrencyFormBuilder() - { - return $this->get('prestashop.core.form.builder.currency_form_builder'); - } - - /** - * @return FormHandlerInterface - */ - private function getCurrencyFormHandler() - { - return $this->get('prestashop.core.form.identifiable_object.currency_form_handler'); - } - - /** - * @return \PrestaShop\PrestaShop\Core\Form\FormHandlerInterface - */ - private function getSettingsFormHandler() - { - return $this->get('prestashop.admin.currency_settings.form_handler'); - } - - /** - * Gets an error by exception class and its code. - * - * @param Exception $e - * - * @return array - */ - private function getErrorMessages(Exception $e) - { - $isoCode = $e instanceof InvalidUnofficialCurrencyException ? $e->getIsoCode() : ''; - - return [ - CurrencyConstraintException::class => [ - CurrencyConstraintException::INVALID_ISO_CODE => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf('"%s"', $this->trans('ISO code', 'Admin.International.Feature')), - ] - ), - CurrencyConstraintException::INVALID_NUMERIC_ISO_CODE => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf('"%s"', $this->trans('Numeric ISO code', 'Admin.International.Feature')), - ] - ), - CurrencyConstraintException::INVALID_EXCHANGE_RATE => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf('"%s"', $this->trans('Exchange rate', 'Admin.International.Feature')), - ] - ), - CurrencyConstraintException::INVALID_NAME => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf('"%s"', $this->trans('Currency name', 'Admin.International.Feature')), - ] - ), - CurrencyConstraintException::CURRENCY_ALREADY_EXISTS => $this->trans( - 'This currency already exists.', - 'Admin.International.Notification' - ), - ], - AutomateExchangeRatesUpdateException::class => [ - AutomateExchangeRatesUpdateException::CRON_TASK_MANAGER_MODULE_NOT_INSTALLED => $this->trans( - 'Please install the %module_name% module before using this feature.', - 'Admin.International.Notification', - [ - '%module_name%' => 'cronjobs', - ] - ), - ], - DefaultCurrencyInMultiShopException::class => [ - DefaultCurrencyInMultiShopException::CANNOT_REMOVE_CURRENCY => $this->trans( - '%currency% is the default currency for shop %shop_name%, and therefore cannot be removed from shop association', - 'Admin.International.Notification', - [ - '%currency%' => $e instanceof DefaultCurrencyInMultiShopException ? $e->getCurrencyName() : '', - '%shop_name%' => $e instanceof DefaultCurrencyInMultiShopException ? $e->getShopName() : '', - ] - ), - DefaultCurrencyInMultiShopException::CANNOT_DISABLE_CURRENCY => $this->trans( - '%currency% is the default currency for shop %shop_name%, and therefore cannot be disabled', - 'Admin.International.Notification', - [ - '%currency%' => $e instanceof DefaultCurrencyInMultiShopException ? $e->getCurrencyName() : '', - '%shop_name%' => $e instanceof DefaultCurrencyInMultiShopException ? $e->getShopName() : '', - ] - ), - ], - CurrencyNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - CannotToggleCurrencyException::class => $this->trans( - 'An error occurred while updating the status.', - 'Admin.Notifications.Error' - ), - CannotDeleteDefaultCurrencyException::class => $this->trans( - 'You cannot delete the default currency', - 'Admin.International.Notification' - ), - CannotDisableDefaultCurrencyException::class => $this->trans( - 'You cannot disable the default currency', - 'Admin.International.Notification' - ), - InvalidUnofficialCurrencyException::class => $this->trans( - 'Oops... it looks like this ISO code already exists. If you are: [1][2]trying to create an alternative currency, you must type a different ISO code[/2][2]trying to modify the currency with ISO code %isoCode%, make sure you did not check the creation box[/2][/1]', - 'Admin.International.Notification', - [ - '%isoCode%' => $isoCode, - '[1]' => '
      ', - '[/1]' => '
    ', - '[2]' => '
  • ', - '[/2]' => '
  • ', - ] - ), - ]; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/GeolocationController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/GeolocationController.php deleted file mode 100644 index c5f2b7f5..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/International/GeolocationController.php +++ /dev/null @@ -1,110 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\International; - -use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class GeolocationController is responsible for "Improve > International > Localization > Geolocation" page. - */ -class GeolocationController extends FrameworkBundleAdminController -{ - /** - * Show geolocation page. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message="Access denied.") - * - * @param Request $request - * - * @return Response - */ - public function indexAction(Request $request) - { - $legacyController = $request->attributes->get('_legacy_controller'); - - $geolocationForm = $this->getGeolocationFormHandler()->getForm(); - $geoLiteCityChecker = $this->get('prestashop.core.geolocation.geo_lite_city.checker'); - - return $this->render('@PrestaShop/Admin/Improve/International/Geolocation/index.html.twig', [ - 'layoutTitle' => $this->trans('Geolocation', 'Admin.Navigation.Menu'), - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($legacyController), - 'geolocationForm' => $geolocationForm->createView(), - 'geolocationDatabaseAvailable' => $geoLiteCityChecker->isAvailable(), - ]); - } - - /** - * Process geolocation configuration form. - * - * @AdminSecurity( - * "is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", - * message="You do not have permission to edit this.", - * redirectRoute="admin_geolocation" - * ) - * @DemoRestricted(redirectRoute="admin_geolocation_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function saveOptionsAction(Request $request) - { - $geolocationFormHandler = $this->getGeolocationFormHandler(); - - $geolocationForm = $geolocationFormHandler->getForm(); - $geolocationForm->handleRequest($request); - - if ($geolocationForm->isSubmitted()) { - $errors = $geolocationFormHandler->save($geolocationForm->getData()); - - if (empty($errors)) { - $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_geolocation_index'); - } - - $this->flashErrors($errors); - } - - return $this->redirectToRoute('admin_geolocation_index'); - } - - /** - * @return FormHandlerInterface - */ - protected function getGeolocationFormHandler() - { - return $this->get('prestashop.admin.geolocation.form_handler'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/LanguageController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/LanguageController.php deleted file mode 100644 index 1086adcd..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/International/LanguageController.php +++ /dev/null @@ -1,399 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\International; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Language\Command\BulkDeleteLanguagesCommand; -use PrestaShop\PrestaShop\Core\Domain\Language\Command\BulkToggleLanguagesStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Language\Command\DeleteLanguageCommand; -use PrestaShop\PrestaShop\Core\Domain\Language\Command\ToggleLanguageStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\CannotDisableDefaultLanguageException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\CopyingNoPictureException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\DefaultLanguageException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageImageUploadingException; -use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Language\Query\GetLanguageForEditing; -use PrestaShop\PrestaShop\Core\Domain\Language\QueryResult\EditableLanguage; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\LanguageGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters\LanguageFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use PrestaShopBundle\Service\Grid\ResponseBuilder; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class LanguageController manages "Improve > International > Localization > Languages". - */ -class LanguageController extends FrameworkBundleAdminController -{ - /** - * Show languages listing page. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * @param LanguageFilters $filters - * - * @return Response - */ - public function indexAction(Request $request, LanguageFilters $filters) - { - $languageGridFactory = $this->get('prestashop.core.grid.factory.language'); - $languageGrid = $languageGridFactory->getGrid($filters); - - return $this->render('@PrestaShop/Admin/Improve/International/Language/index.html.twig', [ - 'languageGrid' => $this->presentGrid($languageGrid), - 'isHtaccessFileWriter' => $this->get('prestashop.core.util.url.url_file_checker')->isHtaccessFileWritable(), - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - ]); - } - - /** - * Process Grid search. - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function searchGridAction(Request $request) - { - /** @var ResponseBuilder $responseBuilder */ - $responseBuilder = $this->get('prestashop.bundle.grid.response_builder'); - - return $responseBuilder->buildSearchResponse( - $this->get('prestashop.core.grid.definition.factory.language'), - $request, - LanguageGridDefinitionFactory::GRID_ID, - 'admin_languages_index' - ); - } - - /** - * Show language creation form page and handle its submit. - * - * @AdminSecurity("is_granted('create', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request) - { - $languageFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.language_form_handler'); - $languageFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.language_form_builder'); - - $languageForm = $languageFormBuilder->getForm(); - $languageForm->handleRequest($request); - - try { - $result = $languageFormHandler->handle($languageForm); - - if (null !== $result->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_languages_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->render('@PrestaShop/Admin/Improve/International/Language/create.html.twig', [ - 'languageForm' => $languageForm->createView(), - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - ]); - } - - /** - * Show language edit form page and handle its submit. - * - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))") - * - * @param int $languageId - * @param Request $request - * - * @return Response - */ - public function editAction($languageId, Request $request) - { - $languageFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.language_form_handler'); - $languageFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.language_form_builder'); - - try { - $languageForm = $languageFormBuilder->getFormFor((int) $languageId, [], [ - 'is_for_editing' => true, - ]); - $languageForm->handleRequest($request); - - $result = $languageFormHandler->handleFor((int) $languageId, $languageForm); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_languages_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - - if ($e instanceof LanguageNotFoundException) { - return $this->redirectToRoute('admin_languages_index'); - } - } - - /** @var EditableLanguage $editableLanguage */ - $editableLanguage = $this->getQueryBus()->handle(new GetLanguageForEditing((int) $languageId)); - - return $this->render('@PrestaShop/Admin/Improve/International/Language/edit.html.twig', [ - 'languageForm' => $languageForm->createView(), - 'editableLanguage' => $editableLanguage, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - ]); - } - - /** - * Deletes language - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", redirectRoute="admin_languages_index") - * @DemoRestricted(redirectRoute="admin_languages_index") - * - * @param int $languageId - * - * @return RedirectResponse - */ - public function deleteAction($languageId) - { - try { - $this->getCommandBus()->handle(new DeleteLanguageCommand((int) $languageId)); - - $this->addFlash('success', $this->trans('Successful deletion.', 'Admin.Notifications.Success')); - } catch (LanguageException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_languages_index'); - } - - /** - * Deletes languages in bulk action - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", redirectRoute="admin_languages_index") - * @DemoRestricted(redirectRoute="admin_languages_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkDeleteAction(Request $request) - { - $languageIds = $this->getBulkLanguagesFromRequest($request); - - try { - $this->getCommandBus()->handle(new BulkDeleteLanguagesCommand($languageIds)); - - $this->addFlash( - 'success', - $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success') - ); - } catch (LanguageException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_languages_index'); - } - - /** - * Toggles language status - * - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute="admin_languages_index") - * @DemoRestricted(redirectRoute="admin_languages_index") - * - * @param int $languageId - * - * @return RedirectResponse - */ - public function toggleStatusAction($languageId) - { - try { - /** @var EditableLanguage $editableLanguage */ - $editableLanguage = $this->getQueryBus()->handle(new GetLanguageForEditing((int) $languageId)); - - $this->getCommandBus()->handle(new ToggleLanguageStatusCommand( - (int) $languageId, - !$editableLanguage->isActive() - )); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (LanguageException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_languages_index'); - } - - /** - * Toggles languages status in bulk action - * - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute="admin_languages_index") - * @DemoRestricted(redirectRoute="admin_languages_index") - * - * @param Request $request - * @param string $status - * - * @return RedirectResponse - */ - public function bulkToggleStatusAction(Request $request, $status) - { - $languageIds = $this->getBulkLanguagesFromRequest($request); - $expectedStatus = 'enable' === $status; - - try { - $this->getCommandBus()->handle(new BulkToggleLanguagesStatusCommand( - $languageIds, - $expectedStatus - )); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (LanguageException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_languages_index'); - } - - /** - * @param Exception $e - * - * @return array - */ - private function getErrorMessages(Exception $e) - { - return [ - LanguageNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - CannotDisableDefaultLanguageException::class => $this->trans( - 'You cannot change the status of the default language.', - 'Admin.International.Notification' - ), - CopyingNoPictureException::class => [ - CopyingNoPictureException::PRODUCT_IMAGE_COPY_ERROR => $this->trans( - 'An error occurred while copying "No Picture" image to your product folder.', - 'Admin.International.Notification' - ), - CopyingNoPictureException::CATEGORY_IMAGE_COPY_ERROR => $this->trans( - 'An error occurred while copying "No picture" image to your category folder.', - 'Admin.International.Notification' - ), - CopyingNoPictureException::BRAND_IMAGE_COPY_ERROR => $this->trans( - 'An error occurred while copying "No picture" image to your brand folder.', - 'Admin.International.Notification' - ), - ], - LanguageImageUploadingException::class => [ - LanguageImageUploadingException::MEMORY_LIMIT_RESTRICTION => $this->trans( - 'Due to memory limit restrictions, this image cannot be loaded. Please increase your memory_limit value via your server\'s configuration settings.', - 'Admin.Notifications.Error' - ), - LanguageImageUploadingException::UNEXPECTED_ERROR => $this->trans( - 'An error occurred while uploading the image.', - 'Admin.Notifications.Error' - ), - ], - LanguageConstraintException::class => [ - LanguageConstraintException::INVALID_ISO_CODE => $this->trans( - 'The %s field is invalid.', - 'Admin.Notifications.Error', - [sprintf('"%s"', $this->trans('ISO code', 'Admin.International.Feature'))] - ), - LanguageConstraintException::INVALID_IETF_TAG => $this->trans( - 'The %s field is invalid.', - 'Admin.Notifications.Error', - [sprintf('"%s"', $this->trans('Language code', 'Admin.International.Feature'))] - ), - LanguageConstraintException::DUPLICATE_ISO_CODE => $this->trans( - 'This ISO code is already linked to another language.', - 'Admin.International.Notification' - ), - LanguageConstraintException::EMPTY_BULK_DELETE => $this->trans( - 'You must select at least one element to delete.', - 'Admin.Notifications.Error' - ), - ], - DefaultLanguageException::class => [ - DefaultLanguageException::CANNOT_DELETE_ERROR => $this->trans( - 'You cannot delete the default language.', - 'Admin.International.Notification' - ), - DefaultLanguageException::CANNOT_DISABLE_ERROR => $this->trans( - 'You cannot change the status of the default language.', - 'Admin.International.Notification' - ), - DefaultLanguageException::CANNOT_DELETE_IN_USE_ERROR => $this->trans( - 'You cannot delete the language currently in use. Please select a different language.', - 'Admin.International.Notification' - ), - ], - ]; - } - - /** - * Get language ids from request for bulk action - * - * @param Request $request - * - * @return int[] - */ - private function getBulkLanguagesFromRequest(Request $request) - { - $languageIds = $request->request->get('language_language_bulk'); - - if (!is_array($languageIds)) { - return []; - } - - foreach ($languageIds as $i => $languageId) { - $languageIds[$i] = (int) $languageId; - } - - return $languageIds; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/LocalizationController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/LocalizationController.php deleted file mode 100644 index 3f0d9664..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/International/LocalizationController.php +++ /dev/null @@ -1,161 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\International; - -use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface; -use PrestaShop\PrestaShop\Core\Localization\Pack\Import\LocalizationPackImportConfig; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Form\Admin\Improve\International\Localization\ImportLocalizationPackType; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class LocalizationController is responsible for handling "Improve > International > Localization" page. - */ -class LocalizationController extends FrameworkBundleAdminController -{ - /** - * Show localization settings page. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message="Access denied.") - * - * @param Request $request - * - * @return Response - */ - public function indexAction(Request $request) - { - $legacyController = $request->attributes->get('_legacy_controller'); - - if (!extension_loaded('openssl')) { - $this->addFlash('warning', $this->trans('Importing a new language may fail without the OpenSSL module. Please enable "openssl.so" on your server configuration.', 'Admin.International.Notification')); - } - - $localizationPackImportForm = $this->createForm(ImportLocalizationPackType::class); - $localizationForm = $this->getLocalizationFormHandler()->getForm(); - - return $this->render('@PrestaShop/Admin/Improve/International/Localization/index.html.twig', [ - 'layoutHeaderToolbarBtn' => [], - 'layoutTitle' => $this->trans('Localization', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($legacyController), - 'localizationForm' => $localizationForm->createView(), - 'localizationPackImportForm' => $localizationPackImportForm->createView(), - ]); - } - - /** - * Save localization settings. - * - * @AdminSecurity("is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", message="You do not have permission to edit this.") - * @DemoRestricted(redirectRoute="admin_localization_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function saveOptionsAction(Request $request) - { - $localizationFormHandler = $this->getLocalizationFormHandler(); - - $localizationForm = $localizationFormHandler->getForm(); - $localizationForm->handleRequest($request); - - if ($localizationForm->isSubmitted()) { - $data = $localizationForm->getData(); - - $errors = $localizationFormHandler->save($data); - if (empty($errors)) { - $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_localization_index'); - } - - $this->flashErrors($errors); - } - - return $this->redirectToRoute('admin_localization_index'); - } - - /** - * Handles localization pack import. - * - * @AdminSecurity("is_granted(['update', 'create','delete'], request.get('_legacy_controller'))", message="You do not have permission to edit this.") - * @DemoRestricted(redirectRoute="admin_localization_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function importPackAction(Request $request) - { - $localizationPackImportForm = $this->createForm(ImportLocalizationPackType::class); - $localizationPackImportForm->handleRequest($request); - - if ($localizationPackImportForm->isSubmitted()) { - $data = $localizationPackImportForm->getData(); - - $localizationImportConfig = new LocalizationPackImportConfig( - $data['iso_localization_pack'], - $data['content_to_import'], - $data['download_pack_data'] - ); - - $localizationPackImporter = $this->get('prestashop.core.localization.pack.import.importer'); - $errors = $localizationPackImporter->import($localizationImportConfig); - - if (empty($errors)) { - $this->addFlash( - 'success', - $this->trans('Localization pack imported successfully.', 'Admin.International.Notification') - ); - - return $this->redirectToRoute('admin_localization_index'); - } - - foreach ($errors as $error) { - $this->addFlash('error', $error); - } - } - - return $this->redirectToRoute('admin_localization_index'); - } - - /** - * Returns localization settings form handler. - * - * @return FormHandlerInterface - */ - private function getLocalizationFormHandler() - { - return $this->get('prestashop.admin.localization.form_handler'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/StateController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/StateController.php deleted file mode 100644 index cecc1935..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/International/StateController.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\International; - -use Exception; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible for handling country states data - */ -class StateController extends FrameworkBundleAdminController -{ - /** - * Provides country states in json response - * - * @param Request $request - * - * @return JsonResponse - */ - public function getStatesAction(Request $request) - { - try { - $countryId = (int) $request->query->get('id_country'); - $statesProvider = $this->get('prestashop.adapter.form.choice_provider.country_state_by_id'); - $states = $statesProvider->getChoices([ - 'id_country' => $countryId, - ]); - - return $this->json([ - 'states' => $states, - ]); - } catch (Exception $e) { - return $this->json([ - 'message' => $this->getErrorMessageForException($e, []), - ], - Response::HTTP_INTERNAL_SERVER_ERROR - ); - } - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/TaxController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/TaxController.php deleted file mode 100644 index d471c45a..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/International/TaxController.php +++ /dev/null @@ -1,414 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\International; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\BulkDeleteTaxCommand; -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\BulkToggleTaxStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\DeleteTaxCommand; -use PrestaShop\PrestaShop\Core\Domain\Tax\Command\ToggleTaxStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\DeleteTaxException; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxException; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\TaxNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\UpdateTaxException; -use PrestaShop\PrestaShop\Core\Domain\Tax\Query\GetTaxForEditing; -use PrestaShop\PrestaShop\Core\Domain\Tax\QueryResult\EditableTax; -use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface; -use PrestaShop\PrestaShop\Core\Search\Filters\TaxFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible for handling "Improve > International > Taxes" page. - */ -class TaxController extends FrameworkBundleAdminController -{ - /** - * Show taxes page. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * @param TaxFilters $filters - * - * @return Response - */ - public function indexAction(Request $request, TaxFilters $filters) - { - $legacyController = $request->attributes->get('_legacy_controller'); - - $taxGridFactory = $this->get('prestashop.core.grid.factory.tax'); - $taxGrid = $taxGridFactory->getGrid($filters); - $gridPresenter = $this->get('prestashop.core.grid.presenter.grid_presenter'); - $taxOptionsForm = $this->getTaxOptionsFormHandler()->getForm(); - - return $this->render('@PrestaShop/Admin/Improve/International/Tax/index.html.twig', [ - 'taxGrid' => $gridPresenter->present($taxGrid), - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($legacyController), - 'taxOptionsForm' => $taxOptionsForm->createView(), - ]); - } - - /** - * Process tax options configuration form. - * - * @AdminSecurity( - * "is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", - * redirectRoute="admin_taxes_index" - * ) - * @DemoRestricted(redirectRoute="admin_taxes_index") - * - * @param Request $request - * - * @return \Symfony\Component\HttpFoundation\RedirectResponse - */ - public function saveOptionsAction(Request $request) - { - $taxOptionsFormHandler = $this->getTaxOptionsFormHandler(); - - $taxOptionsForm = $taxOptionsFormHandler->getForm(); - $taxOptionsForm->handleRequest($request); - - if ($taxOptionsForm->isSubmitted()) { - $errors = $taxOptionsFormHandler->save($taxOptionsForm->getData()); - - if (empty($errors)) { - $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_taxes_index'); - } - - $this->flashErrors($errors); - } - - return $this->redirectToRoute('admin_taxes_index'); - } - - /** - * Provides filters functionality. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function searchAction(Request $request) - { - $definitionFactory = $this->get('prestashop.core.grid.definition.factory.tax'); - $definitionFactory = $definitionFactory->getDefinition(); - - $gridFilterFormFactory = $this->get('prestashop.core.grid.filter.form_factory'); - $searchParametersForm = $gridFilterFormFactory->create($definitionFactory); - $searchParametersForm->handleRequest($request); - - $filters = []; - if ($searchParametersForm->isSubmitted()) { - $filters = $searchParametersForm->getData(); - } - - return $this->redirectToRoute('admin_taxes_index', ['filters' => $filters]); - } - - /** - * @AdminSecurity( - * "is_granted('create', request.get('_legacy_controller'))", - * redirectRoute="admin_taxes_index", - * ) - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request) - { - $taxFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.tax_form_handler'); - $taxFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.tax_form_builder'); - - try { - $taxForm = $taxFormBuilder->getForm(); - $taxForm->handleRequest($request); - $result = $taxFormHandler->handle($taxForm); - if (null !== $result->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_taxes_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->render('@PrestaShop/Admin/Improve/International/Tax/create.html.twig', [ - 'taxForm' => $taxForm->createView(), - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - ]); - } - - /** - * Handles tax edit - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_taxes_index", - * ) - * - * @param Request $request - * @param int $taxId - * - * @return Response - */ - public function editAction(Request $request, $taxId) - { - $taxFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.tax_form_handler'); - $taxFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.tax_form_builder'); - - try { - $taxForm = $taxFormBuilder->getFormFor((int) $taxId); - $taxForm->handleRequest($request); - $result = $taxFormHandler->handleFor((int) $taxId, $taxForm); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_taxes_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - - if ($e instanceof TaxNotFoundException) { - return $this->redirectToRoute('admin_taxes_index'); - } - } - - /** @var EditableTax $editableTax */ - $editableTax = $this->getQueryBus()->handle(new GetTaxForEditing((int) $taxId)); - - return $this->render('@PrestaShop/Admin/Improve/International/Tax/edit.html.twig', [ - 'taxForm' => $taxForm->createView(), - 'taxName' => $editableTax->getLocalizedNames()[$this->getContextLangId()], - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - ]); - } - - /** - * Deletes tax. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_taxes_index", - * ) - * @DemoRestricted(redirectRoute="admin_taxes_index") - * - * @param int $taxId - * - * @return RedirectResponse - */ - public function deleteAction($taxId) - { - try { - $this->getCommandBus()->handle(new DeleteTaxCommand((int) $taxId)); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (TaxException $e) { - } - - return $this->redirectToRoute('admin_taxes_index'); - } - - /** - * Toggles status. - * - * @param int $taxId - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_taxes_index", - * ) - * @DemoRestricted(redirectRoute="admin_taxes_index") - * - * @return RedirectResponse - */ - public function toggleStatusAction($taxId) - { - try { - /** @var EditableTax $editableTax */ - $editableTax = $this->getQueryBus()->handle(new GetTaxForEditing((int) $taxId)); - $this->getCommandBus()->handle(new ToggleTaxStatusCommand((int) $taxId, !$editableTax->isActive())); - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (TaxException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_taxes_index'); - } - - /** - * Enables taxes status on bulk action. - * - * @param Request $request - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_taxes_index", - * ) - * @DemoRestricted(redirectRoute="admin_taxes_index") - * - * @return RedirectResponse - */ - public function bulkEnableStatusAction(Request $request) - { - $taxIds = $request->request->get('tax_bulk'); - try { - $this->getCommandBus()->handle(new BulkToggleTaxStatusCommand($taxIds, true)); - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (TaxException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_taxes_index'); - } - - /** - * Disables taxes status on bulk action. - * - * @param Request $request - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_taxes_index", - * ) - * @DemoRestricted(redirectRoute="admin_taxes_index") - * - * @return RedirectResponse - */ - public function bulkDisableStatusAction(Request $request) - { - $taxIds = $request->request->get('tax_bulk'); - try { - $this->getCommandBus()->handle(new BulkToggleTaxStatusCommand($taxIds, false)); - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (TaxException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_taxes_index'); - } - - /** - * Delete taxes on bulk action. - * - * @param Request $request - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_taxes_index", - * ) - * @DemoRestricted(redirectRoute="admin_taxes_index") - * - * @return RedirectResponse - */ - public function bulkDeleteAction(Request $request) - { - $taxIds = $request->request->get('tax_bulk'); - try { - $this->getCommandBus()->handle(new BulkDeleteTaxCommand($taxIds)); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (TaxException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_taxes_index'); - } - - /** - * @return FormHandlerInterface - */ - private function getTaxOptionsFormHandler() - { - return $this->get('prestashop.admin.tax_options.form_handler'); - } - - /** - * Gets error messages for exceptions - * - * @return array - */ - private function getErrorMessages() - { - return [ - TaxNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - UpdateTaxException::class => [ - UpdateTaxException::FAILED_BULK_UPDATE_STATUS => [ - $this->trans( - 'An error occurred while updating the status.', - 'Admin.Notifications.Error' - ), - ], - UpdateTaxException::FAILED_UPDATE_STATUS => [ - $this->trans( - 'An error occurred while updating the status for an object.', - 'Admin.Notifications.Error' - ), - ], - ], - DeleteTaxException::class => [ - DeleteTaxException::FAILED_BULK_DELETE => $this->trans( - 'An error occurred while deleting this selection.', - 'Admin.Notifications.Error' - ), - DeleteTaxException::FAILED_DELETE => $this->trans( - 'An error occurred while deleting the object.', - 'Admin.Notifications.Error' - ), - ], - ]; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/TaxRulesGroupController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/TaxRulesGroupController.php deleted file mode 100644 index 26011578..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/International/TaxRulesGroupController.php +++ /dev/null @@ -1,343 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\International; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command\BulkDeleteTaxRulesGroupCommand; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command\BulkSetTaxRulesGroupStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command\DeleteTaxRulesGroupCommand; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command\SetTaxRulesGroupStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\CannotBulkDeleteTaxRulesGroupException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\CannotBulkUpdateTaxRulesGroupException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\CannotDeleteTaxRulesGroupException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\CannotUpdateTaxRulesGroupException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupConstraintException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Exception\TaxRulesGroupNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Query\GetTaxRulesGroupForEditing; -use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\QueryResult\EditableTaxRulesGroup; -use PrestaShop\PrestaShop\Core\Search\Filters\TaxRulesGroupFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible for handling "Improve > International > Tax Rules" page. - */ -class TaxRulesGroupController extends FrameworkBundleAdminController -{ - /** - * Show tax rules group page. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * @param TaxRulesGroupFilters $filters - * - * @return Response - */ - public function indexAction(Request $request, TaxRulesGroupFilters $filters): Response - { - $taxRulesGroupGridFactory = $this->get('prestashop.core.grid.factory.tax_rules_group'); - $taxRulesGroupGrid = $taxRulesGroupGridFactory->getGrid($filters); - - return $this->render('@PrestaShop/Admin/Improve/International/TaxRulesGroup/index.html.twig', [ - 'taxRulesGroupGrid' => $this->presentGrid($taxRulesGroupGrid), - 'enableSidebar' => true, - 'layoutHeaderToolbarBtn' => $this->getTaxRulesGroupToolbarButtons(), - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - ]); - } - - /** - * @AdminSecurity( - * "is_granted('create', request.get('_legacy_controller'))", - * redirectRoute="admin_tax_rules_groups_index", - * ) - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request): Response - { - return $this->redirect($this->getAdminLink('AdminTaxRulesGroup', [])); - } - - /** - * Handles tax rules group edit - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_tax_rules_groups_index", - * ) - * - * @param Request $request - * @param int $taxRulesGroupId - * - * @return Response - */ - public function editAction(Request $request, int $taxRulesGroupId): Response - { - return $this->redirect($this->getAdminLink('AdminTaxRulesGroup', [])); - } - - /** - * Deletes tax rules group. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_tax_rules_groups_index", - * ) - * - * @param int $taxRulesGroupId - * - * @return RedirectResponse - */ - public function deleteAction(int $taxRulesGroupId): RedirectResponse - { - try { - $this->getCommandBus()->handle(new DeleteTaxRulesGroupCommand((int) $taxRulesGroupId)); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_tax_rules_groups_index'); - } - - /** - * Toggles status. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_tax_rules_groups_index", - * ) - * - * @param int $taxRulesGroupId - * - * @return RedirectResponse - */ - public function toggleStatusAction(int $taxRulesGroupId): RedirectResponse - { - try { - /** @var EditableTaxRulesGroup $editableTaxRulesGroup */ - $editableTaxRulesGroup = $this->getQueryBus()->handle( - new GetTaxRulesGroupForEditing((int) $taxRulesGroupId) - ); - - $this->getCommandBus()->handle( - new SetTaxRulesGroupStatusCommand((int) $taxRulesGroupId, !$editableTaxRulesGroup->isActive()) - ); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_tax_rules_groups_index'); - } - - /** - * Enables tax rules groups status on bulk action. - * - * @param Request $request - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_tax_rules_groups_index", - * ) - * - * @return RedirectResponse - */ - public function bulkEnableStatusAction(Request $request): RedirectResponse - { - $taxRulesGroupIds = $this->getBulkTaxRulesGroupFromRequest($request); - - try { - $this->getCommandBus()->handle(new BulkSetTaxRulesGroupStatusCommand($taxRulesGroupIds, true)); - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_tax_rules_groups_index'); - } - - /** - * Disables tax rules groups status on bulk action. - * - * @param Request $request - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_tax_rules_groups_index", - * ) - * - * @return RedirectResponse - */ - public function bulkDisableStatusAction(Request $request): RedirectResponse - { - $taxRulesGroupIds = $this->getBulkTaxRulesGroupFromRequest($request); - - try { - $this->getCommandBus()->handle(new BulkSetTaxRulesGroupStatusCommand($taxRulesGroupIds, false)); - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_tax_rules_groups_index'); - } - - /** - * Delete tax rules groups on bulk action. - * - * @param Request $request - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_tax_rules_groups_index", - * ) - * - * @return RedirectResponse - */ - public function bulkDeleteAction(Request $request): RedirectResponse - { - $taxRulesGroupIds = $this->getBulkTaxRulesGroupFromRequest($request); - - try { - $this->getCommandBus()->handle(new BulkDeleteTaxRulesGroupCommand($taxRulesGroupIds)); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_tax_rules_groups_index'); - } - - /** - * @param Request $request - * - * @return array - */ - private function getBulkTaxRulesGroupFromRequest(Request $request): array - { - $taxRulesGroupIds = $request->request->get('tax_rules_group_bulk'); - - if (!is_array($taxRulesGroupIds)) { - return []; - } - - foreach ($taxRulesGroupIds as $i => $taxRulesGroupId) { - $taxRulesGroupIds[$i] = (int) $taxRulesGroupId; - } - - return $taxRulesGroupIds; - } - - /** - * @return array - */ - private function getTaxRulesGroupToolbarButtons(): array - { - $toolbarButtons = []; - - $toolbarButtons['add'] = [ - 'href' => $this->generateUrl('admin_tax_rules_groups_create'), - 'desc' => $this->trans('Add new tax rules group', 'Admin.International.Feature'), - 'icon' => 'add_circle_outline', - ]; - - return $toolbarButtons; - } - - /** - * Gets error messages for exceptions - * - * @param Exception $e - * - * @return array - */ - private function getErrorMessages(Exception $e = null): array - { - return [ - CannotDeleteTaxRulesGroupException::class => $this->trans( - 'An error occurred while deleting the object.', - 'Admin.Notifications.Error' - ), - TaxRulesGroupNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - CannotUpdateTaxRulesGroupException::class => [ - CannotUpdateTaxRulesGroupException::FAILED_TOGGLE_STATUS => $this->trans( - 'An error occurred while updating the status.', - 'Admin.Notifications.Error' - ), - ], - CannotBulkDeleteTaxRulesGroupException::class => sprintf( - '%s: %s', - $this->trans( - 'An error occurred while deleting this selection.', - 'Admin.Notifications.Error' - ), - $e instanceof CannotBulkDeleteTaxRulesGroupException ? implode(', ', $e->getTaxRulesGroupsIds()) : '' - ), - CannotBulkUpdateTaxRulesGroupException::class => sprintf( - '%s: %s', - $this->trans( - 'An error occurred while updating the status.', - 'Admin.Notifications.Error' - ), - $e instanceof CannotBulkUpdateTaxRulesGroupException ? implode(', ', $e->getTaxRulesGroupsIds()) : '' - ), - TaxRulesGroupConstraintException::class => [ - TaxRulesGroupConstraintException::INVALID_ID => $this->trans( - 'The object cannot be loaded (the identifier is missing or invalid)', - 'Admin.Notifications.Error' - ), - ], - ]; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/ModuleController.php b/src/PrestaShopBundle/Controller/Admin/Improve/ModuleController.php deleted file mode 100644 index 2846a2d9..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/ModuleController.php +++ /dev/null @@ -1,826 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve; - -use DateTime; -use Exception; -use Module; -use PrestaShop\PrestaShop\Adapter\Module\AdminModuleDataProvider; -use PrestaShop\PrestaShop\Adapter\Module\Module as ModuleAdapter; -use PrestaShop\PrestaShop\Core\Addon\AddonListFilter; -use PrestaShop\PrestaShop\Core\Addon\AddonListFilterStatus; -use PrestaShop\PrestaShop\Core\Addon\AddonListFilterType; -use PrestaShop\PrestaShop\Core\Addon\AddonsCollection; -use PrestaShop\PrestaShop\Core\Addon\Module\Exception\UnconfirmedModuleActionException; -use PrestaShop\PrestaShop\Core\Addon\Module\ModuleRepository; -use PrestaShopBundle\Controller\Admin\Improve\Modules\ModuleAbstractController; -use PrestaShopBundle\Entity\ModuleHistory; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Voter\PageVoter; -use PrestaShopBundle\Service\DataProvider\Admin\CategoriesProvider; -use Profile; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Validator\Constraints as Assert; - -/** - * Responsible of "Improve > Modules > Modules & Services > Catalog / Manage" page display. - */ -class ModuleController extends ModuleAbstractController -{ - const CONTROLLER_NAME = 'ADMINMODULESSF'; - - const MAX_MODULES_DISPLAYED = 6; - - /** - * @AdminSecurity("is_granted(['read'], 'ADMINMODULESSF_')") - * - * @return Response - */ - public function catalogAction() - { - return $this->render( - '@PrestaShop/Admin/Module/catalog.html.twig', - [ - 'layoutHeaderToolbarBtn' => $this->getToolbarButtons(), - 'layoutTitle' => $this->trans('Modules catalog', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'requireBulkActions' => false, - 'showContentHeader' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink('AdminModules'), - 'requireFilterStatus' => false, - 'level' => $this->authorizationLevel(self::CONTROLLER_NAME), - 'errorMessage' => $this->trans( - 'You do not have permission to add this.', - 'Admin.Notifications.Error' - ), - ] - ); - } - - /** - * Controller responsible for displaying "Catalog Module Grid" section of Module management pages with ajax. - * - * @AdminSecurity("is_granted(['read'], 'ADMINMODULESSF_')") - * - * @param Request $request - * - * @return Response - */ - public function manageAction() - { - $modulesProvider = $this->get('prestashop.core.admin.data_provider.module_interface'); - $shopService = $this->get('prestashop.adapter.shop.context'); - $moduleRepository = $this->get('prestashop.core.admin.module.repository'); - $themeRepository = $this->get('prestashop.core.addon.theme.repository'); - - // Retrieve current shop - $shopId = $shopService->getContextShopId(); - $shops = $shopService->getShops(); - $modulesTheme = []; - if (isset($shops[$shopId]) && is_array($shops[$shopId])) { - $shop = $shops[$shopId]; - $currentTheme = $themeRepository->getInstanceByName($shop['theme_name']); - $modulesTheme = $currentTheme->getModulesToEnable(); - } - - $filters = new AddonListFilter(); - $filters->setType(AddonListFilterType::MODULE | AddonListFilterType::SERVICE) - ->removeStatus(AddonListFilterStatus::UNINSTALLED); - $installedProducts = $moduleRepository->getFilteredList($filters); - - $categories = $this->getCategories($modulesProvider, $installedProducts); - $bulkActions = [ - 'bulk-uninstall' => $this->trans('Uninstall', 'Admin.Actions'), - 'bulk-disable' => $this->trans('Disable', 'Admin.Actions'), - 'bulk-enable' => $this->trans('Enable', 'Admin.Actions'), - 'bulk-reset' => $this->trans('Reset', 'Admin.Actions'), - 'bulk-enable-mobile' => $this->trans('Enable Mobile', 'Admin.Modules.Feature'), - 'bulk-disable-mobile' => $this->trans('Disable Mobile', 'Admin.Modules.Feature'), - ]; - - return $this->render( - '@PrestaShop/Admin/Module/manage.html.twig', - [ - 'maxModulesDisplayed' => self::MAX_MODULES_DISPLAYED, - 'bulkActions' => $bulkActions, - 'layoutHeaderToolbarBtn' => $this->getToolbarButtons(), - 'layoutTitle' => $this->trans('Module manager', 'Admin.Modules.Feature'), - 'categories' => $categories['categories'], - 'topMenuData' => $this->getTopMenuData($categories), - 'requireAddonsSearch' => false, - 'requireBulkActions' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink('AdminModules'), - 'requireFilterStatus' => true, - 'level' => $this->authorizationLevel(self::CONTROLLER_NAME), - 'errorMessage' => $this->trans('You do not have permission to add this.', 'Admin.Notifications.Error'), - ] - ); - } - - /** - * @AdminSecurity("is_granted(['read'], 'ADMINMODULESSF_')") - * - * @param Request $request - * - * @return Response - */ - public function getPreferredModulesAction(Request $request) - { - $tabModulesList = $request->get('tab_modules_list'); - - if ($tabModulesList) { - $tabModulesList = explode(',', $tabModulesList); - $modulesListUnsorted = $this->getModulesByInstallation( - $tabModulesList, - $request->request->get('admin_list_from_source') - ); - } - - $installed = $uninstalled = []; - - if (!empty($tabModulesList)) { - foreach ($tabModulesList as $key => $value) { - foreach ($modulesListUnsorted['installed'] as $moduleInstalled) { - if ($moduleInstalled['attributes']['name'] == $value) { - $installed[] = $moduleInstalled; - - continue 2; - } - } - - foreach ($modulesListUnsorted['not_installed'] as $moduleNotInstalled) { - if ($moduleNotInstalled['attributes']['name'] == $value) { - $uninstalled[] = $moduleNotInstalled; - - continue 2; - } - } - } - } - - $moduleListSorted = [ - 'installed' => $installed, - 'notInstalled' => $uninstalled, - ]; - - $twigParams = [ - 'currentIndex' => '', - 'modulesList' => $moduleListSorted, - 'level' => $this->authorizationLevel(self::CONTROLLER_NAME), - ]; - - if ($request->request->has('admin_list_from_source')) { - $twigParams['adminListFromSource'] = $request->request->get('admin_list_from_source'); - } - - return $this->render( - '@PrestaShop/Admin/Module/tab-modules-list.html.twig', - $twigParams - ); - } - - /** - * @AdminSecurity("is_granted(['read', 'create', 'update', 'delete'], 'ADMINMODULESSF_')") - * - * @param Request $module_name - * - * @return Response - */ - public function configureModuleAction($module_name) - { - /** @var UrlGeneratorInterface $legacyUrlGenerator */ - $legacyUrlGenerator = $this->get('prestashop.core.admin.url_generator_legacy'); - $legacyContextProvider = $this->get('prestashop.adapter.legacy.context'); - $legacyContext = $legacyContextProvider->getContext(); - $moduleRepository = $this->get('prestashop.core.admin.module.repository'); - // Get accessed module object - $moduleAccessed = $moduleRepository->getModule($module_name); - - // Get current employee Id - $currentEmployeeId = $legacyContext->employee->id; - // Get accessed module DB Id - $moduleAccessedId = (int) $moduleAccessed->database->get('id'); - - // Save history for this module - $moduleHistory = $this->getDoctrine() - ->getRepository('PrestaShopBundle:ModuleHistory') - ->findOneBy( - [ - 'idEmployee' => $currentEmployeeId, - 'idModule' => $moduleAccessedId, - ] - ); - - if (null === $moduleHistory) { - $moduleHistory = new ModuleHistory(); - } - - $moduleHistory->setIdEmployee($currentEmployeeId); - $moduleHistory->setIdModule($moduleAccessedId); - $moduleHistory->setDateUpd(new DateTime()); - - $em = $this->getDoctrine()->getManager(); - $em->persist($moduleHistory); - $em->flush(); - - return $this->redirect( - $legacyUrlGenerator->generate( - 'admin_module_configure_action', - [ - // do not transmit limit & offset: go to the first page when redirecting - 'configure' => $module_name, - ] - ) - ); - } - - /** - * @AdminSecurity("is_granted(['read'], 'ADMINMODULESSF_')") - * - * @param Request $request - * - * @return Response - */ - public function getModuleCartAction($moduleId) - { - $moduleRepository = $this->get('prestashop.core.admin.module.repository'); - $module = $moduleRepository->getModuleById($moduleId); - - $addOnsAdminDataProvider = $this->get('prestashop.core.admin.data_provider.module_interface'); - $addOnsAdminDataProvider->generateAddonsUrls( - AddonsCollection::createFrom([$module]) - ); - - $modulePresenter = $this->get('prestashop.adapter.presenter.module'); - $moduleToPresent = $modulePresenter->present($module); - - return $this->render( - '@PrestaShop/Admin/Module/Includes/modal_read_more_content.html.twig', - [ - 'module' => $moduleToPresent, - 'level' => $this->authorizationLevel(self::CONTROLLER_NAME), - ] - ); - } - - /** - * Controller responsible for displaying "Catalog Module Grid" section of Module management pages with ajax. - * - * @param Request $request - * - * @return JsonResponse - */ - public function refreshCatalogAction(Request $request) - { - $deniedAccess = $this->checkPermissions( - [ - PageVoter::LEVEL_READ, - PageVoter::LEVEL_CREATE, - PageVoter::LEVEL_DELETE, - PageVoter::LEVEL_UPDATE, - ] - ); - if (null !== $deniedAccess) { - return $deniedAccess; - } - - $modulesProvider = $this->get('prestashop.core.admin.data_provider.module_interface'); - $moduleRepository = $this->get('prestashop.core.admin.module.repository'); - $responseArray = []; - - $filters = new AddonListFilter(); - $filters->setType(AddonListFilterType::MODULE | AddonListFilterType::SERVICE) - ->setStatus(~AddonListFilterStatus::INSTALLED); - - try { - $modulesFromRepository = AddonsCollection::createFrom($moduleRepository->getFilteredList($filters)); - $modulesProvider->generateAddonsUrls($modulesFromRepository); - - $modules = $modulesFromRepository->toArray(); - shuffle($modules); - $categories = $this->getCategories($modulesProvider, $modules); - - $responseArray['domElements'][] = $this->constructJsonCatalogCategoriesMenuResponse($categories); - $responseArray['domElements'][] = $this->constructJsonCatalogBodyResponse( - $categories, - $modules - ); - $responseArray['status'] = true; - } catch (Exception $e) { - $responseArray['msg'] = $this->trans( - 'Cannot get catalog data, please try again later. Reason: %error_details%', - 'Admin.Modules.Notification', - ['%error_details%' => print_r($e->getMessage(), true)] - ); - $responseArray['status'] = false; - } - - return new JsonResponse($responseArray); - } - - /** - * @param Request $request - * - * @return JsonResponse - */ - public function moduleAction(Request $request) - { - $action = $request->get('action'); - - switch ($action) { - case ModuleAdapter::ACTION_UPGRADE: - case ModuleAdapter::ACTION_RESET: - case ModuleAdapter::ACTION_ENABLE: - case ModuleAdapter::ACTION_DISABLE: - case ModuleAdapter::ACTION_ENABLE_MOBILE: - case ModuleAdapter::ACTION_DISABLE_MOBILE: - $deniedAccess = $this->checkPermission(PageVoter::UPDATE); - break; - case ModuleAdapter::ACTION_INSTALL: - $deniedAccess = $this->checkPermission(PageVoter::CREATE); - break; - case ModuleAdapter::ACTION_UNINSTALL: - $deniedAccess = $this->checkPermission(PageVoter::DELETE); - break; - } - - if (null !== $deniedAccess) { - return $deniedAccess; - } - - if ($this->isDemoModeEnabled()) { - return $this->getDisabledFunctionalityResponse($request); - } - - $module = $request->get('module_name'); - $moduleManager = $this->container->get('prestashop.module.manager'); - $moduleManager->setActionParams($request->request->get('actionParams', [])); - $moduleRepository = $this->container->get('prestashop.core.admin.module.repository'); - $modulesProvider = $this->container->get('prestashop.core.admin.data_provider.module_interface'); - $response = [$module => []]; - - if (!method_exists($moduleManager, $action)) { - $response[$module]['status'] = false; - $response[$module]['msg'] = $this->trans('Invalid action', 'Admin.Notifications.Error'); - - return new JsonResponse($response); - } - - $actionTitle = str_replace('_', ' ', $action); - - try { - $response[$module]['status'] = $moduleManager->{$action}($module); - - if ($response[$module]['status'] === true) { - $response[$module]['msg'] = $this->trans( - '%action% action on module %module% succeeded.', - 'Admin.Modules.Notification', - [ - '%action%' => ucfirst($actionTitle), - '%module%' => $module, - ] - ); - - if ($action !== 'uninstall') { - $response[$module]['module_name'] = $module; - $response[$module]['is_configurable'] = (bool) $this - ->get('prestashop.core.admin.module.repository') - ->getModule($module) - ->attributes - ->get('is_configurable'); - } - } elseif ($response[$module]['status'] === false) { - $error = $moduleManager->getError($module); - $response[$module]['msg'] = $this->trans( - 'Cannot %action% module %module%. %error_details%', - 'Admin.Modules.Notification', - [ - '%action%' => $actionTitle, - '%module%' => $module, - '%error_details%' => $error, - ] - ); - } else { - $response[$module]['status'] = false; - $response[$module]['msg'] = $this->trans( - '%module% did not return a valid response on %action% action.', - 'Admin.Modules.Notification', - [ - '%module%' => $module, - '%action%' => $actionTitle, - ] - ); - } - } catch (UnconfirmedModuleActionException $e) { - $collection = AddonsCollection::createFrom([$e->getModule()]); - $modules = $modulesProvider->generateAddonsUrls($collection); - $response[$module] = array_replace( - $response[$module], - [ - 'status' => false, - 'confirmation_subject' => $e->getSubject(), - 'module' => $this - ->container - ->get('prestashop.adapter.presenter.module') - ->presentCollection($modules)[0], - 'msg' => $this->trans( - 'Confirmation needed by module %module% on %action% (%subject%).', - 'Admin.Modules.Notification', - [ - '%subject%' => $e->getSubject(), - '%action%' => $e->getAction(), - '%module%' => $module, - ] - ), - ] - ); - } catch (Exception $e) { - $response[$module]['status'] = false; - $response[$module]['msg'] = $this->trans( - 'Exception thrown by module %module% on %action%. %error_details%', - 'Admin.Modules.Notification', - [ - '%action%' => $actionTitle, - '%module%' => $module, - '%error_details%' => $e->getMessage(), - ] - ); - - $logger = $this->container->get('logger'); - $logger->error($response[$module]['msg']); - } - - if ($response[$module]['status'] === true && $action != 'uninstall') { - $moduleInstance = $moduleRepository->getModule($module); - $collection = AddonsCollection::createFrom([$moduleInstance]); - $response[$module]['action_menu_html'] = $this->container->get('templating')->render( - '@PrestaShop/Admin/Module/Includes/action_menu.html.twig', - [ - 'module' => $this->container->get('prestashop.adapter.presenter.module') - ->presentCollection($modulesProvider->generateAddonsUrls($collection))[0], - 'level' => $this->authorizationLevel(self::CONTROLLER_NAME), - ] - ); - } - - return new JsonResponse($response); - } - - /** - * Controller responsible for importing new module from DropFile zone in BO. - * - * @param Request $request - * - * @return JsonResponse - */ - public function importModuleAction(Request $request) - { - if ($this->isDemoModeEnabled()) { - return new JsonResponse( - [ - 'status' => false, - 'msg' => $this->getDemoModeErrorMessage(), - ] - ); - } - - $deniedAccess = $this->checkPermissions( - [ - PageVoter::LEVEL_CREATE, - PageVoter::LEVEL_DELETE, - ] - ); - if (null !== $deniedAccess) { - return $deniedAccess; - } - - $moduleManager = $this->get('prestashop.module.manager'); - $moduleZipManager = $this->get('prestashop.module.zip.manager'); - - try { - $fileUploaded = $request->files->get('file_uploaded'); - $constraints = [ - new Assert\NotNull(), - new Assert\File( - [ - 'maxSize' => ini_get('upload_max_filesize'), - 'mimeTypes' => [ - 'application/zip', - 'application/x-gzip', - 'application/gzip', - 'application/x-gtar', - 'application/x-tgz', - ], - ] - ), - ]; - - $violations = $this->get('validator')->validate($fileUploaded, $constraints); - if (0 !== count($violations)) { - $violationsMessages = []; - foreach ($violations as $violation) { - $violationsMessages[] = $violation->getMessage(); - } - - throw new Exception(implode(PHP_EOL, $violationsMessages)); - } - - $moduleName = $moduleZipManager->getName($fileUploaded->getPathname()); - - // Install the module - $installationResponse = [ - 'status' => $moduleManager->install($fileUploaded->getPathname()), - 'msg' => '', - 'module_name' => $moduleName, - ]; - - if ($installationResponse['status'] === null) { - $installationResponse['status'] = false; - $installationResponse['msg'] = $this->trans( - '%module% did not return a valid response on installation.', - 'Admin.Modules.Notification', - ['%module%' => $moduleName] - ); - } elseif ($installationResponse['status'] === true) { - $installationResponse['msg'] = $this->trans( - 'Installation of module %module% was successful.', - 'Admin.Modules.Notification', - ['%module%' => $moduleName] - ); - $installationResponse['is_configurable'] = (bool) $this->get('prestashop.core.admin.module.repository') - ->getModule($moduleName) - ->attributes - ->get('is_configurable'); - } else { - $error = $moduleManager->getError($moduleName); - $installationResponse['msg'] = $this->trans( - 'Installation of module %module% failed. %error%', - 'Admin.Modules.Notification', - [ - '%module%' => $moduleName, - '%error%' => $error, - ] - ); - } - } catch (UnconfirmedModuleActionException $e) { - $collection = AddonsCollection::createFrom([$e->getModule()]); - $modules = $this->get('prestashop.core.admin.data_provider.module_interface') - ->generateAddonsUrls($collection); - $installationResponse = [ - 'status' => false, - 'confirmation_subject' => $e->getSubject(), - 'module' => $this->get('prestashop.adapter.presenter.module')->presentCollection($modules)[0], - 'msg' => $this->trans( - 'Confirmation needed by module %module% on %action% (%subject%).', - 'Admin.Modules.Notification', - [ - '%subject%' => $e->getSubject(), - '%action%' => $e->getAction(), - '%module%' => $moduleName, - ] - ), - ]; - } catch (Exception $e) { - if (isset($moduleName)) { - $moduleManager->disable($moduleName); - } - - $installationResponse = [ - 'status' => false, - 'msg' => $e->getMessage(), - ]; - } - - return new JsonResponse($installationResponse); - } - - private function getModulesByInstallation($modulesSelectList = null) - { - $addonsProvider = $this->get('prestashop.core.admin.data_provider.module_interface'); - $moduleRepository = $this->get('prestashop.core.admin.module.repository'); - $modulePresenter = $this->get('prestashop.adapter.presenter.module'); - $tabRepository = $this->get('prestashop.core.admin.tab.repository'); - - $modulesOnDisk = AddonsCollection::createFrom($moduleRepository->getList()); - - $modulesList = [ - 'installed' => [], - 'not_installed' => [], - ]; - - $modulesOnDisk = $addonsProvider->generateAddonsUrls($modulesOnDisk); - foreach ($modulesOnDisk as $module) { - if (!isset($modulesSelectList) || in_array($module->get('name'), $modulesSelectList)) { - $perm = true; - if ($module->get('id')) { - $perm &= Module::getPermissionStatic( - $module->get('id'), - 'configure', - $this->getContext()->employee - ); - } else { - $id_admin_module = $tabRepository->findOneIdByClassName('AdminModules'); - $access = Profile::getProfileAccess( - $this->getContext()->employee->id_profile, - $id_admin_module - ); - - $perm &= !$access['edit']; - } - - if ($module->get('author') === ModuleRepository::PARTNER_AUTHOR) { - $module->set('type', 'addonsPartner'); - } - - if ($perm) { - $module->fillLogo(); - if ($module->database->get('installed') == 1) { - $modulesList['installed'][] = $modulePresenter->present($module); - } else { - $modulesList['not_installed'][] = $modulePresenter->present($module); - } - } - } - } - - return $modulesList; - } - - private function getTopMenuData(array $topMenuData, $activeMenu = null) - { - if (isset($activeMenu)) { - if (!isset($topMenuData[$activeMenu])) { - throw new Exception(sprintf('Menu \'%s\' not found in Top Menu data', $activeMenu), 1); - } - - $topMenuData[$activeMenu]->class = 'active'; - } - - return $topMenuData; - } - - /** - * @param Request $request - * - * @return JsonResponse - */ - private function getDisabledFunctionalityResponse(Request $request) - { - $content = [ - $request->get('module_name') => [ - 'status' => false, - 'msg' => $this->getDemoModeErrorMessage(), - ], - ]; - - return new JsonResponse($content); - } - - /** - * Construct Json struct for catalog body response. - * - * @param array $categories - * @param array $modules - * - * @return array - */ - private function constructJsonCatalogBodyResponse( - array $categories, - array $modules - ) { - $formattedContent = []; - $formattedContent['selector'] = '.module-catalog-page'; - $formattedContent['content'] = $this->render( - '@PrestaShop/Admin/Module/Includes/sorting.html.twig', - [ - 'totalModules' => count($modules), - ] - )->getContent(); - - $errorMessage = $this->trans('You do not have permission to add this.', 'Admin.Notifications.Error'); - - $formattedContent['content'] .= $this->render( - '@PrestaShop/Admin/Module/catalog-refresh.html.twig', - [ - 'categories' => $categories['categories'], - 'requireAddonsSearch' => true, - 'level' => $this->authorizationLevel(self::CONTROLLER_NAME), - 'errorMessage' => $errorMessage, - ] - )->getContent(); - - return $formattedContent; - } - - /** - * Construct json struct from top menu. - * - * @param array $categories - * - * @return array - */ - private function constructJsonCatalogCategoriesMenuResponse(array $categories) - { - $formattedContent = []; - $formattedContent['selector'] = '.module-menu-item'; - $formattedContent['content'] = $this->render( - '@PrestaShop/Admin/Module/Includes/dropdown_categories_catalog.html.twig', - [ - 'topMenuData' => $this->getTopMenuData($categories), - ] - )->getContent(); - - return $formattedContent; - } - - /** - * Check user permission. - * - * @param array $pageVoter - * - * @return void|JsonResponse - */ - private function checkPermissions(array $pageVoter) - { - if (!in_array( - $this->authorizationLevel(self::CONTROLLER_NAME), - $pageVoter - ) - ) { - return new JsonResponse( - [ - 'status' => false, - 'msg' => $this->trans('You do not have permission to add this.', 'Admin.Notifications.Error'), - ] - ); - } - } - - /** - * @param string $pageVoter - * - * @return JsonResponse - */ - private function checkPermission($pageVoter) - { - if (!$this->isGranted($pageVoter, self::CONTROLLER_NAME)) { - return new JsonResponse( - [ - 'status' => false, - 'msg' => $this->trans('You do not have permission to add this.', 'Admin.Notifications.Error'), - ] - ); - } - } - - /** - * Get categories and its modules. - * - * @param array $modules List of installed modules - * - * @return array - */ - private function getCategories(AdminModuleDataProvider $modulesProvider, array $modules) - { - /** @var CategoriesProvider */ - $categories = $this->get('prestashop.categories_provider')->getCategoriesMenu($modules); - - foreach ($categories['categories']->subMenu as $category) { - $collection = AddonsCollection::createFrom($category->modules); - $modulesProvider->generateAddonsUrls($collection); - $category->modules = $this->get('prestashop.adapter.presenter.module') - ->presentCollection($category->modules); - } - - return $categories; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/Modules/AddonsStoreController.php b/src/PrestaShopBundle/Controller/Admin/Improve/Modules/AddonsStoreController.php deleted file mode 100644 index 2e25c677..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/Modules/AddonsStoreController.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\Modules; - -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\Request; - -/** - * Responsible of "Improve > Modules > Modules Catalog" page display. - */ -class AddonsStoreController extends FrameworkBundleAdminController -{ - /** - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return \Symfony\Component\HttpFoundation\Response - */ - public function indexAction(Request $request) - { - $pageContent = @file_get_contents($this->getAddonsUrl($request)); - - if (!$pageContent) { - $this->addFlash('error', $this->trans( - 'It looks like we have trouble connecting to Addons. Please refresh the page or check your firewall configuration.', - 'Admin.Notifications.Error' - )); - - return $this->redirectToRoute('admin_module_catalog'); - } - - return $this->render('@PrestaShop/Admin/Improve/Module/addons_store.html.twig', [ - 'pageContent' => $pageContent, - 'layoutHeaderToolbarBtn' => [], - 'layoutTitle' => $this->trans('Module selection', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'requireBulkActions' => false, - 'showContentHeader' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'requireFilterStatus' => false, - 'level' => $this->authorizationLevel($request->attributes->get('_legacy_controller')), - ]); - } - - /** - * @param Request $request - * - * @return string - */ - private function getAddonsUrl(Request $request) - { - $psVersion = $this->get('prestashop.core.foundation.version')->getVersion(); - $parent_domain = $request->getSchemeAndHttpHost(); - $context = $this->getContext(); - $currencyCode = $context->currency->iso_code; - $languageCode = $context->language->iso_code; - $countryCode = $context->country->iso_code; - $activity = (int) $this->get('prestashop.adapter.legacy.configuration')->get('PS_SHOP_ACTIVITY'); - - // GET parameters are concatenated this way in order to ensure they are not encoded - return "https://addons.prestashop.com/iframe/search-1.7.php?psVersion=$psVersion&isoLang=$languageCode&isoCurrency=$currencyCode&isoCountry=$countryCode&activity=$activity&parentUrl=$parent_domain"; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/Modules/AlertsController.php b/src/PrestaShopBundle/Controller/Admin/Improve/Modules/AlertsController.php deleted file mode 100644 index 35538e8c..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/Modules/AlertsController.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\Modules; - -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible of "Improve > Modules > Modules & Services > Alerts" page display. - */ -class AlertsController extends ModuleAbstractController -{ - /** - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @return Response - */ - public function indexAction() - { - return $this->render( - '@PrestaShop/Admin/Module/alerts.html.twig', - $this->getNotificationPageData('to_configure') - ); - } - - /** - * @return JsonResponse with number of modules having at least one notification - */ - public function notificationsCountAction() - { - return new JsonResponse( - $this->get('prestashop.module.manager') - ->countModulesWithNotificationsDetailed() - ); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/Modules/ModuleAbstractController.php b/src/PrestaShopBundle/Controller/Admin/Improve/Modules/ModuleAbstractController.php deleted file mode 100644 index 77f7c205..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/Modules/ModuleAbstractController.php +++ /dev/null @@ -1,126 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\Modules; - -use PrestaShop\PrestaShop\Core\Addon\AddonsCollection; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Voter\PageVoter; - -abstract class ModuleAbstractController extends FrameworkBundleAdminController -{ - const CONTROLLER_NAME = 'ADMINMODULESSF'; - - /** - * Common method of alerts & updates routes for getting template variables. - * - * @param string $type Type of alert to display (to_configure / to_update ...) - * - * @return array - */ - protected function getNotificationPageData($type) - { - $modulePresenter = $this->get('prestashop.adapter.presenter.module'); - $modulesPresenterCallback = function (AddonsCollection &$modules) use ($modulePresenter) { - return $modulePresenter->presentCollection($modules); - }; - - $moduleManager = $this->get('prestashop.module.manager'); - $modules = $moduleManager->getModulesWithNotifications($modulesPresenterCallback); - - return [ - 'enableSidebar' => true, - 'layoutHeaderToolbarBtn' => $this->getToolbarButtons(), - 'layoutTitle' => $this->trans('Module notifications', 'Admin.Modules.Feature'), - 'help_link' => $this->generateSidebarLink('AdminModules'), - 'modules' => $modules->{$type}, - 'requireAddonsSearch' => false, - 'requireBulkActions' => false, - 'requireFilterStatus' => false, - 'level' => $this->authorizationLevel($this::CONTROLLER_NAME), - 'errorMessage' => $this->trans('You do not have permission to add this.', 'Admin.Notifications.Error'), - ]; - } - - /** - * Common method for all module related controller for getting the header buttons. - * - * @return array - */ - protected function getToolbarButtons() - { - // toolbarButtons - $toolbarButtons = []; - - if (!in_array( - $this->authorizationLevel($this::CONTROLLER_NAME), - [ - PageVoter::LEVEL_READ, - PageVoter::LEVEL_UPDATE, - ] - )) { - $toolbarButtons['add_module'] = [ - 'href' => '#', - 'desc' => $this->trans('Upload a module', 'Admin.Modules.Feature'), - 'icon' => 'cloud_upload', - 'help' => $this->trans('Upload a module', 'Admin.Modules.Feature'), - ]; - } - - return array_merge($toolbarButtons, $this->getAddonsConnectToolbar()); - } - - /** - * Create a button in the header for the marketplace account (login or logout). - * - * @return array - */ - protected function getAddonsConnectToolbar() - { - $addonsProvider = $this->get('prestashop.core.admin.data_provider.addons_interface'); - if ($addonsProvider->isAddonsAuthenticated()) { - $addonsEmail = $addonsProvider->getAddonsEmail(); - - return [ - 'addons_logout' => [ - 'href' => '#', - 'desc' => $addonsEmail['username_addons'], - 'icon' => 'exit_to_app', - 'help' => $this->trans('Synchronized with Addons marketplace!', 'Admin.Modules.Notification'), - ], - ]; - } - - return [ - 'addons_connect' => [ - 'href' => '#', - 'desc' => $this->trans('Connect to Addons marketplace', 'Admin.Modules.Feature'), - 'icon' => 'vpn_key', - 'help' => $this->trans('Connect to Addons marketplace', 'Admin.Modules.Feature'), - ], - ]; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/Modules/UpdatesController.php b/src/PrestaShopBundle/Controller/Admin/Improve/Modules/UpdatesController.php deleted file mode 100644 index 0dbaf9d4..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/Modules/UpdatesController.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\Modules; - -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible of "Improve > Modules > Modules & Services > Updates" page display. - */ -class UpdatesController extends ModuleAbstractController -{ - /** - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @return Response - */ - public function indexAction() - { - return $this->render( - '@PrestaShop/Admin/Module/updates.html.twig', - $this->getNotificationPageData('to_update') - ); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/Payment/PaymentMethodsController.php b/src/PrestaShopBundle/Controller/Admin/Improve/Payment/PaymentMethodsController.php deleted file mode 100644 index d395a3a3..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/Payment/PaymentMethodsController.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\Payment; - -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class PaymentMethodsController is responsible for 'Improve > Payment > Payment Methods' page. - */ -class PaymentMethodsController extends FrameworkBundleAdminController -{ - /** - * Show payment method modules. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return Response - */ - public function indexAction(Request $request) - { - $legacyController = $request->attributes->get('_legacy_controller'); - - $shopContext = $this->get('prestashop.adapter.shop.context'); - $isSingleShopContext = $shopContext->isSingleShopContext(); - $paymentModules = []; - - if ($isSingleShopContext) { - $paymentMethodsPresenter = $this->get('prestashop.adapter.module.presenter.payment'); - $paymentModules = $paymentMethodsPresenter->present(); - } - - return $this->render('@PrestaShop/Admin/Improve/Payment/PaymentMethods/payment_methods.html.twig', [ - 'paymentModules' => $paymentModules, - 'isSingleShopContext' => $isSingleShopContext, - 'layoutTitle' => $this->trans('Payment Methods', 'Admin.Navigation.Menu'), - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($legacyController), - ]); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/Payment/PaymentPreferencesController.php b/src/PrestaShopBundle/Controller/Admin/Improve/Payment/PaymentPreferencesController.php deleted file mode 100644 index 866d92ad..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/Payment/PaymentPreferencesController.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\Payment; - -use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class PaymentPreferencesController is responsible for "Improve > Payment > Preferences" page. - */ -class PaymentPreferencesController extends FrameworkBundleAdminController -{ - /** - * Show payment preferences page. - * - * @AdminSecurity( - * "is_granted(['read'], request.get('_legacy_controller'))", - * message="Access denied." - * ) - * - * @param Request $request - * - * @return Response - */ - public function indexAction(Request $request) - { - $legacyController = $request->attributes->get('_legacy_controller'); - - $paymentModulesListProvider = $this->get('prestashop.adapter.module.payment_module_provider'); - $shopContext = $this->get('prestashop.adapter.shop.context'); - - $isSingleShopContext = $shopContext->isSingleShopContext(); - - $paymentPreferencesForm = null; - $paymentModulesCount = 0; - - if ($isSingleShopContext) { - $paymentModulesCount = count($paymentModulesListProvider->getPaymentModuleList()); - $paymentPreferencesForm = $this->getPaymentPreferencesFormHandler()->getForm()->createView(); - } - - return $this->render('@PrestaShop/Admin/Improve/Payment/Preferences/payment_preferences.html.twig', [ - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($legacyController), - 'paymentPreferencesForm' => $paymentPreferencesForm, - 'isSingleShopContext' => $isSingleShopContext, - 'paymentModulesCount' => $paymentModulesCount, - ]); - } - - /** - * Process payment modules preferences form. - * - * @AdminSecurity( - * "is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", - * message="Access denied.", - * redirectRoute="admin_payment_preferences" - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function processFormAction(Request $request) - { - $paymentPreferencesFormHandler = $this->getPaymentPreferencesFormHandler(); - - $paymentPreferencesForm = $paymentPreferencesFormHandler->getForm(); - $paymentPreferencesForm->handleRequest($request); - - if ($paymentPreferencesForm->isSubmitted()) { - $paymentPreferences = $paymentPreferencesForm->getData(); - - $errors = $paymentPreferencesFormHandler->save($paymentPreferences); - if (empty($errors)) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_payment_preferences'); - } - - $this->flashErrors($errors); - } - - return $this->redirectToRoute('admin_payment_preferences'); - } - - /** - * @return FormHandlerInterface - */ - private function getPaymentPreferencesFormHandler() - { - return $this->get('prestashop.admin.payment_preferences.form_handler'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/Shipping/PreferencesController.php b/src/PrestaShopBundle/Controller/Admin/Improve/Shipping/PreferencesController.php deleted file mode 100644 index 93c2ee8c..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Improve/Shipping/PreferencesController.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Improve\Shipping; - -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; - -/** - * Controller responsible of "Improve > Shipping > Preferences" page. - */ -class PreferencesController extends FrameworkBundleAdminController -{ - /** - * Show shipping preferences page. - * - * @param Request $request - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @return array Template parameters - */ - public function indexAction(Request $request) - { - $legacyController = $request->attributes->get('_legacy_controller'); - - $form = $this->get('prestashop.admin.shipping_preferences.form_handler')->getForm(); - - return $this->render('@PrestaShop/Admin/Improve/Shipping/Preferences/preferences.html.twig', [ - 'layoutTitle' => $this->trans('Preferences', 'Admin.Navigation.Menu'), - 'requireAddonsSearch' => true, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($legacyController), - 'form' => $form->createView(), - ]); - } - - /** - * Handle form submit. - * - * @AdminSecurity("is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", - * message="You do not have permission to edit this.", - * redirectRoute="admin_shipping_preferences") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function processFormAction(Request $request) - { - $formHandler = $this->get('prestashop.admin.shipping_preferences.form_handler'); - - $form = $formHandler->getForm(); - $form->handleRequest($request); - - if ($form->isSubmitted()) { - if ($errors = $formHandler->save($form->getData())) { - $this->flashErrors($errors); - } else { - $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success')); - } - } - - return $this->redirectToRoute('admin_shipping_preferences'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/ProductController.php b/src/PrestaShopBundle/Controller/Admin/ProductController.php deleted file mode 100644 index 72673fbd..00000000 --- a/src/PrestaShopBundle/Controller/Admin/ProductController.php +++ /dev/null @@ -1,1307 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin; - -use Category; -use Exception; -use PrestaShop\PrestaShop\Adapter\Product\ListParametersUpdater; -use PrestaShop\PrestaShop\Adapter\Tax\TaxRuleDataProvider; -use PrestaShop\PrestaShop\Adapter\Warehouse\WarehouseDataProvider; -use PrestaShop\PrestaShop\Core\Domain\Product\Command\UpdateProductStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\CannotUpdateProductException; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductException; -use PrestaShop\PrestaShop\Core\Domain\Product\Exception\ProductNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Product\Query\GetProductIsEnabled; -use PrestaShopBundle\Component\CsvResponse; -use PrestaShopBundle\Entity\AdminFilter; -use PrestaShopBundle\Exception\UpdateProductException; -use PrestaShopBundle\Form\Admin\Product\ProductCategories; -use PrestaShopBundle\Form\Admin\Product\ProductCombination; -use PrestaShopBundle\Form\Admin\Product\ProductCombinationBulk; -use PrestaShopBundle\Form\Admin\Product\ProductInformation; -use PrestaShopBundle\Form\Admin\Product\ProductOptions; -use PrestaShopBundle\Form\Admin\Product\ProductPrice; -use PrestaShopBundle\Form\Admin\Product\ProductQuantity; -use PrestaShopBundle\Form\Admin\Product\ProductSeo; -use PrestaShopBundle\Form\Admin\Product\ProductShipping; -use PrestaShopBundle\Model\Product\AdminModelAdapter; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Voter\PageVoter; -use PrestaShopBundle\Service\DataProvider\Admin\ProductInterface as ProductInterfaceProvider; -use PrestaShopBundle\Service\DataProvider\StockInterface; -use PrestaShopBundle\Service\DataUpdater\Admin\ProductInterface as ProductInterfaceUpdater; -use PrestaShopBundle\Service\Hook\HookFinder; -use Product; -use Psr\Log\LoggerInterface; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; -use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\Form; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\File\UploadedFile; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Tools; - -/** - * Admin controller for the Product pages using the Symfony architecture: - * - categories - * - product list - * - product details - * - product attributes - * - ... - * - * This controller is the first one to be refactored to the new Symfony Architecture. - * The retro-compatibility is dropped for the corresponding Admin pages. - * A set of hooks are integrated and an Adapter is made to wrap the new EventDispatcher - * component to the existing hook system. So existing hooks are always triggered, but from the new - * code (and so needs to be adapted on the module side ton comply on the new parameters formats, - * the new UI style, etc...). - */ -class ProductController extends FrameworkBundleAdminController -{ - /** - * Used to validate connected user authorizations. - */ - const PRODUCT_OBJECT = 'ADMINPRODUCTS_'; - - /** - * Get the Catalog page with KPI banner, product list, bulk actions, filters, search, etc... - * - * URL example: /product/catalog/40/20/id_product/asc - * - * @Template("@PrestaShop/Admin/Product/CatalogPage/catalog.html.twig") - * - * @param Request $request - * @param int $limit The size of the listing - * @param int $offset The offset of the listing - * @param string $orderBy To order product list - * @param string $sortOrder To order product list - * - * @return array|Template|RedirectResponse|Response - * - * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException - * @throws \Symfony\Component\Routing\Exception\RouteNotFoundException - * @throws \LogicException - * @throws \Symfony\Component\Routing\Exception\MissingMandatoryParametersException - * @throws \Symfony\Component\Routing\Exception\InvalidParameterException - * @throws \Symfony\Component\Form\Exception\LogicException - * @throws \Symfony\Component\Form\Exception\AlreadySubmittedException - */ - public function catalogAction( - Request $request, - $limit = 10, - $offset = 0, - $orderBy = 'id_product', - $sortOrder = 'desc' - ) { - if (!$this->isGranted([PageVoter::READ, PageVoter::UPDATE, PageVoter::CREATE], self::PRODUCT_OBJECT)) { - return $this->redirect('admin_dashboard'); - } - - $language = $this->getContext()->language; - $request->getSession()->set('_locale', $language->locale); - $request = $this->get('prestashop.adapter.product.filter_categories_request_purifier')->purify($request); - - /** @var $productProvider ProductInterfaceProvider */ - $productProvider = $this->get('prestashop.core.admin.data_provider.product_interface'); - - // Set values from persistence and replace in the request - $persistedFilterParameters = $productProvider->getPersistedFilterParameters(); - /** @var ListParametersUpdater $listParametersUpdater */ - $listParametersUpdater = $this->get('prestashop.adapter.product.list_parameters_updater'); - $listParameters = $listParametersUpdater->buildListParameters( - $request->query->all(), - $persistedFilterParameters, - compact('offset', 'limit', 'orderBy', 'sortOrder') - ); - $offset = $listParameters['offset']; - $limit = $listParameters['limit']; - $orderBy = $listParameters['orderBy']; - $sortOrder = $listParameters['sortOrder']; - - //The product provider performs the same merge internally, so we do the same so that the displayed filters are - //consistent with the request ones - $combinedFilterParameters = array_replace($persistedFilterParameters, $request->request->all()); - - $toolbarButtons = $this->getToolbarButtons(); - - // Fetch product list (and cache it into view subcall to listAction) - $products = $productProvider->getCatalogProductList( - $offset, - $limit, - $orderBy, - $sortOrder, - $request->request->all() - ); - $lastSql = $productProvider->getLastCompiledSql(); - - $hasCategoryFilter = $productProvider->isCategoryFiltered(); - $hasColumnFilter = $productProvider->isColumnFiltered(); - $totalFilteredProductCount = (count($products) > 0) ? $products[0]['total'] : 0; - // Alternative layout for empty list - if ((!$hasCategoryFilter && !$hasColumnFilter && $totalFilteredProductCount === 0) - || ($totalProductCount = $productProvider->countAllProducts()) === 0 - ) { - // no filter, total filtered == 0, and then total count == 0 too. - $legacyUrlGenerator = $this->get('prestashop.core.admin.url_generator_legacy'); - - return $this->render( - '@PrestaShop/Admin/Product/CatalogPage/catalog_empty.html.twig', - [ - 'layoutHeaderToolbarBtn' => $toolbarButtons, - 'import_url' => $legacyUrlGenerator->generate('AdminImport'), - ] - ); - } - - // Pagination - $paginationParameters = $request->attributes->all(); - $paginationParameters['_route'] = 'admin_product_catalog'; - $categoriesForm = $this->createForm(ProductCategories::class); - if (!empty($persistedFilterParameters['filter_category'])) { - $categoriesForm->setData( - [ - 'categories' => [ - 'tree' => [0 => $combinedFilterParameters['filter_category']], - ], - ] - ); - } - - $cleanFilterParameters = $listParametersUpdater->cleanFiltersForPositionOrdering( - $combinedFilterParameters, - $orderBy, - $hasCategoryFilter - ); - - $permissionError = null; - if ($this->get('session')->getFlashBag()->has('permission_error')) { - $permissionError = $this->get('session')->getFlashBag()->get('permission_error')[0]; - } - - $categoriesFormView = $categoriesForm->createView(); - $selectedCategory = !empty($combinedFilterParameters['filter_category']) ? new Category($combinedFilterParameters['filter_category']) : null; - - //Drag and drop is ONLY activated when EXPLICITLY requested by the user - //Meaning a category is selected and the user clicks on REORDER button - $activateDragAndDrop = 'position_ordering' === $orderBy && $hasCategoryFilter; - - // Template vars injection - return array_merge( - $cleanFilterParameters, - [ - 'limit' => $limit, - 'offset' => $offset, - 'orderBy' => $orderBy, - 'sortOrder' => $sortOrder, - 'has_filter' => $hasCategoryFilter || $hasColumnFilter, - 'has_category_filter' => $hasCategoryFilter, - 'selected_category' => $selectedCategory, - 'has_column_filter' => $hasColumnFilter, - 'products' => $products, - 'last_sql' => $lastSql, - 'product_count_filtered' => $totalFilteredProductCount, - 'product_count' => $totalProductCount, - 'activate_drag_and_drop' => $activateDragAndDrop, - 'pagination_parameters' => $paginationParameters, - 'layoutHeaderToolbarBtn' => $toolbarButtons, - 'categories' => $categoriesFormView, - 'pagination_limit_choices' => $productProvider->getPaginationLimitChoices(), - 'import_link' => $this->generateUrl('admin_import', ['import_type' => 'products']), - 'sql_manager_add_link' => $this->generateUrl('admin_sql_requests_create'), - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink('AdminProducts'), - 'is_shop_context' => $this->get('prestashop.adapter.shop.context')->isShopContext(), - 'permission_error' => $permissionError, - 'layoutTitle' => $this->trans('Products', 'Admin.Global'), - ] - ); - } - - /** - * Get only the list of products to display on the main Admin Product page. - * The full page that shows products list will subcall this action (from catalogAction). - * URL example: /product/list/html/40/20/id_product/asc. - * - * @Template("@PrestaShop/Admin/Product/CatalogPage/Lists/list.html.twig") - * - * @param Request $request - * @param int $limit The size of the listing - * @param int $offset The offset of the listing - * @param string $orderBy To order product list - * @param string $sortOrder To order product list - * @param string $view full|quicknav To change default template used to render the content - * - * @return array|Template|Response - */ - public function listAction( - Request $request, - $limit = 10, - $offset = 0, - $orderBy = 'id_product', - $sortOrder = 'asc', - $view = 'full' - ) { - if (!$this->isGranted([PageVoter::READ], self::PRODUCT_OBJECT)) { - return $this->redirect('admin_dashboard'); - } - - /** @var $productProvider ProductInterfaceProvider */ - $productProvider = $this->get('prestashop.core.admin.data_provider.product_interface'); - $adminProductWrapper = $this->get('prestashop.adapter.admin.wrapper.product'); - $totalCount = 0; - - $this->get('prestashop.service.product')->cleanupOldTempProducts(); - - $products = $request->attributes->get('products', null); // get from action subcall data, if any - $lastSql = $request->attributes->get('last_sql', null); // get from action subcall data, if any - - if ($products === null) { - // get old values from persistence (before the current update) - $persistedFilterParameters = $productProvider->getPersistedFilterParameters(); - /** @var ListParametersUpdater $listParametersUpdater */ - $listParametersUpdater = $this->get('prestashop.adapter.product.list_parameters_updater'); - $listParameters = $listParametersUpdater->buildListParameters( - $request->query->all(), - $persistedFilterParameters, - compact('offset', 'limit', 'orderBy', 'sortOrder') - ); - $offset = $listParameters['offset']; - $limit = $listParameters['limit']; - $orderBy = $listParameters['orderBy']; - $sortOrder = $listParameters['sortOrder']; - - /** - * 2 hooks are triggered here: - * - actionAdminProductsListingFieldsModifier - * - actionAdminProductsListingResultsModifier. - */ - $products = $productProvider->getCatalogProductList($offset, $limit, $orderBy, $sortOrder); - $lastSql = $productProvider->getLastCompiledSql(); - } - - $hasCategoryFilter = $productProvider->isCategoryFiltered(); - - // Adds controller info (URLs, etc...) to product list - foreach ($products as &$product) { - $totalCount = isset($product['total']) ? $product['total'] : $totalCount; - $product['url'] = $this->generateUrl( - 'admin_product_form', - ['id' => $product['id_product']] - ); - $product['unit_action_url'] = $this->generateUrl( - 'admin_product_unit_action', - [ - 'action' => 'duplicate', - 'id' => $product['id_product'], - ] - ); - $product['preview_url'] = $adminProductWrapper->getPreviewUrlFromId($product['id_product']); - } - - //Drag and drop is ONLY activated when EXPLICITLY requested by the user - //Meaning a category is selected and the user clicks on REORDER button - $activateDragAndDrop = 'position_ordering' === $orderBy && $hasCategoryFilter; - - // Template vars injection - $vars = [ - 'activate_drag_and_drop' => $activateDragAndDrop, - 'products' => $products, - 'product_count' => $totalCount, - 'last_sql_query' => $lastSql, - 'has_category_filter' => $productProvider->isCategoryFiltered(), - 'is_shop_context' => $this->get('prestashop.adapter.shop.context')->isShopContext(), - ]; - if ($view !== 'full') { - return $this->render( - '@Product/CatalogPage/Lists/list_' . $view . '.html.twig', - array_merge( - $vars, - [ - 'limit' => $limit, - 'offset' => $offset, - 'total' => $totalCount, - ] - ) - ); - } - - return $vars; - } - - /** - * Gets the header toolbar buttons. - * - * @return array - */ - private function getToolbarButtons() - { - $toolbarButtons = []; - $toolbarButtons['add'] = [ - 'href' => $this->generateUrl('admin_product_new'), - 'desc' => $this->trans('New product', 'Admin.Actions'), - 'icon' => 'add_circle_outline', - 'help' => $this->trans('Create a new product: CTRL+P', 'Admin.Catalog.Help'), - ]; - - return $toolbarButtons; - } - - /** - * Create a new basic product - * Then return to form action. - * - * @return RedirectResponse - * - * @throws \LogicException - * @throws \PrestaShopException - */ - public function newAction() - { - if (!$this->isGranted(PageVoter::CREATE, self::PRODUCT_OBJECT)) { - $errorMessage = $this->trans('You do not have permission to add this.', 'Admin.Notifications.Error'); - $this->get('session')->getFlashBag()->add('permission_error', $errorMessage); - - return $this->redirectToRoute('admin_product_catalog'); - } - - $productProvider = $this->get('prestashop.core.admin.data_provider.product_interface'); - $languages = $this->get('prestashop.adapter.legacy.context')->getLanguages(); - - /** @var $productProvider ProductInterfaceProvider */ - $productAdapter = $this->get('prestashop.adapter.data_provider.product'); - $productShopCategory = $this->getContext()->shop->id_category; - - /** @var Product $product */ - $product = $productAdapter->getProductInstance(); - $product->id_category_default = $productShopCategory; - - /** @var TaxRuleDataProvider $taxRuleDataProvider */ - $taxRuleDataProvider = $this->get('prestashop.adapter.data_provider.tax'); - $product->id_tax_rules_group = $taxRuleDataProvider->getIdTaxRulesGroupMostUsed(); - $product->active = $productProvider->isNewProductDefaultActivated() ? 1 : 0; - $product->state = Product::STATE_TEMP; - - //set name and link_rewrite in each lang - foreach ($languages as $lang) { - $product->name[$lang['id_lang']] = ''; - $product->link_rewrite[$lang['id_lang']] = ''; - } - - $product->save(); - $product->addToCategories([$productShopCategory]); - - return $this->redirectToRoute('admin_product_form', ['id' => $product->id]); - } - - /** - * Product form. - * - * @Template("@PrestaShop/Admin/Product/ProductPage/product.html.twig") - * - * @param int $id The product ID - * @param Request $request - * - * @return array|Response Template vars - * - * @throws \LogicException - */ - public function formAction($id, Request $request) - { - gc_disable(); - - if (!$this->isGranted([PageVoter::READ, PageVoter::UPDATE, PageVoter::CREATE], self::PRODUCT_OBJECT)) { - return $this->redirect('admin_dashboard'); - } - - $productAdapter = $this->get('prestashop.adapter.data_provider.product'); - $product = $productAdapter->getProduct($id); - - if (!$product || empty($product->id)) { - return $this->redirectToRoute('admin_product_catalog'); - } - - $shopContext = $this->get('prestashop.adapter.shop.context'); - $legacyContextService = $this->get('prestashop.adapter.legacy.context'); - $isMultiShopContext = count($shopContext->getContextListShopID()) > 1; - - $modelMapper = $this->get('prestashop.adapter.admin.model.product'); - $adminProductWrapper = $this->get('prestashop.adapter.admin.wrapper.product'); - - $form = $this->createProductForm($product, $modelMapper); - - $formBulkCombinations = $this->createForm( - ProductCombinationBulk::class, - null, - [ - 'iso_code' => $this - ->get('prestashop.adapter.legacy.context') - ->getContext()->currency->iso_code, - ] - ); - - // Legacy code. To fix when Object model will change. But report Hooks. - $postData = $request->request->all(); - $combinationsList = []; - if (!empty($postData)) { - foreach ($postData as $postKey => $postValue) { - if (preg_match('/^combination_.*/', $postKey)) { - $combinationsList[$postKey] = $postValue; - $postData['form'][$postKey] = $postValue; // need to validate the form - } - } - - // Duplicate Request to be a valid form (like it was real) with postData modified .. - $request = $request->duplicate( - $request->query->all(), - $postData, - $request->attributes->all(), - $request->cookies->all(), - $request->files->all(), - $request->server->all() - ); - } - - /* @var Form $form */ - $form->handleRequest($request); - $formData = $form->getData(); - $formData['step3']['combinations'] = $combinationsList; - - try { - if ($form->isSubmitted()) { - if ($this->isDemoModeEnabled() && $request->isXmlHttpRequest()) { - $errorMessage = $this->getDemoModeErrorMessage(); - - return $this->returnErrorJsonResponse( - ['error' => [$errorMessage]], - Response::HTTP_SERVICE_UNAVAILABLE - ); - } - - if ($form->isValid()) { - //define POST values for keeping legacy adminController skills - $_POST = $modelMapper->getModelData($formData, $isMultiShopContext) + $_POST; - $_POST['form'] = $formData; - $_POST['state'] = Product::STATE_SAVED; - - $adminProductController = $adminProductWrapper->getInstance(); - $adminProductController->setIdObject($formData['id_product']); - $adminProductController->setAction('save'); - - // Hooks: this will trigger legacy AdminProductController, postProcess(): - // actionAdminSaveBefore; actionAdminProductsControllerSaveBefore - // actionProductAdd or actionProductUpdate (from processSave() -> processAdd() or processUpdate()) - // actionAdminSaveAfter; actionAdminProductsControllerSaveAfter - $productSaveResult = $adminProductController->postCoreProcess(); - - if (false == $productSaveResult) { - return $this->returnErrorJsonResponse( - ['error' => $adminProductController->errors], - Response::HTTP_BAD_REQUEST - ); - } - - $product = $productSaveResult; - - /* @var Product $product */ - $adminProductController->processSuppliers($product->id); - $adminProductController->processFeatures($product->id); - $adminProductController->processSpecificPricePriorities(); - foreach ($_POST['combinations'] as $combinationValues) { - $adminProductWrapper->processProductAttribute($product, $combinationValues); - // For now, each attribute set the same value. - $adminProductWrapper->processDependsOnStock( - $product, - ($_POST['depends_on_stock'] == '1'), - $combinationValues['id_product_attribute'] - ); - } - $adminProductWrapper->processDependsOnStock($product, ($_POST['depends_on_stock'] == '1')); - - // If there is no combination, then quantity and location are managed for the whole product (as combination ID 0) - // In all cases, legacy hooks are triggered: actionProductUpdate and actionUpdateQuantity - if (count($_POST['combinations']) === 0 && isset($_POST['qty_0'])) { - $adminProductWrapper->processQuantityUpdate($product, $_POST['qty_0']); - $adminProductWrapper->processLocation($product, (string) $_POST['location']); - } - // else quantities are managed from $adminProductWrapper->processProductAttribute() above. - - $adminProductWrapper->processProductOutOfStock($product, $_POST['out_of_stock']); - - $customizationFieldsIds = $adminProductWrapper - ->processProductCustomization($product, $_POST['custom_fields']); - - $adminProductWrapper->processAttachments($product, $_POST['attachments']); - - $adminProductController->processWarehouses(); - - $response = new JsonResponse(); - $response->setData([ - 'product' => $product, - 'customization_fields_ids' => $customizationFieldsIds, - ]); - - if ($request->isXmlHttpRequest()) { - return $response; - } - } elseif ($request->isXmlHttpRequest()) { - return $this->returnErrorJsonResponse( - $this->getFormErrorsForJS($form), - Response::HTTP_BAD_REQUEST - ); - } - } - } catch (Exception $e) { - // this controller can be called as an AJAX JSON route or a HTML page - // so we need to return the right type of response if an exception it thrown - if ($request->isXmlHttpRequest()) { - return $this->returnErrorJsonResponse( - [], - Response::HTTP_INTERNAL_SERVER_ERROR - ); - } - - throw $e; - } - - /** @var $stockManager StockInterface */ - $stockManager = $this->get('prestashop.core.data_provider.stock_interface'); - - /** @var WarehouseDataProvider $warehouseProvider */ - $warehouseProvider = $this->get('prestashop.adapter.data_provider.warehouse'); - - //If context shop is define to a group shop, disable the form - if ($shopContext->isShopGroupContext()) { - return $this->render('@Product/ProductPage/disabled_form_alert.html.twig', ['showContentHeader' => false]); - } - - // languages for switch dropdown - $languages = $legacyContextService->getLanguages(); - - // generate url preview - if ($product->active) { - $preview_url = $adminProductWrapper->getPreviewUrl($product); - $preview_url_deactive = $adminProductWrapper->getPreviewUrlDeactivate($preview_url); - } else { - $preview_url_deactive = $adminProductWrapper->getPreviewUrl($product, false); - $preview_url = $adminProductWrapper->getPreviewUrlDeactivate($preview_url_deactive); - } - - $doctrine = $this->getDoctrine()->getManager(); - $language = empty($languages[0]) ? ['id_lang' => 1, 'id_shop' => 1] : $languages[0]; - $attributeGroups = $doctrine->getRepository('PrestaShopBundle:Attribute')->findByLangAndShop((int) $language['id_lang'], (int) $language['id_shop']); - - $drawerModules = (new HookFinder())->setHookName('displayProductPageDrawer') - ->setParams(['product' => $product]) - ->addExpectedInstanceClasses('PrestaShop\PrestaShop\Core\Product\ProductAdminDrawer') - ->present(); - - return [ - 'form' => $form->createView(), - 'formCombinations' => $formBulkCombinations->createView(), - 'categories' => $this->get('prestashop.adapter.data_provider.category')->getCategoriesWithBreadCrumb(), - 'id_product' => $id, - 'ids_product_attribute' => (isset($formData['step3']['id_product_attributes']) ? implode(',', $formData['step3']['id_product_attributes']) : ''), - 'has_combinations' => (isset($formData['step3']['id_product_attributes']) && count($formData['step3']['id_product_attributes']) > 0), - 'combinations_count' => isset($formData['step3']['id_product_attributes']) ? count($formData['step3']['id_product_attributes']) : 0, - 'asm_globally_activated' => $stockManager->isAsmGloballyActivated(), - 'warehouses' => ($stockManager->isAsmGloballyActivated()) ? $warehouseProvider->getWarehouses() : [], - 'is_multishop_context' => $isMultiShopContext, - 'is_combination_active' => $this->get('prestashop.adapter.legacy.configuration')->combinationIsActive(), - 'showContentHeader' => false, - 'seo_link' => $adminProductWrapper->getPreviewUrl($product, false), - 'preview_link' => $preview_url, - 'preview_link_deactivate' => $preview_url_deactive, - 'stats_link' => $this->getAdminLink('AdminStats', ['module' => 'statsproduct', 'id_product' => $id]), - 'help_link' => $this->generateSidebarLink('AdminProducts'), - 'languages' => $languages, - 'default_language_iso' => $languages[0]['iso_code'], - 'attribute_groups' => $attributeGroups, - 'max_upload_size' => Tools::formatBytes(UploadedFile::getMaxFilesize()), - 'is_shop_context' => $this->get('prestashop.adapter.shop.context')->isShopContext(), - 'editable' => $this->isGranted(PageVoter::UPDATE, self::PRODUCT_OBJECT), - 'drawerModules' => $drawerModules, - 'layoutTitle' => $this->trans('Product', 'Admin.Global'), - ]; - } - - /** - * Builds the product form. - * - * @param Product $product - * @param AdminModelAdapter $modelMapper - * - * @return FormInterface - * - * @throws \Symfony\Component\Process\Exception\LogicException - */ - private function createProductForm(Product $product, AdminModelAdapter $modelMapper) - { - $formBuilder = $this->createFormBuilder( - $modelMapper->getFormData($product), - ['allow_extra_fields' => true] - ) - ->add('id_product', HiddenType::class) - ->add('step1', ProductInformation::class) - ->add('step2', ProductPrice::class, ['id_product' => $product->id]) - ->add('step3', ProductQuantity::class) - ->add('step4', ProductShipping::class) - ->add('step5', ProductSeo::class, [ - 'mapping_type' => $product->getRedirectType(), - ]) - ->add('step6', ProductOptions::class); - - // Prepare combination form (fake but just to validate the form) - $combinations = $product->getAttributesResume( - $this->getContext()->language->id - ); - - if (is_array($combinations)) { - $maxInputVars = (int) ini_get('max_input_vars'); - $combinationsCount = count($combinations) * 25; - $combinationsInputs = ceil($combinationsCount / 1000) * 1000; - - if ($combinationsInputs > $maxInputVars) { - $this->addFlash( - 'error', - $this->trans( - 'The value of the PHP.ini setting "max_input_vars" must be increased to %value% in order to be able to submit the product form.', - 'Admin.Notifications.Error', - ['%value%' => $combinationsInputs] - ) - ); - } - - foreach ($combinations as $combination) { - $formBuilder->add( - 'combination_' . $combination['id_product_attribute'], - ProductCombination::class - ); - } - } - - return $formBuilder->getForm(); - } - - /** - * Do bulk action on a list of Products. Used with the 'selection action' dropdown menu on the Catalog page. - * - * @param Request $request - * @param string $action The action to apply on the selected products - * - * @throws Exception if action not properly set or unknown - * - * @return \Symfony\Component\HttpFoundation\Response - */ - public function bulkAction(Request $request, $action) - { - if (!$this->actionIsAllowed($action, self::PRODUCT_OBJECT, '_all')) { - $this->addFlash('permission_error', $this->getForbiddenActionMessage($action)); - - return $this->redirectToRoute('admin_product_catalog'); - } - - $productIdList = $request->request->get('bulk_action_selected_products'); - /** @var $productUpdater ProductInterfaceUpdater */ - $productUpdater = $this->get('prestashop.core.admin.data_updater.product_interface'); - - /** @var $logger LoggerInterface */ - $logger = $this->get('logger'); - - $hookEventParameters = ['product_list_id' => $productIdList]; - /** @var HookDispatcher $hookDispatcher */ - $hookDispatcher = $this->get('prestashop.core.hook.dispatcher'); - - try { - $hasMessages = $this->get('session')->getFlashBag()->has('success'); - - if ($this->isDemoModeEnabled()) { - throw new UpdateProductException($this->getDemoModeErrorMessage()); - } - - switch ($action) { - case 'activate_all': - $hookDispatcher->dispatchWithParameters( - 'actionAdminActivateBefore', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerActivateBefore', - $hookEventParameters - ); - // Hooks: managed in ProductUpdater - $productUpdater->activateProductIdList($productIdList); - if (empty($hasMessages)) { - $this->addFlash( - 'success', - $this->trans('Product(s) successfully activated.', 'Admin.Catalog.Notification') - ); - } - - $logger->info('Products activated: (' . implode(',', $productIdList) . ').'); - $hookDispatcher->dispatchWithParameters( - 'actionAdminActivateAfter', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerActivateAfter', - $hookEventParameters - ); - - break; - case 'deactivate_all': - $hookDispatcher->dispatchWithParameters( - 'actionAdminDeactivateBefore', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerDeactivateBefore', - $hookEventParameters - ); - // Hooks: managed in ProductUpdater - $productUpdater->activateProductIdList($productIdList, false); - if (empty($hasMessages)) { - $this->addFlash( - 'success', - $this->trans('Product(s) successfully deactivated.', 'Admin.Catalog.Notification') - ); - } - - $logger->info('Products deactivated: (' . implode(',', $productIdList) . ').'); - $hookDispatcher->dispatchWithParameters( - 'actionAdminDeactivateAfter', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerDeactivateAfter', - $hookEventParameters - ); - - break; - case 'delete_all': - $hookDispatcher->dispatchWithParameters( - 'actionAdminDeleteBefore', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerDeleteBefore', - $hookEventParameters - ); - // Hooks: managed in ProductUpdater - $productUpdater->deleteProductIdList($productIdList); - if (empty($hasMessages)) { - $this->addFlash( - 'success', - $this->trans('Product(s) successfully deleted.', 'Admin.Catalog.Notification') - ); - } - - $logger->info('Products deleted: (' . implode(',', $productIdList) . ').'); - $hookDispatcher->dispatchWithParameters( - 'actionAdminDeleteAfter', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerDeleteAfter', - $hookEventParameters - ); - - break; - case 'duplicate_all': - $hookDispatcher->dispatchWithParameters( - 'actionAdminDuplicateBefore', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerDuplicateBefore', - $hookEventParameters - ); - // Hooks: managed in ProductUpdater - $productUpdater->duplicateProductIdList($productIdList); - if (empty($hasMessages)) { - $this->addFlash( - 'success', - $this->trans('Product(s) successfully duplicated.', 'Admin.Catalog.Notification') - ); - } - - $logger->info('Products duplicated: (' . implode(',', $productIdList) . ').'); - $hookDispatcher->dispatchWithParameters( - 'actionAdminDuplicateAfter', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerDuplicateAfter', - $hookEventParameters - ); - - break; - default: - /* - * should never happens since the route parameters are - * restricted to a set of action values in YML file. - */ - $logger->error('Bulk action from ProductController received a bad parameter.'); - - throw new Exception('Bad action received from call to ProductController::bulkAction: "' . $action . '"', 2001); - } - } catch (UpdateProductException $due) { - //TODO : need to translate this with an domain name - $message = $due->getMessage(); - $this->addFlash('failure', $message); - $logger->warning($message); - } - - return new Response(json_encode(['result' => 'ok'])); - } - - /** - * Do mass edit action on the current page of products. - * Used with the 'grouped action' dropdown menu on the Catalog page. - * - * @param Request $request - * @param string $action The action to apply on the selected products - * - * @throws Exception if action not properly set or unknown - * - * @return \Symfony\Component\HttpFoundation\Response - */ - public function massEditAction(Request $request, $action) - { - if (!$this->isGranted(PageVoter::UPDATE, self::PRODUCT_OBJECT)) { - $errorMessage = $this->trans( - 'You do not have permission to edit this.', - 'Admin.Notifications.Error' - ); - $this->get('session')->getFlashBag()->add('permission_error', $errorMessage); - - return $this->redirectToRoute('admin_product_catalog'); - } - - /** @var $productProvider ProductInterfaceProvider */ - $productProvider = $this->get('prestashop.core.admin.data_provider.product_interface'); - - /** @var $productUpdater ProductInterfaceUpdater */ - $productUpdater = $this->get('prestashop.core.admin.data_updater.product_interface'); - - /** @var $logger LoggerInterface */ - $logger = $this->get('logger'); - - /* @var HookDispatcher $hookDispatcher */ - $hookDispatcher = $this->get('prestashop.core.hook.dispatcher'); - - /* Initialize router params variable. */ - $routerParams = []; - - try { - switch ($action) { - case 'sort': - /* Change position_ordering to position */ - $routerParams['orderBy'] = 'position'; - - $productIdList = $request->request->get('mass_edit_action_sorted_products'); - $productPositionList = $request->request->get('mass_edit_action_sorted_positions'); - $hookEventParameters = [ - 'product_list_id' => $productIdList, - 'product_list_position' => $productPositionList, - ]; - - $hookDispatcher->dispatchWithParameters( - 'actionAdminSortBefore', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerSortBefore', - $hookEventParameters - ); - - // Hooks: managed in ProductUpdater - $persistedFilterParams = $productProvider->getPersistedFilterParameters(); - $productList = array_combine($productIdList, $productPositionList); - $productUpdater->sortProductIdList( - $productList, - ['filter_category' => $persistedFilterParams['filter_category']] - ); - - $this->addFlash( - 'success', - $this->trans('Products successfully sorted.', 'Admin.Catalog.Notification') - ); - $logger->info( - 'Products sorted: (' . implode(',', $productIdList) . - ') with positions (' . implode(',', $productPositionList) . ').' - ); - $hookEventParameters = [ - 'product_list_id' => $productIdList, - 'product_list_position' => $productPositionList, - ]; - $hookDispatcher->dispatchWithParameters( - 'actionAdminSortAfter', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerSortAfter', - $hookEventParameters - ); - - break; - default: - /* - * should never happens since the route parameters are - * restricted to a set of action values in YML file. - */ - $logger->error('Mass edit action from ProductController received a bad parameter.'); - - throw new Exception('Bad action received from call to ProductController::massEditAction: "' . $action . '"', 2001); - } - } catch (UpdateProductException $due) { - //TODO : need to translate with domain name - $message = $due->getMessage(); - $this->addFlash('failure', $message); - $logger->warning($message); - } - - $urlGenerator = $this->get('prestashop.core.admin.url_generator'); - - return $this->redirect($urlGenerator->generate('admin_product_catalog', $routerParams)); - } - - /** - * Do action on one product at a time. Can be used at many places in the controller's page. - * - * @param string $action The action to apply on the selected product - * @param int $id the product ID to apply the action on - * - * @throws Exception if action not properly set or unknown - * - * @return \Symfony\Component\HttpFoundation\Response - */ - public function unitAction($action, $id) - { - if (!$this->actionIsAllowed($action, self::PRODUCT_OBJECT)) { - $this->addFlash('permission_error', $this->getForbiddenActionMessage($action)); - - return $this->redirectToRoute('admin_product_catalog'); - } - - $productUpdater = $this->get('prestashop.core.admin.data_updater.product_interface'); - /** @var $productUpdater ProductInterfaceUpdater */ - - /** @var $logger LoggerInterface */ - $logger = $this->get('logger'); - - $hookEventParameters = ['product_id' => $id]; - /** @var HookDispatcher $hookDispatcher */ - $hookDispatcher = $this->get('prestashop.core.hook.dispatcher'); - - try { - if ($this->isDemoModeEnabled()) { - throw new UpdateProductException($this->getDemoModeErrorMessage()); - } - - switch ($action) { - case 'delete': - $hookDispatcher->dispatchWithParameters( - 'actionAdminDeleteBefore', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerDeleteBefore', - $hookEventParameters - ); - // Hooks: managed in ProductUpdater - $productUpdater->deleteProduct($id); - $this->addFlash( - 'success', - $this->trans('Product successfully deleted.', 'Admin.Catalog.Notification') - ); - $logger->info('Product deleted: (' . $id . ').'); - $hookDispatcher->dispatchWithParameters( - 'actionAdminDeleteAfter', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerDeleteAfter', - $hookEventParameters - ); - - break; - case 'duplicate': - $hookDispatcher->dispatchWithParameters( - 'actionAdminDuplicateBefore', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerDuplicateBefore', - $hookEventParameters - ); - // Hooks: managed in ProductUpdater - $duplicateProductId = $productUpdater->duplicateProduct($id); - $this->addFlash( - 'success', - $this->trans('Product successfully duplicated.', 'Admin.Catalog.Notification') - ); - $logger->info('Product duplicated: (from ' . $id . ' to ' . $duplicateProductId . ').'); - $hookDispatcher->dispatchWithParameters( - 'actionAdminDuplicateAfter', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerDuplicateAfter', - $hookEventParameters - ); - // stops here and redirect to the new product's page. - return $this->redirectToRoute('admin_product_form', ['id' => $duplicateProductId]); - case 'activate': - $hookDispatcher->dispatchWithParameters( - 'actionAdminActivateBefore', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerActivateBefore', - $hookEventParameters - ); - // Hooks: managed in ProductUpdater - $productUpdater->activateProductIdList([$id]); - $this->addFlash( - 'success', - $this->trans('Product successfully activated.', 'Admin.Catalog.Notification') - ); - $logger->info('Product activated: ' . $id); - $hookDispatcher->dispatchWithParameters( - 'actionAdminActivateAfter', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerActivateAfter', - $hookEventParameters - ); - - break; - case 'deactivate': - $hookDispatcher->dispatchWithParameters( - 'actionAdminDeactivateBefore', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerDeactivateBefore', - $hookEventParameters - ); - // Hooks: managed in ProductUpdater - $productUpdater->activateProductIdList([$id], false); - $this->addFlash( - 'success', - $this->trans('Product successfully deactivated.', 'Admin.Catalog.Notification') - ); - $logger->info('Product deactivated: ' . $id); - $hookDispatcher->dispatchWithParameters( - 'actionAdminDeactivateAfter', - $hookEventParameters - ); - $hookDispatcher->dispatchWithParameters( - 'actionAdminProductsControllerDeactivateAfter', - $hookEventParameters - ); - - break; - default: - /* - * should never happens since the route parameters are - * restricted to a set of action values in YML file. - */ - $logger->error('Unit action from ProductController received a bad parameter.'); - - throw new Exception('Bad action received from call to ProductController::unitAction: "' . $action . '"', 2002); - } - } catch (UpdateProductException $due) { - //TODO : need to translate with a domain name - $message = $due->getMessage(); - $this->addFlash('failure', $message); - $logger->warning($message); - } - - return $this->redirect($this->get('prestashop.core.admin.url_generator')->generate('admin_product_catalog')); - } - - /** - * Toggle product status - * - * @AdminSecurity( - * "is_granted(['update'], request.get('_legacy_controller'))", - * message="You do not have permission to update this." - * ) - * - * @param $productId - * - * @return JsonResponse - */ - public function toggleStatusAction($productId) - { - if ($this->isDemoModeEnabled()) { - return $this->json([ - 'status' => false, - 'message' => $this->getDemoModeErrorMessage(), - ]); - } - - try { - $isEnabled = $this->getQueryBus()->handle(new GetProductIsEnabled($productId)); - - $this->getCommandBus()->handle(new UpdateProductStatusCommand($productId, !$isEnabled)); - $response = [ - 'status' => true, - 'message' => $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success'), - ]; - } catch (ProductException $e) { - $response = [ - 'status' => false, - 'message' => $this->getErrorMessageForException($e, $this->getErrorMessages()), - ]; - } - - return $this->json($response); - } - - /** - * @return CsvResponse - * - * @throws \Symfony\Component\Translation\Exception\InvalidArgumentException - */ - public function exportAction() - { - return $this->get('prestashop.core.product.csv_exporter')->export(); - } - - /** - * Set the Catalog filters values and redirect to the catalogAction. - * - * URL example: /product/catalog_filters/42/last/32 - * - * @param int|string $quantity the quantity to set on the catalog filters persistence - * @param string $active the activation state to set on the catalog filters persistence - * - * @return RedirectResponse - */ - public function catalogFiltersAction($quantity = 'none', $active = 'none') - { - $quantity = urldecode($quantity); - - /** @var ProductInterfaceProvider $productProvider */ - $productProvider = $this->get('prestashop.core.admin.data_provider.product_interface'); - - // we merge empty filter set with given values, to reset the other filters! - $productProvider->persistFilterParameters( - array_merge( - AdminFilter::getProductCatalogEmptyFilter(), - [ - 'filter_column_sav_quantity' => ($quantity == 'none') ? '' : $quantity, - 'filter_column_active' => ($active == 'none') ? '' : $active, - ] - ) - ); - - return $this->redirectToRoute('admin_product_catalog'); - } - - /** - * @deprecated since 1.7.5.0, to be removed in 1.8 rely on CommonController::renderFieldAction - * - * @throws \OutOfBoundsException - * @throws \LogicException - * @throws \PrestaShopException - */ - public function renderFieldAction($productId, $step, $fieldName) - { - @trigger_error( - 'This function is deprecated, use CommonController::renderFieldAction instead.', - E_USER_DEPRECATED - ); - - $productAdapter = $this->get('prestashop.adapter.data_provider.product'); - $product = $productAdapter->getProduct($productId); - $modelMapper = new AdminModelAdapter( - $product, - $this->get('prestashop.adapter.legacy.context'), - $this->get('prestashop.adapter.admin.wrapper.product'), - $this->get('prestashop.adapter.tools'), - $productAdapter, - $this->get('prestashop.adapter.data_provider.supplier'), - $this->get('prestashop.adapter.data_provider.warehouse'), - $this->get('prestashop.adapter.data_provider.feature'), - $this->get('prestashop.adapter.data_provider.pack'), - $this->get('prestashop.adapter.shop.context'), - $this->get('prestashop.adapter.data_provider.tax'), - $this->get('router') - ); - $form = $this->createFormBuilder($modelMapper->getFormData()); - switch ($step) { - case 'step1': - $form->add('step1', 'PrestaShopBundle\Form\Admin\Product\ProductInformation'); - - break; - case 'step2': - $form->add('step2', 'PrestaShopBundle\Form\Admin\Product\ProductPrice'); - - break; - case 'step3': - $form->add('step3', 'PrestaShopBundle\Form\Admin\Product\ProductQuantity'); - - break; - case 'step4': - $form->add('step4', 'PrestaShopBundle\Form\Admin\Product\ProductShipping'); - - break; - case 'step5': - $form->add('step5', 'PrestaShopBundle\Form\Admin\Product\ProductSeo'); - - break; - case 'step6': - $form->add('step6', 'PrestaShopBundle\Form\Admin\Product\ProductOptions'); - - break; - case 'default': - } - - return $this->render('@PrestaShop/Admin/Common/_partials/_form_field.html.twig', [ - 'form' => $form->getForm()->get($step)->get($fieldName)->createView(), - 'formId' => $step . '_' . $fieldName . '_rendered', - ]); - } - - /** - * @return array - */ - private function getErrorMessages(): array - { - return [ - ProductNotFoundException::class => $this->trans('The object cannot be loaded (or found)', 'Admin.Notifications.Error'), - CannotUpdateProductException::class => $this->trans('An error occurred while updating the status for an object.', 'Admin.Notifications.Error'), - ]; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/ProductImageController.php b/src/PrestaShopBundle/Controller/Admin/ProductImageController.php deleted file mode 100644 index fce00018..00000000 --- a/src/PrestaShopBundle/Controller/Admin/ProductImageController.php +++ /dev/null @@ -1,195 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin; - -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; -use Symfony\Component\Form\Extension\Core\Type\FormType; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Validator\Constraints as Assert; - -/** - * Admin controller for product images. - */ -class ProductImageController extends FrameworkBundleAdminController -{ - /** - * Manage upload for product image. - * - * @param int $idProduct - * @param Request $request - * - * @return string - */ - public function uploadImageAction($idProduct, Request $request) - { - $response = new JsonResponse(); - $adminProductWrapper = $this->get('prestashop.adapter.admin.wrapper.product'); - $return_data = []; - - if ($idProduct == 0 || !$request->isXmlHttpRequest()) { - return $response; - } - - $form = $this->createFormBuilder(null, ['csrf_protection' => false]) - ->add('file', 'Symfony\Component\Form\Extension\Core\Type\FileType', [ - 'error_bubbling' => true, - 'constraints' => [ - new Assert\NotNull(['message' => $this->trans('Please select a file', 'Admin.Catalog.Feature')]), - new Assert\Image(['maxSize' => $this->configuration->get('PS_ATTACHMENT_MAXIMUM_SIZE') . 'M']), - ], - ]) - ->getForm(); - - $form->handleRequest($request); - - if ($request->isMethod('POST')) { - if ($form->isValid()) { - $return_data = $adminProductWrapper->getInstance()->ajaxProcessaddProductImage($idProduct, 'form', false)[0]; - $return_data = array_merge($return_data, [ - 'url_update' => $this->generateUrl('admin_product_image_form', ['idImage' => $return_data['id']]), - 'url_delete' => $this->generateUrl('admin_product_image_delete', ['idImage' => $return_data['id']]), - ]); - } else { - $error_msg = []; - foreach ($form->getErrors() as $error) { - $error_msg[] = $error->getMessage(); - } - $return_data = ['message' => implode(' ', $error_msg)]; - $response->setStatusCode(400); - } - } - - return $response->setData($return_data); - } - - /** - * Update images positions. - * - * @param Request $request - * - * @return JsonResponse - */ - public function updateImagePositionAction(Request $request) - { - $response = new JsonResponse(); - $adminProductWrapper = $this->get('prestashop.adapter.admin.wrapper.product'); - $json = $request->request->get('json'); - - if (!empty($json) && $request->isXmlHttpRequest()) { - $adminProductWrapper->ajaxProcessUpdateImagePosition(json_decode($json, true)); - } - - return $response; - } - - /** - * Manage form image. - * - * @Template("@PrestaShop/Admin/ProductImage/form.html.twig") - * - * @param $idImage - * @param Request $request - * - * @return array|JsonResponse|Response - */ - public function formAction($idImage, Request $request) - { - $locales = $this->get('prestashop.adapter.legacy.context')->getLanguages(); - $adminProductWrapper = $this->get('prestashop.adapter.admin.wrapper.product'); - $productAdapter = $this->get('prestashop.adapter.data_provider.product'); - - if ($idImage == 0 || !$request->isXmlHttpRequest()) { - return new Response(); - } - - $image = $productAdapter->getImage((int) $idImage); - - $form = $this->get('form.factory')->createNamedBuilder('form_image', FormType::class, $image, ['csrf_protection' => false]) - ->add('legend', 'PrestaShopBundle\Form\Admin\Type\TranslateType', [ - 'type' => 'Symfony\Component\Form\Extension\Core\Type\TextareaType', - 'options' => [], - 'locales' => $locales, - 'hideTabs' => true, - 'label' => $this->trans('Caption', 'Admin.Catalog.Feature'), - 'required' => false, - ]) - ->add('cover', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', [ - 'label' => $this->trans('Cover image', 'Admin.Catalog.Feature'), - 'required' => false, - ]) - ->getForm(); - - $form->handleRequest($request); - - if ($request->isMethod('POST')) { - $jsonResponse = new JsonResponse(); - - if ($form->isValid()) { - $jsonResponse->setData($adminProductWrapper->ajaxProcessUpdateImage($idImage, $form->getData())); - } else { - $error_msg = []; - foreach ($form->getErrors() as $error) { - $error_msg[] = $error->getMessage(); - } - - $jsonResponse->setData(['message' => implode(' ', $error_msg)]); - $jsonResponse->setStatusCode(400); - } - - return $jsonResponse; - } - - return [ - 'image' => $image, - 'form' => $form->createView(), - ]; - } - - /** - * Delete an image from its ID. - * - * @param int $idImage - * @param Request $request - * - * @return JsonResponse - */ - public function deleteAction($idImage, Request $request) - { - $response = new JsonResponse(); - $adminProductWrapper = $this->get('prestashop.adapter.admin.wrapper.product'); - - if (!$request->isXmlHttpRequest()) { - return $response; - } - - $adminProductWrapper->getInstance()->ajaxProcessDeleteProductImage($idImage); - - return $response; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/SecurityController.php b/src/PrestaShopBundle/Controller/Admin/SecurityController.php deleted file mode 100644 index 053affe1..00000000 --- a/src/PrestaShopBundle/Controller/Admin/SecurityController.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin; - -use PrestaShopBundle\Service\Routing\Router as PrestaShopRouter; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Validator\Constraints as Assert; - -/** - * Admin controller to manage security pages. - */ -class SecurityController extends FrameworkBundleAdminController -{ - public function compromisedAccessAction(Request $request) - { - $requestUri = urldecode($request->query->get('uri')); - $url = new Assert\Url(); - $violations = $this->get('validator')->validate($requestUri, [$url]); - if ($violations->count()) { - return $this->redirect('dashboard'); - } - - // getToken() actually generate a new token - $username = $this->get('prestashop.user_provider')->getUsername(); - - $newToken = $this->get('security.csrf.token_manager') - ->getToken($username) - ->getValue(); - - $newUri = PrestaShopRouter::generateTokenizedUrl($requestUri, $newToken); - - return $this->render( - '@PrestaShop/Admin/Security/compromised.html.twig', - [ - 'requestUri' => $newUri, - ] - ); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Address/AddressController.php b/src/PrestaShopBundle/Controller/Admin/Sell/Address/AddressController.php deleted file mode 100644 index 3574b52b..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/Address/AddressController.php +++ /dev/null @@ -1,685 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\Address; - -use Cart; -use Exception; -use Order; -use PrestaShop\PrestaShop\Adapter\Customer\CustomerDataProvider; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\BulkDeleteAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\DeleteAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\SetRequiredFieldsForAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\BulkDeleteAddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\CannotAddAddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\CannotSetRequiredFieldsForAddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\CannotUpdateAddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\DeleteAddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\InvalidAddressFieldException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\InvalidAddressRequiredFieldsException; -use PrestaShop\PrestaShop\Core\Domain\Address\Query\GetCustomerAddressForEditing; -use PrestaShop\PrestaShop\Core\Domain\Address\Query\GetRequiredFieldsForAddress; -use PrestaShop\PrestaShop\Core\Domain\Address\QueryResult\EditableCustomerAddress; -use PrestaShop\PrestaShop\Core\Domain\Cart\CartAddressType; -use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerByEmailNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Order\OrderAddressType; -use PrestaShop\PrestaShop\Core\Domain\State\Exception\StateConstraintException; -use PrestaShop\PrestaShop\Core\Search\Filters\AddressFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Form\Admin\Sell\Address\RequiredFieldsAddressType; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class manages "Sell > Customers > Addresses" page. - */ -class AddressController extends FrameworkBundleAdminController -{ - /** - * Show addresses listing page - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * @param AddressFilters $filters - * - * @return Response - */ - public function indexAction(Request $request, AddressFilters $filters): Response - { - $addressGridFactory = $this->get('prestashop.core.grid.grid_factory.address'); - $addressGrid = $addressGridFactory->getGrid($filters); - $requiredFieldsForm = $this->getRequiredFieldsForm(); - - return $this->render('@PrestaShop/Admin/Sell/Address/index.html.twig', [ - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'addressGrid' => $this->presentGrid($addressGrid), - 'enableSidebar' => true, - 'layoutHeaderToolbarBtn' => $this->getAddressToolbarButtons(), - 'requiredFieldsForm' => $requiredFieldsForm->createView(), - ]); - } - - /** - * Process addresses required fields configuration form. - * - * @AdminSecurity( - * "is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", - * redirectRoute="admin_addresses_index" - * ) - * - * @param Request $request - * - * @return RedirectResponse - * - * @throws Exception - */ - public function saveRequiredFieldsAction(Request $request): RedirectResponse - { - $addressRequiredFieldsForm = $this->getRequiredFieldsForm(); - $addressRequiredFieldsForm->handleRequest($request); - - if ($addressRequiredFieldsForm->isSubmitted() && $addressRequiredFieldsForm->isValid()) { - $data = $addressRequiredFieldsForm->getData(); - - try { - $this->getCommandBus()->handle(new SetRequiredFieldsForAddressCommand($data['required_fields'])); - $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success')); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - } - - return $this->redirectToRoute('admin_addresses_index'); - } - - /** - * Deletes address - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", redirectRoute="admin_addresses_index") - * - * @param int $addressId - * - * @return RedirectResponse - */ - public function deleteAction(Request $request, int $addressId): RedirectResponse - { - try { - $this->getCommandBus()->handle(new DeleteAddressCommand($addressId)); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $request->query->has('redirectUrl') ? - $this->redirect($request->query->get('redirectUrl')) : - $this->redirectToRoute('admin_addresses_index'); - } - - /** - * Delete addresses in bulk action. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_addresses_index", - * message="You do not have permission to delete this." - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function deleteBulkAction(Request $request): RedirectResponse - { - $addressIds = $this->getBulkAddressesFromRequest($request); - - try { - $this->getCommandBus()->handle(new BulkDeleteAddressCommand($addressIds)); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_addresses_index'); - } - - /** - * @return array - */ - private function getAddressToolbarButtons(): array - { - $toolbarButtons = []; - - $toolbarButtons['add'] = [ - 'href' => $this->generateUrl('admin_addresses_create'), - 'desc' => $this->trans('Add new address', 'Admin.Orderscustomers.Feature'), - 'icon' => 'add_circle_outline', - ]; - - return $toolbarButtons; - } - - /** - * @return FormInterface - */ - private function getRequiredFieldsForm(): FormInterface - { - $requiredFields = $this->getQueryBus()->handle(new GetRequiredFieldsForAddress()); - - return $this->createForm(RequiredFieldsAddressType::class, ['required_fields' => $requiredFields]); - } - - /** - * @param Request $request - * - * @return array - */ - private function getBulkAddressesFromRequest(Request $request): array - { - $addressIds = $request->request->get('address_addresses_bulk'); - - if (!is_array($addressIds)) { - return []; - } - - foreach ($addressIds as $i => $addressId) { - $addressIds[$i] = (int) $addressId; - } - - return $addressIds; - } - - /** - * Show "Add new" form and handle form submit. - * - * @AdminSecurity( - * "is_granted(['create'], request.get('_legacy_controller'))", - * redirectRoute="admin_addresses_index", - * message="You do not have permission to create this." - * ) - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request): Response - { - $addressFormBuilder = $this->get( - 'prestashop.core.form.identifiable_object.builder.address_form_builder' - ); - - $addressFormHandler = $this->get( - 'prestashop.core.form.identifiable_object.handler.address_form_handler' - ); - - $formData = []; - $customerInfo = null; - $customerId = null; - if ($request->request->has('customer_address')) { - if (isset($request->request->get('customer_address')['id_country'])) { - $formCountryId = (int) $request->request->get('customer_address')['id_country']; - $formData['id_country'] = $formCountryId; - } - if (isset($request->request->get('customer_address')['id_customer'])) { - $idCustomer = (int) $request->request->get('customer_address')['id_customer']; - $formData['id_customer'] = $idCustomer; - } - } - - if (empty($formData['id_customer']) && $request->query->has('id_customer')) { - $formData['id_customer'] = (int) $request->query->get('id_customer'); - } - - if (!empty($formData['id_customer'])) { - /** @var CustomerDataProvider $customerDataProvider */ - $customerDataProvider = $this->get('prestashop.adapter.data_provider.customer'); - $customerId = $formData['id_customer']; - $customer = $customerDataProvider->getCustomer($customerId); - $formData['first_name'] = $customer->firstname; - $formData['last_name'] = $customer->lastname; - $formData['company'] = $customer->company; - $customerInfo = $customer->firstname . ' ' . $customer->lastname . ' (' . $customer->email . ')'; - } - - $addressForm = $addressFormBuilder->getForm($formData); - $addressForm->handleRequest($request); - - try { - $handlerResult = $addressFormHandler->handle($addressForm); - if ($handlerResult->isSubmitted() && $handlerResult->isValid()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - if ($request->query->has('submitFormAjax')) { - return $this->render( - '@PrestaShop/Admin/Sell/Address/modal_create_success.html.twig', - ['refreshCartAddresses' => 'true'] - ); - } - - return $this->redirectToRoute('admin_addresses_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->render('@PrestaShop/Admin/Sell/Address/add.html.twig', [ - 'customerId' => $customerId, - 'customerInformation' => $customerInfo, - 'enableSidebar' => true, - 'displayInIframe' => $request->query->has('submitFormAjax'), - 'addressForm' => $addressForm->createView(), - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'cancelPath' => $request->query->has('back') ? $request->query->get('back') : $this->generateUrl('admin_addresses_index'), - ]); - } - - /** - * Handles edit form rendering and submission - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_addresses_index" - * ) - * - * @param int $addressId - * @param Request $request - * - * @return Response - */ - public function editAction(int $addressId, Request $request): Response - { - try { - /** @var EditableCustomerAddress $editableAddress */ - $editableAddress = $this->getQueryBus()->handle(new GetCustomerAddressForEditing((int) $addressId)); - - $addressFormBuilder = $this->get( - 'prestashop.core.form.identifiable_object.builder.address_form_builder' - ); - $addressFormHandler = $this->get( - 'prestashop.core.form.identifiable_object.handler.address_form_handler' - ); - - $formData = []; - // Country needs to be preset before building form type because it is used to build state field choices - if ($request->request->has('customer_address') && isset($request->request->get('customer_address')['id_country'])) { - $formCountryId = (int) $request->request->get('customer_address')['id_country']; - $formData['id_country'] = $formCountryId; - } - - $addressForm = $addressFormBuilder->getFormFor($addressId, $formData); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - - return $this->redirectToRoute('admin_addresses_index'); - } - - try { - $addressForm->handleRequest($request); - $result = $addressFormHandler->handleFor($addressId, $addressForm); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success')); - - if ($request->query->has('submitFormAjax')) { - return $this->render( - '@PrestaShop/Admin/Sell/Address/modal_create_success.html.twig', - ['refreshCartAddresses' => 'false'] - ); - } - - return $this->redirectToRoute('admin_addresses_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - $customerInfo = $editableAddress->getLastName() . ' ' . - $editableAddress->getFirstName() . ' (' . - $editableAddress->getCustomerEmail() . ')'; - - return $this->render('@PrestaShop/Admin/Sell/Address/edit.html.twig', [ - 'enableSidebar' => true, - 'customerId' => $editableAddress->getCustomerId()->getValue(), - 'customerInformation' => $customerInfo, - 'layoutTitle' => $this->trans('Edit', 'Admin.Actions'), - 'displayInIframe' => $request->query->has('submitFormAjax'), - 'addressForm' => $addressForm->createView(), - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - ]); - } - - /** - * Handles edit form rendering and submission for order address - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_orders_index" - * ) - * - * @param int $orderId - * @param string $addressType - * @param Request $request - * - * @return Response - */ - public function editOrderAddressAction(int $orderId, string $addressType, Request $request): Response - { - // @todo: don't rely on Order ObjectModel, use a Adapter DataProvider - $order = new Order($orderId); - $addressId = null; - switch ($addressType) { - case 'delivery': - $addressType = OrderAddressType::DELIVERY_ADDRESS_TYPE; - $addressId = $order->id_address_delivery; - break; - case 'invoice': - $addressType = OrderAddressType::INVOICE_ADDRESS_TYPE; - $addressId = $order->id_address_invoice; - break; - } - - try { - /** @var EditableCustomerAddress $editableAddress */ - $editableAddress = $this->getQueryBus()->handle(new GetCustomerAddressForEditing((int) $addressId)); - - $addressFormBuilder = $this->get( - 'prestashop.core.form.identifiable_object.builder.address_form_builder' - ); - // Special order handler - $addressFormHandler = $this->get( - 'prestashop.core.form.identifiable_object.handler.order_address_form_handler' - ); - - // Address type required for EditOrderAddressCommand - $formData = [ - 'address_type' => $addressType, - ]; - // Country needs to be preset before building form type because it is used to build state field choices - if ($request->request->has('customer_address') && isset($request->request->get('customer_address')['id_country'])) { - $formCountryId = (int) $request->request->get('customer_address')['id_country']; - $formData['id_country'] = $formCountryId; - } - - // Address form is built based on address id to fill the data related to this address - $addressForm = $addressFormBuilder->getFormFor($addressId, $formData); - } catch (Exception $e) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($e, $this->getErrorMessages($e)) - ); - - return $this->redirectToRoute('admin_orders_view', ['orderId' => $orderId]); - } - - try { - $addressForm->handleRequest($request); - - // Form is handled based on Order ID because that's the order that needs update - $result = $addressFormHandler->handleFor($orderId, $addressForm); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success')); - - if ($request->query->has('submitFormAjax')) { - return $this->render( - '@PrestaShop/Admin/Sell/Address/modal_create_success.html.twig', - ['refreshCartAddresses' => 'false'] - ); - } - - return $this->redirectToRoute('admin_orders_view', ['orderId' => $orderId]); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - $customerInfo = $editableAddress->getLastName() . ' ' . - $editableAddress->getFirstName() . ' (' . - $editableAddress->getCustomerEmail() . ')'; - - return $this->render('@PrestaShop/Admin/Sell/Address/edit.html.twig', [ - 'enableSidebar' => true, - 'customerId' => $editableAddress->getCustomerId()->getValue(), - 'customerInformation' => $customerInfo, - 'layoutTitle' => $this->trans('Edit', 'Admin.Actions'), - 'addressForm' => $addressForm->createView(), - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'cancelPath' => $this->generateUrl('admin_orders_view', ['orderId' => $orderId]), - 'displayInIframe' => $request->query->has('submitFormAjax'), - ]); - } - - /** - * Handles edit form rendering and submission for cart address - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_orders_index" - * ) - * - * @param int $cartId - * @param string $addressType - * @param Request $request - * - * @return Response - */ - public function editCartAddressAction(int $cartId, string $addressType, Request $request): Response - { - // @todo: don't rely on Cart ObjectModel, use a Adapter DataProvider - $cart = new Cart($cartId); - $addressId = null; - switch ($addressType) { - case 'delivery': - $addressType = CartAddressType::DELIVERY_ADDRESS_TYPE; - $addressId = $cart->id_address_delivery; - break; - case 'invoice': - $addressType = CartAddressType::INVOICE_ADDRESS_TYPE; - $addressId = $cart->id_address_invoice; - break; - } - - try { - /** @var EditableCustomerAddress $editableAddress */ - $editableAddress = $this->getQueryBus()->handle(new GetCustomerAddressForEditing((int) $addressId)); - - $addressFormBuilder = $this->get( - 'prestashop.core.form.identifiable_object.builder.address_form_builder' - ); - // Special cart handler - $addressFormHandler = $this->get( - 'prestashop.core.form.identifiable_object.handler.cart_address_form_handler' - ); - - // Address type required for EditCartAddressCommand - $formData = [ - 'address_type' => $addressType, - ]; - // Country needs to be preset before building form type because it is used to build state field choices - if ($request->request->has('customer_address') && isset($request->request->get('customer_address')['id_country'])) { - $formCountryId = (int) $request->request->get('customer_address')['id_country']; - $formData['id_country'] = $formCountryId; - } - - // Address form is built based on address id to fill the data related to this address - $addressForm = $addressFormBuilder->getFormFor($addressId, $formData); - } catch (Exception $e) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($e, $this->getErrorMessages($e)) - ); - - return $this->redirectToRoute('admin_carts_view', ['cartId' => $cartId]); - } - - try { - $addressForm->handleRequest($request); - - // Form is handled based on Cart ID because that's the cart that needs update - $result = $addressFormHandler->handleFor($cartId, $addressForm); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success')); - - if ($request->query->has('submitFormAjax')) { - return $this->render( - '@PrestaShop/Admin/Sell/Address/modal_create_success.html.twig', - ['refreshCartAddresses' => 'true'] - ); - } - - return $this->redirectToRoute('admin_carts_view', ['cartId' => $cartId]); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - $customerInfo = $editableAddress->getLastName() . ' ' . - $editableAddress->getFirstName() . ' (' . - $editableAddress->getCustomerEmail() . ')'; - - return $this->render('@PrestaShop/Admin/Sell/Address/edit.html.twig', [ - 'enableSidebar' => true, - 'customerId' => $editableAddress->getCustomerId()->getValue(), - 'customerInformation' => $customerInfo, - 'layoutTitle' => $this->trans('Edit', 'Admin.Actions'), - 'addressForm' => $addressForm->createView(), - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'cancelPath' => $this->generateUrl('admin_carts_view', ['cartId' => $cartId]), - 'displayInIframe' => $request->query->has('submitFormAjax'), - ]); - } - - /** - * @param Exception $e - * - * @return array - */ - private function getErrorMessages(Exception $e): array - { - return [ - DeleteAddressException::class => [ - DeleteAddressException::FAILED_DELETE => $this->trans( - 'An error occurred while deleting the object.', - 'Admin.Notifications.Error' - ), - ], - BulkDeleteAddressException::class => sprintf( - '%s: %s', - $this->trans( - 'An error occurred while deleting this selection.', - 'Admin.Notifications.Error' - ), - $e instanceof BulkDeleteAddressException ? $e->getAddressIds() : '' - ), - AddressNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - CannotSetRequiredFieldsForAddressException::class => $this->trans( - 'An error occurred when attempting to update the required fields.', - 'Admin.Notifications.Error' - ), - AddressException::class => sprintf( - $this->trans( - 'Internal error #%s', - 'Admin.Notifications.Error' - ), - $e->getMessage() - ), - InvalidAddressRequiredFieldsException::class => $this->trans( - 'Invalid data supplied.', - 'Admin.Notifications.Error' - ), - AddressConstraintException::class => [ - AddressConstraintException::INVALID_ID => $this->trans( - 'The object cannot be loaded (the identifier is missing or invalid)', - 'Admin.Notifications.Error' - ), - AddressConstraintException::INVALID_REQUIRED_FIELDS => $this->trans( - 'An error occurred when attempting to update the required fields.', - 'Admin.Notifications.Error' - ), - ], - InvalidAddressFieldException::class => $this->trans( - 'Address fields contain invalid values.', - 'Admin.Notifications.Error' - ), - StateConstraintException::class => [ - StateConstraintException::INVALID_ID => $this->trans( - 'The object cannot be loaded (the identifier is missing or invalid)', - 'Admin.Notifications.Error' - ), - ], - CannotUpdateAddressException::class => $this->trans( - 'An error occurred while attempting to save.', - 'Admin.Notifications.Error' - ), - CannotAddAddressException::class => $this->trans( - 'An error occurred while attempting to save.', - 'Admin.Notifications.Error' - ), - CustomerException::class => $this->trans( - 'The object cannot be loaded (the identifier is missing or invalid)', - 'Admin.Notifications.Error' - ), - CountryConstraintException::class => [ - CountryConstraintException::INVALID_ID => $this->trans( - 'The object cannot be loaded (the identifier is missing or invalid)', - 'Admin.Notifications.Error' - ), - ], - CustomerNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - CountryNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - CustomerByEmailNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - ]; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/AttachmentController.php b/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/AttachmentController.php deleted file mode 100644 index 9fa7a1f5..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/AttachmentController.php +++ /dev/null @@ -1,361 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\Catalog; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Command\BulkDeleteAttachmentsCommand; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Command\DeleteAttachmentCommand; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\AttachmentUploadFailedException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\BulkDeleteAttachmentsException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\CannotAddAttachmentException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\CannotUnlinkAttachmentException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\CannotUpdateAttachmentException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\DeleteAttachmentException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Exception\EmptyFileException; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Query\GetAttachment; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Query\GetAttachmentForEditing; -use PrestaShop\PrestaShop\Core\Domain\Attachment\QueryResult\Attachment; -use PrestaShop\PrestaShop\Core\Domain\Attachment\QueryResult\EditableAttachment; -use PrestaShop\PrestaShop\Core\Search\Filters\AttachmentFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class is responsible for "Sell > Catalog > Files" page. - */ -class AttachmentController extends FrameworkBundleAdminController -{ - /** - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - */ - public function indexAction(Request $request, AttachmentFilters $filters): Response - { - $attachmentGridFactory = $this->get('prestashop.core.grid.factory.attachment'); - $attachmentGrid = $attachmentGridFactory->getGrid($filters); - - return $this->render('@PrestaShop/Admin/Sell/Catalog/Attachment/index.html.twig', [ - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'attachmentGrid' => $this->presentGrid($attachmentGrid), - 'enableSidebar' => true, - 'layoutHeaderToolbarBtn' => $this->getAttachmentToolbarButtons(), - ]); - } - - /** - * Show "Add new" form and handle form submit. - * - * @AdminSecurity( - * "is_granted(['create'], request.get('_legacy_controller'))", - * redirectRoute="admin_attachments_index", - * message="You do not have permission to create this." - * ) - * - * @return Response - */ - public function createAction(Request $request) - { - $attachmentFormBuilder = $this->get( - 'prestashop.core.form.identifiable_object.builder.attachment_form_builder' - ); - $attachmentFormHandler = $this->get( - 'prestashop.core.form.identifiable_object.handler.attachment_form_handler' - ); - - $attachmentForm = $attachmentFormBuilder->getForm(); - - $attachmentForm->handleRequest($request); - - try { - $handlerResult = $attachmentFormHandler->handle($attachmentForm); - - if ($handlerResult->isSubmitted() && $handlerResult->isValid()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_attachments_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->render('@PrestaShop/Admin/Sell/Catalog/Attachment/add.html.twig', [ - 'enableSidebar' => true, - 'layoutTitle' => $this->trans('Add new file', 'Admin.Catalog.Feature'), - 'attachmentForm' => $attachmentForm->createView(), - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - ]); - } - - /** - * Show & process attachment editing. - * - * @AdminSecurity( - * "is_granted(['update'], request.get('_legacy_controller'))", - * redirectRoute="admin_attachments_index", - * message="You do not have permission to edit this." - * ) - * - * @param int $attachmentId - * - * @return Response - */ - public function editAction($attachmentId, Request $request) - { - try { - /** @var EditableAttachment $attachmentInformation */ - $attachmentInformation = $this->getQueryBus()->handle(new GetAttachmentForEditing((int) $attachmentId)); - - $attachmentFormBuilder = $this->get( - 'prestashop.core.form.identifiable_object.builder.attachment_form_builder' - ); - $attachmentFormHandler = $this->get( - 'prestashop.core.form.identifiable_object.handler.attachment_form_handler' - ); - - $attachmentForm = $attachmentFormBuilder->getFormFor((int) $attachmentId); - - $attachmentForm->handleRequest($request); - $result = $attachmentFormHandler->handleFor((int) $attachmentId, $attachmentForm); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_attachments_index'); - } - } catch (CannotUnlinkAttachmentException $e) { - $this->addFlash('warning', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - - return $this->redirectToRoute('admin_attachments_index'); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - - if ($e instanceof AttachmentNotFoundException) { - return $this->redirectToRoute('admin_attachments_index'); - } - } - - if (!isset($attachmentInformation) || !isset($attachmentForm)) { - return $this->redirectToRoute('admin_attachments_index'); - } - - $names = $attachmentInformation->getName(); - - return $this->render('@PrestaShop/Admin/Sell/Catalog/Attachment/edit.html.twig', [ - 'enableSidebar' => true, - 'layoutTitle' => $this->trans( - 'Edit: %value%', - 'Admin.Catalog.Feature', - ['%value%' => reset($names)] - ), - 'attachmentForm' => $attachmentForm->createView(), - 'attachmentId' => $attachmentId, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - ]); - } - - /** - * View attachment. - * - * @AdminSecurity( - * "is_granted(['read'], request.get('_legacy_controller'))", - * redirectRoute="admin_attachments_index", - * message="You do not have permission to edit this." - * ) - */ - public function viewAction(int $attachmentId): Response - { - try { - /** @var Attachment $attachment */ - $attachment = $this->getCommandBus()->handle(new GetAttachment((int) $attachmentId)); - - return $this->file($attachment->getPath(), $attachment->getName()); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_attachments_index'); - } - - /** - * Deletes attachment - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", redirectRoute="admin_attachments_index") - * @DemoRestricted(redirectRoute="admin_attachments_index") - */ - public function deleteAction(int $attachmentId): RedirectResponse - { - try { - $this->getCommandBus()->handle(new DeleteAttachmentCommand((int) $attachmentId)); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_attachments_index'); - } - - /** - * Delete attachments in bulk action. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_attachments_index", - * message="You do not have permission to delete this." - * ) - */ - public function deleteBulkAction(Request $request): RedirectResponse - { - $attachmentIds = $this->getBulkAttachmentsFromRequest($request); - - try { - $this->getCommandBus()->handle(new BulkDeleteAttachmentsCommand($attachmentIds)); - $this->addFlash( - 'success', - $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_attachments_index'); - } - - /** - * @param Exception $e - */ - private function getErrorMessages(Exception $e = null): array - { - return [ - DeleteAttachmentException::class => $this->trans( - 'An error occurred while deleting the object.', - 'Admin.Notifications.Error' - ), - AttachmentNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - AttachmentConstraintException::class => [ - AttachmentConstraintException::INVALID_ID => $this->trans( - 'The object cannot be loaded (the identifier is missing or invalid)', - 'Admin.Notifications.Error' - ), - AttachmentConstraintException::INVALID_FILE_SIZE => $this->trans( - 'Upload error. Please check your server configurations for the maximum upload size allowed.', - 'Admin.Catalog.Notification' - ), - AttachmentConstraintException::EMPTY_NAME => $this->trans( - 'An attachment name is required.', - 'Admin.Catalog.Notification' - ), - AttachmentConstraintException::EMPTY_DESCRIPTION => $this->trans( - 'Invalid description for %s language', - 'Admin.Catalog.Notification' - ), - AttachmentConstraintException::INVALID_FIELDS => $this->trans( - 'An error occurred when attempting to update the required fields.', - 'Admin.Notifications.Error' - ), - AttachmentConstraintException::INVALID_DESCRIPTION => $this->trans( - 'Invalid description for %s language', - 'Admin.Catalog.Notification' - ), - AttachmentConstraintException::MISSING_NAME_IN_DEFAULT_LANGUAGE => $this->trans( - 'The %s field is not valid', - 'Admin.Notifications.Error', - [ - sprintf('"%s"', $this->trans('Name', 'Admin.Global')), - ] - ), - ], - AttachmentUploadFailedException::class => $this->trans( - 'Failed to copy the file.', - 'Admin.Catalog.Notification' - ), - CannotAddAttachmentException::class => $this->trans( - 'This attachment was unable to be loaded into the database.', - 'Admin.Catalog.Notification' - ), - CannotUpdateAttachmentException::class => $this->trans( - 'This attachment was unable to be loaded into the database.', - 'Admin.Catalog.Notification' - ), - BulkDeleteAttachmentsException::class => sprintf( - '%s: %s', - $this->trans( - 'An error occurred while deleting this selection.', - 'Admin.Notifications.Error' - ), - $e instanceof BulkDeleteAttachmentsException ? implode(', ', $e->getAttachmentIds()) : '' - ), - EmptyFileException::class => $this->trans('No file has been selected', 'Admin.Notifications.Error'), - ]; - } - - /** - * @param Request $request - * - * @return array - */ - private function getBulkAttachmentsFromRequest(Request $request): array - { - $attachmentIds = $request->request->get('attachment_files_bulk'); - - if (!is_array($attachmentIds)) { - return []; - } - - foreach ($attachmentIds as $i => $attachmentId) { - $attachmentIds[$i] = (int) $attachmentId; - } - - return $attachmentIds; - } - - /** - * @return array - */ - private function getAttachmentToolbarButtons(): array - { - $toolbarButtons = []; - - $toolbarButtons['add'] = [ - 'href' => $this->generateUrl('admin_attachments_create'), - 'desc' => $this->trans('Add new file', 'Admin.Catalog.Feature'), - 'icon' => 'add_circle_outline', - ]; - - return $toolbarButtons; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/AttributeController.php b/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/AttributeController.php deleted file mode 100644 index fa07b4b5..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/AttributeController.php +++ /dev/null @@ -1,262 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\Catalog; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Command\BulkDeleteAttributeCommand; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Command\DeleteAttributeCommand; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Exception\AttributeNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Exception\DeleteAttributeException; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception\AttributeGroupNotFoundException; -use PrestaShop\PrestaShop\Core\Search\Filters\AttributeFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible for Sell > Catalog > Attributes & Features > Attributes > Attribute - */ -class AttributeController extends FrameworkBundleAdminController -{ - /** - * Displays Attribute groups > attributes page - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))", - * redirectRoute="admin_attributes_index", - * redirectQueryParamsToKeep={"attributeGroupId"} - * ) - * - * @param Request $request - * @param $attributeGroupId - * @param AttributeFilters $attributeFilters - * - * @return Response - */ - public function indexAction(Request $request, $attributeGroupId, AttributeFilters $attributeFilters) - { - try { - $attributeGridFactory = $this->get('prestashop.core.grid.factory.attribute'); - $attributeGrid = $attributeGridFactory->getGrid($attributeFilters); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - - return $this->redirectToRoute('admin_attribute_groups_index'); - } - - return $this->render('@PrestaShop/Admin/Sell/Catalog/Attribute/index.html.twig', [ - 'attributeGrid' => $this->presentGrid($attributeGrid), - 'attributeGroupId' => $attributeGroupId, - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - ]); - } - - /** - * Updates attributes positioning order - * - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_attributes_index", - * redirectQueryParamsToKeep={"attributeGroupId"} - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function updatePositionAction(Request $request, $attributeGroupId) - { - $positionsData = [ - 'positions' => $request->request->get('positions'), - 'parentId' => $attributeGroupId, - ]; - - $positionDefinition = $this->get('prestashop.core.grid.attribute.position_definition'); - $positionUpdateFactory = $this->get('prestashop.core.grid.position.position_update_factory'); - - try { - $positionUpdate = $positionUpdateFactory->buildPositionUpdate($positionsData, $positionDefinition); - $updater = $this->get('prestashop.core.grid.position.doctrine_grid_position_updater'); - $updater->update($positionUpdate); - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - } catch (Exception $e) { - $errors = [$e->toArray()]; - $this->flashErrors($errors); - } - - return $this->redirectToRoute('admin_attributes_index', [ - 'attributeGroupId' => $attributeGroupId, - ]); - } - - /** - * @AdminSecurity( - * "is_granted(['create'], request.get('_legacy_controller'))", - * message="You do not have permission to create this." - * ) - * - * @param $attributeGroupId - * - * @return RedirectResponse - */ - public function createAction($attributeGroupId) - { - // @todo: implement in another pr - return $this->redirectToRoute('admin_attributes_index', [ - 'attributeGroupId' => $attributeGroupId, - ]); - } - - /** - * @AdminSecurity( - * "is_granted(['update'], request.get('_legacy_controller'))", - * message="You do not have permission to update this." - * ) - * - * @param $attributeGroupId - * - * @return RedirectResponse - */ - public function editAction($attributeId, $attributeGroupId) - { - // @todo: implement in another pr - return $this->redirectToRoute('admin_attributes_index', [ - 'attributeGroupId' => $attributeGroupId, - ]); - } - - /** - * Deletes attribute - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_attributes_index", - * redirectQueryParamsToKeep={"attributeGroupId"} - * ) - * - * @param int $attributeGroupId - * @param int $attributeId - * - * @return RedirectResponse - */ - public function deleteAction($attributeGroupId, $attributeId) - { - try { - $this->getCommandBus()->handle(new DeleteAttributeCommand((int) $attributeId)); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_attributes_index', [ - 'attributeGroupId' => $attributeGroupId, - ]); - } - - /** - * Deletes multiple attributes by provided ids from request - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_attributes_index", - * redirectQueryParamsToKeep={"attributeGroupId"} - * ) - * - * @param int $attributeGroupId - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkDeleteAction($attributeGroupId, Request $request) - { - try { - $this->getCommandBus()->handle(new BulkDeleteAttributeCommand( - $this->getAttributeIdsFromRequest($request)) - ); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_attributes_index', [ - 'attributeGroupId' => $attributeGroupId, - ]); - } - - /** - * @param Request $request - * - * @return array - */ - private function getAttributeIdsFromRequest(Request $request) - { - $attributeIds = $request->request->get('attribute_bulk'); - - if (!is_array($attributeIds)) { - return []; - } - - foreach ($attributeIds as $i => $attributeId) { - $attributeIds[$i] = (int) $attributeId; - } - - return $attributeIds; - } - - /** - * Provides translated error messages for exceptions - * - * @return array - */ - private function getErrorMessages() - { - $notFoundMessage = $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ); - - return [ - AttributeNotFoundException::class => $notFoundMessage, - AttributeGroupNotFoundException::class => $notFoundMessage, - DeleteAttributeException::class => [ - DeleteAttributeException::FAILED_DELETE => $this->trans( - 'An error occurred while deleting the object.', - 'Admin.Notifications.Error' - ), - DeleteAttributeException::FAILED_BULK_DELETE => $this->trans( - 'An error occurred while deleting this selection.', - 'Admin.Notifications.Error' - ), - ], - ]; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/AttributeGroupController.php b/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/AttributeGroupController.php deleted file mode 100644 index 3f157d72..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/AttributeGroupController.php +++ /dev/null @@ -1,251 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\Catalog; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Command\BulkDeleteAttributeGroupCommand; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Command\DeleteAttributeGroupCommand; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception\AttributeGroupNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Exception\DeleteAttributeGroupException; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Query\GetShowcaseCardIsClosed; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\ValueObject\ShowcaseCard; -use PrestaShop\PrestaShop\Core\Search\Filters\AttributeGroupFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -class AttributeGroupController extends FrameworkBundleAdminController -{ - /** - * Displays Attribute groups page - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * @param AttributeGroupFilters $attributeGroupFilters - * - * @return Response - */ - public function indexAction(Request $request, AttributeGroupFilters $attributeGroupFilters) - { - $attributeGroupGridFactory = $this->get('prestashop.core.grid.factory.attribute_group'); - $attributeGroupGrid = $attributeGroupGridFactory->getGrid($attributeGroupFilters); - - $showcaseCardIsClosed = $this->getQueryBus()->handle( - new GetShowcaseCardIsClosed((int) $this->getContext()->employee->id, ShowcaseCard::ATTRIBUTES_CARD) - ); - - return $this->render('@PrestaShop/Admin/Sell/Catalog/AttributeGroup/index.html.twig', [ - 'attributeGroupGrid' => $this->presentGrid($attributeGroupGrid), - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'showcaseCardName' => ShowcaseCard::ATTRIBUTES_CARD, - 'isShowcaseCardClosed' => $showcaseCardIsClosed, - ]); - } - - /** - * @AdminSecurity( - * "is_granted(['create'], request.get('_legacy_controller'))", - * message="You do not have permission to create this." - * ) - * - * @return RedirectResponse - */ - public function createAction() - { - //@todo: implement in antoher pr - return $this->redirectToRoute('admin_attribute_groups_index'); - } - - /** - * @AdminSecurity( - * "is_granted(['update'], request.get('_legacy_controller'))", - * message="You do not have permission to update this." - * ) - * - * @param $attributeGroupId - * - * @return RedirectResponse - */ - public function editAction($attributeGroupId) - { - //@todo: implement in antoher pr - return $this->redirectToRoute('admin_attribute_groups_index'); - } - - /** - * @AdminSecurity( - * "is_granted(['read'], request.get('_legacy_controller'))", - * message="You do not have permission to export this." - * ) - - * - * @param $attributeGroupId - * - * @return RedirectResponse - */ - public function exportAction($attributeGroupId) - { - //@todo: implement in antoher pr - return $this->redirectToRoute('admin_attribute_groups_index'); - } - - /** - * Updates attribute groups positioning order - * - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_attribute_groups_index" - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function updatePositionAction(Request $request) - { - $positionsData = [ - 'positions' => $request->request->get('positions'), - ]; - - $positionDefinition = $this->get('prestashop.core.grid.attribute_group.position_definition'); - $positionUpdateFactory = $this->get('prestashop.core.grid.position.position_update_factory'); - - try { - $positionUpdate = $positionUpdateFactory->buildPositionUpdate($positionsData, $positionDefinition); - $updater = $this->get('prestashop.core.grid.position.doctrine_grid_position_updater'); - $updater->update($positionUpdate); - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - } catch (Exception $e) { - $errors = [$e->toArray()]; - $this->flashErrors($errors); - } - - return $this->redirectToRoute('admin_attribute_groups_index'); - } - - /** - * Deletes attribute group - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_attribute_groups_index", - * ) - * - * @param int $attributeGroupId - * - * @return RedirectResponse - */ - public function deleteAction($attributeGroupId) - { - try { - $this->getCommandBus()->handle(new DeleteAttributeGroupCommand((int) $attributeGroupId)); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_attribute_groups_index'); - } - - /** - * Deletes multiple attribute groups by provided ids from request - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_attribute_groups_index", - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkDeleteAction(Request $request) - { - try { - $this->getCommandBus()->handle(new BulkDeleteAttributeGroupCommand( - $this->getAttributeGroupIdsFromRequest($request)) - ); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_attribute_groups_index'); - } - - /** - * @param Request $request - * - * @return array - */ - private function getAttributeGroupIdsFromRequest(Request $request) - { - $attributeGroupIds = $request->request->get('attribute_group_bulk'); - - if (!is_array($attributeGroupIds)) { - return []; - } - - foreach ($attributeGroupIds as $i => $attributeGroupId) { - $attributeGroupIds[$i] = (int) $attributeGroupId; - } - - return $attributeGroupIds; - } - - /** - * Provides translated error messages for exceptions - * - * @return array - */ - private function getErrorMessages() - { - return [ - AttributeGroupNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - DeleteAttributeGroupException::class => [ - DeleteAttributeGroupException::FAILED_DELETE => $this->trans( - 'An error occurred while deleting the object.', - 'Admin.Notifications.Error' - ), - DeleteAttributeGroupException::FAILED_BULK_DELETE => $this->trans( - 'An error occurred while deleting this selection.', - 'Admin.Notifications.Error' - ), - ], - ]; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/CartRuleController.php b/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/CartRuleController.php deleted file mode 100644 index 358307a2..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/CartRuleController.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\Catalog; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\CartRule\Query\SearchCartRules; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible for Cart rules (a.k.a cart discounts/vouchers) actions in Back Office - */ -class CartRuleController extends FrameworkBundleAdminController -{ - /** - * Searches for cart rules by provided search phrase - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller')) || is_granted('create', 'AdminOrders')") - * - * @param Request $request - * - * @return JsonResponse - */ - public function searchAction(Request $request): JsonResponse - { - $searchPhrase = $request->query->get('search_phrase'); - $cartRules = []; - - if ($searchPhrase) { - try { - $cartRules = $this->getQueryBus()->handle(new SearchCartRules($searchPhrase)); - } catch (Exception $e) { - return $this->json( - ['message' => $this->getFallbackErrorMessage(get_class($e), $e->getCode())], - Response::HTTP_INTERNAL_SERVER_ERROR - ); - } - } - - return $this->json([ - 'cart_rules' => $cartRules, - ]); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/CatalogPriceRuleController.php b/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/CatalogPriceRuleController.php deleted file mode 100644 index b568f20c..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/CatalogPriceRuleController.php +++ /dev/null @@ -1,292 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\Catalog; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command\BulkDeleteCatalogPriceRuleCommand; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command\DeleteCatalogPriceRuleCommand; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CannotDeleteCatalogPriceRuleException; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CannotUpdateCatalogPriceRuleException; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Exception\CatalogPriceRuleNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Query\GetCatalogPriceRuleForEditing; -use PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\QueryResult\EditableCatalogPriceRule; -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilderInterface; -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandlerInterface; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CatalogPriceRuleGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters\CatalogPriceRuleFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use PrestaShopBundle\Service\Grid\ResponseBuilder; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible for Sell > Catalog > Discounts > Catalog Price Rules page - */ -class CatalogPriceRuleController extends FrameworkBundleAdminController -{ - /** - * Displays catalog price rule listing page. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * @param CatalogPriceRuleFilters $catalogPriceRuleFilters - * - * @return Response - */ - public function indexAction( - Request $request, - CatalogPriceRuleFilters $catalogPriceRuleFilters - ) { - $catalogPriceRuleGridFactory = $this->get('prestashop.core.grid.grid_factory.catalog_price_rule'); - $catalogPriceRuleGrid = $catalogPriceRuleGridFactory->getGrid($catalogPriceRuleFilters); - - return $this->render('@PrestaShop/Admin/Sell/Catalog/CatalogPriceRule/index.html.twig', [ - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'catalogPriceRuleGrid' => $this->presentGrid($catalogPriceRuleGrid), - ]); - } - - /** - * Provides filters functionality. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function searchAction(Request $request) - { - /** @var ResponseBuilder $responseBuilder */ - $responseBuilder = $this->get('prestashop.bundle.grid.response_builder'); - - return $responseBuilder->buildSearchResponse( - $this->get('prestashop.core.grid.definition.factory.catalog_price_rule'), - $request, - CatalogPriceRuleGridDefinitionFactory::GRID_ID, - 'admin_catalog_price_rules_index' - ); - } - - /** - * Deletes catalog price rule - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", redirectRoute="admin_catalog_price_rules_index") - * @DemoRestricted(redirectRoute="admin_catalog_price_rules_index") - * - * @param $catalogPriceRuleId - * - * @return RedirectResponse - */ - public function deleteAction($catalogPriceRuleId) - { - try { - $this->getCommandBus()->handle(new DeleteCatalogPriceRuleCommand((int) $catalogPriceRuleId)); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_catalog_price_rules_index'); - } - - /** - * Deletes catalogPriceRules on bulk action - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", redirectRoute="admin_catalog_price_rules_index") - * @DemoRestricted(redirectRoute="admin_catalog_price_rules_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkDeleteAction(Request $request) - { - $catalogPriceRuleIds = $this->getBulkCatalogPriceRulesFromRequest($request); - - try { - $this->getCommandBus()->handle(new BulkDeleteCatalogPriceRuleCommand($catalogPriceRuleIds)); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_catalog_price_rules_index'); - } - - /** - * Show & process catalog price rule creation. - * - * @AdminSecurity("is_granted(['create'], request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request): Response - { - $catalogPriceRuleForm = $this->getFormBuilder()->getForm(); - $catalogPriceRuleForm->handleRequest($request); - $result = $this->getFormHandler()->handle($catalogPriceRuleForm); - - try { - if (null !== $result->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_catalog_price_rules_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->render('@PrestaShop/Admin/Sell/Catalog/CatalogPriceRule/create.html.twig', [ - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - 'catalogPriceRuleForm' => $catalogPriceRuleForm->createView(), - ]); - } - - /** - * Show & process catalog price rule editing. - * - * @AdminSecurity("is_granted(['update'], request.get('_legacy_controller'))") - * - * @param int $catalogPriceRuleId - * @param Request $request - * - * @return Response - */ - public function editAction(Request $request, int $catalogPriceRuleId): Response - { - $catalogPriceRuleId = (int) $catalogPriceRuleId; - - try { - /** @var EditableCatalogPriceRule $editableCatalogPriceRule */ - $editableCatalogPriceRule = $this->getQueryBus()->handle(new GetCatalogPriceRuleForEditing($catalogPriceRuleId)); - - $catalogPriceRuleForm = $this->getFormBuilder()->getFormFor($catalogPriceRuleId); - $catalogPriceRuleForm->handleRequest($request); - - $result = $this->getFormHandler()->handleFor($catalogPriceRuleId, $catalogPriceRuleForm); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - - return $this->redirectToRoute('admin_catalog_price_rules_index'); - } - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_catalog_price_rules_index'); - } - - return $this->render('@PrestaShop/Admin/Sell/Catalog/CatalogPriceRule/edit.html.twig', [ - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - 'catalogPriceRuleForm' => $catalogPriceRuleForm->createView(), - 'catalogPriceRuleName' => $editableCatalogPriceRule->getName(), - ]); - } - - /** - * Provides translated error messages for exceptions - * - * @return array - */ - private function getErrorMessages(): array - { - return [ - CannotDeleteCatalogPriceRuleException::class => [ - CannotDeleteCatalogPriceRuleException::FAILED_DELETE => $this->trans( - 'An error occurred while deleting the object.', - 'Admin.Notifications.Error' - ), - CannotDeleteCatalogPriceRuleException::FAILED_BULK_DELETE => $this->trans( - 'An error occurred while deleting this selection.', - 'Admin.Notifications.Error' - ), - ], - CannotUpdateCatalogPriceRuleException::class => $this->trans( - 'An error occurred while updating an object.', - 'Admin.Notifications.Error' - ), - CatalogPriceRuleNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - ]; - } - - /** - * Provides catalog price rule ids from request of bulk action - * - * @param Request $request - * - * @return array - */ - private function getBulkCatalogPriceRulesFromRequest(Request $request) - { - $catalogPriceRuleIds = $request->request->get('catalog_price_rule_bulk'); - - if (!is_array($catalogPriceRuleIds)) { - return []; - } - - foreach ($catalogPriceRuleIds as &$catalogPriceRuleId) { - $catalogPriceRuleId = (int) $catalogPriceRuleId; - } - - return $catalogPriceRuleIds; - } - - /** - * @return FormHandlerInterface - */ - private function getFormHandler(): FormHandlerInterface - { - return $this->get('prestashop.core.form.identifiable_object.handler.catalog_price_rule_form_handler'); - } - - /** - * @return FormBuilderInterface - */ - private function getFormBuilder(): FormBuilderInterface - { - return $this->get('prestashop.core.form.identifiable_object.builder.catalog_price_rule_form_builder'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/CategoryController.php b/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/CategoryController.php deleted file mode 100644 index 50a2df1d..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/CategoryController.php +++ /dev/null @@ -1,842 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\Catalog; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\BulkDeleteCategoriesCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\BulkDisableCategoriesCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\BulkEnableCategoriesCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\DeleteCategoryCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\DeleteCategoryCoverImageCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\DeleteCategoryMenuThumbnailImageCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\SetCategoryIsEnabledCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\Command\UpdateCategoryPositionCommand; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CannotAddCategoryException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CannotDeleteImageException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CannotDeleteRootCategoryForShopException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CannotEditCategoryException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CannotUpdateCategoryStatusException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CategoryNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Category\Exception\MenuThumbnailsLimitException; -use PrestaShop\PrestaShop\Core\Domain\Category\Query\GetCategoryForEditing; -use PrestaShop\PrestaShop\Core\Domain\Category\Query\GetCategoryIsEnabled; -use PrestaShop\PrestaShop\Core\Domain\Category\QueryResult\EditableCategory; -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\MenuThumbnailId; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Query\GetShowcaseCardIsClosed; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\ValueObject\ShowcaseCard; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CategoryGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters\CategoryFilters; -use PrestaShopBundle\Component\CsvResponse; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Form\Admin\Sell\Category\DeleteCategoriesType; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; - -/** - * Class CategoryController is responsible for "Sell > Catalog > Categories" page. - */ -class CategoryController extends FrameworkBundleAdminController -{ - /** - * Show categories listing. - * - * @AdminSecurity( - * "is_granted(['read', 'update', 'create', 'delete'], request.get('_legacy_controller'))", - * message="You do not have permission to list this." - * ) - * - * @param Request $request - * @param CategoryFilters $filters - * - * @return Response - */ - public function indexAction(Request $request, CategoryFilters $filters) - { - $categoriesKpiFactory = $this->get('prestashop.core.kpi_row.factory.categories'); - - $currentCategoryId = $filters->getFilters()['id_category_parent']; - $categoryViewDataProvider = $this->get('prestashop.adapter.category.category_view_data_provider'); - $categoryViewData = $categoryViewDataProvider->getViewData($currentCategoryId); - - $isItASearchRequest = $this->requestHasSearchParameters($request); - - $filters->addFilter(['is_home_category' => $categoryViewData['is_home_category']]); - $filters->addFilter(['is_search_request' => $isItASearchRequest]); - - $categoryGridFactory = $this->get('prestashop.core.grid.factory.category_decorator'); - $categoryGrid = $categoryGridFactory->getGrid($filters); - - $deleteCategoriesForm = $this->createForm(DeleteCategoriesType::class); - - $showcaseCardIsClosed = $this->getQueryBus()->handle( - new GetShowcaseCardIsClosed((int) $this->getContext()->employee->id, ShowcaseCard::CATEGORIES_CARD) - ); - - return $this->render('@PrestaShop/Admin/Sell/Catalog/Categories/index.html.twig', [ - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - 'categoriesGrid' => $this->presentGrid($categoryGrid), - 'categoriesKpi' => $categoriesKpiFactory->build(), - 'layoutHeaderToolbarBtn' => $this->getCategoryToolbarButtons($request), - 'currentCategoryView' => $categoryViewData, - 'deleteCategoriesForm' => $deleteCategoriesForm->createView(), - 'isSingleShopContext' => $this->get('prestashop.adapter.shop.context')->isSingleShopContext(), - 'showcaseCardName' => ShowcaseCard::CATEGORIES_CARD, - 'isShowcaseCardClosed' => $showcaseCardIsClosed, - ]); - } - - /** - * Process Grid search. - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function searchGridAction(Request $request) - { - $responseBuilder = $this->get('prestashop.bundle.grid.response_builder'); - - return $responseBuilder->buildSearchResponse( - $this->get('prestashop.core.grid.definition.factory.category'), - $request, - CategoryGridDefinitionFactory::GRID_ID, - 'admin_categories_index', - ['categoryId'] - ); - } - - /** - * Show "Add new" form and handle form submit. - * - * @AdminSecurity( - * "is_granted(['create'], request.get('_legacy_controller'))", - * message="You do not have permission to create this.", - * redirectRoute="admin_categories_index" - * ) - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request) - { - $categoryFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.category_form_builder'); - $categoryFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.category_form_handler'); - - $parentId = (int) $request->query->get('id_parent', $this->configuration->getInt('PS_HOME_CATEGORY')); - - $categoryForm = $categoryFormBuilder->getForm(['id_parent' => $parentId]); - $categoryForm->handleRequest($request); - - try { - $handlerResult = $categoryFormHandler->handle($categoryForm); - - if (null !== $handlerResult->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_categories_index', [ - 'categoryId' => $categoryForm->getData()['id_parent'], - ]); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - $defaultGroups = $this->get('prestashop.adapter.group.provider.default_groups_provider')->getGroups(); - - return $this->render( - '@PrestaShop/Admin/Sell/Catalog/Categories/create.html.twig', - [ - 'allowMenuThumbnailsUpload' => true, - 'categoryForm' => $categoryForm->createView(), - 'defaultGroups' => $defaultGroups, - 'categoryUrl' => $this->get('prestashop.adapter.shop.url.category_provider') - ->getUrl(0, '{friendy-url}'), - ] - ); - } - - /** - * Show "Add new root category" page & process adding. - * - * @AdminSecurity( - * "is_granted(['create'], request.get('_legacy_controller'))", - * message="You do not have permission to create this.", - * redirectRoute="admin_categories_index" - * ) - * - * @param Request $request - * - * @return Response - */ - public function createRootAction(Request $request) - { - $rootCategoryFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.root_category_form_builder'); - $rootCategoryFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.root_category_form_handler'); - - $rootCategoryForm = $rootCategoryFormBuilder->getForm(); - $rootCategoryForm->handleRequest($request); - - try { - $handlerResult = $rootCategoryFormHandler->handle($rootCategoryForm); - - if (null !== $handlerResult->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_categories_index', [ - 'categoryId' => $this->configuration->getInt('PS_ROOT_CATEGORY'), - ]); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - $defaultGroups = $this->get('prestashop.adapter.group.provider.default_groups_provider')->getGroups(); - - return $this->render( - '@PrestaShop/Admin/Sell/Catalog/Categories/create_root.html.twig', - [ - 'allowMenuThumbnailsUpload' => true, - 'rootCategoryForm' => $rootCategoryForm->createView(), - 'defaultGroups' => $defaultGroups, - 'categoryUrl' => $this->get('prestashop.adapter.shop.url.category_provider') - ->getUrl(0, '{friendy-url}'), - ] - ); - } - - /** - * Show & process category editing. - * - * @AdminSecurity( - * "is_granted(['update'], request.get('_legacy_controller'))", - * message="You do not have permission to edit this.", - * redirectRoute="admin_categories_index" - * ) - * - * @param int $categoryId - * @param Request $request - * - * @return Response - */ - public function editAction($categoryId, Request $request) - { - try { - /** @var EditableCategory $editableCategory */ - $editableCategory = $this->getQueryBus()->handle(new GetCategoryForEditing((int) $categoryId)); - - if ($editableCategory->isRootCategory()) { - return $this->redirectToRoute('admin_categories_edit_root', ['categoryId' => $categoryId]); - } - } catch (CategoryException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - - return $this->redirectToRoute('admin_categories_index'); - } - - try { - $categoryFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.category_form_builder'); - $categoryFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.category_form_handler'); - - $categoryFormOptions = [ - 'id_category' => (int) $categoryId, - 'subcategories' => $editableCategory->getSubCategories(), - ]; - - $categoryForm = $categoryFormBuilder->getFormFor((int) $categoryId, [], $categoryFormOptions); - $categoryForm->handleRequest($request); - - $handlerResult = $categoryFormHandler->handleFor((int) $categoryId, $categoryForm); - - if ($handlerResult->isSubmitted() && $handlerResult->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_categories_index', [ - 'categoryId' => $categoryForm->getData()['id_parent'], - ]); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - $defaultGroups = $this->get('prestashop.adapter.group.provider.default_groups_provider')->getGroups(); - - return $this->render( - '@PrestaShop/Admin/Sell/Catalog/Categories/edit.html.twig', - [ - 'allowMenuThumbnailsUpload' => $editableCategory->canContainMoreMenuThumbnails(), - 'maxMenuThumbnails' => count(MenuThumbnailId::ALLOWED_ID_VALUES), - 'contextLangId' => $this->getContextLangId(), - 'editCategoryForm' => $categoryForm->createView(), - 'editableCategory' => $editableCategory, - 'defaultGroups' => $defaultGroups, - 'categoryUrl' => $this->get('prestashop.adapter.shop.url.category_provider') - ->getUrl($categoryId, '{friendy-url}'), - ] - ); - } - - /** - * Show and process category editing. - * - * @AdminSecurity( - * "is_granted(['update'], request.get('_legacy_controller'))", - * message="You do not have permission to edit this.", - * redirectRoute="admin_categories_index" - * ) - * - * @param int $categoryId - * @param Request $request - * - * @return Response - */ - public function editRootAction($categoryId, Request $request) - { - try { - /** @var EditableCategory $editableCategory */ - $editableCategory = $this->getQueryBus()->handle(new GetCategoryForEditing((int) $categoryId)); - - if (!$editableCategory->isRootCategory()) { - return $this->redirectToRoute('admin_categories_edit', ['categoryId' => $categoryId]); - } - } catch (CategoryNotFoundException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - - return $this->redirectToRoute('admin_categories_index'); - } - - $rootCategoryFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.root_category_form_builder'); - $rootCategoryFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.root_category_form_handler'); - - try { - $rootCategoryForm = $rootCategoryFormBuilder->getFormFor((int) $categoryId); - $rootCategoryForm->handleRequest($request); - - $handlerResult = $rootCategoryFormHandler->handleFor((int) $categoryId, $rootCategoryForm); - - if ($handlerResult->isSubmitted() && $handlerResult->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_categories_index', [ - 'categoryId' => $this->configuration->getInt('PS_ROOT_CATEGORY'), - ]); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - $defaultGroups = $this->get('prestashop.adapter.group.provider.default_groups_provider')->getGroups(); - - return $this->render( - '@PrestaShop/Admin/Sell/Catalog/Categories/edit_root.html.twig', - [ - 'allowMenuThumbnailsUpload' => $editableCategory->canContainMoreMenuThumbnails(), - 'maxMenuThumbnails' => count(MenuThumbnailId::ALLOWED_ID_VALUES), - 'contextLangId' => $this->getContextLangId(), - 'editRootCategoryForm' => $rootCategoryForm->createView(), - 'editableCategory' => $editableCategory, - 'defaultGroups' => $defaultGroups, - 'categoryUrl' => $this->get('prestashop.adapter.shop.url.category_provider') - ->getUrl($categoryId, '{friendy-url}'), - ] - ); - } - - /** - * Deletes category cover image. - * - * @AdminSecurity( - * "is_granted(['update'], request.get('_legacy_controller'))", - * message="You do not have permission to edit this.", - * redirectRoute="admin_categories_edit", - * redirectQueryParamsToKeep={"categoryId"} - * ) - * - * @param Request $request - * @param int $categoryId - * - * @return RedirectResponse - */ - public function deleteCoverImageAction(Request $request, $categoryId) - { - if (!$this->isCsrfTokenValid('delete-cover-image', $request->request->get('_csrf_token'))) { - return $this->redirectToRoute('admin_security_compromised', [ - 'uri' => $this->generateUrl('admin_categories_edit', [ - 'categoryId' => $categoryId, - ], UrlGeneratorInterface::ABSOLUTE_URL), - ]); - } - - try { - $this->getCommandBus()->handle(new DeleteCategoryCoverImageCommand((int) $categoryId)); - - $this->addFlash( - 'success', - $this->trans('The image was successfully deleted.', 'Admin.Notifications.Success') - ); - } catch (CategoryException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_categories_edit', [ - 'categoryId' => $categoryId, - ]); - } - - /** - * Delete given menu thumbnail for category. - * - * @AdminSecurity( - * "is_granted(['update'], request.get('_legacy_controller'))", - * message="You do not have permission to edit this.", - * redirectRoute="admin_categories_edit", - * redirectQueryParamsToKeep={"categoryId"} - * ) - * - * @param Request $request - * @param int $categoryId - * @param int $menuThumbnailId - * - * @return RedirectResponse - */ - public function deleteMenuThumbnailAction(Request $request, $categoryId, $menuThumbnailId) - { - if (!$this->isCsrfTokenValid('delete-menu-thumbnail', $request->request->get('_csrf_token'))) { - return $this->redirectToRoute('admin_security_compromised', [ - 'uri' => $this->generateUrl('admin_categories_edit', [ - 'categoryId' => $categoryId, - ], UrlGeneratorInterface::ABSOLUTE_URL), - ]); - } - - try { - $this->getCommandBus()->handle(new DeleteCategoryMenuThumbnailImageCommand( - (int) $categoryId, - (int) $menuThumbnailId - )); - - $this->addFlash( - 'success', - $this->trans('The image was successfully deleted.', 'Admin.Notifications.Success') - ); - } catch (CategoryException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_categories_edit', [ - 'categoryId' => $categoryId, - ]); - } - - /** - * Toggle category status. - * - * @AdminSecurity( - * "is_granted(['update'], request.get('_legacy_controller'))", - * message="You do not have permission to update this." - * ) - * - * @param int $categoryId - * - * @return JsonResponse - */ - public function toggleStatusAction($categoryId) - { - if ($this->isDemoModeEnabled()) { - return $this->json([ - 'status' => false, - 'message' => $this->getDemoModeErrorMessage(), - ]); - } - - try { - $isEnabled = $this->getQueryBus()->handle(new GetCategoryIsEnabled((int) $categoryId)); - - $this->getCommandBus()->handle( - new SetCategoryIsEnabledCommand((int) $categoryId, !$isEnabled) - ); - - $response = [ - 'status' => true, - 'message' => $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success'), - ]; - } catch (CategoryException $e) { - $response = [ - 'status' => false, - 'message' => $this->getErrorMessageForException($e, $this->getErrorMessages()), - ]; - } - - return $this->json($response); - } - - /** - * Process bulk action for categories status enabling. - * - * @AdminSecurity( - * "is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", - * redirectRoute="admin_categories_index", - * message="You do not have permission to update this." - * ) - * @DemoRestricted(redirectRoute="admin_categories_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkEnableStatusAction(Request $request) - { - try { - $categoryIds = $this->getBulkCategoriesFromRequest($request); - - $command = new BulkEnableCategoriesCommand($categoryIds); - - $this->getCommandBus()->handle($command); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (CategoryException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_categories_index'); - } - - /** - * Process bulk action for categories status disabling. - * - * @AdminSecurity( - * "is_granted(['update', 'create', 'delete'], request.get('_legacy_controller'))", - * redirectRoute="admin_categories_index", - * message="You do not have permission to update this." - * ) - * @DemoRestricted(redirectRoute="admin_categories_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkDisableStatusAction(Request $request) - { - try { - $categoryIds = $this->getBulkCategoriesFromRequest($request); - - $command = new BulkDisableCategoriesCommand($categoryIds); - - $this->getCommandBus()->handle($command); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (CategoryException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_categories_index'); - } - - /** - * Processes bulk categories deleting. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_categories_index", - * message="You do not have permission to delete this." - * ) - * @DemoRestricted(redirectRoute="admin_categories_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkDeleteAction(Request $request) - { - $deleteCategoriesForm = $this->createForm(DeleteCategoriesType::class); - $deleteCategoriesForm->handleRequest($request); - - if ($deleteCategoriesForm->isSubmitted()) { - try { - $categoriesDeleteData = $deleteCategoriesForm->getData(); - $categoryIds = array_map(function ($categoryId) { - return (int) $categoryId; - }, $categoriesDeleteData['categories_to_delete']); - - $command = new BulkDeleteCategoriesCommand( - $categoryIds, - $categoriesDeleteData['delete_mode'] - ); - - $this->getCommandBus()->handle($command); - - $this->addFlash( - 'success', - $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success') - ); - } catch (CategoryException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - } - - return $this->redirectToRoute('admin_categories_index'); - } - - /** - * Process single category deleting. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_categories_index", - * message="You do not have permission to delete this." - * ) - * @DemoRestricted(redirectRoute="admin_categories_index") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function deleteAction(Request $request) - { - $deleteCategoriesForm = $this->createForm(DeleteCategoriesType::class); - $deleteCategoriesForm->handleRequest($request); - - if ($deleteCategoriesForm->isSubmitted()) { - $categoriesDeleteData = $deleteCategoriesForm->getData(); - - try { - $command = new DeleteCategoryCommand( - (int) reset($categoriesDeleteData['categories_to_delete']), - $categoriesDeleteData['delete_mode'] - ); - - $this->getCommandBus()->handle($command); - - $this->addFlash('success', $this->trans('Successful deletion.', 'Admin.Notifications.Success')); - } catch (CategoryException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - } - - return $this->redirectToRoute('admin_categories_index'); - } - - /** - * Export filtered categories. - * - * @AdminSecurity( - * "is_granted(['read', 'update', 'create', 'delete'], request.get('_legacy_controller'))", - * redirectRoute="admin_categories_index", - * message="You do not have permission to view this." - * ) - * @DemoRestricted(redirectRoute="admin_categories_index") - * - * @param CategoryFilters $filters - * - * @return Response - */ - public function exportAction(CategoryFilters $filters) - { - $filters = new CategoryFilters(['limit' => null] + $filters->all()); - $categoriesGridFactory = $this->get('prestashop.core.grid.factory.category'); - $categoriesGrid = $categoriesGridFactory->getGrid($filters); - - $headers = [ - 'id_category' => $this->trans('ID', 'Admin.Global'), - 'name' => $this->trans('Name', 'Admin.Global'), - 'description' => $this->trans('Description', 'Admin.Global'), - 'position' => $this->trans('Position', 'Admin.Global'), - 'active' => $this->trans('Displayed', 'Admin.Global'), - ]; - - $data = []; - - foreach ($categoriesGrid->getData()->getRecords()->all() as $record) { - $data[] = [ - 'id_category' => $record['id_category'], - 'name' => $record['name'], - 'description' => $record['description'], - 'position' => $record['position'], - 'active' => $record['active'], - ]; - } - - return (new CsvResponse()) - ->setData($data) - ->setHeadersData($headers) - ->setFileName('category_' . date('Y-m-d_His') . '.csv'); - } - - /** - * Updates category position - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_categories_index", - * ) - * - * @param Request $request - * - * @return JsonResponse - */ - public function updatePositionAction(Request $request) - { - try { - $this->getCommandBus()->handle(new UpdateCategoryPositionCommand( - $request->request->getInt('id_category_to_move'), - $request->request->getInt('id_category_parent'), - $request->request->getInt('way'), - $request->request->get('positions'), - $request->request->getBoolean('found_first') - )); - } catch (CategoryException $e) { - return $this->json([ - 'success' => false, - 'message' => $this->getErrorMessageForException($e, $this->getErrorMessages()), - ]); - } - - return $this->json([ - 'success' => true, - 'message' => $this->trans('Successful update.', 'Admin.Notifications.Success'), - ]); - } - - /** - * @param Request $request - * - * @return array - */ - private function getCategoryToolbarButtons(Request $request) - { - $toolbarButtons = []; - - if ($this->get('prestashop.adapter.feature.multistore')->isUsed()) { - $toolbarButtons['add_root'] = [ - 'href' => $this->generateUrl('admin_categories_create_root'), - 'desc' => $this->trans('Add new root category', 'Admin.Catalog.Feature'), - 'icon' => 'add_circle_outline', - ]; - } - - $categoryId = $request->attributes->get('categoryId'); - if (empty($categoryId)) { - $categoryId = $this->configuration->getInt('PS_HOME_CATEGORY'); - } - - $toolbarButtons['add'] = [ - 'href' => $this->generateUrl('admin_categories_create', ['id_parent' => $categoryId]), - 'desc' => $this->trans('Add new category', 'Admin.Catalog.Feature'), - 'icon' => 'add_circle_outline', - ]; - - return $toolbarButtons; - } - - /** - * Get translated error messages for category exceptions - * - * @return array - */ - private function getErrorMessages() - { - return [ - CannotDeleteImageException::class => $this->trans('Unable to delete associated images.', 'Admin.Notifications.Error'), - CategoryNotFoundException::class => $this->trans('The object cannot be loaded (or found)', 'Admin.Notifications.Error'), - CategoryConstraintException::class => [ - CategoryConstraintException::EMPTY_BULK_DELETE_DATA => $this->trans('You must select at least one element to delete.', 'Admin.Notifications.Error'), - CategoryConstraintException::TOO_MANY_MENU_THUMBNAILS => sprintf( - '%s %s', - $this->trans('An error occurred while uploading the image:', 'Admin.Catalog.Notification'), - $this->trans('You cannot upload more files', 'Admin.Notifications.Error') - ), - ], - CannotDeleteRootCategoryForShopException::class => $this->trans( - 'You cannot remove this category because one of your shops uses it as a root category.', - 'Admin.Catalog.Notification' - ), - CannotAddCategoryException::class => $this->trans( - 'An error occurred while creating the category.', - 'Admin.Catalog.Notification' - ), - CannotEditCategoryException::class => $this->trans( - 'An error occurred while editing the category.', - 'Admin.Catalog.Notification' - ), - CannotUpdateCategoryStatusException::class => $this->trans( - 'An error occurred while updating the status for an object.', - 'Admin.Notifications.Error' - ), - MenuThumbnailsLimitException::class => sprintf( - '%s %s', - $this->trans('An error occurred while uploading the image:', 'Admin.Catalog.Notification'), - $this->trans('You cannot upload more files', 'Admin.Notifications.Error') - ), - ]; - } - - /** - * @param Request $request - * - * @return array - */ - private function getBulkCategoriesFromRequest(Request $request) - { - $categoryIds = $request->request->get('category_id_category'); - - if (!is_array($categoryIds)) { - return []; - } - - foreach ($categoryIds as $i => $categoryId) { - $categoryIds[$i] = (int) $categoryId; - } - - return $categoryIds; - } - - /** - * @param Request $request - * - * @return bool - */ - private function requestHasSearchParameters(Request $request) - { - return !empty($request->query->get('category')['filters']); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/FeatureController.php b/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/FeatureController.php deleted file mode 100644 index a03a53ea..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/FeatureController.php +++ /dev/null @@ -1,188 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\Catalog; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Feature\Exception\FeatureConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Feature\Exception\FeatureNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Feature\Query\GetFeatureForEditing; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Controller responsible for "Sell > Catalog > Attributes & Features > Features" page - */ -class FeatureController extends FrameworkBundleAdminController -{ - /** - * Create feature action. - * - * @AdminSecurity("is_granted(['create'], request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request) - { - if (!$this->isFeatureEnabled()) { - return $this->render('@PrestaShop/Admin/Sell/Catalog/Features/create.html.twig', [ - 'showDisabledFeatureWarning' => true, - ]); - } - - $featureFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.feature_form_builder'); - $featureFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.feature_form_handler'); - - $featureForm = $featureFormBuilder->getForm(); - $featureForm->handleRequest($request); - - try { - $handlerResult = $featureFormHandler->handle($featureForm); - - if (null !== $handlerResult->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - //@todo change route to index when it's migrated - return $this->redirectToRoute('admin_features_create'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->render('@PrestaShop/Admin/Sell/Catalog/Features/create.html.twig', [ - 'featureForm' => $featureForm->createView(), - ]); - } - - /** - * Edit feature action. - * - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))") - * - * @param int $featureId - * @param Request $request - * - * @return Response - */ - public function editAction($featureId, Request $request) - { - try { - $editableFeature = $this->getQueryBus()->handle(new GetFeatureForEditing((int) $featureId)); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - - // @todo change route to features index when it's migrated - return $this->redirectToRoute('admin_features_create'); - } - - if (!$this->isFeatureEnabled()) { - return $this->renderEditForm([ - 'showDisabledFeatureWarning' => true, - 'editableFeature' => $editableFeature, - ]); - } - - $featureFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.feature_form_builder'); - $featureFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.feature_form_handler'); - - $featureForm = $featureFormBuilder->getFormFor($featureId); - $featureForm->handleRequest($request); - - try { - $handlerResult = $featureFormHandler->handleFor($featureId, $featureForm); - - if ($handlerResult->isSubmitted() && $handlerResult->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_features_edit', [ - 'featureId' => $featureId, - ]); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->renderEditForm([ - 'featureForm' => $featureForm->createView(), - 'editableFeature' => $editableFeature, - ]); - } - - /** - * Render feature edit form - * - * @param array $parameters - * - * @return Response - */ - private function renderEditForm(array $parameters = []) - { - return $this->render('@PrestaShop/Admin/Sell/Catalog/Features/edit.html.twig', $parameters + [ - 'contextLangId' => $this->configuration->get('PS_LANG_DEFAULT'), - ]); - } - - /** - * Get translated error messages for feature exceptions - * - * @return array - */ - private function getErrorMessages() - { - return [ - FeatureNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - FeatureConstraintException::class => [ - FeatureConstraintException::EMPTY_NAME => $this->trans( - 'The field %field_name% is required at least in your default language.', - 'Admin.Notifications.Error', - ['%field_name%' => $this->trans('Name', 'Admin.Global')] - ), - FeatureConstraintException::INVALID_NAME => $this->trans( - 'The %s field is invalid.', - 'Admin.Notifications.Error', - [sprintf('"%s"', $this->trans('Name', 'Admin.Global'))] - ), - ], - ]; - } - - /** - * Check if Features functionality is enabled in the shop. - * - * @return bool - */ - private function isFeatureEnabled() - { - return $this->get('prestashop.adapter.feature.feature')->isActive(); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/ManufacturerController.php b/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/ManufacturerController.php deleted file mode 100644 index 664290c6..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/ManufacturerController.php +++ /dev/null @@ -1,786 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\Catalog; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\BulkDeleteAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\Command\DeleteAddressCommand; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\DeleteAddressException; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\InvalidAddressFieldException; -use PrestaShop\PrestaShop\Core\Domain\Address\Query\GetManufacturerAddressForEditing; -use PrestaShop\PrestaShop\Core\Domain\Address\QueryResult\EditableManufacturerAddress; -use PrestaShop\PrestaShop\Core\Domain\Exception\DomainException; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\BulkDeleteManufacturerCommand; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\BulkToggleManufacturerStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\DeleteManufacturerCommand; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\ToggleManufacturerStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\DeleteManufacturerException; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\ManufacturerConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\ManufacturerException; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\ManufacturerNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Exception\UpdateManufacturerException; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Query\GetManufacturerForEditing; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\Query\GetManufacturerForViewing; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\QueryResult\EditableManufacturer; -use PrestaShop\PrestaShop\Core\Domain\Manufacturer\QueryResult\ViewableManufacturer; -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilderInterface; -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandlerInterface; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\ManufacturerAddressGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\ManufacturerGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\ImageOptimizationException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\ImageUploadException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\MemoryLimitException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\UploadedImageConstraintException; -use PrestaShop\PrestaShop\Core\Search\Filters\ManufacturerAddressFilters; -use PrestaShop\PrestaShop\Core\Search\Filters\ManufacturerFilters; -use PrestaShopBundle\Component\CsvResponse; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use PrestaShopBundle\Service\Grid\ResponseBuilder; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Manages "Sell > Catalog > Brands & Suppliers > Brands" page - */ -class ManufacturerController extends FrameworkBundleAdminController -{ - /** - * Show manufacturers listing page. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @return Response - */ - public function indexAction( - Request $request, - ManufacturerFilters $manufacturerFilters, - ManufacturerAddressFilters $manufacturerAddressFilters - ) { - $manufacturerGridFactory = $this->get('prestashop.core.grid.grid_factory.manufacturer'); - $manufacturerGrid = $manufacturerGridFactory->getGrid($manufacturerFilters); - - $manufacturerAddressFactory = $this->get('prestashop.core.grid.grid_factory.manufacturer_address'); - $manufacturerAddressGrid = $manufacturerAddressFactory->getGrid($manufacturerAddressFilters); - - return $this->render('@PrestaShop/Admin/Sell/Catalog/Manufacturer/index.html.twig', [ - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'manufacturerGrid' => $this->presentGrid($manufacturerGrid), - 'manufacturerAddressGrid' => $this->presentGrid($manufacturerAddressGrid), - 'settingsTipMessage' => $this->getSettingsTipMessage(), - ]); - } - - /** - * Provides filters functionality - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @return RedirectResponse - */ - public function searchAction(Request $request) - { - $gridDefinitionFactory = 'prestashop.core.grid.definition.factory.manufacturer'; - $filterId = ManufacturerGridDefinitionFactory::GRID_ID; - if ($request->request->has(ManufacturerAddressGridDefinitionFactory::GRID_ID)) { - $gridDefinitionFactory = 'prestashop.core.grid.definition.factory.manufacturer_address'; - $filterId = ManufacturerAddressGridDefinitionFactory::GRID_ID; - } - - /** @var ResponseBuilder $responseBuilder */ - $responseBuilder = $this->get('prestashop.bundle.grid.response_builder'); - - return $responseBuilder->buildSearchResponse( - $this->get($gridDefinitionFactory), - $request, - $filterId, - 'admin_manufacturers_index' - ); - } - - /** - * Show & process manufacturer creation. - * - * @AdminSecurity( - * "is_granted(['create'], request.get('_legacy_controller'))" - * ) - * - * @return Response - */ - public function createAction(Request $request) - { - $manufacturerForm = $this->getFormBuilder()->getForm(); - $manufacturerForm->handleRequest($request); - - try { - $result = $this->getFormHandler()->handle($manufacturerForm); - - if (null !== $result->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_manufacturers_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->render('@PrestaShop/Admin/Sell/Catalog/Manufacturer/add.html.twig', [ - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - 'manufacturerForm' => $manufacturerForm->createView(), - ]); - } - - /** - * View single manufacturer details - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @param int $manufacturerId - * - * @return Response - */ - public function viewAction(Request $request, $manufacturerId) - { - try { - /** @var ViewableManufacturer $viewableManufacturer */ - $viewableManufacturer = $this->getQueryBus()->handle(new GetManufacturerForViewing( - (int) $manufacturerId, - (int) $this->getContextLangId() - )); - } catch (ManufacturerException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - - return $this->redirectToRoute('admin_manufacturers_index'); - } - - return $this->render('@PrestaShop/Admin/Sell/Catalog/Manufacturer/view.html.twig', [ - 'layoutTitle' => $viewableManufacturer->getName(), - 'viewableManufacturer' => $viewableManufacturer, - 'isStockManagementEnabled' => $this->configuration->get('PS_STOCK_MANAGEMENT'), - 'isAllShopContext' => $this->get('prestashop.adapter.shop.context')->isAllShopContext(), - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - ]); - } - - /** - * Show & process manufacturer editing. - * - * @AdminSecurity( - * "is_granted(['update'], request.get('_legacy_controller'))" - * ) - * - * @param int $manufacturerId - * - * @return Response - */ - public function editAction(Request $request, $manufacturerId) - { - try { - /** @var EditableManufacturer $editableManufacturer */ - $editableManufacturer = $this->getQueryBus()->handle(new GetManufacturerForEditing((int) $manufacturerId)); - - $manufacturerForm = $this->getFormBuilder()->getFormFor((int) $manufacturerId); - $manufacturerForm->handleRequest($request); - - $result = $this->getFormHandler()->handleFor((int) $manufacturerId, $manufacturerForm); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_manufacturers_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - - if ($e instanceof ManufacturerNotFoundException) { - return $this->redirectToRoute('admin_manufacturers_index'); - } - } - - if (!isset($editableManufacturer) || !isset($manufacturerForm)) { - return $this->redirectToRoute('admin_manufacturers_index'); - } - - return $this->render('@PrestaShop/Admin/Sell/Catalog/Manufacturer/edit.html.twig', [ - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - 'manufacturerForm' => $manufacturerForm->createView(), - 'manufacturerName' => $editableManufacturer->getName(), - 'logoImage' => $editableManufacturer->getLogoImage(), - ]); - } - - /** - * Deletes manufacturer - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", redirectRoute="admin_manufacturers_index") - * @DemoRestricted(redirectRoute="admin_manufacturers_index") - * - * @param $manufacturerId - * - * @return RedirectResponse - */ - public function deleteAction($manufacturerId) - { - try { - $this->getCommandBus()->handle(new DeleteManufacturerCommand((int) $manufacturerId)); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (ManufacturerException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_manufacturers_index'); - } - - /** - * Deletes manufacturers on bulk action - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", redirectRoute="admin_manufacturers_index") - * @DemoRestricted(redirectRoute="admin_manufacturers_index") - * - * @return RedirectResponse - */ - public function bulkDeleteAction(Request $request) - { - $manufacturerIds = $this->getBulkManufacturersFromRequest($request); - - try { - $this->getCommandBus()->handle(new BulkDeleteManufacturerCommand($manufacturerIds)); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (ManufacturerException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_manufacturers_index'); - } - - /** - * Enables manufacturers on bulk action - * - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute="admin_manufacturers_index") - * @DemoRestricted(redirectRoute="admin_manufacturers_index") - * - * @return RedirectResponse - */ - public function bulkEnableAction(Request $request) - { - $manufacturerIds = $this->getBulkManufacturersFromRequest($request); - - try { - $this->getCommandBus()->handle(new BulkToggleManufacturerStatusCommand($manufacturerIds, true)); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (ManufacturerException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_manufacturers_index'); - } - - /** - * Disables manufacturers on bulk action - * - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute="admin_manufacturers_index") - * @DemoRestricted(redirectRoute="admin_manufacturers_index") - * - * @return RedirectResponse - */ - public function bulkDisableAction(Request $request) - { - $manufacturerIds = $this->getBulkManufacturersFromRequest($request); - - try { - $this->getCommandBus()->handle(new BulkToggleManufacturerStatusCommand($manufacturerIds, false)); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (ManufacturerException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_manufacturers_index'); - } - - /** - * Toggles manufacturer status - * - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute="admin_manufacturers_index") - * @DemoRestricted(redirectRoute="admin_manufacturers_index") - * - * @param int $manufacturerId - * - * @return RedirectResponse - */ - public function toggleStatusAction($manufacturerId) - { - try { - /** @var EditableManufacturer $editableManufacturer */ - $editableManufacturer = $this->getQueryBus()->handle(new GetManufacturerForEditing((int) $manufacturerId)); - $this->getCommandBus()->handle( - new ToggleManufacturerStatusCommand((int) $manufacturerId, !$editableManufacturer->isEnabled()) - ); - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (ManufacturerException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_manufacturers_index'); - } - - /** - * Export filtered manufacturers. - * - * @AdminSecurity( - * "is_granted(['read', 'update', 'create', 'delete'], request.get('_legacy_controller'))", - * redirectRoute="admin_manufacturers_index" - * ) - * @DemoRestricted(redirectRoute="admin_manufacturers_index") - * - * @return Response - */ - public function exportAction(ManufacturerFilters $filters) - { - $filters = new ManufacturerFilters(['limit' => null] + $filters->all()); - $manufacturersGridFactory = $this->get('prestashop.core.grid.grid_factory.manufacturer'); - $manufacturersGrid = $manufacturersGridFactory->getGrid($filters); - - $headers = [ - 'id_manufacturer' => $this->trans('ID', 'Admin.Global'), - 'logo' => $this->trans('Logo', 'Admin.Global'), - 'name' => $this->trans('Name', 'Admin.Global'), - 'addresses_count' => $this->trans('Addresses', 'Admin.Global'), - 'products_count' => $this->trans('Products', 'Admin.Global'), - 'active' => $this->trans('Enabled', 'Admin.Global'), - ]; - - $data = []; - - foreach ($manufacturersGrid->getData()->getRecords()->all() as $record) { - $data[] = [ - 'id_manufacturer' => $record['id_manufacturer'], - 'logo' => $record['logo'], - 'name' => $record['name'], - 'addresses_count' => $record['addresses_count'], - 'products_count' => $record['products_count'], - 'active' => $record['active'], - ]; - } - - return (new CsvResponse()) - ->setData($data) - ->setHeadersData($headers) - ->setFileName('manufacturer_' . date('Y-m-d_His') . '.csv') - ; - } - - /** - * Deletes address - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", redirectRoute="admin_manufacturers_index") - * @DemoRestricted(redirectRoute="admin_manufacturers_index") - * - * @param int $addressId - * - * @return RedirectResponse - */ - public function deleteAddressAction($addressId) - { - try { - $this->getCommandBus()->handle(new DeleteAddressCommand((int) $addressId)); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (AddressException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_manufacturers_index'); - } - - /** - * Export filtered manufacturer addresses. - * - * @AdminSecurity( - * "is_granted(['read', 'update', 'create', 'delete'], request.get('_legacy_controller'))", - * redirectRoute="admin_manufacturers_index" - * ) - * @DemoRestricted(redirectRoute="admin_manufacturers_index") - * - * @return Response - */ - public function exportAddressAction(ManufacturerAddressFilters $filters) - { - $addressesGridFactory = $this->get('prestashop.core.grid.grid_factory.manufacturer_address'); - $addressesGrid = $addressesGridFactory->getGrid($filters); - - $headers = [ - 'id_address' => $this->trans('ID', 'Admin.Global'), - 'name' => $this->trans('Brand', 'Admin.Global'), - 'firstname' => $this->trans('First name', 'Admin.Global'), - 'lastname' => $this->trans('Last name', 'Admin.Global'), - 'postcode' => $this->trans('Zip/Postal code', 'Admin.Global'), - 'city' => $this->trans('City', 'Admin.Global'), - 'country' => $this->trans('Country', 'Admin.Global'), - ]; - - $data = []; - - foreach ($addressesGrid->getData()->getRecords()->all() as $record) { - $data[] = [ - 'id_address' => $record['id_address'], - 'name' => $record['name'], - 'firstname' => $record['firstname'], - 'lastname' => $record['lastname'], - 'postcode' => $record['postcode'], - 'city' => $record['city'], - 'country' => $record['country'], - ]; - } - - return (new CsvResponse()) - ->setData($data) - ->setHeadersData($headers) - ->setFileName('address_' . date('Y-m-d_His') . '.csv') - ; - } - - /** - * Deletes adresses in bulk action - * - * @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", redirectRoute="admin_manufacturers_index") - * @DemoRestricted(redirectRoute="admin_manufacturers_index") - * - * @return RedirectResponse - */ - public function bulkDeleteAddressAction(Request $request) - { - $addressIds = $this->getBulkAddressesFromRequest($request); - - try { - $this->getCommandBus()->handle(new BulkDeleteAddressCommand($addressIds)); - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (AddressException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_manufacturers_index'); - } - - /** - * Show & process address creation. - * - * @AdminSecurity("is_granted('create', request.get('_legacy_controller'))") - * - * @return Response - */ - public function createAddressAction(Request $request) - { - $addressFormBuilder = $this->getAddressFormBuilder(); - $addressFormHandler = $this->getAddressFormHandler(); - - $formData = []; - if ($request->request->has('manufacturer_address') && isset($request->request->get('manufacturer_address')['id_country'])) { - $formCountryId = (int) $request->request->get('manufacturer_address')['id_country']; - $formData['id_country'] = $formCountryId; - } - - $addressForm = $addressFormBuilder->getForm($formData); - $addressForm->handleRequest($request); - - try { - $result = $addressFormHandler->handle($addressForm); - - if (null !== $result->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_manufacturers_index'); - } - } catch (DomainException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - - if ($e instanceof ManufacturerConstraintException) { - return $this->redirectToRoute('admin_manufacturers_index'); - } - } - - return $this->render('@PrestaShop/Admin/Sell/Catalog/Manufacturer/Address/create.html.twig', [ - 'enableSidebar' => true, - 'layoutTitle' => $this->trans('Add new address', 'Admin.Orderscustomers.Feature'), - 'addressForm' => $addressForm->createView(), - ]); - } - - /** - * Show & process address editing. - * - * @AdminSecurity("is_granted('update', request.get('_legacy_controller'))") - * - * @param int $addressId - * - * @return Response - */ - public function editAddressAction(Request $request, $addressId) - { - $addressId = (int) $addressId; - - $addressFormBuilder = $this->getAddressFormBuilder(); - $addressFormHandler = $this->getAddressFormHandler(); - - $formData = []; - if ($request->request->has('manufacturer_address') && isset($request->request->get('manufacturer_address')['id_country'])) { - $formCountryId = (int) $request->request->get('manufacturer_address')['id_country']; - $formData['id_country'] = $formCountryId; - } - - try { - /** @var EditableManufacturerAddress $editableAddress */ - $editableAddress = $this->getQueryBus()->handle(new GetManufacturerAddressForEditing($addressId)); - $addressForm = $addressFormBuilder->getFormFor($addressId, $formData); - $addressForm->handleRequest($request); - - $result = $addressFormHandler->handleFor($addressId, $addressForm); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_manufacturers_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - - if ($e instanceof AddressNotFoundException || $e instanceof AddressConstraintException) { - return $this->redirectToRoute('admin_manufacturers_index'); - } - } - - if (!isset($editableAddress) || !isset($addressForm)) { - return $this->redirectToRoute('admin_manufacturers_index'); - } - - return $this->render('@PrestaShop/Admin/Sell/Catalog/Manufacturer/Address/edit.html.twig', [ - 'enableSidebar' => true, - 'layoutTitle' => $this->trans('Brands', 'Admin.Catalog.Feature'), - 'addressForm' => $addressForm->createView(), - 'address' => $editableAddress->getAddress(), - ]); - } - - /** - * Provides error messages for exceptions - * - * @return array - */ - private function getErrorMessages() - { - $iniConfig = $this->get('prestashop.core.configuration.ini_configuration'); - - return [ - DeleteManufacturerException::class => [ - DeleteManufacturerException::FAILED_DELETE => $this->trans( - 'An error occurred while deleting the object.', - 'Admin.Notifications.Error' - ), - DeleteManufacturerException::FAILED_BULK_DELETE => $this->trans( - 'An error occurred while deleting this selection.', - 'Admin.Notifications.Error' - ), - ], - UpdateManufacturerException::class => [ - UpdateManufacturerException::FAILED_BULK_UPDATE_STATUS => [ - $this->trans( - 'An error occurred while updating the status.', - 'Admin.Notifications.Error' - ), - ], - UpdateManufacturerException::FAILED_UPDATE_STATUS => [ - $this->trans( - 'An error occurred while updating the status for an object.', - 'Admin.Notifications.Error' - ), - ], - ], - DeleteAddressException::class => [ - DeleteAddressException::FAILED_DELETE => $this->trans( - 'An error occurred while deleting the object.', - 'Admin.Notifications.Error' - ), - DeleteAddressException::FAILED_BULK_DELETE => $this->trans( - 'An error occurred while deleting this selection.', - 'Admin.Notifications.Error' - ), - ], - ManufacturerNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - MemoryLimitException::class => $this->trans( - 'Due to memory limit restrictions, this image cannot be loaded. Please increase your memory_limit value via your server\'s configuration settings.', - 'Admin.Notifications.Error' - ), - ImageUploadException::class => $this->trans( - 'An error occurred while uploading the image.', - 'Admin.Notifications.Error' - ), - ImageOptimizationException::class => $this->trans( - 'Unable to resize one or more of your pictures.', - 'Admin.Catalog.Notification' - ), - UploadedImageConstraintException::class => [ - UploadedImageConstraintException::EXCEEDED_SIZE => $this->trans( - 'Max file size allowed is "%s" bytes.', 'Admin.Notifications.Error', [ - $iniConfig->getUploadMaxSizeInBytes(), - ]), - UploadedImageConstraintException::UNRECOGNIZED_FORMAT => $this->trans( - 'Image format not recognized, allowed formats are: .gif, .jpg, .png', - 'Admin.Notifications.Error' - ), - ], - AddressNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - InvalidAddressFieldException::class => $this->trans( - 'Address fields contain invalid values.', - 'Admin.Notifications.Error' - ), - ]; - } - - /** - * @return array - */ - private function getBulkManufacturersFromRequest(Request $request) - { - $manufacturerIds = $request->request->get('manufacturer_bulk'); - - if (!is_array($manufacturerIds)) { - return []; - } - - foreach ($manufacturerIds as $i => $manufacturerId) { - $manufacturerIds[$i] = (int) $manufacturerId; - } - - return $manufacturerIds; - } - - /** - * @return array - */ - private function getBulkAddressesFromRequest(Request $request) - { - $addressIds = $request->request->get('manufacturer_address_bulk'); - - if (!is_array($addressIds)) { - return []; - } - - foreach ($addressIds as $i => $addressId) { - $addressIds[$i] = (int) $addressId; - } - - return $addressIds; - } - - /** - * @return FormHandlerInterface - */ - private function getFormHandler() - { - return $this->get('prestashop.core.form.identifiable_object.handler.manufacturer_form_handler'); - } - - /** - * @return FormBuilderInterface - */ - private function getFormBuilder() - { - return $this->get('prestashop.core.form.identifiable_object.builder.manufacturer_form_builder'); - } - - /** - * @return FormBuilderInterface - */ - private function getAddressFormBuilder() - { - return $this->get('prestashop.core.form.identifiable_object.builder.manufacturer_address_form_builder'); - } - - /** - * @return FormHandlerInterface - */ - private function getAddressFormHandler() - { - return $this->get('prestashop.core.form.identifiable_object.handler.manufacturer_address_form_handler'); - } - - private function getSettingsTipMessage() - { - $urlOpening = sprintf('', $this->get('router')->generate('admin_preferences')); - $urlEnding = ''; - - if ($this->configuration->get('PS_DISPLAY_MANUFACTURERS')) { - return $this->trans( - 'The display of your brands is enabled on your store. Go to %sShop Parameters > General%s to edit settings.', - 'Admin.Catalog.Notification', - [$urlOpening, $urlEnding] - ); - } - - return $this->trans( - 'The display of your brands is disabled on your store. Go to %sShop Parameters > General%s to edit settings.', - 'Admin.Catalog.Notification', - [$urlOpening, $urlEnding] - ); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/MonitoringController.php b/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/MonitoringController.php deleted file mode 100644 index 2db55be8..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/MonitoringController.php +++ /dev/null @@ -1,258 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\Catalog; - -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Query\GetShowcaseCardIsClosed; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\ValueObject\ShowcaseCard; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\DisabledProductGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\EmptyCategoryGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\NoQtyProductWithCombinationGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\NoQtyProductWithoutCombinationGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\ProductWithoutDescriptionGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\ProductWithoutImageGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\ProductWithoutPriceGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Grid\GridInterface; -use PrestaShop\PrestaShop\Core\Search\Filters\Monitoring\DisabledProductFilters; -use PrestaShop\PrestaShop\Core\Search\Filters\Monitoring\EmptyCategoryFilters; -use PrestaShop\PrestaShop\Core\Search\Filters\Monitoring\NoQtyProductWithCombinationFilters; -use PrestaShop\PrestaShop\Core\Search\Filters\Monitoring\NoQtyProductWithoutCombinationFilters; -use PrestaShop\PrestaShop\Core\Search\Filters\Monitoring\ProductWithoutDescriptionFilters; -use PrestaShop\PrestaShop\Core\Search\Filters\Monitoring\ProductWithoutImageFilters; -use PrestaShop\PrestaShop\Core\Search\Filters\Monitoring\ProductWithoutPriceFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Form\Admin\Sell\Category\DeleteCategoriesType; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Service\Grid\ResponseBuilder; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Responsible for Sell > Catalog > Monitoring page - */ -class MonitoringController extends FrameworkBundleAdminController -{ - /** - * Shows Monitoring listing page - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * @param EmptyCategoryFilters $emptyCategoryFilters - * @param NoQtyProductWithCombinationFilters $noQtyProductWithCombinationFilters - * @param NoQtyProductWithoutCombinationFilters $noQtyProductWithoutCombinationFilters - * @param DisabledProductFilters $disabledProductFilters - * @param ProductWithoutImageFilters $productWithoutImageFilters - * @param ProductWithoutDescriptionFilters $productWithoutDescriptionFilters - * @param ProductWithoutPriceFilters $productWithoutPriceFilters - * - * @return Response - */ - public function indexAction( - Request $request, - EmptyCategoryFilters $emptyCategoryFilters, - NoQtyProductWithCombinationFilters $noQtyProductWithCombinationFilters, - NoQtyProductWithoutCombinationFilters $noQtyProductWithoutCombinationFilters, - DisabledProductFilters $disabledProductFilters, - ProductWithoutImageFilters $productWithoutImageFilters, - ProductWithoutDescriptionFilters $productWithoutDescriptionFilters, - ProductWithoutPriceFilters $productWithoutPriceFilters - ) { - $deleteCategoryForm = $this->createForm(DeleteCategoriesType::class); - - $emptyCategoryGrid = $this->getEmptyCategoryGrid($emptyCategoryFilters); - $noQtyProductWithCombinationGrid = $this->getNoQtyProductWithCombinationGrid($noQtyProductWithCombinationFilters); - $noQtyProductWithoutCombinationGrid = $this->getNoQtyProductWithoutCombinationGrid($noQtyProductWithoutCombinationFilters); - $disabledProductGrid = $this->getDisabledProductGrid($disabledProductFilters); - $productWithoutImageGrid = $this->getProductWithoutImageGrid($productWithoutImageFilters); - $productWithoutDescriptionGrid = $this->getProductWithoutDescriptionGrid($productWithoutDescriptionFilters); - $productWithoutPriceGrid = $this->getProductWithoutPriceGrid($productWithoutPriceFilters); - - $isShowcaseCardClosed = $this->getQueryBus()->handle( - new GetShowcaseCardIsClosed($this->getContext()->employee->id, ShowcaseCard::MONITORING_CARD) - ); - - return $this->render('@PrestaShop/Admin/Sell/Catalog/Monitoring/index.html.twig', [ - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'emptyCategoryGrid' => $this->presentGrid($emptyCategoryGrid), - 'deleteCategoryForm' => $deleteCategoryForm->createView(), - 'noQtyProductWithCombinationGrid' => $this->presentGrid($noQtyProductWithCombinationGrid), - 'noQtyProductWithoutCombinationGrid' => $this->presentGrid($noQtyProductWithoutCombinationGrid), - 'disabledProductGrid' => $this->presentGrid($disabledProductGrid), - 'productWithoutImageGrid' => $this->presentGrid($productWithoutImageGrid), - 'productWithoutDescriptionGrid' => $this->presentGrid($productWithoutDescriptionGrid), - 'productWithoutPriceGrid' => $this->presentGrid($productWithoutPriceGrid), - 'showcaseCardName' => ShowcaseCard::MONITORING_CARD, - 'isShowcaseCardClosed' => $isShowcaseCardClosed, - ]); - } - - /** - * Provides filters functionality - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function searchAction(Request $request) - { - $gridIdentifiers = $this->identifySearchableGrid($request); - - /** @var ResponseBuilder $responseBuilder */ - $responseBuilder = $this->get('prestashop.bundle.grid.response_builder'); - - return $responseBuilder->buildSearchResponse( - $gridIdentifiers['grid_definition'], - $request, - $gridIdentifiers['grid_id'], - 'admin_monitorings_index' - ); - } - - /** - * Parses grid identifying parts from request in order to recognize which grid is being filtered - * - * @param Request $request - * - * @return array - */ - private function identifySearchableGrid(Request $request) - { - $gridDefinition = 'prestashop.core.grid.definition.factory.monitoring.empty_category'; - $gridId = EmptyCategoryGridDefinitionFactory::GRID_ID; - - $definitionMap = [ - NoQtyProductWithCombinationGridDefinitionFactory::GRID_ID => 'prestashop.core.grid.definition.factory.monitoring.no_qty_product_with_combination', - NoQtyProductWithoutCombinationGridDefinitionFactory::GRID_ID => 'prestashop.core.grid.definition.factory.monitoring.no_qty_product_without_combination', - DisabledProductGridDefinitionFactory::GRID_ID => 'prestashop.core.grid.definition.factory.monitoring.disabled_product', - ProductWithoutImageGridDefinitionFactory::GRID_ID => 'prestashop.core.grid.definition.factory.monitoring.product_without_image', - ProductWithoutDescriptionGridDefinitionFactory::GRID_ID => 'prestashop.core.grid.definition.factory.monitoring.product_without_description', - ProductWithoutPriceGridDefinitionFactory::GRID_ID => 'prestashop.core.grid.definition.factory.monitoring.product_without_price', - ]; - - foreach ($definitionMap as $id => $definition) { - if ($request->request->has($id)) { - $gridId = $id; - $gridDefinition = $definition; - - break; - } - } - - return [ - 'grid_id' => $gridId, - 'grid_definition' => $this->get($gridDefinition), - ]; - } - - /** - * @param EmptyCategoryFilters $filters - * - * @return GridInterface - */ - private function getEmptyCategoryGrid(EmptyCategoryFilters $filters) - { - $gridFactory = $this->get('prestashop.core.grid.grid_factory.empty_category'); - - return $gridFactory->getGrid($filters); - } - - /** - * @param NoQtyProductWithCombinationFilters $filters - * - * @return GridInterface - */ - private function getNoQtyProductWithCombinationGrid(NoQtyProductWithCombinationFilters $filters) - { - $gridFactory = $this->get('prestashop.core.grid.grid_factory.no_qty_product_with_combination'); - - return $gridFactory->getGrid($filters); - } - - /** - * @param NoQtyProductWithoutCombinationFilters $filters - * - * @return GridInterface - */ - private function getNoQtyProductWithoutCombinationGrid(NoQtyProductWithoutCombinationFilters $filters) - { - $gridFactory = $this->get('prestashop.core.grid.grid_factory.no_qty_product_without_combination'); - - return $gridFactory->getGrid($filters); - } - - /** - * @param DisabledProductFilters $filters - * - * @return GridInterface - */ - private function getDisabledProductGrid(DisabledProductFilters $filters) - { - $gridFactory = $this->get('prestashop.core.grid.grid_factory.disabled_product'); - - return $gridFactory->getGrid($filters); - } - - /** - * @param ProductWithoutImageFilters $filters - * - * @return GridInterface - */ - private function getProductWithoutImageGrid(ProductWithoutImageFilters $filters) - { - $gridFactory = $this->get('prestashop.core.grid.grid_factory.product_without_image'); - - return $gridFactory->getGrid($filters); - } - - /** - * @param ProductWithoutDescriptionFilters $filters - * - * @return GridInterface - */ - private function getProductWithoutDescriptionGrid(ProductWithoutDescriptionFilters $filters) - { - $gridFactory = $this->get('prestashop.core.grid.grid_factory.product_without_description'); - - return $gridFactory->getGrid($filters); - } - - /** - * @param ProductWithoutPriceFilters $filters - * - * @return GridInterface - */ - private function getProductWithoutPriceGrid(ProductWithoutPriceFilters $filters) - { - $gridFactory = $this->get('prestashop.core.grid.grid_factory.product_without_price'); - - return $gridFactory->getGrid($filters); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/SupplierController.php b/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/SupplierController.php deleted file mode 100644 index 09cd0dfc..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/SupplierController.php +++ /dev/null @@ -1,547 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\Catalog; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Address\Exception\AddressNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\BulkDeleteSupplierCommand; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\BulkDisableSupplierCommand; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\BulkEnableSupplierCommand; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\DeleteSupplierCommand; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Command\ToggleSupplierStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\CannotDeleteSupplierException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\CannotToggleSupplierStatusException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\CannotUpdateSupplierStatusException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Exception\SupplierNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Query\GetSupplierForEditing; -use PrestaShop\PrestaShop\Core\Domain\Supplier\Query\GetSupplierForViewing; -use PrestaShop\PrestaShop\Core\Domain\Supplier\QueryResult\EditableSupplier; -use PrestaShop\PrestaShop\Core\Domain\Supplier\QueryResult\ViewableSupplier; -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilderInterface; -use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandlerInterface; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\ImageOptimizationException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\ImageUploadException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\MemoryLimitException; -use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\UploadedImageConstraintException; -use PrestaShop\PrestaShop\Core\Search\Filters\SupplierFilters; -use PrestaShopBundle\Component\CsvResponse; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class SupplierController is responsible for "Sell > Catalog > Brands & Suppliers > Suppliers" page. - */ -class SupplierController extends FrameworkBundleAdminController -{ - /** - * Show suppliers listing. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * @param SupplierFilters $filters - * - * @return Response - */ - public function indexAction(Request $request, SupplierFilters $filters) - { - $supplierGridFactory = $this->get('prestashop.core.grid.factory.supplier'); - $supplierGrid = $supplierGridFactory->getGrid($filters); - - return $this->render( - '@PrestaShop/Admin/Sell/Catalog/Suppliers/index.html.twig', - [ - 'supplierGrid' => $this->presentGrid($supplierGrid), - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - 'settingsTipMessage' => $this->getSettingsTipMessage(), - ] - ); - } - - /** - * Displays supplier creation form and handles form submit which creates new supplier. - * - * @AdminSecurity( - * "is_granted('create', request.get('_legacy_controller'))", - * redirectRoute="admin_suppliers_index", - * message="You do not have permission to add this." - * ) - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request) - { - $formData = []; - if ($request->request->has('supplier') && isset($request->request->get('supplier')['id_country'])) { - $formCountryId = (int) $request->request->get('supplier')['id_country']; - $formData['id_country'] = $formCountryId; - } - - $supplierForm = $this->getFormBuilder()->getForm($formData); - $supplierForm->handleRequest($request); - - try { - $result = $this->getFormHandler()->handle($supplierForm); - - if (null !== $result->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_suppliers_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->render('@PrestaShop/Admin/Sell/Catalog/Suppliers/add.html.twig', [ - 'supplierForm' => $supplierForm->createView(), - ]); - } - - /** - * Deletes supplier. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_suppliers_index", - * message="You do not have permission to delete this." - * ) - * @DemoRestricted( - * redirectRoute="admin_suppliers_index" - * ) - * - * @param int $supplierId - * - * @return RedirectResponse - */ - public function deleteAction($supplierId) - { - try { - $this->getCommandBus()->handle(new DeleteSupplierCommand((int) $supplierId)); - - $this->addFlash( - 'success', - $this->trans('Successful deletion.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_suppliers_index'); - } - - /** - * Bulk deletion of suppliers. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_suppliers_index", - * message="You do not have permission to delete this." - * ) - * @DemoRestricted( - * redirectRoute="admin_suppliers_index" - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkDeleteAction(Request $request) - { - $suppliersToDelete = $request->request->get('supplier_bulk'); - - try { - $suppliersToDelete = array_map( - function ($item) { - return (int) $item; - }, - $suppliersToDelete - ); - $this->getCommandBus()->handle(new BulkDeleteSupplierCommand($suppliersToDelete)); - - $this->addFlash( - 'success', - $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_suppliers_index'); - } - - /** - * Bulk disables supplier statuses. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_suppliers_index", - * message="You do not have permission to edit this." - * ) - * @DemoRestricted( - * redirectRoute="admin_suppliers_index" - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkDisableAction(Request $request) - { - $suppliersToDisable = $request->request->get('supplier_bulk'); - - try { - $suppliersToDisable = array_map( - function ($item) { - return (int) $item; - }, - $suppliersToDisable - ); - $this->getCommandBus()->handle(new BulkDisableSupplierCommand($suppliersToDisable)); - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_suppliers_index'); - } - - /** - * Bulk enables supplier statuses. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_suppliers_index", - * message="You do not have permission to edit this." - * ) - * @DemoRestricted( - * redirectRoute="admin_suppliers_index" - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkEnableAction(Request $request) - { - $suppliersToEnable = $request->request->get('supplier_bulk'); - - try { - $suppliersToEnable = array_map( - function ($item) { - return (int) $item; - }, - $suppliersToEnable - ); - $this->getCommandBus()->handle(new BulkEnableSupplierCommand($suppliersToEnable)); - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_suppliers_index'); - } - - /** - * Displays edit supplier form and submits form. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_suppliers_index", - * message="You do not have permission to edit this." - * ) - * - * @param Request $request - * @param int $supplierId - * - * @return Response - */ - public function editAction(Request $request, $supplierId) - { - $formData = []; - if ($request->request->has('supplier') && isset($request->request->get('supplier')['id_country'])) { - $formCountryId = (int) $request->request->get('supplier')['id_country']; - $formData['id_country'] = $formCountryId; - } - - try { - /** @var EditableSupplier $editableSupplier */ - $editableSupplier = $this->getQueryBus()->handle(new GetSupplierForEditing((int) $supplierId)); - - $supplierForm = $this->getFormBuilder()->getFormFor((int) $supplierId, $formData); - $supplierForm->handleRequest($request); - - $result = $this->getFormHandler()->handleFor((int) $supplierId, $supplierForm); - - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_suppliers_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - if (!isset($supplierForm) || !isset($editableSupplier)) { - return $this->redirectToRoute('admin_suppliers_index'); - } - - return $this->render('@PrestaShop/Admin/Sell/Catalog/Suppliers/edit.html.twig', [ - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - 'supplierForm' => $supplierForm->createView(), - 'supplierName' => $editableSupplier->getName(), - 'logoImage' => $editableSupplier->getLogoImage(), - ]); - } - - /** - * Toggles supplier active status. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_suppliers_index", - * message="You do not have permission to edit this." - * ) - * @DemoRestricted( - * redirectRoute="admin_suppliers_index" - * ) - * - * @param int $supplierId - * - * @return RedirectResponse - */ - public function toggleStatusAction($supplierId) - { - try { - $this->getCommandBus()->handle(new ToggleSupplierStatusCommand((int) $supplierId)); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_suppliers_index'); - } - - /** - * Views supplier products information. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * @param int $supplierId - * - * @return Response - */ - public function viewAction(Request $request, $supplierId) - { - try { - /** @var ViewableSupplier $viewableSupplier */ - $viewableSupplier = $this->getQueryBus()->handle(new GetSupplierForViewing( - (int) $supplierId, - (int) $this->getContextLangId() - )); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - - return $this->redirectToRoute('admin_suppliers_index'); - } - - return $this->render('@PrestaShop/Admin/Sell/Catalog/Suppliers/view.html.twig', [ - 'layoutTitle' => $viewableSupplier->getName(), - 'viewableSupplier' => $viewableSupplier, - 'isStockManagementEnabled' => $this->configuration->get('PS_STOCK_MANAGEMENT'), - 'isAllShopContext' => $this->get('prestashop.adapter.shop.context')->isAllShopContext(), - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - ]); - } - - /** - * Exports to csv visible suppliers list data. - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @param SupplierFilters $filters - * - * @return CsvResponse - */ - public function exportAction(SupplierFilters $filters) - { - $filters = new SupplierFilters(['limit' => null] + $filters->all()); - $supplierGridFactory = $this->get('prestashop.core.grid.factory.supplier'); - $supplierGrid = $supplierGridFactory->getGrid($filters); - - $headers = [ - 'id_supplier' => $this->trans('ID', 'Admin.Global'), - 'name' => $this->trans('Name', 'Admin.Global'), - 'products_count' => $this->trans('Number of products', 'Admin.Catalog.Feature'), - 'active' => $this->trans('Enabled', 'Admin.Global'), - ]; - - $data = []; - - foreach ($supplierGrid->getData()->getRecords()->all() as $record) { - $data[] = [ - 'id_supplier' => $record['id_supplier'], - 'name' => $record['name'], - 'products_count' => $record['products_count'], - 'active' => $record['active'], - ]; - } - - return (new CsvResponse()) - ->setData($data) - ->setHeadersData($headers) - ->setFileName('supplier_' . date('Y-m-d_His') . '.csv') - ; - } - - /** - * Provides error messages for exceptions - * - * @return array - */ - private function getErrorMessages() - { - $iniConfig = $this->get('prestashop.core.configuration.ini_configuration'); - - return [ - SupplierNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found).', - 'Admin.Notifications.Error' - ), - AddressNotFoundException::class => $this->trans( - 'The address for this supplier has been deleted.', - 'Admin.Notifications.Error' - ), - CannotToggleSupplierStatusException::class => $this->trans( - 'An error occurred while updating the status.', - 'Admin.Notifications.Error' - ), - CannotUpdateSupplierStatusException::class => $this->trans( - 'An error occurred while updating the status for an object.', - 'Admin.Notifications.Error' - ), - SupplierConstraintException::class => [ - SupplierConstraintException::INVALID_BULK_DATA => $this->trans( - 'You must select at least one element to delete.', - 'Admin.Notifications.Error' - ), - ], - CannotDeleteSupplierException::class => [ - CannotDeleteSupplierException::HAS_PENDING_ORDERS => $this->trans( - 'It is not possible to delete a supplier if there are pending supplier orders.', - 'Admin.Catalog.Notification' - ), - CannotDeleteSupplierException::FAILED_DELETE => $this->trans( - 'An error occurred while deleting the object.', - 'Admin.Notifications.Error' - ), - CannotDeleteSupplierException::FAILED_BULK_DELETE => $this->trans( - 'An error occurred while deleting this selection.', - 'Admin.Notifications.Error' - ), - ], - MemoryLimitException::class => $this->trans( - 'Due to memory limit restrictions, this image cannot be loaded. Please increase your memory_limit value via your server\'s configuration settings.', - 'Admin.Notifications.Error' - ), - ImageUploadException::class => $this->trans( - 'An error occurred while uploading the image.', - 'Admin.Notifications.Error' - ), - ImageOptimizationException::class => $this->trans( - 'Unable to resize one or more of your pictures.', - 'Admin.Catalog.Notification' - ), - UploadedImageConstraintException::class => [ - UploadedImageConstraintException::EXCEEDED_SIZE => $this->trans( - 'Maximum image size: %s.', 'Admin.Global', [ - $iniConfig->getUploadMaxSizeInBytes(), - ]), - UploadedImageConstraintException::UNRECOGNIZED_FORMAT => $this->trans( - 'Image format not recognized, allowed formats are: .gif, .jpg, .png', - 'Admin.Notifications.Error' - ), - ], - ]; - } - - /** - * @return FormBuilderInterface - */ - private function getFormBuilder() - { - return $this->get('prestashop.core.form.identifiable_object.builder.supplier_form_builder'); - } - - /** - * @return FormHandlerInterface - */ - private function getFormHandler() - { - return $this->get('prestashop.core.form.identifiable_object.handler.supplier_form_handler'); - } - - protected function getSettingsTipMessage() - { - $urlOpening = sprintf('', $this->get('router')->generate('admin_preferences')); - $urlEnding = ''; - - if ($this->configuration->get('PS_DISPLAY_SUPPLIERS')) { - return $this->trans( - 'The display of your suppliers is enabled on your store. Go to %sShop Parameters > General%s to edit settings.', - 'Admin.Catalog.Notification', - [$urlOpening, $urlEnding] - ); - } - - return $this->trans( - 'The display of your suppliers is disabled on your store. Go to %sShop Parameters > General%s to edit settings.', - 'Admin.Catalog.Notification', - [$urlOpening, $urlEnding] - ); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Customer/CustomerController.php b/src/PrestaShopBundle/Controller/Admin/Sell/Customer/CustomerController.php deleted file mode 100644 index 1d28ee84..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/Customer/CustomerController.php +++ /dev/null @@ -1,963 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\Customer; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\BulkDeleteCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\BulkDisableCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\BulkEnableCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\DeleteCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\EditCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\SetPrivateNoteAboutCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\SetRequiredFieldsForCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\Command\TransformGuestToCustomerCommand; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerByEmailNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerConstraintException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerDefaultGroupAccessException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\CustomerTransformationException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\DuplicateCustomerEmailException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Exception\MissingCustomerRequiredFieldsException; -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerCarts; -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerForAddressCreation; -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerForEditing; -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerForViewing; -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerOrders; -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetRequiredFieldsForCustomer; -use PrestaShop\PrestaShop\Core\Domain\Customer\Query\SearchCustomers; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\AddressCreationCustomerInformation; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\EditableCustomer; -use PrestaShop\PrestaShop\Core\Domain\Customer\QueryResult\ViewableCustomer; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\Password; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Query\GetShowcaseCardIsClosed; -use PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\ValueObject\ShowcaseCard; -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CustomerGridDefinitionFactory; -use PrestaShop\PrestaShop\Core\Search\Filters\CustomerFilters; -use PrestaShopBundle\Component\CsvResponse; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController as AbstractAdminController; -use PrestaShopBundle\Form\Admin\Sell\Customer\DeleteCustomersType; -use PrestaShopBundle\Form\Admin\Sell\Customer\PrivateNoteType; -use PrestaShopBundle\Form\Admin\Sell\Customer\RequiredFieldsType; -use PrestaShopBundle\Form\Admin\Sell\Customer\TransferGuestAccountType; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class CustomerController manages "Sell > Customers" page. - */ -class CustomerController extends AbstractAdminController -{ - /** - * Show customers listing. - * - * @AdminSecurity( - * "is_granted('read', request.get('_legacy_controller'))", - * redirectRoute="admin_customers_index", - * message="You do not have permission to view this." - * ) - * - * @param Request $request - * @param CustomerFilters $filters - * - * @return Response - */ - public function indexAction(Request $request, CustomerFilters $filters) - { - $customersKpiFactory = $this->get('prestashop.core.kpi_row.factory.customers'); - - $customerGridFactory = $this->get('prestashop.core.grid.factory.customer'); - $customerGrid = $customerGridFactory->getGrid($filters); - - $deleteCustomerForm = $this->createForm(DeleteCustomersType::class); - - $showcaseCardIsClosed = $this->getQueryBus()->handle( - new GetShowcaseCardIsClosed((int) $this->getContext()->employee->id, ShowcaseCard::CUSTOMERS_CARD) - ); - - return $this->render('@PrestaShop/Admin/Sell/Customer/index.html.twig', [ - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'customerGrid' => $this->presentGrid($customerGrid), - 'customersKpi' => $customersKpiFactory->build(), - 'customerRequiredFieldsForm' => $this->getRequiredFieldsForm()->createView(), - 'isSingleShopContext' => $this->get('prestashop.adapter.shop.context')->isSingleShopContext(), - 'deleteCustomersForm' => $deleteCustomerForm->createView(), - 'showcaseCardName' => ShowcaseCard::CUSTOMERS_CARD, - 'isShowcaseCardClosed' => $showcaseCardIsClosed, - ]); - } - - /** - * Process Grid search. - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return RedirectResponse - */ - public function searchGridAction(Request $request) - { - $responseBuilder = $this->get('prestashop.bundle.grid.response_builder'); - - return $responseBuilder->buildSearchResponse( - $this->get('prestashop.core.grid.definition.factory.customer'), - $request, - CustomerGridDefinitionFactory::GRID_ID, - 'admin_customers_index' - ); - } - - /** - * Show customer create form & handle processing of it. - * - * @AdminSecurity("is_granted(['create'], request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request) - { - if (!$this->get('prestashop.adapter.shop.context')->isSingleShopContext()) { - return $this->redirectToRoute('admin_customers_index'); - } - - $this->addGroupSelectionToRequest($request); - - $customerForm = $this->get('prestashop.core.form.identifiable_object.builder.customer_form_builder')->getForm(); - $customerForm->handleRequest($request); - - $customerFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.customer_form_handler'); - - try { - $result = $customerFormHandler->handle($customerForm); - - if ($customerId = $result->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - if ($request->query->has('submitFormAjax')) { - /** @var ViewableCustomer $customerInformation */ - $customerInformation = $this->getQueryBus()->handle(new GetCustomerForViewing((int) $customerId)); - - return $this->render('@PrestaShop/Admin/Sell/Customer/modal_create_success.html.twig', [ - 'customerId' => $customerId, - 'customerEmail' => $customerInformation->getPersonalInformation()->getEmail(), - ]); - } - - return $this->redirectToRoute('admin_customers_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->render('@PrestaShop/Admin/Sell/Customer/create.html.twig', [ - 'customerForm' => $customerForm->createView(), - 'isB2bFeatureActive' => $this->get('prestashop.core.b2b.b2b_feature')->isActive(), - 'minPasswordLength' => Password::MIN_LENGTH, - 'displayInIframe' => $request->query->has('submitFormAjax'), - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - ]); - } - - /** - * Show customer edit form & handle processing of it. - * - * @AdminSecurity("is_granted(['update'], request.get('_legacy_controller'))") - * - * @param int $customerId - * @param Request $request - * - * @return Response - */ - public function editAction($customerId, Request $request) - { - $this->addGroupSelectionToRequest($request); - try { - /** @var ViewableCustomer $customerInformation */ - $customerInformation = $this->getQueryBus()->handle(new GetCustomerForViewing((int) $customerId)); - $customerFormOptions = [ - 'is_password_required' => false, - ]; - $customerForm = $this->get('prestashop.core.form.identifiable_object.builder.customer_form_builder') - ->getFormFor((int) $customerId, [], $customerFormOptions); - $customerForm->handleRequest($request); - $customerFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.customer_form_handler'); - $result = $customerFormHandler->handleFor((int) $customerId, $customerForm); - if ($result->isSubmitted() && $result->isValid()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_customers_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - if ($e instanceof CustomerNotFoundException) { - return $this->redirectToRoute('admin_customers_index'); - } - } - - return $this->render('@PrestaShop/Admin/Sell/Customer/edit.html.twig', [ - 'customerForm' => $customerForm->createView(), - 'customerInformation' => $customerInformation, - 'isB2bFeatureActive' => $this->get('prestashop.core.b2b.b2b_feature')->isActive(), - 'minPasswordLength' => Password::MIN_LENGTH, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - ]); - } - - /** - * View customer information. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))", redirectRoute="admin_customers_index") - * @DemoRestricted(redirectRoute="admin_customers_index") - * - * @param int $customerId - * @param Request $request - * - * @return Response - */ - public function viewAction($customerId, Request $request) - { - try { - /** @var ViewableCustomer $customerInformation */ - $customerInformation = $this->getQueryBus()->handle(new GetCustomerForViewing((int) $customerId)); - } catch (CustomerNotFoundException $e) { - $this->addFlash( - 'error', - $this->trans('This customer does not exist.', 'Admin.Orderscustomers.Notification') - ); - - return $this->redirectToRoute('admin_customers_index'); - } - - $transferGuestAccountForm = null; - if ($customerInformation->getPersonalInformation()->isGuest()) { - $transferGuestAccountForm = $this->createForm(TransferGuestAccountType::class, [ - 'id_customer' => $customerId, - ])->createView(); - } - - $privateNoteForm = $this->createForm(PrivateNoteType::class, [ - 'note' => $customerInformation->getGeneralInformation()->getPrivateNote(), - ]); - - if ($request->query->has('conf')) { - $this->manageLegacyFlashes($request->query->get('conf')); - } - - return $this->render('@PrestaShop/Admin/Sell/Customer/view.html.twig', [ - 'enableSidebar' => true, - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'customerInformation' => $customerInformation, - 'isMultistoreEnabled' => $this->get('prestashop.adapter.feature.multistore')->isActive(), - 'transferGuestAccountForm' => $transferGuestAccountForm, - 'privateNoteForm' => $privateNoteForm->createView(), - ]); - } - - /** - * Set private note about customer. - * - * @AdminSecurity( - * "is_granted(['update', 'create'], request.get('_legacy_controller'))", - * redirectRoute="admin_customers_index" - * ) - * - * @param int $customerId - * @param Request $request - * - * @return Response - */ - public function setPrivateNoteAction($customerId, Request $request) - { - $privateNoteForm = $this->createForm(PrivateNoteType::class); - $privateNoteForm->handleRequest($request); - - if ($privateNoteForm->isSubmitted()) { - $data = $privateNoteForm->getData(); - - try { - $this->getCommandBus()->handle(new SetPrivateNoteAboutCustomerCommand( - (int) $customerId, - $data['note'] - )); - - if ($request->isXmlHttpRequest()) { - return $this->json([ - 'success' => true, - 'message' => $this->trans('Successful update.', 'Admin.Notifications.Success'), - ]); - } - - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - } catch (CustomerException $e) { - $this->addFlash( - 'error', - $this->getErrorMessageForException($e, $this->getErrorMessages($e)) - ); - } - } - - return $this->redirectToRoute('admin_customers_view', [ - 'customerId' => $customerId, - ]); - } - - /** - * Transforms guest to customer - * - * @AdminSecurity( - * "is_granted(['update', 'create'], request.get('_legacy_controller'))", - * redirectRoute="admin_customers_index" - * ) - * - * @param int $customerId - * @param Request $request - * - * @return RedirectResponse - */ - public function transformGuestToCustomerAction($customerId, Request $request) - { - try { - $this->getCommandBus()->handle(new TransformGuestToCustomerCommand((int) $customerId)); - - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - } catch (CustomerException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - if ($request->query->get('id_order')) { - $legacyLink = $this->getAdminLink('AdminOrders', [ - 'id_order' => $request->query->get('id_order'), - 'vieworder' => true, - ]); - - return $this->redirect($legacyLink); - } - - return $this->redirectToRoute('admin_customers_view', [ - 'customerId' => $customerId, - ]); - } - - /** - * Sets required fields for customer - * - * @AdminSecurity( - * "is_granted(['update', 'create'], request.get('_legacy_controller'))", - * redirectRoute="admin_customers_index" - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function setRequiredFieldsAction(Request $request) - { - $requiredFieldsForm = $this->getRequiredFieldsForm(); - $requiredFieldsForm->handleRequest($request); - - if ($requiredFieldsForm->isSubmitted()) { - $data = $requiredFieldsForm->getData(); - - $this->getCommandBus()->handle(new SetRequiredFieldsForCustomerCommand($data['required_fields'])); - - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - } - - return $this->redirectToRoute('admin_customers_index'); - } - - /** - * Search for customers by query. - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller')) || is_granted('create', 'AdminOrders')") - * - * @param Request $request - * - * @return JsonResponse - */ - public function searchAction(Request $request) - { - $query = $request->query->get('customer_search'); - $phrases = explode(' ', $query); - $isRequestFromLegacyPage = !$request->query->has('sf2'); - - try { - $customers = $this->getQueryBus()->handle(new SearchCustomers($phrases)); - } catch (Exception $e) { - return $this->json( - ['message' => $this->getErrorMessageForException($e, $this->getErrorMessages($e))], - Response::HTTP_INTERNAL_SERVER_ERROR - ); - } - - // if call is made from legacy page - // it will return response so legacy can understand it - if ($isRequestFromLegacyPage) { - return $this->json([ - 'found' => !empty($customers), - 'customers' => $customers, - ]); - } - - return $this->json($customers); - } - - /** - * Provides customer information for address creation in json format - * - * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") - * - * @param Request $request - * - * @return JsonResponse - */ - public function getCustomerInformationAction(Request $request): Response - { - try { - $email = $request->query->get('email'); - - /** @var AddressCreationCustomerInformation $customerInformation */ - $customerInformation = $this->getQueryBus()->handle(new GetCustomerForAddressCreation($email)); - - return $this->json($customerInformation); - } catch (Exception $e) { - $code = Response::HTTP_INTERNAL_SERVER_ERROR; - - if ($e instanceof CustomerException) { - $code = Response::HTTP_NOT_FOUND; - } - - return $this->json([ - 'message' => $this->getErrorMessageForException($e, $this->getErrorMessages($e)), - ], - $code - ); - } - } - - /** - * Toggle customer status. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_customers_index", - * message="You do not have permission to edit this." - * ) - * - * @param int $customerId - * - * @return RedirectResponse - */ - public function toggleStatusAction($customerId) - { - try { - /** @var EditableCustomer $editableCustomer */ - $editableCustomer = $this->getQueryBus()->handle(new GetCustomerForEditing((int) $customerId)); - - $editCustomerCommand = new EditCustomerCommand((int) $customerId); - $editCustomerCommand->setIsEnabled(!$editableCustomer->isEnabled()); - - $this->getCommandBus()->handle($editCustomerCommand); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (CustomerException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_customers_index'); - } - - /** - * Toggle customer newsletter subscription status. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_customers_index", - * message="You do not have permission to edit this." - * ) - * - * @param int $customerId - * - * @return RedirectResponse - */ - public function toggleNewsletterSubscriptionAction($customerId) - { - try { - /** @var EditableCustomer $editableCustomer */ - $editableCustomer = $this->getQueryBus()->handle(new GetCustomerForEditing((int) $customerId)); - - $editCustomerCommand = new EditCustomerCommand((int) $customerId); - - // toggle newsletter subscription - $editCustomerCommand->setNewsletterSubscribed(!$editableCustomer->isNewsletterSubscribed()); - - $this->getCommandBus()->handle($editCustomerCommand); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (CustomerException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_customers_index'); - } - - /** - * Toggle customer partner offer subscription status. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_customers_index", - * message="You do not have permission to edit this." - * ) - * - * @param int $customerId - * - * @return RedirectResponse - */ - public function togglePartnerOfferSubscriptionAction($customerId) - { - try { - /** @var EditableCustomer $editableCustomer */ - $editableCustomer = $this->getQueryBus()->handle(new GetCustomerForEditing((int) $customerId)); - - $editCustomerCommand = new EditCustomerCommand((int) $customerId); - $editCustomerCommand->setIsPartnerOffersSubscribed(!$editableCustomer->isPartnerOffersSubscribed()); - - $this->getCommandBus()->handle($editCustomerCommand); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (CustomerException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_customers_index'); - } - - /** - * Delete customers in bulk action. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_customers_index", - * message="You do not have permission to delete this." - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function deleteBulkAction(Request $request) - { - $form = $this->createForm(DeleteCustomersType::class); - $form->handleRequest($request); - - if ($form->isSubmitted()) { - $data = $form->getData(); - - $customerIds = array_map(function ($customerId) { - return (int) $customerId; - }, $data['customers_to_delete']); - - try { - $command = new BulkDeleteCustomerCommand( - $customerIds, - $data['delete_method'] - ); - - $this->getCommandBus()->handle($command); - - $this->addFlash( - 'success', - $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success') - ); - } catch (CustomerException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - } - - return $this->redirectToRoute('admin_customers_index'); - } - - /** - * Delete customer. - * - * @AdminSecurity( - * "is_granted('delete', request.get('_legacy_controller'))", - * redirectRoute="admin_customers_index", - * message="You do not have permission to delete this." - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function deleteAction(Request $request) - { - $form = $this->createForm(DeleteCustomersType::class); - $form->handleRequest($request); - - if ($form->isSubmitted()) { - $data = $form->getData(); - - $customerId = (int) reset($data['customers_to_delete']); - - try { - $command = new DeleteCustomerCommand( - $customerId, - $data['delete_method'] - ); - - $this->getCommandBus()->handle($command); - - $this->addFlash('success', $this->trans('Successful deletion.', 'Admin.Notifications.Success')); - } catch (CustomerException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - } - - return $this->redirectToRoute('admin_customers_index'); - } - - /** - * Enable customers in bulk action. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_customers_index", - * message="You do not have permission to edit this." - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function enableBulkAction(Request $request) - { - $customerIds = array_map(function ($customerId) { - return (int) $customerId; - }, $request->request->get('customer_customers_bulk', [])); - - try { - $command = new BulkEnableCustomerCommand($customerIds); - - $this->getCommandBus()->handle($command); - - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - } catch (CustomerException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_customers_index'); - } - - /** - * Disable customers in bulk action. - * - * @AdminSecurity( - * "is_granted('update', request.get('_legacy_controller'))", - * redirectRoute="admin_customers_index", - * message="You do not have permission to edit this." - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function disableBulkAction(Request $request) - { - try { - $customerIds = array_map(function ($customerId) { - return (int) $customerId; - }, $request->request->get('customer_customers_bulk', [])); - - $command = new BulkDisableCustomerCommand($customerIds); - - $this->getCommandBus()->handle($command); - - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - } catch (CustomerException $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e))); - } - - return $this->redirectToRoute('admin_customers_index'); - } - - /** - * Export filtered customers - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @param CustomerFilters $filters - * - * @return CsvResponse - */ - public function exportAction(CustomerFilters $filters) - { - $filters = new CustomerFilters(['limit' => null] + $filters->all()); - $gridFactory = $this->get('prestashop.core.grid.factory.customer'); - $grid = $gridFactory->getGrid($filters); - - $headers = [ - 'id_customer' => $this->trans('ID', 'Admin.Global'), - 'social_title' => $this->trans('Social title', 'Admin.Global'), - 'firstname' => $this->trans('First name', 'Admin.Global'), - 'lastname' => $this->trans('Last name', 'Admin.Global'), - 'email' => $this->trans('Email address', 'Admin.Global'), - 'company' => $this->trans('Company', 'Admin.Global'), - 'total_spent' => $this->trans('Sales', 'Admin.Global'), - 'enabled' => $this->trans('Enabled', 'Admin.Global'), - 'newsletter' => $this->trans('Newsletter', 'Admin.Global'), - 'partner_offers' => $this->trans('Partner offers', 'Admin.Orderscustomers.Feature'), - 'registration' => $this->trans('Registration', 'Admin.Orderscustomers.Feature'), - 'connect' => $this->trans('Last visit', 'Admin.Orderscustomers.Feature'), - ]; - - $data = []; - - foreach ($grid->getData()->getRecords()->all() as $record) { - $data[] = [ - 'id_customer' => $record['id_customer'], - 'social_title' => '--' === $record['social_title'] ? '' : $record['social_title'], - 'firstname' => $record['firstname'], - 'lastname' => $record['lastname'], - 'email' => $record['email'], - 'company' => '--' === $record['company'] ? '' : $record['company'], - 'total_spent' => '--' === $record['total_spent'] ? '' : $record['total_spent'], - 'enabled' => $record['active'], - 'newsletter' => $record['newsletter'], - 'partner_offers' => $record['optin'], - 'registration' => $record['date_add'], - 'connect' => '--' === $record['connect'] ? '' : $record['connect'], - ]; - } - - return (new CsvResponse()) - ->setData($data) - ->setHeadersData($headers) - ->setFileName('customer_' . date('Y-m-d_His') . '.csv'); - } - - /** - * @AdminSecurity("is_granted('read', request.get('_legacy_controller')) || is_granted('create', 'AdminOrders')") - * - * @param int $customerId - * - * @return JsonResponse - */ - public function getCartsAction(int $customerId) - { - try { - $carts = $this->getQueryBus()->handle(new GetCustomerCarts($customerId)); - } catch (Exception $e) { - return $this->json( - ['message' => $this->getErrorMessageForException($e, $this->getErrorMessages($e))], - Response::HTTP_INTERNAL_SERVER_ERROR - ); - } - - return $this->json([ - 'carts' => $carts, - ]); - } - - /** - * @AdminSecurity("is_granted('read', request.get('_legacy_controller')) || is_granted('create', 'AdminOrders')") - * - * @param int $customerId - * - * @return JsonResponse - */ - public function getOrdersAction(int $customerId) - { - try { - $orders = $this->getQueryBus()->handle(new GetCustomerOrders($customerId)); - } catch (Exception $e) { - return $this->json( - ['message' => $this->getErrorMessageForException($e, $this->getErrorMessages($e))], - Response::HTTP_INTERNAL_SERVER_ERROR - ); - } - - return $this->json([ - 'orders' => $orders, - ]); - } - - /** - * @return FormInterface - */ - private function getRequiredFieldsForm() - { - $requiredFields = $this->getQueryBus()->handle(new GetRequiredFieldsForCustomer()); - - return $this->createForm(RequiredFieldsType::class, ['required_fields' => $requiredFields]); - } - - /** - * If customer form is submitted and groups are not selected - * we add empty groups to request - * - * @param Request $request - */ - private function addGroupSelectionToRequest(Request $request) - { - if (!$request->isMethod(Request::METHOD_POST)) { - return; - } - - if (!$request->request->has('customer') - || isset($request->request->get('customer')['group_ids']) - ) { - return; - } - - $customerData = $request->request->get('customer'); - $customerData['group_ids'] = []; - - $request->request->set('customer', $customerData); - } - - /** - * Get errors that can be used to translate exceptions into user friendly messages - * - * @param Exception $e - * - * @return array - */ - private function getErrorMessages(Exception $e) - { - return [ - CustomerNotFoundException::class => $this->trans( - 'This customer does not exist.', - 'Admin.Orderscustomers.Notification' - ), - DuplicateCustomerEmailException::class => sprintf( - '%s %s', - $this->trans('An account already exists for this email address:', 'Admin.Orderscustomers.Notification'), - $e instanceof DuplicateCustomerEmailException ? $e->getEmail()->getValue() : '' - ), - CustomerDefaultGroupAccessException::class => $this->trans( - 'A default customer group must be selected in group box.', - 'Admin.Orderscustomers.Notification' - ), - CustomerByEmailNotFoundException::class => $this->trans( - 'This email address is not registered.', - 'Admin.Orderscustomers.Notification' - ), - CustomerConstraintException::class => [ - CustomerConstraintException::INVALID_PASSWORD => $this->trans( - 'Password should be at least %length% characters long.', - 'Admin.Orderscustomers.Help', - ['%length%' => Password::MIN_LENGTH] - ), - CustomerConstraintException::INVALID_FIRST_NAME => $this->trans( - 'The %s field is invalid.', - 'Admin.Notifications.Error', - [sprintf('"%s"', $this->trans('First name', 'Admin.Global'))] - ), - CustomerConstraintException::INVALID_LAST_NAME => $this->trans( - 'The %s field is invalid.', - 'Admin.Notifications.Error', - [sprintf('"%s"', $this->trans('Last name', 'Admin.Global'))] - ), - CustomerConstraintException::INVALID_EMAIL => $this->trans( - 'The %s field is invalid.', - 'Admin.Notifications.Error', - [sprintf('"%s"', $this->trans('Email', 'Admin.Global'))] - ), - CustomerConstraintException::INVALID_BIRTHDAY => $this->trans( - 'The %s field is invalid.', - 'Admin.Notifications.Error', - [sprintf('"%s"', $this->trans('Birthday', 'Admin.Orderscustomers.Feature'))] - ), - CustomerConstraintException::INVALID_APE_CODE => $this->trans( - 'The %s field is invalid.', - 'Admin.Notifications.Error', - [sprintf('"%s"', $this->trans('APE', 'Admin.Orderscustomers.Feature'))] - ), - ], - CustomerTransformationException::class => [ - CustomerTransformationException::CUSTOMER_IS_NOT_GUEST => $this->trans( - 'This customer already exists as a non-guest.', - 'Admin.Orderscustomers.Notification' - ), - CustomerTransformationException::TRANSFORMATION_FAILED => $this->trans( - 'An error occurred while updating customer information.', - 'Admin.Orderscustomers.Notification' - ), - ], - MissingCustomerRequiredFieldsException::class => $this->trans( - 'The field %s is required.', - 'Admin.Notifications.Error', - [ - implode( - ',', - $e instanceof MissingCustomerRequiredFieldsException ? $e->getMissingRequiredFields() : [] - ), - ] - ), - ]; - } - - /** - * Manage legacy flashes - * - * @todo Remove this code when legacy edit will be migrated. - * - * @param int $messageId The message id from legacy context - */ - private function manageLegacyFlashes($messageId) - { - $messages = [ - 4 => $this->trans('Update successful.', 'Admin.Notifications.Success'), - ]; - - if (isset($messages[$messageId])) { - $this->addFlash( - 'success', - $messages[$messageId] - ); - } - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/CustomerService/CustomerThreadController.php b/src/PrestaShopBundle/Controller/Admin/Sell/CustomerService/CustomerThreadController.php deleted file mode 100644 index 21c38036..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/CustomerService/CustomerThreadController.php +++ /dev/null @@ -1,265 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\CustomerService; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Command\ForwardCustomerThreadCommand; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Command\ReplyToCustomerThreadCommand; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Command\UpdateCustomerThreadStatusCommand; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Query\GetCustomerServiceSignature; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\Query\GetCustomerThreadForViewing; -use PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryResult\CustomerThreadView; -use PrestaShop\PrestaShop\Core\Domain\Employee\Query\GetEmployeeEmailById; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Email; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Form\Admin\CustomerService\CustomerThread\ForwardCustomerThreadType; -use PrestaShopBundle\Form\Admin\Sell\CustomerService\ReplyToCustomerThreadType; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Manages page under "Sell > Customer Service > Customer Service" - */ -class CustomerThreadController extends FrameworkBundleAdminController -{ - /** - * @AdminSecurity( - * "is_granted(['read'], request.get('_legacy_controller'))", - * message="You do not have permission to view this.", - * redirectRoute="admin_customer_threads_index" - * ) - * - * @param Request $request - * @param int $customerThreadId - * - * @return Response - */ - public function viewAction(Request $request, $customerThreadId) - { - /** @var CustomerThreadView $customerThreadView */ - $customerThreadView = $this->getQueryBus()->handle( - new GetCustomerThreadForViewing((int) $customerThreadId) - ); - - /** @var string $customerServiceSignature */ - $customerServiceSignature = $this->getQueryBus()->handle( - new GetCustomerServiceSignature($customerThreadView->getLanguageId()->getValue()) - ); - - $replyToCustomerThreadForm = $this->createForm(ReplyToCustomerThreadType::class, [ - 'reply_message' => $customerServiceSignature, - ]); - - $forwardCustomerThreadForm = $this->createForm(ForwardCustomerThreadType::class); - - return $this->render('@PrestaShop/Admin/Sell/CustomerService/CustomerThread/view.html.twig', [ - 'customerThreadView' => $customerThreadView, - 'employeeAvatarUrl' => $this->getContext()->employee->getImage(), - 'customerServiceSignature' => $customerServiceSignature, - 'replyToCustomerThreadForm' => $replyToCustomerThreadForm->createView(), - 'forwardCustomerThreadForm' => $forwardCustomerThreadForm->createView(), - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - 'layoutTitle' => $this->trans('View', 'Admin.Actions'), - ]); - } - - /** - * Reply to customer thread - * - * @AdminSecurity( - * "is_granted(['create', 'update'], request.get('_legacy_controller'))", - * message="You do not have permission to update this.", - * redirectRoute="admin_customer_threads_index" - * ) - * - * @param Request $request - * @param int $customerThreadId - * - * @return RedirectResponse - */ - public function replyAction(Request $request, $customerThreadId) - { - $replyToCustomerThreadForm = $this->createForm(ReplyToCustomerThreadType::class); - $replyToCustomerThreadForm->handleRequest($request); - - if (!$replyToCustomerThreadForm->isSubmitted()) { - return $this->redirectToRoute('admin_customer_threads_view', [ - 'customerThreadId' => $customerThreadId, - ]); - } - - if (!$replyToCustomerThreadForm->isValid()) { - foreach ($replyToCustomerThreadForm->getErrors(true) as $error) { - $this->addFlash('error', $error->getMessage()); - } - - return $this->redirectToRoute('admin_customer_threads_view', [ - 'customerThreadId' => $customerThreadId, - ]); - } - - $data = $replyToCustomerThreadForm->getData(); - - try { - $this->getCommandBus()->handle( - new ReplyToCustomerThreadCommand((int) $customerThreadId, $data['reply_message']) - ); - - $this->addFlash( - 'success', - $this->trans( - 'The message was successfully sent to the customer.', - 'Admin.Orderscustomers.Notification' - ) - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, [])); - } - - return $this->redirectToRoute('admin_customer_threads_view', [ - 'customerThreadId' => $customerThreadId, - ]); - } - - /** - * Update customer thread status - * - * @AdminSecurity( - * "is_granted(['update'], request.get('_legacy_controller'))", - * message="You do not have permission to update this.", - * redirectRoute="admin_customer_threads_index" - * ) - * - * @param int $customerThreadId - * @param string $newStatus - * - * @return RedirectResponse - */ - public function updateStatusAction($customerThreadId, $newStatus) - { - try { - $this->getCommandBus()->handle( - new UpdateCustomerThreadStatusCommand((int) $customerThreadId, $newStatus) - ); - - $this->addFlash( - 'success', - $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, [])); - } - - return $this->redirectToRoute('admin_customer_threads_view', [ - 'customerThreadId' => $customerThreadId, - ]); - } - - /** - * Forward customer thread to another employee - * - * @AdminSecurity( - * "is_granted(['create', 'update'], request.get('_legacy_controller'))", - * message="You do not have permission to update this.", - * redirectRoute="admin_customer_threads_index" - * ) - * - * @param Request $request - * @param int $customerThreadId - * - * @return RedirectResponse - */ - public function forwardAction(Request $request, $customerThreadId) - { - $forwardCustomerThreadForm = $this->createForm(ForwardCustomerThreadType::class); - $forwardCustomerThreadForm->handleRequest($request); - - if (!$forwardCustomerThreadForm->isSubmitted()) { - return $this->redirectToRoute('admin_customer_threads_view', [ - 'customerThreadId' => $customerThreadId, - ]); - } - - if (!$forwardCustomerThreadForm->isValid()) { - foreach ($forwardCustomerThreadForm->getErrors(true) as $error) { - $this->addFlash('error', $error->getMessage()); - } - - return $this->redirectToRoute('admin_customer_threads_view', [ - 'customerThreadId' => $customerThreadId, - ]); - } - - $data = $forwardCustomerThreadForm->getData(); - - if (!$data['employee_id'] && empty($data['someone_else_email'])) { - $this->addFlash('error', $this->trans('The email address is invalid.', 'Admin.Notifications.Error')); - - return $this->redirectToRoute('admin_customer_threads_view', [ - 'customerThreadId' => $customerThreadId, - ]); - } - - if ($data['employee_id']) { - /** @var Email $employeeEmail */ - $employeeEmail = $this->getQueryBus()->handle(new GetEmployeeEmailById((int) $data['employee_id'])); - $forwardEmail = $employeeEmail->getValue(); - - $command = ForwardCustomerThreadCommand::toAnotherEmployee( - (int) $customerThreadId, - (int) $data['employee_id'], - $data['comment'] - ); - } else { - $forwardEmail = $data['someone_else_email']; - - $command = ForwardCustomerThreadCommand::toSomeoneElse( - (int) $customerThreadId, - $data['someone_else_email'], - $data['comment'] - ); - } - - try { - $this->getCommandBus()->handle($command); - - $this->addFlash( - 'success', - sprintf('%s %s', $this->trans('Message forwarded to', 'Admin.Catalog.Feature'), $forwardEmail) - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, [])); - } - - return $this->redirectToRoute('admin_customer_threads_view', [ - 'customerThreadId' => $customerThreadId, - ]); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/CustomerService/MerchandiseReturnController.php b/src/PrestaShopBundle/Controller/Admin/Sell/CustomerService/MerchandiseReturnController.php deleted file mode 100644 index fab604f8..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/CustomerService/MerchandiseReturnController.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\CustomerService; - -use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface; -use PrestaShop\PrestaShop\Core\Search\Filters\MerchandiseReturnFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Class MerchandiseReturnController responsible for "Sell > Customer Service > Merchandise Returns" page - */ -class MerchandiseReturnController extends FrameworkBundleAdminController -{ - /** - * Render merchandise returns grid and options. - * - * @AdminSecurity( - * "is_granted(['read'], request.get('_legacy_controller'))", - * redirectRoute="admin_merchandise_return_index" - * ) - * - * @param Request $request - * @param MerchandiseReturnFilters $filters - * - * @return Response - */ - public function indexAction(Request $request, MerchandiseReturnFilters $filters): Response - { - $gridFactory = $this->get('prestashop.core.grid.factory.merchandise_return'); - $gridPresenter = $this->get('prestashop.core.grid.presenter.grid_presenter'); - - $optionsFormHandler = $this->getOptionsFormHandler(); - $optionsForm = $optionsFormHandler->getForm(); - $optionsForm->handleRequest($request); - - if ($optionsForm->isSubmitted() && $optionsForm->isValid()) { - $errors = $optionsFormHandler->save($optionsForm->getData()); - - if (empty($errors)) { - $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success')); - } else { - $this->flashErrors($errors); - } - } - - return $this->render('@PrestaShop/Admin/Sell/CustomerService/MerchandiseReturn/index.html.twig', [ - 'merchandiseReturnsGrid' => $gridPresenter->present($gridFactory->getGrid($filters)), - 'merchandiseReturnsOptionsForm' => $optionsForm->createView(), - ]); - } - - /** - * @return FormHandlerInterface - */ - private function getOptionsFormHandler(): FormHandlerInterface - { - return $this->get('prestashop.admin.merchandise_return_options.form_handler'); - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/CustomerService/OrderMessageController.php b/src/PrestaShopBundle/Controller/Admin/Sell/CustomerService/OrderMessageController.php deleted file mode 100644 index d561c044..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/CustomerService/OrderMessageController.php +++ /dev/null @@ -1,249 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\CustomerService; - -use Exception; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command\BulkDeleteOrderMessageCommand; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command\DeleteOrderMessageCommand; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Exception\OrderMessageException; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Exception\OrderMessageNotFoundException; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\Query\GetOrderMessageForEditing; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\QueryResult\EditableOrderMessage; -use PrestaShop\PrestaShop\Core\Search\Filters\OrderMessageFilters; -use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; - -/** - * Manages page under "Sell > Customer Service > Order Messages" - */ -class OrderMessageController extends FrameworkBundleAdminController -{ - /** - * Show list of Order messages - * - * @AdminSecurity("is_granted(['read'], request.get('_legacy_controller'))") - * - * @param OrderMessageFilters $filters - * @param Request $request - * - * @return Response - */ - public function indexAction(OrderMessageFilters $filters, Request $request): Response - { - $gridFactory = $this->get('prestashop.core.grid.grid_factory.order_message'); - $grid = $gridFactory->getGrid($filters); - - return $this->render('@PrestaShop/Admin/Sell/CustomerService/OrderMessage/index.html.twig', [ - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - 'layoutTitle' => $this->trans('Order Messages', 'Admin.Navigation.Menu'), - 'layoutHeaderToolbarBtn' => [ - 'add' => [ - 'href' => $this->generateUrl('admin_order_messages_create'), - 'desc' => $this->trans('Add new order message', 'Admin.Orderscustomers.Feature'), - 'icon' => 'add_circle_outline', - ], - ], - 'orderMessageGrid' => $this->presentGrid($grid), - ]); - } - - /** - * Create new order message - * - * @AdminSecurity( - * "is_granted(['create'], request.get('_legacy_controller'))", - * redirectRoute="admin_order_messages_index" - * ) - * - * @param Request $request - * - * @return Response - */ - public function createAction(Request $request): Response - { - $formBuilder = $this->get('prestashop.core.form.identifiable_object.builder.order_message_form_builder'); - $formHandler = $this->get('prestashop.core.form.identifiable_object.handler.order_message_form_handler'); - - $form = $formBuilder->getForm(); - $form->handleRequest($request); - - try { - $result = $formHandler->handle($form); - - if ($result->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful creation.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_order_messages_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->render('@PrestaShop/Admin/Sell/CustomerService/OrderMessage/create.html.twig', [ - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - 'layoutTitle' => $this->trans('Add new', 'Admin.Actions'), - 'orderMessageForm' => $form->createView(), - ]); - } - - /** - * Edit existing order message - * - * @AdminSecurity( - * "is_granted(['update'], request.get('_legacy_controller'))", - * redirectRoute="admin_order_messages_index" - * ) - * - * @param int $orderMessageId - * @param Request $request - * - * @return Response - */ - public function editAction(int $orderMessageId, Request $request): Response - { - $formBuilder = $this->get('prestashop.core.form.identifiable_object.builder.order_message_form_builder'); - $formHandler = $this->get('prestashop.core.form.identifiable_object.handler.order_message_form_handler'); - - try { - /** @var EditableOrderMessage $editableOrderMessage */ - $editableOrderMessage = $this->getQueryBus()->handle(new GetOrderMessageForEditing($orderMessageId)); - - $orderMessageName = $editableOrderMessage->getLocalizedName()[$this->getContextLangId()]; - - $form = $formBuilder->getFormFor($orderMessageId); - $form->handleRequest($request); - - $result = $formHandler->handleFor($orderMessageId, $form); - - if ($result->getIdentifiableObjectId()) { - $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); - - return $this->redirectToRoute('admin_order_messages_index'); - } - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - if (!isset($form) || !isset($orderMessageName)) { - return $this->redirectToRoute('admin_order_messages_index'); - } - - return $this->render('@PrestaShop/Admin/Sell/CustomerService/OrderMessage/edit.html.twig', [ - 'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')), - 'enableSidebar' => true, - 'layoutTitle' => sprintf($this->trans('Edit: %s', 'Admin.Actions'), $orderMessageName), - 'orderMessageForm' => $form->createView(), - ]); - } - - /** - * Delete single order message - * - * @AdminSecurity( - * "is_granted(['delete'], request.get('_legacy_controller'))", - * redirectRoute="admin_order_messages_index" - * ) - * - * @param int $orderMessageId - * - * @return RedirectResponse - */ - public function deleteAction(int $orderMessageId): RedirectResponse - { - try { - $this->getCommandBus()->handle(new DeleteOrderMessageCommand($orderMessageId)); - - $this->addFlash('success', $this->trans('Successful deletion.', 'Admin.Notifications.Success')); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_order_messages_index'); - } - - /** - * Delete order messages in bulk action - * - * @AdminSecurity( - * "is_granted(['delete'], request.get('_legacy_controller'))", - * redirectRoute="admin_order_messages_index" - * ) - * - * @param Request $request - * - * @return RedirectResponse - */ - public function bulkDeleteAction(Request $request): RedirectResponse - { - try { - $orderMessageIds = array_map(static function ($orderMessageId) { - return (int) $orderMessageId; - }, $request->request->get('order_message_order_messages_bulk')); - - $this->getCommandBus()->handle(new BulkDeleteOrderMessageCommand($orderMessageIds)); - - $this->addFlash( - 'success', - $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success') - ); - } catch (Exception $e) { - $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages())); - } - - return $this->redirectToRoute('admin_order_messages_index'); - } - - /** - * Get user friendly errors for exception - * - * @return array - */ - private function getErrorMessages(): array - { - return [ - OrderMessageException::class => [ - OrderMessageException::FAILED_DELETE => $this->trans( - 'An error occurred while deleting the object.', - 'Admin.Notifications.Error' - ), - OrderMessageException::FAILED_BULK_DELETE => $this->trans( - 'An error occurred while deleting this selection.', - 'Admin.Notifications.Error' - ), - ], - OrderMessageNotFoundException::class => $this->trans( - 'The object cannot be loaded (or found)', - 'Admin.Notifications.Error' - ), - ]; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Order/ActionsBarButton.php b/src/PrestaShopBundle/Controller/Admin/Sell/Order/ActionsBarButton.php deleted file mode 100644 index 35a0f492..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/Order/ActionsBarButton.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\Order; - -class ActionsBarButton implements ActionsBarButtonInterface -{ - /** - * @var string - */ - protected $class; - - /** - * @var string[] - */ - protected $properties; - - /** - * @var string - */ - protected $content; - - /** - * @param string $class - * @param string[] $properties - * @param string $content - */ - public function __construct(string $class = '', array $properties = [], string $content = '') - { - $this->class = $class; - $this->properties = $properties; - $this->content = $content; - } - - /** - * @return string - */ - public function getClass(): string - { - return $this->class; - } - - /** - * @return string[] - */ - public function getProperties(): array - { - return $this->properties; - } - - /** - * @return string - */ - public function getContent(): string - { - return $this->content; - } -} diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Order/ActionsBarButtonInterface.php b/src/PrestaShopBundle/Controller/Admin/Sell/Order/ActionsBarButtonInterface.php deleted file mode 100644 index 85998201..00000000 --- a/src/PrestaShopBundle/Controller/Admin/Sell/Order/ActionsBarButtonInterface.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Controller\Admin\Sell\Order; - -/** - * This class represents buttons to be rendered in Twig - * - * They will be rendered following this structure: - * - * If this is the 1st button or there are only 2 buttons displayed: - * - * - * {{ button.content|raw }} - * - * - * However if there is more than 2 buttons displayed, then they are rendered into a drop-down list: - * - * - * {{ button.content|raw }} - * - */ -interface ActionsBarButtonInterface -{ - /** - * This function will provide content to add extra CSS classes - * - * @return string - */ - public function getClass(): string; - - /** - * Use this property to add extra properties to - ', - 'required' => false, - 'label' => $this->translator->trans('Add products to your pack', [], 'Admin.Catalog.Feature'), - ]) - ->add('name', TranslateType::class, [ - 'type' => FormType\TextType::class, - 'options' => [ - 'constraints' => [ - new Assert\Regex([ - 'pattern' => '/[<>;=#{}]/', - 'match' => false, - ]), - new Assert\NotBlank(), - new Assert\Length(['min' => 3, 'max' => 128]), - ], - 'attr' => [ - 'placeholder' => $this->translator->trans('Enter your product name', [], 'Admin.Catalog.Help'), - 'class' => 'edit js-edit serp-default-title', - ], - ], - 'locales' => $this->locales, - 'hideTabs' => true, - 'label' => $this->translator->trans('Name', [], 'Admin.Global'), - ]) - ->add('description', TranslateType::class, [ - 'type' => FormattedTextareaType::class, - 'options' => [ - 'required' => false, - 'attr' => [ - 'class' => 'serp-default-description', - ], - 'constraints' => [ - new TinyMceMaxLength([ - 'max' => FormattedTextareaType::LIMIT_TEXT_UTF8, - ]), - ], - ], - 'locales' => $this->locales, - 'hideTabs' => true, - 'label' => $this->translator->trans('Description', [], 'Admin.Global'), - 'required' => false, - ]) - ->add('description_short', TranslateType::class, [ - 'type' => FormType\TextareaType::class, // https://github.com/symfony/symfony/issues/5906 - 'options' => [ - 'attr' => [ - 'class' => 'autoload_rte', - 'placeholder' => $this->translator->trans('The summary is a short sentence describing your product.
    It will appears at the top of your shop\'s product page, in product lists, and in search engines\' results page (so it\'s important for SEO). To give more details about your product, use the "Description" tab.', [], 'Admin.Catalog.Help'), - 'counter' => (int) $this->configuration->get('PS_PRODUCT_SHORT_DESC_LIMIT') <= 0 ? 800 : (int) $this->configuration->get('PS_PRODUCT_SHORT_DESC_LIMIT'), - ], - 'constraints' => [ - new TinyMceMaxLength([ - 'max' => (int) $this->configuration->get('PS_PRODUCT_SHORT_DESC_LIMIT') <= 0 ? 800 : (int) $this->configuration->get('PS_PRODUCT_SHORT_DESC_LIMIT'), - ]), - ], - 'required' => false, - ], - 'locales' => $this->locales, - 'hideTabs' => true, - 'label' => $this->translator->trans('Short description', [], 'Admin.Catalog.Feature'), - 'required' => false, - ]) - //FEATURES & ATTRIBUTES - ->add('features', FormType\CollectionType::class, [ - 'entry_type' => ProductFeature::class, - 'prototype' => true, - 'allow_add' => true, - 'allow_delete' => true, - ]) - ->add('id_manufacturer', FormType\ChoiceType::class, [ - 'choices' => $this->manufacturers, - 'required' => false, - 'attr' => [ - 'data-toggle' => 'select2', - 'data-minimumResultsForSearch' => '7', - ], - 'label' => $this->translator->trans('Brand', [], 'Admin.Catalog.Feature'), - ]) - //RIGHT COL - ->add('active', FormType\CheckboxType::class, [ - 'label' => $this->translator->trans('Enabled', [], 'Admin.Global'), - 'required' => false, - ]) - ->add('price_shortcut', FormType\MoneyType::class, [ - 'required' => false, - 'label' => $this->translator->trans('Pre-tax retail price', [], 'Admin.Catalog.Feature'), - 'currency' => $this->currency->iso_code, - 'constraints' => [ - new Assert\NotBlank(), - new Assert\Type(['type' => 'float']), - ], - 'attr' => [], - ]) - ->add('price_ttc_shortcut', FormType\MoneyType::class, [ - 'required' => false, - 'label' => $this->translator->trans('Retail price with tax', [], 'Admin.Catalog.Feature'), - 'mapped' => false, - 'currency' => $this->currency->iso_code, - ]); - if ($is_stock_management) { - $builder->add('qty_0_shortcut', FormType\NumberType::class, [ - 'required' => false, - 'label' => $this->translator->trans('Quantity', [], 'Admin.Catalog.Feature'), - 'constraints' => [ - new Assert\NotBlank(), - new Assert\Type(['type' => 'numeric']), - ], - ]); - } - $builder->add('categories', ChoiceCategoriesTreeType::class, [ - 'label' => $this->translator->trans('Associated categories', [], 'Admin.Catalog.Feature'), - 'list' => $this->nested_categories, - 'valid_list' => $this->categories, - 'multiple' => true, - ]) - ->add('id_category_default', FormType\ChoiceType::class, [ - 'choices' => $this->categories, - 'expanded' => true, - 'multiple' => false, - 'required' => true, - 'label' => $this->translator->trans('Default category', [], 'Admin.Catalog.Feature'), - ]) - ->add('new_category', SimpleCategory::class, [ - 'ajax' => true, - 'required' => false, - 'mapped' => false, - 'constraints' => [], - 'label' => $this->translator->trans('Add a new category', [], 'Admin.Catalog.Feature'), - ]) - ->add('ignore', null, [ - 'mapped' => false, - ]) - ->add('related_products', TypeaheadProductCollectionType::class, [ - 'remote_url' => $this->context->getLegacyAdminLink('AdminProducts', true, ['ajax' => 1, 'action' => 'productsList', 'forceJson' => 1, 'disableCombination' => 1, 'exclude_packs' => 0, 'excludeVirtuals' => 0, 'limit' => 20]) . '&q=%QUERY', - 'mapping_value' => 'id', - 'mapping_name' => 'name', - 'placeholder' => $this->translator->trans('Search and add a related product', [], 'Admin.Catalog.Help'), - 'template_collection' => '%sclear', - 'required' => false, - 'label' => $this->translator->trans('Accessories', [], 'Admin.Catalog.Feature'), - ]); - - $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) { - $data = $event->getData(); - - if (!isset($data['type_product'])) { - $data['type_product'] = 0; - $event->setData($data); - } - - /* - * Remove duplicates to prevent SQL errors. - */ - if (isset($data['features'])) { - $ids = []; - foreach ($data['features'] as $idx => $feature) { - if (empty($feature['value'])) { - continue; - } - - $id = sprintf('%d-%d', $feature['feature'], $feature['value']); - if (in_array($id, $ids)) { - unset($data['features'][$idx]); - } else { - $ids[] = $id; - } - } - - $event->setData($data); - } - - //if product type is pack, check if inputPackItems is not empty - if ($data['type_product'] == 1) { - if (!isset($data['inputPackItems']) || empty($data['inputPackItems']['data'])) { - $form = $event->getForm(); - $error = $this->translator->trans( - 'This pack is empty. You must add at least one product item.', - [], - 'Admin.Catalog.Notification' - ); - $form->get('inputPackItems')->addError(new FormError($error)); - } - } - }); - } - - /** - * Returns the block prefix of this type. - * - * @return string The prefix name - */ - public function getBlockPrefix() - { - return 'product_step1'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Product/ProductOptions.php b/src/PrestaShopBundle/Form/Admin/Product/ProductOptions.php deleted file mode 100644 index cf08de59..00000000 --- a/src/PrestaShopBundle/Form/Admin/Product/ProductOptions.php +++ /dev/null @@ -1,310 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Product; - -use PrestaShopBundle\Form\Admin\Type\CommonAbstractType; -use PrestaShopBundle\Form\Admin\Type\TranslateType; -use Symfony\Component\Form\Extension\Core\Type as FormType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\FormEvents; -use Symfony\Component\Validator\Constraints as Assert; - -/** - * This form class is responsible to generate the product options form. - */ -class ProductOptions extends CommonAbstractType -{ - private $translator; - private $suppliers; - private $context; - private $productAdapter; - private $router; - private $locales; - private $currencyDataprovider; - private $fullAttachmentList; - private $attachmentList; - - /** - * Constructor. - * - * @param object $translator - * @param object $legacyContext - * @param object $productDataProvider - * @param object $supplierDataProvider - * @param object $currencyDataprovider - * @param object $attachmentDataprovider - * @param object $router - */ - public function __construct( - $translator, - $legacyContext, - $productDataProvider, - $supplierDataProvider, - $currencyDataprovider, - $attachmentDataprovider, - $router - ) { - $this->context = $legacyContext; - $this->translator = $translator; - $this->productAdapter = $productDataProvider; - $this->currencyDataprovider = $currencyDataprovider; - $this->locales = $legacyContext->getLanguages(); - $this->router = $router; - - $this->suppliers = $this->formatDataChoicesList( - $supplierDataProvider->getSuppliers(), - 'id_supplier' - ); - - $this->fullAttachmentList = $attachmentDataprovider->getAllAttachments( - $this->context->getLanguages()[0]['id_lang'] - ); - $this->attachmentList = $this->formatDataChoicesList( - $this->fullAttachmentList, - 'id_attachment', - 'file' - ); - } - - /** - * {@inheritdoc} - * - * Builds form - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('visibility', FormType\ChoiceType::class, [ - 'choices' => [ - $this->translator->trans('Everywhere', [], 'Admin.Catalog.Feature') => 'both', - $this->translator->trans('Catalog only', [], 'Admin.Catalog.Feature') => 'catalog', - $this->translator->trans('Search only', [], 'Admin.Catalog.Feature') => 'search', - $this->translator->trans('Nowhere', [], 'Admin.Catalog.Feature') => 'none', - ], - 'attr' => [ - 'class' => 'custom-select', - ], - 'required' => true, - 'label' => $this->translator->trans('Visibility', [], 'Admin.Catalog.Feature'), - ]) - ->add('tags', TranslateType::class, [ - 'type' => FormType\TextType::class, - 'options' => [ - 'attr' => [ - 'class' => 'tokenfield', - 'placeholder' => $this->translator->trans('Use a comma to create separate tags. E.g.: dress, cotton, party dresses.', [], 'Admin.Catalog.Help'), - ], - ], - 'locales' => $this->locales, - 'label' => $this->translator->trans('Tags', [], 'Admin.Catalog.Feature'), - ]) - ->add( - $builder->create( - 'display_options', - FormType\FormType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('Display options', [], 'Admin.Catalog.Feature'), - ] - ) - ->add( - 'available_for_order', - FormType\CheckboxType::class, - [ - 'label' => $this->translator->trans('Available for order', [], 'Admin.Catalog.Feature'), - 'required' => false, - ] - ) - ->add( - 'show_price', - FormType\CheckboxType::class, - [ - 'label' => $this->translator->trans('Show price', [], 'Admin.Catalog.Feature'), - 'required' => false, - ] - ) - ->add( - 'online_only', - FormType\CheckboxType::class, - [ - 'label' => $this->translator->trans( - 'Web only (not sold in your retail store)', - [], - 'Admin.Catalog.Feature' - ), - 'required' => false, - ] - ) - ) - ->add('mpn', FormType\TextType::class, [ - 'required' => false, - 'label' => $this->translator->trans('MPN', [], 'Admin.Catalog.Feature'), - 'constraints' => [ - new Assert\Length(['max' => 40]), - ], - 'empty_data' => '', - ]) - ->add('upc', FormType\TextType::class, [ - 'required' => false, - 'label' => $this->translator->trans('UPC barcode', [], 'Admin.Catalog.Feature'), - 'constraints' => [ - new Assert\Regex('/^[0-9]{0,12}$/'), - ], - 'empty_data' => '', - ]) - ->add('ean13', FormType\TextType::class, [ - 'required' => false, - 'error_bubbling' => true, - 'label' => $this->translator->trans('EAN-13 or JAN barcode', [], 'Admin.Catalog.Feature'), - 'constraints' => [ - new Assert\Regex('/^[0-9]{0,13}$/'), - ], - 'empty_data' => '', - ]) - ->add('isbn', FormType\TextType::class, [ - 'required' => false, - 'label' => $this->translator->trans('ISBN', [], 'Admin.Catalog.Feature'), - 'constraints' => [ - new Assert\Regex('/^[0-9-]{0,32}$/'), - ], - 'empty_data' => '', - ]) - ->add('reference', FormType\TextType::class, [ - 'required' => false, - 'label' => $this->translator->trans('Reference', [], 'Admin.Global'), - 'empty_data' => '', - ]) - ->add('show_condition', FormType\CheckboxType::class, [ - 'required' => false, - 'label' => $this->translator->trans('Display condition on product page', [], 'Admin.Catalog.Feature'), - ]) - ->add('condition', FormType\ChoiceType::class, [ - 'choices' => [ - $this->translator->trans('New', [], 'Shop.Theme.Catalog') => 'new', - $this->translator->trans('Used', [], 'Shop.Theme.Catalog') => 'used', - $this->translator->trans('Refurbished', [], 'Shop.Theme.Catalog') => 'refurbished', - ], - 'attr' => [ - 'class' => 'custom-select', - ], - 'required' => true, - 'label' => $this->translator->trans('Condition', [], 'Admin.Catalog.Feature'), - ]) - ->add('suppliers', FormType\ChoiceType::class, [ - 'choices' => $this->suppliers, - 'expanded' => true, - 'multiple' => true, - 'required' => false, - 'attr' => [ - 'class' => 'custom-select', - ], - 'label' => $this->translator->trans('Suppliers', [], 'Admin.Global'), - ]) - ->add('default_supplier', FormType\ChoiceType::class, [ - 'choices' => $this->suppliers, - 'expanded' => true, - 'multiple' => false, - 'required' => true, - 'attr' => [ - 'class' => 'custom-select', - ], - 'label' => $this->translator->trans('Default suppliers', [], 'Admin.Catalog.Feature'), - ]); - - foreach ($this->suppliers as $supplier => $id) { - $builder->add( - 'supplier_combination_' . $id, - FormType\CollectionType::class, - [ - 'entry_type' => ProductSupplierCombination::class, - 'entry_options' => [ - 'id_supplier' => $id, - ], - 'prototype' => true, - 'allow_add' => true, - 'required' => false, - 'label' => $supplier, - ] - ); - } - - $builder->add('custom_fields', FormType\CollectionType::class, [ - 'entry_type' => ProductCustomField::class, - 'label' => $this->translator->trans('Customization', [], 'Admin.Catalog.Feature'), - 'prototype' => true, - 'allow_add' => true, - 'allow_delete' => true, - ]); - - //Add product attachment form - $builder->add('attachment_product', ProductAttachement::class, [ - 'required' => false, - 'label' => $this->translator->trans('Attachment', [], 'Admin.Catalog.Feature'), - 'attr' => ['data-action' => $this->router->generate('admin_product_attachement_add_action', ['idProduct' => 1])], - ]); - - //Add attachment selectors - $builder->add('attachments', FormType\ChoiceType::class, [ - 'expanded' => true, - 'multiple' => true, - 'choices' => $this->attachmentList, - 'choice_label' => function ($choice, $key, $value) { - $attachmentKey = array_search($key, array_column($this->fullAttachmentList, 'file')); - - return $this->fullAttachmentList[$attachmentKey]['name']; - }, - 'required' => false, - 'attr' => [ - 'class' => 'custom-select', - 'data' => $this->fullAttachmentList, - ], - 'label' => $this->translator->trans('Attachments for this product:', [], 'Admin.Catalog.Feature'), - ]); - - $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) { - $data = $event->getData(); - - //If not supplier selected, remove all supplier combinations collection form - if (!isset($data['suppliers']) || count($data['suppliers']) == 0) { - $form = $event->getForm(); - foreach ($this->suppliers as $supplier => $id) { - $form->remove('supplier_combination_' . $id); - } - } - }); - } - - /** - * Returns the block prefix of this type. - * - * @return string The prefix name - */ - public function getBlockPrefix() - { - return 'product_options'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Product/ProductPrice.php b/src/PrestaShopBundle/Form/Admin/Product/ProductPrice.php deleted file mode 100644 index 4f0bf7f6..00000000 --- a/src/PrestaShopBundle/Form/Admin/Product/ProductPrice.php +++ /dev/null @@ -1,241 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Product; - -use PrestaShopBundle\Form\Admin\Type\CommonAbstractType; -use Symfony\Component\Form\Extension\Core\Type as FormType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Validator\Constraints as Assert; - -/** - * This form class is responsible to generate the product price form. - */ -class ProductPrice extends CommonAbstractType -{ - // When the form is used to create, the product does not yet exists - // however the ID is required for some fields so we use a default one: - const DEFAULT_PRODUCT_ID_FOR_FORM_CREATION = 1; - - private $translator; - private $tax_rules; - private $tax_rules_rates; - private $configuration; - private $eco_tax_rate; - private $customerDataprovider; - - /** - * Constructor. - * - * @param object $translator - * @param object $taxDataProvider - * @param object $router - * @param object $shopContextAdapter - * @param object $countryDataprovider - * @param object $currencyDataprovider - * @param object $groupDataprovider - * @param object $legacyContext - * @param object $customerDataprovider - */ - public function __construct($translator, $taxDataProvider, $router, $shopContextAdapter, $countryDataprovider, $currencyDataprovider, $groupDataprovider, $legacyContext, $customerDataprovider) - { - $this->translator = $translator; - $this->router = $router; - $this->configuration = $this->getConfiguration(); - $this->shopContextAdapter = $shopContextAdapter; - $this->countryDataprovider = $countryDataprovider; - $this->currencyDataprovider = $currencyDataprovider; - $this->groupDataprovider = $groupDataprovider; - $this->customerDataprovider = $customerDataprovider; - $this->legacyContext = $legacyContext; - $this->tax_rules_rates = $taxDataProvider->getTaxRulesGroupWithRates(); - $this->eco_tax_rate = $taxDataProvider->getProductEcotaxRate(); - $this->currency = $legacyContext->getContext()->currency; - $this->tax_rules = $this->formatDataChoicesList( - $taxDataProvider->getTaxRulesGroups(true), - 'id_tax_rules_group' - ); - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $this->tax_rules = [$this->translator->trans('No tax', [], 'Admin.Catalog.Feature') => 0] + $this->tax_rules; - - $builder->add( - 'price', - FormType\MoneyType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('Price (tax excl.)', [], 'Admin.Catalog.Feature'), - 'attr' => ['data-display-price-precision' => self::PRESTASHOP_DECIMALS], - 'currency' => $this->currency->iso_code, - 'constraints' => [ - new Assert\NotBlank(), - new Assert\Type(['type' => 'float']), - ], - ] - ) - ->add( - 'price_ttc', - FormType\MoneyType::class, - [ - 'required' => false, - 'mapped' => false, - 'label' => $this->translator->trans('Price (tax incl.)', [], 'Admin.Catalog.Feature'), - 'currency' => $this->currency->iso_code, - ] - ) - ->add( - 'ecotax', - FormType\MoneyType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('Ecotax (tax incl.)', [], 'Admin.Catalog.Feature'), - 'currency' => $this->currency->iso_code, - 'constraints' => [ - new Assert\NotBlank(), - new Assert\Type(['type' => 'float']), - ], - 'attr' => ['data-eco-tax-rate' => $this->eco_tax_rate], - ] - ) - ->add( - 'id_tax_rules_group', - FormType\ChoiceType::class, - [ - 'choices' => $this->tax_rules, - 'required' => true, - 'choice_attr' => function ($val) { - return [ - 'data-rates' => implode(',', $this->tax_rules_rates[$val]['rates']), - 'data-computation-method' => $this->tax_rules_rates[$val]['computation_method'], - ]; - }, - 'attr' => [ - 'data-toggle' => 'select2', - 'data-minimumResultsForSearch' => '7', - ], - 'label' => $this->translator->trans('Tax rule', [], 'Admin.Catalog.Feature'), - ] - ) - ->add( - 'on_sale', - FormType\CheckboxType::class, - [ - 'required' => false, - 'label' => $this->translator->trans( - 'Display the "On sale!" flag on the product page, and on product listings.', - [], - 'Admin.Catalog.Feature' - ), - ] - ) - ->add( - 'wholesale_price', - FormType\MoneyType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('Price (tax excl.)', [], 'Admin.Catalog.Feature'), - 'currency' => $this->currency->iso_code, - ] - ) - ->add( - 'unit_price', - FormType\MoneyType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('Price per unit (tax excl.)', [], 'Admin.Catalog.Feature'), - 'currency' => $this->currency->iso_code, - ] - ) - ->add( - 'unity', - FormType\TextType::class, - [ - 'required' => false, - 'attr' => ['placeholder' => $this->translator->trans('Per kilo, per litre', [], 'Admin.Catalog.Help')], - ] - ) - ->add( - 'specific_price', - ProductSpecificPrice::class, - [ - 'id_product' => $options['id_product'], - ] - ) - ->add( - 'specificPricePriorityToAll', - FormType\CheckboxType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('Apply to all products', [], 'Admin.Catalog.Feature'), - ] - ); - - //generates fields for price priority - $specificPricePriorityChoices = [ - $this->translator->trans('Shop', [], 'Admin.Global') => 'id_shop', - $this->translator->trans('Currency', [], 'Admin.Global') => 'id_currency', - $this->translator->trans('Country', [], 'Admin.Global') => 'id_country', - $this->translator->trans('Group', [], 'Admin.Global') => 'id_group', - ]; - - for ($i = 0, $iMax = count($specificPricePriorityChoices); $i < $iMax; ++$i) { - $builder->add( - 'specificPricePriority_' . $i, - FormType\ChoiceType::class, - [ - 'choices' => $specificPricePriorityChoices, - 'required' => true, - ] - ); - } - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'id_product' => self::DEFAULT_PRODUCT_ID_FOR_FORM_CREATION, - ]); - } - - /** - * Returns the block prefix of this type. - * - * @return string The prefix name - */ - public function getBlockPrefix() - { - return 'product_price'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Product/ProductQuantity.php b/src/PrestaShopBundle/Form/Admin/Product/ProductQuantity.php deleted file mode 100644 index 7a68d501..00000000 --- a/src/PrestaShopBundle/Form/Admin/Product/ProductQuantity.php +++ /dev/null @@ -1,338 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Product; - -use Pack; -use PrestaShopBundle\Form\Admin\Type\CommonAbstractType; -use PrestaShopBundle\Form\Admin\Type\DatePickerType; -use PrestaShopBundle\Form\Admin\Type\TranslateType; -use Symfony\Component\Form\Extension\Core\Type as FormType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\FormEvents; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Validator\Constraints as Assert; - -/** - * This form class is responsible to generate the product quantity form. - */ -class ProductQuantity extends CommonAbstractType -{ - private $router; - private $translator; - private $configuration; - - /** - * Constructor. - * - * @param object $translator - * @param object $router - * @param object $legacyContext - */ - public function __construct($translator, $router, $legacyContext) - { - $this->router = $router; - $this->translator = $translator; - $this->legacyContext = $legacyContext; - $this->locales = $this->legacyContext->getLanguages(); - $this->configuration = $this->getConfiguration(); - } - - /** - * {@inheritdoc} - * - * Builds form - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $is_stock_management = $this->configuration->get('PS_STOCK_MANAGEMENT'); - $builder - ->add( - 'attributes', - FormType\TextType::class, - [ - 'attr' => [ - 'class' => 'tokenfield', - 'data-minLength' => 1, - 'placeholder' => $this->translator->trans( - 'Combine several attributes, e.g.: "Size: all", "Color: red".', - [], - 'Admin.Catalog.Help' - ), - 'data-prefetch' => $this->router->generate('admin_attribute_get_all'), - 'data-action' => $this->router->generate('admin_attribute_generator'), - ], - 'label' => $this->translator->trans('Create combinations', [], 'Admin.Catalog.Feature'), - 'empty_data' => '', - ] - ) - ->add( - 'advanced_stock_management', - FormType\CheckboxType::class, - [ - 'required' => false, - 'label' => $this->translator->trans( - 'I want to use the advanced stock management system for this product.', - [], - 'Admin.Catalog.Feature' - ), - ] - ) - ->add( - 'pack_stock_type', - FormType\ChoiceType::class - )//see eventListener for details - ->add( - 'depends_on_stock', - FormType\ChoiceType::class, - [ - 'choices' => [ - $this->translator->trans( - 'The available quantities for the current product and its combinations are based on the stock in your warehouse (using the advanced stock management system). ', - [], - 'Admin.Catalog.Feature' - ) => 1, - $this->translator->trans( - 'I want to specify available quantities manually.', - [], - 'Admin.Catalog.Feature' - ) => 0, - ], - 'expanded' => true, - 'required' => true, - 'multiple' => false, - ] - ); - - if ($is_stock_management) { - $builder->add( - 'qty_0', - FormType\NumberType::class, - [ - 'required' => true, - 'label' => $this->translator->trans('Quantity', [], 'Admin.Catalog.Feature'), - 'constraints' => [ - new Assert\NotBlank(), - new Assert\Type(['type' => 'numeric']), - ], - ] - ); - } - $builder - ->add( - 'out_of_stock', - FormType\ChoiceType::class - ) - ->add( - 'minimal_quantity', - FormType\NumberType::class, - [ - 'required' => true, - 'label' => $this->translator->trans('Minimum quantity for sale', [], 'Admin.Catalog.Feature'), - 'constraints' => [ - new Assert\NotBlank(), - new Assert\Type(['type' => 'numeric']), - ], - ] - ) - ->add( - 'location', - FormType\TextType::class, - [ - 'label' => $this->translator->trans('Stock location', [], 'Admin.Catalog.Feature'), - ] - ) - ->add( - 'low_stock_threshold', - FormType\NumberType::class, - [ - 'label' => $this->translator->trans('Low stock level', [], 'Admin.Catalog.Feature'), - 'attr' => [ - 'placeholder' => $this->translator->trans('Leave empty to disable', [], 'Admin.Catalog.Help'), - ], - 'constraints' => [ - new Assert\Type(['type' => 'numeric']), - ], - ] - ) - ->add( - 'low_stock_alert', - FormType\CheckboxType::class, - [ - 'label' => $this->translator->trans( - 'Send me an email when the quantity is below or equals this level', - [], - 'Admin.Catalog.Feature' - ), - 'constraints' => [ - new Assert\Type(['type' => 'bool']), - ], - ] - ) - ->add( - 'available_now', - TranslateType::class, - [ - 'type' => FormType\TextType::class, - 'options' => [], - 'locales' => $this->locales, - 'hideTabs' => true, - 'label' => $this->translator->trans('Label when in stock', [], 'Admin.Catalog.Feature'), - ] - ) - ->add( - 'available_later', - TranslateType::class, - [ - 'type' => FormType\TextType::class, - 'options' => [], - 'locales' => $this->locales, - 'hideTabs' => true, - 'label' => $this->translator->trans( - 'Label when out of stock (and back order allowed)', - [], - 'Admin.Catalog.Feature' - ), - ] - ) - ->add( - 'available_date', - DatePickerType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('Availability date', [], 'Admin.Catalog.Feature'), - 'attr' => ['placeholder' => 'YYYY-MM-DD'], - ] - ) - ->add( - 'virtual_product', - ProductVirtual::class, - [ - 'required' => false, - 'label' => $this->translator->trans( - 'Does this product have an associated file?', - [], - 'Admin.Catalog.Feature' - ), - ] - ); - - $builder->addEventListener( - FormEvents::PRE_SET_DATA, - function (FormEvent $event) { - $form = $event->getForm(); - - //Manage out_of_stock field with contextual values/label - $defaultChoiceLabel = $this->translator->trans( - 'Use default behavior', - [], - 'Admin.Catalog.Feature' - ) . ' ('; - $defaultChoiceLabel .= $this->configuration->get('PS_ORDER_OUT_OF_STOCK') == 1 ? - $this->translator->trans('Allow orders', [], 'Admin.Catalog.Feature') : - $this->translator->trans('Deny orders', [], 'Admin.Catalog.Feature'); - $defaultChoiceLabel .= ')'; - - $form->add( - 'out_of_stock', - FormType\ChoiceType::class, - [ - 'choices' => [ - $this->translator->trans('Deny orders', [], 'Admin.Catalog.Feature') => '0', - $this->translator->trans('Allow orders', [], 'Admin.Catalog.Feature') => '1', - $defaultChoiceLabel => '2', - ], - 'expanded' => true, - 'required' => false, - 'placeholder' => false, - 'label' => $this->translator->trans('When out of stock', [], 'Admin.Catalog.Feature'), - ] - ); - - //Manage out_of_stock field with contextual values/label - $pack_stock_type = $this->configuration->get('PS_PACK_STOCK_TYPE'); - $defaultChoiceLabel = $this->translator->trans('Default', [], 'Admin.Global') . ': '; - if ($pack_stock_type == Pack::STOCK_TYPE_PACK_ONLY) { - $defaultChoiceLabel .= $this->translator->trans( - 'Decrement pack only.', - [], - 'Admin.Catalog.Feature' - ); - } elseif ($pack_stock_type == Pack::STOCK_TYPE_PRODUCTS_ONLY) { - $defaultChoiceLabel .= $this->translator->trans( - 'Decrement products in pack only.', - [], - 'Admin.Catalog.Feature' - ); - } else { - $defaultChoiceLabel .= $this->translator->trans('Decrement both.', [], 'Admin.Catalog.Feature'); - } - - $form->add( - 'pack_stock_type', - FormType\ChoiceType::class, - [ - 'choices' => [ - $this->translator->trans('Decrement pack only.', [], 'Admin.Catalog.Feature') => 0, - $this->translator->trans('Decrement products in pack only.', [], 'Admin.Catalog.Feature') => 1, - $this->translator->trans('Decrement both.', [], 'Admin.Catalog.Feature') => 2, - $defaultChoiceLabel => 3, - ], - 'expanded' => false, - 'required' => true, - 'placeholder' => false, - 'label' => $this->translator->trans('Pack quantities', [], 'Admin.Catalog.Feature'), - ] - ); - } - ); - } - - /** - * {@inheritdoc} - * - * Configure options - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults( - [ - 'allow_extra_fields' => true, - ] - ); - } - - /** - * Returns the block prefix of this type. - * - * @return string The prefix name - */ - public function getBlockPrefix() - { - return 'product_quantity'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Product/ProductSeo.php b/src/PrestaShopBundle/Form/Admin/Product/ProductSeo.php deleted file mode 100644 index 38e4bbc5..00000000 --- a/src/PrestaShopBundle/Form/Admin/Product/ProductSeo.php +++ /dev/null @@ -1,203 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Product; - -use PrestaShop\PrestaShop\Core\Product\ProductInterface; -use PrestaShopBundle\Form\Admin\Type\CommonAbstractType; -use PrestaShopBundle\Form\Admin\Type\TranslateType; -use PrestaShopBundle\Form\Admin\Type\TypeaheadProductCollectionType; -use Symfony\Component\Form\Extension\Core\Type as FormType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * This form class is responsible to generate the product SEO form. - */ -class ProductSeo extends CommonAbstractType -{ - private $translator; - private $locales; - private $router; - - /** - * Constructor. - * - * @param object $translator - * @param object $legacyContext - */ - public function __construct($translator, $legacyContext, $router) - { - $this->translator = $translator; - $this->context = $legacyContext; - $this->locales = $legacyContext->getLanguages(); - $this->router = $router; - } - - /** - * {@inheritdoc} - * - * Builds form - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $remoteUrls = [ - ProductInterface::REDIRECT_TYPE_PRODUCT_MOVED_PERMANENTLY => $this->context->getLegacyAdminLink('AdminProducts', true, ['ajax' => 1, 'action' => 'productsList', 'forceJson' => 1, 'disableCombination' => 1, 'exclude_packs' => 0, 'excludeVirtuals' => 0, 'limit' => 20]) . '&q=%QUERY', - ProductInterface::REDIRECT_TYPE_PRODUCT_FOUND => $this->context->getLegacyAdminLink('AdminProducts', true, ['ajax' => 1, 'action' => 'productsList', 'forceJson' => 1, 'disableCombination' => 1, 'exclude_packs' => 0, 'excludeVirtuals' => 0, 'limit' => 20]) . '&q=%QUERY', - ProductInterface::REDIRECT_TYPE_CATEGORY_MOVED_PERMANENTLY => $this->router->generate('admin_get_ajax_categories') . '&query=%QUERY', - ProductInterface::REDIRECT_TYPE_CATEGORY_FOUND => $this->router->generate('admin_get_ajax_categories') . '&query=%QUERY', - ]; - - $builder->add( - 'meta_title', - TranslateType::class, - [ - 'type' => FormType\TextType::class, - 'options' => [ - 'attr' => [ - 'placeholder' => $this->translator->trans('To have a different title from the product name, enter it here.', [], 'Admin.Catalog.Help'), - 'counter' => 70, - 'counter_type' => 'recommended', - 'class' => 'serp-watched-title', - ], - 'required' => false, - ], - 'locales' => $this->locales, - 'hideTabs' => true, - 'label' => $this->translator->trans('Meta title', [], 'Admin.Catalog.Feature'), - 'label_attr' => [ - 'popover' => $this->translator->trans('Public title for the product\'s page, and for search engines. Leave blank to use the product name. The number of remaining characters is displayed to the left of the field.', [], 'Admin.Catalog.Help'), - 'popover_placement' => 'right', - 'class' => 'px-0', - ], - 'required' => false, - ] - ) - ->add( - 'meta_description', - TranslateType::class, - [ - 'type' => FormType\TextareaType::class, - 'options' => [ - 'attr' => [ - 'placeholder' => $this->translator->trans('To have a different description than your product summary in search results pages, write it here.', [], 'Admin.Catalog.Help'), - 'counter' => 160, - 'counter_type' => 'recommended', - 'class' => 'serp-watched-description', - ], - 'required' => false, - ], - 'locales' => $this->locales, - 'hideTabs' => true, - 'label' => $this->translator->trans('Meta description', [], 'Admin.Catalog.Feature'), - 'label_attr' => [ - 'popover' => $this->translator->trans('This description will appear in search engines. You need a single sentence, shorter than 160 characters (including spaces)', [], 'Admin.Catalog.Help'), - 'popover_placement' => 'right', - 'class' => 'px-0', - ], - 'required' => false, - ] - ) - ->add( - 'link_rewrite', - TranslateType::class, - [ - 'type' => FormType\TextType::class, - 'options' => [ - 'attr' => [ - 'class' => 'serp-watched-url', - ], - ], - 'locales' => $this->locales, - 'hideTabs' => true, - 'label' => $this->translator->trans('Friendly URL', [], 'Admin.Catalog.Feature'), - ] - ) - ->add( - 'redirect_type', - FormType\ChoiceType::class, - [ - 'choices' => [ - $this->translator->trans('Permanent redirection to a category (301)', [], 'Admin.Catalog.Feature') => ProductInterface::REDIRECT_TYPE_CATEGORY_MOVED_PERMANENTLY, - $this->translator->trans('Temporary redirection to a category (302)', [], 'Admin.Catalog.Feature') => ProductInterface::REDIRECT_TYPE_CATEGORY_FOUND, - $this->translator->trans('Permanent redirection to a product (301)', [], 'Admin.Catalog.Feature') => ProductInterface::REDIRECT_TYPE_PRODUCT_MOVED_PERMANENTLY, - $this->translator->trans('Temporary redirection to a product (302)', [], 'Admin.Catalog.Feature') => ProductInterface::REDIRECT_TYPE_PRODUCT_FOUND, - $this->translator->trans('No redirection (404)', [], 'Admin.Catalog.Feature') => ProductInterface::REDIRECT_TYPE_NOT_FOUND, - ], - 'choice_attr' => function ($val, $key, $index) use ($remoteUrls) { - if (array_key_exists($index, $remoteUrls)) { - return ['data-remoteurl' => $remoteUrls[$index]]; - } - - return []; - }, - 'required' => true, - 'label' => $this->translator->trans('Redirection when offline', [], 'Admin.Catalog.Feature'), - 'attr' => [ - 'data-labelproduct' => $this->translator->trans('Target product', [], 'Admin.Catalog.Feature'), - 'data-placeholderproduct' => $this->translator->trans('To which product the page should redirect?', [], 'Admin.Catalog.Help'), - 'data-labelcategory' => $this->translator->trans('Target category', [], 'Admin.Catalog.Feature'), - 'data-placeholdercategory' => $this->translator->trans('To which category the page should redirect?', [], 'Admin.Catalog.Help'), - 'data-hintcategory' => $this->translator->trans('If no category is selected the Main Category is used', [], 'Admin.Catalog.Help'), - ], - ] - ) - ->add( - 'id_type_redirected', - TypeaheadProductCollectionType::class, - [ - 'remote_url' => $this->context->getLegacyAdminLink('AdminProducts', true, ['ajax' => 1, 'action' => 'productsList', 'forceJson' => 1, 'disableCombination' => 1, 'exclude_packs' => 0, 'excludeVirtuals' => 0, 'limit' => 20]) . '&q=%QUERY', - 'mapping_value' => 'id', - 'mapping_name' => 'name', - 'mapping_type' => $options['mapping_type'], - 'template_collection' => '%sclear', - 'limit' => 1, - 'required' => false, - 'label' => $this->translator->trans('Target', [], 'Admin.Catalog.Feature'), - ] - ); - } - - /** - * Returns the block prefix of this type. - * - * @return string The prefix name - */ - public function getBlockPrefix() - { - return 'product_seo'; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'mapping_type' => 'product', - ]); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Product/ProductShipping.php b/src/PrestaShopBundle/Form/Admin/Product/ProductShipping.php deleted file mode 100644 index 53072cac..00000000 --- a/src/PrestaShopBundle/Form/Admin/Product/ProductShipping.php +++ /dev/null @@ -1,240 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Product; - -use PrestaShopBundle\Form\Admin\Type\CommonAbstractType; -use PrestaShopBundle\Form\Admin\Type\TranslateType; -use Symfony\Component\Form\Extension\Core\Type as FormType; -use Symfony\Component\Form\Extension\Core\Type\CollectionType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Validator\Constraints as Assert; - -/** - * This form class is responsible to generate the product shipping form. - */ -class ProductShipping extends CommonAbstractType -{ - private $translator; - private $carriersChoices; - private $warehouses; - - /** - * Constructor. - * - * @param object $translator - * @param object $legacyContext - * @param object $warehouseDataProvider - * @param object $carrierDataProvider - */ - public function __construct($translator, $legacyContext, $warehouseDataProvider, $carrierDataProvider) - { - $this->translator = $translator; - $this->legacyContext = $legacyContext; - $this->currency = $legacyContext->getContext()->currency; - $this->locales = $this->legacyContext->getLanguages(); - $this->warehouses = $warehouseDataProvider->getWarehouses(); - - $carriers = $carrierDataProvider->getCarriers( - $this->locales[0]['id_lang'], - false, - false, - false, - null, - $carrierDataProvider->getAllCarriersConstant() - ); - $this->carriersChoices = []; - foreach ($carriers as $carrier) { - $choiceId = $carrier['id_carrier'] . ' - ' . $carrier['name']; - if ($carrier['name']) { - $choiceId .= ' (' . $carrier['delay'] . ')'; - } - - $this->carriersChoices[$choiceId] = $carrier['id_reference']; - } - } - - /** - * {@inheritdoc} - * - * Builds form - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add( - 'width', - FormType\NumberType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('Width', [], 'Admin.Catalog.Feature'), - 'constraints' => [ - new Assert\NotBlank(), - new Assert\Type(['type' => 'numeric']), - ], - ] - ) - ->add( - 'height', - FormType\NumberType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('Height', [], 'Admin.Catalog.Feature'), - 'constraints' => [ - new Assert\NotBlank(), - new Assert\Type(['type' => 'numeric']), - ], - ] - ) - ->add( - 'depth', - FormType\NumberType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('Depth', [], 'Admin.Catalog.Feature'), - 'constraints' => [ - new Assert\NotBlank(), - new Assert\Type(['type' => 'numeric']), - ], - ] - ) - ->add( - 'weight', - FormType\NumberType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('Weight', [], 'Admin.Catalog.Feature'), - 'constraints' => [ - new Assert\NotBlank(), - new Assert\Type(['type' => 'numeric']), - ], - ] - ) - ->add( - 'additional_shipping_cost', - FormType\MoneyType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('Shipping fees', [], 'Admin.Catalog.Feature'), - 'currency' => $this->currency->iso_code, - 'constraints' => [ - new Assert\NotBlank(), - new Assert\Type(['type' => 'float']), - ], - ] - ) - ->add( - 'selectedCarriers', - FormType\ChoiceType::class, - [ - 'choices' => $this->carriersChoices, - 'expanded' => true, - 'multiple' => true, - 'required' => false, - 'label' => $this->translator->trans('Available carriers', [], 'Admin.Catalog.Feature'), - ] - ) - ->add( - 'additional_delivery_times', - FormType\ChoiceType::class, - [ - 'choices' => [ - $this->translator->trans('None', [], 'Admin.Catalog.Feature') => 0, - $this->translator->trans('Default delivery time', [], 'Admin.Catalog.Feature') => 1, - $this->translator->trans('Specific delivery time to this product', [], 'Admin.Catalog.Feature') => 2, - ], - 'expanded' => true, - 'multiple' => false, - 'required' => false, - 'placeholder' => null, - 'preferred_choices' => ['default'], - 'label' => $this->translator->trans('Delivery Time', [], 'Admin.Catalog.Feature'), - ] - ) - ->add( - 'delivery_out_stock', - TranslateType::class, - [ - 'type' => FormType\TextType::class, - 'options' => [ - 'attr' => [ - 'placeholder' => $this->translator->trans('Delivered within 5-7 days', [], 'Admin.Catalog.Feature'), - ], - ], - 'locales' => $this->locales, - 'hideTabs' => true, - 'required' => false, - 'label' => $this->translator->trans( - 'Delivery time of out-of-stock products with allowed orders:', - [], - 'Admin.Catalog.Feature' - ), - ] - ) - ->add( - 'delivery_in_stock', - TranslateType::class, - [ - 'type' => FormType\TextType::class, - 'options' => [ - 'attr' => [ - 'placeholder' => $this->translator->trans('Delivered within 3-4 days', [], 'Admin.Catalog.Feature'), - ], - ], - 'locales' => $this->locales, - 'hideTabs' => true, - 'required' => false, - 'label' => $this->translator->trans('Delivery time of in-stock products:', [], 'Admin.Catalog.Feature'), - ] - ); - - foreach ($this->warehouses as $warehouse) { - $builder->add( - 'warehouse_combination_' . $warehouse['id_warehouse'], - CollectionType::class, - [ - 'entry_type' => 'PrestaShopBundle\Form\Admin\Product\ProductWarehouseCombination', - 'entry_options' => [ - 'id_warehouse' => $warehouse['id_warehouse'], - ], - 'prototype' => true, - 'allow_add' => true, - 'required' => false, - 'label' => $warehouse['name'], - ] - ); - } - } - - /** - * Returns the block prefix of this type. - * - * @return string The prefix name - */ - public function getBlockPrefix() - { - return 'product_shipping'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Product/ProductSpecificPrice.php b/src/PrestaShopBundle/Form/Admin/Product/ProductSpecificPrice.php deleted file mode 100644 index e8f02894..00000000 --- a/src/PrestaShopBundle/Form/Admin/Product/ProductSpecificPrice.php +++ /dev/null @@ -1,337 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Product; - -use PrestaShopBundle\Form\Admin\Type\CommonAbstractType; -use PrestaShopBundle\Form\Admin\Type\DatePickerType; -use PrestaShopBundle\Form\Admin\Type\TypeaheadCustomerCollectionType; -use Symfony\Component\Form\Extension\Core\Type as FormType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\FormEvents; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Validator\Constraints as Assert; - -/** - * This form class is responsible to generate the basic product specific prices form. - */ -class ProductSpecificPrice extends CommonAbstractType -{ - private $translator; - private $locales; - private $shops; - private $countries; - private $currencies; - private $groups; - private $customerDataprovider; - - /** - * Constructor. - * - * @param object $router - * @param object $translator - * @param object $shopContextAdapter - * @param object $countryDataprovider - * @param object $currencyDataprovider - * @param object $groupDataprovider - * @param object $legacyContext - */ - public function __construct( - $router, - $translator, - $shopContextAdapter, - $countryDataprovider, - $currencyDataprovider, - $groupDataprovider, - $legacyContext, - $customerDataprovider - ) { - $this->router = $router; - $this->translator = $translator; - $this->context = $legacyContext; - $this->locales = $legacyContext->getLanguages(); - $this->shops = $this->formatDataChoicesList($shopContextAdapter->getShops(), 'id_shop'); - $this->countries = $this->formatDataChoicesList( - $countryDataprovider->getCountries($this->locales[0]['id_lang']), - 'id_country' - ); - $this->currencies = $this->formatDataChoicesList($currencyDataprovider->getCurrencies(), 'id_currency'); - $this->groups = $this->formatDataChoicesList( - $groupDataprovider->getGroups($this->locales[0]['id_lang']), - 'id_group' - ); - $this->currency = $legacyContext->getContext()->currency; - $this->customerDataprovider = $customerDataprovider; - } - - /** - * {@inheritdoc} - * - * Builds form - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - //If context multi-shop, hide shop selector - //Else show selector - if (count($this->shops) == 1) { - $builder->add( - 'sp_id_shop', - FormType\HiddenType::class, - [ - 'required' => false, - ] - ); - } else { - $builder->add( - 'sp_id_shop', - FormType\ChoiceType::class, - [ - 'choices' => $this->shops, - 'required' => false, - 'label' => false, - 'placeholder' => $this->translator->trans('All shops', [], 'Admin.Global'), - ] - ); - } - - $builder->add( - 'sp_id_currency', - FormType\ChoiceType::class, - [ - 'choices' => $this->currencies, - 'required' => false, - 'label' => false, - 'attr' => [ - 'data-toggle' => 'select2', - 'data-minimumResultsForSearch' => '7', - ], - 'placeholder' => $this->translator->trans('All currencies', [], 'Admin.Global'), - ] - ) - ->add( - 'sp_id_country', - FormType\ChoiceType::class, - [ - 'choices' => $this->countries, - 'required' => false, - 'label' => false, - 'attr' => [ - 'data-toggle' => 'select2', - 'data-minimumResultsForSearch' => '7', - ], - 'placeholder' => $this->translator->trans('All countries', [], 'Admin.Global'), - ] - ) - ->add( - 'sp_id_group', - FormType\ChoiceType::class, - [ - 'choices' => $this->groups, - 'required' => false, - 'label' => false, - 'attr' => [ - 'data-toggle' => 'select2', - 'data-minimumResultsForSearch' => '7', - ], - 'placeholder' => $this->translator->trans('All groups', [], 'Admin.Global'), - ] - ) - ->add( - 'sp_id_customer', - TypeaheadCustomerCollectionType::class, - [ - // "%QUERY" is appended to url in order to avoid "%" sign being encoded into "%25", - // it used as a placeholder to replace with actual query in JS - 'remote_url' => $this->router->generate('admin_customers_search', ['sf2' => 1]) . '&customer_search=%QUERY', - 'mapping_value' => 'id_customer', - 'mapping_name' => 'fullname_and_email', - 'placeholder' => $this->translator->trans('All customers', [], 'Admin.Global'), - 'template_collection' => '
    %s
    clear
    ', - 'limit' => 1, - 'required' => false, - 'label' => $this->translator->trans('Add customer', [], 'Admin.Catalog.Feature'), - ] - ) - ->add( - 'sp_id_product_attribute', - FormType\ChoiceType::class, - [ - 'choices' => [], - 'required' => false, - 'placeholder' => $this->translator->trans('Apply to all combinations', [], 'Admin.Catalog.Feature'), - 'label' => $this->translator->trans('Combinations', [], 'Admin.Catalog.Feature'), - 'attr' => [ - 'data-action' => $this->router->generate('admin_get_product_combinations', ['idProduct' => $options['id_product']]), - // used to force selected select option after options have been loaded - 'data-selected-attribute' => (array_keys($options, 'selected_product_attribute')) ? $options['selected_product_attribute'] : '0', - ], - ] - ) - ->add( - 'sp_from', - DatePickerType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('Available from', [], 'Admin.Catalog.Feature'), - 'attr' => ['placeholder' => 'YYYY-MM-DD'], - ] - ) - ->add( - 'sp_to', - DatePickerType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('to', [], 'Admin.Global'), - 'attr' => ['placeholder' => 'YYYY-MM-DD'], - ] - ) - ->add( - 'sp_from_quantity', - FormType\NumberType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('Starting at', [], 'Admin.Catalog.Feature'), - 'constraints' => [ - new Assert\Type(['type' => 'numeric']), - ], - ] - ) - ->add( - 'sp_price', - FormType\MoneyType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('Product price (tax excl.)', [], 'Admin.Catalog.Feature'), - 'attr' => ['class' => 'price'], - 'currency' => $this->currency->iso_code, - 'disabled' => true, - ] - ) - ->add( - 'leave_bprice', - FormType\CheckboxType::class, - [ - 'label' => $this->translator->trans('Leave initial price', [], 'Admin.Catalog.Feature'), - 'required' => false, - ] - ) - ->add( - 'sp_reduction', - FormType\NumberType::class, - [ - 'label' => $this->translator->trans('Reduction', [], 'Admin.Catalog.Feature'), - 'required' => false, - ] - ) - ->add( - 'sp_reduction_type', - FormType\ChoiceType::class, - [ - 'label' => $this->translator->trans('Reduction type', [], 'Admin.Catalog.Feature'), - 'choices' => [ - $this->currency->getSign() => 'amount', - $this->translator->trans('%', [], 'Admin.Global') => 'percentage', - ], - 'required' => true, - ] - ) - ->add( - 'sp_reduction_tax', - FormType\ChoiceType::class, - [ - 'label' => $this->translator->trans('Reduction tax', [], 'Admin.Catalog.Feature'), - 'choices' => [ - $this->translator->trans('Tax excluded', [], 'Admin.Catalog.Feature') => '0', - $this->translator->trans('Tax included', [], 'Admin.Catalog.Feature') => '1', - ], - 'required' => true, - ] - ) - ->add( - 'save', - FormType\ButtonType::class, - [ - 'label' => $this->translator->trans('Apply', [], 'Admin.Actions'), - 'attr' => ['class' => 'btn-outline-primary js-save'], - ] - ) - ->add( - 'cancel', - FormType\ButtonType::class, - [ - 'label' => $this->translator->trans('Cancel', [], 'Admin.Actions'), - 'attr' => ['class' => 'btn-outline-secondary js-cancel'], - ] - ); - // - // ResetType can't be used because the product page is wrapped - // inside a big form: reset a specific price form the "right" way - // will reset the global form. - // - - $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) { - $data = $event->getData(); - - if (empty($data['sp_id_product_attribute'])) { - return; - } - - $form = $event->getForm(); - - //bypass SF validation, define submitted value in choice list - $form->add( - 'sp_id_product_attribute', - FormType\ChoiceType::class, - [ - 'choices' => [$data['sp_id_product_attribute'] => ''], - 'required' => false, - ] - ); - }); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'id_product' => 1, // 1 is default value for new form - 'selected_product_attribute' => '0', // used to force selected select option after options have been loaded - ]); - } - - /** - * Returns the block prefix of this type. - * - * @return string The prefix name - */ - public function getBlockPrefix() - { - return 'product_combination'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Product/ProductSupplierCombination.php b/src/PrestaShopBundle/Form/Admin/Product/ProductSupplierCombination.php deleted file mode 100644 index 2993a11d..00000000 --- a/src/PrestaShopBundle/Form/Admin/Product/ProductSupplierCombination.php +++ /dev/null @@ -1,127 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Product; - -use PrestaShopBundle\Form\Admin\Type\CommonAbstractType; -use Symfony\Component\Form\Extension\Core\Type as FormType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Validator\Constraints as Assert; - -/** - * This form class is responsible to generate the basic product suppliers form. - */ -class ProductSupplierCombination extends CommonAbstractType -{ - private $translator; - private $contextLegacy; - private $currencyAdapter; - - /** - * Constructor. - * - * @param object $translator - * @param object $contextLegacy - * @param object $currencyAdapter - */ - public function __construct($translator, $contextLegacy, $currencyAdapter) - { - $this->translator = $translator; - $this->contextLegacy = $contextLegacy->getContext(); - $this->currencyAdapter = $currencyAdapter; - } - - /** - * {@inheritdoc} - * - * Builds form - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add( - 'supplier_reference', - FormType\TextType::class, - [ - 'required' => false, - 'label' => null, - 'empty_data' => '', - ] - ) - ->add( - 'product_price', - FormType\MoneyType::class, - [ - 'required' => false, - 'constraints' => [ - new Assert\NotBlank(), - new Assert\Type(['type' => 'float']), - ], - ] - ) - ->add( - 'product_price_currency', - FormType\ChoiceType::class, - [ - 'choices' => $this->formatDataChoicesList($this->currencyAdapter->getCurrencies(), 'id_currency'), - 'required' => true, - 'attr' => [ - 'class' => 'custom-select', - ], - ] - ) - ->add('id_product_attribute', FormType\HiddenType::class) - ->add('product_id', FormType\HiddenType::class) - ->add('supplier_id', FormType\HiddenType::class); - - //set default minimal values for collection prototype - $builder->setData([ - 'product_price' => 0, - 'supplier_id' => $options['id_supplier'], - 'product_price_currency' => $this->contextLegacy->currency->id, - ]); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'id_supplier' => null, - ]); - } - - /** - * Returns the block prefix of this type. - * - * @return string The prefix name - */ - public function getBlockPrefix() - { - return 'product_supplier_combination'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Product/ProductVirtual.php b/src/PrestaShopBundle/Form/Admin/Product/ProductVirtual.php deleted file mode 100644 index 4af1eb42..00000000 --- a/src/PrestaShopBundle/Form/Admin/Product/ProductVirtual.php +++ /dev/null @@ -1,164 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Product; - -use PrestaShopBundle\Form\Admin\Type\CommonAbstractType; -use PrestaShopBundle\Form\Admin\Type\DatePickerType; -use Symfony\Component\Form\Extension\Core\Type as FormType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\FormEvents; -use Symfony\Component\Validator\Constraints as Assert; - -/** - * This form class is responsible to generate the virtual product. - */ -class ProductVirtual extends CommonAbstractType -{ - private $translator; - private $legacyContext; - private $configuration; - - /** - * Constructor. - * - * @param object $translator - * @param object $legacyContext - */ - public function __construct($translator, $legacyContext) - { - $this->translator = $translator; - $this->legacyContext = $legacyContext; - $this->configuration = $this->getConfiguration(); - } - - /** - * {@inheritdoc} - * - * Builds form - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add( - 'is_virtual_file', - FormType\ChoiceType::class, - [ - 'choices' => [ - $this->translator->trans('Yes', [], 'Admin.Global') => 1, - $this->translator->trans('No', [], 'Admin.Global') => 0, - ], - 'expanded' => true, - 'required' => true, - 'multiple' => false, - ] - ) - ->add( - 'file', - FormType\FileType::class, - [ - 'required' => false, - 'label' => $this->translator->trans('File', [], 'Admin.Global'), - 'constraints' => [ - new Assert\File(['maxSize' => $this->configuration->get('PS_ATTACHMENT_MAXIMUM_SIZE') . 'M']), - ], - ] - ) - ->add( - 'name', - FormType\TextType::class, - [ - 'label' => $this->translator->trans('Filename', [], 'Admin.Global'), - 'constraints' => [ - new Assert\NotBlank(), - ], - ] - ) - ->add( - 'nb_downloadable', - FormType\NumberType::class, - [ - 'label' => $this->translator->trans('Number of allowed downloads', [], 'Admin.Catalog.Feature'), - 'required' => false, - 'constraints' => [ - new Assert\Type(['type' => 'numeric']), - ], - ] - ) - ->add( - 'expiration_date', - DatePickerType::class, - [ - 'label' => $this->translator->trans('Expiration date', [], 'Admin.Catalog.Feature'), - 'required' => false, - 'attr' => ['placeholder' => 'YYYY-MM-DD'], - ] - ) - ->add( - 'nb_days', - FormType\NumberType::class, - [ - 'label' => $this->translator->trans('Number of days', [], 'Admin.Catalog.Feature'), - 'required' => false, - 'constraints' => [ - new Assert\Type(['type' => 'numeric']), - ], - ] - ) - ->add( - 'save', - FormType\ButtonType::class, - [ - 'label' => $this->translator->trans('Save', [], 'Admin.Actions'), - 'attr' => ['class' => 'btn-primary pull-right'], - ] - ); - - $builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) { - $form = $event->getForm(); - $data = $event->getData(); - - //if this partial form is submit from a parent form, disable it - if ($form->getParent()) { - $event->setData([]); - $form->add('name', FormType\TextType::class, ['mapped' => false]); - } elseif ($data['is_virtual_file'] == 0) { - //disable name mapping when is virtual not defined to yes - $form->add('name', FormType\TextType::class, ['mapped' => false]); - } - }); - } - - /** - * Returns the block prefix of this type. - * - * @return string The prefix name - */ - public function getBlockPrefix() - { - return 'product_virtual'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Product/ProductWarehouseCombination.php b/src/PrestaShopBundle/Form/Admin/Product/ProductWarehouseCombination.php deleted file mode 100644 index 4e3e7a0c..00000000 --- a/src/PrestaShopBundle/Form/Admin/Product/ProductWarehouseCombination.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Product; - -use PrestaShopBundle\Form\Admin\Type\CommonAbstractType; -use Symfony\Component\Form\Extension\Core\Type\CheckboxType; -use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * This form class is responsible to generate the basic product Warehouse combinations form. - */ -class ProductWarehouseCombination extends CommonAbstractType -{ - private $translator; - private $contextLegacy; - - /** - * Constructor. - * - * @param object $translator - * @param object $legacyContext - */ - public function __construct($translator, $legacyContext) - { - $this->translator = $translator; - $this->contextLegacy = $legacyContext->getContext(); - } - - /** - * {@inheritdoc} - * - * Builds form - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('activated', CheckboxType::class, [ - 'required' => false, - 'label' => $this->translator->trans('Stored', [], 'Admin.Catalog.Feature'), - ]) - ->add('id_product_attribute', HiddenType::class) - ->add('product_id', HiddenType::class) - ->add('warehouse_id', HiddenType::class) - ->add('location', TextType::class, [ - 'required' => false, - 'label' => $this->translator->trans('Location (optional)', [], 'Admin.Catalog.Feature'), - 'empty_data' => '', - ]); - - //set default minimal values for collection prototype - $builder->setData([ - 'warehouse_id' => $options['id_warehouse'], - 'warehouse_activated' => false, - ]); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'id_warehouse' => null, - ]); - } - - /** - * Returns the block prefix of this type. - * - * @return string The prefix name - */ - public function getBlockPrefix() - { - return 'product_warehouse_combination'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Address/CustomerAddressType.php b/src/PrestaShopBundle/Form/Admin/Sell/Address/CustomerAddressType.php deleted file mode 100644 index e3be2bb6..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Address/CustomerAddressType.php +++ /dev/null @@ -1,393 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Address; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\AddressStateRequired; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\AddressZipCode; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CleanHtml; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\ExistingCustomerEmail; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\TypedRegex; -use PrestaShop\PrestaShop\Core\Domain\Address\Configuration\AddressConstraint; -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; -use PrestaShopBundle\Form\Admin\Type\CountryChoiceType; -use PrestaShopBundle\Form\Admin\Type\EmailType; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\Extension\Core\Type\TextareaType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Validator\Constraints\Email; -use Symfony\Component\Validator\Constraints\Length; -use Symfony\Component\Validator\Constraints\NotBlank; - -/** - * Form type for address add/edit - */ -class CustomerAddressType extends AbstractType -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ConfigurableFormChoiceProviderInterface - */ - private $stateChoiceProvider; - - /** - * @var int - */ - private $contextCountryId; - - /** - * @param TranslatorInterface $translator - * @param ConfigurableFormChoiceProviderInterface $stateChoiceProvider - */ - public function __construct( - TranslatorInterface $translator, - ConfigurableFormChoiceProviderInterface $stateChoiceProvider, - $contextCountryId - ) { - $this->translator = $translator; - $this->stateChoiceProvider = $stateChoiceProvider; - $this->contextCountryId = $contextCountryId; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $data = $builder->getData(); - $countryId = 0 !== $data['id_country'] ? $data['id_country'] : $this->contextCountryId; - $stateChoices = $this->stateChoiceProvider->getChoices(['id_country' => $countryId]); - - $hideStates = empty($stateChoices); - - if (!isset($data['id_customer'])) { - $builder->add('customer_email', EmailType::class, [ - 'required' => true, - 'constraints' => [ - new NotBlank([ - 'message' => $this->translator->trans( - 'This field cannot be empty', [], 'Admin.Notifications.Error' - ), - ]), - new CleanHtml(), - new Email([ - 'message' => $this->translator->trans('This field is invalid', [], 'Admin.Notifications.Error'), - ]), - new ExistingCustomerEmail(), - ], - ]); - } else { - $builder->add('id_customer', HiddenType::class); - } - - $builder->add('phone_mobile', TextType::class, [ - 'required' => false, - 'constraints' => [ - new CleanHtml(), - new TypedRegex([ - 'type' => TypedRegex::TYPE_PHONE_NUMBER, - ]), - new Length([ - 'max' => AddressConstraint::MAX_PHONE_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressConstraint::MAX_PHONE_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('dni', TextType::class, [ - 'required' => false, - 'empty_data' => '', - 'constraints' => [ - new CleanHtml(), - new TypedRegex([ - 'type' => TypedRegex::TYPE_DNI_LITE, - ]), - new Length([ - 'max' => AddressConstraint::MAX_DNI_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressConstraint::MAX_DNI_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('alias', TextType::class, [ - 'required' => true, - 'constraints' => [ - new NotBlank([ - 'message' => $this->translator->trans( - 'This field cannot be empty', [], 'Admin.Notifications.Error' - ), - ]), - new CleanHtml(), - new TypedRegex([ - 'type' => TypedRegex::TYPE_GENERIC_NAME, - ]), - new Length([ - 'max' => AddressConstraint::MAX_ALIAS_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressConstraint::MAX_ALIAS_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('first_name', TextType::class, [ - 'required' => true, - 'constraints' => [ - new NotBlank([ - 'message' => $this->translator->trans( - 'This field cannot be empty', [], 'Admin.Notifications.Error' - ), - ]), - new CleanHtml(), - new TypedRegex([ - 'type' => TypedRegex::TYPE_NAME, - ]), - new Length([ - 'max' => AddressConstraint::MAX_FIRST_NAME_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressConstraint::MAX_FIRST_NAME_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('last_name', TextType::class, [ - 'required' => true, - 'constraints' => [ - new NotBlank([ - 'message' => $this->translator->trans( - 'This field cannot be empty', [], 'Admin.Notifications.Error' - ), - ]), - new CleanHtml(), - new TypedRegex([ - 'type' => TypedRegex::TYPE_NAME, - ]), - new Length([ - 'max' => AddressConstraint::MAX_LAST_NAME_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressConstraint::MAX_LAST_NAME_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('company', TextType::class, [ - 'required' => false, - 'empty_data' => '', - 'constraints' => [ - new CleanHtml(), - new TypedRegex([ - 'type' => TypedRegex::TYPE_GENERIC_NAME, - ]), - new Length([ - 'max' => AddressConstraint::MAX_COMPANY_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressConstraint::MAX_COMPANY_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('vat_number', TextType::class, [ - 'required' => false, - 'empty_data' => '', - 'constraints' => [ - new CleanHtml(), - new TypedRegex([ - 'type' => TypedRegex::TYPE_GENERIC_NAME, - ]), - new Length([ - 'max' => AddressConstraint::MAX_VAT_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressConstraint::MAX_VAT_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('address1', TextType::class, [ - 'required' => true, - 'constraints' => [ - new NotBlank([ - 'message' => $this->translator->trans( - 'This field cannot be empty', [], 'Admin.Notifications.Error' - ), - ]), - new CleanHtml(), - new TypedRegex([ - 'type' => TypedRegex::TYPE_ADDRESS, - ]), - new Length([ - 'max' => AddressConstraint::MAX_ADDRESS_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressConstraint::MAX_ADDRESS_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('address2', TextType::class, [ - 'required' => false, - 'empty_data' => '', - 'constraints' => [ - new CleanHtml(), - new TypedRegex([ - 'type' => TypedRegex::TYPE_ADDRESS, - ]), - new Length([ - 'max' => AddressConstraint::MAX_ADDRESS_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressConstraint::MAX_ADDRESS_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('city', TextType::class, [ - 'required' => true, - 'constraints' => [ - new NotBlank([ - 'message' => $this->translator->trans( - 'This field cannot be empty', [], 'Admin.Notifications.Error' - ), - ]), - new CleanHtml(), - new TypedRegex([ - 'type' => TypedRegex::TYPE_CITY_NAME, - ]), - new Length([ - 'max' => AddressConstraint::MAX_CITY_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressConstraint::MAX_CITY_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('postcode', TextType::class, [ - 'required' => false, - 'empty_data' => '', - 'constraints' => [ - new AddressZipCode([ - 'id_country' => $countryId, - 'required' => false, - ]), - new CleanHtml(), - new TypedRegex([ - 'type' => TypedRegex::TYPE_POST_CODE, - ]), - new Length([ - 'max' => AddressConstraint::MAX_POSTCODE_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressConstraint::MAX_POSTCODE_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('id_country', CountryChoiceType::class, [ - 'required' => true, - 'with_dni_attr' => true, - 'with_postcode_attr' => true, - 'constraints' => [ - new NotBlank([ - 'message' => $this->translator->trans( - 'This field cannot be empty', [], 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('id_state', ChoiceType::class, [ - 'required' => true, - 'choices' => $stateChoices, - 'constraints' => [ - new AddressStateRequired([ - 'id_country' => $countryId, - ]), - ], - ]) - ->add('phone', TextType::class, [ - 'required' => false, - 'empty_data' => '', - 'constraints' => [ - new CleanHtml(), - new TypedRegex([ - 'type' => TypedRegex::TYPE_PHONE_NUMBER, - ]), - new Length([ - 'max' => AddressConstraint::MAX_PHONE_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressConstraint::MAX_PHONE_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('other', TextareaType::class, [ - 'required' => false, - 'empty_data' => '', - 'constraints' => [ - new CleanHtml(), - new TypedRegex([ - 'type' => TypedRegex::TYPE_MESSAGE, - ]), - new Length([ - 'max' => AddressConstraint::MAX_OTHER_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressConstraint::MAX_OTHER_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Address/ManufacturerAddressType.php b/src/PrestaShopBundle/Form/Admin/Sell/Address/ManufacturerAddressType.php deleted file mode 100644 index f491e4bd..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Address/ManufacturerAddressType.php +++ /dev/null @@ -1,334 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Address; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\AddressDniRequired; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\AddressStateRequired; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\TypedRegex; -use PrestaShop\PrestaShop\Core\Domain\Address\AddressSettings; -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; -use PrestaShopBundle\Form\Admin\Type\CountryChoiceType; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Validator\Constraints\Length; -use Symfony\Component\Validator\Constraints\NotBlank; - -/** - * Defines form for address create/edit actions (Sell > Catalog > Brands & Suppliers) - */ -class ManufacturerAddressType extends AbstractType -{ - /** - * @var array - */ - private $manufacturerChoices; - - /** - * @var array - */ - private $countryChoices; - - /** - * @var array - */ - private $countryChoicesAttributes; - - /** - * @var ConfigurableFormChoiceProviderInterface - */ - private $statesChoiceProvider; - - /** - * @var int - */ - private $contextCountryId; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param array $manufacturerChoices - * @param array $countryChoices - * @param ConfigurableFormChoiceProviderInterface $statesChoiceProvider - * @param int $contextCountryId - * @param TranslatorInterface $translator - * @param array $countryChoicesAttributes - */ - public function __construct( - array $manufacturerChoices, - array $countryChoices, - ConfigurableFormChoiceProviderInterface $statesChoiceProvider, - $contextCountryId, - TranslatorInterface $translator, - array $countryChoicesAttributes - ) { - $this->manufacturerChoices = $manufacturerChoices; - $this->countryChoices = $countryChoices; - $this->statesChoiceProvider = $statesChoiceProvider; - $this->contextCountryId = $contextCountryId; - $this->translator = $translator; - $this->countryChoicesAttributes = $countryChoicesAttributes; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $data = $builder->getData(); - $countryId = 0 !== $data['id_country'] ? $data['id_country'] : $this->contextCountryId; - $stateChoices = $this->statesChoiceProvider->getChoices(['id_country' => $countryId]); - - $builder - ->add('id_manufacturer', ChoiceType::class, [ - 'choices' => $this->getManufacturersChoiceList(), - 'translation_domain' => false, - 'placeholder' => false, - 'required' => false, - ]) - ->add('last_name', TextType::class, [ - 'constraints' => [ - new NotBlank([ - 'message' => $this->translator->trans( - 'This field cannot be empty', [], 'Admin.Notifications.Error' - ), - ]), - new TypedRegex([ - 'type' => 'name', - ]), - new Length([ - 'max' => AddressSettings::MAX_NAME_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressSettings::MAX_NAME_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('first_name', TextType::class, [ - 'constraints' => [ - new NotBlank([ - 'message' => $this->translator->trans( - 'This field cannot be empty', [], 'Admin.Notifications.Error' - ), - ]), - new TypedRegex([ - 'type' => 'name', - ]), - new Length([ - 'max' => AddressSettings::MAX_NAME_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressSettings::MAX_NAME_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('address', TextType::class, [ - 'constraints' => [ - new TypedRegex([ - 'type' => 'address', - ]), - new Length([ - 'max' => AddressSettings::MAX_ADDRESS_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressSettings::MAX_ADDRESS_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('address2', TextType::class, [ - 'required' => false, - 'empty_data' => '', - 'constraints' => [ - new TypedRegex([ - 'type' => 'address', - ]), - new Length([ - 'max' => AddressSettings::MAX_ADDRESS_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressSettings::MAX_ADDRESS_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('post_code', TextType::class, [ - 'required' => false, - 'empty_data' => '', - 'constraints' => [ - new TypedRegex([ - 'type' => 'post_code', - ]), - new Length([ - 'max' => AddressSettings::MAX_POST_CODE_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressSettings::MAX_POST_CODE_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('city', TextType::class, [ - 'constraints' => [ - new NotBlank([ - 'message' => $this->translator->trans( - 'This field cannot be empty', [], 'Admin.Notifications.Error' - ), - ]), - new TypedRegex([ - 'type' => 'city_name', - ]), - new Length([ - 'max' => AddressSettings::MAX_CITY_NAME_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressSettings::MAX_CITY_NAME_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('id_country', CountryChoiceType::class, [ - 'required' => true, - 'with_dni_attr' => true, - 'constraints' => [ - new NotBlank([ - 'message' => $this->translator->trans( - 'This field cannot be empty', [], 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('id_state', ChoiceType::class, [ - 'required' => true, - 'choices' => $stateChoices, - 'constraints' => [ - new AddressStateRequired([ - 'id_country' => $countryId, - ]), - ], - ]) - ->add('home_phone', TextType::class, [ - 'required' => false, - 'empty_data' => '', - 'constraints' => [ - new TypedRegex([ - 'type' => 'phone_number', - ]), - new Length([ - 'max' => AddressSettings::MAX_PHONE_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressSettings::MAX_PHONE_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('mobile_phone', TextType::class, [ - 'required' => false, - 'empty_data' => '', - 'constraints' => [ - new TypedRegex([ - 'type' => 'phone_number', - ]), - new Length([ - 'max' => AddressSettings::MAX_PHONE_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressSettings::MAX_PHONE_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('dni', TextType::class, [ - 'required' => false, - 'empty_data' => '', - 'constraints' => [ - new AddressDniRequired([ - 'required' => false, - 'id_country' => $countryId, - ]), - new TypedRegex([ - 'type' => 'dni_lite', - ]), - new Length([ - 'max' => 16, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => 16], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('other', TextType::class, [ - 'required' => false, - 'empty_data' => '', - 'constraints' => [ - new TypedRegex([ - 'type' => 'message', - ]), - new Length([ - 'max' => AddressSettings::MAX_OTHER_LENGTH, - 'maxMessage' => $this->translator->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AddressSettings::MAX_OTHER_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ; - } - - /** - * Get manufacturers array for choice list - * List is modified to enable selecting -no manufacturer- - * - * @return array - */ - private function getManufacturersChoiceList() - { - $this->manufacturerChoices['--'] = 0; - - return $this->manufacturerChoices; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Address/RequiredFieldsAddressType.php b/src/PrestaShopBundle/Form/Admin/Sell/Address/RequiredFieldsAddressType.php deleted file mode 100644 index 84291c35..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Address/RequiredFieldsAddressType.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Address; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShopBundle\Form\Admin\Type\Material\MaterialChoiceTableType; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; - -/** - * Defines form for address required fields modification (Sell > Customers > Addresses) - */ -class RequiredFieldsAddressType extends AbstractType -{ - /** - * @var FormChoiceProviderInterface - */ - private $addressRequiredFieldsChoicesProvider; - - /** - * @param FormChoiceProviderInterface $addressRequiredFieldsChoicesProvider - */ - public function __construct(FormChoiceProviderInterface $addressRequiredFieldsChoicesProvider) - { - $this->addressRequiredFieldsChoicesProvider = $addressRequiredFieldsChoicesProvider; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('required_fields', MaterialChoiceTableType::class, [ - 'label' => false, - 'choices' => $this->addressRequiredFieldsChoicesProvider->getChoices(), - ]) - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Attachment/AttachmentType.php b/src/PrestaShopBundle/Form/Admin/Sell/Attachment/AttachmentType.php deleted file mode 100644 index 04177803..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Attachment/AttachmentType.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Attachment; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CleanHtml; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\DefaultLanguage; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\TypedRegex; -use PrestaShop\PrestaShop\Core\Domain\Attachment\Configuration\AttachmentConstraint; -use PrestaShopBundle\Form\Admin\Type\TranslatableType; -use PrestaShopBundle\Translation\TranslatorAwareTrait; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\FileType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Validator\Constraints\Length; - -/** - * Attachment form type definition - */ -class AttachmentType extends AbstractType -{ - use TranslatorAwareTrait; - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('name', TranslatableType::class, [ - 'type' => TextType::class, - 'required' => true, - 'options' => [ - 'constraints' => [ - new TypedRegex( - [ - 'type' => 'generic_name', - ] - ), - new Length( - [ - 'max' => AttachmentConstraint::MAX_NAME_LENGTH, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => AttachmentConstraint::MAX_NAME_LENGTH], - 'Admin.Notifications.Error' - ), - ] - ), - ], - ], - 'constraints' => [ - new DefaultLanguage(), - ], - ]) - ->add('file_description', TranslatableType::class, [ - 'type' => TextType::class, - 'required' => false, - 'options' => [ - 'constraints' => [ - new CleanHtml(), - ], - ], - ]) - ->add('file', FileType::class, [ - 'required' => false, - ]) - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Catalog/FeatureType.php b/src/PrestaShopBundle/Form/Admin/Sell/Catalog/FeatureType.php deleted file mode 100644 index 07eff9a7..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Catalog/FeatureType.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Catalog; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\TypedRegex; -use PrestaShopBundle\Form\Admin\Type\ShopChoiceTreeType; -use PrestaShopBundle\Form\Admin\Type\TranslatableType; -use PrestaShopBundle\Translation\TranslatorAwareTrait; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; - -/** - * Type that builds a product feature add/edit form. - */ -class FeatureType extends AbstractType -{ - use TranslatorAwareTrait; - - /** - * @var bool - */ - private $isMultistoreFeatureActive; - - /** - * @param bool $isMultistoreFeatureActive - */ - public function __construct($isMultistoreFeatureActive) - { - $this->isMultistoreFeatureActive = $isMultistoreFeatureActive; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('name', TranslatableType::class, [ - 'type' => TextType::class, - 'options' => [ - 'constraints' => [ - new TypedRegex([ - 'type' => 'generic_name', - ]), - ], - ], - ]); - - if ($this->isMultistoreFeatureActive) { - $builder->add('shop_association', ShopChoiceTreeType::class); - } - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/CatalogPriceRule/CatalogPriceRuleType.php b/src/PrestaShopBundle/Form/Admin/Sell/CatalogPriceRule/CatalogPriceRuleType.php deleted file mode 100644 index 6c9c3f7a..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/CatalogPriceRule/CatalogPriceRuleType.php +++ /dev/null @@ -1,249 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\CatalogPriceRule; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CleanHtml; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\DateRange; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\Reduction; -use PrestaShop\PrestaShop\Core\Domain\ValueObject\Reduction as ReductionVO; -use PrestaShopBundle\Form\Admin\Type\DateRangeType; -use PrestaShopBundle\Form\Admin\Type\ReductionType; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\CheckboxType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\NumberType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Validator\Constraints\GreaterThanOrEqual; - -/** - * Defines catalog price rule form for create/edit actions - */ -class CatalogPriceRuleType extends AbstractType -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var bool - */ - private $isMultishopEnabled; - - /** - * @var array - */ - private $currencyByIdChoices; - - /** - * @var array - */ - private $countryByIdChoices; - - /** - * @var array - */ - private $groupByIdChoices; - - /** - * @var array - */ - private $shopByIdChoices; - - /** - * @var array - */ - private $taxInclusionChoices; - - /** - * @param TranslatorInterface $translator - * @param bool $isMultishopEnabled - * @param array $currencyByIdChoices - * @param array $countryByIdChoices - * @param array $groupByIdChoices - * @param array $shopByIdChoices - * @param array $taxInclusionChoices - */ - public function __construct( - TranslatorInterface $translator, - bool $isMultishopEnabled, - array $currencyByIdChoices, - array $countryByIdChoices, - array $groupByIdChoices, - array $shopByIdChoices, - array $taxInclusionChoices - ) { - $this->translator = $translator; - $this->isMultishopEnabled = $isMultishopEnabled; - $this->currencyByIdChoices = $currencyByIdChoices; - $this->countryByIdChoices = $countryByIdChoices; - $this->groupByIdChoices = $groupByIdChoices; - $this->shopByIdChoices = $shopByIdChoices; - $this->taxInclusionChoices = $taxInclusionChoices; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('name', TextType::class, [ - 'constraints' => [ - new CleanHtml(), - ], - ]) - ->add('id_currency', ChoiceType::class, [ - 'required' => false, - 'placeholder' => false, - 'choices' => $this->getModifiedCurrencyChoices(), - ]) - ->add('id_country', ChoiceType::class, [ - 'required' => false, - 'placeholder' => false, - 'choices' => $this->getModifiedCountryChoices(), - ]) - ->add('id_group', ChoiceType::class, [ - 'required' => false, - 'placeholder' => false, - 'choices' => $this->getModifiedGroupChoices(), - ]) - ->add('from_quantity', NumberType::class, [ - 'scale' => 0, - 'constraints' => [ - new GreaterThanOrEqual([ - 'value' => 0, - 'message' => $this->translator->trans( - '%s is invalid.', - [], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('price', NumberType::class, [ - 'required' => false, - 'scale' => 6, - 'constraints' => [ - new GreaterThanOrEqual([ - 'value' => 0, - 'message' => $this->translator->trans( - '%s is invalid.', - [], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('leave_initial_price', CheckboxType::class, [ - 'required' => false, - ]) - ->add('date_range', DateRangeType::class, [ - 'date_format' => 'YYYY-MM-DD HH:mm:ss', - 'constraints' => [ - new DateRange([ - 'message' => $this->translator->trans( - 'The selected date range is not valid.', - [], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('include_tax', ChoiceType::class, [ - 'placeholder' => false, - 'required' => false, - 'choices' => $this->taxInclusionChoices, - ]) - ->add('reduction', ReductionType::class, [ - 'constraints' => [ - new Reduction([ - 'invalidPercentageValueMessage' => $this->translator->trans( - 'Reduction value "%value%" is invalid. Allowed values from 0 to %max%', - ['%max%' => ReductionVO::MAX_ALLOWED_PERCENTAGE . '%'], - 'Admin.Notifications.Error' - ), - 'invalidAmountValueMessage' => $this->translator->trans( - 'Reduction value "%value%" is invalid. Value cannot be negative', - [], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ; - - if ($this->isMultishopEnabled) { - $builder->add('id_shop', ChoiceType::class, [ - 'required' => false, - 'placeholder' => false, - 'choices' => $this->shopByIdChoices, - ]); - } - } - - /** - * Prepends 'All currencies' option with id of 0 to currency choices - * - * @return array - */ - private function getModifiedCurrencyChoices(): array - { - return array_merge( - [$this->translator->trans('All currencies', [], 'Admin.Global') => 0], - $this->currencyByIdChoices - ); - } - - /** - * Prepends 'All countries' option with id of 0 to country choices - * - * @return array - */ - private function getModifiedCountryChoices(): array - { - return array_merge( - [$this->translator->trans('All countries', [], 'Admin.Global') => 0], - $this->countryByIdChoices - ); - } - - /** - * Prepends 'All groups' option with id of 0 to group choices - * - * @return array - */ - private function getModifiedGroupChoices(): array - { - return array_merge( - [$this->translator->trans('All groups', [], 'Admin.Global') => 0], - $this->groupByIdChoices - ); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Category/DeleteCategoriesType.php b/src/PrestaShopBundle/Form/Admin/Sell/Category/DeleteCategoriesType.php deleted file mode 100644 index e974e85d..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Category/DeleteCategoriesType.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Category; - -use PrestaShop\PrestaShop\Core\Domain\Category\ValueObject\CategoryDeleteMode; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\CollectionType; -use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\FormBuilderInterface; - -/** - * Class DeleteCategoriesType. - */ -class DeleteCategoriesType extends AbstractType -{ - /** - * @var array - */ - private $categoryDeleteModelChoices; - - /** - * @param array $categoryDeleteModelChoices - */ - public function __construct(array $categoryDeleteModelChoices) - { - $this->categoryDeleteModelChoices = $categoryDeleteModelChoices; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('delete_mode', ChoiceType::class, [ - 'expanded' => true, - 'choices' => $this->categoryDeleteModelChoices, - 'label' => false, - 'data' => CategoryDeleteMode::ASSOCIATE_PRODUCTS_WITH_PARENT_AND_DISABLE, - ]) - ->add('categories_to_delete', CollectionType::class, [ - 'entry_type' => HiddenType::class, - 'label' => false, - 'allow_add' => true, - ]); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Customer/CustomerType.php b/src/PrestaShopBundle/Form/Admin/Sell/Customer/CustomerType.php deleted file mode 100644 index 73de325a..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Customer/CustomerType.php +++ /dev/null @@ -1,257 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Customer; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CustomerName; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\FirstName; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\LastName; -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\Password; -use PrestaShopBundle\Form\Admin\Type\EmailType; -use PrestaShopBundle\Form\Admin\Type\Material\MaterialChoiceTableType; -use PrestaShopBundle\Form\Admin\Type\SwitchType; -use PrestaShopBundle\Translation\TranslatorAwareTrait; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\BirthdayType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\IntegerType; -use Symfony\Component\Form\Extension\Core\Type\NumberType; -use Symfony\Component\Form\Extension\Core\Type\PasswordType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Validator\Constraints\Email; -use Symfony\Component\Validator\Constraints\Length; -use Symfony\Component\Validator\Constraints\NotBlank; -use Symfony\Component\Validator\Constraints\Type; - -/** - * Type is used to created form for customer add/edit actions - */ -class CustomerType extends AbstractType -{ - use TranslatorAwareTrait; - - /** - * @var array - */ - private $genderChoices; - - /** - * @var array - */ - private $groupChoices; - - /** - * @var bool - */ - private $isB2bFeatureEnabled; - - /** - * @var array - */ - private $riskChoices; - - /** - * @var bool - */ - private $isPartnerOffersEnabled; - - /** - * @param array $genderChoices - * @param array $groupChoices - * @param array $riskChoices - * @param bool $isB2bFeatureEnabled - * @param bool $isPartnerOffersEnabled - */ - public function __construct( - array $genderChoices, - array $groupChoices, - array $riskChoices, - $isB2bFeatureEnabled, - $isPartnerOffersEnabled - ) { - $this->genderChoices = $genderChoices; - $this->groupChoices = $groupChoices; - $this->isB2bFeatureEnabled = $isB2bFeatureEnabled; - $this->riskChoices = $riskChoices; - $this->isPartnerOffersEnabled = $isPartnerOffersEnabled; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('gender_id', ChoiceType::class, [ - 'choices' => $this->genderChoices, - 'multiple' => false, - 'expanded' => true, - 'required' => false, - 'placeholder' => null, - ]) - ->add('first_name', TextType::class, [ - 'constraints' => [ - new NotBlank([ - 'message' => $this->trans('This field cannot be empty', [], 'Admin.Notifications.Error'), - ]), - new Length([ - 'max' => FirstName::MAX_LENGTH, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => FirstName::MAX_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - new CustomerName([ - 'message' => $this->trans('The %s field is invalid.', [sprintf('"%s"', $this->trans('First name', [], 'Admin.Global'))], 'Admin.Notifications.Error'), - ]), - ], - ]) - ->add('last_name', TextType::class, [ - 'constraints' => [ - new NotBlank([ - 'message' => $this->trans('This field cannot be empty', [], 'Admin.Notifications.Error'), - ]), - new Length([ - 'max' => LastName::MAX_LENGTH, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => LastName::MAX_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - new CustomerName([ - 'message' => $this->trans('The %s field is invalid.', [sprintf('"%s"', $this->trans('Last name', [], 'Admin.Global'))], 'Admin.Notifications.Error'), - ]), - ], - ]) - ->add('email', EmailType::class, [ - 'constraints' => [ - new NotBlank([ - 'message' => $this->trans('This field cannot be empty', [], 'Admin.Notifications.Error'), - ]), - new Email([ - 'message' => $this->trans('This field is invalid', [], 'Admin.Notifications.Error'), - ]), - ], - ]) - ->add('password', PasswordType::class, [ - 'constraints' => [ - new Length([ - 'max' => Password::MAX_LENGTH, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => Password::MAX_LENGTH], - 'Admin.Notifications.Error' - ), - 'min' => Password::MIN_LENGTH, - 'minMessage' => $this->trans( - 'This field cannot be shorter than %limit% characters', - ['%limit%' => Password::MIN_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - 'required' => $options['is_password_required'], - ]) - ->add('birthday', BirthdayType::class, [ - 'required' => false, - 'format' => 'yyyy MM dd', - 'input' => 'string', - ]) - ->add('is_enabled', SwitchType::class, [ - 'required' => false, - ]) - ->add('is_partner_offers_subscribed', SwitchType::class, [ - 'required' => false, - 'disabled' => !$this->isPartnerOffersEnabled, - ]) - ->add('group_ids', MaterialChoiceTableType::class, [ - 'empty_data' => [], - 'choices' => $this->groupChoices, - ]) - ->add('default_group_id', ChoiceType::class, [ - 'required' => false, - 'placeholder' => null, - 'choices' => $this->groupChoices, - ]) - ; - - if ($this->isB2bFeatureEnabled) { - $builder - ->add('company_name', TextType::class, [ - 'required' => false, - ]) - ->add('siret_code', TextType::class, [ - 'required' => false, - ]) - ->add('ape_code', TextType::class, [ - 'required' => false, - 'constraints' => [ - new Type([ - 'type' => 'alnum', - 'message' => $this->trans('This field is invalid', [], 'Admin.Notifications.Error'), - ]), - ], - ]) - ->add('website', TextType::class, [ - 'required' => false, - ]) - ->add('allowed_outstanding_amount', NumberType::class, [ - 'scale' => 6, - 'required' => false, - 'invalid_message' => $this->trans('This field is invalid', [], 'Admin.Notifications.Error'), - ]) - ->add('max_payment_days', IntegerType::class, [ - 'required' => false, - 'invalid_message' => $this->trans('This field is invalid', [], 'Admin.Notifications.Error'), - ]) - ->add('risk_id', ChoiceType::class, [ - 'required' => false, - 'placeholder' => null, - 'choices' => $this->riskChoices, - ]) - ; - } - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setDefaults([ - // password is configurable - // so it may be optional when editing customer - 'is_password_required' => true, - ]) - ->setAllowedTypes('is_password_required', 'bool') - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Customer/DeleteCustomersType.php b/src/PrestaShopBundle/Form/Admin/Sell/Customer/DeleteCustomersType.php deleted file mode 100644 index c6da2861..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Customer/DeleteCustomersType.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Customer; - -use PrestaShop\PrestaShop\Core\Domain\Customer\ValueObject\CustomerDeleteMethod; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\CollectionType; -use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\FormBuilderInterface; - -/** - * Class DeleteCustomersType - */ -class DeleteCustomersType extends AbstractType -{ - /** - * @var array - */ - private $customerDeleteMethodChoices; - - /** - * @param array $customerDeleteMethodChoices - */ - public function __construct(array $customerDeleteMethodChoices) - { - $this->customerDeleteMethodChoices = $customerDeleteMethodChoices; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('delete_method', ChoiceType::class, [ - 'choices' => $this->customerDeleteMethodChoices, - 'expanded' => true, - 'multiple' => false, - 'translation_domain' => false, - 'data' => CustomerDeleteMethod::ALLOW_CUSTOMER_REGISTRATION, - ]) - ->add('customers_to_delete', CollectionType::class, [ - 'entry_type' => HiddenType::class, - 'label' => false, - 'allow_add' => true, - ]) - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Customer/PrivateNoteType.php b/src/PrestaShopBundle/Form/Admin/Sell/Customer/PrivateNoteType.php deleted file mode 100644 index 55ed027f..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Customer/PrivateNoteType.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Customer; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\TextareaType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class PrivateNoteType is used to add private notes about customer. - */ -class PrivateNoteType extends AbstractType -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * PrivateNoteType constructor. - * - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('note', TextareaType::class, [ - 'required' => false, - 'empty_data' => '', - 'attr' => [ - 'placeholder' => $this->translator->trans('Add a note on this customer. It will only be visible to you.', [], 'Admin.Orderscustomers.Feature'), - ], - ]); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Customer/RequiredFieldsType.php b/src/PrestaShopBundle/Form/Admin/Sell/Customer/RequiredFieldsType.php deleted file mode 100644 index 0cccff7a..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Customer/RequiredFieldsType.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Customer; - -use PrestaShopBundle\Form\Admin\Type\Material\MaterialChoiceTableType; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; - -/** - * Defines form for customer required fields - */ -class RequiredFieldsType extends AbstractType -{ - /** - * @var array - */ - private $customerRequiredFieldsChoices; - - /** - * @param array $customerRequiredFieldsChoices - */ - public function __construct(array $customerRequiredFieldsChoices) - { - $this->customerRequiredFieldsChoices = $customerRequiredFieldsChoices; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('required_fields', MaterialChoiceTableType::class, [ - 'label' => false, - 'choices' => $this->customerRequiredFieldsChoices, - ]) - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Customer/TransferGuestAccountType.php b/src/PrestaShopBundle/Form/Admin/Sell/Customer/TransferGuestAccountType.php deleted file mode 100644 index 03a458e1..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Customer/TransferGuestAccountType.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Customer; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\FormBuilderInterface; - -/** - * Class TransferGuestAccountType is type used to submit guest customer transformation - * into actual customer with password. - */ -class TransferGuestAccountType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('id_customer', HiddenType::class); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/CustomerService/MerchandiseReturn/MerchandiseReturnOptionsFormDataProvider.php b/src/PrestaShopBundle/Form/Admin/Sell/CustomerService/MerchandiseReturn/MerchandiseReturnOptionsFormDataProvider.php deleted file mode 100644 index e1ac0f8e..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/CustomerService/MerchandiseReturn/MerchandiseReturnOptionsFormDataProvider.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\CustomerService\MerchandiseReturn; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\Form\FormDataProviderInterface; - -/** - * Provides merchandise return options form with data - */ -final class MerchandiseReturnOptionsFormDataProvider implements FormDataProviderInterface -{ - /** - * @var DataConfigurationInterface - */ - private $optionsDataConfiguration; - - /** - * @param DataConfigurationInterface $optionsDataConfiguration - */ - public function __construct(DataConfigurationInterface $optionsDataConfiguration) - { - $this->optionsDataConfiguration = $optionsDataConfiguration; - } - - /** - * {@inheritdoc} - */ - public function getData() - { - return [ - 'options' => $this->optionsDataConfiguration->getConfiguration(), - ]; - } - - /** - * {@inheritdoc} - */ - public function setData(array $data) - { - return $this->optionsDataConfiguration->updateConfiguration($data['options']); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/CustomerService/MerchandiseReturn/MerchandiseReturnOptionsType.php b/src/PrestaShopBundle/Form/Admin/Sell/CustomerService/MerchandiseReturn/MerchandiseReturnOptionsType.php deleted file mode 100644 index 32078031..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/CustomerService/MerchandiseReturn/MerchandiseReturnOptionsType.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\CustomerService\MerchandiseReturn; - -use PrestaShopBundle\Form\Admin\Type\SwitchType; -use PrestaShopBundle\Form\Admin\Type\TranslatableType; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\IntegerType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Validator\Constraints\GreaterThanOrEqual; - -/** - * Form type for merchandise returns options - */ -class MerchandiseReturnOptionsType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('enable_order_return', SwitchType::class, [ - 'required' => false, - ]) - ->add('order_return_period_in_days', IntegerType::class, [ - 'required' => false, - 'constraints' => new GreaterThanOrEqual([ - 'value' => 0, - ]), - ]) - ->add('order_return_prefix', TranslatableType::class, [ - 'required' => false, - ]) - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/CustomerService/OrderMessageType.php b/src/PrestaShopBundle/Form/Admin/Sell/CustomerService/OrderMessageType.php deleted file mode 100644 index 3572b7b8..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/CustomerService/OrderMessageType.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\CustomerService; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\DefaultLanguage; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\TypedRegex; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\OrderMessageConstraint; -use PrestaShopBundle\Form\Admin\Type\TranslatableType; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\TextareaType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Validator\Constraints\Length; - -/** - * Builds add/edit form for order message - */ -class OrderMessageType extends AbstractType -{ - /** - * @param FormBuilderInterface $builder - * @param array $options - */ - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $builder - ->add('name', TranslatableType::class, [ - 'options' => [ - 'constraints' => [ - new TypedRegex([ - 'type' => 'generic_name', - ]), - new Length([ - 'max' => OrderMessageConstraint::MAX_NAME_LENGTH, - ]), - ], - ], - 'constraints' => [ - new DefaultLanguage(), - ], - ]) - ->add('message', TranslatableType::class, [ - 'type' => TextareaType::class, - 'options' => [ - 'constraints' => [ - new TypedRegex([ - 'type' => 'message', - ]), - new Length([ - 'max' => OrderMessageConstraint::MAX_MESSAGE_LENGTH, - ]), - ], - 'attr' => [ - 'rows' => 5, - ], - ], - 'constraints' => [ - new DefaultLanguage(), - ], - ]) - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/CustomerService/ReplyToCustomerThreadType.php b/src/PrestaShopBundle/Form/Admin/Sell/CustomerService/ReplyToCustomerThreadType.php deleted file mode 100644 index 6b402b7c..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/CustomerService/ReplyToCustomerThreadType.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\CustomerService; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CleanHtml; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\TextareaType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Validator\Constraints\NotBlank; - -class ReplyToCustomerThreadType extends AbstractType -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param TranslatorInterface $translator - */ - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('reply_message', TextareaType::class, [ - 'required' => false, - 'constraints' => [ - new NotBlank([ - 'message' => $this->translator->trans( - 'Reply message is required', - [], - 'Admin.Notifications.Error' - ), - ]), - new CleanHtml([ - 'message' => $this->translator->trans( - 'Reply message is invalid', - [], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Manufacturer/ManufacturerType.php b/src/PrestaShopBundle/Form/Admin/Sell/Manufacturer/ManufacturerType.php deleted file mode 100644 index 020e46bf..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Manufacturer/ManufacturerType.php +++ /dev/null @@ -1,201 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Manufacturer; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CleanHtml; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\TypedRegex; -use PrestaShopBundle\Form\Admin\Type\FormattedTextareaType; -use PrestaShopBundle\Form\Admin\Type\ShopChoiceTreeType; -use PrestaShopBundle\Form\Admin\Type\SwitchType; -use PrestaShopBundle\Form\Admin\Type\TranslatableType; -use PrestaShopBundle\Form\Admin\Type\TranslateType; -use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType; -use Symfony\Component\Form\Extension\Core\Type\FileType; -use Symfony\Component\Form\Extension\Core\Type\TextareaType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Validator\Constraints\Length; -use Symfony\Component\Validator\Constraints\NotBlank; - -/** - * Defines form for manufacturer create/edit actions (Sell > Catalog > Brands & Suppliers) - */ -class ManufacturerType extends TranslatorAwareType -{ - /** - * @var bool - */ - private $isMultistoreEnabled; - - /** - * @param TranslatorInterface $translator - * @param array $locales - * @param bool $isMultistoreEnabled - */ - public function __construct( - TranslatorInterface $translator, - array $locales, - $isMultistoreEnabled - ) { - parent::__construct($translator, $locales); - - $this->isMultistoreEnabled = $isMultistoreEnabled; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('name', TextType::class, [ - 'constraints' => [ - new NotBlank([ - 'message' => $this->trans( - 'This field cannot be empty', 'Admin.Notifications.Error' - ), - ]), - new Length([ - 'max' => 64, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - 'Admin.Notifications.Error', - ['%limit%' => 64] - ), - ]), - new TypedRegex([ - 'type' => 'catalog_name', - ]), - ], - ]) - ->add('short_description', TranslateType::class, [ - 'type' => FormattedTextareaType::class, - 'locales' => $this->locales, - 'hideTabs' => false, - 'required' => false, - 'options' => [ - 'constraints' => [ - new CleanHtml([ - 'message' => $this->trans( - '%s is invalid.', - 'Admin.Notifications.Error' - ), - ]), - ], - ], - ]) - ->add('description', TranslateType::class, [ - 'type' => FormattedTextareaType::class, - 'locales' => $this->locales, - 'hideTabs' => false, - 'required' => false, - 'options' => [ - 'constraints' => [ - new CleanHtml([ - 'message' => $this->trans( - '%s is invalid.', - 'Admin.Notifications.Error' - ), - ]), - ], - ], - ]) - ->add('logo', FileType::class, [ - 'required' => false, - ]) - ->add('meta_title', TranslatableType::class, [ - 'type' => TextType::class, - 'required' => false, - 'options' => [ - 'constraints' => [ - new TypedRegex([ - 'type' => 'generic_name', - ]), - new Length([ - 'max' => 255, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - 'Admin.Notifications.Error', - ['%limit%' => 255] - ), - ]), - ], - ], - ]) - ->add('meta_description', TranslatableType::class, [ - 'type' => TextareaType::class, - 'required' => false, - 'options' => [ - 'constraints' => [ - new TypedRegex([ - 'type' => 'generic_name', - ]), - new Length([ - 'max' => 512, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - 'Admin.Notifications.Error', - ['%limit%' => 512] - ), - ]), - ], - ], - ]) - ->add('meta_keyword', TranslatableType::class, [ - 'type' => TextType::class, - 'required' => false, - 'options' => [ - 'attr' => [ - 'class' => 'js-taggable-field', - 'placeholder' => $this->trans('Add tag', 'Admin.Actions'), - ], - 'constraints' => [ - new TypedRegex([ - 'type' => 'generic_name', - ]), - ], - ], - ]) - ->add('is_enabled', SwitchType::class, [ - 'required' => false, - ]); - - if ($this->isMultistoreEnabled) { - $builder->add('shop_association', ShopChoiceTreeType::class, [ - 'required' => false, - 'constraints' => [ - new NotBlank([ - 'message' => $this->trans( - 'This field cannot be empty', 'Admin.Notifications.Error' - ), - ]), - ], - ]); - } - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/AddOrderCartRuleType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/AddOrderCartRuleType.php deleted file mode 100644 index 7a0dd80d..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/AddOrderCartRuleType.php +++ /dev/null @@ -1,131 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CleanHtml; -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShopBundle\Translation\TranslatorAwareTrait; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Validator\Constraints\Type; - -class AddOrderCartRuleType extends AbstractType -{ - use TranslatorAwareTrait; - - /** - * @var FormChoiceProviderInterface - */ - private $orderDiscountTypeChoiceProvider; - - /** - * @var ConfigurableFormChoiceProviderInterface - */ - private $orderInvoiceByIdChoiceProvider; - - /** - * @var int - */ - private $contextLangId; - - /** - * @param FormChoiceProviderInterface $orderDiscountTypeChoiceProvider - * @param ConfigurableFormChoiceProviderInterface $orderInvoiceByIdChoiceProvider - * @param int $contextLangId - * @param TranslatorInterface $translator - */ - public function __construct( - FormChoiceProviderInterface $orderDiscountTypeChoiceProvider, - ConfigurableFormChoiceProviderInterface $orderInvoiceByIdChoiceProvider, - int $contextLangId, - TranslatorInterface $translator - ) { - $this->orderDiscountTypeChoiceProvider = $orderDiscountTypeChoiceProvider; - $this->orderInvoiceByIdChoiceProvider = $orderInvoiceByIdChoiceProvider; - $this->contextLangId = $contextLangId; - $this->setTranslator($translator); - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $invoices = $options['order_id'] ? - $this->orderInvoiceByIdChoiceProvider->getChoices([ - 'id_order' => $options['order_id'], - 'id_lang' => $this->contextLangId, - 'display_total' => true, - ]) : []; - - $builder - ->add('name', TextType::class, [ - 'constraints' => [ - new CleanHtml([ - 'message' => $this->trans( - 'Cart rule name must contain clean HTML', - [], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('type', ChoiceType::class, [ - 'choices' => $this->orderDiscountTypeChoiceProvider->getChoices(), - ]) - ->add('value', TextType::class, [ - 'constraints' => new Type([ - 'type' => 'numeric', - 'message' => $this->trans('Discount value must be a number', [], 'Admin.Notifications.Error'), - ]), - ]) - ->add('invoice_id', ChoiceType::class, [ - 'choices' => $invoices, - 'required' => false, - 'placeholder' => false, - ]) - ; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver): void - { - $resolver - ->setDefaults([ - 'order_id' => null, - ]) - ->setAllowedTypes('order_id', ['int', 'null']) - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/AddProductRowType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/AddProductRowType.php deleted file mode 100644 index a61f207e..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/AddProductRowType.php +++ /dev/null @@ -1,173 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order; - -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; -use PrestaShopBundle\Form\Admin\Type\TextWithUnitType; -use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType; -use Symfony\Component\Form\Extension\Core\Type\ButtonType; -use Symfony\Component\Form\Extension\Core\Type\CheckboxType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\Extension\Core\Type\NumberType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Form type used to add a product row - */ -class AddProductRowType extends TranslatorAwareType -{ - /** - * @var ConfigurableFormChoiceProviderInterface - */ - private $orderInvoiceByIdChoiceProvider; - - /** - * @var int - */ - private $contextLangId; - - public function __construct( - TranslatorInterface $translator, - array $locales, - ConfigurableFormChoiceProviderInterface $orderInvoiceByIdChoiceProvider, - int $contextLangId - ) { - parent::__construct($translator, $locales); - - $this->orderInvoiceByIdChoiceProvider = $orderInvoiceByIdChoiceProvider; - $this->contextLangId = $contextLangId; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $invoices = $options['order_id'] ? - $this->orderInvoiceByIdChoiceProvider->getChoices([ - 'id_order' => $options['order_id'], - 'id_lang' => $this->contextLangId, - 'display_total' => false, - ]) : []; - - $builder - ->add('product_id', HiddenType::class) - ->add('tax_rate', HiddenType::class) - ->add('search', TextType::class, [ - 'label' => $this->trans('Add a product', 'Admin.Orderscustomers.Feature'), - 'attr' => [ - 'class' => 'col-sm-12', - 'autocomplete' => 'off', - 'placeholder' => $this->trans('Search for a product', 'Admin.Orderscustomers.Feature'), - 'data-currency' => $options['currency_id'], - 'data-order' => $options['order_id'], - ], - ]) - ->add('addProductCombinations', ChoiceType::class, [ - 'attr' => [ - 'class' => 'custom-select', - ], - ]) - ->add('price_tax_excluded', TextWithUnitType::class, [ - 'label' => false, - 'unit' => sprintf('%s %s', - $options['symbol'], - $this->trans('tax excl.', 'Admin.Global') - ), - ]) - ->add('price_tax_included', TextWithUnitType::class, [ - 'label' => false, - 'unit' => sprintf('%s %s', - $options['symbol'], - $this->trans('tax incl.', 'Admin.Global') - ), - ]) - ->add('quantity', NumberType::class, [ - 'label' => false, - 'data' => 1, - 'scale' => 0, - 'attr' => [ - 'min' => 1, - ], - ]) - ->add('invoice', ChoiceType::class, [ - 'label' => false, - 'disabled' => true, - 'choices' => [ - $this->trans('Existing', 'Admin.Global') => $invoices, - $this->trans('New', 'Admin.Global') => [ - $this->trans('Create a new invoice', 'Admin.Orderscustomers.Feature') => 0, - ], - ], - ]) - ->add('free_shipping', CheckboxType::class, - [ - 'required' => false, - 'label' => $this->trans('Free shipping', 'Admin.Orderscustomers.Feature', []), - 'attr' => [ - 'material_design' => true, - ], - ] - ) - ->add('cancel', ButtonType::class, [ - 'label' => $this->trans('Cancel', 'Admin.Actions'), - 'attr' => [ - 'class' => 'btn btn-sm btn-secondary js-product-add-action-btn mr-2 mt-2 mb-2', - ], - ]) - ->add('add', ButtonType::class, [ - 'label' => $this->trans('Add', 'Admin.Actions'), - 'disabled' => true, - 'attr' => [ - 'class' => 'btn btn-sm btn-primary js-product-add-action-btn mt-2 mb-2', - 'data-order-id' => $options['order_id'], - ], - ]) - ; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver): void - { - $resolver - ->setRequired(['symbol']) - ->setDefaults([ - 'order_id' => null, - 'currency_id' => null, - ]) - ->setAllowedTypes('order_id', ['int', 'null']) - ->setAllowedTypes('currency_id', ['int', 'null']) - ->setAllowedTypes('symbol', ['string']) - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/CancelProductType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/CancelProductType.php deleted file mode 100644 index f8494f9d..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/CancelProductType.php +++ /dev/null @@ -1,159 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order; - -use PrestaShop\Decimal\Number; -use PrestaShop\PrestaShop\Core\Domain\Order\VoucherRefundType; -use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType; -use Symfony\Component\Form\Extension\Core\Type\CheckboxType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\NumberType; -use Symfony\Component\Form\Extension\Core\Type\SubmitType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; - -class CancelProductType extends TranslatorAwareType -{ - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $products = $options['data']['products']; - $taxMethod = $options['data']['taxMethod']; - $precision = $options['data']['precision']; - - foreach ($products as $product) { - $builder - ->add('selected_' . $product->getOrderDetailId(), CheckboxType::class, - [ - 'required' => false, - 'label' => false, - 'attr' => [ - 'material_design' => true, - ], - ] - ) - ->add('quantity_' . $product->getOrderDetailId(), NumberType::class, [ - 'attr' => ['max' => $product->getQuantity(), 'class' => 'refund-quantity'], - 'label' => $this->trans('Quantity', 'Admin.Global', []), - 'invalid_message' => $this->trans('This field is invalid, it must contain numeric values', 'Admin.Notifications.Error', []), - 'required' => false, - 'data' => 0, - 'scale' => 0, - ]) - ->add('amount_' . $product->getOrderDetailId(), TextType::class, [ - 'attr' => ['max' => $product->getTotalPrice(), 'class' => 'refund-amount'], - 'label' => sprintf( - '%s (%s)', - $this->trans('Amount', 'Admin.Global', []), - $taxMethod - ), - 'invalid_message' => $this->trans('This field is invalid, it must contain numeric values', 'Admin.Notifications.Error', []), - 'required' => false, - 'data' => (new Number('0'))->toPrecision($precision), - ]); - } - $builder - ->add('shipping_amount', TextType::class, - [ - 'label' => $this->trans('Shipping', 'Admin.Catalog.Feature', []), - 'invalid_message' => $this->trans('The "shipping" field must be a valid number', 'Admin.Orderscustomers.Feature', []), - 'required' => false, - 'data' => (new Number('0'))->toPrecision($precision), - ] - ) - ->add('shipping', CheckboxType::class, - [ - 'label' => $this->trans('Shipping', 'Admin.Catalog.Feature', []), - 'required' => false, - 'attr' => [ - 'material_design' => true, - ], - ] - ) - ->add('restock', CheckboxType::class, - [ - 'required' => false, - 'label' => $this->trans('Re-stock products', 'Admin.Orderscustomers.Feature', []), - 'attr' => [ - 'material_design' => true, - ], - ] - ) - ->add('credit_slip', CheckboxType::class, - [ - 'required' => false, - 'label' => $this->trans('Generate a credit slip', 'Admin.Orderscustomers.Feature', []), - 'attr' => [ - 'material_design' => true, - ], - 'data' => true, - ] - ) - ->add('voucher', CheckboxType::class, - [ - 'required' => false, - 'label' => $this->trans('Generate a voucher', 'Admin.Orderscustomers.Feature', []), - 'attr' => [ - 'material_design' => true, - ], - ] - ) - ->add('voucher_refund_type', ChoiceType::class, - [ - 'required' => true, - 'multiple' => false, - 'expanded' => true, - 'choices' => [ - $this->trans('Product(s) price:', 'Admin.Orderscustomers.Feature') => VoucherRefundType::PRODUCT_PRICES_REFUND, - $this->trans('Product(s) price, excluding amount of initial voucher:', 'Admin.Orderscustomers.Feature') => VoucherRefundType::PRODUCT_PRICES_EXCLUDING_VOUCHER_REFUND, - ], - 'choice_attr' => function ($choice, $key) { - return [ - 'voucher-refund-type' => $choice, - 'data-default-label' => $key, - ]; - }, - 'data' => VoucherRefundType::PRODUCT_PRICES_EXCLUDING_VOUCHER_REFUND, - ] - ) - ->add('cancel', SubmitType::class, [ - 'label' => $this->trans('Cancel', 'Admin.Actions'), - 'attr' => [ - 'class' => 'cancel-product-element cancel-product-element-abort btn btn-outline-secondary', - ], - ]) - ->add('save', SubmitType::class, [ - 'attr' => [ - 'class' => 'cancel-product-element save btn btn-primary ml-3', - 'formnovalidate' => true, - 'data-partial-refund-label' => $this->trans('Partial refund', 'Admin.Orderscustomers.Feature'), - 'data-standard-refund-label' => $this->trans('Standard refund', 'Admin.Orderscustomers.Feature'), - 'data-return-product-label' => $this->trans('Return products', 'Admin.Orderscustomers.Feature'), - 'data-cancel-label' => $this->trans('Cancel products', 'Admin.Orderscustomers.Feature'), - ], - ]); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/CartSummaryType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/CartSummaryType.php deleted file mode 100644 index 77a120bd..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/CartSummaryType.php +++ /dev/null @@ -1,119 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\Extension\Core\Type\TextareaType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Form type for cart summary block of order create page - */ -class CartSummaryType extends AbstractType -{ - /** - * @var FormChoiceProviderInterface - */ - private $orderStatesChoiceProvider; - - /** - * @var FormChoiceProviderInterface - */ - private $paymentModulesChoiceProvider; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @param FormChoiceProviderInterface $orderStatesChoiceProvider - * @param FormChoiceProviderInterface $paymentModulesChoiceProvider - * @param TranslatorInterface $translator - */ - public function __construct( - FormChoiceProviderInterface $orderStatesChoiceProvider, - FormChoiceProviderInterface $paymentModulesChoiceProvider, - TranslatorInterface $translator - ) { - $this->orderStatesChoiceProvider = $orderStatesChoiceProvider; - $this->paymentModulesChoiceProvider = $paymentModulesChoiceProvider; - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('cart_id', HiddenType::class, [ - 'required' => false, - ]) - ->add('order_message', TextareaType::class, [ - 'required' => false, - ]) - ->add('payment_module', ChoiceType::class, [ - 'choices' => $this->getPaymentModuleChoices(), - 'required' => true, - 'placeholder' => $this->translator->trans( - '-- Choose --', - [], - 'Admin.Actions' - ), - ]) - ->add('order_state', ChoiceType::class, [ - 'choices' => $this->orderStatesChoiceProvider->getChoices(), - 'required' => true, - 'placeholder' => $this->translator->trans( - '-- Choose --', - [], - 'Admin.Actions' - ), - ]); - } - - /** - * Gets payment module choices - * - * @return array - */ - private function getPaymentModuleChoices(): array - { - $choices = []; - - foreach ($this->paymentModulesChoiceProvider->getChoices() as $name => $displayName) { - $choices[$displayName] = $name; - } - - return $choices; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/ChangeOrderAddressType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/ChangeOrderAddressType.php deleted file mode 100644 index aad5d173..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/ChangeOrderAddressType.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order; - -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Validator\Constraints\Choice; - -class ChangeOrderAddressType extends AbstractType -{ - const SHIPPING_TYPE = 'shipping'; - const INVOICE_TYPE = 'invoice'; - - /** - * @var ConfigurableFormChoiceProviderInterface - */ - private $customerAddressProvider; - - /** - * @param ConfigurableFormChoiceProviderInterface $customerAddressProvider - */ - public function __construct(ConfigurableFormChoiceProviderInterface $customerAddressProvider) - { - $this->customerAddressProvider = $customerAddressProvider; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $builder - ->add('new_address_id', ChoiceType::class, [ - 'choices' => $this->customerAddressProvider->getChoices($options), - ]) - ->add('address_type', HiddenType::class, [ - 'constraints' => [ - new Choice($this->getAvailableAddressTypes()), - ], - ] - ); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver): void - { - $resolver - ->setRequired([ - 'customer_id', - ]) - ->setAllowedTypes('customer_id', 'int'); - } - - /** - * @return array - */ - public function getAvailableAddressTypes() - { - return [ - self::SHIPPING_TYPE, - self::INVOICE_TYPE, - ]; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/ChangeOrderCurrencyType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/ChangeOrderCurrencyType.php deleted file mode 100644 index 0854a570..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/ChangeOrderCurrencyType.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -class ChangeOrderCurrencyType extends AbstractType -{ - /** - * @var FormChoiceProviderInterface - */ - private $currencyChoiceProvider; - - /** - * @param FormChoiceProviderInterface $currencyChoiceProvider - */ - public function __construct(FormChoiceProviderInterface $currencyChoiceProvider) - { - $this->currencyChoiceProvider = $currencyChoiceProvider; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $builder - ->add('new_currency_id', ChoiceType::class, [ - 'choices' => $this->getCurrencyChoices($options['current_currency_id']), - ]) - ; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver): void - { - $resolver - ->setDefaults([ - 'current_currency_id' => null, - ]) - ->setAllowedTypes('current_currency_id', ['int', 'null']) - ; - } - - /** - * @param int|null $currentCurrencyId - * - * @return array - */ - private function getCurrencyChoices(?int $currentCurrencyId): array - { - $choices = $this->currencyChoiceProvider->getChoices(); - - if (null === $currentCurrencyId) { - return $choices; - } - - $currentCurrencyKey = array_search($currentCurrencyId, $choices, true); - - if ($currentCurrencyKey) { - unset($choices[$currentCurrencyKey]); - } - - return $choices; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/ChangeOrdersStatusType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/ChangeOrdersStatusType.php deleted file mode 100644 index 501899dc..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/ChangeOrdersStatusType.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\CallbackTransformer; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\CollectionType; -use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\FormBuilderInterface; - -class ChangeOrdersStatusType extends AbstractType -{ - /** - * @var FormChoiceProviderInterface - */ - private $orderStatusChoiceProvider; - - /** - * @param FormChoiceProviderInterface $orderStatusChoiceProvider - */ - public function __construct(FormChoiceProviderInterface $orderStatusChoiceProvider) - { - $this->orderStatusChoiceProvider = $orderStatusChoiceProvider; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('new_order_status_id', ChoiceType::class, [ - 'choices' => $this->orderStatusChoiceProvider->getChoices(), - 'translation_domain' => false, - ]) - ->add('order_ids', CollectionType::class, [ - 'allow_add' => true, - 'entry_type' => HiddenType::class, - 'label' => false, - ]) - ; - - $builder->get('order_ids') - ->addModelTransformer(new CallbackTransformer( - static function ($orderIds) { - return $orderIds; - }, - static function (array $orderIds) { - return array_map(static function ($orderId) { - return (int) $orderId; - }, $orderIds); - } - )) - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/CreditSlip/CreditSlipOptionsFormDataProvider.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/CreditSlip/CreditSlipOptionsFormDataProvider.php deleted file mode 100644 index 115eb8fa..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/CreditSlip/CreditSlipOptionsFormDataProvider.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order\CreditSlip; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\Form\FormDataProviderInterface; - -/** - * Provides data for credit slip options form - */ -final class CreditSlipOptionsFormDataProvider implements FormDataProviderInterface -{ - /** - * @var DataConfigurationInterface - */ - private $creditSlipOptionsConfiguration; - - /** - * @param DataConfigurationInterface $creditSlipOptionsConfiguration - */ - public function __construct(DataConfigurationInterface $creditSlipOptionsConfiguration) - { - $this->creditSlipOptionsConfiguration = $creditSlipOptionsConfiguration; - } - - /** - * {@inheritdoc} - */ - public function getData() - { - return [ - 'options' => $this->creditSlipOptionsConfiguration->getConfiguration(), - ]; - } - - /** - * {@inheritdoc} - */ - public function setData(array $data) - { - return $this->creditSlipOptionsConfiguration->updateConfiguration($data['options']); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/CreditSlip/CreditSlipOptionsType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/CreditSlip/CreditSlipOptionsType.php deleted file mode 100644 index d37fac45..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/CreditSlip/CreditSlipOptionsType.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order\CreditSlip; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\TypedRegex; -use PrestaShopBundle\Form\Admin\Type\CommonAbstractType; -use PrestaShopBundle\Form\Admin\Type\TranslatableType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Defines credit slips options form - */ -final class CreditSlipOptionsType extends CommonAbstractType -{ - /** - * @var TranslatorInterface - */ - private $translator; - - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('slip_prefix', TranslatableType::class, [ - 'required' => false, - 'error_bubbling' => true, - 'options' => [ - 'constraints' => [ - new TypedRegex([ - 'type' => 'file_name', - 'message' => $this->translator->trans( - '%s is invalid.', - [], - 'Admin.Notifications.Error' - ), - ]), - ], - ], - ]); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/CreditSlip/GeneratePdfByDateType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/CreditSlip/GeneratePdfByDateType.php deleted file mode 100644 index fd5a4675..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/CreditSlip/GeneratePdfByDateType.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order\CreditSlip; - -use PrestaShopBundle\Form\Admin\Type\CommonAbstractType; -use PrestaShopBundle\Form\Admin\Type\DatePickerType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Validator\Constraints\DateTime; -use Symfony\Component\Validator\Constraints\NotBlank; -use Symfony\Component\Validator\Constraints\Valid; - -/** - * Defines form for generating Credit slip PDF - */ -final class GeneratePdfByDateType extends CommonAbstractType -{ - /** - * @var TranslatorInterface - */ - private $translator; - - public function __construct(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $dateFormat = 'Y-m-d'; - $nowDate = (new \DateTime())->format($dateFormat); - - $blankMessage = $this->translator->trans('This field is required', [], 'Admin.Notifications.Error'); - $invalidDateMessage = $this->translator->trans('Invalid date format.', [], 'Admin.Notifications.Error'); - - $builder - ->add('from', DatePickerType::class, [ - 'data' => $nowDate, - 'constraints' => [ - new NotBlank([ - 'message' => $blankMessage, - ]), - new DateTime([ - 'format' => $dateFormat, - 'message' => $invalidDateMessage, - ]), - ], - ]) - ->add('to', DatePickerType::class, [ - 'data' => $nowDate, - 'constraints' => [ - new NotBlank([ - 'message' => $blankMessage, - ]), - new DateTime([ - 'format' => $dateFormat, - 'message' => $invalidDateMessage, - ]), - ], - ]); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'constraints' => [ - new Valid(), - ], - ]); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/Delivery/SlipOptionsFormDataProvider.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/Delivery/SlipOptionsFormDataProvider.php deleted file mode 100644 index 7a351989..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/Delivery/SlipOptionsFormDataProvider.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order\Delivery; - -use PrestaShop\PrestaShop\Adapter\Order\Delivery\SlipOptionsConfiguration; -use PrestaShop\PrestaShop\Core\Form\FormDataProviderInterface; - -/** - * This class is responsible of managing the data manipulated options form - * in "Sells > Orders > Delivery Slips" page. - */ -final class SlipOptionsFormDataProvider implements FormDataProviderInterface -{ - /** - * @var SlipOptionsConfiguration - */ - private $configuration; - - public function __construct(SlipOptionsConfiguration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getData() - { - return [ - 'options' => $this->configuration->getConfiguration(), - ]; - } - - /** - * {@inheritdoc} - */ - public function setData(array $data) - { - return $this->configuration->updateConfiguration($data['options']); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/Delivery/SlipOptionsType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/Delivery/SlipOptionsType.php deleted file mode 100644 index d0f0c98f..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/Delivery/SlipOptionsType.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order\Delivery; - -use PrestaShopBundle\Form\Admin\Type\SwitchType; -use PrestaShopBundle\Form\Admin\Type\TranslatableType; -use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType; -use Symfony\Component\Form\Extension\Core\Type as FormType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; - -/** - * This form class generates the "Options" form in Delivery slips page. - */ -class SlipOptionsType extends TranslatorAwareType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add( - 'prefix', - TranslatableType::class, - [ - 'type' => TextType::class, - ] - ) - ->add( - 'number', - FormType\NumberType::class - ) - ->add( - 'enable_product_image', - SwitchType::class - ); - } - - /** - * {@inheritdoc} - */ - public function getBlockPrefix() - { - return 'order_delivery_slip_options'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/Delivery/SlipPdfFormDataProvider.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/Delivery/SlipPdfFormDataProvider.php deleted file mode 100644 index 8661900f..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/Delivery/SlipPdfFormDataProvider.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order\Delivery; - -use PrestaShop\PrestaShop\Adapter\Order\Delivery\SlipPdfConfiguration; -use PrestaShop\PrestaShop\Core\Form\FormDataProviderInterface; - -/** - * This class is responsible of managing the data manipulated pdf form - * in "Sells > Orders > Delivery Slips" page. - */ -final class SlipPdfFormDataProvider implements FormDataProviderInterface -{ - /** - * @var SlipPdfConfiguration - */ - private $configuration; - - public function __construct(SlipPdfConfiguration $configuration) - { - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getData() - { - return []; - } - - /** - * {@inheritdoc} - */ - public function setData(array $data) - { - return $this->configuration->updateConfiguration($data['pdf']); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/Delivery/SlipPdfType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/Delivery/SlipPdfType.php deleted file mode 100644 index 2f5684fe..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/Delivery/SlipPdfType.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order\Delivery; - -use DateTime; -use PrestaShopBundle\Form\Admin\Type\CommonAbstractType; -use PrestaShopBundle\Form\Admin\Type\DatePickerType; -use Symfony\Component\Form\FormBuilderInterface; - -/** - * This form class generates the "Pdf" form in Delivery slips page. - */ -class SlipPdfType extends CommonAbstractType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $now = (new DateTime())->format('Y-m-d'); - $builder - ->add( - 'date_from', - DatePickerType::class, - [ - 'required' => false, - 'attr' => ['placeholder' => 'YYYY-MM-DD'], - 'data' => $now, - 'empty_data' => $now, - ] - ) - ->add( - 'date_to', - DatePickerType::class, - [ - 'required' => false, - 'attr' => ['placeholder' => 'YYYY-MM-DD'], - 'data' => $now, - 'empty_data' => $now, - ] - ); - } - - /** - * {@inheritdoc} - */ - public function getBlockPrefix() - { - return 'order_delivery_slip_options'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/EditProductRowType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/EditProductRowType.php deleted file mode 100644 index b6d124ca..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/EditProductRowType.php +++ /dev/null @@ -1,152 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order; - -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; -use PrestaShopBundle\Form\Admin\Type\TextWithUnitType; -use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType; -use Symfony\Component\Form\Extension\Core\Type\ButtonType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\NumberType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Translation\TranslatorInterface; - -class EditProductRowType extends TranslatorAwareType -{ - /** - * @var ConfigurableFormChoiceProviderInterface - */ - private $orderInvoiceByIdChoiceProvider; - - /** - * @var int - */ - private $contextLangId; - - /** - * EditProductRowType constructor. - * - * @param TranslatorInterface $translator - * @param array $locales - * @param ConfigurableFormChoiceProviderInterface $orderInvoiceByIdChoiceProvider - * @param int $contextLangId - */ - public function __construct( - TranslatorInterface $translator, - array $locales, - ConfigurableFormChoiceProviderInterface $orderInvoiceByIdChoiceProvider, - int $contextLangId - ) { - parent::__construct($translator, $locales); - - $this->orderInvoiceByIdChoiceProvider = $orderInvoiceByIdChoiceProvider; - $this->contextLangId = $contextLangId; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $invoices = $options['order_id'] ? - $this->orderInvoiceByIdChoiceProvider->getChoices([ - 'id_order' => $options['order_id'], - 'id_lang' => $this->contextLangId, - 'display_total' => false, - ]) : []; - - $builder - ->add('price_tax_excluded', TextWithUnitType::class, [ - 'label' => false, - 'unit' => sprintf('%s %s', - $options['symbol'], - $this->trans('tax excl.', 'Admin.Global') - ), - 'attr' => [ - 'class' => 'editProductPriceTaxExcl', - ], - ]) - ->add('price_tax_included', TextWithUnitType::class, [ - 'label' => false, - 'unit' => sprintf('%s %s', - $options['symbol'], - $this->trans('tax incl.', 'Admin.Global') - ), - 'attr' => [ - 'class' => 'editProductPriceTaxIncl', - ], - ]) - ->add('quantity', NumberType::class, [ - 'label' => false, - 'data' => 1, - 'scale' => 0, - 'attr' => [ - 'min' => 1, - 'class' => 'editProductQuantity', - ], - ]) - ->add('invoice', ChoiceType::class, [ - 'choices' => $invoices, - 'label' => false, - 'attr' => [ - 'class' => 'editProductInvoice custom-select', - ], - ]) - ->add('cancel', ButtonType::class, [ - 'label' => $this->trans('Cancel', 'Admin.Actions'), - 'attr' => [ - 'class' => 'btn btn-sm btn-secondary js-product-edit-action-btn mr-2 mt-2 mb-2 productEditCancelBtn', - ], - ]) - ->add('save', ButtonType::class, [ - 'label' => $this->trans('Save', 'Admin.Actions'), - 'disabled' => true, - 'attr' => [ - 'class' => 'btn btn-sm btn-primary js-product-edit-action-btn mt-2 mb-2 productEditSaveBtn', - 'data-order-id' => $options['order_id'], - 'data-update-message' => $this->trans('Are you sure?', 'Admin.Notifications.Warning'), - ], - ]) - ; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver): void - { - $resolver - ->setRequired(['symbol']) - ->setDefaults([ - 'order_id' => null, - ]) - ->setAllowedTypes('order_id', ['int', 'null']) - ->setAllowedTypes('symbol', ['string']) - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/GenerateByDateType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/GenerateByDateType.php deleted file mode 100644 index 3dc3d757..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/GenerateByDateType.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order\Invoices; - -use PrestaShopBundle\Form\Admin\Type\CommonAbstractType; -use PrestaShopBundle\Form\Admin\Type\DatePickerType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class generates "By Date" form - * in "Sell > Orders > Invoices" page. - */ -class GenerateByDateType extends CommonAbstractType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('date_from', DatePickerType::class) - ->add('date_to', DatePickerType::class); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'translation_domain' => 'Admin.Orderscustomers.Feature', - ]); - } - - /** - * {@inheritdoc} - */ - public function getBlockPrefix() - { - return 'orders_invoices_by_date_block'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/GenerateByStatusType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/GenerateByStatusType.php deleted file mode 100644 index 785e10dd..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/GenerateByStatusType.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order\Invoices; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShopBundle\Form\Admin\Type\CommonAbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class generates "By order status" form - * in "Sell > Orders > Invoices" page. - */ -class GenerateByStatusType extends CommonAbstractType -{ - /** - * @var array - */ - private $orderCountsByState; - /** - * @var FormChoiceProviderInterface - */ - private $orderStateChoiceProvider; - - /** - * @param FormChoiceProviderInterface $orderStateChoiceProvider - * @param array $orderCountsByState - */ - public function __construct(FormChoiceProviderInterface $orderStateChoiceProvider, array $orderCountsByState) - { - $this->orderCountsByState = $orderCountsByState; - $this->orderStateChoiceProvider = $orderStateChoiceProvider; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('order_states', ChoiceType::class, [ - 'expanded' => true, - 'multiple' => true, - 'choices' => $this->orderStateChoiceProvider->getChoices(), - ]); - } - - /** - * {@inheritdoc} - */ - public function finishView(FormView $view, FormInterface $form, array $options) - { - /** @var FormView $child */ - foreach ($view->children['order_states'] as $child) { - $child->vars['orders_count'] = 0; - - if (array_key_exists($child->vars['value'], $this->orderCountsByState)) { - $child->vars['orders_count'] = $this->orderCountsByState[$child->vars['value']]; - } - } - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'translation_domain' => 'Admin.Orderscustomers.Feature', - ]); - } - - /** - * {@inheritdoc} - */ - public function getBlockPrefix() - { - return 'orders_invoices_by_status_block'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoiceByDateFormHandler.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoiceByDateFormHandler.php deleted file mode 100644 index 8a2d77a6..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoiceByDateFormHandler.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order\Invoices; - -use DateTime; -use PrestaShop\PrestaShop\Core\Form\FormDataProviderInterface; -use PrestaShop\PrestaShop\Core\Form\FormHandler; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShop\PrestaShop\Core\Order\OrderInvoiceDataProviderInterface; -use PrestaShop\PrestaShop\Core\PDF\PDFGeneratorInterface; -use Symfony\Component\Form\FormBuilderInterface; - -/** - * Class InvoiceByDateFormHandler manages the data manipulated using "By date" form - * in "Sell > Orders > Invoices" page. - */ -final class InvoiceByDateFormHandler extends FormHandler -{ - /** - * @var OrderInvoiceDataProviderInterface - */ - private $orderInvoiceDataProvider; - - /** - * @var PDFGeneratorInterface - */ - private $pdfGenerator; - - /** - * @param FormBuilderInterface $formBuilder - * @param HookDispatcherInterface $hookDispatcher - * @param FormDataProviderInterface $formDataProvider - * @param array $formTypes - * @param string $hookName - * @param OrderInvoiceDataProviderInterface $orderInvoiceDataProvider - * @param PDFGeneratorInterface $pdfGenerator - */ - public function __construct( - FormBuilderInterface $formBuilder, - HookDispatcherInterface $hookDispatcher, - FormDataProviderInterface $formDataProvider, - array $formTypes, - $hookName, - OrderInvoiceDataProviderInterface $orderInvoiceDataProvider, - PDFGeneratorInterface $pdfGenerator - ) { - parent::__construct($formBuilder, $hookDispatcher, $formDataProvider, $formTypes, $hookName); - $this->orderInvoiceDataProvider = $orderInvoiceDataProvider; - $this->pdfGenerator = $pdfGenerator; - } - - /** - * {@inheritdoc} - */ - public function save(array $data) - { - if ($errors = parent::save($data)) { - return $errors; - } - - // Get invoices by submitted date interval - $invoiceCollection = $this->orderInvoiceDataProvider->getByDateInterval( - new DateTime($data['generate_by_date']['date_from']), - new DateTime($data['generate_by_date']['date_to']) - ); - - // Generate PDF out of found invoices - $this->pdfGenerator->generatePDF($invoiceCollection); - - return []; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoiceByStatusFormHandler.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoiceByStatusFormHandler.php deleted file mode 100644 index 89ff1a0b..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoiceByStatusFormHandler.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order\Invoices; - -use PrestaShop\PrestaShop\Core\Form\FormDataProviderInterface; -use PrestaShop\PrestaShop\Core\Form\FormHandler; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; -use PrestaShop\PrestaShop\Core\Order\OrderInvoiceDataProviderInterface; -use PrestaShop\PrestaShop\Core\PDF\PDFGeneratorInterface; -use Symfony\Component\Form\FormBuilderInterface; - -/** - * Class InvoiceByStatusFormHandler manages the data manipulated using "By status" form - * in "Sell > Orders > Invoices" page. - */ -final class InvoiceByStatusFormHandler extends FormHandler -{ - /** - * @var OrderInvoiceDataProviderInterface - */ - private $orderInvoiceDataProvider; - - /** - * @var PDFGeneratorInterface - */ - private $pdfGenerator; - - /** - * @param FormBuilderInterface $formBuilder - * @param HookDispatcherInterface $hookDispatcher - * @param FormDataProviderInterface $formDataProvider - * @param array $formTypes - * @param string $hookName - * @param OrderInvoiceDataProviderInterface $orderInvoiceDataProvider - * @param PDFGeneratorInterface $pdfGenerator - */ - public function __construct( - FormBuilderInterface $formBuilder, - HookDispatcherInterface $hookDispatcher, - FormDataProviderInterface $formDataProvider, - array $formTypes, - $hookName, - OrderInvoiceDataProviderInterface $orderInvoiceDataProvider, - PDFGeneratorInterface $pdfGenerator - ) { - parent::__construct($formBuilder, $hookDispatcher, $formDataProvider, $formTypes, $hookName); - $this->orderInvoiceDataProvider = $orderInvoiceDataProvider; - $this->pdfGenerator = $pdfGenerator; - } - - /** - * {@inheritdoc} - */ - public function save(array $data) - { - if ($errors = parent::save($data)) { - return $errors; - } - - $invoiceCollection = []; - - foreach ($data['generate_by_status']['order_states'] as $orderStateId) { - // Put invoices for each selected status into one collection - $invoiceCollection = array_merge( - $invoiceCollection, - $this->orderInvoiceDataProvider->getByStatus($orderStateId) - ); - } - - if (empty($invoiceCollection)) { - $errors[] = [ - 'key' => 'No invoice has been found for this status.', - 'domain' => 'Admin.Orderscustomers.Notification', - 'parameters' => [], - ]; - } else { - // Generate PDF out of found invoices - $this->pdfGenerator->generatePDF($invoiceCollection); - } - - return $errors; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoiceOptionsDataProvider.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoiceOptionsDataProvider.php deleted file mode 100644 index 34b7a15b..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoiceOptionsDataProvider.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order\Invoices; - -use PrestaShop\PrestaShop\Core\Configuration\DataConfigurationInterface; -use PrestaShop\PrestaShop\Core\Form\FormDataProviderInterface; - -/** - * Class is responsible of managing the data manipulated using invoice options form - * in "Sell > Orders > Invoices" page. - */ -final class InvoiceOptionsDataProvider implements FormDataProviderInterface -{ - /** - * @var DataConfigurationInterface - */ - private $invoiceOptionsConfiguration; - - /** - * @var int - */ - private $nextInvoiceNumber; - - /** - * @param DataConfigurationInterface $invoiceOptionsConfiguration - * @param int $nextInvoiceNumber next available invoice number - */ - public function __construct( - DataConfigurationInterface $invoiceOptionsConfiguration, - $nextInvoiceNumber - ) { - $this->invoiceOptionsConfiguration = $invoiceOptionsConfiguration; - $this->nextInvoiceNumber = $nextInvoiceNumber; - } - - /** - * {@inheritdoc} - */ - public function getData() - { - return [ - 'invoice_options' => $this->invoiceOptionsConfiguration->getConfiguration(), - ]; - } - - /** - * {@inheritdoc} - */ - public function setData(array $data) - { - if ($errors = $this->validate($data)) { - return $errors; - } - - return $this->invoiceOptionsConfiguration->updateConfiguration($data['invoice_options']); - } - - /** - * Perform validations on form data. - * - * @param array $data - * - * @return array Array of errors if any - */ - private function validate(array $data) - { - $errors = []; - $invoiceNumber = $data['invoice_options']['invoice_number']; - - if ($invoiceNumber > 0 && $invoiceNumber <= $this->nextInvoiceNumber) { - $errors[] = [ - 'key' => 'Invalid invoice number.', - 'domain' => 'Admin.Orderscustomers.Notification', - 'parameters' => [], - ]; - } - - return $errors; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoiceOptionsType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoiceOptionsType.php deleted file mode 100644 index 7e0b2454..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoiceOptionsType.php +++ /dev/null @@ -1,130 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order\Invoices; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShopBundle\Form\Admin\Type\SwitchType; -use PrestaShopBundle\Form\Admin\Type\TranslatableType; -use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\NumberType; -use Symfony\Component\Form\Extension\Core\Type\TextareaType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Class InvoiceOptionsType generates "Invoice options" form - * in "Sell > Orders > Invoices" page. - */ -class InvoiceOptionsType extends TranslatorAwareType -{ - /** - * @var FormChoiceProviderInterface - */ - private $invoiceModelChoiceProvider; - - /** - * @var int the next available invoice number - */ - private $nextInvoiceNumber; - - /** - * @param TranslatorInterface $translator - * @param array $locales - * @param FormChoiceProviderInterface $invoiceModelChoiceProvider - * @param int $nextInvoiceNumber the next available invoice number - */ - public function __construct( - TranslatorInterface $translator, - array $locales, - FormChoiceProviderInterface $invoiceModelChoiceProvider, - $nextInvoiceNumber - ) { - parent::__construct($translator, $locales); - $this->invoiceModelChoiceProvider = $invoiceModelChoiceProvider; - $this->nextInvoiceNumber = $nextInvoiceNumber; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('enable_invoices', SwitchType::class) - ->add('enable_tax_breakdown', SwitchType::class) - ->add('enable_product_images', SwitchType::class) - ->add('invoice_prefix', TranslatableType::class, [ - 'type' => TextType::class, - ]) - ->add('add_current_year', SwitchType::class) - ->add('reset_number_annually', SwitchType::class) - ->add('year_position', ChoiceType::class, [ - 'choices' => [ - $this->trans('After the sequential number', 'Admin.Orderscustomers.Feature') => 0, - $this->trans('Before the sequential number', 'Admin.Orderscustomers.Feature') => 1, - ], - 'expanded' => true, - ]) - ->add('invoice_number', NumberType::class, [ - 'required' => false, - ]) - ->add('legal_free_text', TranslatableType::class, [ - 'type' => TextareaType::class, - ]) - ->add('footer_text', TranslatableType::class, [ - 'type' => TextType::class, - ]) - ->add('invoice_model', ChoiceType::class, [ - 'choices' => $this->invoiceModelChoiceProvider->getChoices(), - 'translation_domain' => false, - ]) - ->add('use_disk_cache', SwitchType::class); - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['next_invoice_number'] = $this->nextInvoiceNumber; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'translation_domain' => 'Admin.Orderscustomers.Feature', - ]); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoicesByDateDataProvider.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoicesByDateDataProvider.php deleted file mode 100644 index 7155bbb6..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoicesByDateDataProvider.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order\Invoices; - -use DateTime; -use PrestaShop\PrestaShop\Core\Form\FormDataProviderInterface; -use PrestaShop\PrestaShop\Core\Order\OrderInvoiceDataProviderInterface; - -/** - * Class is responsible of managing the data manipulated using invoice generation by date form - * in "Sell > Orders > Invoices" page. - */ -final class InvoicesByDateDataProvider implements FormDataProviderInterface -{ - /** - * @var OrderInvoiceDataProviderInterface - */ - private $orderInvoiceDataProvider; - - public function __construct(OrderInvoiceDataProviderInterface $orderInvoiceDataProvider) - { - $this->orderInvoiceDataProvider = $orderInvoiceDataProvider; - } - - /** - * {@inheritdoc} - */ - public function getData() - { - $date = (new DateTime())->format('Y-m-d'); - - return [ - 'generate_by_date' => [ - 'date_from' => $date, - 'date_to' => $date, - ], - ]; - } - - /** - * {@inheritdoc} - */ - public function setData(array $data) - { - // This form doesn't need to save any data, so it only validates the data - return $this->validate($data); - } - - /** - * Perform validations on form data. - * - * @param array $data - * - * @return array Array of errors if any - */ - private function validate(array $data) - { - $errors = []; - - $dateFrom = date_create($data['generate_by_date']['date_from']); - $dateTo = date_create($data['generate_by_date']['date_to']); - - if (false === $dateFrom) { - $errors[] = [ - 'key' => 'Invalid "From" date', - 'domain' => 'Admin.Orderscustomers.Notification', - 'parameters' => [], - ]; - } - - if (false === $dateTo) { - $errors[] = [ - 'key' => 'Invalid "To" date', - 'domain' => 'Admin.Orderscustomers.Notification', - 'parameters' => [], - ]; - } - - if (empty($errors) && !$this->orderInvoiceDataProvider->getByDateInterval($dateFrom, $dateTo)) { - $errors[] = [ - 'key' => 'No invoice has been found for this period.', - 'domain' => 'Admin.Orderscustomers.Notification', - 'parameters' => [], - ]; - } - - return $errors; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoicesByStatusDataProvider.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoicesByStatusDataProvider.php deleted file mode 100644 index d0101cba..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/Invoices/InvoicesByStatusDataProvider.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order\Invoices; - -use PrestaShop\PrestaShop\Core\Form\FormDataProviderInterface; - -/** - * Class is responsible of managing the data manipulated using invoice generation by order status form - * in "Sell > Orders > Invoices" page. - */ -final class InvoicesByStatusDataProvider implements FormDataProviderInterface -{ - /** - * {@inheritdoc} - */ - public function getData() - { - return []; - } - - /** - * {@inheritdoc} - */ - public function setData(array $data) - { - // This form doesn't need to save any data, so it only validates the data - return $this->validate($data); - } - - /** - * Perform validations on form data. - * - * @param array $data - * - * @return array Array of errors if any - */ - private function validate(array $data) - { - $errors = []; - $orderStates = $data['generate_by_status']['order_states']; - - if (!is_array($orderStates) || !count($orderStates)) { - $errors[] = [ - 'key' => 'You must select at least one order status.', - 'domain' => 'Admin.Orderscustomers.Notification', - 'parameters' => [], - ]; - } - - return $errors; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/OrderMessageType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/OrderMessageType.php deleted file mode 100644 index 9d449767..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/OrderMessageType.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CleanHtml; -use PrestaShop\PrestaShop\Core\Domain\OrderMessage\OrderMessageConstraint; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShopBundle\Form\Admin\Type\TextWithLengthCounterType; -use PrestaShopBundle\Translation\TranslatorAwareTrait; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\CheckboxType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\Validator\Constraints\Length; -use Symfony\Component\Validator\Constraints\NotBlank; - -/** - * Helps to render messages block in orders view page. - */ -class OrderMessageType extends AbstractType -{ - use TranslatorAwareTrait; - - /** - * @var FormChoiceProviderInterface - */ - private $orderMessageNameChoiceProvider; - - /** - * @var FormChoiceProviderInterface - */ - private $orderMessageChoiceProvider; - - public function __construct( - FormChoiceProviderInterface $orderMessageNameChoiceProvider, - FormChoiceProviderInterface $orderMessageChoiceProvider - ) { - $this->orderMessageNameChoiceProvider = $orderMessageNameChoiceProvider; - $this->orderMessageChoiceProvider = $orderMessageChoiceProvider; - } - - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('order_message', ChoiceType::class, [ - 'choices' => $this->orderMessageNameChoiceProvider->getChoices(), - 'required' => false, - ]) - ->add('is_displayed_to_customer', CheckboxType::class, [ - 'required' => false, - 'label' => $this->trans('Display to customer?', [], 'Admin.Orderscustomers.Feature'), - ]) - ->add('message', TextWithLengthCounterType::class, [ - 'input' => 'textarea', - 'max_length' => OrderMessageConstraint::MAX_MESSAGE_LENGTH, - 'position' => 'after', - 'constraints' => [ - new NotBlank([ - 'message' => $this->trans( - 'This field cannot be empty', [], 'Admin.Notifications.Error' - ), - ]), - new CleanHtml([ - 'message' => $this->trans( - 'The %s field is not valid', - [ - sprintf('"%s"', $this->trans('Message', [], 'Admin.Global')), - ], - 'Admin.Notifications.Error' - ), - ] - ), - new Length([ - 'max' => OrderMessageConstraint::MAX_MESSAGE_LENGTH, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => OrderMessageConstraint::MAX_MESSAGE_LENGTH], - 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ; - } - - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['messages'] = $this->orderMessageChoiceProvider->getChoices(); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/OrderPaymentType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/OrderPaymentType.php deleted file mode 100644 index 729a8451..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/OrderPaymentType.php +++ /dev/null @@ -1,146 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order; - -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use PrestaShopBundle\Form\Admin\Type\DatePickerType; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Validator\Constraints\GreaterThan; - -class OrderPaymentType extends AbstractType -{ - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var ConfigurableFormChoiceProviderInterface - */ - private $currencySymbolByIdChoiceProvider; - - /** - * @var ConfigurableFormChoiceProviderInterface - */ - private $orderInvoiceChoiceProvider; - - /** - * @var int - */ - private $contextLanguageId; - - /** - * @var int - */ - private $contextShopId; - - /** - * @var FormChoiceProviderInterface - */ - private $installedPaymentModulesChoiceProvider; - - /** - * @param ConfigurableFormChoiceProviderInterface $currencySymbolByIdChoiceProvider - * @param ConfigurableFormChoiceProviderInterface $orderInvoiceChoiceProvider - * @param FormChoiceProviderInterface $installedPaymentModulesChoiceProvider - * @param int $contextLanguageId - * @param int $contextShopId - */ - public function __construct( - TranslatorInterface $translator, - ConfigurableFormChoiceProviderInterface $currencySymbolByIdChoiceProvider, - ConfigurableFormChoiceProviderInterface $orderInvoiceChoiceProvider, - FormChoiceProviderInterface $installedPaymentModulesChoiceProvider, - int $contextLanguageId, - int $contextShopId - ) { - $this->translator = $translator; - $this->currencySymbolByIdChoiceProvider = $currencySymbolByIdChoiceProvider; - $this->orderInvoiceChoiceProvider = $orderInvoiceChoiceProvider; - $this->contextLanguageId = $contextLanguageId; - $this->contextShopId = $contextShopId; - $this->installedPaymentModulesChoiceProvider = $installedPaymentModulesChoiceProvider; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $builder - ->add('date', DatePickerType::class, [ - 'date_format' => 'YYYY-MM-DD H:m:s', - ]) - ->add('payment_method', TextType::class, [ - 'data_list' => $this->installedPaymentModulesChoiceProvider->getChoices(), - ]) - ->add('transaction_id', TextType::class, [ - 'required' => false, - ]) - ->add('amount', TextType::class, [ - 'constraints' => [ - new GreaterThan([ - 'value' => 0, - 'message' => $this->translator->trans( - 'Invalid value: the payment must be a positive amount.', [], 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('id_currency', ChoiceType::class, [ - 'choices' => $this->currencySymbolByIdChoiceProvider->getChoices([ - 'id_shop' => $this->contextShopId, - ]), - ]) - ->add('id_invoice', ChoiceType::class, [ - 'choices' => $this->orderInvoiceChoiceProvider->getChoices([ - 'id_order' => $options['id_order'], - 'id_lang' => $this->contextLanguageId, - ]), - ]) - ; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver): void - { - $resolver - ->setRequired([ - 'id_order', - ]) - ->setAllowedTypes('id_order', 'int') - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/UpdateOrderShippingType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/UpdateOrderShippingType.php deleted file mode 100644 index 3d8a1517..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/UpdateOrderShippingType.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order; - -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -class UpdateOrderShippingType extends AbstractType -{ - /** - * @var ConfigurableFormChoiceProviderInterface - */ - private $carrierForOrderChoiceProvider; - - /** - * @param ConfigurableFormChoiceProviderInterface $carrierForOrderChoiceProvider - */ - public function __construct(ConfigurableFormChoiceProviderInterface $carrierForOrderChoiceProvider) - { - $this->carrierForOrderChoiceProvider = $carrierForOrderChoiceProvider; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options): void - { - $builder - ->add('new_carrier_id', ChoiceType::class, [ - 'choices' => $this->carrierForOrderChoiceProvider->getChoices([ - 'order_id' => $options['order_id'], - ]), - ]) - ->add('current_order_carrier_id', HiddenType::class) - ->add('tracking_number', TextType::class, [ - 'required' => false, - ]) - ; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver): void - { - $resolver - ->setRequired([ - 'order_id', - ]) - ->setAllowedTypes('order_id', 'int') - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Order/UpdateOrderStatusType.php b/src/PrestaShopBundle/Form/Admin/Sell/Order/UpdateOrderStatusType.php deleted file mode 100644 index 481224f3..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Order/UpdateOrderStatusType.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Order; - -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\FormBuilderInterface; - -class UpdateOrderStatusType extends AbstractType -{ - /** - * @var ConfigurableFormChoiceProviderInterface - */ - private $statusChoiceProvider; - - /** - * @var array - */ - private $statusChoiceAttributes; - - /** - * @param ConfigurableFormChoiceProviderInterface $statusChoices - * @param array $statusChoiceAttributes - */ - public function __construct( - ConfigurableFormChoiceProviderInterface $statusChoiceProvider, - array $statusChoiceAttributes - ) { - $this->statusChoiceProvider = $statusChoiceProvider; - $this->statusChoiceAttributes = $statusChoiceAttributes; - } - - public function buildForm(FormBuilderInterface $builder, array $options) - { - $choiceProviderParams = []; - if (!empty($options['data']['new_order_status_id'])) { - $choiceProviderParams = ['current_state' => $options['data']['new_order_status_id']]; - } - $builder - ->add('new_order_status_id', ChoiceType::class, [ - 'required' => false, - 'placeholder' => false, - 'choices' => $this->statusChoiceProvider->getChoices($choiceProviderParams), - 'choice_attr' => $this->statusChoiceAttributes, - 'translation_domain' => false, - ]) - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Supplier/SupplierType.php b/src/PrestaShopBundle/Form/Admin/Sell/Supplier/SupplierType.php deleted file mode 100644 index 10e5ff41..00000000 --- a/src/PrestaShopBundle/Form/Admin/Sell/Supplier/SupplierType.php +++ /dev/null @@ -1,376 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Sell\Supplier; - -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\AddressDniRequired; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\AddressStateRequired; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\CleanHtml; -use PrestaShop\PrestaShop\Core\ConstraintValidator\Constraints\TypedRegex; -use PrestaShop\PrestaShop\Core\Domain\Address\AddressSettings; -use PrestaShop\PrestaShop\Core\Domain\Supplier\SupplierSettings; -use PrestaShop\PrestaShop\Core\Form\ConfigurableFormChoiceProviderInterface; -use PrestaShopBundle\Form\Admin\Type\CountryChoiceType; -use PrestaShopBundle\Form\Admin\Type\FormattedTextareaType; -use PrestaShopBundle\Form\Admin\Type\ShopChoiceTreeType; -use PrestaShopBundle\Form\Admin\Type\SwitchType; -use PrestaShopBundle\Form\Admin\Type\TranslatableType; -use PrestaShopBundle\Form\Admin\Type\TranslateType; -use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\FileType; -use Symfony\Component\Form\Extension\Core\Type\TextareaType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Translation\TranslatorInterface; -use Symfony\Component\Validator\Constraints\Length; -use Symfony\Component\Validator\Constraints\NotBlank; - -/** - * Defines form for supplier create/edit actions (Sell > Catalog > Brands & Suppliers > Supplier) - */ -class SupplierType extends TranslatorAwareType -{ - /** - * @var array - */ - private $countryChoices; - - /** - * @var array - */ - private $countryChoicesAttributes; - - /** - * @var ConfigurableFormChoiceProviderInterface - */ - private $statesChoiceProvider; - - /** - * @var int - */ - private $contextCountryId; - - /** - * @var bool - */ - private $isMultistoreEnabled; - - /** - * @param array $countryChoices - * @param ConfigurableFormChoiceProviderInterface $statesChoiceProvider - * @param $contextCountryId - * @param TranslatorInterface $translator - * @param $isMultistoreEnabled - * @param array $locales - */ - public function __construct( - array $countryChoices, - array $countryChoicesAttributes, - ConfigurableFormChoiceProviderInterface $statesChoiceProvider, - $contextCountryId, - TranslatorInterface $translator, - $isMultistoreEnabled, - array $locales = [] - ) { - parent::__construct($translator, $locales); - - $this->countryChoices = $countryChoices; - $this->countryChoicesAttributes = $countryChoicesAttributes; - $this->statesChoiceProvider = $statesChoiceProvider; - $this->contextCountryId = $contextCountryId; - $this->isMultistoreEnabled = $isMultistoreEnabled; - } - - public function buildForm(FormBuilderInterface $builder, array $options) - { - $data = $builder->getData(); - $countryId = 0 !== $data['id_country'] ? $data['id_country'] : $this->contextCountryId; - $stateChoices = $this->statesChoiceProvider->getChoices(['id_country' => $countryId]); - - $builder - ->add('name', TextType::class, [ - 'empty_data' => '', - 'constraints' => [ - new NotBlank([ - 'message' => $this->trans( - 'This field cannot be empty', 'Admin.Notifications.Error' - ), - ]), - new Length([ - 'max' => SupplierSettings::MAX_NAME_LENGTH, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - 'Admin.Notifications.Error', - ['%limit%' => SupplierSettings::MAX_NAME_LENGTH] - ), - ]), - new TypedRegex([ - 'type' => TypedRegex::TYPE_CATALOG_NAME, - ]), - ], - ]) - ->add('description', TranslateType::class, [ - 'required' => false, - 'type' => FormattedTextareaType::class, - 'locales' => $this->locales, - 'hideTabs' => false, - 'options' => [ - 'constraints' => [ - new CleanHtml([ - 'message' => $this->trans( - '%s is invalid.', - 'Admin.Notifications.Error' - ), - ]), - ], - ], - ]) - ->add('phone', TextType::class, [ - 'empty_data' => '', - 'required' => false, - 'constraints' => $this->getPhoneCommonConstraints(), - ]) - ->add('mobile_phone', TextType::class, [ - 'empty_data' => '', - 'required' => false, - 'constraints' => $this->getPhoneCommonConstraints(), - ]) - ->add('address', TextType::class, [ - 'empty_data' => '', - 'constraints' => $this->getAddressCommonConstraints(), - ]) - ->add('address2', TextType::class, [ - 'empty_data' => '', - 'required' => false, - 'constraints' => $this->getAddressCommonConstraints(), - ]) - ->add('post_code', TextType::class, [ - 'empty_data' => '', - 'required' => false, - 'constraints' => [ - new TypedRegex([ - 'type' => TypedRegex::TYPE_POST_CODE, - ]), - new Length([ - 'max' => AddressSettings::MAX_POST_CODE_LENGTH, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - 'Admin.Notifications.Error', - ['%limit%' => AddressSettings::MAX_POST_CODE_LENGTH] - ), - ]), - ], - ]) - ->add('city', TextType::class, [ - 'empty_data' => '', - 'constraints' => [ - new NotBlank([ - 'message' => $this->trans( - 'This field cannot be empty', 'Admin.Notifications.Error' - ), - ]), - new TypedRegex([ - 'type' => TypedRegex::TYPE_CITY_NAME, - ]), - new Length([ - 'max' => AddressSettings::MAX_CITY_NAME_LENGTH, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - 'Admin.Notifications.Error', - ['%limit%' => AddressSettings::MAX_CITY_NAME_LENGTH] - ), - ]), - ], - ]) - ->add('id_country', CountryChoiceType::class, [ - 'required' => true, - 'with_dni_attr' => true, - 'constraints' => [ - new NotBlank([ - 'message' => $this->trans( - 'This field cannot be empty', 'Admin.Notifications.Error' - ), - ]), - ], - ]) - ->add('id_state', ChoiceType::class, [ - 'required' => true, - 'choices' => $stateChoices, - 'constraints' => [ - new AddressStateRequired([ - 'id_country' => $countryId, - ]), - ], - ]) - ->add('dni', TextType::class, [ - 'required' => false, - 'empty_data' => '', - 'constraints' => [ - new AddressDniRequired([ - 'required' => false, - 'id_country' => $countryId, - ]), - new TypedRegex([ - 'type' => 'dni_lite', - ]), - new Length([ - 'max' => 16, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - 'Admin.Notifications.Error', - ['%limit%' => 16] - ), - ]), - ], - ]) - ->add('logo', FileType::class, [ - 'required' => false, - ]) - ->add('meta_title', TranslatableType::class, [ - 'type' => TextType::class, - 'required' => false, - 'options' => [ - 'constraints' => [ - new TypedRegex([ - 'type' => TypedRegex::TYPE_GENERIC_NAME, - ]), - new Length([ - 'max' => SupplierSettings::MAX_META_TITLE_LENGTH, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - 'Admin.Notifications.Error', - ['%limit%' => SupplierSettings::MAX_META_TITLE_LENGTH] - ), - ]), - ], - ], - ]) - ->add('meta_description', TranslatableType::class, [ - 'type' => TextareaType::class, - 'required' => false, - 'options' => [ - 'constraints' => [ - new TypedRegex([ - 'type' => TypedRegex::TYPE_GENERIC_NAME, - ]), - new Length([ - 'max' => SupplierSettings::MAX_META_DESCRIPTION_LENGTH, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - 'Admin.Notifications.Error', - ['%limit%' => SupplierSettings::MAX_META_DESCRIPTION_LENGTH] - ), - ]), - ], - ], - ]) - ->add('meta_keyword', TranslatableType::class, [ - 'type' => TextType::class, - 'required' => false, - 'options' => [ - 'attr' => [ - 'class' => 'js-taggable-field', - 'placeholder' => $this->trans('Add tag', 'Admin.Actions'), - ], - 'constraints' => [ - new TypedRegex([ - 'type' => TypedRegex::TYPE_GENERIC_NAME, - ]), - new Length([ - 'max' => SupplierSettings::MAX_META_KEYWORD_LENGTH, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - 'Admin.Notifications.Error', - ['%limit%' => SupplierSettings::MAX_META_KEYWORD_LENGTH] - ), - ]), - ], - ], - ]) - ->add('is_enabled', SwitchType::class, [ - 'required' => false, - ]) - ; - - if ($this->isMultistoreEnabled) { - $builder->add('shop_association', ShopChoiceTreeType::class, [ - 'required' => false, - 'constraints' => [ - new NotBlank([ - 'message' => $this->trans( - 'This field cannot be empty', 'Admin.Notifications.Error' - ), - ]), - ], - ]); - } - } - - /** - * Provides reusable address constraints - * - * @return array - */ - private function getAddressCommonConstraints() - { - return [ - new TypedRegex([ - 'type' => TypedRegex::TYPE_ADDRESS, - ]), - new Length([ - 'max' => AddressSettings::MAX_ADDRESS_LENGTH, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - 'Admin.Notifications.Error', - ['%limit%' => AddressSettings::MAX_ADDRESS_LENGTH] - ), - ]), - ]; - } - - /** - * Provides reusable phone constraints - * - * @return array - */ - private function getPhoneCommonConstraints() - { - return [ - new TypedRegex([ - 'type' => TypedRegex::TYPE_PHONE_NUMBER, - ]), - new Length([ - 'max' => AddressSettings::MAX_PHONE_LENGTH, - 'maxMessage' => $this->trans( - 'This field cannot be longer than %limit% characters', - 'Admin.Notifications.Error', - ['%limit%' => AddressSettings::MAX_PHONE_LENGTH] - ), - ]), - ]; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/AddonsConnectType.php b/src/PrestaShopBundle/Form/Admin/Type/AddonsConnectType.php deleted file mode 100644 index fcd810f2..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/AddonsConnectType.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ButtonType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; - -/** - * Class AddonsConnectType defines addons connection form type. - * When not connected to addons, it shows a button to sign in. - * When connected to addons it shows the connected email and sign out button. - */ -class AddonsConnectType extends AbstractType -{ - /** - * @var bool - */ - private $isAddonsConnected; - - /** - * @var string - */ - private $addonsUsername; - - /** - * @param bool $isAddonsConnected - * @param string $addonsUsername - */ - public function __construct($isAddonsConnected, $addonsUsername) - { - $this->isAddonsConnected = $isAddonsConnected; - $this->addonsUsername = $addonsUsername; - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['is_addons_connected'] = $this->isAddonsConnected; - $view->vars['addons_username'] = $this->addonsUsername; - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return ButtonType::class; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/CategoryChoiceTreeType.php b/src/PrestaShopBundle/Form/Admin/Type/CategoryChoiceTreeType.php deleted file mode 100644 index 5e0a836d..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/CategoryChoiceTreeType.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use PrestaShopBundle\Form\Admin\Type\Material\MaterialChoiceTreeType; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class CategoryChoiceTreeType. - */ -class CategoryChoiceTreeType extends AbstractType -{ - /** - * @var array - */ - private $categoryTreeChoices; - - /** - * @param array $categoryTreeChoices - */ - public function __construct(array $categoryTreeChoices) - { - $this->categoryTreeChoices = $categoryTreeChoices; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'choices_tree' => $this->categoryTreeChoices, - 'choice_label' => 'name', - 'choice_value' => 'id_category', - ]); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return MaterialChoiceTreeType::class; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/ChangePasswordType.php b/src/PrestaShopBundle/Form/Admin/Type/ChangePasswordType.php deleted file mode 100644 index 0b62797d..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/ChangePasswordType.php +++ /dev/null @@ -1,145 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use PrestaShop\PrestaShop\Core\Domain\Employee\ValueObject\Password; -use PrestaShopBundle\Translation\TranslatorAwareTrait; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ButtonType; -use Symfony\Component\Form\Extension\Core\Type\PasswordType; -use Symfony\Component\Form\Extension\Core\Type\RepeatedType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Validator\Constraints\Length; - -/** - * Class ChangePasswordType is responsible for defining "change password" form type. - */ -class ChangePasswordType extends AbstractType -{ - use TranslatorAwareTrait; - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('change_password_button', ButtonType::class, [ - 'label' => false, - ]) - ->add('old_password', PasswordType::class) - ->add('new_password', RepeatedType::class, [ - 'type' => PasswordType::class, - 'constraints' => [ - $this->getLengthConstraint(Password::MAX_LENGTH, Password::MIN_LENGTH), - ], - 'first_options' => [ - 'attr' => [ - 'data-password-too-short' => $this->getMinLengthValidationMessage(Password::MIN_LENGTH), - 'data-password-too-long' => $this->getMaxLengthValidationMessage(Password::MAX_LENGTH), - ], - ], - 'second_options' => [ - 'attr' => [ - 'data-invalid-password' => $this->trans( - 'Invalid password confirmation', - [], - 'Admin.Notifications.Error' - ), - ], - ], - ]) - ->add('generated_password', TextType::class, [ - 'label' => false, - 'disabled' => true, - ]) - ->add('generate_password_button', ButtonType::class) - ->add('cancel_button', ButtonType::class) - ; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'required' => false, - ]); - } - - /** - * @param int $maxLength - * @param int|null $minLength - * - * @return Length - */ - private function getLengthConstraint($maxLength, $minLength = null) - { - $options = [ - 'max' => $maxLength, - 'maxMessage' => $this->getMaxLengthValidationMessage($maxLength), - ]; - - if (null !== $minLength) { - $options['min'] = $minLength; - $options['minMessage'] = $this->getMinLengthValidationMessage($minLength); - } - - return new Length($options); - } - - /** - * @param int $minLength - * - * @return string - */ - private function getMinLengthValidationMessage($minLength) - { - return $this->trans( - 'This field cannot be shorter than %limit% characters', - ['%limit%' => $minLength], - 'Admin.Notifications.Error' - ); - } - - /** - * @param int $maxLength - * - * @return string - */ - private function getMaxLengthValidationMessage($maxLength) - { - return $this->trans( - 'This field cannot be longer than %limit% characters', - ['%limit%' => $maxLength], - 'Admin.Notifications.Error' - ); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/ChoiceCategoriesTreeType.php b/src/PrestaShopBundle/Form/Admin/Type/ChoiceCategoriesTreeType.php deleted file mode 100644 index 35d36b22..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/ChoiceCategoriesTreeType.php +++ /dev/null @@ -1,97 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * This form class is responsible to create a category selector using Nested sets. - */ -class ChoiceCategoriesTreeType extends CommonAbstractType -{ - /** - * {@inheritdoc} - * - * Add the var choices to the view - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['choices'] = $options['list']; - $view->vars['multiple'] = $options['multiple']; - $view->vars['expanded'] = $options['expanded']; - - //if form is submitted, inject categories values array to check or not each field - if (!empty($view->vars['value']) && !empty($view->vars['value']['tree'])) { - $view->vars['submitted_values'] = array_flip($view->vars['value']['tree']); - } - } - - /** - * {@inheritdoc} - * - * Builds the form. - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('tree', ChoiceType::class, [ - 'label' => false, - 'choices' => $options['valid_list'], - 'required' => false, - 'multiple' => true, - 'expanded' => true, - 'error_bubbling' => true, - ]); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'label' => '', - 'list' => [], - 'valid_list' => [], - 'multiple' => true, - 'expanded' => true, - ]); - } - - /** - * Returns the block prefix of this type. - * - * @return string The prefix name - */ - public function getBlockPrefix() - { - return 'choice_tree'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/Common/Team/ProfileChoiceType.php b/src/PrestaShopBundle/Form/Admin/Type/Common/Team/ProfileChoiceType.php deleted file mode 100644 index 0b0ffaad..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/Common/Team/ProfileChoiceType.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type\Common\Team; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class ProfileChoiceType is choice type for selecting employee's profile. - */ -class ProfileChoiceType extends AbstractType -{ - /** - * @var array - */ - private $profileChoices; - - /** - * @param array $profileChoices - */ - public function __construct(array $profileChoices) - { - $this->profileChoices = $profileChoices; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setDefaults([ - 'choices' => $this->profileChoices, - 'translation_domain' => false, - 'expanded' => false, - 'multiple' => false, - ]); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return ChoiceType::class; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/CommonAbstractType.php b/src/PrestaShopBundle/Form/Admin/Type/CommonAbstractType.php deleted file mode 100644 index 5a4f2d41..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/CommonAbstractType.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use PrestaShop\PrestaShop\Adapter\Configuration; -use Symfony\Component\Form\AbstractType; - -/** - * This subclass contains common functions for specific Form types needs. - */ -abstract class CommonAbstractType extends AbstractType -{ - const PRESTASHOP_DECIMALS = 6; - - /** - * Get the configuration adapter. - * - * @return object Configuration adapter - */ - protected function getConfiguration() - { - return new Configuration(); - } - - /** - * Format legacy data list to mapping SF2 form field choice. - * - * @param array $list - * @param string $mapping_value - * @param string $mapping_name - * - * @return array - */ - protected function formatDataChoicesList($list, $mapping_value = 'id', $mapping_name = 'name') - { - $new_list = []; - foreach ($list as $item) { - if (array_key_exists($item[$mapping_name], $new_list)) { - return $this->formatDataDuplicateChoicesList($list, $mapping_value, $mapping_name); - } else { - $new_list[$item[$mapping_name]] = $item[$mapping_value]; - } - } - - return $new_list; - } - - /** - * Format legacy data list to mapping SF2 form field choice (possibility to have 2 name equals). - * - * @param array $list - * @param string $mapping_value - * @param string $mapping_name - * - * @return array - */ - protected function formatDataDuplicateChoicesList($list, $mapping_value = 'id', $mapping_name = 'name') - { - $new_list = []; - foreach ($list as $item) { - $new_list[$item[$mapping_value] . ' - ' . $item[$mapping_name]] = $item[$mapping_value]; - } - - return $new_list; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/CountryChoiceType.php b/src/PrestaShopBundle/Form/Admin/Type/CountryChoiceType.php deleted file mode 100644 index 121168f9..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/CountryChoiceType.php +++ /dev/null @@ -1,127 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use PrestaShop\PrestaShop\Core\Form\FormChoiceAttributeProviderInterface; -use PrestaShop\PrestaShop\Core\Form\FormChoiceProviderInterface; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class CountryChoiceType is responsible for providing country choices with -- symbol in front of array. - */ -class CountryChoiceType extends AbstractType -{ - /** - * @var FormChoiceProviderInterface - */ - private $countriesChoiceProvider; - - /** - * @var FormChoiceAttributeProviderInterface - */ - private $countriesAttrChoicesProvider; - - /** - * @var array - */ - private $countriesAttr = []; - - /** - * @var bool - */ - private $needDni = false; - - /** - * @var bool - */ - private $needPostcode = false; - - /** - * @param FormChoiceProviderInterface $countriesChoiceProvider - */ - public function __construct(FormChoiceProviderInterface $countriesChoiceProvider, FormChoiceAttributeProviderInterface $countriesAttrChoicesProvider) - { - $this->countriesChoiceProvider = $countriesChoiceProvider; - $this->countriesAttrChoicesProvider = $countriesAttrChoicesProvider; - } - - public function buildForm(FormBuilderInterface $builder, array $options) - { - if ($options['with_dni_attr'] || $options['with_postcode_attr']) { - $this->needDni = $options['with_dni_attr']; - $this->needPostcode = $options['with_postcode_attr']; - $this->countriesAttr = $this->countriesAttrChoicesProvider->getChoicesAttributes(); - } - parent::buildForm($builder, $options); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $choices = array_merge( - ['--' => ''], - $this->countriesChoiceProvider->getChoices() - ); - - $resolver->setDefaults([ - 'choices' => $choices, - 'choice_attr' => [$this, 'getChoiceAttr'], - 'with_dni_attr' => false, - 'with_postcode_attr' => false, - ]); - - $resolver - ->setAllowedTypes('with_dni_attr', 'boolean') - ->setAllowedTypes('with_postcode_attr', 'boolean'); - } - - public function getChoiceAttr($value, $key) - { - $attr = []; - if ($this->needDni && isset($this->countriesAttr[$key], $this->countriesAttr[$key]['need_dni'])) { - $attr['need_dni'] = 1; - } - if ($this->needPostcode && isset($this->countriesAttr[$key], $this->countriesAttr[$key]['need_postcode'])) { - $attr['need_postcode'] = 1; - } - - return $attr; - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return ChoiceType::class; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/CustomContentType.php b/src/PrestaShopBundle/Form/Admin/Type/CustomContentType.php deleted file mode 100644 index 43be8e3c..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/CustomContentType.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Type is used to add any content in any position of the form rather than actual field. - */ -final class CustomContentType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['data'] = $options['data']; - $view->vars['template'] = $options['template']; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'template', - ]) - ->setDefaults([ - 'required' => false, - 'data' => [], - ]) - ->setAllowedTypes('template', 'string') - ->setAllowedTypes('data', 'array') - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/CustomMoneyType.php b/src/PrestaShopBundle/Form/Admin/Type/CustomMoneyType.php deleted file mode 100644 index 9872d672..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/CustomMoneyType.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\AbstractTypeExtension; -use Symfony\Component\OptionsResolver\OptionsResolver; - -class CustomMoneyType extends AbstractTypeExtension -{ - const PRESTASHOP_DECIMALS = 6; - - public function getExtendedType() - { - return 'Symfony\Component\Form\Extension\Core\Type\MoneyType'; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'precision' => null, - 'scale' => self::PRESTASHOP_DECIMALS, - 'grouping' => false, - 'divisor' => 1, - 'currency' => 'EUR', - 'compound' => false, - ]); - - $resolver->setAllowedTypes('scale', 'int'); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/DatePickerType.php b/src/PrestaShopBundle/Form/Admin/Type/DatePickerType.php deleted file mode 100644 index 19f22731..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/DatePickerType.php +++ /dev/null @@ -1,95 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * This form class is responsible to create a date picker field. - */ -class DatePickerType extends AbstractType -{ - /** - * @var DataTransformerInterface - */ - private $arabicToLatinDigitDataTransformer; - - public function __construct(DataTransformerInterface $arabicToLatinDigitDataTransformer) - { - $this->arabicToLatinDigitDataTransformer = $arabicToLatinDigitDataTransformer; - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return TextType::class; - } - - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->addViewTransformer($this->arabicToLatinDigitDataTransformer); - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['date_format'] = $options['date_format']; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'widget' => 'single_text', - // date_format must be provided in javascript supported type - 'date_format' => 'YYYY-MM-DD', - ]); - $resolver->setAllowedTypes('date_format', 'string'); - } - - /** - * Returns the block prefix of this type. - * - * @return string The prefix name - */ - public function getBlockPrefix() - { - return 'date_picker'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/DateRangeType.php b/src/PrestaShopBundle/Form/Admin/Type/DateRangeType.php deleted file mode 100644 index 7d3f70d5..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/DateRangeType.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -class DateRangeType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('from', DatePickerType::class, [ - 'required' => false, - 'attr' => [ - 'placeholder' => 'From', - ], - 'translation_domain' => 'Admin.Global', - 'date_format' => $options['date_format'], - ]) - ->add('to', DatePickerType::class, [ - 'required' => false, - 'attr' => [ - 'placeholder' => 'To', - ], - 'translation_domain' => 'Admin.Global', - 'date_format' => $options['date_format'], - ]); - } - - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'date_format' => 'YYYY-MM-DD', - ]); - $resolver->setAllowedTypes('date_format', 'string'); - } - - /** - * {@inheritdoc} - */ - public function getBlockPrefix() - { - return 'date_range'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/EmailType.php b/src/PrestaShopBundle/Form/Admin/Type/EmailType.php deleted file mode 100644 index 3763c917..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/EmailType.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShopBundle\Form\Admin\Type; - -use PrestaShopBundle\Form\DataTransformer\IDNConverterDataTransformer; -use Symfony\Component\Form\Extension\Core\Type\EmailType as BaseEmailType; -use Symfony\Component\Form\FormBuilderInterface; - -class EmailType extends BaseEmailType -{ - /** - * @var IDNConverterDataTransformer - */ - private $IDNConverterDataTransformer; - - public function __construct(IDNConverterDataTransformer $IDNConverterDataTransformer) - { - $this->IDNConverterDataTransformer = $IDNConverterDataTransformer; - } - - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->addViewTransformer($this->IDNConverterDataTransformer); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/FormattedTextareaType.php b/src/PrestaShopBundle/Form/Admin/Type/FormattedTextareaType.php deleted file mode 100644 index 3892cba6..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/FormattedTextareaType.php +++ /dev/null @@ -1,86 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use PrestaShopBundle\Form\Validator\Constraints\TinyMceMaxLength; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\TextareaType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class enabling TinyMCE on a Textarea field. - */ -class FormattedTextareaType extends AbstractType -{ - /** - * Max size of UTF-8 content in MySQL text column - */ - const LIMIT_TEXT_UTF8 = 21844; - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'autoload' => true, // Start automatically TinyMCE - 'limit' => self::LIMIT_TEXT_UTF8, - ]); - $resolver->setAllowedTypes('limit', 'int'); - $resolver->setAllowedTypes('autoload', 'bool'); - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - if (!isset($view->vars['attr']['class'])) { - $view->vars['attr']['class'] = ''; - } - - if (true === $options['autoload']) { - $view->vars['attr']['class'] .= ' autoload_rte'; - } - $view->vars['attr']['counter'] = $options['limit']; - $view->vars['constraints'] = [ - new TinyMceMaxLength([ - 'max' => $options['limit'], - ]), - ]; - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return TextareaType::class; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/GeneratableTextType.php b/src/PrestaShopBundle/Form/Admin/Type/GeneratableTextType.php deleted file mode 100644 index 4c8dba88..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/GeneratableTextType.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * It is extension of TextType that adds additonal button which allows generating value for input - */ -class GeneratableTextType extends AbstractType -{ - const DEFAULT_GENERATED_VALUE_LENGTH = 32; - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setDefaults([ - 'generated_value_length' => self::DEFAULT_GENERATED_VALUE_LENGTH, - ]) - ->setAllowedTypes('generated_value_length', 'int') - ; - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['generated_value_length'] = $options['generated_value_length']; - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return TextType::class; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/IntegerMinMaxFilterType.php b/src/PrestaShopBundle/Form/Admin/Type/IntegerMinMaxFilterType.php deleted file mode 100644 index 7c415e20..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/IntegerMinMaxFilterType.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use PrestaShopBundle\Translation\TranslatorAwareTrait; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\IntegerType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Defines the integer type two inputs of min and max value - designed to fit grid in grid filter. - */ -final class IntegerMinMaxFilterType extends AbstractType -{ - use TranslatorAwareTrait; - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'min_field_options' => [], - 'max_field_options' => [], - ]); - - $resolver->setAllowedTypes('min_field_options', 'array'); - $resolver->setAllowedTypes('max_field_options', 'array'); - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - if (!isset($options['min_field_options']['attr']['placeholder'])) { - $options['min_field_options']['attr']['placeholder'] = $this->trans('Min', [], 'Admin.Global'); - } - - if (!isset($options['max_field_options']['attr']['placeholder'])) { - $options['max_field_options']['attr']['placeholder'] = $this->trans('Max', [], 'Admin.Global'); - } - - if (!isset($options['min_field_options']['attr']['min'])) { - $options['min_field_options']['attr']['min'] = 0; - } - - if (!isset($options['max_field_options']['attr']['min'])) { - $options['max_field_options']['attr']['min'] = 0; - } - - $options['min_field_options']['attr']['step'] = 1; - $options['max_field_options']['attr']['step'] = 1; - - $builder->add('min_field', IntegerType::class, $options['min_field_options']); - $builder->add('max_field', IntegerType::class, $options['max_field_options']); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/IpAddressType.php b/src/PrestaShopBundle/Form/Admin/Type/IpAddressType.php deleted file mode 100644 index f6bf29d2..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/IpAddressType.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\Extension\Core\Type\TextType; - -/** - * Extended input type for IP addresses - * Displays a bouton to add the user's one to the list. - */ -class IpAddressType extends TextType -{ - /** - * {@inheritdoc} - */ - public function getExtendedType() - { - return TextType::class; - } - - /** - * {@inheritdoc} - */ - public function getBlockPrefix() - { - return 'ip_address_text'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/Material/MaterialChoiceTableType.php b/src/PrestaShopBundle/Form/Admin/Type/Material/MaterialChoiceTableType.php deleted file mode 100644 index 6753e647..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/Material/MaterialChoiceTableType.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type\Material; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class MaterialChoiceTableType renders checkbox choices using table layout. - */ -class MaterialChoiceTableType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'expanded' => true, - 'multiple' => true, - ]); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return ChoiceType::class; - } - - /** - * {@inheritdoc} - */ - public function getBlockPrefix() - { - return 'material_choice_table'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/Material/MaterialChoiceTreeType.php b/src/PrestaShopBundle/Form/Admin/Type/Material/MaterialChoiceTreeType.php deleted file mode 100644 index da03168a..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/Material/MaterialChoiceTreeType.php +++ /dev/null @@ -1,153 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type\Material; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -class MaterialChoiceTreeType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $selectedData = []; - if (null !== $form->getData()) { - $selectedData = is_array($form->getData()) ? $form->getData() : [$form->getData()]; - } - - $view->vars['multiple'] = $options['multiple']; - $view->vars['choices_tree'] = $this->getFormattedChoicesTree($options, $selectedData); - $view->vars['choice_label'] = $options['choice_label']; - $view->vars['choice_value'] = $options['choice_value']; - $view->vars['choice_children'] = $options['choice_children']; - $view->vars['disabled_values'] = $options['disabled_values']; - $view->vars['selected_values'] = $selectedData; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setDefaults([ - 'choices_tree' => [], - 'choice_label' => 'name', - 'choice_value' => 'id', - 'choice_children' => 'children', - 'disabled_values' => [], - 'disabled' => false, - 'multiple' => false, - 'compound' => false, - ]) - ->setAllowedTypes('choices_tree', 'array') - ->setAllowedTypes('multiple', 'bool') - ->setAllowedTypes('choice_value', 'string') - ->setAllowedTypes('choice_label', 'string') - ->setAllowedTypes('choice_children', 'string') - ->setAllowedTypes('disabled_values', 'array') - ->setAllowedTypes('disabled', 'bool') - ->addAllowedValues('compound', false); - } - - /** - * {@inheritdoc} - */ - public function getBlockPrefix() - { - return 'material_choice_tree'; - } - - /** - * @param array $options - * @param array $selectedData - * - * @return array - */ - private function getFormattedChoicesTree(array $options, array $selectedData) - { - $tree = $options['choices_tree']; - - foreach ($tree as &$choice) { - $this->fillChoiceWithChildrenSelection( - $choice, - $options['choice_value'], - $options['choice_children'], - $selectedData - ); - } - - return $tree; - } - - /** - * @param array $choice - * @param string $choiceValueName - * @param string $choiceChildrenName - * @param array $selectedValues - * - * @return bool - */ - private function fillChoiceWithChildrenSelection( - array &$choice, - $choiceValueName, - $choiceChildrenName, - array $selectedValues - ) { - $isSelected = false; - $isChildrenSelected = false; - - if (in_array($choice[$choiceValueName], $selectedValues)) { - $isSelected = true; - } - - if (isset($choice[$choiceChildrenName])) { - foreach ($choice[$choiceChildrenName] as &$child) { - $selected = $this->fillChoiceWithChildrenSelection( - $child, - $choiceValueName, - $choiceChildrenName, - $selectedValues - ); - - if ($selected) { - $isChildrenSelected = true; - } - } - - unset($child); - } - - $choice['has_selected_children'] = $isChildrenSelected; - - return $isSelected || $isChildrenSelected; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/Material/MaterialMultipleChoiceTableType.php b/src/PrestaShopBundle/Form/Admin/Type/Material/MaterialMultipleChoiceTableType.php deleted file mode 100644 index 95baa5d9..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/Material/MaterialMultipleChoiceTableType.php +++ /dev/null @@ -1,127 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type\Material; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\CallbackTransformer; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -class MaterialMultipleChoiceTableType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - foreach ($options['multiple_choices'] as $choices) { - $builder->add($choices['name'], ChoiceType::class, [ - 'label' => $choices['label'], - 'choices' => $choices['choices'], - 'expanded' => true, - 'multiple' => $choices['multiple'], - 'choice_label' => false, - 'choice_translation_domain' => false, - ]); - - $builder->get($choices['name'])->addModelTransformer(new CallbackTransformer( - function ($value) use ($choices) { - if (is_array($value) && false === $choices['multiple']) { - return reset($value); - } - - return $value; - }, - function ($value) { - return $value; - } - )); - } - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['choices'] = $options['choices']; - $view->vars['scrollable'] = $options['scrollable']; - $view->vars['headers_to_disable'] = $options['headers_to_disable']; - } - - /** - * {@inheritdoc} - */ - public function finishView(FormView $view, FormInterface $form, array $options) - { - $entryIndexMapping = []; - - foreach ($view->children as $childChoiceName => $childChoiceView) { - foreach ($childChoiceView->children as $index => $childChoiceEntryView) { - $entryIndexMapping[$childChoiceEntryView->vars['value']][$childChoiceName] = $index; - } - } - - $view->vars['child_choice_entry_index_mapping'] = $entryIndexMapping; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'multiple_choices', - 'choices', - // in some cases we want to disable - // header for columns - 'headers_to_disable', - ]) - ->setDefaults([ - 'scrollable' => true, - 'headers_to_disable' => [], - ]) - ; - - $resolver->setAllowedTypes('choices', 'array'); - $resolver->setAllowedTypes('multiple_choices', 'array'); - $resolver->setAllowedTypes('scrollable', 'bool'); - $resolver->setAllowedTypes('headers_to_disable', 'array'); - } - - /** - * {@inheritdoc} - */ - public function getBlockPrefix() - { - return 'material_multiple_choice_table'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/MoneyWithSuffixType.php b/src/PrestaShopBundle/Form/Admin/Type/MoneyWithSuffixType.php deleted file mode 100644 index 9ee0db14..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/MoneyWithSuffixType.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\Extension\Core\Type\MoneyType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class MoneyWithSuffixType is a money type, - * which also has a suffix string right after the currency sign. - */ -class MoneyWithSuffixType extends MoneyType -{ - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $pattern = self::getPattern($options['currency']); - - // Currency sign in the pattern string can be either to the left, - // or to the right of the {{ widget }}, depending on the currency. - $tokens = explode('{{ widget }}', $pattern); - - // The only non-empty token will be the currency sign - append the suffix to it - array_walk($tokens, [$this, 'applySuffix'], $options['suffix']); - - // Restore the pattern as it was before, - // just the suffix is already appended after the currency sign - $view->vars['money_pattern'] = implode('{{ widget }}', $tokens); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - parent::configureOptions($resolver); - - $resolver->setDefault('suffix', ''); - } - - /** - * Appends the suffix to the value, if the value is not empty. - * Can be used with array_walk(). - * - * @param string $value - * @param int $key not used, it's only here to make this method compatible with array_walk - * @param string $suffix - */ - private function applySuffix(&$value, $key, $suffix) - { - if (strlen($value) > 0) { - $value = rtrim($value) . ' ' . $suffix; - } - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/NumberMinMaxFilterType.php b/src/PrestaShopBundle/Form/Admin/Type/NumberMinMaxFilterType.php deleted file mode 100644 index 77bdcee8..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/NumberMinMaxFilterType.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use PrestaShopBundle\Translation\TranslatorAwareTrait; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\NumberType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Defines the number type two inputs of min and max value - designed to fit grid in grid filter. - */ -final class NumberMinMaxFilterType extends AbstractType -{ - use TranslatorAwareTrait; - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'min_field_options' => [], - 'max_field_options' => [], - ]); - - $resolver->setAllowedTypes('min_field_options', 'array'); - $resolver->setAllowedTypes('max_field_options', 'array'); - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - if (!isset($options['min_field_options']['attr']['placeholder'])) { - $options['min_field_options']['attr']['placeholder'] = $this->trans('Min', [], 'Admin.Global'); - } - - if (!isset($options['max_field_options']['attr']['placeholder'])) { - $options['max_field_options']['attr']['placeholder'] = $this->trans('Max', [], 'Admin.Global'); - } - - $builder->add('min_field', NumberType::class, $options['min_field_options']); - $builder->add('max_field', NumberType::class, $options['max_field_options']); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/ReductionType.php b/src/PrestaShopBundle/Form/Admin/Type/ReductionType.php deleted file mode 100644 index b29885ef..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/ReductionType.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\Extension\Core\Type\NumberType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Responsible for creating form for price reduction - */ -class ReductionType extends CommonAbstractType -{ - /** - * @var array - */ - private $priceReductionTypeChoices; - - /** - * @param array $priceReductionTypeChoices - */ - public function __construct( - array $priceReductionTypeChoices - ) { - $this->priceReductionTypeChoices = $priceReductionTypeChoices; - } - - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->add('type', ChoiceType::class, [ - 'placeholder' => false, - 'required' => false, - 'choices' => $options['choices'], - ]) - ->add('value', NumberType::class, [ - 'scale' => $options['scale'], - ]); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'choices' => $this->priceReductionTypeChoices, - 'scale' => 6, - ]); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/ResizableTextType.php b/src/PrestaShopBundle/Form/Admin/Type/ResizableTextType.php deleted file mode 100644 index e367f5fc..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/ResizableTextType.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\AbstractTypeExtension; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class ResizableTextType adds new sizing options to TextType. - */ -class ResizableTextType extends AbstractTypeExtension -{ - /** - * {@inheritdoc} - */ - public function getExtendedType() - { - return TextType::class; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setDefined('size') - ->setAllowedValues( - 'size', - [ - 'small', - ] - ) - ; - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - if (isset($options['size'])) { - $sizeClass = 'size-' . $options['size']; - - if (!isset($view->vars['attr']['class'])) { - $view->vars['attr']['class'] = ''; - } - - $view->vars['attr']['class'] = trim($view->vars['attr']['class'] . ' ' . $sizeClass); - } - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/SearchAndResetType.php b/src/PrestaShopBundle/Form/Admin/Type/SearchAndResetType.php deleted file mode 100644 index aab02ec8..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/SearchAndResetType.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use LogicException; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; - -/** - * FormType used in rendering of "Search and Reset" action in Grids. - */ -class SearchAndResetType extends AbstractType -{ - /** - * @var UrlGeneratorInterface - */ - private $urlGenerator; - - /** - * @param UrlGeneratorInterface $urlGenerator - */ - public function __construct(UrlGeneratorInterface $urlGenerator) - { - $this->urlGenerator = $urlGenerator; - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $showResetButton = false; - - if (null !== $form->getParent()) { - $configuredTypeNames = array_keys($form->getParent()->all()); - $availableValueNames = array_keys($form->getParent()->getData()); - - $configuredData = array_intersect($configuredTypeNames, $availableValueNames); - if (!empty($configuredData)) { - $showResetButton = true; - } - } - - $resetUrl = isset($options['attr']['data-url']) ? $options['attr']['data-url'] : null; - $redirectUrl = isset($options['attr']['data-redirect']) ? $options['attr']['data-redirect'] : null; - - if (null !== $options['reset_route']) { - $resetUrl = $this->urlGenerator->generate( - $options['reset_route'], - $options['reset_route_params'] - ); - } - - if (null !== $options['redirect_route']) { - $redirectUrl = $this->urlGenerator->generate( - $options['redirect_route'], - $options['redirect_route_params'] - ); - } - - if (in_array(null, [$resetUrl, $redirectUrl])) { - throw new LogicException(sprintf('You must configure "reset_route" and "redirect_route" options for "%s" type.', self::class)); - } - - $view->vars['show_reset_button'] = $showResetButton; - $view->vars['redirect_url'] = $redirectUrl; - $view->vars['reset_url'] = $resetUrl; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setDefaults([ - 'reset_route' => null, - 'reset_route_params' => [], - 'redirect_route' => null, - 'redirect_route_params' => [], - ]) - ->setAllowedTypes('reset_route', ['string', 'null']) - ->setAllowedTypes('reset_route_params', 'array') - ->setAllowedTypes('redirect_route', ['string', 'null']) - ->setAllowedTypes('redirect_route_params', 'array'); - } - - /** - * {@inheritdoc} - */ - public function getBlockPrefix() - { - return 'search_and_reset'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/ShopChoiceTreeType.php b/src/PrestaShopBundle/Form/Admin/Type/ShopChoiceTreeType.php deleted file mode 100644 index 51370729..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/ShopChoiceTreeType.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use PrestaShopBundle\Form\Admin\Type\Material\MaterialChoiceTreeType; -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class ShopChoiceTreeType. - */ -class ShopChoiceTreeType extends AbstractType -{ - /** - * @var array - */ - private $shopTreeChoices; - - /** - * @var DataTransformerInterface - */ - private $stringArrayToIntegerArrayDataTransformer; - - /** - * @param array $shopTreeChoices - * @param DataTransformerInterface $stringArrayToIntegerArrayDataTransformer - */ - public function __construct( - array $shopTreeChoices, - DataTransformerInterface $stringArrayToIntegerArrayDataTransformer - ) { - $this->shopTreeChoices = $shopTreeChoices; - $this->stringArrayToIntegerArrayDataTransformer = $stringArrayToIntegerArrayDataTransformer; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->addModelTransformer($this->stringArrayToIntegerArrayDataTransformer); - - parent::buildForm($builder, $options); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'choices_tree' => $this->shopTreeChoices, - 'multiple' => true, - 'choice_label' => 'name', - 'choice_value' => 'id_shop', - ]); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return MaterialChoiceTreeType::class; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/ShopRestrictionCheckboxType.php b/src/PrestaShopBundle/Form/Admin/Type/ShopRestrictionCheckboxType.php deleted file mode 100644 index 3ce2329a..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/ShopRestrictionCheckboxType.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\CheckboxType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * This class displays customized checkbox which is used for shop restriction functionality. - */ -class ShopRestrictionCheckboxType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $isChecked = $form->getData(); - - if ($isChecked) { - $view->vars['attr']['checked'] = true; - } - - parent::buildView($view, $form, $options); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'required' => false, - ]); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return CheckboxType::class; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/SwitchType.php b/src/PrestaShopBundle/Form/Admin/Type/SwitchType.php deleted file mode 100644 index b506e5b1..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/SwitchType.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Displays a switch (ON / OFF by default). - */ -class SwitchType extends AbstractType -{ - const TRANS_DOMAIN = 'Admin.Global'; - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'choices' => [ - 'No' => false, - 'Yes' => true, - ], - 'multiple' => false, - 'expanded' => false, - 'disabled' => false, - 'choice_translation_domain' => self::TRANS_DOMAIN, - ]); - $resolver->setAllowedTypes('disabled', 'bool'); - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - if (true === $options['disabled']) { - $view->vars['disabled'] = true; - } - $view->vars['attr']['class'] = 'ps-switch'; - if (isset($options['attr']['class'])) { - $view->vars['attr']['class'] .= ' ' . $options['attr']['class']; - } - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return ChoiceType::class; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/TextEmptyType.php b/src/PrestaShopBundle/Form/Admin/Type/TextEmptyType.php deleted file mode 100644 index 0f6dedab..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/TextEmptyType.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\AbstractTypeExtension; -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\FormBuilderInterface; - -/** - * @deprecated 1.7.5, to be removed in 1.8 - */ -class TextEmptyType extends AbstractTypeExtension implements DataTransformerInterface -{ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->addModelTransformer($this); - } - - public function getExtendedType() - { - return 'Symfony\Component\Form\Extension\Core\Type\TextType'; - } - - public function transform($data) - { - return $data; - } - - public function reverseTransform($data) - { - return empty($data) ? '' : $data; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/TextWithLengthCounterType.php b/src/PrestaShopBundle/Form/Admin/Type/TextWithLengthCounterType.php deleted file mode 100644 index 69170fc8..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/TextWithLengthCounterType.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Defines reusable text input with max length counter - */ -class TextWithLengthCounterType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['max_length'] = $options['max_length']; - $view->vars['position'] = $options['position']; - $view->vars['input'] = $options['input']; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setRequired([ - 'max_length', - ]) - ->setDefaults([ - 'position' => 'before', - 'input' => 'text', - 'compound' => false, - ]) - ->setAllowedTypes('max_length', 'int') - ->setAllowedValues('position', ['before', 'after']) - ->setAllowedValues('input', ['text', 'textarea']); - } - - /** - * {@inheritdoc} - */ - public function getBlockPrefix() - { - return 'text_with_length_counter'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/TextWithRecommendedLengthType.php b/src/PrestaShopBundle/Form/Admin/Type/TextWithRecommendedLengthType.php deleted file mode 100644 index 95632fd1..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/TextWithRecommendedLengthType.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Is used to add field with recommended input length counter to the form. - * - * Requires Javasript text-with-recommended-lenght-counter.js to work properly. - */ -class TextWithRecommendedLengthType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['recommended_length'] = $options['recommended_length']; - $view->vars['input_type'] = $options['input_type']; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver - ->setDefaults([ - 'input_type' => 'text', - 'compound' => false, - ]) - ->setRequired([ - 'recommended_length', - ]) - ->setAllowedTypes('recommended_length', 'int') - ->setAllowedValues('input_type', ['text', 'textarea']) - ; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/TextWithUnitType.php b/src/PrestaShopBundle/Form/Admin/Type/TextWithUnitType.php deleted file mode 100644 index e1e9eb2b..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/TextWithUnitType.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -class TextWithUnitType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function getParent() - { - return TextType::class; - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'widget' => 'single_text', - 'unit' => 'unit', - ]); - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - parent::buildView($view, $form, $options); - - $view->vars = array_merge($view->vars, [ - 'unit' => $options['unit'], - ]); - } - - /** - * {@inheritdoc} - */ - public function getBlockPrefix() - { - return 'text_with_unit'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/TextareaEmptyType.php b/src/PrestaShopBundle/Form/Admin/Type/TextareaEmptyType.php deleted file mode 100644 index cea82546..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/TextareaEmptyType.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\AbstractTypeExtension; -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\FormBuilderInterface; - -/** - * @deprecated 1.7.5, to be removed in 1.8 - */ -class TextareaEmptyType extends AbstractTypeExtension implements DataTransformerInterface -{ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->addModelTransformer($this); - } - - public function getExtendedType() - { - return 'Symfony\Component\Form\Extension\Core\Type\TextareaType'; - } - - public function transform($data) - { - return $data; - } - - public function reverseTransform($data) - { - return empty($data) ? '' : $data; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/TranslatableType.php b/src/PrestaShopBundle/Form/Admin/Type/TranslatableType.php deleted file mode 100644 index 6f04b7ce..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/TranslatableType.php +++ /dev/null @@ -1,351 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormErrorIterator; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; - -/** - * Class TranslatableType adds translatable inputs with custom inner type to forms. - * Language selection uses a dropdown. - */ -class TranslatableType extends AbstractType -{ - /** - * @var array List of enabled locales - */ - private $enabledLocales; - - /** - * @var array List of all available locales - */ - private $availableLocales; - - /** - * @var UrlGeneratorInterface - */ - private $urlGenerator; - - /** - * @var bool indicates whether to save the selected form language or not - */ - private $saveFormLocaleChoice; - - /** - * @var string default form language ID - */ - private $defaultFormLanguageId; - - /** - * @var int default language of the shop, used as a fallback when default form language is not set - */ - private $defaultShopLanguageId; - - /** - * @param array $availableLocales - * @param UrlGeneratorInterface $urlGenerator - * @param bool $saveFormLocaleChoice - * @param int $defaultFormLanguageId - * @param int $defaultShopLanguageId - */ - public function __construct( - array $availableLocales, - UrlGeneratorInterface $urlGenerator, - $saveFormLocaleChoice, - $defaultFormLanguageId, - $defaultShopLanguageId - ) { - $this->enabledLocales = $this->filterEnableLocales($availableLocales); - $this->availableLocales = $availableLocales; - $this->urlGenerator = $urlGenerator; - $this->saveFormLocaleChoice = $saveFormLocaleChoice; - $this->defaultFormLanguageId = $defaultFormLanguageId; - $this->defaultShopLanguageId = $defaultShopLanguageId; - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - foreach ($options['locales'] as $locale) { - $typeOptions = $options['options']; - $typeOptions['label'] = $locale['iso_code']; - - if (!isset($typeOptions['required'])) { - $typeOptions['required'] = false; - } - - $builder->add($locale['id_lang'], $options['type'], $typeOptions); - } - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['locales'] = $options['locales']; - $view->vars['default_locale'] = $this->getDefaultLocale($options['locales']); - $view->vars['hide_locales'] = 1 >= count($options['locales']); - - if ($this->saveFormLocaleChoice) { - $view->vars['change_form_language_url'] = $this->urlGenerator->generate( - 'admin_employees_change_form_language' - ); - } - - $this->setErrorsByLocale($view, $form, $options['locales']); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'type' => TextType::class, - 'options' => [], - 'error_bubbling' => false, - 'only_enabled_locales' => false, - 'locales' => function (Options $options) { - return $options['only_enabled_locales'] ? - $this->enabledLocales : - $this->availableLocales - ; - }, - ]); - - $resolver->setAllowedTypes('locales', 'array'); - $resolver->setAllowedTypes('options', 'array'); - $resolver->setAllowedTypes('type', 'string'); - $resolver->setAllowedTypes('error_bubbling', 'bool'); - } - - /** - * {@inheritdoc} - */ - public function getBlockPrefix() - { - return 'translatable'; - } - - /** - * If there are more then one locale it gets nested errors and if found prepares the errors for usage in twig. - * If there are only one error which is not assigned to the default language then the error is being localised. - * - * @param FormView $view - * @param FormInterface $form - * @param array $locales - */ - private function setErrorsByLocale(FormView $view, FormInterface $form, array $locales) - { - if (count($locales) <= 1) { - return; - } - - $formErrors = $form->getErrors(true); - - if (empty($formErrors)) { - return; - } - - if (1 === count($formErrors)) { - $errorByLocale = $this->getSingleTranslatableErrorExcludingDefaultLocale( - $formErrors, - $form, - $locales - ); - - if (null !== $errorByLocale) { - $view->vars['error_by_locale'] = $errorByLocale; - } - - return; - } - - $errorsByLocale = $this->getTranslatableErrors( - $formErrors, - $form, - $locales - ); - - if (null !== $errorsByLocale) { - $view->vars['errors_by_locale'] = $errorsByLocale; - } - } - - /** - * Gets single error excluding the default locales error since for default locale a language name prefix is not - * required. - * - * @param FormErrorIterator $formErrors - * @param FormInterface $form - * @param array $locales - * - * @return array|null - */ - private function getSingleTranslatableErrorExcludingDefaultLocale( - FormErrorIterator $formErrors, - FormInterface $form, - array $locales - ) { - $errorByLocale = null; - $formError = $formErrors[0]; - $nonDefaultLanguageFormKey = null; - $iteration = 0; - - foreach ($form as $formItem) { - if (0 === $iteration) { - ++$iteration; - - continue; - } - - if ($this->doesErrorFormAndCurrentFormMatches($formError->getOrigin(), $formItem)) { - $nonDefaultLanguageFormKey = $iteration; - - break; - } - - ++$iteration; - } - - if (isset($locales[$nonDefaultLanguageFormKey])) { - $errorByLocale = [ - 'locale_name' => $locales[$nonDefaultLanguageFormKey]['name'], - 'error_message' => $formError->getMessage(), - ]; - } - - return $errorByLocale; - } - - /** - * Gets translatable errors ready for popover display and assigned to each language - * - * @param FormErrorIterator $formErrors - * @param FormInterface $form - * @param array $locales - * - * @return array|null - */ - private function getTranslatableErrors( - FormErrorIterator $formErrors, - FormInterface $form, - array $locales - ) { - $errorsByLocale = null; - $iteration = 0; - foreach ($form as $formItem) { - $doesLocaleExistForInvalidForm = isset($locales[$iteration]) && !$formItem->isValid(); - - if ($doesLocaleExistForInvalidForm) { - foreach ($formErrors as $formError) { - if ($this->doesErrorFormAndCurrentFormMatches($formError->getOrigin(), $formItem)) { - $errorsByLocale[$locales[$iteration]['iso_code']] = [ - 'locale_name' => $locales[$iteration]['name'], - 'error_message' => $formError->getMessage(), - ]; - } - } - } - - ++$iteration; - } - - return $errorsByLocale; - } - - /** - * Determines if the error form matches the given form. Used for mapping the locales for the form fields. - * - * @param FormInterface $errorForm - * @param FormInterface $currentForm - * - * @return bool - */ - private function doesErrorFormAndCurrentFormMatches(FormInterface $errorForm, FormInterface $currentForm) - { - return $errorForm === $currentForm; - } - - /** - * Get default locale. - * - * @param array $locales - * - * @return array - */ - private function getDefaultLocale(array $locales) - { - if ($this->defaultFormLanguageId) { - // Searching for a locale that matches default form language - foreach ($locales as $locale) { - if ($locale['id_lang'] == $this->defaultFormLanguageId) { - return $locale; - } - } - } - - // Searching for locale that matches default shop language - foreach ($locales as $locale) { - if ($locale['id_lang'] == $this->defaultShopLanguageId) { - return $locale; - } - } - - return reset($locales); - } - - /** - * Filters only enabled locales - * - * @param array $availableLocales - * - * @return array - */ - private function filterEnableLocales(array $availableLocales) - { - $enabledLocales = []; - - foreach ($availableLocales as $locale) { - if ($locale['active']) { - $enabledLocales[] = $locale; - } - } - - return $enabledLocales; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/TranslateTextType.php b/src/PrestaShopBundle/Form/Admin/Type/TranslateTextType.php deleted file mode 100644 index 9a4ffd2c..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/TranslateTextType.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class is responsible for creating translatable text inputs. - * - * @deprecated since version 1.7.6 and will be removed in 1.8. Use the TranslatableType instead. - */ -class TranslateTextType extends AbstractType -{ - public function __construct() - { - @trigger_error( - sprintf( - 'The %s class is deprecated since version 1.7.6 and will be removed in 1.8. Use the %s class instead.', - __CLASS__, - TranslatableType::class - ), - E_USER_DEPRECATED - ); - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - foreach ($options['locales'] as $locale) { - $localeOptions = $options['options']; - $localeOptions['label'] = $locale['iso_code']; - - if (!isset($localeOptions['required'])) { - $localeOptions['required'] = false; - } - - $builder->add($locale['id_lang'], TextType::class, $localeOptions); - } - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['locales'] = $options['locales']; - $view->vars['default_locale'] = reset($options['locales']); - $view->vars['hide_locales'] = 1 >= count($options['locales']); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'options' => [], - 'locales' => [], - ]); - - $resolver->setAllowedTypes('locales', 'array'); - $resolver->setAllowedTypes('options', 'array'); - } - - /** - * {@inheritdoc} - */ - public function getBlockPrefix() - { - return 'translate_text'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/TranslateType.php b/src/PrestaShopBundle/Form/Admin/Type/TranslateType.php deleted file mode 100644 index 223226fb..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/TranslateType.php +++ /dev/null @@ -1,163 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; - -/** - * This form class is responsible to create a translatable form. - * Language selection uses tabs. - */ -class TranslateType extends CommonAbstractType -{ - /** - * @var UrlGeneratorInterface - */ - private $urlGenerator; - - /** - * @var bool - */ - private $saveFormLocaleChoice; - - /** - * @var int - */ - private $defaultFormLanguageId; - - /** - * @var int - */ - private $defaultShopLanguageId; - - /** - * @param UrlGeneratorInterface $urlGenerator - * @param bool $saveFormLocaleChoice - * @param int $defaultFormLanguageId - * @param int $defaultShopLanguageId - */ - public function __construct( - UrlGeneratorInterface $urlGenerator, - $saveFormLocaleChoice, - $defaultFormLanguageId, - $defaultShopLanguageId - ) { - $this->urlGenerator = $urlGenerator; - $this->saveFormLocaleChoice = $saveFormLocaleChoice; - $this->defaultFormLanguageId = $defaultFormLanguageId; - $this->defaultShopLanguageId = $defaultShopLanguageId; - } - - /** - * {@inheritdoc} - * - * Builds form fields for each locales - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $i = 0; - foreach ($options['locales'] as $locale) { - $options['options']['empty_data'] = ''; - $locale_options = $options['options']; - $locale_options['label'] = $locale['iso_code']; - if ($i > 0) { - $locale_options['required'] = false; - unset($locale_options['constraints']); - } - - $builder->add($locale['id_lang'], $options['type'], $locale_options); - ++$i; - } - } - - /** - * {@inheritdoc} - * - * Add the var locales and defaultLocale to the view - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['locales'] = $options['locales']; - $view->vars['defaultLocale'] = $this->getDefaultLocale($options['locales']); - $view->vars['hideTabs'] = $options['hideTabs']; - - if ($this->saveFormLocaleChoice) { - $view->vars['change_form_language_url'] = $this->urlGenerator->generate( - 'admin_employees_change_form_language' - ); - } - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'type' => null, - 'options' => [], - 'locales' => [], - 'hideTabs' => true, - ]); - } - - /** - * Returns the block prefix of this type. - * - * @return string The prefix name - */ - public function getBlockPrefix() - { - return 'translatefields'; - } - - /** - * Get default locale. - * - * @param array $locales - * - * @return array - */ - private function getDefaultLocale(array $locales) - { - // If default form language is not available we will use default shop language - $languageId = $this->defaultFormLanguageId ?: $this->defaultShopLanguageId; - - // Searching for a locale that matches the selected language - foreach ($locales as $locale) { - if ($locale['id_lang'] == $languageId) { - return $locale; - } - } - - return reset($locales); - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/TranslatorAwareType.php b/src/PrestaShopBundle/Form/Admin/Type/TranslatorAwareType.php deleted file mode 100644 index caa613f9..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/TranslatorAwareType.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Translation\TranslatorInterface; - -/** - * PrestaShop forms needs custom domain name for field constraints - * This feature is not available in Symfony so we need to inject the translator - * for constraints messages only. - */ -abstract class TranslatorAwareType extends CommonAbstractType -{ - private $translator; - - /** - * All languages available on shop. Used for translations. - * - * @param array $locales - */ - protected $locales; - - public function __construct(TranslatorInterface $translator, array $locales) - { - $this->translator = $translator; - $this->locales = $locales; - } - - /** - * Get the translated chain from key. - * - * @param string $key the key to be translated - * @param string $domain the domain to be selected - * @param array $parameters Optional, pass parameters if needed (uncommon) - * - * @returns string - */ - protected function trans($key, $domain, $parameters = []) - { - return $this->translator->trans($key, $parameters, $domain); - } - - /** - * Get locales to be used in form type. - * - * @return array - */ - protected function getLocaleChoices() - { - $locales = []; - - foreach ($this->locales as $locale) { - $locales[$locale['name']] = $locale['iso_code']; - } - - return $locales; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/TypeaheadCustomerCollectionType.php b/src/PrestaShopBundle/Form/Admin/Type/TypeaheadCustomerCollectionType.php deleted file mode 100644 index cb69a3bd..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/TypeaheadCustomerCollectionType.php +++ /dev/null @@ -1,132 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * This form class is responsible to create a customer. - */ -class TypeaheadCustomerCollectionType extends CommonAbstractType -{ - protected $customerAdapter; - - /** - * {@inheritdoc} - * - * @param object $customerAdapter - */ - public function __construct($customerAdapter) - { - $this->customerAdapter = $customerAdapter; - } - - /** - * {@inheritdoc} - * - * Add the vars to the view - * Inject collection customer - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['placeholder'] = $options['placeholder']; - $view->vars['remote_url'] = $options['remote_url']; - $view->vars['mapping_value'] = $options['mapping_value']; - $view->vars['mapping_name'] = $options['mapping_name']; - $view->vars['template_collection'] = $options['template_collection']; - $view->vars['limit'] = $options['limit']; - - //if form is submitted, inject datas to display collection - if (!empty($view->vars['value']) && !empty($view->vars['value']['data'])) { - $collection = []; - - $i = 0; - foreach ($view->vars['value']['data'] as $id) { - if (!$id) { - continue; - } - $customer = $this->customerAdapter->getCustomer($id); - $collection[] = [ - 'id' => $id, - 'name' => $customer->firstname . ' ' . $customer->lastname . ' - ' . $customer->email, - ]; - ++$i; - - //if collection length is up to limit, break - if ($options['limit'] != 0 && $i >= $options['limit']) { - break; - } - } - $view->vars['collection'] = $collection; - } - } - - /** - * {@inheritdoc} - * - * Builds the form. - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('data', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', [ - 'entry_type' => 'Symfony\Component\Form\Extension\Core\Type\HiddenType', - 'allow_add' => true, - 'allow_delete' => true, - 'label' => false, - 'required' => false, - 'prototype' => true, - ]); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'remote_url' => '', - 'mapping_value' => 'id', - 'mapping_name' => 'name', - 'placeholder' => '', - 'template_collection' => '', - 'limit' => 0, - ]); - } - - /** - * Returns the block prefix of this type. - * - * @return string The prefix name - */ - public function getBlockPrefix() - { - return 'typeahead_customer_collection'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/TypeaheadProductCollectionType.php b/src/PrestaShopBundle/Form/Admin/Type/TypeaheadProductCollectionType.php deleted file mode 100644 index e4a6aed2..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/TypeaheadProductCollectionType.php +++ /dev/null @@ -1,155 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\Extension\Core\Type\CollectionType; -use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * This form class is responsible to create a product, with or without attribute field. - */ -class TypeaheadProductCollectionType extends CommonAbstractType -{ - protected $productAdapter; - protected $categoryAdapter; - - /** - * {@inheritdoc} - * - * @param object $productAdapter - */ - public function __construct($productAdapter, $categoryAdapter) - { - $this->productAdapter = $productAdapter; - $this->categoryAdapter = $categoryAdapter; - } - - /** - * {@inheritdoc} - * - * Add the vars to the view - * Inject collection products - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['placeholder'] = $options['placeholder']; - $view->vars['remote_url'] = $options['remote_url']; - $view->vars['mapping_value'] = $options['mapping_value']; - $view->vars['mapping_name'] = $options['mapping_name']; - $view->vars['mapping_type'] = $options['mapping_type']; - $view->vars['template_collection'] = $options['template_collection']; - $view->vars['limit'] = $options['limit']; - - //if form is submitted, inject datas to display collection - if (!empty($view->vars['value']) && !empty($view->vars['value']['data'])) { - $collection = []; - - $i = 0; - foreach ($view->vars['value']['data'] as $id) { - if (!$id) { - continue; - } - - switch ($view->vars['mapping_type']) { - case 'category': - $category = $this->categoryAdapter->getCategory($id); - $collection[] = [ - 'id' => $id, - 'name' => $this->categoryAdapter->getBreadCrumb($category->id), - 'image' => $category->image, - ]; - - break; - - default: - $product = $this->productAdapter->getProduct($id); - $collection[] = [ - 'id' => $id, - 'name' => reset($product->name) . ' (ref:' . $product->reference . ')', - 'image' => $product->image, - ]; - - break; - } - ++$i; - - //if collection length is up to limit, break - if ($options['limit'] != 0 && $i >= $options['limit']) { - break; - } - } - $view->vars['collection'] = $collection; - } - } - - /** - * {@inheritdoc} - * - * Builds the form. - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('data', CollectionType::class, [ - 'entry_type' => HiddenType::class, - 'allow_add' => true, - 'allow_delete' => true, - 'label' => false, - 'required' => false, - 'prototype' => true, - ]); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'remote_url' => '', - 'mapping_value' => 'id', - 'mapping_name' => 'name', - 'mapping_type' => 'product', - 'placeholder' => '', - 'template_collection' => '', - 'limit' => 0, - ]); - } - - /** - * Returns the block prefix of this type. - * - * @return string The prefix name - */ - public function getBlockPrefix() - { - return 'typeahead_product_collection'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/TypeaheadProductPackCollectionType.php b/src/PrestaShopBundle/Form/Admin/Type/TypeaheadProductPackCollectionType.php deleted file mode 100644 index 0707c4df..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/TypeaheadProductPackCollectionType.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\Extension\Core\Type\CollectionType; -use Symfony\Component\Form\Extension\Core\Type\HiddenType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * This form class is responsible to create a product, with or without attribute field. - */ -class TypeaheadProductPackCollectionType extends CommonAbstractType -{ - private $productAdapter; - - /** - * {@inheritdoc} - * - * @param object $productAdapter - */ - public function __construct($productAdapter) - { - $this->productAdapter = $productAdapter; - } - - /** - * {@inheritdoc} - * - * Add the vars to the view - * Inject collection products - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['placeholder'] = $options['placeholder']; - $view->vars['remote_url'] = $options['remote_url']; - $view->vars['mapping_value'] = $options['mapping_value']; - $view->vars['mapping_name'] = $options['mapping_name']; - $view->vars['template_collection'] = $options['template_collection']; - - //if form is submitted, inject datas to display collection - if (!empty($view->vars['value']) && !empty($view->vars['value']['data'])) { - $view->vars['collection'] = $view->vars['value']['data']; - } - } - - /** - * {@inheritdoc} - * - * Builds the form. - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->add('data', CollectionType::class, [ - 'entry_type' => HiddenType::class, - 'allow_add' => true, - 'allow_delete' => true, - 'label' => false, - 'required' => false, - 'prototype' => true, - ]); - } - - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'remote_url' => '', - 'mapping_value' => 'id', - 'mapping_name' => 'name', - 'placeholder' => '', - 'template_collection' => '', - ]); - } - - /** - * Returns the block prefix of this type. - * - * @return string The prefix name - */ - public function getBlockPrefix() - { - return 'typeahead_product_pack_collection'; - } -} diff --git a/src/PrestaShopBundle/Form/Admin/Type/YesAndNoChoiceType.php b/src/PrestaShopBundle/Form/Admin/Type/YesAndNoChoiceType.php deleted file mode 100644 index 267c5b3e..00000000 --- a/src/PrestaShopBundle/Form/Admin/Type/YesAndNoChoiceType.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Admin\Type; - -use Symfony\Component\Form\Extension\Core\Type\ChoiceType; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Class YesAndNoChoiceType. - */ -class YesAndNoChoiceType extends TranslatorAwareType -{ - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver) - { - $resolver->setDefaults([ - 'choices' => [ - $this->trans('Yes', 'Admin.Global') => 1, - $this->trans('No', 'Admin.Global') => 0, - ], - 'required' => false, - 'choice_translation_domain' => false, - ]); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return ChoiceType::class; - } -} diff --git a/src/PrestaShopBundle/Form/DataTransformer/ArabicToLatinDigitDataTransformer.php b/src/PrestaShopBundle/Form/DataTransformer/ArabicToLatinDigitDataTransformer.php deleted file mode 100644 index 6e8652c3..00000000 --- a/src/PrestaShopBundle/Form/DataTransformer/ArabicToLatinDigitDataTransformer.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShopBundle\Form\DataTransformer; - -use PrestaShop\PrestaShop\Core\Util\ArabicToLatinDigitConverter; -use Symfony\Component\Form\DataTransformerInterface; - -/** - * Class ArabicToLatinDigitDataTransformer is responsible for converting arabic/persian digits to latin digits - */ -final class ArabicToLatinDigitDataTransformer implements DataTransformerInterface -{ - /** - * @var ArabicToLatinDigitConverter - */ - private $arabicToLatinDigitConverter; - - public function __construct(ArabicToLatinDigitConverter $arabicToLatinDigitConverter) - { - $this->arabicToLatinDigitConverter = $arabicToLatinDigitConverter; - } - - /** - * Do not transform latin number to arabic/persian number as - * the javascript datepicker will handle that on its side - * - * {@inheritdoc} - */ - public function transform($value) - { - return $value; - } - - /** - * {@inheritdoc} - */ - public function reverseTransform($value) - { - if (null === $value || '' === $value) { - return null; - } - - return $this->arabicToLatinDigitConverter->convert($value); - } -} diff --git a/src/PrestaShopBundle/Form/DataTransformer/DefaultLanguageToFilledArrayDataTransformer.php b/src/PrestaShopBundle/Form/DataTransformer/DefaultLanguageToFilledArrayDataTransformer.php deleted file mode 100644 index 2c64c442..00000000 --- a/src/PrestaShopBundle/Form/DataTransformer/DefaultLanguageToFilledArrayDataTransformer.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\DataTransformer; - -use Symfony\Component\Form\DataTransformerInterface; - -/** - * Class DefaultLanguageToFilledArrayDataTransformer is responsible for filling empty array values with - * default language value if such exists. - */ -final class DefaultLanguageToFilledArrayDataTransformer implements DataTransformerInterface -{ - /** - * @var int - */ - private $defaultLanguageId; - - /** - * @param int $defaultLanguageId - */ - public function __construct($defaultLanguageId) - { - $this->defaultLanguageId = $defaultLanguageId; - } - - /** - * {@inheritdoc} - */ - public function transform($value) - { - // No transformation is required here due to this data is being sent to template - return $value; - } - - /** - * {@inheritdoc} - * - * @param array $values - */ - public function reverseTransform($values) - { - if (!$this->assertIsValidForDataTransforming($values)) { - return $values; - } - - $defaultValue = $values[$this->defaultLanguageId]; - foreach ($values as $languageId => $item) { - if (!$item) { - $values[$languageId] = $defaultValue; - } - } - - return $values; - } - - /** - * Checks if the value is array and default language key exists in array. - * - * @param array $values - * - * @return bool - */ - private function assertIsValidForDataTransforming($values) - { - return is_array($values) && isset($values[$this->defaultLanguageId]) && $values[$this->defaultLanguageId]; - } -} diff --git a/src/PrestaShopBundle/Form/DataTransformer/IDNConverterDataTransformer.php b/src/PrestaShopBundle/Form/DataTransformer/IDNConverterDataTransformer.php deleted file mode 100644 index 80a40500..00000000 --- a/src/PrestaShopBundle/Form/DataTransformer/IDNConverterDataTransformer.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShopBundle\Form\DataTransformer; - -use PrestaShop\PrestaShop\Core\Util\InternationalizedDomainNameConverter; -use Symfony\Component\Form\DataTransformerInterface; - -/** - * Class DefaultLanguageToFilledArrayDataTransformer is responsible for filling empty array values with - * default language value if such exists. - */ -final class IDNConverterDataTransformer implements DataTransformerInterface -{ - /** - * @var InternationalizedDomainNameConverter - */ - private $converter; - - public function __construct(InternationalizedDomainNameConverter $converter) - { - $this->converter = $converter; - } - - /** - * {@inheritdoc} - * - * Do not convert utf8 to punycode, should be done on the client side - */ - public function transform($value) - { - return $value; - } - - /** - * {@inheritdoc} - * - * Convert punycode to utf8 (prestashop@xn--80aswg.xn--p1ai -> prestashop@сайт.рф) - */ - public function reverseTransform($value) - { - return is_string($value) ? $this->converter->emailToUtf8($value) : $value; - } -} diff --git a/src/PrestaShopBundle/Form/DataTransformer/StringArrayToIntegerArrayDataTransformer.php b/src/PrestaShopBundle/Form/DataTransformer/StringArrayToIntegerArrayDataTransformer.php deleted file mode 100644 index 91a0fe4d..00000000 --- a/src/PrestaShopBundle/Form/DataTransformer/StringArrayToIntegerArrayDataTransformer.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\DataTransformer; - -use Symfony\Component\Form\DataTransformerInterface; - -/** - * Class StringArrayToIntegerArrayTransformer is responsible for applying reverse transformation when form is being - * submitted. If its array, it casts all elements to integer. - */ -final class StringArrayToIntegerArrayDataTransformer implements DataTransformerInterface -{ - /** - * {@inheritdoc} - */ - public function transform($value) - { - // No transformation is required here due to this data is being sent to template - return $value; - } - - /** - * {@inheritdoc} - */ - public function reverseTransform($value) - { - if (!is_array($value)) { - return $value; - } - - return array_map(function ($item) { - return (int) $item; - }, $value); - } -} diff --git a/src/PrestaShopBundle/Form/Extension/DataListExtension.php b/src/PrestaShopBundle/Form/Extension/DataListExtension.php deleted file mode 100644 index 47f26ab9..00000000 --- a/src/PrestaShopBundle/Form/Extension/DataListExtension.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Extension; - -use Symfony\Component\Form\AbstractTypeExtension; -use Symfony\Component\Form\Extension\Core\Type\TextType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * Extends TextType with tag feature - */ -class DataListExtension extends AbstractTypeExtension -{ - /** - * {@inheritdoc} - */ - public function configureOptions(OptionsResolver $resolver): void - { - $resolver - ->setDefaults([ - 'data_list' => null, - ]) - ->setAllowedTypes('data_list', ['null', 'array']) - ; - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options): void - { - $view->vars['data_list'] = $options['data_list']; - } - - /** - * {@inheritdoc} - */ - public function getExtendedType(): string - { - return TextType::class; - } -} diff --git a/src/PrestaShopBundle/Form/Validator/Constraints/TinyMceMaxLength.php b/src/PrestaShopBundle/Form/Validator/Constraints/TinyMceMaxLength.php deleted file mode 100644 index 5198544f..00000000 --- a/src/PrestaShopBundle/Form/Validator/Constraints/TinyMceMaxLength.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Validator\Constraints; - -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\Exception\MissingOptionsException; - -class TinyMceMaxLength extends Constraint -{ - public $max; - - public function __construct($options = null) - { - if (null !== $options && !is_array($options)) { - $options = [ - 'max' => $options, - ]; - } - - parent::__construct($options); - - if (null === $this->max) { - throw new MissingOptionsException(sprintf('Option "max" must be given for constraint %s', __CLASS__), ['max']); - } - } -} diff --git a/src/PrestaShopBundle/Form/Validator/Constraints/TinyMceMaxLengthValidator.php b/src/PrestaShopBundle/Form/Validator/Constraints/TinyMceMaxLengthValidator.php deleted file mode 100644 index 78f1eae1..00000000 --- a/src/PrestaShopBundle/Form/Validator/Constraints/TinyMceMaxLengthValidator.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Form\Validator\Constraints; - -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; - -class TinyMceMaxLengthValidator extends ConstraintValidator -{ - public function validate($value, Constraint $constraint) - { - $replaceArray = [ - "\n", - "\r", - "\n\r", - ]; - $str = str_replace($replaceArray, [''], strip_tags($value)); - - if (iconv_strlen($str) > $constraint->max) { - $this->context->addViolation( - (new LegacyContext())->getContext()->getTranslator()->trans('This value is too long. It should have %limit% characters or less.', [], 'Admin.Catalog.Notification'), - ['%limit%' => $constraint->max] - ); - } - } -} diff --git a/src/PrestaShopBundle/Install/AbstractInstall.php b/src/PrestaShopBundle/Install/AbstractInstall.php deleted file mode 100644 index 5c88726a..00000000 --- a/src/PrestaShopBundle/Install/AbstractInstall.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Install; - -abstract class AbstractInstall -{ - /** - * @var LanguageList - */ - public $language; - - /** - * @var \PrestaShopBundle\Translation\Translator - */ - public $translator; - - /** - * @var array List of errors - */ - protected $errors = []; - - public function __construct() - { - $this->language = LanguageList::getInstance(); - } - - public function setError($errors) - { - if (!is_array($errors)) { - $errors = [$errors]; - } - - $this->errors = array_merge($this->errors, $errors); - } - - public function getErrors() - { - return $this->errors; - } - - public function setTranslator($translator) - { - $this->translator = $translator; - - return $this; - } -} diff --git a/src/PrestaShopBundle/Install/Database.php b/src/PrestaShopBundle/Install/Database.php deleted file mode 100644 index 497d9c7b..00000000 --- a/src/PrestaShopBundle/Install/Database.php +++ /dev/null @@ -1,132 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Install; - -use PrestaShop\PrestaShop\Adapter\Entity\Db; -use PrestaShop\PrestaShop\Adapter\Entity\Validate; - -class Database extends AbstractInstall -{ - /** - * Check database configuration and try a connection. - * - * @param string $server - * @param string $database - * @param string $login - * @param string $password - * @param string $prefix - * @param bool $clear - * - * @return array List of errors - */ - public function testDatabaseSettings($server, $database, $login, $password, $prefix, $clear = false) - { - $errors = []; - - // Check if fields are correctly typed - if (!$server || !Validate::isUrl($server)) { - $errors[] = $this->translator->trans('Server name is not valid', [], 'Install'); - } - - if (!$database) { - $errors[] = $this->translator->trans('You must enter a database name', [], 'Install'); - } - - if (!$login) { - $errors[] = $this->translator->trans('You must enter a database login', [], 'Install'); - } - - if ($prefix && !Validate::isTablePrefix($prefix)) { - $errors[] = $this->translator->trans('Tables prefix is invalid', [], 'Install'); - } - - if (!$errors) { - $dbtype = ' (' . Db::getClass() . ')'; - // Try to connect to database - switch (Db::checkConnection($server, $login, $password, $database, true)) { - case 0: - if (!Db::checkEncoding($server, $login, $password)) { - $errors[] = $this->translator->trans('Cannot convert database data to utf-8', [], 'Install') . $dbtype; - } - - // Check if a table with same prefix already exists - if (!$clear && Db::hasTableWithSamePrefix($server, $login, $password, $database, $prefix)) { - $errors[] = $this->translator->trans('At least one table with same prefix was already found, please change your prefix or drop your database', [], 'Install'); - } - if (!Db::checkAutoIncrement($server, $login, $password)) { - $errors[] = $this->translator->trans('The values of auto_increment increment and offset must be set to 1', [], 'Install'); - } - if (($create_error = Db::checkCreatePrivilege($server, $login, $password, $database, $prefix)) !== true) { - $errors[] = $this->translator->trans('Your database login does not have the privileges to create table on the database "%s". Ask your hosting provider:', ['%database%' => $database], 'Install'); - if ($create_error != false) { - $errors[] = $create_error; - } - } - - break; - - case 1: - $errors[] = $this->translator->trans('Database Server is not found. Please verify the login, password and server fields', [], 'Install') . $dbtype; - - break; - - case 2: - $error = $this->translator->trans('Connection to MySQL server succeeded, but database "%database%" not found', ['%database%' => $database], 'Install') . $dbtype; - if ($this->createDatabase($server, $database, $login, $password, true)) { - $error .= '

    ' . sprintf('', $this->translator->trans('Attempt to create the database automatically', [], 'Install')) . '

    - '; - } - $errors[] = $error; - - break; - } - } - - if (count($errors)) { - $this->setError($errors); - } - - return $errors; - } - - public function createDatabase($server, $database, $login, $password, $dropit = false) - { - $class = '\\' . Db::getClass(); - - return call_user_func([$class, 'createDatabase'], $server, $login, $password, $database, $dropit); - } - - public function getBestEngine($server, $database, $login, $password) - { - $class = '\\' . Db::getClass(); - $instance = new $class($server, $login, $password, $database, true); - $engine = $instance->getBestEngine(); - unset($instance); - - return $engine; - } -} diff --git a/src/PrestaShopBundle/Install/DatabaseDump.php b/src/PrestaShopBundle/Install/DatabaseDump.php deleted file mode 100644 index 751c5451..00000000 --- a/src/PrestaShopBundle/Install/DatabaseDump.php +++ /dev/null @@ -1,156 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Install; - -use Exception; - -class DatabaseDump -{ - private $host; - private $port; - private $user; - private $password; - private $databaseName; - private $dumpFile; - - /** - * Constructor extracts database connection info from PrestaShop's configuration, - * but we use mysqldump and mysql for dump / restore. - * - * @param string $dumpFile dump file name - */ - private function __construct($dumpFile = null) - { - $host_and_maybe_port = explode(':', _DB_SERVER_); - - if (count($host_and_maybe_port) === 1) { - $this->host = $host_and_maybe_port[0]; - $this->port = 3306; - } elseif (count($host_and_maybe_port) === 2) { - $this->host = $host_and_maybe_port[0]; - $this->port = $host_and_maybe_port[1]; - } - - if ($dumpFile === null) { - $this->dumpFile = sys_get_temp_dir() . '/' . 'ps_dump.sql'; - } else { - $this->dumpFile = $dumpFile; - } - $this->databaseName = _DB_NAME_; - $this->user = _DB_USER_; - $this->password = _DB_PASSWD_; - } - - /** - * Wrapper to easily build mysql commands: sets password, port, user. - * - * @param string $executable - * @param array $arguments - * - * @return string - */ - private function buildMySQLCommand($executable, array $arguments = []) - { - $parts = [ - escapeshellarg($executable), - '-u', escapeshellarg($this->user), - '-P', escapeshellarg($this->port), - '-h', escapeshellarg($this->host), - ]; - - if ($this->password) { - $parts[] = '-p' . escapeshellarg($this->password); - } - - $parts = array_merge($parts, array_map('escapeshellarg', $arguments)); - - return implode(' ', $parts); - } - - /** - * Like exec, but will raise an exception if the command failed. - * - * @param string $command - * - * @return array - * - * @throws Exception - */ - private function exec($command) - { - $output = []; - $ret = 1; - exec($command, $output, $ret); - - if ($ret !== 0) { - throw new Exception(sprintf('Unable to exec command: `%s`, missing a binary?', $command)); - } - - return $output; - } - - /** - * The actual dump function. - */ - private function dump() - { - $dumpCommand = $this->buildMySQLCommand('mysqldump', [$this->databaseName]); - $dumpCommand .= ' > ' . escapeshellarg($this->dumpFile) . ' 2> /dev/null'; - $this->exec($dumpCommand); - } - - /** - * Restore the dump to the actual database. - */ - public function restore() - { - $restoreCommand = $this->buildMySQLCommand('mysql', [$this->databaseName]); - $restoreCommand .= ' < ' . escapeshellarg($this->dumpFile) . ' 2> /dev/null'; - $this->exec($restoreCommand); - } - - /** - * Make a database dump. - */ - public static function create() - { - $dump = new static(); - - $dump->dump(); - } - - /** - * Restore a database dump. - */ - public static function restoreDb() - { - $dump = new static(); - - $dump->restore(); - } -} diff --git a/src/PrestaShopBundle/Install/Install.php b/src/PrestaShopBundle/Install/Install.php deleted file mode 100644 index 2ce6df8f..00000000 --- a/src/PrestaShopBundle/Install/Install.php +++ /dev/null @@ -1,1174 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Install; - -use AppKernel; -use InstallSession; -use Language as LanguageLegacy; -use PhpEncryption; -use PrestaShop\PrestaShop\Adapter\Entity\Cache; -use PrestaShop\PrestaShop\Adapter\Entity\Cart; -use PrestaShop\PrestaShop\Adapter\Entity\Category; -use PrestaShop\PrestaShop\Adapter\Entity\Configuration; -use PrestaShop\PrestaShop\Adapter\Entity\Context; -use PrestaShop\PrestaShop\Adapter\Entity\Cookie; -use PrestaShop\PrestaShop\Adapter\Entity\Country; -use PrestaShop\PrestaShop\Adapter\Entity\Currency; -use PrestaShop\PrestaShop\Adapter\Entity\Db; -use PrestaShop\PrestaShop\Adapter\Entity\Employee; -use PrestaShop\PrestaShop\Adapter\Entity\FileLogger; -use PrestaShop\PrestaShop\Adapter\Entity\Group; -use PrestaShop\PrestaShop\Adapter\Entity\ImageManager; -use PrestaShop\PrestaShop\Adapter\Entity\ImageType; -use PrestaShop\PrestaShop\Adapter\Entity\Language as EntityLanguage; -use PrestaShop\PrestaShop\Adapter\Entity\LocalizationPack; -use PrestaShop\PrestaShop\Adapter\Entity\Module; -use PrestaShop\PrestaShop\Adapter\Entity\PrestaShopCollection; -use PrestaShop\PrestaShop\Adapter\Entity\Search; -use PrestaShop\PrestaShop\Adapter\Entity\Shop; -use PrestaShop\PrestaShop\Adapter\Entity\ShopGroup; -use PrestaShop\PrestaShop\Adapter\Entity\ShopUrl; -use PrestaShop\PrestaShop\Adapter\Entity\Tools; -use PrestaShop\PrestaShop\Adapter\Entity\Validate; -use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder; -use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeManagerBuilder; -use PrestaShopBundle\Cache\LocalizationWarmer; -use PrestaShopBundle\Service\Database\Upgrade as UpgradeDatabase; -use PrestashopInstallerException; -use Symfony\Component\Yaml\Yaml; - -class Install extends AbstractInstall -{ - const SETTINGS_FILE = 'config/settings.inc.php'; - const BOOTSTRAP_FILE = 'config/bootstrap.php'; - - protected $logger; - - /** - * The path of the bootsrap file we want to use for the installation. - * - * @var string - */ - protected $bootstrapFile = null; - - /** - * The path of the settings file we want to use for the installation. - * - * @var string - */ - protected $settingsFile = null; - - public function __construct($settingsFile = null, $bootstrapFile = null) - { - if ($bootstrapFile === null) { - $bootstrapFile = static::BOOTSTRAP_FILE; - } - - if ($settingsFile === null) { - $settingsFile = static::SETTINGS_FILE; - } - - $this->settingsFile = $settingsFile; - $this->bootstrapFile = $bootstrapFile; - parent::__construct(); - } - - public function setError($errors) - { - static $logger = null; - - if (null === $logger) { - $logger = new FileLogger(); - $logger->setFilename( - _PS_ROOT_DIR_ . '/var/logs/' . _PS_ENV_ . '_' . @date('Ymd') . '_installation.log' - ); - $this->logger = $logger; - } - - if (!is_array($errors)) { - $errors = [$errors]; - } - - parent::setError($errors); - - foreach ($errors as $error) { - $this->logger->logError($error); - } - } - - /** - * Generate the settings file. - */ - public function generateSettingsFile( - $database_host, - $database_user, - $database_password, - $database_name, - $database_prefix, - $database_engine - ) { - // Check permissions for settings file - if ( - file_exists(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $this->settingsFile) - && !is_writable(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $this->settingsFile) - ) { - $this->setError($this->translator->trans('%file% file is not writable (check permissions)', ['%file%' => $this->settingsFile], 'Install')); - - return false; - } elseif ( - !file_exists(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . $this->settingsFile) - && !is_writable(_PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . dirname($this->settingsFile)) - ) { - $this->setError( - $this->translator->trans( - '%folder% folder is not writable (check permissions)', - ['%folder%' => dirname($this->settingsFile)], - 'Install' - ) - ); - - return false; - } - - $secret = Tools::passwdGen(64); - $cookie_key = defined('_COOKIE_KEY_') ? _COOKIE_KEY_ : Tools::passwdGen(64); - $cookie_iv = defined('_COOKIE_IV_') ? _COOKIE_IV_ : Tools::passwdGen(32); - $database_port = null; - - $splits = preg_split('#:#', $database_host); - $nbSplits = count($splits); - - if ($nbSplits >= 2) { - $database_port = array_pop($splits); - $database_host = implode(':', $splits); - } - - $key = PhpEncryption::createNewRandomKey(); - - $parameters = [ - 'parameters' => [ - 'database_host' => $database_host, - 'database_port' => $database_port, - 'database_user' => $database_user, - 'database_password' => $database_password, - 'database_name' => $database_name, - 'database_prefix' => $database_prefix, - 'database_engine' => $database_engine, - 'cookie_key' => $cookie_key, - 'cookie_iv' => $cookie_iv, - 'new_cookie_key' => $key, - 'ps_creation_date' => date('Y-m-d'), - 'secret' => $secret, - 'locale' => $this->language->getLanguage()->getLocale(), - ], - ]; - - array_walk($parameters['parameters'], function (&$param) { - $param = str_replace('%', '%%', $param); - }); - - $parameters = array_replace_recursive( - Yaml::parse(file_get_contents(_PS_ROOT_DIR_ . '/app/config/parameters.yml.dist')), - $parameters - ); - - $settings_content = "settingsFile, $settings_content)) { - $this->setError($this->translator->trans('Cannot write settings file', [], 'Install')); - - return false; - } - - if (!$this->processParameters($parameters)) { - return false; - } - - return true; - } - - /** - * Replace "parameters.yml" with "parameters.php" in "app/config". - * - * @param $parameters - * - * @return bool|int - */ - public function processParameters($parameters) - { - $parametersContent = sprintf('setError($this->translator->trans('Cannot write app/config/parameters.php file', [], 'Install')); - - return false; - } else { - return $this->emptyYamlParameters(); - } - } - - /** - * Prevent availability of YAML parameters. - */ - protected function emptyYamlParameters() - { - if (!file_put_contents(_PS_ROOT_DIR_ . '/app/config/parameters.yml', 'parameters:')) { - $this->setError($this->translator->trans('Cannot write app/config/parameters.yml file', [], 'Install')); - - return false; - } - - return $this->clearCache(); - } - - protected function clearCache() - { - if (defined('_PS_IN_TEST_')) { - return true; - } - - try { - Tools::clearSf2Cache('prod'); - Tools::clearSf2Cache('dev'); - } catch (\Exception $e) { - $this->setError($e->getMessage()); - - return false; - } - - return true; - } - - /** - * PROCESS : installDatabase - * Generate settings file and create database structure. - */ - public function installDatabase($clear_database = false) - { - // Clear database (only tables with same prefix) - require_once _PS_ROOT_DIR_ . '/' . $this->bootstrapFile; - if ($clear_database) { - $this->clearDatabase(); - } - - $allowed_collation = ['utf8mb4_general_ci', 'utf8mb4_unicode_ci']; - $collation_database = Db::getInstance()->getValue('SELECT @@collation_database'); - // Install database structure - $sql_loader = new SqlLoader(); - $sql_loader->setMetaData([ - 'PREFIX_' => _DB_PREFIX_, - 'ENGINE_TYPE' => _MYSQL_ENGINE_, - 'COLLATION' => (empty($collation_database) || !in_array($collation_database, $allowed_collation)) ? '' : 'COLLATE ' . $collation_database, - ]); - - try { - $sql_loader->parse_file(_PS_INSTALL_DATA_PATH_ . 'db_structure.sql'); - } catch (PrestashopInstallerException $e) { - $this->setError($this->translator->trans('Database structure file not found', [], 'Install')); - - return false; - } - - if ($errors = $sql_loader->getErrors()) { - foreach ($errors as $error) { - $this->setError($this->translator->trans('SQL error on query %query%', ['%query%' => $error['error']], 'Install')); - } - - return false; - } - - return $this->generateSf2ProductionEnv(); - } - - /** - * Pass SF2 to production - * cache:clear - * assetic:dump - * doctrine:schema:update. - * - * @return bool - */ - public function generateSf2ProductionEnv() - { - if (defined('_PS_IN_TEST_')) { - return true; - } - $schemaUpgrade = new UpgradeDatabase(); - $schemaUpgrade->addDoctrineSchemaUpdate(); - $output = $schemaUpgrade->execute(); - - if (0 !== $output['prestashop:schema:update-without-foreign']['exitCode']) { - $this->setError(explode("\n", $output['prestashop:schema:update-without-foreign']['output'])); - - return false; - } - - return true; - } - - /** - * Clear database (only tables with same prefix). - * - * @param bool $truncate If true truncate the table, if false drop the table - */ - public function clearDatabase($truncate = false) - { - $instance = Db::getInstance(); - $instance->execute('SET FOREIGN_KEY_CHECKS=0'); - foreach ($instance->executeS('SHOW TABLES') as $row) { - $table = current($row); - if (!_DB_PREFIX_ || preg_match('#^' . _DB_PREFIX_ . '#i', $table)) { - $instance->execute((($truncate) ? 'TRUNCATE TABLE ' : 'DROP TABLE ') . '`' . $table . '`'); - } - } - - $instance->execute('SET FOREIGN_KEY_CHECKS=1'); - } - - /** - * Initialize the prestashop context with default values during tests. - */ - public function initializeTestContext() - { - $smarty = null; - // Clean all cache values - Cache::clean('*'); - - $_SERVER['HTTP_HOST'] = 'localhost'; - $this->language->setLanguage('en'); - $context = Context::getContext(); - $context->shop = new Shop(1); - Shop::setContext(Shop::CONTEXT_SHOP, 1); - Configuration::loadConfiguration(); - if (!isset($context->language) || !Validate::isLoadedObject($context->language)) { - $context->language = new Language('en'); - } - - if (!isset($context->country) || !Validate::isLoadedObject($context->country)) { - if ($id_country = (int) Configuration::get('PS_COUNTRY_DEFAULT')) { - $context->country = new Country((int) $id_country); - } - } - if (!isset($context->currency) || !Validate::isLoadedObject($context->currency)) { - if ($id_currency = (int) Configuration::get('PS_CURRENCY_DEFAULT')) { - $context->currency = new Currency((int) $id_currency); - } - } - - /* Instantiate cookie */ - $cookie_lifetime = defined('_PS_ADMIN_DIR_') ? (int) Configuration::get('PS_COOKIE_LIFETIME_BO') : (int) Configuration::get('PS_COOKIE_LIFETIME_FO'); - if ($cookie_lifetime > 0) { - $cookie_lifetime = time() + (max($cookie_lifetime, 1) * 3600); - } - - $cookie = new Cookie('ps-s' . $context->shop->id, '', $cookie_lifetime, 'localhost', false, false); - - $context->cookie = $cookie; - - $context->cart = new Cart(); - $context->employee = new Employee(1); - if (!defined('_PS_SMARTY_FAST_LOAD_')) { - define('_PS_SMARTY_FAST_LOAD_', true); - } - require_once _PS_ROOT_DIR_ . '/config/smarty.config.inc.php'; - - $context->smarty = $smarty; - } - - /** - * PROCESS : installDefaultData - * Create default shop and languages. - */ - public function installDefaultData($shop_name, $iso_country = false, $all_languages = false, $clear_database = false) - { - if ($clear_database) { - $this->clearDatabase(true); - } - - // Install first shop - if (!$this->createShop($shop_name)) { - return false; - } - - // Install languages - try { - if (!$all_languages) { - $iso_codes_to_install = [$this->language->getLanguageIso()]; - if ($iso_country) { - $version = str_replace('.', '', AppKernel::VERSION); - $version = substr($version, 0, 2); - $localization_file_content = $this->getLocalizationPackContent($version, $iso_country); - - if ($xml = @simplexml_load_string($localization_file_content)) { - foreach ($xml->languages->language as $language) { - $iso_codes_to_install[] = (string) $language->attributes()->iso_code; - } - } - } - $iso_codes_to_install = array_unique($iso_codes_to_install); - } else { - $iso_codes_to_install = null; - } - $languages = $this->installLanguages($iso_codes_to_install); - } catch (PrestashopInstallerException $e) { - $this->setError($e->getMessage()); - - return false; - } - - $flip_languages = array_flip($languages); - $id_lang = (!empty($flip_languages[$this->language->getLanguageIso()])) ? $flip_languages[$this->language->getLanguageIso()] : 1; - Configuration::updateGlobalValue('PS_LANG_DEFAULT', $id_lang); - Configuration::updateGlobalValue('PS_VERSION_DB', _PS_INSTALL_VERSION_); - Configuration::updateGlobalValue('PS_INSTALL_VERSION', _PS_INSTALL_VERSION_); - - Context::getContext()->language = new LanguageLegacy($id_lang); - - return true; - } - - /** - * PROCESS : populateDatabase - * Populate database with default data. - */ - public function populateDatabase($entity = null) - { - $languages = []; - foreach (EntityLanguage::getLanguages(true) as $lang) { - $languages[$lang['id_lang']] = $lang['iso_code']; - } - - // Install XML data (data/xml/ folder) - $xml_loader = new XmlLoader(); - $xml_loader->setTranslator($this->translator); - $xml_loader->setLanguages($languages); - - if (isset($this->xml_loader_ids) && $this->xml_loader_ids) { - $xml_loader->setIds($this->xml_loader_ids); - } - - try { - if ($entity) { - $xml_loader->populateEntity($entity); - } else { - $xml_loader->populateFromXmlFiles(); - } - if ($errors = $xml_loader->getErrors()) { - $this->setError($errors); - - return false; - } - - // IDS from xmlLoader are stored in order to use them for fixtures - $this->xml_loader_ids = $xml_loader->getIds(); - unset($xml_loader); - - // Install custom SQL data (db_data.sql file) - if (file_exists(_PS_INSTALL_DATA_PATH_ . 'db_data.sql')) { - $sql_loader = new SqlLoader(); - $sql_loader->setMetaData([ - 'PREFIX_' => _DB_PREFIX_, - 'ENGINE_TYPE' => _MYSQL_ENGINE_, - ]); - - $sql_loader->parse_file(_PS_INSTALL_DATA_PATH_ . 'db_data.sql', false); - if ($errors = $sql_loader->getErrors()) { - $this->setError($errors); - - return false; - } - } - } catch (PrestashopInstallerException $e) { - $this->setError($e->getMessage()); - - return false; - } - - return true; - } - - public function createShop($shop_name) - { - // Create default group shop - $shop_group = new ShopGroup(); - $shop_group->name = 'Default'; - $shop_group->active = true; - if (!$shop_group->add()) { - $this->setError($this->translator->trans('Cannot create group shop', [], 'Install') . ' / ' . Db::getInstance()->getMsgError()); - - return false; - } - - // Create default shop - $shop = new Shop(); - $shop->active = true; - $shop->id_shop_group = $shop_group->id; - $shop->id_category = 2; - $shop->theme_name = _THEME_NAME_; - $shop->name = $shop_name; - if (!$shop->add()) { - $this->setError($this->translator->trans('Cannot create shop', [], 'Install') . ' / ' . Db::getInstance()->getMsgError()); - - return false; - } - $shop->setTheme(); - Context::getContext()->shop = $shop; - - // Create default shop URL - $shop_url = new ShopUrl(); - $shop_url->domain = Tools::getHttpHost(); - $shop_url->domain_ssl = Tools::getHttpHost(); - $shop_url->physical_uri = __PS_BASE_URI__; - $shop_url->id_shop = $shop->id; - $shop_url->main = true; - $shop_url->active = true; - if (!$shop_url->add()) { - $this->setError($this->translator->trans('Cannot create shop URL', [], 'Install') . ' / ' . Db::getInstance()->getMsgError()); - - return false; - } - - return true; - } - - /** - * Install languages. - * - * @return array Association between ID and iso array(id_lang => iso, ...) - */ - public function installLanguages($languages_list = null) - { - if ($languages_list == null || !is_array($languages_list) || !count($languages_list)) { - $languages_list = $this->language->getIsoList(); - } - - $languages_list = array_unique($languages_list); - - $languages_available = $this->language->getIsoList(); - $languages = []; - - foreach ($languages_list as $iso) { - if (!in_array($iso, $languages_available)) { - EntityLanguage::downloadAndInstallLanguagePack($iso); - - continue; - } - - if (!file_exists(_PS_INSTALL_LANGS_PATH_ . $iso . '/language.xml')) { - throw new PrestashopInstallerException($this->translator->trans('File "language.xml" not found for language iso "%iso%"', ['%iso%' => $iso], 'Install')); - } - - if (!$xml = @simplexml_load_file(_PS_INSTALL_LANGS_PATH_ . $iso . '/language.xml')) { - throw new PrestashopInstallerException($this->translator->trans('File "language.xml" not valid for language iso "%iso%"', ['%iso%' => $iso], 'Install')); - } - - $params_lang = [ - 'name' => (string) $xml->name, - 'iso_code' => substr((string) $xml->language_code, 0, 2), - 'allow_accented_chars_url' => (string) $xml->allow_accented_chars_url, - 'language_code' => (string) $xml->language_code, - 'locale' => (string) $xml->locale, - ]; - - if (InstallSession::getInstance()->safe_mode) { - EntityLanguage::checkAndAddLanguage($iso, false, true, $params_lang); - } else { - if (file_exists(_PS_TRANSLATIONS_DIR_ . (string) $iso . '.gzip') == false) { - $language = EntityLanguage::downloadLanguagePack($iso, _PS_INSTALL_VERSION_); - - if ($language == false) { - throw new PrestashopInstallerException($this->translator->trans('Cannot download language pack "%iso%"', ['%iso%' => $iso], 'Install')); - } - } - - $errors = []; - EntityLanguage::installLanguagePack($iso, $params_lang, $errors); - } - - EntityLanguage::loadLanguages(); - - Tools::clearCache(); - - if (!$id_lang = EntityLanguage::getIdByIso($iso, true)) { - throw new PrestashopInstallerException($this->translator->trans('Cannot install language "%iso%"', ['%iso%' => ($xml->name ? $xml->name : $iso)], 'Install')); - } - - $languages[$id_lang] = $iso; - - // Copy language flag - if (is_writable(_PS_IMG_DIR_ . 'l/')) { - if (!copy(_PS_INSTALL_LANGS_PATH_ . $iso . '/flag.jpg', _PS_IMG_DIR_ . 'l/' . $id_lang . '.jpg')) { - throw new PrestashopInstallerException($this->translator->trans('Cannot copy flag language "%flag%"', ['%flag%' => _PS_INSTALL_LANGS_PATH_ . $iso . '/flag.jpg => ' . _PS_IMG_DIR_ . 'l/' . $id_lang . '.jpg'], 'Install')); - } - } - } - - return $languages; - } - - public function copyLanguageImages($iso) - { - $img_path = _PS_INSTALL_LANGS_PATH_ . $iso . '/img/'; - if (!is_dir($img_path)) { - return; - } - - $list = [ - 'products' => _PS_PROD_IMG_DIR_, - 'categories' => _PS_CAT_IMG_DIR_, - 'manufacturers' => _PS_MANU_IMG_DIR_, - 'suppliers' => _PS_SUPP_IMG_DIR_, - 'stores' => _PS_STORE_IMG_DIR_, - null => _PS_IMG_DIR_ . 'l/', // Little trick to copy images in img/l/ path with all types - ]; - - foreach ($list as $cat => $dst_path) { - if (!is_writable($dst_path)) { - continue; - } - - copy($img_path . $iso . '.jpg', $dst_path . $iso . '.jpg'); - - $types = ImageType::getImagesTypes($cat); - foreach ($types as $type) { - if (file_exists($img_path . $iso . '-default-' . $type['name'] . '.jpg')) { - copy( - $img_path . $iso . '-default-' . $type['name'] . '.jpg', - $dst_path . $iso . '-default-' . $type['name'] . '.jpg' - ); - } else { - ImageManager::resize( - $img_path . $iso . '.jpg', - $dst_path . $iso . '-default-' . $type['name'] . '.jpg', - $type['width'], - $type['height'] - ); - } - } - } - } - - private static $_cache_localization_pack_content = null; - - public function getLocalizationPackContent($version, $country) - { - if (static::$_cache_localization_pack_content === null || array_key_exists($country, static::$_cache_localization_pack_content)) { - $localizationWarmer = new LocalizationWarmer($version, $country); - $localization_file_content = $localizationWarmer->warmUp(_PS_CACHE_DIR_ . 'sandbox' . DIRECTORY_SEPARATOR); - - static::$_cache_localization_pack_content[$country] = $localization_file_content; - } - - return isset(static::$_cache_localization_pack_content[$country]) ? static::$_cache_localization_pack_content[$country] : false; - } - - /** - * PROCESS : configureShop - * Set default shop configuration. - */ - public function configureShop(array $data = []) - { - //clear image cache in tmp folder - if (file_exists(_PS_TMP_IMG_DIR_)) { - foreach (scandir(_PS_TMP_IMG_DIR_, SCANDIR_SORT_NONE) as $file) { - if ($file[0] != '.' && $file != 'index.php') { - Tools::deleteFile(_PS_TMP_IMG_DIR_ . $file); - } - } - } - - $default_data = [ - 'shop_name' => 'My Shop', - 'shop_activity' => '', - 'shop_country' => 'us', - 'shop_timezone' => 'US/Eastern', // TODO : this timezone is deprecated - 'use_smtp' => false, - 'smtp_encryption' => 'off', - 'smtp_port' => 25, - 'rewrite_engine' => false, - 'enable_ssl' => false, - ]; - - foreach ($default_data as $k => $v) { - if (!isset($data[$k])) { - $data[$k] = $v; - } - } - - Context::getContext()->shop = new Shop(1); - Configuration::loadConfiguration(); - - $id_country = (int) Country::getByIso($data['shop_country']); - - // Set default configuration - Configuration::updateGlobalValue('PS_SHOP_DOMAIN', Tools::getHttpHost()); - Configuration::updateGlobalValue('PS_SHOP_DOMAIN_SSL', Tools::getHttpHost()); - Configuration::updateGlobalValue('PS_INSTALL_VERSION', _PS_INSTALL_VERSION_); - Configuration::updateGlobalValue('PS_LOCALE_LANGUAGE', $this->language->getLanguageIso()); - Configuration::updateGlobalValue('PS_SHOP_NAME', $data['shop_name']); - Configuration::updateGlobalValue('PS_SHOP_ACTIVITY', $data['shop_activity']); - Configuration::updateGlobalValue('PS_COUNTRY_DEFAULT', $id_country); - Configuration::updateGlobalValue('PS_LOCALE_COUNTRY', $data['shop_country']); - Configuration::updateGlobalValue('PS_TIMEZONE', $data['shop_timezone']); - Configuration::updateGlobalValue('PS_CONFIGURATION_AGREMENT', (int) $data['configuration_agrement']); - - // Set SSL configuration - Configuration::updateGlobalValue('PS_SSL_ENABLED', (int) $data['enable_ssl']); - Configuration::updateGlobalValue('PS_SSL_ENABLED_EVERYWHERE', (int) $data['enable_ssl']); - - // Set mails configuration - Configuration::updateGlobalValue('PS_MAIL_METHOD', ($data['use_smtp']) ? 2 : 1); - Configuration::updateGlobalValue('PS_MAIL_SMTP_ENCRYPTION', $data['smtp_encryption']); - Configuration::updateGlobalValue('PS_MAIL_SMTP_PORT', $data['smtp_port']); - - // Set default rewriting settings - Configuration::updateGlobalValue('PS_REWRITING_SETTINGS', $data['rewrite_engine']); - - $groups = Group::getGroups((int) Configuration::get('PS_LANG_DEFAULT')); - $groups_default = Db::getInstance()->executeS('SELECT `name` FROM ' . _DB_PREFIX_ . 'configuration WHERE `name` LIKE "PS_%_GROUP" ORDER BY `id_configuration`'); - foreach ($groups_default as &$group_default) { - if (is_array($group_default) && isset($group_default['name'])) { - $group_default = $group_default['name']; - } - } - - if (is_array($groups) && count($groups)) { - foreach ($groups as $key => $group) { - if (Configuration::get($groups_default[$key]) != $groups[$key]['id_group']) { - Configuration::updateGlobalValue($groups_default[$key], (int) $groups[$key]['id_group']); - } - } - } - - $states = Db::getInstance()->executeS('SELECT `id_order_state` FROM ' . _DB_PREFIX_ . 'order_state ORDER by `id_order_state`'); - $states_default = Db::getInstance()->executeS('SELECT MIN(`id_configuration`), `name` FROM ' . _DB_PREFIX_ . 'configuration WHERE `name` LIKE "PS_OS_%" GROUP BY `value` ORDER BY`id_configuration`'); - - foreach ($states_default as &$state_default) { - if (is_array($state_default) && isset($state_default['name'])) { - $state_default = $state_default['name']; - } - } - - if (is_array($states) && count($states)) { - foreach ($states as $key => $state) { - if (Configuration::get($states_default[$key]) != $states[$key]['id_order_state']) { - Configuration::updateGlobalValue($states_default[$key], (int) $states[$key]['id_order_state']); - } - } - /* deprecated order state */ - Configuration::updateGlobalValue('PS_OS_OUTOFSTOCK_PAID', (int) Configuration::get('PS_OS_OUTOFSTOCK')); - } - - // Set logo configuration - if (file_exists(_PS_IMG_DIR_ . 'logo.png')) { - list($width, $height) = getimagesize(_PS_IMG_DIR_ . 'logo.png'); - Configuration::updateGlobalValue('SHOP_LOGO_WIDTH', round($width)); - Configuration::updateGlobalValue('SHOP_LOGO_HEIGHT', round($height)); - } - - // Disable cache for debug mode - if (_PS_MODE_DEV_) { - Configuration::updateGlobalValue('PS_SMARTY_CACHE', 1); - } - - // Active only the country selected by the merchant - Db::getInstance()->execute('UPDATE ' . _DB_PREFIX_ . 'country SET active = 0 WHERE id_country != ' . (int) $id_country); - - // Set localization configuration - $version = str_replace('.', '', AppKernel::VERSION); - $version = substr($version, 0, 2); - $localization_file_content = $this->getLocalizationPackContent($version, $data['shop_country']); - - $locale = new LocalizationPack(); - $locale->loadLocalisationPack($localization_file_content, false, true); - - // Create default employee - if (isset($data['admin_firstname'], $data['admin_lastname'], $data['admin_password'], $data['admin_email'])) { - $employee = new Employee(); - $employee->firstname = Tools::ucfirst($data['admin_firstname']); - $employee->lastname = Tools::ucfirst($data['admin_lastname']); - $employee->email = $data['admin_email']; - $employee->setWsPasswd($data['admin_password']); - $employee->last_passwd_gen = date('Y-m-d h:i:s', strtotime('-360 minutes')); - $employee->bo_theme = 'default'; - $employee->default_tab = 1; - $employee->active = true; - $employee->id_profile = 1; - $employee->id_lang = Configuration::get('PS_LANG_DEFAULT'); - $employee->bo_menu = 1; - if (!$employee->add()) { - $this->setError($this->translator->trans('Cannot create admin account', [], 'Install')); - - return false; - } - } else { - $this->setError($this->translator->trans('Cannot create admin account', [], 'Install')); - - return false; - } - - // Update default contact - if (isset($data['admin_email'])) { - Configuration::updateGlobalValue('PS_SHOP_EMAIL', $data['admin_email']); - - $contacts = new PrestaShopCollection('Contact'); - foreach ($contacts as $contact) { - $contact->email = $data['admin_email']; - $contact->update(); - } - } - - if (!@Tools::generateHtaccess(null, $data['rewrite_engine'])) { - Configuration::updateGlobalValue('PS_REWRITING_SETTINGS', 0); - } - - Tools::generateRobotsFile(); - - return true; - } - - public function getModulesList() - { - $modules = []; - if (false) { - foreach (scandir(_PS_MODULE_DIR_, SCANDIR_SORT_NONE) as $module) { - if ($module[0] != '.' && is_dir(_PS_MODULE_DIR_ . $module) && file_exists(_PS_MODULE_DIR_ . $module . '/' . $module . '.php')) { - $modules[] = $module; - } - } - } else { - $modules = [ - 'contactform', - 'dashactivity', - 'dashgoals', - 'dashproducts', - 'dashtrends', - 'graphnvd3', - 'gridhtml', - 'gsitemap', - 'pagesnotfound', - 'productcomments', - 'ps_banner', - 'ps_categorytree', - 'ps_checkpayment', - 'ps_contactinfo', - 'ps_crossselling', - 'ps_currencyselector', - 'ps_customeraccountlinks', - 'ps_customersignin', - 'ps_customtext', - 'ps_dataprivacy', - 'ps_emailsubscription', - 'ps_facetedsearch', - 'ps_faviconnotificationbo', - 'ps_featuredproducts', - 'ps_imageslider', - 'ps_languageselector', - 'ps_linklist', - 'ps_mainmenu', - 'ps_searchbar', - 'ps_sharebuttons', - 'ps_shoppingcart', - 'ps_socialfollow', - 'ps_themecusto', - 'ps_wirepayment', - 'sekeywords', - 'statsbestcategories', - 'statsbestcustomers', - 'statsbestproducts', - 'statsbestsuppliers', - 'statsbestvouchers', - 'statscarrier', - 'statscatalog', - 'statscheckup', - 'statsdata', - 'statsequipment', - 'statsforecast', - 'statslive', - 'statsnewsletter', - 'statsorigin', - 'statspersonalinfos', - 'statsproduct', - 'statsregistrations', - 'statssales', - 'statssearch', - 'statsstock', - 'statsvisits', - 'welcome', - ]; - } - - return $modules; - } - - public function getAddonsModulesList($params = []) - { - /** - * TODO: Remove blacklist once 1.7 is out. - */ - $blacklist = [ - 'bankwire', - 'blockadvertising', - 'blockbanner', - 'blockbestsellers', - 'blockcart', - 'blockcategories', - 'blockcms', - 'blockcmsinfo', - 'blockcontact', - 'blockcontactinfos', - 'blockcurrencies', - 'blockcustomerprivacy', - 'blockfacebook', - 'blocklanguages', - 'blocklayered', - 'blocklink', - 'blockmanufacturer', - 'blockmyaccount', - 'blockmyaccountfooter', - 'blocknewproducts', - 'blocknewsletter', - 'blockpaymentlogo', - 'blockpermanentlinks', - 'blockrss', - 'blocksearch', - 'blocksharefb', - 'blocksocial', - 'blockstore', - 'blockspecials', - 'blocksupplier', - 'blocktags', - 'blocktopmenu', - 'blockuserinfo', - 'blockviewed', - 'blockwishlist', - 'cheque', - 'crossselling', - 'homefeatured', - 'homeslider', - 'onboarding', - 'productscategory', - 'producttooltip', - 'sendtoafriend', - 'socialsharing', - ]; - - $addons_modules = []; - $content = Tools::addonsRequest('install-modules', $params); - $xml = @simplexml_load_string($content, null, LIBXML_NOCDATA); - - if ($xml !== false && isset($xml->module)) { - foreach ($xml->module as $modaddons) { - if (in_array($modaddons->name, $blacklist)) { - continue; - } - $addons_modules[] = ['id_module' => $modaddons->id, 'name' => $modaddons->name]; - } - } - - return $addons_modules; - } - - /** - * PROCESS : installModules - * Download module from addons and Install all modules in ~/modules/ directory. - */ - public function installModulesAddons($module = null) - { - $addons_modules = $module ? [$module] : $this->getAddonsModulesList(); - $modules = []; - - foreach ($addons_modules as $addons_module) { - if (file_put_contents(_PS_MODULE_DIR_ . $addons_module['name'] . '.zip', Tools::addonsRequest('module', ['id_module' => $addons_module['id_module']]))) { - if (Tools::ZipExtract(_PS_MODULE_DIR_ . $addons_module['name'] . '.zip', _PS_MODULE_DIR_)) { - $modules[] = (string) $addons_module['name']; //if the module has been unziped we add the name in the modules list to install - unlink(_PS_MODULE_DIR_ . $addons_module['name'] . '.zip'); - } - } - } - - return count($modules) ? $this->installModules($modules) : true; - } - - /** - * PROCESS : installModules - * Download module from addons and Install all modules in ~/modules/ directory. - */ - public function installModules($module = null) - { - if ($module && !is_array($module)) { - $module = [$module]; - } - - $modules = $module ? $module : $this->getModulesList(); - - Module::updateTranslationsAfterInstall(false); - - $moduleManagerBuilder = ModuleManagerBuilder::getInstance(); - $moduleManager = $moduleManagerBuilder->build(); - - $errors = []; - foreach ($modules as $module_name) { - if (!file_exists(_PS_MODULE_DIR_ . $module_name . '/' . $module_name . '.php')) { - continue; - } - - $moduleException = null; - - try { - $moduleInstalled = $moduleManager->install($module_name); - } catch (\PrestaShopException $e) { - $moduleInstalled = false; - $moduleException = $e->getMessage(); - } - - if (!$moduleInstalled) { - $module_errors = [$this->translator->trans('Cannot install module "%module%"', ['%module%' => $module_name], 'Install')]; - if (null !== $moduleException) { - $module_errors[] = $moduleException; - } - $errors[$module_name] = $module_errors; - } - } - - if ($errors) { - $this->setError($errors); - - return false; - } - - Module::updateTranslationsAfterInstall(true); - EntityLanguage::updateModulesTranslations($modules); - - return true; - } - - /** - * PROCESS : installFixtures - * Install fixtures (E.g. demo products). - */ - public function installFixtures($entity = null, array $data = []) - { - $fixtures_path = _PS_INSTALL_FIXTURES_PATH_ . 'fashion/'; - $fixtures_name = 'fashion'; - $zip_file = _PS_ROOT_DIR_ . '/download/fixtures.zip'; - $temp_dir = _PS_ROOT_DIR_ . '/download/fixtures/'; - - // Load class (use fixture class if one exists, or use InstallXmlLoader) - if (file_exists($fixtures_path . '/install.php')) { - require_once $fixtures_path . '/install.php'; - $class = 'InstallFixtures' . Tools::toCamelCase($fixtures_name); - if (!class_exists($class, false)) { - $this->setError($this->translator->trans('Fixtures class "%class%" not found', ['%class%' => $class], 'Install')); - - return false; - } - - $xml_loader = new $class(); - if (!$xml_loader instanceof XmlLoader) { - $this->setError($this->translator->trans('"%class%" must be an instance of "InstallXmlLoader"', ['%class%' => $class], 'Install')); - - return false; - } - } else { - $xml_loader = new XmlLoader(); - $xml_loader->setTranslator($this->translator); - } - - // Install XML data (data/xml/ folder) - $xml_loader->setFixturesPath($fixtures_path); - if (isset($this->xml_loader_ids) && $this->xml_loader_ids) { - $xml_loader->setIds($this->xml_loader_ids); - } - - $languages = []; - foreach (EntityLanguage::getLanguages(false) as $lang) { - $languages[$lang['id_lang']] = $lang['iso_code']; - } - $xml_loader->setLanguages($languages); - - if ($entity) { - $xml_loader->populateEntity($entity); - } else { - $xml_loader->populateFromXmlFiles(); - Tools::deleteDirectory($temp_dir, true); - @unlink($zip_file); - } - - if ($errors = $xml_loader->getErrors()) { - $this->setError($errors); - - return false; - } - - // IDS from xmlLoader are stored in order to use them for fixtures - $this->xml_loader_ids = $xml_loader->getIds(); - unset($xml_loader); - - if ($entity === 'category' || $entity === null) { - Category::regenerateEntireNtree(); - } - - if ($entity === null) { - Search::indexation(true); - } - - // Update fixtures lang - foreach ($languages as $lang) { - LanguageLegacy::updateMultilangTable($lang); - } - - return true; - } - - public function installTheme($themeName = null) - { - $themeName = $themeName ?: _THEME_NAME_; - $builder = new ThemeManagerBuilder( - Context::getContext(), - Db::getInstance() - ); - - $theme_manager = $builder->build(); - - if (!($theme_manager->install($themeName) && $theme_manager->enable($themeName))) { - return false; - } - - /* - * Copy language default images. - * We do this action after install theme because we - * need image types information. - */ - $languages = $this->language->getIsoList(); - foreach ($languages as $iso) { - $this->copyLanguageImages($iso); - } - - return true; - } -} diff --git a/src/PrestaShopBundle/Install/Language.php b/src/PrestaShopBundle/Install/Language.php deleted file mode 100644 index 544f3845..00000000 --- a/src/PrestaShopBundle/Install/Language.php +++ /dev/null @@ -1,138 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Install; - -class Language -{ - public $id; - public $name; - public $locale; - public $iso_code; - public $language_code; - public $is_rtl; - public $date_format_lite; - public $date_format_full; - public $countries; - - public function __construct($iso) - { - $this->iso_code = strtolower($iso); - $xmlPath = _PS_INSTALL_LANGS_PATH_ . $iso . '/'; - $this->setPropertiesFromXml($xmlPath); - $this->is_rtl = ($this->is_rtl === 'true') ? true : false; - } - - public function setPropertiesFromXml($xmlPath) - { - $xml = @simplexml_load_file($xmlPath . '/language.xml'); - if ($xml) { - foreach ($xml->children() as $node) { - $this->{$node->getName()} = (string) $node; - } - } - } - - /** - * Get name. - * - * @return mixed - */ - public function getName() - { - return $this->name; - } - - /** - * Get locale. - * - * @return mixed - */ - public function getLocale() - { - return $this->locale; - } - - /** - * Get language_code. - * - * @return mixed - */ - public function getLanguageCode() - { - return $this->language_code; - } - - /** - * Get is_rtl. - * - * @return mixed - */ - public function isRtl() - { - return $this->is_rtl; - } - - /** - * Get date_format_lite. - * - * @return mixed - */ - public function getDateFormatLite() - { - return $this->date_format_lite; - } - - /** - * Get date_format_full. - * - * @return mixed - */ - public function getDateFormatFull() - { - return $this->date_format_full; - } - - public function getCountries() - { - if (!is_array($this->countries)) { - $this->countries = []; - $filename = _PS_INSTALL_LANGS_PATH_ . substr($this->language_code, 0, 2) . '/data/country.xml'; - - if (!file_exists($filename)) { - $filename = _PS_INSTALL_LANGS_PATH_ . 'en/data/country.xml'; - } - - if ($xml = @simplexml_load_file($filename)) { - foreach ($xml->country as $country) { - $this->countries[strtolower((string) $country['id'])] = (string) $country->name; - } - } - } - - return $this->countries; - } -} diff --git a/src/PrestaShopBundle/Install/LanguageList.php b/src/PrestaShopBundle/Install/LanguageList.php deleted file mode 100644 index 19109d08..00000000 --- a/src/PrestaShopBundle/Install/LanguageList.php +++ /dev/null @@ -1,196 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Install; - -use PrestashopInstallerException; -use Symfony\Component\Finder\Finder; - -class LanguageList -{ - const DEFAULT_ISO = 'en'; - - /** - * @var array List of available languages - */ - protected $languages; - - /** - * @var string Current language - */ - protected $language; - - public $locale; - - public $id; - - /** - * @var Language Default language (english) - */ - protected $default; - - protected static $_instance; - - public static function getInstance() - { - if (!self::$_instance) { - self::$_instance = new self(); - } - - return self::$_instance; - } - - public function __construct() - { - // English language is required - if (!file_exists(_PS_INSTALL_LANGS_PATH_ . 'en/language.xml')) { - throw new PrestashopInstallerException('English language is missing'); - } - - $this->languages = [ - self::DEFAULT_ISO => new Language(self::DEFAULT_ISO), - ]; - - // Load other languages - foreach ((new Finder())->files()->name('language.xml')->in(_PS_INSTALL_LANGS_PATH_) as $langFile) { - $this->languages[$langFile->getRelativePath()] = new Language($langFile->getRelativePath()); - } - uasort($this->languages, function ($a, $b) { - $aname = $a->getName(); - $bname = $b->getName(); - if ($aname == $bname) { - return 0; - } - - return ($aname < $bname) ? -1 : 1; - }); - } - - /** - * Set current language. - * - * @param string $iso Language iso - */ - public function setLanguage($iso) - { - if (!in_array($iso, $this->getIsoList())) { - throw new PrestashopInstallerException('Language ' . $iso . ' not found'); - } - $this->language = $iso; - } - - /** - * Get current language. - * - * @return string - */ - public function getLanguageIso() - { - return $this->language; - } - - /** - * Get current language. - * - * @return Language - */ - public function getLanguage($iso = null) - { - if (!$iso) { - $iso = $this->language; - } - - return $this->languages[$iso]; - } - - public function getIsoList() - { - return array_keys($this->languages); - } - - /** - * Get list of languages iso supported by installer. - * - * @return array - */ - public function getLanguages() - { - return $this->languages; - } - - /** - * Get list of countries for current language. - * - * @return array - */ - public function getCountries() - { - static $countries = null; - - if (null === $countries) { - $countries = []; - $countries_lang = $this->getLanguage()->getCountries(); - $countries_default = $this->getLanguage(self::DEFAULT_ISO)->getCountries(); - $xml = @simplexml_load_file(_PS_INSTALL_DATA_PATH_ . 'xml/country.xml'); - if ($xml) { - foreach ($xml->entities->country as $country) { - $iso = strtolower((string) $country['iso_code']); - $countries[$iso] = isset($countries_lang[$iso]) ? $countries_lang[$iso] : $countries_default[$iso]; - } - } - asort($countries); - } - - return $countries; - } - - /** - * Parse HTTP_ACCEPT_LANGUAGE and get first data matching list of available languages. - * - * @return bool|array - */ - public function detectLanguage() - { - // This code is from a php.net comment : http://www.php.net/manual/fr/reserved.variables.server.php#94237 - $split_languages = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); - if (!is_array($split_languages)) { - return false; - } - - foreach ($split_languages as $lang) { - $pattern = '/^(?P[a-zA-Z]{2,8})' . - '(?:-(?P[a-zA-Z]{2,8}))?(?:(?:;q=)' . - '(?P\d\.\d))?$/'; - if (preg_match($pattern, $lang, $m)) { - if (in_array($m['primarytag'], $this->getIsoList())) { - return $m; - } - } - } - - return false; - } -} diff --git a/src/PrestaShopBundle/Install/Simplexml.php b/src/PrestaShopBundle/Install/Simplexml.php deleted file mode 100644 index 55abeade..00000000 --- a/src/PrestaShopBundle/Install/Simplexml.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Install; - -use DOMDocument; - -class SimplexmlElement extends \SimpleXMLElement -{ - /** - * Can add SimpleXMLElement values in XML tree. - * - * @see SimpleXMLElement::addChild() - */ - public function addChild($name, $value = null, $namespace = null) - { - if ($value instanceof static) { - $content = trim((string) $value); - if (strlen($content) > 0) { - $new_element = parent::addChild($name, str_replace('&', '&', $content), $namespace); - } else { - $new_element = parent::addChild($name); - foreach ($value->attributes() as $k => $v) { - $new_element->addAttribute($k, $v); - } - } - - foreach ($value->children() as $child) { - $new_element->addChild($child->getName(), $child); - } - } else { - return parent::addChild($name, str_replace('&', '&', $value), $namespace); - } - } - - /** - * Generate nice and sweet XML. - * - * @see SimpleXMLElement::asXML() - */ - public function asXML($filename = null) - { - $dom = new DOMDocument('1.0'); - $dom->preserveWhiteSpace = false; - $dom->formatOutput = true; - $dom->loadXML(parent::asXML()); - - if ($filename) { - return (bool) file_put_contents($filename, $dom->saveXML()); - } - - return $dom->saveXML(); - } -} diff --git a/src/PrestaShopBundle/Install/SqlLoader.php b/src/PrestaShopBundle/Install/SqlLoader.php deleted file mode 100644 index 698cde8d..00000000 --- a/src/PrestaShopBundle/Install/SqlLoader.php +++ /dev/null @@ -1,143 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Install; - -use PrestaShop\PrestaShop\Adapter\Entity\Db; -use PrestashopInstallerException; - -class SqlLoader -{ - /** - * @var Db - */ - protected $db; - - /** - * @var array List of keywords which will be replaced in queries - */ - protected $metadata = []; - - /** - * @var array List of errors during last parsing - */ - protected $errors = []; - - /** - * @param Db $db - */ - public function __construct(Db $db = null) - { - if (null === $db) { - $db = Db::getInstance(); - } - $this->db = $db; - } - - /** - * Set a list of keywords which will be replaced in queries. - * - * @param array $data - */ - public function setMetaData(array $data) - { - foreach ($data as $k => $v) { - $this->metadata[$k] = $v; - } - } - - /** - * Parse a SQL file and execute queries. - * - * @deprecated use parseFile() - * - * @param string $filename - * @param bool $stop_when_fail - */ - public function parse_file($filename, $stop_when_fail = true) - { - return $this->parseFile($filename, $stop_when_fail); - } - - /** - * Parse a SQL file and execute queries. - * - * @param string $filename - * @param bool $stop_when_fail - */ - public function parseFile($filename, $stop_when_fail = true) - { - if (!file_exists($filename)) { - throw new PrestashopInstallerException("File $filename not found"); - } - - return $this->parse(file_get_contents($filename), $stop_when_fail); - } - - /** - * Parse and execute a list of SQL queries. - * - * @param string $content - * @param bool $stop_when_fail - */ - public function parse($content, $stop_when_fail = true) - { - $this->errors = []; - - $content = str_replace(array_keys($this->metadata), array_values($this->metadata), $content); - $queries = preg_split('#;\s*[\r\n]+#', $content); - foreach ($queries as $query) { - $query = trim($query); - if (!$query) { - continue; - } - - if (!$this->db->execute($query)) { - $this->errors[] = [ - 'errno' => $this->db->getNumberError(), - 'error' => $this->db->getMsgError(), - 'query' => $query, - ]; - - if ($stop_when_fail) { - return false; - } - } - } - - return count($this->errors) ? false : true; - } - - /** - * Get list of errors from last parsing. - * - * @return array - */ - public function getErrors() - { - return $this->errors; - } -} diff --git a/src/PrestaShopBundle/Install/System.php b/src/PrestaShopBundle/Install/System.php deleted file mode 100644 index 219f30d5..00000000 --- a/src/PrestaShopBundle/Install/System.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Install; - -use ConfigurationTest; -use Requirement; -use SymfonyRequirements; - -require_once __DIR__ . '/../../../var/SymfonyRequirements.php'; - -class System extends AbstractInstall -{ - public function checkRequiredTests() - { - return self::checkTests(ConfigurationTest::getDefaultTests(), 'required'); - } - - public function checkOptionalTests() - { - return self::checkTests(ConfigurationTest::getDefaultTestsOp(), 'optional'); - } - - //get symfony requirements - public function checkSf2Requirements() - { - $symfonyRequirements = new SymfonyRequirements(); - $errors = $symfonyRequirements->getFailedRequirements(); - - return $errors; - } - - //get symfony recommendations - public function checkSf2Recommendations() - { - $symfonyRequirements = new SymfonyRequirements(); - - $failedRecommendations = $symfonyRequirements->getFailedRecommendations(); - - return array_filter($failedRecommendations, function (Requirement $requirement) { - if ($requirement->getTestMessage() === 'Requirements file should be up-to-date') { - // this warning is not relevant - return false; - } - - return true; - }); - } - - public function checkTests($list, $type) - { - $tests = ConfigurationTest::check($list); - - $success = true; - foreach ($tests as $result) { - $success &= ($result == 'ok') ? true : false; - } - - return [ - 'checks' => $tests, - 'success' => $success, - ]; - } -} diff --git a/src/PrestaShopBundle/Install/Upgrade.php b/src/PrestaShopBundle/Install/Upgrade.php deleted file mode 100644 index 97326d6a..00000000 --- a/src/PrestaShopBundle/Install/Upgrade.php +++ /dev/null @@ -1,1237 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace { - $root_dir = realpath(__DIR__ . '/../../..'); - - require_once $root_dir . '/vendor/paragonie/random_compat/lib/random.php'; - - if (!class_exists('PhpEncryptionEngine')) { - require_once $root_dir . '/classes/PhpEncryptionEngine.php'; - class PhpEncryptionEngine extends \PhpEncryptionEngineCore - { - } - } - - if (!class_exists('PhpEncryptionLegacyEngine')) { - require_once $root_dir . '/classes/PhpEncryptionLegacyEngine.php'; - class PhpEncryptionLegacyEngine extends \PhpEncryptionLegacyEngineCore - { - } - } - - if (!class_exists('PhpEncryption')) { - require_once $root_dir . '/classes/PhpEncryption.php'; - class PhpEncryption extends \PhpEncryptionCore - { - } - } -} - -namespace PrestaShopBundle\Install { - use AppKernel; - use Cache; - use Cart; - use Composer\Script\Event; - use Configuration; - use Context; - use Country; - use Db; - use Employee; - use FileLogger; - use Language; - use Module; - use PhpEncryption; - use PrestaShop\PrestaShop\Adapter\SymfonyContainer; - use PrestaShop\PrestaShop\Core\Addon\AddonListFilter; - use PrestaShop\PrestaShop\Core\Addon\AddonListFilterOrigin; - use PrestaShop\PrestaShop\Core\Addon\AddonListFilterStatus; - use PrestaShop\PrestaShop\Core\Addon\AddonListFilterType; - use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder; - use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeManagerBuilder; - use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface; - use PrestaShop\PrestaShop\Core\Domain\MailTemplate\Command\GenerateThemeMailTemplatesCommand; - use PrestaShop\PrestaShop\Core\Exception\CoreException; - use PrestaShopBundle\Service\Database\Upgrade as UpgradeDatabase; - use RandomLib; - use Shop; - use Symfony\Component\Filesystem\Exception\IOException; - use Symfony\Component\Filesystem\Filesystem; - use Symfony\Component\Yaml\Yaml; - use Tools; - use Validate; - - class Upgrade - { - /** @var \FileLogger */ - private $logger; - private $infoList = []; - private $warningList = []; - private $failureList = []; - private $nextQuickInfo = []; - private $nextErrors = []; - private $next; - private $nextDesc; - private $inAutoUpgrade = false; - private $translator; - private $installDir; - private $adminDir = null; - private $oldVersion; - private $db; - private $idEmployee = 0; - private $disableCustomModules = false; - private $changeToDefaultTheme = false; - private $updateDefaultTheme = false; - // used for translations - public static $l_cache; - - const FILE_PREFIX = 'PREFIX_'; - const ENGINE_TYPE = 'ENGINE_TYPE'; - const DB_NAME = 'DB_NAME'; - - private static $classes14 = ['Cache', 'CacheFS', 'CarrierModule', 'Db', 'FrontController', 'Helper', 'ImportModule', - 'MCached', 'Module', 'ModuleGraph', 'ModuleGraphEngine', 'ModuleGrid', 'ModuleGridEngine', - 'MySQL', 'Order', 'OrderDetail', 'OrderDiscount', 'OrderHistory', 'OrderMessage', 'OrderReturn', - 'OrderReturnState', 'OrderSlip', 'OrderState', 'PDF', 'RangePrice', 'RangeWeight', 'StockMvt', - 'StockMvtReason', 'SubDomain', 'Shop', 'Tax', 'TaxRule', 'TaxRulesGroup', 'WebserviceKey', 'WebserviceRequest', '', ]; - - private static $incompatibleModules = [ - 'bankwire', - 'blockbanner', - 'blockcart', - 'blockcategories', - 'blockcms', - 'blockcmsinfo', - 'blockcontact', - 'blockcurrencies', - 'blocklanguages', - 'blocklayered', - 'blockmyaccount', - 'blocknewsletter', - 'blocksearch', - 'blocksocial', - 'blocktopmenu', - 'blockuserinfo', - 'cheque', - 'homefeatured', - 'homeslider', - 'onboarding', - 'socialsharing', - 'vatnumber', - 'blockadvertising', - 'blockbestsellers', - 'blockcustomerprivacy', - 'blocklink', - 'blockmanufacturer', - 'blocknewproducts', - 'blockpermanentlinks', - 'blockrss', - 'blocksharefb', - 'blockspecials', - 'blocksupplier', - 'blockviewed', - 'crossselling', - 'followup', - 'productscategory', - 'producttooltip', - 'mailalert', - 'blockcontactinfos', - 'blockfacebook', - 'blockmyaccountfooter', - 'blockpaymentlogo', - 'blockstore', - 'blocktags', - 'blockwishlist', - 'productpaymentlogos', - 'sendtoafriend', - 'themeconfigurator', - ]; - - public function __construct($cacheDir, $installDir) - { - $this->logger = new FileLogger(); - $this->logger->setFilename($cacheDir . @date('Ymd') . '_upgrade.log'); - $this->installDir = $installDir; - $this->db = Db::getInstance(); - } - - public function setDisableCustomModules($value) - { - $this->disableCustomModules = (bool) $value; - } - - public function setUpdateDefaultTheme($value) - { - $this->updateDefaultTheme = (bool) $value; - } - - public function setAdminDir($value) - { - $this->adminDir = $value; - } - - public function setIdEmployee($id) - { - $this->idEmployee = (int) $id; - } - - public function setChangeToDefaultTheme($value) - { - $this->changeToDefaultTheme = (bool) $value; - } - - private function defineConst() - { - // retrocompatibility (is present in some upgrade scripts) - if (!defined('INSTALL_PATH')) { - define('INSTALL_PATH', $this->installDir); - } - require_once INSTALL_PATH . 'install_version.php'; - // needed for upgrade before 1.5 - if (!defined('__PS_BASE_URI__')) { - define('__PS_BASE_URI__', str_replace('//', '/', '/' . trim(preg_replace('#/(install(-dev)?/upgrade)$#', '/', str_replace('\\', '/', dirname($_SERVER['REQUEST_URI']))), '/') . '/')); - } - if (!defined('_THEME_NAME_')) { - define('_THEME_NAME_', 'default'); - } - if (!defined('_PS_SMARTY_FAST_LOAD_')) { - define('_PS_SMARTY_FAST_LOAD_', true); - } - - // if _PS_ROOT_DIR_ is defined, use it instead of "guessing" the module dir. - if (defined('_PS_ROOT_DIR_') && !defined('_PS_MODULE_DIR_')) { - define('_PS_MODULE_DIR_', _PS_ROOT_DIR_ . '/modules/'); - } elseif (!defined('_PS_MODULE_DIR_')) { - define('_PS_MODULE_DIR_', _PS_INSTALL_PATH_ . '/../modules/'); - } - - if (!defined('_PS_INSTALLER_PHP_UPGRADE_DIR_')) { - define('_PS_INSTALLER_PHP_UPGRADE_DIR_', _PS_INSTALL_PATH_ . 'upgrade/php/'); - } - - if (!defined('_PS_INSTALLER_SQL_UPGRADE_DIR_')) { - define('_PS_INSTALLER_SQL_UPGRADE_DIR_', _PS_INSTALL_PATH_ . 'upgrade/sql/'); - } - - if (!defined('_THEMES_DIR_')) { - define('_THEMES_DIR_', __PS_BASE_URI__ . 'themes/'); - } - if (!defined('_PS_IMG_')) { - define('_PS_IMG_', __PS_BASE_URI__ . 'img/'); - } - if (!defined('_PS_JS_DIR_')) { - define('_PS_JS_DIR_', __PS_BASE_URI__ . 'js/'); - } - if (!defined('_PS_CSS_DIR_')) { - define('_PS_CSS_DIR_', __PS_BASE_URI__ . 'css/'); - } - - $this->oldVersion = Configuration::get('PS_VERSION_DB'); - if (empty($this->oldVersion)) { - $this->oldVersion = Configuration::get('PS_INSTALL_VERSION'); - } - // Since 1.4.4.0 - // Fix complete version number if there is not all 4 numbers - // Eg. replace 1.4.3 by 1.4.3.0 - // Will result in file 1.4.3.0.sql will be skipped if oldversion is 1.4.3 - $arrayVersion = preg_split('#\.#', $this->oldVersion); - $versionNumbers = count($arrayVersion); - - if ($versionNumbers != 4) { - $arrayVersion = array_pad($arrayVersion, 4, '0'); - } - - $this->oldVersion = implode('.', $arrayVersion); - // End of fix - - if (!defined('_PS_CACHE_ENABLED_')) { - define('_PS_CACHE_ENABLED_', '0'); - } - if (!defined('_MYSQL_ENGINE_')) { - define('_MYSQL_ENGINE_', 'MyISAM'); - } - - if (!defined('_PS_TOOL_DIR_')) { - define('_PS_TOOL_DIR_', _PS_ROOT_DIR_ . '/tools/'); - } - if (!defined('_PS_TRANSLATIONS_DIR_')) { - define('_PS_TRANSLATIONS_DIR_', _PS_ROOT_DIR_ . '/translations/'); - } - if (!defined('_PS_MODULES_DIR_')) { - define('_PS_MODULES_DIR_', _PS_ROOT_DIR_ . '/modules/'); - } - if (!defined('_PS_MAILS_DIR_')) { - define('_PS_MAILS_DIR_', _PS_ROOT_DIR_ . '/mails/'); - } - if (!defined('_MEDIA_SERVER_1_')) { - define('_MEDIA_SERVER_1_', ''); - } - - if (!defined('_PS_USE_SQL_SLAVE_')) { - define('_PS_USE_SQL_SLAVE_', false); - } - } - - private function initContext() - { - $smarty = null; - Cache::clean('*'); - - Context::getContext()->shop = new Shop(1); - Shop::setContext(Shop::CONTEXT_SHOP, 1); - - if (!isset(Context::getContext()->language) || !Validate::isLoadedObject(Context::getContext()->language)) { - $idLang = (int) $this->getConfValue('PS_LANG_DEFAULT'); - Context::getContext()->language = new Language($idLang ? $idLang : null); - } - if (!isset(Context::getContext()->country) || !Validate::isLoadedObject(Context::getContext()->country)) { - if ($id_country = (int) $this->getConfValue('PS_COUNTRY_DEFAULT')) { - Context::getContext()->country = new Country((int) $id_country); - } - } - - Context::getContext()->cart = new Cart(); - Context::getContext()->employee = new Employee(1); - - require_once _PS_ROOT_DIR_ . '/config/smarty.config.inc.php'; - - Context::getContext()->smarty = $smarty; - Language::loadLanguages(); - - $this->translator = Context::getContext()->getTranslator(); - } - - private function getConfValue($name) - { - $full = version_compare('1.5.0.10', AppKernel::VERSION) < 0; - - $sql = 'SELECT IF(cl.`id_lang` IS NULL, c.`value`, cl.`value`) AS value - FROM `' . _DB_PREFIX_ . 'configuration` c - LEFT JOIN `' . _DB_PREFIX_ . 'configuration_lang` cl ON (c.`id_configuration` = cl.`id_configuration`) - WHERE c.`name`=\'' . pSQL($name) . '\''; - - if ($full) { - $id_shop = Shop::getContextShopID(true); - $id_shop_group = Shop::getContextShopGroupID(true); - if ($id_shop) { - $sql .= ' AND c.`id_shop` = ' . (int) $id_shop; - } - if ($id_shop_group) { - $sql .= ' AND c.`id_shop_group` = ' . (int) $id_shop_group; - } - } - - return $this->db->getValue($sql); - } - - private function getThemeManager($idEmployee) - { - $context = Context::getContext(); - $context->employee = new Employee((int) $idEmployee); - - return (new ThemeManagerBuilder($context, Db::getInstance()))->build(); - } - - private function checkVersion() - { - $versionCompare = version_compare(_PS_INSTALL_VERSION_, $this->oldVersion); - if ($versionCompare == '-1') { - $this->logError('Current version: %current%. Version to install: %future%.', 27, ['%current%' => $this->oldVersion, '%future%' => _PS_INSTALL_VERSION_]); - } elseif ($versionCompare == 0) { - $this->logError('You already have the %future% version.', 28, ['%future%' => _PS_INSTALL_VERSION_]); - } elseif ($versionCompare === false) { - $this->logError('There is no older version. Did you delete or rename the app/config/parameters.php file?', 29); - } - - if (strpos(_PS_INSTALL_VERSION_, '.') === false) { - $this->logError( - '%install_version% is not a valid version number.', - 40, - ['%install_version%' => _PS_INSTALL_VERSION_] - ); - } - } - - private function getSQLFiles() - { - //custom sql file creation - $neededUpgradeFiles = []; - if (!$this->hasFailure()) { - $upgradeFiles = []; - if (!file_exists(_PS_INSTALLER_SQL_UPGRADE_DIR_)) { - $this->logError('Unable to find upgrade directory in the installation path.', 31); - } - - if ($handle = opendir(_PS_INSTALLER_SQL_UPGRADE_DIR_)) { - while (false !== ($file = readdir($handle))) { - if (!in_array($file, ['.', '..', 'index.php'])) { - $upgradeFiles[] = str_replace('.sql', '', $file); - } - } - closedir($handle); - } - if (empty($upgradeFiles)) { - $this->logError('Cannot find the SQL upgrade files. Please verify that the %folder% folder is not empty)', 31, ['%folder%' => _PS_INSTALLER_SQL_UPGRADE_DIR_]); - } - natcasesort($upgradeFiles); - - $neededUpgradeFiles = []; - foreach ($upgradeFiles as $version) { - if (version_compare($version, $this->oldVersion) == 1 && version_compare(_PS_INSTALL_VERSION_, $version) != -1) { - $neededUpgradeFiles[] = $version; - } - } - } - if (!$this->hasFailure() && empty($neededUpgradeFiles)) { - $this->logError('No upgrade is possible.', 32); - } - - $sqlContentVersion = []; - $mysqlEngine = (defined('_MYSQL_ENGINE_') ? _MYSQL_ENGINE_ : 'MyISAM'); - if (!$this->hasFailure()) { - foreach ($neededUpgradeFiles as $version) { - $file = _PS_INSTALLER_SQL_UPGRADE_DIR_ . $version . '.sql'; - if (!file_exists($file)) { - $this->logError('Error while loading SQL upgrade file "%file%.sql".', 33, ['%file%' => $version]); - } - if (!$sqlContent = file_get_contents($file)) { - $this->logError('Error while loading SQL upgrade file "%file%.sql".', 33, ['%file%' => $version]); - } - $sqlContent .= "\n"; - $sqlContent = str_replace([self::FILE_PREFIX, self::ENGINE_TYPE, self::DB_NAME], [_DB_PREFIX_, $mysqlEngine, _DB_NAME_], $sqlContent); - $sqlContent = preg_split("/;\s*[\r\n]+/", $sqlContent); - - $sqlContentVersion[$version] = $sqlContent; - } - } - - return $sqlContentVersion; - } - - private function upgradeDoctrineSchema() - { - $schemaUpgrade = new UpgradeDatabase(); - $schemaUpgrade->addDoctrineSchemaUpdate(); - $output = $schemaUpgrade->execute(); - if (0 !== $output['prestashop:schema:update-without-foreign']['exitCode']) { - $msgErrors = explode("\n", $output['prestashop:schema:update-without-foreign']['output']); - $this->logError('Error upgrading doctrine schema', 43); - foreach ($msgErrors as $msgError) { - $this->logError('Doctrine SQL Error : ' . $msgError, 43); - } - } - } - - public function upgradeDb($sqlContentVersion) - { - $db = $this->db; - foreach ($sqlContentVersion as $version => $sqlContent) { - foreach ($sqlContent as $query) { - $query = trim($query); - if (!empty($query)) { - /* If php code have to be executed */ - if (strpos($query, '/* PHP:') !== false) { - /* Parsing php code */ - $pos = strpos($query, '/* PHP:') + strlen('/* PHP:'); - $phpString = substr($query, $pos, strlen($query) - $pos - strlen(' */;')); - $php = explode('::', $phpString); - preg_match('/\((.*)\)/', $phpString, $pattern); - $paramsString = trim($pattern[0], '()'); - preg_match_all('/([^,]+),? ?/', $paramsString, $parameters); - if (isset($parameters[1])) { - $parameters = $parameters[1]; - } else { - $parameters = []; - } - if (is_array($parameters)) { - foreach ($parameters as &$parameter) { - $parameter = str_replace('\'', '', $parameter); - } - } - - $phpRes = null; - /* Call a simple function */ - if (strpos($phpString, '::') === false) { - $func_name = str_replace($pattern[0], '', $php[0]); - if (!file_exists(_PS_INSTALLER_PHP_UPGRADE_DIR_ . strtolower($func_name) . '.php')) { - $this->logWarning('[ERROR] ' . $version . ' PHP - missing file ' . $query, 41, [], true); - } else { - require_once _PS_INSTALLER_PHP_UPGRADE_DIR_ . Tools::strtolower($func_name) . '.php'; - $phpRes = call_user_func_array($func_name, $parameters); - } - } else { - /* Or an object method, not supported */ - $this->logWarning('[ERROR] ' . $version . ' PHP - Object Method call is forbidden (' . $php[0] . '::' . str_replace($pattern[0], '', $php[1]) . ')', 42, [], true); - } - if ((is_array($phpRes) && !empty($phpRes['error'])) || $phpRes === false) { - $this->logWarning('[ERROR] PHP ' . $version . ' ' . $query . "\n" . ' - ' . (empty($phpRes['error']) ? '' : $phpRes['error'] . "\n") . ' - ' . (empty($phpRes['msg']) ? '' : ' - ' . $phpRes['msg']), $version, [], true); - } else { - $this->logInfo('[OK] PHP ' . $version . ' : ' . $query, $version, [], true); - } - } else { - if (!$db->execute($query)) { - $error = $db->getMsgError(); - $error_number = $db->getNumberError(); - - $duplicates = ['1050', '1054', '1060', '1061', '1062', '1091']; - if (!in_array($error_number, $duplicates)) { - $this->logWarning('SQL ' . $version . ' - ' . $error_number . ' in ' . $query . ': ' . $error, $version, [], true); - } else { - $this->logInfo('SQL ' . $version . ' - ' . $error_number . ' in ' . $query . ': ' . $error, $version, [], true); - } - } else { - $this->logInfo('[OK] SQL ' . $version . ' : ' . $query, $version, [], true); - } - } - } - } - } - // reload config after DB upgrade - Configuration::loadConfiguration(); - } - - private function disableCustomModules() - { - $moduleManagerBuilder = ModuleManagerBuilder::getInstance(); - $moduleRepository = $moduleManagerBuilder->buildRepository(); - $moduleRepository->clearCache(); - - $filters = new AddonListFilter(); - $filters->setType(AddonListFilterType::MODULE) - ->removeStatus(AddonListFilterStatus::UNINSTALLED); - - $installedProducts = $moduleRepository->getFilteredList($filters); - foreach ($installedProducts as $installedProduct) { - if (!( - $installedProduct->attributes->has('origin_filter_value') - && in_array( - $installedProduct->attributes->get('origin_filter_value'), - [ - AddonListFilterOrigin::ADDONS_NATIVE, - AddonListFilterOrigin::ADDONS_NATIVE_ALL, - ] - ) - && 'PrestaShop' === $installedProduct->attributes->get('author') - ) - && 'autoupgrade' !== $installedProduct->attributes->get('name')) { - $moduleName = $installedProduct->attributes->get('name'); - $this->logInfo('Disabling custom module ' . $moduleName); - Module::disableAllByName($moduleName); - } - } - - return true; - } - - private function disableIncompatibleModules() - { - $fs = new Filesystem(); - - $moduleManagerBuilder = ModuleManagerBuilder::getInstance(); - $moduleManagerRepository = $moduleManagerBuilder->buildRepository(); - $moduleManagerRepository->clearCache(); - - $filters = new AddonListFilter(); - $filters->setStatus(AddonListFilterStatus::ON_DISK | AddonListFilterStatus::INSTALLED); - - $list = $moduleManagerRepository->getFilteredList($filters, true); - foreach ($list as $moduleName => $module) { - if (in_array($moduleName, self::$incompatibleModules)) { - $this->logInfo("Uninstalling module $moduleName, not supported in this PrestaShop version."); - $module->onUninstall(); - $fs->remove(_PS_MODULE_DIR_ . $moduleName); - } else { - $attributes = $module->attributes; - if ($attributes->get('compatibility')) { - $maxVersion = $attributes->get('compatibility')->to; - if (version_compare($maxVersion, _PS_INSTALL_VERSION_) == -1 && Module::isEnabled($moduleName)) { - $this->logInfo("Disabling module $moduleName. Max supported version : " . $maxVersion); - Module::disableAllByName($moduleName); - } - } - } - } - - return true; - } - - private function enableNativeModules() - { - $moduleManagerBuilder = ModuleManagerBuilder::getInstance(); - $moduleManagerRepository = $moduleManagerBuilder->buildRepository(); - $moduleManagerRepository->clearCache(); - - $filters = new AddonListFilter(); - $filters->setOrigin(AddonListFilterOrigin::ADDONS_NATIVE | AddonListFilterOrigin::ADDONS_NATIVE_ALL); - - $list = $moduleManagerRepository->getFilteredList($filters, true); - foreach ($list as $moduleName => $module) { - if ('PrestaShop' === $module->attributes->get('author')) { - if (!$moduleManagerBuilder->build()->isInstalled($moduleName)) { - $this->logInfo('Installing native module ' . $moduleName); - $module = $moduleManagerRepository->getModule($moduleName); - $module->onInstall(); - $module->onEnable(); - } else { - $this->logInfo('Native module ' . $moduleName . ' already installed'); - } - } - } - - return true; - } - - private function cleanCache() - { - // Settings updated, compile and cache directories must be emptied - $install_dir = realpath(rtrim(_PS_INSTALL_PATH_, '\\/') . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; - $tools_dir = $install_dir . 'tools' . DIRECTORY_SEPARATOR; - $arrayToClean = [ - $tools_dir . 'smarty' . DIRECTORY_SEPARATOR . 'cache', - $tools_dir . 'smarty' . DIRECTORY_SEPARATOR . 'compile', - $tools_dir . 'smarty_v2' . DIRECTORY_SEPARATOR . 'cache', - $tools_dir . 'smarty_v2' . DIRECTORY_SEPARATOR . 'compile', - $install_dir . 'app' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR, - $install_dir . 'cache' . DIRECTORY_SEPARATOR . 'smarty' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR, - $install_dir . 'cache' . DIRECTORY_SEPARATOR . 'smarty' . DIRECTORY_SEPARATOR . 'compile' . DIRECTORY_SEPARATOR, - ]; - - foreach ($arrayToClean as $dir) { - if (file_exists($dir)) { - foreach (scandir($dir, SCANDIR_SORT_NONE) as $file) { - if ($file[0] != '.' && $file != 'index.php' && $file != '.htaccess') { - if (is_file($dir . $file)) { - unlink($dir . $file); - } elseif (is_dir($dir . $file . DIRECTORY_SEPARATOR)) { - //\Tools14::deleteDirectory($dir . $file . DIRECTORY_SEPARATOR, true); - } - // To more log - //$this->logInfo('[CLEANING CACHE] File %file% removed', null, array('%file%' => $file)); - } - } - } else { - $this->logInfo('[SKIP] directory "%directory%" does not exist and cannot be emptied.', null, ['%directory%' => str_replace($tools_dir, '', $dir)]); - } - } - - if (file_exists(_PS_ROOT_DIR_ . '/var/cache/dev/class_index.php')) { - unlink(_PS_ROOT_DIR_ . '/var/cache/dev/class_index.php'); - } - if (file_exists(_PS_ROOT_DIR_ . '/var/cache/prod/class_index.php')) { - unlink(_PS_ROOT_DIR_ . '/var/cache/prod/class_index.php'); - } - - // Clear XML files - if (file_exists(_PS_ROOT_DIR_ . '/config/xml/blog-fr.xml')) { - unlink(_PS_ROOT_DIR_ . '/config/xml/blog-fr.xml'); - } - if (file_exists(_PS_ROOT_DIR_ . '/config/xml/default_country_modules_list.xml')) { - unlink(_PS_ROOT_DIR_ . '/config/xml/default_country_modules_list.xml'); - } - if (file_exists(_PS_ROOT_DIR_ . '/config/xml/modules_list.xml')) { - unlink(_PS_ROOT_DIR_ . '/config/xml/modules_list.xml'); - } - if (file_exists(_PS_ROOT_DIR_ . '/config/xml/modules_native_addons.xml')) { - unlink(_PS_ROOT_DIR_ . '/config/xml/modules_native_addons.xml'); - } - if (file_exists(_PS_ROOT_DIR_ . '/config/xml/must_have_modules_list.xml')) { - unlink(_PS_ROOT_DIR_ . '/config/xml/must_have_modules_list.xml'); - } - if (file_exists(_PS_ROOT_DIR_ . '/config/xml/tab_modules_list.xml')) { - unlink(_PS_ROOT_DIR_ . '/config/xml/tab_modules_list.xml'); - } - if (file_exists(_PS_ROOT_DIR_ . '/config/xml/trusted_modules_list.xml')) { - unlink(_PS_ROOT_DIR_ . '/config/xml/trusted_modules_list.xml'); - } - if (file_exists(_PS_ROOT_DIR_ . '/config/xml/untrusted_modules_list.xml')) { - unlink(_PS_ROOT_DIR_ . '/config/xml/untrusted_modules_list.xml'); - } - } - - private function cleanDefaultThemeCache() - { - $separator = addslashes(DIRECTORY_SEPARATOR); - $file = _PS_ROOT_DIR_ . $separator . 'themes' . $separator . _THEME_NAME_ . $separator . 'cache' . $separator; - if (file_exists($file)) { - foreach (scandir($file, SCANDIR_SORT_NONE) as $cache) { - if ($cache[0] != '.' && $cache != 'index.php' && $cache != '.htaccess' && file_exists($file . $cache) && !is_dir($file . $cache)) { - if (file_exists($file . $cache)) { - unlink($file . $cache); - } - } - } - } - } - - private function updateDbImagesLegacy() - { - $db = $this->db; - $db->execute('UPDATE `' . _DB_PREFIX_ . 'configuration` SET `name` = \'PS_LEGACY_IMAGES\' WHERE name LIKE \'0\' AND `value` = 1'); - $db->execute('UPDATE `' . _DB_PREFIX_ . 'configuration` SET `value` = 0 WHERE `name` LIKE \'PS_LEGACY_IMAGES\''); - if ($db->getValue('SELECT COUNT(id_product_download) FROM `' . _DB_PREFIX_ . 'product_download` WHERE `active` = 1') > 0) { - $db->execute('UPDATE `' . _DB_PREFIX_ . 'configuration` SET `value` = 1 WHERE `name` LIKE \'PS_VIRTUAL_PROD_FEATURE_ACTIVE\''); - } - } - - private function cleanupOldDirectories() - { - if ($this->adminDir) { - $path = $this->adminDir . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . 'default' . DIRECTORY_SEPARATOR - . 'template' . DIRECTORY_SEPARATOR . 'controllers' . DIRECTORY_SEPARATOR . 'modules' - . DIRECTORY_SEPARATOR . 'header.tpl'; - if (file_exists($path)) { - unlink($path); - } - } - } - - private function updateLangs() - { - $langs = $this->db->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'lang` WHERE `active` = 1'); - - if (is_array($langs)) { - foreach ($langs as $lang) { - $isoCode = $lang['iso_code']; - - if (Validate::isLangIsoCode($isoCode)) { - $errorsLanguage = []; - - Language::downloadLanguagePack($isoCode, AppKernel::VERSION, $errorsLanguage); - - $lang_pack = Language::getLangDetails($isoCode); - Language::installSfLanguagePack($lang_pack['locale'], $errorsLanguage); - self::generateEmailsLanguagePack($lang_pack, $errorsLanguage); - - if (empty($errorsLanguage)) { - Language::loadLanguages(); - } else { - $this->logError('Error updating translations', 44); - } - - Language::updateMultilangTable($isoCode); - } - } - } - } - - /** - * @param array $langPack - * @param array $errors - */ - private static function generateEmailsLanguagePack($langPack, &$errors = []) - { - $locale = $langPack['locale']; - $sfContainer = SymfonyContainer::getInstance(); - if (null === $sfContainer) { - $errors[] = Context::getContext()->getTranslator()->trans( - 'Cannot generate emails because the Symfony container is unavailable.', - [], - 'Admin.Notifications.Error' - ); - - return; - } - - $mailTheme = Configuration::get('PS_MAIL_THEME'); - /** @var GenerateThemeMailTemplatesCommand $generateCommand */ - $generateCommand = new GenerateThemeMailTemplatesCommand( - $mailTheme, - $locale, - false, - !empty($coreOutputFolder) ? $coreOutputFolder : '', - !empty($modulesOutputFolder) ? $modulesOutputFolder : '' - ); - /** @var CommandBusInterface $commandBus */ - $commandBus = $sfContainer->get('prestashop.core.command_bus'); - try { - $commandBus->handle($generateCommand); - } catch (CoreException $e) { - $errors[] = Context::getContext()->getTranslator()->trans( - 'Cannot generate email templates: %s.', - [$e->getMessage()], - 'Admin.Notifications.Error' - ); - } - } - - private function updateHtaccess() - { - if (!class_exists('\Tools2', false) && class_exists('\ToolsCore')) { - eval('class Tools2 extends \ToolsCore{}'); - } - - if (class_exists('\Tools2') && method_exists('\Tools2', 'generateHtaccess')) { - $url_rewrite = (bool) $this->db->getValue('SELECT `value` FROM `' . _DB_PREFIX_ . 'configuration` WHERE name=\'PS_REWRITING_SETTINGS\''); - - \Tools2::generateHtaccess(null, $url_rewrite); - } - } - - private function updateTheme() - { - $themeManager = $this->getThemeManager($this->idEmployee); - $themeName = ($this->changeToDefaultTheme ? 'classic' : _THEME_NAME_); - - $isThemeEnabled = $themeManager->enable($themeName, true); - if (!$isThemeEnabled) { - $themeErrors = $themeManager->getErrors($themeName); - $this->logError($themeErrors, 45); - } - } - - public function run() - { - Tools::clearAllCache(); - - $this->defineConst(); - $this->initContext(); - $this->checkVersion(); - - $sqlContentVersion = $this->getSQLFiles(); - - if (!$this->hasFailure()) { - $this->disableIncompatibleModules(); - - if ($this->disableCustomModules) { - $this->disableCustomModules(); - } - - $this->upgradeDb($sqlContentVersion); - $this->upgradeDoctrineSchema(); - - $this->enableNativeModules(); - - $this->cleanCache(); - - $this->updateDbImagesLegacy(); - if ($this->updateDefaultTheme) { - $this->cleanDefaultThemeCache(); - } - $this->cleanupOldDirectories(); - $this->updateLangs(); - $this->updateHtaccess(); - - if ($this->idEmployee) { - $this->updateTheme(); - } - } - } - - public function doUpgradeDb() - { - Tools::clearAllCache(); - - $this->defineConst(); - $this->initContext(); - $this->checkVersion(); - - $sqlContentVersion = $this->getSQLFiles(); - - if (!$this->hasFailure()) { - $this->upgradeDb($sqlContentVersion); - $this->upgradeDoctrineSchema(); - } - - $this->next = 'DisableModules'; - $this->nextDesc = $this->getTranslator()->trans('Database upgrade completed.', [], 'Install'); - $this->nextQuickInfo[] = $this->getTranslator()->trans('Database upgrade completed.', [], 'Install'); - $this->nextQuickInfo[] = $this->getTranslator()->trans('Disabling modules now...', [], 'Install'); - } - - public function doDisableModules() - { - $this->defineConst(); - $this->initContext(); - - $this->disableIncompatibleModules(); - - if ($this->disableCustomModules) { - $this->disableCustomModules(); - } - - $this->next = 'EnableModules'; - $this->nextDesc = $this->getTranslator()->trans('Modules successfully disabled.', [], 'Install'); - $this->nextQuickInfo[] = $this->getTranslator()->trans('Modules successfully disabled.', [], 'Install'); - $this->nextQuickInfo[] = $this->getTranslator()->trans('Enabling modules now...', [], 'Install'); - } - - public function doEnableModules() - { - $this->defineConst(); - $this->initContext(); - - $this->enableNativeModules(); - - $this->next = 'UpdateImage'; - $this->nextDesc = $this->getTranslator()->trans('Modules successfully enabled.', [], 'Install'); - $this->nextQuickInfo[] = $this->getTranslator()->trans('Modules successfully enabled.', [], 'Install'); - $this->nextQuickInfo[] = $this->getTranslator()->trans('Upgrading images now...', [], 'Install'); - } - - public function doUpdateImage() - { - $this->defineConst(); - $this->initContext(); - - $this->cleanCache(); - - $this->updateDbImagesLegacy(); - if ($this->updateDefaultTheme) { - $this->cleanDefaultThemeCache(); - } - $this->cleanupOldDirectories(); - - $this->next = 'UpdateLangHtaccess'; - $this->nextDesc = $this->getTranslator()->trans('Images successfully upgraded.', [], 'Install'); - $this->nextQuickInfo[] = $this->getTranslator()->trans('Images successfully upgraded.', [], 'Install'); - $this->nextQuickInfo[] = $this->getTranslator()->trans('Upgrading languages now...', [], 'Install'); - } - - public function doUpdateLangHtaccess() - { - $this->defineConst(); - $this->initContext(); - - $this->updateLangs(); - $this->updateHtaccess(); - - $this->next = 'UpdateTheme'; - $this->nextDesc = $this->getTranslator()->trans('Languages successfully upgraded.', [], 'Install'); - $this->nextQuickInfo[] = $this->getTranslator()->trans('Languages successfully upgraded.', [], 'Install'); - $this->nextQuickInfo[] = $this->getTranslator()->trans('Upgrading theme now...', [], 'Install'); - } - - public function doUpdateTheme() - { - $this->defineConst(); - $this->initContext(); - - if ($this->idEmployee) { - $this->updateTheme(); - } - - $this->next = 'UpgradeComplete'; - $this->nextDesc = $this->getTranslator()->trans('Theme successfully upgraded.', [], 'Install'); - $this->nextQuickInfo[] = $this->getTranslator()->trans('Theme successfully upgraded.', [], 'Install'); - } - - public function getTranslator() - { - return $this->translator; - } - - public function logInfo($quickInfo, $id = null, $transVariables = [], $dbInfo = false) - { - $info = $this->getTranslator()->trans($quickInfo, $transVariables, 'Install'); - if ($this->inAutoUpgrade) { - if ($dbInfo) { - $this->nextQuickInfo[] = '
    ' . $info . '
    '; - } else { - $this->nextQuickInfo[] = $info; - } - $this->infoList[] = $info; - } else { - if (!empty($quickInfo)) { - $this->logger->logInfo($info); - } - if ($id !== null) { - if (!is_numeric($id)) { - $customInfo = '\n"; - } else { - $customInfo = '' . "\n"; - } - $this->infoList[] = $customInfo; - } - } - } - - public function logWarning($quickInfo, $id, $transVariables = [], $dbInfo = false) - { - $info = $this->getTranslator()->trans($quickInfo, $transVariables, 'Install'); - if ($this->inAutoUpgrade) { - if ($dbInfo) { - $this->nextQuickInfo[] = '
    ' . $info . '
    '; - } else { - $this->nextQuickInfo[] = $info; - } - $this->nextErrors[] = $info; - $this->warningList[] = $info; - if (empty($this->failureList)) { - $this->nextDesc = $this->getTranslator()->trans('Warning detected during upgrade.', [], 'Install'); - } - } else { - if (!empty($quickInfo)) { - $this->logger->logWarning($info); - } - if ($id !== null) { - if (!is_numeric($id)) { - $customWarning = '\n"; - } else { - $customWarning = '' . "\n"; - } - $this->warningList[] = $customWarning; - } - } - } - - public function logError($quickInfo, $id, $transVariables = [], $dbInfo = false) - { - $info = $this->getTranslator()->trans($quickInfo, $transVariables, 'Install'); - if ($this->inAutoUpgrade) { - if ($dbInfo) { - $this->nextQuickInfo[] = '
    ' . $info . '
    '; - } else { - $this->nextQuickInfo[] = $info; - } - $this->nextErrors[] = $info; - $this->failureList[] = $info; - $this->nextDesc = $this->getTranslator()->trans('Error detected during upgrade.', [], 'Install'); - $this->next = 'error'; - } else { - if (!empty($quickInfo)) { - $this->logger->logError($info); - } - if ($id !== null) { - if (!is_numeric($id)) { - $customError = '\n"; - } else { - $customError = '' . "\n"; - } - $this->failureList[] = $customError; - } - } - } - - public function getInAutoUpgrade() - { - return $this->inAutoUpgrade; - } - - public function setInAutoUpgrade($value) - { - $this->inAutoUpgrade = $value; - } - - public function getNext() - { - return $this->next; - } - - public function getNextDesc() - { - return $this->nextDesc; - } - - public function getInfoList() - { - return $this->infoList; - } - - public function getWarningList() - { - return $this->warningList; - } - - public function getFailureList() - { - return $this->failureList; - } - - public function getNextQuickInfo() - { - return $this->nextQuickInfo; - } - - public function getNextErrors() - { - return $this->nextErrors; - } - - public function hasInfo() - { - return !empty($this->infoList); - } - - public function hasWarning() - { - return !empty($this->warningList); - } - - public function hasFailure() - { - return !empty($this->failureList); - } - - const SETTINGS_FILE = 'config/settings.inc.php'; - - public static function migrateSettingsFile(Event $event = null) - { - if ($event !== null) { - $event->getIO()->write('Migrating old setting file...'); - } - - $root_dir = realpath(__DIR__ . '/../../../'); - - $phpParametersFilepath = $root_dir . '/app/config/parameters.php'; - $addNewCookieKey = false; - if (file_exists($phpParametersFilepath)) { - $default_parameters = require $phpParametersFilepath; - if (!array_key_exists('new_cookie_key', $default_parameters['parameters'])) { - $addNewCookieKey = true; - } else { - if ($event !== null) { - $event->getIO()->write('parameters file already exists!'); - $event->getIO()->write('Finished...'); - } - - return false; - } - } - - if (!file_exists($phpParametersFilepath) && !file_exists($root_dir . '/app/config/parameters.yml') - && !file_exists($root_dir . '/' . self::SETTINGS_FILE)) { - if ($event !== null) { - $event->getIO()->write('No file to migrate!'); - $event->getIO()->write('Finished...'); - } - - return false; - } - - $filesystem = new Filesystem(); - $exportPhpConfigFile = function ($config, $destination) use ($filesystem) { - try { - $filesystem->dumpFile($destination, 'getIO()->write('parameters file already exists!'); - $event->getIO()->write("add new parameter 'new_cookie_key'"); - $event->getIO()->write('Finished...'); - } - - return false; - } - - if (file_exists($root_dir . '/' . self::SETTINGS_FILE)) { - $tmp_settings = file_get_contents($root_dir . '/' . self::SETTINGS_FILE); - } else { - $tmp_settings = null; - } - - if (!file_exists($root_dir . '/app/config/parameters.yml') && $tmp_settings && strpos($tmp_settings, '_DB_SERVER_') !== false) { - $tmp_settings = preg_replace('/(\'|")\_/', '$1_LEGACY_', $tmp_settings); - $tmp_settings_file = str_replace('/settings', '/tmp_settings', $root_dir . '/' . self::SETTINGS_FILE); - file_put_contents($tmp_settings_file, $tmp_settings); - include $tmp_settings_file; - @unlink($tmp_settings_file); - $factory = new RandomLib\Factory(); - $generator = $factory->getLowStrengthGenerator(); - $secret = $generator->generateString(64); - - if (!defined('_LEGACY_NEW_COOKIE_KEY_')) { - define('_LEGACY_NEW_COOKIE_KEY_', $default_parameters['parameters']['new_cookie_key']); - } - - $db_server_port = explode(':', _LEGACY_DB_SERVER_); - if (count($db_server_port) == 1) { - $db_server = $db_server_port[0]; - $db_port = 3306; - } else { - $db_server = $db_server_port[0]; - $db_port = $db_server_port[1]; - } - - $parameters = [ - 'parameters' => [ - 'database_host' => $db_server, - 'database_port' => $db_port, - 'database_user' => _LEGACY_DB_USER_, - 'database_password' => _LEGACY_DB_PASSWD_, - 'database_name' => _LEGACY_DB_NAME_, - 'database_prefix' => _LEGACY_DB_PREFIX_, - 'database_engine' => defined(_LEGACY_MYSQL_ENGINE_) ? _LEGACY_MYSQL_ENGINE_ : 'InnoDB', - 'cookie_key' => _LEGACY_COOKIE_KEY_, - 'cookie_iv' => _LEGACY_COOKIE_IV_, - 'new_cookie_key' => _LEGACY_NEW_COOKIE_KEY_, - 'ps_caching' => defined(_LEGACY_PS_CACHING_SYSTEM_) ? _LEGACY_PS_CACHING_SYSTEM_ : 'CacheMemcache', - 'ps_cache_enable' => defined(_LEGACY_PS_CACHE_ENABLED_) ? _LEGACY_PS_CACHE_ENABLED_ : false, - 'ps_creation_date' => defined(_LEGACY_PS_CREATION_DATE_) ? _LEGACY_PS_CREATION_DATE_ : date('Y-m-d H:i:s'), - 'secret' => $secret, - 'mailer_transport' => 'smtp', - 'mailer_host' => '127.0.0.1', - 'mailer_user' => '', - 'mailer_password' => '', - ] + $default_parameters['parameters'], - ]; - } elseif (file_exists($root_dir . '/app/config/parameters.yml')) { - $parameters = Yaml::parse(file_get_contents($root_dir . '/app/config/parameters.yml')); - if (empty($parameters['parameters'])) { - $parameters['parameters'] = []; - } - // add potentially missing default entries - $parameters['parameters'] = $parameters['parameters'] + $default_parameters['parameters']; - } else { - $parameters = $default_parameters; - } - - if (!empty($parameters) && $exportPhpConfigFile($parameters, $phpParametersFilepath)) { - $fileMigrated = true; - $settings_content = "getIO()->write('No old config file present!'); - } - $event->getIO()->write('Finished...'); - } - - return true; - } - } -} diff --git a/src/PrestaShopBundle/Install/XmlLoader.php b/src/PrestaShopBundle/Install/XmlLoader.php deleted file mode 100644 index c53984a1..00000000 --- a/src/PrestaShopBundle/Install/XmlLoader.php +++ /dev/null @@ -1,1434 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Install; - -use PrestaShop\PrestaShop\Adapter\Entity\Db; -use PrestaShop\PrestaShop\Adapter\Entity\DbQuery; -use PrestaShop\PrestaShop\Adapter\Entity\Image; -use PrestaShop\PrestaShop\Adapter\Entity\ImageManager; -use PrestaShop\PrestaShop\Adapter\Entity\ImageType; -use PrestaShop\PrestaShop\Adapter\Entity\Pack; -use PrestaShop\PrestaShop\Adapter\Entity\Shop; -use PrestaShop\PrestaShop\Adapter\Entity\StockAvailable; -use PrestaShop\PrestaShop\Adapter\Entity\Tag; -use PrestaShop\PrestaShop\Adapter\Entity\Tools; -use PrestaShop\PrestaShop\Core\Foundation\Filesystem\FileSystem; -use PrestaShopDatabaseException; -use PrestashopInstallerException; - -class XmlLoader -{ - /** - * @var LanguageList - */ - protected $language; - - /** - * @var \Symfony\Bundle\FrameworkBundle\Translation\Translator - */ - protected $translator; - - /** - * @var array List of languages stored as array(id_lang => iso) - */ - protected $languages = []; - - /** - * @var array Store in cache all loaded XML files - */ - protected $cache_xml_entity = []; - - /** - * @var array List of errors - */ - protected $errors = []; - - protected $data_path; - protected $lang_path; - protected $img_path; - public $path_type; - - protected $ids = []; - - protected $primaries = []; - - protected $delayed_inserts = []; - - public function __construct() - { - $this->language = LanguageList::getInstance(); - $this->setDefaultPath(); - } - - /** - * Set list of installed languages. - * - * @param array $languages array(id_lang => iso) - */ - public function setLanguages(array $languages) - { - $this->languages = $languages; - } - - public function setTranslator($translator) - { - $this->translator = $translator; - - return $translator; - } - - public function setDefaultPath() - { - $this->path_type = 'common'; - $this->data_path = _PS_INSTALL_DATA_PATH_ . 'xml/'; - $this->lang_path = _PS_INSTALL_LANGS_PATH_; - $this->img_path = _PS_INSTALL_DATA_PATH_ . 'img/'; - } - - public function setFixturesPath($path = null) - { - if ($path === null) { - $path = _PS_INSTALL_FIXTURES_PATH_ . 'fashion/'; - } - - $this->path_type = 'fixture'; - $this->data_path = $path . 'data/'; - $this->lang_path = $path . 'langs/'; - $this->img_path = $path . 'img/'; - } - - /** - * Get list of errors. - * - * @return array - */ - public function getErrors() - { - return $this->errors; - } - - /** - * Add an error. - * - * @param string $error - */ - public function setError($error) - { - $this->errors[] = $error; - } - - /** - * Store an ID related to an entity and its identifier (E.g. we want to save that product with ID "ipod_nano" has the ID 1). - * - * @param string $entity - * @param string $identifier - * @param int $id - */ - public function storeId($entity, $identifier, $id) - { - $this->ids[$entity . ':' . $identifier] = $id; - } - - /** - * Retrieve an ID related to an entity and its identifier. - * - * @param string $entity - * @param string $identifier - */ - public function retrieveId($entity, $identifier) - { - return isset($this->ids[$entity . ':' . $identifier]) ? $this->ids[$entity . ':' . $identifier] : 0; - } - - public function getIds() - { - return $this->ids; - } - - public function setIds($ids) - { - $this->ids = $ids; - } - - public function getSortedEntities() - { - // Browse all XML files from data/xml directory - $entities = []; - $dependencies = []; - foreach (scandir($this->data_path) as $file) { - if (preg_match('#^(.+)\.xml$#', $file, $m)) { - $entity = $m[1]; - $xml = $this->loadEntity($entity); - - // Store entities dependencies (with field type="relation") - if ($xml->fields) { - foreach ($xml->fields->field as $field) { - if ($field['relation'] && $field['relation'] != $entity) { - if (!isset($dependencies[(string) $field['relation']])) { - $dependencies[(string) $field['relation']] = []; - } - $dependencies[(string) $field['relation']][] = $entity; - } - } - } - $entities[] = $entity; - } - } - - // Sort entities to populate database in good order (E.g. zones before countries) - do { - $current = (isset($sort_entities)) ? $sort_entities : []; - $sort_entities = []; - foreach ($entities as $key => $entity) { - if (isset($dependencies[$entity])) { - $min = count($entities) - 1; - foreach ($dependencies[$entity] as $item) { - if (($key = array_search($item, $sort_entities)) !== false) { - $min = min($min, $key); - } - } - if ($min == 0) { - array_unshift($sort_entities, $entity); - } else { - array_splice($sort_entities, $min, 0, [$entity]); - } - } else { - $sort_entities[] = $entity; - } - } - $entities = $sort_entities; - } while ($current != $sort_entities); - - return $sort_entities; - } - - /** - * Read all XML files from data folder and populate tables. - */ - public function populateFromXmlFiles() - { - $entities = $this->getSortedEntities(); - - // Populate entities - foreach ($entities as $entity) { - $this->populateEntity($entity); - } - } - - /** - * Populate an entity. - * - * @param string $entity - */ - public function populateEntity($entity) - { - if (method_exists($this, 'populateEntity' . Tools::toCamelCase($entity))) { - $this->{'populateEntity' . Tools::toCamelCase($entity)}(); - - return; - } - - if (substr($entity, 0, 1) == '.' || substr($entity, 0, 1) == '_') { - return; - } - - $xml = $this->loadEntity($entity); - - // Read list of fields - if (!is_object($xml) || !$xml->fields) { - throw new PrestashopInstallerException('List of fields not found for entity ' . $entity); - } - - $is_multi_lang_entity = $this->isMultilang($entity); - if ($is_multi_lang_entity) { - $multilang_columns = $this->getColumns($entity, true); - $xml_langs = []; - $default_lang = null; - foreach ($this->languages as $id_lang => $iso) { - if ($iso == $this->language->getLanguageIso()) { - $default_lang = $id_lang; - } - - try { - $xml_langs[$id_lang] = $this->loadEntity($entity, $iso); - } catch (PrestashopInstallerException $e) { - $xml_langs[$id_lang] = null; - } - } - } - - // Load all row for current entity and prepare data to be populated - $i = 0; - foreach ($xml->entities->$entity as $node) { - $data = []; - $identifier = (string) $node['id']; - - // Read attributes - foreach ($node->attributes() as $k => $v) { - if ($k != 'id') { - $data[$k] = (string) $v; - } - } - - // Read cdatas - foreach ($node->children() as $child) { - $data[$child->getName()] = (string) $child; - } - - // Load multilang data - $data_lang = []; - if ($is_multi_lang_entity) { - $xpath_query = $entity . '[@id="' . $identifier . '"]'; - foreach ($xml_langs as $id_lang => $xml_lang) { - if (!$xml_lang) { - continue; - } - - if (($node_lang = $xml_lang->xpath($xpath_query)) || ($node_lang = $xml_langs[$default_lang]->xpath($xpath_query))) { - $node_lang = $node_lang[0]; - foreach ($multilang_columns as $column => $is_text) { - $value = ''; - if ($node_lang[$column]) { - $value = (string) $node_lang[$column]; - } - - if ($node_lang->$column) { - $value = (string) $node_lang->$column; - } - $data_lang[$column][$id_lang] = $value; - } - } - } - } - - $data = $this->rewriteRelationedData($entity, $data); - if (method_exists($this, 'createEntity' . Tools::toCamelCase($entity))) { - // Create entity with custom method in current class - $method = 'createEntity' . Tools::toCamelCase($entity); - $this->$method($identifier, $data, $data_lang); - } else { - $this->createEntity($entity, $identifier, (string) $xml->fields['class'], $data, $data_lang); - } - - if ($xml->fields['image']) { - if (method_exists($this, 'copyImages' . Tools::toCamelCase($entity))) { - $this->{'copyImages' . Tools::toCamelCase($entity)}($identifier, $data); - } else { - $this->copyImages($entity, $identifier, (string) $xml->fields['image'], $data); - } - } - ++$i; - - if ($i >= 100) { - $this->flushDelayedInserts(); - $i = 0; - } - } - - $this->flushDelayedInserts(); - unset($this->cache_xml_entity[$this->path_type][$entity]); - } - - protected function getFallBackToDefaultLanguage($iso) - { - return file_exists($this->lang_path . $iso . '/data/') ? $iso : 'en'; - } - - protected function getFallBackToDefaultEntityLanguage($iso, $entity) - { - if ($this->getFallBackToDefaultLanguage($iso) === 'en') { - return 'en'; - } - - return file_exists($this->lang_path . $this->getFallBackToDefaultLanguage($iso) . '/data/' . $entity . '.xml') ? $iso : 'en'; - } - - /** - * Special case for "tag" entity. - */ - public function populateEntityTag() - { - foreach ($this->languages as $id_lang => $iso) { - if (!file_exists($this->lang_path . $this->getFallBackToDefaultLanguage($iso) . '/data/tag.xml')) { - continue; - } - - $xml = $this->loadEntity('tag', $this->getFallBackToDefaultLanguage($iso)); - $tags = []; - foreach ($xml->tag as $tag_node) { - $products = trim((string) $tag_node['products']); - if (!$products) { - continue; - } - - foreach (explode(',', $products) as $product) { - $product = trim($product); - $product_id = $this->retrieveId('product', $product); - if (!isset($tags[$product_id])) { - $tags[$product_id] = []; - } - $tags[$product_id][] = trim((string) $tag_node['name']); - } - } - - foreach ($tags as $id_product => $tag_list) { - Tag::addTags($id_lang, $id_product, $tag_list); - } - } - } - - /** - * Load an entity XML file. - * - * @param string $entity - * - * @return \SimpleXMLElement - */ - protected function loadEntity($entity, $iso = null) - { - if (!isset($this->cache_xml_entity[$this->path_type][$entity][$iso])) { - if (substr($entity, 0, 1) == '.' || substr($entity, 0, 1) == '_') { - return; - } - - $path = $this->data_path . $entity . '.xml'; - if ($iso) { - $path = $this->lang_path . $this->getFallBackToDefaultEntityLanguage($iso, $entity) . '/data/' . $entity . '.xml'; - } - - if (!file_exists($path)) { - throw new PrestashopInstallerException('XML data file ' . $entity . '.xml not found'); - } - - $this->cache_xml_entity[$this->path_type][$entity][$iso] = @simplexml_load_file($path, 'SimplexmlElement'); - if (!$this->cache_xml_entity[$this->path_type][$entity][$iso]) { - throw new PrestashopInstallerException('XML data file ' . $entity . '.xml invalid'); - } - } - - return $this->cache_xml_entity[$this->path_type][$entity][$iso]; - } - - /** - * Check fields related to an other entity, and replace their values by the ID created by the other entity. - * - * @param string $entity - * @param array $data - */ - protected function rewriteRelationedData($entity, array $data) - { - $xml = $this->loadEntity($entity); - foreach ($xml->fields->field as $field) { - if ($field['relation']) { - $id = $this->retrieveId((string) $field['relation'], $data[(string) $field['name']]); - if (!$id && $data[(string) $field['name']] && is_numeric($data[(string) $field['name']])) { - $id = $data[(string) $field['name']]; - } - $data[(string) $field['name']] = $id; - } - } - - return $data; - } - - public function flushDelayedInserts() - { - foreach ($this->delayed_inserts as $entity => $queries) { - $type = Db::INSERT_IGNORE; - if ($entity == 'access') { - $type = Db::REPLACE; - } - - if (!Db::getInstance()->insert($entity, $queries, false, true, $type)) { - $this->setError($this->translator->trans('An SQL error occurred for entity %entity%: %message%', ['%entity%' => $entity, '%message%' => Db::getInstance()->getMsgError()], 'Install')); - } - unset($this->delayed_inserts[$entity]); - } - } - - /** - * Create a simple entity with all its data and lang data - * If a methode createEntity$entity exists, use it. Else if $classname is given, use it. Else do a simple insert in database. - * - * @param string $entity - * @param string $identifier - * @param string $classname - * @param array $data - * @param array $data_lang - */ - public function createEntity($entity, $identifier, $classname, array $data, array $data_lang = []) - { - $xml = $this->loadEntity($entity); - if ($classname) { - $classname = '\\' . $classname; - // Create entity with ObjectModel class - $object = new $classname(); - $object->hydrate($data); - if ($data_lang) { - $object->hydrate($data_lang); - } - $object->add(true, (isset($xml->fields['null'])) ? true : false); - $entity_id = $object->id; - unset($object); - } else { - // Generate primary key manually - $primary = ''; - $entity_id = 0; - if (!$xml->fields['primary']) { - $primary = 'id_' . $entity; - } elseif (strpos((string) $xml->fields['primary'], ',') === false) { - $primary = (string) $xml->fields['primary']; - } - unset($xml); - - if ($primary) { - $entity_id = $this->generatePrimary($entity, $primary); - $data[$primary] = $entity_id; - } - - // Store INSERT queries in order to optimize install with grouped inserts - $this->delayed_inserts[$entity][] = array_map('pSQL', $data); - if ($data_lang) { - $real_data_lang = []; - foreach ($data_lang as $field => $list) { - foreach ($list as $id_lang => $value) { - $real_data_lang[$id_lang][$field] = $value; - } - } - - foreach ($real_data_lang as $id_lang => $insert_data_lang) { - $insert_data_lang['id_' . $entity] = $entity_id; - $insert_data_lang['id_lang'] = $id_lang; - $this->delayed_inserts[$entity . '_lang'][] = array_map('pSQL', $insert_data_lang); - } - - // Store INSERT queries for _shop associations - $entity_asso = Shop::getAssoTable($entity); - if ($entity_asso !== false && $entity_asso['type'] == 'shop') { - $this->delayed_inserts[$entity . '_shop'][] = [ - 'id_shop' => 1, - 'id_' . $entity => $entity_id, - ]; - } - } - } - - $this->storeId($entity, $identifier, $entity_id); - } - - public function createEntityConfiguration($identifier, array $data, array $data_lang) - { - if (Db::getInstance()->getValue('SELECT id_configuration FROM ' . _DB_PREFIX_ . 'configuration WHERE name = \'' . pSQL($data['name']) . '\'')) { - return; - } - - $entity = 'configuration'; - $entity_id = $this->generatePrimary($entity, 'id_configuration'); - $data['id_configuration'] = $entity_id; - - // Store INSERT queries in order to optimize install with grouped inserts - $this->delayed_inserts[$entity][] = array_map('pSQL', $data); - if ($data_lang) { - $real_data_lang = []; - foreach ($data_lang as $field => $list) { - foreach ($list as $id_lang => $value) { - $real_data_lang[$id_lang][$field] = $value; - } - } - - foreach ($real_data_lang as $id_lang => $insert_data_lang) { - $insert_data_lang['id_' . $entity] = $entity_id; - $insert_data_lang['id_lang'] = $id_lang; - $this->delayed_inserts[$entity . '_lang'][] = array_map('pSQL', $insert_data_lang); - } - } - - $this->storeId($entity, $identifier, $entity_id); - } - - /** - * @param string $identifier - * @param array $data - * @param array $data_lang - * - * @return $this - * - * @throws PrestaShopDatabaseException - */ - public function createEntityPack($identifier, array $data, array $data_lang) - { - Pack::addItem($data['id_product_pack'], $data['id_product_item'], $data['quantity']); - - return $this; - } - - public function createEntityStockAvailable($identifier, array $data, array $data_lang) - { - $stock_available = new StockAvailable(); - $stock_available->updateQuantity($data['id_product'], $data['id_product_attribute'], $data['quantity'], $data['id_shop']); - } - - public function createEntityTab($identifier, array $data, array $data_lang) - { - static $position = []; - - $entity = 'tab'; - $xml = $this->loadEntity($entity); - - if (!isset($position[$data['id_parent']])) { - $position[$data['id_parent']] = 0; - } - $data['position'] = $position[$data['id_parent']]++; - - // Generate primary key manually - $primary = ''; - $entity_id = 0; - if (!$xml->fields['primary']) { - $primary = 'id_' . $entity; - } elseif (strpos((string) $xml->fields['primary'], ',') === false) { - $primary = (string) $xml->fields['primary']; - } - - if ($primary) { - $entity_id = $this->generatePrimary($entity, $primary); - $data[$primary] = $entity_id; - } - - // Store INSERT queries in order to optimize install with grouped inserts - $this->delayed_inserts[$entity][] = array_map('pSQL', $data); - if ($data_lang) { - $real_data_lang = []; - foreach ($data_lang as $field => $list) { - foreach ($list as $id_lang => $value) { - $real_data_lang[$id_lang][$field] = $value; - } - } - - foreach ($real_data_lang as $id_lang => $insert_data_lang) { - $insert_data_lang['id_' . $entity] = $entity_id; - $insert_data_lang['id_lang'] = $id_lang; - $this->delayed_inserts[$entity . '_lang'][] = array_map('pSQL', $insert_data_lang); - } - } - - $this->storeId($entity, $identifier, $entity_id); - } - - public function generatePrimary($entity, $primary) - { - if (!isset($this->primaries[$entity])) { - $entity = Db::getInstance()->escape($entity, false, true); - $primary = Db::getInstance()->escape($primary, false, true); - $this->primaries[$entity] = (int) Db::getInstance()->getValue( - 'SELECT ' . $primary . ' FROM `' . _DB_PREFIX_ . $entity . '` ORDER BY `' . $primary . '` DESC' - ); - } - - return ++$this->primaries[$entity]; - } - - public function copyImages($entity, $identifier, $path, array $data, $extension = 'jpg') - { - // Get list of image types - $reference = [ - 'product' => 'products', - 'category' => 'categories', - 'manufacturer' => 'manufacturers', - 'supplier' => 'suppliers', - 'store' => 'stores', - ]; - - $types = []; - if (isset($reference[$entity])) { - $types = ImageType::getImagesTypes($reference[$entity]); - } - - // For each path copy images - $path = array_map('trim', explode(',', $path)); - foreach ($path as $p) { - $from_path = $this->img_path . $p . '/'; - $dst_path = _PS_IMG_DIR_ . $p . '/'; - $entity_id = $this->retrieveId($entity, $identifier); - - if (!@copy($from_path . $identifier . '.' . $extension, $dst_path . $entity_id . '.' . $extension)) { - $this->setError( - $this->translator->trans( - 'Cannot create image "%identifier%" for entity "%entity%"', - ['%entity%' => $entity, '%identifier%' => $identifier], - 'Install' - ) - ); - - return; - } - - foreach ($types as $type) { - $origin_file = $from_path . $identifier . '-' . $type['name'] . '.' . $extension; - $target_file = $dst_path . $entity_id . '-' . $type['name'] . '.' . $extension; - - // Test if dest folder is writable - if (!is_writable(dirname($target_file))) { - $this->setError( - $this->translator->trans( - 'Cannot create image "%identifier%" (bad permissions on folder "%folder%")', - ['%identifier%' => $identifier . '-' . $type['name'], '%folder%' => dirname($target_file)], - 'Install' - ) - ); - } elseif (file_exists($origin_file)) { - // If a file named folder/entity-type.extension exists just copy it - // this is an optimisation in order to prevent to much resize - if (!@copy($origin_file, $target_file)) { - $this->setError( - $this->translator->trans( - 'Cannot create image "%identifier%"', - ['%identifier%' => $identifier . '-' . $type['name']], - 'Install' - ) - ); - } - @chmod($target_file, FileSystem::DEFAULT_MODE_FILE); - } elseif (!ImageManager::resize( - $from_path . $identifier . '.' . $extension, - $target_file, - $type['width'], - $type['height'] - )) { - // Resize the image if no cache was prepared in fixtures - $this->setError( - $this->translator->trans( - 'Cannot create image "%identifier%" for entity "%entity%"', - ['%identifier%' => $identifier . '-' . $type['name'], '%entity%' => $entity], - 'Install' - ) - ); - } - } - } - Image::moveToNewFileSystem(); - } - - public function copyImagesOrderState($identifier, array $data) - { - $this->copyImages('order_state', $identifier, 'os', $data, 'gif'); - } - - public function copyImagesTab($identifier, array $data) - { - $from_path = $this->img_path . 't/'; - $dst_path = _PS_IMG_DIR_ . 't/'; - if (file_exists($from_path . $data['class_name'] . '.gif') && !file_exists($dst_path . $data['class_name'] . '.gif')) { - //test if file exist in install dir and if do not exist in dest folder. - if (!@copy($from_path . $data['class_name'] . '.gif', $dst_path . $data['class_name'] . '.gif')) { - $this->setError($this->translator->trans('Cannot create image "%identifier%" for entity "%entity%"', ['%identifier%' => $identifier, '%tab%' => 'tab'], 'Install')); - - return; - } - } - } - - public function copyImagesImage($identifier) - { - $path = $this->img_path . 'p/'; - $image = new Image($this->retrieveId('image', $identifier)); - $dst_path = $image->getPathForCreation(); - if (!@copy($path . $identifier . '.jpg', $dst_path . '.' . $image->image_format)) { - $this->setError( - $this->translator->trans( - 'Cannot create image "%identifier%" for entity "%entity%"', - ['%identifier%' => $identifier, '%entity%' => 'product'], - 'Install' - ) - ); - - return; - } - @chmod($dst_path . '.' . $image->image_format, FileSystem::DEFAULT_MODE_FILE); - - $types = ImageType::getImagesTypes('products'); - foreach ($types as $type) { - $origin_file = $path . $identifier . '-' . $type['name'] . '.jpg'; - $target_file = $dst_path . '-' . $type['name'] . '.' . $image->image_format; - - // Test if dest folder is writable - if (!is_writable(dirname($target_file))) { - $this->setError( - $this->translator->trans( - 'Cannot create image "%identifier%" (bad permissions on folder "%folder%")', - ['%identifier%' => $identifier . '-' . $type['name'], '%folder%' => dirname($target_file)], - 'Install' - ) - ); - } elseif (file_exists($origin_file)) { - // If a file named folder/entity-type.jpg exists just copy it - // this is an optimisation in order to prevent to much resize - if (!@copy($origin_file, $target_file)) { - $this->setError( - $this->translator->trans( - 'Cannot create image "%1$s" for entity "%2$s"', - ['%identifier%' => $identifier . '-' . $type['name'], '%entity%' => 'product'], - 'Install' - ) - ); - } - @chmod($target_file, FileSystem::DEFAULT_MODE_FILE); - } elseif (!ImageManager::resize($path . $identifier . '.jpg', $target_file, $type['width'], $type['height'])) { - // Resize the image if no cache was prepared in fixtures - $this->setError( - $this->translator->trans( - 'Cannot create image "%identifier%" for entity "%entity%"', - ['%identifier%' => $identifier . '-' . $type['name'], '%entity%' => 'product'], - 'Install' - ) - ); - } - } - } - - public function getTables() - { - static $tables = null; - - if (null === $tables) { - $tables = []; - foreach (Db::getInstance()->executeS('SHOW TABLES') as $row) { - $table = current($row); - if (preg_match('#^' . _DB_PREFIX_ . '(.+?)(_lang)?$#i', $table, $m)) { - $tables[$m[1]] = (isset($m[2]) && $m[2]) ? true : false; - } - } - } - - return $tables; - } - - public function hasElements($table) - { - $table = Db::getInstance()->escape($table, false, true); - - return (bool) Db::getInstance()->getValue('SELECT COUNT(*) FROM `' . _DB_PREFIX_ . $table . '`'); - } - - public function getColumns($table, $multilang = false, array $exclude = []) - { - static $columns = []; - - if ($multilang) { - return ($this->isMultilang($table)) ? $this->getColumns($table . '_lang', false, ['id_' . $table]) : []; - } - - if (!isset($columns[$table])) { - $columns[$table] = []; - $sql = 'SHOW COLUMNS FROM `' . _DB_PREFIX_ . bqSQL($table) . '`'; - foreach (Db::getInstance()->executeS($sql) as $row) { - $columns[$table][$row['Field']] = $this->checkIfTypeIsText($row['Type']); - } - } - - $exclude = array_merge(['id_' . $table, 'date_add', 'date_upd', 'deleted', 'id_lang'], $exclude); - - $list = []; - foreach ($columns[$table] as $k => $v) { - if (!in_array($k, $exclude)) { - $list[$k] = $v; - } - } - - return $list; - } - - public function getClasses($path = null) - { - static $cache = null; - - if (null !== $cache) { - return $cache; - } - - $dir = $path; - if (null === $dir) { - $dir = _PS_CLASS_DIR_; - } - - $classes = []; - foreach (scandir($dir, SCANDIR_SORT_NONE) as $file) { - if ($file[0] != '.' && $file != 'index.php') { - if (is_dir($dir . $file)) { - $classes = array_merge($classes, $this->getClasses($dir . $file . '/')); - } elseif (preg_match('#^(.+)\.php$#', $file, $m)) { - $classes[] = $m[1]; - } - } - } - - sort($classes); - if (null === $path) { - $cache = $classes; - } - - return $classes; - } - - public function checkIfTypeIsText($type) - { - if (preg_match('#^(longtext|text|tinytext)#i', $type)) { - return true; - } - - if (preg_match('#^varchar\(([0-9]+)\)$#i', $type, $m)) { - return (int) ($m[1]) >= 64 ? true : false; - } - - return false; - } - - public function isMultilang($entity) - { - $tables = $this->getTables(); - - return isset($tables[$entity]) && $tables[$entity]; - } - - public function entityExists($entity) - { - return file_exists($this->data_path . $entity . '.xml'); - } - - public function getEntitiesList() - { - $entities = []; - foreach (scandir($this->data_path, SCANDIR_SORT_NONE) as $file) { - if ($file[0] != '.' && preg_match('#^(.+)\.xml$#', $file, $m)) { - $entities[] = $m[1]; - } - } - - return $entities; - } - - public function getEntityInfo($entity) - { - $info = [ - 'config' => [ - 'id' => '', - 'primary' => '', - 'class' => '', - 'sql' => '', - 'ordersql' => '', - 'image' => '', - 'null' => '', - ], - 'fields' => [], - ]; - - if (!$this->entityExists($entity)) { - return $info; - } - - $xml = @simplexml_load_file($this->data_path . $entity . '.xml', 'SimplexmlElement'); - if (!$xml) { - return $info; - } - - if ($xml->fields['id']) { - $info['config']['id'] = (string) $xml->fields['id']; - } - - if ($xml->fields['primary']) { - $info['config']['primary'] = (string) $xml->fields['primary']; - } - - if ($xml->fields['class']) { - $info['config']['class'] = (string) $xml->fields['class']; - } - - if ($xml->fields['sql']) { - $info['config']['sql'] = (string) $xml->fields['sql']; - } - - if ($xml->fields['ordersql']) { - $info['config']['ordersql'] = (string) $xml->fields['ordersql']; - } - - if ($xml->fields['null']) { - $info['config']['null'] = (string) $xml->fields['null']; - } - - if ($xml->fields['image']) { - $info['config']['image'] = (string) $xml->fields['image']; - } - - foreach ($xml->fields->field as $field) { - $column = (string) $field['name']; - $info['fields'][$column] = []; - if (isset($field['relation'])) { - $info['fields'][$column]['relation'] = (string) $field['relation']; - } - } - - return $info; - } - - public function getDependencies() - { - $entities = []; - foreach ($this->getEntitiesList() as $entity) { - $entities[$entity] = $this->getEntityInfo($entity); - } - - $dependencies = []; - foreach ($entities as $entity => $info) { - foreach ($info['fields'] as $field => $info_field) { - if (isset($info_field['relation']) && $info_field['relation'] != $entity) { - if (!isset($dependencies[$info_field['relation']])) { - $dependencies[$info_field['relation']] = []; - } - $dependencies[$info_field['relation']][] = $entity; - } - } - } - - return $dependencies; - } - - public function generateEntitySchema($entity, array $fields, array $config) - { - if ($this->entityExists($entity)) { - $xml = $this->loadEntity($entity); - } else { - $xml = new SimplexmlElement(''); - } - unset($xml->fields); - - // Fill attributes (config) - $xml_fields = $xml->addChild('fields'); - foreach ($config as $k => $v) { - if ($v) { - $xml_fields[$k] = $v; - } - } - - // Create list of fields - foreach ($fields as $column => $info) { - $field = $xml_fields->addChild('field'); - $field['name'] = $column; - if (isset($info['relation'])) { - $field['relation'] = $info['relation']; - } - } - - // Recreate entities nodes, in order to have the node after the node - $store_entities = clone $xml->entities; - unset($xml->entities); - $xml->addChild('entities', $store_entities); - - $xml->asXML($this->data_path . $entity . '.xml'); - } - - /** - * ONLY FOR DEVELOPMENT PURPOSE. - */ - public function generateAllEntityFiles() - { - $entities = []; - foreach ($this->getEntitiesList() as $entity) { - $entities[$entity] = $this->getEntityInfo($entity); - } - $this->generateEntityFiles($entities); - } - - /** - * ONLY FOR DEVELOPMENT PURPOSE. - */ - public function generateEntityFiles($entities) - { - $dependencies = $this->getDependencies(); - - // Sort entities to populate database in good order (E.g. zones before countries) - do { - $current = (isset($sort_entities)) ? $sort_entities : []; - $sort_entities = []; - foreach ($entities as $entity) { - if (isset($dependencies[$entity])) { - $min = count($entities) - 1; - foreach ($dependencies[$entity] as $item) { - if (($key = array_search($item, $sort_entities)) !== false) { - $min = min($min, $key); - } - } - if ($min == 0) { - array_unshift($sort_entities, $entity); - } else { - array_splice($sort_entities, $min, 0, [$entity]); - } - } else { - $sort_entities[] = $entity; - } - } - $entities = $sort_entities; - } while ($current != $sort_entities); - - foreach ($sort_entities as $entity) { - $this->generateEntityContent($entity); - } - } - - public function generateEntityContent($entity) - { - $xml = $this->loadEntity($entity); - if (method_exists($this, 'getEntityContents' . Tools::toCamelCase($entity))) { - $content = $this->{'getEntityContents' . Tools::toCamelCase($entity)}($entity); - } else { - $content = $this->getEntityContents($entity); - } - - unset($xml->entities); - $entities = $xml->addChild('entities'); - $this->createXmlEntityNodes($entity, $content['nodes'], $entities); - $xml->asXML($this->data_path . $entity . '.xml'); - - // Generate multilang XML files - if ($content['nodes_lang']) { - foreach ($content['nodes_lang'] as $id_lang => $nodes) { - if (!isset($this->languages[$id_lang])) { - continue; - } - - $iso = $this->languages[$id_lang]; - if (!is_dir($this->lang_path . $this->getFallBackToDefaultLanguage($iso) . '/data')) { - mkdir($this->lang_path . $this->getFallBackToDefaultLanguage($iso) . '/data'); - } - - $xml_node = new SimplexmlElement(''); - $this->createXmlEntityNodes($entity, $nodes, $xml_node); - $xml_node->asXML($this->lang_path . $this->getFallBackToDefaultEntityLanguage($iso, $entity) . '/data/' . $entity . '.xml'); - } - } - - if ($xml->fields['image']) { - if (method_exists($this, 'backupImage' . Tools::toCamelCase($entity))) { - $this->{'backupImage' . Tools::toCamelCase($entity)}((string) $xml->fields['image']); - } else { - $this->backupImage($entity, (string) $xml->fields['image']); - } - } - } - - /** - * ONLY FOR DEVELOPMENT PURPOSE. - */ - public function getEntityContents($entity) - { - $xml = $this->loadEntity($entity); - $primary = (isset($xml->fields['primary']) && $xml->fields['primary']) ? (string) $xml->fields['primary'] : 'id_' . $entity; - $is_multilang = $this->isMultilang($entity); - - // Check if current table is an association table (if multiple primary keys) - $is_association = false; - if (strpos($primary, ',') !== false) { - $is_association = true; - $primary = array_map('trim', explode(',', $primary)); - } - - // Build query - $sql = new DbQuery(); - $sql->select('a.*'); - $sql->from($entity, 'a'); - if ($is_multilang) { - $sql->select('b.*'); - $sql->leftJoin($entity . '_lang', 'b', 'a.' . $primary . ' = b.' . $primary); - } - - if (isset($xml->fields['sql']) && $xml->fields['sql']) { - $sql->where((string) $xml->fields['sql']); - } - - if (!$is_association) { - $sql->select('a.' . $primary); - if (!isset($xml->fields['ordersql']) || !$xml->fields['ordersql']) { - $sql->orderBy('a.' . $primary); - } - } - - if ($is_multilang && (!isset($xml->fields['ordersql']) || !$xml->fields['ordersql'])) { - $sql->orderBy('b.id_lang'); - } - - if (isset($xml->fields['ordersql']) && $xml->fields['ordersql']) { - $sql->orderBy((string) $xml->fields['ordersql']); - } - - // Get multilang columns - $alias_multilang = []; - if ($is_multilang) { - $columns = $this->getColumns($entity); - $multilang_columns = $this->getColumns($entity, true); - - // If some columns from _lang table have same name than original table, rename them (E.g. value in configuration) - foreach ($multilang_columns as $c => $is_text) { - if (isset($columns[$c])) { - $alias = $c . '_alias'; - $alias_multilang[$c] = $alias; - $sql->select('a.' . $c . ' as ' . $c . ', b.' . $c . ' as ' . $alias); - } - } - } - - // Get all results - $nodes = $nodes_lang = []; - $results = Db::getInstance()->executeS($sql); - if (Db::getInstance()->getNumberError()) { - $this->setError($this->translator->trans('SQL error on query %query%', ['%sql%' => $sql], 'Install')); - } else { - foreach ($results as $row) { - // Store common columns - if ($is_association) { - $id = $entity; - foreach ($primary as $key) { - $id .= '_' . $row[$key]; - } - } else { - $id = $this->generateId($entity, $row[$primary], $row, (isset($xml->fields['id']) && $xml->fields['id']) ? (string) $xml->fields['id'] : null); - } - - if (!isset($nodes[$id])) { - $node = []; - foreach ($xml->fields->field as $field) { - $column = (string) $field['name']; - if (isset($field['relation'])) { - $sql = 'SELECT `id_' . bqSQL($field['relation']) . '` - FROM `' . bqSQL(_DB_PREFIX_ . $field['relation']) . '` - WHERE `id_' . bqSQL($field['relation']) . '` = ' . (int) $row[$column]; - $node[$column] = $this->generateId((string) $field['relation'], Db::getInstance()->getValue($sql)); - - // A little trick to allow storage of some hard values, like '-1' for tab.id_parent - if (!$node[$column] && $row[$column]) { - $node[$column] = $row[$column]; - } - } else { - $node[$column] = $row[$column]; - } - } - $nodes[$id] = $node; - } - - // Store multilang columns - if ($is_multilang && $row['id_lang']) { - $node = []; - foreach ($multilang_columns as $column => $is_text) { - $node[$column] = $row[isset($alias_multilang[$column]) ? $alias_multilang[$column] : $column]; - } - $nodes_lang[$row['id_lang']][$id] = $node; - } - } - } - - return [ - 'nodes' => $nodes, - 'nodes_lang' => $nodes_lang, - ]; - } - - public function getEntityContentsTag() - { - $nodes_lang = []; - - $sql = 'SELECT t.id_tag, t.id_lang, t.name, pt.id_product - FROM ' . _DB_PREFIX_ . 'tag t - LEFT JOIN ' . _DB_PREFIX_ . 'product_tag pt ON t.id_tag = pt.id_tag - ORDER BY id_lang'; - foreach (Db::getInstance()->executeS($sql) as $row) { - $identifier = $this->generateId('tag', $row['id_tag']); - if (!isset($nodes_lang[$row['id_lang']])) { - $nodes_lang[$row['id_lang']] = []; - } - - if (!isset($nodes_lang[$row['id_lang']][$identifier])) { - $nodes_lang[$row['id_lang']][$identifier] = [ - 'name' => $row['name'], - 'products' => '', - ]; - } - - $nodes_lang[$row['id_lang']][$identifier]['products'] .= (($nodes_lang[$row['id_lang']][$identifier]['products']) ? ',' : '') . $this->generateId('product', $row['id_product']); - } - - return [ - 'nodes' => [], - 'nodes_lang' => $nodes_lang, - ]; - } - - /** - * ONLY FOR DEVELOPMENT PURPOSE. - */ - public function generateId($entity, $primary, array $row = [], $id_format = null) - { - static $ids = []; - - if (isset($ids[$entity][$primary])) { - return $ids[$entity][$primary]; - } - - if (!isset($ids[$entity])) { - $ids[$entity] = []; - } - - if (!$primary) { - return ''; - } - - if (!$id_format || !$row || !$row[$id_format]) { - $ids[$entity][$primary] = $entity . '_' . $primary; - } else { - $value = $row[$id_format]; - $value = preg_replace('#[^a-z0-9_-]#i', '_', $value); - $value = preg_replace('#_+#', '_', $value); - $value = preg_replace('#^_+#', '', $value); - $value = preg_replace('#_+$#', '', $value); - - $store_identifier = $value; - $i = 1; - while (in_array($store_identifier, $ids[$entity])) { - $store_identifier = $value . '_' . $i++; - } - $ids[$entity][$primary] = $store_identifier; - } - - return $ids[$entity][$primary]; - } - - /** - * ONLY FOR DEVELOPMENT PURPOSE. - */ - public function createXmlEntityNodes($entity, array $nodes, \SimpleXMLElement $entities) - { - $types = array_merge($this->getColumns($entity), $this->getColumns($entity, true)); - foreach ($nodes as $id => $node) { - $entity_node = $entities->addChild($entity); - $entity_node['id'] = $id; - foreach ($node as $k => $v) { - if (isset($types[$k]) && $types[$k]) { - $entity_node->addChild($k, $v); - } else { - $entity_node[$k] = $v; - } - } - } - } - - /** - * ONLY FOR DEVELOPMENT PURPOSE. - */ - public function backupImage($entity, $path) - { - $reference = [ - 'product' => 'products', - 'category' => 'categories', - 'manufacturer' => 'manufacturers', - 'supplier' => 'suppliers', - 'store' => 'stores', - ]; - - $types = []; - if (isset($reference[$entity])) { - $types = []; - foreach (ImageType::getImagesTypes($reference[$entity]) as $type) { - $types[] = $type['name']; - } - } - - $path_list = array_map('trim', explode(',', $path)); - foreach ($path_list as $p) { - $backup_path = $this->img_path . $p . '/'; - $from_path = _PS_IMG_DIR_ . $p . '/'; - - if (!is_dir($backup_path) && !mkdir($backup_path)) { - $this->setError(sprintf('Cannot create directory %s', $backup_path)); - } - - foreach (scandir($from_path, SCANDIR_SORT_NONE) as $file) { - if ($file[0] != '.' && preg_match('#^(([0-9]+)(-(' . implode('|', $types) . '))?)\.(gif|jpg|jpeg|png)$#i', $file, $m)) { - $file_id = $m[2]; - $file_type = $m[3]; - $file_extension = $m[5]; - copy($from_path . $file, $backup_path . $this->generateId($entity, $file_id) . $file_type . '.' . $file_extension); - } - } - } - } - - /** - * ONLY FOR DEVELOPMENT PURPOSE. - */ - public function backupImageImage() - { - $types = []; - foreach (ImageType::getImagesTypes('products') as $type) { - $types[] = $type['name']; - } - - $backup_path = $this->img_path . 'p/'; - $from_path = _PS_PROD_IMG_DIR_; - if (!is_dir($backup_path) && !mkdir($backup_path)) { - $this->setError(sprintf('Cannot create directory %s', $backup_path)); - } - - foreach (Image::getAllImages() as $image) { - $image = new Image($image['id_image']); - $image_path = $image->getExistingImgPath(); - if (file_exists($from_path . $image_path . '.' . $image->image_format)) { - copy($from_path . $image_path . '.' . $image->image_format, $backup_path . $this->generateId('image', $image->id) . '.' . $image->image_format); - } - - foreach ($types as $type) { - if (file_exists($from_path . $image_path . '-' . $type . '.' . $image->image_format)) { - copy($from_path . $image_path . '-' . $type . '.' . $image->image_format, $backup_path . $this->generateId('image', $image->id) . '-' . $type . '.' . $image->image_format); - } - } - } - } - - /** - * ONLY FOR DEVELOPMENT PURPOSE. - */ - public function backupImageTab() - { - $backup_path = $this->img_path . 't/'; - $from_path = _PS_IMG_DIR_ . 't/'; - if (!is_dir($backup_path) && !mkdir($backup_path)) { - $this->setError(sprintf('Cannot create directory %s', $backup_path)); - } - - $xml = $this->loadEntity('tab'); - foreach ($xml->entities->tab as $tab) { - if (file_exists($from_path . $tab->class_name . '.gif')) { - copy($from_path . $tab->class_name . '.gif', $backup_path . $tab->class_name . '.gif'); - } - } - } -} diff --git a/src/PrestaShopBundle/Kernel/ModuleRepository.php b/src/PrestaShopBundle/Kernel/ModuleRepository.php deleted file mode 100644 index 6da244a0..00000000 --- a/src/PrestaShopBundle/Kernel/ModuleRepository.php +++ /dev/null @@ -1,99 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Kernel; - -use Doctrine\DBAL\Connection; -use Symfony\Component\Finder\Finder; - -/** - * Before booting the PrestaShop application in Symfony context, - * we register every installed modules. - */ -final class ModuleRepository -{ - /** - * @var Connection - */ - private $connection; - - /** - * @var string the `modules` table name - */ - private $tableName; - - /** - * @var array - */ - private $activeModules; - - /** - * @var array - */ - private $activeModulesPaths; - - public function __construct(Connection $connection, $databasePrefix) - { - $this->connection = $connection; - $this->tableName = $databasePrefix . 'module'; - } - - /** - * @return array the list of installed modules - */ - public function getActiveModules() - { - if (null === $this->activeModules) { - $sth = $this->connection->query('SELECT name FROM ' . $this->tableName . ' WHERE active = 1'); - - $this->activeModules = $sth->fetchAll(\PDO::FETCH_COLUMN); - } - - return $this->activeModules; - } - - /** - * Returns installed module file paths. - * - * @return array - */ - public function getActiveModulesPaths() - { - if (null === $this->activeModulesPaths) { - $this->activeModulesPaths = []; - $modulesFiles = Finder::create()->directories()->in(__DIR__ . '/../../../modules')->depth(0); - $activeModules = $this->getActiveModules(); - - foreach ($modulesFiles as $moduleFile) { - if (in_array($moduleFile->getFilename(), $activeModules)) { - $this->activeModulesPaths[] = $moduleFile->getPathname(); - } - } - } - - return $this->activeModulesPaths; - } -} diff --git a/src/PrestaShopBundle/Kernel/ModuleRepositoryFactory.php b/src/PrestaShopBundle/Kernel/ModuleRepositoryFactory.php deleted file mode 100644 index bc57fff5..00000000 --- a/src/PrestaShopBundle/Kernel/ModuleRepositoryFactory.php +++ /dev/null @@ -1,152 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Kernel; - -use Doctrine\DBAL\DriverManager; -use PrestaShop\PrestaShop\Adapter\Environment; - -/** - * Class ModuleRepositoryFactory is used to build the ModuleRepository in context where symfony container is not - * available or not yet initialised (ex: AppKernel, PrestaShop\PrestaShop\Adapter\ContainerBuilder). - * This factory is able to fetch the necessary parameters itself and builds the database connection for ModuleRepository. - * - * WARNING: this factory is only to be used in the specific cases mentioned above, for any other case please use the - * 'prestashop.module_kernel.repository' or 'prestashop.bundle.repository.module' depending on your needs. - */ -class ModuleRepositoryFactory -{ - /** - * @var self - */ - private static $instance; - - /** - * @var string - */ - private $parameters; - - /** - * @var string - */ - private $environment; - - /** - * @var ModuleRepository - */ - private $moduleRepository; - - /** - * @var string - */ - private $parametersFile = ''; - - public static function getInstance() - { - if (!self::$instance) { - self::$instance = new ModuleRepositoryFactory(); - } - - return self::$instance; - } - - /** - * @param array|null $parameters - * @param string|null $environment - */ - public function __construct(array $parameters = null, $environment = null) - { - $this->parameters = $parameters; - $this->environment = $environment; - if (null === $environment) { - $this->environment = (new Environment())->getName(); - } - } - - /** - * @return ModuleRepository - * - * @throws \Doctrine\DBAL\DBALException - */ - public function getRepository() - { - $parameters = $this->getParameters(); - if (null !== $parameters && null === $this->moduleRepository) { - $databasePrefix = $parameters['database_prefix']; - $this->moduleRepository = new ModuleRepository( - $this->getConnection($parameters), - $databasePrefix - ); - } - - return $this->moduleRepository; - } - - /** - * @param array $parameters - * - * @return \Doctrine\DBAL\Connection - * - * @throws \Doctrine\DBAL\DBALException - */ - private function getConnection(array $parameters) - { - return DriverManager::getConnection([ - 'dbname' => $parameters['database_name'], - 'user' => $parameters['database_user'], - 'password' => $parameters['database_password'], - 'host' => $parameters['database_host'], - 'port' => $parameters['database_port'], - 'charset' => 'utf8', - 'driver' => 'pdo_mysql', - ]); - } - - /** - * @return string file path to PrestaShop configuration parameters - */ - private function getParametersFile() - { - if (empty($this->parametersFile) && file_exists(__DIR__ . '/../../../app/config/parameters.php')) { - $this->parametersFile = realpath(__DIR__ . '/../../../app/config/parameters.php'); - } - - return $this->parametersFile; - } - - /** - * @return array - */ - private function getParameters() - { - if (null === $this->parameters && !empty($this->getParametersFile())) { - $config = require $this->getParametersFile(); - $this->parameters = $config['parameters']; - } - - return $this->parameters; - } -} diff --git a/src/PrestaShopBundle/Model/AdminModelAdapter.php b/src/PrestaShopBundle/Model/AdminModelAdapter.php deleted file mode 100644 index a536ff39..00000000 --- a/src/PrestaShopBundle/Model/AdminModelAdapter.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Model; - -/** - * This form class is responsible to map the form data to the posted object. - * - * For this parent class, only hook sub fields are handled. - */ -class AdminModelAdapter -{ - /** - * modelMapper - * Map form data to object model. - * - * This parent method will return only hook sub array. - * - * @return array Transformed form data to model attempt - */ - public function getHookData() - { - // Hook fields are kept. - if (array_key_exists('hook', $_POST)) { - $hookFields = $_POST['hook']; - - return ['hook' => $hookFields]; - } - - return []; - } -} diff --git a/src/PrestaShopBundle/Model/Product/AdminModelAdapter.php b/src/PrestaShopBundle/Model/Product/AdminModelAdapter.php deleted file mode 100644 index 1af007b4..00000000 --- a/src/PrestaShopBundle/Model/Product/AdminModelAdapter.php +++ /dev/null @@ -1,969 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Model\Product; - -use Attachment; -use Configuration as ConfigurationLegacy; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\Feature\FeatureDataProvider; -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use PrestaShop\PrestaShop\Adapter\Pack\PackDataProvider; -use PrestaShop\PrestaShop\Adapter\Product\AdminProductWrapper; -use PrestaShop\PrestaShop\Adapter\Product\ProductDataProvider; -use PrestaShop\PrestaShop\Adapter\Shop\Context as ShopContext; -use PrestaShop\PrestaShop\Adapter\Supplier\SupplierDataProvider; -use PrestaShop\PrestaShop\Adapter\Tax\TaxRuleDataProvider; -use PrestaShop\PrestaShop\Adapter\Tools; -use PrestaShop\PrestaShop\Adapter\Warehouse\WarehouseDataProvider; -use PrestaShop\PrestaShop\Core\Product\ProductInterface; -use PrestaShopBundle\Utils\FloatParser; -use Product; -use ProductDownload; -use Symfony\Component\Routing\Router; - -/** - * This form class is responsible to map the form data to the product object. - */ -class AdminModelAdapter extends \PrestaShopBundle\Model\AdminModelAdapter -{ - /** @var LegacyContext */ - private $context; - /** @var \Context */ - private $contextShop; - /** @var AdminProductWrapper */ - private $adminProductWrapper; - /** @var array */ - private $locales; - /** @var string */ - private $defaultLocale; - /** @var Tools */ - private $tools; - /** @var ProductDataProvider */ - private $productAdapter; - /** @var SupplierDataProvider */ - private $supplierAdapter; - /** @var FeatureDataProvider */ - private $featureAdapter; - /** @var PackDataProvider */ - private $packAdapter; - /** @var Configuration */ - private $configuration; - /** @var ShopContext */ - private $shopContext; - /** @var TaxRuleDataProvider */ - private $taxRuleDataProvider; - /** @var array */ - private $productPricePriority; - /** @var WarehouseDataProvider */ - private $warehouseAdapter; - /** @var Router */ - private $router; - - /** - * @var FloatParser - */ - private $floatParser; - - /** @var array */ - private $multiShopKeys = [ - 'category_box', - 'id_category_default', - 'attribute_wholesale_price', - 'attribute_price_impact', - 'attribute_weight_impact', - 'attribute_unit_impact', - 'attribute_ecotax', - 'attribute_minimal_quantity', - 'attribute_low_stock_threshold', - 'attribute_low_stock_alert', - 'available_date_attribute', - 'attribute_default', - 'uploadable_files', - 'text_fields', - 'active', - 'redirect_type', - 'id_type_redirected', - 'visibility', - 'available_for_order', - 'show_price', - 'online_only', - 'show_condition', - 'condition', - 'wholesale_price', - 'price', - 'id_tax_rules_group', - 'ecotax', - 'unit_price', - 'on_sale', - 'minimal_quantity', - 'low_stock_threshold', - 'low_stock_alert', - 'available_date', - 'ecotax', - ]; - - /** - * Defines translatable key. - * - * @var array - */ - private $translatableKeys = [ - 'name', - 'description', - 'description_short', - 'link_rewrite', - 'meta_title', - 'meta_description', - 'available_now', - 'available_later', - 'tags', - 'delivery_in_stock', - 'delivery_out_stock', - ]; - - /** - * Defines unused key for manual binding. - * - * @var array - */ - private $unmapKeys = [ - 'name', - 'description', - 'description_short', - 'images', - 'related_products', - 'categories', - 'suppliers', - 'display_options', - 'features', - 'specific_price', - 'virtual_product', - 'attachment_product', - ]; - - /** - * Array containing all the data to be mapped with the form. - * - * @var array - */ - private $formData; - - /** - * Constructor - * Set all adapters needed and get product. - * - * @param LegacyContext $legacyContext - * @param AdminProductWrapper $adminProductWrapper - * @param Tools $toolsAdapter - * @param ProductDataProvider $productDataProvider - * @param SupplierDataProvider $supplierDataProvider - * @param WarehouseDataProvider $warehouseDataProvider - * @param FeatureDataProvider $featureDataProvider - * @param PackDataProvider $packDataProvider - * @param ShopContext $shopContext - * @param TaxRuleDataProvider $taxRuleDataProvider - * @param Router $router - * @param FloatParser|null $floatParser - */ - public function __construct( - LegacyContext $legacyContext, - AdminProductWrapper $adminProductWrapper, - Tools $toolsAdapter, - ProductDataProvider $productDataProvider, - SupplierDataProvider $supplierDataProvider, - WarehouseDataProvider $warehouseDataProvider, - FeatureDataProvider $featureDataProvider, - PackDataProvider $packDataProvider, - ShopContext $shopContext, - TaxRuleDataProvider $taxRuleDataProvider, - Router $router, - FloatParser $floatParser = null - ) { - $this->context = $legacyContext; - $this->contextShop = $this->context->getContext(); - $this->adminProductWrapper = $adminProductWrapper; - $this->locales = $this->context->getLanguages(); - $this->defaultLocale = $this->locales[0]['id_lang']; - $this->tools = $toolsAdapter; - $this->productAdapter = $productDataProvider; - $this->supplierAdapter = $supplierDataProvider; - $this->warehouseAdapter = $warehouseDataProvider; - $this->featureAdapter = $featureDataProvider; - $this->packAdapter = $packDataProvider; - $this->configuration = new Configuration(); - $this->shopContext = $shopContext; - $this->taxRuleDataProvider = $taxRuleDataProvider; - $this->router = $router; - $this->floatParser = $floatParser ?? new FloatParser(); - } - - /** - * modelMapper - * Map form data to object model. - * - * @param array $form_data - * @param bool $isMultiShopContext If the context is define to multishop, force data to be apply on all shops - * - * @return array Transformed form data to model attempt - */ - public function getModelData($form_data, $isMultiShopContext = false) - { - //merge all form steps - $form_data = array_merge( - ['id_product' => $form_data['id_product']], - $form_data['step1'], - $form_data['step2'], - $form_data['step3'], - $form_data['step4'], - $form_data['step5'], - $form_data['step6'] - ); - - //add some legacy field to execute some add/update methods - $form_data['submitted_tabs'] = ['Shipping']; - $form_data['submitted_tabs'][] = 'Associations'; - - //map translatable - foreach ($this->translatableKeys as $field) { - foreach ($form_data[$field] as $lang_id => $translate_value) { - $form_data[$field . '_' . $lang_id] = $translate_value; - } - } - - //Product type - if ($form_data['type_product'] == 2) { - $form_data['condition'] = 'new'; - $form_data['is_virtual'] = 1; - } else { - $form_data['is_virtual'] = 0; - } - - // Product redirection - $form_data['redirect_type'] = (string) $form_data['redirect_type']; - if ($form_data['redirect_type'] != ProductInterface::REDIRECT_TYPE_NOT_FOUND) { - if (isset($form_data['id_type_redirected']) && !empty($form_data['id_type_redirected']['data'])) { - $form_data['id_type_redirected'] = $form_data['id_type_redirected']['data'][0]; - } elseif (ProductInterface::REDIRECT_TYPE_CATEGORY_MOVED_PERMANENTLY == $form_data['redirect_type'] || ProductInterface::REDIRECT_TYPE_CATEGORY_FOUND == $form_data['redirect_type']) { - $form_data['id_type_redirected'] = 0; - } else { - $form_data['id_type_redirected'] = 0; - $form_data['redirect_type'] = ProductInterface::REDIRECT_TYPE_CATEGORY_MOVED_PERMANENTLY; - } - } else { - $form_data['id_type_redirected'] = 0; - } - - //map inputPackItems - if ($form_data['type_product'] == 1 - && !empty($form_data['inputPackItems']) - && !empty($form_data['inputPackItems']['data']) - ) { - $inputPackItems = ''; - foreach ($form_data['inputPackItems']['data'] as $productIds) { - $inputPackItems .= $productIds . '-'; - } - $form_data['inputPackItems'] = $inputPackItems; - } else { - $form_data['inputPackItems'] = ''; - } - - //map categories - foreach ($form_data['categories']['tree'] as $category) { - $form_data['categoryBox'][] = $category; - } - - //if empty categories, set default one - if (empty($form_data['categoryBox'])) { - $form_data['categoryBox'][] = $this->contextShop->shop->id_category; - } - - //if default category not define, set the default one - if (empty($form_data['id_category_default'])) { - $form_data['id_category_default'] = $this->contextShop->shop->id_category; - } - - //map combinations and impact price/weight/unit price - foreach ($form_data['combinations'] as $k => $combination) { - $form_data['combinations'][$k]['attribute_price_impact'] = 0; - $form_data['combinations'][$k]['attribute_weight_impact'] = 0; - $form_data['combinations'][$k]['attribute_unit_impact'] = 0; - - if ($this->floatParser->fromString($combination['attribute_price']) > 0) { - $form_data['combinations'][$k]['attribute_price_impact'] = 1; - } elseif ($this->floatParser->fromString($combination['attribute_price']) < 0) { - $form_data['combinations'][$k]['attribute_price_impact'] = -1; - } - - if ($this->floatParser->fromString($combination['attribute_weight']) > 0) { - $form_data['combinations'][$k]['attribute_weight_impact'] = 1; - } elseif ($this->floatParser->fromString($combination['attribute_weight']) < 0) { - $form_data['combinations'][$k]['attribute_weight_impact'] = -1; - } - - if ($this->floatParser->fromString($combination['attribute_unity']) > 0) { - $form_data['combinations'][$k]['attribute_unit_impact'] = 1; - } elseif ($this->floatParser->fromString($combination['attribute_unity']) < 0) { - $form_data['combinations'][$k]['attribute_unit_impact'] = -1; - } - - $form_data['combinations'][$k]['attribute_price'] = abs( - $this->floatParser->fromString($combination['attribute_price']) - ); - $form_data['combinations'][$k]['attribute_weight'] = abs( - $this->floatParser->fromString($combination['attribute_weight']) - ); - $form_data['combinations'][$k]['attribute_unity'] = abs( - $this->floatParser->fromString($combination['attribute_unity']) - ); - } - - //map suppliers - $form_data['supplier_loaded'] = 1; - if (!empty($form_data['suppliers'])) { - foreach ($form_data['suppliers'] as $id_supplier) { - $form_data['check_supplier_' . $id_supplier] = 1; - - //map supplier combinations - foreach ($form_data['supplier_combination_' . $id_supplier] as $combination) { - $key = $form_data['id_product'] . '_' . $combination['id_product_attribute'] . '_' . $id_supplier; - $form_data['supplier_reference_' . $key] = $combination['supplier_reference']; - $form_data['product_price_' . $key] = $combination['product_price']; - $form_data['product_price_currency_' . $key] = $combination['product_price_currency']; - - unset($form_data['supplier_combination_' . $id_supplier]); - } - } - } - - //map display options - foreach ($form_data['display_options'] as $option => $value) { - $form_data[$option] = $value; - } - - //if empty, set link_rewrite for default locale - $linkRewriteKey = 'link_rewrite_' . $this->locales[0]['id_lang']; - if (empty($form_data[$linkRewriteKey])) { - $form_data[$linkRewriteKey] = $this->tools->link_rewrite($form_data['name_' . $this->locales[0]['id_lang']]); - } - - //map inputAccessories - if (!empty($form_data['related_products']) && !empty($form_data['related_products']['data'])) { - $inputAccessories = ''; - foreach ($form_data['related_products']['data'] as $accessoryIds) { - $accessoryIds = explode(',', $accessoryIds); - $inputAccessories .= $accessoryIds[0] . '-'; - } - $form_data['inputAccessories'] = $inputAccessories; - } - - //map warehouseProductLocations - $form_data['warehouse_loaded'] = 1; - $warehouses = $this->warehouseAdapter->getWarehouses(); - foreach ($warehouses as $warehouse) { - foreach ($form_data['warehouse_combination_' . $warehouse['id_warehouse']] as $combination) { - $key = $combination['warehouse_id'] - . '_' . $combination['product_id'] - . '_' . $combination['id_product_attribute']; - if ($combination['activated']) { - $form_data['check_warehouse_' . $key] = '1'; - } - $form_data['location_warehouse_' . $key] = $combination['location']; - - unset($form_data['warehouse_combination_' . $warehouse['id_warehouse']]); - } - } - - //force customization fields values - $form_data['uploadable_files'] = 0; - $form_data['text_fields'] = 0; - - //map all - $new_form_data = []; - foreach ($form_data as $k => $v) { - if (in_array($k, $this->unmapKeys) || in_array($k, $this->translatableKeys)) { - continue; - } - $new_form_data[$k] = $v; - } - - //map specific price priority - $new_form_data['specificPricePriority'] = [ - $new_form_data['specificPricePriority_0'], - $new_form_data['specificPricePriority_1'], - $new_form_data['specificPricePriority_2'], - $new_form_data['specificPricePriority_3'], - ]; - - $new_form_data = array_merge(parent::getHookData(), $new_form_data); - - //if multiShop context is defined, simulate multiShop checkbox for all POST DATA - if ($isMultiShopContext) { - foreach ($this->multiShopKeys as $multishopKey) { - $new_form_data['multishop_check'][$multishopKey] = 1; - } - - //apply multishop rules for translatables fields - foreach ($this->translatableKeys as $field) { - foreach ($form_data[$field] as $lang_id => $translate_value) { - $new_form_data['multishop_check'][$field][$lang_id] = 1; - } - } - } - - return $new_form_data; - } - - /** - * formMapper - * Map object model to form data. - * - * @param Product $product - * - * @return array Transformed model data to form attempt - */ - public function getFormData(Product $product) - { - $product->loadStockData(); - $this->productPricePriority = $this->adminProductWrapper->getPricePriority($product->id); - - $this->formData['id_product'] = $product->id; - $this->formData['step1'] = $this->mapStep1FromData($product); - $this->formData['step2'] = $this->mapStep2FormData($product); - $this->formData['step3'] = $this->mapStep3FormData($product); - $this->formData['step4'] = $this->mapStep4FormData($product); - $this->formData['step5'] = $this->mapStep5FormData($product); - $this->formData['step6'] = $this->mapStep6FormData($product); - - //Inject data form for supplier combinations - $this->formData['step6'] = array_merge($this->formData['step6'], $this->getDataSuppliersCombinations($product)); - - //Inject data form for warehouse combinations - $this->formData['step4'] = array_merge( - $this->formData['step4'], - $this->getDataWarehousesCombinations($product) - ); - - return $this->formData; - } - - /** - * Maps the existing products data to the form for Step 1. - * - * @param Product $product - * - * @return array - */ - private function mapStep1FromData(Product $product) - { - return [ - 'type_product' => $product->getType(), - 'inputPackItems' => [ - 'data' => array_map( - function ($p) { - return [ - 'id' => $p->id, - 'id_product_attribute' => isset($p->id_pack_product_attribute) - ? $p->id_pack_product_attribute - : 0, - 'name' => $p->name, - 'ref' => $p->reference, - 'quantity' => $p->pack_quantity, - 'image' => $p->image, - ]; - }, - $this->packAdapter->getItems($product->id, $this->locales[0]['id_lang']) - ), - ], - 'name' => $product->name, - 'description' => $product->description, - 'description_short' => $product->description_short, - 'active' => $product->active == 0 ? false : true, - 'price_shortcut' => $product->price, - 'qty_0_shortcut' => $product->getQuantity($product->id), - 'categories' => ['tree' => $product->getCategories()], - 'id_category_default' => $product->id_category_default, - 'related_products' => [ - 'data' => array_map( - function ($p) { - return $p['id_product']; - }, - call_user_func_array( - [$product, 'getAccessoriesLight'], - [$this->locales[0]['id_lang'], $product->id] - ) - ), - ], - 'id_manufacturer' => $product->id_manufacturer, - 'features' => $this->getFormFeatures($product), - 'images' => $this->productAdapter->getImages($product->id, $this->locales[0]['id_lang']), - ]; - } - - /** - * Maps the existing products data to the form for Step 2. - * - * @param Product $product - * - * @return array - */ - private function mapStep2FormData(Product $product) - { - // ecotax is stored with tax included but form uses the tax excluded value - // using a precision of 6 digits as `AdminProductsController::_removeTaxFromEcotax()` - // which does the opposite uses 6 digits too - $ecotax = $this->tools->round( - $product->ecotax * (1 + $this->taxRuleDataProvider->getProductEcotaxRate() / 100), - 6 - ); - - return [ - 'price' => $product->price, - 'ecotax' => $ecotax, - 'id_tax_rules_group' => isset($product->id_tax_rules_group) - ? (int) $product->id_tax_rules_group - : $this->taxRuleDataProvider->getIdTaxRulesGroupMostUsed(), - 'on_sale' => (bool) $product->on_sale, - 'wholesale_price' => $product->wholesale_price, - 'unit_price' => $product->unit_price_ratio != 0 - ? $product->price / $product->unit_price_ratio - : 0, - 'unity' => $product->unity, - 'specific_price' => [ // extra form to be saved separately. Here this is the default form values. - 'sp_from_quantity' => 1, - 'sp_reduction' => 0, - 'sp_reduction_tax' => 1, - 'leave_bprice' => true, - 'sp_id_shop' => $this->shopContext->getContextShopID(), - ], - 'specificPricePriority_0' => $this->productPricePriority[0], - 'specificPricePriority_1' => $this->productPricePriority[1], - 'specificPricePriority_2' => $this->productPricePriority[2], - 'specificPricePriority_3' => $this->productPricePriority[3], - ]; - } - - /** - * Maps the existing products data to the form for Step 3. - * - * @param Product $product - * - * @return array - */ - private function mapStep3FormData(Product $product) - { - return [ - 'advanced_stock_management' => (bool) $product->advanced_stock_management, - 'depends_on_stock' => $product->depends_on_stock ? '1' : '0', - 'qty_0' => $product::getQuantity($product->id), - 'id_product_attributes' => $this->getProductAttributes($product), - 'out_of_stock' => $product->out_of_stock, - 'minimal_quantity' => $product->minimal_quantity, - 'location' => $product->location, - 'low_stock_threshold' => $product->low_stock_threshold, - 'low_stock_alert' => (bool) $product->low_stock_alert, - 'available_now' => $product->available_now, - 'available_later' => $product->available_later, - 'available_date' => $product->available_date, - 'pack_stock_type' => $product->pack_stock_type, - 'virtual_product' => $this->getVirtualProductData($product), - ]; - } - - /** - * Maps the existing products data to the form for Step 4. - * - * @param Product $product - * - * @return array - */ - private function mapStep4FormData(Product $product) - { - return [ - 'width' => $product->width, - 'height' => $product->height, - 'depth' => $product->depth, - 'weight' => $product->weight, - 'additional_shipping_cost' => $product->additional_shipping_cost, - 'selectedCarriers' => $this->getFormProductCarriers($product), - 'additional_delivery_times' => $product->additional_delivery_times, - 'delivery_in_stock' => $product->delivery_in_stock, - 'delivery_out_stock' => $product->delivery_out_stock, - ]; - } - - /** - * Maps the existing products data to the form for Step 5. - * - * @param Product $product - * - * @return array - */ - private function mapStep5FormData(Product $product) - { - return [ - 'link_rewrite' => $product->link_rewrite, - 'meta_title' => $product->meta_title, - 'meta_description' => $product->meta_description, - 'redirect_type' => $product->redirect_type, - 'id_type_redirected' => [ - 'data' => [$product->id_type_redirected], - ], - ]; - } - - /** - * Maps the existing products data to the form for Step 6. - * - * @param Product $product - * - * @return array - */ - private function mapStep6FormData(Product $product) - { - return [ - 'visibility' => $product->visibility, - 'tags' => $this->getTags($product), - 'display_options' => [ - 'available_for_order' => (bool) $product->available_for_order, - 'show_price' => (bool) $product->show_price, - 'online_only' => (bool) $product->online_only, - ], - 'upc' => $product->upc, - 'mpn' => $product->mpn, - 'ean13' => $product->ean13, - 'isbn' => $product->isbn, - 'reference' => $product->reference, - 'show_condition' => (bool) $product->show_condition, - 'condition' => $product->condition, - 'suppliers' => array_map( - function ($s) { - return $s->id_supplier; - }, - $this->supplierAdapter->getProductSuppliers($product->id) - ), - 'default_supplier' => $product->id_supplier, - 'custom_fields' => $this->getCustomFields($product), - 'attachments' => $this->getProductAttachments($product), - ]; - } - - /** - * Get all available product attributes resume. - * - * @param Product $product - * - * @return array Product attributes combinations - */ - public function getAttributesResume(Product $product) - { - return $product->getAttributesResume($this->context->getContext()->language->id); - } - - /** - * Get product attachments. - * - * @param Product $product - * - * @return array - */ - private function getProductAttachments(Product $product) - { - return array_map( - function ($attachment) { - return $attachment['id_attachment']; - }, - Attachment::getAttachments($this->locales[0]['id_lang'], $product->id) - ); - } - - /** - * Get virtual product data. - * - * @param Product $product - * - * @return array - */ - private function getVirtualProductData(Product $product) - { - //force virtual product feature - ConfigurationLegacy::updateGlobalValue('PS_VIRTUAL_PROD_FEATURE_ACTIVE', '1'); - - $id_product_download = ProductDownload::getIdFromIdProduct((int) $product->id, false); - if ($id_product_download) { - $download = new ProductDownload($id_product_download); - $dateValue = $download->date_expiration == '0000-00-00 00:00:00' - ? '' - : date('Y-m-d', strtotime($download->date_expiration)); - - $res = [ - 'is_virtual_file' => $download->active, - 'name' => $download->display_filename, - 'nb_downloadable' => $download->nb_downloadable, - 'expiration_date' => $dateValue, - 'nb_days' => $download->nb_days_accessible, - ]; - - if ($download->filename) { - $res['filename'] = $download->filename; - $res['file_download_link'] = $this->router->generate( - 'admin_product_virtual_download_file_action', - ['idProduct' => $download->id_product] - ); - } - - return $res; - } - - return [ - 'is_virtual_file' => 0, - 'nb_days' => 0, - ]; - } - - /** - * Generate form custom fields configuration. - * - * @param Product $product - * - * @return array - */ - private function getCustomFields(Product $product) - { - $finalCustomFields = []; - $customizationFields = []; - $productCustomizationFields = $product->getCustomizationFields(); - - if (!$productCustomizationFields) { - return []; - } - - foreach ($productCustomizationFields as $customizationField) { - $customizationFields = array_merge($customizationFields, $customizationField); - } - - foreach ($customizationFields as $customizationField) { - $baseObject = [ - 'id_customization_field' => $customizationField[$this->locales[0]['id_lang']]['id_customization_field'], - 'label' => [], - 'type' => $customizationField[$this->locales[0]['id_lang']]['type'], - 'require' => $customizationField[$this->locales[0]['id_lang']]['required'] == 1 ? true : false, - ]; - - //add translation name - foreach ($this->locales as $locale) { - $baseObject['label'][$locale['id_lang']] = $customizationField[$locale['id_lang']]['name']; - } - $finalCustomFields[] = $baseObject; - } - - return $finalCustomFields; - } - - /** - * Generate form supplier/combinations references. - * - * @param Product $product - * - * @return array filled data form references combinations - */ - private function getDataSuppliersCombinations(Product $product) - { - $combinations = $product->getAttributesResume($this->locales[0]['id_lang']); - if (!$combinations || empty($combinations)) { - $combinations[] = [ - 'id_product' => $product->id, - 'id_product_attribute' => 0, - 'attribute_designation' => $product->name[$this->locales[0]['id_lang']], - ]; - } - - //for each supplier, generate combinations list - $dataSuppliersCombinations = []; - - foreach ($this->supplierAdapter->getProductSuppliers($product->id) as $supplier) { - foreach ($combinations as $combination) { - $productSupplierData = $this->supplierAdapter->getProductSupplierData( - $product->id, - $combination['id_product_attribute'], - $supplier->id_supplier - ); - $dataSuppliersCombinations['supplier_combination_' . $supplier->id_supplier][] = [ - 'label' => $combination['attribute_designation'], - 'supplier_reference' => isset($productSupplierData['product_supplier_reference']) - ? $productSupplierData['product_supplier_reference'] - : '', - 'product_price' => isset($productSupplierData['price']) - ? $productSupplierData['price'] - : 0, - 'product_price_currency' => isset($productSupplierData['id_currency']) - ? $productSupplierData['id_currency'] - : 1, - 'supplier_id' => $supplier->id_supplier, - 'product_id' => $product->id, - 'id_product_attribute' => $combination['id_product_attribute'], - ]; - } - } - - return $dataSuppliersCombinations; - } - - /** - * Generate form warehouses/combinations references. - * - * @param Product $product - * - * @return array filled data form references combinations - */ - private function getDataWarehousesCombinations(Product $product) - { - $combinations = $product->getAttributesResume($this->locales[0]['id_lang']); - if (!$combinations || empty($combinations)) { - $combinations[] = [ - 'id_product' => $product->id, - 'id_product_attribute' => 0, - 'attribute_designation' => $product->name[$this->locales[0]['id_lang']], - ]; - } - - //for each warehouse, generate combinations list - $dataWarehousesCombinations = []; - - foreach ($this->warehouseAdapter->getWarehouses() as $warehouse) { - $warehouseId = $warehouse['id_warehouse']; - foreach ($combinations as $combination) { - $warehouseProductLocationData = $this->warehouseAdapter->getWarehouseProductLocationData( - $product->id, - $combination['id_product_attribute'], - $warehouseId - ); - $dataWarehousesCombinations['warehouse_combination_' . $warehouseId][] = [ - 'label' => $combination['attribute_designation'], - 'activated' => (bool) $warehouseProductLocationData['activated'], - 'warehouse_id' => $warehouseId, - 'product_id' => $product->id, - 'id_product_attribute' => $combination['id_product_attribute'], - 'location' => isset($warehouseProductLocationData['location']) - ? $warehouseProductLocationData['location'] - : '', - ]; - } - } - - return $dataWarehousesCombinations; - } - - /** - * get form product features. - * - * @param Product $product - * - * @return array features with translation - */ - private function getFormFeatures(Product $product) - { - $formFeaturesData = []; - foreach ($product->getFeatures() as $featureData) { - $itemForm = [ - 'feature' => $featureData['id_feature'], - 'value' => null, - 'custom_value' => null, - ]; - - if ($featureData['custom'] == 0) { - // use id_feature_value only if this value isn't custom - $itemForm['value'] = $featureData['id_feature_value']; - } else { - $customLangs = []; - $featureLangsData = $this->featureAdapter->getFeatureValueLang($featureData['id_feature_value']); - foreach ($featureLangsData as $langData) { - $customLangs[$langData['id_lang']] = $langData['value']; - } - $itemForm['custom_value'] = $customLangs; - } - - $formFeaturesData[] = $itemForm; - } - - return $formFeaturesData; - } - - /** - * get product carrier. - * - * @param Product $product - * - * @return array carrier - */ - private function getFormProductCarriers(Product $product) - { - $formDataCarriers = []; - foreach ($product->getCarriers() as $carrier) { - $formDataCarriers[] = $carrier['id_reference']; - } - - return $formDataCarriers; - } - - /** - * Get all product id_product_attribute. - * - * @param Product $product - * - * @return array id_product_attribute - */ - private function getProductAttributes(Product $product) - { - $combinations = $product->getAttributesResume($this->context->getContext()->language->id); - $idsProductAttribute = []; - - if (is_array($combinations)) { - foreach ($combinations as $combination) { - $idsProductAttribute[] = $combination['id_product_attribute']; - } - } - - return $idsProductAttribute; - } - - /** - * Get a localized tags for product. - * - * @param Product $product - * - * @return array - */ - private function getTags(Product $product) - { - $tags = []; - foreach ($this->locales as $locale) { - $tags[$locale['id_lang']] = $product->getTags($locale['id_lang']); - } - - return $tags; - } -} diff --git a/src/PrestaShopBundle/PrestaShopBundle.php b/src/PrestaShopBundle/PrestaShopBundle.php deleted file mode 100644 index de50e119..00000000 --- a/src/PrestaShopBundle/PrestaShopBundle.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle; - -use PrestaShopBundle\DependencyInjection\Compiler\CommandAndQueryCollectorPass; -use PrestaShopBundle\DependencyInjection\Compiler\ContainerInjectionPass; -use PrestaShopBundle\DependencyInjection\Compiler\DynamicRolePass; -use PrestaShopBundle\DependencyInjection\Compiler\GridDefinitionServiceIdsCollectorPass; -use PrestaShopBundle\DependencyInjection\Compiler\IdentifiableObjectFormTypesCollectorPass; -use PrestaShopBundle\DependencyInjection\Compiler\LoadServicesFromModulesPass; -use PrestaShopBundle\DependencyInjection\Compiler\ModulesDoctrineCompilerPass; -use PrestaShopBundle\DependencyInjection\Compiler\OptionsFormHookNameCollectorPass; -use PrestaShopBundle\DependencyInjection\Compiler\OverrideTranslatorServiceCompilerPass; -use PrestaShopBundle\DependencyInjection\Compiler\OverrideTwigServiceCompilerPass; -use PrestaShopBundle\DependencyInjection\Compiler\PopulateTranslationProvidersPass; -use PrestaShopBundle\DependencyInjection\Compiler\RemoveXmlCompiledContainerPass; -use PrestaShopBundle\DependencyInjection\Compiler\RouterPass; -use PrestaShopBundle\DependencyInjection\PrestaShopExtension; -use Symfony\Component\DependencyInjection\Compiler\PassConfig; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\HttpKernel\Bundle\Bundle; - -class PrestaShopBundle extends Bundle -{ - /** - * {@inheritdoc} - */ - public function getContainerExtension() - { - return new PrestaShopExtension(); - } - - /** - * {@inheritdoc} - */ - public function build(ContainerBuilder $container) - { - $container->addCompilerPass(new DynamicRolePass()); - $container->addCompilerPass(new PopulateTranslationProvidersPass()); - $container->addCompilerPass(new LoadServicesFromModulesPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 1); - $container->addCompilerPass(new LoadServicesFromModulesPass('admin'), PassConfig::TYPE_BEFORE_OPTIMIZATION, 1); - $container->addCompilerPass(new RemoveXmlCompiledContainerPass(), PassConfig::TYPE_AFTER_REMOVING); - $container->addCompilerPass(new RouterPass(), PassConfig::TYPE_AFTER_REMOVING); - $container->addCompilerPass(new OverrideTranslatorServiceCompilerPass()); - $container->addCompilerPass(new OverrideTwigServiceCompilerPass()); - $container->addCompilerPass(new ModulesDoctrineCompilerPass()); - $container->addCompilerPass(new CommandAndQueryCollectorPass()); - $container->addCompilerPass(new OptionsFormHookNameCollectorPass()); - $container->addCompilerPass(new GridDefinitionServiceIdsCollectorPass()); - $container->addCompilerPass(new IdentifiableObjectFormTypesCollectorPass()); - $container->addCompilerPass(new ContainerInjectionPass()); - } -} diff --git a/src/PrestaShopBundle/Resources/config/routing.yml b/src/PrestaShopBundle/Resources/config/routing.yml deleted file mode 100644 index 01d75f0d..00000000 --- a/src/PrestaShopBundle/Resources/config/routing.yml +++ /dev/null @@ -1,8 +0,0 @@ -# Admin Back Office routing -_admin_routing: - resource: "@PrestaShopBundle/Resources/config/routing/admin.yml" - -# Api-like Back Office routing -_api_routing: - resource: "@PrestaShopBundle/Resources/config/routing/api.yml" - prefix: /api diff --git a/src/PrestaShopBundle/Resources/config/routing/admin.yml b/src/PrestaShopBundle/Resources/config/routing/admin.yml deleted file mode 100644 index 186ae293..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin.yml +++ /dev/null @@ -1,23 +0,0 @@ -_admin_common_routing: - resource: "admin/_common.yml" - prefix: /common - -_admin_security_routing: - resource: "admin/_security.yml" - prefix: /security - -_admin_sell_routing: - resource: "admin/sell/_sell.yml" - prefix: /sell - -_admin_configure_routing: - resource: "admin/configure/_configure.yml" - prefix: /configure - -_admin_improve_routing: - resource: "admin/improve/_improve.yml" - prefix: /improve - -_admin_errors: - resource: "admin/_errors.yml" - prefix: /errors diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/_common.yml b/src/PrestaShopBundle/Resources/config/routing/admin/_common.yml deleted file mode 100644 index 54daa5fd..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/_common.yml +++ /dev/null @@ -1,62 +0,0 @@ -admin_common_notifications: - path: /notifications - methods: [POST] - defaults: - _controller: 'PrestaShopBundle\Controller\Admin\CommonController::notificationsAction' - _legacy_controller: AdminCommon - _legacy_link: AdminCommon - -admin_common_notifications_ack: - path: /notifications/ack - methods: [POST] - defaults: - _controller: 'PrestaShopBundle\Controller\Admin\CommonController::notificationsAckAction' - -admin_common_pagination: - path: /pagination/{offset}/{limit}/{total}/{view} - methods: [GET] - defaults: - _controller: 'PrestaShopBundle\Controller\Admin\CommonController::paginationAction' - offset: 0 - limit: 20 - total: 0 - view: full - requirements: - offset: \d+ - limit: \d+ - total: \d+ - view: full|quicknav - -admin_common_recommended_modules: - path: /recommended_modules/{domain}/{limit}/{randomize} - methods: [GET] - defaults: - _controller: 'PrestaShopBundle\Controller\Admin\CommonController::recommendedModulesAction' - limit: 0 - randomize: 0 - requirements: - limit: \d+ - randomize: 0|1 - -admin_common_sidebar: - path: /sidebar/{url}/{title}/{footer} - methods: [GET] - defaults: - _controller: 'PrestaShopBundle\Controller\Admin\CommonController::renderSidebarAction' - title: '' - footer: '' - -admin_common_reset_search: - path: /reset_search/{controller}/{action} - methods: [POST] - defaults: - _controller: 'PrestaShopBundle\Controller\Admin\CommonController::resetSearchAction' - filterId: '' - -admin_common_reset_search_by_filter_id: - path: /reset_search/{filterId} - methods: [POST] - defaults: - _controller: 'PrestaShopBundle\Controller\Admin\CommonController::resetSearchAction' - controller: '' - action: '' diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/_errors.yml b/src/PrestaShopBundle/Resources/config/routing/admin/_errors.yml deleted file mode 100644 index fac337bc..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/_errors.yml +++ /dev/null @@ -1,5 +0,0 @@ -admin_errors_enable_debug_mode: - path: /enable-debug-mode - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Error:enableDebugMode diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/_security.yml b/src/PrestaShopBundle/Resources/config/routing/admin/_security.yml deleted file mode 100644 index 77913e8b..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/_security.yml +++ /dev/null @@ -1,5 +0,0 @@ -admin_security_compromised: - path: /compromised - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Security:compromisedAccess diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/_configure.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/_configure.yml deleted file mode 100644 index f2f7f23f..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/_configure.yml +++ /dev/null @@ -1,16 +0,0 @@ -_admin_advanced_parameters_routing: - resource: "advanced_parameters/_advanced_parameters.yml" - prefix: /advanced/ - -_admin_shop_parameters_routing: - resource: "shop_parameters/_shop_parameters.yml" - prefix: /shop/ - -admin_close_showcase_card: - path: /showcase-card/close - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShowcaseCard:closeShowcaseCard' - requirements: - close: \d+ - name: \w+ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/_advanced_parameters.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/_advanced_parameters.yml deleted file mode 100644 index c40a475a..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/_advanced_parameters.yml +++ /dev/null @@ -1,43 +0,0 @@ -_logs: - resource: "logs.yml" - prefix: /logs/ - -_administration: - resource: "administration.yml" - prefix: /administration/ - -_import: - resource: "import.yml" - prefix: /import/ - -_performance: - resource: "performance.yml" - prefix: /performance/ - -_system_information: - resource: "system_information.yml" - prefix: /system-information/ - -_email: - resource: "email.yml" - prefix: /emails - -_sql_manager: - resource: "sql_request.yml" - prefix: /sql-requests/ - -_webservice: - resource: "webservice.yml" - prefix: /webservice-keys/ - -_backup: - resource: "backup.yml" - prefix: /backups - -_employee: - resource: "employee.yml" - prefix: /employees - -_profiles: - resource: "profiles.yml" - prefix: /profiles diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/administration.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/administration.yml deleted file mode 100644 index 21e42b19..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/administration.yml +++ /dev/null @@ -1,15 +0,0 @@ -admin_administration: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Administration:index' - _legacy_controller: AdminAdminPreferences - _legacy_link: AdminAdminPreferences - -admin_administration_save: - path: / - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Administration:processForm' - _legacy_controller: AdminAdminPreferences - _legacy_link: AdminAdminPreferences:update diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/backup.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/backup.yml deleted file mode 100644 index dac83fc1..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/backup.yml +++ /dev/null @@ -1,55 +0,0 @@ -admin_backups_index: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Backup:index' - _legacy_controller: 'AdminBackup' - _legacy_link: 'AdminBackup' - -admin_backups_save_options: - path: / - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Backup:saveOptions' - _legacy_controller: 'AdminBackup' - _legacy_link: 'AdminBackup:update' - -admin_backups_create: - path: /new - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Backup:create' - _legacy_controller: 'AdminBackup' - _legacy_link: 'AdminBackup:addbackup' - -admin_backups_download_view: - path: /view/{downloadFileName} - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Backup:downloadView' - _legacy_controller: 'AdminBackup' - -admin_backup_download: - path: /download/{downloadFileName} - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Backup:downloadContent' - _legacy_controller: 'AdminBackup' - -admin_backups_delete: - path: /{deleteFileName} - methods: [DELETE] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Backup:delete' - _legacy_controller: 'AdminBackup' - _legacy_link: 'AdminBackup:delete' - _legacy_parameters: - filename: deleteFileName - -admin_backups_bulk_delete: - path: /bulk-delete/ - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Backup:bulkDelete' - _legacy_controller: 'AdminBackup' - _legacy_link: 'AdminBackup:submitBulkdeletebackup' diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/email.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/email.yml deleted file mode 100644 index dc9734ee..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/email.yml +++ /dev/null @@ -1,60 +0,0 @@ -admin_emails_index: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Email:index' - _legacy_controller: AdminEmails - _legacy_link: AdminEmails - -admin_emails_search: - path: / - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Email:search' - _legacy_controller: AdminEmails - _legacy_link: AdminEmails:search - -admin_emails_save_options: - path: /options - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Email:saveOptions' - _legacy_controller: AdminEmails - _legacy_link: AdminEmails:update - -admin_emails_send_test: - path: /send-testing-email - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Email:sendTest' - _legacy_controller: AdminEmails - _legacy_link: AdminEmails:testEmail - condition: 'request.isXmlHttpRequest()' - -admin_emails_delete_bulk: - path: /delete-bulk - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Email:deleteBulk' - _legacy_controller: AdminEmails - _legacy_link: AdminEmails:submitBulkdeletemail - -admin_emails_delete_all: - path: /delete-all - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Email:deleteAll' - _legacy_controller: AdminEmails - _legacy_link: AdminEmails:deleteAll - -admin_emails_delete: - path: /delete/{mailId} - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Email:delete' - _legacy_controller: AdminEmails - _legacy_link: AdminEmails:deletemail - _legacy_parameters: - id_mail: mailId - requirements: - mailId: \d+ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/employee.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/employee.yml deleted file mode 100644 index 4a0e9dd2..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/employee.yml +++ /dev/null @@ -1,108 +0,0 @@ -admin_employees_index: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Employee:index' - _legacy_controller: AdminEmployees - _legacy_link: AdminEmployees - -admin_employees_search: - path: / - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Common:searchGrid' - _legacy_controller: AdminEmployees - _legacy_link: AdminEmployees:submitFilteremployee - gridDefinitionFactoryServiceId: prestashop.core.grid.definition.factory.employee - redirectRoute: admin_employees_index - -admin_employees_save_options: - path: /save-options - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Employee:saveOptions' - _legacy_controller: AdminEmployees - _legacy_link: AdminEmployees:submitOptionsemployee - -admin_employees_toggle_status: - path: /{employeeId}/toggle-status - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Employee:toggleStatus' - _legacy_controller: AdminEmployees - _legacy_link: AdminEmployees:statusemployee - _legacy_parameters: - id_employee: employeeId - -admin_employees_bulk_enable_status: - path: /bulk-enable-status - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Employee:bulkStatusEnable' - _legacy_controller: AdminEmployees - _legacy_link: AdminEmployees:submitBulkenableSelectionemployee - -admin_employees_bulk_disable_status: - path: /bulk-disable-status - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Employee:bulkStatusDisable' - _legacy_controller: AdminEmployees - _legacy_link: AdminEmployees:submitBulkdisableSelectionemployee - -admin_employees_delete: - path: /{employeeId}/delete - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Employee:delete' - _legacy_controller: AdminEmployees - _legacy_link: AdminEmployees:deleteemployee - _legacy_parameters: - id_employee: employeeId - -admin_employees_bulk_delete: - path: /bulk-delete - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Employee:bulkDelete' - _legacy_controller: AdminEmployees - _legacy_link: AdminEmployees:submitBulkdeleteemployee - -admin_employees_create: - path: /new - methods: [GET,POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Employee:create' - _legacy_controller: AdminEmployees - _legacy_link: AdminEmployees:addemployee - -admin_employees_edit: - path: /{employeeId}/edit - methods: [GET,POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Employee:edit' - _legacy_controller: AdminEmployees - _legacy_link: AdminEmployees:updateemployee - _legacy_parameters: - id_employee: employeeId - requirements: - employeeId: \d+ - -admin_employees_toggle_navigation: - path: /toggle-navigation - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Employee:toggleNavigationMenu' - -admin_employees_change_form_language: - path: /change-form-language - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Employee:changeFormLanguage' - -admin_employees_get_tabs: - path: /tabs - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Employee:getAccessibleTabs' - _legacy_controller: AdminEmployees diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/import.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/import.yml deleted file mode 100644 index ddcaa8bf..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/import.yml +++ /dev/null @@ -1,96 +0,0 @@ -admin_import: - path: / - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Import:import' - _legacy_controller: AdminImport - _legacy_link: AdminImport - -admin_import_data_configuration_index: - path: /data - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\ImportDataConfiguration:index' - _legacy_controller: AdminImport - -# This redirect prevents an error (redirects to import first page instead) when -# trying to access import data page with GET http method. -# It happens on direct access or when the session token expires and -# the user clicks "I understand the risk" in the warning page. -admin_import_data_configuration_index_redirect: - path: /data - methods: [GET] - controller: 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction' - defaults: - route: 'admin_import' - -admin_import_process: - path: /process - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Import:processImport' - _legacy_controller: AdminImport - -admin_import_file_upload: - path: /file/upload - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Import:upload' - _legacy_controller: AdminImport - _legacy_link: AdminImport:uploadCsv - -admin_import_file_delete: - path: /file/delete - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Import:delete' - _legacy_controller: AdminImport - _legacy_link: AdminImport:delete - -admin_import_file_download: - path: /file/download - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Import:download' - _legacy_controller: AdminImport - _legacy_link: AdminImport:download - -admin_import_sample_download: - path: /sample/download/{sampleName} - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Import:downloadSample' - _legacy_controller: AdminImport - _legacy_link: AdminImport:sampleDownload - -admin_import_data_configuration_create: - path: /match - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\ImportDataConfiguration:create' - _legacy_controller: AdminImport - _legacy_link: AdminImport:saveImportMatch - -admin_import_data_configuration_get: - path: /match - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\ImportDataConfiguration:get' - _legacy_controller: AdminImport - _legacy_link: AdminImport:getImportMatch - -admin_import_data_configuration_delete: - path: /match - methods: [DELETE] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\ImportDataConfiguration:delete' - _legacy_controller: AdminImport - _legacy_link: AdminImport:deleteImportMatch - -admin_import_get_available_fields: - path: /fields - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Import:getAvailableEntityFields' - _legacy_controller: AdminImport - _legacy_link: AdminImport:getAvailableEntityFields diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/logs.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/logs.yml deleted file mode 100644 index 6a3351c4..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/logs.yml +++ /dev/null @@ -1,30 +0,0 @@ -admin_logs_index: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Logs:index' - _legacy_controller: AdminLogs - _legacy_link: AdminLogs - -admin_logs_save_settings: - path: /settings - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Logs:saveSettings' - _legacy_controller: AdminLogs - _legacy_link: AdminLogs:update - -admin_logs_delete_all: - path: /delete-all - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Logs:deleteAll' - _legacy_controller: AdminLogs - _legacy_link: AdminLogs:deletelog - -admin_logs_search: - path: / - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Logs:search' - _legacy_controller: AdminLogs diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/performance.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/performance.yml deleted file mode 100644 index 763f6746..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/performance.yml +++ /dev/null @@ -1,58 +0,0 @@ -admin_performance: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Performance:index' - _legacy_controller: AdminPerformance - _legacy_link: AdminPerformance - -admin_performance_save: - path: / - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Performance:processForm' - _legacy_controller: AdminPerformance - _legacy_link: AdminPerformance:update - -admin_clear_cache: - path: /clear-cache - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Performance:clearCache' - _legacy_controller: AdminPerformance - _legacy_link: AdminPerformance:empty_smarty_cache - -admin_servers: - path: /memcache/servers - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\MemcacheServer:list' - _legacy_controller: AdminPerformance - condition: 'request.isXmlHttpRequest()' - -admin_servers_add: - path: /memcache/servers - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\MemcacheServer:add' - _legacy_controller: AdminPerformance - _legacy_link: AdminPerformance:submitAddServer - condition: 'request.isXmlHttpRequest()' - -admin_servers_delete: - path: /memcache/servers - methods: [DELETE] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\MemcacheServer:delete' - _legacy_controller: AdminPerformance - _legacy_link: AdminPerformance:deleteMemcachedServer - condition: 'request.isXmlHttpRequest()' - -admin_servers_test: - path: /memcache/servers/test - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\MemcacheServer:test' - _legacy_controller: AdminPerformance - _legacy_link: AdminPerformance:test_server - condition: 'request.isXmlHttpRequest()' diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/profiles.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/profiles.yml deleted file mode 100644 index 4d702055..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/profiles.yml +++ /dev/null @@ -1,55 +0,0 @@ -admin_profiles_index: - path: / - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Profile:index' - _legacy_controller: AdminProfiles - _legacy_link: AdminProfiles - -admin_profiles_search: - path: / - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Profile:search' - _legacy_controller: AdminProfiles - _legacy_link: AdminProfiles:submitFilterprofile - -admin_profiles_create: - path: /new - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Profile:create' - _legacy_controller: AdminProfiles - _legacy_link: AdminProfiles:addprofile - -admin_profiles_edit: - path: /{profileId}/edit - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Profile:edit' - _legacy_controller: AdminProfiles - _legacy_link: AdminProfiles:updateprofile - _legacy_parameters: - id_profile: profileId - requirements: - profileId: \d+ - -admin_profiles_delete: - path: /{profileId}/delete - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Profile:delete' - _legacy_controller: AdminProfiles - _legacy_link: AdminProfiles:deleteprofile - _legacy_parameters: - id_profile: profileId - requirements: - profileId: \d+ - -admin_profiles_bulk_delete: - path: /delete/bulk - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Profile:bulkDelete' - _legacy_controller: AdminProfiles - _legacy_link: AdminProfiles:submitBulkdeleteprofile diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/sql_request.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/sql_request.yml deleted file mode 100644 index 85a13f6d..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/sql_request.yml +++ /dev/null @@ -1,97 +0,0 @@ -admin_sql_requests_index: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\SqlManager:index' - _legacy_controller: AdminRequestSql - _legacy_link: AdminRequestSql - -admin_sql_requests_search: - path: / - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\SqlManager:search' - _legacy_controller: AdminRequestSql - _legacy_link: AdminRequestSql:search - -admin_sql_requests_process_settings: - path: /process-settings - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\SqlManager:processForm' - _legacy_controller: AdminRequestSql - _legacy_link: AdminRequestSql:update - -admin_sql_requests_create: - path: /new - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\SqlManager:create' - _legacy_controller: AdminRequestSql - _legacy_link: AdminRequestSql:addrequest_sql - -admin_sql_requests_edit: - path: /{sqlRequestId}/edit - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\SqlManager:edit' - _legacy_controller: AdminRequestSql - _legacy_link: AdminRequestSql:updaterequest_sql - _legacy_parameters: - id_request_sql: sqlRequestId - requirements: - sqlRequestId: \d+ - -admin_sql_requests_delete: - path: /{sqlRequestId}/delete - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\SqlManager:delete' - _legacy_controller: AdminRequestSql - _legacy_link: AdminRequestSql:deleterequest_sql - _legacy_parameters: - id_request_sql: sqlRequestId - requirements: - sqlRequestId: \d+ - -admin_sql_requests_delete_bulk: - path: /delete-bulk - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\SqlManager:deleteBulk' - _legacy_controller: AdminRequestSql - _legacy_link: AdminRequestSql:submitBulkdeleterequest_sql - -admin_sql_requests_table_columns: - path: /tables/{mySqlTableName}/columns - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\SqlManager:ajaxTableColumns' - _legacy_controller: AdminRequestSql - _legacy_link: AdminRequestSql:ajax - _legacy_parameters: - table: mySqlTableName - -admin_sql_requests_view: - path: /{sqlRequestId}/view - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\SqlManager:view' - _legacy_controller: AdminRequestSql - _legacy_link: AdminRequestSql:viewsql_request - _legacy_parameters: - id_request_sql: sqlRequestId - requirements: - sqlRequestId: \d+ - -admin_sql_requests_export: - path: /{sqlRequestId}/export - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\SqlManager:export' - _legacy_controller: AdminRequestSql - _legacy_link: AdminRequestSql:exportsql_request - _legacy_parameters: - id_request_sql: sqlRequestId - requirements: - sqlRequestId: \d+ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/system_information.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/system_information.yml deleted file mode 100644 index 9a400605..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/system_information.yml +++ /dev/null @@ -1,16 +0,0 @@ -admin_system_information: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\SystemInformation:index' - _legacy_controller: AdminInformation - _legacy_link: AdminInformation - -admin_system_information_check_files: - path: /files - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\SystemInformation:displayCheckFiles' - _legacy_controller: AdminInformation - _legacy_link: AdminInformation:checkFiles - condition: 'request.isXmlHttpRequest()' diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/webservice.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/webservice.yml deleted file mode 100644 index 7dc759e7..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/advanced_parameters/webservice.yml +++ /dev/null @@ -1,91 +0,0 @@ -admin_webservice_keys_index: - path: / - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Webservice:index' - _legacy_controller: AdminWebservice - _legacy_link: AdminWebservice - -admin_webservice_keys_search: - path: / - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Webservice:search' - _legacy_controller: AdminWebservice - _legacy_link: AdminWebservice:submitFilterwebservice_account - -admin_webservice_save_settings: - path: /settings - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Webservice:saveSettings' - _legacy_controller: AdminWebservice - _legacy_link: AdminWebservice:submitOptionswebservice_account - -admin_webservice_keys_create: - path: /new - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Webservice:create' - _legacy_controller: AdminWebservice - _legacy_link: AdminWebservice:addwebservice_account - -admin_webservice_keys_edit: - path: /{webserviceKeyId}/edit - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Webservice:edit' - _legacy_controller: AdminWebservice - _legacy_link: AdminWebservice:updatewebservice_account - _legacy_parameters: - id_webservice_account: webserviceKeyId - requirements: - webserviceKeyId: \d+ - -admin_webservice_keys_delete: - path: /{webserviceKeyId}/delete - methods: DELETE - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Webservice:delete' - _legacy_controller: AdminWebservice - _legacy_link: AdminWebservice:deletewebservice_account - _legacy_parameters: - id_webservice_account: webserviceKeyId - requirements: - webserviceKeyId: \d+ - -admin_webservice_keys_bulk_delete: - path: /bulk-delete - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Webservice:bulkDelete' - _legacy_controller: AdminWebservice - _legacy_link: AdminWebservice:submitBulkdeletewebservice_account - -admin_webservice_keys_toggle_status: - path: /{webserviceKeyId}/toggle-status - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Webservice:toggleStatus' - _legacy_controller: AdminWebservice - _legacy_link: AdminWebservice:statuswebservice_account - _legacy_parameters: - id_webservice_account: webserviceKeyId - requirements: - webserviceKeyId: \d+ - -admin_webservice_keys_bulk_enable: - path: /bulk-enable - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Webservice:bulkEnable' - _legacy_controller: AdminWebservice - _legacy_link: AdminWebservice:submitBulkenableSelectionwebservice_account - -admin_webservice_keys_bulk_disable: - path: /bulk-disable - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\AdvancedParameters\Webservice:bulkDisable' - _legacy_controller: AdminWebservice - _legacy_link: AdminWebservice:submitBulkdisableSelectionwebservice_account diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/_shop_parameters.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/_shop_parameters.yml deleted file mode 100644 index 582687b0..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/_shop_parameters.yml +++ /dev/null @@ -1,27 +0,0 @@ -_preferences: - resource: "preferences.yml" - prefix: /preferences/ - -_order_preferences: - resource: "order_preferences.yml" - prefix: /order-preferences/ - -_product_preferences: - resource: "product_preferences.yml" - prefix: /product-preferences/ - -_customer_preferences: - resource: "customer_preferences.yml" - prefix: /customer-preferences/ - -_maintenance: - resource: "maintenance.yml" - prefix: /maintenance/ - -_seo_urls: - resource: "meta.yml" - prefix: /seo-urls/ - -_contacts: - resource: "contacts.yml" - prefix: /contacts/ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/contacts.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/contacts.yml deleted file mode 100644 index eaf6b39a..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/contacts.yml +++ /dev/null @@ -1,51 +0,0 @@ -admin_contacts_index: - path: / - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Contacts:index' - _legacy_controller: AdminContacts - _legacy_link: AdminContacts - -admin_contacts_search: - path: / - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Contacts:search' - _legacy_controller: AdminContacts - _legacy_link: AdminContacts:submitFiltercontact - -admin_contacts_create: - path: /new - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Contacts:create' - _legacy_controller: AdminContacts - _legacy_link: AdminContacts:addcontact - -admin_contacts_edit: - path: /{contactId}/edit - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Contacts:edit' - _legacy_controller: AdminContacts - _legacy_link: AdminContacts:updatecontact - requirements: - contactId: \d+ - -admin_contacts_delete: - path: /{contactId}/delete - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Contacts:delete' - _legacy_controller: AdminContacts - _legacy_link: AdminContacts:deletecontact - requirements: - contactId: \d+ - -admin_contacts_delete_bulk: - path: /delete/bulk - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Contacts:deleteBulk' - _legacy_controller: AdminContacts - _legacy_link: AdminContacts:submitBulkdeletecontact diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/customer_preferences.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/customer_preferences.yml deleted file mode 100644 index 77dc8d0d..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/customer_preferences.yml +++ /dev/null @@ -1,15 +0,0 @@ -admin_customer_preferences: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\CustomerPreferences:index' - _legacy_controller: AdminCustomerPreferences - _legacy_link: AdminCustomerPreferences - -admin_customer_preferences_process: - path: / - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\CustomerPreferences:process' - _legacy_controller: AdminCustomerPreferences - _legacy_link: AdminCustomerPreferences:update diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/maintenance.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/maintenance.yml deleted file mode 100644 index dc97437d..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/maintenance.yml +++ /dev/null @@ -1,15 +0,0 @@ -admin_maintenance: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Maintenance:index' - _legacy_controller: AdminMaintenance - _legacy_link: AdminMaintenance - -admin_maintenance_save: - path: / - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Maintenance:processForm' - _legacy_controller: AdminMaintenance - _legacy_link: AdminMaintenance:update diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/meta.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/meta.yml deleted file mode 100644 index 34ac71ef..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/meta.yml +++ /dev/null @@ -1,67 +0,0 @@ -admin_metas_index: - path: / - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Meta:index' - _legacy_controller: AdminMeta - _legacy_link: AdminMeta - -admin_metas_search: - path: / - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Meta:search' - _legacy_controller: AdminMeta - _legacy_link: AdminMeta:submitFiltermeta - -admin_metas_create: - path: /new - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Meta:create' - _legacy_controller: AdminMeta - _legacy_link: AdminMeta:addmeta - -admin_metas_edit: - path: /{metaId}/edit - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Meta:edit' - _legacy_controller: AdminMeta - _legacy_link: AdminMeta:updatemeta - _legacy_parameters: - id_meta: metaId - -admin_metas_delete: - path: /{metaId}/delete - methods: DELETE - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Meta:delete' - _legacy_controller: AdminMeta - _legacy_link: AdminMeta:deletemeta - _legacy_parameters: - id_meta: metaId - -admin_metas_delete_bulk: - path: /delete - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Meta:deleteBulk' - _legacy_controller: AdminMeta - _legacy_link: AdminMeta:submitBulkdeletemeta - -admin_metas_save_options: - path: /options - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Meta:saveOptions' - _legacy_controller: AdminMeta - _legacy_link: AdminMeta:submitOptionsmeta - -admin_metas_generate_robots_text_file: - path: /generate/robots - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Meta:generateRobotsFile' - _legacy_controller: AdminMeta - _legacy_link: AdminMeta:submitRobots diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/order_preferences.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/order_preferences.yml deleted file mode 100644 index 0d8726dc..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/order_preferences.yml +++ /dev/null @@ -1,15 +0,0 @@ -admin_order_preferences: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\OrderPreferences:index' - _legacy_controller: AdminOrderPreferences - _legacy_link: AdminOrderPreferences - -admin_order_preferences_save: - path: / - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\OrderPreferences:process' - _legacy_controller: AdminOrderPreferences - _legacy_link: AdminOrderPreferences:update diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/preferences.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/preferences.yml deleted file mode 100644 index baa945a4..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/preferences.yml +++ /dev/null @@ -1,15 +0,0 @@ -admin_preferences: - path: preferences - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Preferences:index' - _legacy_controller: AdminPreferences - _legacy_link: AdminPreferences - -admin_preferences_save: - path: preferences - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\Preferences:processForm' - _legacy_controller: AdminPreferences - _legacy_link: AdminPreferences:update diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/product_preferences.yml b/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/product_preferences.yml deleted file mode 100644 index 7c65b09d..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/configure/shop_parameters/product_preferences.yml +++ /dev/null @@ -1,15 +0,0 @@ -admin_product_preferences: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\ProductPreferences:index' - _legacy_controller: AdminPPreferences - _legacy_link: AdminPPreferences - -admin_product_preferences_process: - path: / - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Configure\ShopParameters\ProductPreferences:process' - _legacy_controller: AdminPPreferences - _legacy_link: AdminPPreferences:update diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/_improve.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/_improve.yml deleted file mode 100644 index 96fd427e..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/_improve.yml +++ /dev/null @@ -1,19 +0,0 @@ -_international: - resource: "international/_international.yml" - prefix: /international/ - -_modules: - resource: "modules/_modules.yml" - prefix: /modules/ - -_design: - resource: "design/_design.yml" - prefix: /design/ - -_payment: - resource: "payment/*.yml" - prefix: /payment/ - -_shipping: - resource: "shipping/*.yml" - prefix: /shipping/ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/_design.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/_design.yml deleted file mode 100644 index edb67a33..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/_design.yml +++ /dev/null @@ -1,19 +0,0 @@ -_theme_catalog: - resource: "theme_catalog.yml" - prefix: /themes-catalog - -_positions: - resource: "positions.yml" - prefix: /modules/positions - -_theme: - resource: "theme.yml" - prefix: /themes - -_cms_page: - resource: "cms_pages.yml" - prefix: /cms-pages - -_mail_theme: - resource: "mail_theme.yml" - prefix: /mail_theme/ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/_mail_theme_deprecated.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/_mail_theme_deprecated.yml deleted file mode 100644 index 5e46523f..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/_mail_theme_deprecated.yml +++ /dev/null @@ -1,22 +0,0 @@ -# These are alias routes used to manage legacy urls that were badly formatted (camel case) -admin_mail_theme_save_configuration_deprecated: - path: /saveConfiguration - defaults: - _controller: FrameworkBundle:Redirect:redirect - route: admin_mail_theme_save_configuration - permanent: true - -admin_mail_theme_send_test_mail_deprecated: - path: /sendTestMail/{locale}/{theme}/{layout} - defaults: - _controller: FrameworkBundle:Redirect:redirect - route: admin_mail_theme_send_test_mail - permanent: true - -admin_mail_theme_send_test_module_mail_deprecated: - path: /sendTestMail/{locale}/{theme}/{module}/{layout} - methods: [GET] - defaults: - _controller: FrameworkBundle:Redirect:redirect - route: admin_mail_theme_send_test_module_mail - permanent: true diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/cms_pages.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/cms_pages.yml deleted file mode 100644 index 9931a921..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/cms_pages.yml +++ /dev/null @@ -1,178 +0,0 @@ -admin_cms_pages_index: - path: / - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:index' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent - -admin_cms_pages_search: - path: /search - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:search' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:submitFiltercms - -admin_cms_pages_create: - path: /new - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:create' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:addcms - -admin_cms_pages_edit: - path: /{cmsPageId}/edit - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:edit' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:updatecms - _legacy_parameters: - id_cms: cmsPageId - requirements: - cmsPageId: \d+ - -admin_cms_pages_toggle: - path: /{cmsId}/toggle-status - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:toggleCms' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:statuscms - _legacy_parameters: - id_cms: cmsId - requirements: - cmsId: \d+ - -admin_cms_pages_delete: - path: /{cmsId}/delete - methods: DELETE - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:deleteCms' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:deletecms - _legacy_parameters: - id_cms: cmsId - requirements: - cmsId: \d+ - -admin_cms_pages_bulk_enable_status: - path: /bulk-enable-status - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:bulkEnableCmsPageStatus' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:submitBulkenableSelectioncms - -admin_cms_pages_bulk_disable_status: - path: /bulk-disable-status - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:bulkDisableCmsPageStatus' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:submitBulkdisableSelectioncms - -admin_cms_pages_bulk_delete: - path: /bulk-delete - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:bulkDeleteCmsPage' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:submitBulkdeletecms - -admin_cms_pages_search_cms_category: - path: /category/search - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Common:searchGrid' - gridDefinitionFactoryService: prestashop.core.grid.definition.factory.cms_page_category - redirectRoute: admin_cms_pages_index - redirectQueryParamsToKeep: - - 'id_cms_category' - _legacy_link: AdminCmsContent:submitFiltercms_category - -admin_cms_pages_category_create: - path: /category/new - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:createCmsCategory' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:addcms_category - -admin_cms_pages_category_edit: - path: /category/{cmsCategoryId}/edit - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:editCmsCategory' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:updatecms_category - _legacy_parameters: - id_cms_category: cmsCategoryId - requirements: - cmsCategoryId: \d+ - -admin_cms_pages_category_delete: - path: /category/{cmsCategoryId}/delete - methods: DELETE - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:deleteCmsCategory' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:deletecms_category - _legacy_parameters: - id_cms_category: cmsCategoryId - requirements: - cmsCategoryId: \d+ - -admin_cms_pages_category_delete_bulk: - path: /category/delete-bulk - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:deleteBulkCmsCategory' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:submitBulkdeletecms_category - -admin_cms_pages_category_toggle: - path: /category/{cmsCategoryId}/toggle-status - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:toggleCmsCategory' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:statuscms_category - _legacy_parameters: - id_cms_category: cmsCategoryId - requirements: - cmsCategoryId: \d+ - -admin_cms_pages_category_bulk_status_enable: - path: /category/bulk-enable-status - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:bulkCmsPageCategoryStatusEnable' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:submitBulkenableSelectioncms_category - -admin_cms_pages_category_bulk_status_disable: - path: /category/bulk-disable-status - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:bulkCmsPageCategoryStatusDisable' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:submitBulkdisableSelectioncms_category - -admin_cms_pages_category_update_position: - path: /category/update-position - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:updateCmsCategoryPosition' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:updatecms_category - -admin_cms_pages_update_position: - path: /update-position - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\CmsPage:updateCmsPosition' - _legacy_controller: AdminCmsContent - _legacy_link: AdminCmsContent:updatecms diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/mail_theme.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/mail_theme.yml deleted file mode 100644 index bb3d50ab..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/mail_theme.yml +++ /dev/null @@ -1,95 +0,0 @@ -_mail_theme_deprecated: - resource: "_mail_theme_deprecated.yml" - prefix: / - -admin_mail_theme_index: - path: / - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\MailTheme:index - _legacy_controller: AdminMailTheme - _legacy_link: AdminMailTheme - -admin_mail_theme_generate: - path: /generate - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\MailTheme:generateMails - _legacy_controller: AdminMailTheme - _legacy_link: AdminMailTheme:postGenerateMails - -admin_mail_theme_save_configuration: - path: /save-configuration - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\MailTheme:saveConfiguration - _legacy_controller: AdminMailTheme - _legacy_link: AdminMailTheme:saveConfiguration - -admin_mail_theme_preview: - path: /preview/{theme} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\MailTheme:previewTheme - _legacy_controller: AdminMailTheme - _legacy_link: AdminMailTheme:previewTheme - -# Preview layout routes -admin_mail_theme_preview_layout: - path: /preview/{locale}/{theme}/{layout}.{type} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\MailTheme:previewLayout - _legacy_controller: AdminMailTheme - _legacy_link: AdminMailTheme:previewLayout - module: '' - -admin_mail_theme_preview_module_layout: - path: /preview/{locale}/{theme}/{module}/{layout}.{type} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\MailTheme:previewLayout - _legacy_controller: AdminMailTheme - _legacy_link: AdminMailTheme:previewModuleLayout - -admin_mail_theme_raw_layout: - path: /raw/{locale}/{theme}/{layout}.{type} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\MailTheme:rawLayout - _legacy_controller: AdminMailTheme - _legacy_link: AdminMailTheme:rawLayout - module: '' - -admin_mail_theme_raw_module_layout: - path: /raw/{locale}/{theme}/{module}/{layout}.{type} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\MailTheme:rawLayout - _legacy_link: AdminMailTheme:rawModuleLayout - _legacy_controller: AdminMailTheme - -admin_mail_theme_send_test_mail: - path: /send-test-mail/{locale}/{theme}/{layout} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\MailTheme:sendTestMail - _legacy_link: AdminMailTheme:rawModuleLayout - _legacy_controller: AdminMailTheme - module: '' - -admin_mail_theme_send_test_module_mail: - path: /send-test-mail/{locale}/{theme}/{module}/{layout} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\MailTheme:sendTestMail - _legacy_link: AdminMailTheme:rawModuleLayout - _legacy_controller: AdminMailTheme - -admin_mail_theme_translate_body: - path: /translate-body - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\MailTheme:translateBody - _legacy_controller: AdminMailTheme - _legacy_link: AdminMailTheme:translateBody diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/positions.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/positions.yml deleted file mode 100644 index 9bbdb0ce..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/positions.yml +++ /dev/null @@ -1,15 +0,0 @@ -admin_modules_positions: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\Positions:index' - _legacy_controller: AdminModulesPositions - _legacy_link: AdminModulesPositions - -admin_modules_positions_unhook: - path: /unhook - methods: [POST,GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\Positions:unhook' - _legacy_controller: AdminModulesPositions - _legacy_link: AdminModulesPositions:unhook diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/theme.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/theme.yml deleted file mode 100644 index bb421ad9..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/theme.yml +++ /dev/null @@ -1,85 +0,0 @@ -admin_themes_index: - path: / - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\Theme:index - _legacy_controller: AdminThemes - _legacy_link: AdminThemes - -admin_themes_upload_logos: - path: /upload-logos - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\Theme:uploadLogos - _legacy_controller: AdminThemes - _legacy_link: AdminThemes:submitOptionsconfiguration - -admin_themes_export_current: - path: /export - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\Theme:export - _legacy_controller: AdminThemes - _legacy_link: AdminThemes:exporttheme - -admin_themes_import: - path: /import - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\Theme:import - _legacy_controller: AdminThemes - _legacy_link: AdminThemes:importtheme - -admin_themes_enable: - path: /{themeName}/enable - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\Theme:enable - _legacy_controller: AdminThemes - _legacy_link: AdminThemes:enableTheme - _legacy_parameters: - theme_name: themeName - requirements: - themeName: "^[a-zA-Z0-9_.-]+$" - -admin_themes_delete: - path: /{themeName}/delete - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\Theme:delete - _legacy_controller: AdminThemes - _legacy_link: AdminThemes:deleteTheme - _legacy_parameters: - theme_name: themeName - requirements: - themeName: "^[a-zA-Z0-9_.-]+$" - -admin_themes_adapt_to_rtl_languages: - path: /adapt-to-rtl-languages - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\Theme:adaptToRTLLanguages - _legacy_controller: AdminThemes - _legacy_link: AdminThemes:submitGenerateRTL - requirements: - themeName: "^[a-zA-Z0-9_.-]+$" - -admin_theme_customize_layouts: - path: /customize-layouts - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\Theme:customizeLayouts - _legacy_controller: AdminThemes - _legacy_link: AdminThemes:submitConfigureLayouts - -admin_themes_reset_layouts: - path: /{themeName}/reset-layouts - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Design\Theme:resetLayouts - _legacy_controller: AdminThemes - _legacy_link: AdminThemes:resetToDefaults - _legacy_parameters: - theme_name: themeName - requirements: - themeName: "^[a-zA-Z0-9_.-]+$" diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/theme_catalog.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/theme_catalog.yml deleted file mode 100644 index 49698a40..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/design/theme_catalog.yml +++ /dev/null @@ -1,7 +0,0 @@ -admin_theme_catalog: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Design\ThemeCatalog:index' - _legacy_controller: AdminThemesCatalog - _legacy_link: AdminThemesCatalog diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/_international.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/_international.yml deleted file mode 100644 index b4b61a48..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/_international.yml +++ /dev/null @@ -1,31 +0,0 @@ -_translations: - resource: "translations.yml" - prefix: /translations/ - -_localization: - resource: "localization.yml" - prefix: /localization/ - -_geolocation: - resource: "geolocation.yml" - prefix: /geolocation/ - -_language: - resource: "language.yml" - prefix: /languages/ - -_currency: - resource: "currencies.yml" - prefix: /currencies/ - -_tax: - resource: "tax.yml" - prefix: /taxes/ - -_state: - resource: "state.yml" - prefix: /states/ - -_tax_rules_groups: - resource: "tax_rules_groups.yml" - prefix: /tax_rules_groups/ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/currencies.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/currencies.yml deleted file mode 100644 index 8ab88361..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/currencies.yml +++ /dev/null @@ -1,82 +0,0 @@ -admin_currencies_index: - path: / - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Currency:index' - _legacy_controller: AdminCurrencies - _legacy_link: AdminCurrencies - -admin_currencies_search: - path: / - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Currency:search' - _legacy_controller: AdminCurrencies - _legacy_link: AdminCurrencies:submitFiltercurrency - -admin_currencies_create: - path: /new - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Currency:create' - _legacy_controller: AdminCurrencies - _legacy_link: AdminCurrencies:addcurrency - -admin_currencies_edit: - path: /{currencyId}/edit - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Currency:edit' - _legacy_controller: AdminCurrencies - _legacy_link: AdminCurrencies:updatecurrency - _legacy_parameters: - id_currency: currencyId - requirements: - currencyId: \d+ - -admin_currencies_delete: - path: /{currencyId}/delete - methods: DELETE - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Currency:delete' - _legacy_controller: AdminCurrencies - _legacy_link: AdminCurrencies:deletecurrency - _legacy_parameters: - id_currency: currencyId - requirements: - currencyId: \d+ - -admin_currencies_toggle_status: - path: /{currencyId}/toggle-status - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Currency:toggleStatus' - _legacy_controller: AdminCurrencies - _legacy_link: AdminCurrencies:statuscurrency - _legacy_parameters: - id_currency: currencyId - requirements: - currencyId: \d+ - -admin_currencies_update_live_exchange_rates: - path: /update-live-exchange-rates - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Currency:updateLiveExchangeRates' - _legacy_controller: AdminCurrencies - -admin_currencies_refresh_exchange_rates: - path: /refresh-exchange-rates - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Currency:refreshExchangeRates' - _legacy_controller: AdminCurrencies - _legacy_link: AdminCurrencies:SubmitExchangesRates - -admin_currencies_get_reference_data: - path: /reference-data/{currencyIsoCode} - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Currency:getReferenceData' - _legacy_controller: AdminCurrencies - _legacy_link: AdminCurrencies:getReferenceData diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/geolocation.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/geolocation.yml deleted file mode 100644 index c91a4e35..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/geolocation.yml +++ /dev/null @@ -1,15 +0,0 @@ -admin_geolocation_index: - path: / - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Improve\International\Geolocation:index - _legacy_controller: AdminGeolocation - _legacy_link: AdminGeolocation - -admin_geolocation_save_options: - path: /process_form - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\International\Geolocation:saveOptions - _legacy_controller: AdminGeolocation - _legacy_link: AdminGeolocation:update diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/language.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/language.yml deleted file mode 100644 index d2858978..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/language.yml +++ /dev/null @@ -1,71 +0,0 @@ -admin_languages_index: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Language:index' - _legacy_controller: AdminLanguages - _legacy_link: AdminLanguages - -admin_languages_search: - path: / - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Language:searchGrid' - _legacy_controller: AdminLanguages - _legacy_link: - - AdminLanguages:submitFilterlang - - AdminLanguages:submitFiltercurrency - -admin_languages_create: - path: /new - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Language:create' - _legacy_controller: AdminLanguages - _legacy_link: AdminLanguages:addlang - -admin_languages_edit: - path: /{languageId}/edit - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Language:edit' - _legacy_controller: AdminLanguages - _legacy_link: AdminLanguages:updatelang - requirements: - languageId: \d+ - -admin_languages_delete: - path: /{languageId}/delete - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Language:delete' - _legacy_controller: AdminLanguages - _legacy_link: AdminLanguages:deletelang - requirements: - languageId: \d+ - -admin_languages_bulk_delete: - path: /bulk-delete - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Language:bulkDelete' - _legacy_controller: AdminLanguages - _legacy_link: AdminLanguages:submitBulkdeletelang - -admin_languages_toggle_status: - path: /{languageId}/toggle-status - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Language:toggleStatus' - _legacy_controller: AdminLanguages - _legacy_link: AdminLanguages:statuslang - -admin_languages_bulk_toggle_status: - path: /bulk-toggle-status/{status} - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Language:bulkToggleStatus' - _legacy_controller: AdminLanguages - _legacy_link: AdminLanguages:submitBulkupdatelang - requirements: - status: enable|disable diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/localization.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/localization.yml deleted file mode 100644 index a4879ca6..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/localization.yml +++ /dev/null @@ -1,23 +0,0 @@ -admin_localization_index: - path: / - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Improve\International\Localization:index - _legacy_controller: AdminLocalization - _legacy_link: AdminLocalization - -admin_localization_save_options: - path: /options - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\International\Localization:saveOptions - _legacy_controller: AdminLocalization - _legacy_link: AdminLocalization:update - -admin_localization_import_pack: - path: /import-pack - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\International\Localization:importPack - _legacy_controller: AdminLocalization - _legacy_link: AdminLocalization:submitLocalizationPack diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/state.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/state.yml deleted file mode 100644 index 4a482085..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/state.yml +++ /dev/null @@ -1,6 +0,0 @@ -admin_country_states: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\State:getStates' - _legacy_controller: AdminStates diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/tax.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/tax.yml deleted file mode 100644 index 9cd144d8..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/tax.yml +++ /dev/null @@ -1,91 +0,0 @@ -admin_taxes_index: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Tax:index' - _legacy_controller: AdminTaxes - _legacy_link: AdminTaxes - -admin_taxes_save_options: - path: /save-options - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Tax:saveOptions' - _legacy_controller: AdminTaxes - _legacy_link: AdminTaxes:submitOptionstax - -admin_taxes_search: - path: / - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Tax:search' - _legacy_controller: AdminTaxes - _legacy_link: AdminTaxes:submitFiltertax - -admin_taxes_create: - path: /new - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Tax:create' - _legacy_controller: AdminTaxes - _legacy_link: AdminTaxes:addtax - -admin_taxes_edit: - path: /{taxId}/edit - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Tax:edit' - _legacy_controller: AdminTaxes - _legacy_link: AdminTaxes:updatetax - _legacy_parameters: - id_tax: taxId - requirements: - taxId: \d+ - -admin_taxes_delete: - path: /{taxId}/delete - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Tax:delete' - _legacy_controller: AdminTaxes - _legacy_link: AdminTaxes:deletetax - _legacy_parameters: - id_tax: taxId - requirements: - taxId: \d+ - -admin_taxes_toggle_status: - path: /{taxId}/toggle-status - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Tax:toggleStatus' - _legacy_controller: AdminTaxes - _legacy_link: AdminTaxes:statustax - _legacy_parameters: - id_tax: taxId - requirements: - taxId: \d+ - -admin_taxes_bulk_enable_status: - path: /bulk-enable-status - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Tax:bulkEnableStatus' - _legacy_controller: AdminTaxes - _legacy_link: AdminTaxes:submitBulkenableSelectiontax - -admin_taxes_bulk_disable_status: - path: /bulk-disable-status - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Tax:bulkDisableStatus' - _legacy_controller: AdminTaxes - _legacy_link: AdminTaxes:submitBulkdisableSelectiontax - -admin_taxes_bulk_delete: - path: /bulk-delete - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\International\Tax:bulkDelete' - _legacy_controller: AdminTaxes - _legacy_link: AdminTaxes:submitBulkdeletetax diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/tax_rules_groups.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/tax_rules_groups.yml deleted file mode 100644 index ce4d12c7..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/tax_rules_groups.yml +++ /dev/null @@ -1,85 +0,0 @@ -admin_tax_rules_groups_index: - path: / - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Improve\International\TaxRulesGroup:index - _legacy_controller: AdminTaxRulesGroup -# _legacy_link: AdminTaxRulesGroup - -admin_tax_rules_groups_search: - path: / - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Common:searchGrid - _legacy_controller: AdminTaxRulesGroup - gridDefinitionFactoryServiceId: prestashop.core.grid.definition.factory.tax_rules_group - redirectRoute: admin_tax_rules_groups_index -# _legacy_link: AdminTaxRulesGroup:submitFiltertax_rules_group - -admin_tax_rules_groups_create: - path: /new - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\International\TaxRulesGroup:create - _legacy_controller: AdminTaxRulesGroup -# _legacy_link: AdminTaxRulesGroup:addtax_rules_group - -admin_tax_rules_groups_edit: - path: /{taxRulesGroupId}/edit - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\International\TaxRulesGroup:edit - _legacy_controller: AdminTaxRulesGroup -# _legacy_link: AdminTaxRulesGroup:updatetax_rules_group - _legacy_parameters: - id_tax_rules_group: taxRulesGroupId - requirements: - taxRulesGroupId: \d+ - -admin_tax_rules_groups_delete: - path: /{taxRulesGroupId}/delete - methods: POST - defaults: - _controller: PrestaShopBundle:Admin\Improve\International\TaxRulesGroup:delete - _legacy_controller: AdminTaxRulesGroup -# _legacy_link: AdminTaxRulesGroup:deletetax_rules_group - _legacy_parameters: - id_tax_rules_group: taxRulesGroupId - requirements: - taxRulesGroupId: \d+ - -admin_tax_rules_groups_toggle_status: - path: /{taxRulesGroupId}/toggle-status - methods: POST - defaults: - _controller: PrestaShopBundle:Admin\Improve\International\TaxRulesGroup:toggleStatus - _legacy_controller: AdminTaxRulesGroup -# _legacy_link: AdminTaxRulesGroup:statustax_rules_group - _legacy_parameters: - id_tax_rules_group: taxRulesGroupId - requirements: - taxRulesGroupId: \d+ - -admin_tax_rules_groups_bulk_enable_status: - path: /bulk-enable-status - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\International\TaxRulesGroup:bulkEnableStatus - _legacy_controller: AdminTaxRulesGroup -# _legacy_link: AdminTaxRulesGroup:submitBulkenableSelectiontax_rules_group - -admin_tax_rules_groups_bulk_disable_status: - path: /bulk-disable-status - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\International\TaxRulesGroup:bulkDisableStatus - _legacy_controller: AdminTaxRulesGroup -# _legacy_link: AdminTaxRulesGroup:submitBulkdisableSelectiontax_rules_group - -admin_tax_rules_groups_bulk_delete: - path: /bulk-delete - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Improve\International\TaxRulesGroup:bulkDelete - _legacy_controller: AdminTaxRulesGroup -# _legacy_link: AdminTaxRulesGroup:submitBulkdeletetax_rules_group diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/translations.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/translations.yml deleted file mode 100644 index c2b31b46..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/international/translations.yml +++ /dev/null @@ -1,46 +0,0 @@ -admin_international_translation_overview: - path: / - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Translations:overview - _legacy_controller: AdminTranslations - _legacy_link: AdminTranslationSf - -admin_international_translations_export_theme: - path: /export - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Translations:exportThemeLanguage - _legacy_controller: AdminTranslations - _legacy_link: AdminTranslations:submitExport - -admin_international_translations_show_settings: - path: /settings - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Translations:showSettings - _legacy_controller: AdminTranslations - _legacy_link: AdminTranslations:settings - -admin_international_translations_modify: - path: /modify - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Translations:modifyTranslations - _legacy_controller: AdminTranslations - -admin_international_translations_add_update_language: - path: /add-update-language - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Translations:addUpdateLanguage - _legacy_controller: AdminTranslations - _legacy_link: AdminTranslations:submitAddLanguage - -admin_international_translations_copy_language: - path: /copy - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Translations:copyLanguage - _legacy_controller: AdminTranslations - _legacy_link: AdminTranslations:submitCopyLang diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/modules/_modules.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/modules/_modules.yml deleted file mode 100644 index a2a09b36..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/modules/_modules.yml +++ /dev/null @@ -1,122 +0,0 @@ -_addons: - resource: "addons.yml" - prefix: /addons/ - -admin_module_cart: - path: /cart/{moduleId} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Improve/Module:getModuleCart - requirements: - moduleId: \d+ - -admin_module_catalog: - path: /catalog - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Improve/Module:catalog - _legacy_controller: AdminModulesCatalog - _legacy_link: AdminModulesCatalog - -admin_module_catalog_refresh: - path: /catalog/refresh/{category}/{keyword} - methods: [GET] - defaults: - category: - keyword: - _controller: PrestaShopBundle:Admin/Improve/Module:refreshCatalog - _legacy_controller: AdminModulesCatalog - _legacy_link: AdminModulesCatalog:refresh - -admin_module_catalog_post: - path: /catalog/recommended - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Improve/Module:getPreferredModules - _legacy_controller: AdminModulesCatalog - _legacy_link: AdminModulesCatalog:recommended - -admin_module_manage: - path: /manage/{category}/{keyword} - methods: [GET] - defaults: - category: - keyword: - _controller: PrestaShopBundle:Admin/Improve/Module:manage - _legacy_controller: AdminModulesManage - _legacy_link: - - AdminModulesManage - - AdminModulesSf - -admin_module_manage_action: - path: /manage/action/{action}/{module_name} - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Improve/Module:module - requirements: - action: install|uninstall|enable|disable|enable_mobile|disable_mobile|reset|upgrade - -admin_module_configure_action: - path: /manage/action/configure/{module_name} - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin/Improve/Module:configureModule - _legacy_controller: AdminModules -# WARNING: This controller is not fully migrated yet, it is an overlay that redirects to the legacy controller, -# but here is the proper configuration when it will be really migrated -# _legacy_link: AdminModules:configure -# _legacy_parameters: -# configure: module_name - -admin_module_manage_action_bulk: - path: /manage/bulk/{action} - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Improve/Module:module - requirements: - action: install|uninstall|configure|enable|disable|reset|upgrade - -admin_module_manage_update_all: - path: /manage/update/all - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Improve/Module:module - -admin_module_import: - path: /import - methods: [POST] - defaults: - module_name: - _controller: PrestaShopBundle:Admin/Improve/Module:importModule - -admin_module_notification: - path: /alerts - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Improve/Modules/Alerts:index - _legacy_controller: AdminModulesNotifications - _legacy_link: AdminModulesNotifications - -admin_module_notification_count: - path: /alerts/count - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Modules\Alerts:notificationsCount - _legacy_controller: AdminModulesNotifications - _legacy_link: AdminModulesNotifications:count - -admin_module_updates: - path: /updates - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Improve/Modules/Updates:index - _legacy_controller: AdminModulesUpdates - _legacy_link: AdminModulesUpdates - -admin_module_addons_store: - path: /addons-store - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Modules\AddonsStore:index' - _legacy_controller: AdminAddonsCatalog - _legacy_link: AdminAddonsCatalog diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/modules/addons.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/modules/addons.yml deleted file mode 100644 index 2fdcc78f..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/modules/addons.yml +++ /dev/null @@ -1,11 +0,0 @@ -admin_addons_login: - path: /login - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Addons:login - -admin_addons_logout: - path: /logout - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Addons:logout diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/payment/payment_methods.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/payment/payment_methods.yml deleted file mode 100644 index 959cee0b..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/payment/payment_methods.yml +++ /dev/null @@ -1,7 +0,0 @@ -admin_payment_methods: - path: /payment_methods - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Improve\Payment\PaymentMethods:index - _legacy_controller: AdminPayment - _legacy_link: AdminPayment diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/payment/preferences.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/payment/preferences.yml deleted file mode 100644 index 1ecae2cf..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/payment/preferences.yml +++ /dev/null @@ -1,15 +0,0 @@ -admin_payment_preferences: - path: /preferences - methods: [GET] - defaults: - _legacy_controller: AdminPaymentPreferences - _legacy_link: AdminPaymentPreferences - _controller: PrestaShopBundle:Admin\Improve\Payment\PaymentPreferences:index - -admin_payment_preferences_process: - path: /preferences - methods: [POST] - defaults: - _legacy_controller: AdminPaymentPreferences - _legacy_link: AdminPaymentPreferences:update - _controller: PrestaShopBundle:Admin\Improve\Payment\PaymentPreferences:processForm diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/improve/shipping/preferences.yml b/src/PrestaShopBundle/Resources/config/routing/admin/improve/shipping/preferences.yml deleted file mode 100644 index d8396e1f..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/improve/shipping/preferences.yml +++ /dev/null @@ -1,16 +0,0 @@ -# Preferences -admin_shipping_preferences: - path: preferences - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Shipping\Preferences:index' - _legacy_controller: AdminShipping - _legacy_link: AdminShipping - -admin_shipping_preferences_save: - path: preferences - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Improve\Shipping\Preferences:processForm' - _legacy_controller: AdminShipping - _legacy_link: AdminShipping:update diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/_sell.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/_sell.yml deleted file mode 100644 index fe3a117f..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/_sell.yml +++ /dev/null @@ -1,22 +0,0 @@ -_catalog: - resource: "catalog/_catalog.yml" - prefix: /catalog/ - -_customers: - resource: "customer/_customer.yml" - -_customer_services: - resource: "customer_service/_customer_service.yml" - prefix: /customer-service/ - -_orders: - resource: "orders/_orders.yml" - prefix: /orders/ - -_stocks: - resource: "stocks.yml" - prefix: /stocks/ - -_attachment: - resource: "catalog/attachment.yml" - prefix: /attachments/ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/_catalog.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/_catalog.yml deleted file mode 100644 index cb7bc3c5..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/_catalog.yml +++ /dev/null @@ -1,41 +0,0 @@ -_products: - resource: "products/products.yml" - prefix: /products/ - -_categories: - resource: "categories.yml" - prefix: /categories/ - -_suppliers: - resource: "suppliers.yml" - prefix: /suppliers/ - -_manufacturers: - resource: "manufacturer.yml" - prefix: /brands - -_monitoring: - resource: "monitoring.yml" - prefix: /monitoring - -_catalog_price_rules: - resource: "catalog_price_rule.yml" - prefix: /catalog-price-rules - -_features: - resource: "features.yml" - prefix: /features - -_attributes: - resource: "attribute.yml" - prefix: /attribute-groups/{attributeGroupId}/attributes/ - requirements: - attributeGroupId: \d+ - -_attribute_group: - resource: "attribute_group.yml" - prefix: /attribute-groups/ - -_cart_rule: - resource: "cart_rule.yml" - prefix: /cart-rules diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/attachment.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/attachment.yml deleted file mode 100644 index 094c1c54..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/attachment.yml +++ /dev/null @@ -1,69 +0,0 @@ -admin_attachments_index: - path: / - methods: GET - defaults: - _controller: PrestaShopBundle:Admin/Sell/Catalog/Attachment:index - _legacy_controller: AdminAttachments - _legacy_link: AdminAttachments - -admin_attachments_filter: - path: / - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Common:searchGrid - _legacy_controller: AdminAttachments - gridDefinitionFactoryServiceId: prestashop.core.grid.definition.factory.attachment - redirectRoute: admin_attachments_index - _legacy_link: AdminAttachments:submitFilterattachment - -admin_attachments_create: - path: /new - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Catalog/Attachment:create - _legacy_controller: AdminAttachments - _legacy_link: AdminAttachments:addattachment - -admin_attachments_edit: - path: /{attachmentId}/edit - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Catalog/Attachment:edit - _legacy_controller: AdminAttachments - _legacy_link: AdminAttachments:updateattachment - _legacy_parameters: - id_attachment: attachmentId - requirements: - attachmentId: \d+ - -admin_attachments_view: - path: /{attachmentId}/view - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Catalog/Attachment:view - _legacy_controller: AdminAttachments - _legacy_link: AdminAttachments:viewattachment - _legacy_parameters: - id_attachment: attachmentId - requirements: - attachmentId: \d+ - -admin_attachments_delete_bulk: - path: /delete-bulk - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Catalog/Attachment:deleteBulk - _legacy_controller: AdminAttachments - _legacy_link: AdminAttachments:submitBulkdeleteattachment - -admin_attachments_delete: - path: /{attachmentId}/delete - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Catalog/Attachment:delete - _legacy_controller: AdminAttachments - _legacy_link: AdminAttachments:deleteattachment - _legacy_parameters: - id_attachment: attachmentId - requirements: - attachmentId: \d+ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/attribute.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/attribute.yml deleted file mode 100644 index c2dd6283..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/attribute.yml +++ /dev/null @@ -1,85 +0,0 @@ -# @todo: add legacy links after page is fully migrated -admin_attributes_index: - path: / - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Attribute:index' - _legacy_controller: AdminAttributesGroups - redirectQueryParamsToKeep: - - 'attributeGroupId' -# _legacy_link: AdminAttributesGroups:viewattribute_group - _legacy_parameters: - id_attribute_group: attributeGroupId - requirements: - attributeGroupId: \d+ - -admin_attributes_search: - path: / - methods: POST - defaults: - _controller: PrestaShopBundle:Admin\Common:searchGrid - _legacy_controller: AdminAttributesGroups - gridDefinitionFactoryServiceId: prestashop.core.grid.definition.factory.attribute - redirectRoute: admin_attributes_index -# _legacy_link: AdminAttributesGroups:submitFilterattribute_values - redirectQueryParamsToKeep: - - 'attributeGroupId' - -admin_attributes_create: - path: /new - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Attribute:create' - _legacy_controller: AdminAttributesGroups - redirectQueryParamsToKeep: - - 'attributeGroupId' -# _legacy_link: AdminAttributesGroups:addattribute_group - -admin_attributes_edit: - path: /{attributeId}/edit - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Attribute:edit' - _legacy_controller: AdminAttributesGroups - redirectQueryParamsToKeep: - - 'attributeGroupId' -# _legacy_link: AdminAttributesGroups:updateattribute - _legacy_parameters: - id_attribute_group: attributeGroupId - id_attribute: attributeId - requirements: - attributeId: \d+ - -admin_attributes_delete: - path: /{attributeId}/delete - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Attribute:delete' - _legacy_controller: AdminAttributesGroups - redirectQueryParamsToKeep: - - 'attributeGroupId' -# _legacy_link: AdminAttributesGroups:deleteattribute - _legacy_parameters: - id_attribute_group: attributeGroupId - id_attribute: attributeId - -admin_attributes_bulk_delete: - path: /delete - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Attribute:bulkDelete' - _legacy_controller: AdminAttributesGroups - redirectQueryParamsToKeep: - - 'attributeGroupId' -# _legacy_link: AdminAttributesGroups:bulkdeleteattribute - _legacy_parameters: - id_attribute_group: attributeGroupId - id_attribute: attributeId - -admin_attributes_update_position: - path: /update-position - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Attribute:updatePosition' - _legacy_controller: AdminAttributesGroups -# _legacy_link: AdminAttributesGroups:updateAttributesPositions diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/attribute_group.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/attribute_group.yml deleted file mode 100644 index dcf9912b..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/attribute_group.yml +++ /dev/null @@ -1,87 +0,0 @@ -# @todo: uncomment legacy links after page migration -admin_attribute_groups_index: - path: / - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/AttributeGroup:index' - _legacy_controller: AdminAttributesGroups -# _legacy_link: AdminAttributesGroups - -admin_attribute_groups_search: - path: / - methods: POST - defaults: - _controller: PrestaShopBundle:Admin\Common:searchGrid - _legacy_controller: AdminAttributesGroups - # _legacy_link: AdminAttributeGroups:submitFilterattribute_group - gridDefinitionFactoryServiceId: prestashop.core.grid.definition.factory.attribute_group - redirectRoute: admin_attribute_groups_index - -admin_attribute_groups_create: - path: /new - methods: [GET, POST] - defaults: - #todo: implement create - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/AttributeGroup:index' - _legacy_controller: AdminAttributesGroups -# _legacy_link: AdminAttributeGroups:addattribute_group - -admin_attribute_groups_view: - path: /{attributeGroupId}/view - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Attribute:index' - _legacy_controller: AdminAttributesGroups -# _legacy_link: AdminAttributesGroups:viewattribute_group - _legacy_parameters: - id_attribute_group: attributeGroupId - requirements: - attributeGroupId: \d+ - -admin_attribute_groups_edit: - path: /{attributeGroupId}/edit - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/AttributeGroup:edit' - _legacy_controller: AdminAttributesGroups -# _legacy_link: AdminAttributesGroups:updateattribute_group - _legacy_parameters: - id_attribute_group: attributeGroupId - requirements: - attributeGroupId: \d+ - -admin_attribute_groups_delete: - path: /{attributeGroupId}/delete - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/AttributeGroup:delete' - _legacy_controller: AdminAttributesGroups -# _legacy_link: AdminAttributesGroups:deleteattribute_group - _legacy_parameters: - id_attribute_group: attributeGroupId - requirements: - attributeGroupId: \d+ - -admin_attribute_groups_bulk_delete: - path: /bulk-delete - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/AttributeGroup:bulkDelete' - _legacy_controller: AdminAttributesGroups -# _legacy_link: AdminAttributesGroups:submitBulkdeleteattribute_group - -admin_attribute_groups_export: - path: /export - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/AttributeGroup:export' - _legacy_controller: AdminAttributesGroups -# _legacy_link: AdminAttributesGroups:exportattribute_group - -admin_attribute_groups_update_position: - path: /update-position - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/AttributeGroup:updatePosition' - _legacy_controller: AdminAttributesGroups -# _legacy_link: AdminAttributesGroups:updateGroupsPositions diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/cart_rule.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/cart_rule.yml deleted file mode 100644 index 67958c64..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/cart_rule.yml +++ /dev/null @@ -1,8 +0,0 @@ -admin_cart_rules_search: - path: /search - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/CartRule:search' - _legacy_controller: AdminCartRules - options: - expose: true diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/catalog_price_rule.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/catalog_price_rule.yml deleted file mode 100644 index ae1d8d63..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/catalog_price_rule.yml +++ /dev/null @@ -1,56 +0,0 @@ -#@todo: add legacy links after page is fully migrated. (including condition groups) -admin_catalog_price_rules_index: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Catalog\CatalogPriceRule:index' - _legacy_controller: AdminSpecificPriceRule -# _legacy_link: AdminSpecificPriceRule - -admin_catalog_price_rules_search: - path: / - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Catalog\CatalogPriceRule:search' - _legacy_controller: AdminSpecificPriceRule -# _legacy_link: AdminSpecificPriceRule:submitFilterspecific_price_rule - -admin_catalog_price_rules_create: - path: /new - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Catalog\CatalogPriceRule:create' - _legacy_controller: AdminSpecificPriceRule - #_legacy_link: AdminSpecificPriceRule:addspecific_price_rule - -admin_catalog_price_rules_edit: - path: /{catalogPriceRuleId}/edit - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Catalog\CatalogPriceRule:edit' - _legacy_controller: AdminSpecificPriceRule - #_legacy_link: AdminSpecificPriceRule:updatespecific_price_rule - _legacy_parameters: - id_specific_price_rule: catalogPriceRuleId - requirements: - catalogPriceRuleId: \d+ - -admin_catalog_price_rules_delete: - path: /{catalogPriceRuleId}/delete - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Catalog\CatalogPriceRule:delete' - _legacy_controller: AdminSpecificPriceRule -# _legacy_link: AdminSpecificPriceRule:deletespecific_price_rule - _legacy_parameters: - id_specific_price_rule: catalogPriceRuleId - requirements: - catalogPriceRuleId: \d+ - -admin_catalog_price_rules_bulk_delete: - path: /bulk-delete - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Catalog\CatalogPriceRule:bulkDelete' - _legacy_controller: AdminSpecificPriceRule -# _legacy_link: AdminSpecificPriceRule:submitBulkdeletespecific_price_rule diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/categories.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/categories.yml deleted file mode 100644 index 5485fb60..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/categories.yml +++ /dev/null @@ -1,149 +0,0 @@ -admin_categories_index: - path: /{categoryId} - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Catalog\Category:index - _legacy_controller: AdminCategories - _legacy_link: AdminCategories - _legacy_parameters: - id_category: categoryId - categoryId: null - requirements: - categoryId: '\d+' - -admin_categories_search: - path: /search - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Catalog/Category:searchGrid - _legacy_controller: AdminCategories - _legacy_link: AdminCategories:submitFiltercategory - gridDefinitionFactoryServiceId: prestashop.core.grid.definition.factory.category - redirectRoute: admin_categories_index - redirectQueryParamsToKeep: - - 'categoryId' - -admin_categories_bulk_enable_status: - path: /bulk-status-enable - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Catalog\Category:bulkEnableStatus - _legacy_controller: AdminCategories - _legacy_link: AdminCategories:submitBulkenableSelectioncategory - -admin_categories_bulk_disable_status: - path: /bulk-status-disable - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Catalog\Category:bulkDisableStatus - _legacy_controller: AdminCategories - _legacy_link: AdminCategories:submitBulkdisableSelectioncategory - -admin_categories_toggle_status: - path: /{categoryId}/toggle-status - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Catalog\Category:toggleStatus - _legacy_controller: AdminCategories - _legacy_link: AdminCategories:statuscategory - _legacy_parameters: - id_category: categoryId - -admin_categories_bulk_delete: - path: /bulk-delete - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Catalog\Category:bulkDelete - _legacy_controller: AdminCategories - _legacy_link: AdminCategories:submitBulkdeleteSelectioncategory - -admin_categories_delete: - path: /delete - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Catalog\Category:delete - _legacy_controller: AdminCategories - _legacy_link: AdminCategories:deletecategory - -admin_categories_export: - path: /export - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Catalog\Category:export - _legacy_controller: AdminCategories - _legacy_link: AdminCategories:exportcategory - -admin_categories_create: - path: /new - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Catalog\Category:create - _legacy_controller: AdminCategories - _legacy_link: AdminCategories:addcategory - -admin_categories_create_root: - path: /new-root - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Catalog\Category:createRoot - _legacy_controller: AdminCategories - _legacy_link: AdminCategories:addcategoryroot - _legacy_parameters: - id_category: categoryId - -admin_categories_edit: - path: /{categoryId}/edit - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Catalog\Category:edit - _legacy_controller: AdminCategories - _legacy_link: AdminCategories:updatecategory - _legacy_parameters: - id_category: categoryId - requirements: - categoryId: \d+ - -admin_categories_edit_root: - path: /{categoryId}/edit-root - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Catalog\Category:editRoot - _legacy_controller: AdminCategories - _legacy_link: AdminCategories:updatecategory - _legacy_parameters: - id_category: categoryId - requirements: - categoryId: \d+ - -admin_categories_delete_cover_image: - path: /{categoryId}/delete-cover-image - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Catalog\Category:deleteCoverImage - _legacy_controller: AdminCategories - _legacy_link: AdminCategories:deleteImage - _legacy_parameters: - id_category: categoryId - requirements: - categoryId: \d+ - -admin_categories_delete_menu_thumbnail: - path: /{categoryId}/menu-thumbnails/{menuThumbnailId}/delete - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Catalog\Category:deleteMenuThumbnail - _legacy_controller: AdminCategories - _legacy_link: AdminCategories:forceDeleteThumb - _legacy_parameters: - id_category: categoryId - requirements: - categoryId: \d+ - menuThumbnailId: 0|1|2 menu thumbnails only have 3 fixed ids - -admin_categories_update_position: - path: /update-positions - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Catalog\Category:updatePosition - _legacy_controller: AdminCategories - _legacy_link: AdminCategories:updatePositions diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/features.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/features.yml deleted file mode 100644 index 0e1310ff..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/features.yml +++ /dev/null @@ -1,19 +0,0 @@ -admin_features_create: - path: /new - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Catalog\Feature:create - _legacy_controller: AdminFeatures - #_legacy_link: AdminFeatures:addfeature - -admin_features_edit: - path: /{featureId}/edit - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Catalog\Feature:edit - _legacy_controller: AdminFeatures - #_legacy_link: AdminFeatures:updatefeature - _legacy_parameters: - id_feature: featureId - requirements: - featureId: \d+ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/manufacturer.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/manufacturer.yml deleted file mode 100644 index f1410d5c..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/manufacturer.yml +++ /dev/null @@ -1,157 +0,0 @@ -admin_manufacturers_index: - path: / - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer:index' - _legacy_controller: AdminManufacturers - _legacy_link: AdminManufacturers - -# -# Manufacturer routes -# -admin_manufacturers_search: - path: / - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer:search' - _legacy_controller: AdminManufacturers - _legacy_link: AdminManufacturers:submitFiltermanufacturer - -admin_manufacturers_create: - path: /new - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer:create' - _legacy_controller: AdminManufacturers - _legacy_link: AdminManufacturers:addmanufacturer - -admin_manufacturers_view: - path: /{manufacturerId}/view - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer:view' - _legacy_controller: AdminManufacturers - _legacy_link: AdminManufacturers:viewmanufacturer - _legacy_parameters: - id_manufacturer: manufacturerId - requirements: - manufacturerId: \d+ - -admin_manufacturers_edit: - path: /{manufacturerId}/edit - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer:edit' - _legacy_controller: AdminManufacturers - _legacy_link: AdminManufacturers:updatemanufacturer - _legacy_parameters: - id_manufacturer: manufacturerId - requirements: - manufacturerId: \d+ - -admin_manufacturers_delete: - path: /{manufacturerId}/delete - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer:delete' - _legacy_controller: AdminManufacturers - _legacy_link: AdminManufacturers:deletemanufacturer - _legacy_parameters: - id_manufacturer: manufacturerId - requirements: - manufacturerId: \d+ - -admin_manufacturers_bulk_delete: - path: /bulk-delete - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer:bulkDelete' - _legacy_controller: AdminManufacturers - _legacy_link: AdminManufacturers:submitBulkdeletemanufacturer - -admin_manufacturers_bulk_enable_status: - path: /bulk-enable - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer:bulkEnable' - _legacy_controller: AdminManufacturers - _legacy_link: AdminManufacturers:submitBulkenableSelectionmanufacturer - -admin_manufacturers_bulk_disable_status: - path: /bulk-disable - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer:bulkDisable' - _legacy_controller: AdminManufacturers - _legacy_link: AdminManufacturers:submitBulkdisableSelectionmanufacturer - -admin_manufacturers_toggle_status: - path: /{manufacturerId}/toggle-status - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer:toggleStatus' - _legacy_controller: AdminManufacturers - _legacy_link: AdminManufacturers:statusmanufacturer - _legacy_parameters: - id_manufacturer: manufacturerId - requirements: - manufacturerId: \d+ - -admin_manufacturers_export: - path: /export - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer:export' - _legacy_controller: AdminManufacturers - _legacy_link: AdminManufacturers:exportmanufacturer - -# -# Address routes -# -admin_manufacturer_addresses_create: - path: addresses/new - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer:createAddress' - _legacy_controller: AdminManufacturers - _legacy_link: AdminManufacturers:addaddress - -admin_manufacturer_addresses_edit: - path: addresses/{addressId}/edit - methods: [GET, POST] - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer:editAddress' - _legacy_controller: AdminManufacturers - _legacy_link: AdminManufacturers:editaddresses - _legacy_parameters: - id_address: addressId - requirements: - addressId: \d+ - -admin_manufacturer_addresses_delete: - path: addresses/{addressId}/delete - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer:deleteAddress' - _legacy_controller: AdminManufacturers - _legacy_link: AdminManufacturers:deleteaddress - _legacy_parameters: - id_address: addressId - requirements: - addressId: \d+ - -admin_manufacturer_addresses_bulk_delete: - path: addresses/bulk-delete - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer:bulkDeleteAddress' - _legacy_controller: AdminManufacturers - _legacy_link: AdminManufacturers:submitBulkdeleteaddress - -admin_manufacturer_addresses_export: - path: addresses/export - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Manufacturer:exportAddress' - _legacy_controller: AdminManufacturers - _legacy_link: AdminManufacturers:exportaddress diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/monitoring.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/monitoring.yml deleted file mode 100644 index 83f7a402..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/monitoring.yml +++ /dev/null @@ -1,14 +0,0 @@ -admin_monitorings_index: - path: / - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Monitoring:index' - _legacy_controller: AdminTracking - _legacy_link: AdminTracking - -admin_monitorings_search: - path: / - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Catalog/Monitoring:search' - _legacy_controller: AdminTracking diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/attributes.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/attributes.yml deleted file mode 100644 index af87b073..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/attributes.yml +++ /dev/null @@ -1,42 +0,0 @@ -admin_attribute_get_all: - path: /get-all - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Attribute:getAllAttributes - _format: json - _legacy_controller: AdminProducts - -admin_attribute_generator: - path: /generator - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Attribute:attributesGenerator - _legacy_controller: AdminProducts - -admin_delete_attribute: - path: /{idProduct} - methods: [DELETE] - defaults: - _controller: PrestaShopBundle:Admin/Attribute:deleteAttribute - _legacy_controller: AdminProducts - -admin_delete_all_attributes: - path: /delete-all/{idProduct} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Attribute:deleteAllAttribute - _legacy_controller: AdminProducts - idProduct: 0 - requirements: - idProduct: \d+ - -admin_get_form_images_combination: - path: /form-images/{idProduct} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Attribute:getFormImages - _format: json - _legacy_controller: AdminProducts - idProduct: 0 - requirements: - idProduct: \d+ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/categories.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/categories.yml deleted file mode 100644 index 168f0ee4..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/categories.yml +++ /dev/null @@ -1,15 +0,0 @@ -admin_category_simple_add_form: - path: /add/simple - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Category:addSimpleCategoryForm - -admin_get_ajax_categories: - path: /list/{limit} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Category:getAjaxCategories - _format: json - limit: 20 - requirements: - limit: \d+ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/combinations.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/combinations.yml deleted file mode 100644 index 37df4555..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/combinations.yml +++ /dev/null @@ -1,16 +0,0 @@ -admin_combination_generate_form: - path: /form/{combinationIds} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Combination:generateCombinationForm - combinationIds: 0 - -admin_get_product_combinations: - path: /{idProduct} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Combination:getProductCombinations - _format: json - idProduct: 0 - requirements: - idProduct: \d+ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/features.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/features.yml deleted file mode 100644 index 6f68e6bf..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/features.yml +++ /dev/null @@ -1,8 +0,0 @@ -admin_feature_get_feature_values: - path: /{idFeature} - methods: [GET] - defaults: - idFeature: 0 - _controller: PrestaShopBundle:Admin/Feature:getFeatureValues - requirements: - idFeature: \d+ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/product.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/product.yml deleted file mode 100644 index 84f0e3b1..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/product.yml +++ /dev/null @@ -1,102 +0,0 @@ -# Product Form -admin_product_new: - path: /new - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Product:new - -admin_product_form: - path: /{id} - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin/Product:form - _legacy_controller: AdminProducts - _legacy_param_mapper_class: PrestaShop\PrestaShop\Adapter\Product\AdminProductDataProvider - _legacy_param_mapper_method: mapLegacyParametersProductForm - requirements: - id: \d+ - options: - expose: true - -admin_product_virtual_save_action: - path: /virtual/save/{idProduct} - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/VirtualProduct:save - idProduct: 0 - requirements: - idProduct: \d+ - -admin_product_virtual_remove_file_action: - path: /virtual/remove-file/{idProduct} - defaults: - _controller: PrestaShopBundle:Admin/VirtualProduct:removeFile - idProduct: 0 - requirements: - idProduct: \d+ - -admin_product_virtual_download_file_action: - path: /virtual/download-file/{idProduct} - defaults: - _controller: PrestaShopBundle:Admin/VirtualProduct:downloadFile - idProduct: 0 - requirements: - idProduct: \d+ - -admin_product_virtual_remove_action: - path: /virtual/remove/{idProduct} - defaults: - _controller: PrestaShopBundle:Admin/VirtualProduct:remove - idProduct: 0 - requirements: - idProduct: \d+ - -admin_product_attachement_add_action: - path: /attachment/form/add/{idProduct} - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/AttachementProduct:add - idProduct: 0 - requirements: - idProduct: \d+ - -admin_product_image_upload: - path: /image/upload/{idProduct} - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/ProductImage:uploadImage - idProduct: 0 - requirements: - idProduct: \d+ - -admin_product_image_positions: - path: /image/positions - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/ProductImage:updateImagePosition - -admin_product_image_form: - path: image/form/{idImage} - defaults: - _controller: PrestaShopBundle:Admin/ProductImage:form - idImage: 0 - requirements: - idImage: \d+ - -admin_product_image_delete: - path: /image/delete/{idImage} - defaults: - _controller: PrestaShopBundle:Admin/ProductImage:delete - idImage: 0 - requirements: - idImage: \d+ - -admin_product_toggle_status: - path: /{productId}/toggle-status - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Product:toggleStatus - _legacy_controller: AdminTracking - _legacy_link: AdminTracking:statusproduct - _legacy_parameters: - id_product: productId diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/products.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/products.yml deleted file mode 100644 index c5707b74..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/products.yml +++ /dev/null @@ -1,110 +0,0 @@ -_product: - resource: "product.yml" - -_product_attributes: - resource: "attributes.yml" - prefix: /attributes/ - -_product_categories: - resource: "categories.yml" - prefix: /categories/ - -_product_combinations: - resource: "combinations.yml" - prefix: /combinations/ - -_product_features: - resource: "features.yml" - prefix: /features/ - -_product_specific_prices: - resource: "specific_prices.yml" - prefix: /specific-prices/ - -_product_suppliers: - resource: "suppliers.yml" - prefix: /suppliers/ - -_product_warehouses: - resource: "warehouses.yml" - prefix: /warehouses/ - -# Product List -admin_product_catalog: - path: /{offset}/{limit}/{orderBy}/{sortOrder} - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin/Product:catalog - _legacy_controller: AdminProducts - limit: last - offset: 0 - orderBy: last - sortOrder: last - requirements: - limit: _limit|last|\d+ - orderBy: last|id_product|name|reference|name_category|price|sav_quantity|position|active|position_ordering - offset: last|\d+ - sortOrder: last|asc|desc - -admin_product_catalog_filters: - path: /filters/{quantity}/{active} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Product:catalogFilters - _legacy_controller: AdminProducts - quantity: 'none' - active: 'none' - requirements: - quantity: none|<=\d+|<\d+|>\d+|>=\d+ - active: none|1|0 - -admin_product_list: - path: /list/{offset}/{limit}/{orderBy}/{sortOrder}/{view} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Product:list - limit: last - offset: 0 - orderBy: last - sortOrder: last - view: full - requirements: - limit: _limit|last|\d+ - orderBy: last|id_product|name|reference|name_category|price|sav_quantity|position|active|position_ordering - offset: last|\d+ - sortOrder: last|asc|desc - view: full|quicknav - -admin_product_bulk_action: - path: /bulk/{action} - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Product:bulk - requirements: - action: activate_all|deactivate_all|delete_all|duplicate_all - -admin_product_unit_action: - path: /unit/{action}/{id} - methods: [POST|GET] - defaults: - _controller: PrestaShopBundle:Admin/Product:unit - requirements: - action: delete|duplicate|activate|deactivate - id: \d+ - -admin_product_mass_edit_action: - path: /massedit/{action} - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Product:massEdit - requirements: - action: sort - -admin_product_export_action: - path: /export.{_format} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Product:export - _format: csv - requirements: - _format: csv diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/specific_prices.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/specific_prices.yml deleted file mode 100644 index 332a3d15..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/specific_prices.yml +++ /dev/null @@ -1,42 +0,0 @@ -admin_specific_price_list: - path: /list/{idProduct} - methods: [GET] - defaults: - _controller: PrestaShopBundle\Controller\Admin\SpecificPriceController::listAction - _format: json - idProduct: 0 - requirements: - idProduct: \d+ - -admin_get_specific_price_update_form: - path: /form/{idSpecificPrice}/ - methods: [GET] - defaults: - _controller: PrestaShopBundle\Controller\Admin\SpecificPriceController::getUpdateFormAction - idSpecificPrice: 0 - requirements: - idSpecificPrice: \d+ - -admin_specific_price_add: - path: /add - methods: [POST] - defaults: - _controller: PrestaShopBundle\Controller\Admin\SpecificPriceController::addAction - -admin_specific_price_update: - path: /update/{idSpecificPrice}/ - methods: [POST] - defaults: - _controller: PrestaShopBundle\Controller\Admin\SpecificPriceController::updateAction - idSpecificPrice: 0 - requirements: - idSpecificPrice: \d+ - -admin_delete_specific_price: - path: /delete/{idSpecificPrice} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/SpecificPrice:delete - idSpecificPrice: 0 - requirements: - idSpecificPrice: \d+ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/suppliers.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/suppliers.yml deleted file mode 100644 index 7712e58f..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/suppliers.yml +++ /dev/null @@ -1,10 +0,0 @@ -admin_supplier_refresh_product_supplier_combination_form: - path: /refresh-product-supplier-combination-form/{idProduct}/{supplierIds} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Supplier:refreshProductSupplierCombinationForm - supplierIds: 0 - idProduct: 0 - requirements: - idProduct: \d+ - diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/warehouses.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/warehouses.yml deleted file mode 100644 index 2d520fb0..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/products/warehouses.yml +++ /dev/null @@ -1,8 +0,0 @@ -admin_warehouse_refresh_product_warehouse_combination_form: - path: /refresh-product-warehouse-combination-form/{idProduct} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Warehouse:refreshProductWarehouseCombinationForm - idProduct: 0 - requirements: - idProduct: \d+ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/suppliers.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/suppliers.yml deleted file mode 100644 index ef834059..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/suppliers.yml +++ /dev/null @@ -1,106 +0,0 @@ -admin_suppliers_index: - path: / - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Catalog\Supplier:index' - _legacy_controller: AdminSuppliers - _legacy_link: AdminSuppliers - -admin_suppliers_search: - path: / - methods: POST - defaults: - _controller: PrestaShopBundle:Admin\Common:searchGrid - _legacy_controller: AdminSuppliers - _legacy_link: AdminSuppliers:submitFiltersupplier - gridDefinitionFactoryServiceId: prestashop.core.grid.definition.factory.supplier - redirectRoute: admin_suppliers_index - -admin_suppliers_view: - path: /{supplierId}/products - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Catalog\Supplier:view' - _legacy_controller: AdminSuppliers - _legacy_link: AdminSuppliers:viewsupplier - _legacy_parameters: - id_supplier: supplierId - requirements: - supplierId: \d+ - -admin_suppliers_create: - path: /new - methods: [GET,POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Catalog\Supplier:create' - _legacy_controller: AdminSuppliers - _legacy_link: AdminSuppliers:addsupplier - -admin_suppliers_edit: - path: /{supplierId}/edit - methods: [GET,POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Catalog\Supplier:edit' - _legacy_controller: AdminSuppliers - _legacy_link: AdminSuppliers:updatesupplier - _legacy_parameters: - id_supplier: supplierId - requirements: - supplierId: \d+ - -admin_suppliers_delete: - path: /{supplierId}/delete - methods: DELETE - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Catalog\Supplier:delete' - _legacy_controller: AdminSuppliers - _legacy_link: AdminSuppliers:deletesupplier - _legacy_parameters: - id_supplier: supplierId - requirements: - supplierId: \d+ - -admin_suppliers_bulk_delete: - path: /bulk-delete - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Catalog\Supplier:bulkDelete' - _legacy_controller: AdminSuppliers - _legacy_link: AdminSuppliers:submitBulkdeletesupplier - -admin_suppliers_bulk_enable: - path: /bulk-enable - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Catalog\Supplier:bulkEnable' - _legacy_controller: AdminSuppliers - _legacy_link: AdminSuppliers:submitBulkenableSelectionsupplier - -admin_suppliers_bulk_disable: - path: /bulk-disable - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Catalog\Supplier:bulkDisable' - _legacy_controller: AdminSuppliers - _legacy_link: AdminSuppliers:submitBulkdisableSelectionsupplier - -admin_suppliers_toggle_status: - path: /{supplierId}/toggle-status - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Catalog\Supplier:toggleStatus' - _legacy_controller: AdminSuppliers - _legacy_link: AdminSuppliers:statussupplier - _legacy_parameters: - id_supplier: supplierId - requirements: - supplierId: \d+ - -admin_suppliers_export: - path: /export - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Catalog\Supplier:export' - _legacy_controller: AdminSuppliers - _legacy_link: AdminSuppliers:exportsupplier - diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer/_customer.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer/_customer.yml deleted file mode 100644 index 399dfca9..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer/_customer.yml +++ /dev/null @@ -1,7 +0,0 @@ -_catalog: - resource: "customers.yml" - prefix: /customers/ - -_addresses: - resource: "addresses.yml" - prefix: /addresses/ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer/addresses.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer/addresses.yml deleted file mode 100644 index 1e2672da..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer/addresses.yml +++ /dev/null @@ -1,93 +0,0 @@ -admin_addresses_index: - path: / - methods: GET - defaults: - _controller: PrestaShopBundle:Admin\Sell\Address\Address:index - _legacy_controller: AdminAddresses - _legacy_link: AdminAddresses - -admin_addresses_search: - path: / - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Common:searchGrid - gridDefinitionFactoryServiceId: prestashop.core.grid.definition.factory.address - redirectRoute: admin_addresses_index - _legacy_controller: AdminAddresses - _legacy_link: AdminAddresses:submitFilteraddress - -admin_addresses_create: - path: /new - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Address\Address:create - _legacy_controller: AdminAddresses - _legacy_link: AdminAddresses:addaddress - options: - expose: true - -admin_addresses_edit: - path: /{addressId}/edit - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Address\Address:edit - _legacy_controller: AdminAddresses - _legacy_link: AdminAddresses:updateaddress - _legacy_parameters: - id_address: addressId - requirements: - addressId: \d+ - options: - expose: true - -admin_order_addresses_edit: - path: /order/{orderId}/{addressType}/edit - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Address\Address:editOrderAddress - _legacy_controller: AdminAddresses - requirements: - orderId: \d+ - addressType: delivery|invoice - options: - expose: true - -admin_cart_addresses_edit: - path: /cart/{cartId}/{addressType}/edit - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Address\Address:editCartAddress - _legacy_controller: AdminAddresses - requirements: - cartId: \d+ - addressType: delivery|invoice - options: - expose: true - -admin_addresses_delete_bulk: - path: /delete-bulk - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Address\Address:deleteBulk - _legacy_controller: AdminAddresses - _legacy_link: AdminAddresses:submitBulkdeleteaddress - -admin_addresses_delete: - path: /{addressId}/delete - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Address\Address:delete - _legacy_controller: AdminAddresses - _legacy_link: AdminAddresses:deleteaddress - _legacy_parameters: - id_address: addressId - requirements: - addressId: \d+ - -admin_addresses_save_required_fields: - path: /save-required-fields - methods: POST - defaults: - _controller: PrestaShopBundle:Admin\Sell\Address\Address:saveRequiredFields - _legacy_controller: AdminAddresses - _legacy_link: AdminAddresses:submitFields diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer/customers.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer/customers.yml deleted file mode 100644 index 21255bff..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer/customers.yml +++ /dev/null @@ -1,199 +0,0 @@ -admin_customers_index: - path: / - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:index - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers - -admin_customers_filter: - path: / - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:searchGrid - _legacy_controller: AdminCustomers - gridDefinitionFactoryServiceId: prestashop.core.grid.definition.factory.customer - redirectRoute: admin_customers_index - _legacy_link: AdminCustomers:submitFiltercustomer - -admin_customers_create: - path: /new - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:create - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers:addcustomer - -admin_customers_edit: - path: /{customerId}/edit - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:edit - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers:updatecustomer - _legacy_parameters: - id_customer: customerId - requirements: - customerId: \d+ - -admin_customers_view: - path: /{customerId}/view - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:view - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers:viewcustomer - _legacy_parameters: - id_customer: customerId - requirements: - customerId: \d+ - options: - expose: true - -admin_customers_set_private_note: - path: /{customerId}/set-private-note - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:setPrivateNote - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers:updateCustomerNote - _legacy_parameters: - id_customer: customerId - requirements: - customerId: \d+ - -admin_customers_toggle_status: - path: /{customerId}/toggle-status - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:toggleStatus - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers:statuscustomer - _legacy_parameters: - id_customer: customerId - requirements: - customerId: \d+ - -admin_customers_transform_guest_to_customer: - path: /{customerId}/transform-guest-to-customer - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:transformGuestToCustomer - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers:guesttocustomer - _legacy_parameters: - id_customer: customerId - -admin_customers_toggle_newsletter_subscription: - path: /{customerId}/toggle-newsletter-subscription - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:toggleNewsletterSubscription - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers:changeNewsletterVal - _legacy_parameters: - id_customer: customerId - requirements: - customerId: \d+ - -admin_customers_set_required_fields: - path: /set-required-fields - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:setRequiredFields - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers:submitFields - -admin_customers_toggle_partner_offer_subscription: - path: /{customerId}/toggle-partner-offer-subscription - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:togglePartnerOfferSubscription - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers:changeOptinVal - _legacy_parameters: - id_customer: customerId - requirements: - customerId: \d+ - -admin_customers_delete_bulk: - path: /delete-bulk - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:deleteBulk - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers:submitBulkdeletecustomer - -admin_customers_delete: - path: /delete - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:delete - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers:deletecustomer - -admin_customers_enable_bulk: - path: /enable-bulk - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:enableBulk - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers:submitBulkenableSelectioncustomer - -admin_customers_disable_bulk: - path: /disable-bulk - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:disableBulk - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers:submitBulkdisableSelectioncustomer - -admin_customers_export: - path: /export - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:export - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers:exportcustomer - -admin_customers_search: - path: /search - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:search - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers:searchCustomers - options: - expose: true - -admin_customer_for_address_information: - path: /customer-information - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Customer\Customer:getCustomerInformation - _legacy_controller: AdminAddresses - _legacy_link: AdminAddresses:loadNames - -admin_customers_carts: - path: /{customerId}/carts - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:getCarts - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers - requirements: - customerId: \d+ - options: - expose: true - -admin_customers_orders: - path: /{customerId}/orders - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Customer/Customer:getOrders - _legacy_controller: AdminCustomers - _legacy_link: AdminCustomers - requirements: - customerId: \d+ - options: - expose: true diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer_service/_customer_service.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer_service/_customer_service.yml deleted file mode 100644 index fad91e25..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer_service/_customer_service.yml +++ /dev/null @@ -1,11 +0,0 @@ -_order_message: - resource: "order_message.yml" - prefix: /order-messages/ - -_merchandise_return: - resource: "merchandise_return.yml" - prefix: /merchandise-return/ - -_customer_threads: - resource: "customer_threads.yml" - prefix: /customer-threads/ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer_service/customer_threads.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer_service/customer_threads.yml deleted file mode 100644 index 4c67d843..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer_service/customer_threads.yml +++ /dev/null @@ -1,39 +0,0 @@ -admin_customer_threads_view: - path: /{customerThreadId}/view - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/CustomerService/CustomerThread:view - _legacy_controller: AdminCustomerThreads -# _legacy_link: AdminCustomerThreads - requirements: - customerThreadId: \d+ - -admin_customer_threads_reply: - path: /{customerThreadId}/reply - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/CustomerService/CustomerThread:reply - _legacy_controller: AdminCustomerThreads - # _legacy_link: AdminCustomerThreads - requirements: - customerThreadId: \d+ - -admin_customer_threads_update_status: - path: /{customerThreadId}/update-status/{newStatus} - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/CustomerService/CustomerThread:updateStatus - _legacy_controller: AdminCustomerThreads - # _legacy_link: AdminCustomerThreads - requirements: - customerThreadId: \d+ - -admin_customer_threads_forward: - path: /{customerThreadId}/forward - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/CustomerService/CustomerThread:forward - _legacy_controller: AdminCustomerThreads - # _legacy_link: AdminCustomerThreads - requirements: - customerThreadId: \d+ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer_service/merchandise_return.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer_service/merchandise_return.yml deleted file mode 100644 index 5f3c1d0f..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer_service/merchandise_return.yml +++ /dev/null @@ -1,25 +0,0 @@ -admin_merchandise_returns_index: - path: / - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/CustomerService/MerchandiseReturn:index - _legacy_controller: AdminReturn -# _legacy_link: AdminReturn - -admin_merchandise_returns_save_options: - path: /options - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/CustomerService/MerchandiseReturn:index - _legacy_controller: AdminReturn -# _legacy_link: AdminReturn:submitOptionsorder_return - -admin_merchandise_returns_filter: - path: / - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Common:searchGrid - gridDefinitionFactoryServiceId: prestashop.core.grid.definition.factory.merchandise_return - redirectRoute: admin_merchandise_returns_index - _legacy_controller: AdminReturn -# _legacy_link: AdminReturn:submitFilterorder_return diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer_service/order_message.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer_service/order_message.yml deleted file mode 100644 index 8a38ee64..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/customer_service/order_message.yml +++ /dev/null @@ -1,59 +0,0 @@ -admin_order_messages_index: - path: / - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/CustomerService/OrderMessage:index - _legacy_controller: AdminOrderMessage - _legacy_link: AdminOrderMessage - -admin_order_messages_filter: - path: / - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Common:searchGrid - gridDefinitionFactoryServiceId: prestashop.core.grid.definition.factory.order_message - _legacy_controller: AdminOrderMessage - _legacy_link: AdminOrderMessage:submitFilterorder_message - redirectRoute: admin_order_messages_index - -admin_order_messages_create: - path: /new - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/CustomerService/OrderMessage:create - _legacy_controller: AdminOrderMessage - _legacy_link: AdminOrderMessage:addorder_message - -admin_order_messages_edit: - path: /{orderMessageId}/edit - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/CustomerService/OrderMessage:edit - _legacy_controller: AdminOrderMessage - _legacy_link: AdminOrderMessage:updateorder_message - legacy_parameters: - id_order_message: orderMessageId - requirements: - orderMessageId: \d+ - -admin_order_messages_delete: - path: /{orderMessageId}/delete - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/CustomerService/OrderMessage:delete - _legacy_controller: AdminOrderMessage - _legacy_link: AdminOrderMessage:deleteorder_message - legacy_parameters: - id_order_message: orderMessageId - requirements: - orderMessageId: \d+ - -admin_order_messages_bulk_delete: - path: /bulk-delete - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/CustomerService/OrderMessage:bulkDelete - _legacy_controller: AdminOrderMessage - _legacy_link: AdminOrderMessage:submitBulkdeleteorder_message - legacy_parameters: - order_messageBox: order_message_order_messages_bulk diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/_orders.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/_orders.yml deleted file mode 100644 index f34f2ff7..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/_orders.yml +++ /dev/null @@ -1,19 +0,0 @@ -_delivery_slips: - resource: "delivery_slips.yml" - prefix: /delivery-slips/ - -_invoices: - resource: "invoices.yml" - prefix: /invoices/ - -_carts: - resource: "carts.yml" - prefix: /carts/ - -_orders: - resource: "orders.yml" - prefix: / - -_credit_slips: - resource: "credit_slips.yml" - prefix: /credit-slips/ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/carts.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/carts.yml deleted file mode 100644 index bc274c88..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/carts.yml +++ /dev/null @@ -1,152 +0,0 @@ -admin_carts_view: - path: /{cartId}/view - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Cart:view - _legacy_controller: AdminCarts - _legacy_link: AdminCarts:viewcart - _legacy_parameters: - id_cart: cartId - requirements: - cartId: \d+ - options: - expose: true - -admin_carts_info: - path: /{cartId}/info - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Cart:getInfo - _legacy_controller: AdminCarts - requirements: - cartId: \d+ - options: - expose: true - -admin_carts_create: - path: /new - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Cart:create - _legacy_controller: AdminCarts - options: - expose: true - -admin_carts_edit_addresses: - path: /{cartId}/addresses - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Cart:editAddresses - _legacy_controller: AdminCarts - requirements: - cartId: \d+ - options: - expose: true - -admin_carts_edit_carrier: - path: /{cartId}/carrier - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Cart:editCarrier - _legacy_controller: AdminCarts - requirements: - cartId: \d+ - options: - expose: true - -admin_carts_edit_currency: - path: /{cartId}/currency - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Cart:editCurrency - _legacy_controller: AdminCarts - requirements: - cartId: \d+ - options: - expose: true - -admin_carts_edit_language: - path: /{cartId}/language - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Cart:editLanguage - _legacy_controller: AdminCarts - requirements: - cartId: \d+ - options: - expose: true - -admin_carts_set_delivery_settings: - path: /{cartId}/rules/delivery-settings - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Cart:updateDeliverySettings - _legacy_controller: AdminCarts - requirements: - cartId: \d+ - options: - expose: true - -admin_carts_add_cart_rule: - path: /{cartId}/cart-rules - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Cart:addCartRule - _legacy_controller: AdminCarts - options: - expose: true - -admin_carts_delete_cart_rule: - path: /{cartId}/cart-rules/{cartRuleId}/delete - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Cart:deleteCartRule - _legacy_controller: AdminCarts - options: - expose: true - -admin_carts_add_product: - path: /{cartId}/products - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Cart:addProduct - _legacy_controller: AdminCarts - options: - expose: true - requirements: - cartId: \d+ - -admin_carts_edit_product_price: - path: /{cartId}/products/{productId}/price - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Cart:editProductPrice - _legacy_controller: AdminCarts - options: - expose: true - requirements: - cartId: \d+ - productId: \d+ - -admin_carts_edit_product_quantity: - path: /{cartId}/products/{productId}/quantity - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Cart:editProductQuantity - _legacy_controller: AdminCarts - options: - expose: true - requirements: - cartId: \d+ - productId: \d+ - -admin_carts_delete_product: - path: /{cartId}/delete-product - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Cart:deleteProduct - _legacy_controller: AdminCarts - options: - expose: true - requirements: - cartId: \d+ diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/credit_slips.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/credit_slips.yml deleted file mode 100644 index 2494d7fd..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/credit_slips.yml +++ /dev/null @@ -1,43 +0,0 @@ -admin_credit_slips_index: - path: / - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Order/CreditSlip:index' - _legacy_controller: AdminSlip - _legacy_link: AdminSlip - -admin_credit_slips_search: - path: /search - methods: POST - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Order/CreditSlip:search' - _legacy_controller: AdminSlip - _legacy_link: AdminSlip:submitFilterorder_slip - -admin_credit_slips_generate_pdf: - path: /{creditSlipId}/pdf - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Order/CreditSlip:generatePdf' - _legacy_controller: AdminSlip - _legacy_link: AdminSlip:submitgenerateOrderSlipPdf - _legacy_parameters: - id_order_slip: creditSlipId - requirements: - creditSlipId: \d+ - -_admin_credit_slips_pdf_by_date: - path: /pdf-by-date - methods: GET - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Order/CreditSlip:generatePdfByDate' - _legacy_link: AdminSlip:submitAddorder_slip - _legacy_controller: AdminSlip - -admin_credit_slips_process_options: - path: / - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin/Sell/Order/CreditSlip:index' - _legacy_controller: AdminSlip - _legacy_link: AdminSlip:submitOptionsorder_slip diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/delivery_slips.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/delivery_slips.yml deleted file mode 100644 index 0c25bf3b..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/delivery_slips.yml +++ /dev/null @@ -1,15 +0,0 @@ -admin_order_delivery_slip: - path: / - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Delivery:slip - _legacy_controller: AdminDeliverySlip - _legacy_link: AdminDeliverySlip - -admin_order_delivery_slip_pdf: - path: /pdf - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Delivery:generatePdf - _legacy_controller: AdminDeliverySlip - _legacy_link: AdminDeliverySlip:submitAdddelivery diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/invoices.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/invoices.yml deleted file mode 100644 index b51fb378..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/invoices.yml +++ /dev/null @@ -1,35 +0,0 @@ -# Invoices -admin_order_invoices: - path: / - methods: [GET] - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Order\Invoices:index' - _legacy_controller: AdminInvoices - _legacy_link: AdminInvoices - -# Process Invoice Options form -admin_order_invoices_process: - path: / - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Order\Invoices:process' - _legacy_controller: AdminInvoices - _legacy_link: AdminInvoices:update - -# Generate PDF by date -admin_order_invoices_generate_by_date: - path: /by_date - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Order\Invoices:generatePdfByDate' - _legacy_controller: AdminInvoices - _legacy_link: AdminInvoices:submitAddinvoice_date - -# Generate PDF by status -admin_order_invoices_generate_by_status: - path: /by_status - methods: [POST] - defaults: - _controller: 'PrestaShopBundle:Admin\Sell\Order\Invoices:generatePdfByStatus' - _legacy_controller: AdminInvoices - _legacy_link: AdminInvoices:submitAddinvoice_status diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/orders.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/orders.yml deleted file mode 100644 index a87ff113..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/orders/orders.yml +++ /dev/null @@ -1,398 +0,0 @@ -admin_orders_index: - path: / - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:index - _legacy_controller: AdminOrders - _legacy_link: AdminOrders - -admin_orders_create: - path: /new - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Order\Order:create - _legacy_controller: AdminOrders - _legacy_link: AdminOrders:addorder - -admin_orders_place: - path: /place - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Sell\Order\Order:place - _legacy_controller: AdminOrders - options: - expose: true - -admin_orders_search: - path: / - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin\Common:searchGrid - _legacy_controller: AdminOrders - gridDefinitionFactoryServiceId: prestashop.core.grid.definition.factory.order - redirectRoute: admin_orders_index - -admin_orders_generate_invoice_pdf: - path: /{orderId}/generate-invoice-pdf - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:generateInvoicePdf - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - -admin_orders_generate_delivery_slip_pdf: - path: /{orderId}/generate-delivery-slip-pdf - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:generateDeliverySlipPdf - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - -admin_orders_change_orders_status: - path: /change-orders-status - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:changeOrdersStatus - _legacy_controller: AdminOrders - -admin_orders_export: - path: /export - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:export - _legacy_controller: AdminOrders - -admin_orders_view: - path: /{orderId}/view - methods: [GET, POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:view - _legacy_controller: AdminOrders - _legacy_link: AdminOrders:vieworder - _legacy_parameters: - id_order: orderId - options: - expose: true - requirements: - orderId: \d+ - -admin_orders_add_cart_rule: - path: /{orderId}/cart-rules - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:addCartRule - requirements: - orderId: \d+ - -admin_orders_list_update_status: - path: /list/{orderId}/status - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:updateStatusFromList - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - -admin_orders_update_status: - path: /{orderId}/status - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:updateStatus - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - -admin_orders_add_payment: - path: /{orderId}/payment - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:addPayment - requirements: - orderId: \d+ - -admin_orders_duplicate_cart: - path: /{orderId}/duplicate-cart - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:duplicateOrderCart - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - options: - expose: true - -admin_orders_change_currency: - path: /{orderId}/currency/change - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:changeCurrency - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - -admin_orders_update_product: - path: /{orderId}/products/{orderDetailId} - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:updateProduct - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - orderDetailId: \d+ - options: - expose: true - -admin_orders_remove_cart_rule: - path: /{orderId}/cart-rules/{orderCartRuleId}/delete - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:removeCartRule - requirements: - orderId: \d+ - orderCartRuleId: \d+ - -admin_orders_resend_email: - path: /{orderId}/history/{orderHistoryId}/statuses/{orderStatusId}/resend-email - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:resendEmail - requirements: - orderId: \d+ - orderHistoryId: \d+ - orderStatusId: \d+ - -admin_orders_preview: - path: /{orderId}/preview - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:preview - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - -admin_orders_update_shipping: - path: /{orderId}/shipping - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:updateShipping - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - -admin_orders_update_invoice_note: - path: /{orderId}/invoice/{orderInvoiceId}/note - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:updateInvoiceNote - requirements: - orderId: \d+ - orderInvoiceId: \d+ - -admin_orders_generate_invoice: - path: /{orderId}/invoice - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:generateInvoice - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - -admin_orders_change_customer_address: - path: /change-customer-address - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:changeCustomerAddress - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - -admin_orders_send_message: - path: /{orderId}/send-message - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:sendMessage - _legacy_controller: AdminOrders - -admin_orders_partial_refund: - path: /{orderId}/partial-refund - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:partialRefund - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - options: - expose: true - -admin_orders_standard_refund: - path: /{orderId}/standard-refund - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:standardRefund - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - options: - expose: true - -admin_orders_return_product: - path: /{orderId}/return-product - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:returnProduct - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - options: - expose: true - -admin_orders_send_process_order_email: - path: /process-order-email - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:sendProcessOrderEmail - _legacy_controller: AdminOrders - options: - expose: true - -admin_orders_add_product: - path: /{orderId}/products - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:addProduct - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - options: - expose: true - -admin_orders_delete_product: - path: /{orderId}/products/{orderDetailId}/delete - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:deleteProduct - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - orderDetailId: \d+ - options: - expose: true - -admin_orders_get_discounts: - path: /{orderId}/discounts - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:getDiscounts - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - options: - expose: true - -admin_orders_get_prices: - path: /{orderId}/prices - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:getPrices - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - options: - expose: true - -admin_orders_get_payments: - path: /{orderId}/payments - methods: [ GET ] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:getPayments - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - options: - expose: true - -admin_orders_get_products: - path: /{orderId}/products - methods: [ GET ] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:getProductsList - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - options: - expose: true - -admin_orders_get_invoices: - path: /{orderId}/invoices - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:getInvoices - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - options: - expose: true - -admin_orders_get_documents: - path: /{orderId}/documents - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:getDocuments - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - options: - expose: true - -admin_orders_cancellation: - path: /{orderId}/cancellation - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:cancellation - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - options: - expose: true - -admin_orders_configure_product_pagination: - path: /configure-product-pagination - methods: [POST] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:configureProductPagination - _legacy_controller: AdminOrders - options: - expose: true - -admin_orders_display_customization_image: - path: /display-customization-image/{orderId}/{name}/{value} - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:displayCustomizationImage - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - name: \w+ - value: \w+ - -admin_orders_product_prices: - path: /{orderId}/products/prices - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:getProductPrices - _legacy_controller: AdminOrders - requirements: - orderId: \d+ - options: - expose: true - -admin_orders_products_search: - path: /products/search - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Sell/Order/Order:searchProducts - _legacy_controller: AdminOrders - options: - expose: true diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/stocks.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/stocks.yml deleted file mode 100644 index 634e9651..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/stocks.yml +++ /dev/null @@ -1,14 +0,0 @@ -admin_stock_overview: - path: / - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Stock:overview - _legacy_controller: AdminStockManagement - _legacy_link: AdminStockManagement - -admin_stock_movements_overview: - path: /movements - methods: [GET] - defaults: - _controller: PrestaShopBundle:Admin/Stock:overview - _legacy_controller: AdminStockManagement diff --git a/src/PrestaShopBundle/Resources/config/routing/api.yml b/src/PrestaShopBundle/Resources/config/routing/api.yml deleted file mode 100644 index ab513281..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/api.yml +++ /dev/null @@ -1,39 +0,0 @@ -_api_stocks: - resource: "api/stocks.yml" - prefix: /stocks - -_api_stock_movements: - resource: "api/stock_movements.yml" - prefix: /stock-movements - -_api_suppliers: - resource: "api/suppliers.yml" - prefix: /suppliers - -_api_manufacturers: - resource: "api/manufacturers.yml" - prefix: /manufacturers - -_api_categories: - resource: "api/categories.yml" - prefix: /categories - -_api_attributes: - resource: "api/attributes.yml" - prefix: /attributes - -_api_features: - resource: "api/features.yml" - prefix: /features - -_api_i18n: - resource: "api/i18n.yml" - prefix: /i18n - -_api_translations: - resource: "api/translations.yml" - prefix: /translations - -_api_positions: - resource: "api/improve/design/positions.yml" - prefix: /improve/design/positions diff --git a/src/PrestaShopBundle/Resources/config/routing/api/attributes.yml b/src/PrestaShopBundle/Resources/config/routing/api/attributes.yml deleted file mode 100644 index 9c149d67..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/api/attributes.yml +++ /dev/null @@ -1,5 +0,0 @@ -api_stock_list_attributes: - path: / - methods: [GET] - defaults: - _controller: prestashop.core.api.attribute.controller:listAttributesAction diff --git a/src/PrestaShopBundle/Resources/config/routing/api/categories.yml b/src/PrestaShopBundle/Resources/config/routing/api/categories.yml deleted file mode 100644 index 7d554c2c..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/api/categories.yml +++ /dev/null @@ -1,5 +0,0 @@ -api_stock_list_categories: - path: / - methods: [GET] - defaults: - _controller: prestashop.core.api.category.controller:listCategoriesAction diff --git a/src/PrestaShopBundle/Resources/config/routing/api/features.yml b/src/PrestaShopBundle/Resources/config/routing/api/features.yml deleted file mode 100644 index 37f57210..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/api/features.yml +++ /dev/null @@ -1,5 +0,0 @@ -api_stock_list_features: - path: / - methods: [GET] - defaults: - _controller: prestashop.core.api.feature.controller:listFeaturesAction diff --git a/src/PrestaShopBundle/Resources/config/routing/api/i18n.yml b/src/PrestaShopBundle/Resources/config/routing/api/i18n.yml deleted file mode 100644 index 76c03d4c..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/api/i18n.yml +++ /dev/null @@ -1,7 +0,0 @@ -api_i18n_translations_list: - path: /{page} - methods: [GET] - defaults: - _controller: prestashop.core.api.i18n.controller:listTranslationAction - requirements: - page: \w+ diff --git a/src/PrestaShopBundle/Resources/config/routing/api/improve/design/positions.yml b/src/PrestaShopBundle/Resources/config/routing/api/improve/design/positions.yml deleted file mode 100644 index f87b568b..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/api/improve/design/positions.yml +++ /dev/null @@ -1,6 +0,0 @@ -api_improve_design_positions_update: - path: /update - methods: [POST] - defaults: - _controller: prestashop.core.api.improve.design.postions.controller:updateAction - _legacy_controller: AdminModulesPositions diff --git a/src/PrestaShopBundle/Resources/config/routing/api/manufacturers.yml b/src/PrestaShopBundle/Resources/config/routing/api/manufacturers.yml deleted file mode 100644 index 238cd2ab..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/api/manufacturers.yml +++ /dev/null @@ -1,5 +0,0 @@ -api_stock_list_manufacturers: - path: / - methods: [GET] - defaults: - _controller: prestashop.core.api.manufacturer.controller:listManufacturersAction diff --git a/src/PrestaShopBundle/Resources/config/routing/api/stock_movements.yml b/src/PrestaShopBundle/Resources/config/routing/api/stock_movements.yml deleted file mode 100644 index 55a087b8..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/api/stock_movements.yml +++ /dev/null @@ -1,30 +0,0 @@ -api_stock_list_movements: - path: / - methods: [GET] - defaults: - _controller: prestashop.core.api.stock_movement.controller:listMovementsAction - _legacy_controller: AdminStockManagement - -api_stock_product_list_movements: - path: /product/{productId} - methods: [GET] - defaults: - _controller: prestashop.core.api.stock_movement.controller:listMovementsAction - _legacy_controller: AdminStockManagement - requirements: - productId: \d+ - -api_stock_list_movements_employees: - path: /employees - methods: [GET] - defaults: - _controller: prestashop.core.api.stock_movement.controller:listMovementsEmployeesAction - _legacy_controller: AdminStockManagement - - -api_stock_list_movements_types: - path: /types - methods: [GET] - defaults: - _controller: prestashop.core.api.stock_movement.controller:listMovementsTypesAction - _legacy_controller: AdminStockManagement diff --git a/src/PrestaShopBundle/Resources/config/routing/api/stocks.yml b/src/PrestaShopBundle/Resources/config/routing/api/stocks.yml deleted file mode 100644 index f9a47adf..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/api/stocks.yml +++ /dev/null @@ -1,48 +0,0 @@ -api_stock_list_products: - path: / - methods: [GET] - defaults: - _controller: prestashop.core.api.stock.controller:listProductsAction - _legacy_controller: AdminStockManagement - -api_stock_list_products_export: - path: /export - methods: [GET] - defaults: - _controller: prestashop.core.api.stock.controller:listProductsExportAction - _legacy_controller: AdminStockManagement - -api_stock_list_product_combinations: - path: /{productId} - methods: [GET] - defaults: - _controller: prestashop.core.api.stock.controller:listProductsAction - _legacy_controller: AdminStockManagement - requirements: - productId: \d+ - -api_stock_edit_product: - path: /product/{productId} - methods: [POST] - defaults: - _controller: prestashop.core.api.stock.controller:editProductAction - _legacy_controller: AdminStockManagement - requirements: - productId: \d+ - -api_stock_edit_product_combination: - path: /product/{productId}/combination/{combinationId} - methods: [POST] - defaults: - _controller: prestashop.core.api.stock.controller:editProductAction - _legacy_controller: AdminStockManagement - requirements: - productId: \d+ - combinationId: \d+ - -api_stock_bulk_edit_products: - path: /products - methods: [POST] - defaults: - _controller: prestashop.core.api.stock.controller:bulkEditProductsAction - _legacy_controller: AdminStockManagement diff --git a/src/PrestaShopBundle/Resources/config/routing/api/suppliers.yml b/src/PrestaShopBundle/Resources/config/routing/api/suppliers.yml deleted file mode 100644 index 3347e634..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/api/suppliers.yml +++ /dev/null @@ -1,5 +0,0 @@ -api_stock_list_suppliers: - path: / - methods: [GET] - defaults: - _controller: prestashop.core.api.supplier.controller:listSuppliersAction diff --git a/src/PrestaShopBundle/Resources/config/routing/api/translations.yml b/src/PrestaShopBundle/Resources/config/routing/api/translations.yml deleted file mode 100644 index 09de266d..00000000 --- a/src/PrestaShopBundle/Resources/config/routing/api/translations.yml +++ /dev/null @@ -1,30 +0,0 @@ -api_translation_domains_tree: - path: /tree/{lang}/{type}/{selected} - methods: [GET] - defaults: - _controller: prestashop.core.api.translation.controller:listTreeAction - _legacy_controller: AdminTranslations - selected: null - -api_translation_domain_catalog: - path: /{locale}/{domain}/{theme} - methods: [GET] - defaults: - _controller: prestashop.core.api.translation.controller:listDomainTranslationAction - _legacy_controller: AdminTranslations - theme: null - module: null - -api_translation_value_edit: - path: /edit - methods: [POST] - defaults: - _controller: prestashop.core.api.translation.controller:translationEditAction - _legacy_controller: AdminTranslations - -api_translation_value_reset: - path: /reset - methods: [POST] - defaults: - _controller: prestashop.core.api.translation.controller:translationResetAction - _legacy_controller: AdminTranslations diff --git a/src/PrestaShopBundle/Resources/config/services.yml b/src/PrestaShopBundle/Resources/config/services.yml deleted file mode 100644 index 76c4b041..00000000 --- a/src/PrestaShopBundle/Resources/config/services.yml +++ /dev/null @@ -1,8 +0,0 @@ -parameters: - multishop.settings.share_orders: !php/const Shop::SHARE_ORDER - -imports: - - { resource: services/bundle/*.yml } - - { resource: services/core/*.yml } - - { resource: services/adapter/*.yml } - - { resource: services/alias.yml } diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/address.yml b/src/PrestaShopBundle/Resources/config/services/adapter/address.yml deleted file mode 100644 index 35aa346a..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/address.yml +++ /dev/null @@ -1,81 +0,0 @@ -services: - _defaults: - public: true - - # Command handlers - - prestashop.adapter.address.command_handler.delete_address_handler: - class: 'PrestaShop\PrestaShop\Adapter\Address\CommandHandler\DeleteAddressHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Address\Command\DeleteAddressCommand' } - - prestashop.adapter.address.command_handler.bulk_delete_address_handler: - class: 'PrestaShop\PrestaShop\Adapter\Address\CommandHandler\BulkDeleteAddressHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Address\Command\BulkDeleteAddressCommand' } - - prestashop.adapter.address.command_handler.add_manufacturer_address_handler: - class: 'PrestaShop\PrestaShop\Adapter\Address\CommandHandler\AddManufacturerAddressHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Address\Command\AddManufacturerAddressCommand' - - prestashop.adapter.address.command_handler.edit_manufacturer_address_handler: - class: 'PrestaShop\PrestaShop\Adapter\Address\CommandHandler\EditManufacturerAddressHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Address\Command\EditManufacturerAddressCommand' - - prestashop.adapter.address.query_handler.get_manufacturer_address_for_editing_handler: - class: 'PrestaShop\PrestaShop\Adapter\Address\QueryHandler\GetManufacturerAddressForEditingHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Address\Query\GetManufacturerAddressForEditing' - - prestashop.adapter.address.query_handler.get_required_fields_for_address: - class: 'PrestaShop\PrestaShop\Adapter\Address\QueryHandler\GetRequiredFieldsForAddressHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Address\Query\GetRequiredFieldsForAddress' - - prestashop.adapter.address.command_handler.set_required_fields_for_address: - class: 'PrestaShop\PrestaShop\Adapter\Address\CommandHandler\SetRequiredFieldsForAddressHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Address\Command\SetRequiredFieldsForAddressCommand' - - prestashop.adapter.address.command_handler.add_customer_address_handler: - class: 'PrestaShop\PrestaShop\Adapter\Address\CommandHandler\AddCustomerAddressHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Address\Command\AddCustomerAddressCommand' - - prestashop.adapter.address.query_handler.get_customer_address_for_editing_handler: - class: 'PrestaShop\PrestaShop\Adapter\Address\QueryHandler\GetCustomerAddressForEditingHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Address\Query\GetCustomerAddressForEditing' - - prestashop.adapter.address.command_handler.edit_customer_address_handler: - class: 'PrestaShop\PrestaShop\Adapter\Address\CommandHandler\EditCustomerAddressHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Address\Command\EditCustomerAddressCommand' - - prestashop.adapter.address.command_handler.edit_order_address_handler: - class: 'PrestaShop\PrestaShop\Adapter\Address\CommandHandler\EditOrderAddressHandler' - arguments: - - '@prestashop.adapter.address.command_handler.edit_customer_address_handler' - - '@prestashop.adapter.order.command_handler.change_order_delivery_address_handler' - - '@prestashop.adapter.order.command_handler.change_order_invoice_address_handler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Address\Command\EditOrderAddressCommand' - - prestashop.adapter.address.command_handler.edit_cart_address_handler: - class: 'PrestaShop\PrestaShop\Adapter\Address\CommandHandler\EditCartAddressHandler' - arguments: - - '@prestashop.adapter.address.command_handler.edit_customer_address_handler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Address\Command\EditCartAddressCommand' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/admin.yml b/src/PrestaShopBundle/Resources/config/services/adapter/admin.yml deleted file mode 100644 index 4b9723b8..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/admin.yml +++ /dev/null @@ -1,18 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.admin.page_preference: - class: PrestaShop\PrestaShop\Adapter\Admin\PagePreference - arguments: - - "@session" - decorates: prestashop.core.admin.page_preference_interface - public: false - - prestashop.adapter.admin.controller.category: - class: PrestaShop\PrestaShop\Adapter\Category\AdminCategoryControllerWrapper - - prestashop.adapter.legacy_db: - class: 'Db' - factory: ['Db', 'getInstance'] - deprecated: '%service_id% service is deprecated and will be removed in 1.8.' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/attachment.yml b/src/PrestaShopBundle/Resources/config/services/adapter/attachment.yml deleted file mode 100644 index 3da917a8..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/attachment.yml +++ /dev/null @@ -1,59 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.attachment.command_handler.delete_attachment_handler: - public: true - class: 'PrestaShop\PrestaShop\Adapter\Attachment\CommandHandler\DeleteAttachmentHandler' - parent: 'prestashop.adapter.attachment.command_handler.abstract_attachment_handler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Attachment\Command\DeleteAttachmentCommand' } - - prestashop.adapter.attachment.command_handler.bulk_delete_attachment_handler: - public: true - class: 'PrestaShop\PrestaShop\Adapter\Attachment\CommandHandler\BulkDeleteAttachmentsHandler' - parent: 'prestashop.adapter.attachment.command_handler.abstract_attachment_handler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Attachment\Command\BulkDeleteAttachmentsCommand' } - - prestashop.adapter.attachment.query_handler.get_attachment_handler: - class: 'PrestaShop\PrestaShop\Adapter\Attachment\QueryHandler\GetAttachmentHandler' - arguments: - - !php/const _PS_DOWNLOAD_DIR_ - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Attachment\Query\GetAttachment' } - - prestashop.adapter.contact.query_handler.get_attachment_handler: - class: 'PrestaShop\PrestaShop\Adapter\Attachment\QueryHandler\GetAttachmentForEditingHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Attachment\Query\GetAttachmentForEditing' } - - prestashop.adapter.attachment.uploader.attachment_file_uploader: - class: 'PrestaShop\PrestaShop\Adapter\File\Uploader\AttachmentFileUploader' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.core.configuration.upload_size_configuration' - - prestashop.adapter.attachment.command_handler.abstract_attachment_handler: - abstract: true - class: 'PrestaShop\PrestaShop\Adapter\Attachment\AbstractAttachmentHandler' - arguments: - - '@validator' - - prestashop.adapter.attachment.command_handler.edit_attachment_handler: - public: true - class: 'PrestaShop\PrestaShop\Adapter\Attachment\CommandHandler\EditAttachmentHandler' - parent: 'prestashop.adapter.attachment.command_handler.abstract_attachment_handler' - arguments: - - '@prestashop.adapter.attachment.uploader.attachment_file_uploader' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Attachment\Command\EditAttachmentCommand' } - - prestashop.adapter.attachment.command_handler.create_attachment_handler: - public: true - class: 'PrestaShop\PrestaShop\Adapter\Attachment\CommandHandler\AddAttachmentHandler' - parent: 'prestashop.adapter.attachment.command_handler.abstract_attachment_handler' - arguments: - - '@prestashop.adapter.attachment.uploader.attachment_file_uploader' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Attachment\Command\AddAttachmentCommand' } diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/attribute.yml b/src/PrestaShopBundle/Resources/config/services/adapter/attribute.yml deleted file mode 100644 index 5ea44176..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/attribute.yml +++ /dev/null @@ -1,15 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.attribute.command_handler.delete_attribute_handler: - class: 'PrestaShop\PrestaShop\Adapter\Attribute\CommandHandler\DeleteAttributeHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Command\DeleteAttributeCommand' - - prestashop.adapter.attribute.command_handler.bulk_delete_attribute_handler: - class: 'PrestaShop\PrestaShop\Adapter\Attribute\CommandHandler\BulkDeleteAttributeHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Attribute\Command\BulkDeleteAttributeCommand' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/attribute_group.yml b/src/PrestaShopBundle/Resources/config/services/adapter/attribute_group.yml deleted file mode 100644 index c41e7a52..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/attribute_group.yml +++ /dev/null @@ -1,15 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.attribute_group.command_handler.delete_attribute_group_handler: - class: 'PrestaShop\PrestaShop\Adapter\AttributeGroup\CommandHandler\DeleteAttributeGroupHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Command\DeleteAttributeGroupCommand' - - prestashop.adapter.attribute_group.command_handler.bulk_delete_attribute_group_handler: - class: 'PrestaShop\PrestaShop\Adapter\AttributeGroup\CommandHandler\BulkDeleteAttributeGroupHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Product\AttributeGroup\Command\BulkDeleteAttributeGroupCommand' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/backup.yml b/src/PrestaShopBundle/Resources/config/services/adapter/backup.yml deleted file mode 100644 index 05c0b846..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/backup.yml +++ /dev/null @@ -1,12 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.backup.database_creator: - class: 'PrestaShop\PrestaShop\Adapter\Backup\DatabaseBackupCreator' - - prestashop.adapter.backup.backup_provider: - class: 'PrestaShop\PrestaShop\Adapter\Backup\BackupRepository' - - prestashop.adapter.backup.backup_remover: - class: 'PrestaShop\PrestaShop\Adapter\Backup\BackupRemover' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/cache.yml b/src/PrestaShopBundle/Resources/config/services/adapter/cache.yml deleted file mode 100644 index ae571d91..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/cache.yml +++ /dev/null @@ -1,18 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.cache.clearer.class_index_cache_clearer: - class: 'PrestaShop\PrestaShop\Adapter\Cache\Clearer\ClassIndexCacheClearer' - - prestashop.adapter.cache.clearer.media_cache_clearer: - class: 'PrestaShop\PrestaShop\Adapter\Cache\Clearer\MediaCacheClearer' - - prestashop.adapter.cache.clearer.smarty_cache_clearer: - class: 'PrestaShop\PrestaShop\Adapter\Cache\Clearer\SmartyCacheClearer' - - prestashop.adapter.cache.clearer.symfony_cache_clearer: - class: 'PrestaShop\PrestaShop\Adapter\Cache\Clearer\SymfonyCacheClearer' - - prestashop.adapter.cache.clearer.xml_cache_clearer: - class: 'PrestaShop\PrestaShop\Adapter\Cache\Clearer\XmlCacheClearer' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/cart.yml b/src/PrestaShopBundle/Resources/config/services/adapter/cart.yml deleted file mode 100644 index 9c77d521..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/cart.yml +++ /dev/null @@ -1,131 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.cart.command_handler.create_empty_customer_cart_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\CommandHandler\CreateEmptyCustomerCartHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Command\CreateEmptyCustomerCartCommand' - - prestashop.adapter.cart.command_handler.update_cart_currency_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\CommandHandler\UpdateCartCurrencyHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateCartCurrencyCommand' - - prestashop.adapter.cart.command_handler.update_cart_language_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\CommandHandler\UpdateCartLanguageHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateCartLanguageCommand' - - prestashop.adapter.cart.command_handler.update_cart_addresses_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\CommandHandler\UpdateCartAddressesHandler' - arguments: - - '@prestashop.adapter.command_handler.update_cart_carrier_handler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateCartAddressesCommand' - - prestashop.adapter.cart.command_handler.update_delivery_options_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\CommandHandler\UpdateCartDeliverySettingsHandler' - arguments: - - '@translator' - - '@prestashop.adapter.legacy.configuration' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateCartDeliverySettingsCommand' - - prestashop.adapter.command_handler.update_product_quantity_in_cart_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\CommandHandler\UpdateProductQuantityInCartHandler' - arguments: - - '@prestashop.adapter.context_state_manager' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateProductQuantityInCartCommand' - - prestashop.adapter.command_handler.update_cart_carrier_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\CommandHandler\UpdateCartCarrierHandler' - arguments: - - '@prestashop.adapter.context_state_manager' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateCartCarrierCommand' - - prestashop.adapter.command_handler.add_cart_rule_to_cart_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\CommandHandler\AddCartRuleToCartHandler' - arguments: - - '@translator' - - '@prestashop.adapter.context_state_manager' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Command\AddCartRuleToCartCommand' - - prestashop.adapter.command_handler.remove_cart_rule_from_cart_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\CommandHandler\RemoveCartRuleFromCartHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Command\RemoveCartRuleFromCartCommand' - - prestashop.adapter.command_handler.remove_product_from_cart_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\CommandHandler\RemoveProductFromCartHandler' - arguments: - - '@prestashop.adapter.context_state_manager' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Command\RemoveProductFromCartCommand' - - prestashop.adapter.command_handler.update_product_price_in_cart_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\CommandHandler\UpdateProductPriceInCartHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Command\UpdateProductPriceInCartCommand' - - prestashop.adapter.command_handler.send_cart_to_customer_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\CommandHandler\SendCartToCustomerHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Command\SendCartToCustomerCommand' - - prestashop.adapter.query_handler.get_cart_for_viewing_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\QueryHandler\GetCartForViewingHandler' - arguments: - - '@prestashop.adapter.image_manager' - - "@prestashop.core.localization.locale.context_locale" - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Query\GetCartForViewing' - - prestashop.adapter.cart.query_handler.get_last_empty_customer_cart_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\QueryHandler\GetLastEmptyCustomerCartHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Query\GetLastEmptyCustomerCart' - - prestashop.adapter.query_handler.get_cart_information_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\QueryHandler\GetCartForOrderCreationHandler' - arguments: - - "@prestashop.core.localization.locale.context_locale" - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - - '@=service("prestashop.adapter.legacy.context").getContext().link' - - '@prestashop.adapter.context_state_manager' - - '@translator' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Query\GetCartForOrderCreation' - - prestashop.adapter.command_handler.add_customization_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\CommandHandler\AddCustomizationHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Command\AddCustomizationCommand' - - prestashop.adapter.command_handler.add_product_to_cart_handler: - class: 'PrestaShop\PrestaShop\Adapter\Cart\CommandHandler\AddProductToCartHandler' - arguments: - - '@prestashop.adapter.command_handler.add_customization_handler' - - '@prestashop.adapter.command_handler.update_product_quantity_in_cart_handler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Cart\Command\AddProductToCartCommand' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/cart_rule.yml b/src/PrestaShopBundle/Resources/config/services/adapter/cart_rule.yml deleted file mode 100644 index c20bcc33..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/cart_rule.yml +++ /dev/null @@ -1,15 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.cart_rule.command_handler.add_cart_rule_handler: - class: PrestaShop\PrestaShop\Adapter\CartRule\CommandHandler\AddCartRuleHandler - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\CartRule\Command\AddCartRuleCommand } - - prestashop.adapter.cart_rule.query_handler.search_cart_rules_handler: - class: PrestaShop\PrestaShop\Adapter\CartRule\QueryHandler\SearchCartRulesHandler - arguments: - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\CartRule\Query\SearchCartRules } diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/catalog_price_rule.yml b/src/PrestaShopBundle/Resources/config/services/adapter/catalog_price_rule.yml deleted file mode 100644 index 46df1ca6..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/catalog_price_rule.yml +++ /dev/null @@ -1,33 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.catalog_price_rule.command_handler.delete_catalog_price_rule_handler: - class: 'PrestaShop\PrestaShop\Adapter\CatalogPriceRule\CommandHandler\DeleteCatalogPriceRuleHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command\DeleteCatalogPriceRuleCommand' - - prestashop.adapter.catalog_price_rule.command_handler.bulk_delete_catalog_price_rule_handler: - class: 'PrestaShop\PrestaShop\Adapter\CatalogPriceRule\CommandHandler\BulkDeleteCatalogPriceRuleHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command\BulkDeleteCatalogPriceRuleCommand' - - prestashop.adapter.catalog_price_rule.command_handler.add_catalog_price_rule_handler: - class: 'PrestaShop\PrestaShop\Adapter\CatalogPriceRule\CommandHandler\AddCatalogPriceRuleHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command\AddCatalogPriceRuleCommand' - - prestashop.adapter.catalog_price_rule.command_handler.edit_catalog_price_rule_handler: - class: 'PrestaShop\PrestaShop\Adapter\CatalogPriceRule\CommandHandler\EditCatalogPriceRuleHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Command\EditCatalogPriceRuleCommand' - - prestashop.adapter.catalog_price_rule.command_handler.get_catalog_price_rule_for_editing_handler: - class: 'PrestaShop\PrestaShop\Adapter\CatalogPriceRule\QueryHandler\GetCatalogPriceRuleForEditingHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\CatalogPriceRule\Query\GetCatalogPriceRuleForEditing' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/category.yml b/src/PrestaShopBundle/Resources/config/services/adapter/category.yml deleted file mode 100644 index dbabab07..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/category.yml +++ /dev/null @@ -1,116 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.admin.controller.category: - class: PrestaShop\PrestaShop\Adapter\Category\AdminCategoryControllerWrapper - - prestashop.adapter.category.category_view_data_provider: - class: PrestaShop\PrestaShop\Adapter\Category\CategoryViewDataProvider - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.feature.multistore' - - '@prestashop.adapter.shop.context' - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - - prestashop.adapter.category.command_handler.bulk_update_categories_status_handler: - class: PrestaShop\PrestaShop\Adapter\Category\CommandHandler\BulkUpdateCategoriesStatusHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Category\Command\BulkUpdateCategoriesStatusCommand - - prestashop.adapter.category.command_handler.bulk_enable_categories_status_handler: - class: PrestaShop\PrestaShop\Adapter\Category\CommandHandler\BulkUpdateCategoriesStatusHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Category\Command\BulkEnableCategoriesCommand - - prestashop.adapter.category.command_handler.bulk_disable_categories_status_handler: - class: PrestaShop\PrestaShop\Adapter\Category\CommandHandler\BulkUpdateCategoriesStatusHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Category\Command\BulkDisableCategoriesCommand - - prestashop.adapter.category.command_handler.set_category_is_enabled_handler: - class: PrestaShop\PrestaShop\Adapter\Category\CommandHandler\SetCategoryIsEnabledHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Category\Command\SetCategoryIsEnabledCommand - - prestashop.adapter.category.command_handler.delete_category_handler: - class: PrestaShop\PrestaShop\Adapter\Category\CommandHandler\DeleteCategoryHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Category\Command\DeleteCategoryCommand - - prestashop.adapter.category.command_handler.bulk_delete_categories_handler: - class: PrestaShop\PrestaShop\Adapter\Category\CommandHandler\BulkDeleteCategoriesHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Category\Command\BulkDeleteCategoriesCommand - - prestashop.adapter.category.command_handler.add_category_handler: - class: PrestaShop\PrestaShop\Adapter\Category\CommandHandler\AddCategoryHandler - public: true - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Category\Command\AddCategoryCommand } - - prestashop.adapter.category.command_handler.add_root_category_handler: - class: PrestaShop\PrestaShop\Adapter\Category\CommandHandler\AddRootCategoryHandler - arguments: - - '@prestashop.adapter.legacy.configuration' - public: true - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Category\Command\AddRootCategoryCommand - - prestashop.adapter.category.command_handler.edit_root_category_handler: - class: PrestaShop\PrestaShop\Adapter\Category\CommandHandler\EditRootCategoryHandler - public: true - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Category\Command\EditRootCategoryCommand - - prestashop.adapter.category.command_handler.edit_category_handler: - class: PrestaShop\PrestaShop\Adapter\Category\CommandHandler\EditCategoryHandler - public: true - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Category\Command\EditCategoryCommand } - - prestashop.adapter.category.query_handler.get_category_for_editing: - class: PrestaShop\PrestaShop\Adapter\Category\QueryHandler\GetCategoryForEditingHandler - arguments: - - '@prestashop.core.image.parser.image_tag_source_parser' - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Category\Query\GetCategoryForEditing } - - prestashop.adapter.category.command_handler.delete_category_cover_image_handler: - class: PrestaShop\PrestaShop\Adapter\Category\CommandHandler\DeleteCategoryCoverImageHandler - arguments: - - '@filesystem' - - '@prestashop.adapter.legacy.configuration' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Category\Command\DeleteCategoryCoverImageCommand - - prestashop.adapter.category.command_handler.delete_category_menu_thumbnail_image_handler: - class: PrestaShop\PrestaShop\Adapter\Category\CommandHandler\DeleteCategoryMenuThumbnailImageHandler - arguments: - - '@filesystem' - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.cache.clearer.smarty_cache_clearer' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Category\Command\DeleteCategoryMenuThumbnailImageCommand - - prestashop.adapter.category.command_handler.update_category_position_handler: - class: PrestaShop\PrestaShop\Adapter\Category\CommandHandler\UpdateCategoryPositionHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Category\Command\UpdateCategoryPositionCommand - - prestashop.adapter.category.command_handler.get_category_status_handler: - class: PrestaShop\PrestaShop\Adapter\Category\QueryHandler\GetCategoryIsEnabledHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Category\Query\GetCategoryIsEnabled diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/cms_page.yml b/src/PrestaShopBundle/Resources/config/services/adapter/cms_page.yml deleted file mode 100644 index ad15bb12..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/cms_page.yml +++ /dev/null @@ -1,60 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.cms_page.command_handler.bulk_disable_cms_page: - class: PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler\BulkDisableCmsPageHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\BulkDisableCmsPageCommand - - prestashop.adapter.cms_page.command_handler.bulk_enable_cms_page: - class: PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler\BulkEnableCmsPageHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\BulkEnableCmsPageCommand - - prestashop.adapter.cms_page.command_handler.toggle_cms_page_status: - class: PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler\ToggleCmsPageStatusHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\ToggleCmsPageStatusCommand - - prestashop.adapter.cms_page.query_handler.get_cms_category_id_for_redirection: - class: PrestaShop\PrestaShop\Adapter\CMS\Page\QueryHandler\GetCmsCategoryIdForRedirectionHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPage\Query\GetCmsCategoryIdForRedirection - - prestashop.adapter.cms_page.command_handler.delete_cms_page: - class: PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler\DeleteCmsPageHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\DeleteCmsPageCommand - - prestashop.adapter.cms_page.command_handler.bulk_delete_cms_page: - class: PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler\BulkDeleteCmsPageHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\BulkDeleteCmsPageCommand - - prestashop.adapter.cms_page.command_handler.add_cms_page_handler: - class: PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler\AddCmsPageHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\AddCmsPageCommand - - prestashop.adapter.cms_page.command_handler.edit_cms_page_handler: - class: PrestaShop\PrestaShop\Adapter\CMS\Page\CommandHandler\EditCmsPageHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPage\Command\EditCmsPageCommand - - prestashop.adapter.cms_page.query_handler.get_cms_page_for_editing_handler: - class: PrestaShop\PrestaShop\Adapter\CMS\Page\QueryHandler\GetCmsPageForEditingHandler - arguments: - - "@=service('prestashop.adapter.legacy.context').getContext().link" - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPage\Query\GetCmsPageForEditing diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/cms_page_category.yml b/src/PrestaShopBundle/Resources/config/services/adapter/cms_page_category.yml deleted file mode 100644 index 89e28b9d..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/cms_page_category.yml +++ /dev/null @@ -1,94 +0,0 @@ -services: - _defaults: - public: true - -# Command handlers - - prestashop.adapter.cms_page_category.command_handler.abstract_cms_page_category_handler: - class: PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CommandHandler\AbstractCmsPageCategoryHandler - abstract: true - arguments: - - '@validator' - - prestashop.adapter.cms_page_category.command_handler.delete_cms_page_category_handler: - class: PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CommandHandler\DeleteCmsPageCategoryHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\DeleteCmsPageCategoryCommand - - prestashop.adapter.cms_page_category.command_handler.toggle_cms_page_category_status_handler: - class: PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CommandHandler\ToggleCmsPageCategoryStatusHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\ToggleCmsPageCategoryStatusCommand - - prestashop.adapter.cms_page_category.command_handler.bulk_delete_cms_page_category_handler: - class: PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CommandHandler\BulkDeleteCmsPageCategoryHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\BulkDeleteCmsPageCategoryCommand - - prestashop.adapter.cms_page.command_handler.bulk_enable_cms_page_category_handler: - class: PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CommandHandler\BulkEnableCmsPageCategoryHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\BulkEnableCmsPageCategoryCommand - - prestashop.adapter.cms_page.command_handler.bulk_disable_cms_page_category_handler: - class: PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CommandHandler\BulkDisableCmsPageCategoryHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\BulkDisableCmsPageCategoryCommand - - prestashop.adapter.cms_page.command_handler.add_cms_page_category_handler: - class: 'PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CommandHandler\AddCmsPageCategoryHandler' - parent: 'prestashop.adapter.cms_page_category.command_handler.abstract_cms_page_category_handler' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\AddCmsPageCategoryCommand - public: true - - prestashop.adapter.cms_page.command_handler.edit_cms_page_category_handler: - class: 'PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CommandHandler\EditCmsPageCategoryHandler' - parent: 'prestashop.adapter.cms_page_category.command_handler.abstract_cms_page_category_handler' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Command\EditCmsPageCategoryCommand - public: true - - # Query handlers - - prestashop.adapter.cms_page.query_handler.get_cms_page_categories_for_breadcrumbs: - class: PrestaShop\PrestaShop\Adapter\CMS\PageCategory\QueryHandler\GetCmsPageCategoriesForBreadcrumbHandler - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query\GetCmsPageCategoriesForBreadcrumb - - prestashop.adapter.cms_page.query_handler.get_cms_page_categories_for_redirection: - class: PrestaShop\PrestaShop\Adapter\CMS\PageCategory\QueryHandler\GetCmsPageParentCategoryIdForRedirectionHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query\GetCmsPageParentCategoryIdForRedirection - - prestashop.adapter.cms_page.query_handler.get_cms_page_category_for_editing: - class: PrestaShop\PrestaShop\Adapter\CMS\PageCategory\QueryHandler\GetCmsPageCategoryForEditingHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query\GetCmsPageCategoryForEditing - - prestashop.adapter.cms_page.categories_provider: - class: 'PrestaShop\PrestaShop\Adapter\CMS\PageCategory\CategoriesProvider' - arguments: - - '@=service("prestashop.adapter.legacy.context").getLanguage().id' - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - - prestashop.adapter.cms_page.query_handler.get_cms_page_category_name_for_listing: - class: PrestaShop\PrestaShop\Adapter\CMS\PageCategory\QueryHandler\GetCmsPageCategoryNameForListingHandler - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - - '@request_stack' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CmsPageCategory\Query\GetCmsPageCategoryNameForListing diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/common.yml b/src/PrestaShopBundle/Resources/config/services/adapter/common.yml deleted file mode 100644 index bba792b4..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/common.yml +++ /dev/null @@ -1,28 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.legacy.configuration: - class: PrestaShop\PrestaShop\Adapter\Configuration - - prestashop.adapter.tools: - class: PrestaShop\PrestaShop\Adapter\Tools - - prestashop.adapter.legacy.context: - class: PrestaShop\PrestaShop\Adapter\LegacyContext - arguments: - - "%mail_themes_uri%" - - '@prestashop.adapter.tools' - - prestashop.adapter.environment: - class: PrestaShop\PrestaShop\Adapter\Environment - arguments: - - !php/const _PS_MODE_DEV_ - - prestashop.adapter.validate: - class: PrestaShop\PrestaShop\Adapter\Validate - - prestashop.adapter.context_state_manager: - class: PrestaShop\PrestaShop\Adapter\ContextStateManager - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/configuration.yml b/src/PrestaShopBundle/Resources/config/services/adapter/configuration.yml deleted file mode 100644 index e9576c23..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/configuration.yml +++ /dev/null @@ -1,10 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.configuration.command_handler.switch_debug_mode_handler: - class: 'PrestaShop\PrestaShop\Adapter\Configuration\CommandHandler\SwitchDebugModeHandler' - arguments: - - '@prestashop.adapter.debug_mode' - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Configuration\Command\SwitchDebugModeCommand } diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/contact.yml b/src/PrestaShopBundle/Resources/config/services/adapter/contact.yml deleted file mode 100644 index f1074e89..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/contact.yml +++ /dev/null @@ -1,30 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.contact.repository: - class: 'PrestaShop\PrestaShop\Adapter\Support\ContactRepository' - - prestashop.adapter.contact.deleter: - class: 'PrestaShop\PrestaShop\Adapter\Support\ContactDeleter' - - prestashop.adapter.contact.query_handler.get_contact_for_editing: - class: 'PrestaShop\PrestaShop\Adapter\Contact\QueryHandler\GetContactForEditingHandler' - arguments: - - '@prestashop.bundle.form.data_transformer.string_array_to_integer_array' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Contact\Query\GetContactForEditing' } - - prestashop.adapter.contact.command_handler.edit_contact: - class: 'PrestaShop\PrestaShop\Adapter\Contact\CommandHandler\EditContactHandler' - arguments: - - '@validator' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Contact\Command\EditContactCommand' } - - prestashop.adapter.contact.command_handler.add_contact: - class: 'PrestaShop\PrestaShop\Adapter\Contact\CommandHandler\AddContactHandler' - arguments: - - '@validator' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Contact\Command\AddContactCommand' } diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/context.yml b/src/PrestaShopBundle/Resources/config/services/adapter/context.yml deleted file mode 100644 index 168632f4..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/context.yml +++ /dev/null @@ -1,14 +0,0 @@ -services: - _defaults: - public: true - - #SECURITY - #@todo: is this service used? - prestashop.adapter.security.admin: - class: "%AdapterSecurityAdminClass%" - arguments: - - "@prestashop.adapter.legacy.context" - - "@security.token_storage" - - "@prestashop.security.admin.provider" - tags: - - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest } diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/country.yml b/src/PrestaShopBundle/Resources/config/services/adapter/country.yml deleted file mode 100644 index 95f0b0fc..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/country.yml +++ /dev/null @@ -1,22 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.country.query_handler.get_country_required_fields: - class: 'PrestaShop\PrestaShop\Adapter\Country\QueryHandler\GetCountryRequiredFieldsHandler' - arguments: - - '@prestashop.adapter.country.country_required_fields_provider' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Country\Query\GetCountryRequiredFields' - - prestashop.adapter.country.country_zip_code_requirements_provider: - class: 'PrestaShop\PrestaShop\Adapter\Country\CountryZipCodeRequirementsProvider' - arguments: - - '@prestashop.adapter.legacy.context' - - '@prestashop.core.domain.country.zip_code_format_resolver' - - prestashop.adapter.country.country_required_fields_provider: - class: 'PrestaShop\PrestaShop\Adapter\Country\CountryRequiredFieldsProvider' - arguments: - - '@prestashop.adapter.data_provider.country' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/credit_slip.yml b/src/PrestaShopBundle/Resources/config/services/adapter/credit_slip.yml deleted file mode 100644 index 14fa44bd..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/credit_slip.yml +++ /dev/null @@ -1,9 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.credit_slip.query_handler.get_credit_slip_ids_by_date_range_handler: - class: 'PrestaShop\PrestaShop\Adapter\CreditSlip\QueryHandler\GetCreditSlipIdsByDateRangeHandler' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CreditSlip\Query\GetCreditSlipIdsByDateRange diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/currency.yml b/src/PrestaShopBundle/Resources/config/services/adapter/currency.yml deleted file mode 100644 index fccb6b9e..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/currency.yml +++ /dev/null @@ -1,109 +0,0 @@ -services: - _defaults: - public: true - - # Command validator - prestashop.adapter.currency.command_handler.command_validator: - class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\CurrencyCommandValidator' - arguments: - - '@prestashop.core.localization.cldr.locale_repository' - - '@prestashop.adapter.data_provider.currency' - - '@=service("prestashop.adapter.legacy.configuration").get("PS_CURRENCY_DEFAULT")' - - # Command handlers - - prestashop.adapter.currency.command_handler.toggle_currency_status: - class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\ToggleCurrencyStatusHandler' - arguments: - - '@=service("prestashop.adapter.legacy.configuration").get("PS_CURRENCY_DEFAULT")' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\ToggleCurrencyStatusCommand' } - - prestashop.adapter.currency.command_handler.delete_currency: - class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\DeleteCurrencyHandler' - arguments: - - '@=service("prestashop.adapter.legacy.configuration").get("PS_CURRENCY_DEFAULT")' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\DeleteCurrencyCommand' } - - prestashop.adapter.currency.command_handler.create_currency: - class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\AddOfficialCurrencyHandler' - arguments: - - '@prestashop.core.localization.cldr.locale_repository' - - "@=service('prestashop.core.admin.lang.repository').findAll()" - - "@prestashop.adapter.currency.command_handler.command_validator" - - '@prestashop.adapter.data_provider.currency' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\AddCurrencyCommand' } - - prestashop.adapter.currency.command_handler.create_unofficial_currency: - class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\AddUnofficialCurrencyHandler' - arguments: - - '@prestashop.core.localization.cldr.locale_repository' - - "@=service('prestashop.core.admin.lang.repository').findAll()" - - "@prestashop.adapter.currency.command_handler.command_validator" - - '@prestashop.adapter.data_provider.currency' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\AddUnofficialCurrencyCommand' } - - prestashop.adapter.currency.command_handler.update_official_currency: - class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\EditOfficialCurrencyHandler' - arguments: - - '@prestashop.core.localization.cldr.locale_repository' - - "@=service('prestashop.core.admin.lang.repository').findAll()" - - "@prestashop.adapter.currency.command_handler.command_validator" - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\EditCurrencyCommand' } - - prestashop.adapter.currency.command_handler.update_unofficial_currency: - class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\EditUnofficialCurrencyHandler' - arguments: - - '@prestashop.core.localization.cldr.locale_repository' - - "@=service('prestashop.core.admin.lang.repository').findAll()" - - "@prestashop.adapter.currency.command_handler.command_validator" - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\EditUnofficialCurrencyCommand' } - - prestashop.adapter.currency.command_handler.update_exchange_rates: - class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\RefreshExchangeRatesHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\RefreshExchangeRatesCommand' } - - prestashop.adapter.currency.command_handler.update_live_exchange_rates: - class: 'PrestaShop\PrestaShop\Adapter\Currency\CommandHandler\ToggleExchangeRateAutomatizationHandler' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@=service("prestashop.adapter.legacy.context").getContext().shop' - - '@prestashop.adapter.shop.shop_url' - - '@translator' - - '@=service("prestashop.adapter.data_provider.module").isInstalled("cronjobs")' - - '@=service("prestashop.adapter.legacy.context").getAdminBaseUrl()' - - '%database_prefix%' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Command\ToggleExchangeRateAutomatizationCommand' } - - - # Query handlers - - prestashop.adapter.currency.query_handler.get_currency_for_editing: - class: 'PrestaShop\PrestaShop\Adapter\Currency\QueryHandler\GetCurrencyForEditingHandler' - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetCurrencyForEditing' } - - prestashop.adapter.currency.query_handler.get_currency_exchange_rate: - class: 'PrestaShop\PrestaShop\Adapter\Currency\QueryHandler\GetCurrencyExchangeRateHandler' - arguments: - - '@prestashop.core.exchange_rate.provider' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetCurrencyExchangeRate' } - - prestashop.adapter.currency.query_handler.get_reference_currency: - class: 'PrestaShop\PrestaShop\Adapter\Currency\QueryHandler\GetReferenceCurrencyHandler' - arguments: - - '@prestashop.core.localization.cldr.locale_repository' - - '@prestashop.core.query_bus' - - '@=service("prestashop.core.admin.lang.repository").findAll()' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Currency\Query\GetReferenceCurrency' } diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/customer.yml b/src/PrestaShopBundle/Resources/config/services/adapter/customer.yml deleted file mode 100644 index 5a7bd90b..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/customer.yml +++ /dev/null @@ -1,115 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.customer.query_handler.get_customer_for_viewing: - class: 'PrestaShop\PrestaShop\Adapter\Customer\QueryHandler\GetCustomerForViewingHandler' - arguments: - - '@translator' - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - - "@=service('prestashop.adapter.legacy.context').getContext().link" - - "@prestashop.core.localization.locale.context_locale" - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerForViewing' - - prestashop.adapter.customer.command_handler.set_private_note_about_customer_handler: - class: 'PrestaShop\PrestaShop\Adapter\Customer\CommandHandler\SetPrivateNoteAboutCustomerHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Customer\Command\SetPrivateNoteAboutCustomerCommand' - - prestashop.adapter.customer.command_handler.transform_guest_to_customer: - class: 'PrestaShop\PrestaShop\Adapter\Customer\CommandHandler\TransformGuestToCustomerHandler' - arguments: - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Customer\Command\TransformGuestToCustomerCommand' - - prestashop.adapter.customer.command_handler.set_required_fields_for_customer: - class: 'PrestaShop\PrestaShop\Adapter\Customer\CommandHandler\SetRequiredFieldsForCustomerHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Customer\Command\SetRequiredFieldsForCustomerCommand' - - prestashop.adapter.customer.query_handler.get_required_fields_for_customer: - class: 'PrestaShop\PrestaShop\Adapter\Customer\QueryHandler\GetRequiredFieldsForCustomerHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetRequiredFieldsForCustomer' - - prestashop.adapter.customer.command_handler.add_customer: - class: 'PrestaShop\PrestaShop\Adapter\Customer\CommandHandler\AddCustomerHandler' - arguments: - - '@prestashop.core.crypto.hashing' - - '@=service("prestashop.adapter.legacy.configuration").get("_COOKIE_KEY_")' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Customer\Command\AddCustomerCommand' - - prestashop.adapter.customer.query_handler.get_customer_for_editing: - class: 'PrestaShop\PrestaShop\Adapter\Customer\QueryHandler\GetCustomerForEditingHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerForEditing' - - prestashop.adapter.customer.command_handler.edit_customer_handler: - class: 'PrestaShop\PrestaShop\Adapter\Customer\CommandHandler\EditCustomerHandler' - arguments: - - '@prestashop.core.crypto.hashing' - - '@=service("prestashop.adapter.legacy.configuration").get("_COOKIE_KEY_")' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Customer\Command\EditCustomerCommand' - - prestashop.adapter.customer.command_handler.bulk_enable_customer_handler: - class: 'PrestaShop\PrestaShop\Adapter\Customer\CommandHandler\BulkEnableCustomerHandler' - tags: - - { name: tactician.handler, command: 'PrestaShop\PrestaShop\Core\Domain\Customer\Command\BulkEnableCustomerCommand' } - - prestashop.adapter.customer.command_handler.bulk_disable_customer_handler: - class: 'PrestaShop\PrestaShop\Adapter\Customer\CommandHandler\BulkDisableCustomerHandler' - tags: - - { name: tactician.handler, command: 'PrestaShop\PrestaShop\Core\Domain\Customer\Command\BulkDisableCustomerCommand' } - - prestashop.adapter.customer.command_handler.delete_customer_handler: - class: 'PrestaShop\PrestaShop\Adapter\Customer\CommandHandler\DeleteCustomerHandler' - tags: - - { name: tactician.handler, command: 'PrestaShop\PrestaShop\Core\Domain\Customer\Command\DeleteCustomerCommand' } - - prestashop.adapter.customer.command_handler.bulk_delete_customer_handler: - class: 'PrestaShop\PrestaShop\Adapter\Customer\CommandHandler\BulkDeleteCustomerHandler' - tags: - - { name: tactician.handler, command: 'PrestaShop\PrestaShop\Core\Domain\Customer\Command\BulkDeleteCustomerCommand' } - - prestashop.adapter.customer.query_handler.search_customers: - class: 'PrestaShop\PrestaShop\Adapter\Customer\QueryHandler\SearchCustomersHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Customer\Query\SearchCustomers' - - prestashop.adapter.customer.query_handler.get_customer_carts_handler: - class: 'PrestaShop\PrestaShop\Adapter\Customer\QueryHandler\GetCustomerCartsHandler' - arguments: - - "@prestashop.core.localization.locale.context_locale" - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerCarts' - - prestashop.adapter.customer.query_handler.get_customer_orders_handler: - class: 'PrestaShop\PrestaShop\Adapter\Customer\QueryHandler\GetCustomerOrdersHandler' - arguments: - - "@prestashop.core.localization.locale.context_locale" - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerOrders' - - prestashop.adapter.customer.query_handler.get_customer_for_address_creation: - class: 'PrestaShop\PrestaShop\Adapter\Customer\QueryHandler\GetCustomerForAddressCreationHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Customer\Query\GetCustomerForAddressCreation' - - prestashop.adapter.customer.customer_data_source: - class: 'PrestaShop\PrestaShop\Adapter\Customer\CustomerDataSource' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/customer_message.yml b/src/PrestaShopBundle/Resources/config/services/adapter/customer_message.yml deleted file mode 100644 index 17e798c3..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/customer_message.yml +++ /dev/null @@ -1,15 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.customer_message.command_handler.add_order_customer_message: - class: PrestaShop\PrestaShop\Adapter\CustomerService\CommandHandler\AddOrderCustomerMessageHandler - arguments: - - '@translator' - - '@validator' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - - '@=service("prestashop.adapter.legacy.context").getContext().employee.id' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CustomerMessage\Command\AddOrderCustomerMessageCommand diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/customer_service.yml b/src/PrestaShopBundle/Resources/config/services/adapter/customer_service.yml deleted file mode 100644 index 102a4486..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/customer_service.yml +++ /dev/null @@ -1,36 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.customer_service.query_handler.get_customer_thread_for_viewing_handler: - class: 'PrestaShop\PrestaShop\Adapter\CustomerService\QueryHandler\GetCustomerThreadForViewingHandler' - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\CustomerService\Query\GetCustomerThreadForViewing' - - prestashop.adapter.customer_service.query_handler.get_customer_service_signature_handler: - class: 'PrestaShop\PrestaShop\Core\Domain\CustomerService\QueryHandler\GetCustomerServiceSignatureHandler' - arguments: - - '@prestashop.adapter.legacy.configuration' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\CustomerService\Query\GetCustomerServiceSignature' - - prestashop.adapter.customer_service.command_handler.forward_customer_thread_handler: - class: 'PrestaShop\PrestaShop\Adapter\CustomerService\CommandHandler\ForwardCustomerThreadHandler' - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - - '@prestashop.adapter.legacy.configuration' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\CustomerService\Command\ForwardCustomerThreadCommand' - - prestashop.adapter.customer_service.command_handler.reply_to_customer_thread_handler: - class: 'PrestaShop\PrestaShop\Adapter\CustomerService\CommandHandler\ReplyToCustomerThreadHandler' - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\CustomerService\Command\ReplyToCustomerThreadCommand' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/data_configuration.yml b/src/PrestaShopBundle/Resources/config/services/adapter/data_configuration.yml deleted file mode 100644 index bd9b8a35..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/data_configuration.yml +++ /dev/null @@ -1,258 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.product_general.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Product\GeneralConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.adapter.product_pagination.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Product\PaginationConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.adapter.product_page.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Product\PageConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.adapter.product_stock.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Product\StockConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.adapter.customer.customer_configuration: - class: 'PrestaShop\PrestaShop\Adapter\Customer\CustomerConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.adapter.order_general.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Order\GeneralConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.adapter.order_gift.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Order\GiftOptionsConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.adapter.debug_mode.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Debug\DebugModeConfiguration' - arguments: - - '@prestashop.adapter.debug_mode' - - '@prestashop.adapter.legacy.configuration' - - '%ps_config_dir%/defines.inc.php' - - prestashop.adapter.optional_features.configuration: - class: 'PrestaShop\PrestaShop\Adapter\OptionalFeatures\OptionalFeaturesConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.combination_feature' - - '@prestashop.adapter.feature.feature' - - '@prestashop.adapter.group.feature' - - prestashop.adapter.ccc.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Cache\CombineCompressCacheConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@filesystem' - - '@prestashop.adapter.tools' - - '%themes_dir%' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.theme_name' - - prestashop.adapter.media_servers.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Media\MediaServerConfiguration' - arguments: ['@prestashop.adapter.legacy.configuration'] - - prestashop.adapter.caching.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Cache\CachingConfiguration' - arguments: - - '@prestashop.adapter.memcache_server.manager' - - '@prestashop.adapter.php_parameters' - - '@prestashop.adapter.cache.clearer.symfony_cache_clearer' - - '%ps_cache_enable%' - - '%ps_caching%' - - prestashop.adapter.general.configuration: - class: 'PrestaShop\PrestaShop\Adapter\GeneralConfiguration' - arguments: ['@prestashop.adapter.legacy.configuration'] - - prestashop.adapter.maintenance.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Shop\MaintenanceConfiguration' - arguments: ['@prestashop.adapter.legacy.configuration'] - - prestashop.adapter.preferences.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Preferences\PreferencesConfiguration' - arguments: ['@prestashop.adapter.legacy.configuration'] - - prestashop.adapter.upload_quota.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Upload\UploadQuotaConfiguration' - arguments: ['@prestashop.adapter.legacy.configuration'] - - prestashop.adapter.notifications.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Admin\NotificationsConfiguration' - arguments: ['@prestashop.adapter.legacy.configuration'] - - prestashop.adapter.smarty_cache.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Smarty\SmartyCacheConfiguration' - arguments: ['@prestashop.adapter.legacy.configuration'] - - prestashop.adapter.logs.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Configuration\LogsConfiguration' - arguments: ['@prestashop.adapter.legacy.configuration'] - - prestashop.adapter.order.delivery.slip.options.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Order\Delivery\SlipOptionsConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.adapter.order.delivery.slip.pdf.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Order\Delivery\SlipPdfConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.adapter.order.invoice_options.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Invoice\InvoiceOptionsConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.adapter.data_provider.language: - class: 'PrestaShop\PrestaShop\Adapter\Language\LanguageDataProvider' - - prestashop.adapter.language.activator: - class: 'PrestaShop\PrestaShop\Adapter\Language\LanguageActivator' - - prestashop.adapter.language.language_pack_installer: - class: 'PrestaShop\PrestaShop\Adapter\Language\LanguagePackInstaller' - arguments: - - '@translator' - - '@prestashop.core.foundation.version' - - prestashop.adapter.language.validator: - class: 'PrestaShop\PrestaShop\Adapter\Language\LanguageValidator' - - prestashop.adapter.language.copier: - class: 'PrestaShop\PrestaShop\Adapter\Language\LanguageCopier' - arguments: - - '@prestashop.adapter.data_provider.language' - - '@translator' - - '@filesystem' - - '@=service("prestashop.core.addon.theme.repository").getListAsCollection()' - - prestashop.adapter.manager.currency: - class: 'PrestaShop\PrestaShop\Adapter\Currency\CurrencyManager' - - prestashop.adapter.localization.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Localization\LocalizationConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.language.activator' - - '@prestashop.adapter.manager.currency' - - '@prestashop.adapter.admin.data_provider.module' - - prestashop.adapter.local_units.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Localization\LocalUnitsConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.adapter.localization_advanced.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Localization\AdvancedConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.adapter.geolocation_by_ip_address.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Geolocation\GeolocationByIpAddressConfiguration' - arguments: ['@prestashop.adapter.legacy.configuration'] - - prestashop.adapter.geolocation_ip_address_whitelist.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Geolocation\GeolocationIpAddressWhitelistConfiguration' - arguments: ['@prestashop.adapter.legacy.configuration'] - - prestashop.adapter.geolocation_options.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Geolocation\GeolocationOptionsConfiguration' - arguments: ['@prestashop.adapter.legacy.configuration'] - - prestashop.adapter.payment_module_preferences.configuration: - class: 'PrestaShop\PrestaShop\Core\Payment\PaymentModulePreferencesConfiguration' - arguments: - - '@prestashop.adapter.module.payment_module_provider' - - '@prestashop.core.module.configuration.payment_restrictions_configurator' - - prestashop.adapter.shipping_preferences.handling_configuration: - class: 'PrestaShop\PrestaShop\Adapter\Carrier\HandlingConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.adapter.shipping_preferences.carrier_options_configuration: - class: 'PrestaShop\PrestaShop\Adapter\Carrier\CarrierOptionsConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.core.email.email_configurator: - class: 'PrestaShop\PrestaShop\Core\Email\EmailDataConfigurator' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.core.email.smtp_configurator: - class: 'PrestaShop\PrestaShop\Core\Email\SmtpDataConfigurator' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.adapter.webservice.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Webservice\WebserviceConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.adapter.meta.set_up_urls.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Meta\SetUpUrlsDataConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.file.htaccess_file_generator' - - '@translator' - - prestashop.adapter.meta.shop_url.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Meta\ShopUrlDataConfiguration' - arguments: - - '@=service("prestashop.adapter.shop.shop_url").getMainShopUrl()' - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.file.htaccess_file_generator' - - prestashop.adapter.meta.url_schema.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Meta\UrlSchemaDataConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@=service("prestashop.adapter.data_provider.default_route").getRules()' - - prestashop.adapter.meta.seo_options.configuration: - class: 'PrestaShop\PrestaShop\Adapter\Meta\SEOOptionsDataConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.core.team.employee.configuration.employee_options_configuration: - class: 'PrestaShop\PrestaShop\Core\Team\Employee\Configuration\EmployeeOptionsConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.core.team.employee.configuration.options_checker' - - prestashop.core.tax.tax_options_configuration: - class: 'PrestaShop\PrestaShop\Core\Tax\TaxOptionsConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.tax.ecotax.ecotax_resetter' - - prestashop.core.mail_theme.configuration: - class: 'PrestaShop\PrestaShop\Core\MailTemplate\MailThemeConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.core.mail_template.theme_catalog' - - prestashop.core.merchandise_return.configuration.merchandise_return_options_configuration: - class: 'PrestaShop\PrestaShop\Core\MerchandiseReturn\Configuration\MerchandiseReturnOptionsConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.core.credit_slip.credit_slip_options.configuration: - class: 'PrestaShop\PrestaShop\Core\CreditSlip\CreditSlipOptionsConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/data_provider.yml b/src/PrestaShopBundle/Resources/config/services/adapter/data_provider.yml deleted file mode 100644 index 4a6f0a6b..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/data_provider.yml +++ /dev/null @@ -1,117 +0,0 @@ -imports: - - { resource: ./data_provider_common.yml } - -services: - _defaults: - public: true - - prestashop.adapter.admin.data_provider.addons: - class: PrestaShop\PrestaShop\Adapter\Addons\AddonsDataProvider - decorates: prestashop.core.admin.data_provider.addons_interface - arguments: - - '@prestashop.addons.client_api' - - '@prestashop.module.zip.manager' - properties: - cacheDir: "%kernel.cache_dir%" - - prestashop.adapter.admin.data_provider.module: - class: PrestaShop\PrestaShop\Adapter\Module\AdminModuleDataProvider - arguments: - - "@translator" - - "@logger" - - "@prestashop.core.admin.data_provider.addons_interface" - - "@prestashop.categories_provider" - - "@prestashop.adapter.data_provider.module" - - "@doctrine.cache.provider" - - "@=service('prestashop.adapter.legacy.context').getContext().employee" - calls: - - [ setRouter, ['@router']] - decorates: prestashop.core.admin.data_provider.module_interface - public: false - - prestashop.adapter.data_provider.supplier: - class: PrestaShop\PrestaShop\Adapter\Supplier\SupplierDataProvider - - prestashop.adapter.data_provider.warehouse: - class: PrestaShop\PrestaShop\Adapter\Warehouse\WarehouseDataProvider - - prestashop.adapter.data_provider.category: - class: PrestaShop\PrestaShop\Adapter\Category\CategoryDataProvider - arguments: ["@=service('prestashop.adapter.legacy.context')"] - - prestashop.adapter.data_provider.group: - class: PrestaShop\PrestaShop\Adapter\Group\GroupDataProvider - - prestashop.adapter.data_provider.tax: - class: PrestaShop\PrestaShop\Adapter\Tax\TaxRuleDataProvider - - prestashop.adapter.data_provider.manufacturer: - class: PrestaShop\PrestaShop\Adapter\Manufacturer\ManufacturerDataProvider - - prestashop.adapter.data_provider.product: - class: PrestaShop\PrestaShop\Adapter\Product\ProductDataProvider - - prestashop.adapter.data_provider.attachment: - class: PrestaShop\PrestaShop\Adapter\Product\AttachmentDataProvider - - prestashop.adapter.data_provider.feature: - class: PrestaShop\PrestaShop\Adapter\Feature\FeatureDataProvider - - prestashop.adapter.data_provider.carrier: - class: PrestaShop\PrestaShop\Adapter\Carrier\CarrierDataProvider - arguments: ['@prestashop.adapter.legacy.configuration'] - - prestashop.adapter.data_provider.order_invoice: - class: PrestaShop\PrestaShop\Adapter\Invoice\OrderInvoiceDataProvider - - prestashop.adapter.data_provider.order_state: - class: PrestaShop\PrestaShop\Adapter\OrderState\OrderStateDataProvider - - prestashop.adapter.data_provider.attribute: - class: PrestaShop\PrestaShop\Adapter\Attribute\AttributeDataProvider - - prestashop.adapter.data_provider.customer: - class: PrestaShop\PrestaShop\Adapter\Customer\CustomerDataProvider - - prestashop.adapter.data_provider.combination: - class: PrestaShop\PrestaShop\Adapter\CombinationDataProvider - arguments: - - "@prestashop.core.localization.locale.context_locale" - - prestashop.adapter.data_provider.cms: - class: PrestaShop\PrestaShop\Adapter\CMS\CMSDataProvider - - prestashop.adapter.data_provider.pack: - class: PrestaShop\PrestaShop\Adapter\Pack\PackDataProvider - - prestashop.adapter.data_provider.tab: - class: PrestaShop\PrestaShop\Adapter\Tab\TabDataProvider - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext().employee.id_profile' - - '@=service("prestashop.adapter.legacy.configuration").getInt("_PS_ADMIN_PROFILE_")' - - prestashop.adapter.data_provider.profile: - class: PrestaShop\PrestaShop\Adapter\Profile\ProfileDataProvider - arguments: - - '@prestashop.adapter.data_provider.employee' - - '@=service("prestashop.adapter.legacy.configuration").getInt("_PS_ADMIN_PROFILE_")' - - prestashop.adapter.data_provider.module: - class: PrestaShop\PrestaShop\Adapter\Module\ModuleDataProvider - arguments: ["@prestashop.adapter.legacy.logger", "@translator", "@doctrine.orm.entity_manager"] - calls: - - [ "setEmployeeId", ["@=service('prestashop.adapter.legacy.context').getContext().employee?service('prestashop.adapter.legacy.context').getContext().employee.id:0"]] - - prestashop.categories_provider: - class: PrestaShopBundle\Service\DataProvider\Admin\CategoriesProvider - arguments: - - "%prestashop.addons.categories%" - - "@=service('prestashop.adapter.legacy.context').getContext().shop.theme_name?service('prestashop.core.addon.theme.repository').getInstanceByName(service('prestashop.adapter.legacy.context').getContext().shop.theme_name).getModulesToEnable():[]" - - prestashop.adapter.data_provider.default_route: - class: PrestaShop\PrestaShop\Adapter\Routes\DefaultRouteProvider - - prestashop.adapter.data_provider.employee: - class: PrestaShop\PrestaShop\Adapter\Employee\ContextEmployeeProvider - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext().employee' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/data_provider_common.yml b/src/PrestaShopBundle/Resources/config/services/adapter/data_provider_common.yml deleted file mode 100644 index 53d96bc9..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/data_provider_common.yml +++ /dev/null @@ -1,12 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.data_provider.country: - class: PrestaShop\PrestaShop\Adapter\Country\CountryDataProvider - - prestashop.adapter.data_provider.currency: - class: PrestaShop\PrestaShop\Adapter\Currency\CurrencyDataProvider - arguments: - - "@prestashop.adapter.legacy.configuration" - - "@=service('prestashop.adapter.legacy.context').getContext().shop?service('prestashop.adapter.legacy.context').getContext().shop.id" diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/email.yml b/src/PrestaShopBundle/Resources/config/services/adapter/email.yml deleted file mode 100644 index 2210296e..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/email.yml +++ /dev/null @@ -1,12 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.email.email_configuration_tester: - class: 'PrestaShop\PrestaShop\Adapter\Email\EmailConfigurationTester' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@translator' - - prestashop.adapter.email.email_log_eraser: - class: 'PrestaShop\PrestaShop\Adapter\Email\EmailLogEraser' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/employee.yml b/src/PrestaShopBundle/Resources/config/services/adapter/employee.yml deleted file mode 100644 index 6fc926c8..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/employee.yml +++ /dev/null @@ -1,77 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.profile.employee.command_handler.toggle_employee_status_handler: - class: 'PrestaShop\PrestaShop\Adapter\Profile\Employee\CommandHandler\ToggleEmployeeStatusHandler' - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Employee\Command\ToggleEmployeeStatusCommand } - - prestashop.adapter.profile.employee.command_handler.bulk_update_employee_status_handler: - class: 'PrestaShop\PrestaShop\Adapter\Profile\Employee\CommandHandler\BulkUpdateEmployeeStatusHandler' - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Employee\Command\BulkUpdateEmployeeStatusCommand } - - prestashop.adapter.profile.employee.command_handler.delete_employee_handler: - class: 'PrestaShop\PrestaShop\Adapter\Profile\Employee\CommandHandler\DeleteEmployeeHandler' - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Employee\Command\DeleteEmployeeCommand } - - prestashop.adapter.profile.employee.command_handler.bulk_delete_employee_handler: - class: 'PrestaShop\PrestaShop\Adapter\Profile\Employee\CommandHandler\BulkDeleteEmployeeHandler' - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Employee\Command\BulkDeleteEmployeeCommand } - - prestashop.adapter.employee.query_handler.get_employee_for_editing: - class: 'PrestaShop\PrestaShop\Adapter\Profile\Employee\QueryHandler\GetEmployeeForEditingHandler' - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Employee\Query\GetEmployeeForEditing } - - prestashop.adapter.employee.form_access_checker: - class: 'PrestaShop\PrestaShop\Adapter\Employee\EmployeeFormAccessChecker' - arguments: - - '@prestashop.adapter.data_provider.employee' - - '@prestashop.adapter.employee.data_provider' - - '@prestashop.core.admin.tab.repository' - - prestashop.adapter.employee.command_handler.add_employee_handler: - class: 'PrestaShop\PrestaShop\Adapter\Profile\Employee\CommandHandler\AddEmployeeHandler' - arguments: - - '@prestashop.core.crypto.hashing' - - '@prestashop.core.employee.profile_access_checker' - - '@prestashop.adapter.data_provider.employee' - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Employee\Command\AddEmployeeCommand } - - prestashop.adapter.employee.command_handler.edit_employee_handler: - class: 'PrestaShop\PrestaShop\Adapter\Profile\Employee\CommandHandler\EditEmployeeHandler' - arguments: - - '@prestashop.core.crypto.hashing' - - '@prestashop.core.employee.profile_access_checker' - - '@prestashop.adapter.data_provider.employee' - - '@prestashop.adapter.legacy.context' - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Employee\Command\EditEmployeeCommand } - - prestashop.adapter.employee.avatar_provider: - class: 'PrestaShop\PrestaShop\Adapter\Employee\AvatarProvider' - arguments: - - '@prestashop.adapter.tools' - - prestashop.adapter.employee.data_provider: - class: 'PrestaShop\PrestaShop\Adapter\Employee\EmployeeDataProvider' - - prestashop.adapter.employee.navigation_menu_toggler: - class: 'PrestaShop\PrestaShop\Adapter\Employee\NavigationMenuToggler' - arguments: - - '@prestashop.adapter.legacy.context' - - prestashop.adapter.employee.form_language_changer: - class: 'PrestaShop\PrestaShop\Adapter\Employee\FormLanguageChanger' - arguments: - - '@prestashop.adapter.legacy.context' - - prestashop.adapter.employee.query_handler.get_employee_email_by_id_handler: - class: PrestaShop\PrestaShop\Adapter\Profile\Employee\QueryHandler\GetEmployeeEmailByIdHandler - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Employee\Query\GetEmployeeEmailById } diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/feature.yml b/src/PrestaShopBundle/Resources/config/services/adapter/feature.yml deleted file mode 100644 index 0b39e2b9..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/feature.yml +++ /dev/null @@ -1,18 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.feature.command_handler.add_feature_handler: - class: PrestaShop\PrestaShop\Adapter\Feature\CommandHandler\AddFeatureHandler - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Feature\Command\AddFeatureCommand } - - prestashop.adapter.feature.command_handler.edit_feature_handler: - class: PrestaShop\PrestaShop\Adapter\Feature\CommandHandler\EditFeatureHandler - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Feature\Command\EditFeatureCommand } - - prestashop.adapter.feature.query_handler.get_feature_for_editing: - class: PrestaShop\PrestaShop\Adapter\Feature\QueryHandler\GetFeatureForEditingHandler - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Feature\Query\GetFeatureForEditing } diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/form.yml b/src/PrestaShopBundle/Resources/config/services/adapter/form.yml deleted file mode 100644 index ecb72281..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/form.yml +++ /dev/null @@ -1,64 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.form.choice_provider.profile_by_id_choice_provider: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\ProfileByIdChoiceProvider' - arguments: - - '@=service("prestashop.adapter.legacy.context").getLanguage().id' - - prestashop.adapter.form.choice_provider.shop_tree_choice_provider: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\ShopTreeChoiceProvider' - - prestashop.adapter.form.choice_provider.category_tree_choice_provider: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\CategoryTreeChoiceProvider' - arguments: - - '@prestashop.adapter.data_provider.category' - - '@=service("prestashop.adapter.data_provider.category").getRootCategory().id' - - false - - prestashop.adapter.form.choice_provider.gender_by_id_choice_provider: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\GenderByIdChoiceProvider' - - prestashop.adapter.form.choice_provider.group_by_id_choice_provider: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\GroupByIdChoiceProvider' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@=service("prestashop.adapter.legacy.context").getLanguage().id' - - prestashop.adapter.form.choice_provider.risk_by_id_choice_provider: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\RiskByIdChoiceProvider' - - prestashop.adapter.form.choice_provider.resources_choice_provider: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\ResourcesChoiceProvider' - - prestashop.adapter.form.choice_provider.manufacturer_name_by_id: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\ManufacturerNameByIdChoiceProvider' - arguments: - - '@=service("prestashop.adapter.data_provider.manufacturer").getManufacturers()' - - prestashop.adapter.form.choice_provider.country_state_by_id: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\CountryStateByIdChoiceProvider' - - prestashop.adapter.form.choice_provider.order_countries: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\OrderCountriesChoiceProvider' - - prestashop.adapter.form.choice_provider.order_invoice_by_id: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\OrderInvoiceByIdChoiceProvider' - arguments: - - '@prestashop.core.localization.locale.context_locale' - - prestashop.adapter.form.choice_provider.currency_symbol_by_id: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\CurrencySymbolByIdChoiceProvider' - - prestashop.adapter.form.choice_provider.installed_payment_modules: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\InstalledPaymentModulesChoiceProvider' - - prestashop.adapter.form.choice.provider.carrier_for_order_choice_provider: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\CarrierForOrderChoiceProvider' - - prestashop.adapter.form.choice_provider.shop_name_by_id: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\ShopNameByIdChoiceProvider' - - prestashop.adapter.form.choice_provider.employee_name_by_id: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\EmployeeNameByIdChoiceProvider' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/grid.yml b/src/PrestaShopBundle/Resources/config/services/adapter/grid.yml deleted file mode 100644 index 475f544a..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/grid.yml +++ /dev/null @@ -1,19 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.grid.search.factory.search_criteria_with_category_parent_id: - class: 'PrestaShop\PrestaShop\Adapter\Grid\Search\Factory\SearchCriteriaWithCategoryParentIdFilterFactory' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.shop.context' - - '@prestashop.adapter.feature.multistore' - - '@prestashop.adapter.shop.context' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id_category' - - '@request_stack' - - # Action accessibility checkers - prestashop.adapter.grid.action.row.accessibility_checker.category_for_view: - class: 'PrestaShop\PrestaShop\Adapter\Grid\Action\Row\AccessibilityChecker\CategoryForViewAccessibilityChecker' - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/group.yml b/src/PrestaShopBundle/Resources/config/services/adapter/group.yml deleted file mode 100644 index 59510304..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/group.yml +++ /dev/null @@ -1,9 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.group.provider.default_groups_provider: - class: 'PrestaShop\PrestaShop\Adapter\Group\Provider\DefaultGroupsProvider' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/image.yml b/src/PrestaShopBundle/Resources/config/services/adapter/image.yml deleted file mode 100644 index bcb83987..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/image.yml +++ /dev/null @@ -1,20 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.image.uploader.category_cover_image_uploader: - class: 'PrestaShop\PrestaShop\Adapter\Image\Uploader\CategoryCoverImageUploader' - - prestashop.adapter.image.uploader.category_thumbnail_image_uploader: - class: 'PrestaShop\PrestaShop\Adapter\Image\Uploader\CategoryThumbnailImageUploader' - - prestashop.adapter.image.uploader.category_menu_thumbnail_image_uploader: - class: 'PrestaShop\PrestaShop\Adapter\Image\Uploader\CategoryMenuThumbnailUploader' - arguments: - - '@prestashop.adapter.cache_clearer' - - prestashop.adapter.image.uploader.manufacturer_image_uploader: - class: 'PrestaShop\PrestaShop\Adapter\Image\Uploader\ManufacturerImageUploader' - - prestashop.adapter.image.uploader.supplier_image_uploader: - class: 'PrestaShop\PrestaShop\Adapter\Image\Uploader\SupplierImageUploader' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/import.yml b/src/PrestaShopBundle/Resources/config/services/adapter/import.yml deleted file mode 100644 index 643148e1..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/import.yml +++ /dev/null @@ -1,93 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.import.data_match_saver: - class: 'PrestaShop\PrestaShop\Adapter\Import\DataMatchSaver' - arguments: - - '@doctrine.dbal.default_connection' - - '%database_prefix%' - - prestashop.adapter.import.entity_deleter: - class: 'PrestaShop\PrestaShop\Adapter\Import\ImportEntityDeleter' - arguments: - - '@doctrine.dbal.default_connection' - - '%database_prefix%' - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.core.image.file_deleter' - - prestashop.adapter.import.excel_to_csv_converter: - class: 'PrestaShop\PrestaShop\Adapter\Converter\ExcelToCsvFileConverter' - arguments: - - '@filesystem' - - '@=service("prestashop.core.import.dir").getDir()' - - '@=service("prestashop.core.import.dir").getDir() ~ "csvfromexcel/"' - - prestashop.adapter.import.file_opener: - class: 'PrestaShop\PrestaShop\Adapter\Import\CsvFileOpener' - arguments: - - '@prestashop.adapter.import.excel_to_csv_converter' - - '@prestashop.core.import.dir' - - prestashop.adapter.import.handler.product: - class: 'PrestaShop\PrestaShop\Adapter\Import\Handler\ProductImportHandler' - arguments: - - '@prestashop.adapter.import.data_formatter' - - '@=service("prestashop.adapter.shop.context").getAllShopIds()' - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id' - - '@=service("prestashop.adapter.feature.multistore").isUsed()' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - - '@translator' - - '@prestashop.adapter.legacy.logger' - - '@=service("prestashop.adapter.data_provider.employee").getId()' - - '@prestashop.adapter.database' - - '@prestashop.adapter.cache.clearer.smarty_cache_clearer' - - '@doctrine.dbal.default_connection' - - '%database_prefix%' - - '@prestashop.adapter.legacy.configuration' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.getAddress()' - - '@prestashop.adapter.validate' - - '@prestashop.adapter.tools' - - '@prestashop.adapter.import.image_copier' - - prestashop.adapter.import.handler.category: - class: 'PrestaShop\PrestaShop\Adapter\Import\Handler\CategoryImportHandler' - arguments: - - '@prestashop.adapter.import.data_formatter' - - '@=service("prestashop.adapter.shop.context").getAllShopIds()' - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id' - - '@=service("prestashop.adapter.feature.multistore").isUsed()' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - - '@translator' - - '@prestashop.adapter.legacy.logger' - - '@=service("prestashop.adapter.data_provider.employee").getId()' - - '@prestashop.adapter.database' - - '@prestashop.adapter.cache.clearer.smarty_cache_clearer' - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.validate' - - '@prestashop.adapter.import.image_copier' - - '@prestashop.adapter.tools' - - '@doctrine.dbal.default_connection' - - '%database_prefix%' - - prestashop.adapter.import.handler_finder: - class: 'PrestaShop\PrestaShop\Adapter\Import\Handler\ImportHandlerFinder' - arguments: - - '@prestashop.adapter.import.handler.category' - - '@prestashop.adapter.import.handler.product' - - prestashop.adapter.import.data_formatter: - class: 'PrestaShop\PrestaShop\Adapter\Import\ImportDataFormatter' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.tools' - - prestashop.adapter.import.image_copier: - class: 'PrestaShop\PrestaShop\Adapter\Import\ImageCopier' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.tools' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id' - - '@prestashop.core.hook.dispatcher' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/kpi.yml b/src/PrestaShopBundle/Resources/config/services/adapter/kpi.yml deleted file mode 100644 index 79393cc6..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/kpi.yml +++ /dev/null @@ -1,100 +0,0 @@ -services: - _defaults: - public: true - - # KPI implementations - prestashop.adapter.kpi.enabled_languages: - class: PrestaShop\PrestaShop\Adapter\Kpi\EnabledLanguagesKpi - arguments: - - '@translator' - - '@prestashop.adapter.legacy.kpi_configuration' - - '@=service("prestashop.adapter.legacy.context").getAdminLink("AdminLanguages")' - - '@=service("prestashop.adapter.legacy.context").getAdminLink("AdminStats", true, {"ajax": 1, "action": "getKpi", "kpi": "enabled_languages"})' - - prestashop.adapter.kpi.main_country: - class: PrestaShop\PrestaShop\Adapter\Kpi\MainCountryKpi - arguments: - - '@translator' - - '@prestashop.adapter.legacy.kpi_configuration' - - '@=service("prestashop.adapter.legacy.context").getAdminLink("AdminStats", true, {"ajax": 1, "action": "getKpi", "kpi": "main_country"})' - - prestashop.adapter.kpi.translations: - class: PrestaShop\PrestaShop\Adapter\Kpi\TranslationsKpi - arguments: - - '@translator' - - '@prestashop.adapter.legacy.kpi_configuration' - - '@=service("prestashop.adapter.legacy.context").getAdminLink("AdminStats", true, {"ajax": 1, "action": "getKpi", "kpi": "frontoffice_translations"})' - - prestashop.adapter.kpi.disabled_categories: - class: PrestaShop\PrestaShop\Adapter\Kpi\DisabledCategoriesKpi - arguments: - - '@translator' - - '@prestashop.adapter.legacy.kpi_configuration' - - '@=service("prestashop.adapter.legacy.context").getAdminLink("AdminStats", true, {"ajax": 1, "action": "getKpi", "kpi": "disabled_categories"})' - - prestashop.adapter.kpi.empty_categories: - class: PrestaShop\PrestaShop\Adapter\Kpi\EmptyCategoriesKpi - arguments: - - '@translator' - - '@prestashop.adapter.legacy.kpi_configuration' - - '@=service("prestashop.adapter.legacy.context").getAdminLink("AdminStats", true, {"ajax": 1, "action": "getKpi", "kpi": "empty_categories"})' - - '@=service("prestashop.adapter.legacy.context").getAdminLink("AdminTracking")' - - prestashop.adapter.kpi.top_category: - class: PrestaShop\PrestaShop\Adapter\Kpi\TopCategoryKpi - arguments: - - '@translator' - - '@prestashop.adapter.legacy.kpi_configuration' - - '@=service("prestashop.adapter.legacy.context").getAdminLink("AdminStats", true, {"ajax": 1, "action": "getKpi", "kpi": "top_category"})' - - "@=service('prestashop.adapter.legacy.context').getContext().employee.id_lang" - - prestashop.adapter.kpi.average_products_in_category: - class: PrestaShop\PrestaShop\Adapter\Kpi\AverageProductsInCategoryKpi - arguments: - - '@translator' - - '@prestashop.adapter.legacy.kpi_configuration' - - '@=service("prestashop.adapter.legacy.context").getAdminLink("AdminStats", true, {"ajax": 1, "action": "getKpi", "kpi": "products_per_category"})' - - prestashop.adapter.kpi.most_common_customers_gender: - class: 'PrestaShop\PrestaShop\Adapter\Kpi\MostCommonCustomersGenderKpi' - arguments: - - '@translator' - - '@prestashop.adapter.legacy.kpi_configuration' - - '@=service("prestashop.adapter.legacy.context").getAdminLink("AdminStats", true, {"ajax": 1, "action": "getKpi", "kpi": "customer_main_gender"})' - - prestashop.adapter.kpi.average_customer_age: - class: 'PrestaShop\PrestaShop\Adapter\Kpi\AverageCustomerAgeKpi' - arguments: - - '@translator' - - '@prestashop.adapter.legacy.kpi_configuration' - - '@=service("prestashop.adapter.legacy.context").getAdminLink("AdminStats", true, {"ajax": 1, "action": "getKpi", "kpi": "avg_customer_age"})' - - prestashop.adapter.kpi.order_per_customer: - class: 'PrestaShop\PrestaShop\Adapter\Kpi\OrdersPerCustomerKpi' - arguments: - - '@translator' - - '@prestashop.adapter.legacy.kpi_configuration' - - '@=service("prestashop.adapter.legacy.context").getAdminLink("AdminStats", true, {"ajax": 1, "action": "getKpi", "kpi": "orders_per_customer"})' - - prestashop.adapter.kpi.newsletter_registrations: - class: 'PrestaShop\PrestaShop\Adapter\Kpi\NewsletterRegistrationsKpi' - arguments: - - '@translator' - - '@prestashop.adapter.legacy.kpi_configuration' - - '@=service("prestashop.adapter.legacy.context").getAdminLink("AdminStats", true, {"ajax": 1, "action": "getKpi", "kpi": "newsletter_registrations"})' - - prestashop.adapter.kpi.shopping_cart_total_kpi: - class: 'PrestaShop\PrestaShop\Adapter\Kpi\ShoppingCartTotalKpi' - arguments: - - "@prestashop.core.localization.locale.context_locale" - prestashop.adapter.kpi.abandoned_cart: - class: 'PrestaShop\PrestaShop\Adapter\Kpi\AbandonedCartKpi' - - prestashop.adapter.kpi.average_order_value: - class: 'PrestaShop\PrestaShop\Adapter\Kpi\AverageOrderValueKpi' - - prestashop.adapter.kpi.conversion_rate: - class: 'PrestaShop\PrestaShop\Adapter\Kpi\ConversionRateKpi' - - prestashop.adapter.kpi.net_profit_per_visit: - class: 'PrestaShop\PrestaShop\Adapter\Kpi\NetProfitPerVisitKpi' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/language.yml b/src/PrestaShopBundle/Resources/config/services/adapter/language.yml deleted file mode 100644 index 76dad40a..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/language.yml +++ /dev/null @@ -1,64 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.language.pack.importer: - class: 'PrestaShop\PrestaShop\Adapter\Language\Pack\LanguagePackImporter' - arguments: - - '@prestashop.adapter.language.language_pack_installer' - - '@prestashop.adapter.data_provider.language' - - '@prestashop.core.cache.clearer.cache_clearer_chain' - - '@=service("prestashop.adapter.legacy.configuration").get("_PS_TRANSLATIONS_DIR_")' - - prestashop.adapter.language.language_flag_thumbnail_provider: - class: 'PrestaShop\PrestaShop\Adapter\Language\LanguageFlagThumbnailProvider' - arguments: - - '@prestashop.core.image.parser.image_tag_source_parser' - - "@=service('prestashop.adapter.legacy.context').getContext().shop.id" - - prestashop.adapter.language.rtl.installed_language_checker: - class: 'PrestaShop\PrestaShop\Adapter\Language\RTL\InstalledLanguageChecker' - arguments: - - '@prestashop.adapter.data_provider.language' - - prestashop.adapter.language.command_handler.add_language_handler: - class: 'PrestaShop\PrestaShop\Adapter\Language\CommandHandler\AddLanguageHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Language\Command\AddLanguageCommand' - - prestashop.adapter.language.command_handler.edit_language_handler: - class: 'PrestaShop\PrestaShop\Adapter\Language\CommandHandler\EditLanguageHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Language\Command\EditLanguageCommand' - - prestashop.adapter.language.query_handler.get_language_for_editing: - class: 'PrestaShop\PrestaShop\Adapter\Language\QueryHandler\GetLanguageForEditingHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Language\Query\GetLanguageForEditing' - - prestashop.adapter.language.command_handler.toggle_language_status_handler: - class: 'PrestaShop\PrestaShop\Adapter\Language\CommandHandler\ToggleLanguageStatusHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Language\Command\ToggleLanguageStatusCommand' - - prestashop.adapter.language.command_handler.bulk_toggle_languages_status_handler: - class: 'PrestaShop\PrestaShop\Adapter\Language\CommandHandler\BulkToggleLanguagesStatusHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Language\Command\BulkToggleLanguagesStatusCommand' - - prestashop.adapter.language.command_handler.bulk_delete_languages_handler: - class: 'PrestaShop\PrestaShop\Adapter\Language\CommandHandler\BulkDeleteLanguagesHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Language\Command\BulkDeleteLanguagesCommand' - - prestashop.adapter.language.command_handler.delete_language_handler: - class: 'PrestaShop\PrestaShop\Adapter\Language\CommandHandler\DeleteLanguageHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Language\Command\DeleteLanguageCommand' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/mail_template.yml b/src/PrestaShopBundle/Resources/config/services/adapter/mail_template.yml deleted file mode 100644 index 41c74658..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/mail_template.yml +++ /dev/null @@ -1,32 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.mail_template.twig_renderer: - class: 'PrestaShop\PrestaShop\Adapter\MailTemplate\MailTemplateTwigRenderer' - arguments: - - '@templating.engine.twig' - - '@prestashop.core.mail_template.variables_builder' - - '@prestashop.core.hook.dispatcher' - calls: - - method: 'addTransformation' - arguments: - - '@prestashop.core.mail_template.transformation.css_inline' - - method: 'addTransformation' - arguments: - - '@prestashop.core.mail_template.transformation.html_textify' - - prestashop.adapter.mail_template.partial_template_renderer: - class: 'PrestaShop\PrestaShop\Adapter\MailTemplate\MailPartialTemplateRenderer' - arguments: - - "@=service('prestashop.adapter.legacy.context').getSmarty()" - - prestashop.adapter.mail_template.preview_variables_builder: - class: 'PrestaShop\PrestaShop\Adapter\MailTemplate\MailPreviewVariablesBuilder' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.legacy.context' - - '@prestashop.adapter.data_provider.employee' - - "@prestashop.adapter.mail_template.partial_template_renderer" - - "@prestashop.core.localization.locale.context_locale" - - "@translator" diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/manufacturer.yml b/src/PrestaShopBundle/Resources/config/services/adapter/manufacturer.yml deleted file mode 100644 index f1cd93b2..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/manufacturer.yml +++ /dev/null @@ -1,56 +0,0 @@ -services: - _defaults: - public: true - - # Command handlers - - prestashop.adapter.manufacturer.manufacturer_logo_thumbnail_provider: - class: 'PrestaShop\PrestaShop\Adapter\Manufacturer\ManufacturerLogoThumbnailProvider' - arguments: - - '@prestashop.core.image.parser.image_tag_source_parser' - - prestashop.adapter.manufacturer.command_handler.toggle_manufacturer_status_handler: - class: 'PrestaShop\PrestaShop\Adapter\Manufacturer\CommandHandler\ToggleManufacturerStatusHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\ToggleManufacturerStatusCommand' } - - prestashop.adapter.manufacturer.command_handler.bulk_toggle_manufacturer_status_handler: - class: 'PrestaShop\PrestaShop\Adapter\Manufacturer\CommandHandler\BulkToggleManufacturerStatusHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\BulkToggleManufacturerStatusCommand' } - - prestashop.adapter.manufacturer.command_handler.delete_manufacturer_handler: - class: 'PrestaShop\PrestaShop\Adapter\Manufacturer\CommandHandler\DeleteManufacturerHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\DeleteManufacturerCommand' } - - prestashop.adapter.manufacturer.command_handler.bulk_delete_manufacturer_handler: - class: 'PrestaShop\PrestaShop\Adapter\Manufacturer\CommandHandler\BulkDeleteManufacturerHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\BulkDeleteManufacturerCommand' } - - prestashop.adapter.manufacturer.query_handler.get_manufacturer_for_editing: - class: 'PrestaShop\PrestaShop\Adapter\Manufacturer\QueryHandler\GetManufacturerForEditingHandler' - arguments: - - '@prestashop.core.image.parser.image_tag_source_parser' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Manufacturer\Query\GetManufacturerForEditing' - - prestashop.adapter.manufacturer.command_handler.edit_manufacturer_handler: - class: 'PrestaShop\PrestaShop\Adapter\Manufacturer\CommandHandler\EditManufacturerHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\EditManufacturerCommand' - - prestashop.adapter.manufacturer.command_handler.add_manufacturer_handler: - class: 'PrestaShop\PrestaShop\Adapter\Manufacturer\CommandHandler\AddManufacturerHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Manufacturer\Command\AddManufacturerCommand' - - prestashop.adapter.manufacturer.query_handler.get_manufacturer_for_viewing_handler: - class: 'PrestaShop\PrestaShop\Adapter\Manufacturer\QueryHandler\GetManufacturerForViewingHandler' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Manufacturer\Query\GetManufacturerForViewing diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/meta.yml b/src/PrestaShopBundle/Resources/config/services/adapter/meta.yml deleted file mode 100644 index c52de95b..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/meta.yml +++ /dev/null @@ -1,48 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.meta.meta_eraser: - class: 'PrestaShop\PrestaShop\Adapter\Meta\MetaEraser' - - prestashop.adapter.meta.data_provider: - class: 'PrestaShop\PrestaShop\Adapter\Meta\MetaDataProvider' - - # COMMAND HANDLERS - - prestashop.adapter.meta.command_handler.save_meta: - class: 'PrestaShop\PrestaShop\Adapter\Meta\CommandHandler\AddMetaHandler' - arguments: - - '@prestashop.core.hook.dispatcher' - - '@validator' - - '@=service("prestashop.adapter.legacy.configuration").get("PS_LANG_DEFAULT")' - - '@prestashop.adapter.meta.data_provider' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Meta\Command\AddMetaCommand' - - prestashop.adapter.meta.command_handler.edit_meta: - class: 'PrestaShop\PrestaShop\Adapter\Meta\CommandHandler\EditMetaHandler' - arguments: - - '@validator' - - '@prestashop.adapter.meta.data_provider' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Meta\Command\EditMetaCommand' - - # QUERY HANDLERS - - prestashop.adapter.meta.query_handler.get_meta_for_editing: - class: 'PrestaShop\PrestaShop\Adapter\Meta\QueryHandler\GetMetaForEditingHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Meta\Query\GetMetaForEditing' - - - prestashop.adapter.meta.query_handler.get_pages_for_layout_customization_handler: - class: 'PrestaShop\PrestaShop\Adapter\Meta\QueryHandler\GetPagesForLayoutCustomizationHandler' - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Meta\Query\GetPagesForLayoutCustomization' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/module.yml b/src/PrestaShopBundle/Resources/config/services/adapter/module.yml deleted file mode 100644 index b92ecdce..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/module.yml +++ /dev/null @@ -1,83 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.module.self_configurator: - class: PrestaShop\PrestaShop\Adapter\Module\Configuration\ModuleSelfConfigurator - arguments: - - "@prestashop.core.admin.module.repository" - - "@prestashop.adapter.legacy.configuration" - - "@doctrine.dbal.default_connection" - - "@filesystem" - - # MODULE TAB MANAGEMENT - prestashop.adapter.module.tab.register: - class: PrestaShop\PrestaShop\Adapter\Module\Tab\ModuleTabRegister - arguments: - - "@prestashop.core.admin.tab.repository" - - "@prestashop.core.admin.lang.repository" - - "@logger" - - "@translator" - - "@filesystem" - - "@=service('prestashop.adapter.legacy.context').getLanguages()" - - "@routing.loader.yml" - - prestashop.adapter.module.tab.unregister: - class: PrestaShop\PrestaShop\Adapter\Module\Tab\ModuleTabUnregister - arguments: - - "@prestashop.core.admin.tab.repository" - - "@prestashop.core.admin.lang.repository" - - "@logger" - - "@translator" - - prestashop.adapter.module.tab.eventsubscriber: - class: PrestaShop\PrestaShop\Adapter\Module\Tab\ModuleTabManagementSubscriber - arguments: - - "@prestashop.adapter.module.tab.register" - - "@prestashop.adapter.module.tab.unregister" - tags: - - { name: kernel.event_subscriber } - - prestashop.module.manager: - class: PrestaShop\PrestaShop\Core\Addon\Module\ModuleManager - arguments: - - "@prestashop.adapter.admin.data_provider.module" - - "@prestashop.adapter.data_provider.module" - - "@prestashop.core.module.updater" - - "@prestashop.core.admin.module.repository" - - "@prestashop.module.zip.manager" - - "@translator" - - "@event_dispatcher" - - "@prestashop.adapter.cache.clearer.symfony_cache_clearer" - - prestashop.module.zip.manager: - class: PrestaShop\PrestaShop\Adapter\Module\ModuleZipManager - arguments: - - "@filesystem" - - "@translator" - - "@event_dispatcher" - - prestashop.adapter.presenter.module: - class: PrestaShop\PrestaShop\Adapter\Presenter\Module\ModulePresenter - arguments: ["@=service('prestashop.adapter.legacy.context').getContext().currency", "@prestashop.adapter.formatter.price"] - - prestashop.adapter.module.data_provider.tab_module_list: - class: PrestaShop\PrestaShop\Adapter\Module\TabModuleListProvider - - prestashop.adapter.module.presenter.payment: - class: PrestaShop\PrestaShop\Adapter\Module\Presenter\PaymentModulesPresenter - arguments: - - '@prestashop.adapter.module.data_provider.tab_module_list' - - '@prestashop.adapter.data_provider.module' - - '@prestashop.adapter.presenter.module' - - '@prestashop.core.admin.module.repository' - - prestashop.adapter.module.payment_module_provider: - class: PrestaShop\PrestaShop\Adapter\Module\PaymentModuleListProvider - arguments: - - '@prestashop.core.admin.module.repository' - - '@prestashop.bundle.repository.module' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id' - - prestashop.adapter.legacy.module: - class: PrestaShop\PrestaShop\Adapter\Module\Module diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/news.yml b/src/PrestaShopBundle/Resources/config/services/adapter/news.yml deleted file mode 100644 index 2fb4af4e..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/news.yml +++ /dev/null @@ -1,31 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.news.circuit_breaker.settings: - class: PrestaShop\CircuitBreaker\FactorySettings - arguments: - - !php/const \PrestaShop\PrestaShop\Adapter\News\NewsDataProvider::CLOSED_ALLOWED_FAILURES - - !php/const \PrestaShop\PrestaShop\Adapter\News\NewsDataProvider::CLOSED_TIMEOUT_SECONDS - - !php/const \PrestaShop\PrestaShop\Adapter\News\NewsDataProvider::OPEN_THRESHOLD_SECONDS - calls: - - ['setStrippedFailures', [!php/const \PrestaShop\PrestaShop\Adapter\News\NewsDataProvider::OPEN_ALLOWED_FAILURES]] - - ['setStrippedTimeout', [!php/const \PrestaShop\PrestaShop\Adapter\News\NewsDataProvider::OPEN_TIMEOUT_SECONDS]] - - ['setStorage', ['@prestashop.core.circuit_breaker.storage']] - - ['setClientOptions', [{'method': 'GET', 'subscribers': ['@prestashop.core.circuit_breaker.guzzle.cache_subscriber']}]] - - prestashop.adapter.news.circuit_breaker: - class: 'PrestaShop\CircuitBreaker\Contract\CircuitBreakerInterface' - factory: ["@prestashop.core.circuit_breaker.advanced_factory", create] - arguments: - - "@prestashop.adapter.news.circuit_breaker.settings" - - prestashop.adapter.news.provider: - class: PrestaShop\PrestaShop\Adapter\News\NewsDataProvider - arguments: - - "@prestashop.adapter.news.circuit_breaker" - - "@prestashop.adapter.data_provider.country" - - "@prestashop.adapter.tools" - - "@prestashop.adapter.legacy.configuration" - - "@prestashop.adapter.validate" - - "@=service('prestashop.adapter.legacy.context').getContext().mode" diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/notification.yml b/src/PrestaShopBundle/Resources/config/services/adapter/notification.yml deleted file mode 100644 index 7c019e70..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/notification.yml +++ /dev/null @@ -1,16 +0,0 @@ -services: - _defaults: - public: true - - - prestashop.adapter.notification.command_handler.update_employee_notification_last_element_handler: - class: 'PrestaShop\PrestaShop\Adapter\Notification\CommandHandler\UpdateEmployeeNotificationLastElementHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Notification\Command\UpdateEmployeeNotificationLastElementCommand' - - prestashop.adapter.notification.query_handler.get_notification_last_elements_handler: - class: 'PrestaShop\PrestaShop\Adapter\Notification\QueryHandler\GetNotificationLastElementsHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Notification\Query\GetNotificationLastElements' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/order.yml b/src/PrestaShopBundle/Resources/config/services/adapter/order.yml deleted file mode 100644 index b268beae..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/order.yml +++ /dev/null @@ -1,275 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.order.command_handler.duplicate_order_cart_handler: - class: 'PrestaShop\PrestaShop\Adapter\Order\CommandHandler\DuplicateOrderCartHandler' - arguments: - - '@prestashop.adapter.context_state_manager' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Order\Command\DuplicateOrderCartCommand' - - prestashop.adapter.order.command_handler.add_order_from_back_office_handler: - class: 'PrestaShop\PrestaShop\Adapter\Order\CommandHandler\AddOrderFromBackOfficeHandler' - arguments: - - '@prestashop.adapter.context_state_manager' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Order\Command\AddOrderFromBackOfficeCommand' - - prestashop.adapter.order.command_handler.add_product_to_order_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\AddProductToOrderHandler - arguments: - - '@translator' - - '@prestashop.adapter.context_state_manager' - - '@prestashop.adapter.order.amount.updater' - - '@prestashop.adapter.order.product_quantity.updater' - - '@prestashop.adapter.order.order_detail.updater' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Product\Command\AddProductToOrderCommand - - prestashop.adapter.order.command_handler.update_order_status_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\UpdateOrderStatusHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Command\UpdateOrderStatusCommand - - prestashop.adapter.order.command_handler.update_product_in_order_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\UpdateProductInOrderHandler - arguments: - - '@prestashop.adapter.order.product_quantity.updater' - - '@prestashop.adapter.order.order_detail.updater' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Product\Command\UpdateProductInOrderCommand - - prestashop.adapter.order.command_handler.change_order_delivery_address_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\ChangeOrderDeliveryAddressHandler - arguments: - - '@prestashop.adapter.order.amount.updater' - - '@prestashop.adapter.order.order_detail.updater' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Command\ChangeOrderDeliveryAddressCommand - - prestashop.adapter.order.command_handler.change_order_invoice_address_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\ChangeOrderInvoiceAddressHandler - arguments: - - '@prestashop.adapter.order.amount.updater' - - '@prestashop.adapter.order.order_detail.updater' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Command\ChangeOrderInvoiceAddressCommand - - prestashop.adapter.order.command_handler.change_order_currency_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\ChangeOrderCurrencyHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Command\ChangeOrderCurrencyCommand - - prestashop.adapter.order.command_handler.add_payment_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\AddPaymentHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Payment\Command\AddPaymentCommand - - prestashop.adapter.order.command_handler.generate_invoice_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\GenerateInvoiceHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Invoice\Command\GenerateInvoiceCommand - - prestashop.adapter.order.command_handler.update_order_shipping_details_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\UpdateOrderShippingDetailsHandler - arguments: - - '@prestashop.adapter.order.amount.updater' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Command\UpdateOrderShippingDetailsCommand - - prestashop.adapter.order.command_handler.delete_cart_rule_from_order_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\DeleteCartRuleFromOrderHandler - arguments: - - '@prestashop.adapter.order.amount.updater' - - '@prestashop.adapter.order.product_quantity.updater' - - '@prestashop.adapter.context_state_manager' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Command\DeleteCartRuleFromOrderCommand - - prestashop.adapter.order.command_handler.add_cart_rule_to_order_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\AddCartRuleToOrderHandler - arguments: - - '@prestashop.adapter.order.amount.updater' - - '@prestashop.adapter.context_state_manager' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Command\AddCartRuleToOrderCommand - - prestashop.adapter.order.command_handler.update_invoice_note_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\UpdateInvoiceNoteHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Invoice\Command\UpdateInvoiceNoteCommand - - prestashop.adapter.order.command_handler.issue_partial_refund_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\IssuePartialRefundHandler - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.order.refund.order_refund_calculator' - - '@prestashop.adapter.order.refund.order_slip_creator' - - '@prestashop.adapter.order.refund.voucher_generator' - - '@prestashop.adapter.order.refund.updater' - - '@prestashop.adapter.context_state_manager' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Command\IssuePartialRefundCommand - - prestashop.adapter.order.command_handler.issue_standard_refund_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\IssueStandardRefundHandler - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.order.refund.order_refund_calculator' - - '@prestashop.adapter.order.refund.order_slip_creator' - - '@prestashop.adapter.order.refund.voucher_generator' - - '@prestashop.adapter.order.refund.updater' - - '@prestashop.adapter.context_state_manager' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Command\IssueStandardRefundCommand - - prestashop.adapter.order.command_handler.issue_return_product_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\IssueReturnProductHandler - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.order.refund.order_refund_calculator' - - '@prestashop.adapter.order.refund.order_slip_creator' - - '@prestashop.adapter.order.refund.voucher_generator' - - '@prestashop.adapter.order.refund.updater' - - '@prestashop.adapter.context_state_manager' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Command\IssueReturnProductCommand - - prestashop.adapter.order.refund.order_refund_calculator: - class: PrestaShop\PrestaShop\Adapter\Order\Refund\OrderRefundCalculator - - prestashop.adapter.order.refund.order_slip_creator: - class: PrestaShop\PrestaShop\Adapter\Order\Refund\OrderSlipCreator - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@translator' - - prestashop.adapter.order.refund.voucher_generator: - class: PrestaShop\PrestaShop\Adapter\Order\Refund\VoucherGenerator - arguments: - - '@prestashop.core.localization.locale.context_locale' - - '@translator' - - prestashop.adapter.order.refund.updater: - class: PrestaShop\PrestaShop\Adapter\Order\Refund\OrderRefundUpdater - - prestashop.adapter.order.product.remover: - class: PrestaShop\PrestaShop\Adapter\Order\Refund\OrderProductRemover - arguments: - - "@logger" - - "@translator" - - prestashop.adapter.order.command_handler.delete_product_from_order_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\DeleteProductFromOrderHandler - arguments: - - '@prestashop.adapter.context_state_manager' - - '@prestashop.adapter.order.amount.updater' - - '@prestashop.adapter.order.product_quantity.updater' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Product\Command\DeleteProductFromOrderCommand - - prestashop.adapter.order.command_handler.bulk_change_order_status_handler: - class: 'PrestaShop\PrestaShop\Adapter\Order\CommandHandler\BulkChangeOrderStatusHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Order\Command\BulkChangeOrderStatusCommand' - - prestashop.adapter.order.query_handler.get_order_for_viewing_handler: - class: PrestaShop\PrestaShop\Adapter\Order\QueryHandler\GetOrderForViewingHandler - arguments: - - '@translator' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - - "@prestashop.core.localization.locale.context_locale" - - '@=service("prestashop.adapter.legacy.context").getContext()' - - '@prestashop.adapter.data_provider.customer' - - '@prestashop.adapter.order.query_handler.get_order_products_for_viewing_handler' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Query\GetOrderForViewing - - prestashop.adapter.order.query_handler.get_order_products_for_viewing_handler: - class: PrestaShop\PrestaShop\Adapter\Order\QueryHandler\GetOrderProductsForViewingHandler - arguments: - - '@prestashop.core.image.parser.image_tag_source_parser' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - - "@prestashop.core.localization.locale.context_locale" - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Query\GetOrderProductsForViewing - - - prestashop.adapter.order.command_handler.resend_order_email_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\ResendOrderEmailHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Command\ResendOrderEmailCommand - - prestashop.adapter.order.query_handler.get_order_preview_handler: - class: 'PrestaShop\PrestaShop\Adapter\Order\QueryHandler\GetOrderPreviewHandler' - arguments: - - '@prestashop.core.localization.locale.repository' - - "@=service('prestashop.adapter.legacy.context').getContext().language.getLocale()" - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Order\Query\GetOrderPreview' - - prestashop.adapter.order.command_handler.send_process_order_email_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\SendProcessOrderEmailHandler - arguments: - - '@translator' - - '@=service("prestashop.adapter.legacy.context").getContext().link' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Command\SendProcessOrderEmailCommand - - prestashop.adapter.order.command_handler.cancel_order_product_handler: - class: PrestaShop\PrestaShop\Adapter\Order\CommandHandler\CancelOrderProductHandler - arguments: - - '@prestashop.adapter.order.product_quantity.updater' - - '@logger' - - '@translator' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Order\Command\CancelOrderProductCommand - - prestashop.adapter.order.order_sibling_provider: - class: PrestaShop\PrestaShop\Adapter\Order\OrderSiblingProvider - - prestashop.adapter.order.amount.updater: - class: PrestaShop\PrestaShop\Adapter\Order\OrderAmountUpdater - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.context_state_manager' - - '@prestashop.adapter.order.order_detail.updater' - - prestashop.adapter.order.product_quantity.updater: - class: PrestaShop\PrestaShop\Adapter\Order\OrderProductQuantityUpdater - arguments: - - '@prestashop.adapter.order.amount.updater' - - '@prestashop.adapter.order.product.remover' - - '@prestashop.adapter.context_state_manager' - - prestashop.adapter.order.order_detail.updater: - class: PrestaShop\PrestaShop\Adapter\Order\OrderDetailUpdater - arguments: - - '@prestashop.adapter.context_state_manager' - - '@prestashop.adapter.legacy.configuration' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/order_message.yml b/src/PrestaShopBundle/Resources/config/services/adapter/order_message.yml deleted file mode 100644 index 8a958836..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/order_message.yml +++ /dev/null @@ -1,38 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.order_message.command_handler.add_order_message_handler: - class: PrestaShop\PrestaShop\Adapter\OrderMessage\CommandHandler\AddOrderMessageHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command\AddOrderMessageCommand - - prestashop.adapter.order_message.command_handler.edit_order_message_handler: - class: PrestaShop\PrestaShop\Adapter\OrderMessage\CommandHandler\EditOrderMessageHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command\EditOrderMessageCommand - - prestashop.adapter.order_message.query_handler.get_order_message_for_editing_handler: - class: PrestaShop\PrestaShop\Adapter\OrderMessage\QueryHandler\GetOrderMessageForEditingHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\OrderMessage\Query\GetOrderMessageForEditing - - prestashop.adapter.order_message.command_handler.delete_order_message_handler: - class: PrestaShop\PrestaShop\Adapter\OrderMessage\CommandHandler\DeleteOrderMessageHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command\DeleteOrderMessageCommand - - prestashop.adapter.order_message.command_handler.bulk_delete_order_message_handler: - class: PrestaShop\PrestaShop\Adapter\OrderMessage\CommandHandler\BulkDeleteOrderMessageHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\OrderMessage\Command\BulkDeleteOrderMessageCommand - - prestashop.adapter.order_message.order_message_provider: - class: 'PrestaShop\PrestaShop\Adapter\OrderMessage\OrderMessageProvider' - arguments: - - '@=service("prestashop.adapter.legacy.context").getLanguage().id' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/pdf.yml b/src/PrestaShopBundle/Resources/config/services/adapter/pdf.yml deleted file mode 100644 index fa40bfbc..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/pdf.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: pdf/*.yml } diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/pdf/generator.yml b/src/PrestaShopBundle/Resources/config/services/adapter/pdf/generator.yml deleted file mode 100644 index 01238a93..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/pdf/generator.yml +++ /dev/null @@ -1,32 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.pdf.generator.invoice: - class: PrestaShop\PrestaShop\Adapter\PDF\PDFGenerator - arguments: - - "@=service('prestashop.adapter.legacy.context').getSmarty()" - - '@prestashop.adapter.pdf.type_provider.invoice' - - prestashop.adapter.pdf.order_invoice_pdf_generator: - class: PrestaShop\PrestaShop\Adapter\PDF\OrderInvoicePdfGenerator - arguments: - - '@translator' - - prestashop.adapter.pdf.delivery_slip_pdf_generator: - class: PrestaShop\PrestaShop\Adapter\PDF\DeliverySlipPdfGenerator - arguments: - - '@translator' - - prestashop.adapter.pdf.generator.credit_slip: - class: PrestaShop\PrestaShop\Adapter\PDF\PDFGenerator - arguments: - - "@=service('prestashop.adapter.legacy.context').getSmarty()" - - '@prestashop.adapter.pdf.type_provider.credit_slip' - - prestashop.adapter.pdf.credit_slip_pdf_generator: - class: PrestaShop\PrestaShop\Adapter\PDF\CreditSlipPdfGenerator - arguments: - - '@translator' - - '%database_prefix%' - - '@doctrine.dbal.default_connection' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/pdf/template_type_provider.yml b/src/PrestaShopBundle/Resources/config/services/adapter/pdf/template_type_provider.yml deleted file mode 100644 index 27265bb3..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/pdf/template_type_provider.yml +++ /dev/null @@ -1,9 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.pdf.type_provider.invoice: - class: PrestaShop\PrestaShop\Adapter\Invoice\InvoiceTemplateTypeProvider - - prestashop.adapter.pdf.type_provider.credit_slip: - class: PrestaShop\PrestaShop\Adapter\CreditSlip\CreditSlipTemplateTypeProvider diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/prestatrust.yml b/src/PrestaShopBundle/Resources/config/services/adapter/prestatrust.yml deleted file mode 100644 index 815ed5d4..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/prestatrust.yml +++ /dev/null @@ -1,19 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.module.prestatrust.checker: - class: PrestaShop\PrestaShop\Adapter\Module\PrestaTrust\PrestaTrustChecker - arguments: - - "@doctrine.cache.provider" - - "@prestashop.addons.client_api" - - "@translator" - - prestashop.adapter.module.prestatrust.eventsubscriber: - class: PrestaShop\PrestaShop\Adapter\Module\PrestaTrust\ModuleEventSubscriber - arguments: - - "@prestashop.adapter.module.prestatrust.checker" - calls: - - [ setEnabled, ['%prestashop.addons.prestatrust.enabled%']] - tags: - - { name: kernel.event_subscriber } diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/product.yml b/src/PrestaShopBundle/Resources/config/services/adapter/product.yml deleted file mode 100644 index 38d04692..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/product.yml +++ /dev/null @@ -1,67 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.admin.data_provider.product: - class: PrestaShop\PrestaShop\Adapter\Product\AdminProductDataProvider - decorates: prestashop.core.admin.data_provider.product_interface - arguments: - - "@doctrine.orm.entity_manager" - - "@prestashop.adapter.image_manager" - - "@prestashop.static_cache.adapter" - public: false - - prestashop.adapter.admin.data_updater.product: - class: PrestaShop\PrestaShop\Adapter\Product\AdminProductDataUpdater - decorates: prestashop.core.admin.data_updater.product_interface - public: false - arguments: - - "@prestashop.core.hook.dispatcher" - - "@prestashop.static_cache.adapter" - - prestashop.adapter.admin.wrapper.product: - class: PrestaShop\PrestaShop\Adapter\Product\AdminProductWrapper - arguments: - - "@translator" - - "@=service('prestashop.adapter.legacy.context').getContext().employee.getAssociatedShops()" - - "@prestashop.core.localization.locale.context_locale" - - "@prestashop.utils.float_parser" - - prestashop.adapter.admin.controller.attribute_generator: - class: PrestaShop\PrestaShop\Adapter\Attribute\AdminAttributeGeneratorControllerWrapper - - prestashop.adapter.product.filter_categories_request_purifier: - class: 'PrestaShop\PrestaShop\Adapter\Product\FilterCategoriesRequestPurifier' - - prestashop.adapter.product.list_parameters_updater: - class: 'PrestaShop\PrestaShop\Adapter\Product\ListParametersUpdater' - - prestashop.adapter.product.command_handler.add_category_to_product_handler: - class: PrestaShop\PrestaShop\Adapter\Product\CommandHandler\AssignProductToCategoryHandler - public: true - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Product\Command\AssignProductToCategoryCommand } - - prestashop.adapter.product.command_handler.update_product_status_handler: - class: PrestaShop\PrestaShop\Adapter\Product\CommandHandler\UpdateProductStatusCommandHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Product\Command\UpdateProductStatusCommand - - prestashop.adapter.product.query_handler.search_products: - class: PrestaShop\PrestaShop\Adapter\Product\QueryHandler\SearchProductsHandler - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - - '@prestashop.core.localization.locale.context_locale' - - '@prestashop.adapter.tools' - - '@prestashop.adapter.data_provider.currency' - - '@prestashop.adapter.context_state_manager' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Product\Query\SearchProducts - - prestashop.adapter.product.command_handler.get_product_is_enabled_handler: - class: PrestaShop\PrestaShop\Adapter\Product\QueryHandler\GetProductIsEnabledHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\Product\Query\GetProductIsEnabled diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/profile.yml b/src/PrestaShopBundle/Resources/config/services/adapter/profile.yml deleted file mode 100644 index b8cde9ca..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/profile.yml +++ /dev/null @@ -1,37 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.profile.command_handler.delete_profile: - class: 'PrestaShop\PrestaShop\Adapter\Profile\CommandHandler\DeleteProfileHandler' - arguments: - - '@=service("prestashop.adapter.legacy.configuration").get("_PS_ADMIN_PROFILE_")' - - '@prestashop.adapter.data_provider.employee' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Profile\Command\DeleteProfileCommand' } - - prestashop.adapter.profile.command_handler.bulk_delete_profile: - class: 'PrestaShop\PrestaShop\Adapter\Profile\CommandHandler\BulkDeleteProfileHandler' - arguments: - - '@=service("prestashop.adapter.legacy.configuration").get("_PS_ADMIN_PROFILE_")' - - '@prestashop.adapter.data_provider.employee' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Profile\Command\BulkDeleteProfileCommand' } - - prestashop.adapter.profile.command_handler.add_profile_handler: - class: 'PrestaShop\PrestaShop\Adapter\Profile\CommandHandler\AddProfileHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Profile\Command\AddProfileCommand' - - prestashop.adapter.profile.command_handler.edit_profile_handler: - class: 'PrestaShop\PrestaShop\Adapter\Profile\CommandHandler\EditProfileHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Profile\Command\EditProfileCommand' - - prestashop.adapter.profile.query_handler.get_profile_for_editing_handler: - class: 'PrestaShop\PrestaShop\Adapter\Profile\QueryHandler\GetProfileForEditingHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Profile\Query\GetProfileForEditing' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/routes.yml b/src/PrestaShopBundle/Resources/config/services/adapter/routes.yml deleted file mode 100644 index 2fc8e316..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/routes.yml +++ /dev/null @@ -1,6 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.routes.route_validator: - class: 'PrestaShop\PrestaShop\Adapter\Routes\RouteValidator' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/services.yml b/src/PrestaShopBundle/Resources/config/services/adapter/services.yml deleted file mode 100644 index b93138f6..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/services.yml +++ /dev/null @@ -1,134 +0,0 @@ -imports: - - { resource: ./common.yml } - -services: - _defaults: - public: true - - prestashop.adapter.hosting_information: - class: 'PrestaShop\PrestaShop\Adapter\Hosting\HostingInformation' - - prestashop.adapter.shop_information: - class: 'PrestaShop\PrestaShop\Adapter\Shop\ShopInformation' - arguments: ['@prestashop.adapter.legacy.context'] - - prestashop.adapter.mailing_information: - class: 'PrestaShop\PrestaShop\Adapter\Mail\MailingInformation' - - prestashop.adapter.check_requirements: - class: 'PrestaShop\PrestaShop\Adapter\Requirement\CheckRequirements' - arguments: ['@translator'] - - prestashop.adapter.system_information: - class: 'PrestaShop\PrestaShop\Adapter\System\SystemInformation' - arguments: - - '@prestashop.adapter.hosting_information' - - '@prestashop.adapter.mailing_information' - - '@prestashop.adapter.shop_information' - - prestashop.adapter.check_missing_files: - class: 'PrestaShop\PrestaShop\Adapter\Requirement\CheckMissingOrUpdatedFiles' - - prestashop.adapter.cache_clearer: - class: 'PrestaShop\PrestaShop\Adapter\Cache\CacheClearer' - arguments: - - '@prestashop.core.cache.clearer.cache_clearer_chain' - - '@prestashop.adapter.cache.clearer.symfony_cache_clearer' - - '@prestashop.adapter.cache.clearer.media_cache_clearer' - - '@prestashop.adapter.cache.clearer.smarty_cache_clearer' - - prestashop.adapter.debug_mode: - class: 'PrestaShop\PrestaShop\Adapter\Debug\DebugMode' - - prestashop.adapter.database: - class: 'PrestaShop\PrestaShop\Adapter\Database' - - prestashop.adapter.memcache_server.manager: - class: 'PrestaShop\PrestaShop\Adapter\Cache\MemcacheServerManager' - arguments: ['@database_connection', '%database_prefix%'] - - prestashop.adapter.php_parameters: - class: 'PrestaShop\PrestaShop\Adapter\Configuration\PhpParameters' - arguments: ['%kernel.root_dir%/config/parameters.php'] - - prestashop.adapter.legacy.kpi_configuration: - class: PrestaShop\PrestaShop\Adapter\Configuration\KpiConfiguration - - prestashop.adapter.legacy.logger: - class: PrestaShop\PrestaShop\Adapter\LegacyLogger - - prestashop.adapter.legacy.hook: - class: PrestaShop\PrestaShop\Adapter\Hook\HookInformationProvider - - # SSL middleware - prestashop.adapter.middleware.ssl: - class: PrestaShop\PrestaShop\Adapter\Security\SslMiddleware - tags: - - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest } - - # Legacy Hooks registrator - prestashop.adapter.legacy.hook.subscriber: - class: PrestaShop\PrestaShop\Adapter\LegacyHookSubscriber - - prestashop.adapter.legacy.block.helper.subscriber: - class: PrestaShop\PrestaShop\Adapter\Admin\LegacyBlockHelperSubscriber - - prestashop.adapter.stock_manager: - class: PrestaShop\PrestaShop\Adapter\StockManager - decorates: prestashop.core.data_provider.stock_interface - public: false - - prestashop.adapter.formatter.price: - class: PrestaShop\PrestaShop\Adapter\Product\PriceFormatter - - # Other adapters - prestashop.adapter.shop.context: - class: PrestaShop\PrestaShop\Adapter\Shop\Context - - prestashop.adapter.image_manager: - class: PrestaShop\PrestaShop\Adapter\ImageManager - arguments: ["@prestashop.adapter.legacy.context"] - - prestashop.core.module.updater: - class: PrestaShop\PrestaShop\Adapter\Module\ModuleDataUpdater - arguments: - - "@prestashop.core.admin.data_provider.addons_interface" - - "@prestashop.adapter.admin.data_provider.module" - - prestashop.adapter.admin.model.product: - class: PrestaShopBundle\Model\Product\AdminModelAdapter - arguments: - - "@prestashop.adapter.legacy.context" - - "@prestashop.adapter.admin.wrapper.product" - - "@prestashop.adapter.tools" - - "@prestashop.adapter.data_provider.product" - - "@prestashop.adapter.data_provider.supplier" - - "@prestashop.adapter.data_provider.warehouse" - - "@prestashop.adapter.data_provider.feature" - - "@prestashop.adapter.data_provider.pack" - - "@prestashop.adapter.shop.context" - - "@prestashop.adapter.data_provider.tax" - - "@router" - - "@prestashop.utils.float_parser" - - prestashop.adapter.translation_route_finder: - class: PrestaShop\PrestaShop\Adapter\Translations\TranslationRouteFinder - arguments: - - '@prestashop.service.translation' - - '@=service("prestashop.adapter.legacy.context").getContext().link' - - '@prestashop.core.admin.module.repository' - - prestashop.adapter.shop.shop_url: - class: 'PrestaShop\PrestaShop\Adapter\Shop\ShopUrlDataProvider' - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id' - - prestashop.adapter.file.htaccess_file_generator: - class: 'PrestaShop\PrestaShop\Adapter\File\HtaccessFileGenerator' - arguments: - - '@prestashop.adapter.cache_clearer' - - '@prestashop.adapter.tools' - - "@=service('prestashop.adapter.legacy.configuration').getBoolean('PS_HTACCESS_DISABLE_MULTIVIEWS')" - - prestashop.adapter.file.robots_text_file_generator: - class: 'PrestaShop\PrestaShop\Adapter\File\RobotsTextFileGenerator' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/shop.yml b/src/PrestaShopBundle/Resources/config/services/adapter/shop.yml deleted file mode 100644 index 22dfc992..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/shop.yml +++ /dev/null @@ -1,36 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.shop.command_handler.upload_logos_handler: - class: 'PrestaShop\PrestaShop\Adapter\Shop\CommandHandler\UploadLogosHandler' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.core.shop.logo_uploader' - - '@prestashop.core.hook.dispatcher' - tags: - - { name: tactician.handler, command: 'PrestaShop\PrestaShop\Core\Domain\Shop\Command\UploadLogosCommand' } - - prestashop.adapter.shop.url.base_url_provider: - class: 'PrestaShop\PrestaShop\Adapter\Shop\Url\BaseUrlProvider' - arguments: - - "@=service('prestashop.adapter.legacy.context').getContext().link" - - prestashop.adapter.shop.url.category_provider: - class: 'PrestaShop\PrestaShop\Adapter\Shop\Url\CategoryProvider' - arguments: - - "@=service('prestashop.adapter.legacy.context').getContext().link" - - prestashop.adapter.shop.url.cms_provider: - class: 'PrestaShop\PrestaShop\Adapter\Shop\Url\CmsProvider' - arguments: - - "@=service('prestashop.adapter.legacy.context').getContext().link" - - prestashop.adapter.shop.query_handler.get_logos_paths_handler: - class: 'PrestaShop\PrestaShop\Adapter\Shop\QueryHandler\GetLogosPathsHandler' - arguments: - - '@=service("prestashop.adapter.legacy.configuration").get("_PS_IMG_")' - - '@=service("prestashop.adapter.legacy.configuration").get("_PS_IMG_DIR_")' - tags: - - name: 'tactician.handler' - command: PrestaShop\PrestaShop\Core\Domain\Shop\Query\GetLogosPaths diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/shop_feature.yml b/src/PrestaShopBundle/Resources/config/services/adapter/shop_feature.yml deleted file mode 100644 index 596b0c2e..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/shop_feature.yml +++ /dev/null @@ -1,25 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.combination_feature: - class: 'PrestaShop\PrestaShop\Adapter\Feature\CombinationFeature' - arguments: ['@prestashop.adapter.legacy.configuration'] - - prestashop.adapter.feature.feature: - class: 'PrestaShop\PrestaShop\Adapter\Feature\FeatureFeature' - arguments: ['@prestashop.adapter.legacy.configuration'] - - prestashop.adapter.group.feature: - class: 'PrestaShop\PrestaShop\Adapter\Feature\GroupFeature' - arguments: ['@prestashop.adapter.legacy.configuration'] - - prestashop.adapter.multistore_feature: - class: 'PrestaShop\PrestaShop\Adapter\Feature\MultistoreFeature' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.adapter.feature.multistore: - class: 'PrestaShop\PrestaShop\Adapter\Feature\MultistoreFeature' - arguments: - - '@prestashop.adapter.legacy.configuration' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/specific_price.yml b/src/PrestaShopBundle/Resources/config/services/adapter/specific_price.yml deleted file mode 100644 index 93e7d195..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/specific_price.yml +++ /dev/null @@ -1,15 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.specific_price.command_handler.add_specific_price: - class: PrestaShop\PrestaShop\Adapter\SpecificPrice\CommandHandler\AddSpecificPriceHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Command\AddSpecificPriceCommand - - prestashop.adapter.specific_price.command_handler.delete_specific_price_by_cart_product: - class: PrestaShop\PrestaShop\Adapter\SpecificPrice\CommandHandler\DeleteSpecificPriceByCartProductHandler - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\SpecificPrice\Command\DeleteSpecificPriceByCartProductCommand diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/sql_manager.yml b/src/PrestaShopBundle/Resources/config/services/adapter/sql_manager.yml deleted file mode 100644 index 544f2652..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/sql_manager.yml +++ /dev/null @@ -1,59 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.sql_manager.sql_query_validator: - class: 'PrestaShop\PrestaShop\Adapter\SqlManager\SqlQueryValidator' - - prestashop.adapter.sql_manager.request_sql_form_data_validator: - class: 'PrestaShop\PrestaShop\Adapter\SqlManager\SqlRequestFormDataValidator' - arguments: - - '@prestashop.adapter.sql_manager.sql_query_validator' - - # Command handlers - prestashop.adapter.sql_manager.command_handler.add_request_sql: - class: 'PrestaShop\PrestaShop\Adapter\SqlManager\CommandHandler\AddSqlRequestHandler' - arguments: - - '@prestashop.adapter.sql_manager.sql_query_validator' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\AddSqlRequestCommand' } - - prestashop.adapter.sql_manager.command_handler.edit_request_sql: - class: 'PrestaShop\PrestaShop\Adapter\SqlManager\CommandHandler\EditSqlRequestHandler' - arguments: - - '@prestashop.adapter.sql_manager.sql_query_validator' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\EditSqlRequestCommand' } - - prestashop.adapter.sql_manager.command_handler.delete_request_sql: - class: 'PrestaShop\PrestaShop\Adapter\SqlManager\CommandHandler\DeleteSqlRequestHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\DeleteSqlRequestCommand' } - - prestashop.adapter.sql_manager.command_handler.bulk_delete_request_sql: - class: 'PrestaShop\PrestaShop\Adapter\SqlManager\CommandHandler\BulkDeleteSqlRequestHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\BulkDeleteSqlRequestCommand' } - - # Query handlers - prestashop.adapter.sql_manager.query_handler.get_request_sql_for_editing: - class: 'PrestaShop\PrestaShop\Adapter\SqlManager\QueryHandler\GetSqlRequestForEditingHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetSqlRequestForEditing' } - - prestashop.adapter.sql_manager.query_handler.get_request_sql_execution_result: - class: 'PrestaShop\PrestaShop\Adapter\SqlManager\QueryHandler\GetSqlRequestExecutionResultHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetSqlRequestExecutionResult' } - - prestashop.adapter.sql_manager.query_handler.get_database_tables_list: - class: 'PrestaShop\PrestaShop\Adapter\SqlManager\QueryHandler\GetDatabaseTablesListHandler' - arguments: - - '@prestashop.adapter.legacy.configuration' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetDatabaseTablesList' } - - prestashop.adapter.sql_manager.query_handler.get_database_table_fields_list: - class: 'PrestaShop\PrestaShop\Adapter\SqlManager\QueryHandler\GetDatabaseTableFieldsListHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetDatabaseTableFieldsList' } diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/supplier.yml b/src/PrestaShopBundle/Resources/config/services/adapter/supplier.yml deleted file mode 100644 index 8c903afd..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/supplier.yml +++ /dev/null @@ -1,89 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.supplier.provider.supplier_logo: - class: 'PrestaShop\PrestaShop\Adapter\Supplier\SupplierLogoThumbnailProvider' - arguments: - - '@prestashop.core.image.parser.image_tag_source_parser' - - '@prestashop.adapter.image_manager' - - prestashop.adapter.supplier.provider.supplier_address: - class: 'PrestaShop\PrestaShop\Adapter\Supplier\SupplierAddressProvider' - - prestashop.adapter.supplier.supplier_order_validator: - class: 'PrestaShop\PrestaShop\Adapter\Supplier\SupplierOrderValidator' - -# Command handlers - - prestashop.adapter.supplier.command_handler.abstract_delete_supplier_handler: - class: 'PrestaShop\PrestaShop\Adapter\Supplier\CommandHandler\AbstractDeleteSupplierHandler' - abstract: true - arguments: - - '@prestashop.adapter.supplier.supplier_order_validator' - - '@prestashop.adapter.supplier.provider.supplier_address' - - '%database_prefix%' - public: false - - prestashop.adapter.supplier.command_handler.toggle_supplier_status_handler: - class: 'PrestaShop\PrestaShop\Adapter\Supplier\CommandHandler\ToggleSupplierStatusHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Supplier\Command\ToggleSupplierStatusCommand' - - prestashop.adapter.supplier.command_handler.delete_supplier_handler: - class: 'PrestaShop\PrestaShop\Adapter\Supplier\CommandHandler\DeleteSupplierHandler' - parent: 'prestashop.adapter.supplier.command_handler.abstract_delete_supplier_handler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Supplier\Command\DeleteSupplierCommand' - public: true - - prestashop.adapter.supplier.command_handler.bulk_delete_supplier_handler: - class: 'PrestaShop\PrestaShop\Adapter\Supplier\CommandHandler\BulkDeleteSupplierHandler' - parent: 'prestashop.adapter.supplier.command_handler.abstract_delete_supplier_handler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Supplier\Command\BulkDeleteSupplierCommand' - public: true - - prestashop.adapter.supplier.command_handler.bulk_disable_supplier_handler: - class: 'PrestaShop\PrestaShop\Adapter\Supplier\CommandHandler\BulkDisableSupplierHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Supplier\Command\BulkDisableSupplierCommand' - - prestashop.adapter.supplier.command_handler.bulk_enable_supplier_handler: - class: 'PrestaShop\PrestaShop\Adapter\Supplier\CommandHandler\BulkEnableSupplierHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Supplier\Command\BulkEnableSupplierCommand' - - prestashop.adapter.supplier.query_handler.get_supplier_for_viewing_handler: - class: 'PrestaShop\PrestaShop\Adapter\Supplier\QueryHandler\GetSupplierForViewingHandler' - arguments: - - '@prestashop.core.localization.locale.context_locale' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Supplier\Query\GetSupplierForViewing' - - prestashop.adapter.supplier.command_handler.add_supplier_handler: - class: 'PrestaShop\PrestaShop\Adapter\Supplier\CommandHandler\AddSupplierHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Supplier\Command\AddSupplierCommand' - - prestashop.adapter.supplier.query_handler.get_supplier_for_editing: - class: 'PrestaShop\PrestaShop\Adapter\Supplier\QueryHandler\GetSupplierForEditingHandler' - arguments: - - '@prestashop.core.image.parser.image_tag_source_parser' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Supplier\Query\GetSupplierForEditing' - - prestashop.adapter.supplier.command_handler.edit_supplier_handler: - class: 'PrestaShop\PrestaShop\Adapter\Supplier\CommandHandler\EditSupplierHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\Supplier\Command\EditSupplierCommand' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/tax.yml b/src/PrestaShopBundle/Resources/config/services/adapter/tax.yml deleted file mode 100644 index fcddc136..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/tax.yml +++ /dev/null @@ -1,45 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.tax.ecotax.ecotax_resetter: - class: 'PrestaShop\PrestaShop\Adapter\Tax\Ecotax\ProductEcotaxResetter' - - # Command handlers - prestashop.adapter.tax.command_handler.delete_tax_handler: - class: 'PrestaShop\PrestaShop\Adapter\Tax\CommandHandler\DeleteTaxHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Tax\Command\DeleteTaxCommand' } - - prestashop.adapter.tax.command_handler.toggle_tax_status_handler: - class: 'PrestaShop\PrestaShop\Adapter\Tax\CommandHandler\ToggleTaxStatusHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Tax\Command\ToggleTaxStatusCommand' } - - prestashop.adapter.tax.command_handler.bulk_toggle_tax_status_handler: - class: 'PrestaShop\PrestaShop\Adapter\Tax\CommandHandler\BulkToggleTaxStatusHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Tax\Command\BulkToggleTaxStatusCommand' } - - prestashop.adapter.tax.command_handler.bulk_delete_tax_handler: - class: 'PrestaShop\PrestaShop\Adapter\Tax\CommandHandler\BulkDeleteTaxHandler' - tags: - - { name: 'tactician.handler', command: 'PrestaShop\PrestaShop\Core\Domain\Tax\Command\BulkDeleteTaxCommand' } - - prestashop.adapter.tax.query_handler.get_tax_for_editing_handler: - class: 'PrestaShop\PrestaShop\Adapter\Tax\QueryHandler\GetTaxForEditingHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Tax\Query\GetTaxForEditing' - - prestashop.adapter.tax.command_handler.edit_tax_handler: - class: 'PrestaShop\PrestaShop\Adapter\Tax\CommandHandler\EditTaxHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Tax\Command\EditTaxCommand' - - prestashop.adapter.tax.command_handler.add_tax_handler: - class: 'PrestaShop\PrestaShop\Adapter\Tax\CommandHandler\AddTaxHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Tax\Command\AddTaxCommand' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/tax_rules_group.yml b/src/PrestaShopBundle/Resources/config/services/adapter/tax_rules_group.yml deleted file mode 100644 index 6f8ef103..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/tax_rules_group.yml +++ /dev/null @@ -1,33 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.tax_rules_group.command_handler.delete_tax_rules_group_handler: - class: 'PrestaShop\PrestaShop\Adapter\TaxRulesGroup\CommandHandler\DeleteTaxRulesGroupHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command\DeleteTaxRulesGroupCommand' - - prestashop.adapter.tax_rules_group.command_handler.bulk_delete_tax_rules_group_handler: - class: 'PrestaShop\PrestaShop\Adapter\TaxRulesGroup\CommandHandler\BulkDeleteTaxRulesGroupHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command\BulkDeleteTaxRulesGroupCommand' - - prestashop.adapter.tax_rules_group.command_handler.bulk_set_tax_rules_group_status_handler: - class: 'PrestaShop\PrestaShop\Adapter\TaxRulesGroup\CommandHandler\BulkSetTaxRulesGroupStatusHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command\BulkSetTaxRulesGroupStatusCommand' - - prestashop.adapter.tax_rules_group.query_handler.get_tax_rules_group_for_editing: - class: 'PrestaShop\PrestaShop\Adapter\TaxRulesGroup\QueryHandler\GetTaxRulesGroupForEditingHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Query\GetTaxRulesGroupForEditing' - - prestashop.adapter.tax_rules_group.command_handler.set_tax_rules_group_status_handler: - class: 'PrestaShop\PrestaShop\Adapter\TaxRulesGroup\CommandHandler\SetTaxRulesGroupStatusHandler' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\Command\SetTaxRulesGroupStatusCommand' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/theme.yml b/src/PrestaShopBundle/Resources/config/services/adapter/theme.yml deleted file mode 100644 index e8cf8551..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/theme.yml +++ /dev/null @@ -1,9 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.theme.theme_multi_store_settings_form_data_provider: - class: 'PrestaShop\PrestaShop\Adapter\Theme\ThemeMultiStoreSettingsFormDataProvider' - arguments: - - '@=service("prestashop.adapter.multistore_feature").isUsed()' - - '@=service("prestashop.adapter.shop.context").isSingleShopContext()' diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/twig.yml b/src/PrestaShopBundle/Resources/config/services/adapter/twig.yml deleted file mode 100644 index cd1cf569..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/twig.yml +++ /dev/null @@ -1,10 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.twig.locale_extension: - class: PrestaShop\PrestaShop\Adapter\Twig\LocaleExtension - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext().language.date_format_lite' - tags: - - { name: twig.extension } diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/webservice.yml b/src/PrestaShopBundle/Resources/config/services/adapter/webservice.yml deleted file mode 100644 index 0f0e1dfd..00000000 --- a/src/PrestaShopBundle/Resources/config/services/adapter/webservice.yml +++ /dev/null @@ -1,29 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.webservice.webservice_key_eraser: - class: 'PrestaShop\PrestaShop\Adapter\Webservice\WebserviceKeyEraser' - - prestashop.adapter.webservice.webservice_key_status_modifier: - class: 'PrestaShop\PrestaShop\Adapter\Webservice\WebserviceKeyStatusModifier' - arguments: - - '@translator' - - prestashop.adapter.webservice.query_handler.get_webservice_key_for_editing_handler: - class: 'PrestaShop\PrestaShop\Adapter\Webservice\QueryHandler\GetWebserviceKeyForEditingHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Webservice\Query\GetWebserviceKeyForEditing' - - prestashop.adapter.webservice.command_handler.add_webservice_key_handler: - class: 'PrestaShop\PrestaShop\Adapter\Webservice\CommandHandler\AddWebserviceKeyHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Webservice\Command\AddWebserviceKeyCommand' - - prestashop.adapter.webservice.command_handler.edit_webservice_key_handler: - class: 'PrestaShop\PrestaShop\Adapter\Webservice\CommandHandler\EditWebserviceKeyHandler' - tags: - - name: tactician.handler - command: 'PrestaShop\PrestaShop\Core\Domain\Webservice\Command\EditWebserviceKeyCommand' diff --git a/src/PrestaShopBundle/Resources/config/services/alias.yml b/src/PrestaShopBundle/Resources/config/services/alias.yml deleted file mode 100644 index 74883fce..00000000 --- a/src/PrestaShopBundle/Resources/config/services/alias.yml +++ /dev/null @@ -1,13 +0,0 @@ -services: - _defaults: - public: true - - # Service aliases for backward campatibility - prestashop.core.api.stockMovement.repository: - alias: prestashop.core.api.stock_movement.repository - - prestashop.core.api.stockMovement.controller: - alias: prestashop.core.api.stock_movement.controller - - prestashop.twig.extension.dataFormatter: - alias: prestashop.twig.extension.data_formatter diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/api.yml b/src/PrestaShopBundle/Resources/config/services/bundle/api.yml deleted file mode 100644 index d082dc5d..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/api.yml +++ /dev/null @@ -1,25 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.api.query_params_collection: - abstract: true - class: PrestaShopBundle\Api\QueryParamsCollection - - prestashop.core.api.query_stock_params_collection: - parent: prestashop.core.api.query_params_collection - class: PrestaShopBundle\Api\QueryStockParamsCollection - public: true - - prestashop.core.api.query_stock_movement_params_collection: - parent: prestashop.core.api.query_params_collection - class: PrestaShopBundle\Api\QueryStockMovementParamsCollection - public: true - - prestashop.core.api.query_translation_params_collection: - parent: prestashop.core.api.query_params_collection - class: PrestaShopBundle\Api\QueryTranslationParamsCollection - public: true - - prestashop.core.api.stock.movements_collection: - class: PrestaShopBundle\Api\Stock\MovementsCollection diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/cache.yml b/src/PrestaShopBundle/Resources/config/services/bundle/cache.yml deleted file mode 100644 index be1d19b0..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/cache.yml +++ /dev/null @@ -1,29 +0,0 @@ -services: - _defaults: - public: true - - doctrine.cache.provider: - class: Doctrine\Common\Cache\FilesystemCache - arguments: - - "%kernel.cache_dir%/doctrine" - - guzzle.cache: - class: Csa\Bundle\GuzzleBundle\GuzzleHttp\Cache\DoctrineAdapter - arguments: - - "@doctrine.cache.provider" - - "%prestashop.addons.api_client.ttl%" - shared: false - - main.warmer.cache_warmer: - class: PrestaShopBundle\Cache\CacheWarmer - arguments: - - "@filesystem" - tags: - - { name: kernel.cache_warmer } - - prestashop.cache.refresh: - class: PrestaShopBundle\Service\Cache\Refresh - arguments: - - "@kernel" - calls: - - [addCacheClear, []] diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/controller.yml b/src/PrestaShopBundle/Resources/config/services/bundle/controller.yml deleted file mode 100644 index 96b65614..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/controller.yml +++ /dev/null @@ -1,135 +0,0 @@ -services: - _defaults: - public: true - - PrestaShopBundle\Controller\Api\ApiController: - abstract: true - class: PrestaShopBundle\Controller\Api\ApiController - calls: - - [setLogger, ['@logger']] - - [setContainer, ['@service_container']] - tags: - - { name: !php/const PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController::PRESTASHOP_CORE_CONTROLLERS_TAG } - - prestashop.core.api.controller: - alias: PrestaShopBundle\Controller\Api\ApiController - - PrestaShopBundle\Controller\Api\StockController: - class: PrestaShopBundle\Controller\Api\StockController - parent: PrestaShopBundle\Controller\Api\ApiController - public: true - properties: - movements: "@prestashop.core.api.stock.movements_collection" - stockRepository: "@prestashop.core.api.stock.repository" - queryParams: "@prestashop.core.api.query_stock_params_collection" - tags: - - { name: !php/const PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController::PRESTASHOP_CORE_CONTROLLERS_TAG } - - prestashop.core.api.stock.controller: - alias: PrestaShopBundle\Controller\Api\StockController - - PrestaShopBundle\Controller\Api\StockMovementController: - class: PrestaShopBundle\Controller\Api\StockMovementController - parent: PrestaShopBundle\Controller\Api\ApiController - public: true - properties: - stockMovementRepository: "@prestashop.core.api.stock_movement.repository" - queryParams: "@prestashop.core.api.query_stock_movement_params_collection" - tags: - - { name: !php/const PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController::PRESTASHOP_CORE_CONTROLLERS_TAG } - - prestashop.core.api.stock_movement.controller: - alias: PrestaShopBundle\Controller\Api\StockMovementController - - PrestaShopBundle\Controller\Api\SupplierController: - class: PrestaShopBundle\Controller\Api\SupplierController - parent: PrestaShopBundle\Controller\Api\ApiController - public: true - properties: - supplierRepository: "@prestashop.core.api.supplier.repository" - tags: - - { name: !php/const PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController::PRESTASHOP_CORE_CONTROLLERS_TAG } - - prestashop.core.api.supplier.controller: - alias: PrestaShopBundle\Controller\Api\SupplierController - - PrestaShopBundle\Controller\Api\ManufacturerController: - class: PrestaShopBundle\Controller\Api\ManufacturerController - parent: PrestaShopBundle\Controller\Api\ApiController - public: true - properties: - manufacturerRepository: "@prestashop.core.api.manufacturer.repository" - tags: - - { name: !php/const PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController::PRESTASHOP_CORE_CONTROLLERS_TAG } - - prestashop.core.api.manufacturer.controller: - alias: PrestaShopBundle\Controller\Api\ManufacturerController - - PrestaShopBundle\Controller\Api\CategoryController: - class: PrestaShopBundle\Controller\Api\CategoryController - parent: PrestaShopBundle\Controller\Api\ApiController - public: true - properties: - categoryRepository: "@prestashop.core.api.category.repository" - tags: - - { name: !php/const PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController::PRESTASHOP_CORE_CONTROLLERS_TAG } - - prestashop.core.api.category.controller: - alias: PrestaShopBundle\Controller\Api\CategoryController - - PrestaShopBundle\Controller\Api\AttributeController: - class: PrestaShopBundle\Controller\Api\AttributeController - parent: PrestaShopBundle\Controller\Api\ApiController - public: true - properties: - featureAttributeRepository: "@prestashop.core.api.feature_attribute.repository" - tags: - - { name: !php/const PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController::PRESTASHOP_CORE_CONTROLLERS_TAG } - - prestashop.core.api.attribute.controller: - alias: PrestaShopBundle\Controller\Api\AttributeController - - PrestaShopBundle\Controller\Api\FeatureController: - class: PrestaShopBundle\Controller\Api\FeatureController - parent: PrestaShopBundle\Controller\Api\ApiController - public: true - properties: - featureAttributeRepository: "@prestashop.core.api.feature_attribute.repository" - tags: - - { name: !php/const PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController::PRESTASHOP_CORE_CONTROLLERS_TAG } - - prestashop.core.api.feature.controller: - alias: PrestaShopBundle\Controller\Api\FeatureController - - PrestaShopBundle\Controller\Api\I18nController: - class: PrestaShopBundle\Controller\Api\I18nController - parent: PrestaShopBundle\Controller\Api\ApiController - public: true - tags: - - { name: !php/const PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController::PRESTASHOP_CORE_CONTROLLERS_TAG } - - prestashop.core.api.i18n.controller: - alias: PrestaShopBundle\Controller\Api\I18nController - - PrestaShopBundle\Controller\Api\TranslationController: - class: PrestaShopBundle\Controller\Api\TranslationController - parent: PrestaShopBundle\Controller\Api\ApiController - public: true - properties: - translationService: "@prestashop.service.translation" - queryParams: "@prestashop.core.api.query_translation_params_collection" - tags: - - { name: !php/const PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController::PRESTASHOP_CORE_CONTROLLERS_TAG } - - prestashop.core.api.translation.controller: - alias: PrestaShopBundle\Controller\Api\TranslationController - - PrestaShopBundle\Controller\Api\Improve\Design\PositionsController: - class: PrestaShopBundle\Controller\Api\Improve\Design\PositionsController - parent: PrestaShopBundle\Controller\Api\ApiController - public: true - tags: - - { name: !php/const PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController::PRESTASHOP_CORE_CONTROLLERS_TAG } - - prestashop.core.api.improve.design.postions.controller: - alias: PrestaShopBundle\Controller\Api\Improve\Design\PositionsController diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/data_collector.yml b/src/PrestaShopBundle/Resources/config/services/bundle/data_collector.yml deleted file mode 100644 index 3f4d6117..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/data_collector.yml +++ /dev/null @@ -1,32 +0,0 @@ -services: - _defaults: - public: true - - prestashop.hooks_registry: - class: PrestaShopBundle\DataCollector\HookRegistry - - prestashop.hooks_collector: - class: PrestaShopBundle\DataCollector\HookDataCollector - arguments: ['@prestashop.hooks_registry'] - public: false - tags: - - {name: data_collector, template: '@PrestaShop/Admin/WebProfiler/hooks_collector.html.twig', id: 'ps.hooks_collector'} - - prestashop.bundle.data_collector.commands_and_queries_collector: - class: PrestaShopBundle\DataCollector\CommandsAndQueriesDataCollector - arguments: - - '@prestashop.core.command_bus.executed_command_registry' - tags: - - name: data_collector - id: ps.commands_and_queries_collector - template: '@PrestaShop/Admin/WebProfiler/commands_and_queries.html.twig' - - # Web Profiler Bundle - data_collector.config: - class: Symfony\Component\HttpKernel\DataCollector\ConfigDataCollector - arguments: ["PrestaShop", "@=service('prestashop.core.foundation.version').getVersion()"] - public: false - calls: - - ["setKernel", ["@kernel"]] - tags: - - {name: data_collector, template: "@PrestaShop/Admin/WebProfiler/config.html.twig", id: "config", priority: "-255"} diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/event_listener.yml b/src/PrestaShopBundle/Resources/config/services/bundle/event_listener.yml deleted file mode 100644 index ef55f943..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/event_listener.yml +++ /dev/null @@ -1,112 +0,0 @@ -services: - _defaults: - public: true - - prestashop.user_locale.listener: - class: PrestaShopBundle\EventListener\UserLocaleListener - arguments: - - "@prestashop.adapter.legacy.context" - tags: - - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 15 } - - prestashop.dispatcher.legacy_hooks.subscriber: - class: 'PrestaShopBundle\EventListener\ActionDispatcherLegacyHooksSubscriber' - arguments: ['@prestashop.core.hook.dispatcher'] - tags: - - { name: kernel.event_subscriber } - - prestashop.tokenized_url_listener: - class: PrestaShopBundle\EventListener\TokenizedUrlsListener - arguments: - - "@security.csrf.token_manager" - - "@router" - - "@=service('prestashop.user_provider').getUsername()" - - "@prestashop.adapter.legacy.context" - tags: - - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest } - - # Priority 40 to be called before the RouterListener - prestashop.legacy_url_listener: - class: PrestaShopBundle\EventListener\LegacyUrlListener - arguments: - - "@prestashop.bundle.routing.converter.legacy_url_converter" - tags: - - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 40 } - - # Priority 30 to be called after the RouterListener - prestashop.legacy_parameters_listener: - class: PrestaShopBundle\EventListener\LegacyParametersListener - arguments: - - "@prestashop.bundle.routing.converter.legacy_parameters_converter" - tags: - - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 30 } - - prestashop.multishop_command_listener: - class: PrestaShopBundle\EventListener\MultishopCommandListener - arguments: - - "@prestashop.adapter.shop.context" - - "@=service('kernel').getRootDir()" - tags: - - { name: kernel.event_listener, event: console.command, method: onConsoleCommand } - - prestashop.access_denied.listener: - class: PrestaShopBundle\EventListener\AccessDeniedListener - arguments: - - "@router" - - "@translator" - - "@session" - tags: - - { name: kernel.event_listener, event: kernel.exception, method: onKernelException } - - prestashop.demo_mode_enabled.listener: - class: PrestaShopBundle\EventListener\DemoModeEnabledListener - arguments: - - "@router" - - "@translator" - - "@session" - - "@annotation_reader" - - "@=service('prestashop.adapter.legacy.configuration').getBoolean('_PS_MODE_DEMO_')" - tags: - - { name: kernel.event_listener, event: kernel.controller, method: onKernelController } - - prestashop.module_activated.listener: - class: PrestaShopBundle\EventListener\ModuleActivatedListener - arguments: - - "@router" - - "@translator" - - "@session" - - "@annotation_reader" - - "@prestashop.core.admin.module.repository" - tags: - - { name: kernel.event_listener, event: kernel.controller, method: onKernelController } - - prestashop.bundle.event_listener.filter_category_search_criteria: - class: PrestaShopBundle\EventListener\FilterCategorySearchCriteriaListener - arguments: - - '@prestashop.adapter.grid.search.factory.search_criteria_with_category_parent_id' - tags: - - { name: kernel.event_listener, event: prestashop.search_criteria.filter, method: onFilterSearchCriteria } - - prestashop.bundle.event_listener.filter_cms_page_category_search_criteria: - class: PrestaShopBundle\EventListener\FilterCmsPageCategorySearchCriteriaListener - arguments: - - '@request_stack' - tags: - - { name: kernel.event_listener, event: prestashop.search_criteria.filter, method: onFilterSearchCriteria } - - prestashop.bundle.event_listener.back_url_redirect_response_listener: - class: PrestaShopBundle\EventListener\BackUrlRedirectResponseListener - arguments: - - '@prestashop.core.uti.back_url_provider' - - "@prestashop.adapter.legacy.context" - tags: - - { name: kernel.event_listener, event: kernel.response, method: onKernelResponse } - - prestashop.bundle.event_listener.module_guard_listener: - class: PrestaShopBundle\EventListener\ModuleGuardListener - arguments: - - '@prestashop.core.security.folder_guard.vendor' - - '%modules_dir%' - - '@logger' - tags: - - { name: kernel.event_subscriber } diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/form.yml b/src/PrestaShopBundle/Resources/config/services/bundle/form.yml deleted file mode 100644 index 860de7a2..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/form.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: form/*.yml } diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_builder.yml b/src/PrestaShopBundle/Resources/config/services/bundle/form/form_builder.yml deleted file mode 100644 index 873e66e5..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_builder.yml +++ /dev/null @@ -1,17 +0,0 @@ -services: - _defaults: - public: true - - prestashop.admin.import.form_builder: - class: 'Symfony\Component\Form\FormBuilder' - factory: 'form.factory:createNamedBuilder' - arguments: - - '' - - 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Import\ImportType' - - prestashop.admin.import_data_configuration.form_builder: - class: 'Symfony\Component\Form\FormBuilder' - factory: 'form.factory:createNamedBuilder' - arguments: - - '' - - 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Import\ImportDataConfigurationType' diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_data_provider.yml b/src/PrestaShopBundle/Resources/config/services/bundle/form/form_data_provider.yml deleted file mode 100644 index cba06c6e..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_data_provider.yml +++ /dev/null @@ -1,194 +0,0 @@ -services: - _defaults: - public: true - - prestashop.admin.shipping_preferences.data_provider: - class: 'PrestaShopBundle\Form\Admin\Improve\Shipping\Preferences\PreferencesFormDataProvider' - arguments: - - '@prestashop.adapter.shipping_preferences.handling_configuration' - - '@prestashop.adapter.shipping_preferences.carrier_options_configuration' - - '@translator' - - prestashop.admin.order.invoices.by_date.data_provider: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\Invoices\InvoicesByDateDataProvider' - arguments: - - '@prestashop.adapter.data_provider.order_invoice' - - prestashop.admin.order.invoices.by_status.data_provider: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\Invoices\InvoicesByStatusDataProvider' - - prestashop.admin.order.invoices.options.data_provider: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\Invoices\InvoiceOptionsDataProvider' - arguments: - - '@prestashop.adapter.order.invoice_options.configuration' - - '@=service("prestashop.adapter.data_provider.order_invoice").getNextInvoiceNumber()' - - prestashop.admin.customer_preferences.data_provider: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\CustomerPreferences\CustomerPreferencesDataProvider' - arguments: - - '@prestashop.adapter.customer.customer_configuration' - - '@translator' - - prestashop.admin.order_preferences.data_provider: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\OrderPreferences\OrderPreferencesFormDataProvider' - arguments: - - '@prestashop.adapter.order_general.configuration' - - '@prestashop.adapter.order_gift.configuration' - - '@translator' - - '@prestashop.adapter.data_provider.cms' - - prestashop.admin.product_preferences.data_provider: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\ProductPreferences\ProductPreferencesFormDataProvider' - arguments: - - '@prestashop.adapter.product_general.configuration' - - '@prestashop.adapter.product_pagination.configuration' - - '@prestashop.adapter.product_page.configuration' - - '@prestashop.adapter.product_stock.configuration' - - '@translator' - - prestashop.adapter.performance.form_provider: - class: 'PrestaShopBundle\Form\Admin\AdvancedParameters\Performance\PerformanceFormDataProvider' - arguments: - - '@prestashop.adapter.smarty_cache.configuration' - - '@prestashop.adapter.debug_mode.configuration' - - '@prestashop.adapter.optional_features.configuration' - - '@prestashop.adapter.ccc.configuration' - - '@prestashop.adapter.media_servers.configuration' - - '@prestashop.adapter.caching.configuration' - - prestashop.adapter.maintenance.form_provider: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\General\MaintenanceFormDataProvider' - arguments: - - '@prestashop.adapter.maintenance.configuration' - - prestashop.adapter.administration.form_provider: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Administration\FormDataProvider' - arguments: - - '@prestashop.adapter.general.configuration' - - '@prestashop.adapter.upload_quota.configuration' - - '@prestashop.adapter.notifications.configuration' - - prestashop.adapter.preferences.form_provider: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\General\PreferencesFormDataProvider' - arguments: - - '@prestashop.adapter.preferences.configuration' - - prestashop.adapter.logs.form_provider: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Logs\LogsFormDataProvider' - arguments: - - '@prestashop.adapter.logs.configuration' - - prestashop.admin.import.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Import\ImportFormDataProvider' - arguments: - - '@prestashop.core.import.file_finder' - - '@session' - - prestashop.admin.import_data_configuration.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Import\ImportDataConfigurationFormDataProvider' - arguments: - - '@prestashop.core.import.dir' - - '@prestashop.core.import.factory.data_row.collection_factory' - - '@prestashop.core.admin.import_match.repository' - - '@prestashop.adapter.import.data_match_saver' - - '@=service("prestashop.core.form.choice_provider.import_entity_field").getChoices()' - - prestashop.adapter.order.delivery.slip.options.form_provider: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\Delivery\SlipOptionsFormDataProvider' - arguments: - - '@prestashop.adapter.order.delivery.slip.options.configuration' - - prestashop.adapter.order.delivery.slip.pdf.form_provider: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\Delivery\SlipPdfFormDataProvider' - arguments: - - '@prestashop.adapter.order.delivery.slip.pdf.configuration' - - prestashop.admin.localization.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Localization\LocalizationFormDataProvider' - arguments: - - '@prestashop.adapter.localization.configuration' - - '@prestashop.adapter.local_units.configuration' - - '@prestashop.adapter.localization_advanced.configuration' - - prestashop.admin.geolocation.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Geolocation\GeolocationFormDataProvider' - arguments: - - '@prestashop.adapter.geolocation_by_ip_address.configuration' - - '@prestashop.adapter.geolocation_ip_address_whitelist.configuration' - - '@prestashop.adapter.geolocation_options.configuration' - - '@prestashop.core.geolocation.geo_lite_city.checker' - - '@prestashop.core.validation.validator' - - prestashop.admin.payment_preferences.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Improve\Payment\Preferences\PaymentPreferencesFormDataProvider' - arguments: - - '@prestashop.adapter.payment_module_preferences.configuration' - - prestashop.admin.email_configuration.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Email\EmailConfigurationFormDataProvider' - arguments: - - '@prestashop.core.email.email_configurator' - - '@prestashop.core.email.smtp_configurator' - - prestashop.admin.request_sql_settings.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\RequestSql\SqlRequestSettingsFormDataProvider' - arguments: - - '@prestashop.core.sql_manager.configuration.sql_request_configuration' - - prestashop.admin.webservice.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Webservice\WebserviceFormDataProvider' - arguments: - - '@prestashop.adapter.webservice.configuration' - - prestashop.admin.backup.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Backup\BackupDataProvider' - arguments: - - '@prestashop.core.backup.options_configuration' - - prestashop.admin.traffic_seo.meta_settings.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\TrafficSeo\Meta\MetaSettingsFormDataProvider' - arguments: - - '@prestashop.adapter.meta.set_up_urls.configuration' - - '@prestashop.adapter.meta.shop_url.configuration' - - '@prestashop.adapter.meta.url_schema.configuration' - - '@prestashop.adapter.meta.seo_options.configuration' - - '@translator' - - '@prestashop.adapter.routes.route_validator' - - '@prestashop.adapter.validate' - - prestashop.admin.employee_options.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Employee\EmployeeOptionsFormDataProvider' - arguments: - - '@prestashop.core.team.employee.configuration.employee_options_configuration' - - prestashop.admin.currency.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Currencies\CurrencyFormDataProvider' - arguments: - - '@prestashop.core.command_bus' - - '@=service("prestashop.adapter.legacy.configuration").get("PS_ACTIVE_CRONJOB_EXCHANGE_RATE")' - - prestashop.admin.tax_options.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Tax\TaxOptionsFormDataProvider' - arguments: - - '@prestashop.core.tax.tax_options_configuration' - - prestashop.admin.improve.design.theme.shop_logos.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Improve\Design\Theme\ShopLogosFormDataProvider' - arguments: - - '@prestashop.core.command_bus' - - '@prestashop.adapter.theme.theme_multi_store_settings_form_data_provider' - - prestashop.admin.mail_theme.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Improve\Design\MailTheme\MailThemeFormDataProvider' - arguments: - - '@prestashop.core.mail_theme.configuration' - - prestashop.admin.merchandise_return_options.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Sell\CustomerService\MerchandiseReturn\MerchandiseReturnOptionsFormDataProvider' - arguments: - - '@prestashop.core.merchandise_return.configuration.merchandise_return_options_configuration' - - prestashop.admin.sell.order.credit_slip.credit_slip_options_form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\CreditSlip\CreditSlipOptionsFormDataProvider' - arguments: - - '@prestashop.core.credit_slip.credit_slip_options.configuration' diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_data_transformer.yml b/src/PrestaShopBundle/Resources/config/services/bundle/form/form_data_transformer.yml deleted file mode 100644 index c7d7865a..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_data_transformer.yml +++ /dev/null @@ -1,21 +0,0 @@ -services: - _defaults: - public: true - - prestashop.bundle.form.data_transformer.string_array_to_integer_array: - class: 'PrestaShopBundle\Form\DataTransformer\StringArrayToIntegerArrayDataTransformer' - - prestashop.bundle.form.data_transformer.default_language_to_filled_array: - class: 'PrestaShopBundle\Form\DataTransformer\DefaultLanguageToFilledArrayDataTransformer' - arguments: - - '@=service("prestashop.adapter.legacy.configuration").get("PS_LANG_DEFAULT")' - - prestashop.bundle.form.data_transformer.arabic_to_latin_digit: - class: 'PrestaShopBundle\Form\DataTransformer\ArabicToLatinDigitDataTransformer' - arguments: - - '@prestashop.core.util.arabic_to_latin_digit_converter' - - prestashop.bundle.form.data_transformer.idn_converter: - class: 'PrestaShopBundle\Form\DataTransformer\IDNConverterDataTransformer' - arguments: - - '@prestashop.core.util.internationalized_domain_name_converter' diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_extension.yml b/src/PrestaShopBundle/Resources/config/services/bundle/form/form_extension.yml deleted file mode 100644 index 8fd537e2..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_extension.yml +++ /dev/null @@ -1,29 +0,0 @@ -services: - _defaults: - public: true - - form.type.extension.money: - class: 'PrestaShopBundle\Form\Admin\Type\CustomMoneyType' - tags: - - { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\MoneyType } - - form.type.extension.resizable_text: - class: 'PrestaShopBundle\Form\Admin\Type\ResizableTextType' - tags: - - { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\TextType } - - form.extension.help_text: - class: 'PrestaShopBundle\Form\Admin\Extension\HelpTextExtension' - tags: - - { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\FormType } - - form.extension.data_list: - class: 'PrestaShopBundle\Form\Extension\DataListExtension' - tags: - - { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\TextType } - - form.extension.row_attributes: - class: 'PrestaShopBundle\Form\Admin\Extension\RowAttributesExtension' - tags: - - { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\FormType } - diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_factory.yml b/src/PrestaShopBundle/Resources/config/services/bundle/form/form_factory.yml deleted file mode 100644 index c90ccc67..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_factory.yml +++ /dev/null @@ -1,10 +0,0 @@ -services: - _defaults: - public: true - - prestashop.bundle.form.admin.improve.design.theme.page_layout_customization_form_factory: - class: 'PrestaShopBundle\Form\Admin\Improve\Design\Theme\PageLayoutCustomizationFormFactory' - arguments: - - '@form.factory' - - '@prestashop.core.addon.theme.repository' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.theme.getName()' diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_handler.yml b/src/PrestaShopBundle/Resources/config/services/bundle/form/form_handler.yml deleted file mode 100644 index ae3d7da7..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_handler.yml +++ /dev/null @@ -1,390 +0,0 @@ -services: - _defaults: - public: true - - prestashop.adapter.performance.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.adapter.performance.form_provider' - - - 'smarty': 'PrestaShopBundle\Form\Admin\AdvancedParameters\Performance\SmartyType' - 'debug_mode': 'PrestaShopBundle\Form\Admin\AdvancedParameters\Performance\DebugModeType' - 'optional_features': 'PrestaShopBundle\Form\Admin\AdvancedParameters\Performance\OptionalFeaturesType' - 'ccc': 'PrestaShopBundle\Form\Admin\AdvancedParameters\Performance\CombineCompressCacheType' - 'media_servers': 'PrestaShopBundle\Form\Admin\AdvancedParameters\Performance\MediaServersType' - 'caching': 'PrestaShopBundle\Form\Admin\AdvancedParameters\Performance\CachingType' - 'add_memcache_server': 'PrestaShopBundle\Form\Admin\AdvancedParameters\Performance\MemcacheServerType' - - 'PerformancePage' - - prestashop.adapter.maintenance.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.adapter.maintenance.form_provider' - - - 'general': 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\General\MaintenanceType' - - 'MaintenancePage' - - prestashop.adapter.administration.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.adapter.administration.form_provider' - - - 'general': 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Administration\GeneralType' - 'upload_quota': 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Administration\UploadQuotaType' - 'notifications': 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Administration\NotificationsType' - - 'AdministrationPage' - - prestashop.admin.shipping_preferences.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.shipping_preferences.data_provider' - - - 'handling': 'PrestaShopBundle\Form\Admin\Improve\Shipping\Preferences\HandlingType' - 'carrier_options': 'PrestaShopBundle\Form\Admin\Improve\Shipping\Preferences\CarrierOptionsType' - - 'ShippingPreferencesPage' - - prestashop.admin.order.invoices.by_date.form_handler: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\Invoices\InvoiceByDateFormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.order.invoices.by_date.data_provider' - - - 'generate_by_date': 'PrestaShopBundle\Form\Admin\Sell\Order\Invoices\GenerateByDateType' - - 'OrdersInvoicesByDate' - - '@prestashop.adapter.data_provider.order_invoice' - - '@prestashop.adapter.pdf.generator.invoice' - - prestashop.admin.order.invoices.by_status.form_handler: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\Invoices\InvoiceByStatusFormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.order.invoices.by_status.data_provider' - - - 'generate_by_status': 'PrestaShopBundle\Form\Admin\Sell\Order\Invoices\GenerateByStatusType' - - 'OrdersInvoicesByStatus' - - '@prestashop.adapter.data_provider.order_invoice' - - '@prestashop.adapter.pdf.generator.invoice' - - prestashop.admin.order.invoices.options.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.order.invoices.options.data_provider' - - - 'invoice_options': 'PrestaShopBundle\Form\Admin\Sell\Order\Invoices\InvoiceOptionsType' - - 'OrdersInvoicesOptions' - - prestashop.admin.customer_preferences.form_handler: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\CustomerPreferences\CustomerPreferencesFormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.customer_preferences.data_provider' - - - 'general': 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\CustomerPreferences\GeneralType' - - 'CustomerPreferencesPage' - calls: - - method: setTabRepository - arguments: - - '@prestashop.core.admin.tab.repository' - - prestashop.admin.order_preferences.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.order_preferences.data_provider' - - - 'general': 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\OrderPreferences\GeneralType' - 'gift_options': 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\OrderPreferences\GiftOptionsType' - - 'OrderPreferencesPage' - - prestashop.admin.product_preferences.form_handler: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\ProductPreferences\ProductPreferencesFormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.product_preferences.data_provider' - - - 'general': 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\ProductPreferences\GeneralType' - 'pagination': 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\ProductPreferences\PaginationType' - 'page': 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\ProductPreferences\PageType' - 'stock': 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\ProductPreferences\StockType' - - 'ProductPreferencesPage' - calls: - - method: setCacheClearer - arguments: - - '@prestashop.adapter.cache_clearer' - - prestashop.adapter.preferences.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.adapter.preferences.form_provider' - - - 'general': 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\General\PreferencesType' - - 'GeneralPage' - - prestashop.adapter.logs.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.adapter.logs.form_provider' - - - 'logs_by_email': 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Logs\LogsByEmailType' - - 'LogsPage' - - prestashop.admin.import.form_handler: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Import\ImportFormHandler' - arguments: - - '@prestashop.admin.import.form_builder' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.import.form_data_provider' - - 'Import' - - prestashop.admin.import_data_configuration.form_handler: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Import\ImportFormHandler' - arguments: - - '@prestashop.admin.import_data_configuration.form_builder' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.import_data_configuration.form_data_provider' - - 'ImportDataConfiguration' - - prestashop.adapter.order.delivery.slip.options.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.adapter.order.delivery.slip.options.form_provider' - - - 'options': 'PrestaShopBundle\Form\Admin\Sell\Order\Delivery\SlipOptionsType' - - 'OrderDeliverySlipOptions' - - prestashop.adapter.order.delivery.slip.pdf.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.adapter.order.delivery.slip.pdf.form_provider' - - - 'pdf': 'PrestaShopBundle\Form\Admin\Sell\Order\Delivery\SlipPdfType' - - 'OrderDeliverySlipPdf' - - 'slip_pdf_form' - - prestashop.admin.geolocation.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.geolocation.form_data_provider' - - - 'geolocation_by_id_address': 'PrestaShopBundle\Form\Admin\Improve\International\Geolocation\GeolocationByIpAddressType' - 'geolocation_ip_address_whitelist': 'PrestaShopBundle\Form\Admin\Improve\International\Geolocation\GeolocationIpAddressWhitelistType' - 'geolocation_options': 'PrestaShopBundle\Form\Admin\Improve\International\Geolocation\GeolocationOptionsType' - - 'GeolocationPage' - - prestashop.admin.localization.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.localization.form_data_provider' - - - 'configuration': 'PrestaShopBundle\Form\Admin\Improve\International\Localization\LocalizationConfigurationType' - 'local_units': 'PrestaShopBundle\Form\Admin\Improve\International\Localization\LocalUnitsType' - 'advanced': 'PrestaShopBundle\Form\Admin\Improve\International\Localization\AdvancedConfigurationType' - - 'LocalizationPage' - - prestashop.admin.payment_preferences.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.payment_preferences.form_data_provider' - - - 'payment_module_preferences': 'PrestaShopBundle\Form\Admin\Improve\Payment\Preferences\PaymentModulePreferencesType' - - 'PaymentPreferences' - - prestashop.admin.email_configuration.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.email_configuration.form_data_provider' - - - 'email_config': 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Email\EmailConfigurationType' - 'smtp_config': 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Email\SmtpConfigurationType' - - 'EmailConfiguration' - - prestashop.admin.request_sql_settings.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.request_sql_settings.form_data_provider' - - - 'settings': 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\RequestSql\SqlRequestSettingsType' - - 'RequestSql' - - prestashop.admin.backup.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.backup.form_data_provider' - - - 'backup_options': 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Backup\BackupOptionsType' - - 'Backup' - - prestashop.adapter.webservice.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.webservice.form_data_provider' - - - 'webservice_configuration': 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Webservice\WebserviceConfigurationType' - - 'WebservicePage' - - prestashop.admin.translations_settings.modify_translations.form_handler: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Translations\TranslationsSettingsFormHandler' - arguments: - - '@form.factory' - - '@prestashop.core.hook.dispatcher' - - 'PrestaShopBundle\Form\Admin\Improve\International\Translations\ModifyTranslationsType' - - 'TranslationSettingsPageModifyTranslations' - - prestashop.admin.translations_settings.add_update_language.form_handler: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Translations\TranslationsSettingsFormHandler' - arguments: - - '@form.factory' - - '@prestashop.core.hook.dispatcher' - - 'PrestaShopBundle\Form\Admin\Improve\International\Translations\AddUpdateLanguageType' - - 'TranslationSettingsPageAddUpdateLanguage' - - prestashop.admin.translations_settings.export_language.form_handler: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Translations\TranslationsSettingsFormHandler' - arguments: - - '@form.factory' - - '@prestashop.core.hook.dispatcher' - - 'PrestaShopBundle\Form\Admin\Improve\International\Translations\ExportThemeLanguageType' - - 'TranslationSettingsPageExportLanguage' - - prestashop.admin.translations_settings.copy_language.form_handler: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Translations\TranslationsSettingsFormHandler' - arguments: - - '@form.factory' - - '@prestashop.core.hook.dispatcher' - - 'PrestaShopBundle\Form\Admin\Improve\International\Translations\CopyLanguageType' - - 'TranslationSettingsPageCopyLanguage' - - prestashop.admin.meta_settings.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.traffic_seo.meta_settings.form_data_provider' - - - 'set_up_urls': 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\TrafficSeo\Meta\SetUpUrlType' - 'shop_urls': 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\TrafficSeo\Meta\ShopUrlType' - 'url_schema': 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\TrafficSeo\Meta\UrlSchemaType' - 'seo_options': 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\TrafficSeo\Meta\SEOOptionsType' - - 'MetaPage' - - 'meta_settings_form' - - prestashop.admin.employee_options.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.employee_options.form_data_provider' - - - 'options': 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Employee\EmployeeOptionsType' - - 'Employee' - - prestashop.admin.currency_settings.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.currency.form_data_provider' - - - 'exchange_rates': 'PrestaShopBundle\Form\Admin\Improve\International\Currencies\CurrencyExchangeRateType' - - 'Currency' - - prestashop.admin.shop_logos_settings.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.improve.design.theme.shop_logos.form_data_provider' - - - 'shop_logos': 'PrestaShopBundle\Form\Admin\Improve\Design\Theme\ShopLogosType' - - 'ShopLogo' - - # Entity form handler - prestashop.admin.request_sql.form_handler: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\RequestSql\SqlRequestFormHandler' - arguments: - - '@form.factory' - - '@prestashop.adapter.sql_manager.request_sql_form_data_validator' - - '@prestashop.bundle.form.admin.configure.advanced_parameters.request_sql.form_data_provider' - - prestashop.bundle.form.admin.configure.advanced_parameters.request_sql.form_data_provider: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\RequestSql\SqlRequestFormDataProvider' - arguments: - - '@prestashop.core.command_bus' - - '@prestashop.core.query_bus' - - prestashop.admin.tax_options.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.tax_options.form_data_provider' - - - 'options': 'PrestaShopBundle\Form\Admin\Improve\International\Tax\TaxOptionsType' - - 'Tax' - - prestashop.admin.mail_theme.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.mail_theme.form_data_provider' - - - 'configuration': 'PrestaShopBundle\Form\Admin\Improve\Design\MailTheme\MailThemeConfigurationType' - - 'MailTheme' - - prestashop.admin.merchandise_return_options.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.merchandise_return_options.form_data_provider' - - - 'options': 'PrestaShopBundle\Form\Admin\Sell\CustomerService\MerchandiseReturn\MerchandiseReturnOptionsType' - - 'MerchandiseReturn' - - prestashop.admin.credit_slip_options.form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\FormHandler' - arguments: - - '@=service("form.factory").createBuilder()' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.admin.sell.order.credit_slip.credit_slip_options_form_data_provider' - - - 'options': 'PrestaShopBundle\Form\Admin\Sell\Order\CreditSlip\CreditSlipOptionsType' - - 'CreditSlip' diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_type.yml b/src/PrestaShopBundle/Resources/config/services/bundle/form/form_type.yml deleted file mode 100644 index 797bd9aa..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_type.yml +++ /dev/null @@ -1,1148 +0,0 @@ -imports: - - { resource: 'form_type/*' } - -services: - _defaults: - public: true - - form.type.date_picker: - class: PrestaShopBundle\Form\Admin\Type\DatePickerType - arguments: - - '@prestashop.bundle.form.data_transformer.arabic_to_latin_digit' - tags: - - { name: form.type } - - form.type.email: - class: PrestaShopBundle\Form\Admin\Type\EmailType - arguments: - - '@prestashop.bundle.form.data_transformer.idn_converter' - tags: - - { name: form.type } - - form.type.product.simple_category: - class: PrestaShopBundle\Form\Admin\Category\SimpleCategory - arguments: - - "@translator" - - "@prestashop.adapter.data_provider.category" - tags: - - { name: form.type } - - form.type.product.categories_tree: - class: 'PrestaShopBundle\Form\Admin\Type\ChoiceCategoriesTreeType' - parent: 'form.type.common_type' - public: true - tags: - - { name: form.type } - - form.type.product.translate: - class: 'PrestaShopBundle\Form\Admin\Type\TranslateType' - parent: 'form.type.common_type' - arguments: - - '@router.default' - - "@=service('prestashop.adapter.legacy.configuration').getBoolean('PS_BO_ALLOW_EMPLOYEE_FORM_LANG')" - - "@=service('prestashop.adapter.legacy.context').getContext().cookie.employee_form_lang" - - "@=service('prestashop.adapter.legacy.configuration').getInt('PS_LANG_DEFAULT')" - public: true - tags: - - { name: form.type } - - form.type.product.feature: - class: PrestaShopBundle\Form\Admin\Feature\ProductFeature - arguments: - - "@translator" - - "@prestashop.adapter.legacy.context" - - "@router" - - "@prestashop.adapter.data_provider.feature" - parent: 'form.type.common_type' - public: true - tags: - - { name: form.type } - - form.type.product.attachment: - class: PrestaShopBundle\Form\Admin\Product\ProductAttachement - arguments: - - "@translator" - - "@prestashop.adapter.legacy.context" - parent: 'form.type.common_type' - public: true - tags: - - { name: form.type } - - form.type.product.combination: - class: PrestaShopBundle\Form\Admin\Product\ProductCombination - arguments: - - "@translator" - - "@prestashop.adapter.legacy.context" - parent: 'form.type.common_type' - public: true - tags: - - { name: form.type } - - form.type.product.custom_field: - class: PrestaShopBundle\Form\Admin\Product\ProductCustomField - arguments: - - "@translator" - - "@prestashop.adapter.legacy.context" - parent: 'form.type.common_type' - public: true - tags: - - { name: form.type } - - form.type.product.information: - class: PrestaShopBundle\Form\Admin\Product\ProductInformation - arguments: - - "@translator" - - "@prestashop.adapter.legacy.context" - - "@router" - - "@prestashop.adapter.data_provider.category" - - "@prestashop.adapter.data_provider.product" - - "@prestashop.adapter.data_provider.feature" - - "@prestashop.adapter.data_provider.manufacturer" - parent: 'form.type.common_type' - public: true - tags: - - { name: form.type } - - form.type.product.options: - class: PrestaShopBundle\Form\Admin\Product\ProductOptions - arguments: - - "@translator" - - "@prestashop.adapter.legacy.context" - - "@prestashop.adapter.data_provider.product" - - "@prestashop.adapter.data_provider.supplier" - - "@prestashop.adapter.data_provider.currency" - - "@prestashop.adapter.data_provider.attachment" - - "@router" - parent: 'form.type.common_type' - public: true - tags: - - { name: form.type } - - form.type.product.price: - class: PrestaShopBundle\Form\Admin\Product\ProductPrice - arguments: - - "@translator" - - "@prestashop.adapter.data_provider.tax" - - "@router" - - "@prestashop.adapter.shop.context" - - "@prestashop.adapter.data_provider.country" - - "@prestashop.adapter.data_provider.currency" - - "@prestashop.adapter.data_provider.group" - - "@prestashop.adapter.legacy.context" - - "@prestashop.adapter.data_provider.customer" - parent: 'form.type.common_type' - public: true - tags: - - { name: form.type } - - form.type.product.quantity: - class: PrestaShopBundle\Form\Admin\Product\ProductQuantity - arguments: - - "@translator" - - "@router" - - "@prestashop.adapter.legacy.context" - parent: 'form.type.common_type' - public: true - tags: - - { name: form.type } - - form.type.product.seo: - class: PrestaShopBundle\Form\Admin\Product\ProductSeo - arguments: - - "@translator" - - "@prestashop.adapter.legacy.context" - - "@router" - parent: 'form.type.common_type' - public: true - tags: - - { name: form.type } - - form.type.product.shipping: - class: PrestaShopBundle\Form\Admin\Product\ProductShipping - arguments: - - "@translator" - - "@prestashop.adapter.legacy.context" - - "@prestashop.adapter.data_provider.warehouse" - - "@prestashop.adapter.data_provider.carrier" - parent: 'form.type.common_type' - public: true - tags: - - { name: form.type } - - form.type.product.specific_price: - class: PrestaShopBundle\Form\Admin\Product\ProductSpecificPrice - arguments: - - "@router" - - "@translator" - - "@prestashop.adapter.shop.context" - - "@prestashop.adapter.data_provider.country" - - "@prestashop.adapter.data_provider.currency" - - "@prestashop.adapter.data_provider.group" - - "@prestashop.adapter.legacy.context" - - "@prestashop.adapter.data_provider.customer" - parent: 'form.type.common_type' - public: true - tags: - - { name: form.type } - - form.type.product.supplier_combination: - class: PrestaShopBundle\Form\Admin\Product\ProductSupplierCombination - arguments: - - "@translator" - - "@prestashop.adapter.legacy.context" - - "@prestashop.adapter.data_provider.currency" - parent: 'form.type.common_type' - public: true - tags: - - { name: form.type } - - form.type.product.virtual: - class: PrestaShopBundle\Form\Admin\Product\ProductVirtual - arguments: - - "@translator" - - "@prestashop.adapter.legacy.context" - parent: 'form.type.common_type' - public: true - tags: - - { name: form.type } - - form.type.product.warehouse_combination: - class: PrestaShopBundle\Form\Admin\Product\ProductWarehouseCombination - arguments: - - "@translator" - - "@prestashop.adapter.legacy.context" - parent: 'form.type.common_type' - public: true - tags: - - { name: form.type } - - form.type.typeahead.product: - class: PrestaShopBundle\Form\Admin\Type\TypeaheadProductCollectionType - arguments: - - "@prestashop.adapter.data_provider.product" - - "@prestashop.adapter.data_provider.category" - tags: - - { name: form.type } - - form.type.typeahead.product_pack: - class: PrestaShopBundle\Form\Admin\Type\TypeaheadProductPackCollectionType - arguments: - - "@prestashop.adapter.data_provider.product" - tags: - - { name: form.type } - - form.type.typeahead.customer: - class: PrestaShopBundle\Form\Admin\Type\TypeaheadCustomerCollectionType - arguments: - - "@prestashop.adapter.data_provider.customer" - tags: - - { name: form.type } - - form.type.product.combination_bulk: - class: PrestaShopBundle\Form\Admin\Product\ProductCombinationBulk - arguments: - - "@translator" - - "@prestashop.adapter.legacy.configuration" - tags: - - { name: form.type } - - form.type.product.categories: - class: PrestaShopBundle\Form\Admin\Product\ProductCategories - arguments: - - "@translator" - - "@prestashop.adapter.data_provider.category" - - "@=service('prestashop.adapter.legacy.context').getLanguages()" - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - tags: - - { name: form.type } - - form.type.translatable.aware: - abstract: true - parent: 'form.type.common_type' - public: true - arguments: - - "@translator" - - "@=service('prestashop.adapter.legacy.context').getLanguages()" - - form.type.order.invoices.generate_by_date: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\Invoices\GenerateByDateType' - parent: 'form.type.common_type' - public: true - tags: - - { name: form.type } - - form.type.order.invoices.generate_by_status: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\Invoices\GenerateByStatusType' - parent: 'form.type.common_type' - public: true - arguments: - - '@prestashop.core.form.choice_provider.order_state_by_id' - - '@=service("prestashop.core.api.order_invoice.repository").countByOrderState(service("prestashop.adapter.shop.context").getContextListShopID())' - tags: - - { name: form.type } - - form.type.order.invoices.invoice_options: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\Invoices\InvoiceOptionsType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@prestashop.core.form.choice_provider.invoice_model_by_name' - - '@=service("prestashop.adapter.data_provider.order_invoice").getNextInvoiceNumber()' - tags: - - { name: form.type } - - form.type.performance.smarty: - class: 'PrestaShopBundle\Form\Admin\AdvancedParameters\Performance\SmartyType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.performance.debug_mode: - class: 'PrestaShopBundle\Form\Admin\AdvancedParameters\Performance\DebugModeType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.performance.optional_features: - class: 'PrestaShopBundle\Form\Admin\AdvancedParameters\Performance\OptionalFeaturesType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@=service("prestashop.adapter.combination_feature").isUsed()' - tags: - - { name: form.type } - - form.type.performance.ccc: - class: 'PrestaShopBundle\Form\Admin\AdvancedParameters\Performance\CombineCompressCacheType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.performance.media_servers: - class: 'PrestaShopBundle\Form\Admin\AdvancedParameters\Performance\MediaServersType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.performance.memcache_servers: - class: 'PrestaShopBundle\Form\Admin\AdvancedParameters\Performance\MemcacheServerType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.performance.caching: - class: 'PrestaShopBundle\Form\Admin\AdvancedParameters\Performance\CachingType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.shop_parameters.general: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\General\PreferencesType' - parent: 'form.type.translatable.aware' - arguments: - - '@=service("prestashop.adapter.multistore_feature").isUsed()' - - '@=service("prestashop.adapter.shop.context").isShopContext()' - - '@=service("prestashop.adapter.shop.context").isAllContext()' - public: true - calls: - - ['setIsSecure', ["@=service('request_stack').getCurrentRequest().isSecure()"]] - tags: - - { name: form.type } - - form.type.maintenance.general: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\General\MaintenanceType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.admininistration.general: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Administration\GeneralType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.administration.upload_quota: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Administration\UploadQuotaType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.administration.notification: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Administration\NotificationsType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.common_type: - abstract: true - - form.type.shipping_preferences.handling: - class: 'PrestaShopBundle\Form\Admin\Improve\Shipping\Preferences\HandlingType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@prestashop.adapter.data_provider.currency' - tags: - - { name: form.type } - - form.type.shipping_preferences.carrier_options: - class: 'PrestaShopBundle\Form\Admin\Improve\Shipping\Preferences\CarrierOptionsType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@=service("prestashop.adapter.data_provider.carrier").getActiveCarriersChoices()' - - '@=service("prestashop.adapter.data_provider.carrier").getOrderByChoices()' - - '@=service("prestashop.adapter.data_provider.carrier").getOrderWayChoices()' - tags: - - { name: form.type } - - form.type.product_preferences.general: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\ProductPreferences\GeneralType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.product_preferences.stock: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\ProductPreferences\StockType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.customer_preferences.general: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\CustomerPreferences\GeneralType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.order_preferences.general: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\OrderPreferences\GeneralType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@=service("prestashop.adapter.data_provider.currency").getDefaultCurrencyIsoCode()' - - '@=service("prestashop.adapter.data_provider.cms").getCmsChoices()' - tags: - - { name: form.type } - - form.type.order_preferences.gift_options: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\OrderPreferences\GiftOptionsType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@=service("prestashop.adapter.data_provider.currency").getDefaultCurrencyIsoCode()' - - '@=service("prestashop.adapter.data_provider.tax").getTaxRulesGroupChoices()' - tags: - - { name: form.type } - - form.type.import.import: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Import\ImportType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.order.delivery.slip.options: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\Delivery\SlipOptionsType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.localization_configuration: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Localization\LocalizationConfigurationType' - arguments: - - '@=service("prestashop.core.form.choice_provider.language_by_id").getChoices()' - - '@=service("prestashop.core.form.choice_provider.country_by_id").getChoices()' - - '@=service("prestashop.core.form.choice_provider.currency_by_id").getChoices()' - - '@=service("prestashop.core.form.choice_provider.timezone_by_name").getChoices()' - tags: - - { name: form.type } - - form.type.localization.import_pack: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Localization\ImportLocalizationPackType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@=service("prestashop.core.form.choice_provider.localization_pack_by_iso_code").getChoices()' - tags: - - { name: form.type } - - form.type.geolocation.options: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Geolocation\GeolocationOptionsType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@=service("prestashop.core.form.choice_provider.country_by_iso_code").getChoices()' - - '@prestashop.adapter.legacy.configuration' - tags: - - { name: form.type } - - form.type.payment.module_currency_restriction: - class: 'PrestaShopBundle\Form\Admin\Improve\Payment\Preferences\PaymentModulePreferencesType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@=service("prestashop.adapter.module.payment_module_provider").getPaymentModuleList()' - - '@=service("prestashop.core.form.choice_provider.country_by_id").getChoices()' - - '@=service("prestashop.core.form.choice_provider.group_by_id").getChoices()' - - '@=service("prestashop.core.form.choice_provider.carrier_by_reference_id").getChoices()' - - '@=service("prestashop.core.form.choice_provider.currency_by_id").getChoices()' - - '@prestashop.adapter.data_provider.country' - tags: - - { name: form.type } - - form.type.email.email_configuration: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Email\EmailConfigurationType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@prestashop.core.form.choice_provider.mail_method' - - '@prestashop.core.form.choice_provider.contact_by_id' - tags: - - { name: form.type } - - form.type.translations.modify: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Translations\ModifyTranslationsType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@=service("prestashop.core.form.choice_provider.translation_type").getChoices()' - - '@=service("prestashop.core.form.choice_provider.email_content_type").getChoices()' - - '@=service("prestashop.core.form.choice_provider.theme_by_name").getChoices()' - - '@=service("prestashop.core.form.choice_provider.module_by_name").getChoices()' - tags: - - { name: form.type } - - form.type.translations.add_update_language: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Translations\AddUpdateLanguageType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@=service("prestashop.core.form.choice_provider.non_installed_localization").getChoices()' - tags: - - { name: form.type } - - form.type.translations.export_language: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Translations\ExportThemeLanguageType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@=service("prestashop.core.form.choice_provider.theme_by_name").getChoices()' - tags: - - { name: form.type } - - form.type.translations.copy_language: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Translations\CopyLanguageType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@=service("prestashop.core.form.choice_provider.theme_by_name").getChoices()' - tags: - - { name: form.type } - - form.type.shop.traffic_seo.meta.set_up_url: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\TrafficSeo\Meta\SetUpUrlType' - arguments: - - '@=service("prestashop.core.form.choice_provider.canonical_redirect_type").getChoices()' - - '@=service("prestashop.core.util.url.url_file_checker").isHtaccessFileWritable()' - - '@=service("prestashop.adapter.hosting_information").isHostMode()' - tags: - - { name: form.type } - - form.type.shop.traffic_seo.meta.shop_url: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\TrafficSeo\Meta\ShopUrlType' - arguments: - - '@=service("prestashop.adapter.hosting_information").isHostMode()' - - '@=service("prestashop.adapter.multistore_feature").isActive()' - - '@=service("prestashop.adapter.shop.shop_url").doesMainShopUrlExist()' - tags: - - { name: form.type } - - form.type.shop.traffic_seo.meta.url_schema: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\TrafficSeo\Meta\UrlSchemaType' - arguments: - - '@=service("prestashop.adapter.legacy.configuration").get("PS_REWRITING_SETTINGS")' - tags: - - { name: form.type } - - form.type.shop.traffic_seo.meta: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\TrafficSeo\Meta\MetaType' - arguments: - - '@=service("prestashop.core.form.choice_provider.default_meta_page_name").getChoices()' - - '@=service("prestashop.core.form.choice_provider.module_meta_page_name").getChoices()' - calls: - - { method: setTranslator, arguments: ['@translator'] } - tags: - - { name: form.type } - - form.type.catalog.abstract_category: - class: 'PrestaShopBundle\Form\Admin\Catalog\Category\AbstractCategoryType' - abstract: true - parent: 'form.type.translatable.aware' - arguments: - - '@=service("prestashop.core.form.choice_provider.group_by_id").getChoices()' - - '@prestashop.adapter.feature.multistore' - - '@prestashop.adapter.legacy.configuration' - public: true - - form.type.category.delete_categories: - class: 'PrestaShopBundle\Form\Admin\Sell\Category\DeleteCategoriesType' - arguments: - - '@=service("prestashop.core.form.choice_provider.category_delete_mode").getChoices()' - tags: - - { name: form.type } - - from.type.yes_and_no_choice: - class: 'PrestaShopBundle\Form\Admin\Type\YesAndNoChoiceType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.team.employee.employee_options: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Employee\EmployeeOptionsType' - parent: 'form.type.translatable.aware' - arguments: - - '@=service("prestashop.core.team.employee.configuration.options_checker").canBeChanged()' - public: true - tags: - - { name: form.type } - - form.type.common.team.profile_choice: - class: 'PrestaShopBundle\Form\Admin\Type\Common\Team\ProfileChoiceType' - arguments: - - '@=service("prestashop.adapter.form.choice_provider.profile_by_id_choice_provider").getChoices()' - tags: - - { name: form.type } - - form.type.import.import_data_configuration: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Import\ImportDataConfigurationType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@=service("prestashop.core.form.choice_provider.import_match_configuration").getChoices()' - - '@=service("prestashop.core.form.choice_provider.import_entity_field").getChoices()' - - form.type.common.country_choice: - class: 'PrestaShopBundle\Form\Admin\Type\CountryChoiceType' - arguments: - - '@prestashop.core.form.choice_provider.country_by_id' - - '@prestashop.core.form.choice_provider.country_by_id' - tags: - - { name: form.type } - - form.type.design.theme.page_layouts_customization: - class: 'PrestaShopBundle\Form\Admin\Improve\Design\Theme\PageLayoutsCustomizationType' - arguments: - - '@=service("prestashop.core.form.choice_provider.theme_page_layouts").getChoices()' - tags: - - { name: form.type } - - form.type.catalog.category: - class: 'PrestaShopBundle\Form\Admin\Catalog\Category\CategoryType' - parent: 'form.type.catalog.abstract_category' - public: true - tags: - - { name: form.type } - - form.type.catalog.root_category: - class: 'PrestaShopBundle\Form\Admin\Catalog\Category\RootCategoryType' - parent: 'form.type.catalog.abstract_category' - public: true - tags: - - { name: form.type } - - form.type.common.category_choice_tree: - class: 'PrestaShopBundle\Form\Admin\Type\CategoryChoiceTreeType' - arguments: - - '@=service("prestashop.adapter.form.choice_provider.category_tree_choice_provider").getChoices()' - tags: - - { name: form.type } - - form.type.common.translatable: - class: 'PrestaShopBundle\Form\Admin\Type\TranslatableType' - arguments: - - "@=service('prestashop.adapter.legacy.context').getAvailableLanguages()" - - '@router.default' - - "@=service('prestashop.adapter.legacy.configuration').getBoolean('PS_BO_ALLOW_EMPLOYEE_FORM_LANG')" - - "@=service('prestashop.adapter.legacy.context').getContext().cookie.employee_form_lang" - - "@=service('prestashop.adapter.legacy.configuration').getInt('PS_LANG_DEFAULT')" - tags: - - { name: form.type } - - form.type.common.shop_choice_tree: - class: 'PrestaShopBundle\Form\Admin\Type\ShopChoiceTreeType' - arguments: - - "@=service('prestashop.adapter.form.choice_provider.shop_tree_choice_provider').getChoices()" - - '@prestashop.bundle.form.data_transformer.string_array_to_integer_array' - tags: - - { name: form.type } - - form.type.search_and_reset: - class: 'PrestaShopBundle\Form\Admin\Type\SearchAndResetType' - arguments: - - '@router.default' - tags: - - { name: form.type } - - form.type.database.sql_request: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\RequestSql\SqlRequestType' - calls: - - { method: setTranslator, arguments: ['@translator'] } - tags: - - { name: form.type } - - form.type.customer.required_fields: - class: 'PrestaShopBundle\Form\Admin\Sell\Customer\RequiredFieldsType' - arguments: - - '@=service("prestashop.core.form.choice_provider.customer_required_fields").getChoices()' - tags: - - { name: form.type } - - prestashop.bundle.form.admin.sell.customer.customer: - class: 'PrestaShopBundle\Form\Admin\Sell\Customer\CustomerType' - arguments: - - '@=service("prestashop.adapter.form.choice_provider.gender_by_id_choice_provider").getChoices()' - - '@=service("prestashop.adapter.form.choice_provider.group_by_id_choice_provider").getChoices()' - - '@=service("prestashop.adapter.form.choice_provider.risk_by_id_choice_provider").getChoices()' - - '@=service("prestashop.core.b2b.b2b_feature").isActive()' - - '@=service("prestashop.adapter.legacy.configuration").get("PS_CUSTOMER_OPTIN")' - calls: - - { method: setTranslator, arguments: ['@translator'] } - tags: - - { name: form.type } - - form.type.currency: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Currencies\CurrencyType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@=service("prestashop.core.form.choice_provider.currency_name_by_iso_code").getChoices()' - - '@=service("prestashop.adapter.multistore_feature").isUsed()' - tags: - - { name: form.type } - - form.type.customer.delete_customer: - class: 'PrestaShopBundle\Form\Admin\Sell\Customer\DeleteCustomersType' - arguments: - - '@=service("prestashop.core.form.choice_provider.customer_delete_method").getChoices()' - tags: - - { name: form.type } - - form.type.design.theme.import_theme: - class: 'PrestaShopBundle\Form\Admin\Improve\Design\Theme\ImportThemeType' - arguments: - - '@=service("prestashop.core.form.choice_provider.theme_zip").getChoices()' - calls: - - { method: setTranslator, arguments: ['@translator'] } - tags: - - { name: form.type } - - form.type.design.theme.adapt_theme_to_rtl_languages: - class: 'PrestaShopBundle\Form\Admin\Improve\Design\Theme\AdaptThemeToRTLLanguagesType' - arguments: - - '@=service("prestashop.core.form.choice_provider.theme").getChoices()' - tags: - - { name: form.type } - - form.type.international.language: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Language\LanguageType' - arguments: - - '@=service("prestashop.adapter.multistore_feature").isActive()' - calls: - - { method: setTranslator, arguments: ['@translator'] } - tags: - - { name: form.type } - - form.type.currency_exchange_rate: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Currencies\CurrencyExchangeRateType' - arguments: - - '@=service("prestashop.adapter.data_provider.module").isInstalled("cronjobs")' - tags: - - { name: form.type } - - form.type.international.tax_options: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Tax\TaxOptionsType' - arguments: - - '@=service("prestashop.adapter.legacy.configuration").getBoolean("PS_USE_ECOTAX")' - - '@=service("prestashop.core.form.choice_provider.tax_address_type_choice_provider")' - - '@=service("prestashop.core.form.choice_provider.tax_rule_group_choice_provider")' - tags: - - { name: form.type } - - form.type.contact: - class: 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\Contact\ContactType' - arguments: - - '@prestashop.bundle.form.data_transformer.default_language_to_filled_array' - - '@=service("prestashop.adapter.multistore_feature").isUsed()' - calls: - - { method: setTranslator, arguments: ['@translator'] } - tags: - - { name: form.type } - - form.type.cms_page_category: - class: 'PrestaShopBundle\Form\Admin\Improve\Design\Pages\CmsPageCategoryType' - arguments: - - '@=service("prestashop.core.form.choice_provider.cms_categories").getChoices()' - - '@=service("prestashop.adapter.multistore_feature").isUsed()' - calls: - - { method: setTranslator, arguments: ['@translator'] } - tags: - - { name: form.type } - - form.type.international.tax: - class: 'PrestaShopBundle\Form\Admin\Improve\International\Tax\TaxType' - arguments: - - '@translator' - tags: - - { name: form.type } - - form.type.sell.manufacturer: - class: 'PrestaShopBundle\Form\Admin\Sell\Manufacturer\ManufacturerType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@=service("prestashop.adapter.multistore_feature").isActive()' - tags: - - { name: form.type } - - prestashop.bundle.form.admin.configure.advanced_parameters.employee.employee: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Employee\EmployeeType' - arguments: - - '@=service("prestashop.core.form.choice_provider.all_languages").getChoices()' - - '@=service("prestashop.core.form.choice_provider.accessible_tab").getChoices()' - - '@=service("prestashop.core.form.choice_provider.profile").getChoices()' - - '@=service("prestashop.adapter.multistore_feature").isActive()' - - '@=service("prestashop.adapter.employee.avatar_provider").getDefaultAvatarUrl()' - calls: - - { method: setTranslator, arguments: ['@translator'] } - tags: - - { name: form.type } - - form.type.change_password: - class: 'PrestaShopBundle\Form\Admin\Type\ChangePasswordType' - calls: - - { method: setTranslator, arguments: ['@translator'] } - tags: - - { name: form.type } - - form.type.addons_connect: - class: 'PrestaShopBundle\Form\Admin\Type\AddonsConnectType' - arguments: - - '@=service("prestashop.adapter.admin.data_provider.addons").isAddonsAuthenticated()' - - '@=service("prestashop.adapter.admin.data_provider.addons").getAddonsEmail()["username_addons"]' - tags: - - { name: form.type } - - form.type.cms_page: - class: 'PrestaShopBundle\Form\Admin\Improve\Design\Pages\CmsPageType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@=service("prestashop.core.form.choice_provider.cms_categories").getChoices()' - - '@=service("prestashop.adapter.multistore_feature").isUsed()' - tags: - - { name: form.type } - - form.type.manufacturer_address: - class: 'PrestaShopBundle\Form\Admin\Sell\Address\ManufacturerAddressType' - arguments: - - '@=service("prestashop.adapter.form.choice_provider.manufacturer_name_by_id").getChoices()' - - '@=service("prestashop.core.form.choice_provider.country_by_id").getChoices()' - - '@prestashop.adapter.form.choice_provider.country_state_by_id' - - '@=service("prestashop.adapter.legacy.context").getContext().country.id' - - '@translator' - - '@=service("prestashop.core.form.choice_provider.country_by_id").getChoicesAttributes()' - tags: - - { name: form.type } - - form.type.shop_logos: - class: 'PrestaShopBundle\Form\Admin\Improve\Design\Theme\ShopLogosType' - arguments: - - '@=service("prestashop.adapter.multistore_feature").isUsed()' - - '@=service("prestashop.adapter.shop.context").isSingleShopContext()' - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - tags: - - { name: form.type } - - form.type.localization.generate_mails: - class: 'PrestaShopBundle\Form\Admin\Improve\Design\MailTheme\GenerateMailsType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@=service("prestashop.core.form.choice_provider.mail_themes").getChoices()' - - '@=service("prestashop.core.form.choice_provider.theme_by_name_with_emails").getChoices()' - tags: - - { name: form.type } - - form.type.localization.mail_theme_configuration: - class: 'PrestaShopBundle\Form\Admin\Improve\Design\MailTheme\MailThemeConfigurationType' - public: true - arguments: - - '@=service("prestashop.core.form.choice_provider.mail_themes").getChoices()' - tags: - - { name: form.type } - - form.type.integer_min_max_filter: - class: 'PrestaShopBundle\Form\Admin\Type\IntegerMinMaxFilterType' - public: true - calls: - - { method: setTranslator, arguments: ['@translator'] } - tags: - - { name: form.type } - - form.type.number_min_max_filter: - class: 'PrestaShopBundle\Form\Admin\Type\NumberMinMaxFilterType' - public: true - calls: - - { method: setTranslator, arguments: ['@translator'] } - tags: - - { name: form.type } - - form.type.order.change_order_statuses: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\ChangeOrdersStatusType' - public: true - arguments: - - '@prestashop.core.form.choice_provider.order_state_by_id' - tags: - - { name: form.type } - - form.type.sell.supplier: - class: 'PrestaShopBundle\Form\Admin\Sell\Supplier\SupplierType' - arguments: - - '@=service("prestashop.core.form.choice_provider.country_by_id").getChoices()' - - '@=service("prestashop.core.form.choice_provider.country_by_id").getChoicesAttributes()' - - '@prestashop.adapter.form.choice_provider.country_state_by_id' - - '@=service("prestashop.adapter.legacy.context").getContext().country.id' - - '@translator' - - '@=service("prestashop.adapter.multistore_feature").isActive()' - - "@=service('prestashop.adapter.legacy.context').getLanguages()" - tags: - - { name: form.type } - - form.type.sell.catalog_price_rule: - class: 'PrestaShopBundle\Form\Admin\Sell\CatalogPriceRule\CatalogPriceRuleType' - public: true - arguments: - - '@translator' - - '@=service("prestashop.adapter.multistore_feature").isUsed()' - - '@=service("prestashop.core.form.choice_provider.currency_by_id").getChoices()' - - '@=service("prestashop.core.form.choice_provider.country_by_id").getChoices()' - - '@=service("prestashop.core.form.choice_provider.group_by_id").getChoices()' - - '@=service("prestashop.adapter.form.choice_provider.shop_name_by_id").getChoices()' - - '@=service("prestashop.core.form.choice_provider.tax_inclusion").getChoices()' - tags: - - { name: form.type } - - form.type.reduction: - class: 'PrestaShopBundle\Form\Admin\Type\ReductionType' - parent: 'form.type.common_type' - arguments: - - '@=service("prestashop.core.form.choice_provider.price_reduction_type").getChoices()' - public: true - tags: - - { name: form.type } - - form.type.sell.customer.private_note: - class: 'PrestaShopBundle\Form\Admin\Sell\Customer\PrivateNoteType' - arguments: - - "@translator" - tags: - - { name: form.type } - - form.type.order.add_order_cart_rule: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\AddOrderCartRuleType' - arguments: - - '@prestashop.core.form.choice.provider.order_discount_type' - - '@prestashop.adapter.form.choice_provider.order_invoice_by_id' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - - '@translator' - tags: - - { name: form.type } - - form.type.order.add_product_row: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\AddProductRowType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@prestashop.adapter.form.choice_provider.order_invoice_by_id' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - tags: - - { name: form.type } - - form.type.order.edit_product_row: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\EditProductRowType' - parent: 'form.type.translatable.aware' - public: true - arguments: - - '@prestashop.adapter.form.choice_provider.order_invoice_by_id' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - tags: - - { name: form.type } - - form.type.order.update_order_status: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\UpdateOrderStatusType' - arguments: - - '@prestashop.core.form.choice_provider.order_state_by_id' - - '@=service("prestashop.core.form.choice_provider.order_state_by_id").getChoicesAttributes()' - tags: - - { name: form.type } - - form.type.order.order_payment: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\OrderPaymentType' - arguments: - - '@translator' - - '@prestashop.adapter.form.choice_provider.currency_symbol_by_id' - - '@prestashop.adapter.form.choice_provider.order_invoice_by_id' - - '@prestashop.adapter.form.choice_provider.installed_payment_modules' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id' - tags: - - { name: form.type } - - form.type.feature: - class: 'PrestaShopBundle\Form\Admin\Sell\Catalog\FeatureType' - arguments: - - '@=service("prestashop.adapter.multistore_feature").isUsed()' - calls: - - { method: setTranslator, arguments: ['@translator'] } - tags: - - { name: form.type } - - form.type.order.change_order_currency: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\ChangeOrderCurrencyType' - arguments: - - '@prestashop.core.form.choice_provider.currency_by_id' - tags: - - { name: form.type } - - form.type.localization.translate_mails_body: - class: 'PrestaShopBundle\Form\Admin\Improve\Design\MailTheme\TranslateMailsBodyType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.order.update_order_shipping: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\UpdateOrderShippingType' - arguments: - - '@prestashop.adapter.form.choice.provider.carrier_for_order_choice_provider' - tags: - - { name: form.type } - - form.type.address.required_fields: - class: 'PrestaShopBundle\Form\Admin\Sell\Address\RequiredFieldsAddressType' - arguments: - - '@prestashop.core.form.choice_provider.address_required_fields' - tags: - - { name: form.type } - - form.type.customer_service.reply_to_customer_thread: - class: 'PrestaShopBundle\Form\Admin\Sell\CustomerService\ReplyToCustomerThreadType' - public: true - arguments: - - '@translator' - tags: - - { name: form.type } - - form.type.customer_service.forward_customer_thread: - class: 'PrestaShopBundle\Form\Admin\CustomerService\CustomerThread\ForwardCustomerThreadType' - public: true - arguments: - - '@translator' - - '@prestashop.adapter.form.choice_provider.employee_name_by_id' - tags: - - { name: form.type } - - form.type.order.credit_slip.generate_pdf_by_date: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\CreditSlip\GeneratePdfByDateType' - parent: 'form.type.common_type' - arguments: - - '@translator' - public: true - tags: - - { name: form.type } - - form.type.order.credit_slip.credit_slip_options: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\CreditSlip\CreditSlipOptionsType' - parent: 'form.type.common_type' - arguments: - - '@translator' - public: true - tags: - - { name: form.type } - - form.type.order.change_order_address: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\ChangeOrderAddressType' - arguments: - - '@prestashop.core.form.choice_provider.customer_addresses_by_id' - tags: - - { name: form.type } - - form.type.order.message: - class: 'PrestaShopBundle\Form\Admin\Sell\CustomerService\OrderMessageType' - tags: - - { name: form.type } - - form.type.order.customer_service_message: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\OrderMessageType' - arguments: - - '@prestashop.core.form.choice_provider.customer_service_order_messages_name' - - '@prestashop.core.form.choice_provider.customer_service_order_messages' - calls: - - { method: setTranslator, arguments: ['@translator'] } - tags: - - { name: form.type } - - form.type.customer_address: - class: 'PrestaShopBundle\Form\Admin\Sell\Address\CustomerAddressType' - arguments: - - '@translator' - - '@prestashop.adapter.form.choice_provider.country_state_by_id' - - '@=service("prestashop.adapter.legacy.context").getContext().country.id' - tags: - - { name: form.type } - - prestashop.bundle.form.admin.sell.attachment.attachment: - class: 'PrestaShopBundle\Form\Admin\Sell\Attachment\AttachmentType' - calls: - - { method: setTranslator, arguments: ['@translator'] } - tags: - - { name: form.type } - - form.type.order.cancel_product: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\CancelProductType' - parent: 'form.type.translatable.aware' - public: true - tags: - - { name: form.type } - - form.type.order.cart_summary: - class: 'PrestaShopBundle\Form\Admin\Sell\Order\CartSummaryType' - arguments: - - '@prestashop.core.form.choice_provider.order_state_by_id' - - '@prestashop.adapter.form.choice_provider.installed_payment_modules' - - '@translator' - tags: - - { name: form.type } - - form.type.configure.advanced_parameters.profile: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Profile\ProfileType' - public: true - arguments: - - '@translator' - tags: - - { name: form.type } diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_type/webservice.yml b/src/PrestaShopBundle/Resources/config/services/bundle/form/form_type/webservice.yml deleted file mode 100644 index 9c8f14bc..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_type/webservice.yml +++ /dev/null @@ -1,14 +0,0 @@ -services: - _defaults: - public: true - - form.type.webservice.webservice_key_type: - class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Webservice\WebserviceKeyType' - arguments: - - '@=service("prestashop.adapter.multistore_feature").isUsed()' - - '@=service("prestashop.adapter.form.choice_provider.resources_choice_provider").getChoices()' - - '@=service("prestashop.core.form.choice_provider.permissions_choice_provider").getChoices()' - calls: - - { method: setTranslator, arguments: ['@translator'] } - tags: - - { name: form.type } diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/grid.yml b/src/PrestaShopBundle/Resources/config/services/bundle/grid.yml deleted file mode 100644 index 229f4805..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/grid.yml +++ /dev/null @@ -1,15 +0,0 @@ -services: - _defaults: - public: true - - prestashop.bundle.grid.response_builder: - class: PrestaShopBundle\Service\Grid\ResponseBuilder - arguments: - - '@prestashop.core.grid.filter.form_factory' - - '@router' - - prestashop.bundle.grid.controller_response_builder: - class: PrestaShopBundle\Service\Grid\ControllerResponseBuilder - arguments: - - '@prestashop.core.grid.filter.form_factory' - - '@router' diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/repository.yml b/src/PrestaShopBundle/Resources/config/services/bundle/repository.yml deleted file mode 100644 index 4772eaaa..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/repository.yml +++ /dev/null @@ -1,123 +0,0 @@ -services: - _defaults: - public: true - - prestashop.module_kernel.repository: - class: 'PrestaShopBundle\Kernel\ModuleRepository' - arguments: ['@doctrine.dbal.default_connection', '%database_prefix%'] - - prestashop.core.admin.tab.repository: - class: PrestaShopBundle\Entity\Repository\TabRepository - factory: ['@doctrine.orm.default_entity_manager', getRepository] - arguments: - - PrestaShopBundle\Entity\Tab - - prestashop.core.admin.shop.repository: - class: 'PrestaShopBundle\Entity\Repository\ShopRepository' - factory: ['@doctrine.orm.default_entity_manager', getRepository] - arguments: - - 'PrestaShopBundle\Entity\Shop' - - prestashop.core.admin.translation.repository: - class: PrestaShopBundle\Entity\Repository\TranslationRepository - factory: ['@doctrine.orm.default_entity_manager', getRepository] - arguments: - - PrestaShopBundle\Entity\Translation - - prestashop.core.admin.lang.repository: - class: PrestaShopBundle\Entity\Repository\LangRepository - factory: ['@doctrine.orm.default_entity_manager', getRepository] - arguments: - - PrestaShopBundle\Entity\Lang - - prestashop.core.admin.log.repository: - class: PrestaShopBundle\Entity\Repository\LogRepository - arguments: - - '@doctrine.dbal.default_connection' - - '%database_prefix%' - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - prestashop.core.api.stock.repository: - class: PrestaShopBundle\Entity\Repository\StockRepository - arguments: - - "@service_container" - - "@doctrine.dbal.default_connection" - - "@doctrine.orm.default_entity_manager" - - "@prestashop.adapter.legacy.context" - - "@prestashop.adapter.image_manager" - - "@prestashop.adapter.stock_manager" - - "%database_prefix%" - - prestashop.core.api.stock_movement.repository: - class: PrestaShopBundle\Entity\Repository\StockMovementRepository - arguments: - - "@service_container" - - "@doctrine.dbal.default_connection" - - "@doctrine.orm.default_entity_manager" - - "@prestashop.adapter.legacy.context" - - "@prestashop.adapter.image_manager" - - "%database_prefix%" - - prestashop.core.api.supplier.repository: - class: PrestaShopBundle\Entity\Repository\SupplierRepository - arguments: - - "@doctrine.dbal.default_connection" - - "@prestashop.adapter.legacy.context" - - "%database_prefix%" - - prestashop.core.api.manufacturer.repository: - class: PrestaShopBundle\Entity\Repository\ManufacturerRepository - arguments: - - "@doctrine.dbal.default_connection" - - "@prestashop.adapter.legacy.context" - - "%database_prefix%" - - prestashop.core.api.category.repository: - class: PrestaShopBundle\Entity\Repository\CategoryRepository - arguments: - - "@doctrine.dbal.default_connection" - - "@prestashop.adapter.legacy.context" - - "%database_prefix%" - - prestashop.core.api.feature_attribute.repository: - class: PrestaShopBundle\Entity\Repository\FeatureAttributeRepository - arguments: - - "@doctrine.dbal.default_connection" - - "@prestashop.adapter.legacy.context" - - "%database_prefix%" - - prestashop.core.admin.timezone.repository: - class: PrestaShopBundle\Entity\Repository\TimezoneRepository - arguments: - - '@doctrine.dbal.default_connection' - - '%database_prefix%' - - prestashop.core.admin.import_match.repository: - class: PrestaShopBundle\Entity\Repository\ImportMatchRepository - arguments: - - '@doctrine.dbal.default_connection' - - '%database_prefix%' - - prestashop.bundle.repository.module: - class: PrestaShopBundle\Entity\Repository\ModuleRepository - arguments: - - '@doctrine.dbal.default_connection' - - '%database_prefix%' - - prestashop.core.admin.request_sql.repository: - class: PrestaShopBundle\Entity\Repository\RequestSqlRepository - arguments: - - '@doctrine.dbal.default_connection' - - '%database_prefix%' - - prestashop.core.admin.admin_filter.repository: - class: PrestaShopBundle\Entity\Repository\AdminFilterRepository - factory: ['@doctrine.orm.default_entity_manager', getRepository] - arguments: - - PrestaShopBundle\Entity\AdminFilter - - prestashop.core.api.order_invoice.repository: - class: PrestaShopBundle\Entity\Repository\OrderInvoiceRepository - arguments: - - "@doctrine.dbal.default_connection" - - "%database_prefix%" diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/routing.yml b/src/PrestaShopBundle/Resources/config/services/bundle/routing.yml deleted file mode 100644 index d08f42da..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/routing.yml +++ /dev/null @@ -1,59 +0,0 @@ -services: - prestashop.bundle.routing.module_route_loader: - class: 'PrestaShopBundle\Routing\YamlModuleLoader' - arguments: - - '@=service("prestashop.module_kernel.repository").getActiveModulesPaths()' - tags: [routing.loader] - - prestashop.bundle.routing.converter.legacy_url_converter: - class: 'PrestaShopBundle\Routing\Converter\LegacyUrlConverter' - public: true - arguments: - - '@router' - - '@prestashop.bundle.routing.converter.cache_provider' - - prestashop.bundle.routing.converter.legacy_parameters_converter: - class: 'PrestaShopBundle\Routing\Converter\LegacyParametersConverter' - public: true - - prestashop.bundle.routing.converter.router_provider: - class: 'PrestaShopBundle\Routing\Converter\RouterProvider' - arguments: - - '@router' - - # We set this alias so that we can override it in test environment (to avoid memory limit crashes) - prestashop.bundle.routing.converter.cache: - alias: Symfony\Component\Cache\Adapter\AdapterInterface - - prestashop.bundle.routing.converter.cache_provider: - class: 'PrestaShopBundle\Routing\Converter\CacheProvider' - arguments: - - '@prestashop.bundle.routing.converter.router_provider' - - '@prestashop.bundle.routing.converter.cache' - - '@prestashop.bundle.routing.converter.routing_cache_key_generator' - - prestashop.bundle.routing.converter.routing_cache_key_generator: - class: 'PrestaShopBundle\Routing\Converter\RoutingCacheKeyGenerator' - arguments: - - ["%kernel.project_dir%/src/PrestaShopBundle/Resources/config/routing/admin"] - - '@=service("prestashop.module_kernel.repository").getActiveModulesPaths()' - - '%kernel.environment%' - - prestashop.bundle.routing.linter.security_annotation_linter: - class: 'PrestaShopBundle\Routing\Linter\SecurityAnnotationLinter' - arguments: - - '@annotation_reader' - - '@controller_name_converter' - - prestashop.bundle.routing.linter.naming_convention_linter: - class: 'PrestaShopBundle\Routing\Linter\NamingConventionLinter' - arguments: - - '@controller_name_converter' - - prestashop.bundle.routing.linter.legacy_link_linter: - class: 'PrestaShopBundle\Routing\Linter\LegacyLinkLinter' - - prestashop.bundle.routing.linter.admin_route_provider: - class: 'PrestaShopBundle\Routing\Linter\AdminRouteProvider' - arguments: - - '@router' diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/security.yml b/src/PrestaShopBundle/Resources/config/services/bundle/security.yml deleted file mode 100644 index 2d66d0e0..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/security.yml +++ /dev/null @@ -1,21 +0,0 @@ -parameters: - prestashop.security.voter.product.class: PrestaShopBundle\Security\Voter\PageVoter - -services: - _defaults: - public: true - - prestashop.security.admin.provider: - class: PrestaShopBundle\Security\Admin\EmployeeProvider - arguments: - - "@prestashop.adapter.legacy.context" - - "@prestashop.static_cache.adapter" - - prestashop.security.role.dynamic_role_hierarchy: - class: PrestaShopBundle\Security\Role\DynamicRoleHierarchy - - prestashop.security.voter.product: - class: "%prestashop.security.voter.product.class%" - tags: - - { name: security.voter } - public: false diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/services.yml b/src/PrestaShopBundle/Resources/config/services/bundle/services.yml deleted file mode 100644 index b05f2c4c..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/services.yml +++ /dev/null @@ -1,108 +0,0 @@ -parameters: - ps_root_dir: "%kernel.root_dir%/../" - ps_config_dir: "%ps_root_dir%config" - translations_dir: "%kernel.root_dir%/Resources/translations" - themes_translations_dir: "%kernel.cache_dir%/themes" - modules_dir: "%kernel.root_dir%/../modules" - themes_dir: "%kernel.root_dir%/../themes" - -services: - _defaults: - public: true - - # Interfaced services to decorate - prestashop.core.admin.data_provider.product_interface: - class: PrestaShopBundle\Service\DataProvider\Admin\ProductInterface - prestashop.core.admin.data_updater.product_interface: - class: PrestaShopBundle\Service\DataUpdater\Admin\ProductInterface - prestashop.core.admin.page_preference_interface: - class: PrestaShopBundle\Service\TransitionalBehavior\AdminPagePreferenceInterface - prestashop.core.admin.data_provider.addons_interface: - class: PrestaShopBundle\Service\DataProvider\Admin\AddonsInterface - prestashop.core.admin.data_provider.module_interface: - class: PrestaShopBundle\Service\DataProvider\Admin\ModuleInterface - - # URL generation - prestashop.core.admin.url_generator_factory: - class: PrestaShopBundle\Service\TransitionalBehavior\AdminUrlGeneratorFactory - arguments: - - "@router" - - prestashop.core.admin.url_generator_legacy: - class: Symfony\Component\Routing\Generator\UrlGeneratorInterface - factory: ["@prestashop.core.admin.url_generator_factory", forLegacy] - arguments: - - "@prestashop.adapter.legacy.context" - - prestashop.core.admin.url_generator: - class: Symfony\Component\Routing\Generator\UrlGeneratorInterface - factory: ["@prestashop.core.admin.url_generator_factory", forSymfony] - - prestashop.database.naming_strategy: - class: PrestaShopBundle\Service\Database\DoctrineNamingStrategy - arguments: ["%database_prefix%"] - - prestashop.data_provider.modules.recommended: - class: PrestaShopBundle\Service\DataProvider\Admin\RecommendedModules - arguments: ["@router"] - - prestashop.service.product: - class: PrestaShopBundle\Service\ProductService - arguments: - - "@prestashop.adapter.data_provider.product" - - prestashop.service.translation: - class: PrestaShopBundle\Service\TranslationService - properties: - container: "@service_container" - - # Interfaced services to decorate - prestashop.core.data_provider.stock_interface: - class: PrestaShopBundle\Service\DataProvider\StockInterface - - # DISPATCHERS - prestashop.hook.dispatcher: - class: PrestaShop\PrestaShop\Adapter\Hook\HookDispatcher - calls: - - [addSubscriber, ["@prestashop.adapter.legacy.hook.subscriber"]] - - [addSubscriber, ["@prestashop.adapter.legacy.block.helper.subscriber"]] - - prestashop.hook.finder: - class: PrestaShopBundle\Service\Hook\HookFinder - - # EVENT HANDLER - prestashop.handler.log: - class: PrestaShopBundle\Service\Log\LogHandler - arguments: - - "@service_container" - - # CSRF/XSS additional protection middleware - prestashop.user_provider: - class: PrestaShopBundle\Service\DataProvider\UserProvider - arguments: ['@security.token_storage'] - - prestashop.router: - class: PrestaShopBundle\Service\Routing\Router - parent: 'router.default' - public: true - calls: - - ['setTokenManager', ['@security.csrf.token_manager']] - - ['setUserProvider', ["@=service('prestashop.user_provider')"]] - - # Addons API Client - prestashop.addons.client_api: - class: PrestaShopBundle\Service\DataProvider\Marketplace\ApiClient - arguments: - - "@csa_guzzle.client.addons_api" - - "@=service('translator').getLocale()" - - "@=service('prestashop.adapter.data_provider.country').getIsoCodebyId()" - - "@prestashop.adapter.tools" - - "@=service('prestashop.adapter.legacy.configuration').get('_PS_BASE_URL_')" - - "@=service('prestashop.core.foundation.version').getVersion()" - calls: - - [ "setSslVerification", ["%prestashop.addons.api_client.verify_ssl%"]] - - # Product CSV Exporter - prestashop.core.product.csv_exporter: - class: PrestaShop\PrestaShop\Core\Product\ProductCsvExporter - arguments: ['@translator', '@prestashop.core.admin.data_provider.product_interface'] diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/translation.yml b/src/PrestaShopBundle/Resources/config/services/bundle/translation.yml deleted file mode 100644 index 3fd9d2e5..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/translation.yml +++ /dev/null @@ -1,189 +0,0 @@ -services: - _defaults: - public: true - - #TRANSLATIONS FACTORIES - prestashop.translation.translations_factory: - class: PrestaShopBundle\Translation\Factory\TranslationsFactory - - ps.translations_factory: - alias: "prestashop.translation.translations_factory" - - prestashop.translation.theme_translations_factory: - class: PrestaShopBundle\Translation\Factory\ThemeTranslationsFactory - arguments: ['@prestashop.translation.theme_provider'] - calls: - - [ addProvider, ['@prestashop.translation.theme_provider']] - - ps.theme_translations_factory: - alias: "prestashop.translation.theme_translations_factory" - - #TRANSLATIONS PROVIDERS - prestashop.translation.backoffice_provider: - class: PrestaShopBundle\Translation\Provider\BackOfficeProvider - arguments: - - "@prestashop.translation.database_loader" - - "%translations_dir%" - tags: - - { name: "ps.translation_provider" } - - prestashop.translation.frontoffice_provider: - class: PrestaShopBundle\Translation\Provider\FrontOfficeProvider - arguments: - - "@prestashop.translation.database_loader" - - "%translations_dir%" - tags: - - { name: "ps.translation_provider" } - - prestashop.translation.mails_provider: - class: PrestaShopBundle\Translation\Provider\MailsProvider - arguments: - - "@prestashop.translation.database_loader" - - "%translations_dir%" - tags: - - { name: "ps.translation_provider" } - - prestashop.translation.mails_body_provider: - class: PrestaShopBundle\Translation\Provider\MailsBodyProvider - arguments: - - "@prestashop.translation.database_loader" - - "%translations_dir%" - tags: - - { name: "ps.translation_provider" } - - prestashop.translation.others_provider: - class: PrestaShopBundle\Translation\Provider\OthersProvider - arguments: - - "@prestashop.translation.database_loader" - - "%translations_dir%" - tags: - - { name: "ps.translation_provider" } - - prestashop.translation.theme_provider: - class: PrestaShopBundle\Translation\Provider\ThemeProvider - arguments: - - "@prestashop.translation.database_loader" - - "%themes_translations_dir%" - properties: - themeResourcesDirectory: "%themes_dir%" - filesystem: "@filesystem" - themeRepository: "@prestashop.core.addon.theme.repository" - themeExtractor: "@prestashop.translation.theme_extractor" - defaultTranslationDir: "%translations_dir%" - - prestashop.translation.modules_provider: - class: PrestaShopBundle\Translation\Provider\ModulesProvider - arguments: - - "@prestashop.translation.database_loader" - - "%translations_dir%" - tags: - - { name: "ps.translation_provider" } - - prestashop.translation.external_module_provider: - class: PrestaShopBundle\Translation\Provider\ExternalModuleLegacySystemProvider - arguments: - - "@prestashop.translation.database_loader" - - "%modules_dir%" - - "@prestashop.translation.legacy_file_loader" - - "@prestashop.translation.legacy_module.extractor" - - "@prestashop.translation.module_provider" - tags: - - { name: "ps.translation_provider" } - - prestashop.translation.module_provider: - class: PrestaShopBundle\Translation\Provider\ModuleProvider - arguments: - - "@prestashop.translation.database_loader" - - "%translations_dir%" - tags: - - { name: "ps.translation_provider" } - - prestashop.translation.search_provider: - class: PrestaShopBundle\Translation\Provider\SearchProvider - arguments: - - "@prestashop.translation.database_loader" - - "@prestashop.translation.external_module_provider" - - "%translations_dir%" - - "%modules_dir%" - tags: - - { name: "ps.translation_provider" } - - # TRANSLATIONS - prestashop.translation.database_loader: - class: PrestaShopBundle\Translation\Loader\DatabaseTranslationLoader - arguments: - - "@doctrine.orm.entity_manager" - tags: - - {name: translation.loader, alias: db} - - prestashop.translation.sql_loader: - class: PrestaShopBundle\Translation\Loader\SqlTranslationLoader - tags: - - {name: translation.loader, alias: db} - - prestashop.translation.legacy_file_reader: - class: PrestaShopBundle\Translation\Loader\LegacyFileReader - arguments: - - "@prestashop.core.translation.locale.converter" - - prestashop.translation.legacy_file_loader: - class: PrestaShopBundle\Translation\Loader\LegacyFileLoader - arguments: - - "@prestashop.translation.legacy_file_reader" - tags: - - {name: translation.loader, alias: legacy_files} - - # cannot decorate the original one because it is loaded later - # this version activates loading legacy wordings in smarty files - prestashop.translation.extractor.smarty.legacy: - class: PrestaShop\TranslationToolsBundle\Translation\Extractor\SmartyExtractor - arguments: - - "@prestashop.compiler.smarty.template" - - true - - prestashop.translation.theme_extractor: - class: PrestaShopBundle\Translation\Extractor\ThemeExtractor - arguments: - - "@prestashop.translation.extractor.smarty.legacy" - - prestashop.translation.legacy_module.extractor: - class: PrestaShopBundle\Translation\Extractor\LegacyModuleExtractor - arguments: - - "@prestashop.translation.extractor.php" - - "@prestashop.translation.extractor.smarty.legacy" - - "@prestashop.translation.extractor.twig" - - "%modules_dir%" - - prestashop.translation.dumper.xliff: - class: PrestaShop\TranslationToolsBundle\Translation\Dumper\XliffFileDumper - - prestashop.translation.theme.exporter: - class: PrestaShopBundle\Translation\Exporter\ThemeExporter - arguments: - - "@prestashop.translation.theme_extractor" - - "@prestashop.translation.theme_provider" - - "@prestashop.core.addon.theme.repository" - - "@prestashop.translation.dumper.xliff" - - "@prestashop.utils.zip_manager" - - "@filesystem" - properties: - cacheDir: "%kernel.cache_dir%" - calls: - - [ setExportDir, ["%kernel.cache_dir%/export"]] - - # Api - i18n - prestashop.translation.api: - abstract: true - class: PrestaShopBundle\Translation\Api\AbstractApi - calls: - - [setTranslator, ['@translator']] - - prestashop.translation.api.stock: - class: PrestaShopBundle\Translation\Api\StockApi - parent: prestashop.translation.api - public: true - - prestashop.translation.api.international: - class: PrestaShopBundle\Translation\Api\InternationalApi - parent: prestashop.translation.api - public: true diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/twig.yml b/src/PrestaShopBundle/Resources/config/services/bundle/twig.yml deleted file mode 100644 index 40f2d4ff..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/twig.yml +++ /dev/null @@ -1,120 +0,0 @@ -services: - _defaults: - public: true - - prestashop.twig.modules.loader: - class: 'PrestaShopBundle\Twig\Locator\ModuleTemplateLoader' - arguments: - - - 'PrestaShop': '' - 'Product': '/Admin/Product' - 'Twig': '/Admin/TwigTemplateForm' - 'AdvancedParameters': '/Admin/Configure/AdvancedParameters' - 'ShopParameters': '/Admin/Configure/ShopParameters' - - '@=service("prestashop.module_kernel.repository").getActiveModulesPaths()' - tags: - - { name: twig.loader, priority: 1} - - # Extensions - - prestashop.twig.extension.stringloader: - class: Twig_Extension_StringLoader - tags: - - { name: twig.extension } - - prestashop.twig.extension.layout: - class: PrestaShopBundle\Twig\LayoutExtension - arguments: - - "@prestashop.adapter.legacy.context" - - "%kernel.environment%" - - "@prestashop.adapter.legacy.configuration" - - "@prestashop.adapter.data_provider.currency" - tags: - - { name: twig.extension } - - prestashop.twig.extension.translation: - class: PrestaShopBundle\Twig\TranslationsExtension - arguments: ["@service_container", "@router"] - properties: - logger: "@logger" - translator: "@translator" - tags: - - { name: twig.extension } - - prestashop.twig.extension.data_formatter: - class: PrestaShopBundle\Twig\DataFormatterExtension - tags: - - { name: twig.extension } - - prestashop.twig.extension.hook: - class: PrestaShopBundle\Twig\HookExtension - arguments: - - "@prestashop.core.hook.dispatcher" - - "@prestashop.adapter.data_provider.module" - - "@=service('prestashop.adapter.legacy.context').getContext().employee?service('prestashop.core.admin.module.repository'):null" - tags: - - { name: twig.extension } - - prestashop.bundle.twig.extension.column: - class: 'PrestaShopBundle\Twig\Extension\GridExtension' - arguments: - - '@twig' - - '@prestashop.static_cache.adapter' - tags: - - { name: twig.extension } - - prestashop.bundle.twig.extension.documentation_link_provider_extension: - class: 'PrestaShopBundle\Twig\Extension\DocumentationLinkExtension' - arguments: - - '@prestashop.core.util.helper_card.documentation_link_provider' - tags: - - { name: twig.extension } - - prestashop.twig.extension.context_iso_code_provider_extension: - class: PrestaShopBundle\Twig\ContextIsoCodeProviderExtension - arguments: - - "@=service('prestashop.adapter.legacy.context').getContext().language ? service('prestashop.adapter.legacy.context').getContext().language.iso_code : 'en'" - properties: - logger: "@logger" - translator: "@translator" - tags: - - { name: twig.extension } - - prestashop.twig.extension.path_with_back_url_extension: - class: PrestaShopBundle\Twig\Extension\PathWithBackUrlExtension - arguments: - - '@twig.extension.routing' - - '@prestashop.core.uti.back_url_provider' - - '@=service("request_stack") ? service("request_stack") : null' - public: true - tags: - - { name: twig.extension } - - prestashop.bundle.twig.extension.color_brightness_calculator_extension: - class: PrestaShopBundle\Twig\Extension\ColorBrightnessCalculatorExtension - arguments: - - '@prestashop.core.util.color_brightness_calculator' - tags: - - { name: twig.extension } - - prestashop.bundle.twig.extension.js_router_metadata_extension: - class: PrestaShopBundle\Twig\Extension\JsRouterMetadataExtension - arguments: - - '@=service("request_stack")' - - '@=service("security.csrf.token_manager")' - - '@=service("prestashop.user_provider").getUsername()' - tags: - - { name: twig.extension } - - prestashop.bundle.twig.extension.localization_extension: - class: 'PrestaShopBundle\Twig\Extension\LocalizationExtension' - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext().language.date_format_full' - - '@=service("prestashop.adapter.legacy.context").getContext().language.date_format_lite' - tags: - - { name: twig.extension } - - prestashop.bundle.twig.extension.number_extension: - class: 'PrestaShopBundle\Twig\Extension\NumberExtension' - tags: - - { name: twig.extension } diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/utils.yml b/src/PrestaShopBundle/Resources/config/services/bundle/utils.yml deleted file mode 100644 index 23ea7547..00000000 --- a/src/PrestaShopBundle/Resources/config/services/bundle/utils.yml +++ /dev/null @@ -1,11 +0,0 @@ -services: - _defaults: - public: true - - prestashop.utils.zip_manager: - class: PrestaShopBundle\Utils\ZipManager - - prestashop.utils.float_parser: - class: PrestaShopBundle\Utils\FloatParser - arguments: - - '@prestashop.core.util.arabic_to_latin_digit_converter' diff --git a/src/PrestaShopBundle/Resources/config/services/core/addon.yml b/src/PrestaShopBundle/Resources/config/services/core/addon.yml deleted file mode 100644 index f0f76a28..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/addon.yml +++ /dev/null @@ -1,59 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.admin.module.repository: - class: PrestaShop\PrestaShop\Core\Addon\Module\ModuleRepository - arguments: - - "@prestashop.adapter.admin.data_provider.module" - - "@prestashop.adapter.data_provider.module" - - "@prestashop.core.module.updater" - - "@prestashop.adapter.legacy.logger" - - "@translator" - - "@=service('prestashop.adapter.legacy.configuration').get('_PS_MODULE_DIR_')" - - "@doctrine.cache.provider" - calls: - - [setPrestaTrustChecker, ['@prestashop.adapter.module.prestatrust.checker']] - - prestashop.core.addon.theme.repository: - class: PrestaShop\PrestaShop\Core\Addon\Theme\ThemeRepository - arguments: - - "@prestashop.adapter.legacy.configuration" - - "@filesystem" - - "@=service('prestashop.adapter.legacy.context').getContext().shop" - - prestashop.core.addon.theme.exporter: - class: PrestaShop\PrestaShop\Core\Addon\Theme\ThemeExporter - arguments: - - "@prestashop.adapter.legacy.configuration" - - "@filesystem" - - "@prestashop.core.admin.lang.repository" - - "@prestashop.translation.theme.exporter" - - prestashop.core.addon.theme.theme_manager_builder: - class: PrestaShop\PrestaShop\Core\Addon\Theme\ThemeManagerBuilder - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext()' - - '@prestashop.adapter.legacy_db' - - prestashop.core.addon.theme.theme_manager: - class: PrestaShop\PrestaShop\Core\Addon\Theme\ThemeManager - factory: 'prestashop.core.addon.theme.theme_manager_builder:build' - - prestashop.core.addon.theme.theme.page_layouts_customizer: - class: PrestaShop\PrestaShop\Core\Addon\Theme\ThemePageLayoutsCustomizer - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext().shop.theme' - - '@prestashop.core.addon.theme.theme_manager' - - '@prestashop.adapter.cache.clearer.smarty_cache_clearer' - - prestashop.core.addon.theme.theme_zip_uploader: - class: PrestaShop\PrestaShop\Core\Addon\Theme\ThemeZipUploader - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.core.addon.theme.theme_provider: - class: PrestaShop\PrestaShop\Core\Addon\Theme\ThemeProvider - arguments: - - '@prestashop.core.addon.theme.repository' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.theme' diff --git a/src/PrestaShopBundle/Resources/config/services/core/attribute_group.yml b/src/PrestaShopBundle/Resources/config/services/core/attribute_group.yml deleted file mode 100644 index 76c5186d..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/attribute_group.yml +++ /dev/null @@ -1,9 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.attribute_group.attribute_group_view_data_provider: - class: 'PrestaShop\PrestaShop\Adapter\AttributeGroup\AttributeGroupViewDataProvider' - arguments: - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - - "@=service('prestashop.adapter.legacy.configuration')" diff --git a/src/PrestaShopBundle/Resources/config/services/core/b2b.yml b/src/PrestaShopBundle/Resources/config/services/core/b2b.yml deleted file mode 100644 index 78a81848..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/b2b.yml +++ /dev/null @@ -1,8 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.b2b.b2b_feature: - class: 'PrestaShop\PrestaShop\Core\B2b\B2bFeature' - arguments: - - '@prestashop.adapter.legacy.configuration' diff --git a/src/PrestaShopBundle/Resources/config/services/core/backup.yml b/src/PrestaShopBundle/Resources/config/services/core/backup.yml deleted file mode 100644 index 82add452..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/backup.yml +++ /dev/null @@ -1,19 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.backup.options_configuration: - class: 'PrestaShop\PrestaShop\Core\Backup\Configuration\BackupOptionsConfiguration' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.core.backup.listing.grid_data_factory: - class: 'PrestaShop\PrestaShop\Core\Backup\Listing\BackupGridDataFactory' - arguments: - - '@prestashop.adapter.backup.backup_provider' - - '@prestashop.core.backup.comparator.backup_by_date_comparator' - - '@translator' - - '@=service("prestashop.adapter.legacy.context").getLanguage().date_format_full' - - prestashop.core.backup.comparator.backup_by_date_comparator: - class: 'PrestaShop\PrestaShop\Core\Backup\Comparator\BackupByDateComparator' diff --git a/src/PrestaShopBundle/Resources/config/services/core/cache.yml b/src/PrestaShopBundle/Resources/config/services/core/cache.yml deleted file mode 100644 index c4854694..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/cache.yml +++ /dev/null @@ -1,21 +0,0 @@ -services: - _defaults: - public: true - - # Cache adapter - prestashop.static_cache.adapter: - class: Symfony\Component\Cache\Adapter\ArrayAdapter - tags: - - { name: monolog.logger, channel: cache } - - { name: cache.pool, clearer: cache.default_clearer } - calls: - - ['setLogger', ['@logger']] - - prestashop.core.cache.clearer.cache_clearer_chain: - class: 'PrestaShop\PrestaShop\Core\Cache\Clearer\CacheClearerChain' - arguments: - - '@prestashop.adapter.cache.clearer.symfony_cache_clearer' - - '@prestashop.adapter.cache.clearer.smarty_cache_clearer' - - '@prestashop.adapter.cache.clearer.xml_cache_clearer' - - '@prestashop.adapter.cache.clearer.media_cache_clearer' - - '@prestashop.adapter.cache.clearer.class_index_cache_clearer' diff --git a/src/PrestaShopBundle/Resources/config/services/core/circuit_breaker.yml b/src/PrestaShopBundle/Resources/config/services/core/circuit_breaker.yml deleted file mode 100644 index 974d52f7..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/circuit_breaker.yml +++ /dev/null @@ -1,33 +0,0 @@ -# circuit_breaker.yml -services: - _defaults: - public: true - - prestashop.core.circuit_breaker.doctrine_cache: - class: Doctrine\Common\Cache\FilesystemCache - arguments: - - '@=service("prestashop.adapter.environment").getCacheDir() ~ "/circuit_breaker"' - - prestashop.core.circuit_breaker.guzzle.cache_storage: - class: GuzzleHttp\Subscriber\Cache\CacheStorage - arguments: - - "@prestashop.core.circuit_breaker.doctrine_cache" - - "circuit_breaker_" - - 86400 - - prestashop.core.circuit_breaker.guzzle.cache_subscriber_factory: - class: PrestaShopBundle\Cache\Factory\CacheSubscriberFactory - - prestashop.core.circuit_breaker.guzzle.cache_subscriber: - class: GuzzleHttp\Subscriber\Cache\CacheSubscriber - factory: ['@prestashop.core.circuit_breaker.guzzle.cache_subscriber_factory', 'create'] - arguments: - - "@prestashop.core.circuit_breaker.guzzle.cache_storage" - - prestashop.core.circuit_breaker.storage: - class: PrestaShop\CircuitBreaker\Storage\DoctrineCache - arguments: - - "@prestashop.core.circuit_breaker.doctrine_cache" - - prestashop.core.circuit_breaker.advanced_factory: - class: PrestaShop\CircuitBreaker\AdvancedCircuitBreakerFactory diff --git a/src/PrestaShopBundle/Resources/config/services/core/cldr.yml b/src/PrestaShopBundle/Resources/config/services/core/cldr.yml deleted file mode 100644 index 6f2afbcc..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/cldr.yml +++ /dev/null @@ -1,91 +0,0 @@ -parameters: - ps_cache_dir: !php/const _PS_CACHE_DIR_ - -services: - _defaults: - public: true - - prestashop.core.localization.cache.adapter: - class: Symfony\Component\Cache\Adapter\ArrayAdapter - - prestashop.core.localization.cldr.cache.adapter: - class: Symfony\Component\Cache\Adapter\FilesystemAdapter - arguments: - - 'CLDR' - - 0 - - '%ps_cache_dir%/localization' - - prestashop.core.localization.locale.repository: - class: PrestaShop\PrestaShop\Core\Localization\Locale\Repository - arguments: - - '@prestashop.core.localization.cldr.locale_repository' - - '@prestashop.core.localization.currency.repository' - - prestashop.core.localization.locale.context_locale: - factory: ['@prestashop.core.localization.locale.repository', 'getLocale'] - class: PrestaShop\PrestaShop\Core\Localization\Locale - arguments: ['@=service("prestashop.adapter.legacy.context").getContext().language.getLocale()'] - - prestashop.core.localization.currency.repository: - class: PrestaShop\PrestaShop\Core\Localization\Currency\Repository - arguments: - - '@prestashop.core.localization.currency.datasource' - - prestashop.core.localization.cldr.locale_repository: - class: PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleRepository - arguments: - - '@prestashop.core.localization.cldr.locale_data_source' - - prestashop.core.localization.cldr.locale_data_source: - class: PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleDataSource - arguments: - - '@prestashop.core.localization.cldr.datalayer.top_layer' - - prestashop.core.localization.cldr.datalayer.top_layer: '@prestashop.core.localization.cldr.datalayer.locale_cache' - - prestashop.core.localization.cldr.datalayer.locale_cache: - class: PrestaShop\PrestaShop\Core\Localization\CLDR\DataLayer\LocaleCache - arguments: - - '@prestashop.core.localization.cldr.cache.adapter' - calls: - - [ 'setLowerLayer', ["@prestashop.core.localization.cldr.datalayer.locale_reference"]] - - prestashop.core.localization.cldr.datalayer.locale_reference: - class: PrestaShop\PrestaShop\Core\Localization\CLDR\DataLayer\LocaleReference - arguments: - - '@prestashop.core.localization.cldr.reader' - - prestashop.core.localization.cldr.reader: - class: PrestaShop\PrestaShop\Core\Localization\CLDR\Reader - - prestashop.core.localization.currency.datasource: - class: PrestaShop\PrestaShop\Core\Localization\Currency\CurrencyDataSource - arguments: - - '@prestashop.core.localization.currency.middleware.top_layer' - - '@prestashop.core.localization.currency.middleware.installed' - - prestashop.core.localization.currency.middleware.top_layer: '@prestashop.core.localization.currency.middleware.cache' - - prestashop.core.localization.currency.middleware.cache: - class: PrestaShop\PrestaShop\Core\Localization\Currency\DataLayer\CurrencyCache - arguments: - - '@prestashop.core.localization.cache.adapter' - calls: - - [ 'setLowerLayer', ["@prestashop.core.localization.currency.middleware.database"]] - - prestashop.core.localization.currency.middleware.database: - class: PrestaShop\PrestaShop\Core\Localization\Currency\DataLayer\CurrencyDatabase - arguments: - - '@prestashop.adapter.data_provider.currency' - calls: - - [ 'setLowerLayer', ["@prestashop.core.localization.currency.middleware.reference"]] - - prestashop.core.localization.currency.middleware.reference: - class: PrestaShop\PrestaShop\Core\Localization\Currency\DataLayer\CurrencyReference - arguments: - - '@prestashop.core.localization.cldr.locale_repository' - - prestashop.core.localization.currency.middleware.installed: - class: PrestaShop\PrestaShop\Core\Localization\Currency\DataLayer\CurrencyInstalled - arguments: - - '@prestashop.adapter.data_provider.currency' diff --git a/src/PrestaShopBundle/Resources/config/services/core/cms_page.yml b/src/PrestaShopBundle/Resources/config/services/core/cms_page.yml deleted file mode 100644 index c50f0f03..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/cms_page.yml +++ /dev/null @@ -1,8 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.cms_page.data_provider.cms_page_view: - class: 'PrestaShop\PrestaShop\Core\CMS\CmsPageViewDataProvider' - arguments: - - '@prestashop.core.query_bus' diff --git a/src/PrestaShopBundle/Resources/config/services/core/command_bus.yml b/src/PrestaShopBundle/Resources/config/services/core/command_bus.yml deleted file mode 100644 index 8cfa2080..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/command_bus.yml +++ /dev/null @@ -1,31 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.command_bus: - class: 'PrestaShop\PrestaShop\Core\CommandBus\TacticianCommandBusAdapter' - arguments: - - '@tactician.commandbus.default' - - prestashop.core.query_bus: - class: 'PrestaShop\PrestaShop\Core\CommandBus\TacticianCommandBusAdapter' - arguments: - - '@tactician.commandbus.default' - - prestashop.core.provider.command_definition_provider: - class: 'PrestaShop\PrestaShop\Core\CommandBus\Parser\CommandDefinitionParser' - - prestashop.core.command_bus.middleware.command_register_middleware: - class: PrestaShop\PrestaShop\Core\CommandBus\Middleware\CommandRegisterMiddleware - arguments: - - '@tactician.handler.locator.symfony' - - '@tactician.handler.command_name_extractor.class_name' - - '@prestashop.core.command_bus.executed_command_registry' - - prestashop.core.command_bus.executed_command_registry: - class: PrestaShop\PrestaShop\Core\CommandBus\ExecutedCommandRegistry - arguments: - - '@prestashop.core.command_bus.parser.command_type_parser' - - prestashop.core.command_bus.parser.command_type_parser: - class: PrestaShop\PrestaShop\Core\CommandBus\Parser\CommandTypeParser diff --git a/src/PrestaShopBundle/Resources/config/services/core/common.yml b/src/PrestaShopBundle/Resources/config/services/core/common.yml deleted file mode 100644 index be57c3ee..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/common.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: ./circuit_breaker.yml } diff --git a/src/PrestaShopBundle/Resources/config/services/core/configuration.yml b/src/PrestaShopBundle/Resources/config/services/core/configuration.yml deleted file mode 100644 index d76f2508..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/configuration.yml +++ /dev/null @@ -1,15 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.configuration.ini_configuration: - class: 'PrestaShop\PrestaShop\Core\Configuration\IniConfiguration' - - prestashop.core.configuration.php_extension_checker: - class: 'PrestaShop\PrestaShop\Core\Configuration\PhpExtensionChecker' - public: true - - prestashop.core.configuration.upload_size_configuration: - class: 'PrestaShop\PrestaShop\Core\Configuration\UploadSizeConfiguration' - arguments: - - '@prestashop.core.configuration.ini_configuration' diff --git a/src/PrestaShopBundle/Resources/config/services/core/constraint_validator.yml b/src/PrestaShopBundle/Resources/config/services/core/constraint_validator.yml deleted file mode 100644 index f903548e..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/constraint_validator.yml +++ /dev/null @@ -1,60 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.constraint_validator.is_url_rewrite_validator: - class: 'PrestaShop\PrestaShop\Core\ConstraintValidator\IsUrlRewriteValidator' - arguments: - - '@prestashop.adapter.legacy.configuration' - tags: - - { name: validator.constraint_validator } - - prestashop.core.constraint_validator.default_language_validator: - class: 'PrestaShop\PrestaShop\Core\ConstraintValidator\DefaultLanguageValidator' - arguments: - - '@=service("prestashop.adapter.legacy.configuration").get("PS_LANG_DEFAULT")' - tags: - - { name: validator.constraint_validator } - - prestashop.core.constraint_validator.customer_name_validator: - class: 'PrestaShop\PrestaShop\Core\ConstraintValidator\CustomerNameValidator' - arguments: - - '@prestashop.core.string.character_cleaner' - tags: - - { name: validator.constraint_validator } - - prestashop.core.constraint_validator.typed_regex_validator: - class: 'PrestaShop\PrestaShop\Core\ConstraintValidator\TypedRegexValidator' - arguments: - - '@prestashop.core.string.character_cleaner' - tags: - - { name: validator.constraint_validator } - - prestashop.core.constraint_validator.existing_customer_email_validator: - class: 'PrestaShop\PrestaShop\Core\ConstraintValidator\ExistingCustomerEmailValidator' - arguments: - - '@prestashop.adapter.customer.customer_data_source' - tags: - - { name: validator.constraint_validator } - - prestashop.core.constraint_validator.address_zip_code_validator: - class: 'PrestaShop\PrestaShop\Core\ConstraintValidator\AddressZipCodeValidator' - arguments: - - '@translator' - - '@prestashop.adapter.country.country_zip_code_requirements_provider' - tags: - - { name: validator.constraint_validator } - - prestashop.core.constraint_validator.address_country_dni_validator: - class: 'PrestaShop\PrestaShop\Core\ConstraintValidator\AddressDniRequiredValidator' - arguments: - - '@prestashop.adapter.country.country_required_fields_provider' - tags: - - { name: validator.constraint_validator } - - prestashop.core.constraint_validator.address_country_state_validator: - class: 'PrestaShop\PrestaShop\Core\ConstraintValidator\AddressStateRequiredValidator' - arguments: - - '@prestashop.adapter.country.country_required_fields_provider' - tags: - - { name: validator.constraint_validator } diff --git a/src/PrestaShopBundle/Resources/config/services/core/currency.yml b/src/PrestaShopBundle/Resources/config/services/core/currency.yml deleted file mode 100644 index 9f37a4ea..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/currency.yml +++ /dev/null @@ -1,36 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.currency.grid_data_factory: - class: 'PrestaShop\PrestaShop\Core\Currency\CurrencyGridDataFactory' - arguments: - - '@prestashop.core.grid.data_provider.currency' - - '@translator' - - prestashop.core.currency.exchange_rate.settings: - class: PrestaShop\CircuitBreaker\FactorySettings - arguments: - - !php/const \PrestaShop\PrestaShop\Core\Currency\ExchangeRateProvider::CLOSED_ALLOWED_FAILURES - - !php/const \PrestaShop\PrestaShop\Core\Currency\ExchangeRateProvider::CLOSED_TIMEOUT_SECONDS - - !php/const \PrestaShop\PrestaShop\Core\Currency\ExchangeRateProvider::OPEN_THRESHOLD_SECONDS - calls: - - ['setStrippedFailures', [!php/const \PrestaShop\PrestaShop\Core\Currency\ExchangeRateProvider::OPEN_ALLOWED_FAILURES]] - - ['setStrippedTimeout', [!php/const \PrestaShop\PrestaShop\Core\Currency\ExchangeRateProvider::OPEN_TIMEOUT_SECONDS]] - - ['setStorage', ['@prestashop.core.circuit_breaker.storage']] - - ['setClientOptions', [{'method': 'GET', 'subscribers': ['@prestashop.core.circuit_breaker.guzzle.cache_subscriber']}]] - # create a factory for cache_subscriber so that we can easily adapt the cache duration - - prestashop.core.currency.exchange_rate.circuit_breaker: - class: 'PrestaShop\CircuitBreaker\Contract\CircuitBreakerInterface' - factory: ["@prestashop.core.circuit_breaker.advanced_factory", create] - arguments: - - "@prestashop.core.currency.exchange_rate.settings" - - prestashop.core.exchange_rate.provider: - class: PrestaShop\PrestaShop\Core\Currency\ExchangeRateProvider - arguments: - - !php/const \PrestaShop\PrestaShop\Core\Currency\ExchangeRateProvider::CURRENCY_FEED_URL - - '@=service("prestashop.adapter.data_provider.currency").getDefaultCurrencyIsoCode()' - - '@prestashop.core.currency.exchange_rate.circuit_breaker' - - '@cache.app' diff --git a/src/PrestaShopBundle/Resources/config/services/core/domain.yml b/src/PrestaShopBundle/Resources/config/services/core/domain.yml deleted file mode 100644 index b491df33..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/domain.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: domain/*.yml } diff --git a/src/PrestaShopBundle/Resources/config/services/core/domain/cart.yml b/src/PrestaShopBundle/Resources/config/services/core/domain/cart.yml deleted file mode 100644 index bf647149..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/domain/cart.yml +++ /dev/null @@ -1,3 +0,0 @@ -services: - _defaults: - public: true diff --git a/src/PrestaShopBundle/Resources/config/services/core/domain/country.yml b/src/PrestaShopBundle/Resources/config/services/core/domain/country.yml deleted file mode 100644 index 6dcfbc08..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/domain/country.yml +++ /dev/null @@ -1,6 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.domain.country.zip_code_format_resolver: - class: 'PrestaShop\PrestaShop\Core\Domain\Country\ZipCodePatternResolver' diff --git a/src/PrestaShopBundle/Resources/config/services/core/domain/customer_service.yml b/src/PrestaShopBundle/Resources/config/services/core/domain/customer_service.yml deleted file mode 100644 index 3a0587a0..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/domain/customer_service.yml +++ /dev/null @@ -1,12 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.domain.customer_service.command_handler.update_customer_thread_status_handler: - class: PrestaShop\PrestaShop\Core\Domain\CustomerService\CommandHandler\UpdateCustomerThreadStatusHandler - arguments: - - '@doctrine.dbal.default_connection' - - '%database_prefix%' - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\CustomerService\Command\UpdateCustomerThreadStatusCommand diff --git a/src/PrestaShopBundle/Resources/config/services/core/domain/showcase_card.yml b/src/PrestaShopBundle/Resources/config/services/core/domain/showcase_card.yml deleted file mode 100644 index faa47e0f..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/domain/showcase_card.yml +++ /dev/null @@ -1,28 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.showcase_card.configuration_map: - class: 'PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\ConfigurationMap' - - # Command handlers - - prestashop.core.showcase_card.command_handler.close_showcase_card: - class: 'PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\CommandHandler\CloseShowcaseCardHandler' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.core.showcase_card.configuration_map' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Command\CloseShowcaseCardCommand' - - # Query handlers - - prestashop.core.domain.showcase_card.query_handler.get_showcase_card_is_closed_handler: - class: PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\QueryHandler\GetShowcaseCardIsClosedHandler - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.core.showcase_card.configuration_map' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\ShowcaseCard\Query\GetShowcaseCardIsClosed' diff --git a/src/PrestaShopBundle/Resources/config/services/core/domain/sql_management.yml b/src/PrestaShopBundle/Resources/config/services/core/domain/sql_management.yml deleted file mode 100644 index bb10155d..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/domain/sql_management.yml +++ /dev/null @@ -1,23 +0,0 @@ -services: - _defaults: - public: true - - # COMMAND HANDLERS - - prestashop.core.domain.sql_management.command_handler.save_settings: - class: 'PrestaShop\PrestaShop\Core\Domain\SqlManagement\CommandHandler\SaveSqlRequestSettingsHandler' - arguments: - - '@prestashop.adapter.legacy.configuration' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\SqlManagement\Command\SaveSqlRequestSettingsCommand' - - # QUERY HANDLERS - - prestashop.core.domain.sql_management.query_handler.get_sql_request_settings: - class: 'PrestaShop\PrestaShop\Core\Domain\SqlManagement\QueryHandler\GetSqlRequestSettingsHandler' - arguments: - - '@prestashop.adapter.legacy.configuration' - tags: - - name: 'tactician.handler' - command: 'PrestaShop\PrestaShop\Core\Domain\SqlManagement\Query\GetSqlRequestSettings' diff --git a/src/PrestaShopBundle/Resources/config/services/core/domain/theme.yml b/src/PrestaShopBundle/Resources/config/services/core/domain/theme.yml deleted file mode 100644 index 0d431091..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/domain/theme.yml +++ /dev/null @@ -1,46 +0,0 @@ -services: - _defaults: - public: true - - # COMMAND HANDLERS - - prestashop.core.domain.theme.command_handler.import_theme_handler: - class: 'PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler\ImportThemeHandler' - arguments: - - '@prestashop.core.addon.theme.theme_zip_uploader' - - '@prestashop.core.addon.theme.theme_manager' - - '@prestashop.adapter.legacy.configuration' - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Theme\Command\ImportThemeCommand } - - prestashop.core.domain.theme.command_handler.enable_theme_handler: - class: 'PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler\EnableThemeHandler' - arguments: - - '@prestashop.core.addon.theme.theme_manager' - - '@prestashop.adapter.cache.clearer.smarty_cache_clearer' - - '@=service("prestashop.adapter.shop.context").isSingleShopContext()' - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Theme\Command\EnableThemeCommand } - - prestashop.core.domain.theme.command_handler.delete_theme_handler: - class: 'PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler\DeleteThemeHandler' - arguments: - - '@prestashop.core.addon.theme.theme_manager' - tags: - - { name: tactician.handler, command: PrestaShop\PrestaShop\Core\Domain\Theme\Command\DeleteThemeCommand } - - prestashop.core.domain.theme.command_handler.adapt_theme_to_rtl_languages_handler: - class: 'PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler\AdaptThemeToRTLLanguagesHandler' - arguments: - - '@prestashop.core.localization.rtl.processor_factory' - tags: - - name: 'tactician.handler' - command: PrestaShop\PrestaShop\Core\Domain\Theme\Command\AdaptThemeToRTLLanguagesCommand - - prestashop.core.domain.theme.command_handler.reset_theme_layouts_handler: - class: 'PrestaShop\PrestaShop\Core\Domain\Theme\CommandHandler\ResetThemeLayoutsHandler' - arguments: - - '@prestashop.core.addon.theme.theme_manager' - tags: - - name: 'tactician.handler' - command: PrestaShop\PrestaShop\Core\Domain\Theme\Command\ResetThemeLayoutsCommand diff --git a/src/PrestaShopBundle/Resources/config/services/core/employee.yml b/src/PrestaShopBundle/Resources/config/services/core/employee.yml deleted file mode 100644 index 5ecfc9ac..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/employee.yml +++ /dev/null @@ -1,15 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.team.employee.configuration.options_checker: - class: 'PrestaShop\PrestaShop\Core\Team\Employee\Configuration\OptionsChecker' - arguments: - - '@prestashop.adapter.multistore_feature' - - '@prestashop.adapter.shop.context' - - prestashop.core.employee.profile_access_checker: - class: 'PrestaShop\PrestaShop\Core\Employee\Access\ProfileAccessChecker' - arguments: - - '@prestashop.adapter.employee.data_provider' - - '@=service("prestashop.adapter.legacy.configuration").getInt("_PS_ADMIN_PROFILE_")' diff --git a/src/PrestaShopBundle/Resources/config/services/core/export.yml b/src/PrestaShopBundle/Resources/config/services/core/export.yml deleted file mode 100644 index 50870e9b..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/export.yml +++ /dev/null @@ -1,13 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.export.dir: - class: 'PrestaShop\PrestaShop\Core\Export\ExportDirectory' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.core.export.file_writer.export_csv_file_writer: - class: 'PrestaShop\PrestaShop\Core\Export\FileWriter\ExportCsvFileWriter' - arguments: - - '@prestashop.core.export.dir' diff --git a/src/PrestaShopBundle/Resources/config/services/core/file.yml b/src/PrestaShopBundle/Resources/config/services/core/file.yml deleted file mode 100644 index 2e2f28bf..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/file.yml +++ /dev/null @@ -1,16 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.file.finder.invoice_model: - class: 'PrestaShop\PrestaShop\Core\File\InvoiceModelFinder' - arguments: - - [ - "@=service('prestashop.adapter.legacy.configuration').get('_PS_THEME_DIR_')~'pdf/'", - "@=service('prestashop.adapter.legacy.configuration').get('_PS_PDF_DIR_')" - ] - - prestashop.core.file.cached_finder.invoice_model: - class: 'PrestaShop\PrestaShop\Core\Proxy\CachedFileFinderProxy' - arguments: - - '@prestashop.core.file.finder.invoice_model' diff --git a/src/PrestaShopBundle/Resources/config/services/core/form.yml b/src/PrestaShopBundle/Resources/config/services/core/form.yml deleted file mode 100644 index b0040024..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/form.yml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: form/*.yml } diff --git a/src/PrestaShopBundle/Resources/config/services/core/form/choice_provider.yml b/src/PrestaShopBundle/Resources/config/services/core/form/choice_provider.yml deleted file mode 100644 index 1e88cfac..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/form/choice_provider.yml +++ /dev/null @@ -1,247 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.form.choice_provider.language_by_id: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\LanguageByIdChoiceProvider' - arguments: - - '@prestashop.adapter.data_provider.language' - - prestashop.core.form.choice_provider.all_languages: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\LanguageChoiceProvider' - arguments: - - '@=service("prestashop.adapter.data_provider.language").getLanguages(false)' - - prestashop.core.form.choice_provider.country_by_id: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\CountryByIdChoiceProvider' - arguments: - - '@=service("prestashop.adapter.legacy.context").getLanguage().id' - - '@prestashop.adapter.data_provider.country' - - prestashop.core.form.choice_provider.currency_by_id: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\CurrencyByIdChoiceProvider' - arguments: - - '@prestashop.adapter.data_provider.currency' - - prestashop.core.form.choice_provider.timezone_by_name: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\TimezoneByNameChoiceProvider' - arguments: - - '@prestashop.core.admin.timezone.repository' - - prestashop.core.form.choice_provider.localization_pack_by_iso_code: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\LocalizationPackByIsoCodeChoiceProvider' - arguments: - - '@prestashop.core.localization.pack.loader.remote' - - '@prestashop.core.localization.pack.loader.local' - - '@prestashop.adapter.legacy.configuration' - - '@translator' - - prestashop.core.form.choice_provider.non_installed_localization: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\NonInstalledLocalizationChoiceProvider' - arguments: - - '@=service("prestashop.core.language.pack.loader.remote").getLanguagePackList()' - - '@prestashop.adapter.language.validator' - - '@prestashop.adapter.data_provider.language' - - prestashop.core.form.choice_provider.country_by_iso_code: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\CountryByIsoCodeChoiceProvider' - arguments: - - '@=service("prestashop.adapter.legacy.context").getLanguage().id' - - '@prestashop.adapter.data_provider.country' - - prestashop.core.form.choice_provider.group_by_id: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\GroupByIdChoiceProvider' - arguments: - - '@prestashop.adapter.data_provider.group' - - '@=service("prestashop.adapter.legacy.context").getLanguage().id' - - prestashop.core.form.choice_provider.carrier_by_reference_id: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\CarrierByReferenceChoiceProvider' - arguments: - - '@prestashop.adapter.data_provider.carrier' - - '@=service("prestashop.adapter.legacy.context").getLanguage().id' - - prestashop.core.form.choice_provider.order_state_by_id: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\OrderStateByIdChoiceProvider' - arguments: - - '@=service("prestashop.adapter.legacy.context").getLanguage().id' - - '@prestashop.adapter.data_provider.order_state' - - '@prestashop.core.util.color_brightness_calculator' - - '@translator' - - prestashop.core.form.choice_provider.invoice_model_by_name: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\InvoiceModelByNameChoiceProvider' - arguments: - - '@prestashop.core.file.cached_finder.invoice_model' - - prestashop.core.form.choice_provider.mail_method: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\MailMethodChoiceProvider' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@translator' - - prestashop.core.form.choice_provider.contact_by_id: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\ContactByIdChoiceProvider' - arguments: - - '@prestashop.adapter.contact.repository' - - '@=service("prestashop.adapter.legacy.context").getLanguage().id' - - prestashop.core.form.choice_provider.translation_type: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\TranslationTypeChoiceProvider' - arguments: - - '@translator' - - prestashop.core.form.choice_provider.email_content_type: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\EmailContentTypeChoiceProvider' - arguments: - - '@translator' - - prestashop.core.form.choice_provider.theme_by_name: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\ThemeByNameChoiceProvider' - arguments: - - '@=service("prestashop.core.addon.theme.repository").getListAsCollection()' - - prestashop.core.form.choice_provider.theme_by_name_with_emails: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\ThemeByNameWithEmailsChoiceProvider' - arguments: - - '@=service("prestashop.core.addon.theme.repository").getListAsCollection()' - - prestashop.core.form.choice_provider.module_by_name: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\ModuleByNameChoiceProvider' - arguments: - - '@=service("prestashop.core.admin.module.repository").getInstalledModulesCollection()' - - prestashop.core.form.choice_provider.status: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\StatusChoiceProvider' - arguments: - - '@translator' - - prestashop.core.form.choice_provider.canonical_redirect_type: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\CanonicalRedirectTypeChoiceProvider' - arguments: - - '@translator' - - prestashop.core.form.choice_provider.category_delete_mode: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\CategoryDeleteModeChoiceProvider' - arguments: - - '@translator' - - prestashop.core.form.choice_provider.customer_required_fields: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\CustomerRequiredFieldsChoiceProvider' - arguments: - - '@translator' - - prestashop.core.form.choice_provider.import_match_configuration: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\ImportMatchConfigurationChoiceProvider' - arguments: - - '@=service("prestashop.core.admin.import_match.repository").findAll()' - - prestashop.core.form.choice_provider.import_entity_field: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\ImportEntityFieldChoiceProvider' - arguments: - - '@=service("prestashop.core.import.fields_provider_finder")' - - '@=service("session").get("entity")' - - prestashop.core.form.choice_provider.customer_delete_method: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\CustomerDeleteMethodChoiceProvider' - arguments: - - '@translator' - - prestashop.core.form.choice_provider.theme_page_layouts: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\ThemePageLayoutsChoiceProvider' - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext().shop.theme' - - prestashop.core.form.choice_provider.theme_zip: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\ThemeZipChoiceProvider' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.core.form.choice_provider.theme: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\ThemeChoiceProvider' - arguments: - - '@prestashop.core.addon.theme.theme_provider' - - prestashop.core.form.choice_provider.currency_name_by_iso_code: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\CurrencyNameByIsoCodeChoiceProvider' - arguments: - - '@=service("prestashop.core.localization.cldr.locale_repository").getLocale(service("prestashop.adapter.legacy.context").getContext().language.getLocale()).getAllCurrencies()' - - prestashop.core.form.choice_provider.permissions_choice_provider: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\PermissionsChoiceProvider' - arguments: - - '@translator' - - prestashop.core.form.choice_provider.default_meta_page_name: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\DefaultMetaPageNameChoiceProvider' - arguments: - - '@request_stack' - - '@prestashop.adapter.meta.data_provider' - - prestashop.core.form.choice_provider.module_meta_page_name: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\ModuleMetaPageNameChoiceProvider' - arguments: - - '@request_stack' - - '@prestashop.adapter.meta.data_provider' - - prestashop.core.form.choice_provider.tax_address_type_choice_provider: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\TaxAddressTypeChoiceProvider' - arguments: - - '@translator' - - prestashop.core.form.choice_provider.tax_rule_group_choice_provider: - class: 'PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\TaxRuleGroupChoiceProvider' - - prestashop.core.form.choice_provider.cms_categories: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\CmsCategoriesChoiceProvider' - arguments: - - '@=service("prestashop.adapter.cms_page.categories_provider").getAllNestedCategories()' - - prestashop.core.form.choice_provider.accessible_tab: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\TabChoiceProvider' - arguments: - - '@=service("prestashop.adapter.data_provider.tab").getViewableTabsForContextEmployee(service("prestashop.adapter.legacy.context").getLanguage().id)' - - prestashop.core.form.choice_provider.profile: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\ProfileChoiceProvider' - arguments: - - '@=service("prestashop.adapter.data_provider.profile").getProfiles(service("prestashop.adapter.legacy.context").getLanguage().id)' - - prestashop.core.form.choice_provider.mail_themes: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\MailThemeChoiceProvider' - arguments: - - '@prestashop.core.mail_template.theme_catalog' - - prestashop.core.form.choice.provider.order_discount_type: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\OrderDiscountTypeChoiceProvider' - arguments: - - '@translator' - - prestashop.core.form.choice_provider.tax_inclusion: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\TaxInclusionChoiceProvider' - arguments: - - '@translator' - - prestashop.core.form.choice_provider.price_reduction_type: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\PriceReductionTypeChoiceProvider' - arguments: - - '@translator' - - prestashop.core.form.choice_provider.address_required_fields: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\AddressRequiredFieldsChoiceProvider' - - prestashop.core.form.choice_provider.customer_addresses_by_id: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\CustomerAddressesChoiceProvider' - arguments: - - '@prestashop.adapter.data_provider.customer' - - '@=service("prestashop.adapter.legacy.context").getLanguage().id' - - prestashop.core.form.choice_provider.customer_service_order_messages_name: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\CustomerServiceOrderMessagesNameChoiceProvider' - arguments: - - '@=service("prestashop.adapter.order_message.order_message_provider").getMessages()' - - prestashop.core.form.choice_provider.customer_service_order_messages: - class: 'PrestaShop\PrestaShop\Core\Form\ChoiceProvider\CustomerServiceOrderMessagesChoiceProvider' - arguments: - - '@=service("prestashop.adapter.order_message.order_message_provider").getMessages()' diff --git a/src/PrestaShopBundle/Resources/config/services/core/form/form_builder.yml b/src/PrestaShopBundle/Resources/config/services/core/form/form_builder.yml deleted file mode 100644 index 0e8a4d1b..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/form/form_builder.yml +++ /dev/null @@ -1,170 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.form.builder.form_builder_factory: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilderFactory' - arguments: - - '@form.factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.form.builder.sql_request_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\RequestSql\SqlRequestType' - - '@prestashop.core.form.identifiable_object.data_provider.sql_request_form_data_provider' - - prestashop.core.form.identifiable_object.builder.customer_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Sell\Customer\CustomerType' - - '@prestashop.core.form.identifiable_object.data_provider.customer_form_data_provider' - - prestashop.core.form.identifiable_object.builder.language_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Improve\International\Language\LanguageType' - - '@prestashop.core.form.identifiable_object.data_provider.language_form_data_provider' - - prestashop.core.form.builder.currency_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Improve\International\Currencies\CurrencyType' - - '@prestashop.core.form.identifiable_object.data_provider.currency_form_data_provider' - - prestashop.core.form.identifiable_object.builder.webservice_key_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Webservice\WebserviceKeyType' - - '@prestashop.core.form.identifiable_object.data_provider.webservice_key_form_data_provider' - - prestashop.core.form.builder.meta_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\TrafficSeo\Meta\MetaType' - - '@prestashop.core.form.identifiable_object.data_provider.meta_form_data_provider' - - prestashop.core.form.identifiable_object.builder.category_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Catalog\Category\CategoryType' - - '@prestashop.core.form.identifiable_object.data_provider.category_form_data_provider' - - prestashop.core.form.identifiable_object.builder.root_category_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Catalog\Category\RootCategoryType' - - '@prestashop.core.form.identifiable_object.data_provider.category_form_data_provider' - - prestashop.core.form.identifiable_object.builder.contact_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Configure\ShopParameters\Contact\ContactType' - - '@prestashop.core.form.identifiable_object.data_provider.contact_form_data_provider' - - prestashop.core.form.identifiable_object.builder.cms_page_category_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Improve\Design\Pages\CmsPageCategoryType' - - '@prestashop.core.form.identifiable_object.data_provider.cms_page_category_form_data_provider' - - prestashop.core.form.identifiable_object.builder.tax_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Improve\International\Tax\TaxType' - - '@prestashop.core.form.identifiable_object.data_provider.tax_form_data_provider' - - prestashop.core.form.identifiable_object.builder.manufacturer_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Sell\Manufacturer\ManufacturerType' - - '@prestashop.core.form.identifiable_object.data_provider.manufacturer_form_data_provider' - - prestashop.core.form.identifiable_object.builder.employee_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Employee\EmployeeType' - - '@prestashop.core.form.identifiable_object.data_provider.employee_form_data_provider' - - prestashop.core.form.identifiable_object.builder.profile_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Profile\ProfileType' - - '@prestashop.core.form.identifiable_object.data_provider.profile_form_data_provider' - - prestashop.core.form.identifiable_object.builder.cms_page_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Improve\Design\Pages\CmsPageType' - - '@prestashop.core.form.identifiable_object.data_provider.cms_page_form_data_provider' - - prestashop.core.form.identifiable_object.builder.manufacturer_address_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Sell\Address\ManufacturerAddressType' - - '@prestashop.core.form.identifiable_object.data_provider.manufacturer_address_form_data_provider' - - prestashop.core.form.identifiable_object.builder.supplier_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Sell\Supplier\SupplierType' - - '@prestashop.core.form.identifiable_object.data_provider.supplier_form_data_provider' - - prestashop.core.form.identifiable_object.builder.feature_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Sell\Catalog\FeatureType' - - '@prestashop.core.form.identifiable_object.data_provider.feature_form_data_provider' - - prestashop.core.form.identifiable_object.builder.order_message_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Sell\CustomerService\OrderMessageType' - - '@prestashop.core.form.identifiable_object.data_provider.order_message_form_data_provider' - - prestashop.core.form.identifiable_object.builder.catalog_price_rule_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Sell\CatalogPriceRule\CatalogPriceRuleType' - - '@prestashop.core.form.identifiable_object.data_provider.catalog_price_rule_form_data_provider' - - prestashop.core.form.identifiable_object.builder.attachment_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Sell\Attachment\AttachmentType' - - '@prestashop.core.form.identifiable_object.data_provider.attachment_form_data_provider' - - prestashop.core.form.identifiable_object.builder.cancel_product_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Sell\Order\CancelProductType' - - '@prestashop.core.form.identifiable_object.data_provider.cancel_product_form_data_provider' - - prestashop.core.form.identifiable_object.builder.address_form_builder: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilder' - factory: 'prestashop.core.form.builder.form_builder_factory:create' - arguments: - - 'PrestaShopBundle\Form\Admin\Sell\Address\CustomerAddressType' - - '@prestashop.core.form.identifiable_object.data_provider.address_form_data_provider' diff --git a/src/PrestaShopBundle/Resources/config/services/core/form/form_data_handler.yml b/src/PrestaShopBundle/Resources/config/services/core/form/form_data_handler.yml deleted file mode 100644 index 262188fb..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/form/form_data_handler.yml +++ /dev/null @@ -1,167 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.form.identifiable_object.sql_request_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\SqlRequestFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.data_handler.customer_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\CustomerFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id' - - '@=service("prestashop.core.b2b.b2b_feature").isActive()' - - prestashop.core.form.identifiable_object.data_handler.language_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\LanguageFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.meta_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\MetaFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.currency_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\CurrencyFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - - - '@prestashop.adapter.cache.clearer.symfony_cache_clearer' - - '@prestashop.adapter.cache.clearer.smarty_cache_clearer' - - prestashop.core.form.identifiable_object.data_handler.webservice_key_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\WebserviceKeyFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id' - - prestashop.core.form.identifiable_object.data_handler.category_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\CategoryFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - '@prestashop.adapter.image.uploader.category_cover_image_uploader' - - '@prestashop.adapter.image.uploader.category_thumbnail_image_uploader' - - '@prestashop.adapter.image.uploader.category_menu_thumbnail_image_uploader' - - prestashop.core.form.identifiable_object.data_handler.root_category_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\RootCategoryFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - '@prestashop.adapter.image.uploader.category_cover_image_uploader' - - '@prestashop.adapter.image.uploader.category_thumbnail_image_uploader' - - '@prestashop.adapter.image.uploader.category_menu_thumbnail_image_uploader' - - prestashop.core.form.identifiable_object.data_handler.contact_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\ContactFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.data_handler.cms_page_category_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\CmsPageCategoryFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.data_handler.tax_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\TaxFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.data_handler.manufacturer_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\ManufacturerFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - '@prestashop.adapter.image.uploader.manufacturer_image_uploader' - - prestashop.core.form.identifiable_object.data_handler.employee_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\EmployeeFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - '@=service("prestashop.adapter.shop.context").getShops(true, true)' - - '@=service("prestashop.adapter.legacy.configuration").getInt("_PS_ADMIN_PROFILE_")' - - '@prestashop.adapter.employee.form_access_checker' - - '@prestashop.adapter.employee.data_provider' - - '@prestashop.core.crypto.hashing' - - prestashop.core.form.identifiable_object.data_handler.profile_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\ProfileFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.data_handler.cms_page_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\CmsPageFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.data_handler.manufacturer_address_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\ManufacturerAddressFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.data_handler.supplier_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\SupplierFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - '@prestashop.adapter.image.uploader.supplier_image_uploader' - - prestashop.core.form.identifiable_object.data_handler.feature_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\FeatureFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.data_handler.order_message_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\OrderMessageFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.data_handler.catalog_price_rule_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\CatalogPriceRuleFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - '@=service("prestashop.adapter.multistore_feature").isUsed()' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id' - - prestashop.core.form.identifiable_object.data_handler.attachment_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\AttachmentFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - '@prestashop.adapter.attachment.uploader.attachment_file_uploader' - - prestashop.core.form.identifiable_object.partial_refund_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\PartialRefundFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.standard_refund_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\StandardRefundFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.return_product_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\ReturnProductFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.data_handler.address_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\AddressFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - '@prestashop.adapter.data_provider.customer' - - prestashop.core.form.identifiable_object.data_handler.order_address_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\OrderAddressFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.data_handler.cart_address_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\CartAddressFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.cancellation_form_data_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataHandler\CancellationFormDataHandler' - arguments: - - '@prestashop.core.command_bus' - - '@prestashop.core.query_bus' diff --git a/src/PrestaShopBundle/Resources/config/services/core/form/form_data_provider.yml b/src/PrestaShopBundle/Resources/config/services/core/form/form_data_provider.yml deleted file mode 100644 index d94f66ce..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/form/form_data_provider.yml +++ /dev/null @@ -1,140 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.form.identifiable_object.data_provider.sql_request_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\SqlRequestFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - prestashop.core.form.identifiable_object.data_provider.customer_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\CustomerFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.group.provider.default_groups_provider' - - '@=service("prestashop.core.b2b.b2b_feature").isActive()' - - prestashop.core.form.identifiable_object.data_provider.language_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\LanguageFormDataProvider' - arguments: - - '@prestashop.core.command_bus' - - '@=service("prestashop.adapter.multistore_feature").isActive()' - - '@=service("prestashop.adapter.shop.context").getShops(true, true)' - - prestashop.core.form.identifiable_object.data_provider.currency_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\CurrencyFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - - prestashop.core.form.identifiable_object.data_provider.webservice_key_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\WebserviceKeyFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - '@=service("prestashop.adapter.shop.context").getShops(true, true)' - - - prestashop.core.form.identifiable_object.data_provider.meta_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\MetaFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - prestashop.core.form.identifiable_object.data_provider.category_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\CategoryFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.getCategory()' - - '@prestashop.adapter.group.provider.default_groups_provider' - - prestashop.core.form.identifiable_object.data_provider.contact_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\ContactFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - '@prestashop.bundle.form.data_transformer.string_array_to_integer_array' - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - - prestashop.core.form.identifiable_object.data_provider.cms_page_category_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\CmsPageCategoryFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - - prestashop.core.form.identifiable_object.data_provider.tax_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\TaxFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - prestashop.core.form.identifiable_object.data_provider.manufacturer_address_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\ManufacturerAddressFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - '@=service("prestashop.adapter.legacy.context").getContext().country.id' - - prestashop.core.form.identifiable_object.data_provider.manufacturer_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\ManufacturerFormDataProvider' - arguments: - - '@prestashop.core.command_bus' - - '@=service("prestashop.adapter.multistore_feature").isActive()' - - '@=service("prestashop.adapter.shop.context").getShops(true, true)' - - prestashop.core.form.identifiable_object.data_provider.employee_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\EmployeeFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - '@=service("prestashop.adapter.multistore_feature").isActive()' - - '@=service("prestashop.adapter.shop.context").getShops(true, true)' - - prestashop.core.form.identifiable_object.data_provider.profile_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\ProfileFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - prestashop.core.form.identifiable_object.data_provider.cms_page_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\CmsPageFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - - prestashop.core.form.identifiable_object.data_provider.supplier_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\SupplierFormDataProvider' - arguments: - - '@prestashop.core.command_bus' - - '@=service("prestashop.adapter.multistore_feature").isActive()' - - '@=service("prestashop.adapter.shop.context").getShops(true, true)' - - '@=service("prestashop.adapter.legacy.context").getContext().country.id' - - prestashop.core.form.identifiable_object.data_provider.feature_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\FeatureFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - '@=service("prestashop.adapter.multistore_feature").isActive()' - - '@=service("prestashop.adapter.shop.context").getShops(true, true)' - - prestashop.core.form.identifiable_object.data_provider.order_message_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\OrderMessageFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - prestashop.core.form.identifiable_object.data_provider.catalog_price_rule_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\CatalogPriceRuleFormDataProvider' - arguments: - - '@prestashop.core.command_bus' - - prestashop.core.form.identifiable_object.data_provider.attachment_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\AttachmentFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - prestashop.core.form.identifiable_object.data_provider.cancel_product_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\CancelProductFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - '@prestashop.adapter.data_provider.currency' - - prestashop.core.form.identifiable_object.data_provider.address_form_data_provider: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\DataProvider\AddressFormDataProvider' - arguments: - - '@prestashop.core.query_bus' - - '@=service("prestashop.adapter.legacy.context").getContext().country.id' diff --git a/src/PrestaShopBundle/Resources/config/services/core/form/form_handler.yml b/src/PrestaShopBundle/Resources/config/services/core/form/form_handler.yml deleted file mode 100644 index 74e80f44..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/form/form_handler.yml +++ /dev/null @@ -1,179 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.form.identifiable_object.handler.form_handler_factory: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandlerFactory' - arguments: - - '@prestashop.core.hook.dispatcher' - - '@translator' - - '@=service("prestashop.adapter.legacy.configuration").get("_PS_MODE_DEMO_")' - - prestashop.core.form.identifiable_object.sql_request_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.sql_request_form_data_handler' - - prestashop.core.form.identifiable_object.handler.customer_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.customer_form_data_handler' - - prestashop.core.form.identifiable_object.handler.language_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.language_form_data_handler' - - prestashop.core.form.identifiable_object.currency_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.currency_form_data_handler' - - prestashop.core.form.identifiable_object.handler.webservice_key_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.webservice_key_form_data_handler' - - - prestashop.core.form.identifiable_object.meta_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.meta_form_data_handler' - - prestashop.core.form.identifiable_object.handler.category_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.category_form_data_handler' - - prestashop.core.form.identifiable_object.handler.root_category_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.root_category_form_data_handler' - - prestashop.core.form.identifiable_object.handler.contact_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.contact_form_data_handler' - - prestashop.core.form.identifiable_object.handler.cms_page_category_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.cms_page_category_form_data_handler' - - prestashop.core.form.identifiable_object.handler.tax_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.tax_form_data_handler' - - prestashop.core.form.identifiable_object.handler.manufacturer_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.manufacturer_form_data_handler' - - prestashop.core.form.identifiable_object.handler.employee_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.employee_form_data_handler' - - prestashop.core.form.identifiable_object.handler.profile_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.profile_form_data_handler' - - prestashop.core.form.identifiable_object.handler.cms_page_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.cms_page_form_data_handler' - - prestashop.core.form.identifiable_object.handler.manufacturer_address_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.manufacturer_address_form_data_handler' - - prestashop.core.form.identifiable_object.handler.supplier_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.supplier_form_data_handler' - - prestashop.core.form.identifiable_object.handler.feature_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.feature_form_data_handler' - - prestashop.core.form.identifiable_object.handler.order_message_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.order_message_form_data_handler' - - prestashop.core.form.identifiable_object.handler.catalog_price_rule_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.catalog_price_rule_form_data_handler' - - prestashop.core.form.identifiable_object.handler.attachment_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.attachment_form_data_handler' - - prestashop.core.form.identifiable_object.partial_refund_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.partial_refund_form_data_handler' - - prestashop.core.form.identifiable_object.standard_refund_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.standard_refund_form_data_handler' - - prestashop.core.form.identifiable_object.return_product_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.return_product_form_data_handler' - - prestashop.core.form.identifiable_object.handler.address_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.address_form_data_handler' - - prestashop.core.form.identifiable_object.handler.order_address_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.order_address_form_data_handler' - - prestashop.core.form.identifiable_object.handler.cart_address_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.data_handler.cart_address_form_data_handler' - - prestashop.core.form.identifiable_object.cancellation_form_handler: - class: 'PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandler' - factory: 'prestashop.core.form.identifiable_object.handler.form_handler_factory:create' - arguments: - - '@prestashop.core.form.identifiable_object.cancellation_form_data_handler' diff --git a/src/PrestaShopBundle/Resources/config/services/core/foundation.yml b/src/PrestaShopBundle/Resources/config/services/core/foundation.yml deleted file mode 100644 index 223e39df..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/foundation.yml +++ /dev/null @@ -1,12 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.foundation.version: - class: PrestaShop\PrestaShop\Core\Foundation\Version - arguments: - - !php/const AppKernel::VERSION - - !php/const AppKernel::MAJOR_VERSION_STRING - - !php/const AppKernel::MAJOR_VERSION - - !php/const AppKernel::MINOR_VERSION - - !php/const AppKernel::RELEASE_VERSION diff --git a/src/PrestaShopBundle/Resources/config/services/core/geolocation.yml b/src/PrestaShopBundle/Resources/config/services/core/geolocation.yml deleted file mode 100644 index 533033c3..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/geolocation.yml +++ /dev/null @@ -1,8 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.geolocation.geo_lite_city.checker: - class: 'PrestaShop\PrestaShop\Core\Geolocation\GeoLite\GeoLiteCityChecker' - arguments: - - '@prestashop.adapter.legacy.configuration' diff --git a/src/PrestaShopBundle/Resources/config/services/core/grid.yml b/src/PrestaShopBundle/Resources/config/services/core/grid.yml deleted file mode 100644 index d23b8b7f..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/grid.yml +++ /dev/null @@ -1,44 +0,0 @@ -imports: - - { resource: grid/*.yml } - -parameters: - prestashop.core.grid.data.factory.doctrine_grid_data_factory: PrestaShop\PrestaShop\Core\Grid\Data\Factory\DoctrineGridDataFactory - -services: - _defaults: - public: true - - prestashop.core.grid.presenter.grid_presenter: - class: 'PrestaShop\PrestaShop\Core\Grid\Presenter\GridPresenter' - arguments: - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.query.doctrine_query_parser: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\DoctrineQueryParser' - - prestashop.core.query.doctrine_search_criteria_applicator: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\DoctrineSearchCriteriaApplicator' - - # Grid position updater - prestashop.core.grid.position.position_update_factory: - class: 'PrestaShop\PrestaShop\Core\Grid\Position\PositionUpdateFactory' - arguments: - - 'positions' - - 'rowId' - - 'oldPosition' - - 'newPosition' - - 'parentId' - - prestashop.core.grid.position.update_handler.doctrine_position_update_handler: - class: 'PrestaShop\PrestaShop\Core\Grid\Position\UpdateHandler\DoctrinePositionUpdateHandler' - arguments: - - '@doctrine.dbal.default_connection' - - '%database_prefix%' - - prestashop.core.grid.position.doctrine_grid_position_updater: - class: 'PrestaShop\PrestaShop\Core\Grid\Position\GridPositionUpdater' - arguments: - - '@prestashop.core.grid.position.update_handler.doctrine_position_update_handler' - - prestashop.core.grid.query.filter.doctrine_filter_applicator: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\Filter\DoctrineFilterApplicator' diff --git a/src/PrestaShopBundle/Resources/config/services/core/grid/accessibility_checker.yml b/src/PrestaShopBundle/Resources/config/services/core/grid/accessibility_checker.yml deleted file mode 100644 index 8b70c2b7..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/grid/accessibility_checker.yml +++ /dev/null @@ -1,14 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.grid.action.row.accessibility_checker.delete_profile: - class: 'PrestaShop\PrestaShop\Core\Grid\Action\Row\AccessibilityChecker\DeleteProfileAccessibilityChecker' - arguments: - - '@=service("prestashop.adapter.legacy.configuration").get("_PS_ADMIN_PROFILE_")' - - prestashop.core.grid.action.row.accessibility_checker.print_invoice: - class: 'PrestaShop\PrestaShop\Core\Grid\Action\Row\AccessibilityChecker\PrintInvoiceAccessibilityChecker' - - prestashop.core.grid.action.row.accessibility_checker.print_delivery_slip: - class: 'PrestaShop\PrestaShop\Core\Grid\Action\Row\AccessibilityChecker\PrintDeliverySlipAccessibilityChecker' diff --git a/src/PrestaShopBundle/Resources/config/services/core/grid/doctrine_query_builder.yml b/src/PrestaShopBundle/Resources/config/services/core/grid/doctrine_query_builder.yml deleted file mode 100644 index b2b2d1d2..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/grid/doctrine_query_builder.yml +++ /dev/null @@ -1,291 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.grid.abstract_query_builder: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\AbstractDoctrineQueryBuilder' - abstract: true - arguments: - - '@doctrine.dbal.default_connection' - - '%database_prefix%' - - prestashop.core.grid.query_builder.email_logs: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\EmailLogsQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - public: true - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - prestashop.core.grid.query.webservice_key: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\WebserviceKeyQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - - '@prestashop.core.grid.query.filter.doctrine_filter_applicator' - public: true - - prestashop.core.grid.query_builder.meta: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\MetaQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - - "@=service('prestashop.adapter.legacy.context').getContext().shop.id" - public: true - - prestashop.core.grid.query_builder.employee: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\EmployeeQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - - "@=service('prestashop.adapter.legacy.context').getContext().shop.getContextListShopID()" - public: true - - prestashop.core.grid.query_builder.contact: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\ContactQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - public: true - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - - "@=service('prestashop.adapter.shop.context').getContextListShopID()" - - prestashop.core.grid.query_builder.customer: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\CustomerQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - - '@=service("prestashop.adapter.shop.context").getContextListShopIDUsingCustomerSharingSettings()' - public: true - - prestashop.core.grid.quer_.builder.language: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\LanguageQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - public: true - - prestashop.core.grid.query_builder.currency: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\CurrencyQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - public: true - - prestashop.core.grid.query_builder.supplier: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\SupplierQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - - "@=service('prestashop.adapter.shop.context').getContextListShopID()" - public: true - - prestashop.core.grid.query_builder.profile: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\ProfileQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - public: true - - prestashop.core.grid.query_builder.cms_page_category: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\CmsPageCategoryQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - public: true - - prestashop.core.grid.query_builder.tax: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\TaxQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - "@=service('prestashop.adapter.legacy.context').getContext().employee.id_lang" - public: true - - prestashop.core.grid.query_builder.manufacturer: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\ManufacturerQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - '@=service("prestashop.adapter.shop.context").getContextListShopId()' - public: true - - prestashop.core.grid.query_builder.manufacturer_address: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\ManufacturerAddressQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - "@=service('prestashop.adapter.legacy.context').getContext().shop.id" - public: true - - prestashop.core.grid.query_builder.category: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\CategoryQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - - "@=service('prestashop.adapter.legacy.context').getContext().shop.id" - - '@prestashop.adapter.shop.context' - - '@prestashop.adapter.feature.multistore' - - "@=service('prestashop.adapter.legacy.configuration').get('PS_ROOT_CATEGORY')" - public: true - - prestashop.core.grid.query_builder.cms_page: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\CmsPageQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - public: true - - prestashop.core.grid.query_builder.monitoring.empty_category: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\Monitoring\EmptyCategoryQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - - "@=service('prestashop.adapter.legacy.context').getContext().shop.id" - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - '@prestashop.adapter.shop.context' - - "@=service('prestashop.adapter.legacy.configuration').get('PS_ROOT_CATEGORY')" - public: true - - prestashop.core.grid.query_builder.monitoring.abstract_product_query_builder: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\Monitoring\AbstractProductQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - - "@=service('prestashop.adapter.legacy.context').getContext().shop.id" - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - '@prestashop.adapter.shop.context' - - '@prestashop.adapter.feature.multistore' - public: true - - prestashop.core.grid.query_builder.monitoring.no_qty_product_with_combination: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\Monitoring\NoQtyProductWithCombinationQueryBuilder' - parent: 'prestashop.core.grid.query_builder.monitoring.abstract_product_query_builder' - public: true - - prestashop.core.grid.query_builder.monitoring.no_qty_product_without_combination: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\Monitoring\NoQtyProductWithoutCombinationQueryBuilder' - parent: 'prestashop.core.grid.query_builder.monitoring.abstract_product_query_builder' - public: true - - prestashop.core.grid.query_builder.monitoring.disabled_product: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\Monitoring\DisabledProductQueryBuilder' - parent: 'prestashop.core.grid.query_builder.monitoring.abstract_product_query_builder' - public: true - - prestashop.core.grid.query_builder.monitoring.product_without_image: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\Monitoring\ProductWithoutImageQueryBuilder' - parent: 'prestashop.core.grid.query_builder.monitoring.abstract_product_query_builder' - public: true - - prestashop.core.grid.query_builder.monitoring.product_without_description: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\Monitoring\ProductWithoutDescriptionQueryBuilder' - parent: 'prestashop.core.grid.query_builder.monitoring.abstract_product_query_builder' - public: true - - prestashop.core.grid.query_builder.monitoring.product_without_price: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\Monitoring\ProductWithoutPriceQueryBuilder' - parent: 'prestashop.core.grid.query_builder.monitoring.abstract_product_query_builder' - public: true - - prestashop.core.grid.query_builder.order: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\OrderQueryBuilder' - arguments: - - '@doctrine.dbal.default_connection' - - '%database_prefix%' - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - - "@=service(\"prestashop.adapter.shop.context\").getContextListShopID(parameter('multishop.settings.share_orders'))" - - prestashop.core.grid.query_builder.catalog_price_rule: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\CatalogPriceRuleQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - '@=service("prestashop.adapter.shop.context").getShops(true, true)' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - public: true - - prestashop.core.grid.query_builder.order_message: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\OrderMessageQueryBuilder' - arguments: - - '@doctrine.dbal.default_connection' - - '%database_prefix%' - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - - '@prestashop.core.grid.query.filter.doctrine_filter_applicator' - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - prestashop.core.grid.query_builder.attachment: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\AttachmentQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - "@=service('prestashop.adapter.legacy.context').getContext().employee.id_lang" - public: true - - prestashop.core.grid.query_builder.attribute: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\AttributeQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - - '@=service("request_stack").getCurrentRequest().attributes.getInt("attributeGroupId")' - - '@prestashop.adapter.shop.context' - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - public: true - - prestashop.core.grid.query_builder.attribute_group: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\AttributeGroupQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - '@=service("prestashop.adapter.legacy.context").getContext().language.id' - - '@prestashop.adapter.shop.context' - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - public: true - - prestashop.core.grid.query_builder.merchandise_return: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\MerchandiseReturnQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - public: true - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - - "@=service('prestashop.adapter.shop.context').getContextListShopID()" - - prestashop.core.grid.query_builder.tax_rules_group: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\TaxRulesGroupQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - "@=service('prestashop.adapter.shop.context').getContextListShopID()" - public: true - - prestashop.core.grid.query_builder.address: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\AddressQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - public: true - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - "@=service('prestashop.adapter.legacy.context').getContext().language.id" - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - - prestashop.core.grid.query_builder.credit_slip: - class: 'PrestaShop\PrestaShop\Core\Grid\Query\CreditSlipQueryBuilder' - parent: 'prestashop.core.grid.abstract_query_builder' - arguments: - - '@prestashop.core.query.doctrine_search_criteria_applicator' - - '@=service("prestashop.adapter.shop.context").getContextListShopID()' - public: true diff --git a/src/PrestaShopBundle/Resources/config/services/core/grid/grid_data_factory.yml b/src/PrestaShopBundle/Resources/config/services/core/grid/grid_data_factory.yml deleted file mode 100644 index 134203e6..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/grid/grid_data_factory.yml +++ /dev/null @@ -1,359 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.grid.data_factory.log: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.admin.log.repository' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'logs' - - prestashop.core.grid.data_factory.email_logs: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.email_logs' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'email_logs' - - prestashop.core.grid.data_factory.request_sql: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.admin.request_sql.repository' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'request_sql' - - prestashop.core.grid.data_factory.webservice_key: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query.webservice_key' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'webservice_key' - - prestashop.core.grid.data_provider.meta: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.meta' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'meta' - - prestashop.core.grid.data.factory.category: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.category' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'category' - - prestashop.core.grid.data.factory.category_decorator: - class: 'PrestaShop\PrestaShop\Core\Grid\Data\Factory\CategoryDataFactory' - arguments: - - '@prestashop.core.grid.data.factory.category' - - prestashop.core.grid.data_provider.employee: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.employee' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'employee' - - prestashop.core.grid.data_provider.contacts: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.contact' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'contact' - - prestashop.core.grid.data_provider.customer: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.customer' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'customer' - - prestashop.core.grid.data_provider.customer_decorator: - class: 'PrestaShop\PrestaShop\Core\Grid\Data\Factory\CustomerGridDataFactoryDecorator' - arguments: - - '@prestashop.core.grid.data_provider.customer' - - "@prestashop.core.localization.locale.context_locale" - - "@=service('prestashop.adapter.legacy.context').getContext().currency.iso_code" - - prestashop.core.grid.data.factory.language: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.quer_.builder.language' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'language' - - prestashop.core.grid.factory.language_decorator: - class: 'PrestaShop\PrestaShop\Core\Grid\Data\Factory\LanguageGridDataFactory' - arguments: - - '@prestashop.core.grid.data.factory.language' - - '@prestashop.adapter.language.language_flag_thumbnail_provider' - - prestashop.core.grid.data_provider.currency: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.currency' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'currency' - - prestashop.core.grid.data_provider.supplier: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.supplier' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'suppliers' - - prestashop.core.grid.factory.supplier_decorator: - class: 'PrestaShop\PrestaShop\Core\Grid\Data\Factory\SupplierGridDataFactory' - arguments: - - '@prestashop.core.grid.data_provider.supplier' - - '@prestashop.adapter.supplier.provider.supplier_logo' - - prestashop.core.grid.data_factory.profiles: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.profile' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'profile' - - prestashop.core.grid.data_provider.cms_page_category: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.cms_page_category' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'cms_page_category' - - prestashop.core.grid.data_factory.tax: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.tax' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'tax' - - prestashop.core.grid.data.factory.manufacturer: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.manufacturer' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'manufacturer' - - prestashop.core.grid.data.factory.manufacturer_decorator: - class: 'PrestaShop\PrestaShop\Core\Grid\Data\Factory\ManufacturerGridDataFactory' - arguments: - - '@prestashop.core.grid.data.factory.manufacturer' - - '@prestashop.adapter.manufacturer.manufacturer_logo_thumbnail_provider' - - prestashop.core.grid.data.factory.manufacturer_address: - class: 'PrestaShop\PrestaShop\Core\Grid\Data\Factory\DoctrineGridDataFactory' - arguments: - - '@prestashop.core.grid.query_builder.manufacturer_address' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'manufacturer_address' - - prestashop.core.grid.data.factory.manufacturer_address_decorator: - class: 'PrestaShop\PrestaShop\Core\Grid\Data\Factory\ManufacturerAddressGridDataFactory' - arguments: - - '@prestashop.core.grid.data.factory.manufacturer_address' - - prestashop.core.grid.data_provider.cms_page: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.cms_page' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'cms_page' - - prestashop.core.grid.data.factory.empty_category: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.monitoring.empty_category' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'empty_category' - - prestashop.core.grid.data.factory.empty_category_decorator: - class: 'PrestaShop\PrestaShop\Core\Grid\Data\Factory\EmptyCategoryGridDataFactory' - arguments: - - '@prestashop.core.grid.data.factory.empty_category' - - prestashop.core.grid.data.factory.no_qty_product_with_combination: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.monitoring.no_qty_product_with_combination' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'no_qty_product_with_combination' - - prestashop.core.grid.data.factory.no_qty_product_without_combination: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.monitoring.no_qty_product_without_combination' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'no_qty_product_without_combination' - - prestashop.core.grid.data.factory.disabled_product: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.monitoring.disabled_product' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'disabled_product' - - prestashop.core.grid.data.factory.product_without_image: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.monitoring.product_without_image' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'product_without_image' - - prestashop.core.grid.data.factory.product_without_description: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.monitoring.product_without_description' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'product_without_description' - - prestashop.core.grid.data.factory.product_without_price: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.monitoring.product_without_price' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'product_without_price' - - prestashop.core.grid.data.factory.order: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.order' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'order' - - prestashop.core.grid.data.factory.order_decorator: - class: 'PrestaShop\PrestaShop\Core\Grid\Data\Factory\OrderGridDataFactory' - arguments: - - '@prestashop.core.grid.data.factory.order' - - '@prestashop.core.localization.locale.repository' - - '@prestashop.adapter.legacy.configuration' - - '@=service("prestashop.adapter.legacy.context").getContext().language.getLocale()' - - prestashop.core.grid.data.factory.catalog_price_rule: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.catalog_price_rule' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'catalog_price_rule' - - prestashop.core.grid.data.factory.catalog_price_rule_decorator: - class: 'PrestaShop\PrestaShop\Core\Grid\Data\Factory\CatalogPriceRuleGridDataFactory' - arguments: - - '@prestashop.core.grid.data.factory.catalog_price_rule' - - '@translator' - - prestashop.core.grid.data.factory.order_message: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.order_message' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'order_message' - - prestashop.core.grid.data_factory.attachment: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.attachment' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'attachment' - - prestashop.core.grid.data_factory.attachment_decorator: - class: 'PrestaShop\PrestaShop\Core\Grid\Data\Factory\AttachmentGridDataFactoryDecorator' - arguments: - - '@prestashop.core.grid.data_factory.attachment' - - "@=service('prestashop.adapter.legacy.context').getContext().employee.id_lang" - - '@doctrine.dbal.default_connection' - - '%database_prefix%' - - "@prestashop.core.util.file_size.size_converter" - calls: - - [setTranslator, ['@translator']] - - prestashop.core.grid.data.factory.attribute: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.attribute' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'attribute' - - prestashop.core.grid.data.factory.attribute_group: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.attribute_group' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'attribute_group' - - prestashop.core.grid.data.factory.attribute_group_decorator: - class: 'PrestaShop\PrestaShop\Core\Grid\Data\Factory\AttributeGroupGridDataFactory' - arguments: - - '@prestashop.core.grid.data.factory.attribute_group' - - prestashop.core.grid.data_provider.merchandise_return: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.merchandise_return' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'merchandise_return' - - prestashop.core.grid.data.factory.tax_rules_group: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.tax_rules_group' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'tax_rules_group' - - prestashop.core.grid.data.factory.address: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.address' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'address' - - prestashop.core.grid.data.factory.credit_slip: - class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%' - arguments: - - '@prestashop.core.grid.query_builder.credit_slip' - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.grid.query.doctrine_query_parser' - - 'credit_slip' - - prestashop.core.grid.data.factory.credit_slip_decorator: - class: 'PrestaShop\PrestaShop\Core\Grid\Data\Factory\CreditSlipGridDataFactory' - arguments: - - '@prestashop.core.grid.data.factory.credit_slip' - - '@translator' diff --git a/src/PrestaShopBundle/Resources/config/services/core/grid/grid_definition_factory.yml b/src/PrestaShopBundle/Resources/config/services/core/grid/grid_definition_factory.yml deleted file mode 100644 index abd29273..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/grid/grid_definition_factory.yml +++ /dev/null @@ -1,253 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.grid.definition.factory.abstract_grid_definition: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AbstractGridDefinitionFactory' - abstract: true - arguments: - - '@prestashop.core.hook.dispatcher' - calls: - - [setTranslator, ['@translator']] - - prestashop.core.grid.definition.factory.logs: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\LogGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - arguments: - - "@=service('router').generate('admin_common_reset_search', {'controller': 'logs', 'action': 'index'})" - - "@=service('router').generate('admin_logs_index')" - public: true - - prestashop.core.grid.definition.factory.email_logs: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\EmailLogsDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - arguments: - - "@=service('router').generate('admin_common_reset_search', {'controller': 'email', 'action': 'index'})" - - "@=service('router').generate('admin_emails_index')" - - '@prestashop.core.form.choice_provider.language_by_id' - public: true - - prestashop.core.grid.definition.factory.request_sql: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\RequestSqlGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - arguments: - - "@=service('router').generate('admin_common_reset_search', {'controller': 'sqlmanager', 'action': 'index'})" - - "@=service('router').generate('admin_sql_requests_index')" - public: true - - prestashop.core.grid.definition.factory.backup: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\BackupDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.webservice_key: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\WebserviceKeyDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - arguments: - - '@=service("prestashop.core.form.choice_provider.status").getChoices()' - - "@=service('router').generate('admin_common_reset_search', {'controller': 'webservice', 'action': 'index'})" - - "@=service('router').generate('admin_webservice_keys_index')" - public: true - - prestashop.core.grid.definition.factory.meta: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\MetaGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.category: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CategoryGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - arguments: - - "@=service('router').generate('admin_common_reset_search', {'controller': 'category', 'action': 'index'})" - - "@=service('router').generate('admin_categories_index')" - - '@prestashop.adapter.shop.context' - - '@prestashop.adapter.grid.action.row.accessibility_checker.category_for_view' - public: true - - prestashop.core.grid.definition.factory.employee: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\EmployeeGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - arguments: - - "@=service('router').generate('admin_common_reset_search', {'controller': 'employee', 'action': 'index'})" - - "@=service('router').generate('admin_employees_index')" - public: true - - prestashop.core.grid.definition.factory.contacts: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\ContactGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - arguments: - - "@=service('router').generate('admin_common_reset_search', {'controller': 'contacts', 'action': 'index'})" - - "@=service('router').generate('admin_contacts_index')" - public: true - - prestashop.core.grid.definition.factory.customer: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CustomerGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - arguments: - - '@=service("prestashop.core.b2b.b2b_feature").isActive()' - - '@=service("prestashop.adapter.multistore_feature").isActive()' - - '@=service("prestashop.adapter.form.choice_provider.gender_by_id_choice_provider").getChoices()' - public: true - - prestashop.core.grid.definition.factory.language: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\LanguageGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.currency: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CurrencyGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.supplier: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\SupplierGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.profile: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\ProfileGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - arguments: - - "@=service('router').generate('admin_common_reset_search', {'controller': 'profile', 'action': 'index'})" - - "@=service('router').generate('admin_profiles_index')" - - '@prestashop.core.grid.action.row.accessibility_checker.delete_profile' - public: true - - prestashop.core.grid.definition.factory.cms_page_category: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CmsPageCategoryDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - arguments: - - '@request_stack' - - '@prestashop.adapter.shop.context' - - '@=service("prestashop.adapter.multistore_feature").isUsed()' - public: true - - prestashop.core.grid.definition.factory.tax: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\TaxGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.manufacturer: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\ManufacturerGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.manufacturer_address: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\ManufacturerAddressGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.cms_page: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CmsPageDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - arguments: - - '@prestashop.core.query_bus' - - '@request_stack' - - '@prestashop.adapter.shop.context' - - '@=service("prestashop.adapter.multistore_feature").isUsed()' - public: true - - prestashop.core.grid.definition.factory.monitoring.empty_category: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\EmptyCategoryGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - arguments: - - '@prestashop.adapter.grid.action.row.accessibility_checker.category_for_view' - public: true - - prestashop.core.grid.definition.factory.monitoring.no_qty_product_with_combination: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\NoQtyProductWithCombinationGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.monitoring.no_qty_product_without_combination: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\NoQtyProductWithoutCombinationGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.monitoring.disabled_product: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\DisabledProductGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.monitoring.product_without_image: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\ProductWithoutImageGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.monitoring.product_without_description: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\ProductWithoutDescriptionGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.monitoring.product_without_price: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\Monitoring\ProductWithoutPriceGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.order: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\OrderGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.form.choice_provider.order_countries' - - '@prestashop.core.form.choice_provider.order_state_by_id' - - '@=service("prestashop.adapter.legacy.context").getContext().language.date_format_full' - - '@prestashop.adapter.feature.multistore' - - '@prestashop.core.grid.action.row.accessibility_checker.print_invoice' - - '@prestashop.core.grid.action.row.accessibility_checker.print_delivery_slip' - - '@prestashop.core.form.choice_provider.order_state_by_id' - public: true - - prestashop.core.grid.definition.factory.catalog_price_rule: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CatalogPriceRuleGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - arguments: - - '@request_stack' - - '@prestashop.adapter.shop.context' - - '@=service("prestashop.adapter.multistore_feature").isUsed()' - public: true - - prestashop.core.grid.definition.factory.order_message: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\OrderMessageGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.attachment: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AttachmentGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.attribute: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AttributeGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - arguments: - - '@=service("request_stack").getCurrentRequest().attributes.getInt("attributeGroupId")' - - '@prestashop.core.attribute_group.attribute_group_view_data_provider' - public: true - - prestashop.core.grid.definition.factory.attribute_group: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AttributeGroupGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.merchandise_return: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\MerchandiseReturnGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.tax_rules_group: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\TaxRulesGroupGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.address: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AddressGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - public: true - - prestashop.core.grid.definition.factory.credit_slip: - class: 'PrestaShop\PrestaShop\Core\Grid\Definition\Factory\CreditSlipGridDefinitionFactory' - parent: 'prestashop.core.grid.definition.factory.abstract_grid_definition' - arguments: - - '@=service("prestashop.adapter.legacy.context").getLanguage().date_format_lite' - public: true diff --git a/src/PrestaShopBundle/Resources/config/services/core/grid/grid_factory.yml b/src/PrestaShopBundle/Resources/config/services/core/grid/grid_factory.yml deleted file mode 100644 index d6cd401b..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/grid/grid_factory.yml +++ /dev/null @@ -1,297 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.grid.log_factory: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.logs' - - '@prestashop.core.grid.data_factory.log' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.email_logs: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.email_logs' - - '@prestashop.core.grid.data_factory.email_logs' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.request_sql: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.request_sql' - - '@prestashop.core.grid.data_factory.request_sql' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.backup: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.backup' - - '@prestashop.core.backup.listing.grid_data_factory' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.webservice_key: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.webservice_key' - - '@prestashop.core.grid.data_factory.webservice_key' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.meta: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.meta' - - '@prestashop.core.grid.data_provider.meta' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.category: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.category' - - '@prestashop.core.grid.data.factory.category_decorator' - - '@prestashop.core.grid.filter.category_form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.category_decorator: - class: 'PrestaShop\PrestaShop\Core\Grid\Factory\CategoryGridFactoryDecorator' - arguments: - - '@prestashop.core.grid.factory.category' - - '@prestashop.core.grid.filter.category_form_factory' - - prestashop.core.grid.factory.employee: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.employee' - - '@prestashop.core.grid.data_provider.employee' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.contacts: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.contacts' - - '@prestashop.core.grid.data_provider.contacts' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.customer: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.customer' - - '@prestashop.core.grid.data_provider.customer_decorator' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.language: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.language' - - '@prestashop.core.grid.factory.language_decorator' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.supplier: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.supplier' - - '@prestashop.core.grid.factory.supplier_decorator' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.currency: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.currency' - - '@prestashop.core.currency.grid_data_factory' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.profiles: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.profile' - - '@prestashop.core.grid.data_factory.profiles' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.cms_page_category: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.cms_page_category' - - '@prestashop.core.grid.data_provider.cms_page_category' - - '@prestashop.core.grid.filter.cms_page_form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.tax: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.tax' - - '@prestashop.core.grid.data_factory.tax' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.grid_factory.manufacturer: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.manufacturer' - - '@prestashop.core.grid.data.factory.manufacturer_decorator' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.grid_factory.manufacturer_address: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.manufacturer_address' - - '@prestashop.core.grid.data.factory.manufacturer_address_decorator' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.cms_page: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.cms_page' - - '@prestashop.core.grid.data_provider.cms_page' - - '@prestashop.core.grid.filter.cms_page_form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.grid_factory.empty_category: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.monitoring.empty_category' - - '@prestashop.core.grid.data.factory.empty_category_decorator' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.grid_factory.no_qty_product_with_combination: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.monitoring.no_qty_product_with_combination' - - '@prestashop.core.grid.data.factory.no_qty_product_with_combination' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.grid_factory.no_qty_product_without_combination: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.monitoring.no_qty_product_without_combination' - - '@prestashop.core.grid.data.factory.no_qty_product_without_combination' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.grid_factory.disabled_product: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.monitoring.disabled_product' - - '@prestashop.core.grid.data.factory.disabled_product' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.grid_factory.product_without_image: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.monitoring.product_without_image' - - '@prestashop.core.grid.data.factory.product_without_image' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.grid_factory.product_without_description: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.monitoring.product_without_description' - - '@prestashop.core.grid.data.factory.product_without_description' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.grid_factory.product_without_price: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.monitoring.product_without_price' - - '@prestashop.core.grid.data.factory.product_without_price' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.order: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.order' - - '@prestashop.core.grid.data.factory.order_decorator' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.grid_factory.catalog_price_rule: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.catalog_price_rule' - - '@prestashop.core.grid.data.factory.catalog_price_rule_decorator' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.grid_factory.order_message: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.order_message' - - '@prestashop.core.grid.data.factory.order_message' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.attachment: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.attachment' - - '@prestashop.core.grid.data_factory.attachment_decorator' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.attribute: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.attribute' - - '@prestashop.core.grid.data.factory.attribute' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.attribute_group: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.attribute_group' - - '@prestashop.core.grid.data.factory.attribute_group_decorator' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.merchandise_return: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.merchandise_return' - - '@prestashop.core.grid.data_provider.merchandise_return' - - '@prestashop.core.grid.filter.merchandise_return_form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.tax_rules_group: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.tax_rules_group' - - '@prestashop.core.grid.data.factory.tax_rules_group' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.grid_factory.address: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.address' - - '@prestashop.core.grid.data.factory.address' - - '@prestashop.core.grid.filter.form_factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.factory.credit_slip: - class: 'PrestaShop\PrestaShop\Core\Grid\GridFactory' - arguments: - - '@prestashop.core.grid.definition.factory.credit_slip' - - '@prestashop.core.grid.data.factory.credit_slip_decorator' - - '@prestashop.core.grid.filter.credit_slip_form_factory' - - '@prestashop.core.hook.dispatcher' diff --git a/src/PrestaShopBundle/Resources/config/services/core/grid/grid_filter_form_factory.yml b/src/PrestaShopBundle/Resources/config/services/core/grid/grid_filter_form_factory.yml deleted file mode 100644 index 4acd122a..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/grid/grid_filter_form_factory.yml +++ /dev/null @@ -1,38 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.grid.filter.form_factory: - class: 'PrestaShop\PrestaShop\Core\Grid\Filter\GridFilterFormFactory' - arguments: - - '@form.factory' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.grid.filter.category_form_factory: - class: 'PrestaShop\PrestaShop\Core\Grid\Filter\CategoryFilterFormFactory' - arguments: - - '@prestashop.core.grid.filter.form_factory' - - '@router' - - '@request_stack' - - prestashop.core.grid.filter.cms_page_form_factory: - class: 'PrestaShop\PrestaShop\Core\Grid\Filter\CmsPageFilterFormFactory' - arguments: - - '@prestashop.core.grid.filter.form_factory' - - '@router' - - '@request_stack' - - prestashop.core.grid.filter.merchandise_return_form_factory: - class: 'PrestaShop\PrestaShop\Core\Grid\Filter\FilterFormFactoryFormActionDecorator' - arguments: - - '@prestashop.core.grid.filter.form_factory' - - '@router' - - 'admin_merchandise_returns_filter' - - - prestashop.core.grid.filter.credit_slip_form_factory: - class: 'PrestaShop\PrestaShop\Core\Grid\Filter\FilterFormFactoryFormActionDecorator' - arguments: - - '@prestashop.core.grid.filter.form_factory' - - '@router' - - 'admin_credit_slips_search' diff --git a/src/PrestaShopBundle/Resources/config/services/core/grid/grid_position_definition_factory.yml b/src/PrestaShopBundle/Resources/config/services/core/grid/grid_position_definition_factory.yml deleted file mode 100644 index 0bca4905..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/grid/grid_position_definition_factory.yml +++ /dev/null @@ -1,34 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.grid.cms_page_category.position_definition: - class: 'PrestaShop\PrestaShop\Core\Grid\Position\PositionDefinition' - arguments: - $table: 'cms_category' - $idField: 'id_cms_category' - $positionField: 'position' - $parentIdField: 'id_parent' - - prestashop.core.grid.cms_page.position_definition: - class: 'PrestaShop\PrestaShop\Core\Grid\Position\PositionDefinition' - arguments: - $table: 'cms' - $idField: 'id_cms' - $positionField: 'position' - $parentIdField: 'id_cms_category' - - prestashop.core.grid.attribute.position_definition: - class: 'PrestaShop\PrestaShop\Core\Grid\Position\PositionDefinition' - arguments: - $table: 'attribute' - $idField: 'id_attribute' - $positionField: 'position' - $parentIdField: 'id_attribute_group' - - prestashop.core.grid.attribute_group.position_definition: - class: 'PrestaShop\PrestaShop\Core\Grid\Position\PositionDefinition' - arguments: - $table: 'attribute_group' - $idField: 'id_attribute_group' - $positionField: 'position' diff --git a/src/PrestaShopBundle/Resources/config/services/core/hook.yml b/src/PrestaShopBundle/Resources/config/services/core/hook.yml deleted file mode 100644 index 91b085da..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/hook.yml +++ /dev/null @@ -1,88 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.hook.dispatcher: - class: 'PrestaShop\PrestaShop\Core\Hook\HookDispatcher' - arguments: - - '@prestashop.hook.dispatcher' - - prestashop.core.hook.provider.grid_definition_hook_by_service_ids_provider: - class: PrestaShop\PrestaShop\Core\Hook\Provider\GridDefinitionHookByServiceIdsProvider - arguments: - - '@service_container' - - prestashop.core.hook.provider.identifiable_object_hook_by_form_type_provider: - class: PrestaShop\PrestaShop\Core\Hook\Provider\IdentifiableObjectHookByFormTypeProvider - arguments: - - '@form.factory' - - prestashop.core.hook.generator.hook_description_generator: - class: 'PrestaShop\PrestaShop\Core\Hook\Generator\HookDescriptionGenerator' - arguments: - - '%hook_descriptions%' - - '@prestashop.core.util.string.string_validator' - - '@prestashop.core.util.string.string_modifier' - -parameters: - hook_descriptions: - 'grid_definition_modifier': - 'prefix': 'action' - 'suffix': 'GridDefinitionModifier' - 'title': 'Modify %s grid definition' - 'description': 'This hook allows to alter %s grid columns, actions and filters' - 'grid_query_builder_modifier': - 'prefix': 'action' - 'suffix': 'GridQueryBuilderModifier' - 'title': 'Modify %s grid query builder' - 'description': 'This hook allows to alter Doctrine query builder for %s grid' - 'grid_data_modifier': - 'prefix': 'action' - 'suffix': 'GridDataModifier' - 'title': 'Modify %s grid data' - 'description': 'This hook allows to modify %s grid data' - 'grid_filter_form_modifier': - 'prefix': 'action' - 'suffix': 'GridFilterFormModifier' - 'title': 'Modify %s grid filters' - 'description': 'This hook allows to modify filters for %s grid' - 'grid_presenter_modifier': - 'prefix': 'action' - 'suffix': 'GridPresenterModifier' - 'title': 'Modify %s grid template data' - 'description': 'This hook allows to modify data which is about to be used in template for %s grid' - 'option_form': - 'prefix': 'action' - 'suffix': 'Form' - 'title': 'Modify %s options form content' - 'description': 'This hook allows to modify %s options form FormBuilder' - 'option_save': - 'prefix': 'action' - 'suffix': 'Save' - 'title': 'Modify %s options form saved data' - 'description': 'This hook allows to modify data of %s options form after it was saved' - 'form_builder_modifier': - 'prefix': 'action' - 'suffix': 'FormBuilderModifier' - 'title': 'Modify %s identifiable object form' - 'description': 'This hook allows to modify %s identifiable object forms content by modifying form builder data or FormBuilder itself' - 'action_before_update_form_handler': - 'prefix': 'actionBeforeUpdate' - 'suffix': 'FormHandler' - 'title': 'Modify %s identifiable object data before updating it' - 'description': 'This hook allows to modify %s identifiable object forms data before it was updated' - 'action_after_update_form_handler': - 'prefix': 'actionAfterUpdate' - 'suffix': 'FormHandler' - 'title': 'Modify %s identifiable object data after updating it' - 'description': 'This hook allows to modify %s identifiable object forms data after it was updated' - 'action_before_create_form_handler': - 'prefix': 'actionBeforeCreate' - 'suffix': 'FormHandler' - 'title': 'Modify %s identifiable object data before creating it' - 'description': 'This hook allows to modify %s identifiable object forms data before it was created' - 'action_after_create_form_handler': - 'prefix': 'actionAfterCreate' - 'suffix': 'FormHandler' - 'title': 'Modify %s identifiable object data after creating it' - 'description': 'This hook allows to modify %s identifiable object forms data after it was created' diff --git a/src/PrestaShopBundle/Resources/config/services/core/image.yml b/src/PrestaShopBundle/Resources/config/services/core/image.yml deleted file mode 100644 index 476a4c37..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/image.yml +++ /dev/null @@ -1,11 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.image.parser.image_tag_source_parser: - class: 'PrestaShop\PrestaShop\Core\Image\Parser\ImageTagSourceParser' - arguments: - - '@=service("prestashop.adapter.legacy.context").getRootUrl()' - - prestashop.core.image.file_deleter: - class: 'PrestaShop\PrestaShop\Core\Image\Deleter\ImageFileDeleter' diff --git a/src/PrestaShopBundle/Resources/config/services/core/import.yml b/src/PrestaShopBundle/Resources/config/services/core/import.yml deleted file mode 100644 index 1ec3fcf7..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/import.yml +++ /dev/null @@ -1,128 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.import.file_uploader: - class: 'PrestaShop\PrestaShop\Core\Import\File\FileUploader' - arguments: - - '@translator' - - '@prestashop.core.import.dir' - - prestashop.core.import.file_finder: - class: 'PrestaShop\PrestaShop\Core\Import\File\FileFinder' - arguments: - - '@prestashop.core.import.dir' - - prestashop.core.import.dir: - class: 'PrestaShop\PrestaShop\Core\Import\ImportDirectory' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.core.import.file_removal: - class: 'PrestaShop\PrestaShop\Core\Import\File\FileRemoval' - arguments: - - '@prestashop.core.import.dir' - - prestashop.core.import.sample.file_provider: - class: 'PrestaShop\PrestaShop\Core\Import\Sample\SampleFileProvider' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.core.import.csv_file_reader: - class: 'PrestaShop\PrestaShop\Core\Import\File\CsvFileReader' - arguments: - - '@prestashop.adapter.import.file_opener' - - '@=service("prestashop.core.import.normalizer.csv_value_separator").normalize(service("session").get("separator"))' - - prestashop.core.import.data_row.presenter: - class: 'PrestaShop\PrestaShop\Core\Import\File\DataRow\DataRowPresenter' - - prestashop.core.import.data_row.collection_presenter: - class: 'PrestaShop\PrestaShop\Core\Import\File\DataRow\DataRowCollectionPresenter' - arguments: - - '@prestashop.core.import.data_row.presenter' - - prestashop.core.import.factory.data_row.collection_factory: - class: 'PrestaShop\PrestaShop\Core\Import\File\DataRow\Factory\DataRowCollectionFactory' - arguments: - - '@prestashop.core.import.csv_file_reader' - - prestashop.core.import.fields_provider.product: - class: 'PrestaShop\PrestaShop\Core\Import\EntityField\Provider\ProductFieldsProvider' - arguments: - - '@translator' - - prestashop.core.import.fields_provider.category: - class: 'PrestaShop\PrestaShop\Core\Import\EntityField\Provider\CategoryFieldsProvider' - arguments: - - '@translator' - - prestashop.core.import.fields_provider.combination: - class: 'PrestaShop\PrestaShop\Core\Import\EntityField\Provider\CombinationFieldsProvider' - arguments: - - '@translator' - - prestashop.core.import.fields_provider.customer: - class: 'PrestaShop\PrestaShop\Core\Import\EntityField\Provider\CustomerFieldsProvider' - arguments: - - '@translator' - - prestashop.core.import.fields_provider.address: - class: 'PrestaShop\PrestaShop\Core\Import\EntityField\Provider\AddressFieldsProvider' - arguments: - - '@translator' - - prestashop.core.import.fields_provider.supplier: - class: 'PrestaShop\PrestaShop\Core\Import\EntityField\Provider\SupplierFieldsProvider' - arguments: - - '@translator' - - prestashop.core.import.fields_provider.alias: - class: 'PrestaShop\PrestaShop\Core\Import\EntityField\Provider\AliasFieldsProvider' - arguments: - - '@translator' - - prestashop.core.import.fields_provider.store_contact: - class: 'PrestaShop\PrestaShop\Core\Import\EntityField\Provider\StoreContactFieldsProvider' - arguments: - - '@translator' - - prestashop.core.import.normalizer.csv_value_separator: - class: 'PrestaShop\PrestaShop\Core\Import\CsvValueSeparatorNormalizer' - - prestashop.core.import.fields_provider_finder: - class: 'PrestaShop\PrestaShop\Core\Import\EntityField\Provider\EntityFieldsProviderFinder' - arguments: - - - 0: '@prestashop.core.import.fields_provider.category' - 1: '@prestashop.core.import.fields_provider.product' - 2: '@prestashop.core.import.fields_provider.combination' - 3: '@prestashop.core.import.fields_provider.customer' - 4: '@prestashop.core.import.fields_provider.address' - 5: '@prestashop.core.import.fields_provider.supplier' - 6: '@prestashop.core.import.fields_provider.supplier' - 7: '@prestashop.core.import.fields_provider.alias' - 8: '@prestashop.core.import.fields_provider.store_contact' - - prestashop.core.import.config_factory: - class: 'PrestaShop\PrestaShop\Core\Import\Configuration\ImportConfigFactory' - - prestashop.core.import.runtime_config_factory: - class: 'PrestaShop\PrestaShop\Core\Import\Configuration\ImportRuntimeConfigFactory' - - prestashop.core.import.request_validator: - class: 'PrestaShop\PrestaShop\Core\Import\Validator\ImportRequestValidator' - - prestashop.core.import.access_checker: - class: 'PrestaShop\PrestaShop\Core\Import\Access\ImportAccessChecker' - arguments: - - '@prestashop.adapter.data_provider.employee' - - prestashop.core.import.importer: - class: 'PrestaShop\PrestaShop\Core\Import\Importer' - arguments: - - '@prestashop.core.import.access_checker' - - '@prestashop.adapter.import.entity_deleter' - - '@prestashop.core.import.csv_file_reader' - - '@prestashop.core.import.dir' - - '@prestashop.core.configuration.ini_configuration' diff --git a/src/PrestaShopBundle/Resources/config/services/core/kpi.yml b/src/PrestaShopBundle/Resources/config/services/core/kpi.yml deleted file mode 100644 index dbe7aac3..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/kpi.yml +++ /dev/null @@ -1,59 +0,0 @@ -services: - _defaults: - public: true - - # KPI Row presenter - prestashop.core.kpi_row.presenter: - class: PrestaShop\PrestaShop\Core\Kpi\Row\KpiRowPresenter - - # KPI Row factories - prestashop.core.kpi_row.factory.translations_page: - class: PrestaShop\PrestaShop\Core\Kpi\Row\HookableKpiRowFactory - arguments: - - - - '@prestashop.adapter.kpi.enabled_languages' - - '@prestashop.adapter.kpi.main_country' - - '@prestashop.adapter.kpi.translations' - - '@prestashop.core.hook.dispatcher' - - 'translations' - - prestashop.core.kpi_row.factory.categories: - class: PrestaShop\PrestaShop\Core\Kpi\Row\HookableKpiRowFactory - arguments: - - - - '@prestashop.adapter.kpi.disabled_categories' - - '@prestashop.adapter.kpi.empty_categories' - - '@prestashop.adapter.kpi.top_category' - - '@prestashop.adapter.kpi.average_products_in_category' - - '@prestashop.core.hook.dispatcher' - - 'categories' - - prestashop.core.kpi_row.factory.customers: - class: PrestaShop\PrestaShop\Core\Kpi\Row\HookableKpiRowFactory - arguments: - - - - '@prestashop.adapter.kpi.most_common_customers_gender' - - '@prestashop.adapter.kpi.average_customer_age' - - '@prestashop.adapter.kpi.order_per_customer' - - '@prestashop.adapter.kpi.newsletter_registrations' - - '@prestashop.core.hook.dispatcher' - - 'customers' - - prestashop.core.kpi_row.factory.cart: - class: PrestaShop\PrestaShop\Core\Kpi\Row\HookableKpiRowFactory - arguments: - - - - '@prestashop.adapter.kpi.shopping_cart_total_kpi' - - '@prestashop.core.hook.dispatcher' - - 'cart' - - prestashop.core.kpi_row.factory.orders: - class: PrestaShop\PrestaShop\Core\Kpi\Row\HookableKpiRowFactory - arguments: - - - - '@prestashop.adapter.kpi.conversion_rate' - - '@prestashop.adapter.kpi.abandoned_cart' - - '@prestashop.adapter.kpi.average_order_value' - - '@prestashop.adapter.kpi.net_profit_per_visit' - - '@prestashop.core.hook.dispatcher' - - 'orders' diff --git a/src/PrestaShopBundle/Resources/config/services/core/language.yml b/src/PrestaShopBundle/Resources/config/services/core/language.yml deleted file mode 100644 index 7778ec27..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/language.yml +++ /dev/null @@ -1,15 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.language.pack.loader.remote: - class: 'PrestaShop\PrestaShop\Core\Language\Pack\Loader\RemoteLanguagePackLoader' - arguments: - - '@prestashop.core.foundation.version' - - prestashop.core.language.language_default_fonts_catalog: - class: 'PrestaShop\PrestaShop\Core\Language\LanguageDefaultFontsCatalog' - arguments: - - - 'fa': 'Tahoma' - 'ar': 'Tahoma' diff --git a/src/PrestaShopBundle/Resources/config/services/core/localization.yml b/src/PrestaShopBundle/Resources/config/services/core/localization.yml deleted file mode 100644 index 9e99714c..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/localization.yml +++ /dev/null @@ -1,31 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.localozation.pack.factory.localization_pack: - class: 'PrestaShop\PrestaShop\Core\Localization\Pack\Factory\LocalizationPackFactory' - - prestashop.core.localization.pack.import.importer: - class: 'PrestaShop\PrestaShop\Core\Localization\Pack\Import\LocalizationPackImporter' - arguments: - - '@prestashop.core.localization.pack.loader.remote' - - '@prestashop.core.localization.pack.loader.local' - - '@prestashop.core.localozation.pack.factory.localization_pack' - - '@translator' - - '@prestashop.adapter.legacy.configuration' - - prestashop.core.localization.pack.loader.local: - class: 'PrestaShop\PrestaShop\Core\Localization\Pack\Loader\LocalLocalizationPackLoader' - arguments: - - '@prestashop.adapter.legacy.configuration' - - prestashop.core.localization.pack.loader.remote: - class: 'PrestaShop\PrestaShop\Core\Localization\Pack\Loader\RemoteLocalizationPackLoader' - arguments: - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.core.foundation.version' - - prestashop.core.localization.rtl.processor_factory: - class: 'PrestaShop\PrestaShop\Core\Localization\RTL\StyleSheetProcessorFactory' - arguments: - - '@prestashop.adapter.legacy.configuration' diff --git a/src/PrestaShopBundle/Resources/config/services/core/mail_template.yml b/src/PrestaShopBundle/Resources/config/services/core/mail_template.yml deleted file mode 100644 index 8beffd2b..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/mail_template.yml +++ /dev/null @@ -1,50 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.mail_template.mail_template_renderer: '@prestashop.adapter.mail_template.twig_renderer' - prestashop.core.mail_template.theme_catalog: '@prestashop.core.mail_template.theme_folder_catalog' - - prestashop.core.mail_template.theme_folder_scanner: - class: 'PrestaShop\PrestaShop\Core\MailTemplate\FolderThemeScanner' - - prestashop.core.mail_template.theme_folder_catalog: - class: 'PrestaShop\PrestaShop\Core\MailTemplate\FolderThemeCatalog' - arguments: - - '%mail_themes_dir%' - - '@prestashop.core.mail_template.theme_folder_scanner' - - '@prestashop.core.hook.dispatcher' - - prestashop.core.mail_template.variables_builder: - class: 'PrestaShop\PrestaShop\Core\MailTemplate\Layout\LayoutVariablesBuilder' - arguments: - - '@prestashop.core.hook.dispatcher' - - '@prestashop.core.language.language_default_fonts_catalog' - - - mailThemesUrl: "@=service('prestashop.adapter.legacy.context').getMailThemesUrl()" - - prestashop.core.mail_template.generator: - class: 'PrestaShop\PrestaShop\Core\MailTemplate\MailTemplateGenerator' - arguments: - - '@prestashop.core.mail_template.mail_template_renderer' - - '@logger' - - prestashop.core.mail_template.transformation.css_inline: - class: 'PrestaShop\PrestaShop\Core\MailTemplate\Transformation\CSSInlineTransformation' - - prestashop.core.mail_template.transformation.html_textify: - class: 'PrestaShop\PrestaShop\Core\MailTemplate\Transformation\HTMLToTextTransformation' - - prestashop.core.mail_template.command_handler.generate_theme_mails_handler: - class: 'PrestaShop\PrestaShop\Core\Domain\MailTemplate\CommandHandler\GenerateThemeMailTemplatesCommandHandler' - arguments: - - '@prestashop.core.admin.lang.repository' - - '@prestashop.core.mail_template.theme_catalog' - - '@prestashop.core.mail_template.generator' - - '@translator' - - '%kernel.project_dir%/mails' - - "@=service('prestashop.adapter.legacy.configuration').get('_PS_MODULE_DIR_')" - public: true - tags: - - name: tactician.handler - command: PrestaShop\PrestaShop\Core\Domain\MailTemplate\Command\GenerateThemeMailTemplatesCommand diff --git a/src/PrestaShopBundle/Resources/config/services/core/module.yml b/src/PrestaShopBundle/Resources/config/services/core/module.yml deleted file mode 100644 index 5fa293b6..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/module.yml +++ /dev/null @@ -1,11 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.module.configuration.payment_restrictions_configurator: - class: PrestaShop\PrestaShop\Core\Module\Configuration\PaymentRestrictionsConfigurator - arguments: - - '@doctrine.dbal.default_connection' - - '%database_prefix%' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id' - - '@prestashop.adapter.module.payment_module_provider' diff --git a/src/PrestaShopBundle/Resources/config/services/core/search.yml b/src/PrestaShopBundle/Resources/config/services/core/search.yml deleted file mode 100644 index 372ea826..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/search.yml +++ /dev/null @@ -1,62 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.admin.search_parameters: - class: PrestaShop\PrestaShop\Core\Search\SearchParameters - arguments: ['@prestashop.core.admin.admin_filter.repository'] - - # Controller Argument Resolver - prestashop.search_parameters.resolver: - class: 'PrestaShopBundle\Controller\ArgumentResolver\SearchParametersResolver' - arguments: - - '@prestashop.core.admin.search_parameters' - - '@security.token_storage' - - '@prestashop.core.admin.admin_filter.repository' - - '@event_dispatcher' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id' -# tags: -# - { name: controller.argument_value_resolver, priority: 50 } - - # Filters builder argument resolver - prestashop.filters_builder.resolver: - class: 'PrestaShopBundle\Controller\ArgumentResolver\FiltersBuilderResolver' - arguments: - - '@prestashop.core.search.builder' - tags: - - { name: controller.argument_value_resolver, priority: 51 } - - prestashop.core.search.builder.class: - class: 'PrestaShop\PrestaShop\Core\Search\Builder\ClassFiltersBuilder' - - prestashop.core.search.builder.request: - class: 'PrestaShop\PrestaShop\Core\Search\Builder\RequestFiltersBuilder' - - prestashop.core.search.builder.repository: - class: 'PrestaShop\PrestaShop\Core\Search\Builder\RepositoryFiltersBuilder' - arguments: - - '@prestashop.core.admin.admin_filter.repository' - - '@prestashop.adapter.data_provider.employee' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id' - - prestashop.core.search.builder.event: - class: 'PrestaShop\PrestaShop\Core\Search\Builder\EventFiltersBuilder' - arguments: - - '@event_dispatcher' - - prestashop.core.search.builder.persist: - class: 'PrestaShop\PrestaShop\Core\Search\Builder\PersistFiltersBuilder' - arguments: - - '@prestashop.core.admin.admin_filter.repository' - - '@prestashop.adapter.data_provider.employee' - - '@=service("prestashop.adapter.legacy.context").getContext().shop.id' - - prestashop.core.search.builder: - class: 'PrestaShop\PrestaShop\Core\Search\Builder\ChainedFiltersBuilder' - arguments: - - - - '@prestashop.core.search.builder.class' - - '@prestashop.core.search.builder.repository' - - '@prestashop.core.search.builder.request' - - '@prestashop.core.search.builder.event' - - '@prestashop.core.search.builder.persist' diff --git a/src/PrestaShopBundle/Resources/config/services/core/security.yml b/src/PrestaShopBundle/Resources/config/services/core/security.yml deleted file mode 100644 index 0c570bee..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/security.yml +++ /dev/null @@ -1,11 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.crypto.hashing: - class: 'PrestaShop\PrestaShop\Core\Crypto\Hashing' - - prestashop.core.security.folder_guard.vendor: - class: 'PrestaShop\PrestaShop\Core\Security\HtaccessFolderGuard' - arguments: - - '%kernel.root_dir%/Resources/security/.htaccess.dist' diff --git a/src/PrestaShopBundle/Resources/config/services/core/shop.yml b/src/PrestaShopBundle/Resources/config/services/core/shop.yml deleted file mode 100644 index bfe292de..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/shop.yml +++ /dev/null @@ -1,8 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.shop.logo_uploader: - class: 'PrestaShop\PrestaShop\Core\Shop\LogoUploader' - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext().shop' diff --git a/src/PrestaShopBundle/Resources/config/services/core/sql_request.yml b/src/PrestaShopBundle/Resources/config/services/core/sql_request.yml deleted file mode 100644 index 53975a34..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/sql_request.yml +++ /dev/null @@ -1,14 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.sql_manager.exporter.sql_request_exporter: - class: 'PrestaShop\PrestaShop\Core\SqlManager\Exporter\SqlRequestExporter' - arguments: - - '@prestashop.core.export.file_writer.export_csv_file_writer' - - prestashop.core.sql_manager.configuration.sql_request_configuration: - class: 'PrestaShop\PrestaShop\Core\SqlManager\Configuration\SqlRequestConfiguration' - arguments: - - '@prestashop.core.command_bus' - - '@prestashop.core.query_bus' diff --git a/src/PrestaShopBundle/Resources/config/services/core/string.yml b/src/PrestaShopBundle/Resources/config/services/core/string.yml deleted file mode 100644 index 4abcc674..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/string.yml +++ /dev/null @@ -1,6 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.string.character_cleaner: - class: 'PrestaShop\PrestaShop\Core\String\CharacterCleaner' diff --git a/src/PrestaShopBundle/Resources/config/services/core/translation.yml b/src/PrestaShopBundle/Resources/config/services/core/translation.yml deleted file mode 100644 index ed149af9..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/translation.yml +++ /dev/null @@ -1,8 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.translation.locale.converter: - class: 'PrestaShop\PrestaShop\Core\Translation\Locale\Converter' - arguments: - - '%translations_dir%/../legacy-to-standard-locales.json' diff --git a/src/PrestaShopBundle/Resources/config/services/core/util.yml b/src/PrestaShopBundle/Resources/config/services/core/util.yml deleted file mode 100644 index 65bd4bac..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/util.yml +++ /dev/null @@ -1,23 +0,0 @@ -imports: - - { resource: 'util/*' } - -services: - _defaults: - public: true - - prestashop.core.util.url.url_file_checker: - class: 'PrestaShop\PrestaShop\Core\Util\Url\UrlFileChecker' - arguments: - - '@=service("prestashop.adapter.legacy.configuration").get("_PS_ROOT_DIR_")' - - prestashop.core.uti.back_url_provider: - class: PrestaShop\PrestaShop\Core\Util\Url\BackUrlProvider - - prestashop.core.util.color_brightness_calculator: - class: PrestaShop\PrestaShop\Core\Util\ColorBrightnessCalculator - - prestashop.core.util.arabic_to_latin_digit_converter: - class: PrestaShop\PrestaShop\Core\Util\ArabicToLatinDigitConverter - - prestashop.core.util.internationalized_domain_name_converter: - class: 'PrestaShop\PrestaShop\Core\Util\InternationalizedDomainNameConverter' diff --git a/src/PrestaShopBundle/Resources/config/services/core/util/file_size.yml b/src/PrestaShopBundle/Resources/config/services/core/util/file_size.yml deleted file mode 100644 index 7c9dcfb2..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/util/file_size.yml +++ /dev/null @@ -1,6 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.util.file_size.size_converter: - class: 'PrestaShop\PrestaShop\Core\Util\File\FileSizeConverter' diff --git a/src/PrestaShopBundle/Resources/config/services/core/util/helper_card.yml b/src/PrestaShopBundle/Resources/config/services/core/util/helper_card.yml deleted file mode 100644 index f3b94eb2..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/util/helper_card.yml +++ /dev/null @@ -1,73 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.util.helper_card.documentation_link_provider: - class: 'PrestaShop\PrestaShop\Core\Util\HelperCard\DocumentationLinkProvider' - arguments: - - '@=service("prestashop.adapter.legacy.context").getContext().language ? service("prestashop.adapter.legacy.context").getContext().language.iso_code : "en-US"' - - - 'team': - 'en': 'https://doc.prestashop.com/display/PS17/Team' - 'fr': 'http://doc.prestashop.com/pages/viewpage.action?pageId=51840334' - 'es': 'https://doc.prestashop.com/display/PS17/Equipo' - 'it': 'http://doc.prestashop.com/pages/viewpage.action?pageId=54266520' - '_fallback': 'https://doc.prestashop.com/display/PS17/Team' - 'meta': - 'fr': 'https://doc.prestashop.com/display/PS17/SEO+et+URL' - 'es': 'https://doc.prestashop.com/display/PS17/SEO+y+URLs' - 'it': 'https://doc.prestashop.com/display/PS17/SEO+e+URL' - '_fallback': 'https://doc.prestashop.com/display/PS17/SEO+and+URLs' - 'customer': - 'fr': 'https://doc.prestashop.com/display/PS17/Vos+clients' - 'es': 'https://doc.prestashop.com/display/PS17/Tus+clientes' - 'it': 'https://doc.prestashop.com/display/PS17/I+Tuoi+Clienti' - '_fallback': 'https://doc.prestashop.com/display/PS17/Your+customers' - 'supplier': - 'en': 'https://doc.prestashop.com/display/PS17/Managing+Suppliers' - 'fr': 'https://doc.prestashop.com/display/PS17/Gerer+les+fournisseurs' - 'es': 'https://doc.prestashop.com/display/PS17/Gestionar+Proveedores' - 'it': 'https://doc.prestashop.com/display/PS17/Gestire+Fornitori' - '_fallback': 'https://doc.prestashop.com/display/PS17/Managing+Suppliers' - 'category': - 'en': 'https://doc.prestashop.com/display/PS17/Managing+Categories' - 'fr': 'https://doc.prestashop.com/display/PS17/Gerer+les+categories' - 'es': 'https://doc.prestashop.com/display/PS17/Gestionar+las+categorias' - 'it': 'https://doc.prestashop.com/display/PS17/Gestire+Categorie' - '_fallback': 'https://doc.prestashop.com/display/PS17/Managing+Categories' - 'cms_pages': - 'en': 'https://doc.prestashop.com/display/PS17/Pages+-+Managing+Static+Content' - 'fr': 'https://doc.prestashop.com/display/PS17/Gerer+votre+contenu+statique+grace+aux+pages' - 'es': 'https://doc.prestashop.com/display/PS17/Paginas+-+Gestionar+el+Contenido+Estatico' - 'it': 'https://doc.prestashop.com/display/PS17/Pagine+-+Gestione+Contenuti+Statici' - '_fallback': 'https://doc.prestashop.com/display/PS17/Pages+-+Managing+Static+Content' - 'debug_mode': - 'en': 'https://doc.prestashop.com/display/PS17/Performance#Performance-Debugmode' - 'fr': 'http://doc.prestashop.com/pages/viewpage.action?pageId=51840325#Param%%C3%%A8tresdeperformances-Modedebug' - 'it': 'http://doc.prestashop.com/pages/viewpage.action?pageId=54266514' - 'es': 'https://doc.prestashop.com/display/PS17/Rendimiento#Rendimiento-ModoDepuraci%%C3%%B3n' - '_fallback': 'https://doc.prestashop.com/display/PS17/Performance#Performance-Debugmode' - 'attribute': - 'en': 'https://doc.prestashop.com/display/PS17/Managing+Product+Attributes' - 'fr': 'https://doc.prestashop.com/display/PS17/Gerer+les+attributs+de+vos+produits' - 'es': 'https://doc.prestashop.com/display/PS17/Gestionar+Atributos+del+Producto' - 'it': 'https://doc.prestashop.com/display/PS17/Gestire+gli+Attributi+dei+Prodotti' - '_fallback': 'https://doc.prestashop.com/display/PS17/Managing+Product+Attributes' - 'monitoring': - 'en': 'https://doc.prestashop.com/display/PS17/Monitoring+your+Catalog' - 'fr': 'https://doc.prestashop.com/display/PS17/Faire+le+suivi+de+votre+catalogue' - 'es': 'https://doc.prestashop.com/display/PS17/Monitorear+el+catalogo' - 'it': 'https://doc.prestashop.com/display/PS17/Monitorare+il+Catalogo' - '_fallback': 'https://doc.prestashop.com/display/PS17/Monitoring+your+Catalog' - 'attachment': - 'en': 'https://doc.prestashop.com/display/PS17/Managing+Files' - 'fr': 'https://doc.prestashop.com/display/PS17/Gerer+les+fichiers' - 'es': 'https://doc.prestashop.com/display/PS17/Gestionar+Archivos' - 'it': 'https://doc.prestashop.com/display/PS17/Gestire+i+Files' - '_fallback': 'https://doc.prestashop.com/display/PS17/Managing+Files' - 'credit_slip': - 'en': 'https://doc.prestashop.com/display/PS17/Credit+Slips' - 'fr': 'https://doc.prestashop.com/display/PS17/Avoirs' - 'es': 'https://doc.prestashop.com/display/PS17/Facturas+por+abono' - 'it': 'https://doc.prestashop.com/display/PS17/Note+di+credito' - '_fallback': 'https://doc.prestashop.com/display/PS17/Credit+Slips' diff --git a/src/PrestaShopBundle/Resources/config/services/core/util/string.yml b/src/PrestaShopBundle/Resources/config/services/core/util/string.yml deleted file mode 100644 index 3f0dbb00..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/util/string.yml +++ /dev/null @@ -1,9 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.util.string.string_validator: - class: 'PrestaShop\PrestaShop\Core\Util\String\StringValidator' - - prestashop.core.util.string.string_modifier: - class: 'PrestaShop\PrestaShop\Core\Util\String\StringModifier' diff --git a/src/PrestaShopBundle/Resources/config/services/core/validation.yml b/src/PrestaShopBundle/Resources/config/services/core/validation.yml deleted file mode 100644 index 5928dd1a..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/validation.yml +++ /dev/null @@ -1,8 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.validation.validator: - class: 'PrestaShop\PrestaShop\Core\Validation\Validator' - arguments: - - '@prestashop.adapter.validate' diff --git a/src/PrestaShopBundle/Resources/config/services/core/webservice.yml b/src/PrestaShopBundle/Resources/config/services/core/webservice.yml deleted file mode 100644 index b9b92976..00000000 --- a/src/PrestaShopBundle/Resources/config/services/core/webservice.yml +++ /dev/null @@ -1,11 +0,0 @@ -services: - _defaults: - public: true - - prestashop.core.webservice.server_requirements_checker: - class: 'PrestaShop\PrestaShop\Core\Webservice\ServerRequirementsChecker' - arguments: - - '@translator' - - '@prestashop.adapter.legacy.configuration' - - '@prestashop.adapter.hosting_information' - - '@prestashop.core.configuration.php_extension_checker' diff --git a/src/PrestaShopBundle/Resources/views/Admin/Category/categories.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Category/categories.html.twig deleted file mode 100644 index e3e3786d..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Category/categories.html.twig +++ /dev/null @@ -1,31 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    - -
    - -
    - {{ categories|json_encode }} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Bulk/button.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Bulk/button.html.twig deleted file mode 100644 index 27b40b51..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Bulk/button.html.twig +++ /dev/null @@ -1,34 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Bulk/delete_categories.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Bulk/delete_categories.html.twig deleted file mode 100644 index 24856621..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Bulk/delete_categories.html.twig +++ /dev/null @@ -1,32 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Bulk/delete_customers.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Bulk/delete_customers.html.twig deleted file mode 100644 index 6f745080..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Bulk/delete_customers.html.twig +++ /dev/null @@ -1,32 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Bulk/modal_form_submit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Bulk/modal_form_submit.html.twig deleted file mode 100644 index a4a9a9f6..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Bulk/modal_form_submit.html.twig +++ /dev/null @@ -1,33 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Bulk/submit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Bulk/submit.html.twig deleted file mode 100644 index cd8e22ec..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Bulk/submit.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Grid/link.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Grid/link.html.twig deleted file mode 100644 index 32d26367..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Grid/link.html.twig +++ /dev/null @@ -1,33 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - - - {% if action.icon is not empty %} - {{ action.icon }} - {% endif %} - {{ action.name }} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Grid/simple.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Grid/simple.html.twig deleted file mode 100644 index 81a903c6..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Grid/simple.html.twig +++ /dev/null @@ -1,34 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Grid/submit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Grid/submit.html.twig deleted file mode 100644 index 55ddbbf5..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Grid/submit.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Row/delete_category.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Row/delete_category.html.twig deleted file mode 100644 index deb8a772..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Row/delete_category.html.twig +++ /dev/null @@ -1,48 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set class = 'btn tooltip-link js-delete-category-row-action' %} - -{% if attributes.class is defined %} - {% set class = class ~ ' ' ~ attributes.class %} -{% endif %} - - - {% if action.icon is not empty %} - {{ action.icon }} - {% endif %} - {% if not attributes.tooltip_name %} - {{ action.name }} - {% endif %} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Row/delete_customer.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Row/delete_customer.html.twig deleted file mode 100644 index 3ef8045f..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Row/delete_customer.html.twig +++ /dev/null @@ -1,48 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set class = 'btn tooltip-link js-delete-customer-row-action' %} - -{% if attributes.class is defined %} - {% set class = class ~ ' ' ~ attributes.class %} -{% endif %} - - - {% if action.icon is not empty %} - {{ action.icon }} - {% endif %} - {% if not attributes.tooltip_name %} - {{ action.name }} - {% endif %} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Row/link.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Row/link.html.twig deleted file mode 100644 index a4b1a8b7..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Row/link.html.twig +++ /dev/null @@ -1,55 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set class = 'btn tooltip-link js-link-row-action' %} - -{% if attributes.class is defined %} - {% set class = class ~ ' ' ~ attributes.class %} -{% endif %} - - {% set route_params = { (action.options.route_param_name) : (record[action.options.route_param_field]) } %} - {% set extra_route_params = action.options.extra_route_params %} - - {% for name, field in extra_route_params %} - {% set route_params = route_params|merge({ (name) : (record[field] ?? field) }) %} - {% endfor %} - - - {% if action.icon is not empty %} - {{ action.icon }} - {% endif %} - {% if not attributes.tooltip_name %} - {{ action.name }} - {% endif %} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Row/submit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Row/submit.html.twig deleted file mode 100644 index e55f3608..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Actions/Row/submit.html.twig +++ /dev/null @@ -1,62 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set class = 'btn tooltip-link js-submit-row-action' %} - -{% if attributes.class is defined %} - {% set class = class ~ ' ' ~ attributes.class %} -{% endif %} - -{% set confirmation_message = action.options.confirm_message %} -{% if action.options.confirm_message_type == 'dynamic' and record[action.options.dynamic_message_field] is defined %} - {% set dynamic_field = record[action.options.dynamic_message_field] %} - {% set confirmation_message = dynamic_field|default(action.options.confirm_message) %} -{% endif %} - -{% set route_params = { (action.options.route_param_name) : (record[action.options.route_param_field]) } %} -{% set extra_route_params = action.options.extra_route_params %} - -{% for name, field in extra_route_params %} - {% set route_params = route_params|merge({ (name) : (record[field]) }) %} -{% endfor %} - - - {% if action.icon is not empty %} - {{ action.icon }} - {% endif %} - {% if not attributes.tooltip_name %} - {{ action.name }} - {% endif %} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/EmptyState/_default.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/EmptyState/_default.html.twig deleted file mode 100644 index 8269579b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/EmptyState/_default.html.twig +++ /dev/null @@ -1,29 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    warning

    -

    {{ 'No records found'|trans({}, 'Admin.Global') }}

    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/EmptyState/attachment.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/EmptyState/attachment.html.twig deleted file mode 100644 index 50bac490..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/EmptyState/attachment.html.twig +++ /dev/null @@ -1,39 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    - - -

    {{ 'Upload files here'|trans({}, 'Admin.Catalog.Feature') }}

    - -

    - {{ 'Make some files available to your customers and facilitate their purchasing environment by adding them just here! It can be instruction manuals, technical works or anything you want to attach to a product.'|trans({}, 'Admin.Catalog.Feature') }} -

    - - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/EmptyState/credit_slip.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/EmptyState/credit_slip.html.twig deleted file mode 100644 index 010e3e04..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/EmptyState/credit_slip.html.twig +++ /dev/null @@ -1,38 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    - - -

    {{ 'Manage your credit slips'|trans({}, 'Admin.Catalog.Feature') }}

    - -

    - {{ 'When a customer returns a product, a credit slip must be created in his favor. Generate vouchers and have a look at their follow-up.'|trans({}, 'Admin.Catalog.Feature') }} -

    - - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/EmptyState/order.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/EmptyState/order.html.twig deleted file mode 100644 index ba62f194..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/EmptyState/order.html.twig +++ /dev/null @@ -1,35 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    - - -

    {{ 'Manage your orders'|trans({}, 'Admin.Orderscustomers.Feature') }}

    - -

    - {{ 'Find all your orders on this page and access their main information in one click: check the cart total, the payment method, the shipping details, or if it comes from a new client. You can even update the status from the listing!'|trans({}, 'Admin.Orderscustomers.Feature') }} -

    - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/EmptyState/supplier.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/EmptyState/supplier.html.twig deleted file mode 100644 index 72420415..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/EmptyState/supplier.html.twig +++ /dev/null @@ -1,39 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    - - -

    {{ 'Keep in touch with your suppliers'|trans({}, 'Admin.Catalog.Feature') }}

    - -

    - {{ 'Having suppliers is optional if brands supply you directly. Make sure you don\'t confuse product suppliers and product brands to facilitate stock management.'|trans({}, 'Admin.Catalog.Feature') }} -

    - - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/Table/empty_row.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/Table/empty_row.html.twig deleted file mode 100644 index d8be980c..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/Table/empty_row.html.twig +++ /dev/null @@ -1,38 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - - - {% if grid.attributes.is_empty_state %} - {% include [ - '@PrestaShop/Admin/Common/Grid/Blocks/EmptyState/'~grid.id~'.html.twig', - '@PrestaShop/Admin/Common/Grid/Blocks/EmptyState/_default.html.twig' - ] with {'grid': grid} - %} - {% else %} - {% include '@PrestaShop/Admin/Common/Grid/Blocks/EmptyState/_default.html.twig' with {'grid': grid} %} - {% endif %} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/Table/filters_row.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/Table/filters_row.html.twig deleted file mode 100644 index 45bdec43..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/Table/filters_row.html.twig +++ /dev/null @@ -1,42 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - - {% for column in grid.columns %} - - {% if loop.first and grid.actions.bulk|length > 0 %} - {{ include('@PrestaShop/Admin/Common/Grid/Blocks/bulk_actions_select_all.html.twig', {'grid': grid}) }} - {% endif %} - - {% if grid.filter_form|length > 1 %} - {% if grid.column_filters[column.id] is defined %} - {% for filter_name in grid.column_filters[column.id] %} - {{ form_widget(grid.filter_form[filter_name]) }} - {% endfor %} - {% endif %} - {% endif %} - - {% endfor %} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/Table/headers_row.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/Table/headers_row.html.twig deleted file mode 100644 index a55777f4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/Table/headers_row.html.twig +++ /dev/null @@ -1,32 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - - {% for column in grid.columns %} - - {{ column_header(column, grid) }} - - {% endfor %} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/bulk_actions.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/bulk_actions.html.twig deleted file mode 100644 index b7252526..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/bulk_actions.html.twig +++ /dev/null @@ -1,42 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if grid.actions.bulk|length > 0 and grid.data.records_total > 0 %} -
    - - - -
    -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/bulk_actions_select_all.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/bulk_actions_select_all.html.twig deleted file mode 100644 index a8c43e17..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/bulk_actions_select_all.html.twig +++ /dev/null @@ -1,34 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/grid_actions.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/grid_actions.html.twig deleted file mode 100644 index 6505d0d8..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/grid_actions.html.twig +++ /dev/null @@ -1,71 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% if grid.actions.grid|length > 0 %} - {% set gridActionsButtonId = grid.id ~ '-grid-actions-button' %} - - -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/pagination.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/pagination.html.twig deleted file mode 100644 index 09601dbd..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/pagination.html.twig +++ /dev/null @@ -1,48 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block grid_pagination %} - {% if grid.data.records_total > 10 or grid.pagination.offset %} -
    -
    - {% set route_params = {} %} - - {% for param_name, param_value in app.request.attributes.get('_route_params') %} - {% set route_params = route_params|merge({ (param_name) : (param_value) }) %} - {% endfor %} - - {{ render(controller('PrestaShopBundle:Admin\\Common:pagination', { - 'limit': grid.pagination.limit, - 'offset': grid.pagination.offset, - 'total': grid.data.records_total, - 'prefix': grid.form_prefix, - 'caller_route': app.request.attributes.get('_route'), - 'caller_parameters': route_params - })) }} -
    -
    - {% endif %} -{% endblock %} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/table.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/table.html.twig deleted file mode 100644 index 18ac8f18..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Blocks/table.html.twig +++ /dev/null @@ -1,56 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{{ form_start(grid.filter_form, {'attr': {'id': grid.id ~ '_filter_form', 'class': 'table-responsive'}}) }} - - - {% block grid_table_head %} - {{ include('@PrestaShop/Admin/Common/Grid/Blocks/Table/headers_row.html.twig', {'grid': grid}) }} - {{ include('@PrestaShop/Admin/Common/Grid/Blocks/Table/filters_row.html.twig', {'grid': grid}) }} - {% endblock %} - - - {% block grid_table_body %} - {% if grid.data.records is not empty %} - {% for record in grid.data.records %} - - {% for column in grid.columns %} - - {% endfor %} - - {% endfor %} - {% else %} - {{ include('@PrestaShop/Admin/Common/Grid/Blocks/Table/empty_row.html.twig', {'grid': grid}) }} - {% endif %} - {% endblock %} - - {% block grid_table_footer %}{% endblock %} -
    - {{ column_content(record, column, grid) }} -
    -{{ form_end(grid.filter_form) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/action.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/action.html.twig deleted file mode 100644 index 4d4d31b5..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/action.html.twig +++ /dev/null @@ -1,107 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set actions = column.options.actions %} - -{% if actions is not empty %} - {% set inlineActions = [] %} - {% set regularActions = [] %} - - {% for action in actions %} - {% if action.options['use_inline_display'] == true %} - {% set inlineActions = inlineActions|merge([action]) %} - {% else %} - {% set regularActions = regularActions|merge([action]) %} - {% endif %} - {% endfor %} - -
    - {% if inlineActions is not empty %} -
    - {% for inlineAction in inlineActions -%} - {% if inlineAction.isApplicable(record) %} - - {% set class = 'dropdown-item inline-dropdown-item' %} - - {{ include('@PrestaShop/Admin/Common/Grid/Actions/Row/'~inlineAction.type~'.html.twig', { - 'grid': grid, - 'column': column, - 'attributes': {'class': class, 'tooltip_name': true}, - 'record': record, - 'action': inlineAction - }) }} - {% endif %} - {% endfor %} -
    - {% endif %} - - {% if regularActions is not empty %} -
    - {% set skippedActions, isFirstRendered = 0, false %} - - {# Render first item that is not in dropwdown #} - {% for action in regularActions %} - {% if not isFirstRendered %} - {% set skippedActions = skippedActions + 1 %} - {% endif %} - - {% if action.isApplicable(record) and not isFirstRendered %} - {{ include('@PrestaShop/Admin/Common/Grid/Actions/Row/'~action.type~'.html.twig', { - 'grid': grid, - 'column': column, - 'attributes': {'class': 'dropdown-item', 'tooltip_name': true}, - 'record': record, - 'action': action - }) }} - - {% set isFirstRendered = true %} - {% endif %} - {% endfor %} - - {# Render remaining items in dropdown #} - {% if regularActions|length > skippedActions %} - - - - {% endif %} -
    - {% endif %} -
    -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/attribute_color.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/attribute_color.html.twig deleted file mode 100644 index f7dc9a5f..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/attribute_color.html.twig +++ /dev/null @@ -1,26 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/badge.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/badge.html.twig deleted file mode 100644 index 68d9a24e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/badge.html.twig +++ /dev/null @@ -1,35 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -{% if record[column.options.field] is not empty %} - - {{ record[column.options.field] }} - -{% else %} - {{ column.options.empty_value }} -{% endif %} -
    - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/boolean.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/boolean.html.twig deleted file mode 100644 index 8b01b81d..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/boolean.html.twig +++ /dev/null @@ -1,30 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if record[column.options.field] %} - {{ column.options.true_name }} -{% else %} - {{ column.options.false_name }} -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/bulk_action.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/bulk_action.html.twig deleted file mode 100644 index 3b8f8bdb..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/bulk_action.html.twig +++ /dev/null @@ -1,36 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/category_position.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/category_position.html.twig deleted file mode 100644 index 5108b174..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/category_position.html.twig +++ /dev/null @@ -1,46 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    - {% if grid.sorting.order_by == 'position' and grid.sorting.order_way == 'asc' %} -
    - - {{ record[column.options.field] + 1 }} - -
    - {% else %} -
    - - {{ record[column.options.field] + 1 }} - -
    - {% endif %} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/choice.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/choice.html.twig deleted file mode 100644 index 9805631e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/choice.html.twig +++ /dev/null @@ -1,65 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set choices = column.options.choice_provider.getChoices(record) %} -{% set selectedChoice = record[column.options.field] %} -{% set selectedChoiceName = '' %} -{% set routeParams = record|array_pluck(column.options.record_route_params) %} - -{% for name,value in choices %} - {% if value == selectedChoice %} - {% set selectedChoiceName = name %} - {% endif %} -{% endfor %} - -{% set classes = 'btn btn-secondary dropdown-toggle dropdown-toggle-split rounded' %} - -{% if choices is not empty %} - -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/color.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/color.html.twig deleted file mode 100644 index 6d9f1ded..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/color.html.twig +++ /dev/null @@ -1,30 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set textColor = is_color_bright(record[column.options.color_field]) ? '#383838' : 'white' %} - - - {{ record[column.options.field] }} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/data.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/data.html.twig deleted file mode 100644 index 5b5a02f2..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/data.html.twig +++ /dev/null @@ -1,26 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{{ record[column.options.field]|raw }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/date_time.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/date_time.html.twig deleted file mode 100644 index 38b89bae..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/date_time.html.twig +++ /dev/null @@ -1,32 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set valueToDisplay = record[column.id]|date(column.options.format) %} - -{% if record[column.id] == constant('PrestaShop\\PrestaShop\\Core\\Util\\DateTime\\DateTime::NULL_VALUE') %} - {% set valueToDisplay = column.options.empty_data %} -{% endif %} - -{{ valueToDisplay }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/disableable_link.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/disableable_link.html.twig deleted file mode 100644 index 15b582c6..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/disableable_link.html.twig +++ /dev/null @@ -1,35 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends "@PrestaShop/Admin/Common/Grid/Columns/Content/link.html.twig" %} - - -{% block link %} - {% if record[column.options.disabled_field] %} - {{ 'Deleted customer'|trans({}, 'Admin.Global') }} - {% else %} - {{ parent() }} - {% endif %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/draggable.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/draggable.html.twig deleted file mode 100644 index b2da7af1..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/draggable.html.twig +++ /dev/null @@ -1,28 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - - drag_indicator - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/employee_name_with_avatar.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/employee_name_with_avatar.html.twig deleted file mode 100644 index 22020fea..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/employee_name_with_avatar.html.twig +++ /dev/null @@ -1,36 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if record.employee is not null %} - {% - set employeeName, employeeImage = record.employee, 'http://profile.prestashop.com/'~record.email|url_encode~'.jpg' - %} - - {{ employeeName }} - - {{ employeeName }} -{% else %} - {{ 'N/A'|trans({}, 'Admin.Global') }} -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/identifier.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/identifier.html.twig deleted file mode 100644 index 0f6f0c07..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/identifier.html.twig +++ /dev/null @@ -1,48 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if column.options.with_bulk_field %} -
    - -
    -{% endif %} - -{{ record[column.options.identifier_field] }} - -{% if column.options.preview is not null %} - {% include '@PrestaShop/Admin/Common/Grid/Columns/Content/preview.html.twig' with { - 'column': column.options.preview, - 'record': record, - } - %} -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/image.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/image.html.twig deleted file mode 100644 index 83ca6e5c..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/image.html.twig +++ /dev/null @@ -1,26 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/link.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/link.html.twig deleted file mode 100644 index 52c0983b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/link.html.twig +++ /dev/null @@ -1,51 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set color = column.options.color_template%} -{% set class = "text-" ~ color %} - -{% if column.options.button_template %} - {% set style = column.options.button_template %} - {% if style == 'normal' %} - {% set class = "btn btn-" ~ color %} - {% elseif style == 'outline' %} - {% set class = "btn btn-outline-" ~ color %} - {% endif %} -{% endif %} - -{% block link %} - - {% if column.options.icon is defined %} - {{ column.options.icon }} - {% endif %} - {{ record[column.options.field] }} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/link_group.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/link_group.html.twig deleted file mode 100644 index b93c3b64..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/link_group.html.twig +++ /dev/null @@ -1,34 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    - {% for link in column.options.links %} - {% if record[link.is_link_available_field] %} - - {{ link.icon }} - - {% endif %} - {% endfor %} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/order_price.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/order_price.html.twig deleted file mode 100644 index ebb5cebf..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/order_price.html.twig +++ /dev/null @@ -1,34 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    - {% if record[column.options.is_paid_field] %} - - {{ record[column.options.field] }} - - {% else %} - {{ record[column.options.field] }} - {% endif %} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/position.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/position.html.twig deleted file mode 100644 index 125d8fe0..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/position.html.twig +++ /dev/null @@ -1,28 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    - {{ record[column.options.position_field] + 1 }} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/position_handle.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/position_handle.html.twig deleted file mode 100644 index 3e03b31b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/position_handle.html.twig +++ /dev/null @@ -1,36 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set updateRouteParams = record|array_pluck(column.options.record_route_params) %} - -
    - drag_indicator -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/preview.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/preview.html.twig deleted file mode 100644 index 9a37f16e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/preview.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - - {{ column.options.icon_expand }} - {{ column.options.icon_collapse }} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/severity_level.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/severity_level.html.twig deleted file mode 100644 index 2602189b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/severity_level.html.twig +++ /dev/null @@ -1,51 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set severity = record.severity %} -{% set withMessage = column.options.with_message %} - -{% if severity == 1 %} - {% set severityClass = 'success' %} - {% set severityMessage = withMessage ? 'Informative only'|trans({}, 'Admin.Advparameters.Help') : '' %} -{% elseif severity == 2 %} - {% set severityClass = 'warning' %} - {% set severityMessage = withMessage ? 'Warning'|trans({}, 'Admin.Advparameters.Help') : '' %} -{% elseif severity == 3 %} - {% set severityClass = 'danger' %} - {% set severityMessage = withMessage ? 'Error'|trans({}, 'Admin.Advparameters.Help') : '' %} -{% elseif severity == 4 %} - {% set severityClass = 'dark' %} - {% set severityMessage = withMessage ? 'Major issue (crash)!'|trans({}, 'Admin.Advparameters.Help') : '' %} -{% else %} - {% set severityClass = '' %} -{% endif %} - - - {% if withMessage %} - {{ severityMessage }} ({{ severity }}) - {% else %} - {{ severity }} - {% endif %} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/toggle.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/toggle.html.twig deleted file mode 100644 index f50e12f1..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Content/toggle.html.twig +++ /dev/null @@ -1,42 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% set id_property_name = column.options.primary_field %} -{% set id_primary_key = record[id_property_name] %} -{% set record_id = record[id_property_name] %} - -{% set isValid = record[column.id] is same as('1') %} - -
    - - {% if isValid %} - check - {% else %} - clear - {% endif %} - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Header/Content/action.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Header/Content/action.html.twig deleted file mode 100644 index 712e79c5..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Header/Content/action.html.twig +++ /dev/null @@ -1,27 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    - {{ column.name }} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Header/Content/default.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Header/Content/default.html.twig deleted file mode 100644 index ce5f22bb..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Header/Content/default.html.twig +++ /dev/null @@ -1,34 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% set orderBy, orderWay = grid.sorting.order_by, grid.sorting.order_way %} - -{% if column.options.sortable is defined and column.options.sortable and grid.data.records_total > 0 %} - {{ ps.sortable_column_header(column.name, column.id, orderBy, orderWay, grid.form_prefix) }} -{% else %} - {{ column.name }} -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Header/Content/position_handle.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Header/Content/position_handle.html.twig deleted file mode 100644 index f4e4cf9d..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/Columns/Header/Content/position_handle.html.twig +++ /dev/null @@ -1,24 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/grid.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/grid.html.twig deleted file mode 100644 index 46aa0701..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/grid.html.twig +++ /dev/null @@ -1,60 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -
    - {% block grid_header_row %} -
    - {% block grid_bulk_actions_block %} -
    -
    -
    - {{ include('@PrestaShop/Admin/Common/Grid/Blocks/bulk_actions.html.twig', {'grid': grid}) }} -
    -
    -
    - {% endblock %} -
    - {% endblock %} - - {% block grid_table_row %} -
    -
    - {{ include('@PrestaShop/Admin/Common/Grid/Blocks/table.html.twig', {'grid': grid}) }} -
    -
    - {% endblock %} - - {% block grid_footer_row %} -
    -
    - {{ include('@PrestaShop/Admin/Common/Grid/Blocks/pagination.html.twig', {'grid': grid}) }} -
    -
    - {% endblock %} -
    -
    - -{% block grid_extra_content %}{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/grid_panel.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/grid_panel.html.twig deleted file mode 100644 index bc2cb0b3..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Grid/grid_panel.html.twig +++ /dev/null @@ -1,51 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    - {% block grid_panel_header %} -
    -

    - {{ grid.name }} ({{ grid.data.records_total }}) -

    - {% block grid_actions_block %} -
    - {{ include('@PrestaShop/Admin/Common/Grid/Blocks/grid_actions.html.twig', {'grid': grid}) }} -
    - {% endblock %} -
    - {% endblock %} - - {% block grid_panel_body %} -
    - {% block grid_view_block %} - {{ include('@PrestaShop/Admin/Common/Grid/grid.html.twig', {'grid': grid }) }} - {% endblock %} -
    - {% endblock %} - - {% block grid_panel_footer %}{% endblock %} -
    - -{% block grid_panel_extra_content %}{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/Kpi/kpi_row.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/Kpi/kpi_row.html.twig deleted file mode 100644 index 80da3211..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/Kpi/kpi_row.html.twig +++ /dev/null @@ -1,46 +0,0 @@ - {#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block kpi_row %} -
    -
    -
    - {% for kpi in kpiRow.kpis %} -
    - {{ kpi|raw }} -
    - {% endfor %} -
    -
    -
    - - {% if kpiRow.allowRefresh %} -
    - -
    - {% endif %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/_partials/_form_field.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/_partials/_form_field.html.twig deleted file mode 100644 index eb947425..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/_partials/_form_field.html.twig +++ /dev/null @@ -1,26 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{{ form_widget(form, {'id': formId }) }} -{{ form_errors(form) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/_partials/_sidebar.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/_partials/_sidebar.html.twig deleted file mode 100644 index 01c88c78..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/_partials/_sidebar.html.twig +++ /dev/null @@ -1,36 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    - -

    {{ title|raw|trans({}, 'AdminCommon') }}

    -
    -
    - -
    - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/pagination.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/pagination.html.twig deleted file mode 100644 index 8bc7ddd3..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/pagination.html.twig +++ /dev/null @@ -1,69 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/pagination_quicknav.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/pagination_quicknav.html.twig deleted file mode 100644 index decaa3f9..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/pagination_quicknav.html.twig +++ /dev/null @@ -1,46 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% if previous_url or next_url %} - -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Common/recommendedModules.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Common/recommendedModules.html.twig deleted file mode 100644 index c0381a41..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Common/recommendedModules.html.twig +++ /dev/null @@ -1,49 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/Blocks/backup_form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/Blocks/backup_form.html.twig deleted file mode 100644 index 1170a021..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/Blocks/backup_form.html.twig +++ /dev/null @@ -1,35 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block backup_creation_form %} -
    - - - -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/Blocks/backup_info.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/Blocks/backup_info.html.twig deleted file mode 100644 index 05457900..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/Blocks/backup_info.html.twig +++ /dev/null @@ -1,54 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block backup_info %} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/Blocks/backup_warning.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/Blocks/backup_warning.html.twig deleted file mode 100644 index 1459bc6e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/Blocks/backup_warning.html.twig +++ /dev/null @@ -1,44 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -{% block backup_warning %} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/Blocks/download_file.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/Blocks/download_file.html.twig deleted file mode 100644 index 52b9d013..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/Blocks/download_file.html.twig +++ /dev/null @@ -1,42 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -
    -

    - cloud_download - {{ 'Download'|trans({}, 'Admin.Actions') }} -

    -
    -

    - - cloud_download - {{ 'Download the backup file (%s MB)'|trans({'%s': downloadFile.size}) }} - -

    -

    {{ 'Tip: You can also download this file from your FTP server. Backup files are located in the "/adminXXXX/backups" directory.'|trans }}

    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/Blocks/options.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/Blocks/options.html.twig deleted file mode 100644 index cf762621..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/Blocks/options.html.twig +++ /dev/null @@ -1,73 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.Advparameters.Feature' %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block backup_options_card %} - {{ form_start(backupForm) }} -
    -

    - settings {{ 'Backup options'|trans({}, 'Admin.Advparameters.Feature') }} -

    -
    -
    -
    - -
    - {{ form_errors(backupForm.backup_options.backup_all) }} - {{ form_widget(backupForm.backup_options.backup_all) }} - - - {{ 'Drop existing tables during import.'|trans({}, 'Admin.Advparameters.Help') }}
    - {{ '%prefix%connections, %prefix%connections_page %prefix%connections_source, %prefix%guest, %prefix%statssearch'|replace({'%prefix%': dbPrefix}) }} -
    -
    -
    - -
    - {% set helpMessage = 'If enabled, the backup script will drop your tables prior to restoring data.'|trans({}, 'Admin.Advparameters.Help') %} - {% set helpMessage = helpMessage ~ ' ' ~ '(ie. "DROP TABLE IF EXISTS")'|trans({}, 'Admin.Advparameters.Help') %} - - {{ ps.label_with_help(('Drop existing tables during import'|trans), helpMessage) }} -
    - {{ form_errors(backupForm.backup_options.backup_drop_tables) }} - {{ form_widget(backupForm.backup_options.backup_drop_tables) }} -
    -
    - - {% block backup_options_rest %} - {{ form_rest(backupForm) }} - {% endblock %} -
    -
    - -
    - {{ form_end(backupForm) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/download_view.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/download_view.html.twig deleted file mode 100644 index d2ddb2a9..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/download_view.html.twig +++ /dev/null @@ -1,53 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -{% block content %} -
    -
    -
    -
    -

    - cloud_download - {{ 'Download'|trans({}, 'Admin.Actions') }} -

    -
    - -

    {{ 'Backup files should automatically start downloading.'|trans({}, 'Admin.Advparameters.Notification') }}

    -

    {{ 'If not,[1][2] please click here[/1]!'|trans({'[1]': ' ', '[/1]': ' ', '[2]': ''}, 'Admin.Advparameters.Notification')|raw }}

    - - -
    -
    -
    -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/index.html.twig deleted file mode 100644 index c18dbc39..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Backup/index.html.twig +++ /dev/null @@ -1,72 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -{% block content %} - {% block backup_download_file %} - {% if hasDownloadFile %} - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Backup/Blocks/download_file.html.twig' %} - {% endif %} - {% endblock %} - - {% block backup_alerts %} -
    -
    - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Backup/Blocks/backup_warning.html.twig' %} -
    -
    - -
    -
    - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Backup/Blocks/backup_info.html.twig' %} -
    -
    - {% endblock %} - - {% block backup_listing %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': backupGrid} %} -
    -
    - {% endblock %} - - {% block backup_options %} -
    -
    - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Backup/Blocks/options.html.twig' %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Blocks/import_available_fields.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Blocks/import_available_fields.html.twig deleted file mode 100644 index f170a138..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Blocks/import_available_fields.html.twig +++ /dev/null @@ -1,44 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -
    -

    - list {{ 'Available fields'|trans }} -

    -
    -
    - - - -

    {{ '* Required field'|trans({}, 'Admin.Advparameters.Feature') }}

    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Blocks/import_file_history.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Blocks/import_file_history.html.twig deleted file mode 100644 index 3acad9f3..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Blocks/import_file_history.html.twig +++ /dev/null @@ -1,106 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -
    -
    - {{ 'History of uploaded files'|trans({}, 'Admin.Advparameters.Feature') }} - {{ importFileNames|length }} - - - -
    -
    - - - - - - - {% for fileName in importFileNames %} - - - - - {% endfor %} - -
    -
    - - - -
    -
    {{ fileName }} -
    - - - -
    -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Blocks/import_panel.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Blocks/import_panel.html.twig deleted file mode 100644 index 75e3b13a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Blocks/import_panel.html.twig +++ /dev/null @@ -1,182 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -{{ form_start(importForm, {'attr': { 'data-file-upload-url': importFileUploadUrl, 'data-delete-confirm-message': ('Are you sure you want to delete this entity:'|trans({}, 'Admin.Advparameters.Notification')), 'class': 'js-import-form' }}) }} -
    -

    - import_export {{ 'Import'|trans({}, 'Admin.Actions') }} -

    -
    - - -
    - -
    - - {{ form_errors(importForm.entity) }} - {{ form_widget(importForm.entity, {'attr': {'class': 'js-entity-select'}}) }} -
    - - - -
    - -
    - {{ form_errors(importForm.csv) }} - {{ form_widget(importForm.csv, {'attr': {'class': 'js-import-file-input'}}) }} -
    - -
    - -
    -
    - {{ form_errors(importForm.file) }} - {{ form_widget(importForm.file, {'attr': {'class': 'js-import-file', 'data-max-file-upload-size': maxFileUploadSize }}) }} -
    -
    - {{ 'or'|trans({}, 'Admin.Global') }} - -
    -
    - {{ 'Allowed formats: .csv, .xls, .xlsx, .xlst, .ods, .ots'|trans({}, 'Admin.Advparameters.Help') }} - {{ 'Only UTF-8 and ISO 8859-1 encodings are allowed'|trans({}, 'Admin.Advparameters.Help') }} - {{ 'You can also upload your file via FTP to the following directory: %s .'|trans({'%s': importDirectory}, 'Admin.Advparameters.Help') }} -
    - - - - - - {% block import_file_history_block %} - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Blocks/import_file_history.html.twig' %} - {% endblock %} - -
    - -
    - {{ ps.label_with_help(('Language of the file'|trans), ('The locale must be installed'|trans({}, 'Admin.Advparameters.Notification'))) }} - {{ form_errors(importForm.iso_lang) }} - {{ form_widget(importForm.iso_lang) }} -
    - -
    - - {{ form_errors(importForm.separator) }} - {{ form_widget(importForm.separator) }} - {{ 'e.g. '|trans({}, 'Admin.Advparameters.Help') }} 1; Blouse; 129.90; 5 -
    - -
    - - {{ form_errors(importForm.multiple_value_separator) }} - {{ form_widget(importForm.multiple_value_separator) }} - {{ 'e.g. '|trans({}, 'Admin.Advparameters.Help') }} Blouse; red.jpg, blue.jpg, green.jpg; 129.90 -
    - -
    - -
    - - {{ form_errors(importForm.truncate) }} - {{ form_widget(importForm.truncate) }} -
    - -
    - {{ ps.label_with_help(('Use product reference as key'|trans), ('If enabled, the product\'s reference number MUST be unique!'|trans({}, 'Admin.Advparameters.Help'))) }} - {{ form_errors(importForm.match_ref) }} - {{ form_widget(importForm.match_ref) }} -
    - -
    - - {{ form_errors(importForm.regenerate) }} - {{ form_widget(importForm.regenerate) }} -
    - -
    - {{ ps.label_with_help(('Force all ID numbers'|trans), ("If you enable this option, your imported items' ID number will be used as is. If you do not enable this option, the imported ID numbers will be ignored, and PrestaShop will instead create auto-incremented ID numbers for all the imported items."|trans({}, 'Admin.Advparameters.Help'))) }} - {{ form_errors(importForm.forceIDs) }} - {{ form_widget(importForm.forceIDs) }} -
    - -
    - {{ ps.label_with_help(('Send notification email'|trans), ('Sends an email to let you know your import is complete. It can be useful when handling large files, as the import may take some time.'|trans({}, 'Admin.Advparameters.Help'))) }} - {{ form_errors(importForm.sendemail) }} - {{ form_widget(importForm.sendemail) }} -
    - - {{ form_rest(importForm) }} -
    - -
    -{{ form_end(importForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Blocks/import_sample_files.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Blocks/import_sample_files.html.twig deleted file mode 100644 index 07aea531..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Blocks/import_sample_files.html.twig +++ /dev/null @@ -1,47 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.Advparameters.Feature' %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -
    -

    - file_download {{ 'Download sample csv files'|trans({}, 'Admin.Advparameters.Feature') }} -

    - -
    -
    - {{ ps.import_file_sample('Sample Categories file', 'categories_import') }} - {{ ps.import_file_sample('Sample Products file', 'products_import') }} - {{ ps.import_file_sample('Sample Combinations file', 'combinations_import') }} - {{ ps.import_file_sample('Sample Customers file', 'customers_import') }} - {{ ps.import_file_sample('Sample Addresses file', 'addresses_import') }} - {{ ps.import_file_sample('Sample Brands file', 'manufacturers_import') }} - {{ ps.import_file_sample('Sample Suppliers file', 'suppliers_import') }} - {{ ps.import_file_sample('Sample Aliases file', 'alias_import') }} - {{ ps.import_file_sample('Sample Store Contacts file', 'store_contacts') }} -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email/Blocks/email_configuration.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email/Blocks/email_configuration.html.twig deleted file mode 100644 index 282b5f9e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email/Blocks/email_configuration.html.twig +++ /dev/null @@ -1,82 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -{% block email_configuration %} -
    -
    -

    - mail {{ 'Email'|trans({}, 'Admin.Global') }} -

    -
    -
    -
    - -
    - {{ form_errors(emailConfigurationForm.email_config.send_emails_to) }} - {{ form_widget(emailConfigurationForm.email_config.send_emails_to) }} - - {{ 'Where customers send messages from the order page.'|trans({}, 'Admin.Advparameters.Help') }} - -
    -
    - -
    - -
    - {{ form_errors(emailConfigurationForm.email_config.mail_method) }} - {{ form_widget(emailConfigurationForm.email_config.mail_method) }} -
    -
    - -
    - -
    - {{ form_errors(emailConfigurationForm.email_config.mail_type) }} - {{ form_widget(emailConfigurationForm.email_config.mail_type) }} -
    -
    - -
    - -
    - {{ form_errors(emailConfigurationForm.email_config.log_emails) }} - {{ form_widget(emailConfigurationForm.email_config.log_emails) }} -
    -
    - - {% block email_configuration_form_rest %} - {{ form_rest(emailConfigurationForm.email_config) }} - {% endblock %} -
    -
    - -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email/Blocks/email_logs_grid.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email/Blocks/email_logs_grid.html.twig deleted file mode 100644 index ebb4174b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email/Blocks/email_logs_grid.html.twig +++ /dev/null @@ -1,37 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% embed '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with { 'grid': emailLogsGrid } %} - {% trans_default_domain 'Admin.Advparameters.Feature' %} - - {% block grid_footer %} - - {% endblock %} -{% endembed %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email/Blocks/smtp_configuration.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email/Blocks/smtp_configuration.html.twig deleted file mode 100644 index 8546161a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email/Blocks/smtp_configuration.html.twig +++ /dev/null @@ -1,101 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% trans_default_domain 'Admin.Advparameters.Feature' %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block smtp_configuration %} -
    -
    -

    - settings {{ 'Email'|trans({}, 'Admin.Global') }} -

    -
    -
    -
    - {{ ps.label_with_help(('Mail domain name'|trans), ('Fully qualified domain name (keep this field empty if you don\'t know).'|trans({}, 'Admin.Advparameters.Help'))) }} -
    - {{ form_errors(emailConfigurationForm.smtp_config.domain) }} - {{ form_widget(emailConfigurationForm.smtp_config.domain) }} -
    -
    - -
    - {{ ps.label_with_help(('SMTP server'|trans), ('IP address or server name (e.g. smtp.mydomain.com).'|trans({}, 'Admin.Advparameters.Help'))) }} -
    - {{ form_errors(emailConfigurationForm.smtp_config.server) }} - {{ form_widget(emailConfigurationForm.smtp_config.server) }} -
    -
    - -
    - {{ ps.label_with_help(('SMTP username'|trans), ('Leave blank if not applicable.'|trans({}, 'Admin.Advparameters.Help'))) }} -
    - {{ form_errors(emailConfigurationForm.smtp_config.username) }} - {{ form_widget(emailConfigurationForm.smtp_config.username) }} -
    -
    - -
    - {{ ps.label_with_help(('SMTP password'|trans), ('Leave blank if not applicable.'|trans({}, 'Admin.Advparameters.Help'))) }} -
    - {{ form_errors(emailConfigurationForm.smtp_config.password) }} - {{ form_widget(emailConfigurationForm.smtp_config.password) }} -
    -
    - -
    - -
    - {{ form_errors(emailConfigurationForm.smtp_config.encryption) }} - {{ form_widget(emailConfigurationForm.smtp_config.encryption) }} - {% if not isOpenSslExtensionLoaded %} - - {{ 'SSL does not seem to be available on your server.'|trans({}, 'Admin.Advparameters.Notification') }} - - {% endif %} -
    -
    - -
    - {{ ps.label_with_help(('Port'|trans), ('Port number to use.'|trans)) }} -
    - {{ form_errors(emailConfigurationForm.smtp_config.port) }} - {{ form_widget(emailConfigurationForm.smtp_config.port) }} -
    -
    - - {% block smtp_configuration_form_rest %} - {{ form_rest(emailConfigurationForm.smtp_config) }} - {% endblock %} -
    -
    - -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email/Blocks/test_email_sending.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email/Blocks/test_email_sending.html.twig deleted file mode 100644 index 6c22064e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email/Blocks/test_email_sending.html.twig +++ /dev/null @@ -1,69 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -{% block test_email_sending %} - {{ form_start(testEmailSendingForm, {'action': path('admin_emails_send_test')}) }} -
    -
    -
    -

    - settings {{ 'Test your email configuration'|trans }} -

    -
    -
    -
    - -
    - {{ form_widget(testEmailSendingForm.send_email_to) }} -
    -
    - -
    -
    - - -
    -
    -
    -
    - -
    -
    -
    - {{ form_end(testEmailSendingForm) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email/index.html.twig deleted file mode 100644 index 6009d9fd..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Email/index.html.twig +++ /dev/null @@ -1,56 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -{% block content %} - {% if isEmailLogsEnabled %} -
    -
    - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Email/Blocks/email_logs_grid.html.twig' %} -
    -
    - {% endif %} - - {{ form_start(emailConfigurationForm, {'action': path('admin_emails_save_options')}) }} -
    - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Email/Blocks/email_configuration.html.twig' %} - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Email/Blocks/smtp_configuration.html.twig' %} - - {% block email_configuration_form_rest %} - {{ form_rest(emailConfigurationForm) }} - {% endblock %} -
    - {{ form_end(emailConfigurationForm) }} - - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Email/Blocks/test_email_sending.html.twig' %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/Blocks/employee_options.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/Blocks/employee_options.html.twig deleted file mode 100644 index 096de0cd..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/Blocks/employee_options.html.twig +++ /dev/null @@ -1,95 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block employee_options_form %} - {{ form_start(employeeOptionsForm, {'action': path('admin_employees_save_options') }) }} -
    -

    - settings - {{ 'Employee options'|trans({}, 'Admin.Advparameters.Feature') }} -

    -
    -
    -
    - - -
    - {{ form_errors(employeeOptionsForm.options.password_change_time) }} - {{ form_widget(employeeOptionsForm.options.password_change_time) }} - - {{ 'Security: Minimum time to wait between two password changes.'|trans({}, 'Admin.Advparameters.Feature') }} - - - {% if not canOptionsBeChanged %} - - {% endif %} -
    -
    - -
    - - -
    - {{ form_errors(employeeOptionsForm.options.allow_employee_specific_language) }} - {{ form_widget(employeeOptionsForm.options.allow_employee_specific_language) }} - - {{ 'Allow employees to select a specific language for the Admin panel form.'|trans({}, 'Admin.Advparameters.Feature') }} - - - {% if not canOptionsBeChanged %} - - {% endif %} -
    -
    - - {% block employee_options_form_rest %} - {{ form_rest(employeeOptionsForm) }} - {% endblock %} -
    -
    - -
    - {{ form_end(employeeOptionsForm) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/Blocks/form.html.twig deleted file mode 100644 index f43d1919..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/Blocks/form.html.twig +++ /dev/null @@ -1,251 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -{% block employee_addons_connect %} - {% include '@PrestaShop/Admin/Module/Includes/modal_addons_connect.html.twig' with { 'level' : level, 'errorMessage' : errorMessage } %} -{% endblock %} - -{% block employee_form %} - {{ form_start(employeeForm) }} -
    -

    - {{ 'Employees'|trans }} -

    -
    -
    - {{ form_errors(employeeForm) }} - - {{ ps.form_group_row(employeeForm.firstname, {}, { - 'label': 'First name'|trans({}, 'Admin.Global') - }) }} - - {{ ps.form_group_row(employeeForm.lastname, {}, { - 'label': 'Last name'|trans({}, 'Admin.Global') - }) }} - -
    - -
    - - - -
    -
    - -
    - -
    - -
    -
    - - {{ ps.form_group_row(employeeForm.email, {}, { - 'label': 'Email address'|trans({}, 'Admin.Global') - }) }} - - {% set passwordHelpMessage = 'Password should be at least %num% characters long.'|trans({ '%num%': 8 }, 'Admin.Advparameters.Help') %} - - {% if isRestrictedAccess %} - {% set oldPasswordVars = employeeForm.change_password.old_password.vars|merge(old_password|default({})) %} - {% set newPasswordFirstVars = employeeForm.change_password.new_password.children.first.vars|merge(new_password.first_options|default({})) %} - {% set newPasswordSecondVars = employeeForm.change_password.new_password.children.second.vars|merge(new_password.second_options|default({})) %} - -
    - -
    - {# "Change password" button #} - {{ form_widget(employeeForm.change_password.change_password_button, { - label: 'Change password...'|trans({}, 'messages'), - attr: { - class: 'btn-outline-secondary js-change-password', - } - }) }} - -
    - {# Current password input #} - {{ ps.form_group_row(employeeForm.change_password.old_password, oldPasswordVars, { - label: 'Current password'|trans({}, 'messages'), - required: true, - }) }} - - {# New password first input #} -
    - {{ ps.label_with_help('New password'|trans({}, 'messages'), passwordHelpMessage, '', employeeForm.change_password.new_password.children.first.vars.id, true) }} -
    - {{ ps.form_widget_with_error(employeeForm.change_password.new_password.children.first, employeeForm.change_password.new_password.children.first.vars) }} -
    -
    - - {# New password second input (confirmation) #} - {# Empty help text needed to render the text container for validation feedback messages #} - {{ ps.form_group_row(employeeForm.change_password.new_password.children.second, newPasswordSecondVars, { - label: 'Confirm password'|trans({}, 'messages'), - help: '', - required: true, - }) }} - -
    - -
    - {{ form_widget(employeeForm.change_password.generated_password) }} -
    -
    - {{ form_widget(employeeForm.change_password.generate_password_button, { - label: 'Generate password'|trans({}, 'messages'), - attr: { - class: 'btn-outline-secondary', - } - }) }} -
    -
    - - {{ ps.form_group_row(employeeForm.change_password.cancel_button, { - label: 'Cancel'|trans({}, 'Admin.Actions'), - attr: { - class: 'btn-outline-secondary js-change-password-cancel', - } - }) }} - - {# Password strength feedback messages - used in JS #} -
    - {{ 'Invalid'|trans({}, 'messages') }} - {{ 'Okay'|trans({}, 'messages') }} - {{ 'Good'|trans({}, 'messages') }} - {{ 'Fabulous'|trans({}, 'messages') }} -
    -
    -
    -
    - {% else %} - {{ ps.form_group_row(employeeForm.password, {}, { - 'label': 'Password'|trans({}, 'Admin.Global'), - 'help': passwordHelpMessage, - }) }} - {% endif %} - - {% if isRestrictedAccess and showAddonsConnectButton %} -
    - -
    - {% if employeeForm.prestashop_addons.vars.is_addons_connected %} -

    - account_circle - {{ 'You are currently connected as %username%' - |trans({}, 'Admin.Advparameters.Feature') - |replace({ '%username%': employeeForm.prestashop_addons.vars.addons_username }) - }} -

    - {% endif %} - -
    - {% if employeeForm.prestashop_addons.vars.is_addons_connected %} - {% set label, target = - 'Sign out from PrestaShop Addons'|trans({}, 'Admin.Advparameters.Feature'), - '#module-modal-addons-logout' - %} - {% else %} - {% set label, target = - 'Sign in'|trans({}, 'Admin.Advparameters.Feature'), - '#module-modal-addons-connect' - %} - {% endif %} - - {{ form_widget(employeeForm.prestashop_addons, { - attr: { - 'class': 'btn-outline-secondary', - 'data-toggle': 'modal', - 'data-target': target, - }, - label: label, - }) }} -
    -
    -
    - {% endif %} - - {{ ps.form_group_row(employeeForm.default_page, {'attr': {'data-minimumResultsForSearch': '7', 'data-toggle': 'select2'}}, { - 'label': 'Default page'|trans, - 'help': 'This page will be displayed just after login.'|trans({}, 'Admin.Advparameters.Help') - }) }} - - {{ ps.form_group_row(employeeForm.language, {}, { - 'label': 'Language'|trans({}, 'Admin.Global') - }) }} - - {% if not isRestrictedAccess %} - {{ ps.form_group_row(employeeForm.active, {}, { - 'label': 'Active'|trans({}, 'Admin.Global'), - 'help': 'Allow or disallow this employee to log in to the Admin panel.'|trans({}, 'Admin.Advparameters.Help') - }) }} - - {{ ps.form_group_row(employeeForm.profile, { - 'attr': { - 'data-admin-profile': superAdminProfileId, - 'data-get-tabs-url': getTabsUrl, - } - }, { - 'label': 'Permission profile'|trans({}, 'Admin.Advparameters.Feature') - }) }} - - {% if employeeForm.shop_association is defined %} - {{ ps.form_group_row(employeeForm.shop_association, {}, { - 'label': 'Shop association'|trans({}, 'Admin.Global'), - 'help': 'Select the shops the employee is allowed to access.'|trans({}, 'Admin.Advparameters.Help') - }) }} - {% endif %} - {% endif %} - - {% block employee_form_rest %} - {{ form_rest(employeeForm) }} - {% endblock %} -
    -
    - -
    - {{ form_end(employeeForm) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/Blocks/showcase_card.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/Blocks/showcase_card.html.twig deleted file mode 100644 index 4482b762..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/Blocks/showcase_card.html.twig +++ /dev/null @@ -1,45 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if not isShowcaseCardClosed %} -
    -
    - -
    -
    -

    {{ 'Manage your team'|trans({}, 'Admin.Advparameters.Feature') }}

    -

    {{ 'Create profiles for your employees with specific rights. SuperAdmin can access the entire store while other people can only be dedicated to the catalog or orders pages.'|trans({}, 'Admin.Advparameters.Feature') }}

    - - {{ 'Learn more'|trans({}, 'Admin.Actions') }} - -
    - - close - -
    -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/create.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/create.html.twig deleted file mode 100644 index 446fc42f..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/create.html.twig +++ /dev/null @@ -1,53 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% set layoutTitle = 'Add new'|trans({}, 'Admin.Actions') %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Employee/Blocks/form.html.twig' with { - employeeForm: employeeForm, - level: level, - errorMessage: errorMessage, - isRestrictedAccess: false, - superAdminProfileId: superAdminProfileId, - getTabsUrl: getTabsUrl, - avatarUrl: employeeForm.vars.defaultAvatarUrl - } %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - {# Password generation plugin #} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/edit.html.twig deleted file mode 100644 index 4358c1b4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/edit.html.twig +++ /dev/null @@ -1,66 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% set enableSidebar = true %} -{% set layoutTitle = 'Edit: %lastname% %firstname%'|trans({ - '%firstname%': editableEmployee.firstName.value, - '%lastname%': editableEmployee.lastName.value -}, 'Admin.Advparameters.Feature') %} - -{% block content %} - {% if employeeForm.vars.errors is not empty %} -
    - {% for error in employeeForm.vars.errors %} -
    {{ error.message }}
    - {% endfor %} -
    - {% endif %} - -
    -
    - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Employee/Blocks/form.html.twig' with { - employeeForm: employeeForm, - level: level, - errorMessage: errorMessage, - isRestrictedAccess: isRestrictedAccess, - superAdminProfileId: superAdminProfileId, - showAddonsConnectButton: showAddonsConnectButton, - getTabsUrl: getTabsUrl, - avatarUrl: editableEmployee.avatarUrl - } %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - {# Password generation plugin #} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/index.html.twig deleted file mode 100644 index 69abda6e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Employee/index.html.twig +++ /dev/null @@ -1,64 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set enableSidebar = true %} -{% set layoutHeaderToolbarBtn = { - 'add': { - 'href': path('admin_employees_create'), - 'desc': 'Add new employee'|trans({}, 'Admin.Advparameters.Feature'), - 'icon': 'add_circle_outline' - } -} %} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} - {% block employee_showcase_card %} -
    -
    - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Employee/Blocks/showcase_card.html.twig' %} -
    -
    - {% endblock %} - - {% block employee_listing %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with { 'grid': employeeGrid } %} -
    -
    - {% endblock %} - - {% block employee_options %} - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Employee/Blocks/employee_options.html.twig' %} - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/ImportDataConfiguration/Blocks/import_data_configuration.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/ImportDataConfiguration/Blocks/import_data_configuration.html.twig deleted file mode 100644 index 22762d14..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/ImportDataConfiguration/Blocks/import_data_configuration.html.twig +++ /dev/null @@ -1,174 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -{{ form_start(importDataConfigurationForm, {attr: {class: 'import-data-configuration-form'}}) }} -
    -

    - list {{ 'Match your data'|trans }} -

    -
    -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - {{ form_widget(importDataConfigurationForm.matches) }} -
    -
    - - -
    -
    -
    -
    -
    - -
    -
    -
    - {{ form_widget(importDataConfigurationForm.match_name, {'attr': {'class': 'js-import-match-input', 'type': 'button'}}) }} -
    -
    - -
    -
    -
    -
    -
    - -
    - {{ form_widget(importDataConfigurationForm.skip, {'attr': {'class': 'col-xs-12 col-md-4 js-rows-skip', 'min': 0}}) }} - {{ 'Indicate how many of the first rows of your file should be skipped when importing the data. For instance set it to 1 if the first row of your file contains headers.'|trans }} -
    -
    -
    -
    - - -
    -
    -
    - - - - {% for importEntityField in importDataConfigurationForm.type_value %} - - {% endfor %} - - - - {% for row in dataRowCollection.rows %} - - {% for cell in row %} - maxVisibleColumns %} class="d-none"{% endif %}>{{ cell.value }} - {% endfor %} - - {% endfor %} - -
    - {{ form_errors(importEntityField) }} - {{ form_widget(importEntityField) }} -
    -
    -
    -
    - -
    -
    - -
    -
    - {{ form_rest(importDataConfigurationForm) }} -
    -
    - -
    -{{ form_end(importDataConfigurationForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/ImportDataConfiguration/Blocks/import_modal.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/ImportDataConfiguration/Blocks/import_modal.html.twig deleted file mode 100644 index e1e97f14..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/ImportDataConfiguration/Blocks/import_modal.html.twig +++ /dev/null @@ -1,87 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.Advparameters.Notification' %} - -{% embed 'PrestaShopBundle:Admin/Helpers:bootstrap_popup.html.twig' with { - 'id': 'import_progress_modal', - 'title': 'Importing your data...'|trans, - 'closable': false, - 'progressbar': { - id: 'import_progress_bar', - label: 'Validating data...'|trans - }, - 'actions': [ - { - 'type': 'button', - 'label': 'Ignore warnings and continue?'|trans, - 'class': 'btn btn-outline-warning btn-lg js-continue-import', - }, - { - 'type': 'button', - 'label': 'Abort import'|trans, - 'class': 'btn btn-outline-danger btn-lg js-abort-import', - }, - { - 'type': 'button', - 'label': 'Close'|trans({}, 'Admin.Actions'), - 'class': 'btn btn-outline-secondary btn-lg js-close-modal', - } - ], -} %} - {% block content %} - - {% endblock %} -{% endembed %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/ImportDataConfiguration/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/ImportDataConfiguration/index.html.twig deleted file mode 100644 index d1cbb590..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/ImportDataConfiguration/index.html.twig +++ /dev/null @@ -1,47 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -{% block content %} -
    -
    - {% block import_data_configuration_panel %} - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/ImportDataConfiguration/Blocks/import_data_configuration.html.twig' %} - {% endblock %} - - {% block import_modal %} - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/ImportDataConfiguration/Blocks/import_modal.html.twig' %} - {% endblock %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/ImportPage/import.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/ImportPage/import.html.twig deleted file mode 100644 index 6f98b782..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/ImportPage/import.html.twig +++ /dev/null @@ -1,59 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -{% block content %} - {% if importForm is defined %} -
    -
    -
    -
    - {% block import_panel %} - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Blocks/import_panel.html.twig' %} - {% endblock %} -
    - -
    - {% block import_available_fields %} - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Blocks/import_available_fields.html.twig' %} - {% endblock %} - - {% block import_sample_files %} - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Blocks/import_sample_files.html.twig' %} - {% endblock %} -
    -
    -
    -
    - {% endif %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/LogsPage/Blocks/severity_levels.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/LogsPage/Blocks/severity_levels.html.twig deleted file mode 100644 index c3c26cf9..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/LogsPage/Blocks/severity_levels.html.twig +++ /dev/null @@ -1,59 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% trans_default_domain "Admin.Advparameters.Feature" %} -
    -
    -

    - warning {{ 'Severity levels'|trans({}, 'Admin.Advparameters.Help') }} -

    -
    -
    -

    {{ 'Meaning of severity levels:'|trans }}

    -
      -
    1. - - {{ 'Informative only'|trans({}, 'Admin.Advparameters.Help') }} - -
    2. -
    3. - - {{ 'Warning'|trans({}, 'Admin.Advparameters.Help') }} - -
    4. -
    5. - - {{ 'Error'|trans({}, 'Admin.Advparameters.Help') }} - -
    6. -
    7. - - {{ 'Major issue (crash)!'|trans({}, 'Admin.Advparameters.Help') }} - -
    8. -
    -
    -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/LogsPage/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/LogsPage/index.html.twig deleted file mode 100644 index b0043764..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/LogsPage/index.html.twig +++ /dev/null @@ -1,83 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain "Admin.Advparameters.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block content %} - {% block logs_severity_level_meaning %} -
    - {{ include('@PrestaShop/Admin/Configure/AdvancedParameters/LogsPage/Blocks/severity_levels.html.twig') }} -
    - {% endblock %} - - {% block logs_main_panel %} -
    -
    - {{ include('@PrestaShop/Admin/Common/Grid/grid_panel.html.twig', {'grid': grid }) }} -
    -
    - {% endblock %} - - {% block logs_by_mail %} - {{ form_start(logsByEmailForm, {'action': path('admin_logs_save_settings')}) }} -
    -
    -
    -

    - business_center {{ 'Logs by email'|trans }} -

    -
    -
    -
    - {% set helptip = 'Enter "5" if you do not want to receive any emails.'|trans({}, 'Admin.Advparameters.Help') ~ ' ' ~ 'Emails will be sent to the shop owner.'|trans({}, 'Admin.Advparameters.Help') %} - {{ ps.label_with_help(('Minimum severity level'|trans), helptip, 'col-sm-2') }} -
    - {{ form_errors(logsByEmailForm.logs_by_email) }} - {{ form_widget(logsByEmailForm.logs_by_email) }} -
    -
    - - {% block logs_by_email_form_rest %} - {{ form_rest(logsByEmailForm) }} - {% endblock %} -
    -
    - -
    -
    -
    - {{ form_end(logsByEmailForm) }} - {% endblock %} -{% endblock %} -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Profiles/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Profiles/Blocks/form.html.twig deleted file mode 100644 index 92403801..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Profiles/Blocks/form.html.twig +++ /dev/null @@ -1,56 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{{ form_start(profileForm) }} -
    -

    - group - {{ 'Profile'|trans({}, 'Admin.Advparameters.Feature') }} -

    -
    -
    - {{ form_errors(profileForm) }} - - {{ ps.form_group_row(profileForm.name, {}, { - 'label': 'Name'|trans({}, 'Admin.Global') - }) }} - - {% block profile_form_rest %} - {{ form_rest(profileForm) }} - {% endblock %} -
    -
    - -
    -{{ form_end(profileForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Profiles/create.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Profiles/create.html.twig deleted file mode 100644 index a345e174..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Profiles/create.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Profiles/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Profiles/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Profiles/edit.html.twig deleted file mode 100644 index a345e174..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Profiles/edit.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Profiles/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Profiles/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Profiles/index.html.twig deleted file mode 100644 index 60771001..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Profiles/index.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} - {% block profiles_list_panel %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': grid} %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/Blocks/db_tables_panel.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/Blocks/db_tables_panel.html.twig deleted file mode 100644 index eded126b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/Blocks/db_tables_panel.html.twig +++ /dev/null @@ -1,82 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Advparameters.Feature" %} - -
    -
    -
    -

    - {{ 'List of MySQL Tables'|trans }} -

    -
    -
    - -
    - - -
    -
    -
    -
    -
    -

    - {{ 'List of attributes for this MySQL table'|trans }} -

    -
    - - - - - - - - - - -
    {{ 'Attribute'|trans({}, 'Admin.Global') }}{{ 'Type'|trans({}, 'Admin.Global') }}{{ 'Action'|trans }}
    - -
    -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/Blocks/form.html.twig deleted file mode 100644 index 9a73d6d6..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/Blocks/form.html.twig +++ /dev/null @@ -1,69 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% trans_default_domain "Admin.Advparameters.Feature" %} - -{% block sql_request_form %} - {{ form_start(requestSqlForm) }} -
    -

    - {{ 'SQL query'|trans }} -

    -
    -
    - {{ form_errors(requestSqlForm) }} - -
    - - -
    - {{ ps.form_widget_with_error(requestSqlForm.name) }} -
    -
    - -
    - - -
    - {{ ps.form_widget_with_error(requestSqlForm.sql, {'attr': {'rows': 10}}) }} -
    -
    -
    - - {{ form_rest(requestSqlForm) }} -
    - -
    - {{ form_end(requestSqlForm) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/Blocks/settings_panel.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/Blocks/settings_panel.html.twig deleted file mode 100644 index 7652b590..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/Blocks/settings_panel.html.twig +++ /dev/null @@ -1,57 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -{{ form_start(requestSqlSettingsForm, {'action': path('admin_sql_requests_process_settings') }) }} -
    -

    - settings - {{ 'Settings'|trans({}, 'Admin.Global') }} -

    -
    -
    -
    - -
    - {{ form_errors(requestSqlSettingsForm.settings.default_file_encoding) }} - {{ form_widget(requestSqlSettingsForm.settings.default_file_encoding) }} -
    -
    - - {% block request_sql_settings %} - {{ form_rest(requestSqlSettingsForm) }} - {% endblock %} -
    -
    - -
    -{{ form_end(requestSqlSettingsForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/create.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/create.html.twig deleted file mode 100644 index 28377b2b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/create.html.twig +++ /dev/null @@ -1,54 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -{% block content %} - {% if requestSqlForm.vars.errors is not empty %} -
    - {% for error in requestSqlForm.vars.errors %} -
    {{ error.message }}
    - {% endfor %} -
    - {% endif %} - -
    -
    - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/RequestSql/Blocks/form.html.twig' %} - - {% block sql_manager_db_tables_panel %} - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/RequestSql/Blocks/db_tables_panel.html.twig' %} - {% endblock %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/edit.html.twig deleted file mode 100644 index 28377b2b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/edit.html.twig +++ /dev/null @@ -1,54 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain 'Admin.Advparameters.Feature' %} - -{% block content %} - {% if requestSqlForm.vars.errors is not empty %} -
    - {% for error in requestSqlForm.vars.errors %} -
    {{ error.message }}
    - {% endfor %} -
    - {% endif %} - -
    -
    - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/RequestSql/Blocks/form.html.twig' %} - - {% block sql_manager_db_tables_panel %} - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/RequestSql/Blocks/db_tables_panel.html.twig' %} - {% endblock %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/index.html.twig deleted file mode 100644 index 3c917174..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/index.html.twig +++ /dev/null @@ -1,78 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain "Admin.Advparameters.Feature" %} - -{% block content %} - {% block sql_manager_info_block %} -
    -
    - -
    -
    - {% endblock %} - - {% block sql_manager_warning_block %} -
    -
    - -
    -
    - {% endblock %} - - {% block sql_manager_list_panel %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': requestSqlGrid} %} -
    -
    - {% endblock %} - - {% block sql_manager_settings_panel %} -
    -
    - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/RequestSql/Blocks/settings_panel.html.twig' %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/view.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/view.html.twig deleted file mode 100644 index f7569a7a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/RequestSql/view.html.twig +++ /dev/null @@ -1,78 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain "Admin.Advparameters.Feature" %} - -{% block content %} - {% block request_sql_view_block %} -
    -
    -
    -
    -

    - list - {{ 'SQL query result'|trans }} ({{ sqlRequestResult.rows|length }}) -

    -
    -
    - {% if sqlRequestResult.rows is not empty %} -
    - - - - {% for column in sqlRequestResult.columns %} - - {% endfor %} - - - - {% for row in sqlRequestResult.rows %} - - {% for column in sqlRequestResult.columns %} - {% if requestSqlView.attributes[column] is defined %} - - {% else %} - - {% endif %} - {% endfor %} - - {% endfor %} - -
    {{ column }}
    {{ requestSqlView.attributes[column] }}{{ row[column] }}
    -
    - {% else %} -
    -

    - {{ 'This SQL query has no result.'|trans({}, 'Admin.Advparameters.Notification') }} -

    -
    - {% endif %} -
    -
    -
    -
    - {% endblock %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Webservice/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Webservice/Blocks/form.html.twig deleted file mode 100644 index 7edb5821..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Webservice/Blocks/form.html.twig +++ /dev/null @@ -1,88 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block webservice_key_form %} - {{ form_start(webserviceKeyForm) }} -
    -

    - {{ 'Webservice Accounts'|trans({}, 'Admin.Advparameters.Feature') }} -

    -
    -
    - {{ form_errors(webserviceKeyForm) }} - - {{ ps.form_group_row(webserviceKeyForm.key, {}, { - 'label': 'Key'|trans({}, 'Admin.Advparameters.Feature'), - 'help': 'Webservice account key.'|trans({}, 'Admin.Advparameters.Feature') - }) }} - - {{ ps.form_group_row(webserviceKeyForm.description, {}, { - 'label': 'Key description'|trans({}, 'Admin.Advparameters.Feature'), - 'help': 'Quick description of the key: who it is for, what permissions it has, etc.'|trans({}, 'Admin.Advparameters.Help') - }) }} - - {{ ps.form_group_row(webserviceKeyForm.status, {}, { - 'label': 'Status'|trans({}, 'Admin.Global') - }) }} - -
    - -
    - -
    -
    - - {{ ps.form_group_row(webserviceKeyForm.permissions, { - 'label': 'Resource'|trans({}, 'Admin.Global') - }, { - 'label': 'Permissions'|trans({}, 'Admin.Advparameters.Feature') - }) }} - - {% if webserviceKeyForm.shop_association is defined %} - {{ ps.form_group_row(webserviceKeyForm.shop_association, {}, { - 'label': 'Shop association'|trans({}, 'Admin.Global') - }) }} - {% endif %} - - {% block webservice_key_form_rest %} - {{ form_rest(webserviceKeyForm) }} - {% endblock %} -
    -
    - -
    - {{ form_end(webserviceKeyForm) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Webservice/create.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Webservice/create.html.twig deleted file mode 100644 index 04f14551..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Webservice/create.html.twig +++ /dev/null @@ -1,41 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Webservice/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Webservice/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Webservice/edit.html.twig deleted file mode 100644 index 04f14551..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Webservice/edit.html.twig +++ /dev/null @@ -1,41 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Configure/AdvancedParameters/Webservice/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Webservice/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Webservice/index.html.twig deleted file mode 100644 index 239f4098..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Webservice/index.html.twig +++ /dev/null @@ -1,81 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain "Admin.Advparameters.Feature" %} - -{% set layoutTitle = 'Webservice'|trans({}, 'Admin.Navigation.Menu') %} -{% set enableSidebar = true %} -{% set layoutHeaderToolbarBtn = { - 'add': { - 'href': path('admin_webservice_keys_create'), - 'desc': 'Add new webservice key'|trans({}, 'Admin.Advparameters.Feature'), - 'icon': 'add_circle_outline' - } -} %} - -{% block content %} - - {% block webservice_list_notifications %} - {% if configurationWarnings is not empty %} -
    -
    - -
    -
    - {% endif %} - {% endblock %} - -
    -
    - {{ include('@PrestaShop/Admin/Common/Grid/grid_panel.html.twig', {'grid': grid }) }} -
    -
    - -
    -
    - {{ form_start(form, {'action': path('admin_webservice_save_settings') ,'attr' : {'class': 'form', 'id': 'configuration_form'} }) }} - - {{ include('@PrestaShop/Admin/Configure/AdvancedParameters/Webservice/webservice_settings.html.twig') }} - - {% block webservice_configuration_form_rest %} - {{ form_rest(form) }} - {% endblock %} - - {{ form_end(form) }} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Webservice/webservice_settings.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Webservice/webservice_settings.html.twig deleted file mode 100644 index f4ba3e10..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/Webservice/webservice_settings.html.twig +++ /dev/null @@ -1,79 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Advparameters.Feature" %} - -{% set webserviceConfigurationForm = form.webservice_configuration %} - -{% block webservice_form_configuration %} -
    -

    - settings {{ 'Configuration'|trans({}, 'Admin.Global') }} -

    - -
    -
    -
    - - -
    - {{ form_errors(webserviceConfigurationForm.enable_webservice) }} - {{ form_widget(webserviceConfigurationForm.enable_webservice) }} - - - {{ 'Before activating the webservice, you must be sure to: '|trans({}, 'Admin.Advparameters.Help') }} -
    - 1. {{ 'Check that URL rewriting is available on this server.'|trans({}, 'Admin.Advparameters.Help') }} -
    - 2. {{ 'Check that the five methods GET, POST, PUT, DELETE and HEAD are supported by this server.'|trans({}, 'Admin.Advparameters.Help') }} -
    -
    -
    - -
    - - -
    - {{ form_errors(webserviceConfigurationForm.enable_cgi) }} - {{ form_widget(webserviceConfigurationForm.enable_cgi) }} - - - {{ 'Before choosing "Yes", check that PHP is not configured as an Apache module on your server.'|trans({}, 'Admin.Advparameters.Help') }} - -
    -
    - - {% block webservice_configuration_form_rest %} - {{ form_rest(webserviceConfigurationForm) }} - {% endblock %} -
    -
    - -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/administration.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/administration.html.twig deleted file mode 100644 index ab0f3d10..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/administration.html.twig +++ /dev/null @@ -1,172 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain "Admin.Advparameters.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% set generalForm, uploadQuotaForm, notificationsForm = form.general, form.upload_quota, form.notifications %} - -{% block content %} - {{ form_start(form, {'attr' : {'class': 'form'} }) }} -
    - {% block administration_form_general %} -
    -
    -

    - settings {{ 'General'|trans({}, 'Admin.Global') }} -

    -
    -
    -
    - {{ ps.label_with_help(('Automatically check for module updates'|trans), ('New modules and updates are displayed on the modules page.'|trans({}, 'Admin.Advparameters.Help'))) }} -
    - {{ form_errors(generalForm.check_modules_update) }} - {{ form_widget(generalForm.check_modules_update, {'attr' : {'class': 'custom-select'} }) }} -
    -
    -
    - {{ ps.label_with_help(("Check the cookie's IP address"|trans), ('Check the IP address of the cookie in order to prevent your cookie from being stolen.'|trans({}, 'Admin.Advparameters.Help'))) }} -
    - {{ form_errors(generalForm.check_ip_address) }} - {{ form_widget(generalForm.check_ip_address, {'attr' : {'class': 'custom-select'} }) }} -
    -
    -
    - {{ ps.label_with_help(('Lifetime of front office cookies'|trans), ('Set the amount of hours during which the front office cookies are valid. After that amount of time, the customer will have to log in again.'|trans({}, 'Admin.Advparameters.Help'))) }} -
    - {{ form_errors(generalForm.front_cookie_lifetime) }} - {{ form_widget(generalForm.front_cookie_lifetime) }} -
    -
    -
    - {{ ps.label_with_help(('Lifetime of back office cookies'|trans), ('When you access your back office and decide to stay logged in, your cookies lifetime defines your browser session. Set here the number of hours during which you want them valid before logging in again.'|trans({}, 'Admin.Advparameters.Help'))) }} -
    - {{ form_errors(generalForm.back_cookie_lifetime) }} - {{ form_widget(generalForm.back_cookie_lifetime) }} -
    -
    - {{ form_rest(generalForm) }} -
    -
    - -
    -
    - {% endblock %} - - {% block administration_form_upload_quota %} -
    -
    -

    - file_upload {{ 'Upload quota'|trans }} -

    -
    -
    -
    - {{ ps.label_with_help(('Maximum size for attached files'|trans), ('Set the maximum size allowed for attachment files (in megabytes). This value has to be lower or equal to the maximum file upload allotted by your server (currently: %size% MB).'|trans({'%size%': 'PS_ATTACHMENT_MAXIMUM_SIZE'|configuration}, 'Admin.Advparameters.Help'))) }} -
    - {{ form_errors(uploadQuotaForm.max_size_attached_files) }} - {{ form_widget(uploadQuotaForm.max_size_attached_files) }} -
    -
    -
    - {{ ps.label_with_help(('Maximum size for a downloadable product'|trans), ('Define the upload limit for a downloadable product (in megabytes). This value has to be lower or equal to the maximum file upload allotted by your server (currently: %size% MB).'|trans({'%size%': 'PS_LIMIT_UPLOAD_FILE_VALUE'|configuration}, 'Admin.Advparameters.Help'))) }} -
    - {{ form_errors(uploadQuotaForm.max_size_downloadable_product) }} - {{ form_widget(uploadQuotaForm.max_size_downloadable_product) }} -
    -
    -
    - {{ ps.label_with_help(("Maximum size for a product's image"|trans), ('Define the upload limit for an image (in megabytes). This value has to be lower or equal to the maximum file upload allotted by your server (currently: %size% MB).'|trans({'%size%': 'PS_LIMIT_UPLOAD_IMAGE_VALUE'|configuration}, 'Admin.Advparameters.Help'))) }} -
    - {{ form_errors(uploadQuotaForm.max_size_product_image) }} - {{ form_widget(uploadQuotaForm.max_size_product_image) }} -
    -
    - {{ form_rest(uploadQuotaForm) }} -
    -
    - -
    -
    - {% endblock %} - - {% block administration_form_notifications %} -
    -
    -

    - priority_high {{ 'Notifications'|trans }} -

    -
    -
    - -
    -
    - {{ ps.infotip("Notifications are numbered bubbles displayed at the very top of your back office, right next to the shop's name. They display the number of new items since you last clicked on them."|trans({}, 'Admin.Advparameters.Help')) }} -
    -
    - -
    - {{ ps.label_with_help(('Show notifications for new orders'|trans), ("This will display notifications when new orders are made in your shop."|trans({}, 'Admin.Advparameters.Help'))) }} -
    - {{ form_errors(notificationsForm.show_notifs_new_orders) }} - {{ form_widget(notificationsForm.show_notifs_new_orders, {'attr' : {'class': 'custom-select'} }) }} -
    -
    -
    - {{ ps.label_with_help(('Show notifications for new customers'|trans), ('This will display notifications every time a new customer registers in your shop.'|trans({}, 'Admin.Advparameters.Help'))) }} -
    - {{ form_errors(notificationsForm.show_notifs_new_customers) }} - {{ form_widget(notificationsForm.show_notifs_new_customers, {'attr' : {'class': 'custom-select'} }) }} -
    -
    -
    - {{ ps.label_with_help(('Show notifications for new messages'|trans), ('This will display notifications when new messages are posted in your shop.'|trans({}, 'Admin.Advparameters.Help'))) }} -
    - {{ form_errors(notificationsForm.show_notifs_new_messages) }} - {{ form_widget(notificationsForm.show_notifs_new_messages, {'attr' : {'class': 'custom-select'} }) }} -
    -
    - {{ form_rest(notificationsForm) }} -
    -
    - -
    -
    - {% endblock %} -
    - {{ form_end(form) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/memcache_servers.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/memcache_servers.html.twig deleted file mode 100644 index f0dd4f5e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/memcache_servers.html.twig +++ /dev/null @@ -1,78 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% trans_default_domain "Admin.Advparameters.Feature" %} - -{% block perfs_memcache_servers %} - - -
    - {{ form_widget(form) }} - -
    -
    - - -
    -
    -
    - -
    -
    - - - - - - - - - - - - {% for server in servers %} - - - - - - - - {% endfor %} - -
    {{ 'ID'|trans({}, 'Admin.Global') }}{{ 'IP Address'|trans }}{{ 'Port'|trans }}{{ 'Weight'|trans }} 
    {{ server.id_memcached_server }}{{ server.ip }}{{ server.port }}{{ server.weight }} - {% set removeMsg = 'Do you really want to remove the server %serverIp%:%serverPort% ?'|trans({'%serverIp%': server.ip, '%serverPort%': server.port}, 'Admin.Advparameters.Notification')|json_encode|raw %} - remove_circle {{ 'Remove'|trans({}, 'Admin.Actions') }} -
    -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/performance.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/performance.html.twig deleted file mode 100644 index 7b5dd8f4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/performance.html.twig +++ /dev/null @@ -1,226 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain "Admin.Advparameters.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} -{% form_theme form 'PrestaShopBundle:Admin/TwigTemplateForm:prestashop_ui_kit.html.twig' %} - -{% - set smartyForm, debugModeForm, optionalFeaturesForm, combineCompressCacheForm, mediaServersForm, cachingForm, memcacheForm = - form.smarty, form.debug_mode, form.optional_features, form.ccc, form.media_servers, form.caching, form.add_memcache_server -%} - -{% block content %} - {{ form_start(form, {'attr' : {'class': 'form'} }) }} -
    - {% block perfs_form_smarty_cache %} -
    -
    -

    - business_center {{ 'Smarty'|trans }} -

    -
    -
    - {% block perfs_form_smarty_cache_form %} - {{ form_widget(smartyForm) }} - {% endblock %} -
    -
    - -
    -
    - {% endblock %} - - {% block perfs_form_debug_mode %} -
    -
    -

    - bug_report {{ 'Debug mode'|trans }} -

    -
    -
    - {% block perfs_form_debug_mode_form %} - {{ form_widget(debugModeForm) }} - {% endblock %} -
    -
    - -
    -
    - {% endblock %} - - {% block perfs_form_optional_features %} -
    -
    -

    - extension {{ 'Optional features'|trans }} -

    -
    -
    - -
    -
    - {{ ps.infotip('Some features can be disabled in order to improve performance.'|trans({}, 'Admin.Advparameters.Help')) }} -
    -
    - - {% block perfs_form_optional_features_form %} - {{ form_widget(optionalFeaturesForm) }} - {% endblock %} -
    -
    - -
    -
    - {% endblock %} - - {% block perfs_form_ccc %} -
    -
    -

    - zoom_out_map {{ 'CCC (Combine, Compress and Cache)'|trans }} -

    -
    -
    -
    -
    - {{ ps.infotip('CCC allows you to reduce the loading time of your page. With these settings you will gain performance without even touching the code of your theme. Make sure, however, that your theme is compatible with PrestaShop 1.4+. Otherwise, CCC will cause problems.'|trans({}, 'Admin.Advparameters.Help')) }} -
    -
    - - {% block perfs_form_ccc_form %} - {{ form_widget(combineCompressCacheForm) }} - {% endblock %} -
    -
    - -
    -
    - {% endblock %} - - {% block perfs_form_media_servers %} -
    -
    -

    - link {{ 'Media servers (use only with CCC)'|trans }} -

    -
    -
    -
    -
    - {{ ps.infotip('You must enter another domain, or subdomain, in order to use cookieless static content.'|trans({}, 'Admin.Advparameters.Feature')) }} -
    -
    - - {% block perfs_form_media_servers_form %} - {{ form_widget(mediaServersForm) }} - {% endblock %} -
    -
    - -
    -
    - {% endblock %} - - {% block perfs_form_caching %} -
    -
    -

    - link {{ 'Caching'|trans }} -

    -
    -
    - {% block perfs_form_caching_form %} - {{ form_widget(cachingForm) }} - {% endblock %} - - {{ include('@AdvancedParameters/memcache_servers.html.twig', {'form': memcacheForm}) }} -
    -
    - -
    -
    - {% endblock %} -
    - {{ form_end(form) }} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/system_information.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/system_information.html.twig deleted file mode 100644 index 9ab24d08..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/AdvancedParameters/system_information.html.twig +++ /dev/null @@ -1,287 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain "Admin.Advparameters.Feature" %} - -{% block content %} -
    -
    -
    -

    - info_outline {{ 'Configuration information'|trans }} -

    -
    -
    -

    {{ 'This information must be provided when you report an issue on our bug tracker or forum.'|trans }}

    -
    -
    -
    - {% if system.notHostMode %} -
    -

    - info_outline {{ 'Server information'|trans }} -

    -
    -
    - {% if system.uname is not empty %} -

    - {{ 'Server information'|trans }} {{ system.uname }} -

    - {% endif %} -

    - {{ 'Server software version:'|trans }} {{ system.server.version }} -

    -

    - {{ 'PHP version:'|trans }} {{ system.server.php.version }} -

    -

    - {{ 'Memory limit:'|trans }} {{ system.server.php.memoryLimit }} -

    -

    - {{ 'Max execution time:'|trans }} {{ system.server.php.maxExecutionTime }} -

    -

    - {{ 'Upload Max File size:'|trans }} {{ system.server.php.maxFileSizeUpload }} -

    - {% if system.instaWebInstalled %} -

    {{ 'PageSpeed module for Apache installed (mod_instaweb)'|trans }}

    - {% endif %} -
    -
    -
    - -
    -

    - info_outline {{ 'Database information'|trans({}, 'Admin.Advparameters.Feature') }} -

    -
    -
    -

    - {{ 'MySQL version:'|trans }} {{ system.database.version }} -

    -

    - {{ 'MySQL server:'|trans }} {{ system.database.server }} -

    -

    - {{ 'MySQL name:'|trans }} {{ system.database.name }} -

    -

    - {{ 'MySQL user:'|trans }} {{ system.database.user }} -

    -

    - {{ 'Tables prefix:'|trans }} {{ system.database.prefix }} -

    -

    - {{ 'MySQL engine:'|trans }} {{ system.database.engine }} -

    -

    - {{ 'MySQL driver:'|trans }} {{ system.database.driver }} -

    -
    -
    -
    -
    - {% endif %} -
    -
    -

    - info_outline {{ 'Store information'|trans }} -

    -
    -
    -

    - {{ 'PrestaShop version:'|trans }} {{ system.shop.version }} -

    -

    - {{ 'Shop URL:'|trans }} {{ system.shop.url }} -

    -

    - {{ 'Shop path:'|trans }} {{ system.shop.path }} -

    -

    - {{ 'Current theme in use:'|trans }} {{ system.shop.theme }} -

    -
    -
    -
    - -
    -

    - info_outline {{ 'Mail configuration'|trans }} -

    -
    -
    -

    - {{ 'Mail method:'|trans }} - - {% if system.isNativePHPmail %} - {{ 'You are using /usr/sbin/sendmail'|trans }} - {% else %} - {{ 'You are using your own SMTP parameters.'|trans }}

    -

    - {{ 'SMTP server:'|trans }} {{ system.smtp.server }} -

    -

    - {{ 'SMTP username:'|trans }} - {% if system.smtp.user is not empty %} - {{ 'Defined'|trans }} - {% else %} - {{ 'Not defined'|trans }} - {% endif %} -

    -

    - {{ 'SMTP password:'|trans }} - {% if system.smtp.password is not empty %} - {{ 'Defined'|trans }} - {% else %} - {{ 'Not defined'|trans }} - {% endif %} -

    -

    - {{ 'Encryption:'|trans }} {{ system.smtp.encryption }} -

    -

    - {{ 'SMTP port:'|trans }} {{ system.smtp.port }} -

    - {% endif %} -
    -
    -
    - -
    -

    - info_outline {{ 'Your information'|trans }} -

    -
    -
    -

    - {{ 'Your web browser:'|trans }} {{ userAgent }} -

    -
    -
    -
    - -
    -

    - info_outline {{ 'Check your configuration'|trans }} -

    -
    -
    -

    - {{ 'Required parameters:'|trans }} - {% if requirements.failRequired == false %} - {{ 'OK'|trans({}, 'Admin.Advparameters.Notification') }} -

    - {% else %} - {{ 'Please fix the following error(s)'|trans({}, 'Admin.Advparameters.Notification') }} -

    -
      - {% for key, value in requirements.testsRequired %} - {% if 'fail' == value %} -
    • {{ requirements.testsErrors[key] }}
    • - {% endif %} - {% endfor %} -
    - {% endif %} - {% if requirements.failOptional is defined %} -

    - {{ 'Optional parameters:'|trans }} - {% if requirements.failOptional == false %} - {{ 'OK'|trans({}, 'Admin.Advparameters.Notification') }} -

    - {% else %} - {{ 'Please fix the following error(s)'|trans({}, 'Admin.Advparameters.Notification') }} -

    -
      - {% for key, value in requirements.testsOptional %} - {% if 'fail' == value %} -
    • {{ requirements.testsErrors[key] }}
    • - {% endif %} - {% endfor %} -
    - {% endif %} - {% endif %} -
    -
    -
    -
    -
    -{% if system.notHostMode %} -
    -

    - info_outline {{ 'List of changed files'|trans }} -

    -
    -
    - loop {{ 'Checking files...'|trans({}, 'Admin.Advparameters.Notification') }} -
    -
    -
    -{% endif %} -{% if system.notHostMode %} - -{% endif %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Blocks/customer_preferences_general.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Blocks/customer_preferences_general.html.twig deleted file mode 100644 index 87821792..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Blocks/customer_preferences_general.html.twig +++ /dev/null @@ -1,92 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Shopparameters.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block customer_preferences_general %} -
    -
    -

    - settings {{ 'General'|trans({}, 'Admin.Global') }} -

    -
    -
    -
    - {{ ps.label_with_help(('Re-display cart at login'|trans), ('After a customer logs in, you can recall and display the content of his/her last shopping cart.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(generalForm.redisplay_cart_at_login) }} - {{ form_widget(generalForm.redisplay_cart_at_login) }} -
    -
    -
    - {{ ps.label_with_help(('Send an email after registration'|trans), ('Send an email with summary of the account information (email, password) after registration.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(generalForm.send_email_after_registration) }} - {{ form_widget(generalForm.send_email_after_registration) }} -
    -
    -
    - {{ ps.label_with_help(('Password reset delay'|trans), ('Minimum time required between two requests for a password reset.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(generalForm.password_reset_delay) }} - {{ form_widget(generalForm.password_reset_delay) }} -
    -
    -
    - {{ ps.label_with_help(('Enable B2B mode'|trans), ('Activate or deactivate B2B mode. When this option is enabled, B2B features will be made available.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(generalForm.enable_b2b_mode) }} - {{ form_widget(generalForm.enable_b2b_mode) }} -
    -
    -
    - {{ ps.label_with_help(('Ask for birth date'|trans), ('Display or not the birth date field.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(generalForm.ask_for_birthday) }} - {{ form_widget(generalForm.ask_for_birthday) }} -
    -
    -
    - {{ ps.label_with_help(('Enable partner offers'|trans), ('Display or not the partner offers tick box, to receive offers from the store\'s partners.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(generalForm.enable_offers) }} - {{ form_widget(generalForm.enable_offers) }} -
    -
    - - {% block customer_general_preferences_form_rest %} - {{ form_rest(generalForm) }} - {% endblock %} -
    -
    - -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Blocks/product_preferences_general.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Blocks/product_preferences_general.html.twig deleted file mode 100644 index 28046504..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Blocks/product_preferences_general.html.twig +++ /dev/null @@ -1,102 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Shopparameters.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block product_preferences_general %} -
    -
    -

    - settings {{ 'Products (general)'|trans }} -

    -
    -
    -
    - {{ ps.label_with_help(('Catalog mode'|trans), ('Catalog mode disables the shopping cart on your store. Visitors will be able to browse your products catalog, but not buy them.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(generalForm.catalog_mode) }} - {{ form_widget(generalForm.catalog_mode) }} - {{ 'Have specific needs? Edit particular groups to let them see prices or not.'|trans({}, 'Admin.Shopparameters.Help') }} -
    -
    -
    - {{ ps.label_with_help(('Show prices'|trans), ('Display product prices when in catalog mode.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(generalForm.catalog_mode_with_prices) }} - {{ form_widget(generalForm.catalog_mode_with_prices) }} -
    -
    -
    - -
    - {{ form_errors(generalForm.new_days_number) }} - {{ form_widget(generalForm.new_days_number) }} -
    -
    -
    - {{ ps.label_with_help(('Max size of product summary'|trans), ('Set the maximum size of the summary of your product description (in characters).'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(generalForm.short_description_limit) }} - {{ form_widget(generalForm.short_description_limit) }} -
    -
    -
    - {{ ps.label_with_help(('Quantity discounts based on'|trans), ('How to calculate quantity discounts.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(generalForm.quantity_discount) }} - {{ form_widget(generalForm.quantity_discount) }} -
    -
    -
    - {{ ps.label_with_help(('Force update of friendly URL'|trans), ('When active, friendly URL will be updated on every save.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(generalForm.force_friendly_url) }} - {{ form_widget(generalForm.force_friendly_url) }} -
    -
    -
    - {{ ps.label_with_help(('Default activation status'|trans), ('When active, new products will be activated by default during creation.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(generalForm.default_status) }} - {{ form_widget(generalForm.default_status) }} -
    -
    - - {% block product_general_preferences_form_rest %} - {{ form_rest(generalForm) }} - {% endblock %} -
    -
    - -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Blocks/product_preferences_page.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Blocks/product_preferences_page.html.twig deleted file mode 100644 index 6a69007f..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Blocks/product_preferences_page.html.twig +++ /dev/null @@ -1,101 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Shopparameters.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block product_preferences_page %} -
    -
    -

    - shopping_basket {{ 'Product page'|trans }} -

    -
    -
    -
    - -
    - {{ form_errors(pageForm.display_quantities) }} - {{ form_widget(pageForm.display_quantities) }} -
    -
    -
    - {{ ps.label_with_help(('Display remaining quantities when the quantity is lower than'|trans), ('Set to "0" to disable this feature.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(pageForm.display_last_quantities) }} - {{ form_widget(pageForm.display_last_quantities) }} -
    -
    -
    - -
    - {{ form_errors(pageForm.display_unavailable_attributes) }} - {{ form_widget(pageForm.display_unavailable_attributes) }} -
    -
    -
    - {{ ps.label_with_help(('Display the "%add_to_cart_label%" button when a product has attributes'|trans({'%add_to_cart_label%': 'Add to cart'|trans({}, 'Shop.Theme.Actions')}, 'Admin.Shopparameters.Help')), ('Display or hide the "%add_to_cart_label%" button on category pages for products that have attributes forcing customers to see product details.'|trans({'%add_to_cart_label%': 'Add to cart'|trans({}, 'Shop.Theme.Actions')}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(pageForm.allow_add_variant_to_cart_from_listing) }} - {{ form_widget(pageForm.allow_add_variant_to_cart_from_listing) }} -
    -
    -
    - -
    - {{ form_errors(pageForm.attribute_anchor_separator) }} - {{ form_widget(pageForm.attribute_anchor_separator) }} -
    -
    -
    - -
    - {{ form_errors(pageForm.display_discount_price) }} - {{ form_widget(pageForm.display_discount_price) }} - {{ 'In the volume discounts board, display the new price with the applied discount instead of showing the discount (ie. "-5%").'|trans({}, 'Admin.Shopparameters.Help') }} -
    -
    -
    - - {% block product_page_preferences_form_rest %} - {{ form_rest(pageForm) }} - {% endblock %} -
    - -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Blocks/product_preferences_pagination.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Blocks/product_preferences_pagination.html.twig deleted file mode 100644 index f88995b8..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Blocks/product_preferences_pagination.html.twig +++ /dev/null @@ -1,71 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Shopparameters.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block product_preferences_pagination %} -
    -
    -

    - view_headline {{ 'Pagination'|trans }} -

    -
    -
    -
    - {{ ps.label_with_help(('Products per page'|trans), ('Number of products displayed per page. Default is 10.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(paginationForm.products_per_page) }} - {{ form_widget(paginationForm.products_per_page) }} -
    -
    -
    - {{ ps.label_with_help(('Default order by'|trans), ('The order in which products are displayed in the product list.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(paginationForm.default_order_by) }} - {{ form_widget(paginationForm.default_order_by) }} -
    -
    -
    - {{ ps.label_with_help(('Default order method'|trans), ('Default order method for product list.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(paginationForm.default_order_way) }} - {{ form_widget(paginationForm.default_order_way) }} -
    -
    - - {% block product_pagination_preferences_form_rest %} - {{ form_rest(paginationForm) }} - {% endblock %} -
    -
    - -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Blocks/product_preferences_stock.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Blocks/product_preferences_stock.html.twig deleted file mode 100644 index c15895b7..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Blocks/product_preferences_stock.html.twig +++ /dev/null @@ -1,116 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Shopparameters.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block product_preferences_stock %} -
    -
    -

    - shop {{ 'Products stock'|trans }} -

    -
    -
    -
    - {{ ps.label_with_help(('Allow ordering of out-of-stock products'|trans), ('By default, the "%add_to_cart_label%" button is hidden when a product is unavailable. You can choose to have it displayed in all cases.'|trans({'%add_to_cart_label%': 'Add to cart'|trans({}, 'Shop.Theme.Actions')}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(stockForm.allow_ordering_oos) }} - {{ form_widget(stockForm.allow_ordering_oos) }} -
    -
    -
    - -
    - {{ form_errors(stockForm.stock_management) }} - {{ form_widget(stockForm.stock_management) }} -
    -
    -
    - -
    - {{ form_errors(stockForm.stock_management) }} - {{ form_widget(stockForm.in_stock_label) }} -
    -
    -
    - -
    - {{ form_errors(stockForm.oos_allowed_backorders) }} - {{ form_widget(stockForm.oos_allowed_backorders) }} -
    -
    -
    - -
    - {{ form_errors(stockForm.oos_denied_backorders) }} - {{ form_widget(stockForm.oos_denied_backorders) }} -
    -
    -
    - {{ ps.label_with_help(('Delivery time of in-stock products'|trans), ('Advised for European merchants to be legally compliant (eg: Delivered within 3-4 days)'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(stockForm.delivery_time) }} - {{ form_widget(stockForm.delivery_time) }} - {{ 'Leave empty to disable'|trans }} -
    -
    -
    - {{ ps.label_with_help(('Delivery time of out-of-stock products with allowed backorders'|trans), ('Advised for European merchants to be legally compliant (eg: Delivered within 5-7 days)'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(stockForm.oos_delivery_time) }} - {{ form_widget(stockForm.oos_delivery_time) }} - {{ 'Leave empty to disable'|trans }} -
    -
    -
    - {{ ps.label_with_help(('Default pack stock management'|trans), ('When selling packs of products, how do you want your stock to be calculated?'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(stockForm.pack_stock_management) }} - {{ form_widget(stockForm.pack_stock_management) }} -
    -
    - - {% block product_stock_preferences_form_rest %} - {{ form_rest(stockForm) }} - {% endblock %} -
    -
    - -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Contact/Contacts/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Contact/Contacts/Blocks/form.html.twig deleted file mode 100644 index f42d1248..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Contact/Contacts/Blocks/form.html.twig +++ /dev/null @@ -1,79 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block contact_form %} - {{ form_start(contactForm) }} -
    -

    - mail_outline - {{ 'Contacts'|trans({}, 'Admin.Shopparameters.Feature') }} -

    -
    -
    - {{ form_errors(contactForm) }} - - {{ ps.form_group_row(contactForm.title, {}, { - 'label': 'Title'|trans({}, 'Admin.Global'), - 'help': 'Contact name (e.g. Customer Support).'|trans({}, 'Admin.Shopparameters.Help') - }) }} - - {{ ps.form_group_row(contactForm.email, {}, { - 'label': 'Email address'|trans({}, 'Admin.Global'), - 'help': 'Emails will be sent to this address.'|trans({}, 'Admin.Shopparameters.Help') - }) }} - - {{ ps.form_group_row(contactForm.is_messages_saving_enabled, {}, { - 'label': 'Save messages?'|trans({}, 'Admin.Shopparameters.Feature'), - 'help': 'If enabled, all messages will be saved in the "Customer Service" page under the "Customer" menu.'|trans({}, 'Admin.Shopparameters.Help') - }) }} - - {{ ps.form_group_row(contactForm.description, {}, { - 'label': 'Description'|trans({}, 'Admin.Global') - }) }} - - {% if contactForm.shop_association is defined %} - {{ ps.form_group_row(contactForm.shop_association, {}, { - 'label': 'Shop association'|trans({}, 'Admin.Global') - }) }} - {% endif %} - - {% block contact_form_rest %} - {{ form_rest(contactForm) }} - {% endblock %} -
    -
    - -
    - {{ form_end(contactForm) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Contact/Contacts/create.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Contact/Contacts/create.html.twig deleted file mode 100644 index 7161dd90..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Contact/Contacts/create.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Configure/ShopParameters/Contact/Contacts/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Contact/Contacts/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Contact/Contacts/edit.html.twig deleted file mode 100644 index 7161dd90..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Contact/Contacts/edit.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Configure/ShopParameters/Contact/Contacts/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Contact/Contacts/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Contact/Contacts/index.html.twig deleted file mode 100644 index 55253f40..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/Contact/Contacts/index.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} - {% block contacts_list_panel %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': contactGrid} %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/OrderPreferences/Blocks/order_preferences_general.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/OrderPreferences/Blocks/order_preferences_general.html.twig deleted file mode 100644 index a7747a16..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/OrderPreferences/Blocks/order_preferences_general.html.twig +++ /dev/null @@ -1,49 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Shopparameters.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block order_preferences_general %} -
    -
    -

    - settings {{ 'General'|trans({}, 'Admin.Global') }} -

    -
    -
    - {% block order_general_preferences_form_rest %} - {{ form_rest(generalForm) }} - {% endblock %} -
    -
    - -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/OrderPreferences/Blocks/order_preferences_gift_options.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/OrderPreferences/Blocks/order_preferences_gift_options.html.twig deleted file mode 100644 index 38bfaaf6..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/OrderPreferences/Blocks/order_preferences_gift_options.html.twig +++ /dev/null @@ -1,49 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Shopparameters.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block order_preferences_gift_options %} -
    -
    -

    - cake {{ 'Gift options'|trans({}, 'Admin.Shopparameters.Feature') }} -

    -
    -
    - {% block order_gift_options_preferences_form_rest %} - {{ form_rest(giftOptionsForm) }} - {% endblock %} -
    -
    - -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/OrderPreferences/order_preferences.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/OrderPreferences/order_preferences.html.twig deleted file mode 100644 index 6a367325..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/OrderPreferences/order_preferences.html.twig +++ /dev/null @@ -1,46 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain "Admin.Shopparameters.Feature" %} - -{% set generalForm, giftOptionsForm = form.general, form.gift_options %} - -{% block content %} - {{ form_start(form, {'attr': {'class': 'form', 'id': 'configuration_form'}}) }} -
    - {# General options block #} - {% include '@PrestaShop/Admin/Configure/ShopParameters/OrderPreferences/Blocks/order_preferences_general.html.twig' %} - - {# Gift options block #} - {% include '@PrestaShop/Admin/Configure/ShopParameters/OrderPreferences/Blocks/order_preferences_gift_options.html.twig' %} -
    - {{ form_end(form) }} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/domain_name_management.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/domain_name_management.html.twig deleted file mode 100644 index ac3ca040..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/domain_name_management.html.twig +++ /dev/null @@ -1,56 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Shopparameters.Feature" %} - -{% block domain_name_management %} -{% if isHostMode %} -
    -

    - settings {{ 'Manage domain name'|trans }} -

    -
    -
    -
    -
    - -
    -
    -
    -
    - - - -
    - {% endif %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/form.html.twig deleted file mode 100644 index 619a2aa0..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/form.html.twig +++ /dev/null @@ -1,105 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{{ form_start(metaForm) }} -
    -
    - {{ 'Meta tags'|trans({}, 'Admin.Shopparameters.Feature') }} -
    -
    -
    - {{ form_errors(metaForm) }} - - {{ ps.form_group_row(metaForm.page_name, { - 'attr': { - 'class': 'js-meta-page-name', - 'data-toggle': 'select2', - 'data-minimumResultsForSearch': '7' - } - }, { - 'label': 'Page name'|trans({}, 'Admin.Shopparameters.Feature'), - 'help': 'Name of the related page.'|trans({}, 'Admin.Shopparameters.Help') - }) }} - - {% set pageTitleHelpLabel %} - {{ 'Title of this page.'|trans({}, 'Admin.Shopparameters.Help') }} - {{ 'Invalid characters:'|trans({}, 'Admin.Shopparameters.Help') ~ ' <>={}'}} - {% endset %} - - {{ ps.form_group_row(metaForm.page_title, {}, { - 'label': 'Page title'|trans({}, 'Admin.Shopparameters.Feature'), - 'help': pageTitleHelpLabel - }) }} - - {% set metaDescriptionHelpLabel %} - {{ 'A short description of your shop.'|trans({}, 'Admin.Shopparameters.Help') }} - {{ 'Invalid characters:'|trans({}, 'Admin.Shopparameters.Help') ~ ' <>={}' }} - {% endset %} - - {{ ps.form_group_row(metaForm.meta_description, {}, { - 'label': 'Meta description'|trans({}, 'Admin.Global'), - 'help': metaDescriptionHelpLabel - }) }} - - {% set metaKeywordsHelpLabel %} - {{ 'List of keywords for search engines.'|trans({}, 'Admin.Shopparameters.Help') }} - {{ 'To add tags, click in the field, write something, and then press the "Enter" key.'|trans({}, 'Admin.Shopparameters.Help') }} - {{ 'Invalid characters:'|trans({}, 'Admin.Shopparameters.Help') ~ ' <>={}' }} - {% endset %} - - {{ ps.form_group_row(metaForm.meta_keywords, {}, { - 'label': 'Meta keywords'|trans({}, 'Admin.Global'), - 'help': metaKeywordsHelpLabel - }) }} - - {% set rewriteUrlHelpLabel %} - {{ 'For instance, "contacts" for http://example.com/shop/contacts to redirect to http://example.com/shop/contact-form.php'|trans({}, 'Admin.Shopparameters.Help') }} - {{ 'Only letters and hyphens are allowed.'|trans({}, 'Admin.Shopparameters.Help') }} - {% endset %} - - {{ ps.form_group_row(metaForm.url_rewrite, {'attr': {'class': 'js-url-rewrite'}}, { - 'label': 'Rewritten URL'|trans({}, 'Admin.Shopparameters.Feature'), - 'help': rewriteUrlHelpLabel - }) }} - - {% block meta_form_rest %} - {{ form_rest(metaForm) }} - {% endblock %} -
    -
    - -
    -{{ form_end(metaForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/keyword.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/keyword.html.twig deleted file mode 100644 index 4b2b04d9..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/keyword.html.twig +++ /dev/null @@ -1,39 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block keyword %} - {% if routeKeywords[idRoute] is defined%} - {% set formattedKeywords = [] %} - {% for keyword, value in routeKeywords[idRoute] %} - {% set formattedKeyword %} - {{ keyword }}{% if value['param'] is defined %}*{% endif %} - {% endset %} - - {% set formattedKeywords = formattedKeywords|merge([formattedKeyword]) %} - {% endfor %} - - {{ 'Keywords: %keywords%'|trans({'%keywords%': formattedKeywords|join(', ')}, 'Admin.Shopparameters.Feature') }} - {% endif %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/meta_showcase_card.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/meta_showcase_card.html.twig deleted file mode 100644 index d3f80004..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/meta_showcase_card.html.twig +++ /dev/null @@ -1,45 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Shopparameters.Feature" %} - -{% block meta_showcase_card %} - {% if not showcaseCardIsClosed %} -
    -
    - -
    -
    -

    {{ 'Improve your SEO'|trans }}

    -

    {{ 'Edit information about your pages to gain visibility and therefore reach more visitors. We advise you to start with the index page, it stands for your homepage.'|trans }}

    - {{ 'Learn more'|trans({}, 'Admin.Actions') }} - {% if indexPageId and isGridDisplayed %} - {{ 'Configure index page'|trans }} - {% endif %} -
    - close -
    - {% endif %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/robots_file_generation.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/robots_file_generation.html.twig deleted file mode 100644 index 01a844f1..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/robots_file_generation.html.twig +++ /dev/null @@ -1,65 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Shopparameters.Feature" %} - -{% block keyword %} -
    -

    - settings {{ 'Robots file generation'|trans }} -

    - -
    -
    -
    -
    - -
    -
    -
    -
    - -
    -{% endblock %} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/seo_options_configuration.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/seo_options_configuration.html.twig deleted file mode 100644 index 936e7534..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/seo_options_configuration.html.twig +++ /dev/null @@ -1,56 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Shopparameters.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block seo_options_configuration %} -
    -

    - settings {{ 'SEO options'|trans }} -

    -
    -
    - -
    - {{ ps.label_with_help(('Display attributes in the product meta title'|trans), ('Enable this option if you want to display your product\'s attributes in its meta title.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(metaForm.seo_options.product_attributes_in_title) }} - {{ form_widget(metaForm.seo_options.product_attributes_in_title) }} -
    -
    - - {% block meta_form_rest %} - {{ form_rest(metaForm.seo_options) }} - {% endblock %} -
    -
    - -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/set_up_urls_configuration.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/set_up_urls_configuration.html.twig deleted file mode 100644 index 990b6f21..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/set_up_urls_configuration.html.twig +++ /dev/null @@ -1,116 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Shopparameters.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block set_up_urls_configuration %} -
    -

    - settings {{ 'Set up URLs'|trans }} -

    -
    -
    - - {% if not isHtaccessFileValid %} -
    -
    - -
    -
    - {% endif %} - -
    - {% if isModRewriteActive %} - {{ ps.label_with_help('Friendly URL'|trans({}, 'Admin.Global'), ('Enable this option only if your server allows URL rewriting (recommended).'|trans({}, 'Admin.Shopparameters.Help'))) }} - {% endif %} -
    - {{ form_errors(metaForm.set_up_urls.friendly_url) }} - {{ form_widget(metaForm.set_up_urls.friendly_url) }} - - {% if not isModRewriteActive %} - - {{ 'URL rewriting (mod_rewrite) is not active on your server, or it is not possible to check your server configuration. If you want to use Friendly URLs, you must activate this mod.'|trans({}, 'Admin.Shopparameters.Help') }} - - {% endif %} -
    -
    - -
    - {{ ps.label_with_help(('Accented URL'|trans), ('Enable this option if you want to allow accented characters in your friendly URLs.'|trans({}, 'Admin.Shopparameters.Help') ~ ' ' ~ 'You should only activate this option if you are using non-latin characters ; for all the latin charsets, your SEO will be better without this option.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(metaForm.set_up_urls.accented_url) }} - {{ form_widget(metaForm.set_up_urls.accented_url) }} -
    -
    - -
    - -
    - {{ form_errors(metaForm.set_up_urls.canonical_url_redirection) }} - {{ form_widget(metaForm.set_up_urls.canonical_url_redirection) }} -
    -
    - - {% if metaForm.set_up_urls.disable_apache_multiview is defined %} -
    - {{ ps.label_with_help(("Disable Apache's MultiViews option"|trans), ('Enable this option only if you have problems with URL rewriting.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(metaForm.set_up_urls.disable_apache_multiview) }} - {{ form_widget(metaForm.set_up_urls.disable_apache_multiview) }} -
    -
    - {% endif %} - - {% if metaForm.set_up_urls.disable_apache_mod_security is defined %} -
    - {{ ps.label_with_help(("Disable Apache's mod_security module"|trans), ("Some of PrestaShop's features might not work correctly with a specific configuration of Apache's mod_security module. We recommend to turn it off."|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(metaForm.set_up_urls.disable_apache_mod_security) }} - {{ form_widget(metaForm.set_up_urls.disable_apache_mod_security) }} -
    -
    - {% endif %} - - {% block meta_form_rest %} - {{ form_rest(metaForm.set_up_urls) }} - {% endblock %} -
    -
    - -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/shop_urls_configuration.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/shop_urls_configuration.html.twig deleted file mode 100644 index 4863a5f1..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/shop_urls_configuration.html.twig +++ /dev/null @@ -1,115 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Shopparameters.Feature" %} - -{% set shopUrlForm = metaForm.shop_urls %} - -{% block shop_urls_configuration %} - - {% set cardHeaderLabel = 'Set shop URL'|trans %} - {% if isShopFeatureActive and not isHostMode %} -
    -
    - settings {{ cardHeaderLabel }} -
    -
    -
    -
    -
    - -
    -
    -
    -
    -
    - {% endif %} - - {% if shopUrlForm.children is not empty %} -
    -

    - settings {{ cardHeaderLabel }} -

    -
    -
    -
    -
    - -
    -
    - -
    - -
    - {{ form_errors(shopUrlForm.domain) }} - {{ form_widget(shopUrlForm.domain) }} -
    -
    - -
    - -
    - {{ form_errors(shopUrlForm.domain_ssl) }} - {{ form_widget(shopUrlForm.domain_ssl) }} -
    -
    - -
    - -
    - {{ form_errors(shopUrlForm.physical_uri) }} - {{ form_widget(shopUrlForm.physical_uri, {'required': false}) }} -
    -
    - - {% block meta_form_rest %} - {{ form_rest(shopUrlForm) }} - {% endblock %} -
    -
    - - -
    - {% endif %} -{% endblock %} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/url_schema_configuration.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/url_schema_configuration.html.twig deleted file mode 100644 index 70f3c6ce..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/url_schema_configuration.html.twig +++ /dev/null @@ -1,165 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Shopparameters.Feature" %} - -{% set urlSchemaForm = metaForm.url_schema %} - -{% block url_schema_configuration %} - {% if urlSchemaForm.children is not empty %} -
    -

    - settings {{ 'Schema of URLs'|trans }} -

    -
    -
    -
    -
    - -
    -
    - -
    - -
    - {{ form_errors(urlSchemaForm.product_rule) }} - {{ form_widget(urlSchemaForm.product_rule) }} - - {{ include('@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/keyword.html.twig', {'idRoute': 'product_rule'}) }} - -
    -
    - -
    - -
    - {{ form_errors(urlSchemaForm.category_rule) }} - {{ form_widget(urlSchemaForm.category_rule) }} - - {{ include('@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/keyword.html.twig', {'idRoute': 'category_rule'}) }} - -
    -
    - -
    - -
    - {{ form_errors(urlSchemaForm.layered_rule) }} - {{ form_widget(urlSchemaForm.layered_rule) }} - - {{ include('@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/keyword.html.twig', {'idRoute': 'layered_rule'}) }} - -
    -
    - -
    - -
    - {{ form_errors(urlSchemaForm.supplier_rule) }} - {{ form_widget(urlSchemaForm.supplier_rule) }} - - {{ include('@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/keyword.html.twig', {'idRoute': 'supplier_rule'}) }} - -
    -
    - -
    - -
    - {{ form_errors(urlSchemaForm.manufacturer_rule) }} - {{ form_widget(urlSchemaForm.manufacturer_rule) }} - - {{ include('@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/keyword.html.twig', {'idRoute': 'manufacturer_rule'}) }} - -
    -
    - -
    - -
    - {{ form_errors(urlSchemaForm.cms_rule) }} - {{ form_widget(urlSchemaForm.cms_rule) }} - - {{ include('@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/keyword.html.twig', {'idRoute': 'cms_rule'}) }} - -
    -
    - -
    - -
    - {{ form_errors(urlSchemaForm.cms_category_rule) }} - {{ form_widget(urlSchemaForm.cms_category_rule) }} - - {{ include('@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/keyword.html.twig', {'idRoute': 'cms_category_rule'}) }} - -
    -
    - -
    - -
    - {{ form_errors(urlSchemaForm.module) }} - {{ form_widget(urlSchemaForm.module) }} - - {{ include('@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/keyword.html.twig', {'idRoute': 'module'}) }} - -
    -
    - -
    -
    - -
    - {% else %} - {% do urlSchemaForm.setRendered %} - {% endif %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/create.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/create.html.twig deleted file mode 100644 index 5085b95d..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/create.html.twig +++ /dev/null @@ -1,39 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {{ include('@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/form.html.twig', {'metaForm': meta_form}) }} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/edit.html.twig deleted file mode 100644 index 5085b95d..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/edit.html.twig +++ /dev/null @@ -1,39 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {{ include('@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/form.html.twig', {'metaForm': meta_form}) }} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/index.html.twig deleted file mode 100644 index 691f67a5..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/TrafficSeo/Meta/index.html.twig +++ /dev/null @@ -1,81 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain "Admin.Shopparameters.Feature" %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/meta_showcase_card.html.twig' %} -
    -
    - {% if not isGridDisplayed %} -
    -
    - -
    -
    - {% else %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': grid} %} -
    -
    - {% endif %} - -
    -
    - {{ form_start(metaForm, {'action': path('admin_metas_save_options')}) }} - {% include '@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/set_up_urls_configuration.html.twig' %} - {% include '@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/shop_urls_configuration.html.twig' %} - {% include '@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/domain_name_management.html.twig' %} - {% include '@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/url_schema_configuration.html.twig' %} - {% include '@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/seo_options_configuration.html.twig' %} - - {% block meta_form_rest %} - {{ form_rest(metaForm) }} - {% endblock %} - - {{ form_end(metaForm) }} - - {{ form_start(robotsForm, {'action': path('admin_metas_generate_robots_text_file')}) }} - {% include '@PrestaShop/Admin/Configure/ShopParameters/TrafficSeo/Meta/Blocks/robots_file_generation.html.twig' %} - {{ form_rest(robotsForm) }} - {{ form_end(robotsForm) }} -
    -
    - -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/customer_preferences.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/customer_preferences.html.twig deleted file mode 100644 index 0609545a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/customer_preferences.html.twig +++ /dev/null @@ -1,36 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain "Admin.Shopparameters.Feature" %} - -{% set generalForm = form.general %} - -{% block content %} - {{ form_start(form, {'attr': {'class': 'form', 'id': 'configuration_form'}}) }} -
    - {% include '@PrestaShop/Admin/Configure/ShopParameters/Blocks/customer_preferences_general.html.twig' %} -
    - {{ form_end(form) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/maintenance.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/maintenance.html.twig deleted file mode 100644 index 4e59f8c4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/maintenance.html.twig +++ /dev/null @@ -1,82 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain "Admin.Shopparameters.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% set generalForm = form.general %} - -{% block content %} - {{ form_start(form, {'attr' : {'class': 'form'} }) }} -
    - {% block maintenance_form_general %} -
    -
    -

    - business_center {{ 'General'|trans({}, 'Admin.Global') }} -

    -
    -
    -
    - {{ ps.label_with_help(('Enable Shop'|trans), ('Activate or deactivate your shop (It is a good idea to deactivate your shop while you perform maintenance. Please note that the webservice will not be disabled).'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(generalForm.enable_shop) }} - {{ form_widget(generalForm.enable_shop) }} -
    -
    -
    - {{ ps.label_with_help(('Maintenance IP'|trans), ('IP addresses allowed to access the front office even if the shop is disabled. Please use a comma to separate them (e.g. 42.24.4.2,127.0.0.1,99.98.97.96)'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(generalForm.maintenance_ip) }} - {{ form_widget(generalForm.maintenance_ip, { 'currentIp': currentIp}) }} -
    -
    -
    - {{ ps.label_with_help(('Custom maintenance text'|trans), ('Custom text displayed on maintenance page while shop is deactivated.'|trans({}, 'Admin.Shopparameters.Help'))) }} -
    - {{ form_errors(generalForm.maintenance_text) }} - {{ form_widget(generalForm.maintenance_text) }} -
    -
    - {{ form_rest(generalForm) }} -
    -
    - -
    -
    - {% endblock %} -
    - {{ form_end(form) }} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/preferences.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/preferences.html.twig deleted file mode 100644 index b7dbe2d2..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/preferences.html.twig +++ /dev/null @@ -1,184 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain "Admin.Shopparameters.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% - set generalForm = form.general -%} - -{% block content %} - {{ form_start(form, {'attr' : {'class': 'form', 'id': 'configuration_form'} }) }} -
    - {% block preferences_form_general %} -
    -
    -

    - settings {{ 'General'|trans({}, 'Admin.Global') }} -

    -
    -
    -
    - {{ ps.label_with_help( - ('Enable SSL'|trans), - ('If you want to enable SSL on all the pages of your shop, activate the "Enable on all the pages" option below.'|trans({}, 'Admin.Shopparameters.Help')) - ) }} - {% if app.request.isSecure() %} -
    - {{ form_errors(generalForm.enable_ssl) }} - {{ form_widget(generalForm.enable_ssl) }} - {{ 'If you own an SSL certificate for your shop\'s domain name, you can activate SSL encryption (https://) for customer account identification and order processing.'|trans({}, 'Admin.Shopparameters.Help') }} -
    - {% else %} - - {% endif %} -
    -
    - -
    - {{ form_errors(generalForm.enable_ssl_everywhere) }} - {{ form_widget(generalForm.enable_ssl_everywhere) }} - {{ 'When enabled, all the pages of your shop will be SSL-secured.'|trans({}, 'Admin.Shopparameters.Help') }} -
    -
    -
    - -
    - {{ form_errors(generalForm.enable_token) }} - {{ form_widget(generalForm.enable_token) }} - {{ 'Enable or disable token in the Front Office to improve PrestaShop\'s security.'|trans({}, 'Admin.Shopparameters.Help') }} - - {% if generalForm.enable_token.vars.disabled %} - - {% endif %} -
    -
    -
    - -
    - {{ form_errors(generalForm.allow_html_iframes) }} - {{ form_widget(generalForm.allow_html_iframes) }} - {{ 'Allow iframes on text fields like product description. We recommend that you leave this option disabled.'|trans({}, 'Admin.Shopparameters.Help') }} -
    -
    -
    - -
    - {{ form_errors(generalForm.use_htmlpurifier) }} - {{ form_widget(generalForm.use_htmlpurifier) }} - {{ 'Clean the HTML content on text fields. We recommend that you leave this option enabled.'|trans({}, 'Admin.Shopparameters.Help') }} -
    -
    -
    - -
    - {{ form_errors(generalForm.price_round_mode) }} - {{ form_widget(generalForm.price_round_mode) }} - {{ 'You can choose among 6 different ways of rounding prices. "Round up away from zero ..." is the recommended behavior.'|trans({}, 'Admin.Shopparameters.Help') }} -
    -
    -
    - -
    - {{ form_errors(generalForm.price_round_type) }} - {{ form_widget(generalForm.price_round_type) }} - {{ 'You can choose when to round prices: either on each item, each line or the total (of an invoice, for example).'|trans({}, 'Admin.Shopparameters.Help') }} -
    -
    -
    - -
    - {{ form_errors(generalForm.display_suppliers) }} - {{ form_widget(generalForm.display_suppliers) }} - {{ 'Enable suppliers page on your front office even when its module is disabled.'|trans({}, 'Admin.Shopparameters.Help') }} -
    -
    -
    - -
    - {{ form_errors(generalForm.display_manufacturers) }} - {{ form_widget(generalForm.display_manufacturers) }} - {{ 'Enable brands page on your front office even when its module is disabled.'|trans({}, 'Admin.Shopparameters.Help') }} -
    -
    -
    - -
    - {{ form_errors(generalForm.display_best_sellers) }} - {{ form_widget(generalForm.display_best_sellers) }} - {{ 'Enable best sellers page on your front office even when its respective module is disabled.'|trans({}, 'Admin.Shopparameters.Help') }} -
    -
    -
    - -
    - {{ form_errors(generalForm.multishop_feature_active) }} - {{ form_widget(generalForm.multishop_feature_active) }} - {{ 'The multistore feature allows you to manage several e-shops with one Back Office. If this feature is enabled, a "Multistore" page will be available in the "Advanced Parameters" menu.'|trans({}, 'Admin.Shopparameters.Help') }} - - {% if generalForm.multishop_feature_active.vars.disabled %} - - {% endif %} -
    -
    -
    - -
    - {{ form_errors(generalForm.shop_activity) }} - {{ form_widget(generalForm.shop_activity) }} -
    -
    - {% block shop_preferences_form_rest %} - {{ form_rest(form) }} - {% endblock %} -
    -
    - -
    -
    - {% endblock %} - -
    - {{ form_end(form) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/product_preferences.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/product_preferences.html.twig deleted file mode 100644 index acf6f61b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Configure/ShopParameters/product_preferences.html.twig +++ /dev/null @@ -1,52 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain "Admin.Shopparameters.Feature" %} - -{% set generalForm, paginationForm, pageForm, stockForm = form.general, form.pagination, form.page, form.stock %} - -{% block content %} - {{ form_start(form, {'attr': {'class': 'form', 'id': 'configuration_form'}}) }} -
    - {# Product preferences General block #} - {% include '@PrestaShop/Admin/Configure/ShopParameters/Blocks/product_preferences_general.html.twig' %} - - {# Product preferences Page block #} - {% include '@PrestaShop/Admin/Configure/ShopParameters/Blocks/product_preferences_page.html.twig' %} - - {# Product preferences Stock block #} - {% include '@PrestaShop/Admin/Configure/ShopParameters/Blocks/product_preferences_stock.html.twig' %} - - {# Product preferences Pagination block #} - {% include '@PrestaShop/Admin/Configure/ShopParameters/Blocks/product_preferences_pagination.html.twig' %} -
    - {{ form_end(form) }} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Exception/error.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Exception/error.html.twig deleted file mode 100644 index 36a80450..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Exception/error.html.twig +++ /dev/null @@ -1,88 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '::base.html.twig' %} - -{% block stylesheets %} - -{% endblock %} - -{% block title %} - {{ 'Oops... looks like an unexpected error occurred'|trans({},'Admin.Notifications.Error' ) }} -{% endblock %} - -{% block body %} -
    -
    -
    -
    -
    - {{ 'Oops... looks like an unexpected error occurred'|trans({}, 'Admin.Notifications.Error') }} - -
    -

    - {{ 'Oops... looks like an unexpected error occurred'|trans({}, 'Admin.Notifications.Error') }} -

    - - {% if exception %} -
    -

    {{ exception.message }}

    -

    [{{ exception.class }} {{ exception.code }}]

    -
    - {% endif %} - -
    -
    - - - -
    - -
    - -

    - - {{ 'Learn more about debug mode'|trans({}, 'Admin.Actions') }} - arrow_right_alt - -

    -
    -
    -
    -
    -
    -
    -{% endblock %} - -{% block javascripts %} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Helpers/bootstrap_popup.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Helpers/bootstrap_popup.html.twig deleted file mode 100644 index 776b81f7..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Helpers/bootstrap_popup.html.twig +++ /dev/null @@ -1,84 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Helpers/dropdown_menu.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Helpers/dropdown_menu.html.twig deleted file mode 100644 index 7ddc3c6b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Helpers/dropdown_menu.html.twig +++ /dev/null @@ -1,73 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% set buttonType = buttonType|default('primary') %} -{% set right = right|default(false) %} - -
    - - {% if default_item is defined %} - - {% if default_item.icon %} - {{ default_item.icon }} - {% endif %} - {{ default_item.label|default('') }} - - {% endif %} - - - - - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Helpers/range_inputs.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Helpers/range_inputs.html.twig deleted file mode 100644 index a29b9ea0..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Helpers/range_inputs.html.twig +++ /dev/null @@ -1,123 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{# Display a range input with min/max controls #} - -
    - - - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Helpers/range_slider.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Helpers/range_slider.html.twig deleted file mode 100644 index cd0bfe45..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Helpers/range_slider.html.twig +++ /dev/null @@ -1,96 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/breadcrumb.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/breadcrumb.html.twig deleted file mode 100644 index d6beb127..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/breadcrumb.html.twig +++ /dev/null @@ -1,53 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if cmsPageView.breadcrumb_tree is not empty %} -
    -
    -
    -
    - -
    -
    -
    -
    -{% endif %} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/category_form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/category_form.html.twig deleted file mode 100644 index 52b19c14..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/category_form.html.twig +++ /dev/null @@ -1,102 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block category_form %} - {{ form_start(cmsPageCategoryForm) }} - -
    -
    - {{ 'CMS Category'|trans({}, 'Admin.Design.Feature') }} -
    -
    -
    - - {% set invalidCharactersForCatalogLabel = 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ '<>;=#{}' %} - {% set invalidCharactersForNameLabel = 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ '<>={}' %} - - {{ ps.form_group_row(cmsPageCategoryForm.name, {}, { - 'label': 'Name'|trans({}, 'Admin.Global'), - 'help': invalidCharactersForCatalogLabel - }) }} - - {{ ps.form_group_row(cmsPageCategoryForm.is_displayed, {}, { - 'label': 'Displayed'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(cmsPageCategoryForm.parent_category, {}, { - 'label': 'Parent category'|trans({}, 'Admin.Design.Feature'), - }) }} - - {{ ps.form_group_row(cmsPageCategoryForm.description, {}, { - 'label': 'Description'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(cmsPageCategoryForm.meta_title, {}, { - 'label': 'Meta title'|trans({}, 'Admin.Global'), - 'help': invalidCharactersForNameLabel - }) }} - - {{ ps.form_group_row(cmsPageCategoryForm.meta_description, {}, { - 'label': 'Meta description'|trans({}, 'Admin.Global'), - 'help': invalidCharactersForNameLabel - }) }} - - {{ ps.form_group_row(cmsPageCategoryForm.meta_keywords, {}, { - 'label': 'Meta keywords'|trans({}, 'Admin.Global'), - 'help': invalidCharactersForNameLabel - }) }} - - {{ ps.form_group_row(cmsPageCategoryForm.friendly_url, {}, { - 'label': 'Friendly URL'|trans({}, 'Admin.Global'), - 'help': 'Only letters and the minus (-) character are allowed.'|trans({}, 'Admin.Catalog.Help') - }) }} - - {% if cmsPageCategoryForm.shop_association is defined %} - {{ ps.form_group_row(cmsPageCategoryForm.shop_association, {}, { - 'label': 'Shop association'|trans({}, 'Admin.Global') - }) }} - {% endif %} - -
    -
    - - - -
    - - {{ form_rest(cmsPageCategoryForm) }} - {{ form_end(cmsPageCategoryForm) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/form.html.twig deleted file mode 100644 index 032e5fb9..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/form.html.twig +++ /dev/null @@ -1,58 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{{ form_start(cmsPageForm) }} -
    -
    - {{ 'Page'|trans({}, 'Admin.Shopparameters.Feature') }} -
    -
    -
    - {% block cms_page_form_rest %} - {{ form_rest(cmsPageForm) }} - {% endblock %} -
    -
    - - - -
    -{{ form_end(cmsPageForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/listing_panel_footer.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/listing_panel_footer.html.twig deleted file mode 100644 index a2c2ee29..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/listing_panel_footer.html.twig +++ /dev/null @@ -1,31 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/seo_preview.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/seo_preview.html.twig deleted file mode 100644 index ea7b27b2..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/seo_preview.html.twig +++ /dev/null @@ -1,26 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/showcase_card.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/showcase_card.html.twig deleted file mode 100644 index 4631fa6b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/Blocks/showcase_card.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block cms_pages_showcase_card %} - {% if not showcaseCardIsClosed %} -
    -
    - -
    -
    -

    {{ 'Create meaningful content'|trans({}, 'Admin.Design.Help') }}

    -

    {{ 'Because it is not just selling products but also creating a universe, build pages to tell stories and catch your visitors’ interest, to turn them into loyal customers.'|trans({}, 'Admin.Design.Help') }}

    - {{ 'Learn more'|trans({}, 'Admin.Actions') }} -
    - close -
    - {% endif %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/add.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/add.html.twig deleted file mode 100644 index 1e23a4fc..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/add.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {{ include('@PrestaShop/Admin/Improve/Design/Cms/Blocks/form.html.twig', {}) }} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/create_category.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/create_category.html.twig deleted file mode 100644 index 25d7761d..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/create_category.html.twig +++ /dev/null @@ -1,42 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {{ include('@PrestaShop/Admin/Improve/Design/Cms/Blocks/category_form.html.twig', { - 'cmsPageCategoryForm': cmsPageCategoryForm, - 'cmsCategoryParentId': app.request.query.get('id_cms_category') - }) - }} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/edit.html.twig deleted file mode 100644 index 01466ff1..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/edit.html.twig +++ /dev/null @@ -1,41 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {{ include('@PrestaShop/Admin/Improve/Design/Cms/Blocks/form.html.twig', {}) }} - -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/edit_category.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/edit_category.html.twig deleted file mode 100644 index d05c94e2..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/edit_category.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {{ include('@PrestaShop/Admin/Improve/Design/Cms/Blocks/category_form.html.twig', { - 'cmsPageCategoryForm': cmsPageCategoryForm, - 'cmsCategoryParentId': cmsCategoryParentId - }) - }} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/index.html.twig deleted file mode 100644 index cc2d8fc0..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Cms/index.html.twig +++ /dev/null @@ -1,82 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% set layoutHeaderToolbarBtn = { - add_cms_category: { - href: path('admin_cms_pages_category_create', {'id_cms_category' : app.request.query.get('id_cms_category')}), - desc: 'Add new page category'|trans({}, 'Admin.Design.Help'), - icon: 'add_circle_outline', - }, - add_cms_page: { - href: path('admin_cms_pages_create', {'id_cms_category' : app.request.query.get('id_cms_category')}), - desc: 'Add new page'|trans({}, 'Admin.Design.Help'), - icon: 'add_circle_outline', - } -} -%} - -{% block content %} - -
    -
    - {% include '@PrestaShop/Admin/Improve/Design/Cms/Blocks/showcase_card.html.twig' %} -
    -
    - - {% block cms_page_category_breadcrumb %} - {% include '@PrestaShop/Admin/Improve/Design/Cms/Blocks/breadcrumb.html.twig' %} - {% endblock %} - - {% block cms_category_grid %} -
    -
    - {% embed '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': cmsCategoryGrid} %} - - {% block grid_panel_footer %} - {% if app.request.query.get('id_cms_category') and app.request.query.get('id_cms_category') != cmsPageView.root_category_id %} - {% include '@PrestaShop/Admin/Improve/Design/Cms/Blocks/listing_panel_footer.html.twig' %} - {% endif %} - {% endblock %} - {% endembed %} -
    -
    - {% endblock %} - - {% block cms_grid %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': cmsGrid} %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/Blocks/configuration_form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/Blocks/configuration_form.html.twig deleted file mode 100644 index 65e8bcb7..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/Blocks/configuration_form.html.twig +++ /dev/null @@ -1,65 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block mailThemeConfigurationFormBlock %} -
    -
    - {{ form_start(mailThemeConfigurationForm, {'action': path('admin_mail_theme_save_configuration')}) }} -
    -

    - settings {{ 'Configuration'|trans({}, 'Admin.Global') }} -

    - -
    -
    - -
    - -
    - {{ form_errors(mailThemeConfigurationForm.configuration.defaultTheme) }} - {{ form_widget(mailThemeConfigurationForm.configuration.defaultTheme) }} -
    -
    -
    -
    - - -
    - {{ form_end(mailThemeConfigurationForm) }} -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/Blocks/generate_mails_form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/Blocks/generate_mails_form.html.twig deleted file mode 100644 index 1309ad2f..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/Blocks/generate_mails_form.html.twig +++ /dev/null @@ -1,101 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block generateMailsFormBlock %} -
    -
    - {{ form_start(generateMailsForm, {'action': path('admin_mail_theme_generate')}) }} -
    -

    - email {{ 'Generate emails'|trans({}, 'Admin.Design.Feature') }} -

    - -
    -
    - -
    - -
    - {{ form_errors(generateMailsForm.mailTheme) }} - {{ form_widget(generateMailsForm.mailTheme) }} -
    -
    - -
    - -
    - {{ form_errors(generateMailsForm.language) }} - {{ form_widget(generateMailsForm.language) }} -
    -
    - -
    - -
    - {{ form_errors(generateMailsForm.theme) }} - {{ form_widget(generateMailsForm.theme) }} - {% if generateMailsForm.theme.vars.disabled %} - {{ 'No emails were detected in any theme folder so this field is disabled.'|trans({}, 'Admin.Design.Help') }} - {% endif %} -
    -
    - -
    - {{ ps.label_with_help( - ('Overwrite templates'|trans({}, 'Admin.Design.Feature')), - ('By default, existing email template files are not modified to avoid deleting any modification you may have done. Enable this option to force the overwrite.'|trans({}, 'Admin.Design.Help')) - ) }} -
    - {{ form_errors(generateMailsForm.overwrite) }} - {{ form_widget(generateMailsForm.overwrite) }} -
    -
    - -
    -
    - - -
    - {{ form_end(generateMailsForm) }} -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/Blocks/list_mail_theme_layouts.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/Blocks/list_mail_theme_layouts.html.twig deleted file mode 100644 index 952892bc..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/Blocks/list_mail_theme_layouts.html.twig +++ /dev/null @@ -1,121 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block generateMailsFormBlock %} -
    -
    -
    -

    - email {{ 'List %theme% layouts'|trans({'%theme%': mailTheme.name}, 'Admin.Design.Feature') }} -

    - -
    - - - - - - - - - - - {% for mailLayout in mailTheme.layouts %} - - - - - - {% endfor %} - -
    - {{ 'Name'|trans({}, 'Admin.Global') }} - - {{ 'Module'|trans({}, 'Admin.Global') }} - -
    - {{ 'Actions'|trans({}, 'Admin.Global') }} -
    -
    - {{ mailLayout.name }} - - {{ mailLayout.moduleName }} - - {% if mailLayout.moduleName is empty %} - {% set previewUrl = path('admin_mail_theme_preview_layout', {locale: app.request.locale, theme: mailTheme.name, layout: mailLayout.name, type: 'html'}) %} - {% set rawUrl = path('admin_mail_theme_raw_layout', {locale: app.request.locale, theme: mailTheme.name, layout: mailLayout.name, type: 'html'}) %} - {% set txtUrl = path('admin_mail_theme_raw_layout', {locale: app.request.locale, theme: mailTheme.name, layout: mailLayout.name, type: 'txt'}) %} - {% set mailUrl = path('admin_mail_theme_send_test_mail', {locale: app.request.locale, theme: mailTheme.name, layout: mailLayout.name}) %} - {% else %} - {% set previewUrl = path('admin_mail_theme_preview_module_layout', {locale: app.request.locale, theme: mailTheme.name, module: mailLayout.moduleName, layout: mailLayout.name, type: 'html'}) %} - {% set rawUrl = path('admin_mail_theme_raw_module_layout', {locale: app.request.locale, theme: mailTheme.name, module: mailLayout.moduleName, layout: mailLayout.name, type: 'html'}) %} - {% set txtUrl = path('admin_mail_theme_raw_module_layout', {locale: app.request.locale, theme: mailTheme.name, module: mailLayout.moduleName, layout: mailLayout.name, type: 'txt'}) %} - {% set mailUrl = path('admin_mail_theme_send_test_module_mail', {locale: app.request.locale, theme: mailTheme.name, module: mailLayout.moduleName, layout: mailLayout.name}) %} - {% endif %} - - -
    - -
    - - - -
    -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/Blocks/list_mail_themes.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/Blocks/list_mail_themes.html.twig deleted file mode 100644 index 96f077cc..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/Blocks/list_mail_themes.html.twig +++ /dev/null @@ -1,71 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block generateMailsFormBlock %} -
    -
    -
    -

    - email {{ 'Email themes'|trans({}, 'Admin.Design.Feature') }} -

    - -
    - - - - - - - - - - {% for theme in mailThemes %} - - - - - {% endfor %} - -
    - {{ 'Name'|trans({}, 'Admin.Global') }} - -
    - {{ 'Actions'|trans({}, 'Admin.Global') }} -
    -
    - {{ theme.name }} - - -
    - -
    -
    -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/Blocks/translate_mails_body_form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/Blocks/translate_mails_body_form.html.twig deleted file mode 100644 index a3216b42..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/Blocks/translate_mails_body_form.html.twig +++ /dev/null @@ -1,61 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block translateMailsBodyFormBlock %} -
    -
    - {{ form_start(translateMailsBodyForm, {'action': path('admin_mail_theme_translate_body')}) }} -
    -

    - email {{ 'Translate emails'|trans({}, 'Admin.Actions') }} -

    - -
    -
    -
    - -
    - {{ form_errors(translateMailsBodyForm.language) }} - {{ form_widget(translateMailsBodyForm.language) }} -
    -
    -
    -
    - - -
    - {{ form_end(translateMailsBodyForm) }} -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/index.html.twig deleted file mode 100644 index 746673c8..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/index.html.twig +++ /dev/null @@ -1,52 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} - {{ - include('@PrestaShop/Admin/Improve/Design/MailTheme/Blocks/configuration_form.html.twig', { - 'mailThemeConfigurationForm': mailThemeConfigurationForm - }) - }} - - {{ - include('@PrestaShop/Admin/Improve/Design/MailTheme/Blocks/generate_mails_form.html.twig', { - 'generateMailsForm': generateMailsForm - }) - }} - - {{ - include('@PrestaShop/Admin/Improve/Design/MailTheme/Blocks/translate_mails_body_form.html.twig', { - 'generateMailsForm': generateMailsForm - }) - }} - - {{ - include('@PrestaShop/Admin/Improve/Design/MailTheme/Blocks/list_mail_themes.html.twig', { - 'mailThemes': mailThemes - }) - }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/preview.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/preview.html.twig deleted file mode 100644 index 5fb68bce..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/MailTheme/preview.html.twig +++ /dev/null @@ -1,34 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} - {{ - include('@PrestaShop/Admin/Improve/Design/MailTheme/Blocks/list_mail_theme_layouts.html.twig', { - 'mailTheme': mailTheme - }) - }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/Partials/logo_card.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/Partials/logo_card.html.twig deleted file mode 100644 index 96070245..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/Partials/logo_card.html.twig +++ /dev/null @@ -1,37 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block logo_card %} -
    -
    -
    - {% block card_title %} - {% endblock %} -
    - {% block card_content %} - {% endblock %} -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/Partials/theme_card.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/Partials/theme_card.html.twig deleted file mode 100644 index 6564229e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/Partials/theme_card.html.twig +++ /dev/null @@ -1,52 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/Improve/Design/Theme/Blocks/Partials/theme_card_container.html.twig' %} - -{% block content %} -
    -
    - - {% block image %} - {% endblock %} - -
    - {% block button_container %} - {% endblock %} -
    -
    - -
    - - {{ themeName }} - - - {{ 'Version'|trans({}, 'Admin.Global') }} {{ themeVersion }} - - -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/Partials/theme_card_container.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/Partials/theme_card_container.html.twig deleted file mode 100644 index 6744f7e5..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/Partials/theme_card_container.html.twig +++ /dev/null @@ -1,29 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    - {% block content %} - {% endblock %} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/Partials/theme_catalog_card.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/Partials/theme_catalog_card.html.twig deleted file mode 100644 index 432daf30..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/Partials/theme_catalog_card.html.twig +++ /dev/null @@ -1,47 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/Improve/Design/Theme/Blocks/Partials/theme_card_container.html.twig' %} - -{% block content %} -
    - -
    - {% block image %} - {% endblock %} -
    - -
    - {% block description %} - {% endblock %} -
    - -
    - {% block button_container %} - {% endblock %} -
    -
    -{% endblock %} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/delete_theme_modal.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/delete_theme_modal.html.twig deleted file mode 100644 index 89a7205f..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/delete_theme_modal.html.twig +++ /dev/null @@ -1,50 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% embed 'PrestaShopBundle:Admin/Helpers:bootstrap_popup.html.twig' with { - 'id': 'delete_theme_modal' -} %} - {% block header %} - - {% endblock %} - - {% block footer %} - - {% endblock %} - -{% endembed %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/layouts_configuration.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/layouts_configuration.html.twig deleted file mode 100644 index 21de2869..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/layouts_configuration.html.twig +++ /dev/null @@ -1,59 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block layouts_configuration %} -
    -
    -
    - -
    - {{ 'Configure your page layouts'|trans({}, 'Admin.Design.Feature') }} -

    {{ 'Each page can use a different layout, choose it among the layouts bundled in your theme.'|trans({}, 'Admin.Design.Feature') }}

    -
    -
    -
    - - {{ 'Choose layouts'|trans({}, 'Admin.Design.Feature') }} - - - {% if isDevModeOn %} - - {% endif %} -
    -
    -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/logo_configuration.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/logo_configuration.html.twig deleted file mode 100644 index 34e1b0aa..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/logo_configuration.html.twig +++ /dev/null @@ -1,154 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    - {% embed '@PrestaShop/Admin/Improve/Design/Theme/Blocks/Partials/logo_card.html.twig' %} - {% import '@PrestaShop/Admin/macros.html.twig' as ps %} - {% block card_title %} - {{ form_widget(shopLogosForm.shop_logos.header_logo_is_restricted_to_shop) }} {{ 'Header logo'|trans({}, 'Admin.Design.Feature') }} - {% endblock %} - {% block card_content %} -

    - {{ 'Will appear on your main page. Recommended size for the default theme: height %height% and width %width%.'|trans({'%height%': '40px', '%width%': '200px'}, 'Admin.Design.Help') }} -

    - -
    - -
    - - {{ ps.form_group_row(shopLogosForm.shop_logos.header_logo) }} - {% endblock %} - {% endembed %} - - {% embed '@PrestaShop/Admin/Improve/Design/Theme/Blocks/Partials/logo_card.html.twig' %} - {% import '@PrestaShop/Admin/macros.html.twig' as ps %} - {% block card_title %} - - {% endblock %} - {% block card_content %} -
    -
    -

    - {{ 'Will appear on email headers. If undefined, the header logo will be used.'|trans({}, 'Admin.Design.Help') }} -

    - -
    - -
    -
    - {{ ps.form_group_row(shopLogosForm.shop_logos.mail_logo, {}, {'help': headerLogoPath == mailLogoPath ? 'Warning: if no email logo is available, the main logo will be used instead.'|trans({}, 'Admin.Design.Notification') : '' }) }} -
    -
    -
    -

    - {{ 'Will appear on invoice headers.'|trans({}, 'Admin.Design.Help') }} -

    - -
    - -
    -
    - {{ ps.form_group_row(shopLogosForm.shop_logos.invoice_logo, {}, {'help': headerLogoPath == invoiceLogoPath ? 'Warning: if no invoice logo is available, the main logo will be used instead.'|trans({}, 'Admin.Design.Help') : '' }) }} -
    -
    -
    - {% endblock %} - {% endembed %} - - {% embed '@PrestaShop/Admin/Improve/Design/Theme/Blocks/Partials/logo_card.html.twig' %} - {% import '@PrestaShop/Admin/macros.html.twig' as ps %} - {% block card_title %} - {{ form_widget(shopLogosForm.shop_logos.favicon_is_restricted_to_shop) }} {{ 'Favicon'|trans({}, 'Admin.Design.Feature') }} - {% endblock %} - {% block card_content %} -

    - {{ 'It is the small icon that appears in browser tabs, next to the title.'|trans({}, 'Admin.Design.Help') }} -

    - -
    - -
    - -
    -
    - {{ ps.form_widget_with_error(shopLogosForm.shop_logos.favicon) }} - - {{ 'Use our [1]favicon generator on PrestaShop Marketplace[/1] to boost your brand image!'|trans({'[1]': '', '[/1]': ''}, 'Admin.Design.Help')|raw }} - -
    -
    - - {% endblock %} - {% endembed %} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/multishop_switch.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/multishop_switch.html.twig deleted file mode 100644 index 8bb7c934..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/multishop_switch.html.twig +++ /dev/null @@ -1,38 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - {{ 'Multistore'|trans({}, 'Admin.Global') }} -

    -
    -
    - {{ ps.multistore_switch(shopLogosForm.shop_logos, { - 'label': 'Multistore'|trans({}, 'Admin.Global'), - }) }} -
    -
    -
    - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/rtl_configuration.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/rtl_configuration.html.twig deleted file mode 100644 index e7a8b341..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/rtl_configuration.html.twig +++ /dev/null @@ -1,70 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{{ form_start(adaptThemeToRtlLanguagesForm, {'action': path('admin_themes_adapt_to_rtl_languages')}) }} -
    -

    - {{ 'Adaptation to Right-to-Left languages'|trans({}, 'Admin.Design.Feature') }} -

    -
    -
    -
    -

    - {{ 'Be careful! Please check your theme in an RTL language before generating the RTL stylesheet: your theme could be already adapted to RTL.\nOnce you enable the "%generate_rtl_label%" option, any RTL-specific file that you might have added to your theme might be deleted by the created stylesheet.'|trans({'%generate_rtl_label%': 'Generate RTL stylesheet'|trans({}, 'Admin.Design.Feature')}, 'Admin.Design.Help') }} -

    -
    - - {{ ps.form_group_row(adaptThemeToRtlLanguagesForm.theme_to_adapt, {}, { - 'label': 'Theme to adapt'|trans({}, 'Admin.Design.Feature') - }) }} - - {{ ps.form_group_row(adaptThemeToRtlLanguagesForm.generate_rtl_css, {}, { - 'label': 'Generate RTL stylesheet'|trans({}, 'Admin.Design.Feature') - }) }} -
    -
    - - {% if isMultiShopFeatureUsed and isSingleShopContext %} -
    -
    -
    - {{ ps.multistore_switch(shopLogosForm.shop_logos, { - 'label': 'Multistore'|trans({}, 'Admin.Global'), - }) }} -
    -
    - {% endif %} - -
    -{{ form_rest(adaptThemeToRtlLanguagesForm) }} -{{ form_end(adaptThemeToRtlLanguagesForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/use_theme_modal.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/use_theme_modal.html.twig deleted file mode 100644 index 1bab208f..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/Blocks/use_theme_modal.html.twig +++ /dev/null @@ -1,50 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% embed 'PrestaShopBundle:Admin/Helpers:bootstrap_popup.html.twig' with { - 'id': 'use_theme_modal' -} %} - {% block header %} - - {% endblock %} - - {% block footer %} - - {% endblock %} - -{% endembed %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/customize_page_layouts.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/customize_page_layouts.html.twig deleted file mode 100644 index 81fe32bc..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/customize_page_layouts.html.twig +++ /dev/null @@ -1,74 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {{ form_start(pageLayoutCustomizationForm) }} -
    -
    -
    -

    - settings - {{ 'Choose layouts'|trans({}, 'Admin.Actions') }} -

    -
    - - - - - - - - - - {% for customizablePage in pages %} - - - - - - {% endfor %} - -
    {{ 'Page'|trans({}, 'Admin.Global') }}{{ 'Description'|trans({}, 'Admin.Global') }}{{ 'Layout'|trans({}, 'Admin.Global') }}
    {{ customizablePage.title|default(customizablePage.page) }}{{ customizablePage.description }}{{ form_widget(pageLayoutCustomizationForm['layouts'][customizablePage.page]) }}
    - - {% block page_layout_customization_form_rest %} - {{ form_rest(pageLayoutCustomizationForm) }} - {% endblock %} -
    - -
    -
    -
    - {{ form_end(pageLayoutCustomizationForm) }} -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/import.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/import.html.twig deleted file mode 100644 index e6516033..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/import.html.twig +++ /dev/null @@ -1,132 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% set layoutTitle = 'Theme & Logo'|trans({}, 'Admin.Navigation.Menu') ~ ' > ' ~ 'Theme'|trans({}, 'Admin.Design.Feature') %} -{% set layoutHeaderToolbarBtn = { - 'add': { - 'href': path('admin_themes_import'), - 'desc': 'Add new theme'|trans({}, 'Admin.Design.Feature'), - 'icon': 'add' - }, - 'export': { - 'href': path('admin_themes_export_current'), - 'desc': 'Export current theme'|trans({}, 'Admin.Design.Feature'), - 'icon': 'cloud_download' - } -} %} - -{% block content %} -
    -
    - {{ form_errors(importThemeForm) }} - {{ form_start(importThemeForm) }} -
    -
    -
    -

    - file_copy - {{ 'Import from your computer'|trans({}, 'Admin.Design.Feature') }} -

    -
    -
    - {{ ps.form_group_row(importThemeForm.import_from_computer, {}, { - label: 'Zip file'|trans({}, 'Admin.Design.Feature'), - help: 'Browse your computer files and select the Zip file for your new theme.'|trans({}, 'Admin.Design.Help') - }) }} -
    -
    - -
    -
    - -
    -
    -

    - file_copy - {{ 'Import from the web'|trans({}, 'Admin.Design.Feature') }} -

    -
    -
    - {{ ps.form_group_row(importThemeForm.import_from_web, {}, { - label: 'Archive URL'|trans({}, 'Admin.Design.Feature'), - help: 'Indicate the complete URL to an online Zip file that contains your new theme. For instance, "http://example.com/files/theme.zip".'|trans({}, 'Admin.Design.Help') - }) }} -
    -
    - -
    -
    - -
    -
    -

    - file_copy - {{ 'Import from FTP'|trans({}, 'Admin.Design.Feature') }} -

    -
    -
    - {{ ps.form_group_row(importThemeForm.import_from_ftp, {}, { - label: 'Select the archive'|trans({}, 'Admin.Design.Feature'), - help: 'This selector lists the Zip files that you uploaded in the \'/themes\' folder.'|trans({}, 'Admin.Design.Help') - }) }} -
    -
    - -
    -
    -
    - - {% block import_theme_form_rest %} - {{ form_rest(importThemeForm) }} - {% endblock %} - - {{ form_end(importThemeForm) }} -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/index.html.twig deleted file mode 100644 index 172eee67..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/Theme/index.html.twig +++ /dev/null @@ -1,171 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% set layoutTitle = 'Theme & Logo'|trans({}, 'Admin.Navigation.Menu') ~ ' > ' ~ 'Theme'|trans({}, 'Admin.Design.Feature') %} -{% set layoutHeaderToolbarBtn = { - 'add': { - 'href': path('admin_themes_import'), - 'desc': 'Add new theme'|trans({}, 'Admin.Design.Feature'), - 'icon': 'add' - }, - 'export': { - 'href': path('admin_themes_export_current'), - 'desc': 'Export current theme'|trans({}, 'Admin.Design.Feature'), - 'icon': 'cloud_download' - } - } %} - -{% block content %} -
    -
    -
    - - {% if not isSingleShopContext %} -
    -

    - {{ 'You must select a shop from the above list if you wish to choose a theme.'|trans({}, 'Admin.Design.Help') }} -

    -
    - {% endif %} - - {% if isInstalledRtlLanguage %} - {% include '@PrestaShop/Admin/Improve/Design/Theme/Blocks/rtl_configuration.html.twig' %} - {% endif %} - - {{ form_start(shopLogosForm.shop_logos, {'action': path('admin_themes_upload_logos')}) }} - {% if not isInstalledRtlLanguage and isSingleShopContext and isMultiShopFeatureUsed %} - {% include '@PrestaShop/Admin/Improve/Design/Theme/Blocks/multishop_switch.html.twig' %} - {% endif %} -
    -
    - {{ 'Logo'|trans({}, 'Admin.Global') }} -
    -
    - {% include '@PrestaShop/Admin/Improve/Design/Theme/Blocks/logo_configuration.html.twig' %} -
    - -
    - {{ form_rest(shopLogosForm.shop_logos) }} - {{ form_end(shopLogosForm.shop_logos) }} - -
    -
    - {{ 'My theme for %name% shop'|trans({'%name%': shopName}, 'Admin.Design.Feature') }} -
    -
    - - {% embed '@PrestaShop/Admin/Improve/Design/Theme/Blocks/Partials/theme_card.html.twig' with { - 'themeName': currentlyUsedTheme.get('display_name'), - 'themeVersion': currentlyUsedTheme.get('version'), - 'themeAuthor': currentlyUsedTheme.get('author.name'), - 'themeAuthorUrl': theme.get('author.url'), - 'isActive': true - } %} - {% block image %} - {{ currentlyUsedTheme.get('display_name')   }} - {% endblock %} - {% block button_container %} - - {% endblock %} - {% endembed %} - - {% if notUsedThemes is not empty %} - {% for theme in notUsedThemes %} - {% embed '@PrestaShop/Admin/Improve/Design/Theme/Blocks/Partials/theme_card.html.twig' with { - 'themeName': theme.get('display_name'), - 'themeVersion': theme.get('version'), - 'themeAuthor': theme.get('author.name'), - 'themeAuthorUrl': theme.get('author.url'), - 'isActive': false - } %} - {% block image %} - {{ theme.get('display_name') }} - {% endblock %} - {% block button_container %} -
    - - -
    -
    - - -
    - {% endblock %} - {% endembed %} - {% endfor %} - - {% include '@PrestaShop/Admin/Improve/Design/Theme/Blocks/use_theme_modal.html.twig' %} - {% include '@PrestaShop/Admin/Improve/Design/Theme/Blocks/delete_theme_modal.html.twig' %} - {% endif %} - - {% embed '@PrestaShop/Admin/Improve/Design/Theme/Blocks/Partials/theme_catalog_card.html.twig' %} - {% block image %} - {{ 'Visit the theme catalog'|trans({}, 'Admin.Design.Feature') }} - {% endblock %} - - {% block description %} - {{ 'Explore more than a thousand themes'|trans({}, 'Admin.Design.Feature') }} - {% endblock %} - - {% block button_container %} - - {{ 'Visit the theme catalog'|trans({}, 'Admin.Design.Feature') }} - - {% endblock %} - - {% endembed %} - - {% include '@PrestaShop/Admin/Improve/Design/Theme/Blocks/layouts_configuration.html.twig' %} -
    -
    -
    -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/ThemesCatalogPage/addons_store.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/ThemesCatalogPage/addons_store.html.twig deleted file mode 100644 index 19eeadbb..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/ThemesCatalogPage/addons_store.html.twig +++ /dev/null @@ -1,29 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} - {{ pageContent|raw }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/positions.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/positions.html.twig deleted file mode 100644 index c08814c6..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Design/positions.html.twig +++ /dev/null @@ -1,214 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain "Admin.Design.Feature" %} - -{% block content %} -
    - {% if not canMove %} -

    - {{ 'If you want to order/move the following data, please select a shop from the shop list.' | trans({}, 'Admin.Design.Notification') }} -

    - {% endif %} - -
    -
    -
    -
    -
    -
    -
    - -
    - -
    -
    - -
    - -
    -
    -
    - search -
    -
    - -
    -
    -
    -
    - -
    -
    -
    -

    - -

    -
    -
    -
    -
    -
    - -
    - {% for hook in hooks %} - - {% endfor %} - -
    - -
    -
    -
    -
    - -
    -
    -

    checked {{ 'Selection' | trans({}, 'Admin.Global') }}

    -
    -

    - {{ '1 module selected' | trans }} - - {{ 'modules selected' | trans({}, 'Admin.Design.Feature') }} - -

    -
    - -
    -
    -
    -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Currency/Blocks/exchange_rates.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Currency/Blocks/exchange_rates.html.twig deleted file mode 100644 index c2707c7d..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Currency/Blocks/exchange_rates.html.twig +++ /dev/null @@ -1,69 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{{ form_start(exchangeRatesForm, {'action': path('admin_currencies_refresh_exchange_rates') }) }} -
    -

    - {{ 'Exchange rate'|trans({}, 'Admin.International.Feature') }} -

    -
    -
    -
    - -
    - {{ form_widget(exchangeRatesForm.live_exchange_rate, {'attr': {'class': 'js-live-exchange-rate', 'data-url': path('admin_currencies_update_live_exchange_rates')}}) }} - - {% if exchangeRatesForm.live_exchange_rate.vars.disabled %} - - {{ 'Please install the %module_name% module before using this feature.'|trans({'%module_name%': 'cronjobs'}, 'Admin.International.Notification') }} - - {% else %} - - {{ 'The exchange rates are not automatically updated'|trans({}, 'Admin.International.Feature') }} - - - {{ 'The exchange rates are automatically updated'|trans({}, 'Admin.International.Feature') }} - - {% endif %} -
    -
    -
    - -
    - -
    -
    - {% block currency_settings %} - {{ form_rest(exchangeRatesForm) }} - {% endblock %} -
    -
    -
    -{{ form_end(exchangeRatesForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Currency/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Currency/Blocks/form.html.twig deleted file mode 100644 index 846d41df..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Currency/Blocks/form.html.twig +++ /dev/null @@ -1,159 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block form %} - {{ form_start(currencyForm, { - 'attr': { - 'id': 'currency_form', - 'data-reference-url': path('admin_currencies_get_reference_data', {'currencyIsoCode': 'CURRENCY_ISO_CODE'})|replace({'/CURRENCY_ISO_CODE': '{/id}'}), - 'data-languages': languages|json_encode|replace("'", "'")|raw, - 'data-translations': { - 'step.symbol': '1. Enter symbol'|trans({}, 'Admin.International.Feature'), - 'step.format': '2. Choose format'|trans({}, 'Admin.International.Feature'), - 'modal.title': 'Customize symbol and format'|trans({}, 'Admin.International.Feature'), - 'modal.apply': 'Apply'|trans({}, 'Admin.Actions'), - 'modal.cancel': 'Cancel'|trans({}, 'Admin.Actions'), - 'modal.close': 'Close'|trans({}, 'Admin.Actions'), - 'list.language': 'Language'|trans({}, 'Admin.Global'), - 'list.example': 'Example'|trans({}, 'Admin.Global'), - 'list.edit': 'Edit symbol / format'|trans({}, 'Admin.International.Feature'), - 'list.reset': 'Reset'|trans({}, 'Admin.Actions'), - 'list.reset.success': 'Your symbol and format customizations have been successfully reset for this language.'|trans({}, 'Admin.Notifications.Success'), - 'list.example.format': '%price%'|trans({}, 'Admin.International.Feature'), - 'modal.restore.title': 'Are you sure you want to restore default settings?'|trans({}, 'Admin.International.Feature'), - 'modal.restore.apply': 'Restore'|trans({}, 'Admin.Actions'), - 'modal.restore.cancel': 'Cancel'|trans({}, 'Admin.Actions'), - 'modal.restore.body': 'Restoring your currency\'s default settings will delete all the customizations you made before. Parameters will look just the same as when the currency is freshly imported.'|trans({}, 'Admin.International.Feature') - }|json_encode|replace("'", "'")|raw - } - }) }} - -
    -
    - {{ 'Currencies'|trans({}, 'Admin.Global') }} -
    -
    -
    - {{ form_errors(currencyForm) }} - - {% if not currencyForm.vars.data.id is defined %} - {% set selectIsoCodeHelp %} - {{ 'By default, PrestaShop comes with a list of official currencies. If you want to use a local currency, you will have to add it manually. For example, to accept the Iranian Toman on your store, you need to create it before.'|trans({}, 'Admin.International.Help') }} - {% endset %} - {{ ps.form_group_row(currencyForm.selected_iso_code, {}, { - 'label': 'Select a currency'|trans({}, 'Admin.International.Feature'), - 'help': selectIsoCodeHelp - }) }} - - {{ ps.form_group_row(currencyForm.unofficial, {}, { - 'label': 'or'|trans({}, 'Admin.Global'), - }) }} - {% endif %} - - {{ ps.form_group_row(currencyForm.names, {}, { - 'label': 'Currency name'|trans({}, 'Admin.International.Feature'), - }) }} - - {% set symbolsClass = currencyForm.symbols.vars.errors|length ? '' : 'd-none' %} - {{ ps.form_group_row(currencyForm.symbols, {}, { - 'label': 'Symbol'|trans({}, 'Admin.International.Feature'), - 'class': symbolsClass - }) }} - - {{ ps.form_group_row(currencyForm.iso_code, {}, { - 'label': 'ISO code'|trans({}, 'Admin.International.Feature'), - 'help': 'ISO 4217 code (e.g. USD for Dollars, EUR for Euros, etc.)'|trans({}, 'Admin.International.Help') - }) }} - - {% set exchangeRateHelp %} - {{ 'Exchange rates are calculated from one unit of your shop\'s default currency. For example, if the default currency is euros and your chosen currency is dollars, type "1.20" (1€ = $1.20).'|trans({}, 'Admin.International.Help') }} - {% endset %} - - {{ ps.form_group_row(currencyForm.exchange_rate, {}, { - 'label': 'Exchange rate'|trans({}, 'Admin.International.Feature'), - 'help': exchangeRateHelp - }) }} - - {{ ps.form_group_row(currencyForm.precision, {}, { - 'label': 'Decimals'|trans({}, 'Admin.International.Feature') - }) }} - - {{ ps.form_group_row(currencyForm.active, {}, { - 'label': 'Status'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(currencyForm.transformations, {}, {'class': 'd-none'}) }} - - {% if isShopFeatureEnabled %} - {{ ps.form_group_row(currencyForm.shop_association, {}, { - 'label': 'Shop association'|trans({}, 'Admin.Global'), - }) }} - {% endif %} - - {% block currency_form_rest %} - {{ form_rest(currencyForm) }} - {% endblock %} -
    -
    - - - -
    - {{ form_end(currencyForm) }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Currency/create.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Currency/create.html.twig deleted file mode 100644 index 33930256..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Currency/create.html.twig +++ /dev/null @@ -1,39 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {{ include('@PrestaShop/Admin/Improve/International/Currency/Blocks/form.html.twig', {'currencyForm': currencyForm, 'languages': []}) }} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Currency/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Currency/edit.html.twig deleted file mode 100644 index 7ee12b6e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Currency/edit.html.twig +++ /dev/null @@ -1,39 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {{ include('@PrestaShop/Admin/Improve/International/Currency/Blocks/form.html.twig', {'currencyForm': currencyForm, 'languages': languages}) }} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Currency/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Currency/index.html.twig deleted file mode 100644 index dc2970c5..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Currency/index.html.twig +++ /dev/null @@ -1,60 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% set layoutHeaderToolbarBtn = { - add: { - href: path('admin_currencies_create'), - desc: 'Add new currency'|trans({}, 'Admin.International.Feature'), - icon: 'add_circle_outline', - } -} -%} - -{% block content %} - -
    -
    - {{ include('@PrestaShop/Admin/Common/Grid/grid_panel.html.twig', {'grid': currencyGrid }) }} -
    -
    - - {% block exchange_rates_block %} -
    -
    - {{ include('@PrestaShop/Admin/Improve/International/Currency/Blocks/exchange_rates.html.twig', {'exchangeRatesForm': currencySettingsForm.exchange_rates}) }} -
    -
    - {% endblock %} - -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Geolocation/Blocks/geolocation_by_ip_address.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Geolocation/Blocks/geolocation_by_ip_address.html.twig deleted file mode 100644 index 0bd94fe6..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Geolocation/Blocks/geolocation_by_ip_address.html.twig +++ /dev/null @@ -1,53 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.International.Feature' %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block geolocation_by_ip_address %} -
    -

    - {{ 'Geolocation by IP address'|trans }} -

    -
    -
    -
    - {{ ps.label_with_help(('Geolocation by IP address'|trans), ('This option allows you, among other things, to restrict access to your shop for certain countries. See below.'|trans({}, 'Admin.International.Help'))) }} -
    - {{ form_errors(geolocationByIpAddressForm.geolocation_enabled) }} - {{ form_widget(geolocationByIpAddressForm.geolocation_enabled) }} -
    -
    -
    -
    - -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Geolocation/Blocks/geolocation_ip_address_whitelist.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Geolocation/Blocks/geolocation_ip_address_whitelist.html.twig deleted file mode 100644 index 5ea0b4d6..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Geolocation/Blocks/geolocation_ip_address_whitelist.html.twig +++ /dev/null @@ -1,64 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.International.Feature' %} - -{% block geolocation_ip_address_whitelist %} -
    -

    - {{ 'IP address whitelist'|trans }} -

    -
    -
    -
    -
    - -
    -
    - -
    - -
    - {{ form_errors(geolocationIpAddressWhitelistForm.geolocation_whitelist) }} - {{ form_widget(geolocationIpAddressWhitelistForm.geolocation_whitelist) }} -
    -
    -
    -
    - -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Geolocation/Blocks/geolocation_options.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Geolocation/Blocks/geolocation_options.html.twig deleted file mode 100644 index 16fb1e9a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Geolocation/Blocks/geolocation_options.html.twig +++ /dev/null @@ -1,87 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.International.Feature' %} - -{% block geolocation_options %} -
    -

    - {{ 'Options'|trans({}, 'Admin.Global') }} -

    -
    -
    -
    -
    - -
    -
    - -
    - -
    - {{ form_errors(geolocationOptionsForm.geolocation_behaviour) }} - {{ form_widget(geolocationOptionsForm.geolocation_behaviour) }} -
    -
    - -
    - -
    - {{ form_errors(geolocationOptionsForm.geolocation_na_behaviour) }} - {{ form_widget(geolocationOptionsForm.geolocation_na_behaviour) }} -
    -
    - -
    - - -
    -
    - {{ form_errors(geolocationOptionsForm.geolocation_countries) }} - {{ form_widget(geolocationOptionsForm.geolocation_countries) }} -
    -
    -
    -
    -
    - -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Geolocation/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Geolocation/index.html.twig deleted file mode 100644 index 774baf8a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Geolocation/index.html.twig +++ /dev/null @@ -1,69 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain 'Admin.International.Feature' %} - -{% set geolocationByIpAddressForm, geolocationIpAddressWhitelistForm, geolocationOptionsForm = geolocationForm.geolocation_by_id_address, geolocationForm.geolocation_ip_address_whitelist, geolocationForm.geolocation_options %} - -{% block content %} - {% if not geolocationDatabaseAvailable %} -
    -
    - -
    -
    - {% endif %} - - {{ form_start(geolocationForm, {'action': path('admin_geolocation_save_options')}) }} -
    -
    - {% include '@PrestaShop/Admin/Improve/International/Geolocation/Blocks/geolocation_by_ip_address.html.twig' %} -
    - -
    - {% include '@PrestaShop/Admin/Improve/International/Geolocation/Blocks/geolocation_options.html.twig' %} -
    - -
    - {% include '@PrestaShop/Admin/Improve/International/Geolocation/Blocks/geolocation_ip_address_whitelist.html.twig' %} -
    -
    - - {% block geolocation_form_rest %} - {{ form_rest(geolocationForm) }} - {% endblock %} - {{ form_end(geolocationForm) }} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Language/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Language/Blocks/form.html.twig deleted file mode 100644 index c0ca0369..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Language/Blocks/form.html.twig +++ /dev/null @@ -1,110 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{{ form_start(languageForm) }} -
    -

    - language - {{ 'Languages'|trans({}, 'Admin.Global') }} -

    -
    -
    - {{ form_errors(languageForm) }} - - {{ ps.form_group_row(languageForm.name, {}, { - 'label': 'Name'|trans({}, 'Admin.Global') - }) }} - - {{ ps.form_group_row(languageForm.iso_code, { - 'attr': { - 'maxlength': 2 - } - }, { - 'label': 'ISO code'|trans({}, 'Admin.International.Feature'), - 'help': 'Two-letter ISO code (e.g. FR, EN, DE).'|trans({}, 'Admin.International.Help') - }) }} - - {{ ps.form_group_row(languageForm.tag_ietf, { - 'attr': { - 'maxlength': 5 - } - }, { - 'label': 'Language code'|trans({}, 'Admin.International.Feature'), - 'help': 'IETF language tag (e.g. en-US, pt-BR).'|trans({}, 'Admin.International.Help') - }) }} - - {{ ps.form_group_row(languageForm.short_date_format, {}, { - 'label': 'Date format'|trans({}, 'Admin.International.Feature'), - 'help': 'Short date format (e.g., Y-m-d).'|trans({}, 'Admin.International.Help') - }) }} - - {{ ps.form_group_row(languageForm.full_date_format, {}, { - 'label': 'Date format (full)'|trans({}, 'Admin.International.Feature'), - 'help': 'Full date format (e.g., Y-m-d H:i:s).'|trans({}, 'Admin.International.Help') - }) }} - - {{ ps.form_group_row(languageForm.flag_image, {}, { - 'label': 'Flag'|trans({}, 'Admin.International.Feature'), - 'help': 'Upload the country flag from your computer.'|trans({}, 'Admin.International.Help') - }) }} - - {{ ps.form_group_row(languageForm.no_picture_image, {}, { - 'label': '"No-picture" image'|trans({}, 'Admin.International.Feature'), - 'help': 'Image is displayed when "no picture is found".'|trans({}, 'Admin.International.Help') - }) }} - - {{ ps.form_group_row(languageForm.is_rtl, {}, { - 'label': 'Is RTL language'|trans({}, 'Admin.International.Feature'), - 'help': 'Enable if this language is read from right to left.'|trans({}, 'Admin.International.Help') ~ '(Experimental: your theme must be compliant with RTL languages).'|trans({}, 'Admin.International.Help') - }) }} - - {{ ps.form_group_row(languageForm.is_active, {}, { - 'label': 'Status'|trans({}, 'Admin.Global'), - 'help': 'Activate this language.'|trans({}, 'Admin.International.Feature') - }) }} - - {% if languageForm.shop_association is defined %} - {{ ps.form_group_row(languageForm.shop_association, {}, { - 'label': 'Shop association'|trans({}, 'Admin.Global') - }) }} - {% endif %} - - {% block language_form_rest %} - {{ form_rest(languageForm) }} - {% endblock %} -
    -
    -
    -
    -{{ form_end(languageForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Language/create.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Language/create.html.twig deleted file mode 100644 index 68224a6f..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Language/create.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% set layoutTitle = 'Add new'|trans({}, 'Admin.Actions') %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Improve/International/Language/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Language/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Language/edit.html.twig deleted file mode 100644 index 75d877ef..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Language/edit.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% set layoutTitle = 'Edit: %value%'|trans({'%value%': editableLanguage.name}, 'Admin.Catalog.Feature') %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Improve/International/Language/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Language/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Language/index.html.twig deleted file mode 100644 index 0c5e8aa9..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Language/index.html.twig +++ /dev/null @@ -1,67 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set layoutHeaderToolbarBtn = { - 'add' : { - 'href': path('admin_languages_create'), - 'desc': 'Add new language'|trans({}, 'Admin.International.Feature'), - 'icon': 'add_circle_outline' - } -} %} -{% set layoutTitle = 'Languages'|trans({}, 'Admin.Global') %} -{% set enableSidebar = true %} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - - - {% if not isHtaccessFileWriter %} - - {% endif %} -
    -
    - - {% block language_listing %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with { 'grid': languageGrid } %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Localization/Blocks/advanced_configuration.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Localization/Blocks/advanced_configuration.html.twig deleted file mode 100644 index 263da7cc..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Localization/Blocks/advanced_configuration.html.twig +++ /dev/null @@ -1,61 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.International.Feature' %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block localization_advanced_configuration %} -
    -

    - settings {{ 'Advanced'|trans({}, 'Admin.Global') }} -

    - -
    -
    -
    - {{ ps.label_with_help(('Language identifier'|trans), ('The ISO 639-1 identifier for the language of the country where your web server is located (en, fr, sp, ru, pl, nl, etc.).'|trans({}, 'Admin.International.Help'))) }} -
    - {{ form_errors(advancedForm.language_identifier) }} - {{ form_widget(advancedForm.language_identifier) }} -
    -
    - -
    - {{ ps.label_with_help(('Country identifier'|trans), ('The ISO 3166-1 alpha-2 identifier for the country/region where your web server is located, in lowercase (us, gb, fr, sp, ru, pl, nl, etc.).'|trans({}, 'Admin.International.Help'))) }} -
    - {{ form_errors(advancedForm.country_identifier) }} - {{ form_widget(advancedForm.country_identifier) }} -
    -
    -
    -
    - - -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Localization/Blocks/configuration.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Localization/Blocks/configuration.html.twig deleted file mode 100644 index 598536cf..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Localization/Blocks/configuration.html.twig +++ /dev/null @@ -1,103 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.International.Feature' %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block localization_configuration %} -
    -

    - settings {{ 'Configuration'|trans({}, 'Admin.Global') }} -

    - -
    -
    -
    - {{ ps.label_with_help(('Default language'|trans), ('The default language used in your shop.'|trans({}, 'Admin.International.Help'))) }} -
    - {{ form_errors(configurationForm.default_language) }} - {{ form_widget(configurationForm.default_language, {'attr': {'data-minimumResultsForSearch': '7', 'data-toggle': 'select2'}}) }} -
    -
    - -
    - -
    - {{ form_errors(configurationForm.detect_language_from_browser) }} - {{ form_widget(configurationForm.detect_language_from_browser) }} - {{ 'Set browser language as default language'|trans({}, 'Admin.International.Help') }} -
    -
    - -
    - {{ ps.label_with_help(('Default country'|trans), ('The default country used in your shop.'|trans({}, 'Admin.International.Help'))) }} -
    - {{ form_errors(configurationForm.default_country) }} - {{ form_widget(configurationForm.default_country, {'attr': {'data-minimumResultsForSearch': '7', 'data-toggle': 'select2'}}) }} -
    -
    - -
    - -
    - {{ form_errors(configurationForm.detect_country_from_browser) }} - {{ form_widget(configurationForm.detect_country_from_browser) }} - {{ 'Set country corresponding to browser language'|trans({}, 'Admin.International.Help') }} -
    -
    - -
    - {% set currencyChangeWarningMessage = 'Before changing the default currency, we strongly recommend that you enable maintenance mode. Indeed, any change on the default currency requires a manual adjustment of the price of each product and its combinations.'|trans({}, 'Admin.International.Notification') %} - - {{ ps.label_with_help(('Default currency'|trans), ('The default currency used in your shop.'|trans({}, 'Admin.International.Help'))) }} -
    - {{ form_errors(configurationForm.default_currency) }} - {{ form_widget(configurationForm.default_currency, {'attr': {'data-warning-message': currencyChangeWarningMessage, 'data-minimumResultsForSearch': '7', 'data-toggle': 'select2'}}) }} -
    -
    - -
    - -
    - {{ form_errors(configurationForm.timezone) }} - {{ form_widget(configurationForm.timezone, {'attr': {'data-minimumResultsForSearch': '7', 'data-toggle': 'select2'}}) }} -
    -
    -
    -
    - - -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Localization/Blocks/import_localization_pack_block.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Localization/Blocks/import_localization_pack_block.html.twig deleted file mode 100644 index c41cec50..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Localization/Blocks/import_localization_pack_block.html.twig +++ /dev/null @@ -1,80 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.International.Feature' %} - -{% block import_localization_pack %} - {{ form_start(localizationPackImportForm, {'action': path('admin_localization_import_pack')}) }} -
    -

    - language {{ 'Import a localization pack'|trans }} -

    - -
    -
    -
    - -
    - {{ form_errors(localizationPackImportForm.iso_localization_pack) }} - {{ form_widget(localizationPackImportForm.iso_localization_pack, {'attr': {'data-minimumResultsForSearch': '7', 'data-toggle': 'select2'}}) }} -
    -
    - -
    - -
    - {{ form_errors(localizationPackImportForm.content_to_import) }} - {{ form_widget(localizationPackImportForm.content_to_import) }} -
    -
    - -
    - -
    - {{ form_errors(localizationPackImportForm.download_pack_data) }} - {{ form_widget(localizationPackImportForm.download_pack_data) }} - {{ 'If set to yes then the localization pack will be downloaded from prestashop.com. Otherwise the local xml file found in the localization folder of your PrestaShop installation will be used.'|trans({}, 'Admin.International.Help') }} -
    -
    -
    -
    - - -
    - {{ form_end(localizationPackImportForm) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Localization/Blocks/local_units.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Localization/Blocks/local_units.html.twig deleted file mode 100644 index fc4b393b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Localization/Blocks/local_units.html.twig +++ /dev/null @@ -1,77 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.International.Feature' %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block localization_local_units %} -
    -

    - language {{ 'Local units'|trans }} -

    - -
    -
    -
    - {{ ps.label_with_help(('Weight unit'|trans), ('The default weight unit for your shop (e.g. "kg" for kilograms, "lbs" for pound-mass, etc.).'|trans({}, 'Admin.International.Help'))) }} -
    - {{ form_errors(localUnitsForm.weight_unit) }} - {{ form_widget(localUnitsForm.weight_unit) }} -
    -
    - -
    - {{ ps.label_with_help(('Distance unit'|trans), ('The default distance unit for your shop (e.g. "km" for kilometer, "mi" for mile, etc.).'|trans({}, 'Admin.International.Help'))) }} -
    - {{ form_errors(localUnitsForm.distance_unit) }} - {{ form_widget(localUnitsForm.distance_unit) }} -
    -
    - -
    - {{ ps.label_with_help(('Volume unit'|trans), ('The default volume unit for your shop (e.g. "L" for liter, "gal" for gallon, etc.).'|trans({}, 'Admin.International.Help'))) }} -
    - {{ form_errors(localUnitsForm.volume_unit) }} - {{ form_widget(localUnitsForm.volume_unit) }} -
    -
    - -
    - {{ ps.label_with_help(('Dimension unit'|trans), ('The default dimension unit for your shop (e.g. "cm" for centimeter, "in" for inch, etc.).'|trans({}, 'Admin.International.Help'))) }} -
    - {{ form_errors(localUnitsForm.dimension_unit) }} - {{ form_widget(localUnitsForm.dimension_unit) }} -
    -
    -
    -
    - - -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Localization/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Localization/index.html.twig deleted file mode 100644 index 23ea5fd3..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Localization/index.html.twig +++ /dev/null @@ -1,62 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain 'Admin.International.Feature' %} - -{% set configurationForm, localUnitsForm, advancedForm = localizationForm.configuration, localizationForm.local_units, localizationForm.advanced %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Improve/International/Localization/Blocks/import_localization_pack_block.html.twig' %} -
    -
    - - {{ form_start(localizationForm, {'action': path('admin_localization_save_options')}) }} -
    -
    - {% include '@PrestaShop/Admin/Improve/International/Localization/Blocks/configuration.html.twig' %} -
    -
    - {% include '@PrestaShop/Admin/Improve/International/Localization/Blocks/local_units.html.twig' %} -
    -
    - {% include '@PrestaShop/Admin/Improve/International/Localization/Blocks/advanced_configuration.html.twig' %} -
    -
    - - {% block localization_settings_form_rest %} - {{ form_rest(localizationForm) }} - {% endblock %} - - {{ form_end(localizationForm) }} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Tax/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Tax/Blocks/form.html.twig deleted file mode 100644 index a1271a83..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Tax/Blocks/form.html.twig +++ /dev/null @@ -1,79 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{{ form_start(taxForm) }} -
    -
    - {{ 'Taxes'|trans({}, 'Admin.Global') }} -
    - -
    -
    - {{ form_errors(taxForm) }} - - {% set nameHint %} - {{ 'Tax name to display in carts and on invoices (e.g. "VAT").'|trans({}, 'Admin.International.Help') }} - {{ 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>;=#{}' }} - {% endset %} - - {{ ps.form_group_row(taxForm.name, {}, { - 'label': 'Name'|trans({}, 'Admin.Global'), - 'help': nameHint, - }) }} - - {% set rateHint %} - {{ 'Format: XX.XX or XX.XXX (e.g. 19.60 or 13.925)'|trans({}, 'Admin.International.Help') }} - {% endset %} - - {{ ps.form_group_row(taxForm.rate, {}, { - 'label': 'Rate'|trans({}, 'Admin.International.Feature'), - 'help': rateHint, - }) }} - - {{ ps.form_group_row(taxForm.is_enabled, {}, { - 'label': 'Enable'|trans({}, 'Admin.Actions') - }) }} - - {% block tax_form_rest %} - {{ form_rest(taxForm) }} - {% endblock %} -
    -
    - - - -
    -{{ form_end(taxForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Tax/Blocks/tax_options.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Tax/Blocks/tax_options.html.twig deleted file mode 100644 index 75fce382..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Tax/Blocks/tax_options.html.twig +++ /dev/null @@ -1,98 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{{ form_start(taxOptionsForm, {'action': path('admin_taxes_save_options')}) }} -
    -

    - {{ 'Tax options'|trans({}, 'Admin.International.Feature') }} -

    -
    -
    -
    - -
    - {{ form_widget(taxOptionsForm.options.enable_tax, {'attr': {'class': 'js-enable-tax'}}) }} - - {{ 'Select whether or not to include tax on purchases.'|trans({}, 'Admin.International.Help') }} - -
    -
    -
    - -
    - {{ form_widget(taxOptionsForm.options.display_tax_in_cart, {'attr': {'class': 'js-display-in-cart'}}) }} - - {{ 'Select whether or not to display tax on a distinct line in the cart.'|trans({}, 'Admin.International.Help') }} - -
    -
    -
    - -
    - {{ form_widget(taxOptionsForm.options.tax_address_type) }} -
    -
    -
    - -
    - {{ form_widget(taxOptionsForm.options.use_eco_tax) }} - {% if (taxOptionsForm.options.use_eco_tax.vars.value != 0) %} - - {{ 'If you disable the ecotax, the ecotax for all your products will be set to 0.'|trans({}, 'Admin.International.Help') }} - - {% endif %} -
    -
    - {% if taxOptionsForm.options.eco_tax_rule_group is defined %} - {{ ps.form_group_row(taxOptionsForm.options.eco_tax_rule_group, {}, { - label: 'Ecotax'|trans({}, 'Admin.International.Feature'), - help: 'Define the ecotax (e.g. French ecotax: 19.6%).'|trans({}, 'Admin.International.Help') - }) }} - {% endif %} - - {% block tax_options_rest %} - {{ form_rest(taxOptionsForm) }} - {% endblock %} -
    -
    - -
    -{{ form_end(taxOptionsForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Tax/create.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Tax/create.html.twig deleted file mode 100644 index 266b02c4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Tax/create.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {{ include('@PrestaShop/Admin/Improve/International/Tax/Blocks/form.html.twig', {'taxForm': taxForm}) }} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Tax/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Tax/edit.html.twig deleted file mode 100644 index bd2e280f..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Tax/edit.html.twig +++ /dev/null @@ -1,42 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% set layoutTitle = 'Edit: %value%'|trans({'%value%': taxName}, 'Admin.Actions') %} - -{% block content %} -
    -
    - {{ include('@PrestaShop/Admin/Improve/International/Tax/Blocks/form.html.twig', {'taxForm': taxForm}) }} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Tax/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Tax/index.html.twig deleted file mode 100644 index b372c346..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Tax/index.html.twig +++ /dev/null @@ -1,52 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set layoutHeaderToolbarBtn = { - 'add' : { - 'href': path('admin_taxes_create'), - 'desc': 'Add new tax'|trans({}, 'Admin.International.Feature'), - 'icon': 'add_circle_outline' - } -} %} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% trans_default_domain 'Admin.International.Feature' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': taxGrid} %} - {% include '@PrestaShop/Admin/Improve/International/Tax/Blocks/tax_options.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/TaxRulesGroup/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/TaxRulesGroup/index.html.twig deleted file mode 100644 index 020c659e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/TaxRulesGroup/index.html.twig +++ /dev/null @@ -1,41 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': taxRulesGroupGrid} %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Translations/Blocks/add_update_language.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Translations/Blocks/add_update_language.html.twig deleted file mode 100644 index 24ec7abc..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Translations/Blocks/add_update_language.html.twig +++ /dev/null @@ -1,69 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.International.Feature' %} - -{{ form_start(addUpdateLanguageForm, {action: path('admin_international_translations_add_update_language')}) }} - -
    -

    -
    arrow_drop_down_circle
    {{ 'Add / Update a language'|trans }} -

    - -
    -
    -
    -
    - -
    -
    -
    - -
    - {{ form_errors(addUpdateLanguageForm.iso_localization_pack) }} - {{ form_widget(addUpdateLanguageForm.iso_localization_pack, {'attr': {'data-minimumResultsForSearch': '7', 'data-toggle': 'select2'}}) }} -
    -
    - {{ form_rest(addUpdateLanguageForm) }} -
    -
    - - -
    - -{{ form_end(addUpdateLanguageForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Translations/Blocks/copy_language.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Translations/Blocks/copy_language.html.twig deleted file mode 100644 index 546ad6ae..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Translations/Blocks/copy_language.html.twig +++ /dev/null @@ -1,95 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.International.Feature' %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block copy_language %} - {{ form_start(copyLanguageForm, {action: path('admin_international_translations_copy_language')}) }} - -
    -

    - file_copy {{ 'Copy'|trans({}, 'Admin.Actions') }} -

    - -
    -
    -
    -
    - -
    -
    - -
    - -
    -
    - {{ form_errors(copyLanguageForm.from_language) }} - {{ form_widget(copyLanguageForm.from_language) }} - - {{ form_errors(copyLanguageForm.from_theme) }} - {{ form_widget(copyLanguageForm.from_theme) }} -
    -
    -
    - -
    - -
    -
    - {{ form_errors(copyLanguageForm.to_language) }} - {{ form_widget(copyLanguageForm.to_language) }} - - {{ form_errors(copyLanguageForm.to_theme) }} - {{ form_widget(copyLanguageForm.to_theme) }} -
    -
    -
    - {{ form_rest(copyLanguageForm) }} -
    -
    - - -
    - - {{ form_end(copyLanguageForm) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Translations/Blocks/export_language.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Translations/Blocks/export_language.html.twig deleted file mode 100644 index 683951af..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Translations/Blocks/export_language.html.twig +++ /dev/null @@ -1,80 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.International.Feature' %} - -{{ form_start(exportLanguageForm, {action: path('admin_international_translations_export_theme')}) }} - -
    -

    - cloud_upload {{ 'Export a language'|trans }} -

    -
    -
    -
    -
    - -
    -
    - -
    - -
    - {{ form_errors(exportLanguageForm.iso_code) }} - {{ form_widget(exportLanguageForm.iso_code) }} -
    -
    - -
    - -
    - {{ form_errors(exportLanguageForm.theme_name) }} - {{ form_widget(exportLanguageForm.theme_name) }} -
    -
    - {{ form_rest(exportLanguageForm) }} -
    -
    - - -
    - -{{ form_end(exportLanguageForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Translations/Blocks/modify_translations.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Translations/Blocks/modify_translations.html.twig deleted file mode 100644 index 15706aa6..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Translations/Blocks/modify_translations.html.twig +++ /dev/null @@ -1,110 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain 'Admin.International.Feature' %} - -{% block modify_translations %} - {{ form_start(modifyTranslationsForm, {method: 'get', action: path('admin_international_translations_modify')}) }} - -
    -

    - description {{ 'Modify translations'|trans }} -

    - -
    -
    -
    -
    - -
    -
    - -
    - -
    - {{ form_errors(modifyTranslationsForm.translation_type) }} - {{ form_widget(modifyTranslationsForm.translation_type, {'attr': {'class': 'js-translation-type'}}) }} -
    -
    -
    - -
    - {{ form_errors(modifyTranslationsForm.email_content_type) }} - {{ form_widget(modifyTranslationsForm.email_content_type, {'attr': {'class': 'js-email-content-type'}}) }} -
    -
    -
    - -
    - {{ form_errors(modifyTranslationsForm.theme) }} - {{ form_widget(modifyTranslationsForm.theme) }} -
    -
    -
    - -
    - {{ form_errors(modifyTranslationsForm.module) }} - {{ form_widget(modifyTranslationsForm.module, {'attr': {'data-minimumResultsForSearch': '7', 'data-toggle': 'select2'}}) }} -
    -
    -
    - -
    - {{ form_errors(modifyTranslationsForm.language) }} - {{ form_widget(modifyTranslationsForm.language) }} -
    -
    - {{ form_rest(modifyTranslationsForm) }} -
    -
    - - -
    - - {{ form_end(modifyTranslationsForm) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Translations/translations_settings.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Translations/translations_settings.html.twig deleted file mode 100644 index b4b9b2a4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/International/Translations/translations_settings.html.twig +++ /dev/null @@ -1,66 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain 'Admin.International.Feature' %} - -{% block content %} -
    -
    -
    - {% block translations_kpis_row %} -
    - {{ render(controller( - 'PrestaShopBundle:Admin\\Common:renderKpiRow', - { 'kpiRow': kpiRow } - )) }} -
    - {% endblock %} -
    -
    - -
    - {% include '@PrestaShop/Admin/Improve/International/Translations/Blocks/modify_translations.html.twig' %} -
    - -
    - {% include '@PrestaShop/Admin/Improve/International/Translations/Blocks/add_update_language.html.twig' %} -
    - -
    - {% include '@PrestaShop/Admin/Improve/International/Translations/Blocks/export_language.html.twig' %} -
    - -
    - {% include '@PrestaShop/Admin/Improve/International/Translations/Blocks/copy_language.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Module/addons_store.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Module/addons_store.html.twig deleted file mode 100644 index 19eeadbb..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Module/addons_store.html.twig +++ /dev/null @@ -1,29 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} - {{ pageContent|raw }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Payment/PaymentMethods/Blocks/payment_modules_list.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Payment/PaymentMethods/Blocks/payment_modules_list.html.twig deleted file mode 100644 index c6784e76..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Payment/PaymentMethods/Blocks/payment_modules_list.html.twig +++ /dev/null @@ -1,70 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% trans_default_domain 'Admin.Payment.Feature' %} - -{% block payment_methods_module_list %} - {% if paymentModules|length > 0 %} -
    - {% for module in paymentModules %} -
    -
    -
    - {{ module.attributes.displayName }} -
    -
    -
    -

    - {{ module.attributes.displayName|raw }} - - {{ 'v%version% - by %author%'|trans({ '%version%' : module.attributes.version, '%author%' : module.attributes.author}, 'Admin.Modules.Feature') }} - -

    -

    - {{ module.attributes.description|raw }} -

    -
    - {% if module.attributes.is_configurable %} - - {% endif %} -
    - {% endfor %} -
    - {% else %} - - {% endif %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Payment/PaymentMethods/payment_methods.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Payment/PaymentMethods/payment_methods.html.twig deleted file mode 100644 index 8ac67d68..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Payment/PaymentMethods/payment_methods.html.twig +++ /dev/null @@ -1,49 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain 'Admin.Payment.Feature' %} - -{% block content %} -
    -
    -
    - {% if isSingleShopContext %} -
    -

    - credit_card {{ 'Active payment'|trans }} -

    -
    - {% include '@PrestaShop/Admin/Improve/Payment/PaymentMethods/Blocks/payment_modules_list.html.twig' %} -
    -
    - {% else %} - - {% endif %} -
    -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Payment/Preferences/Blocks/payment_preferences_form_block.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Payment/Preferences/Blocks/payment_preferences_form_block.html.twig deleted file mode 100644 index 6b7cffb4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Payment/Preferences/Blocks/payment_preferences_form_block.html.twig +++ /dev/null @@ -1,141 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% trans_default_domain 'Admin.Payment.Feature' %} - -{% block payment_preferences_form %} - {{ form_start(paymentPreferencesForm) }} - {% block payment_modules_currency_restrictions %} -
    -

    - euro_symbol - {{ 'Currency restrictions'|trans({}, 'Admin.Payment.Feature') }} -

    -
    -

    - - {{ 'Please mark each checkbox for the currency, or currencies, for which you want the payment module(s) to be available.'|trans({}, 'Admin.Payment.Help') }} - -

    - -
    - {{ form_widget(paymentPreferencesForm.payment_module_preferences.currency_restrictions) }} -
    -
    - -
    - {% endblock %} - - {% block payment_modules_group_restrictions %} -
    -

    - group - {{ 'Group restrictions'|trans({}, 'Admin.Payment.Feature') }} -

    -
    -

    - - {{ 'Please mark each checkbox for the customer group(s), for which you want the payment module(s) to be available.'|trans({}, 'Admin.Payment.Help') }} - -

    - -
    - {{ form_widget(paymentPreferencesForm.payment_module_preferences.group_restrictions) }} -
    -
    - -
    - {% endblock %} - - {% block payment_modules_country_restrictions %} -
    -

    - public - {{ 'Country restrictions'|trans({}, 'Admin.Payment.Feature') }} -

    -
    -

    - - {{ 'Please mark each checkbox for the country, or countries, in which you want the payment module(s) to be available.'|trans({}, 'Admin.Payment.Help') }} - -

    - -
    - {{ form_widget(paymentPreferencesForm.payment_module_preferences.country_restrictions) }} -
    -
    - -
    - {% endblock %} - - {% block payment_modules_carrier_restrictions %} -
    -

    - local_shipping - {{ 'Carrier restrictions'|trans({}, 'Admin.Payment.Feature') }} -

    -
    -

    - - {{ 'Please mark each checkbox for the carrier, or carrier, for which you want the payment module(s) to be available.'|trans({}, 'Admin.Payment.Help') }} - -

    -
    - {{ form_widget(paymentPreferencesForm.payment_module_preferences.carrier_restrictions) }} -
    -
    - -
    - {% endblock %} - - {% block payment_preferences_block_rest %} - {{ form_rest(paymentPreferencesForm) }} - {% endblock %} - - {{ form_end(paymentPreferencesForm) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Payment/Preferences/payment_preferences.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Payment/Preferences/payment_preferences.html.twig deleted file mode 100644 index bbfefd49..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Payment/Preferences/payment_preferences.html.twig +++ /dev/null @@ -1,66 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain 'Admin.Payment.Feature' %} - -{% block content %} -
    -
    -
    - {% if not isSingleShopContext %} - - {% elseif paymentModulesCount == 0 %} - - {% else %} - - - {% include '@PrestaShop/Admin/Improve/Payment/Preferences/Blocks/payment_preferences_form_block.html.twig' %} - {% endif %} -
    -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Shipping/Preferences/Blocks/shipping_preferences_carrier_options.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Shipping/Preferences/Blocks/shipping_preferences_carrier_options.html.twig deleted file mode 100644 index 06386183..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Shipping/Preferences/Blocks/shipping_preferences_carrier_options.html.twig +++ /dev/null @@ -1,69 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Shipping.Feature" %} - -{% block shipping_preferences_carrier_options %} -
    -
    -

    - local_shipping {{ 'Carrier options'|trans }} -

    -
    -
    -
    - -
    - {{ form_errors(carrierOptionsForm.default_carrier) }} - {{ form_widget(carrierOptionsForm.default_carrier) }} - {{ 'Your shop\'s default carrier'|trans({}, 'Admin.Shipping.Help') }} -
    -
    -
    - -
    - {{ form_errors(carrierOptionsForm.carrier_default_order_by) }} - {{ form_widget(carrierOptionsForm.carrier_default_order_by) }} - {{ 'This will only be visible in the front office.'|trans({}, 'Admin.Shipping.Help') }} -
    -
    -
    - -
    - {{ form_errors(carrierOptionsForm.carrier_default_order_way) }} - {{ form_widget(carrierOptionsForm.carrier_default_order_way) }} - {{ 'This will only be visible in the front office.'|trans({}, 'Admin.Shipping.Help') }} -
    -
    -
    -
    - -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Shipping/Preferences/Blocks/shipping_preferences_handling.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Shipping/Preferences/Blocks/shipping_preferences_handling.html.twig deleted file mode 100644 index 386f27e4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Shipping/Preferences/Blocks/shipping_preferences_handling.html.twig +++ /dev/null @@ -1,83 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Shipping.Feature" %} - -{% block shipping_preferences_handling %} -
    -
    -

    - filter_none {{ 'Handling'|trans }} -

    -
    -
    -
    -
    - -
    -
    - -
    - -
    - {{ form_errors(handlingForm.shipping_handling_charges) }} - {{ form_widget(handlingForm.shipping_handling_charges) }} -
    -
    - -
    - -
    - {{ form_errors(handlingForm.free_shipping_price) }} - {{ form_widget(handlingForm.free_shipping_price) }} -
    -
    - -
    - -
    - {{ form_errors(handlingForm.free_shipping_weight) }} - {{ form_widget(handlingForm.free_shipping_weight) }} -
    -
    -
    -
    - -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Improve/Shipping/Preferences/preferences.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Improve/Shipping/Preferences/preferences.html.twig deleted file mode 100644 index 511b7098..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Improve/Shipping/Preferences/preferences.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% set handlingForm, carrierOptionsForm = form.handling, form.carrier_options %} - -{% block content %} - {{ form_start(form, {'attr': {'class': 'form', 'id': 'configuration_form'}}) }} -
    - {# Block for "Handling" fieldset #} - {% include '@PrestaShop/Admin/Improve/Shipping/Preferences/Blocks/shipping_preferences_handling.html.twig' %} - - {# Block for "Carrier options" fieldset #} - {% include '@PrestaShop/Admin/Improve/Shipping/Preferences/Blocks/shipping_preferences_carrier_options.html.twig' %} -
    - {{ form_end(form) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/action_button.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/action_button.html.twig deleted file mode 100644 index 1ec4af37..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/action_button.html.twig +++ /dev/null @@ -1,42 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set displayAction = action|title|replace({'_': " "})|trans({}, transDomain[action]) %} - -{% if (action == 'configure') %} - - - {{ displayAction }} - - -{% else %} - -
    - -
    - -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/action_menu.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/action_menu.html.twig deleted file mode 100644 index 5646edc0..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/action_menu.html.twig +++ /dev/null @@ -1,71 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% set url, priceRaw, priceDisplay, url_active, urls, name, transDomains = - module.attributes.url, - module.attributes.price.raw, - module.attributes.price.displayPrice, - module.attributes.url_active, - module.attributes.urls, - module.attributes.name, - module.attributes.actionTranslationDomains -%} -
    - {% if url_active == 'buy' %} - - {{ 'Discover'|trans({}, 'Admin.Modules.Feature') }} - - {% elseif urls|length %} - {% include '@PrestaShop/Admin/Module/Includes/action_button.html.twig' with { - 'name': name, - 'classes_form': 'btn-group form-action-button', - 'classes' : 'btn btn-primary-reverse btn-outline-primary', - 'url': urls[url_active], - 'action': url_active, - 'transDomain': transDomains} - %} - {% if (urls|length > 1) %} - - - {{ 'Toggle Dropdown'|trans({}, 'Admin.Modules.Feature') }} - - {% endif %} - {% endif %} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_grid.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_grid.html.twig deleted file mode 100644 index 11a6ee78..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_grid.html.twig +++ /dev/null @@ -1,121 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% set isModuleActive = module.database.active %} - -
    -
    -
    -
    - {{ module.attributes.displayName }} -
    -

    - {% if module.attributes.displayName %} - {{ module.attributes.displayName|raw }} - {% else %} - {{ module.attributes.name }} - {% endif %} - {% for pico in module.attributes.picos %} - {{pico.label}} - {% endfor %} -

    -
    - {% block addon_version %} - {% if module.attributes.productType == "service" %} - {{ 'Service by %author%'|trans({'%author%' : '' ~ module.attributes.author ~ ''}, 'Admin.Modules.Feature')|raw }} - {% else %} - {{ 'v%version% - by %author%'|trans({ '%version%' : module.attributes.version, '%author%' : '' ~ module.attributes.author ~ '' }, 'Admin.Modules.Feature')|raw }} - {% endif %} - {% endblock %} -
    -
    -
    - {% block addon_description %} -
    - {{ module.attributes.description|raw }} - {% if module.attributes.description|length > 0 and module.attributes.description|length < module.attributes.fullDescription|length %} - ... - {% endif %} -
    -
    - {% if module.attributes.id != "0" %} - {{ 'Read More'|trans({}, 'Admin.Modules.Feature') }} - {% endif %} -
    - {% endblock %} -
    - -
    -
    - {% set badges = module.attributes.badges %} - {% if badges %} - {% set badge = badges|first %} - {{badge.label}} - {{badge.label}} - {% endif %} -
    -
    - {% if module.attributes.nbRates > 0 %} -
    - ({{ module.attributes.nbRates }}) -
    - {% endif %} -
    - {% if module.attributes.url_active == 'buy' and module.attributes.price.raw != '0.00' %} - {{ module.attributes.price.displayPrice }} - {% elseif module.attributes.url_active != 'buy' %} - {{ 'Free'|trans({}, 'Admin.Modules.Feature') }} - {% endif %} -
    - {% if requireBulkActions is defined and requireBulkActions == true %} -
    - -
    - {% endif %} - {% include '@PrestaShop/Admin/Module/Includes/action_menu.html.twig' with { 'module': module, 'level' : level } %} -
    - {% include '@PrestaShop/Admin/Module/Includes/modal_read_more.html.twig' with { 'module': module, 'additionalModalSuffix': additionalModalSuffix|default(''), 'level' : level } %} - {% include '@PrestaShop/Admin/Module/Includes/modal_confirm.html.twig' with { 'module': module } %} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_grid_addons.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_grid_addons.html.twig deleted file mode 100644 index 54777d7c..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_grid_addons.html.twig +++ /dev/null @@ -1,33 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    - - {{ 'Exit to PrestaShop Addons Marketplace'|trans({}, 'Admin.Modules.Feature') }} - - {{ 'See all results for your search on'|trans({}, 'Admin.Modules.Feature') }}
    - {{ 'PrestaShop Addons Marketplace'|trans({}, 'Admin.Modules.Feature') }} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_list.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_list.html.twig deleted file mode 100644 index 5b0a1686..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_list.html.twig +++ /dev/null @@ -1,112 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% set isModuleActive = module.database.active|default('0') %} - -
    -
    -
    -
    -
    - {{ module.attributes.displayName }} -
    -
    -
    -
    -

    - {% if module.attributes.displayName %} - {{ module.attributes.displayName|raw }} - - {% else %} - {{ module.attributes.name }} - {% endif %} - - {% for pico in module.attributes.picos %} - {{pico.label}} {{ pico.text}} - {% endfor %} - -

    -
    -
    - - {% block addon_version %} - {% if module.attributes.productType == "service" %} - {{ 'Service by %author%'|trans({'%author%' : '' ~ module.attributes.author ~ ''}, 'Admin.Modules.Feature')|raw }} - {% else %} - {{ 'v%version% - by %author%'|trans({ '%version%' : module.attributes.version, '%author%' : '' ~ module.attributes.author ~ '' }, 'Admin.Modules.Feature')|raw }} - {% endif %} - {% endblock %} - -
    -
    - {% block addon_description %} - {{ module.attributes.description|raw }} - {% if module.attributes.description|length > 0 and module.attributes.description|length < module.attributes.fullDescription|length %} - ... - {% endif %} - - {% if module.attributes.id != "0" %} - {{ 'Read More'|trans({}, 'Admin.Modules.Feature') }} - {% endif %} - - {% endblock %} -
    -
    - {% if requireBulkActions is defined and requireBulkActions == true %} -
    - -
    - {% endif %} - {% include '@PrestaShop/Admin/Module/Includes/action_menu.html.twig' with { 'module': module } %} -
    - {% include '@PrestaShop/Admin/Module/Includes/modal_read_more.html.twig' with { 'module': module, 'additionalModalSuffix': additionalModalSuffix|default('') } %} - {% include '@PrestaShop/Admin/Module/Includes/modal_confirm.html.twig' with { 'module': module } %} -
    -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_list_addons.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_list_addons.html.twig deleted file mode 100644 index 3f55f275..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_list_addons.html.twig +++ /dev/null @@ -1,35 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    -
    - - {{ 'Exit to PrestaShop Addons Marketplace'|trans({}, 'Admin.Modules.Feature') }} - - {{ 'See all results for your search on'|trans({}, 'Admin.Modules.Feature') }}
    - {{ 'PrestaShop Addons Marketplace'|trans({}, 'Admin.Modules.Feature') }} -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_manage_installed.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_manage_installed.html.twig deleted file mode 100644 index b5877ae4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_manage_installed.html.twig +++ /dev/null @@ -1,36 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/Module/Includes/card_list.html.twig' %} - -{# Twig extension for "Addons to update" part in notification page #} - -{# Display database version #} -{% block addon_version %} - {% if module.attributes.productType == "service" %} - {{ 'Service by %author%'|trans({'%author%' : '' ~ module.attributes.author ~ ''}, 'Admin.Modules.Feature')|raw }} - {% else %} - {{ 'v%version% - by %author%'|trans({ '%version%' : module.attributes.version, '%author%' : '' ~ module.attributes.author ~ '' }, 'Admin.Modules.Feature')|raw }} - {% endif %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_notification_configure.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_notification_configure.html.twig deleted file mode 100644 index 281e1d8b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_notification_configure.html.twig +++ /dev/null @@ -1,32 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/Module/Includes/card_manage_installed.html.twig' %} - -{# Twig extension for "Addons to configure" part in notification page #} - -{# Display the warning message instead of the addon description #} -{% block addon_description %} - {{module.attributes.warning}} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_notification_update.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_notification_update.html.twig deleted file mode 100644 index 8c4458c1..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/card_notification_update.html.twig +++ /dev/null @@ -1,50 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/Module/Includes/card_list.html.twig' %} - -{# Twig extension for "Addons to update" part in notification page #} - -{# Display "Old version -> New version" #} -{% block addon_version %} - v{{ module.database.version }} arrow_forward v{{ module.attributes.version_available }} -{% endblock %} - -{# Display changelog instead of the description #} -{% block addon_description %} - {% if module.attributes.changeLog is defined %} -
      - {% for version, lines in module.attributes.changeLog|arrayCast %} -
    • {{ version }}: - {% for line in lines %} - {{ line }}
      - {% endfor %} -
    • - {% endfor %} -
    - {% else %} - {{ 'No changelog provided'|trans({}, 'Admin.Modules.Notification') }} - {% endif %} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/categories_card.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/categories_card.html.twig deleted file mode 100644 index 78b9e125..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/categories_card.html.twig +++ /dev/null @@ -1,32 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    - {{ category.name|trans({}, 'Admin.Modules.Feature') }} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/categories_grid.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/categories_grid.html.twig deleted file mode 100644 index 14897e95..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/categories_grid.html.twig +++ /dev/null @@ -1,32 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    - {% for category in categories.subMenu|arrayCast %} - {# Module Card #} - {% include '@PrestaShop/Admin/Module/Includes/categories_card.html.twig' with { 'category': category } %} - {% endfor %} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/dropdown_bulk.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/dropdown_bulk.html.twig deleted file mode 100644 index 96331f5e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/dropdown_bulk.html.twig +++ /dev/null @@ -1,48 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/dropdown_categories.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/dropdown_categories.html.twig deleted file mode 100644 index d2e3e88c..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/dropdown_categories.html.twig +++ /dev/null @@ -1,65 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/dropdown_categories_catalog.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/dropdown_categories_catalog.html.twig deleted file mode 100644 index ebc74268..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/dropdown_categories_catalog.html.twig +++ /dev/null @@ -1,56 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/dropdown_status.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/dropdown_status.html.twig deleted file mode 100644 index e5089d65..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/dropdown_status.html.twig +++ /dev/null @@ -1,50 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid.html.twig deleted file mode 100644 index 9d9f5e16..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid.html.twig +++ /dev/null @@ -1,38 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    - {% for index, module in modules %} - {% block addon_card %} - {% include '@PrestaShop/Admin/Module/Includes/card_list.html.twig' with { 'index': index, 'module': module, 'origin': origin|default('none'), 'category': id } %} - {% endblock %} - {% endfor %} - - {% block addon_search_card %} - {% if requireAddonsSearch is defined and requireAddonsSearch == true %} - {% include '@PrestaShop/Admin/Module/Includes/card_grid_addons.html.twig'%} - {% include '@PrestaShop/Admin/Module/Includes/card_list_addons.html.twig'%} - {% endif %} - {% endblock %} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_loader.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_loader.html.twig deleted file mode 100644 index ea89f01f..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_loader.html.twig +++ /dev/null @@ -1,59 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{#Simulate a bunch of module card #} -
    - {% for i in 0..8 %} - -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - {% endfor %} -
    - -
    -
    -
    -
    - -
    - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_manage_empty.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_manage_empty.html.twig deleted file mode 100644 index 11a9ef6e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_manage_empty.html.twig +++ /dev/null @@ -1,33 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block catalog_category_empty %} -
    -

    - {{ 'You do not have module in « %categoryName% ».' | trans({'%categoryName%': category.name}, 'Admin.Modules.Feature') }}
    - {{ 'Discover the best-selling modules of this category in the %link% page.' | trans({'%link%': ''~category.name~''}, 'Admin.Modules.Feature') | raw }} -

    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_manage_installed.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_manage_installed.html.twig deleted file mode 100644 index a40c8bf7..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_manage_installed.html.twig +++ /dev/null @@ -1,29 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/Module/Includes/grid.html.twig' %} - -{% block addon_card %} - {% include '@PrestaShop/Admin/Module/Includes/card_manage_installed.html.twig' with { 'display_type': display_type, 'module': module, 'origin': origin|default('none'), 'category': id } %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_manage_recently_used.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_manage_recently_used.html.twig deleted file mode 100644 index f595b399..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_manage_recently_used.html.twig +++ /dev/null @@ -1,31 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block catalog_recently_used %} -
    - {{ 'Recently Used' | trans({}, 'Admin.Modules.Feature') }} -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_notification_configure.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_notification_configure.html.twig deleted file mode 100644 index da30ebc9..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_notification_configure.html.twig +++ /dev/null @@ -1,35 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/Module/Includes/grid.html.twig' %} - -{% block addon_card %} - {% include '@PrestaShop/Admin/Module/Includes/card_notification_configure.html.twig' - with { - 'module': module, - 'display_type': display_type, - 'origin': origin|default('none') - } - %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_notification_update.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_notification_update.html.twig deleted file mode 100644 index 2d111b2b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/grid_notification_update.html.twig +++ /dev/null @@ -1,35 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/Module/Includes/grid.html.twig' %} - -{% block addon_card %} - {% include '@PrestaShop/Admin/Module/Includes/card_notification_update.html.twig' - with { - 'module': module, - 'display_type': display_type, - 'origin': origin|default('none') - } - %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/menu_top.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/menu_top.html.twig deleted file mode 100644 index 9c0b2677..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/menu_top.html.twig +++ /dev/null @@ -1,69 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    -
    -
    - -
    - -
    -
    -
    -
    -
    -
    - -
    - {% if topMenuData is defined %} -
    -

    {{ 'Category' | trans({}, 'Admin.Catalog.Feature') }}

    - {% include '@PrestaShop/Admin/Module/Includes/dropdown_categories.html.twig' with { 'topMenuData': topMenuData } %} -
    - {% endif %} - - {% if requireFilterStatus is defined and requireFilterStatus == true %} -
    -

    {{ 'Status' | trans({}, 'Admin.Global') }}

    - {% include '@PrestaShop/Admin/Module/Includes/dropdown_status.html.twig' %} -
    - {% endif %} - - {% if level > constant('PrestaShopBundle\\Security\\Voter\\PageVoter::LEVEL_UPDATE') and bulkActions is defined %} -
    -

    {{ 'Bulk Actions'|trans({}, 'Admin.Global') }}

    - {% include '@PrestaShop/Admin/Module/Includes/dropdown_bulk.html.twig' %} -
    - {% endif %} -
    -
    - -
    - -{% set js_translatable = { - "Search - placeholder": "Search modules: keyword, name, author..."|trans({}, 'Admin.Modules.Help'), - }|merge(js_translatable) %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_addons_connect.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_addons_connect.html.twig deleted file mode 100644 index 1b6da76e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_addons_connect.html.twig +++ /dev/null @@ -1,110 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_confirm.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_confirm.html.twig deleted file mode 100644 index 348ee6a3..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_confirm.html.twig +++ /dev/null @@ -1,124 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% if module.attributes.urls|length >= 1 %} - {% for module_action, module_url in module.attributes.urls %} - {% if module_action in ['disable', 'uninstall', 'reset'] %} - - {% endif %} - {% endfor %} -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_confirm_bulk_action.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_confirm_bulk_action.html.twig deleted file mode 100644 index ada12a80..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_confirm_bulk_action.html.twig +++ /dev/null @@ -1,58 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_confirm_prestatrust.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_confirm_prestatrust.html.twig deleted file mode 100644 index 31fd1d20..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_confirm_prestatrust.html.twig +++ /dev/null @@ -1,73 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_import.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_import.html.twig deleted file mode 100644 index 1148403f..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_import.html.twig +++ /dev/null @@ -1,90 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_read_more.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_read_more.html.twig deleted file mode 100644 index 3e5675a4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_read_more.html.twig +++ /dev/null @@ -1,27 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_read_more_content.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_read_more_content.html.twig deleted file mode 100644 index 752676ea..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/modal_read_more_content.html.twig +++ /dev/null @@ -1,207 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% set ats = module.attributes %} -{% set name, displayName, nbRates, - starsRate, img, serviceUrl, version, cover, additionalDescription, - fullDescription, changeLog, customerBenefits, demoVideo, author, notFoundImg, features, badges = - ats.name, ats.displayName, ats.nbRates, ats.starsRate, ats.img, - ats.serviceUrl is defined and ats.serviceUrl|length > 0 ? ats.serviceUrl : false, - ats.version, ats.cover, - ats.additionalDescription is defined and ats.additionalDescription|length > 0 ? ats.additionalDescription : false, - ats.fullDescription is defined and ats.fullDescription|length > 0 ? ats.fullDescription : false, - ats.changeLog is defined and ats.changeLog|length > 0 ? ats.changeLog : false, - ats.customer_benefits is defined and ats.customer_benefits|length > 0 ? ats.customer_benefits : false, - ats.demo_video is defined and ats.demo_video|length > 0 ? ats.demo_video : false, - ats.author, 'https://cdn4.iconfinder.com/data/icons/ballicons-2-free/100/box-512.png', - ats.features, - ats.badges is defined and ats.badges|length > 0 ? ats.badges : false -%} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/see_more.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/see_more.html.twig deleted file mode 100644 index ccf5e0d4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/see_more.html.twig +++ /dev/null @@ -1,34 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -

    - - -

    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/sorting.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/sorting.html.twig deleted file mode 100644 index 77e8673b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/sorting.html.twig +++ /dev/null @@ -1,48 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    -
    -
    - {{ '%nbModules% modules and services selected for you'|trans({'%nbModules%' : totalModules}, 'Admin.Modules.Feature') }} - - -
    -
    -
    -
    - -
    -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/tab-module-line.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/tab-module-line.html.twig deleted file mode 100644 index eff8f461..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/Includes/tab-module-line.html.twig +++ /dev/null @@ -1,74 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% - set moduleImage = module.attributes.img is null ? - constant('_MODULE_DIR_') ~ module.attributes.name ~ '/' ~ module.attributes.logo : - module.attributes.img -%} - - - {{ module.attributes.name }} - - -
    -
    - {{ module.attributes.name }} - {{ module.attributes.displayName }} - v{{ module.attributes.version }} - by {{ module.attributes.author }} - {% if module.attributes.type is not empty and module.attributes.type == 'addonsBought' %} - - {{ 'Bought'|trans({}, 'Admin.Modules.Help') }} - {% elseif module.attributes.type is not empty and module.attributes.type == 'addonsMustHave' %} - - {{ 'Popular'|trans({}, 'Admin.Modules.Help') }} - {% elseif module.attributes.type is not empty and module.attributes.type == 'addonsPartner' %} - - {{ 'Official'|trans({}, 'Admin.Modules.Help') }} - {% elseif module.attributes.id is defined and module.attributes.id >= 0 %} - {% if module.attributes.version_addons is defined and module.attributes.version_addons %} - {{ 'Need update'|trans({}, 'Admin.Modules.Help') }} - {% endif %} - {% endif %} -
    -

    - {% if module.attributes.description is defined and module.attributes.description is not empty %} - {{ module.attributes.description }} - {% endif %} -

    - {% if (module.attributes.message is defined and module.attributes.name is not empty) and (module.attributes.type is not defined or module.attributes.type != 'addonsMustHave' or module.attributes.type != 'addonsNative') %} - - {% endif %} -
    - - - {{ include('@PrestaShop/Admin/Module/Includes/action_menu.html.twig', {'module': module}) }} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/alerts.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/alerts.html.twig deleted file mode 100644 index 50f1eb6a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/alerts.html.twig +++ /dev/null @@ -1,47 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/Module/common.html.twig' %} - -{% block content %} - {# Addons connect modal #} - {% include '@PrestaShop/Admin/Module/Includes/modal_addons_connect.html.twig' with { 'level' : level, 'errorMessage' : errorMessage } %} - {# PrestaTrust modal #} - {% include '@PrestaShop/Admin/Module/Includes/modal_confirm_prestatrust.html.twig' %} - {# Contains toolbar-nav for module page #} - {% include '@PrestaShop/Admin/Module/Includes/modal_import.html.twig' with { 'level' : level, 'errorMessage' : errorMessage } %} - {# Actual Page Content #} -
    -
    -
    - {{ '%nbModules% modules to configure'|trans({'%nbModules%' : modules|length}, 'Admin.Modules.Feature') }} - - -
    - {% include '@PrestaShop/Admin/Module/Includes/grid_notification_configure.html.twig' with { 'modules': modules, 'display_type': 'list', id: 'notification', 'category': 'notification' } %} -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/catalog-refresh.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/catalog-refresh.html.twig deleted file mode 100644 index 4c4af3a3..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/catalog-refresh.html.twig +++ /dev/null @@ -1,31 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    - {% for category in categories.subMenu %} - {% for module in category.modules %} - {% include '@PrestaShop/Admin/Module/Includes/card_grid.html.twig' with { 'module': module, 'origin': origin|default('none'), 'level' : level, 'category': category.refMenu } %} - {% endfor %} - {% endfor %} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/catalog.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/catalog.html.twig deleted file mode 100644 index 1ae577fb..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/catalog.html.twig +++ /dev/null @@ -1,63 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/Module/common.html.twig' %} - -{% block javascripts %} - {{ parent() }} - -{% endblock %} - -{% block content %} -
    -
    - {# Addons connect modal #} - {% include '@PrestaShop/Admin/Module/Includes/modal_addons_connect.html.twig' with { 'level' : level, 'errorMessage' : errorMessage } %} - {# PrestaTrust modal #} - {% include '@PrestaShop/Admin/Module/Includes/modal_confirm_prestatrust.html.twig' %} - {# Contains toolbar-nav for module page #} - {% include '@PrestaShop/Admin/Module/Includes/modal_import.html.twig' with { 'level' : level, 'errorMessage' : errorMessage } %} - {# Contains menu with Selection/Categories/Popular and Tag Search #} - {% include '@PrestaShop/Admin/Module/Includes/menu_top.html.twig' %} - {# Temporary loader until ajax has finished and display the full catalog #} - {% include '@PrestaShop/Admin/Module/Includes/grid_loader.html.twig' %} - {# Module Categories Grid #} - {% if topMenuData.categories is defined %} - {% include '@PrestaShop/Admin/Module/Includes/categories_grid.html.twig' with { 'categories' : topMenuData.categories } %} - {% endif %} -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/common.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/common.html.twig deleted file mode 100644 index 67dac761..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/common.html.twig +++ /dev/null @@ -1,46 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} - -{% set js_translatable = { - "Bulk Action - One module minimum": "You need to select at least one module to use the bulk action."|trans({}, 'Admin.Modules.Notification'), - "Bulk Action - Request not found": 'The action "[1]" is not available, impossible to perform your request.'|trans({}, 'Admin.Modules.Notification'), - "Bulk Action - Request not available for module": "The action [1] is not available for module [2]. Skipped."|trans({}, 'Admin.Modules.Notification'), -}|merge(js_translatable) -%} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/manage.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/manage.html.twig deleted file mode 100644 index 3e875468..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/manage.html.twig +++ /dev/null @@ -1,64 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/Module/common.html.twig' %} - -{% block content %} -
    -
    - {# Bulk Action confirm modal #} - {% include '@PrestaShop/Admin/Module/Includes/modal_confirm_bulk_action.html.twig' %} - {# PrestaTrust modal #} - {% include '@PrestaShop/Admin/Module/Includes/modal_confirm_prestatrust.html.twig' %} - {# Addons connect modal with level authorization#} - {% include '@PrestaShop/Admin/Module/Includes/modal_addons_connect.html.twig' with { 'level' : level, 'errorMessage' : errorMessage } %} - {# Contains toolbar-nav for module page with level authorization #} - {% include '@PrestaShop/Admin/Module/Includes/modal_import.html.twig' with { 'level' : level, 'errorMessage' : errorMessage } %} - {# Contains menu with Selection/Categories/Popular and Tag Search #} - {% include '@PrestaShop/Admin/Module/Includes/menu_top.html.twig' with { 'topMenuData': topMenuData, 'bulkActions': bulkActions } %} - - {% include '@PrestaShop/Admin/Module/Includes/grid_manage_recently_used.html.twig' with { 'display_type': 'list', 'origin': 'manage' } %} - - {% block catalog_categories_listing %} - {% for category in categories.subMenu %} -
    - {{ category.name | trans({}, 'Admin.Modules.Feature') }} - - {% if category.modules is empty %} - {% include '@PrestaShop/Admin/Module/Includes/grid_manage_empty.html.twig' with { 'category': category, 'display_type': 'list', 'origin': 'manage' } %} - {% else %} - {% include '@PrestaShop/Admin/Module/Includes/grid_manage_installed.html.twig' with { 'modules': category.modules, 'display_type': 'list', 'origin': 'manage', 'id': category.refMenu } %} - - {% block addon_card_see_more %} - {% if (category.modules | length) > maxModulesDisplayed %} - {% include '@PrestaShop/Admin/Module/Includes/see_more.html.twig' with { 'id': category.refMenu } %} - {% endif %} - {% endblock %} - {% endif %} -
    - {% endfor %} - {% endblock %} -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/tab-modules-list.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/tab-modules-list.html.twig deleted file mode 100644 index 7149f4f6..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/tab-modules-list.html.twig +++ /dev/null @@ -1,77 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% set modulesListShouldBeDisplayed = (modulesList is defined and modulesList is not empty) %} -{% if modulesListShouldBeDisplayed == true %} -
    -
    - -
    -
    - -{% endif %} - - -{% if modulesListShouldBeDisplayed == true %} - -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Module/updates.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Module/updates.html.twig deleted file mode 100644 index 2b99b7ab..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Module/updates.html.twig +++ /dev/null @@ -1,50 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/Module/common.html.twig' %} - -{% block content %} - {# Addons connect modal #} - {% include '@PrestaShop/Admin/Module/Includes/modal_addons_connect.html.twig' with { 'level' : level, 'errorMessage' : errorMessage } %} - {# PrestaTrust modal #} - {% include '@PrestaShop/Admin/Module/Includes/modal_confirm_prestatrust.html.twig' %} - {# Contains toolbar-nav for module page #} - {% include '@PrestaShop/Admin/Module/Includes/modal_import.html.twig' with { 'level' : level, 'errorMessage' : errorMessage } %} - {# Actual Page Content #} -
    -
    -
    - {{ '%nbModules% modules to update'|trans({'%nbModules%' : modules|length}, 'Admin.Modules.Feature') }} - - - {% if (modules|length > 1) and (level >= constant('PrestaShopBundle\\Security\\Voter\\PageVoter::LEVEL_UPDATE')) %} - {{ "Upgrade All"|trans({}, 'Admin.Modules.Feature') }} - {% endif %} -
    - {% include '@PrestaShop/Admin/Module/Includes/grid_notification_update.html.twig' with { 'modules': modules, 'display_type': 'list', id: 'update', 'level' : level, 'category': 'notification' } %} -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Blocks/filters.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Blocks/filters.html.twig deleted file mode 100644 index ec7c5c80..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Blocks/filters.html.twig +++ /dev/null @@ -1,150 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    -
    - {% block product_catalog_filter_by_categories %} - - {% endblock %} - - {% block product_catalog_filter_bulk_actions %} -
    - {% set buttons_action = [ - { - "onclick": "bulkProductAction(this, 'activate_all');", - "icon": "radio_button_checked", - "label": "Activate selection"|trans({}, 'Admin.Actions') - }, { - "onclick": "bulkProductAction(this, 'deactivate_all');", - "icon": "radio_button_unchecked", - "label": "Deactivate selection"|trans({}, 'Admin.Actions') - } - ] %} - - {% set buttons_action = buttons_action|merge([ - { - "divider": true - }, { - "onclick": "bulkProductAction(this, 'duplicate_all');", - "icon": "content_copy", - "label": "Duplicate selection"|trans({}, 'Admin.Actions') - } - ]) %} - - - {% set buttons_action = buttons_action|merge([ - { - "divider": true - }, { - "onclick": "bulkProductAction(this, 'delete_all');", - "icon": "delete", - "label": "Delete selection"|trans({}, 'Admin.Actions') - } - ]) %} - - {% include '@PrestaShop/Admin/Helpers/dropdown_menu.html.twig' with { - 'div_style': "btn-group dropdown bulk-catalog", - 'button_id': "product_bulk_menu", - 'disabled': true, - 'menu_label': "Bulk actions"|trans({}, 'Admin.Global'), - 'buttonType': "outline-secondary", - 'menu_icon': "icon-caret-up", - 'items': buttons_action - } %} -
    - {% endblock %} -
    -
    - - {% block product_catalog_filter_select_all %} -
    -
    -
    - -
    -
    -
    - {% endblock %} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Blocks/tools.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Blocks/tools.html.twig deleted file mode 100644 index 1ab854fe..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Blocks/tools.html.twig +++ /dev/null @@ -1,52 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Forms/form_edit_dropdown.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Forms/form_edit_dropdown.html.twig deleted file mode 100644 index 10b4f528..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Forms/form_edit_dropdown.html.twig +++ /dev/null @@ -1,67 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% set buttonType = buttonType|default('primary') %} -{% set right = right|default(false) %} - -
    - - {% if default_item is defined %} - - {% if default_item.icon %} - {{ default_item.icon }} - {% endif %} - {{ default_item.label|default('') }} - - {% endif %} - - - - - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Forms/form_products.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Forms/form_products.html.twig deleted file mode 100644 index 4a979369..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Forms/form_products.html.twig +++ /dev/null @@ -1,80 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    -
    - -
    -
    - -
    -
    - {% block product_catalog_form_table %} - {{ include('@Product/CatalogPage/Lists/products_table.html.twig', { - 'limit': limit, - 'orderBy': orderBy, - 'offset': offset, - 'sortOrder': sortOrder, - 'filter_category': filter_category, - 'filter_column_id_product': filter_column_id_product, - 'filter_column_name': filter_column_name, - 'filter_column_reference': filter_column_reference, - 'filter_column_name_category': filter_column_name_category, - 'filter_column_price': filter_column_price, - 'filter_column_sav_quantity': filter_column_sav_quantity, - 'filter_column_active':filter_column_active, - 'has_category_filter': has_category_filter, - 'activate_drag_and_drop': activate_drag_and_drop, - 'products': products, - 'last_sql': last_sql - }) - }} - {% endblock %} -
    -
    - - {% if product_count_filtered > 20 %} -
    -
    - - {{ render(controller('PrestaShopBundle:Admin\\Common:pagination', { - 'limit': limit, - 'offset': offset, - 'total': product_count_filtered, - 'caller_route': app.request.attributes.get('_route'), - 'caller_parameters': pagination_parameters, - 'limit_choices': pagination_limit_choices - })) }} -
    -
    - {% endif %} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Lists/list.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Lists/list.html.twig deleted file mode 100644 index 4a4e5d7b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Lists/list.html.twig +++ /dev/null @@ -1,143 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - {% for product in products %} - {% block product_catalog_form_table_row %} - - -
    - -
    - - - - - - {{ product.image|raw }} - - - {{ product.name|default('N/A'|trans({}, 'Admin.Global')) }} - - - {{ product.reference|default('') }} - - - {{ product.name_category|default('') }} - - - {{ product.price|default('N/A'|trans({}, 'Admin.Global')) }} - - - {{ product.price_final|default('N/A'|trans({}, 'Admin.Global')) }} - - - {% if 'PS_STOCK_MANAGEMENT'|configuration %} - - - {% if product.sav_quantity is defined and product.sav_quantity > 0 %} - {{ product.sav_quantity }} - {% else %} - {{ product.sav_quantity|default('N/A'|trans({}, 'Admin.Global')) }} - {% endif %} - - - {% else %} - - {% endif %} - - {% if product.active|default(0) == 0 %} - - clear - - {% else %} - - check - - {% endif %} - - {% if product.position is defined %} - - {% if activate_drag_and_drop %} - - {% endif %} - {{ product.position }} - - - - {% endif %} - -
    - - {% set buttons_action = [ - { - "href": product.preview_url|default('#'), - "target": "_blank", - "icon": "remove_red_eye", - "label": "Preview"|trans({}, 'Admin.Actions') - } - ] %} - - {% set buttons_action = buttons_action|merge([ - { - "onclick": "unitProductAction(this, 'duplicate');", - "icon": "content_copy", - "label": "Duplicate"|trans({}, 'Admin.Actions') - } - ]) %} - - {% set buttons_action = buttons_action|merge([ - { - "onclick": "unitProductAction(this, 'delete');", - "icon": "delete", - "label": "Delete"|trans({}, 'Admin.Actions') - } - ]) %} - - {% include '@Product/CatalogPage/Forms/form_edit_dropdown.html.twig' with { - 'button_id': "product_list_id_" ~ product.id_product ~ "_menu", - 'default_item': { - "href": product.url|default('#'), - "icon": "mode_edit" - }, - 'right': true, - 'items': buttons_action - } %} -
    - - - {% endblock %} -{% else %} - - {{ "There is no result for this search. Update your filters to view other products."|trans({}, 'Admin.Catalog.Notification') }} - -{% endfor %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Lists/list_quicknav.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Lists/list_quicknav.html.twig deleted file mode 100644 index 16ab7a39..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Lists/list_quicknav.html.twig +++ /dev/null @@ -1,99 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    - -

    {{ "Quick navigation"|trans({}, 'Admin.Global') }}

    -
    -
    - - - - - - - {% if 'PS_STOCK_MANAGEMENT'|configuration %} - - {% endif %} - - - - {% for product in products %} - - - - - {% if 'PS_STOCK_MANAGEMENT'|configuration %} - - {% endif %} - - {% else %} - - {% endfor %} - -
    - {{ "Name"|trans({}, 'Admin.Global') }} -
    - {{ product.name|default('N/A'|trans({}, 'Admin.Global')) }} -
    - {{ "There is no result for this search. Update your filters to view other products."|trans({}, 'Admin.Catalog.Notification') }} -
    -
    - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Lists/products_table.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Lists/products_table.html.twig deleted file mode 100644 index f29fe701..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/Lists/products_table.html.twig +++ /dev/null @@ -1,211 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} -
    - - - {% block product_catalog_form_table_header %} - - - - - - - - - - - {% if 'PS_STOCK_MANAGEMENT'|configuration %} - - {% else %} - - {% endif %} - - - {% if has_category_filter == true %} - - {% endif %} - - - {% endblock %} - - {% block product_catalog_form_table_filters %} - {% set filters_disabled = activate_drag_and_drop %} - - - - - - - - - {% if 'PS_STOCK_MANAGEMENT'|configuration %} - - {% else %} - - {% endif %} - - - {% if has_category_filter == true %} - - {% endif %} - - - {% endblock %} - - {% block product_catalog_form_table_items %} - {{ render(controller('PrestaShopBundle\\Controller\\Admin\\ProductController::listAction', { - 'limit': limit, - 'offset': offset, - 'orderBy': orderBy, - 'sortOrder': sortOrder, - 'products': products, - 'last_sql': last_sql - })) }} - {% endblock %} -
    - {{ ps.sortable_column_header("ID"|trans({}, 'Admin.Global'), 'id_product', orderBy, sortOrder) }} - - {{ "Image"|trans({}, 'Admin.Global') }} - - {{ ps.sortable_column_header("Name"|trans({}, 'Admin.Global'), 'name', orderBy, sortOrder) }} - - {{ ps.sortable_column_header("Reference"|trans({}, 'Admin.Global'), 'reference', orderBy, sortOrder) }} - - {{ ps.sortable_column_header("Category"|trans({}, 'Admin.Catalog.Feature'), 'name_category', orderBy, sortOrder) }} - - {{ ps.sortable_column_header("Price (tax excl.)"|trans({}, 'Admin.Catalog.Feature'), 'price', orderBy, sortOrder) }} - - {{ "Price (tax incl.)"|trans({}, 'Admin.Catalog.Feature') }} - - {{ ps.sortable_column_header("Quantity"|trans({}, 'Admin.Catalog.Feature'), 'sav_quantity', orderBy, sortOrder) }} - - {{ ps.sortable_column_header("Status"|trans({}, 'Admin.Global'), 'active', orderBy, sortOrder) }} - - {{ ps.sortable_column_header("Position"|trans({}, 'Admin.Global'), 'position', orderBy, sortOrder) }} - - {{ "Actions"|trans({}, 'Admin.Global') }} -
    - {% include '@PrestaShop/Admin/Helpers/range_inputs.html.twig' with { - 'input_name': "filter_column_id_product", - 'min': '0', - 'max': '1000000', - 'minLabel': "Min"|trans({}, 'Admin.Global'), - 'maxLabel': "Max"|trans({}, 'Admin.Global'), - 'value': filter_column_id_product, - 'disabled': filters_disabled, - } %} -   - - - - - - - {% include '@PrestaShop/Admin/Helpers/range_inputs.html.twig' with { - 'input_name': "filter_column_price", - 'min': '0', - 'max': '1000000', - 'minLabel': "Min"|trans({}, 'Admin.Global'), - 'maxLabel': "Max"|trans({}, 'Admin.Global'), - 'value': filter_column_price, - 'disabled': filters_disabled, - } %} - - {% include '@PrestaShop/Admin/Helpers/range_inputs.html.twig' with { - 'input_name': "filter_column_sav_quantity", - 'min': '-1000000', - 'max': '1000000', - 'minLabel': "Min"|trans({}, 'Admin.Global'), - 'maxLabel': "Max"|trans({}, 'Admin.Global'), - 'value': filter_column_sav_quantity, - 'disabled': filters_disabled, - } %} - -
    - -
    -
    - {% if not(activate_drag_and_drop) %} - - {% else %} - - {% endif %} - - - -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/catalog.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/catalog.html.twig deleted file mode 100644 index bcfb0361..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/catalog.html.twig +++ /dev/null @@ -1,231 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% form_theme categories '@PrestaShop/Admin/Product/Themes/categories_theme.html.twig' %} - -{% block javascripts %} - {{ parent() }} - - - - - -{% endblock %} - -{% block content %} -
    - - {{ renderhook('legacy_block_kpi', {'kpi_controller': 'AdminProductsController'}) }} - -
    - - {% if permission_error|length %} -
    -
    - -
    -
    - {% endif %} - -
    - {% block product_catalog_tools %} - {{ include('@Product/CatalogPage/Blocks/tools.html.twig', {'import_link': import_link }) }} - {% endblock %} - - {% block product_catalog_filters %} - {{ include('@Product/CatalogPage/Blocks/filters.html.twig', { - 'limit': limit, - 'offset': offset, - 'orderBy': orderBy, - 'sortOrder': sortOrder - }) - }} - {% endblock %} -
    - - {% block product_catalog_form %} - {{ include('@Product/CatalogPage/Forms/form_products.html.twig', { - 'limit': limit, - 'orderBy': orderBy, - 'offset': offset, - 'sortOrder': sortOrder, - 'filter_category': filter_category, - 'filter_column_id_product': filter_column_id_product, - 'filter_column_name': filter_column_name, - 'filter_column_reference': filter_column_reference, - 'filter_column_name_category': filter_column_name_category, - 'filter_column_price': filter_column_price, - 'filter_column_sav_quantity': filter_column_sav_quantity, - 'filter_column_active': filter_column_active, - 'has_category_filter': has_category_filter, - 'activate_drag_and_drop': activate_drag_and_drop, - 'products': products, - 'last_sql': last_sql, - 'product_count_filtered': product_count_filtered, - 'pagination_parameters': pagination_parameters, - 'pagination_limit_choices': pagination_limit_choices - }) - }} - {% endblock %} - -
    -
    - - {# Duplication product modal #} - {% embed '@PrestaShop/Admin/Helpers/bootstrap_popup.html.twig' with { - 'id': "catalog_duplicate_all_modal", - 'title': "Duplicating products"|trans({}, 'Admin.Catalog.Notification'), - 'closable': true, - 'progressbar': { - 'id': "catalog_duplicate_all_progression", - 'label': "Duplicating..."|trans({}, 'Admin.Catalog.Notification') - }, - 'actions': [], - }%} - {% block content %} - - {% endblock %} - {% endembed %} - - - {# Activation product modal #} - {% embed '@PrestaShop/Admin/Helpers/bootstrap_popup.html.twig' with { - 'id': "catalog_activate_all_modal", - 'title': "Activating products"|trans({}, 'Admin.Catalog.Notification'), - 'closable': true, - 'progressbar': { - 'id': "catalog_activate_all_progression", - 'label': "Activating..."|trans({}, 'Admin.Catalog.Notification') - }, - 'actions': [], - }%} - {% block content %} - - {% endblock %} - {% endembed %} - - - {# Desactivation product modal #} - {% embed '@PrestaShop/Admin/Helpers/bootstrap_popup.html.twig' with { - 'id': "catalog_deactivate_all_modal", - 'title': "Deactivating products"|trans({}, 'Admin.Catalog.Notification'), - 'closable': true, - 'progressbar': { - 'id': "catalog_deactivate_all_progression", - 'label': "Deactivating..."|trans({}, 'Admin.Catalog.Notification') - }, - 'actions': [], - }%} - {% block content %} - - {% endblock %} - {% endembed %} - - - {# Deletion product modal #} - {% embed '@PrestaShop/Admin/Helpers/bootstrap_popup.html.twig' with { - 'id': "catalog_delete_all_modal", - 'title': "Deleting products"|trans({}, 'Admin.Catalog.Notification'), - 'closable': true, - 'progressbar': { - 'id': "catalog_delete_all_progression", - 'label': "Deleting..."|trans({}, 'Admin.Catalog.Notification') - }, - 'actions': [], - }%} - {% block content %} - - {% endblock %} - {% endembed %} - - - {# Confirmation deletion product modal #} - {% embed '@PrestaShop/Admin/Helpers/bootstrap_popup.html.twig' with { - 'id': "catalog_deletion_modal", - 'title': "Delete products?"|trans({}, 'Admin.Catalog.Feature'), - 'closable': true, - 'actions': [{ - 'type': 'button', - 'label': "Delete now"|trans({}, 'Admin.Actions'), - 'value': 'confirm', - 'class': 'btn btn-primary btn-lg', - }], - }%} - {% block content %} - - {% endblock %} - {% endembed %} - - {% embed '@PrestaShop/Admin/Helpers/bootstrap_popup.html.twig' with { - 'id': "catalog_sql_query_modal", - 'title': "SQL query"|trans({}, 'Admin.Global'), - 'closable': true, - 'actions': [{ - 'type': 'button', - 'label': "Export to SQL Manager"|trans({}, 'Admin.Actions'), - 'value': 'sql_manager', - 'class': 'btn btn-primary btn-lg', - }], - } %} - {% block content %} -
    - -
    - {% endblock %} - {% endembed %} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/catalog_empty.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/catalog_empty.html.twig deleted file mode 100644 index 66df64c5..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/CatalogPage/catalog_empty.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - add_shopping_cart -
    - - {{ '[1]Add your first product[/1][2]or import a list of products (filetypes: .csv, .xls, .xlsx, .xlst, .ods, .ots).[/2]'|trans({}, 'Admin.Catalog.Feature')| - replace({ - '[1]': '', - '[2]': '', - })|raw - }} - -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Blocks/footer.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Blocks/footer.html.twig deleted file mode 100644 index 6a65a672..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Blocks/footer.html.twig +++ /dev/null @@ -1,151 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% block product_footer %} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Blocks/header.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Blocks/header.html.twig deleted file mode 100644 index 5ea3e250..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Blocks/header.html.twig +++ /dev/null @@ -1,94 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    - {% if is_multishop_context %} -
    - -
    - {% endif %} - -
    -
    -
    - {{ form_widget(formName) }} -
    -
    - {{ form_widget(formType) }} - -
    -
    -
    - -
    -
    - -
    -
    -
    - {{ form_errors(formName) }} - {{ form_errors(formType) }} -
    -
    -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Blocks/tabs.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Blocks/tabs.html.twig deleted file mode 100644 index 73b30014..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Blocks/tabs.html.twig +++ /dev/null @@ -1,44 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_categories.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_categories.html.twig deleted file mode 100644 index 2c38a45f..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_categories.html.twig +++ /dev/null @@ -1,80 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -

    {{ "Categories"|trans({}, 'Admin.Catalog.Feature') }} - -

    -
    -
    -
    - - - {{ include('@PrestaShop/Admin/Category/categories.html.twig', {'categories': categories }) }} - {{ form_errors(form.id_category_default) }} - {{ form_widget(form.id_category_default) }} -
    - expand_more{{ "Expand"|trans({}, 'Admin.Actions') }} - expand_less{{ "Collapse"|trans({}, 'Admin.Actions') }} -
    - {{ form_widget(form.categories, {'defaultCategory': true}) }} {# see bootstrap_4_layout.html.twig #} -
    -
    - {{ form_errors(form.categories) }} - {{ form_widget(form.categories) }} {# see bootstrap_4_layout.html.twig #} -
    -
    -

    - {{ "Create a new category"|trans({}, 'Admin.Catalog.Feature') }} - -

    -
    -
    -
    - - {{ form_errors(form.new_category) }} - {{ form_widget(form.new_category.name) }} -
    - -
    - -
    - - {{ form_widget(form.new_category.id_parent) }} -
    - -
    - - -
    -
    - - - add_circle - {{ 'Create a category'|trans({}, 'Admin.Catalog.Feature') }} - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_combination.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_combination.html.twig deleted file mode 100644 index 5b8834ee..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_combination.html.twig +++ /dev/null @@ -1,269 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - -
    - {{ form.vars.value.name }} - -
    -
    - {{ default_currency }} -
    - -
    - - - {{ form.vars.value.final_price }} {{ default_currency }} - - {% if 'PS_STOCK_MANAGEMENT'|configuration %} - -
    - -
    - - {% endif %} - - -
    - mode_edit -
    -
    - -
    -
    - -
    -

    - {{ "Combination details"|trans({}, 'Admin.Catalog.Feature') }} - - {{ form.vars.value.name }} -

    - {{ form_widget(form.attribute_default) }} -
    - {% if 'PS_STOCK_MANAGEMENT'|configuration %} -
    -
    - - {{ form_errors(form.attribute_quantity) }} - {{ form_widget(form.attribute_quantity) }} -
    -
    - {% endif %} -
    -
    - - {{ form_errors(form.available_date_attribute) }} - {{ form_widget(form.available_date_attribute) }} -
    -
    -
    -
    - - {{ form_errors(form.attribute_minimal_quantity) }} - {{ form_widget(form.attribute_minimal_quantity) }} -
    -
    -
    -
    - - {{ form_errors(form.attribute_reference) }} - {{ form_widget(form.attribute_reference) }} -
    -
    -
    -

    - {{ 'Stock'|trans({}, 'Admin.Catalog.Feature') }} -

    -
    -
    -
    - - {{ form_errors(form.attribute_location) }} - {{ form_widget(form.attribute_location) }} -
    -
    -
    -
    - - {{ form_errors(form.attribute_low_stock_threshold) }} - {{ form_widget(form.attribute_low_stock_threshold) }} -
    -
    -
    -
    - -
    - {{ form_errors(form.attribute_low_stock_alert) }} - {{ form_widget(form.attribute_low_stock_alert) }} - Team[/1]"|trans({'[1]':'','[/1]':''}, 'Admin.Catalog.Help')|raw }}" > -
    -
    -
    -
    -

    - {{ "Price and impact"|trans({}, 'Admin.Catalog.Feature') }} -

    -
    -
    -
    - - {{ form_errors(form.attribute_wholesale_price) }} - {{ form_widget(form.attribute_wholesale_price) }} -
    -
    -
    -
    - - {{ form_errors(form.attribute_price) }} - {{ form_widget(form.attribute_price) }} -
    -
    -
    -
    - - {{ form_errors(form.attribute_priceTI) }} - {{ form_widget(form.attribute_priceTI) }} -
    -
    -
    - {{ "Final retail price (tax excl.) will be"|trans({}, 'Admin.Catalog.Feature') }} {{ form.vars.value.final_price }} {{ default_currency }} -
    -
    -
    -
    -
    - - {{ form_errors(form.attribute_ecotax) }} - {{ form_widget(form.attribute_ecotax) }} -
    -
    -
    -
    - - {{ form_errors(form.attribute_unity) }} - {{ form_widget(form.attribute_unity) }} -
    -
    -
    -
    - -
    -
    - {{ 'PS_WEIGHT_UNIT'|configuration }} -
    - {{ form_errors(form.attribute_weight) }} - {{ form_widget(form.attribute_weight) }} -
    -
    -
    -
    -

    - {{ "Specific references"|trans({}, 'Admin.Catalog.Feature') }} -

    -
    -
    -
    - - {{ form_errors(form.attribute_isbn) }} - {{ form_widget(form.attribute_isbn) }} -
    -
    -
    -
    - - {{ form_errors(form.attribute_ean13) }} - {{ form_widget(form.attribute_ean13) }} -
    -
    -
    -
    - - {{ form_errors(form.attribute_upc) }} - {{ form_widget(form.attribute_upc) }} -
    -
    -
    -
    - - {{ form_errors(form.attribute_mpn) }} - {{ form_widget(form.attribute_mpn) }} -
    -
    -
    -

    - {{ "Images"|trans({}, 'Admin.Catalog.Feature') }} -

    -
    -
    -
    - - {{ form_errors(form.id_image_attr) }} - {{ form_widget(form.id_image_attr) }} -
    -
    -
    - -
    -
    - {{ renderhook('displayAdminProductsCombinationBottom', { 'id_product': form.vars.value.id_product, 'id_product_attribute': form.vars.value.id_product_attribute }) }} -
    -
    - - {{ form_widget(form.id_product_attribute) }} -
    -
    - - - delete - - - {% set checked = form.vars.value.attribute_default == 1 ? 'checked' : '' %} - - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_combination_collection.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_combination_collection.html.twig deleted file mode 100644 index 76aa484b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_combination_collection.html.twig +++ /dev/null @@ -1,27 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% for combinationForm in combinationForms %} - {{ include('@Product/ProductPage/Forms/form_combination.html.twig', {'form': combinationForm}) }} -{% endfor %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_combinations.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_combinations.html.twig deleted file mode 100644 index a772f8e0..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_combinations.html.twig +++ /dev/null @@ -1,207 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    -

    - {{ 'Manage your product combinations'|trans({}, 'Admin.Catalog.Feature') }} - Attributes & Features for this!"|trans({}, 'Admin.Catalog.Help') }}" - > -

    -
    - -
    -
    -
    - {{ form_errors(form.attributes) }} - {{ form_widget(form.attributes) }} -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - {{ include('@Product/ProductPage/Forms/form_combinations_bulk.html.twig', { 'form': form_combination_bulk }) }} -
    -
    -
    -
    - -
    - - - - - - - - - {% if 'PS_STOCK_MANAGEMENT'|configuration %} - - {% endif %} - - - - - {% if has_combinations %} - - - - - - - {% if 'PS_STOCK_MANAGEMENT'|configuration %} - - {% endif %} - - - {% endif %} - -
    - - {{ 'Combinations'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Impact on price (tax excl.)'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Final price (tax excl.)'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Quantity'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Default combination'|trans({}, 'Admin.Catalog.Feature') }}
    - -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - -
    - {% for attribute_group in attribute_groups %} -
    - -
    -
    - {% for attribute in attribute_group.attributes %} -
    - - -
    - {% endfor %} -
    -
    -
    - {% endfor %} -
    -
    - -
    -
    - -
    -

    {{ 'Availability preferences'|trans({}, 'Admin.Catalog.Feature') }}

    -
    - {% if 'PS_STOCK_MANAGEMENT'|configuration %} -
    - - {{ form_errors(form.out_of_stock) }} - {{ form_widget(form.out_of_stock) }} -
    - -
    - - {{ form_errors(form.available_now) }} - {{ form_widget(form.available_now) }} -
    - -
    - - {{ form_errors(form.available_later) }} - {{ form_widget(form.available_later) }} -
    - {% else %} -
    -

    {{ 'Stock management is disabled'|trans({}, 'Admin.Catalog.Feature') }}

    -
    - {% endif %} - - {% if not has_combinations %} -
    - - {{ form_errors(form.available_date) }} - {{ form_widget(form.available_date) }} -
    - {% endif %} - -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_combinations_bulk.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_combinations_bulk.html.twig deleted file mode 100644 index d29420a7..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_combinations_bulk.html.twig +++ /dev/null @@ -1,101 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    - {% if 'PS_STOCK_MANAGEMENT'|configuration %} -
    - - {{ form_errors(form.quantity) }} - {{ form_widget(form.quantity) }} -
    - {% endif %} - -
    - - {{ form_errors(form.cost_price) }} - {{ form_widget(form.cost_price) }} -
    - -
    - - {{ form_errors(form.impact_on_weight) }} - {{ form_widget(form.impact_on_weight) }} -
    - -
    - - {{ form_errors(form.impact_on_price_te) }} - {{ form_widget(form.impact_on_price_te) }} -
    - -
    - - {{ form_errors(form.impact_on_price_ti) }} - {{ form_widget(form.impact_on_price_ti) }} -
    - -
    - - {{ form_errors(form.date_availability) }} - {{ form_widget(form.date_availability) }} -
    - -
    - - {{ form_errors(form.reference) }} - {{ form_widget(form.reference) }} -
    - -
    - - {{ form_errors(form.minimal_quantity) }} - {{ form_widget(form.minimal_quantity) }} -
    - -
    - - {{ form_errors(form.low_stock_threshold) }} - {{ form_widget(form.low_stock_threshold) }} -
    - -
    -
    - {{ form_errors(form.low_stock_alert) }} - {{ form_widget(form.low_stock_alert) }} - -
    -
    -
    -
    - - - {{ form_widget(form) }} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_custom_fields.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_custom_fields.html.twig deleted file mode 100644 index a0a0ad79..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_custom_fields.html.twig +++ /dev/null @@ -1,57 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    - {{ form_widget(form.id_customization_field) }} -
    -
    - - {{ form_errors(form.label) }} - {{ form_widget(form.label) }} -
    -
    -
    -
    - - {{ form_errors(form.type) }} - {{ form_widget(form.type) }} -
    -
    -
    -
    - - delete -
    -
    -
    -
    -
    - -
    -
    - {{ form_widget(form.require, {'switch': 'tiny'}) }} -
    -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_edit_specific_price_modal.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_edit_specific_price_modal.html.twig deleted file mode 100644 index 7e11d431..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_edit_specific_price_modal.html.twig +++ /dev/null @@ -1,44 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_feature.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_feature.html.twig deleted file mode 100644 index cd14a3cd..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_feature.html.twig +++ /dev/null @@ -1,48 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    -
    - - {{ form_widget(form.feature) }} -
    -
    -
    -
    - - {{ form_widget(form.value) }} -
    -
    -
    -
    - - {{ form_widget(form.custom_value) }} -
    -
    -
    - delete -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_manufacturer.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_manufacturer.html.twig deleted file mode 100644 index 7f9fdea1..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_manufacturer.html.twig +++ /dev/null @@ -1,47 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -

    {{ "Brand"|trans({}, 'Admin.Catalog.Feature') }}

    -
    -
    -
    - {{ form_widget(form) }} -
    - {{ form_errors(form) }} -
    -
    -
    -
    - delete -
    -
    -
    -
    -
    - -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_related_products.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_related_products.html.twig deleted file mode 100644 index f4cf0f7a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_related_products.html.twig +++ /dev/null @@ -1,46 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -
    - -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_seo.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_seo.html.twig deleted file mode 100644 index 6ec38119..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_seo.html.twig +++ /dev/null @@ -1,135 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    - -

    {{ 'Search Engine Optimization'|trans({}, 'Admin.Catalog.Feature') }}

    -

    {{ 'Improve your ranking and how your product page will appear in search engines results.'|trans({}, 'Admin.Catalog.Feature') }}

    - - {% block product_catalog_tool_serp %} -

    {{ "Here is a preview of your search engine result, play with it!"|trans({}, 'Admin.Catalog.Feature') }}

    - {# Div targetted by the SERP component in VueJs. It displays a Google search result preview. #} -
    - {% endblock %} - -
    -
    -
    - {{ form_label(seoForm.meta_title) }} - {{ form_errors(seoForm.meta_title) }} - {{ form_widget(seoForm.meta_title) }} -
    -
    -
    - -
    -
    -
    - {{ form_label(seoForm.meta_description) }} - {{ form_errors(seoForm.meta_description) }} - {{ form_widget(seoForm.meta_description) }} -
    -
    -
    -
    - - {{ form_errors(seoForm.link_rewrite) }} -
    -
    - {{ form_widget(seoForm.link_rewrite) }} -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    - -

    - {{ 'Redirection page'|trans({}, 'Admin.Catalog.Feature') }} - -

    - -
    - -
    -
    - - {{ form_errors(seoForm.redirect_type) }} - {{ form_widget(seoForm.redirect_type) }} -
    -
    - -
    -
    - - {{ form_errors(seoForm.id_type_redirected) }} - {{ form_widget(seoForm.id_type_redirected) }} -
    - -
    -
    -
    -
    - -
    -
    - - {{ form_rest(seoForm) }} - - {{ renderhook('displayAdminProductsSeoStepBottom', { 'id_product': productId }) }} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_shipping.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_shipping.html.twig deleted file mode 100644 index 20564ed2..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_shipping.html.twig +++ /dev/null @@ -1,161 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% set dimension_unit, weight_unit = 'PS_DIMENSION_UNIT'|configuration, 'PS_WEIGHT_UNIT'|configuration %} - -
    -

    {{ 'Package dimension'|trans({}, 'Admin.Catalog.Feature') }}

    -

    {{ 'Adjust your shipping costs by filling in the product dimensions.'|trans({}, 'Admin.Catalog.Feature') }}

    -
    - -
    -
    - - {{ form_errors(form.width) }} -
    - {{ form_widget(form.width) }} -
    - {{ dimension_unit }} -
    -
    -
    -
    -
    -
    - - {{ form_errors(form.height) }} -
    - {{ form_widget(form.height) }} -
    - {{ dimension_unit }} -
    -
    -
    -
    -
    -
    - - {{ form_errors(form.depth) }} -
    - {{ form_widget(form.depth) }} -
    - {{ dimension_unit }} -
    -
    -
    -
    -
    -
    - - {{ form_errors(form.weight) }} -
    - {{ form_widget(form.weight) }} -
    - {{ weight_unit }} -
    -
    -
    -
    - -
    -
    -

    - {{ form.additional_delivery_times.vars.label }} - -

    -
    -
    - {% for child in form.additional_delivery_times %} - {% if child.vars.value == 1 %} - - {% else %} - {{ form_widget(child) }} - {% endif %} - {% endfor %} -
    -
    -
    -
    - -
    -
    - - {{ form_errors(form.delivery_in_stock) }} - {{ form_widget(form.delivery_in_stock) }} -

    {{ 'Leave empty to disable.'|trans({}, 'Admin.Catalog.Feature') }}

    -
    -
    -
    -
    - - {{ form_errors(form.delivery_out_stock) }} - {{ form_widget(form.delivery_out_stock) }} -

    {{ 'Leave empty to disable.'|trans({}, 'Admin.Catalog.Feature') }}

    -
    -
    - -
    -
    -

    - {{ form.additional_shipping_cost.vars.label }} - -

    - -
    -
    - {{ form_widget(form.additional_shipping_cost) }} -
    -
    -
    -
    - -
    -
    -

    {{ form.selectedCarriers.vars.label }}

    - {{ form_widget(form.selectedCarriers) }} -
    -
    - -
    - -
    - -
    -
    - {% if asm_globally_activated and isNotVirtual and isChecked %} - {{ include('@PrestaShop/Admin:Product/ProductPage/Forms/form_warehouse_combination.html.twig', { 'warehouses': warehouses, 'form': form }) }} - {% endif %} -
    -
    - -{{ renderhook('displayAdminProductsShippingStepBottom', { 'id_product': id_product }) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_specific_price.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_specific_price.html.twig deleted file mode 100644 index a3db3159..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_specific_price.html.twig +++ /dev/null @@ -1,174 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% if is_modal is not defined %} - {% set is_modal = false %} -{% endif %} - -{% if is_modal == false %} - {% set column_default_md_3 = 'col-md-3' %} - {% set column_default_md_2 = 'col-md-2' %} - {% set column_default_xl_2 = 'col-xl-2' %} -{% else %} - {% set column_default_md_3 = 'col-md-9' %} - {% set column_default_md_2 = 'col-md-4' %} - {% set column_default_xl_2 = 'col-xl-4' %} -{% endif %} - -
    -

    {{ 'Specific price conditions'|trans({}, 'Admin.Catalog.Feature') }}

    - {{ form_errors(form) }} - - {% if form.sp_id_shop.vars.choices is defined %} -
    -
    -
    - - {{ form_errors(form.sp_id_shop) }} - {{ form_widget(form.sp_id_shop) }} -
    -
    -
    - {% else %} - {{ form_widget(form.sp_id_shop) }} - {% endif %} - -
    -
    -
    - - {{ form_errors(form.sp_id_currency) }} - {{ form_widget(form.sp_id_currency) }} -
    -
    -
    -
    - - {{ form_errors(form.sp_id_country) }} - {{ form_widget(form.sp_id_country) }} -
    -
    -
    -
    - - {{ form_errors(form.sp_id_group) }} - {{ form_widget(form.sp_id_group) }} -
    -
    -
    -
    - - {{ form_errors(form.sp_id_customer) }} - {{ form_widget(form.sp_id_customer) }} -
    -
    -
    -
    -
    -
    - - {{ form_errors(form.sp_id_product_attribute) }} - {{ form_widget(form.sp_id_product_attribute) }} -
    -
    -
    -
    -
    - - {{ form_errors(form.sp_from) }} - {{ form_widget(form.sp_from) }} -
    -
    -
    -
    - - {{ form_errors(form.sp_to) }} - {{ form_widget(form.sp_to) }} -
    -
    - {% if is_modal == true %} -
    -
    - {% endif %} -
    -
    - - {{ form_errors(form.sp_from_quantity) }} -
    - {{ form_widget(form.sp_from_quantity) }} -
    - {{ 'Unit(s)'|trans({}, 'Admin.Catalog.Feature') }} -
    -
    -
    -
    -
    -
    - -

    {{ 'Impact on price'|trans({}, 'Admin.Catalog.Feature') }}

    -
    -
    -
    - - {{ form_errors(form.sp_price) }} - {{ form_widget(form.sp_price) }} -
    -
    -
    -
    - - {{ form_errors(form.leave_bprice) }} - {{ form_widget(form.leave_bprice) }} -
    -
    -
    -
    -
    -
    - - {{ form_errors(form.sp_reduction) }} - {{ form_widget(form.sp_reduction) }} -
    -
    -
    -
    - - {{ form_errors(form.sp_reduction_type) }} - {{ form_widget(form.sp_reduction_type) }} -
    -
    -
    -
    - - {{ form_errors(form.sp_reduction_tax) }} - {{ form_widget(form.sp_reduction_tax) }} -
    -
    -
    -
    - {{ form_widget(form.cancel) }} - {{ form_widget(form.save) }} -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_supplier_choice.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_supplier_choice.html.twig deleted file mode 100644 index cd1aa6a4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_supplier_choice.html.twig +++ /dev/null @@ -1,72 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% if form.suppliers|length > 0 %} -
    -

    {{ form.suppliers.vars.label }}

    -
    -
    - -
    -
    - -
    -
    -
    - {{ form_errors(form.suppliers) }} - - - - - - - - - {% for key, supplier in form.suppliers %} - - - - - {% endfor %} - -
    {{ 'Choose the suppliers associated with this product'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Default supplier'|trans({}, 'Admin.Catalog.Feature') }}
    {{ form_widget(supplier) }}{{ form_widget(form.default_supplier[key]) }}
    -
    -
    -
    - -
    -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_supplier_combination.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_supplier_combination.html.twig deleted file mode 100644 index 5b6fa658..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_supplier_combination.html.twig +++ /dev/null @@ -1,72 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% if suppliers|length > 0 %} -

    {{ 'Supplier reference(s)'|trans({}, 'Admin.Catalog.Feature') }}

    -
    -
    - -
    -
    -{% endif %} - -{% for supplierId in suppliers %} - {% set collectionName = 'supplier_combination_' ~ supplierId %} -
    -
    {{ form[collectionName].vars.label }}
    -
    -
    - {{ form_errors(form[collectionName]) }} - - - - - - - - - - - {% for supplier_combination in form[collectionName] %} - - - - - - - {% endfor %} - -
    {{ 'Product name'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Supplier reference'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Price (tax excl.)'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Currency'|trans({}, 'Admin.Global') }}
    {{ supplier_combination.vars.value.label }}{{ form_widget(supplier_combination.supplier_reference) }}{{ form_widget(supplier_combination.product_price) }} - {{ form_widget(supplier_combination.product_price_currency) }} - {{ form_widget(supplier_combination.id_product_attribute) }} - {{ form_widget(supplier_combination.supplier_id) }} -
    -
    -
    -
    -{% endfor %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_warehouse_combination.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_warehouse_combination.html.twig deleted file mode 100644 index e485ed9d..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Forms/form_warehouse_combination.html.twig +++ /dev/null @@ -1,67 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% if warehouses|length > 0 %} -

    {{ 'Product location in warehouses'|trans({}, 'Admin.Catalog.Feature') }}

    - - -

    {{ 'Please choose the warehouses associated with this product.'|trans({}, 'Admin.Catalog.Feature') }}

    - - {% for warehouse in warehouses %} -
    - {% set collectionName = 'warehouse_combination_' ~ warehouse.id_warehouse %} -
    - -
    - {{ form_errors(form[collectionName]) }} - {% for warehouse_combination in form[collectionName] %} -
    - -
    -
    {{ form_widget(warehouse_combination.activated) }}
    - {{ form_label(warehouse_combination.location) }} -
    {{ form_widget(warehouse_combination.location) }}
    - {{ form_widget(warehouse_combination.id_product_attribute) }} - {{ form_widget(warehouse_combination.warehouse_id) }} - {{ form_widget(warehouse_combination.product_id) }} -
    -
    - {% endfor %} -
    -
    -
    - {% endfor %} -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/combinations.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/combinations.html.twig deleted file mode 100644 index a2f0caf7..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/combinations.html.twig +++ /dev/null @@ -1,191 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    -
    -
    -
    - -
    - -
    -

    {{ 'Quantities'|trans({}, 'Admin.Catalog.Feature') }}

    -
    -
    - {% if 'PS_STOCK_MANAGEMENT'|configuration %} -
    - - {{ form_errors(formStockQuantity) }} - {{ form_widget(formStockQuantity) }} -
    - {% endif %} -
    - - - {{ form_errors(formStockMinimalQuantity) }} - {{ form_widget(formStockMinimalQuantity) }} -
    -
    -
    - -

    {{ 'Stock'|trans({}, 'Admin.Catalog.Feature') }}

    -
    -
    -
    - - {{ form_errors(formLocation) }} - {{ form_widget(formLocation) }} -
    -
    -
    -
    - - {{ form_errors(formLowStockThreshold) }} - {{ form_widget(formLowStockThreshold) }} -
    -
    - -
    - {{ form_errors(formLowStockAlert) }} - {{ form_widget(formLowStockAlert) }} - Team[/1]"|trans({'[1]':'','[/1]':''}, 'Admin.Catalog.Help')|raw }}" > -
    -
    -
    -
    -
    - -
    - -
    -
    -

    {{ formVirtualProduct.vars.label }}

    -
    -
    -
    - {{ form_widget(formVirtualProduct.is_virtual_file) }} -
    -
    -
    - -
    - {{ form_errors(formVirtualProduct) }} -
    -
    - - -
    - {{ form_widget(formVirtualProduct.file) }} -
    - -
    -
    -
    -
    - - - {{ form_errors(formVirtualProduct.name) }} - {{ form_widget(formVirtualProduct.name) }} -
    -
    -
    -
    - - - {{ form_errors(formVirtualProduct.nb_downloadable) }} - {{ form_widget(formVirtualProduct.nb_downloadable) }} -
    -
    -
    -
    - - - {{ form_errors(formVirtualProduct.expiration_date) }} - {{ form_widget(formVirtualProduct.expiration_date) }} -
    -
    -
    -
    - - - {{ form_errors(formVirtualProduct.nb_days) }} - {{ form_widget(formVirtualProduct.nb_days) }} -
    -
    -
    - {{ form_widget(formVirtualProduct.save) }} -
    -
    -
    - - {% if asm_globally_activated and formType.vars.value != "2" %} -
    - -
    - {{ form_errors(formAdvancedStockManagement) }} - {{ form_widget(formAdvancedStockManagement) }} - {% if form.step1.type_product.vars.value == "1" %} - {{ 'When enabling advanced stock management for a pack, please make sure it is also enabled for its product(s) – if you choose to decrement product quantities.'|trans({}, 'Admin.Catalog.Notification') }} - {% endif %} -
    -
    -
    - -
    - {{ form_errors(formDependsOnStocks) }} - {{ form_widget(formDependsOnStocks) }} -
    -
    - {% endif %} - {% if 'PS_STOCK_MANAGEMENT'|configuration %} -
    -

    {{ formPackStockType.vars.label }}

    -
    -
    - {{ form_errors(formPackStockType) }} - {{ form_widget(formPackStockType) }} -
    -
    -
    - {% endif %} - {{ include('@Product/ProductPage/Forms/form_combinations.html.twig', {'form': formStep3, 'form_combination_bulk': formCombinations}) }} - - {{ renderhook('displayAdminProductsQuantitiesStepBottom', { 'id_product': productId }) }} - -
    -
    -
    -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/essentials.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/essentials.html.twig deleted file mode 100644 index 429b68ec..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/essentials.html.twig +++ /dev/null @@ -1,274 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    -
    -
    -
    - - {# LEFT #} -
    - -
    - {{ form_errors(formPackItems) }} - {{ form_widget(formPackItems) }} -
    - -
    -
    -
    -
    - add_a_photo
    - {{js_translatable['Drop images here']}}
    - {{js_translatable['or select files']}}
    - - {{js_translatable['files recommandations']}}
    - {{js_translatable['files recommandations2']}} -
    -
    - {% if images is defined %} - {% if editable %} -
    -
    +
    -
    - {% endif %} - {% for image in images %} -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - {% if image.cover %} -
    {{ 'Cover'|trans({}, 'Admin.Catalog.Feature') }}
    - {% endif %} -
    - {% endfor %} - {% endif %} -
    -
    -
    -
    -
    - {{ 'View all images'|trans({}, 'Admin.Catalog.Feature') }} - {{ 'View less'|trans({}, 'Admin.Catalog.Feature') }} -
    - -
    - -
    - - -
    -
    - {{ form_widget(formShortDescription) }} -
    -
    - {{ form_widget(formDescription) }} -
    -
    -
    - - {{ renderhook('displayAdminProductsMainStepLeftColumnMiddle', { 'id_product': productId }) }} - -
    -
    -

    {{ 'Features'|trans({}, 'Admin.Catalog.Feature') }}

    - {{ form_errors(formFeatures) }} -
    - {% for feature in formFeatures %} - {{ include('@Product/ProductPage/Forms/form_feature.html.twig', { 'form': feature }) }} - {% endfor %} -
    -
    -
    -
    - -
    -
    -
    - -
    - {{ include('@Product/ProductPage/Forms/form_manufacturer.html.twig', { 'form': formManufacturer }) }} -
    - - - - {{ renderhook('displayAdminProductsMainStepLeftColumnBottom', { 'id_product': productId }) }} - -
    - - {# RIGHT #} -
    - -
    -
    - - {% if is_combination_active %} -
    -

    - {{ "Combinations"|trans({}, 'Admin.Catalog.Feature') }} - -

    -
    - -
    -
    - -
    - - {# First tag [1][/1] is for a HTML link. Second tag [2] is an icon (no closing tag needed). #} - {{ "Advanced settings in [1][2]Combinations[/1]"|trans({}, 'Admin.Catalog.Help')|replace({'[1]': '', '[/1]': '', '[2]': 'open_in_new'})|raw }} - -
    -
    -
    - {% endif %} - -
    -

    - {{ "Reference"|trans({}, 'Admin.Catalog.Feature') }} - -

    - {{ form_errors(formReference) }} -
    -
    - {{ form_widget(formReference) }} -
    -
    -
    - - {% if 'PS_STOCK_MANAGEMENT'|configuration %} -
    -

    - {{ "Quantity"|trans({}, 'Admin.Catalog.Feature') }} - -

    - {{ form_errors(formQuantityShortcut) }} -
    -
    - {{ form_widget(formQuantityShortcut) }} -
    -
    - - {# First tag [1][/1] is for a HTML link. Second tag [2] is an icon (no closing tag needed). #} - {{ "Advanced settings in [1][2]Quantities[/1]"|trans({}, 'Admin.Catalog.Help')|replace({'[1]': '', '[/1]': '', '[2]': 'open_in_new'})|raw }} - -
    - {% endif %} - -
    -

    - {{ "Price"|trans({}, 'Admin.Global') }} - -

    -
    -
    - - {{ form_widget(formPriceShortcut) }} - {{ form_errors(formPriceShortcut) }} -
    -
    - - {{ form_widget(formPriceShortcutTTC) }} - {{ form_errors(formPriceShortcutTTC) }} -
    -
    - - {{ render( - controller('PrestaShopBundle:Admin/Common:renderField', { - 'formName': 'step2', - 'formType': 'PrestaShopBundle\\Form\\Admin\\Product\\ProductPrice', - 'fieldName': 'id_tax_rules_group', - 'fieldData' : form.step2.id_tax_rules_group.vars.value - } - ) - ) - }} -
    -
    - - {# First tag [1][/1] is for a HTML link. Second tag [2] is an icon (no closing tag needed). #} - {{ "Advanced settings in [1][2]Pricing[/1]"|trans({}, 'Admin.Catalog.Help')|replace({'[1]': '', '[/1]': '', '[2]': 'open_in_new'})|raw }} - -
    -
    -
    -
    - -
    -
    -
    -
    - × -
    -
    - -
    - {{ include('@Product/ProductPage/Forms/form_categories.html.twig', { 'form': formCategories, 'productId': productId }) }} -
    - - {{ renderhook('displayAdminProductsMainStepRightColumnBottom', { 'id_product': productId }) }} - -
    -
    -
    -
    -
    -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/options.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/options.html.twig deleted file mode 100644 index 6f257470..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/options.html.twig +++ /dev/null @@ -1,228 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    -
    -
    -
    - -
    - - {{ renderhook('displayAdminProductsOptionsStepTop', { 'id_product': productId }) }} - -
    -
    -

    {{ 'Visibility'|trans({}, 'Admin.Catalog.Feature') }}

    -

    {{ 'Where do you want your product to appear?'|trans({}, 'Admin.Catalog.Feature') }}

    -
    -
    - -
    -
    - {{ form_errors(optionsForm.visibility) }} - {{ form_widget(optionsForm.visibility) }} -
    -
    - -
    -
    - {{ form_errors(optionsForm.display_options) }} -
    -
    - {{ form_widget(optionsForm.display_options.available_for_order) }} -
    -
    - {{ form_widget(optionsForm.display_options.show_price) }} -
    -
    - {{ form_widget(optionsForm.display_options.online_only) }} -
    -
    -
    -
    -
    -
    - - {{ form_errors(optionsForm.tags) }} - {{ form_widget(optionsForm.tags) }} - -
    -
    - -
    -
    -

    {{ 'Condition & References'|trans({}, 'Admin.Catalog.Feature')|raw }}

    -
    -
    - -
    -
    - - {{ form_errors(optionsForm.condition) }} - {{ form_widget(optionsForm.condition) }} -
    -
    - - {{ form_widget(optionsForm.show_condition) }} -
    -
    -
    -
    - - {{ form_errors(optionsForm.isbn) }} - {{ form_widget(optionsForm.isbn) }} -
    -
    - - {{ form_errors(optionsForm.ean13) }} - {{ form_widget(optionsForm.ean13) }} -
    -
    -
    -
    - - {{ form_errors(optionsForm.upc) }} - {{ form_widget(optionsForm.upc) }} -
    -
    - - {{ form_errors(optionsForm.mpn) }} - {{ form_widget(optionsForm.mpn) }} -
    -
    - -
    -
    -
    -

    {{ optionsForm.custom_fields.vars.label }}

    -

    {{ 'Customers can personalize the product by entering some text or by providing custom image files.'|trans({}, 'Admin.Catalog.Feature') }}

    - {{ form_errors(optionsForm.custom_fields) }} -
      - {% for field in optionsForm.custom_fields %} -
    • - {{ include('@Product/ProductPage/Forms/form_custom_fields.html.twig', { 'form': field }) }} -
    • - {% endfor %} -
    - - add_circle - {{ 'Add a customization field'|trans({}, 'Admin.Catalog.Feature') }} - -
    -
    -
    - -
    -
    -

    {{ 'Attached files'|trans({}, 'Admin.Catalog.Feature') }}

    -

    {{ 'Select the files (instructions, documentation, recipes, etc.) your customers can directly download on this product page.'|trans({}, 'Admin.Catalog.Feature') }}
    {{ 'Need to browse all files? Go to [1]Catalog > Files[/1]'|trans({'[1]':'','[/1]':''}, 'Admin.Catalog.Feature')|raw }}

    - {{ form_widget(optionsForm.attachments) }} -
    -
    -
    -
    - -
    - {{ form_errors(optionsForm.attachment_product) }} -
    -
    {{ form_widget(optionsForm.attachment_product.file) }}
    -
    {{ form_widget(optionsForm.attachment_product.name) }}
    -
    {{ form_widget(optionsForm.attachment_product.description) }}
    -
    - {{ form_widget(optionsForm.attachment_product.add) }} - {{ form_widget(optionsForm.attachment_product.cancel) }} -
    -
    -
    -
    -
    - -
    -
    - {{ include('@Product/ProductPage/Forms/form_supplier_choice.html.twig', { 'form': optionsForm }) }} -
    -
    -
    -
    - {{ include('@Product/ProductPage/Forms/form_supplier_combination.html.twig', { 'suppliers': optionsForm.suppliers.vars.value, 'form': optionsForm }) }} -
    -
    - - {{ renderhook('displayAdminProductsOptionsStepBottom', { 'id_product': productId }) }} - -
    -
    -
    -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/pricing.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/pricing.html.twig deleted file mode 100644 index 3d6da7f8..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/pricing.html.twig +++ /dev/null @@ -1,225 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    -
    -
    -
    - -
    -

    {{ 'Retail price'|trans({}, 'Admin.Catalog.Feature') }} - -

    -
    - -
    -
    - -
    - - {{ form_errors(pricingForm.price) }} - {{ form_widget(pricingForm.price) }} -
    -
    - - {{ form_errors(pricingForm.price_ttc) }} - {{ form_widget(pricingForm.price_ttc) }} -
    - -
    - -
    -
    - {{ form_errors(pricingForm.unit_price) }} - {{ form_widget(pricingForm.unit_price) }} -
    -
    - {{ form_errors(pricingForm.unity) }} - {{ form_widget(pricingForm.unity) }} -
    -
    -
    -
    - - {{ form_errors(pricingForm.ecotax) }} - {{ form_widget(pricingForm.ecotax) }} -
    -
    -
    - -
    -
    -
    - - {{ form_errors(pricingForm.id_tax_rules_group) }} - {{ form_widget(pricingForm.id_tax_rules_group) }} -
    - -
    - {{ form_widget(pricingForm.on_sale) }} -
    -
    -
    -
    - -
    -
    -
    -
    -
    - -
    -
    -
    -

    - {{ 'Cost price'|trans({}, 'Admin.Catalog.Feature') }} - -

    -
    -
    - - {{ form_errors(pricingForm.wholesale_price) }} - {{ form_widget(pricingForm.wholesale_price) }} -
    -
    -
    - -
    -
    -
    -

    - {{ 'Specific prices'|trans({}, 'Admin.Catalog.Feature') }} - -

    -
    -
    -
    - -
    - {{ include('@Product/ProductPage/Forms/form_specific_price.html.twig', {'form': pricingForm.specific_price, 'is_multishop_context': is_multishop_context}) }} -
    - - - - - - - - - - - - - - - - - - -
    {{ 'Rule'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Combination'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Currency'|trans({}, 'Admin.Global') }}{{ 'Country'|trans({}, 'Admin.Global') }}{{ 'Group'|trans({}, 'Admin.Global') }}{{ 'Customer'|trans({}, 'Admin.Global') }}{{ 'Fixed price'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Impact'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Period'|trans({}, 'Admin.Global') }}{{ 'From'|trans({}, 'Admin.Catalog.Feature') }}
    -
    -
    -
    -
    - -
    - {{ include('@Product/ProductPage/Forms/form_edit_specific_price_modal.html.twig') }} -
    - - -
    -
    -
    -

    - {{ 'Priority management'|trans({}, 'Admin.Catalog.Feature') }} - -

    -
    -
    -
    - - {{ form_errors(pricingForm.specificPricePriority_0) }} - {{ form_widget(pricingForm.specificPricePriority_0) }} -
    -
    -
    -
    - - {{ form_errors(pricingForm.specificPricePriority_1) }} - {{ form_widget(pricingForm.specificPricePriority_1) }} -
    -
    -
    -
    - - {{ form_errors(pricingForm.specificPricePriority_2) }} - {{ form_widget(pricingForm.specificPricePriority_2) }} -
    -
    -
    -
    - - {{ form_errors(pricingForm.specificPricePriority_3) }} - {{ form_widget(pricingForm.specificPricePriority_3) }} -
    -
    -
    - {{ form_widget(pricingForm.specificPricePriorityToAll) }} -
    -
    -
    - - {{ renderhook('displayAdminProductsPriceStepBottom', { 'id_product': productId }) }} - -
    -
    -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/seo.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/seo.html.twig deleted file mode 100644 index 8bfe5a34..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/seo.html.twig +++ /dev/null @@ -1,39 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    -
    -
    -
    -
    - {{ include('@Product/ProductPage/Forms/form_seo.html.twig', { - 'seoForm' : seoForm, - 'productId': productId - }) - }} -
    -
    -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/disabled_form_alert.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/disabled_form_alert.html.twig deleted file mode 100644 index 26d94b07..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/disabled_form_alert.html.twig +++ /dev/null @@ -1,35 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    - -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/product.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/product.html.twig deleted file mode 100644 index 8e492bfd..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/product.html.twig +++ /dev/null @@ -1,354 +0,0 @@ - {#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} - - {% set hooks = renderhooksarray('displayAdminProductsExtra', { 'id_product': id_product }) %} - -
    - - {% if not editable %}
    {% endif %} - {# PRODUCT HEADER #} - {% block product_header %} - {{ include('@Product/ProductPage/Blocks/header.html.twig', { - 'formName': form.step1.name, - 'formType': form.step1.type_product, - 'is_multishop_context': is_multishop_context, - 'languages': languages, - 'help_link': help_link, - 'stats_link': stats_link - }) - }} - {% endblock %} - -
    -
    - {{ form_errors(form) }} -
    -
    - -
    - {# FORM TABS CONTAINER #} - {% block product_tabs_container %} - {{ include('@Product/ProductPage/Blocks/tabs.html.twig', { 'hooks': hooks }) }} - {% endblock %} -
    - - {# PANEL ESSENTIALS #} - {% block product_panel_essentials %} - {% set formQuantityShortcut = form.step1.qty_0_shortcut is defined ? form.step1.qty_0_shortcut : null %} - {{ include('@Product/ProductPage/Panels/essentials.html.twig', { - 'formPackItems': form.step1.inputPackItems, - 'productId': id_product, - 'images': form.step1.vars.value.images, - 'formShortDescription': form.step1.description_short, - 'formDescription': form.step1.description, - 'formFeatures': form.step1.features, - 'formManufacturer': form.step1.id_manufacturer, - 'formRelatedProducts': form.step1.related_products, - 'is_combination_active': is_combination_active, - 'has_combinations': has_combinations, - 'formReference': form.step6.reference, - 'formQuantityShortcut': formQuantityShortcut, - 'formPriceShortcut': form.step1.price_shortcut, - 'formPriceShortcutTTC': form.step1.price_ttc_shortcut, - 'formCategories': form.step1, - }) - }} - {% endblock %} - - {# PANEL COMBINATIONS #} - {% block product_panel_combinations %} - {% set formStockQuantity = form.step3.qty_0 is defined ? form.step3.qty_0 : null %} - {{ include('@Product/ProductPage/Panels/combinations.html.twig', { - 'formDependsOnStocks': form.step3.depends_on_stock, - 'productId': id_product, - 'formStockQuantity': formStockQuantity, - 'formStockMinimalQuantity': form.step3.minimal_quantity, - 'formLowStockThreshold': form.step3.low_stock_threshold, - 'formLocation': form.step3.location, - 'formLowStockAlert': form.step3.low_stock_alert, - 'formVirtualProduct': form.step3.virtual_product, - 'asm_globally_activated': asm_globally_activated, - 'formType': form.step1.type_product, - 'formAdvancedStockManagement': form.step3.advanced_stock_management, - 'formPackStockType': form.step3.pack_stock_type, - 'formStep3': form.step3, - 'formCombinations': formCombinations, - 'has_combinations': has_combinations, - 'max_upload_size': max_upload_size - }) - }} - {% endblock %} - - {# PANEL SHIPPING #} - {% block product_panel_shipping %} -
    -
    -
    -
    -
    - {{ include('@Product/ProductPage/Forms/form_shipping.html.twig', { - 'form' : form.step4, - 'asm_globally_activated': asm_globally_activated, - 'isNotVirtual': form.step1.type_product.vars.value != "2", - 'isChecked': form.step3.advanced_stock_management.vars.checked, - 'warehouses': warehouses - }) }} -
    -
    -
    -
    -
    - {% endblock %} - - {# PANEL PRICING #} - {% block product_panel_pricing %} - {{ include('@Product/ProductPage/Panels/pricing.html.twig', { - 'pricingForm': form.step2, - 'is_multishop_context': is_multishop_context, - 'productId': id_product - }) }} - {% endblock %} - - {# PANEL SEO #} - {% block product_panel_seo %} - {{ include('@Product/ProductPage/Panels/seo.html.twig', { - 'seoForm': form.step5, - 'productId': id_product - }) }} - {% endblock %} - - {# PANEL OPTIONS #} - {% block product_panel_options %} - {{ include('@Product/ProductPage/Panels/options.html.twig', { - 'optionsForm': form.step6, - 'productId': id_product - }) }} - {% endblock %} - - {# PANEL HOOKED MODULES #} - {% block product_panel_modules %} - {% if hooksarraycontent(hooks) is not empty %} -
    -
    -
    -
    -
    - - {# LEFT #} -
    - - -
    -

    -

    {{ 'Choose a module to configure'|trans({}, 'Admin.Catalog.Feature') }}

    - {{ 'These modules are relative to the product page of your shop.'|trans({}, 'Admin.Catalog.Feature') }}
    - {{ 'To manage all your modules go to the [1]Installed module page[/1]'|trans({}, 'Admin.Catalog.Feature')|replace({'[1]': '', '[/1]': ''})|raw }} -

    -
    - {% for module in hooks %} -
    -
    -
    - {{ module.attributes.displayName }} -

    - {{ module.attributes.displayName }} -

    -
    - {{ module.attributes.version }} by {{ module.attributes.author }} -
    -
    -
    - {{ module.attributes.description }} -
    -
    -
    - -
    -
    -
    -
    - {% endfor %} -
    -
    - - {% for module in hooks %} - - {% endfor %} -
    - -
    -
    -
    -
    -
    - {% endif %} - {% endblock %} -
    - - {{ form_widget(form.id_product) }} - {{ form_widget(form._token) }} - -
    - {# FOOTER #} - {{ include('@Product/ProductPage/Blocks/footer.html.twig', { - 'preview_link': preview_link, - 'preview_link_deactivate': preview_link_deactivate, - 'is_shop_context': is_shop_context, - 'editable': editable, - 'is_active': form.step1.vars.value.active, - 'productId': id_product - }) }} - {% if not editable %}
    {% endif %} -
    - - - {% embed '@PrestaShop/Admin/Helpers/bootstrap_popup.html.twig' with { - 'id': 'confirmation_modal', - 'title': "Warning"|trans({}, 'Admin.Notifications.Warning'), - 'closable': false, - 'actions': [ - { - 'type': 'button', - 'label': "No"|trans({}, 'Admin.Global'), - 'class': 'btn btn-outline-secondary btn-lg cancel' - }, - { - 'type': 'button', - 'label': "Yes"|trans({}, 'Admin.Global'), - 'class': 'btn btn-primary btn-lg continue' - } - ], - } %} - {% block content %} - - {% endblock %} - {% endembed %} - -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - - - - - - - - - - - - - - - - -{% endblock %} - -{% set js_translatable = { -"Are you sure to disable variations ? they will all be deleted": "This will delete all the combinations. Do you wish to proceed?"|trans({}, 'Admin.Catalog.Notification'), -}|merge(js_translatable) %} - -{% set js_translatable = { -"Form update success": "Settings updated."|trans({}, 'Admin.Notifications.Success'), -"Form update errors": "Unable to update settings."|trans({}, 'Admin.Notifications.Error'), -"Delete": "Delete"|trans({}, 'Admin.Actions'), -"ToLargeFile": "The file is too large. Maximum size allowed is: [1]. The file you are trying to upload is [2]."|trans({}, 'Admin.Notifications.Error')|replace({ '[1]': '{{maxFilesize}}', '[2]': '{{filesize}}' }), -"Drop images here": "Drop images here"|trans({}, 'Admin.Catalog.Feature'), -"or select files": "or select files"|trans({}, 'Admin.Catalog.Feature'), -"files recommandations": "Recommended size 800 x 800px for default theme."|trans({}, 'Admin.Catalog.Feature'), -"files recommandations2": "JPG, GIF or PNG format."|trans({}, 'Admin.Catalog.Feature'), -"Cover": "Cover"|trans({}, 'Admin.Catalog.Feature'), -"Are you sure to delete this?": "Are you sure to delete this?"|trans({}, 'Admin.Notifications.Warning'), -"This will delete the specific price. Do you wish to proceed?": "This will delete the specific price. Do you wish to proceed?"|trans({}, 'Admin.Catalog.Notification'), -"Quantities": "Quantities"|trans({}, 'Admin.Catalog.Feature'), -"Combinations": "Combinations"|trans({}, 'Admin.Catalog.Feature'), -"Virtual product": "Virtual product"|trans({}, 'Admin.Catalog.Feature'), -"tax incl.": "tax incl."|trans({}, 'Admin.Catalog.Feature'), -"tax excl.": "tax excl."|trans({}, 'Admin.Catalog.Feature'), -"You can't create pack product with variations. Are you sure to disable variations ? they will all be deleted.": "A pack of products can't have combinations."|trans({}, "Admin.Catalog.Notification") ~ ' ' ~ js_translatable['Are you sure to disable variations ? they will all be deleted'], -"You can't create virtual product with variations. Are you sure to disable variations ? they will all be deleted.": "A virtual product can't have combinations."|trans({}, "Admin.Catalog.Notification") ~ ' ' ~ js_translatable['Are you sure to disable variations ? they will all be deleted'], -}|merge(js_translatable) %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Product/Themes/categories_theme.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Product/Themes/categories_theme.html.twig deleted file mode 100644 index 699d41a1..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Product/Themes/categories_theme.html.twig +++ /dev/null @@ -1,61 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% block choice_tree_widget -%} -
    -
      - - {%- for child in choices %} - {{ block('choice_tree_item_widget') }} - {% endfor -%} -
    -
    - -{%- endblock choice_tree_widget %} - -{% block choice_tree_item_widget -%} -
  • - {% set checked = (form.vars.submitted_values is defined and submitted_values[child.id_category] is defined) ? 'checked="checked"' : '' %} - -
    - -
    - - {% if child.children is defined %} -
      - {% for item in child.children %} - {% set child = item %} - {{ block('choice_tree_item_widget') }} - {% endfor -%} -
    - {% endif %} -
  • -{%- endblock choice_tree_item_widget %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/ProductImage/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/ProductImage/form.html.twig deleted file mode 100644 index 19fb1461..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/ProductImage/form.html.twig +++ /dev/null @@ -1,45 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - -
    -
    - {{ form_widget(form.cover) }} -
    - -
    - - -{{ form_widget(form.legend) }} -{{ form_errors(form.legend) }} - -
    - - -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Security/compromised.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Security/compromised.html.twig deleted file mode 100644 index 0298803b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Security/compromised.html.twig +++ /dev/null @@ -1,72 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '::base.html.twig' %} - -{% block stylesheets %} - - -{% endblock %} - -{% block title %} - {{ 'Invalid token'|trans({},'Admin.Catalog.Help' ) }} -{% endblock %} -{% block body %} -
    -
    -
    - - -

    {{ 'Do you want to display this page?'|trans({},'Admin.Catalog.Help' ) }}

    - -
    -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/Blocks/form.html.twig deleted file mode 100644 index 830dff49..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/Blocks/form.html.twig +++ /dev/null @@ -1,153 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{{ form_start(addressForm) }} -
    -
    - mail_outline - {{ 'Addresses'|trans({}, 'Admin.Navigation.Menu') }} -
    - -
    -
    - {{ form_errors(addressForm) }} - - {% block customer_information %} - {% if customerInformation is not null %} - {% if addressForm.id_customer is defined %} - {{ ps.form_widget_with_error(addressForm.id_customer) }} - {% endif %} -
    - - -
    - {% endif %} - {% if addressForm.customer_email is defined %} - {{ ps.form_group_row(addressForm.customer_email, {'attr': { - 'data-customer-information-url': path('admin_customer_for_address_information') }}, { - 'label': 'Customer email'|trans({}, 'Admin.Orderscustomers.Feature'), - }) }} - {% endif %} - {% endblock %} - - {{ ps.form_group_row(addressForm.dni, {}, { - 'label': 'Identification number'|trans({}, 'Admin.Orderscustomers.Feature'), - 'help' : 'The national ID card number of this person, or a unique tax identification number.'|trans({}, 'Admin.Orderscustomers.Help') - }) }} - - {{ ps.form_group_row(addressForm.alias, {}, { - 'label': 'Address alias'|trans({}, 'Admin.Orderscustomers.Feature'), - 'help' : 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>;=#{}' - }) }} - - {{ ps.form_group_row(addressForm.first_name, {}, { - 'label': 'First name'|trans({}, 'Admin.Global'), - 'help' : 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' 0-9!<>,;?=+()@#"�{}_$%:' - }) }} - - {{ ps.form_group_row(addressForm.last_name, {}, { - 'label': 'Last name'|trans({}, 'Admin.Global'), - 'help' : 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' 0-9!<>,;?=+()@#"�{}_$%:' - }) }} - - {{ ps.form_group_row(addressForm.company, {}, { - 'label': 'Company'|trans({}, 'Admin.Global'), - 'help' : 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>;=#{}' - }) }} - - {{ ps.form_group_row(addressForm.vat_number, {}, { - 'label': 'VAT number'|trans({}, 'Admin.Orderscustomers.Feature'), - }) }} - - {{ ps.form_group_row(addressForm.address1, {}, { - 'label': 'Address'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(addressForm.address2, {}, { - 'label': 'Address (2)'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(addressForm.postcode, {}, { - 'label': 'Zip/postal code'|trans({}, 'Admin.Global') - }) }} - - {{ ps.form_group_row(addressForm.city, {}, { - 'label': 'City'|trans({}, 'Admin.Global') - }) }} - - {{ ps.form_group_row(addressForm.id_country, {'attr': { - 'class': 'js-customer-country-select', - 'data-states-url': path('admin_country_states') }}, { - 'label': 'Country'|trans({}, 'Admin.Global'), - }) }} - -
    - {{ ps.form_group_row(addressForm.id_state, {}, { - 'label': 'State'|trans({}, 'Admin.Global'), - }) }} -
    - - {{ ps.form_group_row(addressForm.phone, {}, { - 'label': 'Phone'|trans({}, 'Admin.Global') - }) }} - - {{ ps.form_group_row(addressForm.phone_mobile, {}, { - 'label': 'Mobile phone'|trans({}, 'Admin.Global') - }) }} - - {{ ps.form_group_row(addressForm.other, {}, { - 'label': 'Other'|trans({}, 'Admin.Global'), - 'help' : 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>;=#{}' - }) }} - - {{ form_rest(addressForm) }} -
    -
    - - -
    -{{ form_end(addressForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/Blocks/required_fields.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/Blocks/required_fields.html.twig deleted file mode 100644 index a6b8afc1..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/Blocks/required_fields.html.twig +++ /dev/null @@ -1,56 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    - {{ form_start(requiredFieldsForm, {'action': path('admin_addresses_save_required_fields')}) }} -
    -

    - {{ 'Required Fields'|trans({}, 'Admin.Orderscustomers.Feature') }} -

    -
    - - {{ form_widget(requiredFieldsForm.required_fields) }} - {{ form_rest(requiredFieldsForm) }} -
    - -
    - {{ form_end(requiredFieldsForm) }} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/add.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/add.html.twig deleted file mode 100644 index f5ee0ed4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/add.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {{ include('@PrestaShop/Admin/Sell/Address/Blocks/form.html.twig', {'addressForm': addressForm}) }} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/edit.html.twig deleted file mode 100644 index f5ee0ed4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/edit.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {{ include('@PrestaShop/Admin/Sell/Address/Blocks/form.html.twig', {'addressForm': addressForm}) }} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/index.html.twig deleted file mode 100644 index b3fa4c74..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/index.html.twig +++ /dev/null @@ -1,66 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} - {% block addresses_listing %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': addressGrid} %} -
    -
    - {% endblock %} - - {% block address_required_fields_form %} -
    -
    -

    - -

    -
    - -
    - {% include '@PrestaShop/Admin/Sell/Address/Blocks/required_fields.html.twig' %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/modal_create_success.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/modal_create_success.html.twig deleted file mode 100644 index 83ecf833..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Address/modal_create_success.html.twig +++ /dev/null @@ -1,51 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -{% endblock %} - -{% block javascripts %} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Attachment/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Attachment/Blocks/form.html.twig deleted file mode 100644 index 9c1c584f..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Attachment/Blocks/form.html.twig +++ /dev/null @@ -1,85 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block attachment_form %} - {{ form_start(attachmentForm) }} -
    -

    - person - {{ 'File'|trans({}, 'Admin.Global') }} -

    -
    -
    - {{ form_errors(attachmentForm) }} - - {{ ps.form_group_row(attachmentForm.name, {}, { - 'label': 'File name'|trans({}, 'Admin.Global') - }) }} - - {{ ps.form_group_row(attachmentForm.file_description, {}, { - 'label': 'Description'|trans({}, 'Admin.Global') - }) }} - -
    - -
    - {{ form_widget(attachmentForm.file) }} - {{ form_errors(attachmentForm.file) }} -
    - {% block attachment_download %}{% endblock %} -
    - - {% if attachmentId is defined %} - - {% endif %} - - {% block attachment_form_rest %} - {{ form_rest(attachmentForm) }} - {% endblock %} -
    -
    - -
    - {{ form_end(attachmentForm) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Attachment/add.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Attachment/add.html.twig deleted file mode 100644 index f741eadb..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Attachment/add.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Attachment/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Attachment/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Attachment/edit.html.twig deleted file mode 100644 index 1ed81608..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Attachment/edit.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Attachment/Blocks/form.html.twig' with {'attachmentId': attachmentId} %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Attachment/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Attachment/index.html.twig deleted file mode 100644 index 8024272a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Attachment/index.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} - {% block attachments_listing %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': attachmentGrid} %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Attribute/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Attribute/index.html.twig deleted file mode 100644 index 16b72eeb..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Attribute/index.html.twig +++ /dev/null @@ -1,61 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% set layoutHeaderToolbarBtn = { - add: { - href: path('admin_attributes_create', { 'attributeGroupId': attributeGroupId}), - desc: 'Add new value'|trans({}, 'Admin.Catalog.Feature'), - icon: 'add_circle_outline', - } -} -%} - -{% block content %} - {% block attributes_listing %} -
    -
    - {% embed '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': attributeGrid} %} - {% block grid_panel_footer %} - - {% endblock %} - {% endembed %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/AttributeGroup/Blocks/showcase_card.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/AttributeGroup/Blocks/showcase_card.html.twig deleted file mode 100644 index 9cbc748d..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/AttributeGroup/Blocks/showcase_card.html.twig +++ /dev/null @@ -1,48 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if not isShowcaseCardClosed %} -
    -
    - -
    -
    -

    {{ 'Create attributes'|trans({}, 'Admin.Catalog.Feature') }}

    -

    {{ 'Color, dimension, size, disk space... think about attributes as properties that change from one product to another. As a consequence, attributes allow you to build product combinations.'|trans({}, 'Admin.Catalog.Feature') }}

    - - {{ 'Learn more'|trans({}, 'Admin.Actions') }} - -
    - - close - -
    -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/AttributeGroup/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/AttributeGroup/index.html.twig deleted file mode 100644 index 9f688cd6..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/AttributeGroup/index.html.twig +++ /dev/null @@ -1,60 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% set layoutHeaderToolbarBtn = { - add: { - href: path('admin_attribute_groups_create'), - desc: 'Add new attribute'|trans({}, 'Admin.Catalog.Feature'), - icon: 'add_circle_outline', - } -} -%} - -{% block content %} - - {% block attribute_group_showcase_card %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/AttributeGroup/Blocks/showcase_card.html.twig' %} -
    -
    - {% endblock %} - - {% block attributes_listing %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': attributeGroupGrid} %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/CatalogPriceRule/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/CatalogPriceRule/Blocks/form.html.twig deleted file mode 100644 index 0532c84c..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/CatalogPriceRule/Blocks/form.html.twig +++ /dev/null @@ -1,104 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} -{{ form_start(catalogPriceRuleForm) }} -{{ form_errors(catalogPriceRuleForm) }} -
    -

    - attach_money - {{ 'Catalog price rules'|trans({}, 'Admin.Catalog.Feature') }} -

    -
    -
    - {{ ps.form_group_row(catalogPriceRuleForm.name, {}, { - 'label': 'Name'|trans({}, 'Admin.Global'), - }) }} - - {% if catalogPriceRuleForm.id_shop is defined %} - {{ ps.form_group_row(catalogPriceRuleForm.id_shop, {}, { - 'label': 'Shop'|trans({}, 'Admin.Global') - }) }} - {% endif %} - - {{ ps.form_group_row(catalogPriceRuleForm.id_currency, {}, { - 'label': 'Currency'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(catalogPriceRuleForm.id_country, {}, { - 'label': 'Country'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(catalogPriceRuleForm.id_group, {}, { - 'label': 'Group'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(catalogPriceRuleForm.from_quantity, {}, { - 'label': 'From quantity'|trans({}, 'Admin.Catalog.Feature'), - }) }} - - {{ ps.form_group_row(catalogPriceRuleForm.price, {}, { - 'label': 'Price (tax excl.)'|trans({}, 'Admin.Catalog.Feature'), - }) }} - - {{ ps.form_group_row(catalogPriceRuleForm.leave_initial_price, {}, {'label': ''}) }} - - {{ ps.form_group_row(catalogPriceRuleForm.date_range.from, {}, { - 'label': 'From'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(catalogPriceRuleForm.date_range.to, {}, { - 'label': 'To'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(catalogPriceRuleForm.reduction.type, {'attr': {'class': 'js-reduction-type-source'}}, { - 'label': 'Reduction type'|trans({}, 'Admin.Catalog.Feature'), - }) }} - -
    - {{ ps.form_group_row(catalogPriceRuleForm.include_tax, {'attr': {'class': 'js-include-tax-target'}}, { - 'label': 'Reduction with or without taxes'|trans({}, 'Admin.Catalog.Feature'), - }) }} -
    - - {{ ps.form_group_row(catalogPriceRuleForm.reduction.value, {}, { - 'label': 'Reduction'|trans({}, 'Admin.Catalog.Feature'), - }) }} - - {% block catalog_price_rule_form_rest %} - {{ form_rest(catalogPriceRuleForm) }} - {% endblock %} -
    -
    - -
    -{{ form_end(catalogPriceRuleForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/CatalogPriceRule/create.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/CatalogPriceRule/create.html.twig deleted file mode 100644 index 9a7a5399..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/CatalogPriceRule/create.html.twig +++ /dev/null @@ -1,42 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set layoutTitle = 'Add new'|trans({}, 'Admin.Actions') %} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/CatalogPriceRule/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/CatalogPriceRule/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/CatalogPriceRule/edit.html.twig deleted file mode 100644 index 7bf706e7..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/CatalogPriceRule/edit.html.twig +++ /dev/null @@ -1,42 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set layoutTitle = 'Edit: %name%'|trans({'%name%': catalogPriceRuleName}, 'Admin.Actions') %} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/CatalogPriceRule/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/CatalogPriceRule/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/CatalogPriceRule/index.html.twig deleted file mode 100644 index 5771c326..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/CatalogPriceRule/index.html.twig +++ /dev/null @@ -1,52 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% set layoutHeaderToolbarBtn = { - add: { - href: path('admin_catalog_price_rules_create'), - desc: 'Add new catalog price rule'|trans({}, 'Admin.Catalog.Feature'), - icon: 'add_circle_outline', - } -} -%} - -{% block content %} - {% block catalog_price_rule_listing %} -
    -
    - {% include'@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': catalogPriceRuleGrid} %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/breadcrumb.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/breadcrumb.html.twig deleted file mode 100644 index 2099d74d..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/breadcrumb.html.twig +++ /dev/null @@ -1,60 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -
    - -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/cover_image.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/cover_image.html.twig deleted file mode 100644 index 93c3df68..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/cover_image.html.twig +++ /dev/null @@ -1,49 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block category_cover_image %} - {% if coverImage is defined and coverImage is not null %} -
    -
    -
    - -
    -

    {{ 'File size'|trans({}, 'Admin.Advparameters.Feature') }} {{ coverImage.size }}

    - -
    -
    -
    -
    - {% endif %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/delete_block.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/delete_block.html.twig deleted file mode 100644 index 52f95e51..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/delete_block.html.twig +++ /dev/null @@ -1,63 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if isDeleteSubmitted %} - {{ form_start(deleteCategoriesForm) }} -
    -
    -

    - {{ 'What do you want to do with the products associated with this category?'|trans({}, 'Admin.Catalog.Notification') }} -

    -
    -
    -
    -
    - {{ form_widget(deleteCategoriesForm.delete_mode) }} -
    -
    - {{ form_widget(deleteCategoriesForm.categories_to_delete) }} -
    -
    -
    -
    - -
    -
    - {{ form_end(deleteCategoriesForm) }} -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/delete_categories_modal.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/delete_categories_modal.html.twig deleted file mode 100644 index b953d72a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/delete_categories_modal.html.twig +++ /dev/null @@ -1,51 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% embed 'PrestaShopBundle:Admin/Helpers:bootstrap_popup.html.twig' with { - 'id': grid.id ~ '_grid_delete_categories_modal', - 'title': "What do you want to do with the products associated with this category?"|trans({}, 'Admin.Catalog.Notification'), - 'closable': true, - 'actions': [{ - 'type': 'button', - 'label': "Delete"|trans({}, 'Admin.Actions'), - 'class': 'btn btn-danger btn-lg js-submit-delete-categories', - }], -} %} - {% block content %} - - {% endblock %} -{% endembed %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/form.html.twig deleted file mode 100644 index a6eb2476..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/form.html.twig +++ /dev/null @@ -1,213 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import 'PrestaShopBundle:Admin:macros.html.twig' as ps %} - -{% block category_form_block %} -{{ form_start(categoryForm) }} -
    -

    - {{ 'Category'|trans({}, 'Admin.Catalog.Feature') }} -

    -
    -
    - {{ form_errors(categoryForm) }} - - {{ ps.form_group_row(categoryForm.name, {}, { - 'label': 'Name'|trans({}, 'Admin.Global'), - 'help': 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>;=#{}' - }) }} - -
    - {{ ps.label_with_help(('Displayed'|trans({}, 'Admin.Global')), ('Click on "%displayed_label%" to index the category on your shop.'|trans({'%displayed_label%': 'Displayed'|trans({}, 'Admin.Global')}, 'Admin.Catalog.Help'))) }} -
    - {{ form_widget(categoryForm.active) }} - - {{ 'If you want a category to appear in the menu of your shop, go to [1]Modules > Module Manager[/1] and configure your menu module.'|trans({ - '[1]': '', - '[/1]': '' - }, 'Admin.Catalog.Help')|raw }} - -
    -
    - - {% if categoryForm.id_parent is defined %} -
    - -
    - {{ form_widget(categoryForm.id_parent) }} -
    -
    - {% endif %} - - {{ ps.form_group_row(categoryForm.description, {}, { - 'label': 'Description'|trans({}, 'Admin.Global'), - 'help': 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>;=#{}' - }) }} - -
    - -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/cover_image.html.twig' %} - - {{ form_widget(categoryForm.cover_image) }} - - - {{ 'This is the main image for your category, displayed in the category page. The category description will overlap this image and appear in its top-left corner.'|trans({}, 'Admin.Catalog.Help') }} - -
    -
    - -
    - -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/thumbnail_image.html.twig' %} - - {{ form_widget(categoryForm.thumbnail_image) }} - - - {{ 'Displays a small image in the parent category\'s page, if the theme allows it.'|trans({}, 'Admin.Catalog.Help') }} - -
    -
    - -
    - -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/menu_thumbnail_images.html.twig' %} - - {% if allowMenuThumbnailsUpload %} - {{ form_widget(categoryForm.menu_thumbnail_images) }} - {% else %} - {{ form_widget(categoryForm.menu_thumbnail_images, {'attr': {'class': 'd-none'}}) }} - - - {% endif %} - - {{ 'The category thumbnail appears in the menu as a small image representing the category, if the theme allows it.'|trans({}, 'Admin.Catalog.Help') }} - -
    -
    - - {{ renderhook('displayBackOfficeCategory') }} - - {% block category_tool_serp %} -
    - -
    -
    - - {{ 'Here is a preview of how your page will appear in search engine results.'|trans({}, 'Admin.Global') }} - -
    -
    - {% endblock %} - -
    - {{ ps.label_with_help(('Meta title'|trans({}, 'Admin.Global')), ('Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>;=#{}')) }} -
    - {{ form_widget(categoryForm.meta_title) }} -
    -
    - -
    - {{ ps.label_with_help(('Meta description'|trans({}, 'Admin.Global')), ('Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>;=#{}')) }} -
    - {{ form_widget(categoryForm.meta_description) }} -
    -
    - - {% set metaKeywordHelp %} - {{ 'To add tags, click in the field, write something, and then press the "Enter" key.'|trans({}, 'Admin.Shopparameters.Help') }} - {{ 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>;=#{}' }} - {% endset %} - - {{ ps.form_group_row(categoryForm.meta_keyword, {}, { - 'label': 'Meta keywords'|trans({}, 'Admin.Global'), - 'help': metaKeywordHelp - }) }} - - {{ ps.form_group_row(categoryForm.link_rewrite, {}, { - 'label': 'Friendly URL'|trans({}, 'Admin.Global'), - 'help': 'Only letters, numbers, underscore (_) and the minus (-) character are allowed.'|trans({}, 'Admin.Catalog.Help') - }) }} - - {{ ps.form_group_row(categoryForm.group_association, {}, { - 'label': 'Group access'|trans({}, 'Admin.Catalog.Feature'), - 'help': 'Mark all of the customer groups which you would like to have access to this category.'|trans({}, 'Admin.Catalog.Help') - }) }} - -
    - -
    -
    -

    - {{ 'You now have three default customer groups.'|trans({}, 'Admin.Catalog.Help') }} -

    - -

    {{ '%group_name% - All people without a valid customer account.'|trans({'%group_name%': '' ~ defaultGroups.visitorsGroup.name ~ ''}, 'Admin.Catalog.Feature')|raw }}

    -

    {{ '%group_name% - Customer who placed an order with the guest checkout.'|trans({'%group_name%': '' ~ defaultGroups.guestsGroup.name ~ ''}, 'Admin.Catalog.Feature')|raw }}

    -

    {{ '%group_name% - All people who have created an account on this site.'|trans({'%group_name%': '' ~ defaultGroups.customersGroup.name ~ ''}, 'Admin.Catalog.Feature')|raw }}

    -
    -
    -
    - - {% if categoryForm.shop_association is defined %} -
    - -
    - {{ form_widget(categoryForm.shop_association) }} -
    -
    - {% endif %} - - {% block category_form_rest %} - {{ form_rest(categoryForm) }} - {% endblock %} -
    -
    - -
    -{{ form_end(categoryForm) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/javascripts.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/javascripts.html.twig deleted file mode 100644 index 3848082d..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/javascripts.html.twig +++ /dev/null @@ -1,28 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block category_javascript_block %} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/listing_panel_footer.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/listing_panel_footer.html.twig deleted file mode 100644 index 97f64112..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/listing_panel_footer.html.twig +++ /dev/null @@ -1,37 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if app.request.query.has('id_category') and not currentCategoryView.is_home_category %} - {% if currentCategoryView.id_parent %} - {% set params = {'id_category': currentCategoryView.id_parent} %} - {% endif %} - - -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/menu_thumbnail_images.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/menu_thumbnail_images.html.twig deleted file mode 100644 index 5b95ff65..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/menu_thumbnail_images.html.twig +++ /dev/null @@ -1,47 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block category_menu_thumbnails %} - {% if menuThumbnailImages is defined and menuThumbnailImages is not empty %} -
    - {% for menuThumbnail in menuThumbnailImages %} -
    - -
    - -
    -
    - {% endfor %} -
    - {% endif %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/showcase_card.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/showcase_card.html.twig deleted file mode 100644 index 82e74a75..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/showcase_card.html.twig +++ /dev/null @@ -1,48 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if not isShowcaseCardClosed %} -
    -
    - -
    -
    -

    {{ 'Set categories'|trans({}, 'Admin.Catalog.Feature') }}

    -

    {{ 'Categories are essential, as they enable you to group equivalent products. This helps customers find their way through the variety of your catalog.'|trans({}, 'Admin.Catalog.Feature') }}

    - - {{ 'Learn more'|trans({}, 'Admin.Actions') }} - -
    - - close - -
    -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/thumbnail_image.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/thumbnail_image.html.twig deleted file mode 100644 index 1c768efb..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/Blocks/thumbnail_image.html.twig +++ /dev/null @@ -1,35 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block category_thumbnail_image %} - {% if thumbnailImage is defined and thumbnailImage is not null %} -
    -
    - -
    {{ 'File size'|trans({}, 'Admin.Advparameters.Feature') }} {{ thumbnailImage.size }}
    -
    -
    - {% endif %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/create.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/create.html.twig deleted file mode 100644 index 8856f4e0..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/create.html.twig +++ /dev/null @@ -1,42 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set layoutTitle = 'Add new'|trans({}, 'Admin.Actions') %} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/javascripts.html.twig' %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/create_root.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/create_root.html.twig deleted file mode 100644 index e3821ec3..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/create_root.html.twig +++ /dev/null @@ -1,42 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set layoutTitle = 'Add new'|trans({}, 'Admin.Actions') %} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/form.html.twig' with {'categoryForm': rootCategoryForm} %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/javascripts.html.twig' %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/edit.html.twig deleted file mode 100644 index 373ee15a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/edit.html.twig +++ /dev/null @@ -1,47 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set layoutTitle = 'Edit: %value%'|trans({'%value%': editableCategory.name[contextLangId]}, 'Admin.Catalog.Feature') %} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/form.html.twig' with { - 'categoryForm': editCategoryForm, - 'thumbnailImage': editableCategory.thumbnailImage, - 'coverImage': editableCategory.coverImage, - 'menuThumbnailImages': editableCategory.menuThumbnailImages, - } %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/javascripts.html.twig' %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/edit_root.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/edit_root.html.twig deleted file mode 100644 index 22f7ee59..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/edit_root.html.twig +++ /dev/null @@ -1,47 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set layoutTitle = 'Edit: %value%'|trans({'%value%': editableCategory.name[contextLangId]}, 'Admin.Catalog.Feature') %} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/form.html.twig' with { - 'categoryForm': editRootCategoryForm, - 'thumbnailImage': editableCategory.thumbnailImage, - 'coverImage': editableCategory.coverImage, - 'menuThumbnailImages': editableCategory.menuThumbnailImages, - } %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/javascripts.html.twig' %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/index.html.twig deleted file mode 100644 index fda2d3b9..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Categories/index.html.twig +++ /dev/null @@ -1,86 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% if not currentCategoryView.is_home_category %} - {% set layoutTitle = currentCategoryView.name %} -{% endif %} - -{% block content %} - {% block category_showcase_card %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/showcase_card.html.twig' %} -
    -
    - {% endblock %} - - {% block categories_kpis %} -
    -
    -
    -
    - {{ render(controller( - 'PrestaShopBundle:Admin\\Common:renderKpiRow', - { 'kpiRow': categoriesKpi } - )) }} -
    -
    -
    -
    - {% endblock %} - - {% block categories_breadcrumb %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/breadcrumb.html.twig' %} -
    -
    - {% endblock %} - - {% block categories_listing %} -
    -
    - {% embed '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': categoriesGrid} %} - {% block grid_panel_footer %} - {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/listing_panel_footer.html.twig' %} - {% endblock %} - - {% block grid_panel_extra_content %} - {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/delete_categories_modal.html.twig' %} - {% endblock %} - {% endembed %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Features/Blocks/disabled_feature_warning.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Features/Blocks/disabled_feature_warning.html.twig deleted file mode 100644 index 6a51108e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Features/Blocks/disabled_feature_warning.html.twig +++ /dev/null @@ -1,35 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set href = path('admin_performance') ~ '#optional_features' %} -{% set linkText = 'Performance'|trans({}, 'Admin.Global') %} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Features/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Features/Blocks/form.html.twig deleted file mode 100644 index a227d9ec..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Features/Blocks/form.html.twig +++ /dev/null @@ -1,69 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import 'PrestaShopBundle:Admin:macros.html.twig' as ps %} - -{% block feature_form_block %} - {{ form_start(featureForm) }} - -
    -

    - {{ 'Feature'|trans({}, 'Admin.Catalog.Feature') }} -

    - -
    -
    - {{ ps.form_group_row(featureForm.name, {}, { - 'label': 'Name'|trans({}, 'Admin.Global'), - 'help': 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>={}' - }) }} - - {{ renderhook('displayFeatureForm', {'id_feature': featureId}) }} - - {% if featureForm.shop_association is defined %} - {{ ps.form_group_row(featureForm.shop_association, {}, { - 'label': 'Shop association'|trans({}, 'Admin.Global') - }) }} - {% endif %} - - {% block feature_form_rest %} - {{ form_rest(featureForm) }} - {% endblock %} -
    -
    - - -
    - - {{ form_end(featureForm) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Features/Blocks/form_javascripts.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Features/Blocks/form_javascripts.html.twig deleted file mode 100644 index 4c5c4cd4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Features/Blocks/form_javascripts.html.twig +++ /dev/null @@ -1,28 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block feature_javascript_block %} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Features/create.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Features/create.html.twig deleted file mode 100644 index ca3b175c..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Features/create.html.twig +++ /dev/null @@ -1,48 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set layoutTitle = 'Add a new feature'|trans({}, 'Admin.Catalog.Feature') %} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} - {% if showDisabledFeatureWarning is defined and showDisabledFeatureWarning %} - {% include '@PrestaShop/Admin/Sell/Catalog/Features/Blocks/disabled_feature_warning.html.twig' %} - {% else %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Features/Blocks/form.html.twig' with { - featureId: null, - featureForm: featureForm - } %} -
    -
    - {% endif %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - {% include '@PrestaShop/Admin/Sell/Catalog/Features/Blocks/form_javascripts.html.twig' %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Features/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Features/edit.html.twig deleted file mode 100644 index e1a768c7..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Features/edit.html.twig +++ /dev/null @@ -1,48 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set layoutTitle = 'Edit: %value%'|trans({'%value%': editableFeature.name[contextLangId]}, 'Admin.Catalog.Feature') %} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} - {% if showDisabledFeatureWarning is defined and showDisabledFeatureWarning %} - {% include '@PrestaShop/Admin/Sell/Catalog/Features/Blocks/disabled_feature_warning.html.twig' %} - {% else %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Features/Blocks/form.html.twig' with { - featureId: editableFeature.featureId.getValue, - featureForm: featureForm - } %} -
    -
    - {% endif %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - {% include '@PrestaShop/Admin/Sell/Catalog/Features/Blocks/form_javascripts.html.twig' %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Address/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Address/Blocks/form.html.twig deleted file mode 100644 index e358da40..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Address/Blocks/form.html.twig +++ /dev/null @@ -1,120 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{{ form_start(addressForm) }} -
    -
    - {{ 'Addresses'|trans({}, 'Admin.Catalog.Feature') }} -
    -
    -
    - {{ form_errors(addressForm) }} - - {{ ps.form_group_row(addressForm.id_manufacturer, {}, { - 'label': 'Brand'|trans({}, 'Admin.Catalog.Feature'), - }) }} - - {% set nameHint = 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' 0-9!<>,;?=+()@#"�{}_$%:' %} - - {{ ps.form_group_row(addressForm.last_name, {}, { - 'label': 'Last name'|trans({}, 'Admin.Global'), - 'help': nameHint - }) }} - - {{ ps.form_group_row(addressForm.first_name, {}, { - 'label': 'First name'|trans({}, 'Admin.Global'), - 'help': nameHint - }) }} - - {{ ps.form_group_row(addressForm.address, {}, { - 'label': 'Address'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(addressForm.address2, {}, { - 'label': 'Address (2)'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(addressForm.post_code, {}, { - 'label': 'Zip/postal code'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(addressForm.city, {}, { - 'label': 'City'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(addressForm.id_country, {'attr': { - 'class': 'js-manufacturer-country-select', - 'data-states-url': path('admin_country_states') }}, { - 'label': 'Country'|trans({}, 'Admin.Global'), - }) }} - -
    - {{ ps.form_group_row(addressForm.id_state, {}, { - 'label': 'State'|trans({}, 'Admin.Global'), - }) }} -
    - - {{ ps.form_group_row(addressForm.dni, {}, { - 'label': 'DNI'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(addressForm.home_phone, {}, { - 'label': 'Home phone'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(addressForm.mobile_phone, {}, { - 'label': 'Mobile phone'|trans({}, 'Admin.Global'), - }) }} - - {% set otherHint %} - {{ 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>{}' }} - {% endset %} - - {{ ps.form_group_row(addressForm.other, {}, { - 'label': 'Other'|trans({}, 'Admin.Global'), - 'help': otherHint - }) }} - - {% block manufacturer_address_form_rest %} - {{ form_rest(addressForm) }} - {% endblock %} -
    -
    - - - -
    -{{ form_end(addressForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Address/create.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Address/create.html.twig deleted file mode 100644 index 10d76961..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Address/create.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Manufacturer/Address/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Address/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Address/edit.html.twig deleted file mode 100644 index 10d76961..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Address/edit.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Manufacturer/Address/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Blocks/View/addresses.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Blocks/View/addresses.html.twig deleted file mode 100644 index f028a753..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Blocks/View/addresses.html.twig +++ /dev/null @@ -1,80 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - {{ 'Addresses'|trans({}, 'Admin.Global') }} - ({{ viewableManufacturer.manufacturerAddresses|length }}) -

    -
    - {% if viewableManufacturer.manufacturerAddresses is not empty %} - - - - - - - - - - - - - - - - {% for address in viewableManufacturer.manufacturerAddresses %} - - - - - - - - - - - - {% endfor %} - -
    {{ 'Name'|trans({}, 'Admin.Global') }}{{ 'Address'|trans({}, 'Admin.Global') }}{{ 'Address (2)'|trans({}, 'Admin.Global') }}{{ 'City'|trans({}, 'Admin.Global') }}{{ 'State'|trans({}, 'Admin.Global') }}{{ 'Home phone'|trans({}, 'Admin.Global') }}{{ 'Mobile phone'|trans({}, 'Admin.Global') }}{{ 'Other'|trans({}, 'Admin.Global') }}
    {{ address.first_name }} {{ address.last_name }}{{ address.address1 }}{{ address.address2 }}{{ address.city }}{% if address.state %}{{ address.state }}{% else %}-{% endif %}{% if address.phone %}{{ address.phone }}{% else %}-{% endif %}{% if address.phone_mobile %}{{ address.phone_mobile }}{% else %}-{% endif %}{% if address.other %}{{ address.other|nl2br }}{% else %}-{% endif %} -
    - -
    -
    - {% else %} - {{ 'No address has been found for this brand.'|trans({}, 'Admin.Catalog.Notification') }} - {% endif %} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Blocks/View/products.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Blocks/View/products.html.twig deleted file mode 100644 index 09f9d9ac..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Blocks/View/products.html.twig +++ /dev/null @@ -1,120 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - {{ 'Products'|trans({}, 'Admin.Global') }} - ({{ viewableManufacturer.manufacturerProducts|length }}) -

    -
    - {% for product in viewableManufacturer.manufacturerProducts %} -
    -
    - {{ product.name }} - -
    -
    -
    - - -
    -
    -
    -
    -
    - {% if product.combinations is not empty %} - - - - - - - - - {% if not isAllShopContext and isStockManagementEnabled %} - - {% endif %} - - - - {% for combination in product.combinations %} - - - - - - - {% if not isAllShopContext and isStockManagementEnabled %} - - {% endif %} - - {% endfor %} - -
    {{ 'Attribute name'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Reference'|trans({}, 'Admin.Global') }}{{ 'EAN13'|trans({}, 'Admin.Catalog.Feature') }}{{ 'UPC'|trans({}, 'Admin.Catalog.Feature') }}{{ 'MPN'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Available quantity'|trans({}, 'Admin.Catalog.Feature') }}
    {{ combination.attributes }}{{ combination.reference }}{{ combination.ean13 }}{{ combination.upc }}{{ combination.mpn }}{{ combination.quantity }}
    - {% else %} - - - - - - - - {% if isStockManagementEnabled %} - - {% endif %} - - - - - - - - - {% if isStockManagementEnabled %} - - {% endif %} - - -
    {{ 'Ref:'|trans({}, 'Admin.Catalog.Feature') }}{{ 'EAN13:'|trans({}, 'Admin.Catalog.Feature') }}{{ 'UPC:'|trans({}, 'Admin.Catalog.Feature') }}{{ 'MPN:'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Qty:'|trans({}, 'Admin.Catalog.Feature') }}
    {{ product.reference }}{{ product.ean13 }}{{ product.upc }}{{ product.mpn }}{{ product.quantity }}
    - {% endif %} -
    -
    - {% endfor %} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Blocks/form.html.twig deleted file mode 100644 index 160a0a78..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/Blocks/form.html.twig +++ /dev/null @@ -1,121 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{{ form_start(manufacturerForm) }} -
    -

    - star - {{ 'Brands'|trans({}, 'Admin.Catalog.Feature') }} -

    -
    -
    - {{ form_errors(manufacturerForm) }} - - {% set invalidCatalogNameHint %} - {{ 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>;=#{}' }} - {% endset %} - - {{ ps.form_group_row(manufacturerForm.name, {}, { - 'label': 'Name'|trans({}, 'Admin.Global'), - 'help': invalidCatalogNameHint - }) }} - - {% set invalidGenericNameHint %} - {{ 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>={}' }} - {% endset %} - - {{ ps.form_group_row(manufacturerForm.short_description, {}, { - 'label': 'Short description'|trans({}, 'Admin.Catalog.Feature'), - }) }} - - {{ ps.form_group_row(manufacturerForm.description, {}, { - 'label': 'Description'|trans({}, 'Admin.Global') - }) }} - - {% set logoHint %} - {{ 'Upload a brand logo from your computer.'|trans({}, 'Admin.Catalog.Help') }} - {% endset %} - - {{ ps.form_group_row(manufacturerForm.logo, {}, { - 'label': 'Logo'|trans({}, 'Admin.Global'), - 'help': logoHint - }) }} - - {% if logoImage is defined and logoImage is not null %} -
    - -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Manufacturer/logo_image.html.twig' %} -
    -
    - {% endif %} - - {{ ps.form_group_row(manufacturerForm.meta_title, {}, { - 'label': 'Meta title'|trans({}, 'Admin.Catalog.Feature'), - 'help': invalidGenericNameHint - }) }} - - {{ ps.form_group_row(manufacturerForm.meta_description, {}, { - 'label': 'Meta description'|trans({}, 'Admin.Global'), - 'help': invalidGenericNameHint - }) }} - - {% set keywordHint %} - {{ 'To add tags, click in the field, write something, and then press the "Enter" key.'|trans({}, 'Admin.Shopparameters.Help') }} - {{ invalidGenericNameHint }} - {% endset %} - - {{ ps.form_group_row(manufacturerForm.meta_keyword, {}, { - 'label': 'Meta keywords'|trans({}, 'Admin.Global'), - 'help': keywordHint - }) }} - - {{ ps.form_group_row(manufacturerForm.is_enabled, {}, { - 'label': 'Enabled'|trans({}, 'Admin.Global') - }) }} - - {% if manufacturerForm.shop_association is defined %} - {{ ps.form_group_row(manufacturerForm.shop_association, {}, { - 'label': 'Shop association'|trans({}, 'Admin.Global') - }) }} - {% endif %} - - {% block manufacturer_form_rest %} - {{ form_rest(manufacturerForm) }} - {% endblock %} -
    -
    - -
    -{{ form_end(manufacturerForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/add.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/add.html.twig deleted file mode 100644 index 208244a2..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/add.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set enableSidebar = true %} -{% set layoutTitle = 'Add new'|trans({}, 'Admin.Actions') %} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Manufacturer/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/edit.html.twig deleted file mode 100644 index 94f863aa..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/edit.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set enableSidebar = true %} -{% set layoutTitle = 'Edit: %name%'|trans({'%name%': manufacturerName}, 'Admin.Actions') %} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Manufacturer/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/index.html.twig deleted file mode 100644 index e16b8f36..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/index.html.twig +++ /dev/null @@ -1,66 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% set layoutHeaderToolbarBtn = { - add_manufacturer: { - href: path('admin_manufacturers_create'), - desc: 'Add new brand'|trans({}, 'Admin.Catalog.Feature'), - icon: 'add_circle_outline', - }, - add_manufacturer_address: { - href: path('admin_manufacturer_addresses_create'), - desc: 'Add new brand address'|trans({}, 'Admin.Catalog.Feature'), - icon: 'add_circle_outline', - }, -} -%} - -{% block content %} - {% block manufacturers_listing %} - {{ ps.infotip(settingsTipMessage, true) }} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': manufacturerGrid} %} -
    -
    - {% endblock %} - - {% block manufacturers_address_listing %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': manufacturerAddressGrid} %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/logo_image.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/logo_image.html.twig deleted file mode 100644 index da8e989b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/logo_image.html.twig +++ /dev/null @@ -1,28 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    - -
    {{ 'File size'|trans({}, 'Admin.Advparameters.Feature') }} {{ logoImage.size }}
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/view.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/view.html.twig deleted file mode 100644 index a413ed91..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/view.html.twig +++ /dev/null @@ -1,46 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Manufacturer/Blocks/View/addresses.html.twig' %} -
    -
    - -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Manufacturer/Blocks/View/products.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Monitoring/Blocks/showcase_card.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Monitoring/Blocks/showcase_card.html.twig deleted file mode 100644 index afbb4ad3..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Monitoring/Blocks/showcase_card.html.twig +++ /dev/null @@ -1,48 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if not isShowcaseCardClosed %} -
    -
    - -
    -
    -

    {{ 'Focus on your catalog'|trans({}, 'Admin.Catalog.Feature') }}

    -

    {{ 'Empty categories, disabled products, items that lack image or price... check the monitoring section to optimize your products management and make sure you forgot nothing.'|trans({}, 'Admin.Catalog.Feature') }}

    - - {{ 'Learn more'|trans({}, 'Admin.Actions') }} - -
    - - close - -
    -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Monitoring/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Monitoring/index.html.twig deleted file mode 100644 index 0829c629..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Monitoring/index.html.twig +++ /dev/null @@ -1,120 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} - {% block monitoring_showcase_card %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Monitoring/Blocks/showcase_card.html.twig' %} -
    -
    - {% endblock %} - - {% block empty_categories_listing %} -
    -
    - {% embed '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': emptyCategoryGrid} %} - - {% block grid_panel_body %} -
    -
    -
    - {{ 'An empty category is a category that has no product directly associated to it. An empty category may however contain products through its subcategories.'|trans({}, 'Admin.Catalog.Help') }} -
    -
    - {% block grid_view_block %} - {{ include('@PrestaShop/Admin/Common/Grid/grid.html.twig', {'grid': emptyCategoryGrid }) }} - {% endblock %} -
    - {% endblock %} - - {% block grid_panel_extra_content %} - {% include '@PrestaShop/Admin/Sell/Catalog/Categories/Blocks/delete_categories_modal.html.twig' - with {'deleteCategoriesForm': deleteCategoryForm } - %} - {% endblock %} - {% endembed %} -
    -
    - {% endblock %} - - {% block no_qty_product_with_combinations_listing %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': noQtyProductWithCombinationGrid} %} -
    -
    - {% endblock %} - - {% block no_qty_product_without_combinations_listing %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': noQtyProductWithoutCombinationGrid} %} -
    -
    - {% endblock %} - - {% block disabled_product_listing %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': disabledProductGrid} %} -
    -
    - {% endblock %} - - {% block product_without_image_listing %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': productWithoutImageGrid} %} -
    -
    - {% endblock %} - - {% block product_without_description_listing %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': productWithoutDescriptionGrid} %} -
    -
    - {% endblock %} - - {% block product_without_price_listing %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': productWithoutPriceGrid} %} -
    -
    - {% endblock %} - -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/Blocks/View/products.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/Blocks/View/products.html.twig deleted file mode 100644 index e6ff545b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/Blocks/View/products.html.twig +++ /dev/null @@ -1,92 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - {{ 'Products'|trans({}, 'Admin.Global') }} - ({{ viewableSupplier.supplierProducts|length }}) -

    -
    - {% for product in viewableSupplier.supplierProducts %} -
    - -
    - - - - - - - - - - {% if not isAllShopContext and isStockManagementEnabled %} - - {% endif %} - - - - {% if product.combinations is not empty %} - {% for combination in product.combinations %} - - - - - - - - {% if not isAllShopContext and isStockManagementEnabled %} - - {% endif %} - - {% endfor %} - {% else %} - - - - - - - - {% if not isAllShopContext and isStockManagementEnabled %} - - {% endif %} - - {% endif %} - -
    {{ 'Attribute name'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Supplier reference'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Wholesale price'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Reference'|trans({}, 'Admin.Global') }}{{ 'EAN13'|trans({}, 'Admin.Catalog.Feature') }}{{ 'UPC'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Available quantity'|trans({}, 'Admin.Catalog.Feature') }}
    {{ combination.attributes|default('N/A'|trans({}, 'Admin.Global')) }}{{ combination.supplier_reference|default('N/A'|trans({}, 'Admin.Global')) }}{{ combination.wholesale_price|default('N/A'|trans({}, 'Admin.Global')) }}{{ combination.reference|default('N/A'|trans({}, 'Admin.Global')) }}{{ combination.ean13|default('N/A'|trans({}, 'Admin.Global')) }}{{ combination.upc|default('N/A'|trans({}, 'Admin.Global')) }}{{ combination.quantity|default('N/A'|trans({}, 'Admin.Global')) }}
    {{ product.combinations|default('N/A'|trans({}, 'Admin.Global')) }}{{ product.supplier_reference|default('N/A'|trans({}, 'Admin.Global')) }}{{ product.wholesale_price|default('N/A'|trans({}, 'Admin.Global')) }}{{ product.reference|default('N/A'|trans({}, 'Admin.Global')) }}{{ product.ean13|default('N/A'|trans({}, 'Admin.Global')) }}{{ product.upc|default('N/A'|trans({}, 'Admin.Global')) }}{{ product.quantity|default('N/A'|trans({}, 'Admin.Global')) }}
    -
    -
    - {% endfor %} - {% if viewableSupplier.supplierProducts is empty %} -
    -

    warning

    -

    {{ 'No records found'|trans({}, 'Admin.Global') }}

    -
    - {% endif %} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/Blocks/form.html.twig deleted file mode 100644 index 84a83576..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/Blocks/form.html.twig +++ /dev/null @@ -1,162 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{{ form_start(supplierForm) }} -
    -

    - local_shipping - {{ 'Suppliers'|trans({}, 'Admin.Global') }} -

    -
    -
    - - {% set invalidCatalogNameHint %} - {{ 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>;=#{}' }} - {% endset %} - - {{ ps.form_group_row(supplierForm.name, {}, { - 'label': 'Name'|trans({}, 'Admin.Global'), - 'help': invalidCatalogNameHint - }) }} - - {% set invalidGenericNameHint %} - {{ 'Invalid characters:'|trans({}, 'Admin.Notifications.Info') ~ ' <>={}' }} - {% endset %} - - {% set descriptionHint %} - {% autoescape false %} - {{ 'Will appear in the list of suppliers.'|trans({}, 'Admin.Catalog.Help')~ invalidCatalogNameHint }} - {% endautoescape %} - {% endset %} - - {{ ps.form_group_row(supplierForm.description, {}, { - 'label': 'Description'|trans({}, 'Admin.Global'), - 'help': descriptionHint - }) }} - - {{ ps.form_group_row(supplierForm.phone, {}, { - 'label': 'Home phone'|trans({}, 'Admin.Global'), - 'hint': 'Phone number for this supplier'|trans({}, 'Admin.Catalog.Help') - }) }} - - {{ ps.form_group_row(supplierForm.mobile_phone, {}, { - 'label': 'Mobile phone'|trans({}, 'Admin.Global'), - 'hint': 'Mobile phone number for this supplier.'|trans({}, 'Admin.Catalog.Help') - }) }} - - {{ ps.form_group_row(supplierForm.address, {}, { - 'label': 'Address'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(supplierForm.address2, {}, { - 'label': 'Address (2)'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(supplierForm.post_code, {}, { - 'label': 'Zip/postal code'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(supplierForm.city, {}, { - 'label': 'City'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(supplierForm.id_country, {'attr': { - 'class': 'js-supplier-country-select', - 'data-states-url': path('admin_country_states') }}, { - 'label': 'Country'|trans({}, 'Admin.Global'), - }) }} - -
    - {{ ps.form_group_row(supplierForm.id_state, {}, { - 'label': 'State'|trans({}, 'Admin.Global'), - }) }} -
    - - {{ ps.form_group_row(supplierForm.dni, {}, { - 'label': 'DNI'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(supplierForm.logo, {}, { - 'label': 'Logo'|trans({}, 'Admin.Global'), - 'help': 'Upload a supplier logo from your computer.'|trans({}, 'Admin.Catalog.Help') - }) }} - - {% if logoImage is defined and logoImage is not null %} -
    - -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Suppliers/logo_image.html.twig' %} -
    -
    - {% endif %} - - {{ ps.form_group_row(supplierForm.meta_title, {}, { - 'label': 'Meta title'|trans({}, 'Admin.Catalog.Feature'), - 'help': invalidGenericNameHint - }) }} - - {{ ps.form_group_row(supplierForm.meta_description, {}, { - 'label': 'Meta description'|trans({}, 'Admin.Global'), - 'help': invalidGenericNameHint - }) }} - - {% set keywordHint %} - {{ 'To add tags, click in the field, write something, and then press the "Enter" key.'|trans({}, 'Admin.Shopparameters.Help') }} - {{ invalidGenericNameHint }} - {% endset %} - - {{ ps.form_group_row(supplierForm.meta_keyword, {}, { - 'label': 'Meta keywords'|trans({}, 'Admin.Global'), - 'help': keywordHint - }) }} - - {{ ps.form_group_row(supplierForm.is_enabled, {}, { - 'label': 'Enabled'|trans({}, 'Admin.Global') - }) }} - - {% if supplierForm.shop_association is defined %} - {{ ps.form_group_row(supplierForm.shop_association, {}, { - 'label': 'Shop association'|trans({}, 'Admin.Global') - }) }} - {% endif %} - - {% block supplier_form_rest %} - {{ form_rest(supplierForm) }} - {% endblock %} - -
    -
    - -
    - {{ form_end(supplierForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/add.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/add.html.twig deleted file mode 100644 index 6b471172..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/add.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set enableSidebar = true %} -{% set layoutTitle = 'Add new'|trans({}, 'Admin.Actions') %} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Suppliers/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/edit.html.twig deleted file mode 100644 index 12715260..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/edit.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set enableSidebar = true %} -{% set layoutTitle = 'Edit: %name%'|trans({'%name%': supplierName}, 'Admin.Actions') %} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Suppliers/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/index.html.twig deleted file mode 100644 index 1720cc1e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/index.html.twig +++ /dev/null @@ -1,53 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% set layoutHeaderToolbarBtn = { - add: { - href: path('admin_suppliers_create'), - desc: 'Add new supplier'|trans({}, 'Admin.Catalog.Feature'), - icon: 'add_circle_outline', - } -} -%} - -{% block content %} - {% block supplier_grid %} - {{ ps.infotip(settingsTipMessage, true) }} -
    -
    - {% include'@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': supplierGrid} %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/logo_image.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/logo_image.html.twig deleted file mode 100644 index da8e989b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/logo_image.html.twig +++ /dev/null @@ -1,28 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
    - -
    {{ 'File size'|trans({}, 'Admin.Advparameters.Feature') }} {{ logoImage.size }}
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/view.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/view.html.twig deleted file mode 100644 index 6db0572a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Suppliers/view.html.twig +++ /dev/null @@ -1,34 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Catalog/Suppliers/Blocks/View/products.html.twig' %} -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/Index/required_fields.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/Index/required_fields.html.twig deleted file mode 100644 index 47b16f8c..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/Index/required_fields.html.twig +++ /dev/null @@ -1,49 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    - {{ form_start(customerRequiredFieldsForm, {'action': path('admin_customers_set_required_fields')}) }} -
    -

    - {{ 'Required Fields'|trans({}, 'Admin.Orderscustomers.Feature') }} -

    -
    - - - {{ form_widget(customerRequiredFieldsForm.required_fields) }} -
    - -
    - {{ form_end(customerRequiredFieldsForm) }} -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/addresses.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/addresses.html.twig deleted file mode 100644 index 5b559ee7..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/addresses.html.twig +++ /dev/null @@ -1,120 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - location_on - {{ 'Addresses'|trans({}, 'Admin.Global') }} - - - add_circle - -

    - -
    - {% if customerInformation.addressesInformation is not empty %} - - - - - - - - - - - - - {% for address in customerInformation.addressesInformation %} - {% set addressEditUrl = getAdminLink('AdminAddresses', true, {'id_address': address.addressId, 'updateaddress': 1, 'back': app.request.uri}) %} - - - - - - - - - - {% endfor %} - -
    {{ 'Company'|trans({}, 'Admin.Global') }}{{ 'Name'|trans({}, 'Admin.Global') }}{{ 'Address'|trans({}, 'Admin.Global') }}{{ 'Country'|trans({}, 'Admin.Global') }}{{ 'Phone number(s)'|trans({}, 'Admin.Orderscustomers.Feature') }}{{ 'Actions'|trans({}, 'Admin.Global') }}
    {{ address.company }}{{ address.fullName }}{{ address.fullAddress }}{{ address.countryName }} - {% if address.phone %} - {{ address.phone }} - {% if address.phoneMobile is not empty %} -
    {{ address.phoneMobile }} - {% endif %} - {% elseif address.phoneMobile is not empty %} - {{ address.phoneMobile }} - {% else %} - -- - {% endif %} -
    -
    -
    - - edit - - - - - -
    -
    -
    - {% else %} -

    - {{ '%firstname% %lastname% has not registered any addresses yet'|trans({'%firstname%': customerInformation.personalInformation.firstName, '%lastname%': customerInformation.personalInformation.lastName}, 'Admin.Orderscustomers.Feature') }} -

    - {% endif %} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/bought_products.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/bought_products.html.twig deleted file mode 100644 index 7862f5fa..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/bought_products.html.twig +++ /dev/null @@ -1,58 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if customerInformation.productsInformation.boughtProductsInformation is not empty %} -
    -

    - attach_money - {{ 'Purchased products'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ customerInformation.productsInformation.boughtProductsInformation|length }} -

    -
    - - - - - - - - - - {% for product in customerInformation.productsInformation.boughtProductsInformation %} - - - - - - {% endfor %} - -
    {{ 'Date'|trans({}, 'Admin.Global') }}{{ 'Name'|trans({}, 'Admin.Global') }}{{ 'Quantity'|trans({}, 'Admin.Global') }}
    {{ product.boughtDate }} - - {{ product.productName }} - - {{ product.boughtQuantity }}
    -
    -
    -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/carts.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/carts.html.twig deleted file mode 100644 index 0060d302..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/carts.html.twig +++ /dev/null @@ -1,77 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - shopping_cart - {{ 'Carts'|trans({}, 'Admin.Global') }} - {{ customerInformation.cartsInformation|length }} -

    -
    - {% if customerInformation.cartsInformation is not empty %} - - - - - - - - - - - - {% for cart in customerInformation.cartsInformation %} - {% set cartViewUrl = getAdminLink('AdminCarts', true, {'id_cart': cart.cartId, 'viewcart': 1}) %} - - - - - - - - - {% endfor %} - -
    {{ 'ID'|trans({}, 'Admin.Global') }}{{ 'Date'|trans({}, 'Admin.Global') }}{{ 'Carrier'|trans({}, 'Admin.Global') }}{{ 'Total'|trans({}, 'Admin.Global') }}{{ 'Actions'|trans({}, 'Admin.Global') }}
    {{ cart.cartId }}{{ cart.cartCreationDate }}{{ cart.carrierName }}{{ cart.cartTotal }} - -
    - {% else %} -

    - {{ 'No cart is available'|trans({}, 'Admin.Orderscustomers.Notification') }} -

    - {% endif %} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/discounts.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/discounts.html.twig deleted file mode 100644 index 2ce78b44..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/discounts.html.twig +++ /dev/null @@ -1,104 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - loyalty - {{ 'Vouchers'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ customerInformation.discountsInformation|length }} -

    -
    - {% if customerInformation.discountsInformation is not empty %} - - - - - - - - - - - - - {% for discount in customerInformation.discountsInformation %} - {% set discountEditUrl = getAdminLink('AdminCartRules', true, {'id_cart_rule': discount.discountId, 'addcart_rule': 1, 'back': app.request.uri}) %} - - - - - - - - - - {% endfor %} - -
    {{ 'ID'|trans({}, 'Admin.Global') }}{{ 'Code'|trans({}, 'Admin.Global') }}{{ 'Name'|trans({}, 'Admin.Global') }}{{ 'Status'|trans({}, 'Admin.Global') }}{{ 'Qty available'|trans({}, 'Admin.Orderscustomers.Feature') }}{{ 'Actions'|trans({}, 'Admin.Global') }}
    {{ discount.discountId }}{{ discount.code }}{{ discount.name }} - {% if discount.active %} - - check - - {% else %} - - clear - - {% endif %} - {{ discount.availableQuantity }} - -
    - {% else %} -

    - {{ '%firstname% %lastname% has no discount vouchers'|trans({'%firstname%': customerInformation.personalInformation.firstName, '%lastname%': customerInformation.personalInformation.lastName}, 'Admin.Orderscustomers.Feature') }} -

    - {% endif %} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/groups.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/groups.html.twig deleted file mode 100644 index b1ac7d44..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/groups.html.twig +++ /dev/null @@ -1,69 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - group - {{ 'Groups'|trans({}, 'Admin.Global') }} - {{ customerInformation.groupsInformation|length }} - - - edit - -

    -
    - {% if customerInformation.groupsInformation is not empty %} - - - - - - - - - {% for group in customerInformation.groupsInformation %} - - - - - {% endfor %} - -
    {{ 'ID'|trans({}, 'Admin.Global') }}{{ 'Name'|trans({}, 'Admin.Global') }}
    {{ group.groupId }} - - {{ group.name }} - -
    - {% else %} -

    - {{ 'No cart is available'|trans({}, 'Admin.Orderscustomers.Notification') }} -

    - {% endif %} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/last_connections.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/last_connections.html.twig deleted file mode 100644 index d0a30053..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/last_connections.html.twig +++ /dev/null @@ -1,60 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if customerInformation.lastConnectionsInformation is not empty %} -
    -

    - access_time - {{ 'Last connections'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ customerInformation.lastConnectionsInformation|length }} -

    -
    - - - - - - - - - - - - - {% for connection in customerInformation.lastConnectionsInformation %} - - - - - - - - - {% endfor %} - -
    {{ 'ID'|trans({}, 'Admin.Global') }}{{ 'Date'|trans({}, 'Admin.Global') }}{{ 'Pages viewed'|trans({}, 'Admin.Orderscustomers.Feature') }}{{ 'Total time'|trans({}, 'Admin.Orderscustomers.Feature') }}{{ 'Origin'|trans({}, 'Admin.Orderscustomers.Feature') }}{{ 'IP Address'|trans({}, 'Admin.Orderscustomers.Feature') }}
    {{ connection.connectionId }}{{ connection.connectionDate }}{{ connection.pagesViewed }}{{ connection.totalTime }}{{ connection.httpReferer }}{{ connection.ipAddress }}
    -
    -
    -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/messages.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/messages.html.twig deleted file mode 100644 index 5f943eb9..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/messages.html.twig +++ /dev/null @@ -1,62 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - message - {{ 'Messages'|trans({}, 'Admin.Global') }} - {{ customerInformation.messagesInformation|length }} -

    -
    - {% if customerInformation.messagesInformation is not empty %} - - - - - - - - - - {% for message in customerInformation.messagesInformation %} - - - - - - {% endfor %} - -
    {{ 'Status'|trans({}, 'Admin.Global') }}{{ 'Message'|trans({}, 'Admin.Global') }}{{ 'Sent on'|trans({}, 'Admin.Orderscustomers.Feature') }}
    {{ message.status }} - - {{ message.message }}... - - {{ message.date }}
    - {% else %} -

    - {{ '%firstname% %lastname% has never contacted you'|trans({'%firstname%': customerInformation.personalInformation.firstName, '%lastname%': customerInformation.personalInformation.lastName}, 'Admin.Orderscustomers.Feature') }} -

    - {% endif %} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/orders.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/orders.html.twig deleted file mode 100644 index ebdd8ed4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/orders.html.twig +++ /dev/null @@ -1,156 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set validOrdersCount = customerInformation.ordersInformation.validOrders|length %} -{% set invalidOrdersCount = customerInformation.ordersInformation.invalidOrders|length %} -{% set ordersCount = validOrdersCount + invalidOrdersCount %} - -
    -

    - shopping_basket - {{ 'Orders'|trans({}, 'Admin.Global') }} - {{ ordersCount }} -

    -
    - {% if ordersCount > 0 %} -
    -
    -
    -
    - {{ 'Valid orders:'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ validOrdersCount }} - {% set totalAmount = ''~customerInformation.ordersInformation.totalSpent~'' %} - {{ 'for a total amount of %s'|trans({}, 'Admin.Orderscustomers.Feature')|format(totalAmount)|raw }} -
    -
    - {{ 'Invalid orders:'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ invalidOrdersCount }} -
    -
    -
    -
    - -
    -
    - {% if validOrdersCount %} - - - - - - - - - - - - - - {% for order in customerInformation.ordersInformation.validOrders %} - {% set orderViewUrl = getAdminLink('AdminOrders', true, {'id_order': order.orderId, 'vieworder': 1}) %} - - - - - - - - - - - {% endfor %} - -
    {{ 'ID'|trans({}, 'Admin.Global') }}{{ 'Date'|trans({}, 'Admin.Global') }}{{ 'Payment'|trans({}, 'Admin.Global') }}{{ 'Status'|trans({}, 'Admin.Global') }}{{ 'Products'|trans({}, 'Admin.Global') }}{{ 'Total spent'|trans({}, 'Admin.Orderscustomers.Feature') }}{{ 'Actions'|trans({}, 'Admin.Global') }}
    {{ order.orderId }}{{ order.orderPlacedDate }}{{ order.paymentMethodName }}{{ order.orderStatus }}{{ order.orderProductsCount }}{{ order.totalPaid }} - -
    - {% endif %} -
    -
    - -
    -
    - {% if invalidOrdersCount %} - - - - - - - - - - - - - - {% for order in customerInformation.ordersInformation.invalidOrders %} - {% set orderViewUrl = getAdminLink('AdminOrders', true, {'id_order': order.orderId, 'vieworder': 1}) %} - - - - - - - - - - - {% endfor %} - -
    {{ 'ID'|trans({}, 'Admin.Global') }}{{ 'Date'|trans({}, 'Admin.Global') }}{{ 'Payment'|trans({}, 'Admin.Global') }}{{ 'Status'|trans({}, 'Admin.Global') }}{{ 'Products'|trans({}, 'Admin.Global') }}{{ 'Total spent'|trans({}, 'Admin.Orderscustomers.Feature') }}{{ 'Actions'|trans({}, 'Admin.Global') }}
    {{ order.orderId }}{{ order.orderPlacedDate }}{{ order.paymentMethodName }}{{ order.orderStatus }}{{ order.orderProductsCount }}{{ order.totalPaid }} - -
    - {% endif %} -
    -
    - {% else %} -

    - {{ '%firstname% %lastname% has not placed any orders yet'|trans({'%firstname%': customerInformation.personalInformation.firstName, '%lastname%': customerInformation.personalInformation.lastName}, 'Admin.Orderscustomers.Feature') }} -

    - {% endif %} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/personal_information.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/personal_information.html.twig deleted file mode 100644 index af1a9cb4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/personal_information.html.twig +++ /dev/null @@ -1,184 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - person - {{ customerInformation.personalInformation.firstName }} - {{ customerInformation.personalInformation.lastName }} - {{ '[%06d]'|format(customerInformation.customerId.value) }} - - - - {{ customerInformation.personalInformation.email }} - - - - edit - -

    -
    -
    -
    - {{ 'Social Title'|trans({}, 'Admin.Global') }} -
    -
    - {{ customerInformation.personalInformation.socialTitle }} -
    -
    - -
    -
    - {{ 'Age'|trans({}, 'Admin.Orderscustomers.Feature') }} -
    -
    - {{ customerInformation.personalInformation.birthday }} -
    -
    - -
    -
    - {{ 'Registration Date'|trans({}, 'Admin.Orderscustomers.Feature') }} -
    -
    - {{ customerInformation.personalInformation.registrationDate }} -
    -
    - -
    -
    - {{ 'Last Visit'|trans({}, 'Admin.Orderscustomers.Feature') }} -
    -
    - {{ customerInformation.personalInformation.lastVisitDate }} -
    -
    - - {% if customerInformation.personalInformation.rankBySales %} -
    -
    - {{ 'Best Customer Rank'|trans({}, 'Admin.Orderscustomers.Feature') }} -
    -
    - {{ customerInformation.personalInformation.rankBySales }} -
    -
    - {% endif %} - - {% if isMultistoreEnabled %} -
    -
    - {{ 'Shop'|trans({}, 'Admin.Global') }} -
    -
    - {{ customerInformation.personalInformation.shopName }} -
    -
    - {% endif %} - -
    -
    - {{ 'Language'|trans({}, 'Admin.Global') }} -
    -
    - {{ customerInformation.personalInformation.languageName }} -
    -
    - -
    -
    - {{ 'Registrations'|trans({}, 'Admin.Orderscustomers.Feature') }} -
    -
    - {% set isNewsletterSubscribed = customerInformation.personalInformation.subscriptions.newsletterSubscribed %} - {% set isPartnerOffersSubscribed = customerInformation.personalInformation.subscriptions.partnerOffersSubscribed %} - - - {% if isNewsletterSubscribed %}check{% else %}cancel{% endif %} - {{ 'Newsletter'|trans({}, 'Admin.Global') }} - - - - {% if isPartnerOffersSubscribed %}check{% else %}cancel{% endif %} - {{ 'Partner offers'|trans({}, 'Admin.Orderscustomers.Feature') }} - -
    -
    - -
    -
    - {{ 'Latest Update'|trans({}, 'Admin.Orderscustomers.Feature') }} -
    -
    - {{ customerInformation.personalInformation.lastUpdateDate }} -
    -
    - -
    -
    - {{ 'Status'|trans({}, 'Admin.Global') }} -
    -
    - {% set isCustomerActive = customerInformation.personalInformation.active %} - - - {% if isCustomerActive %} - check - {{ 'Active'|trans({}, 'Admin.Global') }} - {% else %} - cancel - {{ 'Inactive'|trans({}, 'Admin.Global') }} - {% endif %} - -
    -
    - - {% if customerInformation.personalInformation.guest %} -
    -
    - {{ 'This customer is registered as a Guest.'|trans({}, 'Admin.Orderscustomers.Feature') }} -
    -
    - {% if customerInformation.generalInformation.customerBySameEmailExists %} -

    {{ 'A registered customer account using the defined email address already exists. '|trans({}, 'Admin.Orderscustomers.Notification') }}

    - {% else %} - {{ form_start(transferGuestAccountForm, {'action': path('admin_customers_transform_guest_to_customer', {'customerId': customerInformation.customerId.value})}) }} - - -

    {{ 'This feature generates a random password before sending an email to your customer.'|trans({}, 'Admin.Orderscustomers.Help') }}

    - {{ form_end(transferGuestAccountForm) }} - {% endif %} -
    -
    - {% endif %} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/private_note.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/private_note.html.twig deleted file mode 100644 index e04c7fac..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/private_note.html.twig +++ /dev/null @@ -1,46 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - visibility_off - {{ 'Add a private note'|trans({}, 'Admin.Orderscustomers.Feature') }} -

    -
    - - - {{ form_start(privateNoteForm, {'action': path('admin_customers_set_private_note', {'customerId': customerInformation.customerId.value})}) }} - {{ form_widget(privateNoteForm.note) }} - - - {{ form_end(privateNoteForm) }} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/sent_emails.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/sent_emails.html.twig deleted file mode 100644 index 0620442e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/sent_emails.html.twig +++ /dev/null @@ -1,60 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - mail_outline - {{ 'Last emails'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ customerInformation.sentEmailsInformation|length }} -

    -
    - {% if customerInformation.sentEmailsInformation is not empty %} - - - - - - - - - - - {% for sentEmail in customerInformation.sentEmailsInformation %} - - - - - - - {% endfor %} - -
    {{ 'Date'|trans({}, 'Admin.Global') }}{{ 'Language'|trans({}, 'Admin.Global') }}{{ 'Subject'|trans({}, 'Admin.Global') }}{{ 'Template'|trans({}, 'Admin.Global') }}
    {{ sentEmail.date }}{{ sentEmail.language }}{{ sentEmail.subject }}{{ sentEmail.template }}
    - {% else %} -

    - {{ 'No records found'|trans({}, 'Admin.Global') }} -

    - {% endif %} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/viewed_products.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/viewed_products.html.twig deleted file mode 100644 index 6946c509..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/View/viewed_products.html.twig +++ /dev/null @@ -1,56 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if customerInformation.productsInformation.viewedProductsInformation is not empty %} -
    -

    - remove_red_eye - {{ 'Viewed products'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ customerInformation.productsInformation.viewedProductsInformation|length }} -

    -
    - - - - - - - - - {% for product in customerInformation.productsInformation.viewedProductsInformation %} - - - - - {% endfor %} - -
    {{ 'ID'|trans({}, 'Admin.Global') }}{{ 'Name'|trans({}, 'Admin.Global') }}
    {{ product.productId }} - - {{ product.productName }} - -
    -
    -
    -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/delete_modal.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/delete_modal.html.twig deleted file mode 100644 index ac340fa2..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/delete_modal.html.twig +++ /dev/null @@ -1,53 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% embed 'PrestaShopBundle:Admin/Helpers:bootstrap_popup.html.twig' with { - 'id': grid.id ~ '_grid_delete_customers_modal', - 'title': "How do you want to delete the selected customers?"|trans({}, 'Admin.Orderscustomers.Notification'), - 'closable': true, - 'actions': [{ - 'type': 'button', - 'label': "Delete"|trans({}, 'Admin.Actions'), - 'class': 'btn btn-danger btn-lg js-submit-delete-customers', - }], -} %} - {% block content %} - - {% endblock %} -{% endembed %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/form.html.twig deleted file mode 100644 index 2554421f..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/form.html.twig +++ /dev/null @@ -1,141 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% set allowedNameChars = '0-9!<>,;?=+()@#"°{}_$%:' %} -{% set isGuest = isGuest|default(false) %} - -{% block customer_form %} - {{ form_start(customerForm) }} -
    -

    - person - {{ 'Customer'|trans({}, 'Admin.Global') }} -

    -
    -
    - {{ form_errors(customerForm) }} - - {{ ps.form_group_row(customerForm.gender_id, {}, { - 'label': 'Social title'|trans({}, 'Admin.Global') - }) }} - - {{ ps.form_group_row(customerForm.first_name, {}, { - 'label': 'First name'|trans({}, 'Admin.Global'), - 'help': 'Only letters and the dot (.) character, followed by a space, are allowed.'|trans({}, 'Admin.Orderscustomers.Help') - }) }} - - {{ ps.form_group_row(customerForm.last_name, {}, { - 'label': 'Last name'|trans({}, 'Admin.Global'), - 'help': 'Only letters and the dot (.) character, followed by a space, are allowed.'|trans({}, 'Admin.Orderscustomers.Help') - }) }} - - {{ ps.form_group_row(customerForm.email, {}, { - 'label': 'Email'|trans({}, 'Admin.Global') - }) }} - - {{ ps.form_group_row(customerForm.password, {}, { - 'label': 'Password'|trans({}, 'Admin.Global'), - 'help': 'Password should be at least %length% characters long.'|trans({'%length%': minPasswordLength}, 'Admin.Notifications.Info'), - 'class': isGuest ? 'd-none' : '' - }) }} - - {{ ps.form_group_row(customerForm.birthday, {}, { - 'label': 'Birthday'|trans({}, 'Admin.Orderscustomers.Feature') - }) }} - - {{ ps.form_group_row(customerForm.is_enabled, {}, { - 'label': 'Enabled'|trans({}, 'Admin.Global'), - 'help': 'Enable or disable customer login.'|trans({}, 'Admin.Orderscustomers.Help') - }) }} - - {{ ps.form_group_row(customerForm.is_partner_offers_subscribed, {}, { - 'label': 'Partner offers'|trans({}, 'Admin.Orderscustomers.Feature'), - 'help': 'This customer will receive your ads via email.'|trans({}, 'Admin.Orderscustomers.Help') - }) }} - - {{ ps.form_group_row(customerForm.group_ids, {}, { - 'label': 'Group access'|trans({}, 'Admin.Orderscustomers.Feature'), - 'help': 'Select all the groups that you would like to apply to this customer.'|trans({}, 'Admin.Orderscustomers.Help') - }) }} - - {{ ps.form_group_row(customerForm.default_group_id, {}, { - 'label': 'Default customer group'|trans({}, 'Admin.Orderscustomers.Feature'), - 'help': '%s %s'|format('This group will be the user\'s default group.'|trans({}, 'Admin.Orderscustomers.Help'), 'Only the discount for the selected group will be applied to this customer.'|trans({}, 'Admin.Orderscustomers.Help')) - }) }} - - {% if isB2bFeatureActive %} - {{ ps.form_group_row(customerForm.company_name, {}, { - 'label': 'Company'|trans({}, 'Admin.Global') - }) }} - - {{ ps.form_group_row(customerForm.siret_code, {}, { - 'label': 'SIRET'|trans({}, 'Admin.Orderscustomers.Feature') - }) }} - - {{ ps.form_group_row(customerForm.ape_code, {}, { - 'label': 'APE'|trans({}, 'Admin.Orderscustomers.Feature') - }) }} - - {{ ps.form_group_row(customerForm.website, {}, { - 'label': 'Website'|trans({}, 'Admin.Orderscustomers.Feature') - }) }} - - {{ ps.form_group_row(customerForm.allowed_outstanding_amount, {}, { - 'label': 'Allowed outstanding amount'|trans({}, 'Admin.Orderscustomers.Feature'), - 'help': '%s 0-9'|format('Valid characters:'|trans({}, 'Admin.Orderscustomers.Help')) - }) }} - - {{ ps.form_group_row(customerForm.max_payment_days, {}, { - 'label': 'Maximum number of payment days'|trans({}, 'Admin.Orderscustomers.Feature'), - 'help': '%s 0-9'|format('Valid characters:'|trans({}, 'Admin.Orderscustomers.Help')) - }) }} - - {{ ps.form_group_row(customerForm.risk_id, {}, { - 'label': 'Risk rating'|trans({}, 'Admin.Orderscustomers.Feature') - }) }} - {% endif %} - - {% block customer_form_rest %} - {{ form_rest(customerForm) }} - {% endblock %} -
    -
    - -
    - {{ form_end(customerForm) }} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/javascript.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/javascript.html.twig deleted file mode 100644 index dd00e545..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/javascript.html.twig +++ /dev/null @@ -1,29 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block customer_javascripts %} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/showcase_card.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/showcase_card.html.twig deleted file mode 100644 index 39678bd3..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/Blocks/showcase_card.html.twig +++ /dev/null @@ -1,45 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if not isShowcaseCardClosed %} -
    -
    - -
    -
    -

    {{ 'Administrate your customers'|trans({}, 'Admin.Orderscustomers.Feature') }}

    -

    {{ 'Taking good care of your customers starts with making sure their profiles contain all the information needed to have their packages shipped without mishap.'|trans({}, 'Admin.Orderscustomers.Feature') }}

    - - {{ 'Learn more'|trans({}, 'Admin.Actions') }} - -
    - - close - -
    -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/create.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/create.html.twig deleted file mode 100644 index d80909ad..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/create.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set enableSidebar = true %} -{% set layoutTitle = 'Creating a new Customer'|trans({}, 'Admin.Orderscustomers.Feature') %} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/javascript.html.twig' %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/edit.html.twig deleted file mode 100644 index 508fc871..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/edit.html.twig +++ /dev/null @@ -1,44 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set enableSidebar = true %} -{% set fullName = '%s. %s'|format(customerInformation.personalInformation.firstName[:1], customerInformation.personalInformation.lastName) %} -{% set layoutTitle = 'Editing customer %name%'|trans({'%name%': fullName}, 'Admin.Orderscustomers.Feature') %} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/form.html.twig' with {'isGuest': customerInformation.personalInformation.guest} %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/javascript.html.twig' %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/index.html.twig deleted file mode 100644 index 949ca04c..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/index.html.twig +++ /dev/null @@ -1,118 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set enableSidebar = true %} -{% set layoutTitle = 'Manage your Customers'|trans({}, 'Admin.Orderscustomers.Feature') %} - -{% if isSingleShopContext %} - {% set layoutHeaderToolbarBtn = { - 'add': { - 'href': path('admin_customers_create'), - 'desc': 'Add new customer'|trans({}, 'Admin.Orderscustomers.Feature'), - 'icon': 'add_circle_outline' - } - } %} -{% endif %} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} - {% block employee_helper_card %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/showcase_card.html.twig' %} -
    -
    - {% endblock %} - - {% block customers_kpis %} -
    -
    -
    -
    - {{ render(controller( - 'PrestaShopBundle:Admin\\Common:renderKpiRow', - { 'kpiRow': customersKpi } - )) }} -
    -
    -
    -
    - {% endblock %} - - {% block customers_listing %} - {% if not isSingleShopContext %} -
    -
    - -
    -
    - {% endif %} - -
    -
    - {% embed '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': customerGrid} %} - {% block grid_panel_extra_content %} - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/delete_modal.html.twig' %} - {% endblock %} - {% endembed %} -
    -
    - {% endblock %} - - {% block customer_required_fields_form %} -
    -
    -

    - -

    -
    - -
    - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/Index/required_fields.html.twig' %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/javascript.html.twig' %} -{% endblock %} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/modal_create_success.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/modal_create_success.html.twig deleted file mode 100644 index 02669e23..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/modal_create_success.html.twig +++ /dev/null @@ -1,48 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -{% endblock %} - -{% block javascripts %} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/view.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/view.html.twig deleted file mode 100644 index 9631c88a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Customer/view.html.twig +++ /dev/null @@ -1,63 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set layoutTitle = 'Information about customer %name%'|trans({'%name%': customerInformation.personalInformation.firstName[0:1] ~ '. ' ~ customerInformation.personalInformation.lastName}, 'Admin.Orderscustomers.Feature') %} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/View/personal_information.html.twig' %} - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/View/orders.html.twig' %} - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/View/carts.html.twig' %} - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/View/bought_products.html.twig' %} - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/View/viewed_products.html.twig' %} -
    - -
    - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/View/private_note.html.twig' %} - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/View/messages.html.twig' %} - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/View/discounts.html.twig' %} - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/View/sent_emails.html.twig' %} - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/View/last_connections.html.twig' %} - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/View/groups.html.twig' %} -
    -
    - -
    - {{ renderhook('displayAdminCustomers', {'id_customer': customerInformation.customerId.value}) }} - -
    - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/View/addresses.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - {% include '@PrestaShop/Admin/Sell/Customer/Blocks/javascript.html.twig' %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/customer_information.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/customer_information.html.twig deleted file mode 100644 index be509297..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/customer_information.html.twig +++ /dev/null @@ -1,84 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -
    -
    - {% if customerThreadView.customerInformation.customerId %} - - - person - - - {% else %} - - person - - {% endif %} - -
    -

    - {% if customerThreadView.customerInformation.firstName %} - - {{ customerThreadView.customerInformation.firstName }} - {{ customerThreadView.customerInformation.lastName }} - ({{ customerThreadView.customerInformation.email }}) - - {% else %} - {{ customerThreadView.customerInformation.email }} - {% endif %} -

    -

    - {% if customerThreadView.contactName is not empty %} - {{ 'To:'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ customerThreadView.contactName }} - {% endif %} -

    -
    - -
    -
    -
    - {% if customerThreadView.customerInformation.validatedOrdersCount %} - {{ '[1]%count%[/1] order(s) validated for a total amount of [2]%total%[/2]'|trans({ - '%count%': customerThreadView.customerInformation.validatedOrdersCount, - '%total%': customerThreadView.customerInformation.validatedOrdersAmount, - '[1]': '', - '[/1]': '', - '[2]': '', - '[/2]': '' - }, 'Admin.Orderscustomers.Feature')|raw }} - {% else %} - {{ 'No order validated for the moment. By default, an order is considered validated when its payment is accepted.'|trans({}, 'Admin.Orderscustomers.Feature') }} - {% endif %} - -

    - {{ 'Customer since: %s'|trans( - {'%s': customerThreadView.customerInformation.customerSinceDate}, - 'Admin.Orderscustomers.Feature' - ) }} -

    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/forward_thread_modal.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/forward_thread_modal.html.twig deleted file mode 100644 index f66b60a3..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/forward_thread_modal.html.twig +++ /dev/null @@ -1,101 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/thread_actions.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/thread_actions.html.twig deleted file mode 100644 index db60cdb6..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/thread_actions.html.twig +++ /dev/null @@ -1,43 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -
    - {% for action in customerThreadView.actions %} -
    - -
    - {% endfor %} - - - - {% include '@PrestaShop/Admin/Sell/CustomerService/CustomerThread/Block/forward_thread_modal.html.twig' %} -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/thread_messages.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/thread_messages.html.twig deleted file mode 100644 index bf34e4a6..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/thread_messages.html.twig +++ /dev/null @@ -1,83 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -
    -
      - {% for message in customerThreadView.messages %} - {% if not loop.first %} -
    • -
      -
    • - {% endif %} - -
    • - {% if message.type == 'customer' %} - person - {% else %} - - {% endif %} - -
      -

      - reply - - {% if message.type == constant('PrestaShop\\PrestaShop\\Core\\Domain\\CustomerService\\ValueObject\\CustomerThreadMessageType::CUSTOMER') %} - {{ message.customerName }} - {% else %} - {{ message.employeeName }} - {% endif %} - - - calendar_today - - - {{ format_date(message.date) }} - access_time - - - {{ message.date|date('H:i') }} - - - {% if message.attachmentFile %} - attachment - - {{ 'Attachment'|trans({}, 'Admin.Catalog.Feature') }} - - {% endif %} - - {% if message.productId %} - library_books - - {{ 'Product'|trans({}, 'Admin.Global') }} - {{ message.productName }} - - {% endif %} -

      -

      {{ message.message|nl2br }}

      -
      -
    • - {% endfor %} -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/timeline.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/timeline.html.twig deleted file mode 100644 index 4f8f9f67..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/timeline.html.twig +++ /dev/null @@ -1,69 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - {{ 'Orders and messages timeline'|trans({}, 'Admin.Orderscustomers.Feature') }} -

    -
    -
    - {% for timelineItem in customerThreadView.timeline.timelineItems %} -
    -
    -
    - - {{ timelineItem.icon }} - - - - calendar_today - {{ format_date(timelineItem.date) }} - access_time - {{ timelineItem.date|date('H:i') }} - - - - {{ timelineItem.content|raw|nl2br }} - - - {% if timelineItem.relatedOrderId %} -

    - - {{ 'See more'|trans({}, 'Admin.Actions') }} - -

    - {% endif %} -
    -
    -
    - {% endfor %} -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/your_answer.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/your_answer.html.twig deleted file mode 100644 index 26e81137..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/Block/your_answer.html.twig +++ /dev/null @@ -1,64 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{{ form_start(replyToCustomerThreadForm, { - 'action': path('admin_customer_threads_reply', {'customerThreadId': customerThreadView.customerThreadId.value}) -}) }} -
    -

    - {{ 'Your answer to'|trans({}, 'Admin.Orderscustomers.Feature') }} - - {% if customerThreadView.customerInformation.firstName %} - {{ customerThreadView.customerInformation.firstName }} - {{ customerThreadView.customerInformation.lastName }} - {% else %} - {{ customerThreadView.customerInformation.email }} - {% endif %} -

    - -
    -
    - -
    - {{ form_widget(replyToCustomerThreadForm.reply_message, {'attr': {'rows': 5}}) }} -
    -
    - -
    - {{ form_widget(replyToCustomerThreadForm._token) }} -
    - - {% block reply_to_customer_form_rest %} - {{ form_rest(replyToCustomerThreadForm) }} - {% endblock %} -
    - - -
    -{{ form_end(replyToCustomerThreadForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/view.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/view.html.twig deleted file mode 100644 index c828c4ed..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/CustomerThread/view.html.twig +++ /dev/null @@ -1,74 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    -
    -

    - {{ 'Thread'|trans({}, 'Admin.Orderscustomers.Feature') }} - #{{ customerThreadView.customerThreadId.value }} -

    -
    - {% block customer_thread_actions %} - {% include '@PrestaShop/Admin/Sell/CustomerService/CustomerThread/Block/thread_actions.html.twig' %} - {% endblock %} - - {% block customer_information %} - {% include '@PrestaShop/Admin/Sell/CustomerService/CustomerThread/Block/customer_information.html.twig' %} - {% endblock %} - - {% block customer_thread_messages %} - {% include '@PrestaShop/Admin/Sell/CustomerService/CustomerThread/Block/thread_messages.html.twig' %} - {% endblock %} -
    -
    -
    -
    - -
    -
    - {% block customer_thread_reply %} - {% include '@PrestaShop/Admin/Sell/CustomerService/CustomerThread/Block/your_answer.html.twig' %} - {% endblock %} -
    -
    - -
    -
    - {% block customer_thread_timeline %} - {% include '@PrestaShop/Admin/Sell/CustomerService/CustomerThread/Block/timeline.html.twig' %} - {% endblock %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/MerchandiseReturn/Blocks/options.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/MerchandiseReturn/Blocks/options.html.twig deleted file mode 100644 index 04c1e9f4..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/MerchandiseReturn/Blocks/options.html.twig +++ /dev/null @@ -1,64 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{{ form_start(merchandiseReturnsOptionsForm, {action: path('admin_merchandise_returns_save_options')}) }} -
    -

    - {{ 'Merchandise return (RMA) options'|trans({}, 'Admin.Orderscustomers.Feature') }} -

    -
    -
    - {{ ps.form_group_row(merchandiseReturnsOptionsForm.options.enable_order_return, {}, { - label: 'Enable returns'|trans({}, 'Admin.Orderscustomers.Feature'), - help: 'Would you like to allow merchandise returns in your shop?'|trans({}, 'Admin.Orderscustomers.Help') - }) }} - - {{ ps.form_group_row(merchandiseReturnsOptionsForm.options.order_return_period_in_days, {}, { - label: 'Time limit of validity'|trans({}, 'Admin.Orderscustomers.Feature'), - help: 'How many days after the delivery date does the customer have to return a product?'|trans({}, 'Admin.Orderscustomers.Help') - }) }} - - {{ ps.form_group_row(merchandiseReturnsOptionsForm.options.order_return_prefix, {}, { - label: 'Returns prefix'|trans({}, 'Admin.Orderscustomers.Feature'), - help: 'Prefix used for return name (e.g. RE00001).'|trans({}, 'Admin.Orderscustomers.Help') - }) }} - - {% block merchandise_return_options_form_rest %} - {{ form_rest(merchandiseReturnsOptionsForm) }} - {% endblock %} -
    -
    - -
    -{{ form_end(merchandiseReturnsOptionsForm) }} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/MerchandiseReturn/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/MerchandiseReturn/index.html.twig deleted file mode 100644 index 7a1ced62..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/MerchandiseReturn/index.html.twig +++ /dev/null @@ -1,54 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set enableSidebar = true %} -{% set layoutTitle = 'Merchandise Returns'|trans({}, 'Admin.Orderscustomers.Feature') %} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} - {% block merchandise_returns_listing %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': merchandiseReturnsGrid} %} -
    -
    - {% endblock %} - - {% block merchandise_returns_options %} -
    -
    - {% include '@PrestaShop/Admin/Sell/CustomerService/MerchandiseReturn/Blocks/options.html.twig' %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/OrderMessage/Blocks/form.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/OrderMessage/Blocks/form.html.twig deleted file mode 100644 index 130a87b7..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/OrderMessage/Blocks/form.html.twig +++ /dev/null @@ -1,58 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{{ form_start(orderMessageForm) }} -
    -

    - person - {{ 'Order messages'|trans({}, 'Admin.Orderscustomers.Feature') }} -

    -
    -
    - {{ form_errors(orderMessageForm) }} - - {{ ps.form_group_row(orderMessageForm.name, {}, { - 'label': 'Name'|trans({}, 'Admin.Global') - }) }} - - {{ ps.form_group_row(orderMessageForm.message, {}, { - 'label': 'Message'|trans({}, 'Admin.Global') - }) }} - - {% block order_message_form_rest %} - {{ form_rest(orderMessageForm) }} - {% endblock %} -
    -
    - -
    -{{ form_end(orderMessageForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/OrderMessage/create.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/OrderMessage/create.html.twig deleted file mode 100644 index 03bf4d67..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/OrderMessage/create.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/CustomerService/OrderMessage/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/OrderMessage/edit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/OrderMessage/edit.html.twig deleted file mode 100644 index 03bf4d67..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/OrderMessage/edit.html.twig +++ /dev/null @@ -1,40 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Sell/CustomerService/OrderMessage/Blocks/form.html.twig' %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/OrderMessage/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/OrderMessage/index.html.twig deleted file mode 100644 index daa3454a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/CustomerService/OrderMessage/index.html.twig +++ /dev/null @@ -1,41 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': orderMessageGrid} %} -
    -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Cart/Blocks/View/cart_summary.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Cart/Blocks/View/cart_summary.html.twig deleted file mode 100644 index d9f01570..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Cart/Blocks/View/cart_summary.html.twig +++ /dev/null @@ -1,215 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - {{ 'Cart summary'|trans({}, 'Admin.Orderscustomers.Feature') }} -

    -
    - - - - - - - - - - - - - {% for product in cartView.cartSummary.products %} - {% if product.customization is not empty %} - - - - - - - - - - - - - - - - - - {% endif %} - - {% if product.customization is empty or product.cart_quantity > product.customization_quantity %} - - - - - - - - - {% endif %} - {% endfor %} - - - - - - - {% if cartView.cartSummary.total_discounts %} - - - - - {% endif %} - - {% if cartView.cartSummary.total_wrapping %} - - - - - {% endif %} - - {% if cartView.cartSummary.total_shipping %} - - - - - {% endif %} - - - - - - -
     {{ 'Product'|trans({}, 'Admin.Global') }}{{ 'Unit price'|trans({}, 'Admin.Global') }}{{ 'Quantity'|trans({}, 'Admin.Global') }}{{ 'Stock'|trans({}, 'Admin.Global') }}{{ 'Total'|trans({}, 'Admin.Global') }}
    {{ product.image|raw }} - - {{ product.name }} - - {% if product.attributes %} -
    {{ product.attributes }} - {% endif %} -
    - - {% if product.reference %} - {{ 'Ref:'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ product.reference }} - {% endif %} - - {% if product.reference and product.supplier_reference %} - / {{ product.supplier_reference }} - {% endif %} -
    -
    {{ product.unit_price_formatted }}{{ product.quantity }}{{ product.stock_quantity }}{{ product.total_price_formatted }}
    - {% for customizationField in product.customization.fields %} -
    -
    - {% if customizationField.name %} - {{ customizationField.name }} - {% else %} - {{ 'Text #'|trans({}, 'Admin.Orderscustomers.Feature') }} - {% endif %} -
    -
    - {% if customizationField.type == 'customizable_file' %} - - {% else %} - {{ customizationField.value }} - {% endif %} -
    -
    - {% endfor %} -
    {{ product.customization.quantity }}
    {{ product.image|raw }} - - {{ product.name }} - - {% if product.attributes %} -
    {{ product.attributes }} - {% endif %} -
    - - {% if product.reference %} - {{ 'Ref:'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ product.reference }} - {% endif %} - - {% if product.reference and product.supplier_reference %} - / {{ product.supplier_reference }} - {% endif %} -
    -
    {{ product.unit_price_formatted }}{{ product.cart_quantity }}{{ product.stock_quantity }}{{ product.total_price_formatted }}
    {{ 'Total cost of products:'|trans({}, 'Admin.Orderscustomers.Feature') }}{{ cartView.cartSummary.total_products_formatted }}
    {{ 'Total value of vouchers:'|trans({}, 'Admin.Orderscustomers.Feature') }}{{ cartView.cartSummary.total_discounts_formatted }}
    {{ 'Total cost of gift wrapping:'|trans({}, 'Admin.Orderscustomers.Feature') }}{{ cartView.cartSummary.total_wrapping_formatted }}
    {{ 'Total shipping costs:'|trans({}, 'Admin.Orderscustomers.Feature') }}{{ cartView.cartSummary.total_shipping_formatted }}
    - {{ 'Total'|trans({}, 'Admin.Global') }} - - {{ cartView.cartSummary.total_formatted }} -
    - - {% if cartView.cartSummary.cart_rules is not empty %} - - - - - - - - - - {% for cartRule in cartView.cartSummary.cart_rules %} - - - - - - {% endfor %} - -
    {{ 'ID'|trans({}, 'Admin.Global') }}{{ 'Discount name'|trans({}, 'Admin.Orderscustomers.Feature') }}{{ 'Value'|trans({}, 'Admin.Global') }}
    {{ cartRule.id }} - - {{ cartRule.name }} - - - {% if cartRule.is_free_shipping %} - {{ 'Free shipping'|trans({}, 'Admin.Shipping.Feature') }} - {% else %} - - {{ cartRule.formatted_value }} - {% endif %} -
    - {% endif %} - - -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Cart/Blocks/View/customer_information.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Cart/Blocks/View/customer_information.html.twig deleted file mode 100644 index 26ae0990..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Cart/Blocks/View/customer_information.html.twig +++ /dev/null @@ -1,72 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - {{ 'Customer information'|trans({}, 'Admin.Orderscustomers.Feature') }} -

    -
    -
    - {% if cartView.customerInformation.id %} -
    -

    - - {% if cartView.customerInformation.gender %} - {{ cartView.customerInformation.gender }} - {% endif %} - {{ cartView.customerInformation.first_name }} - {{ cartView.customerInformation.last_name }} - -

    - -

    - {{ 'Account registration date:'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ cartView.customerInformation.registration_date }} -

    - -

    - {{ 'Valid orders placed:'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ cartView.customerInformation.valid_orders_count }} -

    - -

    - {{ 'Total spent since registration:'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ cartView.customerInformation.total_spent_since_registration }} -

    -
    - - - {% else %} -
    -

    {{ 'Guest not registered'|trans({}, 'Admin.Orderscustomers.Feature') }}

    -
    - {% endif %} -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Cart/Blocks/View/order_information.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Cart/Blocks/View/order_information.html.twig deleted file mode 100644 index 0ae00f25..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Cart/Blocks/View/order_information.html.twig +++ /dev/null @@ -1,60 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - {{ 'Order information'|trans({}, 'Admin.Orderscustomers.Feature') }} -

    -
    -
    -
    - {% if cartView.orderInformation.id %} -

    - - {{ 'Order #%d'|trans({ - '%d': cartView.orderInformation.id|format('"%06d') - }, 'Admin.Orderscustomers.Feature') }} - -

    - -

    - {{ 'Made on:'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ cartView.orderInformation.placed_date }} -

    - {% else %} -

    {{ 'No order was created from this cart.'|trans({}, 'Admin.Orderscustomers.Feature') }}

    - - {% if cartView.customerInformation.id %} - - {{ 'Create an order from this cart.'|trans({}, 'Admin.Orderscustomers.Feature') }} - - {% endif %} - {% endif %} -
    -
    -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Cart/view.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Cart/view.html.twig deleted file mode 100644 index 0200bcb2..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Cart/view.html.twig +++ /dev/null @@ -1,64 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} - {% block cart_kpis %} -
    -
    -
    -
    - {{ render(controller( - 'PrestaShopBundle:Admin\\Common:renderKpiRow', - { 'kpiRow': cartKpi } - )) }} -
    -
    -
    -
    - {% endblock %} - -
    -
    - {% block cart_customer_information %} - {% include '@PrestaShop/Admin/Sell/Order/Cart/Blocks/View/customer_information.html.twig' %} - {% endblock %} -
    -
    - {% block cart_order_information %} - {% include '@PrestaShop/Admin/Sell/Order/Cart/Blocks/View/order_information.html.twig' %} - {% endblock %} -
    -
    - -
    -
    - {% block cart_summary %} - {% include '@PrestaShop/Admin/Sell/Order/Cart/Blocks/View/cart_summary.html.twig' %} - {% endblock %} -
    -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/CreditSlip/Blocks/credit_slip_options.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/CreditSlip/Blocks/credit_slip_options.html.twig deleted file mode 100644 index 7c99d04a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/CreditSlip/Blocks/credit_slip_options.html.twig +++ /dev/null @@ -1,60 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Orderscustomers.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{{ form_start(creditSlipOptionsForm, { - 'method': 'POST', - 'action': path('admin_credit_slips_process_options')}) -}} -
    - -

    - settings {{ 'Credit slip options'|trans({}, 'Admin.Orderscustomers.Feature') }} -

    - -
    -
    - {{ ps.form_group_row(creditSlipOptionsForm.options.slip_prefix, {}, { - 'label': 'Credit slip prefix'|trans({}, 'Admin.Orderscustomers.Feature'), - 'help': 'Prefix used for credit slips.'|trans({}, 'Admin.Orderscustomers.Help') - }) }} -
    - {% block credit_slip_options_form_rest %} - {{ form_rest(creditSlipOptionsForm) }} - {% endblock %} -
    - - - -
    -{{ form_end(creditSlipOptionsForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/CreditSlip/Blocks/pdf_by_date.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/CreditSlip/Blocks/pdf_by_date.html.twig deleted file mode 100644 index 8a869d9e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/CreditSlip/Blocks/pdf_by_date.html.twig +++ /dev/null @@ -1,64 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Orderscustomers.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{{ form_start(pdfByDateForm, { - 'method': 'GET', - 'action': path('_admin_credit_slips_pdf_by_date')}) -}} -
    -

    - date_range {{ 'By date'|trans }} -

    - -
    -
    - {% set dateHint = 'Format: 2011-12-31 (inclusive).'|trans({}, 'Admin.Orderscustomers.Help') %} - {{ ps.form_group_row(pdfByDateForm.from, {}, { - 'label': 'From'|trans({}, 'Admin.Global'), - 'help': dateHint - }) }} - - {{ ps.form_group_row(pdfByDateForm.to, {}, { - 'label': 'To'|trans({}, 'Admin.Global'), - 'help': dateHint - }) }} -
    - {% block credit_slip_pdf_by_date_form_rest %} - {{ form_rest(pdfByDateForm) }} - {% endblock %} -
    - - -
    -{{ form_end(pdfByDateForm) }} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/CreditSlip/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/CreditSlip/index.html.twig deleted file mode 100644 index 32bf685c..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/CreditSlip/index.html.twig +++ /dev/null @@ -1,59 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} - {% block credit_slips_listing %} -
    -
    - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': creditSlipGrid} %} -
    -
    - {% endblock %} - - {% block credit_slips_print_pdf %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Order/CreditSlip/Blocks/pdf_by_date.html.twig' %} -
    -
    - {% endblock %} - - {% block credit_slips_options %} -
    -
    - {% include '@PrestaShop/Admin/Sell/Order/CreditSlip/Blocks/credit_slip_options.html.twig' %} -
    -
    - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Delivery/slip.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Delivery/slip.html.twig deleted file mode 100644 index 0bd591c0..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Delivery/slip.html.twig +++ /dev/null @@ -1,118 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} -{% trans_default_domain "Admin.Orderscustomers.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block content %} - {{ form_start(pdfForm, {'attr' : {'class': 'form', 'autocomplete': 'off'}, 'action': path('admin_order_delivery_slip_pdf') }) }} -
    - {% block admin_form_order_delivery_slip_pdf %} -
    -
    -

    - print {{ 'Print PDF'|trans }} -

    -
    -
    -
    - {{ ps.label_with_help('From'|trans({}, 'Admin.Global'), ('Format: 2011-12-31 (inclusive).'|trans({}, 'Admin.Orderscustomers.Help'))) }} -
    - {{ form_errors(pdfForm.pdf.date_from) }} - {{ form_widget(pdfForm.pdf.date_from) }} -
    -
    -
    - {{ ps.label_with_help('To'|trans({}, 'Admin.Global'), ('Format: 2011-12-31 (inclusive).'|trans({}, 'Admin.Orderscustomers.Help'))) }} -
    - {{ form_errors(pdfForm.pdf.date_to) }} - {{ form_widget(pdfForm.pdf.date_to) }} -
    -
    - {{ form_rest(pdfForm) }} -
    -
    - -
    -
    - {% endblock %} -
    - {{ form_end(pdfForm) }} - - {{ form_start(optionsForm, {'attr' : {'class': 'form'} }) }} -
    - {% block admin_form_order_delivery_slip_options %} -
    -
    -

    - settings {{ 'Delivery slip options'|trans }} -

    -
    -
    -
    - {{ ps.label_with_help(('Delivery prefix'|trans), ('Prefix used for delivery slips.'|trans({}, 'Admin.Orderscustomers.Help'))) }} -
    - {{ form_errors(optionsForm.options.prefix) }} - {{ form_widget(optionsForm.options.prefix) }} -
    -
    -
    - {{ ps.label_with_help(('Delivery Number'|trans), ('The next delivery slip will begin with this number and then increase with each additional slip.'|trans({}, 'Admin.Orderscustomers.Help'))) }} -
    - {{ form_errors(optionsForm.options.number) }} - {{ form_widget(optionsForm.options.number) }} -
    -
    -
    - {{ ps.label_with_help(('Enable product image'|trans), ('Adds an image before product name on Delivery-slip'|trans({}, 'Admin.Orderscustomers.Help'))) }} -
    - {{ form_errors(optionsForm.options.enable_product_image) }} - {{ form_widget(optionsForm.options.enable_product_image) }} -
    -
    - {{ form_rest(optionsForm) }} -
    -
    - -
    -
    - {% endblock %} -
    - {{ form_end(optionsForm) }} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Invoices/Blocks/generate_by_date.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Invoices/Blocks/generate_by_date.html.twig deleted file mode 100644 index 471a4c03..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Invoices/Blocks/generate_by_date.html.twig +++ /dev/null @@ -1,63 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Orderscustomers.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block invoices_generate_by_date %} -
    - {{ form_start(generateByDateForm, {'method': 'POST', 'action': path('admin_order_invoices_generate_by_date')}) }} -
    -

    - date_range {{ 'By date'|trans }} -

    -
    -
    -
    - {{ ps.label_with_help(('From'|trans({}, 'Admin.Global')), ('Format: 2011-12-31 (inclusive).'|trans({}, 'Admin.Orderscustomers.Help'))) }} -
    - {{ form_errors(generateByDateForm.date_from) }} - {{ form_widget(generateByDateForm.date_from) }} -
    -
    -
    - {{ ps.label_with_help(('To'|trans({}, 'Admin.Global')), ('Format: 2011-12-31 (inclusive).'|trans({}, 'Admin.Orderscustomers.Help'))) }} -
    - {{ form_errors(generateByDateForm.date_to) }} - {{ form_widget(generateByDateForm.date_to) }} -
    -
    -
    - {{ form_rest(generateByDateForm) }} -
    - -
    - {{ form_end(generateByDateForm) }} -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Invoices/Blocks/generate_by_status.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Invoices/Blocks/generate_by_status.html.twig deleted file mode 100644 index ea1e8639..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Invoices/Blocks/generate_by_status.html.twig +++ /dev/null @@ -1,78 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Orderscustomers.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% form_theme generateByStatusForm _self %} - -{% block invoices_generate_by_status %} -
    - {{ form_start(generateByStatusForm, {'method': 'POST', 'action': path('admin_order_invoices_generate_by_status')}) }} -
    -

    - schedule {{ 'By order status'|trans }} -

    -
    -
    -
    - {{ ps.label_with_help(('Order statuses'|trans), ('You can also export orders which have not been charged yet.'|trans({}, 'Admin.Orderscustomers.Help'))) }} -
    - {{ form_errors(generateByStatusForm.order_states) }} - {{ form_widget(generateByStatusForm.order_states) }} -
    -
    -
    - {{ form_rest(generateByStatusForm) }} -
    - -
    - {{ form_end(generateByStatusForm) }} -
    -{% endblock %} - -{% block _form_generate_by_status_order_states_entry_label %} - {# Do not display the label if widget is not defined in order to prevent double label rendering #} - {% if widget is defined %} - {% if parent_label_class is defined %} - {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|trim}) %} - {% endif %} -
    - - {{- widget|raw -}} - - {% set badgeType = orders_count > 0 ? 'success' : 'danger' %} - {{ orders_count }} - - {{- label is not same as(false) ? label|raw -}} - - -
    - {% endif %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Invoices/Blocks/invoice_options.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Invoices/Blocks/invoice_options.html.twig deleted file mode 100644 index fe33d45f..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Invoices/Blocks/invoice_options.html.twig +++ /dev/null @@ -1,139 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% trans_default_domain "Admin.Orderscustomers.Feature" %} -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block invoice_options %} -
    - {{ form_start(invoiceOptionsForm, {'method': 'POST', 'action': path('admin_order_invoices_process')}) }} -
    -

    - settings {{ 'Invoice options'|trans }} -

    -
    -
    -
    - {{ ps.label_with_help('Enable invoices'|trans, 'If enabled, your customers will receive an invoice for the purchase.'|trans({}, 'Admin.Orderscustomers.Help')) }} -
    - {{ form_errors(invoiceOptionsForm.enable_invoices) }} - {{ form_widget(invoiceOptionsForm.enable_invoices) }} -
    -
    -
    - {{ ps.label_with_help('Enable tax breakdown'|trans, 'If required, show the total amount per rate of the corresponding tax.'|trans({}, 'Admin.Orderscustomers.Help')) }} -
    - {{ form_errors(invoiceOptionsForm.enable_tax_breakdown) }} - {{ form_widget(invoiceOptionsForm.enable_tax_breakdown) }} -
    -
    -
    - {{ ps.label_with_help('Enable product image'|trans, 'Adds an image in front of the product name on the invoice'|trans({}, 'Admin.Orderscustomers.Help')) }} -
    - {{ form_errors(invoiceOptionsForm.enable_product_images) }} - {{ form_widget(invoiceOptionsForm.enable_product_images) }} -
    -
    -
    - {{ ps.label_with_help('Invoice prefix'|trans, 'Freely definable prefix for invoice number (e.g. #IN00001).'|trans({}, 'Admin.Orderscustomers.Help')) }} -
    - {{ form_errors(invoiceOptionsForm.invoice_prefix) }} - {{ form_widget(invoiceOptionsForm.invoice_prefix) }} -
    -
    -
    - -
    - {{ form_errors(invoiceOptionsForm.add_current_year) }} - {{ form_widget(invoiceOptionsForm.add_current_year) }} -
    -
    -
    - -
    - {{ form_errors(invoiceOptionsForm.reset_number_annually) }} - {{ form_widget(invoiceOptionsForm.reset_number_annually) }} -
    -
    -
    - -
    - {{ form_errors(invoiceOptionsForm.year_position) }} - {{ form_widget(invoiceOptionsForm.year_position) }} -
    -
    -
    - {{ ps.label_with_help('Invoice number'|trans, 'The next invoice will begin with this number, and then increase with each additional invoice. Set to 0 if you want to keep the current number (which is #%number%).'|trans({'%number%': invoiceOptionsForm.vars.next_invoice_number}, 'Admin.Orderscustomers.Help')) }} -
    - {{ form_errors(invoiceOptionsForm.invoice_number) }} - {{ form_widget(invoiceOptionsForm.invoice_number) }} -
    -
    -
    - {{ ps.label_with_help('Legal free text'|trans, 'Use this field to show additional information on the invoice, below the payment methods summary (like specific legal information).'|trans({}, 'Admin.Orderscustomers.Help')) }} -
    - {{ form_errors(invoiceOptionsForm.legal_free_text) }} - {{ form_widget(invoiceOptionsForm.legal_free_text) }} -
    -
    -
    - {{ ps.label_with_help('Footer text'|trans, 'This text will appear at the bottom of the invoice, below your company details.'|trans({}, 'Admin.Orderscustomers.Help')) }} -
    - {{ form_errors(invoiceOptionsForm.footer_text) }} - {{ form_widget(invoiceOptionsForm.footer_text) }} -
    -
    -
    - {{ ps.label_with_help('Invoice model'|trans, 'Choose an invoice model.'|trans({}, 'Admin.Orderscustomers.Help')) }} -
    - {{ form_errors(invoiceOptionsForm.invoice_model) }} - {{ form_widget(invoiceOptionsForm.invoice_model) }} -
    -
    -
    - {{ ps.label_with_help('Use the disk as cache for PDF invoices'|trans, 'Saves memory but slows down the PDF generation.'|trans({}, 'Admin.Orderscustomers.Help')) }} -
    - {{ form_errors(invoiceOptionsForm.use_disk_cache) }} - {{ form_widget(invoiceOptionsForm.use_disk_cache) }} -
    -
    - {{ form_rest(invoiceOptionsForm) }} -
    -
    - -
    - {{ form_end(invoiceOptionsForm) }} -
    -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Invoices/invoices.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Invoices/invoices.html.twig deleted file mode 100644 index 75969554..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Invoices/invoices.html.twig +++ /dev/null @@ -1,51 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% set generateByDateForm, generateByStatusForm, invoiceOptionsForm = - byDateForm.generate_by_date, byStatusForm.generate_by_status, optionsForm.invoice_options -%} - -{% block content %} -
    - {# "By Date" block #} - {% include '@PrestaShop/Admin/Sell/Order/Invoices/Blocks/generate_by_date.html.twig' %} - - {# "By order status" block #} - {% include '@PrestaShop/Admin/Sell/Order/Invoices/Blocks/generate_by_status.html.twig' %} - -
    - -
    - {# "Invoice options" block #} - {% include '@PrestaShop/Admin/Sell/Order/Invoices/Blocks/invoice_options.html.twig' %} -
    -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/addresses.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/addresses.html.twig deleted file mode 100644 index 0ed0a662..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/addresses.html.twig +++ /dev/null @@ -1,72 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - {{ 'Addresses'|trans({}, 'Admin.Global') }} -

    -
    -
    -
    -
    -
    - {{ 'You must add at least one address to process the order.'|trans({}, 'Admin.Orderscustomers.Notification') }} -
    -
    -
    -
    -
    -
    - {{ 'Delivery'|trans({}, 'Admin.Global') }} - - - -
    -
    - {{ 'Invoice'|trans({}, 'Admin.Global') }} - - - -
    -
    - -
    -
    diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/cart.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/cart.html.twig deleted file mode 100644 index 4bd6c862..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/cart.html.twig +++ /dev/null @@ -1,261 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    {{ 'Cart'|trans({}, 'Admin.Orderscustomers.Feature') }}

    -
    -
    -
    -
    -
    -
    - {{ 'Search for a product'|trans({}, 'Admin.Orderscustomers.Feature') }} -
    -
    - - - {{ 'Search for an existing product by typing the first letters of its name.'|trans({}, 'Admin.Orderscustomers.Help') }} - -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    -
    - -
    - -
    -
    -
    -
    - -
    -
    - {{ 'Product'|trans({}, 'Admin.Global') }} -
    -
    - -
    -
    - -
    -
    - {{ 'Combination'|trans({}, 'Admin.Global') }} -
    -
    - -
    -
    - -
    -
    - - {{ 'Customization'|trans({}, 'Admin.Catalog.Feature') }} - -
    -
    -
    - -
    -
    - {{ 'Quantity'|trans({}, 'Admin.Global') }} -
    -
    - - - {{ 'In stock'|trans({}, 'Admin.Orderscustomers.Feature') }} - - -
    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
    -
    -
    -
    -
    - - - - - - - - - - - - - -
    {{ 'Product'|trans({}, 'Admin.Global') }}{{ 'Description'|trans({}, 'Admin.Global') }}{{ 'Reference'|trans({}, 'Admin.Global') }}{{ 'Price per unit'|trans({}, 'Admin.Catalog.Feature') }}{{ 'Quantity'|trans({}, 'Admin.Global') }}{{ 'Price'|trans({}, 'Admin.Global') }}
    -
    -
    -
    -
    -
    -
    - {{ 'The prices are without taxes.'|trans({}, 'Admin.Orderscustomers.Notification') }} -
    -
    -
    -
    -
    -
    - - {{ 'Currency'|trans({}, 'Admin.Global') }} - -
    -
    - -
    -
    -
    -
    - - {{ 'Language'|trans({}, 'Admin.Global') }} - -
    -
    - -
    -
    -
    -
    -
    -
    - -{% set requiredFieldMarkTemplate %} - * -{% endset %} - - - - - - - - - - - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/cart_rules.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/cart_rules.html.twig deleted file mode 100644 index f76c157b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/cart_rules.html.twig +++ /dev/null @@ -1,89 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    -

    - {{ 'Vouchers'|trans({}, 'Admin.Orderscustomers.Feature') }} -

    -
    -
    -
    - {{ 'Search for a voucher'|trans({}, 'Admin.Orderscustomers.Feature') }} -
    -
    -
    - -
      -
      - error_outline - -
      -
      -
      - -
      - - - - - - - - - - - -
      {{ 'Name'|trans({}, 'Admin.Global') }}{{ 'Description'|trans({}, 'Admin.Global') }}{{ 'Value'|trans({}, 'Admin.Global') }}
      -
      -
      - - - - - - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/customer.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/customer.html.twig deleted file mode 100644 index 2fcedf25..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/customer.html.twig +++ /dev/null @@ -1,247 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
      -

      {{ 'Customer'|trans({}, 'Admin.Global') }}

      -
      -
      -
      - {{ 'Search for a customer'|trans({}, 'Admin.Orderscustomers.Feature') }} -
      -
      - - - {{ 'Search for an existing customer by typing the first letters of his/her name.'|trans({}, 'Admin.Orderscustomers.Help') }} - -
      - -
      - -
      -
      -
      - -
      -
      -
      - -
      -
      -
      - -
      -
      -
      - -
      -
      -
      -
      -
      -
      -
      - -
      -
      - - - - - - - - - - -
      {{ 'ID'|trans({}, 'Admin.Global') }}{{ 'Date'|trans({}, 'Admin.Global') }}{{ 'Total'|trans({}, 'Admin.Global') }}
      -
      -
      - - - - - - - - - - - - - -
      {{ 'ID'|trans({}, 'Admin.Global') }}{{ 'Date'|trans({}, 'Admin.Global') }}{{ 'Products'|trans({}, 'Admin.Global') }}{{ 'Total paid'|trans({}, 'Admin.Orderscustomers.Feature') }}{{ 'Payment'|trans({}, 'Admin.Global') }}{{ 'Status'|trans({}, 'Admin.Global') }}
      -
      -
      -
      -
      -
      -
      - -
      -
      -
      -
      -

      -
      - # -
      -
      -
      -

      -

      -
      - -
      -
      -
      - - - - - - - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/shipping.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/shipping.html.twig deleted file mode 100644 index 5d4319cb..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/shipping.html.twig +++ /dev/null @@ -1,123 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
      -

      - {{ 'Shipping'|trans({}, 'Admin.Actions') }} -

      -
      - -
      -
      -
      - - {{ 'Delivery option'|trans({}, 'Admin.Orderscustomers.Feature') }} - -
      -
      - -
      -
      -
      -
      - - {{ 'Shipping price (Tax incl.)'|trans({}, 'Admin.Orderscustomers.Feature') }} - -
      -
      -

      -
      -
      -
      -
      - - {{ 'Free shipping'|trans({}, 'Admin.Shipping.Feature') }} - -
      -
      - - - - - - - -
      -
      -
      -
      - - {{ 'Recycled packaging'|trans({}, 'Admin.Orderscustomers.Feature') }} - -
      -
      - - - - - - - -
      -
      -
      -
      - - {{ 'Gift'|trans({}, 'Admin.Orderscustomers.Feature') }} - -
      -
      - - - - - - - -
      - - - -
      -
      -
      - -
      -
      - -
      -
      -
      - -
      -
      -
      - {{ 'No carrier can be applied to this order'|trans({}, 'Admin.Orderscustomers.Notification') }} -
      -
      -
      -
      -
      diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/summary.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/summary.html.twig deleted file mode 100644 index 97aaa78e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/Create/summary.html.twig +++ /dev/null @@ -1,126 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
      -

      - {{ 'Summary'|trans({}, 'Admin.Global') }} -

      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -
      -

      - {{ 'Total products'|trans({}, 'Admin.Orderscustomers.Feature') }} -

      - -
      -
      -

      - {{ 'Total vouchers (Tax excl.)'|trans({}, 'Admin.Orderscustomers.Feature') }} -

      - -
      -
      -

      - {{ 'Total shipping (Tax excl.)'|trans({}, 'Admin.Orderscustomers.Feature') }} -

      - -
      -
      -

      - {{ 'Total taxes'|trans({}, 'Admin.Orderscustomers.Feature') }} -

      - -
      -
      -

      - {{ 'Total (Tax excl.)'|trans({}, 'Admin.Orderscustomers.Feature') }} -

      - -
      -
      -

      - {{ 'Total (Tax incl.)'|trans({}, 'Admin.Orderscustomers.Feature') }} -

      - -
      -
      -
      -
      -
      -
      - - {{ form_start(summaryForm, {'action': path('admin_orders_place')}) }} -
      -
      - -
      - {{ ps.form_group_row(summaryForm.order_message, {}, { - 'label': 'Order message'|trans({}, 'Admin.Orderscustomers.Feature'), - }) }} -
      - -
      -
      - - - {{ 'Go on payment page to process the payment.'|trans({}, 'Admin.Orderscustomers.Help') }} - -
      -
      - - {{ ps.form_group_row(summaryForm.payment_module, {}, { - 'label': 'Payment'|trans({}, 'Admin.Global'), - }) }} - - {{ ps.form_group_row(summaryForm.order_state, {}, { - 'label': 'Order status'|trans({}, 'Admin.Orderscustomers.Feature'), - }) }} - -
      -
      - - {{ form_row(summaryForm.cart_id, {'attr': {'class': 'js-place-order-cart-id'}}) }} -
      -
      -
      -
      - {{ form_end(summaryForm) }} - -
      -
      diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/add_order_discount_modal.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/add_order_discount_modal.html.twig deleted file mode 100644 index 3dbab78b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/add_order_discount_modal.html.twig +++ /dev/null @@ -1,107 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/add_product_modal.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/add_product_modal.html.twig deleted file mode 100644 index 5094f40b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/add_product_modal.html.twig +++ /dev/null @@ -1,117 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/update_customer_address_modal.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/update_customer_address_modal.html.twig deleted file mode 100644 index 6ffd1ef3..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/update_customer_address_modal.html.twig +++ /dev/null @@ -1,61 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/update_product_modal.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/update_product_modal.html.twig deleted file mode 100644 index f4e4cf9d..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/update_product_modal.html.twig +++ /dev/null @@ -1,24 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/update_shipping_modal.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/update_shipping_modal.html.twig deleted file mode 100644 index f1299bf3..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/update_shipping_modal.html.twig +++ /dev/null @@ -1,78 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/view_all_messages_modal.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/view_all_messages_modal.html.twig deleted file mode 100644 index ca3d7ba7..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/view_all_messages_modal.html.twig +++ /dev/null @@ -1,59 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/view_product_pack_modal.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/view_product_pack_modal.html.twig deleted file mode 100644 index 1a2f86e6..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/Modal/view_product_pack_modal.html.twig +++ /dev/null @@ -1,81 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/add_product_row.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/add_product_row.html.twig deleted file mode 100644 index 076b375a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/add_product_row.html.twig +++ /dev/null @@ -1,91 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - - - {{ form_row(addProductRowForm.product_id) }} - {{ form_row(addProductRowForm.tax_rate) }} - {{ form_label(addProductRowForm.search) }} - {{ form_widget(addProductRowForm.search) }} - -
      -
      -
      {{ 'Combinations'|trans({}, 'Admin.Global') }}
      -
      - -
      - - -
      -
      - {{ form_widget(addProductRowForm.price_tax_excluded) }} -
      - -
      - {{ form_widget(addProductRowForm.price_tax_included) }} -
      -
      - - - {{ form_row(addProductRowForm.quantity, {'type':'number'}) }} - - - - - - {% if orderForViewing.hasInvoice() %} - - {{ form_row(addProductRowForm.invoice, { - 'attr': { - 'data-modal-title': 'Create a new invoice'|trans({}, 'Admin.Orderscustomers.Feature'), - 'data-modal-apply': 'Create'|trans({}, 'Admin.Actions'), - 'data-modal-cancel': 'Cancel'|trans({}, 'Admin.Actions'), - 'data-modal-body': 'Are you sure you want to create a new invoice?'|trans({}, 'Admin.Orderscustomers.Notification'), - 'data-modal-edit-price-title': 'Edit the price'|trans({}, 'Admin.Orderscustomers.Feature'), - 'data-modal-edit-price-apply': 'Update'|trans({}, 'Admin.Actions'), - 'data-modal-edit-price-cancel': 'Cancel'|trans({}, 'Admin.Actions'), - 'data-modal-edit-price-body': 'Are you sure you want to edit this product price? It will be applied to all invoices of this order.'|trans({}, 'Admin.Orderscustomers.Notification'), - }}) - }} - - {% endif %} - -
      - {{ form_row(addProductRowForm.cancel) }} - {{ form_row(addProductRowForm.add) }} -
      - - - - -
      -

      {{ 'New invoice information'|trans({}, 'Admin.Orderscustomers.Feature') }}

      -

      {{ 'Carrier'|trans({}, 'Admin.Shipping.Feature') }} : {{ orderForViewing.carrierName }}

      - {{ form_row(addProductRowForm.free_shipping) }} -
      - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/customer.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/customer.html.twig deleted file mode 100644 index 593044d0..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/customer.html.twig +++ /dev/null @@ -1,253 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
      -
      -

      - {{ 'Customer'|trans({}, 'Admin.Global') }} -

      -
      - -
      -
      -
      - {% if orderForViewing.customer is not null %} -
      -

      - account_box - - {{ orderForViewing.customer.gender }} - {{ orderForViewing.customer.firstName }} - {{ orderForViewing.customer.lastName }} - - #{{ orderForViewing.customer.id }} -

      - {% if orderForViewing.customer.isGuest %} - Guest - {% endif %} -
      - - {% else %} -
      -

      {{ 'Deleted customer'|trans({}, 'Admin.Global') }}

      -
      - {% endif %} -
      -
      - {% if orderForViewing.customer is not null %} -
      -
      -

      - {{ 'Email:'|trans({}, 'Admin.Global') }} -

      -

      - - {{ orderForViewing.customer.email }} - -

      - - {% if orderForViewing.customer.isGuest is same as(false) %} -

      - {{ 'Account registered:'|trans({}, 'Admin.Orderscustomers.Feature') }} -

      -

      {{ orderForViewing.customer.accountRegistrationDate|date_format_full }}

      - {% endif %} -
      -
      -

      - {{ 'Validated orders placed:'|trans({}, 'Admin.Orderscustomers.Feature') }} -

      -

      - {{ orderForViewing.customer.validOrdersPlaced }} -

      - - {% if orderForViewing.customer.isGuest is same as(false) %} -

      - {{ 'Total spent since registration:'|trans({}, 'Admin.Orderscustomers.Feature') }} -

      -

      - {{ orderForViewing.customer.totalSpentSinceRegistration }} -

      - {% endif %} -
      -
      - {% endif %} -
      -
      - {% if orderForViewing.virtual is same as(false) %} -
      -
      - {{ 'Shipping address'|trans({}, 'Admin.Orderscustomers.Feature') }} - {% if orderForViewing.customer is not null %} - - more_vert - - - - {% endif %} -
      - -

      {{ orderForViewing.shippingAddress.fullName }}

      - {% if orderForViewing.shippingAddress.companyName is not empty %} -

      {{ orderForViewing.shippingAddress.companyName }}

      - {% endif %} -

      {{ orderForViewing.shippingAddress.address1 }}

      - {% if orderForViewing.shippingAddress.address2 is not empty %} -

      {{ orderForViewing.shippingAddress.address2 }}

      - {% endif %} -

      - {{ orderForViewing.shippingAddress.cityName }}, - {% if orderForViewing.shippingAddress.stateName is not empty %} - {{ orderForViewing.shippingAddress.stateName }} - {% endif %} - {{ orderForViewing.shippingAddress.postCode }} -

      -

      {{ orderForViewing.shippingAddress.countryName }}

      -

      - {{ orderForViewing.shippingAddress.phoneNumber }} - {{ orderForViewing.shippingAddress.mobilePhoneNumber }} -

      -
      - {% endif %} -
      -
      - {{ 'Invoice address'|trans({}, 'Admin.Orderscustomers.Feature') }} - - {% if orderForViewing.customer is not null %} - - more_vert - - - - {% endif %} -
      - -

      {{ orderForViewing.invoiceAddress.fullName }}

      - {% if orderForViewing.invoiceAddress.companyName is not empty %} -

      {{ orderForViewing.invoiceAddress.companyName }}

      - {% endif %} -

      {{ orderForViewing.invoiceAddress.address1 }}

      - {% if orderForViewing.invoiceAddress.address2 is not empty %} -

      {{ orderForViewing.invoiceAddress.address2 }}

      - {% endif %} -

      - {{ orderForViewing.invoiceAddress.cityName }}, - {% if orderForViewing.invoiceAddress.stateName is not empty %} - {{ orderForViewing.invoiceAddress.stateName }} - {% endif %} - {{ orderForViewing.invoiceAddress.postCode }} -

      -

      {{ orderForViewing.invoiceAddress.countryName }}

      -

      - {{ orderForViewing.invoiceAddress.phoneNumber }} - {{ orderForViewing.invoiceAddress.mobilePhoneNumber }} -

      -
      -
      -
      - {% if orderForViewing.customer is not null %} -
      -
      - {% set isPrivateNoteOpen = not orderForViewing.customer.privateNote is empty %} - -
      -

      - {{ 'Private note'|trans({}, 'Admin.Orderscustomers.Feature') }} -

      -
      - - -
      - {{ form_start(privateNoteForm, { - 'action': path('admin_customers_set_private_note', { - 'customerId': orderForViewing.customer.id, - 'back': path('admin_orders_view', {'orderId': orderForViewing.id}) - }) - }) }} - - {{ form_widget(privateNoteForm.note) }} -
      - {{ form_rest(privateNoteForm) }} -
      - -
      - -
      - {{ form_end(privateNoteForm) }} -
      -
      -
      - {% endif %} -
      -
      diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/details.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/details.html.twig deleted file mode 100644 index 575642ef..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/details.html.twig +++ /dev/null @@ -1,128 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set statusTitle %} - {{ 'Status'|trans({}, 'Admin.Global') }} ({{ orderForViewing.history.statuses|length }}) -{% endset %} - -{% set documentsTitle %} - {{ 'Documents'|trans({}, 'Admin.Orderscustomers.Feature') }} ({{ orderForViewing.documents.documents|length }}) -{% endset %} - -{% set carriersTitle %} - {{ 'Carriers'|trans({}, 'Admin.Shipping.Feature') }} ({{ orderForViewing.shipping.carriers|length }}) -{% endset %} - -{% set merchantReturnsTitle %} - {{ 'Merchandise returns'|trans({}, 'Admin.Orderscustomers.Feature') }} ({{ orderForViewing.returns.orderReturns|length }}) -{% endset %} - -
      - - -
      -
      - {% embed '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/details_card.html.twig' %} - {% block header %} - {{ statusTitle }} - {% endblock %} - {% block body %} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/history.html.twig' %} - {% endblock %} - {% endembed %} -
      -
      - {% embed '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/details_card.html.twig' %} - {% block header %} - {{ documentsTitle }} - {% endblock %} - {% block body %} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/documents.html.twig' %} - {% endblock %} - {% endembed %} -
      -
      - {% embed '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/details_card.html.twig' %} - {% block header %} - {{ carriersTitle }} - {% endblock %} - {% block body %} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/shipping.html.twig' %} - {% endblock %} - {% endembed %} -
      -
      - {% embed '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/details_card.html.twig' %} - {% block header %} - {{ merchantReturnsTitle }} - {% endblock %} - {% block body %} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/merchandise_returns.html.twig' %} - {% endblock %} - {% endembed %} -
      -
      -
      - -{% set displayAdminOrderTabLink = renderhook('displayAdminOrderTabLink', {'id_order': orderForViewing.id}) %} -{% set displayAdminOrderTabContent = renderhook('displayAdminOrderTabContent', {'id_order': orderForViewing.id}) %} -{% if displayAdminOrderTabLink is not empty or displayAdminOrderTabContent is not empty%} -
      - - -
      - {# Rendering of hook displayAdminOrderTabContent, we expect tab contents #} - {{ displayAdminOrderTabContent|raw }} -
      -
      -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/details_card.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/details_card.html.twig deleted file mode 100644 index a5fe887d..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/details_card.html.twig +++ /dev/null @@ -1,34 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
      -
      - {% block header %} - {% endblock %} -
      -
      - {% block body %} - {% endblock %} -
      -
      diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/discount_list.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/discount_list.html.twig deleted file mode 100644 index 440026ec..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/discount_list.html.twig +++ /dev/null @@ -1,49 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - - - - - - - - - {% for discount in discounts %} - - - - - - {% endfor %} - -
      {{ 'Name'|trans({}, 'Admin.Global') }}{{ 'Value'|trans({}, 'Admin.Global') }}{{ 'Actions'|trans({}, 'Admin.Global') }}
      {{ discount.name }} - {% if discount.amountRaw.greaterThan(number(0)) %}-{% endif %} - {{ discount.amountFormatted }} - - - delete - -
      diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/documents.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/documents.html.twig deleted file mode 100644 index 6e3d339a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/documents.html.twig +++ /dev/null @@ -1,149 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - - - - - - - - - - - - {% if orderForViewing.documents.documents is not empty %} - {% for document in orderForViewing.documents.documents %} - - - - - - - - {% if document.type == 'invoice' %} - - - - {% endif %} - {% endfor %} - {% else %} - - - - {% endif %} - -
      - {{ 'Date'|trans({}, 'Admin.Global') }} - - {{ 'Document'|trans({}, 'Admin.Orderscustomers.Feature') }} - - {{ 'Number'|trans({}, 'Admin.Orderscustomers.Feature') }} - - {{ 'Amount'|trans({}, 'Admin.Global') }} - - {{ 'Actions'|trans({}, 'Admin.Global') }} -
      - {{ document.createdAt|date_format_lite }} - - {% if document.type == 'invoice' %} - {{ 'Invoice'|trans({}, 'Admin.Global') }} - {% elseif document.type == 'credit_slip' %} - {{ 'Credit slip'|trans({}, 'Admin.Orderscustomers.Feature') }} - {% else %} - {{ 'Delivery slip'|trans({}, 'Admin.Orderscustomers.Feature') }} - {% endif %} - - {% if document.type == 'invoice' %} - - {{ document.referenceNumber }} - - {% elseif document.type == 'delivery_slip' %} - - {{ document.referenceNumber }} - - {% elseif document.type == 'credit_slip' %} - - {{ document.referenceNumber }} - - {% endif %} - - {% if document.amount %} -

      - {{ document.amount }} - - {% if document.amountMismatch %} - ({{ document.amountMismatch }}) - {% endif %} -

      - {% else %} - -- - {% endif %} -
      - {% if document.type == 'invoice' %} - {% if (document.isAddPaymentAllowed and document.amount) %} - - {% endif %} - - {% endif %} -
      -
      -
      - - - -
      -
      -
      - {{ 'There is no available document'|trans({}, 'Admin.Orderscustomers.Notification') }} -
      - -{% if orderForViewing.documents.documents is empty and orderForViewing.invoiceManagementIsEnabled %} -
      - -
      -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/edit_product_row.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/edit_product_row.html.twig deleted file mode 100644 index 2debee83..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/edit_product_row.html.twig +++ /dev/null @@ -1,58 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - - - - - {{ form_row(editProductRowForm.price_tax_excluded) }} - {{ form_row(editProductRowForm.price_tax_included) }} - - - {{ form_row(editProductRowForm.quantity, {'type':'number'}) }} - - - - - - {% if orderForViewing.hasInvoice() %} - - {{ form_row(editProductRowForm.invoice, { - 'attr': { - 'data-modal-edit-price-title': 'Edit the price'|trans({}, 'Admin.Orderscustomers.Feature'), - 'data-modal-edit-price-apply': 'Update'|trans({}, 'Admin.Actions'), - 'data-modal-edit-price-cancel': 'Cancel'|trans({}, 'Admin.Actions'), - 'data-modal-edit-price-body': 'Are you sure you want to edit this product price? It will be applied to all invoices of this order.'|trans({}, 'Admin.Orderscustomers.Notification'), - }}) - }} - - {% endif %} - -
      - {{ form_row(editProductRowForm.cancel) }} - {{ form_row(editProductRowForm.save) }} -
      - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/extra_order_button_actions.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/extra_order_button_actions.html.twig deleted file mode 100644 index d6f2a4b9..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/extra_order_button_actions.html.twig +++ /dev/null @@ -1,90 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{# Rendering of hook actionGetAdminOrderButtons, see ActionsBarButtonsCollection #} -{% if (backOfficeOrderButtons.isEmpty() != true) %} - - {% set buttons = backOfficeOrderButtons.toArray() %} - {% if buttons|length > 2 %} - - {% set firstButton = buttons|first %} - - - {# Display other buttons into a dropdown #} - {% set buttons = buttons|slice(1, buttons|length) %} - -
      -
      - -
      -
      - {% else %} - {# If only 2 buttons, display them like this #} - - {% for button in buttons %} - - {% endfor %} - {% endif %} - -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/header.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/header.html.twig deleted file mode 100644 index 6605db38..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/header.html.twig +++ /dev/null @@ -1,53 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -

      - #{{ orderForViewing.id }} - {{ orderForViewing.reference }} -

      - -

      - {{ 'from'|trans({}, 'Admin.Global') }} - - {% if orderForViewing.customer is not null %} - {{ orderForViewing.customer.firstName }} - {{ orderForViewing.customer.lastName }} - {% else %} - {{ 'Deleted customer'|trans({}, 'Admin.Global') }} - {% endif %} -

      - - - {{ orderForViewing.prices.totalAmountFormatted }} - - -

      - {{ orderForViewing.createdAt|date_format_lite }} - - {{ 'at'|trans({}, 'Admin.Global') }} - - {{ orderForViewing.createdAt|date('H:i:s') }} - -

      diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/history.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/history.html.twig deleted file mode 100644 index 6a49a9f5..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/history.html.twig +++ /dev/null @@ -1,75 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - - - {% for status in orderForViewing.history.statuses %} - - - - - - - {% endfor %} - -
      - - {{ status.name }} - - - {% if status.employeeLastName is not empty %} - {{ status.employeeFirstName ~ ' ' ~ status.employeeLastName }} - {% endif %} - - {{ status.createdAt|date_format_full }} - - {% if status.withEmail %} -
      - -
      - {% endif %} -
      - -
      -
      - {{ form_start(updateOrderStatusForm, {'action': path('admin_orders_update_status', {'orderId': orderForViewing.id}), 'attr': {'class': 'card-details-form'}, }) }} -
      - {{ form_widget(updateOrderStatusForm.new_order_status_id) }} - - -
      - -
      - {{ form_rest(updateOrderStatusForm) }} -
      - {{ form_end(updateOrderStatusForm) }} -
      -
      diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/linked_orders.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/linked_orders.html.twig deleted file mode 100644 index d7b2ea4a..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/linked_orders.html.twig +++ /dev/null @@ -1,75 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
      -
      -

      - {{ 'Linked orders'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ orderForViewing.linkedOrders.linkedOrders|length }} -

      -
      - -
      - - - - - - - - - - - {% if orderForViewing.linkedOrders.linkedOrders is not empty %} - {% for linkedOrder in orderForViewing.linkedOrders.linkedOrders %} - - - - - - {% endfor %} - {% endif %} - -
      - {{ 'Order ID'|trans({}, 'Admin.Orderscustomers.Feature') }} - - {{ 'Status'|trans({}, 'Admin.Global') }} - - {{ 'Amount'|trans({}, 'Admin.Global') }} -
      - - {{ linkedOrder.orderId }} - - - {{ linkedOrder.statusName }} - - {{ linkedOrder.amount }} - - - remove_red_eye - {{ 'View order'|trans({}, 'Admin.Orderscustomers.Feature') }} - -
      -
      diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/merchandise_returns.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/merchandise_returns.html.twig deleted file mode 100644 index a0645352..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/merchandise_returns.html.twig +++ /dev/null @@ -1,63 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if not orderForViewing.virtual %} - {% if orderForViewing.returns.orderReturns is not empty %} - - - - - - - - - - - {% for return in orderForViewing.returns.orderReturns %} - - - - - - - {% endfor %} - -
      {{ 'Date'|trans({}, 'Admin.Global') }}{{ 'Type'|trans({}, 'Admin.Global') }}{{ 'Carrier'|trans({}, 'Admin.Shipping.Feature') }}{{ 'Tracking number'|trans({}, 'Admin.Shipping.Feature') }}
      {{ return.date|date_format_full }}{{ return.type }}{{ return.stateName }} - {% if return.trackingNumber and return.trackingUrl %} - {{ return.trackingNumber }} - {% elseif return.trackingNumber %} - {{ return.trackingNumber }} - {% endif %} -
      - {% else %} -

      {{ 'No merchandise returned yet'|trans({}, 'Admin.Orderscustomers.Notification') }}

      - {% endif %} - - {% if orderForViewing.shipping.carrierModuleInfo %} - {{ orderForViewing.shipping.carrierModuleInfo|raw }} - {% endif %} -{% else %} -

      {{ 'Merchandise returns are not applicable for virtual orders'|trans({}, 'Admin.Orderscustomers.Notification') }}

      -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/messages.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/messages.html.twig deleted file mode 100644 index e6a5020b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/messages.html.twig +++ /dev/null @@ -1,109 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% set messagesToShow = 4 %} - -
      -
      -
      -
      -

      - {{ 'Messages'|trans({}, 'Admin.Global') }} ({{ orderForViewing.messages.total }}) -

      -
      - {% if orderForViewing.messages.total > messagesToShow %} - - {% endif %} -
      -
      - - {% if orderForViewing.messages.messages is not empty %} -
        - {% for message in orderForViewing.messages.messages|slice(0, messagesToShow)|reverse %} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/msg_list_item.html.twig' %} - {% endfor %} -
      - {% endif %} - -
      - {{ form_start(orderMessageForm, { - 'action': path('admin_orders_send_message', { orderId: orderForViewing.id }) - }) }} - - {{ ps.form_group_row(orderMessageForm.order_message, {}, { - 'label': 'Choose your order message'|trans({}, 'Admin.Orderscustomers.Feature'), - 'label_on_top': true, - 'class': 'mb-0' - }) }} - -
      -
      {{ 'Do you want to overwrite your existing message?'|trans({}, 'Admin.Orderscustomers.Notification') }}
      - {% for id, message in orderMessageForm.vars['messages'] %} -
      - {{ message }} -
      - {% endfor %} -
      - - - - {{ ps.form_group_row(orderMessageForm.is_displayed_to_customer, {'material_design': true}) }} - - {{ ps.form_group_row(orderMessageForm.message, {'attr': { 'cols':30, 'rows':3 }}, { - 'label': 'Message'|trans({}, 'Admin.Global'), - 'label_on_top': true, - 'class': 'js-text-with-length-counter' - }) }} - - {% block order_message_form_rest %} - {{ form_rest(orderMessageForm) }} - {% endblock %} - -
      - -
      - - {{ form_end(orderMessageForm) }} -
      -
      - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/msg_list_item.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/msg_list_item.html.twig deleted file mode 100644 index 4e0fa679..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/msg_list_item.html.twig +++ /dev/null @@ -1,65 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
    • -
      - {% if not message.employeeId %} -
      - account_circle -
      - -
      -

      - {{ message.message|nl2br }} -

      -

      - {{ message.customerFirstName ~ ' ' ~ message.customerLastName }} - {{ message.messageDate.format }} -

      -
      - {% endif %} - - {% if message.employeeId %} -
      -

      - {{ message.message|nl2br }} -

      -

      - {% if message.isCurrentEmployeesMessage %} - {{ 'Me'|trans({}, 'Admin.Global') }} - {% else %} - {{ message.employeeFirstName ~ ' ' ~ message.employeeLastName }} - {% endif %} - - {{ message.messageDate.format }} -

      -
      - -
      - -
      - {% endif %} -
      -
    • diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/order_actions.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/order_actions.html.twig deleted file mode 100644 index 99ee0ff6..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/order_actions.html.twig +++ /dev/null @@ -1,125 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - {{ form_start(updateOrderStatusActionBarForm, { - 'action': path('admin_orders_update_status', {'orderId': orderForViewing.id}), - 'attr': { - 'id': 'update_order_status_action_form' - } - }) }} - -
      - {% set backgroundColor = '#ffffff' %} - {% set isBright = true %} - {% for choice in updateOrderStatusActionBarForm.new_order_status_id.vars.choices %} - {% if choice.value == updateOrderStatusActionBarForm.new_order_status_id.vars.data %} - {% set backgroundColor = choice.attr['data-background-color'] %} - {% set isBright = choice.attr['data-is-bright'] %} - {% endif %} - {% endfor %} -
      - {{ form_widget(updateOrderStatusActionBarForm.new_order_status_id, { - 'attr': { - 'class': 'select-status-colored', - }, - 'id': 'update_order_status_action_input', - }) }} -
      - - -
      - -
      - {{ form_rest(updateOrderStatusActionBarForm) }} -
      - {{ form_end(updateOrderStatusActionBarForm) }} - - {% if orderForViewing.documents.canGenerateInvoice %} -
      - -
      - {% endif %} - -
      -
      - -
      -
      - - {% if orderForViewing.documents.canGenerateDeliverySlip %} -
      - -
      - {% endif %} - - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/extra_order_button_actions.html.twig' %} - - {% if merchandiseReturnEnabled %} - {% if orderForViewing.isDelivered() %} - - {% elseif orderForViewing.hasBeenPaid() or orderForViewing.hasPayments() %} - - {% else %} - - {% endif %} - {% endif %} - - {% if orderForViewing.hasBeenPaid() or orderForViewing.hasPayments() %} - - {% endif %} - - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/order_navigation.html.twig' %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/order_navigation.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/order_navigation.html.twig deleted file mode 100644 index 8cfaf704..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/order_navigation.html.twig +++ /dev/null @@ -1,46 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/payments.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/payments.html.twig deleted file mode 100644 index bc7c6810..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/payments.html.twig +++ /dev/null @@ -1,155 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -
      -
      -

      - {{ 'Payment'|trans({}, 'Admin.Global') }} ({{ orderForViewing.payments.payments|length }}) -

      -
      - -
      - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/payments_alert.html.twig' with { - 'payments': orderForViewing.payments, - 'linkedOrders': orderForViewing.linkedOrders - } %} - - - - - - - - - - - - - - {% for payment in orderForViewing.payments.payments %} - - - - - - - - - - - - {% endfor %} - - {{ form_start(addOrderPaymentForm, {'action': path('admin_orders_add_payment', {'orderId': orderForViewing.id})}) }} - - - - - - - {{ form_end(addOrderPaymentForm) }} - - -
      {{ 'Date'|trans({}, 'Admin.Global') }}{{ 'Payment method'|trans({}, 'Admin.Orderscustomers.Feature') }}{{ 'Transaction ID'|trans({}, 'Admin.Orderscustomers.Feature') }}{{ 'Amount'|trans({}, 'Admin.Global') }}{{ 'Invoice'|trans({}, 'Admin.Global') }}
      {{ payment.date|date_format_full }}{{ payment.paymentMethod }}{{ payment.transactionId }}{{ payment.amount }}{% if payment.invoiceNumber %}{{ payment.invoiceNumber }}{% endif %} - -
      -

      - {{ 'Card number'|trans({}, 'Admin.Orderscustomers.Feature') }} - {% if payment.cardNumber %} - {{ payment.cardNumber }} - {% else %} - {{ 'Not defined'|trans({}, 'Admin.Orderscustomers.Feature') }} - {% endif %} -

      -

      - {{ 'Card type'|trans({}, 'Admin.Orderscustomers.Feature') }}  - {% if payment.cardBrand %} - {{ payment.cardBrand }} - {% else %} - {{ 'Not defined'|trans({}, 'Admin.Orderscustomers.Feature') }} - {% endif %} -

      -

      - {{ 'Expiration date'|trans({}, 'Admin.Catalog.Feature') }}  - {% if payment.cardExpiration %} - {{ payment.cardExpiration }} - {% else %} - {{ 'Not defined'|trans({}, 'Admin.Orderscustomers.Feature') }} - {% endif %} -

      -

      - {{ 'Cardholder name'|trans({}, 'Admin.Orderscustomers.Feature') }}  - {% if payment.cardHolder %} - {{ payment.cardHolder }} - {% else %} - {{ 'Not defined'|trans({}, 'Admin.Orderscustomers.Feature') }} - {% endif %} -

      -
      - {{ form_widget(addOrderPaymentForm.date) }} - - {{ form_widget(addOrderPaymentForm.payment_method) }} - - {{ form_widget(addOrderPaymentForm.transaction_id) }} - -
      - {{ form_widget(addOrderPaymentForm.amount) }} - {{ form_widget(addOrderPaymentForm.id_currency) }} -
      -
      -
      - {{ form_widget(addOrderPaymentForm.id_invoice) }} -
      -
      - -
      - - {% if not orderForViewing.valid and changeOrderCurrencyForm.new_currency_id.vars.choices|length %} - {{ form_start(changeOrderCurrencyForm, {'action': path('admin_orders_change_currency', {'orderId': orderForViewing.id})}) }} -
      - -
      -
      - {{ form_widget(changeOrderCurrencyForm.new_currency_id) }} - -
      - -
      - {{ form_rest(changeOrderCurrencyForm) }} -
      - - - {{ 'Do not forget to update your exchange rate before making this change.'|trans({}, 'Admin.Orderscustomers.Help') }} - -
      -
      - {{ form_end(changeOrderCurrencyForm) }} - {% endif %} -
      -
      diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/payments_alert.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/payments_alert.html.twig deleted file mode 100644 index 17ab4631..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/payments_alert.html.twig +++ /dev/null @@ -1,24 +0,0 @@ -{% if payments.amountToPay and payments.paidAmount %} - -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/print_order_statistics.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/print_order_statistics.html.twig deleted file mode 100644 index 9635a338..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/print_order_statistics.html.twig +++ /dev/null @@ -1,66 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -
      -
      -
      -
      -

      - {{ 'Date'|trans({}, 'Admin.Global') }} -

      - {{ orderForViewing.createdAt|date_format_full }} -
      -
      -

      - {{ 'Total'|trans({}, 'Admin.Global') }} -

      -

      - - {{ orderForViewing.prices.totalAmountFormatted }} - -

      -
      -
      -

      - - {{ 'Message'|trans({}, 'Admin.Global') }} - -

      - - {{ orderForViewing.messages.total }} - -
      -
      -

      - - {{ 'Products'|trans({}, 'Admin.Global') }} - -

      - - {{ orderForViewing.products.products|length }} - -
      -
      -
      -
      diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/print_title.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/print_title.html.twig deleted file mode 100644 index b722d814..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/print_title.html.twig +++ /dev/null @@ -1,31 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - {{ 'Order'|trans({}, 'Admin.Global') }} - - #{{ orderForViewing.id }} - - {{ orderForViewing.reference }} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/product.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/product.html.twig deleted file mode 100644 index fd4aa55c..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/product.html.twig +++ /dev/null @@ -1,181 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set rowIsDisplayed = (productIndex is defined and paginationNum is defined and productIndex > paginationNum) %} - - - {% if product.imagePath %} - {{ product.name }} - {% endif %} - - - -

      {{ product.name }}

      - {% if product.reference %} -

      - {{ 'Reference number:'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ product.reference }} -

      - {% endif %} - {% if product.supplierReference is not empty %} -

      - {{ 'Supplier reference:'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ product.supplierReference }} -

      - {% endif %} -
      - {% if product.type == constant('PrestaShop\\PrestaShop\\Core\\Domain\\Order\\QueryResult\\OrderProductForViewing::TYPE_PACK') and product.customizations is null %} - - {{ 'View pack content'|trans({}, 'Admin.Actions') }} - - {% endif %} - - {{ product.unitPrice }} - - {% if product.quantity > 1 %} - {{ product.quantity }} - {% else %} - {{ product.quantity }} - {% endif %} - -
      - -
      - - {{ product.location }} - - {% if product.quantityRefunded > 0 %} - {{ product.quantityRefunded }} ({{ product.amountRefunded }} {{ 'Refunded'|trans({}, 'Admin.Orderscustomers.Feature') }}) - {% endif %} - - {{ product.availableQuantity }} - {{ product.totalPrice }} - {% if orderForViewing.hasInvoice() %} - {{ product.orderInvoiceNumber }} - {% endif %} - {% if not orderForViewing.delivered %} - - - - - {% endif %} - -
      -
      -
      - {{ form_widget(cancelProductForm['selected_' ~ product.orderDetailId]) }} -
      -
      - {{ form_label(cancelProductForm['quantity_' ~ product.orderDetailId]) }} -
      - {% set quantityInputOptions = { - 'attr': { - 'data-product-price-tax-incl': product.unitPriceTaxInclRaw, - 'data-product-price-tax-excl': product.unitPriceTaxExclRaw, - 'data-amount-refundable': product.amountRefundableRaw, - 'data-quantity-refundable': product.quantityRefundable, - } - } %} - {{ form_widget(cancelProductForm['quantity_' ~ product.orderDetailId], quantityInputOptions) }} -
      / {{ product.quantityRefundable }}
      -
      -
      -
      - {{ form_label(cancelProductForm['amount_' ~ product.orderDetailId]) }} -
      - {{ form_widget(cancelProductForm['amount_' ~ product.orderDetailId]) }} -
      {{ orderCurrency.symbol }}
      - - {{ '(Max %amount_refundable% %tax_method%)'|trans({ - '%amount_refundable%': product.amountRefundable, - '%tax_method%': orderForViewing.taxMethod - }, 'Admin.Orderscustomers.Help')|raw }} - -
      -
      -
      -
      - - -{% if product.customizations is not null %} - - - {% set colspan = 8 %} - {% set colspan = (orderForViewing.hasInvoice() ? colspan + 1 : colspan) %} - {% set colspan = (not orderForViewing.delivered ? colspan + 1 : colspan) %} - - {% if product.customizations.fileCustomizations %} -
      - {% for customization in product.customizations.fileCustomizations %} -
      -

      {{ customization.name }}

      -

      - - {{ customization.name }} - -

      -
      - {% endfor %} -
      - {% endif %} - {% for customization in product.customizations.textCustomizations %} -

      {{ customization.name }} : {{ customization.value }}

      - {% endfor %} - {% if product.type == constant('PrestaShop\\PrestaShop\\Core\\Domain\\Order\\QueryResult\\OrderProductForViewing::TYPE_PACK') %} -
      - {{ 'View pack content'|trans({}, 'Admin.Actions') }} -
      - {% endif %} - - -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/product_list.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/product_list.html.twig deleted file mode 100644 index 2ba3375e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/product_list.html.twig +++ /dev/null @@ -1,10 +0,0 @@ -{% for product in orderForViewing.products.products %} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/product.html.twig' with { - 'product': product, - 'productIndex': loop.index, - 'paginationNum': paginationNum, - 'isColumnLocationDisplayed': isColumnLocationDisplayed, - 'isColumnRefundedDisplayed': isColumnRefundedDisplayed, - 'isAvailableQuantityDisplayed': isAvailableQuantityDisplayed - } %} -{% endfor %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/products.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/products.html.twig deleted file mode 100644 index 962d469c..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/products.html.twig +++ /dev/null @@ -1,257 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set isColumnLocationDisplayed = false %} -{% set isColumnRefundedDisplayed = false %} -{% for product in orderForViewing.products.products|slice(0, paginationNum) %} - {% if product.location is not empty %} - {% set isColumnLocationDisplayed = true %} - {% endif %} - {% if product.quantityRefunded > 0 %} - {% set isColumnRefundedDisplayed = true %} - {% endif %} -{% endfor %} -
      -
      -

      - {{ 'Products'|trans({}, 'Admin.Global') }} ({{ orderForViewing.products.products|length }}) -

      -
      - -
      -
      -
      -
      - {% set formOptions = { - 'attr': { - 'data-order-id': orderForViewing.id, - 'data-is-delivered': orderForViewing.isDelivered, - 'data-is-tax-included': orderForViewing.isTaxIncluded, - 'data-discounts-amount': orderForViewing.prices.discountsAmountRaw, - 'data-price-specification': priceSpecification|json_encode|replace("'", "'")|raw - } - } %} - {{ form_start(cancelProductForm, formOptions) }} - - - - - - - - - - - - {% if orderForViewing.hasInvoice() %} - - {% endif %} - {% if not orderForViewing.delivered %} - - {% endif %} - - - - - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/product_list.html.twig' %} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/add_product_row.html.twig' %} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/edit_product_row.html.twig' %} - -
      -

      {{ 'Product'|trans({}, 'Admin.Global') }}

      -
      -

      {{ 'Price per unit'|trans({}, 'Admin.Advparameters.Feature') }}

      - {{ orderForViewing.taxMethod }} -
      -

      {{ 'Quantity'|trans({}, 'Admin.Global') }}

      -
      -

      {{ 'Stock location'|trans({}, 'Admin.Orderscustomers.Feature') }}

      -
      -

      {{ 'Refunded'|trans({}, 'Admin.Orderscustomers.Feature') }}

      -
      -

      {{ 'Available'|trans({}, 'Admin.Global') }}

      -
      -

      {{ 'Total'|trans({}, 'Admin.Global') }}

      - {{ orderForViewing.taxMethod }} -
      -

      {{ 'Invoice'|trans({}, 'Admin.Global') }}

      -
      -

      {{ 'Actions'|trans({}, 'Admin.Global') }}

      -
      -

      {{ 'Partial refund'|trans({}, 'Admin.Orderscustomers.Feature') }}

      -
      - -
      -
      -
      - -
      - -
      -
      - {% set numPages = max(orderForViewing.products.products|length / paginationNum, 1)|round(0, 'ceil') %} - -
      -
      - {% if not orderForViewing.delivered %} - - {% endif %} - -
      -
      - - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/discount_list.html.twig' with { - 'discounts': orderForViewing.discounts.discounts, - 'orderId': orderForViewing.id - } %} - -
      -
      -
      -
      -
      -

      {{ 'Products'|trans({}, 'Admin.Global') }}

      - {{ orderForViewing.prices.productsPriceFormatted }} -
      - -
      -

      {{ 'Discounts'|trans({}, 'Admin.Global') }}

      - -{{ orderForViewing.prices.discountsAmountFormatted }} -
      - - {% if orderForViewing.prices.wrappingPriceRaw.greaterThan(number(0)) %} -
      -

      {{ 'Wrapping'|trans({}, 'Admin.Orderscustomers.Feature') }}

      - {{ orderForViewing.prices.wrappingPriceFormatted }} -
      - {% endif %} - -
      -

      {{ 'Shipping'|trans({}, 'Admin.Catalog.Feature') }}

      -
      - {{ orderForViewing.prices.shippingPriceFormatted }} -
      -
      - {{ form_widget(cancelProductForm.shipping_amount) }} -
      -
      {{ orderCurrency.symbol }}
      -
      -
      -

      (max {{ orderForViewing.prices.shippingRefundableAmountFormatted }} tax included)

      -
      -
      -
      - - {% if not orderForViewing.taxIncluded %} -
      -

      {{ 'Taxes'|trans({}, 'Admin.Global') }}

      - {{ orderForViewing.prices.taxesAmountFormatted }} -
      - {% endif %} - -
      -

      {{ 'Total'|trans({}, 'Admin.Global') }}

      - {{ orderForViewing.prices.totalAmountFormatted }} -
      - -
      -
      -
      -
      -

      - - {{ 'For this customer group, prices are displayed as: [1]%tax_method%[/1]'|trans({ - '%tax_method%': orderForViewing.taxMethod, - '[1]': '', - '[/1]': '' - }, 'Admin.Orderscustomers.Notification')|raw }}. - - {% if not 'PS_ORDER_RETURN'|configuration %} - {{ 'Merchandise returns are disabled'|trans({}, 'Admin.Orderscustomers.Notification') }} - {% endif %} - -

      -
      -
      - {{ form_widget(cancelProductForm.restock) }} -
      -
      - {{ form_widget(cancelProductForm.credit_slip) }} -
      -
      - {{ form_widget(cancelProductForm.voucher) }} -
      -
      -
      - {{ form_widget(cancelProductForm.shipping) }} - ({{ orderForViewing.prices.shippingRefundableAmountFormatted }}) -
      -
      -
      - {{ 'This order has been partially paid by voucher. Choose the amount you want to refund:'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ form_widget(cancelProductForm.voucher_refund_type) }} -
      - {{ 'Error. You cannot refund a negative amount.'|trans({}, 'Admin.Orderscustomers.Notification') }} -
      -
      -
      -
      -
      - {{ form_widget(cancelProductForm.cancel) }} - {{ form_widget(cancelProductForm.save) }} -
      -
      - {{ form_end(cancelProductForm) }} -
      -
      diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/shipping.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/shipping.html.twig deleted file mode 100644 index a1eb0bfe..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/shipping.html.twig +++ /dev/null @@ -1,101 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% if not orderForViewing.virtual %} - - {% if orderForViewing.shipping.giftMessage %} -
      - -
      - {{ orderForViewing.shipping.giftMessage }} -
      -
      - {% endif %} - - - - - - - - - - - - - - - {% for carrier in orderForViewing.shipping.carriers %} - - - - - - - - - - {% endfor %} - -
      {{ 'Date'|trans({}, 'Admin.Global') }} {{ 'Carrier'|trans({}, 'Admin.Shipping.Feature') }}{{ 'Weight'|trans({}, 'Admin.Global') }}{{ 'Shipping cost'|trans({}, 'Admin.Shipping.Feature') }}{{ 'Tracking number'|trans({}, 'Admin.Shipping.Feature') }}
      {{ carrier.date|date_format_lite }} {{ carrier.name }}{{ carrier.weight }}{{ carrier.price }} - {% if carrier.trackingNumber %} - {% if carrier.trackingUrl %} - {{ carrier.trackingNumber }} - {% else %} - {{ carrier.trackingNumber }} - {% endif %} - {% endif %} - - {% if carrier.canEdit %} - - {{ 'Edit'|trans({}, 'Admin.Actions') }} - - {% endif %} -
      - - {% if orderForViewing.shipping.carrierModuleInfo %} - {{ orderForViewing.shipping.carrierModuleInfo|raw }} - {% endif %} - - {% if orderForViewing.shipping.recycledPackaging %} - {{ 'Recycled packaging'|trans({}, 'Admin.Orderscustomers.Feature') }} - {% endif %} - - {% if orderForViewing.shipping.giftWrapping %} - {{ 'Gift wrapping'|trans({}, 'Admin.Orderscustomers.Feature') }} - {% endif %} -{% else %} -

      - {{ 'Shipping does not apply to virtual orders'|trans({}, 'Admin.Orderscustomers.Feature') }} -

      -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/sources.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/sources.html.twig deleted file mode 100644 index 4f7c2882..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/View/sources.html.twig +++ /dev/null @@ -1,63 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - - {% if orderForViewing.sources.sources is not empty %} -
      -
      -
      -
      - public - {{ 'Sources'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ orderForViewing.sources.sources|length }} -
      - -
        - {% for source in orderForViewing.sources.sources %} -
      • - {{ source.addedAt|date_format_full }} -
        - {{ 'From'|trans({}, 'Admin.Orderscustomers.Feature') }} - {% if source.httpReferer != '' %} - {{ source.httpReferer }} - {% else %} - - - {% endif %} -
        - {{ 'To'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ source.requestUri | slice(0,100) }} -
        - {% if source.keywords != '' %} - {{ 'Keywords'|trans({}, 'Admin.Global') }} -
        - {{ source.keywords }} - {% endif %} -
        -
      • - {% endfor %} -
      -
      -
      -
      - {% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/change_orders_status_modal.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/change_orders_status_modal.html.twig deleted file mode 100644 index 6603dd46..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/Blocks/change_orders_status_modal.html.twig +++ /dev/null @@ -1,56 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% embed 'PrestaShopBundle:Admin/Helpers:bootstrap_popup.html.twig' with { - 'id': 'changeOrdersStatusModal', - 'title': 'Choose an order status'|trans({}, 'Admin.Orderscustomers.Feature'), - 'closable': true, - 'actions': [{ - 'type': 'button', - 'label': 'Update status'|trans({}, 'Admin.Orderscustomers.Feature'), - 'class': 'btn btn-primary btn-lg js-submit-modal-form-btn', - }], -} %} - {% block content %} - - {% endblock %} -{% endembed %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/create.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/create.html.twig deleted file mode 100644 index 75590098..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/create.html.twig +++ /dev/null @@ -1,71 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% set layoutTitle = 'Create order'|trans({}, 'Admin.Orderscustomers.Feature') %} - -{% block content %} -
      -
      -
      - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/Create/customer.html.twig' %} -
      -
      -
      -
      -
      - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/Create/cart.html.twig' %} -
      -
      -
      -
      - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/Create/cart_rules.html.twig' %} -
      -
      -
      -
      - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/Create/addresses.html.twig' %} -
      -
      -
      -
      - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/Create/shipping.html.twig' %} -
      -
      -
      -
      - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/Create/summary.html.twig' %} -
      -
      -
      -
      -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/index.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/index.html.twig deleted file mode 100644 index 0a227187..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/index.html.twig +++ /dev/null @@ -1,60 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends 'PrestaShopBundle:Admin:layout.html.twig' %} - -{% block content %} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/change_orders_status_modal.html.twig' %} - - {% block orders_kpi %} -
      -
      -
      -
      - {{ render(controller( - 'PrestaShopBundle:Admin\\Common:renderKpiRow', - { 'kpiRow': orderKpi } - )) }} -
      -
      -
      -
      - {% endblock %} - - {% block order_grid_row %} -
      -
      - {% include '@PrestaShop/Admin/Common/Grid/grid_panel.html.twig' with {'grid': orderGrid} %} -
      -
      - {% endblock %} -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/preview.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/preview.html.twig deleted file mode 100644 index 948c8c6e..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/preview.html.twig +++ /dev/null @@ -1,193 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block order_preview %} -
      -
      -
      -
      -
      -
      -

      - local_shipping -

      -
      -
      -

      - {{ 'Carrier'|trans({}, 'Admin.Global') }}: - {% if not orderPreview.isVirtual %} - {{ orderPreview.shippingDetails.carrierName }} - {% else %} - - - {% endif %} -

      - -

      - {{ 'Tracking number'|trans({}, 'Admin.Shipping.Feature') }}: - {% if not orderPreview.isVirtual and orderPreview.shippingDetails.trackingNumber is not empty %} - {{ orderPreview.shippingDetails.trackingNumber }} - {% else %} - - - {% endif %} -

      - -

      - {{ 'Shipping details'|trans({}, 'Admin.Orderscustomers.Feature') }}: - {% if orderPreview.virtual %} - - - {% endif %} -

      - - {% if not orderPreview.virtual %} -

      {{ orderPreview.shippingDetails.firstName }} {{ orderPreview.shippingDetails.lastName }}

      - {% if orderPreview.shippingDetails.company %} -

      {{ orderPreview.shippingDetails.company }}

      - {% endif %} - {% if orderPreview.shippingDetails.vatNumber %} -

      {{ orderPreview.shippingDetails.vatNumber }}

      - {% endif %} -

      {{ orderPreview.shippingDetails.address1 }}

      -

      {{ orderPreview.shippingDetails.address2 }}

      -

      - {{ orderPreview.shippingDetails.city }}, - {% if orderPreview.shippingDetails.stateName %} - {{ orderPreview.shippingDetails.stateName }} - {% endif %} - {{ orderPreview.shippingDetails.postalCode }} -

      -

      {{ orderPreview.shippingDetails.country }}

      -

      {{ orderPreview.shippingDetails.phone }}

      - {% endif %} -
      -
      -
      -
      -
      -
      -

      - receipt -

      -
      -
      -

      - {{ 'Invoice details'|trans({}, 'Admin.Orderscustomers.Feature') }}: -

      - -

      {{ orderPreview.invoiceDetails.firstName }} {{ orderPreview.invoiceDetails.lastName }}

      - {% if orderPreview.invoiceDetails.company %} -

      {{ orderPreview.invoiceDetails.company }}

      - {% endif %} - {% if orderPreview.invoiceDetails.vatNumber %} -

      {{ orderPreview.invoiceDetails.vatNumber }}

      - {% endif %} -

      {{ orderPreview.invoiceDetails.address1 }}

      -

      {{ orderPreview.invoiceDetails.address2 }}

      -

      {{ orderPreview.invoiceDetails.country }}

      -

      - {{ orderPreview.invoiceDetails.city }}, - {% if orderPreview.invoiceDetails.stateName %} - {{ orderPreview.invoiceDetails.stateName }} - {% endif %} - {{ orderPreview.invoiceDetails.postalCode }} -

      -

      {{ orderPreview.invoiceDetails.phone }}

      -

      {{ orderPreview.invoiceDetails.email }}

      -
      -
      -
      -
      -
      -
      -
      - - - - {% if orderPreview.taxIncluded %} - {% set taxInclusion = 'Tax included'|trans({}, 'Admin.Global') %} - {% else %} - {% set taxInclusion = 'Tax excluded'|trans({}, 'Admin.Global') %} - {% endif %} - - - - - {% if orderPreview.taxIncluded == false %} - - {% endif %} - - - - - - {% for productDetail in orderPreview.productDetails %} - - - - - {% if orderPreview.taxIncluded == false %} - - {% endif %} - - - - {% endfor %} - - {% if orderPreview.productDetails|length > productsPreviewLimit %} - - - - {% endif %} - -
      - {{ 'Products'|trans({}, 'Admin.Global') }} - ({{ orderPreview.productDetails|length }}) - {{ 'Reference'|trans({}, 'Admin.Global') }}{{ 'Stock location'|trans({}, 'Admin.Orderscustomers.Feature') }} - {{ 'Tax'|trans({}, 'Admin.Global') }} - {{ 'Quantity'|trans({}, 'Admin.Global') }} - {{ 'Total'|trans({}, 'Admin.Global') }} - {{ taxInclusion }} -
      {{ productDetail.name }}{{ productDetail.reference }} - {% if productDetail.location is not empty %}{{ productDetail.location }}{% endif %} - {{ productDetail.totalTax }}{{ productDetail.quantity }}{{ productDetail.totalPrice }}
      - - more_horiz - {{ '(%count% more)'|trans({ - '%count%': orderPreview.productDetails|length - productsPreviewLimit - }, 'Admin.Global') }} - -
      -
      - - -
      -
      - {{ renderhook('displayOrderPreview', {'order_id': orderId}) }} -{% endblock %} - diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/view.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/view.html.twig deleted file mode 100644 index e81a1db2..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Order/Order/view.html.twig +++ /dev/null @@ -1,125 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% set use_regular_h1_structure = false %} -{% set layoutTitle %} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/header.html.twig' %} -{% endset %} - -{% extends '@PrestaShop/Admin/layout.html.twig' %} - - -{% block content %} -
      -
      - {% set displayAdminOrderTopHookContent = renderhook('displayAdminOrderTop', {'id_order': orderForViewing.id}) %} - - {% if displayAdminOrderTopHookContent != '' %} -
      - {{ displayAdminOrderTopHookContent|raw }} -
      - {% endif %} -
      - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/order_actions.html.twig' %} -
      -
      - -
      -
      - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/print_order_statistics.html.twig' %} -
      -
      - -
      -
      -
      - -
      -
      - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/print_title.html.twig' %} -
      -
      - -
      -
      - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/customer.html.twig' %} - - {{ renderhook('displayAdminOrderSide', {'id_order': orderForViewing.id}) }} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/messages.html.twig' %} - - {{ renderhook('displayAdminOrderSideBottom', {'id_order': orderForViewing.id}) }} -
      - -
      -
      - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/products.html.twig' %} -
      - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/details.html.twig' %} - - {{ renderhook('displayAdminOrderMain', {'id_order': orderForViewing.id}) }} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/payments.html.twig' %} - - {{ renderhook('displayAdminOrderMainBottom', {'id_order': orderForViewing.id}) }} -
      -
      - - {% if orderForViewing.sources.sources is not empty %} -
      -
      - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/sources.html.twig' %} -
      -
      - {% endif %} - - {% if orderForViewing.linkedOrders.linkedOrders is not empty %} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/linked_orders.html.twig' %} - {% endif %} - - {{ renderhook('displayAdminOrder', {'id_order': orderForViewing.id}) }} - - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/Modal/add_order_discount_modal.html.twig' %} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/Modal/update_shipping_modal.html.twig' %} - {% if orderForViewing.customer is not null %} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/Modal/update_customer_address_modal.html.twig' %} - {% endif %} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/Modal/view_all_messages_modal.html.twig' %} - {% include '@PrestaShop/Admin/Sell/Order/Order/Blocks/View/Modal/view_product_pack_modal.html.twig' %} -
      -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - -{% endblock %} - -{% set js_translatable = { - "The product was successfully added.": 'The product was successfully added.'|trans({}, 'Admin.Notifications.Success'), - "The product was successfully removed.": 'The product was successfully removed.'|trans({}, 'Admin.Notifications.Success'), - "[1] products were successfully added.": '[1] products were successfully added.'|trans({}, 'Admin.Notifications.Success'), - "[1] products were successfully removed.": '[1] products were successfully removed.'|trans({}, 'Admin.Notifications.Success'), -}|merge(js_translatable) -%} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Stock/overview.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Stock/overview.html.twig deleted file mode 100644 index 6add9736..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Stock/overview.html.twig +++ /dev/null @@ -1,73 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} - - {% if is_shop_context %} -
      - - {% else %} -
      - -
      - {% endif %} - -{% endblock %} - -{% block javascripts %} - - {% if is_shop_context %} - {{ parent() }} - - {% set productId = app.request.query.get('productId') ? app.request.query.get('productId') : false %} - - - {% if webpack_server %} - - {% else %} - - {% endif %} - {% endif %} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/Translations/overview.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Translations/overview.html.twig deleted file mode 100644 index 203ad028..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/Translations/overview.html.twig +++ /dev/null @@ -1,58 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@PrestaShop/Admin/layout.html.twig' %} - -{% block content %} -
      -{% endblock %} - -{% block javascripts %} - {{ parent() }} - - - - {% if webpack_server %} - - {% else %} - - {% endif %} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/bootstrap_4_horizontal_layout.html.twig b/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/bootstrap_4_horizontal_layout.html.twig deleted file mode 100644 index aed51b65..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/bootstrap_4_horizontal_layout.html.twig +++ /dev/null @@ -1,151 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% use '@PrestaShop/Admin/TwigTemplateForm/bootstrap_4_layout.html.twig' %} -{% block form_start -%} - {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-horizontal')|trim}) %} - {{- parent() -}} -{%- endblock form_start %} - -{# Labels #} - -{% block form_label -%} - {% spaceless %} - {% if label is same as(false) %} -
      - {% else %} - {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ block('form_label_class'))|trim}) %} - {{- parent() -}} - {% endif %} - {% endspaceless %} -{%- endblock form_label %} - -{% block form_label_class -%} - form-control-label -{%- endblock form_label_class %} - -{# Rows #} - -{% block form_row -%} - {% spaceless %} -
      - {{ form_label(form) }} -
      - {{ form_widget(form) }} - {{ form_errors(form) }} -
      -
      - {% endspaceless %} -{%- endblock form_row %} - -{% block checkbox_row -%} - {{- block('checkbox_radio_row') -}} -{%- endblock checkbox_row %} - -{% block radio_row -%} - {{- block('checkbox_radio_row') -}} -{%- endblock radio_row %} - -{% block checkbox_radio_row -%} - {% spaceless %} -
      -
      -
      - {{ form_widget(form) }} - {{ form_errors(form) }} -
      -
      - {% endspaceless %} -{%- endblock checkbox_radio_row %} - -{% block submit_row -%} - {% spaceless %} -
      -
      -
      - {{ form_widget(form) }} -
      -
      - {% endspaceless %} -{% endblock submit_row %} - -{% block form_group_class -%} - col-sm -{%- endblock form_group_class %} - -{% block form_row_class -%} - form-group row -{%- endblock form_row_class %} - -{% block text_with_unit_widget %} -
      - {{- block('form_widget_simple') -}} - {% if form.vars.unit is defined %} -
      - {{ form.vars.unit }} -
      - {% endif %} -
      -{% endblock text_with_unit_widget %} - -{% block ip_address_text_widget %} -
      - {{- block('form_widget_simple') -}} - -
      -{% endblock ip_address_text_widget %} - -{% block switch_widget %} -
      - {{- parent() -}} -
      -{% endblock switch_widget %} - -{% block text_with_length_counter_widget %} -
      - {% set current_length = form.vars.max_length - form.vars.value|length %} - - {% if form.vars.position == 'before' %} -
      - {{ current_length }} -
      - {% endif %} - - {% set attr = attr|merge({'data-max-length': form.vars.max_length, 'maxlength': form.vars.max_length, 'class': 'js-countable-input'}) -%} - - {% if form.vars.input == 'textarea' %} - {{- block('textarea_widget') -}} - {% else %} - {{- block('form_widget_simple') -}} - {% endif %} - - {% if form.vars.position == 'after' %} -
      - {{ current_length }} -
      - {% endif %} -
      -{% endblock text_with_length_counter_widget %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/bootstrap_4_layout.html.twig b/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/bootstrap_4_layout.html.twig deleted file mode 100644 index 5db9e33c..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/bootstrap_4_layout.html.twig +++ /dev/null @@ -1,827 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% use '@PrestaShop/Admin/TwigTemplateForm/form_div_layout.html.twig' %} -{% use '@PrestaShop/Admin/TwigTemplateForm/typeahead.html.twig' %} -{% use '@PrestaShop/Admin/TwigTemplateForm/material.html.twig' %} - -{# Widgets #} - -{% block form_widget_simple -%} - {% if type is not defined or 'file' != type %} - {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) -%} - {% endif %} - {{- parent() -}} -{%- endblock form_widget_simple %} - -{% block textarea_widget -%} - {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %} - {{- parent() -}} - - {{ block('form_help') }} -{%- endblock textarea_widget %} - -{% block button_widget -%} - {% set attr = attr|merge({class: (attr.class|default('btn-default') ~ ' btn')|trim}) %} - {{- parent() -}} -{%- endblock %} - -{% block money_widget -%} -
      - {% set prepend = '{{' == money_pattern[0:2] %} - {% if not prepend %} -
      - {{ money_pattern|replace({ '{{ widget }}':''}) }} -
      - {% endif %} - {{- block('form_widget_simple') -}} - {% if prepend %} -
      - {{ money_pattern|replace({ '{{ widget }}':''}) }} -
      - {% endif %} -
      -{%- endblock money_widget %} - -{% block percent_widget -%} -
      - {{- block('form_widget_simple') -}} -
      - % -
      -
      -{%- endblock percent_widget %} - -{% block datetime_widget -%} - {% if widget == 'single_text' %} - {{- block('form_widget_simple') -}} - {% else -%} - {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} -
      - {{- form_errors(form.date) -}} - {{- form_errors(form.time) -}} - {{- form_widget(form.date, { datetime: true } ) -}} - {{- form_widget(form.time, { datetime: true } ) -}} -
      - {%- endif %} -{%- endblock datetime_widget %} - -{% block date_widget -%} - {% if widget == 'single_text' %} - {{- block('form_widget_simple') -}} - {% else -%} - {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} - {% if datetime is not defined or not datetime -%} -
      - {%- endif %} - {{- date_pattern|replace({ - '{{ year }}': form_widget(form.year), - '{{ month }}': form_widget(form.month), - '{{ day }}': form_widget(form.day), - })|raw -}} - {% if datetime is not defined or not datetime -%} -
      - {%- endif -%} - {% endif %} -{%- endblock date_widget %} - -{% block time_widget -%} - {% if widget == 'single_text' %} - {{- block('form_widget_simple') -}} - {% else -%} - {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} - {% if datetime is not defined or false == datetime -%} -
      - {%- endif -%} - {{- form_widget(form.hour) }}:{{ form_widget(form.minute) }}{% if with_seconds %}:{{ form_widget(form.second) }}{% endif %} - {% if datetime is not defined or false == datetime -%} -
      - {%- endif -%} - {% endif %} -{%- endblock time_widget %} - -{% block choice_widget_collapsed -%} - {% set attr = attr|merge({class: (attr.class|default('') ~ ' custom-select')|trim}) %} - {{- parent() -}} -{%- endblock %} - -{% block choice_widget_expanded -%} - {% if '-inline' in label_attr.class|default('') -%} -
      - {%- for child in form %} - {{- form_widget(child, { - parent_label_class: label_attr.class|default(''), - translation_domain: choice_translation_domain, - }) -}} - {% endfor -%} -
      - {%- else -%} -
      - {%- for child in form %} - {{- form_widget(child, { - parent_label_class: label_attr.class|default(''), - translation_domain: choice_translation_domain, - }) -}} - {% endfor -%} -
      - {%- endif %} -{%- endblock choice_widget_expanded %} - -{% block checkbox_widget -%} - {% set parent_label_class = parent_label_class|default('') -%} - {% if 'checkbox-inline' in parent_label_class %} - {{- form_label(form, null, { widget: parent() }) -}} - {% else -%} -
      - {{- form_label(form, null, { widget: parent() }) -}} -
      - {%- endif %} -{%- endblock checkbox_widget %} - -{% block radio_widget -%} - {%- set parent_label_class = parent_label_class|default('') -%} - {% if 'radio-inline' in parent_label_class %} - {{- form_label(form, null, { widget: parent() }) -}} - {% else -%} -
      - {{- form_label(form, null, { widget: parent() }) -}} -
      - {%- endif %} -{%- endblock radio_widget %} - -{% block choice_tree_widget -%} -
      -
        -
      • {{ "Main category"|trans({}, 'Admin.Catalog.Feature') }}
      • - {%- for child in choices %} - {{ block('choice_tree_item_widget') }} - {% endfor -%} -
      -
      -{%- endblock choice_tree_widget %} - -{% block choice_tree_item_widget -%} -
    • - {% set checked = (form.vars.submitted_values is defined and submitted_values[child.id_category] is defined) ? 'checked="checked"' : '' %} - {% if multiple -%} -
      - -
      - {%- else -%} -
      - -
      - {%- endif %} - {% if child.children is defined %} -
        - {% for item in child.children %} - {% set child = item %} - {{ block('choice_tree_item_widget') }} - {% endfor -%} -
      - {% endif %} -
    • -{%- endblock choice_tree_item_widget %} - -{% block translatefields_widget %} - {{ form_errors(form) }} -
      - {% if hideTabs == false and form|length > 1 %} - - {% endif %} - -
      - {% for translationsFields in form %} -
      - {{ form_errors(translationsFields) }} - {{ form_widget(translationsFields) }} -
      - {% endfor %} -
      -
      -{% endblock %} - -{% block translate_fields_widget -%} - {% if type is not defined or 'file' != type %} - {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) -%} - {% endif %} - {{- parent() -}} -{%- endblock translate_fields_widget %} - -{% block translate_text_widget -%} - {{ form_errors(form) }} -
      - {% for translateField in form %} - {% set classes = translateField.vars.attr.class|default('') ~ ' js-locale-input'%} - {% set classes = classes ~ ' js-locale-' ~ translateField.vars.label %} - - {% if default_locale.id_lang != translateField.vars.name %} - {% set classes = classes ~ ' d-none' %} - {% endif %} - - {% set attr = translateField.vars.attr %} - - {{ form_widget(translateField, {attr: {'class': classes|trim}}) }} - {% endfor %} - - {% if not hide_locales %} - - {% endif %} -
      -{%- endblock translate_text_widget %} - -{% block translate_textarea_widget -%} - {{ form_errors(form) }} -
      - {% for textarea in form %} - {% set classes = textarea.vars.attr.class|default('') ~ ' js-locale-input'%} - {% set classes = classes ~ ' js-locale-' ~ textarea.vars.label %} - - {% if default_locale.id_lang != textarea.vars.name %} - {% set classes = classes ~ ' d-none' %} - {% endif %} - -
      - {{ form_widget(textarea, {attr: {'class': classes|trim}}) }} -
      - {% endfor %} - - {% if show_locale_select %} - - {% endif %} -
      -{%- endblock translate_textarea_widget %} - -{% block date_picker_widget %} - {% spaceless %} - {% set attr = attr|merge({'class': ((attr.class|default('') ~ ' datepicker')|trim)}) %} -
      - -
      -
      - date_range -
      -
      -
      - {% endspaceless %} -{% endblock date_picker_widget %} - -{% block date_range_widget %} - {% spaceless %} - {{ form_widget(form.from) }} - {{ form_widget(form.to) }} - {% endspaceless %} -{% endblock date_range_widget %} - -{% block search_and_reset_widget %} - {% spaceless %} - - {% if show_reset_button %} -
      -
      - -
      - {% endif %} - {% endspaceless %} -{% endblock search_and_reset_widget %} - -{% block switch_widget %} - {% spaceless %} - - {% for choice in choices %} - {% set inputId = id ~'_' ~ choice.value %} - - - {% endfor %} - - - {% endspaceless %} -{% endblock switch_widget %} - -{% block _form_step6_attachments_widget %} -
      - {{ 'There is no attachment yet.'|trans({}, 'Admin.Catalog.Notification') }} -
      -
      -
      -
      - - - - - - - - - - {%- for child in form %} - - - - - - {% endfor -%} - -
      {{ 'Title'|trans({}, 'Admin.Global') }}{{ 'File name'|trans({}, 'Admin.Global') }}{{ 'Type'|trans({}, 'Admin.Catalog.Feature') }}
      {{ form_widget(child) }}{{ form.vars.attr.data[loop.index0]['file_name'] }}{{ form.vars.attr.data[loop.index0]['mime'] }}
      -
      -
      -
      -{% endblock %} - -{# Labels #} - -{% block form_label -%} - {{- parent() -}} -{%- endblock form_label %} - -{% block choice_label -%} - {# remove the checkbox-inline and radio-inline class, it's only useful for embed labels #} - {%- set label_attr = label_attr|merge({class: label_attr.class|default('')|replace({'checkbox-inline': '', 'radio-inline': ''})|trim}) -%} - {{- block('form_label') -}} -{% endblock %} - -{% block checkbox_label -%} - {{- block('checkbox_radio_label') -}} -{%- endblock checkbox_label %} - -{% block radio_label -%} - {{- block('checkbox_radio_label') -}} -{%- endblock radio_label %} - -{% block checkbox_radio_label %} - {# Do not display the label if widget is not defined in order to prevent double label rendering #} - {% if widget is defined %} - {% if required %} - {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} - {% endif %} - {% if parent_label_class is defined %} - {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|trim}) %} - {% endif %} - {% if label is not same as(false) and label is empty %} - {% set label = name|humanize %} - {% endif %} - - {% if material_design is defined or attr.material_design is defined %} -
      - - {{- widget|raw -}} - - {{- label is not same as(false) ? (translation_domain is same as(false) ? label|raw : label|raw) -}} - -
      - {% else %} - - {{- widget|raw -}} - {{- label is not same as(false) ? (translation_domain is same as(false) ? label|raw : label|raw) -}} - - {% endif %} - {% endif %} -{% endblock checkbox_radio_label %} - -{# Rows #} - -{% block form_row -%} -
      - {{- form_label(form) -}} - {{- form_widget(form) -}} - {{- form_errors(form) -}} -
      -{%- endblock form_row %} - -{% block button_row -%} -
      - {{- form_widget(form) -}} -
      -{%- endblock button_row %} - -{% block choice_row -%} - {% set force_error = true %} - {{- block('form_row') }} -{%- endblock choice_row %} - -{% block date_row -%} - {% set force_error = true %} - {{- block('form_row') }} -{%- endblock date_row %} - -{% block time_row -%} - {% set force_error = true %} - {{- block('form_row') }} -{%- endblock time_row %} - -{% block datetime_row -%} - {% set force_error = true %} - {{- block('form_row') }} -{%- endblock datetime_row %} - -{% block checkbox_row -%} -
      - {{- form_widget(form) -}} - {{- form_errors(form) -}} -
      -{%- endblock checkbox_row %} - -{% block radio_row -%} -
      - {{- form_widget(form) -}} - {{- form_errors(form) -}} -
      -{%- endblock radio_row %} - -{# Errors #} - -{% block form_errors -%} - {% if errors|length > 0 -%} -
      - {%- if errors|length > 1 -%} -
        - {%- for error in errors -%} -
      • {{ - error.messagePluralization is null - ? error.messageTemplate|trans(error.messageParameters, 'form_error') - : error.messageTemplate|transchoice(error.messagePluralization, error.messageParameters, 'form_error') - }} -
      • - {%- endfor -%} -
      - {%- else -%} -
      - {%- for error in errors -%} -

      {{ - error.messagePluralization is null - ? error.messageTemplate|trans(error.messageParameters, 'form_error') - : error.messageTemplate|transchoice(error.messagePluralization, error.messageParameters, 'form_error') - }} -

      - {%- endfor -%} -
      - {%- endif -%} -
      - {%- endif %} -{%- endblock form_errors %} - - -{# Material design widgets #} - -{% block material_choice_table_widget %} - {% spaceless %} -
      - - - - - - - - {% for child in form %} - - - - {% endfor %} - -
      -
      - -
      -
      - {{ form_widget(child, {'material_design': true}) }} -
      -
      - {% endspaceless %} -{% endblock material_choice_table_widget %} - -{% block material_multiple_choice_table_widget %} - {% spaceless %} -
      - - - - - {% for child_choice in form %} - - {% endfor %} - - - - {% for choice_name, choice_value in choices %} - - - {% for child_choice_name, child_choice in form %} - - {% endfor %} - - {% endfor %} - -
      {{ label }} - {% if child_choice.vars.multiple and child_choice.vars.name not in headers_to_disable %} - - {{ child_choice.vars.label }} - - {% else %} - {{ child_choice.vars.label }} - {% endif %} -
      - {{ choice_name }} - - {% if child_choice_entry_index_mapping[choice_value][child_choice_name] is defined %} - {% set entry_index = child_choice_entry_index_mapping[choice_value][child_choice_name] %} - - {% if child_choice.vars.multiple %} - {{ form_widget(child_choice[entry_index], {'material_design': true}) }} - {% else %} - {{ form_widget(child_choice[entry_index]) }} - {% endif %} - {% else %} - -- - {% endif %} -
      -
      - {% endspaceless %} -{% endblock material_multiple_choice_table_widget %} - -{% block translatable_widget -%} -
      - {% for translateField in form %} - {% set classes = translateField.vars.attr.class|default('') ~ ' js-locale-input'%} - {% set classes = classes ~ ' js-locale-' ~ translateField.vars.label %} - {% if default_locale.id_lang != translateField.vars.name %} - {% set classes = classes ~ ' d-none' %} - {% endif %} -
      - {{ form_widget(translateField) }} -
      - {% endfor %} - {% if not hide_locales %} - - {% endif %} -
      -{%- endblock translatable_widget %} - -{% block birthday_widget %} - {% if widget == 'single_text' %} - {{- block('form_widget_simple') -}} - {% else -%} - {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} - {% if datetime is not defined or not datetime -%} -
      - {%- endif %} - - {% set yearWidget = '
      ' ~ form_widget(form.year) ~ '
      '|raw %} - {% set monthWidget = '
      ' ~ form_widget(form.month) ~ '
      '|raw %} - {% set dayWidget = '
      ' ~ form_widget(form.day) ~ '
      '|raw %} - - {{- date_pattern|replace({ - '{{ year }}': yearWidget, - '{{ month }}': monthWidget, - '{{ day }}': dayWidget, - })|raw -}} - - {% if datetime is not defined or not datetime -%} -
      - {%- endif -%} - {% endif %} -{% endblock birthday_widget %} - -{% block file_widget %} - -
      - {% set attr = attr|merge({ - class: (attr.class|default('') ~ ' custom-file-input')|trim, - 'data-multiple-files-text': '%count% file(s)'|trans({}, 'Admin.Global'), - 'data-locale': get_context_iso_code() - }) -%} - - {% if attr.disabled is defined and attr.disabled %} - {% set attr = attr|merge({ - class: attr.class ~ ' disabled' - }) %} - {% endif %} - - {{ form_widget(form, {'attr': attr}) }} - - -
      -{% endblock file_widget %} - -{% block shop_restriction_checkbox_widget %} - {% if form.vars.attr.is_allowed_to_display %} -
      - -
      - {% endif %} -{% endblock %} - -{% block generatable_text_widget %} -
      - {{- block('form_widget') -}} - - - -
      -{% endblock generatable_text_widget %} - -{% block text_with_recommended_length_widget %} - {% set attr = attr|merge({ - 'data-recommended-length-counter': '#' ~ id ~ '_recommended_length_counter', - 'class': 'js-recommended-length-input' - }) -%} - - {% if input_type == 'textarea' %} - {{- block('textarea_widget') -}} - {% else %} - {{- block('form_widget_simple') -}} - {% endif %} - - - - {{ '[1][/1] of [2][/2] characters used (recommended)'|trans({}, 'Admin.Catalog.Feature')|replace({ - '[1]': '' ~ value|length, - '[/1]': '', - '[2]': '' ~ recommended_length, - '[/2]': '', - })|raw }} - - -{% endblock text_with_recommended_length_widget %} - -{% block integer_min_max_filter_widget %} - {{ form_widget(form['min_field'], { attr: {class: 'min-field'}}) }} - {{ form_widget(form['max_field'], { attr: {class: 'max-field'}}) }} -{% endblock %} - -{% block number_min_max_filter_widget %} - {{ form_widget(form['min_field'], { attr: {class: 'min-field'}}) }} - {{ form_widget(form['max_field'], { attr: {class: 'max-field'}}) }} -{% endblock %} - -{% block form_help %} - {% if help %} - {{ help }} - {% endif %} -{% endblock form_help %} - -{% block custom_content_widget %} - {% include template with data %} -{% endblock %} - -{% block text_widget %} - {% if data_list is not null %} - {%- set attr = attr|merge({'list': id ~ '_datalist'}) -%} - {% endif %} - - {{ form_widget(form, {'attr': attr}) }} - - {% if data_list is not null %} - - {% for item in data_list %} - - {% endfor%} - - {% endif %} -{% endblock text_widget %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/form_div_layout.html.twig b/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/form_div_layout.html.twig deleted file mode 100644 index 2e38c430..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/form_div_layout.html.twig +++ /dev/null @@ -1,420 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{# Widgets #} - -{%- block form_widget -%} - {% if compound %} - {{- block('form_widget_compound') -}} - {% else %} - {{- block('form_widget_simple') -}} - {% endif %} - - {{- block('form_help') -}} -{%- endblock form_widget -%} - -{%- block form_widget_simple -%} - {%- set type = type|default('text') -%} - - {% include "@Twig/form_max_length.html.twig" with {"attr": attr} %} -{%- endblock form_widget_simple -%} - -{%- block form_widget_compound -%} -
      - {%- if form.parent is empty -%} - {{ form_errors(form) }} - {%- endif -%} - {{- block('form_rows') -}} - {{- form_rest(form) -}} -
      -{%- endblock form_widget_compound -%} - -{%- block collection_widget -%} - {% if prototype is defined %} - {%- set attr = attr|merge({'data-prototype': form_row(prototype) }) -%} - {% endif %} - {{- block('form_widget') -}} -{%- endblock collection_widget -%} - -{%- block textarea_widget -%} - - {% include "@Twig/form_max_length.html.twig" with {"attr": attr} %} -{%- endblock textarea_widget -%} - -{%- block choice_widget -%} - {% if expanded %} - {{- block('choice_widget_expanded') -}} - {% else %} - {{- block('choice_widget_collapsed') -}} - {% endif %} -{%- endblock choice_widget -%} - -{%- block choice_widget_expanded -%} -
      - {%- for child in form %} - {{- form_widget(child) -}} - {{- form_label(child, null, {translation_domain: choice_translation_domain}) -}} - {% endfor -%} -
      -{%- endblock choice_widget_expanded -%} - -{%- block choice_widget_collapsed -%} - {%- if required and placeholder is none and not placeholder_in_choices and not multiple -%} - {% set required = false %} - {%- endif -%} - -{%- endblock choice_widget_collapsed -%} - -{%- block choice_widget_options -%} - {% for group_label, choice in options %} - {%- if choice is iterable -%} - - {% set options = choice %} - {{- block('choice_widget_options') -}} - - {%- else -%} - - {%- endif -%} - {% endfor %} -{%- endblock choice_widget_options -%} - -{%- block checkbox_widget -%} - {% set switch = switch|default('') -%} - -{% endblock checkbox_widget -%} - -{%- block radio_widget -%} - -{% endblock radio_widget -%} - -{%- block datetime_widget -%} - {% if widget == 'single_text' %} - {{- block('form_widget_simple') -}} - {%- else -%} -
      - {{- form_errors(form.date) -}} - {{- form_errors(form.time) -}} - {{- form_widget(form.date) -}} - {{- form_widget(form.time) -}} -
      - {%- endif -%} -{%- endblock datetime_widget -%} - -{%- block date_widget -%} - {%- if widget == 'single_text' -%} - {{ block('form_widget_simple') }} - {%- else -%} -
      - {{- date_pattern|replace({ - '{{ year }}': form_widget(form.year), - '{{ month }}': form_widget(form.month), - '{{ day }}': form_widget(form.day), - })|raw -}} -
      - {%- endif -%} -{%- endblock date_widget -%} - -{%- block time_widget -%} - {%- if widget == 'single_text' -%} - {{ block('form_widget_simple') }} - {%- else -%} - {%- set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} -%} -
      - {{ form_widget(form.hour, vars) }}{% if with_minutes %}:{{ form_widget(form.minute, vars) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %} -
      - {%- endif -%} -{%- endblock time_widget -%} - -{%- block number_widget -%} - {# type="number" doesn't work with floats #} - {%- set type = type|default('text') -%} - {{ block('form_widget_simple') }} -{%- endblock number_widget -%} - -{%- block integer_widget -%} - {%- set type = type|default('number') -%} - {{ block('form_widget_simple') }} -{%- endblock integer_widget -%} - -{%- block money_widget -%} - {{ money_pattern|replace({ '{{ widget }}': block('form_widget_simple') })|raw }} -{%- endblock money_widget -%} - -{%- block url_widget -%} - {%- set type = type|default('url') -%} - {{ block('form_widget_simple') }} -{%- endblock url_widget -%} - -{%- block search_widget -%} - {%- set type = type|default('search') -%} - {{ block('form_widget_simple') }} -{%- endblock search_widget -%} - -{%- block percent_widget -%} - {%- set type = type|default('text') -%} - {{ block('form_widget_simple') }} % -{%- endblock percent_widget -%} - -{%- block password_widget -%} - {%- set type = type|default('password') -%} - {{ block('form_widget_simple') }} -{%- endblock password_widget -%} - -{%- block hidden_widget -%} - {%- set type = type|default('hidden') -%} - {{ block('form_widget_simple') }} -{%- endblock hidden_widget -%} - -{%- block email_widget -%} - {%- set type = type|default('email') -%} - {{ block('form_widget_simple') }} -{%- endblock email_widget -%} - -{%- block button_widget -%} - {%- if label is empty -%} - {%- if label_format is not empty -%} - {% set label = label_format|replace({ - '%name%': name, - '%id%': id, - }) %} - {%- else -%} - {% set label = name|humanize %} - {%- endif -%} - {%- endif -%} - -{%- endblock button_widget -%} - -{%- block submit_widget -%} - {%- set type = type|default('submit') -%} - {{ block('button_widget') }} -{%- endblock submit_widget -%} - -{%- block reset_widget -%} - {%- set type = type|default('reset') -%} - {{ block('button_widget') }} -{%- endblock reset_widget -%} - -{# Labels #} - -{%- block form_label -%} - {% if label is not same as(false) -%} - {% if not compound -%} - {% set label_attr = label_attr|merge({'for': id}) %} - {%- endif %} - {% if required -%} - {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %} - {%- endif %} - {% if label is empty -%} - {%- if label_format is not empty -%} - {% set label = label_format|replace({ - '%name%': name, - '%id%': id, - }) %} - {%- else -%} - {% set label = name|humanize %} - {%- endif -%} - {%- endif -%} - {{ translation_domain is same as(false) ? label|raw : label|raw }} - {% if label_attr['tooltip'] is defined %} - {% set placement = label_attr['tooltip_placement'] is defined ? label_attr['tooltip_placement'] : 'top' %} - - {% endif %} - - {% if label_attr['popover'] is defined %} - {% set placement = label_attr['popover_placement'] is defined ? label_attr['popover_placement'] : 'top' %} - - {% endif %} - - - {%- endif -%} -{%- endblock form_label -%} - -{%- block button_label -%}{%- endblock -%} - -{# Rows #} - -{%- block repeated_row -%} - {# - No need to render the errors here, as all errors are mapped - to the first child (see RepeatedTypeValidatorExtension). - #} - {{- block('form_rows') -}} -{%- endblock repeated_row -%} - -{%- block form_row -%} -
      - {{- form_label(form) -}} - {{- form_errors(form) -}} - {{- form_widget(form) -}} -
      -{%- endblock form_row -%} - -{%- block button_row -%} -
      - {{- form_widget(form) -}} -
      -{%- endblock button_row -%} - -{%- block hidden_row -%} - {{ form_widget(form) }} -{%- endblock hidden_row -%} - -{# Misc #} - -{%- block form -%} - {{ form_start(form) }} - {{- form_widget(form) -}} - {{ form_end(form) }} -{%- endblock form -%} - -{%- block form_start -%} - {% set method = method|upper %} - {%- if method in ["GET", "POST"] -%} - {% set form_method = method %} - {%- else -%} - {% set form_method = "POST" %} - {%- endif -%} -
      - {%- if form_method != method -%} - - {%- endif -%} -{%- endblock form_start -%} - -{%- block form_end -%} - {%- if not render_rest is defined or render_rest -%} - {{ form_rest(form) }} - {%- endif -%} -
      -{%- endblock form_end -%} - -{%- block form_enctype -%} - {% if multipart %}enctype="multipart/form-data"{% endif %} -{%- endblock form_enctype -%} - -{%- block form_errors -%} - {%- if errors|length > 0 -%} -
        - {%- for error in errors -%} -
      • {{ error.message }}
      • - {%- endfor -%} -
      - {%- endif -%} -{%- endblock form_errors -%} - -{%- block form_rest -%} - {% import '@PrestaShop/Admin/macros.html.twig' as ps %} - - {% for child in form -%} - {% if not child.rendered %} - {{- ps.form_group_row(child, { attr: child.vars.attr }, { - 'label': child.vars.label - }) -}} - {% endif %} - {%- endfor %} -{% endblock form_rest %} - -{# Support #} - -{%- block form_rows -%} - {% for child in form %} - {{- form_row(child) -}} - {% endfor %} -{%- endblock form_rows -%} - -{%- block widget_attributes -%} - id="{{ id }}" name="{{ full_name }}" - {%- if read_only|default(false) and attr.readonly is not defined %} readonly="readonly"{% endif -%} - {%- if disabled %} disabled="disabled"{% endif -%} - {%- if required %} required="required"{% endif -%} - {%- for attrname, attrvalue in attr -%} - {{- " " -}} - {%- if attrname in ['placeholder', 'title'] -%} - {{- attrname }}="{{ attrvalue }}" - {%- elseif attrvalue is same as(true) -%} - {{- attrname }}="{{ attrname }}" - {%- elseif attrvalue is not same as(false) -%} - {{- attrname }}="{{ attrvalue }}" - {%- endif -%} - {%- endfor -%} -{%- endblock widget_attributes -%} - -{%- block widget_container_attributes -%} - {%- if id is not empty %}id="{{ id }}"{% endif -%} - {%- for attrname, attrvalue in attr -%} - {{- " " -}} - {%- if attrname in ['placeholder', 'title'] -%} - {{- attrname }}="{{ attrvalue }}" - {%- elseif attrvalue is same as(true) -%} - {{- attrname }}="{{ attrname }}" - {%- elseif attrvalue is not same as(false) -%} - {{- attrname }}="{{ attrvalue }}" - {%- endif -%} - {%- endfor -%} -{%- endblock widget_container_attributes -%} - -{%- block button_attributes -%} - id="{{ id }}" name="{{ full_name }}"{% if disabled %} disabled="disabled"{% endif -%} - {%- for attrname, attrvalue in attr -%} - {{- " " -}} - {%- if attrname in ['placeholder', 'title'] -%} - {{- attrname }}="{{ attrvalue }}" - {%- elseif attrvalue is same as(true) -%} - {{- attrname }}="{{ attrname }}" - {%- elseif attrvalue is not same as(false) -%} - {{- attrname }}="{{ attrvalue }}" - {%- endif -%} - {%- endfor -%} -{%- endblock button_attributes -%} - -{% block attributes -%} - {%- for attrname, attrvalue in attr -%} - {{- " " -}} - {%- if attrname in ['placeholder', 'title'] -%} - {{- attrname }}="{{ attrvalue }}" - {%- elseif attrvalue is same as(true) -%} - {{- attrname }}="{{ attrname }}" - {%- elseif attrvalue is not same as(false) -%} - {{- attrname }}="{{ attrvalue }}" - {%- endif -%} - {%- endfor -%} -{%- endblock attributes -%} diff --git a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/form_max_length.html.twig b/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/form_max_length.html.twig deleted file mode 100644 index 160636cc..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/form_max_length.html.twig +++ /dev/null @@ -1,46 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% if attr.counter is defined %} - {% set isRecommandedType = attr.counter_type is defined and attr.counter_type == 'recommended' %} - - - {% if isRecommandedType %} - {{ '[1][/1] of [2][/2] characters used (recommended)'|trans({}, 'Admin.Catalog.Feature')|replace({ - '[1]': '', - '[/1]': '', - '[2]': ''~attr.counter, - '[/2]': '', - })|raw }} - {% else %} - {{ '[1][/1] of [2][/2] characters allowed'|trans({}, 'Admin.Catalog.Feature')|replace({ - '[1]': '', - '[/1]': '', - '[2]': ''~attr.counter, - '[/2]': '', - })|raw }} - {% endif %} - - -{% endif %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/form_table_layout.html.twig b/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/form_table_layout.html.twig deleted file mode 100644 index e5cf85c1..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/form_table_layout.html.twig +++ /dev/null @@ -1,68 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% use "form_div_layout.html.twig" %} - -{%- block form_row -%} - - - {{- form_label(form) -}} - - - {{- form_errors(form) -}} - {{- form_widget(form) -}} - - -{%- endblock form_row -%} - -{%- block button_row -%} - - - - {{- form_widget(form) -}} - - -{%- endblock button_row -%} - -{%- block hidden_row -%} - - - {{- form_widget(form) -}} - - -{%- endblock hidden_row -%} - -{%- block form_widget_compound -%} - - {%- if form.parent is empty and errors|length > 0 -%} - - - - {%- endif -%} - {{- block('form_rows') -}} - {{- form_rest(form) -}} -
      - {{- form_errors(form) -}} -
      -{%- endblock form_widget_compound -%} diff --git a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/material.html.twig b/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/material.html.twig deleted file mode 100644 index ad9647b9..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/material.html.twig +++ /dev/null @@ -1,101 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% block material_choice_tree_widget %} -
      -
      - - expand_more - {{ 'Expand'|trans({}, 'Admin.Actions') }} - -
      - -
        - {% for choice in choices_tree %} - {{ block('material_choice_tree_item_widget') }} - {% endfor %} -
      -
      -{% endblock material_choice_tree_widget %} - -{% block material_choice_tree_item_widget %} - {% set has_children = choice[choice_children] is defined %} - -
    • - {% if multiple %} - {{ block('material_choice_tree_item_checkbox_widget') }} - {% else %} - {{ block('material_choice_tree_item_radio_widget') }} - {% endif %} - - {% if has_children %} -
        - {% for item in choice[choice_children] %} - {% set choice = item %} - {{ block('material_choice_tree_item_widget') }} - {% endfor %} -
      - {% endif %} -
    • -{% endblock material_choice_tree_item_widget %} - -{% block material_choice_tree_item_checkbox_widget %} -
      -
      - -
      -
      -{% endblock material_choice_tree_item_checkbox_widget %} - -{% block material_choice_tree_item_radio_widget %} -
      - -
      -{% endblock material_choice_tree_item_radio_widget %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/prestashop_ui_kit.html.twig b/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/prestashop_ui_kit.html.twig deleted file mode 100644 index d8423a5b..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/prestashop_ui_kit.html.twig +++ /dev/null @@ -1,128 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% use 'bootstrap_4_horizontal_layout.html.twig' %} -{% use '@PrestaShop/Admin/TwigTemplateForm/prestashop_ui_kit_base.html.twig' %} - -{# overrides from bootstrap_4_horizontal_layout #} - -{% block form_start -%} - {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-horizontal')|trim}) %} - {{- parent() -}} -{%- endblock form_start %} - -{# Labels #} - -{% block form_label -%} - {% spaceless %} - {% if label is same as(false) %} -
      - {% else %} - {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ block('form_label_class'))|trim}) %} - {{- parent() -}} - {% endif %} - {% endspaceless %} -{%- endblock form_label %} - -{% block form_label_class -%} - form-control-label -{%- endblock form_label_class %} - -{# Rows #} - -{% block form_row -%} - {% spaceless %} -
      - {{ form_label(form) }} -
      - {{ form_widget(form) }} - {{ form_errors(form) }} -
      -
      - {% endspaceless %} -{%- endblock form_row %} - -{% block form_group_class -%} - col-sm -{%- endblock form_group_class %} - -{% block form_row_class -%} - form-group row{% if row_attr.class is defined %} {{ row_attr.class }}{% endif %} -{%- endblock form_row_class %} - -{# Widgets #} - -{% block text_with_unit_widget %} -
      - {{- block('form_widget_simple') -}} - {% if form.vars.unit is defined %} -
      - {{ form.vars.unit }} -
      - {% endif %} -
      -{% endblock text_with_unit_widget %} - -{% block ip_address_text_widget %} -
      - {{- block('form_widget_simple') -}} - -
      - -{% endblock ip_address_text_widget %} - -{% block switch_widget %} -
      - {{- parent() -}} -
      - {{ block('form_help') }} -{% endblock switch_widget %} - -{% block text_with_length_counter_widget %} -
      - {% set current_length = form.vars.max_length - form.vars.value|length %} - - {% if form.vars.position == 'before' %} -
      - {{ current_length }} -
      - {% endif %} - - {% set attr = attr|merge({'data-max-length': form.vars.max_length, 'maxlength': form.vars.max_length, 'class': 'js-countable-input'}) -%} - - {% if form.vars.input == 'textarea' %} - {{- block('textarea_widget') -}} - {% else %} - {{- block('form_widget_simple') -}} - {% endif %} - - {% if form.vars.position == 'after' %} -
      - {{ current_length }} -
      - {% endif %} -
      -{% endblock text_with_length_counter_widget %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/prestashop_ui_kit_base.html.twig b/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/prestashop_ui_kit_base.html.twig deleted file mode 100644 index 495c49fa..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/prestashop_ui_kit_base.html.twig +++ /dev/null @@ -1,849 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% use 'bootstrap_4_layout.html.twig' %} -{% use '@PrestaShop/Admin/TwigTemplateForm/typeahead.html.twig' %} -{% use '@PrestaShop/Admin/TwigTemplateForm/material.html.twig' %} - -{# overrides from form_div_layout #} - -{#--deleted {% block form_start -%} - {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-horizontal')|trim}) %} - {{- parent() -}} -{%- endblock form_start %}#} - -{# Widgets #} - -{%- block form_widget -%} - {{ parent() }} - {{- block('form_help') -}} -{%- endblock form_widget -%} - -{%- block form_widget_simple -%} - {{ parent() }} - {% include "@Twig/form_max_length.html.twig" with {"attr": attr} %} -{%- endblock form_widget_simple -%} - -{#--deleted {%- block checkbox_widget -%} - {% set switch = switch|default('') -%} - -{%- endblock checkbox_widget -%}#} - -{# Labels #} - -{%- block form_label -%} - {% if label is not same as(false) -%} - {% if not compound -%} - {% set label_attr = label_attr|merge({'for': id}) %} - {%- endif %} - {% if required -%} - {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %} - {%- endif %} - {% if label is empty -%} - {%- if label_format is not empty -%} - {% set label = label_format|replace({ - '%name%': name, - '%id%': id, - }) %} - {%- else -%} - {% set label = name|humanize %} - {%- endif -%} - {%- endif -%} - {{ translation_domain is same as(false) ? label|raw : label|raw }} - {% if label_attr['tooltip'] is defined %} - {% set placement = label_attr['tooltip_placement'] is defined ? label_attr['tooltip_placement'] : 'top' %} - - {% endif %} - - {% if label_attr['popover'] is defined %} - {% set placement = label_attr['popover_placement'] is defined ? label_attr['popover_placement'] : 'top' %} - - {% endif %} - - - {%- endif -%} -{%- endblock form_label -%} - -{# Misc #} - -{#--deleted {%- block form_row -%} - {% import '@PrestaShop/Admin/macros.html.twig' as ps %} - - {{- ps.form_group_row(form, { attr: form.vars.attr }, { - 'label': form.vars.label - }) -}} -{% endblock form_row %}#} - -{# overrides from bootstrap_4_layout #} - -{# Widgets #} - -{% block textarea_widget -%} - {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) %} - {{- parent() -}} - - {{ block('form_help') }} -{%- endblock textarea_widget %} - -{% block money_widget -%} -
      - {% set prepend = '{{' == money_pattern[0:2] %} - {% if not prepend %} -
      - {{ money_pattern|replace({ '{{ widget }}':''}) }} -
      - {% endif %} - {{- block('form_widget_simple') -}} - {% if prepend %} -
      - {{ money_pattern|replace({ '{{ widget }}':''}) }} -
      - {% endif %} -
      -{%- endblock money_widget %} - -{% block percent_widget -%} -
      - {{- block('form_widget_simple') -}} -
      - % -
      -
      -{%- endblock percent_widget %} - -{% block datetime_widget -%} - {% if widget == 'single_text' %} - {{- block('form_widget_simple') -}} - {% else -%} - {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} -
      - {{- form_errors(form.date) -}} - {{- form_errors(form.time) -}} - {{- form_widget(form.date, { datetime: true } ) -}} - {{- form_widget(form.time, { datetime: true } ) -}} -
      - {%- endif %} -{%- endblock datetime_widget %} - -{% block date_widget -%} - {% if widget == 'single_text' %} - {{- block('form_widget_simple') -}} - {% else -%} - {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} - {% if datetime is not defined or not datetime -%} -
      - {%- endif %} - {{- date_pattern|replace({ - '{{ year }}': form_widget(form.year), - '{{ month }}': form_widget(form.month), - '{{ day }}': form_widget(form.day), - })|raw -}} - {% if datetime is not defined or not datetime -%} -
      - {%- endif -%} - {% endif %} -{%- endblock date_widget %} - -{% block time_widget -%} - {% if widget == 'single_text' %} - {{- block('form_widget_simple') -}} - {% else -%} - {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} - {% if datetime is not defined or false == datetime -%} -
      - {%- endif -%} - {{- form_widget(form.hour) }}:{{ form_widget(form.minute) }}{% if with_seconds %}:{{ form_widget(form.second) }}{% endif %} - {% if datetime is not defined or false == datetime -%} -
      - {%- endif -%} - {% endif %} -{%- endblock time_widget %} - -{% block button_widget -%} - {% set attr = attr|merge({class: (attr.class|default('btn-default') ~ ' btn')|trim}) %} - {{- parent() -}} -{%- endblock %} - -{#{% block checkbox_widget -%} - {% set parent_label_class = parent_label_class|default('') -%} - {% if 'checkbox-inline' in parent_label_class %} - {{- form_label(form, null, { widget: parent() }) -}} - {% else -%} -
      - {{- form_label(form, null, { widget: parent() }) -}} -
      - {%- endif %} -{%- endblock checkbox_widget %} - -{% block radio_widget -%} - {%- set parent_label_class = parent_label_class|default('') -%} - {% if 'radio-inline' in parent_label_class %} - {{- form_label(form, null, { widget: parent() }) -}} - {% else -%} -
      - {{- form_label(form, null, { widget: parent() }) -}} -
      - {%- endif %} -{%- endblock radio_widget %}#} - -{% block choice_widget %} - {{- parent() -}} - {{ block('form_help') }} -{% endblock choice_widget %} - -{% block choice_widget_collapsed -%} - {% set attr = attr|merge({class: (attr.class|default('') ~ ' custom-select')|trim}) %} - {{- parent() -}} -{%- endblock %} - -{% block choice_widget_expanded -%} - {% if '-inline' in label_attr.class|default('') -%} -
      - {%- for child in form %} - {{- form_widget(child, { - parent_label_class: label_attr.class|default(''), - translation_domain: choice_translation_domain, - valid: valid, - }) -}} - {% endfor -%} -
      - {%- else -%} -
      - {%- for child in form %} - {{- form_widget(child, { - parent_label_class: label_attr.class|default(''), - translation_domain: choice_translation_domain, - valid: valid, - }) -}} - {% endfor -%} -
      - {%- endif %} -{%- endblock choice_widget_expanded %} - -{% block choice_tree_widget -%} -
      -
        -
      • {{ "Main category"|trans({}, 'Admin.Catalog.Feature') }}
      • - {%- for child in choices %} - {{ block('choice_tree_item_widget') }} - {% endfor -%} -
      -
      -{%- endblock choice_tree_widget %} - -{% block choice_tree_item_widget -%} -
    • - {% set checked = (form.vars.submitted_values is defined and submitted_values[child.id_category] is defined) ? 'checked="checked"' : '' %} - {% if multiple -%} -
      - -
      - {%- else -%} -
      - -
      - {%- endif %} - {% if child.children is defined %} -
        - {% for item in child.children %} - {% set child = item %} - {{ block('choice_tree_item_widget') }} - {% endfor -%} -
      - {% endif %} -
    • -{%- endblock choice_tree_item_widget %} - -{% block translatefields_widget %} - {{ form_errors(form) }} -
      - {% if hideTabs == false and form|length > 1 %} - - {% endif %} - -
      - {% for translationsFields in form %} -
      - {{ form_errors(translationsFields) }} - {{ form_widget(translationsFields) }} -
      - {% endfor %} -
      -
      -{% endblock %} - -{% block translate_fields_widget -%} - {% if type is not defined or 'file' != type %} - {%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) -%} - {% endif %} - {{- parent() -}} -{%- endblock translate_fields_widget %} - -{% block translate_text_widget -%} - {{ form_errors(form) }} -
      - {% for translateField in form %} - {% set classes = translateField.vars.attr.class|default('') ~ ' js-locale-input'%} - {% set classes = classes ~ ' js-locale-' ~ translateField.vars.label %} - - {% if default_locale.id_lang != translateField.vars.name %} - {% set classes = classes ~ ' d-none' %} - {% endif %} - - {% set attr = translateField.vars.attr %} - - {{ form_widget(translateField, {attr: {'class': classes|trim}}) }} - {% endfor %} - - {% if not hide_locales %} - - {% endif %} -
      -{%- endblock translate_text_widget %} - -{% block translate_textarea_widget -%} - {{ form_errors(form) }} -
      - {% for textarea in form %} - {% set classes = textarea.vars.attr.class|default('') ~ ' js-locale-input'%} - {% set classes = classes ~ ' js-locale-' ~ textarea.vars.label %} - - {% if default_locale.id_lang != textarea.vars.name %} - {% set classes = classes ~ ' d-none' %} - {% endif %} - -
      - {{ form_widget(textarea, {attr: {'class': classes|trim}}) }} -
      - {% endfor %} - - {% if show_locale_select %} - - {% endif %} -
      -{%- endblock translate_textarea_widget %} - -{% block date_picker_widget %} - {% spaceless %} - {% set attr = attr|merge({'class': ((attr.class|default('') ~ ' datepicker')|trim)}) %} -
      - -
      -
      - date_range -
      -
      -
      - {% endspaceless %} -{% endblock date_picker_widget %} - -{% block date_range_widget %} - {% spaceless %} - {{ form_widget(form.from) }} - {{ form_widget(form.to) }} - {% endspaceless %} -{% endblock date_range_widget %} - -{% block search_and_reset_widget %} - {% spaceless %} - - {% if show_reset_button %} -
      -
      - -
      - {% endif %} - {% endspaceless %} -{% endblock search_and_reset_widget %} - -{% block switch_widget %} - {% spaceless %} - - {% for choice in choices %} - {% set inputId = id ~'_' ~ choice.value %} - - - {% endfor %} - - - {% endspaceless %} -{% endblock switch_widget %} - -{% block _form_step6_attachments_widget %} -
      - {{ 'There is no attachment yet.'|trans({}, 'Admin.Catalog.Notification') }} -
      -
      -
      -
      - - - - - - - - - - {%- for child in form %} - - - - - - {% endfor -%} - -
      {{ 'Title'|trans({}, 'Admin.Global') }}{{ 'File name'|trans({}, 'Admin.Global') }}{{ 'Type'|trans({}, 'Admin.Catalog.Feature') }}
      {{ form_widget(child) }}{{ form.vars.attr.data[loop.index0]['file_name'] }}{{ form.vars.attr.data[loop.index0]['mime'] }}
      -
      -
      -
      -{% endblock %} - -{# Labels #} - -{% block choice_label -%} - {# remove the checkbox-inline and radio-inline class, it's only useful for embed labels #} - {%- set label_attr = label_attr|merge({class: label_attr.class|default('')|replace({'checkbox-inline': '', 'radio-inline': ''})|trim}) -%} - {{- block('form_label') -}} -{% endblock %} - -{% block checkbox_label -%} - {{- block('checkbox_radio_label') -}} -{%- endblock checkbox_label %} - -{% block radio_label -%} - {{- block('checkbox_radio_label') -}} -{%- endblock radio_label %} - -{% block checkbox_radio_label %} - {# Do not display the label if widget is not defined in order to prevent double label rendering #} - {% if widget is defined %} - {% if required %} - {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %} - {% endif %} - {% if parent_label_class is defined %} - {% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|trim}) %} - {% endif %} - {% if label is not same as(false) and label is empty %} - {% set label = name|humanize %} - {% endif %} - - {% if material_design is defined or attr.material_design is defined %} -
      - - {{- widget|raw -}} - - {{- label is not same as(false) ? (translation_domain is same as(false) ? label|raw : label|raw) -}} - -
      - {% else %} - - {{- widget|raw -}} - {{- label is not same as(false) ? (translation_domain is same as(false) ? label|raw : label|raw) -}} - - {% endif %} - {% endif %} -{% endblock checkbox_radio_label %} - -{# Errors #} - -{% block form_errors -%} - {% if errors|length > 0 -%} -
      - {%- if errors|length > 1 -%} -
        - {%- for error in errors -%} -
      • {{ - error.messagePluralization is null - ? error.messageTemplate|trans(error.messageParameters, 'form_error') - : error.messageTemplate|transchoice(error.messagePluralization, error.messageParameters, 'form_error') - }} -
      • - {%- endfor -%} -
      - {%- else -%} -
      - {%- for error in errors -%} -

      {{ - error.messagePluralization is null - ? error.messageTemplate|trans(error.messageParameters, 'form_error') - : error.messageTemplate|transchoice(error.messagePluralization, error.messageParameters, 'form_error') - }} -

      - {%- endfor -%} -
      - {%- endif -%} -
      - {%- endif %} -{%- endblock form_errors %} - -{# Material design widgets #} - -{% block material_choice_table_widget %} - {% spaceless %} -
      - - - - - - - - {% for child in form %} - - - - {% endfor %} - -
      -
      - -
      -
      - {{ form_widget(child, {'material_design': true}) }} -
      -
      - {% endspaceless %} -{% endblock material_choice_table_widget %} - -{% block material_multiple_choice_table_widget %} - {% spaceless %} -
      - - - - - {% for child_choice in form %} - - {% endfor %} - - - - {% for choice_name, choice_value in choices %} - - - {% for child_choice_name, child_choice in form %} - - {% endfor %} - - {% endfor %} - -
      {{ label }} - {% if child_choice.vars.multiple and child_choice.vars.name not in headers_to_disable %} - - {{ child_choice.vars.label }} - - {% else %} - {{ child_choice.vars.label }} - {% endif %} -
      - {{ choice_name }} - - {% if child_choice_entry_index_mapping[choice_value][child_choice_name] is defined %} - {% set entry_index = child_choice_entry_index_mapping[choice_value][child_choice_name] %} - - {% if child_choice.vars.multiple %} - {{ form_widget(child_choice[entry_index], {'material_design': true}) }} - {% else %} - {{ form_widget(child_choice[entry_index]) }} - {% endif %} - {% else %} - -- - {% endif %} -
      -
      - {% endspaceless %} -{% endblock material_multiple_choice_table_widget %} - -{% block translatable_widget -%} -
      - {% for translateField in form %} - {% set classes = translateField.vars.attr.class|default('') ~ ' js-locale-input'%} - {% set classes = classes ~ ' js-locale-' ~ translateField.vars.label %} - {% if default_locale.id_lang != translateField.vars.name %} - {% set classes = classes ~ ' d-none' %} - {% endif %} -
      - {{ form_widget(translateField) }} -
      - {% endfor %} - {% if not hide_locales %} - - {% endif %} -
      -{%- endblock translatable_widget %} - -{% block birthday_widget %} - {% if widget == 'single_text' %} - {{- block('form_widget_simple') -}} - {% else -%} - {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} - {% if datetime is not defined or not datetime -%} -
      - {%- endif %} - - {% set yearWidget = '
      ' ~ form_widget(form.year) ~ '
      '|raw %} - {% set monthWidget = '
      ' ~ form_widget(form.month) ~ '
      '|raw %} - {% set dayWidget = '
      ' ~ form_widget(form.day) ~ '
      '|raw %} - - {{- date_pattern|replace({ - '{{ year }}': yearWidget, - '{{ month }}': monthWidget, - '{{ day }}': dayWidget, - })|raw -}} - - {% if datetime is not defined or not datetime -%} -
      - {%- endif -%} - {% endif %} -{% endblock birthday_widget %} - -{% block file_widget %} - -
      - {% set attr = attr|merge({ - class: (attr.class|default('') ~ ' custom-file-input')|trim, - 'data-multiple-files-text': '%count% file(s)'|trans({}, 'Admin.Global'), - 'data-locale': get_context_iso_code() - }) -%} - - {% if attr.disabled is defined and attr.disabled %} - {% set attr = attr|merge({ - class: attr.class ~ ' disabled' - }) %} - {% endif %} - - {{ form_widget(form, {'attr': attr}) }} - - -
      -{% endblock file_widget %} - -{% block shop_restriction_checkbox_widget %} - {% if form.vars.attr.is_allowed_to_display %} -
      - -
      - {% endif %} -{% endblock %} - -{% block generatable_text_widget %} -
      - {{- block('form_widget') -}} - - - -
      -{% endblock generatable_text_widget %} - -{% block text_with_recommended_length_widget %} - {% set attr = attr|merge({ - 'data-recommended-length-counter': '#' ~ id ~ '_recommended_length_counter', - 'class': 'js-recommended-length-input' - }) -%} - - {% if input_type == 'textarea' %} - {{- block('textarea_widget') -}} - {% else %} - {{- block('form_widget_simple') -}} - {% endif %} - - - - {{ '[1][/1] of [2][/2] characters used (recommended)'|trans({}, 'Admin.Catalog.Feature')|replace({ - '[1]': '' ~ value|length, - '[/1]': '', - '[2]': '' ~ recommended_length, - '[/2]': '', - })|raw }} - - -{% endblock text_with_recommended_length_widget %} - -{% block integer_min_max_filter_widget %} - {{ form_widget(form['min_field'], { attr: {class: 'min-field'}}) }} - {{ form_widget(form['max_field'], { attr: {class: 'max-field'}}) }} -{% endblock %} - -{% block number_min_max_filter_widget %} - {{ form_widget(form['min_field'], { attr: {class: 'min-field'}}) }} - {{ form_widget(form['max_field'], { attr: {class: 'max-field'}}) }} -{% endblock %} - -{% block form_help %} - {% if help %} - {{ help|raw }} - {% endif %} - {% if warning is defined %} - {{ warning }} - {% endif %} -{% endblock form_help %} - -{% block custom_content_widget %} - {% include template with data %} -{% endblock %} - -{% block text_widget %} - {% if data_list is not null %} - {%- set attr = attr|merge({'list': id ~ '_datalist'}) -%} - {% endif %} - - {{ form_widget(form, {'attr': attr}) }} - - {% if data_list is not null %} - - {% for item in data_list %} - - {% endfor%} - - {% endif %} -{% endblock text_widget %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/typeahead.html.twig b/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/typeahead.html.twig deleted file mode 100644 index 1cf9c830..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/TwigTemplateForm/typeahead.html.twig +++ /dev/null @@ -1,305 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% block typeahead_product_collection_widget %} - - -{% endblock %} - -{% block typeahead_product_pack_collection_widget %} -

      {{ 'List of products for this pack'|trans({}, 'Admin.Catalog.Feature') }}

      -
        - {% if collection is defined and collection|length > 0 %} - {% for item in collection %} -
      • -
        - {{ template_collection|format(item.name, item.ref, item.quantity)|raw }} - - -
        -
      • - {% endfor %} - {% endif %} -
      - -

      {{ form.vars.label }}

      - -
      -
      - -
      -
      -
      -
      - × -
      - -
      -
      -
      -
      - -
      -
      -
      - - -
      -{% endblock %} - -{% block typeahead_customer_collection_widget %} - {{ form_errors(form) }} - -
        - {% if collection is defined and collection|length > 0 %} - {% for item in collection %} -
      • -
        - {{ template_collection|format(item.name)|raw }} -
        - -
      • - {% endfor %} - {% endif %} -
      - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/WebProfiler/commands_and_queries.html.twig b/src/PrestaShopBundle/Resources/views/Admin/WebProfiler/commands_and_queries.html.twig deleted file mode 100644 index a0da7dd5..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/WebProfiler/commands_and_queries.html.twig +++ /dev/null @@ -1,122 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} - -{% extends '@WebProfiler/Profiler/layout.html.twig' %} - -{% block toolbar %} - {% set icon %} - {{ include('@WebProfiler/Icon/request.svg') }} - Commands / Queries - {% endset %} - - {% set text %} -
      -
      - Commands / Queries -
      -
      - Commands - {% set commandsCount = collector.executedCommands|length %} - - {{ commandsCount }} - -
      -
      - Queries - {% set queriesCount = collector.executedQueries|length %} - - {{ queriesCount }} - -
      -
      - {% endset %} - - {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { 'link': true }) }} -{% endblock %} - -{% block menu %} - - {{ include('@WebProfiler/Icon/request.svg') }} - Commands / Queries - -{% endblock %} - -{% block panel %} -

      Commands

      - -
      - - - - - - - - - - {% if collector.executedCommands is not empty %} - {% for command in collector.executedCommands %} - - - - - - {% endfor %} - {% else %} - - - - {% endif %} - -
      CommandCommand HandlerCalled from
      {{ command.command }}{{ command.command_handler }}{{ command.trace.file }}:{{ command.trace.line }}
      No Commands where executed during request.
      - -

      Queries

      - - - - - - - - - - - {% if collector.executedQueries is not empty %} - {% for query in collector.executedQueries %} - - - - - - {% endfor %} - {% else %} - - - - {% endif %} - -
      QueryQuery HandlerCalled from
      {{ query.query }}{{ query.query_handler }}{{ query.trace.file }}:{{ query.trace.line }}
      No Queries where executed during request.
      -
      -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/WebProfiler/config.html.twig b/src/PrestaShopBundle/Resources/views/Admin/WebProfiler/config.html.twig deleted file mode 100644 index f8d5e1f2..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/WebProfiler/config.html.twig +++ /dev/null @@ -1,274 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@WebProfiler/Profiler/layout.html.twig' %} - -{% block toolbar %} - {% if 'unknown' == collector.symfonyState %} - {% set block_status = '' %} - {% set symfony_version_status = 'Unable to retrieve information about the Symfony version.' %} - {% elseif 'eol' == collector.symfonyState %} - {% set block_status = 'red' %} - {% set symfony_version_status = 'This Symfony version will no longer receive security fixes.' %} - {% elseif 'eom' == collector.symfonyState %} - {% set block_status = 'yellow' %} - {% set symfony_version_status = 'This Symfony version will only receive security fixes.' %} - {% elseif 'dev' == collector.symfonyState %} - {% set block_status = 'yellow' %} - {% set symfony_version_status = 'This Symfony version is still in the development phase.' %} - {% else %} - {% set block_status = '' %} - {% set symfony_version_status = '' %} - {% endif %} - - {% set icon %} - - {{ collector.applicationversion }} - {% endset %} - - {% set text %} -
      -
      - {{ collector.applicationname }} - {{ collector.applicationversion }} -
      - -
      - Profiler token - - {% if profiler_url %} - {{ collector.token }} - {% else %} - {{ collector.token }} - {% endif %} - -
      - - -
      -
      -
      - PHP version - - {{ collector.phpversion }} -   View phpinfo() - -
      - -
      - PHP Extensions - xdebug - APCu - OPcache -
      - -
      - PHP SAPI - {{ collector.sapiName }} -
      -
      - -
      -
      - Resources - - {% set appVersion = collector.applicationversion|split('.')|join()[:2] %} - - Read PrestaShop {{ collector.applicationversion }} Docs - - -
      -
      - {% endset %} - - {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: true, name: 'config', status: block_status, additional_classes: 'sf-toolbar-block-right', block_attrs: 'title="' ~ symfony_version_status ~ '"' }) }} -{% endblock %} - -{% block menu %} - - {{ include('@WebProfiler/Icon/config.svg') }} - Configuration - -{% endblock %} - -{% block panel %} - {% if collector.applicationname %} - {# this application is not the Symfony framework #} -

      Project Configuration

      - -
      -
      - {{ collector.applicationname }} - Application name -
      - -
      - {{ collector.applicationversion }} - Application version -
      -
      - -

      - Based on Symfony {{ collector.symfonyversion }} -

      - {% else %} -

      Symfony Configuration

      - -
      -
      - {{ collector.symfonyversion }} - Symfony version -
      - - {% if 'n/a' != collector.appname %} -
      - {{ collector.appname }} - Application name -
      - {% endif %} - - {% if 'n/a' != collector.env %} -
      - {{ collector.env }} - Environment -
      - {% endif %} - - {% if 'n/a' != collector.debug %} -
      - {{ collector.debug ? 'enabled' : 'disabled' }} - Debug -
      - {% endif %} -
      - - {% set symfony_status = { dev: 'Unstable Version', stable: 'Stable Version', eom: 'Maintenance Ended', eol: 'Version Expired' } %} - {% set symfony_status_class = { dev: 'warning', stable: 'success', eom: 'warning', eol: 'error' } %} - - - - - - - - - - - - - - - - - -
      Symfony StatusBugs {{ collector.symfonystate in ['eom', 'eol'] ? 'were' : 'are' }} fixed untilSecurity issues {{ collector.symfonystate == 'eol' ? 'were' : 'are' }} fixed until
      - {{ symfony_status[collector.symfonystate]|upper }} - {{ collector.symfonyeom }}{{ collector.symfonyeol }} - View roadmap -
      - {% endif %} - -

      PHP Configuration

      - -
      -
      - {{ collector.phpversion }}{% if collector.phpversionextra %} {{ collector.phpversionextra }}{% endif %} - PHP version -
      - -
      - {{ collector.phparchitecture }} bits - Architecture -
      - -
      - {{ collector.phpintllocale }} - Intl locale -
      - -
      - {{ collector.phptimezone }} - Timezone -
      -
      - -
      -
      - Resources - - {% set appVersion = collector.applicationversion|split('.')|join()[:2] %} - - Read PrestaShop {{ collector.applicationversion }} Docs - - -
      -
      -
      -
      - {{ include('@WebProfiler/Icon/' ~ (collector.haszendopcache ? 'yes' : 'no') ~ '.svg') }} - OPcache -
      - -
      - {{ include('@WebProfiler/Icon/' ~ (collector.hasapcu ? 'yes' : 'no') ~ '.svg') }} - APCu -
      - -
      - {{ include('@WebProfiler/Icon/' ~ (collector.hasxdebug ? 'yes' : 'no') ~ '.svg') }} - Xdebug -
      -
      - -

      - View full PHP configuration -

      - - {% if collector.bundles %} -

      Enabled Bundles ({{ collector.bundles|length }})

      - - - - - - - - - {% for name in collector.bundles|keys|sort %} - - - - - {% endfor %} - -
      NamePath
      {{ name }}{{ profiler_dump(collector.bundles[name]) }}
      - {% endif %} -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/WebProfiler/hooks_collector.html.twig b/src/PrestaShopBundle/Resources/views/Admin/WebProfiler/hooks_collector.html.twig deleted file mode 100644 index d9e13a16..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/WebProfiler/hooks_collector.html.twig +++ /dev/null @@ -1,165 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends '@WebProfiler/Profiler/layout.html.twig' %} - -{% import _self as helper %} - -{% block toolbar %} - {% set icon %} - {{ include('@WebProfiler/Icon/event.svg') }} - Hooks ({{ collector.calledHooks|length }}) - {% endset %} - - {% set text %} -
      -
      - {{ collector.calledHooks|length }} Hooks called -
      -
      - - - - - - - - - {% for hookName, hooks in collector.calledHooks %} - - {% else %} - - {% endfor %} - -
      Hook nameCall(s)
      {{ hookName }}{{ hooks|length }}
      No hook dispatched.
      -
      -
      - {% endset %} - - {{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: true }) }} - -{% endblock %} - -{% block menu %} - {# This left-hand menu appears when using the full-screen profiler. #} - - {{ include('@WebProfiler/Icon/event.svg') }} - Hooks - -{% endblock %} - -{% block panel %} -

      Hooks

      - - {% if collector.notCalledHooks is empty %} -
      -

      No Hooks have been recorded. Check that debugging is enabled in the kernel.

      -
      - {% else %} -
      -
      -

      Called Hooks {{ collector.calledHooks|length }}

      - -
      - {{ helper.render_table(collector.calledHooks, true) }} -
      -
      - -
      -

      Not Called Hooks {{ collector.notCalledHooks|length }}

      -
      - {% if collector.notCalledHooks is empty %} -
      -

      - There are no uncalled hooks. -

      -

      - All hooks were called for this request or an error occurred - when trying to collect uncalled listeners (in which case check the - logs to get more information). -

      -
      - {% else %} - {{ helper.render_table(collector.notCalledHooks, false) }} - {% endif %} -
      -
      -
      - {% endif %} -{% endblock %} - -{% macro render_table(hookList, hookModules) %} - {% for hookName, hooks in hookList %} -

      {{ hookName }}

      - - - - - - - {% if hookModules %} - - {% endif %} - - - - {% for position, hook in hooks %} - - - - {% if hookModules %} - - {% endif %} - - {% endfor %} - -
      ArgumentsLocationHooked modules
      - {{ profiler_dump(hook.args) }} - - {{ hook.location }} - - {% set modules = hook.modules %} - {% for moduleName, module in modules %} -

      {{ moduleName|capitalize }}

      - - - - - - - - {% if module.callback is defined %} - - - - {% else %} - - - - {% endif %} -
      Module arguments
      {{ profiler_dump(module.callback.args) }}
      {{ profiler_dump(module.widget.args) }}
      - {% endfor %} -
      - {% endfor %} -{% endmacro %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/layout.html.twig b/src/PrestaShopBundle/Resources/views/Admin/layout.html.twig deleted file mode 100644 index 8a895867..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/layout.html.twig +++ /dev/null @@ -1,104 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% extends(template_from_string( - getLegacyLayout( - app.request.attributes.get('_legacy_controller'), - layoutTitle is defined ? layoutTitle : '', - layoutHeaderToolbarBtn is defined ? layoutHeaderToolbarBtn : [], - layoutDisplayType is defined ? layoutDisplayType : '', - showContentHeader is defined ? showContentHeader : true, - headerTabContent is defined ? headerTabContent : '', - enableSidebar is defined ? enableSidebar : false, - help_link is defined ? help_link : '', - js_router_metadata(), - meta_title is defined ? meta_title : '', - use_regular_h1_structure is defined ? use_regular_h1_structure : true - ) - )) %} - -{% import '@PrestaShop/Admin/macros.html.twig' as ps %} - -{% block javascripts %} - - - -{% endblock %} - -{% block translate_javascripts %} - -{% endblock %} - -{% block content_header %} - {% macro alert(type, flashbagContent) %} - - {% endmacro %} - {% import _self as layout %} - - {% if app.session.flashbag.peek('error')|length() > 0 %} - {{ layout.alert('danger', app.session.flashbag.get('error')) }} - {% endif %} - {% if app.session.flashbag.peek('failure')|length() > 0 %} - {{ layout.alert('danger', app.session.flashbag.get('failure')) }} - {% endif %} - {% if app.session.flashbag.peek('success')|length() > 0 %} - {{ layout.alert('success', app.session.flashbag.get('success')) }} - {% endif %} - {% if app.session.flashbag.peek('warning')|length() > 0 %} - {{ layout.alert('warning', app.session.flashbag.get('warning')) }} - {% endif %} -{% endblock %} - -{% block sidebar_right %} - -{% endblock %} diff --git a/src/PrestaShopBundle/Resources/views/Admin/macros.html.twig b/src/PrestaShopBundle/Resources/views/Admin/macros.html.twig deleted file mode 100644 index 5bdc8abe..00000000 --- a/src/PrestaShopBundle/Resources/views/Admin/macros.html.twig +++ /dev/null @@ -1,310 +0,0 @@ -{#** - * Copyright since 2007 PrestaShop SA and Contributors - * PrestaShop is an International Registered Trademark & Property of PrestaShop SA - * - * NOTICE OF LICENSE - * - * This source file is subject to the Open Software License (OSL 3.0) - * that is bundled with this package in the file LICENSE.md. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://devdocs.prestashop.com/ for more information. - * - * @author PrestaShop SA and Contributors - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - *#} -{% macro form_label_tooltip(name, tooltip, placement) %} - {{ form_label(name, null, {'label_attr': {'tooltip': tooltip, 'tooltip_placement': placement|default('top')}}) }} -{% endmacro %} - -{% macro check(variable) %} - {{ variable is defined and variable|length > 0 ? variable : false }} -{% endmacro %} - -{% macro tooltip(text, icon, position) %} - - {{ icon }} - -{% endmacro %} - -{% macro infotip(text, use_raw = false)%} - -{% endmacro %} - -{% macro warningtip(text)%} - -{% endmacro %} - -{% macro label_with_help(label, help, class = '', for = '', isRequired = false) %} - - {% if isRequired %} - * - {% endif %} - - {{ label }} - - - -

      {{ help }}

      -{% endmacro %} - -{# Table column headers with sorting indicators #} -{% macro sortable_column_header(title, sortColumnName, orderBy, sortOrder, prefix) %} - {% set sortOrder, orderBy, prefix = sortOrder|default(''), orderBy|default, prefix|default('') %} -
      - {{ title }} - -
      - -{% endmacro %} - -{# Show link to import file sample #} -{% macro import_file_sample(label, filename) %} - - {{ label|trans({}, 'Admin.Advparameters.Feature') }} - -{% endmacro %} - -{# - Show form widget with errors rendered below it. It displays all nested errors for any form type. - If form type has error_by_locale parameter set then the error is being displayed with the specific locale assigned to it. - If form type has errors_by_locale parameter set then the errors are being assigned to the locales and are displayed - in the popover template. - If there are more then one error it also assigns all errors in the pop-up to appear. - On page load, user sees only the errors count but then user hovers over the element the popover - appears with the errors combined by language. -#} -{% macro form_widget_with_error(form, vars, extraVars) %} - {% import '@PrestaShop/Admin/macros.html.twig' as self %} - - {% set vars = vars|default({}) %} - {% set extraVars = extraVars|default({}) %} - {% set attr = vars.attr|default({}) %} - {% set attr = attr|merge({'class': (attr.class is defined ? attr.class : '')} ) %} - {% set vars = vars|merge({'attr': attr}) %} - - {{ form_widget(form, vars) }} - - {% if extraVars.help is defined and extraVars.help%} - {{ extraVars.help }} - {% elseif form.vars.help is defined and form.vars.help %} - {{ form.vars.help }} - {% endif %} - - {{ self.form_error_with_popover(form) }} - -{% endmacro %} - -{# - It displays all nested errors for any form type. - If form type has error_by_locale parameter set then the error is being displayed with the specific locale assigned to it. - If form type has errors_by_locale parameter set then the errors are being assigned to the locales and are displayed - in the popover template. - If there are more then one error it also assigns all errors in the pop-up to appear. - On page load, user sees only the errors count but then user hovers over the element the popover - appears with the errors combined by language. -#} -{% macro form_error_with_popover(form) %} - {% set errors = [] %} - - {% if form.vars.valid is defined and not form.vars.valid %} - {% for parentError in form.vars.errors %} - {% set errors = errors|merge([parentError.message]) %} - {% endfor %} - - {#iterating over child errors because errors can be nested#} - {% for child in form.children %} - {% for error in child.vars.errors %} - {% set errors = errors|merge([error.message]) %} - {% endfor %} - {% endfor %} - {% endif %} - - {% if errors|length > 0 %} - {# for form types which has locales and there are more then 1 error , additional errors are displaying inside popover #} - {% set errorPopover = null %} - - {% if errors|length > 1 %} - {% set popoverContainer = 'popover-error-container-'~form.vars.id %} -
      - - - {% if form.vars.errors_by_locale is defined %} - {% set popoverErrors = form.vars.errors_by_locale %} - - {# collecting translatable errors - the ones which has locale name attached #} - {% set translatableErrors = [] %} - {% for translatableError in popoverErrors %} - {% set translatableErrors = translatableErrors|merge([translatableError.error_message]) %} - {% endfor %} - - {# if an error found which does not exist in translatable errors array - it adds it to the popover error container #} - {% for error in errors %} - {% if error not in translatableErrors %} - {% set popoverErrors = popoverErrors|merge([error]) %} - {% endif %} - {% endfor %} - - {% else %} - {% set popoverErrors = errors %} - {% endif %} - - {% set errorMessages = [] %} - {% for popoverError in popoverErrors %} - {% set errorMessage = popoverError %} - - {% if popoverError.error_message is defined and popoverError.locale_name is defined %} - {% set errorMessage = '%error_message% - Language: %language_name%'|trans({'%error_message%': popoverError.error_message, '%language_name%': popoverError.locale_name}, 'Admin.Notifications.Error') %} - {% endif %} - - {% set errorMessages = errorMessages|merge([errorMessage]) %} - {% endfor %} - - {% set popoverErrorContent %} -
      -
        - {% for popoverError in errorMessages %} -
      • - {{ popoverError }} -
      • - {% endfor %} -
      -
      - {% endset %} - - - - {% set errorPopover %} - - error_outline {{ '%count% errors'|transchoice(popoverErrors|length, {}, 'Admin.Global') }} - - {% endset %} - - {% elseif form.vars.error_by_locale is defined %} - {% set errorByLocale = '%error_message% - Language: %language_name%'|trans({'%error_message%': form.vars.error_by_locale.error_message, '%language_name%': form.vars.error_by_locale.locale_name}, 'Admin.Notifications.Error') %} - {% set errors = [errorByLocale] %} - {% endif %} - -
      - {% if errorPopover is not null %} -
      - {{ errorPopover }} -
      - {% else %} -
      - error_outline -
      -
      - {% for error in errors %} -
      - {{ error }} -
      - {% endfor %} -
      - {% endif %} -
      - {% endif %} -{% endmacro %} - - {# - Helper function to render most common structure for single input - @param form - form view to render - @param vars - custom vars that are passed to form_widget - @param extraVars - parameters that are not related to form_widget, but are needed for input (label, help text & etc.) - #} -{% macro form_group_row(form, vars, extraVars) %} - {% import '@PrestaShop/Admin/macros.html.twig' as self %} - - {% set class = extraVars.class|default('') %} - {% set inputType = form.vars.block_prefixes.1|default('text') %} - {% set rowAttributes = extraVars.row_attr|default({}) %} -
      - {% set extraVars = extraVars|default({}) %} - - {# renders label above the form field if set to true #} - {% set labelOnTop = false %} - - {% if extraVars.label_on_top is defined %} - {% set labelOnTop = extraVars.label_on_top %} - {% endif %} - - {% if extraVars.label is defined %} - {% set isRequired = form.vars.required|default(false) %} - - {% if extraVars.required is defined %} - {% set isRequired = extraVars.required %} - {% endif %} - - - {% endif %} - -
      - {{ self.form_widget_with_error(form, vars, extraVars) }} -
      -
      -{% endmacro %} - -{% macro multistore_switch(form, extraVars) %} - {% import '@PrestaShop/Admin/macros.html.twig' as self %} - {% if form.shop_restriction_switch is defined %} - {% set defaultLabel %} - {{ 'Check / Uncheck all'|trans({}, 'Admin.Actions') }}
      - {{ 'You are editing this page for a specific shop or group. Click "%yes_label%" to check all fields, "%no_label%" to uncheck all.'|trans({'%yes_label%': 'Yes'|trans({}, 'Admin.Global'), '%no_label%': 'No'|trans({}, 'Admin.Global')}, 'Admin.Design.Help') }}
      - {{ 'If you check a field, change its value, and save, the multistore behavior will not apply to this shop (or group), for this particular parameter.'|trans({}, 'Admin.Design.Help') }} - {% endset %} - - {% if extraVars.help is not defined %} - {% set extraVars = extraVars|merge({'help': defaultLabel}) %} - {% endif %} - - {% set vars = { 'attr': { 'class': 'js-multi-store-restriction-switch'}} %} - - {{ self.form_group_row(form.shop_restriction_switch, vars, extraVars) }} - {% endif %} -{% endmacro %} diff --git a/src/PrestaShopBundle/Routing/Converter/AbstractLegacyRouteProvider.php b/src/PrestaShopBundle/Routing/Converter/AbstractLegacyRouteProvider.php deleted file mode 100644 index ac347261..00000000 --- a/src/PrestaShopBundle/Routing/Converter/AbstractLegacyRouteProvider.php +++ /dev/null @@ -1,150 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Converter; - -use PrestaShopBundle\Routing\Converter\Exception\RouteNotFoundException; - -/** - * Class AbstractLegacyRouteProvider. - */ -abstract class AbstractLegacyRouteProvider implements LegacyRouteProviderInterface -{ - /** - * @var array|null - */ - protected $controllersActions; - - /** - * This is the only method that child classes need to implement. - * - * @return LegacyRoute[] - */ - abstract public function getLegacyRoutes(); - - /** - * @return array - */ - public function getControllersActions() - { - $this->initControllerActions(); - - return $this->controllersActions; - } - - /** - * {@inheritdoc} - */ - public function getActionsByController($controller) - { - $this->initControllerActions(); - - $controllerActions = $this->getControllerActions($controller); - if (null === $controllerActions) { - throw new RouteNotFoundException(sprintf('Could not find a route matching for legacy controller: %s', $controller)); - } - - return array_keys($controllerActions); - } - - /** - * {@inheritdoc} - */ - public function getLegacyRouteByAction($controller, $action) - { - $this->initControllerActions(); - - $controllerActions = $this->getControllerActions($controller); - if (null === $controllerActions) { - throw new RouteNotFoundException(sprintf('Could not find a route matching for legacy controller: %s', $controller)); - } - - $action = LegacyRoute::isIndexAction($action) ? 'index' : $action; - $routeName = $this->getRouteName($controllerActions, $action); - if (null === $routeName) { - throw new RouteNotFoundException(sprintf('Could not find a route matching for legacy action: %s', $controller . ':' . $action)); - } - - return $this->getLegacyRoutes()[$routeName]; - } - - /** - * Get the route name. - * - * @param array $controllerActions - * @param string $action - * - * @return string|null - */ - private function getRouteName(array $controllerActions, $action) - { - $routeName = null; - foreach ($controllerActions as $controllerAction => $actionRoute) { - if (strtolower($controllerAction) == strtolower($action)) { - $routeName = $actionRoute; - break; - } - } - - if (is_array($routeName)) { - return $routeName[0]; - } - - return $routeName; - } - - /** - * Init the controller actions has map. - */ - private function initControllerActions() - { - if (null === $this->controllersActions) { - $this->controllersActions = []; - /** @var LegacyRoute $legacyRoute */ - foreach ($this->getLegacyRoutes() as $legacyRoute) { - $this->controllersActions = array_merge_recursive($this->controllersActions, $legacyRoute->getControllersActions()); - } - } - } - - /** - * @param string $controller - * - * @return array|null - */ - private function getControllerActions($controller) - { - $controllerActions = null; - foreach ($this->controllersActions as $listController => $actions) { - if (strtolower($listController) == strtolower($controller)) { - $controllerActions = $actions; - break; - } - } - - return $controllerActions; - } -} diff --git a/src/PrestaShopBundle/Routing/Converter/CacheKeyGeneratorInterface.php b/src/PrestaShopBundle/Routing/Converter/CacheKeyGeneratorInterface.php deleted file mode 100644 index 1b7adc66..00000000 --- a/src/PrestaShopBundle/Routing/Converter/CacheKeyGeneratorInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Converter; - -/** - * Interface CacheKeyGeneratorInterface is used by CacheProvider to generate - * the key used for its cache, it allows to update the cache easily by varying the key. - */ -interface CacheKeyGeneratorInterface -{ - /** - * Returns a string used as key for caching the legacy routes information. - * You can vary this cache key in order to update the cache when needed. - * (e.g: RoutingCacheKeyGenerator generates its key based on the last modification - * date of routing files so that each modifications regenerate the cache). - * - * @return string - */ - public function getCacheKey(); -} diff --git a/src/PrestaShopBundle/Routing/Converter/CacheProvider.php b/src/PrestaShopBundle/Routing/Converter/CacheProvider.php deleted file mode 100644 index d42edb10..00000000 --- a/src/PrestaShopBundle/Routing/Converter/CacheProvider.php +++ /dev/null @@ -1,133 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Converter; - -use Symfony\Component\Cache\Adapter\AdapterInterface; - -/** - * Class CacheProvider. - */ -class CacheProvider extends AbstractLegacyRouteProvider -{ - /** - * @var AdapterInterface - */ - private $cache; - - /** - * @var LegacyRouteProviderInterface - */ - private $legacyRouteProvider; - - /** - * @var CacheKeyGeneratorInterface - */ - private $cacheKeyGenerator; - - /** - * @var LegacyRoute[] - */ - private $legacyRoutes; - - public function __construct( - LegacyRouteProviderInterface $legacyRouteProvider, - AdapterInterface $cache, - CacheKeyGeneratorInterface $cacheKeyGenerator - ) { - $this->legacyRouteProvider = $legacyRouteProvider; - $this->cache = $cache; - $this->cacheKeyGenerator = $cacheKeyGenerator; - } - - /** - * {@inheritdoc} - */ - public function getLegacyRoutes() - { - if (null === $this->legacyRoutes) { - $cacheItem = $this->cache->getItem($this->cacheKeyGenerator->getCacheKey()); - if (!$cacheItem->isHit()) { - $this->legacyRoutes = $this->legacyRouteProvider->getLegacyRoutes(); - $cacheItem->set($this->serializeLegacyRoutes($this->legacyRoutes)); - $this->cache->save($cacheItem); - } else { - $this->legacyRoutes = $this->unserializeLegacyRoutes($cacheItem->get()); - } - } - - return $this->legacyRoutes; - } - - /** - * @param LegacyRoute[] $legacyRoutes - * - * @return string - */ - private function serializeLegacyRoutes(array $legacyRoutes) - { - $flattenRoutes = []; - /** @var LegacyRoute $legacyRoute */ - foreach ($legacyRoutes as $legacyRoute) { - $legacyLinks = []; - foreach ($legacyRoute->getLegacyLinks() as $legacyLink) { - if (empty($legacyLink['action'])) { - $legacyLinks[] = $legacyLink['controller']; - } else { - $legacyLinks[] = $legacyLink['controller'] . ':' . $legacyLink['action']; - } - } - $flattenRoutes[] = [ - 'route_name' => $legacyRoute->getRouteName(), - 'legacy_links' => $legacyLinks, - 'legacy_parameters' => $legacyRoute->getRouteParameters(), - ]; - } - - return json_encode($flattenRoutes); - } - - /** - * @param string $serializedLegacyRoutes - * - * @return LegacyRoute[] - */ - private function unserializeLegacyRoutes($serializedLegacyRoutes) - { - $flattenRoutes = json_decode($serializedLegacyRoutes, true); - - $legacyRoutes = []; - foreach ($flattenRoutes as $flattenRoute) { - $legacyRoutes[$flattenRoute['route_name']] = new LegacyRoute( - $flattenRoute['route_name'], - $flattenRoute['legacy_links'], - $flattenRoute['legacy_parameters'] - ); - } - - return $legacyRoutes; - } -} diff --git a/src/PrestaShopBundle/Routing/Converter/Exception/AlreadyConvertedException.php b/src/PrestaShopBundle/Routing/Converter/Exception/AlreadyConvertedException.php deleted file mode 100644 index 44084b0b..00000000 --- a/src/PrestaShopBundle/Routing/Converter/Exception/AlreadyConvertedException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Converter\Exception; - -/** - * Class AlreadyConvertedException is thrown when trying to converting - * an already converted url. Thus you can detect no redirection is needed - * and avoid an infinite loop. - */ -class AlreadyConvertedException extends RoutingException -{ -} diff --git a/src/PrestaShopBundle/Routing/Converter/Exception/ArgumentException.php b/src/PrestaShopBundle/Routing/Converter/Exception/ArgumentException.php deleted file mode 100644 index a9c923af..00000000 --- a/src/PrestaShopBundle/Routing/Converter/Exception/ArgumentException.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Converter\Exception; - -/** - * Class ArgumentException. - */ -class ArgumentException extends RoutingException -{ -} diff --git a/src/PrestaShopBundle/Routing/Converter/Exception/RouteNotFoundException.php b/src/PrestaShopBundle/Routing/Converter/Exception/RouteNotFoundException.php deleted file mode 100644 index 9b89c5be..00000000 --- a/src/PrestaShopBundle/Routing/Converter/Exception/RouteNotFoundException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Converter\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Class RouteNotFoundException. - */ -class RouteNotFoundException extends CoreException -{ -} diff --git a/src/PrestaShopBundle/Routing/Converter/Exception/RoutingException.php b/src/PrestaShopBundle/Routing/Converter/Exception/RoutingException.php deleted file mode 100644 index bf5ffa14..00000000 --- a/src/PrestaShopBundle/Routing/Converter/Exception/RoutingException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Converter\Exception; - -use PrestaShop\PrestaShop\Core\Exception\CoreException; - -/** - * Class RoutingException. - */ -class RoutingException extends CoreException -{ -} diff --git a/src/PrestaShopBundle/Routing/Converter/LegacyParametersConverter.php b/src/PrestaShopBundle/Routing/Converter/LegacyParametersConverter.php deleted file mode 100644 index 4daadc39..00000000 --- a/src/PrestaShopBundle/Routing/Converter/LegacyParametersConverter.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShopBundle\Routing\Converter; - -/** - * This class converts the request information (attributes and query parameters) - * and returns an array of parameters adapted with their legacy names (based on - * the configuration from the routing). - */ -class LegacyParametersConverter -{ - /** - * Use the request attributes which contain the routing configuration along with query - * parameters to return an array containing the equivalent with legacy parameters names. - * - * Example with $request being a Symfony Request: - * - * $legacyParameters = $converter->getParameters($request->attributes->all(), $request->query->all()); - * - * @param array $requestAttributes - * @param array $queryParameters - * - * @return array|null - */ - public function getParameters(array $requestAttributes, array $queryParameters): ?array - { - if (!isset($requestAttributes['_legacy_parameters']) && !isset($requestAttributes['_legacy_link'])) { - return null; - } - - $legacyParameters = []; - - // Convert new parameters into legacy ones (search in attributes and query parameters) - $parametersMatching = $requestAttributes['_legacy_parameters'] ?? []; - foreach ($parametersMatching as $legacyParameter => $routingParameter) { - if (isset($requestAttributes[$routingParameter])) { - $legacyParameters[$legacyParameter] = $requestAttributes[$routingParameter]; - } elseif (isset($queryParameters[$routingParameter])) { - $legacyParameters[$legacyParameter] = $queryParameters[$routingParameter]; - } - } - - // Set controller and action based on _legacy_link - if (isset($requestAttributes['_legacy_link'])) { - $legacyLinks = $requestAttributes['_legacy_link']; - if (!is_array($legacyLinks)) { - $legacyLinks = [$legacyLinks]; - } - - // Loop through the _legacy_link until a controller and action is found - foreach ($legacyLinks as $legacyLink) { - $linkParts = explode(':', $legacyLink); - if (!isset($legacyParameters['controller'])) { - $legacyParameters['controller'] = $linkParts[0]; - } - if (!isset($legacyParameters['action']) && count($linkParts) > 1) { - $legacyParameters['action'] = $linkParts[1]; - } - if (isset($legacyParameters['controller'], $legacyParameters['action'])) { - break; - } - } - } - - return $legacyParameters; - } -} diff --git a/src/PrestaShopBundle/Routing/Converter/LegacyRoute.php b/src/PrestaShopBundle/Routing/Converter/LegacyRoute.php deleted file mode 100644 index c98d4a8d..00000000 --- a/src/PrestaShopBundle/Routing/Converter/LegacyRoute.php +++ /dev/null @@ -1,178 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Converter; - -/** - * Class LegacyRoute contains the info about a route, its legacyLinks, legacyParameters - * and controller actions hash map. This class can be built simply based on the routeDefaults - * parameters and its name. - */ -class LegacyRoute -{ - /** - * @var string - */ - private $routeName; - - /** - * @var array - */ - private $legacyLinks; - - /** - * @var array - */ - private $routeParameters; - - /** - * @var array - */ - private $controllersActions; - - /** - * @param string|null $action - * - * @return bool - */ - public static function isIndexAction($action) - { - $indexAliases = ['list', 'index']; - - return empty($action) || in_array(strtolower($action), $indexAliases); - } - - /** - * @param $routeName - * @param array $routeDefaults - * - * @return LegacyRoute - */ - public static function buildLegacyRoute($routeName, array $routeDefaults) - { - $legacyLinks = $routeDefaults['_legacy_link']; - if (!is_array($legacyLinks)) { - $legacyLinks = [$legacyLinks]; - } - - $legacyParameters = []; - if (!empty($routeDefaults['_legacy_parameters']) && is_array($routeDefaults['_legacy_parameters'])) { - $legacyParameters = $routeDefaults['_legacy_parameters']; - } - - return new static($routeName, $legacyLinks, $legacyParameters); - } - - /** - * LegacyRoute constructor. - * - * @param string $routeName - * @param array $legacyLinks - * @param array $routeParameters - */ - public function __construct($routeName, array $legacyLinks, array $routeParameters) - { - $this->routeName = $routeName; - $this->routeParameters = $routeParameters; - $this->legacyLinks = $this->buildLegacyLinks($legacyLinks); - $this->controllersActions = $this->buildControllerActions($this->legacyLinks, $routeName); - } - - /** - * @return string - */ - public function getRouteName() - { - return $this->routeName; - } - - /** - * @return array - */ - public function getLegacyLinks() - { - return $this->legacyLinks; - } - - /** - * @return array - */ - public function getRouteParameters() - { - return $this->routeParameters; - } - - /** - * @return array - */ - public function getControllersActions() - { - return $this->controllersActions; - } - - /** - * @param array $legacyLinks - * - * @return array - */ - private function buildLegacyLinks(array $legacyLinks) - { - $brokenLegacyLinks = []; - foreach ($legacyLinks as $legacyLink) { - $linkParts = explode(':', $legacyLink); - $legacyController = $linkParts[0]; - $legacyAction = isset($linkParts[1]) ? $linkParts[1] : null; - $brokenLegacyLinks[] = [ - 'controller' => $legacyController, - 'action' => $legacyAction, - ]; - } - - return $brokenLegacyLinks; - } - - /** - * @param array $legacyLinks - * @param string $routeName - * - * @return array - */ - private function buildControllerActions(array $legacyLinks, $routeName) - { - $controllersActions = []; - foreach ($legacyLinks as $legacyLink) { - $controller = $legacyLink['controller']; - if (!isset($controllersActions[$controller])) { - $controllersActions[$controller] = []; - } - - $action = self::isIndexAction($legacyLink['action']) ? 'index' : $legacyLink['action']; - $controllersActions[$controller][$action] = $routeName; - } - - return $controllersActions; - } -} diff --git a/src/PrestaShopBundle/Routing/Converter/LegacyRouteProviderInterface.php b/src/PrestaShopBundle/Routing/Converter/LegacyRouteProviderInterface.php deleted file mode 100644 index 9d48ca59..00000000 --- a/src/PrestaShopBundle/Routing/Converter/LegacyRouteProviderInterface.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Converter; - -use PrestaShopBundle\Routing\Converter\Exception\RouteNotFoundException; - -/** - * Interface LegacyRouteProviderInterface is used by LegacyUrlConverter to fetch - * the information about legacy routes, stored in LegacyRoute objects. - */ -interface LegacyRouteProviderInterface -{ - /** - * Returns the list of LegacyRoute based on what was set in the routing files. - * - * @return LegacyRoute[] - */ - public function getLegacyRoutes(); - - /** - * Returns the list of controllers, their action and the associated route. - * e.g: $controllerActions = [ - * 'AdminPreferences' => [ - * 'index' => 'admin_preferences', - * 'update' => 'admin_preferences_save', - * ], - * 'AdminMeta' => [ - * 'index' => 'admin_metas_index', - * 'search' => 'admin_metas_search', - * ], - * ];. - * - * @return array - */ - public function getControllersActions(); - - /** - * Return the list of actions for a defined controller. - * - * @param string $controller - * - * @return string[] - */ - public function getActionsByController($controller); - - /** - * Return the LegacyRoute object matching $controller and $action. - * - * @param string $controller - * @param string $action - * - * @return LegacyRoute - * - * @throws RouteNotFoundException - */ - public function getLegacyRouteByAction($controller, $action); -} diff --git a/src/PrestaShopBundle/Routing/Converter/LegacyUrlConverter.php b/src/PrestaShopBundle/Routing/Converter/LegacyUrlConverter.php deleted file mode 100644 index 33ece2be..00000000 --- a/src/PrestaShopBundle/Routing/Converter/LegacyUrlConverter.php +++ /dev/null @@ -1,249 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Converter; - -use PrestaShopBundle\Routing\Converter\Exception\AlreadyConvertedException; -use PrestaShopBundle\Routing\Converter\Exception\ArgumentException; -use PrestaShopBundle\Routing\Converter\Exception\RouteNotFoundException; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Exception\Exceptioninterface; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Routing\RouterInterface; - -/** - * Class LegacyUrlConverter is able to convert query parameters or an url into a - * migrated Symfony url. It uses information set in the routes via _legacy_link - * to do so. - */ -final class LegacyUrlConverter -{ - /** - * @var LegacyRouteProviderInterface - */ - private $legacyRouteProvider; - - /** - * @var RouterInterface - */ - private $router; - - /** - * LegacyUrlConverter constructor. - * - * @param RouterInterface $router - * @param LegacyRouteProviderInterface $legacyRouteProvider - */ - public function __construct(RouterInterface $router, LegacyRouteProviderInterface $legacyRouteProvider) - { - $this->router = $router; - $this->legacyRouteProvider = $legacyRouteProvider; - } - - /** - * @param array $parameters - * - * @return string - * - * @throws ArgumentException - * @throws RouteNotFoundException - */ - public function convertByParameters(array $parameters) - { - //Tab parameter can be used as an alias for controller - if (!empty($parameters['tab'])) { - if (empty($parameters['controller'])) { - $parameters['controller'] = $parameters['tab']; - } - unset($parameters['tab']); - } - - if (empty($parameters['controller'])) { - throw new ArgumentException('Missing required controller argument'); - } - - /** @var LegacyRoute $legacyRoute */ - $legacyRoute = $this->findLegacyRouteNameByParameters($parameters); - $parameters = $this->convertLegacyParameters($parameters, $legacyRoute); - - return $this->router->generate($legacyRoute->getRouteName(), $parameters, UrlGeneratorInterface::ABSOLUTE_URL); - } - - /** - * @param string $url - * - * @return string - * - * @throws ArgumentException - * @throws RouteNotFoundException - * @throws AlreadyConvertedException - */ - public function convertByUrl($url) - { - $this->checkAlreadyMatchingRoute($url); - - $parsedUrl = parse_url($url); - $parameters = []; - if (isset($parsedUrl['query'])) { - parse_str($parsedUrl['query'], $parameters); - } - - return $this->convertByParameters($parameters); - } - - /** - * This conversion method is used by the listener, indeed it needs to update the - * router context because it is executed before the RouterListener. Thus the router - * does not have the appropriate information to generate an admin url and would redirect - * to the front office. - * - * @param Request $request - * - * @return string - * - * @throws ArgumentException - * @throws RouteNotFoundException - * @throws AlreadyConvertedException - */ - public function convertByRequest(Request $request) - { - $this->router->getContext()->fromRequest($request); - $this->checkAlreadyMatchingRoute($request->getRequestUri()); - - $parameters = array_merge($request->query->all(), $request->request->all()); - - return $this->convertByParameters($parameters); - } - - /** - * @param array $parameters - * @param LegacyRoute $legacyRoute - * - * @return array - */ - private function convertLegacyParameters(array $parameters, LegacyRoute $legacyRoute) - { - $legacyAction = $this->getActionFromParameters($parameters); - - foreach ($legacyRoute->getRouteParameters() as $legacyParameter => $parameter) { - if (isset($parameters[$legacyParameter])) { - $parameters[$parameter] = $parameters[$legacyParameter]; - unset($parameters[$legacyParameter]); - } - } - - unset( - $parameters['controller'], - $parameters['action'], - $parameters[$legacyAction] - ); - - return $parameters; - } - - /** - * @param array $parameters - * - * @return LegacyRoute - * - * @throws RouteNotFoundException - */ - private function findLegacyRouteNameByParameters(array $parameters) - { - $legacyController = $parameters['controller']; - $legacyAction = $this->getActionFromParameters($parameters); - - return $this->legacyRouteProvider->getLegacyRouteByAction($legacyController, $legacyAction); - } - - /** - * @param array $parameters - * - * @return string|null - */ - private function getActionFromParameters(array $parameters) - { - $legacyAction = null; - - if (!empty($parameters['action'])) { - $legacyAction = $parameters['action']; - } - - //Actions can be defined as simple query parameter (e.g: ?controller=AdminProducts&save) - if (null === $legacyAction) { - //We prioritize the actions defined in the migrated routes - $controllerActions = $this->legacyRouteProvider->getActionsByController($parameters['controller']); - foreach ($parameters as $parameter => $value) { - if (in_array($parameter, $controllerActions)) { - $legacyAction = $parameter; - - break; - } - } - } - - //Last chance if a non migrated action is present (note: a bit risky since any empty parameter can be - //interpreted as an action.. but some old link need this feature, ?controller=AdminModulesPositions&addToHook) - if (null === $legacyAction) { - foreach ($parameters as $parameter => $value) { - if ($value === '' || 1 === (int) $value) { - //Avoid confusing an entity/row id with an action - // e.g. - // create=1 is an action - // id_product=1 is NOT an action - if (false === strpos($parameter, 'id_') - && false === strpos($parameter, '_id')) { - $legacyAction = $parameter; - - break; - } - } - } - } - - return LegacyRoute::isIndexAction($legacyAction) ? 'index' : $legacyAction; - } - - /** - * We check that the router doesn't match the url, if no exception is thrown - * then the url is already converted and we throw our own AlreadyConvertedException - * - * @param string $url - * - * @throws AlreadyConvertedException - */ - private function checkAlreadyMatchingRoute($url) - { - try { - $urlPath = parse_url($url, PHP_URL_PATH); - if (!empty($urlPath)) { - $this->router->match($urlPath); - throw new AlreadyConvertedException(sprintf('%s is already a converted url', $url)); - } - } catch (ExceptionInterface $e) { - } - } -} diff --git a/src/PrestaShopBundle/Routing/Converter/RouterProvider.php b/src/PrestaShopBundle/Routing/Converter/RouterProvider.php deleted file mode 100644 index 711dd6d1..00000000 --- a/src/PrestaShopBundle/Routing/Converter/RouterProvider.php +++ /dev/null @@ -1,87 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Converter; - -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouterInterface; - -/** - * Class RouterProvider. - */ -class RouterProvider extends AbstractLegacyRouteProvider -{ - /** - * @var LegacyRoute[] - */ - private $legacyRoutes; - - /** - * @var RouterInterface - */ - private $router; - - /** - * RouterProvider constructor. - * - * @param RouterInterface $router - */ - public function __construct(RouterInterface $router) - { - $this->router = $router; - } - - /** - * {@inheritdoc} - */ - public function getLegacyRoutes() - { - if (null == $this->legacyRoutes) { - $this->legacyRoutes = $this->buildLegacyRoutes(); - } - - return $this->legacyRoutes; - } - - /** - * @return array - */ - private function buildLegacyRoutes() - { - $legacyRoutes = []; - /** @var Route $route */ - foreach ($this->router->getRouteCollection() as $routeName => $route) { - $routeDefaults = $route->getDefaults(); - if (empty($routeDefaults['_legacy_link'])) { - continue; - } - - $legacyRoutes[$routeName] = LegacyRoute::buildLegacyRoute($routeName, $routeDefaults); - } - - return $legacyRoutes; - } -} diff --git a/src/PrestaShopBundle/Routing/Converter/RoutingCacheKeyGenerator.php b/src/PrestaShopBundle/Routing/Converter/RoutingCacheKeyGenerator.php deleted file mode 100644 index c97d48b1..00000000 --- a/src/PrestaShopBundle/Routing/Converter/RoutingCacheKeyGenerator.php +++ /dev/null @@ -1,134 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Converter; - -use Symfony\Component\Finder\Finder; -use Symfony\Component\Finder\SplFileInfo; - -/** - * Class RoutingCacheKeyGenerator generates the cache key for the CacheProvider. - * In prod environment the key never changes so you need to use cache:clear if you - * need to update the cache. - * In dev environment this class inspects the routing files to get their last modification - * date which is then used to generate the key, hence each time a routing file is modified - * the cache key changes so the cache is regenerated. - */ -class RoutingCacheKeyGenerator implements CacheKeyGeneratorInterface -{ - /** - * @var array - */ - private $coreRoutingPaths; - - /** - * @var array - */ - private $activeModulesPaths; - - /** - * @var string - */ - private $environment; - - /** - * RoutingCacheKeyGenerator constructor. - * - * @param array $coreRoutingPaths - * @param array $activeModulesPaths - * @param string $environment - */ - public function __construct( - array $coreRoutingPaths, - array $activeModulesPaths, - $environment = 'dev' - ) { - $this->coreRoutingPaths = $coreRoutingPaths; - $this->activeModulesPaths = $activeModulesPaths; - $this->environment = $environment; - } - - /** - * @return array - */ - public function getLastModifications() - { - $routingFiles = []; - - if (count($this->coreRoutingPaths)) { - $finder = new Finder(); - $finder->files()->in($this->coreRoutingPaths); - $finder->name('/\.(yml|yaml)$/'); - /** @var SplFileInfo $yamlFile */ - foreach ($finder as $yamlFile) { - $routingFiles[$yamlFile->getPathname()] = $yamlFile->getMTime(); - } - } - - foreach ($this->activeModulesPaths as $modulePath) { - $extensions = ['yml', 'yaml']; - foreach ($extensions as $extension) { - $routingFile = $modulePath . '/config/routes.' . $extension; - if (file_exists($routingFile)) { - $routingFiles[$routingFile] = filemtime($routingFile); - } - } - } - - arsort($routingFiles); - - return $routingFiles; - } - - /** - * @return int|null - */ - public function getLatestModificationTime() - { - $lastModifications = $this->getLastModifications(); - if (!count($lastModifications)) { - return null; - } - - return reset($lastModifications); - } - - /** - * {@inheritdoc} - */ - public function getCacheKey() - { - $cacheKey = preg_replace('@\\\\@', '_', __NAMESPACE__); - if ('prod' !== $this->environment) { - $latestModification = $this->getLatestModificationTime(); - if (null !== $latestModification) { - $cacheKey .= '_' . $latestModification; - } - } - - return $cacheKey; - } -} diff --git a/src/PrestaShopBundle/Routing/Linter/AdminRouteProvider.php b/src/PrestaShopBundle/Routing/Linter/AdminRouteProvider.php deleted file mode 100644 index 98bd2f29..00000000 --- a/src/PrestaShopBundle/Routing/Linter/AdminRouteProvider.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Linter; - -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouterInterface; - -/** - * Get all configured routes for Back Office - */ -final class AdminRouteProvider -{ - /** - * @var RouterInterface - */ - private $router; - - /** - * @param RouterInterface $router - */ - public function __construct(RouterInterface $router) - { - $this->router = $router; - } - - /** - * @return Route[] As routeName => route - */ - public function getRoutes() - { - $adminRoutes = []; - - foreach ($this->router->getRouteCollection() as $routeName => $route) { - if (strpos($routeName, 'admin_') !== 0) { - continue; - } - - $adminRoutes[$routeName] = $route; - } - - return $adminRoutes; - } -} diff --git a/src/PrestaShopBundle/Routing/Linter/Exception/LinterException.php b/src/PrestaShopBundle/Routing/Linter/Exception/LinterException.php deleted file mode 100644 index 9ea0d0c8..00000000 --- a/src/PrestaShopBundle/Routing/Linter/Exception/LinterException.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Linter\Exception; - -use RuntimeException; - -/** - * Is thrown when error occurs during linting. - */ -class LinterException extends RuntimeException -{ -} diff --git a/src/PrestaShopBundle/Routing/Linter/Exception/NamingConventionException.php b/src/PrestaShopBundle/Routing/Linter/Exception/NamingConventionException.php deleted file mode 100644 index 4b7b9eff..00000000 --- a/src/PrestaShopBundle/Routing/Linter/Exception/NamingConventionException.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Linter\Exception; - -/** - * Thrown when naming convention is not followed - */ -class NamingConventionException extends LinterException -{ - /** - * @var string - */ - protected $expectedRouteName; - - public function __construct($message = '', $code = 0, \RuntimeException $previous = null, $expectedRouteName = null) - { - $this->expectedRouteName = $expectedRouteName; - parent::__construct($message, $code, $previous); - } - - /** - * @return string - */ - public function getExpectedRouteName(): string - { - return $this->expectedRouteName; - } -} diff --git a/src/PrestaShopBundle/Routing/Linter/LegacyLinkLinter.php b/src/PrestaShopBundle/Routing/Linter/LegacyLinkLinter.php deleted file mode 100644 index 49b79f88..00000000 --- a/src/PrestaShopBundle/Routing/Linter/LegacyLinkLinter.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Linter; - -use Symfony\Component\Routing\Route; - -/** - * Responsible for checking route _legacy_link configuration - */ -final class LegacyLinkLinter implements RouteLinterInterface -{ - /** - * Checks if _legacy_link is configured to route. - * Returns true if configured, false if not. - * - * {@inheritdoc} - */ - public function lint($routeName, Route $route) - { - if ($route->hasDefault($routeName)) { - return true; - } - - return false; - } -} diff --git a/src/PrestaShopBundle/Routing/Linter/NamingConventionLinter.php b/src/PrestaShopBundle/Routing/Linter/NamingConventionLinter.php deleted file mode 100644 index 144ce1a4..00000000 --- a/src/PrestaShopBundle/Routing/Linter/NamingConventionLinter.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Linter; - -use Doctrine\Common\Inflector\Inflector; -use PrestaShopBundle\Routing\Linter\Exception\NamingConventionException; -use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser; -use Symfony\Component\Routing\Route; - -/** - * Checks that route and contoller follows naming conventions - */ -final class NamingConventionLinter implements RouteLinterInterface -{ - /** - * @var ControllerNameParser - */ - private $controllerNameParser; - - /** - * @param ControllerNameParser $controllerNameParser - */ - public function __construct(ControllerNameParser $controllerNameParser) - { - $this->controllerNameParser = $controllerNameParser; - } - - /** - * {@inheritdoc} - */ - public function lint($routeName, Route $route) - { - $controllerAndMethodName = $this->getControllerAndMethodName($route); - - $pluralizedController = Inflector::tableize( - Inflector::pluralize($controllerAndMethodName['controller']) - ); - - $expectedRouteName = strtr('admin_{resources}_{action}', [ - '{resources}' => $pluralizedController, - '{action}' => Inflector::tableize($controllerAndMethodName['method']), - ]); - - if ($routeName !== $expectedRouteName) { - throw new NamingConventionException( - sprintf('Route "%s" does not follow naming convention.', $routeName), - 0, - null, - $expectedRouteName - ); - } - } - - /** - * @param Route $route - * - * @return array - */ - private function getControllerAndMethodName(Route $route) - { - $controller = $route->getDefault('_controller'); - - if (strpos($controller, '::') === false) { - $controller = $this->controllerNameParser->parse($controller); - } - - list($controller, $method) = explode('::', $controller, 2); - - $controllerParts = explode('\\', $controller); - $controller = preg_replace('/Controller$/', '', end($controllerParts)); - - $method = preg_replace('/Action$/', '', $method); - - return [ - 'controller' => $controller, - 'method' => $method, - ]; - } -} diff --git a/src/PrestaShopBundle/Routing/Linter/RouteLinterInterface.php b/src/PrestaShopBundle/Routing/Linter/RouteLinterInterface.php deleted file mode 100644 index e99e6254..00000000 --- a/src/PrestaShopBundle/Routing/Linter/RouteLinterInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Linter; - -use PrestaShopBundle\Routing\Linter\Exception\LinterException; -use Symfony\Component\Routing\Route; - -/** - * Interface for service that performs linting on route - */ -interface RouteLinterInterface -{ - /** - * @param Route $route - * - * @throws LinterException when linting error occurs - */ - public function lint($routeName, Route $route); -} diff --git a/src/PrestaShopBundle/Routing/Linter/SecurityAnnotationLinter.php b/src/PrestaShopBundle/Routing/Linter/SecurityAnnotationLinter.php deleted file mode 100644 index a8c59277..00000000 --- a/src/PrestaShopBundle/Routing/Linter/SecurityAnnotationLinter.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing\Linter; - -use Doctrine\Common\Annotations\Reader; -use PrestaShopBundle\Routing\Linter\Exception\LinterException; -use PrestaShopBundle\Security\Annotation\AdminSecurity; -use ReflectionMethod; -use Symfony\Bundle\FrameworkBundle\Controller\ControllerNameParser; -use Symfony\Component\Routing\Route; - -/** - * Checks if SecurityAnnotation is configured for route's controller action - */ -final class SecurityAnnotationLinter implements RouteLinterInterface -{ - /** - * @var Reader - */ - private $annotationReader; - - /** - * @var ControllerNameParser - */ - private $controllerNameParser; - - /** - * @param Reader $annotationReader - * @param ControllerNameParser $controllerNameParser - */ - public function __construct(Reader $annotationReader, ControllerNameParser $controllerNameParser) - { - $this->annotationReader = $annotationReader; - $this->controllerNameParser = $controllerNameParser; - } - - /** - * {@inheritdoc} - */ - public function lint($routeName, Route $route) - { - $controllerAndMethod = $this->extractControllerAndMethodNamesFromRoute($route); - - $reflection = new ReflectionMethod( - $controllerAndMethod['controller'], - $controllerAndMethod['method'] - ); - - $annotation = $this->annotationReader->getMethodAnnotation($reflection, AdminSecurity::class); - - if (null === $annotation) { - throw new LinterException(sprintf('"%s:%s" does not have AdminSecurity annotation configured', $controllerAndMethod['controller'], $controllerAndMethod['method'])); - } - } - - /** - * @param Route $route - * - * @return array - */ - private function extractControllerAndMethodNamesFromRoute(Route $route) - { - $controller = $route->getDefault('_controller'); - - if (strpos($controller, '::') === false) { - // we need to support controllers defined as services & defined using short notation - $controller = $this->controllerNameParser->parse($controller); - } - - list($controller, $method) = explode('::', $controller, 2); - - return [ - 'controller' => $controller, - 'method' => $method, - ]; - } -} diff --git a/src/PrestaShopBundle/Routing/YamlModuleLoader.php b/src/PrestaShopBundle/Routing/YamlModuleLoader.php deleted file mode 100644 index c3fa1e64..00000000 --- a/src/PrestaShopBundle/Routing/YamlModuleLoader.php +++ /dev/null @@ -1,113 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Routing; - -use RuntimeException; -use Symfony\Component\Config\Loader\Loader; -use Symfony\Component\Routing\Route; -use Symfony\Component\Routing\RouteCollection; - -/** - * This class is responsible of loading routes of enabled modules. - */ -class YamlModuleLoader extends Loader -{ - /** - * @var array the list of activated modules - */ - private $activeModulesPaths; - - /** - * @var bool we load the route collection only once per request - */ - private $isLoaded = false; - - public function __construct(array $activeModulesPaths) - { - $this->activeModulesPaths = $activeModulesPaths; - } - - /** - * {@inheritdoc} - */ - public function load($resource, $type = null) - { - if (true === $this->isLoaded) { - throw new RuntimeException('Do not add the "module" loader twice.'); - } - - $routes = new RouteCollection(); - - foreach ($this->activeModulesPaths as $modulePath) { - $routingFile = $modulePath . '/config/routes.yml'; - if (file_exists($routingFile)) { - $loadedRoutes = $this->import($routingFile, 'yaml'); - $routes->addCollection($loadedRoutes); - } - } - - $this->isLoaded = true; - - return $routes; - } - - /** - * {@inheritdoc} - */ - public function supports($resource, $type = null) - { - return 'module' === $type; - } - - /** - * {@inheritdoc} - */ - public function import($resource, $type = null) - { - $loadedRoutes = parent::import($resource, $type); - - return $this->modifyRoutes($loadedRoutes); - } - - /** - * @param RouteCollection $routes - * - * @return RouteCollection - */ - private function modifyRoutes(RouteCollection $routes) - { - foreach ($routes->getIterator() as $route) { - if ($route->hasDefault('_disable_module_prefix') && $route->getDefault('_disable_module_prefix') === true) { - continue; - } - - $route->setPath('/modules' . $route->getPath()); - } - - return $routes; - } -} diff --git a/src/PrestaShopBundle/Security/Admin/Employee.php b/src/PrestaShopBundle/Security/Admin/Employee.php deleted file mode 100644 index fd8af08e..00000000 --- a/src/PrestaShopBundle/Security/Admin/Employee.php +++ /dev/null @@ -1,190 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Security\Admin; - -use Symfony\Component\Security\Core\User\EquatableInterface; -use Symfony\Component\Security\Core\User\UserInterface; - -/** - * Class Employee is used for Symfony security components to authenticate the user. - */ -class Employee implements UserInterface, EquatableInterface -{ - /** - * @var int - */ - private $id; - - /** - * @var string - */ - private $username; - - /** - * @var string - */ - private $password; - - /** - * @var string - */ - private $salt; - - /** - * @var array - */ - private $roles = []; - - private $data; - - /** - * Constructor. - * - * @param object $data The employee legacy object - */ - public function __construct($data) - { - $this->username = $data->email; - $this->password = $data->passwd; - $this->salt = ''; - $this->data = $data; - $this->id = (int) $data->id; - } - - public function __toString() - { - return $this->username; - } - - /** - * Returns roles for the current employee. - * - * @return array - */ - public function getRoles() - { - return $this->roles; - } - - /** - * Get typed password. - * - * @return string - */ - public function getPassword() - { - return $this->password; - } - - /** - * The salt used to hash the password. - * - * @return string - */ - public function getSalt() - { - return $this->salt; - } - - /** - * Get the login of the current employee. - * - * @return string - */ - public function getUsername() - { - return $this->username; - } - - /** - * Get the id of the current employee. - * - * @return int - */ - public function getId() - { - return $this->id; - } - - /** - * Get the data parameter of the current employee. - * - * @return object - */ - public function getData() - { - return $this->data; - } - - /** - * Used by Symfony to ensure credentials are removed when logout. - */ - public function eraseCredentials() - { - } - - /** - * @param array $roles - * - * @return Employee - */ - public function setRoles(array $roles) - { - $this->roles = $roles; - - return $this; - } - - /** - * Test equality between two Employee entities - * (instance of class, password, salt and username). - * - * @param UserInterface $user - * - * @return bool - */ - public function isEqualTo(UserInterface $user) - { - if (!$user instanceof static) { - return false; - } - - if ($this->password !== $user->getPassword()) { - return false; - } - - if ($this->salt !== $user->getSalt()) { - return false; - } - - if ($this->username !== $user->getUsername()) { - return false; - } - - return true; - } -} diff --git a/src/PrestaShopBundle/Security/Admin/EmployeeProvider.php b/src/PrestaShopBundle/Security/Admin/EmployeeProvider.php deleted file mode 100644 index 1a30744f..00000000 --- a/src/PrestaShopBundle/Security/Admin/EmployeeProvider.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Security\Admin; - -use Access; -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use Psr\Cache\CacheItemPoolInterface; -use Symfony\Component\Security\Core\Exception\UnsupportedUserException; -use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; -use Symfony\Component\Security\Core\User\UserInterface; -use Symfony\Component\Security\Core\User\UserProviderInterface; - -/** - * Class EmployeeProvider To retrieve Employee entities for the Symfony security components. - */ -class EmployeeProvider implements UserProviderInterface -{ - const ROLE_EMPLOYEE = 'ROLE_EMPLOYEE'; - - private $legacyContext; - - /** - * @var CacheItemPoolInterface - */ - private $cache; - - public function __construct(LegacyContext $context, CacheItemPoolInterface $cache) - { - $this->legacyContext = $context->getContext(); - $this->cache = $cache; - } - - /** - * Fetch the Employee entity that matches the given username. - * Cache system doesn't supports "@" character, so we rely on a sha1 expression. - * - * @param string $username - * - * @return Employee - * - * @throws \Psr\Cache\InvalidArgumentException - * @throws \Symfony\Component\Security\Core\Exception\UsernameNotFoundException - */ - public function loadUserByUsername($username) - { - $cacheKey = sha1($username); - $cachedEmployee = $this->cache->getItem("app.employees_${cacheKey}"); - - if ($cachedEmployee->isHit()) { - return $cachedEmployee->get(); - } - - if ( - null !== $this->legacyContext->employee - && $this->legacyContext->employee->email === $username - ) { - $employee = new Employee($this->legacyContext->employee); - $employee->setRoles( - array_merge([self::ROLE_EMPLOYEE], Access::getRoles($this->legacyContext->employee->id_profile)) - ); - - $cachedEmployee->set($employee); - $this->cache->save($cachedEmployee); - - return $cachedEmployee->get(); - } - - throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username)); - } - - /** - * Reload an Employee and returns a fresh instance. - * - * @param UserInterface $employee - * - * @return Employee - */ - public function refreshUser(UserInterface $employee) - { - if (!$employee instanceof Employee) { - throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_class($employee))); - } - - return $this->loadUserByUsername($employee->getUsername()); - } - - /** - * Tests if the given class supports the security layer. Here, only Employee class is allowed to be used to authenticate. - * - * @param string $class - * - * @return bool - */ - public function supportsClass($class) - { - return $class === 'PrestaShopBundle\Security\Admin\Employee'; - } -} diff --git a/src/PrestaShopBundle/Security/Annotation/AdminSecurity.php b/src/PrestaShopBundle/Security/Annotation/AdminSecurity.php deleted file mode 100644 index 4e584a19..00000000 --- a/src/PrestaShopBundle/Security/Annotation/AdminSecurity.php +++ /dev/null @@ -1,135 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Security\Annotation; - -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; - -/** - * Improves the existing Security annotation, adding: - * `domain`: to translate the sent message using a PrestaShop domain; - * `redirectRoute`: to select the route for redirection; - * `url`: only available in 1.7.x, to redirect to legacy pages;. - * - * @Annotation - */ -class AdminSecurity extends Security -{ - /** - * The translation domain for the message. - * - * @var string - */ - protected $domain = 'Admin.Notifications.Error'; - - /** - * The route for the redirection. - * - * @todo: Once the onboarding page is migrated, set default to his route name. - * - * @var string - */ - protected $redirectRoute; - - /** - * @deprecated once the back office is migrated, rely only on route. - * The url for the redirection - * - * @return string - */ - protected $url = 'admin_domain'; - - /** - * The route params which are used together to generate the redirect route. - * - * @var array - */ - protected $redirectQueryParamsToKeep = []; - - /** - * @return string - */ - public function getDomain() - { - return $this->domain; - } - - /** - * @param string $domain the translation domain name - */ - public function setDomain($domain) - { - $this->domain = $domain; - } - - /** - * @return string - */ - public function getRedirectRoute() - { - return $this->redirectRoute; - } - - /** - * @param string $redirectRoute the route used for redirection - */ - public function setRedirectRoute($redirectRoute) - { - $this->redirectRoute = $redirectRoute; - } - - /** - * @return mixed - */ - public function getUrl() - { - return $this->url; - } - - /** - * @param string $url the url used for redirection - */ - public function setUrl($url) - { - $this->url = $url; - } - - /** - * @return array - */ - public function getRedirectQueryParamsToKeep() - { - return $this->redirectQueryParamsToKeep; - } - - /** - * @param array $redirectQueryParamsToKeep - */ - public function setRedirectQueryParamsToKeep($redirectQueryParamsToKeep) - { - $this->redirectQueryParamsToKeep = $redirectQueryParamsToKeep; - } -} diff --git a/src/PrestaShopBundle/Security/Annotation/DemoRestricted.php b/src/PrestaShopBundle/Security/Annotation/DemoRestricted.php deleted file mode 100644 index 70303a9c..00000000 --- a/src/PrestaShopBundle/Security/Annotation/DemoRestricted.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Security\Annotation; - -use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation; - -/** - * Forbid access to the page if Demonstration mode is enabled. - * - * @Annotation - */ -class DemoRestricted extends ConfigurationAnnotation -{ - /** - * The translation domain for the message. - * - * @var string - */ - protected $domain = 'Admin.Notifications.Error'; - - /** - * The message of the exception. - * - * @var string - */ - protected $message = 'This functionality has been disabled.'; - - /** - * The route for the redirection. - * - * @var string - */ - protected $redirectRoute; - - /** - * The route params which are used together to generate the redirect route. - * - * @var array - */ - protected $redirectQueryParamsToKeep = []; - - /** - * @return string - */ - public function getDomain() - { - return $this->domain; - } - - /** - * @param string $domain the translation domain name - */ - public function setDomain($domain) - { - $this->domain = $domain; - } - - /** - * @return string - */ - public function getMessage() - { - return $this->message; - } - - /** - * @param string $message the message displayed after redirection - */ - public function setMessage($message) - { - $this->message = $message; - } - - /** - * @return string - */ - public function getRedirectRoute() - { - return $this->redirectRoute; - } - - /** - * @param string $redirectRoute the route used for redirection - */ - public function setRedirectRoute($redirectRoute) - { - $this->redirectRoute = $redirectRoute; - } - - /** - * Returns the alias name for an annotated configuration. - * - * @return string - */ - public function getAliasName() - { - return 'demo_restricted'; - } - - /** - * Returns whether multiple annotations of this type are allowed. - * - * @return bool - */ - public function allowArray() - { - return true; - } - - /** - * @return array - */ - public function getRedirectQueryParamsToKeep() - { - return $this->redirectQueryParamsToKeep; - } - - /** - * @param array $redirectQueryParamsToKeep - */ - public function setRedirectQueryParamsToKeep($redirectQueryParamsToKeep) - { - $this->redirectQueryParamsToKeep = $redirectQueryParamsToKeep; - } -} diff --git a/src/PrestaShopBundle/Security/Annotation/ModuleActivated.php b/src/PrestaShopBundle/Security/Annotation/ModuleActivated.php deleted file mode 100644 index 55f99457..00000000 --- a/src/PrestaShopBundle/Security/Annotation/ModuleActivated.php +++ /dev/null @@ -1,151 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Security\Annotation; - -use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation; - -/** - * Forbid access to the page if the defined module mode is inactive. - * - * @Annotation - */ -class ModuleActivated extends ConfigurationAnnotation -{ - /** - * The translation domain for the message. - * - * @var string - */ - protected $domain = 'Admin.Notifications.Error'; - - /** - * The message of the exception. - * - * @var string - */ - protected $message = 'The module %s is inactive.'; - - /** - * The route for the redirection. - * - * @var string - */ - protected $redirectRoute; - - /** - * The module name to check. - * - * @var string - */ - protected $moduleName; - - /** - * @return string - */ - public function getDomain() - { - return $this->domain; - } - - /** - * @param string $domain the translation domain name - */ - public function setDomain($domain) - { - $this->domain = $domain; - } - - /** - * @return string - */ - public function getMessage() - { - return $this->message; - } - - /** - * @param string $message the message displayed after redirection - */ - public function setMessage($message) - { - $this->message = $message; - } - - /** - * @return string - */ - public function getRedirectRoute() - { - return $this->redirectRoute; - } - - /** - * @param string $redirectRoute the route used for redirection - */ - public function setRedirectRoute($redirectRoute) - { - $this->redirectRoute = $redirectRoute; - } - - /** - * Returns the alias name for an annotated configuration. - * - * @return string - */ - public function getAliasName() - { - return 'module_activated'; - } - - /** - * Returns the name of the module to check. - * - * @return string - */ - public function getModuleName() - { - return $this->moduleName; - } - - /** - * @param string $moduleName - */ - public function setModuleName($moduleName) - { - $this->moduleName = $moduleName; - } - - /** - * Returns whether multiple annotations of this type are allowed. - * - * @return bool - */ - public function allowArray() - { - return true; - } -} diff --git a/src/PrestaShopBundle/Security/Role/DynamicRoleHierarchy.php b/src/PrestaShopBundle/Security/Role/DynamicRoleHierarchy.php deleted file mode 100644 index a06b57e8..00000000 --- a/src/PrestaShopBundle/Security/Role/DynamicRoleHierarchy.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Security\Role; - -use Symfony\Component\Security\Core\Role\RoleHierarchyInterface; - -/** - * Class DynamicRoleHierarchy is used for Symfony role hierarchy voter to load roles from database. - */ -class DynamicRoleHierarchy implements RoleHierarchyInterface -{ - public function getReachableRoles(array $roles) - { - } -} diff --git a/src/PrestaShopBundle/Security/Voter/PageVoter.php b/src/PrestaShopBundle/Security/Voter/PageVoter.php deleted file mode 100644 index e0281cb2..00000000 --- a/src/PrestaShopBundle/Security/Voter/PageVoter.php +++ /dev/null @@ -1,117 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Security\Voter; - -use Access; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Core\Authorization\Voter\Voter; - -/** - * Decides on access rights to a Page. - */ -class PageVoter extends Voter -{ - const CREATE = 'create'; - - const UPDATE = 'update'; - - const DELETE = 'delete'; - - const READ = 'read'; - - const LEVEL_DELETE = 4; - - const LEVEL_UPDATE = 2; - - const LEVEL_CREATE = 3; - - const LEVEL_READ = 1; - - /** - * Indicates if this voter should pronounce on this attribute and subject. - * - * @param string $attribute Rights to test - * @param mixed $subject Subject to secure (a controller name) - * - * @return bool - */ - protected function supports($attribute, $subject) - { - return in_array($attribute, [self::CREATE, self::UPDATE, self::DELETE, self::READ]); - } - - /** - * @param string $attribute Access right to test - * @param string $subject Controller name - * @param TokenInterface $token - * - * @return bool - */ - protected function voteOnAttribute($attribute, $subject, TokenInterface $token) - { - $user = $token->getUser(); - $employeeProfileId = $user->getData()->id_profile; - $action = $this->buildAction($subject, $attribute); - - return $this->can($action, $employeeProfileId); - } - - /** - * Checks if the provided user profile is allowed to perform the requested action. - * - * @param string $action - * @param int $employeeProfileId - * - * @return bool - * - * @throws \Exception - */ - protected function can($action, $employeeProfileId) - { - return Access::isGranted('ROLE_MOD_TAB_' . strtoupper($action), $employeeProfileId); - } - - /** - * Builds the action name by joining subject and attribute. - * - * @param string $subject Subject the attribute is performed onto (usually a controller name) - * @param string $attribute - * - * @return string - */ - private function buildAction($subject, $attribute) - { - $action = $subject; - - // add underscore to join if needed - if (substr($action, -1) !== '_') { - $action .= '_'; - } - - return $action . $attribute; - } -} diff --git a/src/PrestaShopBundle/Service/Cache/Refresh.php b/src/PrestaShopBundle/Service/Cache/Refresh.php deleted file mode 100644 index c9c74574..00000000 --- a/src/PrestaShopBundle/Service/Cache/Refresh.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\Cache; - -use PrestaShopBundle\Service\Command\AbstractCommand; - -class Refresh extends AbstractCommand -{ - /** - * Add doctrine:schema:update to the execution. - */ - public function addDoctrineSchemaUpdate() - { - $this->addCacheClear(); - - $this->commands[] = [ - 'command' => 'doctrine:schema:update', - '--force' => true, - ]; - } -} diff --git a/src/PrestaShopBundle/Service/Command/AbstractCommand.php b/src/PrestaShopBundle/Service/Command/AbstractCommand.php deleted file mode 100644 index b61242cb..00000000 --- a/src/PrestaShopBundle/Service/Command/AbstractCommand.php +++ /dev/null @@ -1,117 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\Command; - -use AppKernel; -use Exception; -use Symfony\Bundle\FrameworkBundle\Console\Application; -use Symfony\Component\Console\Input\ArrayInput; -use Symfony\Component\Console\Output\BufferedOutput; - -abstract class AbstractCommand -{ - protected $kernel; - protected $application; - protected $commands = []; - - /** - * Constructor. - * - * Construct the symfony environment. - * - * @param AppKernel $kernel Symfony Kernel - */ - public function __construct(AppKernel $kernel = null) - { - set_time_limit(0); - - if (null === $kernel) { - global $kernel; - - if (null === $kernel) { - require_once _PS_ROOT_DIR_ . '/app/AppKernel.php'; - $kernel = new AppKernel(_PS_ENV_, _PS_MODE_DEV_); - } - } - - $this->kernel = $kernel; - $this->application = new Application($this->kernel); - $this->application->setAutoExit(false); - } - - /** - * Execute all defined commands. - * - * @throws Exception if no command defined - */ - public function execute() - { - $bufferedOutput = new BufferedOutput(); - $commandOutput = []; - - if (empty($this->commands)) { - throw new Exception('Error, you need to define at least one command'); - } - - foreach ($this->commands as $command) { - $exitCode = $this->application->run(new ArrayInput($command), $bufferedOutput); - - $commandOutput[$command['command']] = [ - 'exitCode' => $exitCode, - 'output' => $bufferedOutput->fetch(), - ]; - } - - return $commandOutput; - } - - /** - * Add cache:clear to the execution. - */ - public function addCacheClear() - { - $this->commands[] = [ - 'command' => 'doctrine:cache:clear-metadata', - '--flush' => true, - ]; - - $this->commands[] = [ - 'command' => 'doctrine:cache:clear-query', - '--flush' => true, - ]; - - $this->commands[] = [ - 'command' => 'doctrine:cache:clear-result', - '--flush' => true, - ]; - - $this->commands[] = [ - 'command' => 'cache:clear', - '--no-warmup' => true, - ]; - } -} diff --git a/src/PrestaShopBundle/Service/DataProvider/Admin/AddonsInterface.php b/src/PrestaShopBundle/Service/DataProvider/Admin/AddonsInterface.php deleted file mode 100644 index 8e72870e..00000000 --- a/src/PrestaShopBundle/Service/DataProvider/Admin/AddonsInterface.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\DataProvider\Admin; - -/** - * Data provider for new Architecture, about Module object model. - * - * This class will provide data from DB / ORM about Modules for the Admin interface. - */ -interface AddonsInterface -{ - /** - * Send a request to addons.prestashop.com to retrieve Modules/Addons data. - * - * @param string $action the query type - * @param array $params the request parameters - */ - public function request($action, $params); -} diff --git a/src/PrestaShopBundle/Service/DataProvider/Admin/CategoriesProvider.php b/src/PrestaShopBundle/Service/DataProvider/Admin/CategoriesProvider.php deleted file mode 100644 index 0a5a5a4c..00000000 --- a/src/PrestaShopBundle/Service/DataProvider/Admin/CategoriesProvider.php +++ /dev/null @@ -1,247 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\DataProvider\Admin; - -use PrestaShop\PrestaShop\Adapter\Module\Module as ApiModule; -use stdClass; - -/** - * Provide the categories used to order modules and themes on https://addons.prestashop.com. - */ -class CategoriesProvider -{ - const CATEGORY_OTHER = 'other'; - const CATEGORY_OTHER_NAME = 'Other'; - - const CATEGORY_THEME = 'theme_modules'; - const CATEGORY_THEME_NAME = 'Theme modules'; - - /** - * @var array - */ - private $modulesTheme; - - /** - * @var array - */ - private $categories; - - /** - * @var array - */ - private $categoriesFromSource; - - public function __construct(array $addonsCategories, array $modulesTheme) - { - $this->modulesTheme = $modulesTheme; - // We now avoid calling the API. This data is loaded from a local YML file - $this->categoriesFromSource = $this->sortCategories($addonsCategories); - } - - /** - * Return the list of categories with the associated modules. - * - * @param array|AddonsCollection the list of modules - * - * @return array the list of categories - */ - public function getCategoriesMenu($modules): array - { - if (null === $this->categories) { - // The Root category is "Categories" - $categories = $this->initializeCategories($this->categoriesFromSource); - foreach ($modules as $module) { - $category = $this->findModuleCategory($module, $categories); - - $categories['categories']->subMenu[$category]->modules[] = $module; - } - - // Clear custom categories if there is no module inside - if (empty($categories['categories']->subMenu[self::CATEGORY_THEME]->modules)) { - unset($categories['categories']->subMenu[self::CATEGORY_THEME]); - } - - $this->categories = $categories; - } - - return $this->categories; - } - - /** - * Initialize categories from API or if this one is empty, - * use theme and my modules categories. - * - * @param array|stdClass $categoriesListing Category listing - * - * @return array - */ - private function initializeCategories($categoriesListing) - { - $categories = [ - 'categories' => $this->createMenuObject('categories', 'Categories'), - ]; - - foreach ($categoriesListing as $category) { - $categories['categories']->subMenu[$category->name] = $this->createMenuObject( - $category->id_category, - $category->name, - [], - isset($category->tab) ? $category->tab : null - ); - } - - $categories['categories']->subMenu[self::CATEGORY_THEME] = $this->createMenuObject( - self::CATEGORY_THEME, - self::CATEGORY_THEME_NAME, - [], - self::CATEGORY_THEME - ); - $categories['categories']->subMenu[self::CATEGORY_OTHER] = $this->createMenuObject( - self::CATEGORY_OTHER, - self::CATEGORY_OTHER_NAME, - [], - self::CATEGORY_OTHER - ); - - return $categories; - } - - /** - * Considering a category name, return his category parent name. - * - * @param string the category - * - * @return string the category - */ - public function getParentCategory(string $categoryName): string - { - foreach ($this->categoriesFromSource as $parentCategory) { - foreach ($parentCategory->categories as $childCategory) { - if ($childCategory->name === $categoryName) { - return $parentCategory->name; - } - } - } - - return $categoryName; - } - - /** - * Re-organize category data into a Menu item. - * - * @param string $menu - * @param string $name - * @param array $moduleIds - * @param string $tab - * - * @return stdClass - */ - private function createMenuObject(string $menu, string $name, array $moduleIds = [], ?string $tab = null): stdClass - { - return (object) [ - 'tab' => $tab, - 'name' => $name, - 'refMenu' => $menu, - 'modules' => $moduleIds, - 'subMenu' => [], - ]; - } - - /** - * Find module category. - * - * @param ApiModule $installedProduct Installed product - * @param array $categories Available categories - */ - private function findModuleCategory(ApiModule $installedProduct, array $categories): string - { - $moduleCategoryParent = $installedProduct->attributes->get('categoryParentEnglishName'); - if (!isset($categories['categories']->subMenu[$moduleCategoryParent])) { - if (in_array($installedProduct->attributes->get('name'), $this->modulesTheme)) { - $moduleCategoryParent = self::CATEGORY_THEME; - } else { - $moduleCategoryParent = $this->getParentCategoryFromTabAttribute($installedProduct); - } - } - - if (array_key_exists($moduleCategoryParent, $categories['categories']->subMenu)) { - return $moduleCategoryParent; - } - - return self::CATEGORY_OTHER; - } - - /** - * Sort addons categories by order field. - * - * @param array $categories - * - * @return stdClass - */ - private function sortCategories(array $categories): stdClass - { - uasort( - $categories, - function ($a, $b) { - $a = !isset($a['order']) ? 0 : $a['order']; - $b = !isset($b['order']) ? 0 : $b['order']; - - if ($a === $b) { - return 0; - } - - return ($a < $b) ? -1 : 1; - } - ); - - // Convert array to object to be consistent with current API call - $categories = json_decode(json_encode($categories)); - - return $categories; - } - - /** - * Try to find the parent category depending on - * the module's tab attribute. - * - * @param ApiModule $module - * - * @return ?string - */ - private function getParentCategoryFromTabAttribute(ApiModule $module): ?string - { - foreach ($this->categoriesFromSource as $parentCategory) { - foreach ($parentCategory->categories as $category) { - if (isset($category->tab) && $category->tab === $module->attributes->get('tab')) { - return $parentCategory->name; - } - } - } - - return null; - } -} diff --git a/src/PrestaShopBundle/Service/DataProvider/Admin/ModuleInterface.php b/src/PrestaShopBundle/Service/DataProvider/Admin/ModuleInterface.php deleted file mode 100644 index ae36d001..00000000 --- a/src/PrestaShopBundle/Service/DataProvider/Admin/ModuleInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\DataProvider\Admin; - -/** - * Data provider for new Architecture, about Module object model. - * - * This class will provide data from DB / ORM about Modules for the Admin interface. - */ -interface ModuleInterface -{ - /** - * Return all module entities coming from DB. - * - * @return array|bool - */ - public function getAllModules(); -} diff --git a/src/PrestaShopBundle/Service/DataProvider/Admin/ProductInterface.php b/src/PrestaShopBundle/Service/DataProvider/Admin/ProductInterface.php deleted file mode 100644 index 6a775e22..00000000 --- a/src/PrestaShopBundle/Service/DataProvider/Admin/ProductInterface.php +++ /dev/null @@ -1,124 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\DataProvider\Admin; - -/** - * Data provider for new Architecture, about Product object model. - * - * This class will provide data from DB / ORM about Products for the Admin interface. - */ -interface ProductInterface -{ - /** - * Will retrieve set of parameters from persistence, for product filters. - * - * @return string[] The old filter parameters values - */ - public function getPersistedFilterParameters(); - - /** - * Is there a specific category selected to filter product? - * - * @return bool true if a category is selected - */ - public function isCategoryFiltered(); - - /** - * Is there any column filter value? - * - * A filter with empty string '' is considered as not filtering, but 0 or '0' is a filter value! - * - * @return bool True if at least one column is filtered (except categories) - */ - public function isColumnFiltered(); - - /** - * Will persist set of parameters for product filters. - * - * @param string[] $parameters - */ - public function persistFilterParameters(array $parameters); - - /** - * Combines new filter values with old ones (persisted), then persists the combination and returns it. - * - * @param string[]|null $paramsIn New filter params values to take into account. If not given, the method will simply return persisted values. - * @param bool $avoidPersistence true to avoid persisting these preferences (for an export for example) - * - * @return string[] The new filter params values - */ - public function combinePersistentCatalogProductFilter($paramsIn = [], $avoidPersistence = false); - - /** - * Returns a collection of products, using default language, currency and others, from Context. - * - * @param int|string $offset an offset, or the 'last' token - * @param int|string $limit a limit, or the 'last' token - * @param string $orderBy Field name to sort during SQL query - * @param string $sortOrder 'asc' or 'desc' - * @param string[] $post filter params values to take into acount (often comes from POST data) - * @param bool $avoidPersistence True to avoid persisting these preferences (for an export for example) - * @param bool $formatCldr False to avoid CLDR formatting (heavy memory usage) - * - * @return array[mixed[]] A list of products, as an array of arrays of raw data - */ - public function getCatalogProductList($offset, $limit, $orderBy, $sortOrder, $post = [], $avoidPersistence = false, $formatCldr = true); - - /** - * Retrieve global product count (for the current shop). - * - * No filtering/limit/offset is applied to give this count. - * - * @return int The product count on the current shop - */ - public function countAllProducts(); - - /** - * Because pagination is tied to memory available on the server side, the choices can vary from one to another platform, - * depending on the memory_limit allocated to PHP. - * This will return Elements per page that are recommended to fetch products on the Admin catalog page. - * - * @return array[int] A list of pagination limits to show in the select dropbox in paginator component - */ - public function getPaginationLimitChoices(); - - /** - * Returns the last SQL query that was compiled on this Provider. - * - * @return string The last SQL query that was compiled with $this->compileSqlQuery() - */ - public function getLastCompiledSql(); - - /** - * Returns default activation state for new product. - * - * Duplication process could be different since duplicated product is always deactivated after duplication. - * - * @return bool true if a newly created product should be activated by default - */ - public function isNewProductDefaultActivated(); -} diff --git a/src/PrestaShopBundle/Service/DataProvider/Admin/RecommendedModules.php b/src/PrestaShopBundle/Service/DataProvider/Admin/RecommendedModules.php deleted file mode 100644 index d9185a7d..00000000 --- a/src/PrestaShopBundle/Service/DataProvider/Admin/RecommendedModules.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\DataProvider\Admin; - -use Module; -use Symfony\Component\Routing\Router; - -/** - * Data provider for new Architecture, about recommended modules. - * - * This class will provide modules data from Add-ons API depending on the domain to display recommended modules. - */ -class RecommendedModules -{ - /** - * @var Router - */ - private $router; - - /** - * Constructor. - * - * Dependency injection will give the required services. - * - * @param Router $router - */ - public function __construct(Router $router) - { - $this->router = $router; - } - - /** - * Gets all recommended modules for a specific domain. - * - * @param string $domain The given domain to filter recommended modules - * @param bool|false $randomize To shuffle results - * - * @return array A list of modules names (identifiers) - */ - public function getRecommendedModuleIdList($domain = 'administration', $randomize = false) - { - // FIXME: replace static by dynamic call from add-ons when available - switch ($domain) { - case 'products_quantity': - return ['pm_advancedpack', 'quotation', 'amazon', 'pushoncart', 'cartabandonmentpro']; - case 'products_shipping': - return ['orderpreparation', 'pqeasypost', 'printlabels', 'upstrackingv2']; - case 'products_price': - return ['ordertaxprofitreport', 'massiveprices', 'giftcards', 'groupinc', 'moneybookers', 'authorizeaim']; - case 'products_seo': - return ['ganalytics', 'gshopping', 'leguide', 'seoexpert', 'pm_seointernallinking', 'ec_seo404']; - case 'products_options': - return ['pm_multiplefeatures', 'pm_advancedsearch4', 'banipmod', 'mynewsletter', 'allinone_rewards', 'pm_cachemanager', 'lgcookieslaw', 'customfields']; - case 'products_others': - default: - return []; - } - } - - /** - * Filters the given module list to remove installed ones, and bad filled cases. - * - * @param array $moduleFullList The input list to filter - * - * @return array The filtered list of modules - */ - public function filterInstalledAndBadModules(array $moduleFullList) - { - $installed_modules = []; - array_map(function ($module) use (&$installed_modules) { - $installed_modules[$module['name']] = $module; - }, Module::getModulesInstalled()); - - foreach ($moduleFullList as $key => $module) { - if ((bool) array_key_exists($module->attributes->get('name'), $installed_modules) === true) { - unset($moduleFullList[$key]); - } - if (!isset($module->attributes->get('media')->img)) { - unset($moduleFullList[$key]); - } - } - - return $moduleFullList; - } -} diff --git a/src/PrestaShopBundle/Service/DataProvider/Marketplace/ApiClient.php b/src/PrestaShopBundle/Service/DataProvider/Marketplace/ApiClient.php deleted file mode 100644 index 48b67e6e..00000000 --- a/src/PrestaShopBundle/Service/DataProvider/Marketplace/ApiClient.php +++ /dev/null @@ -1,346 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\DataProvider\Marketplace; - -use GuzzleHttp\Client; - -class ApiClient -{ - private $addonsApiClient; - private $queryParameters = [ - 'format' => 'json', - ]; - private $defaultQueryParameters; - - /** - * @var \PrestaShop\PrestaShop\Adapter\Tools - */ - private $toolsAdapter; - - public function __construct( - Client $addonsApiClient, - $locale, - $isoCode, - $toolsAdapter, - $domain, - $shopVersion - ) { - $this->addonsApiClient = $addonsApiClient; - $this->toolsAdapter = $toolsAdapter; - - list($isoLang) = explode('-', $locale); - - $this->setIsoLang($isoLang) - ->setIsoCode($isoCode) - ->setVersion($shopVersion) - ->setShopUrl($domain); - $this->defaultQueryParameters = $this->queryParameters; - } - - public function setSslVerification($verifySsl) - { - $this->toolsAdapter->refreshCaCertFile(); - $this->addonsApiClient->setDefaultOption('verify', $verifySsl); - } - - /** - * @param Client $client - * - * @return $this - */ - public function setClient(Client $client) - { - $this->addonsApiClient = $client; - - return $this; - } - - /** - * In case you reuse the Client, you may want to clean the previous parameters. - */ - public function reset() - { - $this->queryParameters = $this->defaultQueryParameters; - } - - /** - * Check Addons client account credentials. - * - * @return object - */ - public function getCheckCustomer() - { - $response = $this->setMethod('check_customer') - ->getResponse(); - - return json_decode($response); - } - - public function getNativesModules() - { - $response = $this->setMethod('listing') - ->setAction('native') - ->getResponse(); - - $responseArray = json_decode($response); - - return isset($responseArray->modules) ? $responseArray->modules : []; - } - - public function getPreInstalledModules() - { - $response = $this->setMethod('listing') - ->setAction('install-modules') - ->getResponse(); - $responseDecoded = json_decode($response); - - return isset($responseDecoded->modules) ? $responseDecoded->modules : []; - } - - public function getMustHaveModules() - { - $response = $this->setMethod('listing') - ->setAction('must-have') - ->getResponse(); - - $responseArray = json_decode($response); - - return isset($responseArray->modules) ? $responseArray->modules : []; - } - - /** - * Prepare and call API for PrestaTrust integrity and property module details. - * - * @param string $hash Hash of module files - * @param string $sc_address Smart contract (Module licence) - * - * @return object List of checks made and their results - */ - public function getPrestaTrustCheck($hash, $sc_address) - { - $this->queryParameters['module_hash'] = $hash; - $this->queryParameters['sc_address'] = $sc_address; - - $response = $this->setMethod('trust') - ->getResponse(); - - return json_decode($response); - } - - public function getServices() - { - $response = $this->setMethod('listing') - ->setAction('service') - ->getResponse(); - - $responseArray = json_decode($response); - - return isset($responseArray->services) ? $responseArray->services : []; - } - - public function getCategories() - { - $response = $this->setMethod('listing') - ->setAction('categories') - ->getResponse(); - - $responseArray = json_decode($response); - - return isset($responseArray->module) ? $responseArray->module : []; - } - - public function getModule($moduleId) - { - $response = $this->setMethod('listing') - ->setAction('module') - ->setModuleId($moduleId) - ->getResponse(); - - $responseArray = json_decode($response); - - if (!empty($responseArray->modules)) { - return $responseArray->modules[0]; - } - } - - /** - * Call API for module ZIP content (= download). - * - * @param int $moduleId - * - * @return string binary content (zip format) - */ - public function getModuleZip($moduleId) - { - return $this->setMethod('module') - ->setModuleId($moduleId) - ->getPostResponse(); - } - - public function getCustomerModules($userMail, $password) - { - $response = $this->setMethod('listing') - ->setAction('customer') - ->setUserMail($userMail) - ->setPassword($password) - ->getPostResponse(); - - $responseArray = json_decode($response); - - if (!empty($responseArray->modules)) { - return $responseArray->modules; - } - - return []; - } - - /** - * Get list of themes bought by customer. - * - * @return object - */ - public function getCustomerThemes() - { - $response = $this->setMethod('listing') - ->setAction('customer-themes') - ->getPostResponse(); - - $responseDecoded = json_decode($response); - - if (!empty($responseDecoded->themes)) { - return $responseDecoded->themes; - } - - return []; - } - - public function getResponse() - { - return (string) $this->addonsApiClient - ->get( - null, - ['query' => $this->queryParameters, - ] - )->getBody(); - } - - public function getPostResponse() - { - return (string) $this->addonsApiClient - ->post( - null, - ['query' => $this->queryParameters, - ] - )->getBody(); - } - - /* - * REQUEST PARAMETER SETTERS. - * All parameters will have the same label as their function name. - */ - - public function setMethod($method) - { - $this->queryParameters['method'] = $method; - - return $this; - } - - public function setAction($action) - { - $this->queryParameters['action'] = $action; - - return $this; - } - - public function setIsoLang($isoLang) - { - $this->queryParameters['iso_lang'] = $isoLang; - - return $this; - } - - public function setIsoCode($isoCode) - { - $this->queryParameters['iso_code'] = $isoCode; - - return $this; - } - - public function setVersion($version) - { - $this->queryParameters['version'] = $version; - - return $this; - } - - public function setModuleId($moduleId) - { - $this->queryParameters['id_module'] = $moduleId; - - return $this; - } - - public function setModuleKey($moduleKey) - { - $this->queryParameters['module_key'] = $moduleKey; - - return $this; - } - - public function setModuleName($moduleName) - { - $this->queryParameters['module_name'] = $moduleName; - - return $this; - } - - public function setShopUrl($shop_url) - { - $this->queryParameters['shop_url'] = $shop_url; - - return $this; - } - - public function setUserMail($userMail) - { - $this->queryParameters['username'] = $userMail; - - return $this; - } - - public function setPassword($password) - { - $this->queryParameters['password'] = $password; - - return $this; - } - - /* - * END OF REQUEST PARAMETER SETTERS. - */ -} diff --git a/src/PrestaShopBundle/Service/DataProvider/StockInterface.php b/src/PrestaShopBundle/Service/DataProvider/StockInterface.php deleted file mode 100644 index 4e195618..00000000 --- a/src/PrestaShopBundle/Service/DataProvider/StockInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\DataProvider; - -/** - * Data provider for new Architecture, about Product stocks. - * - * This class will provide data from DB / ORM about Product stocks. - */ -interface StockInterface -{ - /** - * Returns True if Stocks are managed by a module (or by legacy ASM). - * - * @return bool True if Stocks are managed by a module (or by legacy ASM) - */ - public function isAsmGloballyActivated(); -} diff --git a/src/PrestaShopBundle/Service/DataProvider/UserProvider.php b/src/PrestaShopBundle/Service/DataProvider/UserProvider.php deleted file mode 100644 index fe014935..00000000 --- a/src/PrestaShopBundle/Service/DataProvider/UserProvider.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\DataProvider; - -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; -use Symfony\Component\Security\Core\User\User; - -/** - * Convenient way to access User, if exists. - */ -class UserProvider -{ - const ANONYMOUS_USER = 'ANONYMOUS_USER'; - - private $tokenStorage; - - public function __construct(TokenStorage $tokenStorage) - { - $this->tokenStorage = $tokenStorage; - } - - /** - * @see \Symfony\Bundle\FrameworkBundle\Controller::getUser() - */ - public function getUser() - { - if (null === $token = $this->tokenStorage->getToken()) { - return; - } - - if (!is_object($user = $token->getUser())) { - // e.g. anonymous authentication - return; - } - - return $user; - } - - public function getUsername() - { - if ($this->getUser() instanceof User) { - return $this->getUser()->getUsername(); - } - - return self::ANONYMOUS_USER; - } -} diff --git a/src/PrestaShopBundle/Service/DataUpdater/Admin/ProductInterface.php b/src/PrestaShopBundle/Service/DataUpdater/Admin/ProductInterface.php deleted file mode 100644 index 4a7793d9..00000000 --- a/src/PrestaShopBundle/Service/DataUpdater/Admin/ProductInterface.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\DataUpdater\Admin; - -/** - * Data updater for new Architecture, about Product object model. - * - * This class will provide data from DB / ORM about Products for the Admin interface. - */ -interface ProductInterface -{ - /** - * Activate or deactivate a list of products. - * - * @param array $productListId The ID list of products to (de)activate - * @param bool $activate true to activate, false to deactivate - * - * @throws \PrestaShopBundle\Exception\UpdateProductException If an error occured during update (not really blocking since its just activation flag) - * - * @return bool true when succeed - */ - public function activateProductIdList(array $productListId, $activate = true); - - /** - * Do a safe delete on given product IDs. - * - * @param array $productListId The ID list of products to delete - * - * @throws \PrestaShopBundle\Exception\UpdateProductException If deletion failed (some normal cases can brings this, it's not a Development error) - * - * @return bool true when succeed - */ - public function deleteProductIdList(array $productIdList); - - /** - * Duplicates the given product IDs. - * - * @param array $productListId The ID list of products to delete - * - * @throws \PrestaShopBundle\Exception\UpdateProductException if duplication failed - * - * @return bool true when succeed - */ - public function duplicateProductIdList(array $productIdList); - - /** - * Do a safe delete on given product ID. - * - * @param int $productId The product ID to delete - * - * @throws \PrestaShopBundle\Exception\UpdateProductException If deletion failed (some normal cases can brings this, it's not a Development error) - * - * @return bool - */ - public function deleteProduct($productId); - - /** - * Duplicates the given product, and returns the new ID. - * - * Code comes from Legacy controller! - * - * @param int $productId The product ID to duplicate - * - * @return int The new product ID (duplicate) - */ - public function duplicateProduct($productId); - - /** - * Do a sort on a page of products. - * - * Since the sort can be partial (only one page, with offset and limit), we MUST sort only the given IDs, - * and keep the others safely sorted without any functional change (even if we can bulk shift positions to fix gaps and duplicates). - * - * @param array $productList the list of products to sort (keys: ID, values: old positions) The natural order of the array is the new order to update - * @param array $filterParams Contains the ID of the category to sort. Take it from AdminProductDataProvider::getPersistedFilterParameters(). - * - * @throws \PrestaShopBundle\Exception\UpdateProductException If deletion failed (some normal cases can brings this, it's not a Development error) - * - * @return bool true when succeed - */ - public function sortProductIdList(array $productList, $filterParams); -} diff --git a/src/PrestaShopBundle/Service/Database/DoctrineNamingStrategy.php b/src/PrestaShopBundle/Service/Database/DoctrineNamingStrategy.php deleted file mode 100644 index 75b04546..00000000 --- a/src/PrestaShopBundle/Service/Database/DoctrineNamingStrategy.php +++ /dev/null @@ -1,72 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\Database; - -use Doctrine\ORM\Mapping\UnderscoreNamingStrategy; - -/** - * Naming strategy for Doctrine ORM to use prefixed database table names. - */ -class DoctrineNamingStrategy extends UnderscoreNamingStrategy -{ - private $prefix; - - /** - * Constructor. - * - * Prefix is given by injection, set in app/config/parameters.yml. - * - * @param string $prefix - */ - public function __construct($prefix = 'ps_') - { - parent::__construct(CASE_LOWER); - $this->prefix = $prefix; - } - - /** - * {@inheritdoc} - * - * This override adds a prefix to the underscored table name. - */ - public function classToTableName($className) - { - $underscored = parent::classToTableName($className); - - return $this->prefix . $underscored; - } - - /** - * {@inheritdoc} - * - * This override adds a prefix to the underscored table name. - */ - public function joinTableName($sourceEntity, $targetEntity, $propertyName = null) - { - return $this->prefix . parent::classToTableName($sourceEntity) . '_' . parent::classToTableName($targetEntity); - } -} diff --git a/src/PrestaShopBundle/Service/Database/Upgrade.php b/src/PrestaShopBundle/Service/Database/Upgrade.php deleted file mode 100644 index 0709e9e7..00000000 --- a/src/PrestaShopBundle/Service/Database/Upgrade.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\Database; - -use PrestaShopBundle\Command\UpdateSchemaCommand; -use PrestaShopBundle\Service\Command\AbstractCommand; - -class Upgrade extends AbstractCommand -{ - /** - * Run the custom schemaUpgrade command. - */ - public function addDoctrineSchemaUpdate() - { - $command = new UpdateSchemaCommand(); - $this->application->add($command); - - $this->commands[] = [ - 'command' => 'prestashop:schema:update-without-foreign', - '--env' => _PS_ENV_, - ]; - } -} diff --git a/src/PrestaShopBundle/Service/Grid/ControllerResponseBuilder.php b/src/PrestaShopBundle/Service/Grid/ControllerResponseBuilder.php deleted file mode 100644 index e6d7a012..00000000 --- a/src/PrestaShopBundle/Service/Grid/ControllerResponseBuilder.php +++ /dev/null @@ -1,106 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ -declare(strict_types=1); - -namespace PrestaShopBundle\Service\Grid; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\GridDefinitionFactoryInterface; -use PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface; -use PrestaShop\PrestaShop\Core\Grid\Filter\GridFilterFormFactoryInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Router; - -/** - * Before we introduced the filterId notion to store/clean filters on grids the solution - * used controller and action as a key to retrieve and filter. The filters were not scoped - * in the request either (which prevented having two grids on the same page). - * This class is responsible for building the controller response just like it worked before - * filterId, this allows us to keep a backward compatibility in CommonController::searchAction. - */ -class ControllerResponseBuilder -{ - /** @var GridFilterFormFactoryInterface */ - private $filterFormFactory; - - /** @var Router */ - private $router; - - /** - * @param GridFilterFormFactoryInterface $filterFormFactory - * @param Router $router - */ - public function __construct( - GridFilterFormFactoryInterface $filterFormFactory, - Router $router - ) { - $this->filterFormFactory = $filterFormFactory; - $this->router = $router; - } - - /** - * @param GridDefinitionFactoryInterface $definitionFactory - * @param Request $request - * @param string $redirectRoute - * @param array $queryParamsToKeep - * - * @return RedirectResponse - */ - public function buildSearchResponse( - GridDefinitionFactoryInterface $definitionFactory, - Request $request, - $redirectRoute, - array $queryParamsToKeep = [] - ) { - /** @var GridDefinitionInterface $definition */ - $definition = $definitionFactory->getDefinition(); - - /** @var FormInterface $filtersForm */ - $filtersForm = $this->filterFormFactory->create($definition); - $filtersForm->handleRequest($request); - - $redirectParams = []; - if ($filtersForm->isSubmitted()) { - $redirectParams = [ - 'filters' => $filtersForm->getData(), - ]; - } - - foreach ($queryParamsToKeep as $paramName) { - if ($request->query->has($paramName)) { - $redirectParams[$paramName] = $request->query->get($paramName); - } - if ($request->attributes->has($paramName)) { - $redirectParams[$paramName] = $request->attributes->get($paramName); - } - } - - $redirectUrl = $this->router->generate($redirectRoute, $redirectParams); - - return new RedirectResponse($redirectUrl, 302); - } -} diff --git a/src/PrestaShopBundle/Service/Grid/ResponseBuilder.php b/src/PrestaShopBundle/Service/Grid/ResponseBuilder.php deleted file mode 100644 index fb70527f..00000000 --- a/src/PrestaShopBundle/Service/Grid/ResponseBuilder.php +++ /dev/null @@ -1,102 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\Grid; - -use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\GridDefinitionFactoryInterface; -use PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface; -use PrestaShop\PrestaShop\Core\Grid\Filter\GridFilterFormFactoryInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\Routing\Router; - -class ResponseBuilder -{ - /** @var GridFilterFormFactoryInterface */ - private $filterFormFactory; - - /** @var Router */ - private $router; - - /** - * @param GridFilterFormFactoryInterface $filterFormFactory - * @param Router $router - */ - public function __construct( - GridFilterFormFactoryInterface $filterFormFactory, - Router $router - ) { - $this->filterFormFactory = $filterFormFactory; - $this->router = $router; - } - - /** - * @param GridDefinitionFactoryInterface $definitionFactory - * @param Request $request - * @param string $filterId - * @param string $redirectRoute - * @param array $queryParamsToKeep - * - * @return RedirectResponse - */ - public function buildSearchResponse( - GridDefinitionFactoryInterface $definitionFactory, - Request $request, - $filterId, - $redirectRoute, - array $queryParamsToKeep = [] - ) { - /** @var GridDefinitionInterface $definition */ - $definition = $definitionFactory->getDefinition(); - - /** @var FormInterface $filtersForm */ - $filtersForm = $this->filterFormFactory->create($definition); - $filtersForm->handleRequest($request); - - $redirectParams = []; - if ($filtersForm->isSubmitted()) { - $redirectParams = [ - $filterId => [ - 'filters' => $filtersForm->getData(), - ], - ]; - } - - foreach ($queryParamsToKeep as $paramName) { - if ($request->query->has($paramName)) { - $redirectParams[$paramName] = $request->query->get($paramName); - } - if ($request->attributes->has($paramName)) { - $redirectParams[$paramName] = $request->attributes->get($paramName); - } - } - - $redirectUrl = $this->router->generate($redirectRoute, $redirectParams); - - return new RedirectResponse($redirectUrl, 302); - } -} diff --git a/src/PrestaShopBundle/Service/Hook/HookContentClassInterface.php b/src/PrestaShopBundle/Service/Hook/HookContentClassInterface.php deleted file mode 100644 index ab026488..00000000 --- a/src/PrestaShopBundle/Service/Hook/HookContentClassInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\Hook; - -interface HookContentClassInterface -{ - public function toArray(); -} diff --git a/src/PrestaShopBundle/Service/Hook/HookDispatcher.php b/src/PrestaShopBundle/Service/Hook/HookDispatcher.php deleted file mode 100644 index 4505f24f..00000000 --- a/src/PrestaShopBundle/Service/Hook/HookDispatcher.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\Hook; - -use PrestaShop\PrestaShop\Adapter\Hook\HookDispatcher as HookDispatcherAdapter; - -/** - * This dispatcher is used to trigger hook listeners. - * - * The dispatch process cannot be stopped like a common EventDispatcher. - * - * If the event is a RenderingHookEvent, then the final result is - * an array of contents accessed from $event->getContent(). - * - * @deprecated since 1.7.5, to be removed in 1.8. Use PrestaShop\PrestaShop\Adapter\Hook\HookDispatcher instead. - */ -class HookDispatcher extends HookDispatcherAdapter -{ - public function __construct() - { - @trigger_error('Deprecated since 1.7.5, to be removed in 1.8. Use PrestaShop\PrestaShop\Core\Hook\HookDispatcher instead.', E_USER_DEPRECATED); - } -} diff --git a/src/PrestaShopBundle/Service/Hook/HookEvent.php b/src/PrestaShopBundle/Service/Hook/HookEvent.php deleted file mode 100644 index 7cbea0d9..00000000 --- a/src/PrestaShopBundle/Service/Hook/HookEvent.php +++ /dev/null @@ -1,78 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\Hook; - -use AppKernel; -use PrestaShop\PrestaShop\Adapter\SymfonyContainer; -use Symfony\Component\EventDispatcher\Event; - -/** - * HookEvent is used in HookDispatcher. - * - * A HookEvent can contains parameters to give to the listeners through getHookParameters. - */ -class HookEvent extends Event -{ - private $hookParameters = []; - - /** - * Sets the Hook parameters. - * - * @param array hook parameters - * - * @return $this, for fluent use of object - */ - public function setHookParameters($parameters) - { - $this->hookParameters = $parameters; - - return $this; - } - - /** - * Returns Hook parameters and default values. - * - * More values than the param set is returned: - * - _ps_version contains PrestaShop version, and is here only if the Hook is triggered by Symfony architecture. - * These values can either be overriden by setHookParameters using the same parameter key. - * - * @return array the array of hook parameters, more default fixed values - */ - public function getHookParameters() - { - $globalParameters = ['_ps_version' => AppKernel::VERSION]; - - $sfContainer = SymfonyContainer::getInstance(); - if (null !== $sfContainer && null !== $sfContainer->get('request_stack')->getCurrentRequest()) { - $request = $sfContainer->get('request_stack')->getCurrentRequest(); - $globalParameters['request'] = $request; - $globalParameters['route'] = $request->get('_route'); - } - - return array_merge($globalParameters, $this->hookParameters); - } -} diff --git a/src/PrestaShopBundle/Service/Hook/HookFinder.php b/src/PrestaShopBundle/Service/Hook/HookFinder.php deleted file mode 100644 index 91043058..00000000 --- a/src/PrestaShopBundle/Service/Hook/HookFinder.php +++ /dev/null @@ -1,228 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\Hook; - -use PrestaShop\PrestaShop\Adapter\HookManager; - -/** - * This class declares the functions needed to get structured data - * from the modules, by asking them to follow a specific class. - */ -class HookFinder -{ - /** - * In order to not return wrong things to the caller, we ask for an - * instance of specific classes. - * Please note it must implement the function toArray(). - * - * @var string - */ - protected $expectedInstanceClasses = []; - - /** - * Because we cannot send the same parameters between two different finders, - * we need a attribute. It will be sent to the Hook::exec() function. - * - * @var array - */ - protected $params = []; - - /** - * The hook to call. - * - * @var string - */ - protected $hookName; - - /** - * Execute hook specified in params and check if the result matches the expected classes if asked. - * - * @return array Content returned by modules - * - * @throws \Exception if class doesn't match interface or expected classes - */ - public function find() - { - $hookContent = (new HookManager())->exec($this->hookName, $this->params, null, true); - if (!is_array($hookContent)) { - $hookContent = []; - } - - foreach ($hookContent as $moduleName => $moduleContents) { - if (!is_array($moduleContents)) { - continue; - } - foreach ($moduleContents as $content) { - // Check data returned if asked - if (!count($this->expectedInstanceClasses)) { - continue; - } - if (is_object($content) && !in_array(get_class($content), $this->expectedInstanceClasses)) { - throw new \Exception('The module ' . $moduleName . ' did not return expected class. Was ' . get_class($content) . ' instead of ' . implode(' or ', $this->expectedInstanceClasses) . '.'); - } elseif (!is_object($content)) { - throw new \Exception('The module ' . $moduleName . ' did not return expected type. Was ' . gettype($content) . ' instead of ' . implode(' or ', $this->expectedInstanceClasses) . '.'); - } - } - } - - return $hookContent; - } - - /** - * Present all extra content for templates, meaning converting them as arrays. - * - * @return array - */ - public function present() - { - $hookContent = $this->find(); - $presentedContents = []; - - foreach ($hookContent as $moduleName => $moduleContents) { - if (!is_array($moduleContents)) { - continue; - } - foreach ($moduleContents as $content) { - if (!$content instanceof HookContentClassInterface) { - throw new \Exception('The class returned must implement HookContentClassInterface to be presented'); - } - - $presentedContent = $content->toArray(); - $presentedContent['moduleName'] = $moduleName; - $presentedContents[] = $presentedContent; - } - } - - return $presentedContents; - } - - /** - * This array contains all the classes expected to be returned - * by the modules on Hook::exec. - * - * @return array - */ - public function getExpectedInstanceClasses() - { - return $this->expectedInstanceClasses; - } - - /** - * The hook going to be called when firing find(). - * - * @return string - */ - public function getHookName() - { - return $this->hookName; - } - - /** - * The $params sent to Hook::exec(). - * - * @return array - */ - public function getParams() - { - return $this->params; - } - - /** - * Add an instance of class to be returned by the hook without - * erasing the other values. - * - * @param string|array $expectedInstanceClasses - * - * @return \PrestaShopBundle\Service\Hook\Finder - */ - public function addExpectedInstanceClasses($expectedInstanceClasses) - { - if (is_array($expectedInstanceClasses)) { - $this->expectedInstanceClasses = array_merge($this->expectedInstanceClasses, $expectedInstanceClasses); - } else { - $this->expectedInstanceClasses[] = $expectedInstanceClasses; - } - - return $this; - } - - /** - * Replace all expected classes and types. - * - * @param array $expectedInstanceClasses - * - * @return \PrestaShopBundle\Service\Hook\Finder - */ - public function setExpectedInstanceClasses($expectedInstanceClasses) - { - $this->expectedInstanceClasses = $expectedInstanceClasses; - - return $this; - } - - /** - * Change the hook to be called. - * - * @param string $hookName - * - * @return \PrestaShopBundle\Service\Hook\Finder - */ - public function setHookName($hookName) - { - $this->hookName = $hookName; - - return $this; - } - - /** - * Add a hook param without erasing all the other values. - * - * @param array $params - * - * @return \PrestaShopBundle\Service\Hook\Finder - */ - public function addParams($params) - { - $this->params = array_merge($this->params, $params); - - return $this; - } - - /** - * Replace the params array. - * - * @param array $params - * - * @return \PrestaShopBundle\Service\Hook\Finder - */ - public function setParams($params) - { - $this->params = $params; - - return $this; - } -} diff --git a/src/PrestaShopBundle/Service/Hook/RenderingHookEvent.php b/src/PrestaShopBundle/Service/Hook/RenderingHookEvent.php deleted file mode 100644 index 6efc887a..00000000 --- a/src/PrestaShopBundle/Service/Hook/RenderingHookEvent.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\Hook; - -/** - * RenderingHookEvent is used in HookDispatcher for rendering hooks. - * - * A HookEvent can contains parameters to give to the listeners through getHookParameters, - * but can also contains responses from subscribers, to deliver HTML or other data to the caller. - */ -class RenderingHookEvent extends HookEvent -{ - /** - * @var array - */ - private $currentContent = []; - /** - * @var string - */ - private $currentListener = ''; - - /** - * Sets the response from the listener. - * - * Should be called by the listener to store its response. - * This content will be pushed in a stack between each listener call. - * Every response is kept, but a given listener cannot see the previous listeners' responses. - * - * @param array $content The rendering content returned by the listener - * @param string $fromListener The listener that sets the content - * - * @return $this for fluent use - */ - public function setContent(array $content, $fromListener = '') - { - $this->currentContent = $content; - $this->currentListener = $fromListener; - - return $this; - } - - /** - * Gets the last pushed content (for the current listener). - * - * @return array - */ - public function getContent() - { - return $this->currentContent; - } - - /** - * Retrieves the last pushed content (and cleans the corresponding attribute). - * - * @return array - */ - public function popContent() - { - $content = $this->currentContent; - $this->currentContent = []; - - return $content; - } - - /** - * Gets the current listener that put the response (and cleans the corresponding attribute). - * - * @return string a listener - */ - public function popListener() - { - $listener = $this->currentListener; - $this->currentListener = ''; - - return $listener; - } -} diff --git a/src/PrestaShopBundle/Service/Log/LogHandler.php b/src/PrestaShopBundle/Service/Log/LogHandler.php deleted file mode 100644 index 82b7d6cd..00000000 --- a/src/PrestaShopBundle/Service/Log/LogHandler.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\Log; - -use Monolog\Handler\AbstractProcessingHandler; -use Monolog\Logger; -use Symfony\Component\DependencyInjection\Container; - -class LogHandler extends AbstractProcessingHandler -{ - protected $container; - - public function __construct(Container $container, $level = Logger::DEBUG, $bubble = true) - { - $this->container = $container; - parent::__construct($level, $bubble); - } - - protected function write(array $record) - { - $logger = $this->container->get('prestashop.adapter.legacy.logger'); - $logger->log($record['level'], $record['message'], $record['context']); - } -} diff --git a/src/PrestaShopBundle/Service/ProductService.php b/src/PrestaShopBundle/Service/ProductService.php deleted file mode 100644 index 88827216..00000000 --- a/src/PrestaShopBundle/Service/ProductService.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service; - -use PrestaShop\PrestaShop\Adapter\Product\ProductDataProvider; -use Product; - -class ProductService -{ - /** @var ProductDataProvider */ - protected $dataProvider; - - public function __construct(ProductDataProvider $dataProvider) - { - $this->dataProvider = $dataProvider; - } - - public function cleanupOldTempProducts() - { - $oldProducts = Product::getOldTempProducts(); - - foreach ($oldProducts as $oldProduct) { - $id_product = $oldProduct['id_product']; - $product = $this->dataProvider->getProduct($id_product); - if ($product) { - $product->delete(); - } - } - } -} diff --git a/src/PrestaShopBundle/Service/Routing/Router.php b/src/PrestaShopBundle/Service/Routing/Router.php deleted file mode 100644 index 9bc34132..00000000 --- a/src/PrestaShopBundle/Service/Routing/Router.php +++ /dev/null @@ -1,101 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\Routing; - -use PrestaShop\PrestaShop\Core\Feature\TokenInUrls; -use PrestaShopBundle\Service\DataProvider\UserProvider; -use Symfony\Bundle\FrameworkBundle\Routing\Router as BaseRouter; -use Symfony\Component\Security\Csrf\CsrfTokenManager; - -/** - * We extends Symfony Router in order to add a token to each url. - * - * This is done for Security purposes. - */ -class Router extends BaseRouter -{ - /** - * @var UserProvider - */ - private $userProvider; - - /** - * @var CsrfTokenManager - */ - private $tokenManager; - - /** - * @var array - */ - private $tokens = []; - - /** - * {@inheritdoc} - */ - public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) - { - $username = $this->userProvider->getUsername(); - // Do not generate token each time we want to generate a route for a user - if (!isset($this->tokens[$username])) { - $this->tokens[$username] = $this->tokenManager->getToken($username)->getValue(); - } - - $url = parent::generate($name, $parameters, $referenceType); - - return self::generateTokenizedUrl($url, $this->tokens[$username]); - } - - public function setTokenManager(CsrfTokenManager $tokenManager) - { - $this->tokenManager = $tokenManager; - } - - public function setUserProvider(UserProvider $userProvider) - { - $this->userProvider = $userProvider; - } - - public static function generateTokenizedUrl($url, $token) - { - if (TokenInUrls::isDisabled()) { - return $url; - } - - $components = parse_url($url); - $baseUrl = (isset($components['path']) ? $components['path'] : ''); - $queryParams = []; - if (isset($components['query'])) { - $query = $components['query']; - - parse_str($query, $queryParams); - } - - $queryParams['_token'] = $token; - - return $baseUrl . '?' . http_build_query($queryParams, '', '&'); - } -} diff --git a/src/PrestaShopBundle/Service/TransitionalBehavior/AdminPagePreferenceInterface.php b/src/PrestaShopBundle/Service/TransitionalBehavior/AdminPagePreferenceInterface.php deleted file mode 100644 index aa7f95f3..00000000 --- a/src/PrestaShopBundle/Service/TransitionalBehavior/AdminPagePreferenceInterface.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\TransitionalBehavior; - -/** - * Contract to know which page's version to display. - * - * This interface gives methods to use to take decision: - * - if we should display the new refactored page, or the old legacy one. - * - if we should display the switch on the admin layout to change this setting. - */ -interface AdminPagePreferenceInterface -{ - /** - * Use it to know if we need to redirect to legacy Controllers or not. - * - * @param string $page the page to look for - * - * @return bool true to redirect to legacy - */ - public function getTemporaryShouldUseLegacyPage($page); - - /** - * Set the temporary behavior of the new/old page on Admin interface. - * - * @param string $page the page to look for - * @param bool $useLegacy true to redirect to old legacy pages for Product controller - */ - public function setTemporaryShouldUseLegacyPage($page, $useLegacy); - - /** - * Use it to know if we need to display the 'switch to legacy page' button or not. - * In debug mode, always shown. - * - * @param string $page the page to look for - * - * @return bool true to show the switch to legacy page button - */ - public function getTemporaryShouldAllowUseLegacyPage($page = null); -} diff --git a/src/PrestaShopBundle/Service/TransitionalBehavior/AdminUrlGeneratorFactory.php b/src/PrestaShopBundle/Service/TransitionalBehavior/AdminUrlGeneratorFactory.php deleted file mode 100644 index 9cb75cf4..00000000 --- a/src/PrestaShopBundle/Service/TransitionalBehavior/AdminUrlGeneratorFactory.php +++ /dev/null @@ -1,77 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service\TransitionalBehavior; - -use PrestaShop\PrestaShop\Adapter\Admin\UrlGenerator as LegacyUrlGenerator; -use PrestaShop\PrestaShop\Adapter\LegacyContext; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Routing\Router; - -/** - * Factory to return a UrlGeneratorInterface. - * Either the base generator from Symfony (the Router class instance) - * Either an Adapter for Admin legacy controllers. - */ -class AdminUrlGeneratorFactory -{ - /** - * @var Router - */ - private $router; - - /** - * Constructor. - * - * @param Router $router - */ - public function __construct(Router $router) - { - $this->router = $router; - } - - /** - * Gets the UrlGeneratorInterface subclass for Legacy Admin controllers. - * - * @param LegacyContext $legacyContext The legacy context needed by Legacy UrlGenerator - * - * @return UrlGeneratorInterface the UrlGenerator instance for Admin legacy controllers - */ - public function forLegacy(LegacyContext $legacyContext) - { - return new LegacyUrlGenerator($legacyContext, $this->router); - } - - /** - * Gets the UrlGeneratorInterface subclass for Symfony routes. - * - * @return UrlGeneratorInterface the UrlGenerator instance for Admin Symfony routes - */ - public function forSymfony() - { - return $this->router; - } -} diff --git a/src/PrestaShopBundle/Service/TranslationService.php b/src/PrestaShopBundle/Service/TranslationService.php deleted file mode 100644 index f2c888c6..00000000 --- a/src/PrestaShopBundle/Service/TranslationService.php +++ /dev/null @@ -1,355 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Service; - -use Exception; -use PrestaShopBundle\Entity\Translation; -use PrestaShopBundle\Exception\InvalidLanguageException; -use PrestaShopBundle\Translation\Constraints\PassVsprintf; -use PrestaShopBundle\Translation\Provider\UseModuleInterface; -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\Validator\Validation; - -class TranslationService -{ - /** - * @var Container - */ - public $container; - - /** - * @param string $lang - * - * @return mixed - */ - public function langToLocale($lang) - { - $legacyToStandardLocales = $this->getLangToLocalesMapping(); - - return $legacyToStandardLocales[$lang]; - } - - /** - * @param string $locale - * - * @return mixed - * - * @throws InvalidLanguageException - */ - public function findLanguageByLocale($locale) - { - $doctrine = $this->container->get('doctrine'); - - $lang = $doctrine->getManager()->getRepository('PrestaShopBundle:Lang')->findOneByLocale($locale); - - if (!$lang) { - throw InvalidLanguageException::localeNotFound($locale); - } - - return $lang; - } - - /** - * @return mixed - * - * @throws Exception - */ - private function getLangToLocalesMapping() - { - $translationsDirectory = $this->getResourcesDirectory(); - - $legacyToStandardLocalesJson = file_get_contents($translationsDirectory . '/legacy-to-standard-locales.json'); - $legacyToStandardLocales = json_decode($legacyToStandardLocalesJson, true); - - $jsonLastErrorCode = json_last_error(); - if (JSON_ERROR_NONE !== $jsonLastErrorCode) { - throw new Exception('The legacy to standard locales JSON could not be decoded', $jsonLastErrorCode); - } - - return $legacyToStandardLocales; - } - - /** - * @return string - */ - private function getResourcesDirectory() - { - return $this->container->getParameter('kernel.root_dir') . '/Resources'; - } - - /** - * @param $lang - * @param $type - * @param $theme - * @param null $search - * - * @return array|mixed - */ - public function getTranslationsCatalogue($lang, $type, $theme, $search = null) - { - $factory = $this->container->get('ps.translations_factory'); - - if ($this->requiresThemeTranslationsFactory($theme, $type)) { - if ('classic' === $theme) { - $type = 'front'; - } else { - $type = $theme; - $factory = $this->container->get('ps.theme_translations_factory'); - } - } - - $locale = $this->langToLocale($lang); - - return $factory->createTranslationsArray($type, $locale, $theme, $search); - } - - /** - * @param $theme - * @param $type - * - * @return bool - */ - private function requiresThemeTranslationsFactory($theme, $type) - { - return $type === 'themes' && null !== $theme; - } - - /** - * List translations for a specific domain. - * - * @todo: we need module information here - * @todo: we need to improve the Vuejs application to send the information - * - * @param $locale - * @param $domain - * @param null $theme - * @param null $search - * @param null $module - * - * @return array - */ - public function listDomainTranslation($locale, $domain, $theme = null, $search = null, $module = null) - { - if (!empty($theme) && 'classic' !== $theme) { - $translationProvider = $this->container->get('prestashop.translation.theme_provider'); - $translationProvider->setThemeName($theme); - } else { - $translationProvider = $this->container->get('prestashop.translation.search_provider'); - if ($module !== null && $translationProvider instanceof UseModuleInterface) { - $translationProvider->setModuleName($module); - } - } - if ('Messages' === $domain) { - $domain = 'messages'; - } - - $translationProvider->setDomain($domain); - $translationProvider->setLocale($locale); - - $router = $this->container->get('router'); - $domains = [ - 'info' => [ - 'edit_url' => $router->generate('api_translation_value_edit'), - 'reset_url' => $router->generate('api_translation_value_reset'), - ], - 'data' => [], - ]; - $treeDomain = preg_split('/(?=[A-Z])/', $domain, -1, PREG_SPLIT_NO_EMPTY); - if (!empty($theme) && 'classic' !== $theme) { - $defaultCatalog = current($translationProvider->getThemeCatalogue()->all()); - } else { - $defaultCatalog = current($translationProvider->getDefaultCatalogue()->all()); - } - - $xliffCatalog = current($translationProvider->getXliffCatalogue()->all()); - $dbCatalog = current($translationProvider->getDatabaseCatalogue($theme)->all()); - - foreach ($defaultCatalog as $key => $message) { - $data = [ - 'default' => $key, - 'xliff' => (array_key_exists($key, (array) $xliffCatalog) ? $xliffCatalog[$key] : null), - 'database' => (array_key_exists($key, (array) $dbCatalog) ? $dbCatalog[$key] : null), - 'tree_domain' => $treeDomain, - ]; - // if search is empty or is in catalog default|xlf|database - if (empty($search) || $this->dataContainsSearchWord($search, $data)) { - if (empty($data['xliff']) && empty($data['database'])) { - array_unshift($domains['data'], $data); - } else { - $domains['data'][] = $data; - } - } - } - - return $domains; - } - - /** - * Check if data contains search word. - * - * @param $search - * @param $data - * - * @return bool - */ - private function dataContainsSearchWord($search, $data) - { - if (is_string($search)) { - $search = strtolower($search); - - return false !== strpos(strtolower($data['default']), $search) || - false !== strpos(strtolower($data['xliff']), $search) || - false !== strpos(strtolower($data['database']), $search); - } - - if (is_array($search)) { - $contains = true; - foreach ($search as $s) { - $s = strtolower($s); - $contains &= false !== strpos(strtolower($data['default']), $s) || - false !== strpos(strtolower($data['xliff']), $s) || - false !== strpos(strtolower($data['database']), $s); - } - - return $contains; - } - - return false; - } - - /** - * Save a translation in database. - * - * @param $lang - * @param $domain - * @param $key - * @param $translationValue - * @param null $theme - * - * @return bool - */ - public function saveTranslationMessage($lang, $domain, $key, $translationValue, $theme = null) - { - $doctrine = $this->container->get('doctrine'); - $entityManager = $doctrine->getManager(); - $logger = $this->container->get('logger'); - - if (empty($theme)) { - $theme = null; - } - - $translation = $entityManager->getRepository('PrestaShopBundle:Translation') - ->findOneBy([ - 'lang' => $lang, - 'domain' => $domain, - 'key' => $key, - 'theme' => $theme, - ]); - - if (null === $translation) { - $translation = new Translation(); - $translation->setDomain($domain); - $translation->setLang($lang); - $translation->setKey(htmlspecialchars_decode($key, ENT_QUOTES)); - $translation->setTranslation($translationValue); - if (!empty($theme)) { - $translation->setTheme($theme); - } - } else { - if (!empty($theme)) { - $translation->setTheme($theme); - } - $translation->setTranslation($translationValue); - } - - $validator = Validation::createValidator(); - $violations = $validator->validate($translation, new PassVsprintf()); - if (0 !== count($violations)) { - foreach ($violations as $violation) { - $logger->error($violation->getMessage()); - } - - return false; - } - - $updatedTranslationSuccessfully = false; - - try { - $entityManager->persist($translation); - $entityManager->flush(); - - $updatedTranslationSuccessfully = true; - } catch (Exception $exception) { - $logger->error($exception->getMessage()); - } - - return $updatedTranslationSuccessfully; - } - - /** - * Reset translation from database. - * - * @param $lang - * @param $domain - * @param $key - * @param null $theme - * - * @return bool - */ - public function resetTranslationMessage($lang, $domain, $key, $theme = null) - { - $doctrine = $this->container->get('doctrine'); - $entityManager = $doctrine->getManager(); - - $searchTranslation = [ - 'lang' => $lang, - 'domain' => $domain, - 'key' => $key, - ]; - if (!empty($theme)) { - $searchTranslation['theme'] = $theme; - } - - $translation = $entityManager->getRepository('PrestaShopBundle:Translation')->findOneBy($searchTranslation); - - $resetTranslationSuccessfully = false; - if (null === $translation) { - $resetTranslationSuccessfully = true; - } - - try { - $entityManager->remove($translation); - $entityManager->flush(); - - $resetTranslationSuccessfully = true; - } catch (Exception $exception) { - $this->container->get('logger')->error($exception->getMessage()); - } - - return $resetTranslationSuccessfully; - } -} diff --git a/src/PrestaShopBundle/Translation/Api/AbstractApi.php b/src/PrestaShopBundle/Translation/Api/AbstractApi.php deleted file mode 100644 index c194ce82..00000000 --- a/src/PrestaShopBundle/Translation/Api/AbstractApi.php +++ /dev/null @@ -1,58 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Api; - -use Symfony\Component\Translation\TranslatorInterface; - -abstract class AbstractApi -{ - /** - * @var TranslatorInterface - */ - protected $translator; - - public function setTranslator(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - public function getFormattedTranslations() - { - $all = []; - - foreach ($this->getTranslations() as $key => $translation) { - $all[] = [ - 'translation_id' => $key, - 'name' => $translation, - ]; - } - - return $all; - } - - abstract public function getTranslations(); -} diff --git a/src/PrestaShopBundle/Translation/Api/InternationalApi.php b/src/PrestaShopBundle/Translation/Api/InternationalApi.php deleted file mode 100644 index 03d940c8..00000000 --- a/src/PrestaShopBundle/Translation/Api/InternationalApi.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Api; - -class InternationalApi extends AbstractApi -{ - /** - * @return string[] List of translations - */ - public function getTranslations() - { - return [ - 'button_reset' => $this->translator->trans('Reset', [], 'Admin.Actions'), - 'button_save' => $this->translator->trans('Save', [], 'Admin.Global'), - 'button_leave' => $this->translator->trans('Leave anyway', [], 'Admin.Notifications.Warning'), - 'button_search' => $this->translator->trans('Search', [], 'Admin.Actions'), - 'modal_title' => $this->translator->trans('Confirm this action', [], 'Admin.Actions'), - 'modal_content' => $this->translator->trans('Your modifications are not saved yet. Do you wish to save it before leaving?', [], 'Admin.Notifications.Warning'), - 'head_title' => $this->translator->trans('Translations', [], 'Admin.Navigation.Menu'), - /* Missing is plural, always > 1 */ - 'label_missing' => $this->translator->trans('%d missing', [], 'Admin.International.Feature'), - 'label_missing_singular' => $this->translator->trans('1 missing', [], 'Admin.International.Feature'), - 'label_total_domain' => $this->translator->trans('%nb_translations% expressions', [], 'Admin.International.Feature'), - /* nb_translations can be 0 or 1 */ - 'label_total_domain_singular' => $this->translator->trans('%nb_translation% expression', [], 'Admin.International.Feature'), - 'link_international' => $this->translator->trans('International', [], 'Admin.Navigation.Menu'), - 'link_translations' => $this->translator->trans('Translations', [], 'Admin.Navigation.Menu'), - 'no_result' => $this->translator->trans('There are no results matching your query "%s".', [], 'Admin.Navigation.Search'), - 'sidebar_expand' => $this->translator->trans('Expand', [], 'Admin.Actions'), - 'sidebar_collapse' => $this->translator->trans('Collapse', [], 'Admin.Actions'), - 'search_info' => $this->translator->trans('%d results match your query "%s".', [], 'Admin.Navigation.Search'), - /* %d can be 0 or 1 */ - 'search_info_singular' => $this->translator->trans('%d result matches your query "%s".', [], 'Admin.Navigation.Search'), - 'search_label' => $this->translator->trans('Search translations', [], 'Admin.International.Feature'), - 'search_placeholder' => $this->translator->trans('Search a word or expression, e.g.: "Order confirmation"', [], 'Admin.International.Help'), - ]; - } -} diff --git a/src/PrestaShopBundle/Translation/Api/StockApi.php b/src/PrestaShopBundle/Translation/Api/StockApi.php deleted file mode 100644 index 44d19dce..00000000 --- a/src/PrestaShopBundle/Translation/Api/StockApi.php +++ /dev/null @@ -1,90 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Api; - -class StockApi extends AbstractApi -{ - /** - * @return string[] List of translations - */ - public function getTranslations() - { - return [ - 'alert_bulk_edit' => $this->translator->trans('Use checkboxes to bulk edit quantities', [], 'Admin.Catalog.Feature'), - 'button_advanced_filter' => $this->translator->trans('Advanced filters', [], 'Admin.Catalog.Feature'), - 'button_apply_advanced_filter' => $this->translator->trans('Apply advanced filters', [], 'Admin.Catalog.Feature'), - 'button_movement_type' => $this->translator->trans('Apply new quantity', [], 'Admin.Catalog.Feature'), - 'button_search' => $this->translator->trans('Search', [], 'Admin.Actions'), - 'filter_categories' => $this->translator->trans('Filter by categories', [], 'Admin.Actions'), - 'filter_datepicker_from' => $this->translator->trans('From', [], 'Admin.Global'), - 'filter_datepicker_to' => $this->translator->trans('To', [], 'Admin.Global'), - 'filter_low_stock' => $this->translator->trans('Display products below low stock level first', [], 'Admin.Catalog.Feature'), - 'filter_movements_type' => $this->translator->trans('Filter by movement type', [], 'Admin.Catalog.Feature'), - 'filter_movements_employee' => $this->translator->trans('Filter by employee', [], 'Admin.Catalog.Feature'), - 'filter_movements_period' => $this->translator->trans('Filter by period', [], 'Admin.Catalog.Feature'), - 'filter_search_category' => $this->translator->trans('Search a category', [], 'Admin.Catalog.Feature'), - 'filter_search_suppliers' => $this->translator->trans('Search a supplier', [], 'Admin.Catalog.Feature'), - 'filter_status' => $this->translator->trans('Filter by status', [], 'Admin.Catalog.Feature'), - // 'All' refers to statuses as if "All statuses". Please adapt as necessary in your language - 'filter_status_all' => $this->translator->trans('All', [], 'Admin.Catalog.Feature'), - 'filter_status_disable' => $this->translator->trans('Disabled', [], 'Admin.Global'), - 'filter_status_enable' => $this->translator->trans('Enabled', [], 'Admin.Global'), - 'filter_suppliers' => $this->translator->trans('Filter by supplier', [], 'Admin.Catalog.Feature'), - 'head_title' => $this->translator->trans('Stock management', [], 'Admin.Catalog.Feature'), - 'link_catalog' => $this->translator->trans('Catalog', [], 'Admin.Navigation.Menu'), - 'link_movements' => $this->translator->trans('Movements', [], 'Admin.Catalog.Feature'), - 'link_overview' => $this->translator->trans('Stock', [], 'Admin.Global'), - 'link_stock' => $this->translator->trans('Stock management', [], 'Admin.Catalog.Feature'), - 'menu_stock' => $this->translator->trans('Stock', [], 'Admin.Global'), - 'menu_movements' => $this->translator->trans('Movements', [], 'Admin.Catalog.Feature'), - 'no_product' => $this->translator->trans('No product matches your search. Try changing search terms.', [], 'Admin.Catalog.Notification'), - 'none' => $this->translator->trans('None', [], 'Admin.Catalog.Feature'), - 'notification_stock_updated' => $this->translator->trans('Stock successfully updated', [], 'Admin.Catalog.Notification'), - 'product_search' => $this->translator->trans('Search products (search by name, reference, supplier)', [], 'Admin.Catalog.Feature'), - 'product_low_stock' => $this->translator->trans('This product is below the low stock level you have defined.', [], 'Admin.Catalog.Feature'), - 'product_low_stock_level' => $this->translator->trans('Low stock level:', [], 'Admin.Catalog.Feature'), - 'product_low_stock_alert' => $this->translator->trans('Low stock alert:', [], 'Admin.Catalog.Feature'), - 'title_available' => $this->translator->trans('Available', [], 'Admin.Global'), - 'title_bulk' => $this->translator->trans('Bulk edit quantity', [], 'Admin.Catalog.Feature'), - 'title_date' => $this->translator->trans('Date & Time', [], 'Admin.Catalog.Feature'), - 'title_edit_quantity' => $this->translator->trans('Edit quantity', [], 'Admin.Catalog.Feature'), - 'title_employee' => $this->translator->trans('Employee', [], 'Admin.Global'), - 'title_import' => $this->translator->trans('Go to the import system', [], 'Admin.Catalog.Feature'), - 'title_export' => $this->translator->trans('Export data into CSV', [], 'Admin.Catalog.Feature'), - 'title_movements_type' => $this->translator->trans('Type', [], 'Admin.Global'), - 'title_physical' => $this->translator->trans('Physical', [], 'Admin.Catalog.Feature'), - 'title_product' => $this->translator->trans('Product', [], 'Admin.Global'), - 'title_reference' => $this->translator->trans('Reference', [], 'Admin.Global'), - 'title_reserved' => $this->translator->trans('Reserved', [], 'Admin.Catalog.Feature'), - 'title_status' => $this->translator->trans('Status', [], 'Admin.Global'), - 'title_supplier' => $this->translator->trans('Supplier', [], 'Admin.Global'), - 'title_quantity' => $this->translator->trans('Quantity', [], 'Admin.Global'), - 'tree_expand' => $this->translator->trans('Expand', [], 'Admin.Actions'), - 'tree_reduce' => $this->translator->trans('Collapse', [], 'Admin.Actions'), - ]; - } -} diff --git a/src/PrestaShopBundle/Translation/Constraints/PassVsprintf.php b/src/PrestaShopBundle/Translation/Constraints/PassVsprintf.php deleted file mode 100644 index 0a304577..00000000 --- a/src/PrestaShopBundle/Translation/Constraints/PassVsprintf.php +++ /dev/null @@ -1,43 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Constraints; - -use Symfony\Component\Validator\Constraint; - -/** - * @Annotation - * @Target({"CLASS", "ANNOTATION"}) - */ -class PassVsprintf extends Constraint -{ - public $message = 'You must specify as many arguments (%d, %s ...) as the original string.'; - - public function getTargets() - { - return static::CLASS_CONSTRAINT; - } -} diff --git a/src/PrestaShopBundle/Translation/Constraints/PassVsprintfValidator.php b/src/PrestaShopBundle/Translation/Constraints/PassVsprintfValidator.php deleted file mode 100644 index 90f2773e..00000000 --- a/src/PrestaShopBundle/Translation/Constraints/PassVsprintfValidator.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Constraints; - -use Exception; -use PrestaShopBundle\Entity\Translation; -use PrestaShopBundle\Translation\PrestaShopTranslatorTrait; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; - -class PassVsprintfValidator extends ConstraintValidator -{ - public function validate($translation, Constraint $constraint) - { - if (!$constraint instanceof PassVsprintf) { - throw new UnexpectedTypeException($constraint, 'PrestaShopBundle\Translation\Constraints\PassVsprintf'); - } - - if (!$translation instanceof Translation) { - throw new UnexpectedTypeException($translation, 'PrestaShopBundle\Entity\Translation'); - } - - if ($this->countArgumentsOfTranslation($translation->getKey()) != $this->countArgumentsOfTranslation($translation->getTranslation())) { - $this->context->buildViolation($constraint->message) - ->addViolation(); - } - } - - private function countArgumentsOfTranslation($property) - { - $matches = []; - if (preg_match_all(PrestaShopTranslatorTrait::$regexSprintfParams, $property, $matches) === false) { - throw new Exception('Preg_match failed'); - } - - return count($matches[0]); - } -} diff --git a/src/PrestaShopBundle/Translation/DataCollectorTranslator.php b/src/PrestaShopBundle/Translation/DataCollectorTranslator.php deleted file mode 100644 index 77f492df..00000000 --- a/src/PrestaShopBundle/Translation/DataCollectorTranslator.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation; - -use Symfony\Component\Translation\DataCollectorTranslator as BaseTranslator; - -class DataCollectorTranslator extends BaseTranslator -{ - use PrestaShopTranslatorTrait; -} diff --git a/src/PrestaShopBundle/Translation/DomainNormalizer.php b/src/PrestaShopBundle/Translation/DomainNormalizer.php deleted file mode 100644 index 53c7fb0f..00000000 --- a/src/PrestaShopBundle/Translation/DomainNormalizer.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation; - -use RuntimeException; - -/** - * Normalizes domain names by removing dots - */ -class DomainNormalizer -{ - /** - * @param string $domain Domain name - * - * @return string - * - * @throws RuntimeException - */ - public function normalize($domain) - { - // remove up to two dots from the domain name - // (because legacy domain translations CAN have dots in the third part) - $normalizedDomain = preg_replace('/\./', '', $domain, 2); - - if ($normalizedDomain === null) { - throw new RuntimeException(sprintf('An error occurred while normalizing domain "%s"', $domain)); - } - - return $normalizedDomain; - } -} diff --git a/src/PrestaShopBundle/Translation/Exception/InvalidLegacyTranslationKeyException.php b/src/PrestaShopBundle/Translation/Exception/InvalidLegacyTranslationKeyException.php deleted file mode 100644 index fa56dc36..00000000 --- a/src/PrestaShopBundle/Translation/Exception/InvalidLegacyTranslationKeyException.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Exception; - -/** - * Thrown when an invalid key is found in a legacy translation file - */ -class InvalidLegacyTranslationKeyException extends \Exception -{ - /** - * @var string The invalid key - */ - private $key = ''; - - /** - * @param string $missingElement The missing element - * @param string $key The offending key - * - * @return InvalidLegacyTranslationKeyException - */ - public static function missingElementFromKey($missingElement, $key) - { - $instance = new self( - sprintf('Invalid key in legacy translation file: "%s" (missing %s)', $key, $missingElement) - ); - $instance->setKey($key); - - return $instance; - } - - /** - * @return string - */ - public function getKey() - { - return $this->key; - } - - /** - * @param string $key - */ - private function setKey($key) - { - $this->key = $key; - } -} diff --git a/src/PrestaShopBundle/Translation/Exception/LegacyFileFormattingException.php b/src/PrestaShopBundle/Translation/Exception/LegacyFileFormattingException.php deleted file mode 100644 index fb631499..00000000 --- a/src/PrestaShopBundle/Translation/Exception/LegacyFileFormattingException.php +++ /dev/null @@ -1,53 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Exception; - -use Symfony\Component\Translation\Exception\InvalidResourceException; - -/** - * Will be thrown if a legacy file for a locale is found, but invalid. - */ -final class LegacyFileFormattingException extends InvalidResourceException -{ - /** - * @param string $filePath the expected file path of the translations - * @param string $locale the translation locale - * - * @return self - */ - public static function fileIsInvalid($filePath, $locale) - { - $exceptionMessage = sprintf( - 'The locale "%s" is not supported, because we have found an invalid file in the module. - Have you updated the file "%s" manually?', - $locale, - $filePath - ); - - return new self($exceptionMessage); - } -} diff --git a/src/PrestaShopBundle/Translation/Exception/UnsupportedLocaleException.php b/src/PrestaShopBundle/Translation/Exception/UnsupportedLocaleException.php deleted file mode 100644 index 87a52802..00000000 --- a/src/PrestaShopBundle/Translation/Exception/UnsupportedLocaleException.php +++ /dev/null @@ -1,68 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Exception; - -use Symfony\Component\Translation\Exception\NotFoundResourceException; - -/** - * Will be thrown if a locale is not supported in Legacy format - */ -final class UnsupportedLocaleException extends NotFoundResourceException -{ - /** - * @param string $filePath the expected file path of the translations - * @param string $locale the translation locale - * - * @return self - */ - public static function fileNotFound($filePath, $locale) - { - $exceptionMessage = sprintf( - 'The locale "%s" is not supported, because we can\'t find the related file in the module: - have you created the file "%s"?', - $locale, - $filePath - ); - - return new self($exceptionMessage); - } - - /** - * @param string $locale the translation locale - * - * @return self - */ - public static function invalidLocale($locale) - { - $exceptionMessage = sprintf( - 'The provided locale `%s` is invalid.', - $locale - ); - - return new self($exceptionMessage); - } -} diff --git a/src/PrestaShopBundle/Translation/Exception/UnsupportedModuleException.php b/src/PrestaShopBundle/Translation/Exception/UnsupportedModuleException.php deleted file mode 100644 index e836ee27..00000000 --- a/src/PrestaShopBundle/Translation/Exception/UnsupportedModuleException.php +++ /dev/null @@ -1,50 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Exception; - -use Symfony\Component\Translation\Exception\NotFoundResourceException; - -/** - * Will be thrown if a module name is required by a provider and not set. - */ -final class UnsupportedModuleException extends NotFoundResourceException -{ - /** - * @param string $providerIdentifier the provider identifier - * - * @return self - */ - public static function moduleNotProvided($providerIdentifier) - { - $exceptionMessage = sprintf( - 'The translation provider with the identifier "%s" require a module to be set.', - $providerIdentifier - ); - - return new self($exceptionMessage); - } -} diff --git a/src/PrestaShopBundle/Translation/Exporter/ThemeExporter.php b/src/PrestaShopBundle/Translation/Exporter/ThemeExporter.php deleted file mode 100644 index 11ff4f19..00000000 --- a/src/PrestaShopBundle/Translation/Exporter/ThemeExporter.php +++ /dev/null @@ -1,410 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Exporter; - -use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeRepository; -use PrestaShop\TranslationToolsBundle\Translation\Dumper\XliffFileDumper; -use PrestaShop\TranslationToolsBundle\Translation\Extractor\Util\Flattenizer; -use PrestaShopBundle\Translation\Extractor\ThemeExtractor; -use PrestaShopBundle\Translation\Provider\ThemeProvider; -use PrestaShopBundle\Utils\ZipManager; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Translation\MessageCatalogue; - -class ThemeExporter -{ - /** - * @var ThemeExtractor the theme extractor - */ - private $themeExtractor; - - /** - * @var ThemeProvider the theme provider - */ - private $themeProvider; - - /** - * @var ZipManager the zip manager - */ - private $zipManager; - - /** - * @var ThemeRepository the theme repository - */ - private $themeRepository; - - /** - * @var XliffFileDumper the Xliff dumper - */ - private $dumper; - - /** - * @var Filesystem the Filesystem - */ - private $filesystem; - - /** - * @var string the cache directory path - */ - public $cacheDir; - - /** - * @var string the export directory path - */ - public $exportDir; - - public function __construct( - ThemeExtractor $themeExtractor, - ThemeProvider $themeProvider, - ThemeRepository $themeRepository, - XliffFileDumper $dumper, - ZipManager $zipManager, - Filesystem $filesystem - ) { - $this->themeExtractor = $themeExtractor; - $this->themeExtractor - ->setThemeProvider($themeProvider); - - $this->themeProvider = $themeProvider; - $this->themeRepository = $themeRepository; - $this->dumper = $dumper; - $this->zipManager = $zipManager; - $this->filesystem = $filesystem; - } - - /** - * @param string $themeName - * @param string $locale - * @param bool $rootDir - * - * @return string - */ - public function createZipArchive($themeName, $locale, $rootDir = false) - { - $archiveParentDirectory = $this->exportCatalogues($themeName, $locale, $rootDir); - $zipFilename = $this->makeZipFilename($themeName, $locale); - $this->zipManager->createArchive($zipFilename, $archiveParentDirectory); - - return $zipFilename; - } - - /** - * @param string $themeName - * @param string $locale - * @param bool $rootDir - * - * @return string - */ - public function exportCatalogues($themeName, $locale, $rootDir = false) - { - $this->themeProvider->setLocale($locale); - $this->themeProvider->setThemeName($themeName); - - $mergedTranslations = $this->getCatalogueExtractedFromTemplates($themeName, $locale, $rootDir); - - try { - $themeCatalogue = $this->themeProvider->getThemeCatalogue(); - } catch (\Exception $exception) { - $themeCatalogue = new MessageCatalogue($locale, []); - } - $databaseCatalogue = $this->themeProvider->getDatabaseCatalogue($themeName); - $databaseCatalogue = $this->addLocaleToDomain($locale, $databaseCatalogue); - - $mergedTranslations->addCatalogue($themeCatalogue); - $mergedTranslations->addCatalogue($databaseCatalogue); - - $this->updateCatalogueMetadata($mergedTranslations); - - $archiveParentDirectory = $this->makeArchiveParentDirectory($themeName, $locale); - - if ($this->ensureFileBelongsToExportDirectory($archiveParentDirectory)) { - // Clean up previously exported archives - $this->filesystem->remove($archiveParentDirectory); - } - - $this->filesystem->mkdir($archiveParentDirectory); - - $this->dumper->dump($mergedTranslations, [ - 'path' => $archiveParentDirectory, - 'default_locale' => $locale, - 'root_dir' => $rootDir, - ]); - - $this->renameCatalogues($locale, $archiveParentDirectory); - - return $archiveParentDirectory; - } - - /** - * @param string $exportDir - */ - public function setExportDir($exportDir) - { - $this->exportDir = str_replace('/export', DIRECTORY_SEPARATOR . 'export', $exportDir); - } - - /** - * @param string $filePath - * - * @return bool - * - * @throws \Exception - */ - protected function ensureFileBelongsToExportDirectory($filePath) - { - if (!$this->filesystem->exists($filePath)) { - return false; - } - - $validFileLocation = substr(realpath($filePath), 0, strlen(realpath($this->exportDir))) === realpath($this->exportDir); - - if (!$validFileLocation) { - throw new \Exception('Invalid file location. This file should belong to the export directory'); - } - - return $validFileLocation; - } - - /** - * @param string $themeName - * @param string $locale - * @param bool $rootDir - * - * @return \Symfony\Component\Translation\MessageCatalogue - */ - protected function getCatalogueExtractedFromTemplates($themeName, $locale, $rootDir = false) - { - $tmpFolderPath = $this->getTemporaryExtractionFolder($themeName); - $folderPath = $this->getFlattenizationFolder($themeName); - - $this->filesystem->remove($folderPath); - $this->filesystem->remove($tmpFolderPath); - - $this->filesystem->mkdir($folderPath); - $this->filesystem->mkdir($tmpFolderPath); - - $theme = $this->themeRepository->getInstanceByName($themeName); - $this->themeExtractor - ->setOutputPath($tmpFolderPath) - ->extract($theme, $locale, $rootDir); - - Flattenizer::flatten($tmpFolderPath . DIRECTORY_SEPARATOR . $locale, $folderPath . DIRECTORY_SEPARATOR . $locale, $locale); - - return $this->themeProvider->getCatalogueFromPaths($folderPath, $locale, '*'); - } - - /** - * @param string $locale - * @param string $archiveParentDirectory - */ - protected function renameCatalogues($locale, $archiveParentDirectory) - { - $finder = Finder::create(); - - foreach ($finder->in($archiveParentDirectory . DIRECTORY_SEPARATOR . $locale)->files() as $file) { - $parentDirectoryParts = explode(DIRECTORY_SEPARATOR, dirname($file)); - $destinationFilenameParts = [ - $archiveParentDirectory, - $parentDirectoryParts[count($parentDirectoryParts) - 1] . '.' . $locale . '.xlf', - ]; - $destinationFilename = implode(DIRECTORY_SEPARATOR, $destinationFilenameParts); - if ($this->filesystem->exists($destinationFilename)) { - $this->filesystem->remove($destinationFilename); - } - $this->filesystem->rename($file->getPathname(), $destinationFilename); - } - - $this->filesystem->remove($archiveParentDirectory . DIRECTORY_SEPARATOR . $locale); - } - - /** - * @param string $themeName - */ - public function cleanArtifacts($themeName) - { - $this->filesystem->remove($this->getFlattenizationFolder($themeName)); - $this->filesystem->remove($this->getTemporaryExtractionFolder($themeName)); - } - - /** - * @param string $themeName - * - * @return string - */ - protected function getTemporaryExtractionFolder($themeName) - { - return $this->cacheDir . DIRECTORY_SEPARATOR . $themeName . '-tmp'; - } - - /** - * @param string $themeName - * - * @return string - */ - protected function getFlattenizationFolder($themeName) - { - return $this->cacheDir . DIRECTORY_SEPARATOR . $themeName; - } - - /** - * @param string $themeName - * - * @return string - */ - protected function getExportDir($themeName) - { - return $this->exportDir . DIRECTORY_SEPARATOR . $themeName; - } - - /** - * @param string $themeName - * @param string $locale - * - * @return string - */ - protected function makeZipFilename($themeName, $locale) - { - if (!file_exists($this->exportDir)) { - mkdir($this->exportDir); - } - - $zipFilenameParts = [ - $this->exportDir, - $themeName, - $locale, - $themeName . '.' . $locale . '.zip', - ]; - - return implode(DIRECTORY_SEPARATOR, $zipFilenameParts); - } - - /** - * @param string $themeName - * @param string $locale - * - * @return string - * - * @throws \Exception - */ - protected function makeArchiveParentDirectory($themeName, $locale) - { - $zipFilename = $this->makeZipFilename($themeName, $locale); - - return dirname($zipFilename); - } - - /** - * @param MessageCatalogue $catalogue - */ - protected function updateCatalogueMetadata(MessageCatalogue $catalogue) - { - foreach ($catalogue->all() as $domain => $messages) { - $this->ensureCatalogueHasRequiredMetadata($catalogue, $messages, $domain); - } - } - - /** - * @param MessageCatalogue $catalogue - * @param array $messages - * @param string $domain - */ - protected function ensureCatalogueHasRequiredMetadata( - MessageCatalogue $catalogue, - array $messages, - $domain - ) { - foreach (array_keys($messages) as $id) { - $metadata = $catalogue->getMetadata($id, $domain); - if ($this->shouldAddFileMetadata($metadata)) { - $catalogue->setMetadata($id, $this->parseMetadataNotes($metadata), $domain); - } - } - } - - /** - * @param array|null $metadata - * - * @return bool - */ - protected function metadataContainNotes(array $metadata = null) - { - return null !== $metadata && array_key_exists('notes', $metadata) && is_array($metadata['notes']) && - array_key_exists(0, $metadata['notes']) && is_array($metadata['notes'][0]) && - array_key_exists('content', $metadata['notes'][0]); - } - - /** - * @param array|null $metadata - * - * @return bool - */ - protected function shouldAddFileMetadata(array $metadata = null) - { - return null === $metadata || !array_key_exists('file', $metadata); - } - - /** - * @param string $locale - * @param MessageCatalogue $sourceCatalogue - * - * @return MessageCatalogue - */ - protected function addLocaleToDomain($locale, MessageCatalogue $sourceCatalogue) - { - $catalogue = new MessageCatalogue($locale, []); - foreach ($sourceCatalogue->all() as $domain => $messages) { - $catalogue->add($messages, $domain . '.' . $locale); - } - - return $catalogue; - } - - /** - * @param array|null $metadata - * - * @return array - */ - protected function parseMetadataNotes(array $metadata = null) - { - $defaultMetadata = ['file' => '', 'line' => '']; - - if (!$this->metadataContainNotes($metadata)) { - return $defaultMetadata; - } - - $notes = $metadata['notes'][0]['content']; - if (1 !== preg_match('/(?\S+):(?\S+)/m', $notes, $matches)) { - return $defaultMetadata; - } - - return [ - 'file' => $matches['file'], - 'line' => $matches['line'], - ]; - } -} diff --git a/src/PrestaShopBundle/Translation/Extractor/LegacyModuleExtractor.php b/src/PrestaShopBundle/Translation/Extractor/LegacyModuleExtractor.php deleted file mode 100644 index 612e8af5..00000000 --- a/src/PrestaShopBundle/Translation/Extractor/LegacyModuleExtractor.php +++ /dev/null @@ -1,127 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Extractor; - -use PrestaShop\TranslationToolsBundle\Translation\Helper\DomainHelper; -use Symfony\Component\Translation\Extractor\ExtractorInterface; -use Symfony\Component\Translation\MessageCatalogue; - -/** - * Able to convert old translation files (in translations/es.php) into - * Symfony MessageCatalogue objects. - */ -final class LegacyModuleExtractor implements LegacyModuleExtractorInterface -{ - /** - * @var ExtractorInterface the PHP Code extractor - */ - private $phpExtractor; - - /** - * @var ExtractorInterface the Smarty Code extractor - */ - private $smartyExtractor; - - /** - * @var ExtractorInterface the Twig Code extractor - */ - private $twigExtractor; - - /** - * @var string the "modules" directory path - */ - private $modulesDirectory; - - /** - * @param ExtractorInterface $phpExtractor - * @param ExtractorInterface $smartyExtractor - * @param ExtractorInterface $twigExtractor - * @param string $modulesDirectory - */ - public function __construct( - ExtractorInterface $phpExtractor, - ExtractorInterface $smartyExtractor, - ExtractorInterface $twigExtractor, - $modulesDirectory - ) { - $this->phpExtractor = $phpExtractor; - $this->smartyExtractor = $smartyExtractor; - $this->twigExtractor = $twigExtractor; - $this->modulesDirectory = $modulesDirectory; - } - - /** - * {@inheritdoc} - * - * WARNING: The domains in the returned catalogue are dot-separated - */ - public function extract($moduleName, $locale) - { - $extractedCatalogue = new MessageCatalogue($locale); - - $this->phpExtractor->extract($this->modulesDirectory . '/' . $moduleName, $extractedCatalogue); - $extractedCatalogue = $this->postprocessPhpCatalogue($extractedCatalogue, $moduleName); - - $this->smartyExtractor->extract($this->modulesDirectory . '/' . $moduleName, $extractedCatalogue); - $this->twigExtractor->extract($this->modulesDirectory . '/' . $moduleName, $extractedCatalogue); - - return $extractedCatalogue; - } - - /** - * Modules usually don't use domain names when calling the l() function in PHP files. - * Therefore, the PHP extractor will stores those calls in the default domain named "messages". - * This process moves all wordings in the "messages" domain to the inferred module domain. - * - * @param MessageCatalogue $extractedCatalogue - * @param string $moduleName - * - * @return MessageCatalogue - */ - private function postprocessPhpCatalogue(MessageCatalogue $extractedCatalogue, $moduleName) - { - $defaultDomain = 'messages'; - - if (!in_array($defaultDomain, $extractedCatalogue->getDomains())) { - return $extractedCatalogue; - } - - $newDomain = DomainHelper::buildModuleDomainFromLegacySource($moduleName, ''); - - $allWordings = $extractedCatalogue->all(); - - // move default domain into the new domain (avoiding to overwrite existing translations) - $allWordings[$newDomain] = (isset($allWordings[$newDomain])) - ? array_merge($allWordings[$newDomain], $allWordings[$defaultDomain]) - : $allWordings[$defaultDomain]; - - unset($allWordings[$defaultDomain]); - - return new MessageCatalogue($extractedCatalogue->getLocale(), $allWordings); - } -} diff --git a/src/PrestaShopBundle/Translation/Extractor/LegacyModuleExtractorInterface.php b/src/PrestaShopBundle/Translation/Extractor/LegacyModuleExtractorInterface.php deleted file mode 100644 index a3825896..00000000 --- a/src/PrestaShopBundle/Translation/Extractor/LegacyModuleExtractorInterface.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Extractor; - -use Symfony\Component\Translation\MessageCatalogueInterface; - -/** - * Parse code content of module, searching for l() calls and retrieve - * a Message Catalogue with all the keys and translations. - */ -interface LegacyModuleExtractorInterface -{ - /** - * Extracts the wordings from source code and returns the translation messages. - * Note that domain names will contain separating dots. - * - * @param string $moduleName - * @param string $locale The locale used for the message catalogue. Note that wordings won't be translated in this locale. - * - * @return MessageCatalogueInterface - */ - public function extract($moduleName, $locale); -} diff --git a/src/PrestaShopBundle/Translation/Extractor/ThemeExtractor.php b/src/PrestaShopBundle/Translation/Extractor/ThemeExtractor.php deleted file mode 100644 index 3a27dcc6..00000000 --- a/src/PrestaShopBundle/Translation/Extractor/ThemeExtractor.php +++ /dev/null @@ -1,290 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Extractor; - -use PrestaShop\PrestaShop\Core\Addon\Theme\Theme; -use PrestaShop\TranslationToolsBundle\Translation\Dumper\XliffFileDumper; -use PrestaShop\TranslationToolsBundle\Translation\Extractor\SmartyExtractor; -use PrestaShopBundle\Translation\Provider\ThemeProvider; -use Symfony\Component\Translation\Dumper\DumperInterface; -use Symfony\Component\Translation\Dumper\FileDumper; -use Symfony\Component\Translation\MessageCatalogue; - -/** - * Extract all theme translations from Theme templates. - * - * xliff is the default file format, you can add custom File dumpers. - */ -class ThemeExtractor -{ - /** - * @var MessageCatalogue|null the Message catalogue - */ - private $catalog; - - /** - * @var array the list of Translation dumpers - */ - private $dumpers = []; - - /** - * @var string the format of extracted files - */ - private $format = 'xlf'; - - /** - * @var string the output path for extraction - */ - private $outputPath; - - /** - * @var SmartyExtractor the Smarty Extractor - */ - private $smartyExtractor; - - /** - * @var ThemeProvider the Theme Provider - */ - private $themeProvider; - - /** - * @var bool checks wether we should override the database with results or not - */ - private $overrideFromDatabase = false; - - public function __construct(SmartyExtractor $smartyExtractor) - { - $this->smartyExtractor = $smartyExtractor; - $this->dumpers[] = new XliffFileDumper(); - } - - /** - * @param ThemeProvider $themeProvider - * - * @return $this - */ - public function setThemeProvider(ThemeProvider $themeProvider) - { - $this->themeProvider = $themeProvider; - - return $this; - } - - /** - * @param Theme $theme - * @param string $locale - * @param bool $rootDir - * - * @return mixed - * - * @throws \Exception - */ - public function extract(Theme $theme, $locale = 'en-US', $rootDir = false) - { - $this->catalog = new MessageCatalogue($locale); - // remove the last "/" - $themeDirectory = substr($theme->getDirectory(), 0, -1); - - $options = [ - 'path' => $themeDirectory, - 'default_locale' => $locale, - 'root_dir' => $rootDir, - ]; - $this->smartyExtractor->extract($themeDirectory, $this->catalog); - - $this->overrideFromDefaultCatalog($locale, $this->catalog); - - if ($this->overrideFromDatabase) { - $this->overrideFromDatabase($theme->getName(), $locale, $this->catalog); - } - - foreach ($this->dumpers as $dumper) { - if ($this->format === $dumper->getExtension()) { - if (null !== $this->outputPath) { - $options['path'] = $this->outputPath; - } - - return $dumper->dump($this->catalog, $options); - } - } - - throw new \LogicException(sprintf('The format %s is not supported.', $this->format)); - } - - /** - * Add default catalogue in this &$catalogue when the translation exists. - * - * @param string $locale - * @param MessageCatalogue $catalogue - */ - private function overrideFromDefaultCatalog($locale, &$catalogue) - { - $defaultCatalogue = $this->themeProvider - ->setLocale($locale) - ->getDefaultCatalogue(); - - if (empty($defaultCatalogue)) { - return; - } - - $defaultCatalogue = $defaultCatalogue->all(); - - if (empty($defaultCatalogue)) { - return; - } - - $defaultDomainsCatalogue = $catalogue->getDomains(); - - foreach ($defaultCatalogue as $domain => $translation) { - // AdminCatalogFeature.fr-FR to AdminCatalogFeature - $domain = str_replace('.' . $locale, '', $domain); - - // AdminCatalogFeature to Admin.Catalog.Feature - $domain = implode('.', preg_split('/(?=[A-Z])/', $domain, -1, PREG_SPLIT_NO_EMPTY)); - - if (in_array($domain, $defaultDomainsCatalogue, true)) { - foreach ($translation as $key => $trans) { - if ($catalogue->has($key, $domain)) { - $catalogue->set($key, $trans, $domain); - } - } - } - } - } - - /** - * Add database catalogue in this &$catalogue. - * - * @param string $themeName - * @param string $locale - * @param MessageCatalogue $catalogue - * - * @throws \Exception - */ - private function overrideFromDatabase($themeName, $locale, &$catalogue) - { - if (null === $this->themeProvider) { - throw new \Exception('Theme provider is required.'); - } - - $databaseCatalogue = $this->themeProvider - ->setLocale($locale) - ->setThemeName($themeName) - ->getDatabaseCatalogue(); - - $catalogue->addCatalogue($databaseCatalogue); - } - - /** - * @param FileDumper $dumper - * - * @return $this - */ - public function addDumper(FileDumper $dumper) - { - $this->dumpers[] = $dumper; - - return $this; - } - - /** - * @return DumperInterface[] - */ - public function getDumpers() - { - return $this->dumpers; - } - - /** - * @param string $format - * - * @return $this - */ - public function setFormat($format) - { - $this->format = $format; - - return $this; - } - - /** - * @return string - */ - public function getFormat() - { - return $this->format; - } - - /** - * @param $outputPath - * - * @return $this - */ - public function setOutputPath($outputPath) - { - $this->outputPath = $outputPath; - - return $this; - } - - /** - * @return string - */ - public function getOutputPath() - { - return $this->outputPath; - } - - /** - * @return MessageCatalogue|null - */ - public function getCatalog() - { - return $this->catalog; - } - - /** - * @return $this - */ - public function disableOverridingFromDatabase() - { - $this->overrideFromDatabase = false; - - return $this; - } - - /** - * @return $this - */ - public function enableOverridingFromDatabase() - { - $this->overrideFromDatabase = true; - - return $this; - } -} diff --git a/src/PrestaShopBundle/Translation/Factory/ProviderNotFoundException.php b/src/PrestaShopBundle/Translation/Factory/ProviderNotFoundException.php deleted file mode 100644 index 20e5de84..00000000 --- a/src/PrestaShopBundle/Translation/Factory/ProviderNotFoundException.php +++ /dev/null @@ -1,41 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Factory; - -use Exception; - -/** - * Thrown if no provider is found for the selected identifier. - */ -class ProviderNotFoundException extends Exception -{ - public function __construct($identifier) - { - parent::__construct(sprintf('The provider with the identifier %s is not found.', $identifier), 0, null); - } -} diff --git a/src/PrestaShopBundle/Translation/Factory/ThemeTranslationsFactory.php b/src/PrestaShopBundle/Translation/Factory/ThemeTranslationsFactory.php deleted file mode 100644 index 3d2159c3..00000000 --- a/src/PrestaShopBundle/Translation/Factory/ThemeTranslationsFactory.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Factory; - -use PrestaShopBundle\Translation\Provider\ThemeProvider; - -/** - * This class returns a collection of translations, using locale and identifier. - * - * But in this particular case, the identifier is the theme name. - * - * Returns MessageCatalogue object or Translation tree array. - */ -class ThemeTranslationsFactory extends TranslationsFactory -{ - /** - * @var ThemeProvider the theme provider - */ - private $themeProvider; - - public function __construct(ThemeProvider $themeProvider) - { - $this->themeProvider = $themeProvider; - } - - /** - * {@inheritdoc} - */ - public function createCatalogue($themeName, $locale = 'en_US') - { - return $this->themeProvider - ->setThemeName($themeName) - ->setLocale($locale) - ->getMessageCatalogue(); - } - - /** - * {@inheritdoc} - */ - public function createTranslationsArray($themeName, $locale = 'en_US', $theme = null, $search = null) - { - $this->themeProvider - ->setThemeName($themeName) - ->setLocale($locale) - ->synchronizeTheme(); - - $translations = $this->getFrontTranslationsForThemeAndLocale($themeName, $locale, $search); - - ksort($translations); - - return $translations; - } - - /** - * @param string $locale the catalogue locale - * @param string $domain the catalogue domain - * - * @return string - */ - protected function removeLocaleFromDomain($locale, $domain) - { - return str_replace('.' . $locale, '', $domain); - } - - /** - * @param string $themeName the theme name - * @param string $locale the catalogue locale - * @param string|null $search - * - * @throws ProviderNotFoundException - * - * @return array - */ - protected function getFrontTranslationsForThemeAndLocale($themeName, $locale, $search = null) - { - return parent::createTranslationsArray('theme', $locale, $themeName, $search); - } -} diff --git a/src/PrestaShopBundle/Translation/Factory/TranslationsFactory.php b/src/PrestaShopBundle/Translation/Factory/TranslationsFactory.php deleted file mode 100644 index 6306dd9c..00000000 --- a/src/PrestaShopBundle/Translation/Factory/TranslationsFactory.php +++ /dev/null @@ -1,82 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Factory; - -use PrestaShopBundle\Translation\Provider\AbstractProvider; -use PrestaShopBundle\Translation\View\TreeBuilder; - -/** - * This class returns a collection of translations, using a locale and an identifier. - * - * Returns MessageCatalogue object or Translation tree array. - */ -class TranslationsFactory implements TranslationsFactoryInterface -{ - /** - * @var array the list of translation providers - */ - private $providers = []; - - /** - * {@inheritdoc} - */ - public function createCatalogue($domainIdentifier, $locale = 'en_US') - { - foreach ($this->providers as $provider) { - if ($domainIdentifier === $provider->getIdentifier()) { - return $provider->setLocale($locale)->getMessageCatalogue(); - } - } - - throw new ProviderNotFoundException($domainIdentifier); - } - - /** - * {@inheritdoc} - */ - public function createTranslationsArray($domainIdentifier, $locale = self::DEFAULT_LOCALE, $theme = null, $search = null) - { - foreach ($this->providers as $provider) { - if ($domainIdentifier === $provider->getIdentifier()) { - $treeBuilder = new TreeBuilder($locale, $theme); - - return $treeBuilder->makeTranslationArray($provider, $search); - } - } - - throw new ProviderNotFoundException($domainIdentifier); - } - - /** - * @param AbstractProvider $provider - */ - public function addProvider(AbstractProvider $provider) - { - $this->providers[] = $provider; - } -} diff --git a/src/PrestaShopBundle/Translation/Factory/TranslationsFactoryInterface.php b/src/PrestaShopBundle/Translation/Factory/TranslationsFactoryInterface.php deleted file mode 100644 index a3fe9fbd..00000000 --- a/src/PrestaShopBundle/Translation/Factory/TranslationsFactoryInterface.php +++ /dev/null @@ -1,61 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Factory; - -use Symfony\Component\Translation\MessageCatalogueInterface; - -interface TranslationsFactoryInterface -{ - const DEFAULT_LOCALE = 'en_US'; - - /** - * Generates extract of global Catalogue, using domain's identifiers. - * - * @param string $identifier Domain identifier - * @param string $locale Locale identifier - * - * @throws ProviderNotFoundException - * - * @return MessageCatalogueInterface - */ - public function createCatalogue($identifier, $locale = self::DEFAULT_LOCALE); - - /** - * Generates Translation tree in Back Office. - * - * @param string $domainIdentifier Domain identifier - * @param string $locale Locale identifier - * @param null $theme - * @param null $search - * - * @throws ProviderNotFoundException - * - * @return array Translation tree structure - */ - public function createTranslationsArray($domainIdentifier, $locale = self::DEFAULT_LOCALE, $theme = null, $search = null); -} diff --git a/src/PrestaShopBundle/Translation/Loader/DatabaseTranslationLoader.php b/src/PrestaShopBundle/Translation/Loader/DatabaseTranslationLoader.php deleted file mode 100644 index 6d4e85c8..00000000 --- a/src/PrestaShopBundle/Translation/Loader/DatabaseTranslationLoader.php +++ /dev/null @@ -1,130 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Loader; - -use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\QueryBuilder; -use PrestaShopBundle\Entity\Lang; -use PrestaShopBundle\Entity\Translation; -use Symfony\Component\Translation\Loader\LoaderInterface; -use Symfony\Component\Translation\MessageCatalogue; - -class DatabaseTranslationLoader implements LoaderInterface -{ - /** @var EntityManagerInterface */ - protected $entityManager; - - /** - * @param EntityManagerInterface $entityManager - */ - public function __construct(EntityManagerInterface $entityManager) - { - $this->entityManager = $entityManager; - } - - /** - * {@inheritdoc} - * - * @todo: this method doesn't match the interface - */ - public function load($resource, $locale, $domain = 'messages', $theme = null) - { - static $langs = []; - $catalogue = new MessageCatalogue($locale); - - // do not try and load translations for a locale that cannot be saved to DB anyway - if ($locale === 'default') { - return $catalogue; - } - - if (!array_key_exists($locale, $langs)) { - $langs[$locale] = $this->entityManager - ->getRepository('PrestaShopBundle:Lang') - ->findOneByLocale($locale); - } - - $translationRepository = $this->entityManager - ->getRepository('PrestaShopBundle:Translation'); - - $queryBuilder = $translationRepository->createQueryBuilder('t'); - - $this->addLangConstraint($queryBuilder, $langs[$locale]); - - $this->addThemeConstraint($queryBuilder, $theme); - - $this->addDomainConstraint($queryBuilder, $domain); - - $translations = $queryBuilder - ->getQuery() - ->getResult(); - - /** @var Translation $translation */ - foreach ($translations as $translation) { - $catalogue->set($translation->getKey(), $translation->getTranslation(), $translation->getDomain()); - } - - return $catalogue; - } - - /** - * @param QueryBuilder $queryBuilder - * @param Lang $currentLang - */ - private function addLangConstraint(QueryBuilder $queryBuilder, Lang $currentLang) - { - $queryBuilder->andWhere('t.lang =:lang') - ->setParameter('lang', $currentLang); - } - - /** - * @param QueryBuilder $queryBuilder - * @param string|null $theme - */ - private function addThemeConstraint(QueryBuilder $queryBuilder, $theme) - { - if (null === $theme) { - $queryBuilder->andWhere('t.theme IS NULL'); - } else { - $queryBuilder - ->andWhere('t.theme = :theme') - ->setParameter('theme', $theme); - } - } - - /** - * @param QueryBuilder $queryBuilder - * @param string $domain - */ - private function addDomainConstraint(QueryBuilder $queryBuilder, $domain) - { - if ($domain !== '*') { - $queryBuilder->andWhere('REGEXP(t.domain, :domain) = true') - ->setParameter('domain', $domain); - } - } -} diff --git a/src/PrestaShopBundle/Translation/Loader/LegacyFileLoader.php b/src/PrestaShopBundle/Translation/Loader/LegacyFileLoader.php deleted file mode 100644 index f2d83754..00000000 --- a/src/PrestaShopBundle/Translation/Loader/LegacyFileLoader.php +++ /dev/null @@ -1,98 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Loader; - -use PrestaShop\TranslationToolsBundle\Translation\Helper\DomainHelper; -use PrestaShopBundle\Translation\DomainNormalizer; -use Symfony\Component\Translation\Loader\LoaderInterface; -use Symfony\Component\Translation\MessageCatalogue; - -/** - * Able to convert old translation files (in translations/es.php) into - * Symfony MessageCatalogue objects. - */ -final class LegacyFileLoader implements LoaderInterface -{ - /** - * @var LegacyFileReader - */ - private $fileReader; - - /** - * @var DomainNormalizer - */ - private $domainNormalizer; - - /** - * @param LegacyFileReader $fileReader - */ - public function __construct(LegacyFileReader $fileReader) - { - $this->fileReader = $fileReader; - $this->domainNormalizer = new DomainNormalizer(); - } - - /** - * {@inheritdoc} - * - * Note that parameter "domain" is useless, as domain is inferred from source files - * - * @throws \PrestaShopBundle\Translation\Exception\InvalidLegacyTranslationKeyException - */ - public function load($path, $locale, $domain = 'messages') - { - $catalogue = new MessageCatalogue($locale); - - $tokens = $this->fileReader->load($path, $locale); - - foreach ($tokens as $translationKey => $translationValue) { - $parsed = LegacyTranslationKey::buildFromString($translationKey); - $id = $parsed->getHash(); - $catalogue->set($id, $translationValue, $this->buildDomain($parsed)); - } - - return $catalogue; - } - - /** - * Builds the domain using information in the translation key - * - * @param LegacyTranslationKey $translationKey - * - * @return string - */ - private function buildDomain(LegacyTranslationKey $translationKey) - { - $newDomain = DomainHelper::buildModuleDomainFromLegacySource( - $translationKey->getModule(), - $translationKey->getSource() - ); - - return $this->domainNormalizer->normalize($newDomain); - } -} diff --git a/src/PrestaShopBundle/Translation/Loader/LegacyFileReader.php b/src/PrestaShopBundle/Translation/Loader/LegacyFileReader.php deleted file mode 100644 index 45d2d27b..00000000 --- a/src/PrestaShopBundle/Translation/Loader/LegacyFileReader.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Loader; - -use PrestaShop\PrestaShop\Core\Translation\Locale\Converter; -use PrestaShopBundle\Translation\Exception\UnsupportedLocaleException; - -/** - * Reads legacy locale files - */ -class LegacyFileReader -{ - /** - * @var Converter Converts IETF language tags into two-letter language code - */ - private $localeConverter; - - public function __construct(Converter $converter) - { - $this->localeConverter = $converter; - } - - /** - * Loads legacy translations from a file - * - * @param string $path Path where the locale file should be looked up - * @param string $locale IETF language tag - * - * @return array Translation tokens - */ - public function load($path, $locale) - { - // Each legacy file declare this variable to store the translations - $_MODULE = []; - - $shopLocale = $this->localeConverter->toLegacyLocale($locale); - - $filePath = $path . "$shopLocale.php"; - - if (!file_exists($filePath)) { - throw UnsupportedLocaleException::fileNotFound($filePath, $locale); - } - - // Load a global array $_MODULE - include_once $filePath; - - return $_MODULE; - } -} diff --git a/src/PrestaShopBundle/Translation/Loader/LegacyTranslationKey.php b/src/PrestaShopBundle/Translation/Loader/LegacyTranslationKey.php deleted file mode 100644 index ffe5ed13..00000000 --- a/src/PrestaShopBundle/Translation/Loader/LegacyTranslationKey.php +++ /dev/null @@ -1,128 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Loader; - -use PrestaShopBundle\Translation\Exception\InvalidLegacyTranslationKeyException; - -/** - * Parses a legacy translation key and returns its data - */ -class LegacyTranslationKey -{ - /** - * @var string the expected format of a legacy translation key - */ - const LEGACY_TRANSLATION_FORMAT = '#\<\{(?[\w-]+)\}(?[\w-]+)\>(?[\.\w_-]+)_(?[0-9a-f]+)#'; - - /** - * @var string - */ - private $module; - /** - * @var string - */ - private $theme; - /** - * @var string - */ - private $source; - - /** - * @var string - */ - private $hash; - - /** - * Parses a legacy translation key and returns its data - * - * @param string $key Legacy translation key - * - * @return LegacyTranslationKey - * - * @throws InvalidLegacyTranslationKeyException - */ - public static function buildFromString($key) - { - $matches = []; - preg_match(self::LEGACY_TRANSLATION_FORMAT, $key, $matches); - - foreach (['module', 'theme', 'source', 'hash'] as $item) { - if (!isset($matches[$item])) { - throw InvalidLegacyTranslationKeyException::missingElementFromKey($item, $key); - } - } - - return new self($matches['module'], $matches['theme'], $matches['source'], $matches['hash']); - } - - /** - * @param string $module - * @param string $theme - * @param string $source - * @param string $hash - */ - public function __construct($module, $theme, $source, $hash) - { - $this->module = $module; - $this->theme = $theme; - $this->source = $source; - $this->hash = $hash; - } - - /** - * @return string - */ - public function getModule() - { - return $this->module; - } - - /** - * @return string - */ - public function getTheme() - { - return $this->theme; - } - - /** - * @return string - */ - public function getSource() - { - return $this->source; - } - - /** - * @return string - */ - public function getHash() - { - return $this->hash; - } -} diff --git a/src/PrestaShopBundle/Translation/Loader/SqlTranslationLoader.php b/src/PrestaShopBundle/Translation/Loader/SqlTranslationLoader.php deleted file mode 100644 index 685d3ef9..00000000 --- a/src/PrestaShopBundle/Translation/Loader/SqlTranslationLoader.php +++ /dev/null @@ -1,107 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Loader; - -use Db; -use PrestaShop\PrestaShop\Core\Addon\Theme\Theme; -use Symfony\Component\Translation\Exception\NotFoundResourceException; -use Symfony\Component\Translation\Loader\LoaderInterface; -use Symfony\Component\Translation\MessageCatalogue; -use Symfony\Component\Translation\MessageCatalogueInterface; - -class SqlTranslationLoader implements LoaderInterface -{ - /** - * @var Theme the theme - */ - protected $theme; - - /** - * @param Theme $theme the theme - * - * @return $this - */ - public function setTheme(Theme $theme) - { - $this->theme = $theme; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function load($resource, $locale, $domain = 'messages') - { - static $localeResults = []; - - if (!array_key_exists($locale, $localeResults)) { - $locale = Db::getInstance()->escape($locale, false, true); - - $localeResults[$locale] = Db::getInstance()->getRow( - 'SELECT `id_lang` - FROM `' . _DB_PREFIX_ . 'lang` - WHERE `locale` = "' . $locale . '"' - ); - } - - if (empty($localeResults[$locale])) { - throw new NotFoundResourceException(sprintf('Language not found in database: %s', $locale)); - } - - $selectTranslationsQuery = ' - SELECT `key`, `translation`, `domain` - FROM `' . _DB_PREFIX_ . 'translation` - WHERE `id_lang` = ' . $localeResults[$locale]['id_lang']; - $translations = Db::getInstance()->executeS($selectTranslationsQuery) ?: []; - - $catalogue = new MessageCatalogue($locale); - $this->addTranslationsToCatalogue($translations, $catalogue); - - if (null !== $this->theme) { - $selectThemeTranslationsQuery = - $selectTranslationsQuery . "\n" . - "AND theme = '" . $this->theme->getName() . "'"; - $themeTranslations = Db::getInstance()->executeS($selectThemeTranslationsQuery) ?: []; - $this->addTranslationsToCatalogue($themeTranslations, $catalogue); - } - - return $catalogue; - } - - /** - * @param array $translations the list of translations - * @param MessageCatalogueInterface $catalogue the Message Catalogue - */ - protected function addTranslationsToCatalogue(array $translations, MessageCatalogueInterface $catalogue) - { - foreach ($translations as $translation) { - $catalogue->set($translation['key'], $translation['translation'], $translation['domain']); - } - } -} diff --git a/src/PrestaShopBundle/Translation/PrestaShopTranslatorTrait.php b/src/PrestaShopBundle/Translation/PrestaShopTranslatorTrait.php deleted file mode 100644 index 307611e5..00000000 --- a/src/PrestaShopBundle/Translation/PrestaShopTranslatorTrait.php +++ /dev/null @@ -1,208 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation; - -use PrestaShop\PrestaShop\Adapter\Localization\LegacyTranslator; -use Symfony\Component\Translation\Exception\InvalidArgumentException; - -trait PrestaShopTranslatorTrait -{ - public static $regexSprintfParams = '#(?:%%|%(?:[0-9]+\$)?[+-]?(?:[ 0]|\'.)?-?[0-9]*(?:\.[0-9]+)?[bcdeufFosxX])#'; - public static $regexClassicParams = '/%\w+%/'; - - /** - * Translates the given message. - * - * @param string $id The message id (may also be an object that can be cast to string) - * @param array $parameters An array of parameters for the message - * @param string|null $domain The domain for the message or null to use the default - * @param string|null $locale The locale or null to use the default - * - * @return string The translated string - * - * @throws InvalidArgumentException If the locale contains invalid characters - */ - public function trans($id, array $parameters = [], $domain = null, $locale = null) - { - if (isset($parameters['legacy'])) { - $legacy = $parameters['legacy']; - unset($parameters['legacy']); - } - - $translated = parent::trans($id, [], $this->normalizeDomain($domain), $locale); - - // @todo to remove after the legacy translation system has ben phased out - if ($this->shouldFallbackToLegacyModuleTranslation($id, $domain, $translated)) { - return $this->translateUsingLegacySystem($id, $parameters, $domain, $locale); - } - - if (isset($legacy) && 'htmlspecialchars' === $legacy) { - $translated = call_user_func($legacy, $translated, ENT_NOQUOTES); - } elseif (isset($legacy)) { - $translated = call_user_func($legacy, $translated); - } - - if (!empty($parameters) && $this->isSprintfString($id)) { - $translated = vsprintf($translated, $parameters); - } elseif (!empty($parameters)) { - $translated = strtr($translated, $parameters); - } - - return $translated; - } - - /** - * Performs a reverse search in the catalogue and returns the translation key if found. - * AVOID USING THIS, IT PROVIDES APPROXIMATE RESULTS. - * - * @param string $translated Translated string - * @param string $domain Translation domain - * @param string|null $locale Unused - * - * @return string The translation - * - * @deprecated This method should not be used and will be removed - */ - public function getSourceString($translated, $domain, $locale = null) - { - if (empty($domain)) { - return $translated; - } - - $domain = str_replace('.', '', $domain); - $contextCatalog = $this->getCatalogue()->all($domain); - - if ($untranslated = array_search($translated, $contextCatalog)) { - return $untranslated; - } - - return $translated; - } - - /** - * Translates the given choice message by choosing a translation according to a number. - * - * @param string $id The message id (may also be an object that can be cast to string) - * @param int $number The number to use to find the index of the message - * @param array $parameters An array of parameters for the message - * @param string|null $domain The domain for the message or null to use the default - * @param string|null $locale The locale or null to use the default - * - * @return string The translated string - * - * @throws InvalidArgumentException If the locale contains invalid characters - */ - public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null) - { - if (null !== $domain) { - $domain = str_replace('.', '', $domain); - } - - if (!$this->isSprintfString($id)) { - return parent::transChoice($id, $number, $parameters, $domain, $locale); - } - - return vsprintf(parent::transChoice($id, $number, [], $domain, $locale), $parameters); - } - - /** - * @param string $string - * - * @return bool - */ - final private function isSprintfString($string) - { - return (bool) preg_match_all(static::$regexSprintfParams, $string) - && !(bool) preg_match_all(static::$regexClassicParams, $string); - } - - /** - * Tries to translate the provided message using the legacy system - * - * @param string $message - * @param array $parameters - * @param string $domain - * @param string|null $locale - * - * @return mixed|string - * - * @throws \Exception - */ - private function translateUsingLegacySystem($message, array $parameters, $domain, $locale = null) - { - $domainParts = explode('.', $domain); - if (count($domainParts) < 2) { - throw new InvalidArgumentException(sprintf('Invalid domain: "%s"', $domain)); - } - - $moduleName = strtolower($domainParts[1]); - $sourceFile = (!empty($domainParts[2])) ? strtolower($domainParts[2]) : $moduleName; - - // translate using the legacy system WITHOUT fallback and escape to the new system (to avoid infinite loop) - return (new LegacyTranslator())->translate($moduleName, $message, $sourceFile, $parameters, false, $locale, false, false); - } - - /** - * Indicates if we should try and translate the provided wording using the legacy system. - * - * @param string $message Message to translate - * @param string $domain Translation domain - * @param string $translated Message after first translation attempt - * - * @return bool - */ - private function shouldFallbackToLegacyModuleTranslation($message, $domain, $translated) - { - return - $message === $translated - && 'Modules.' === substr($domain, 0, 8) - && ( - !method_exists($this, 'getCatalogue') - || !$this->getCatalogue()->has($message, $this->normalizeDomain($domain)) - ) - ; - } - - /** - * Returns the domain without separating dots - * - * @param string|null $domain Domain name - * - * @return string|null - */ - private function normalizeDomain($domain) - { - // remove up to two dots from the domain name - // (because legacy domain translations CAN have dots in the third part) - $normalizedDomain = (!empty($domain)) ? - (new DomainNormalizer())->normalize($domain) - : null; - - return $normalizedDomain; - } -} diff --git a/src/PrestaShopBundle/Translation/Provider/AbstractProvider.php b/src/PrestaShopBundle/Translation/Provider/AbstractProvider.php deleted file mode 100644 index 9eadf4f9..00000000 --- a/src/PrestaShopBundle/Translation/Provider/AbstractProvider.php +++ /dev/null @@ -1,273 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -use PrestaShop\PrestaShop\Core\Exception\FileNotFoundException; -use PrestaShop\PrestaShop\Core\Translation\Locale\Converter; -use Symfony\Component\Translation\Loader\LoaderInterface; -use Symfony\Component\Translation\MessageCatalogue; -use Symfony\Component\Translation\MessageCatalogueInterface; - -abstract class AbstractProvider implements ProviderInterface, XliffCatalogueInterface, DatabaseCatalogueInterface -{ - const DEFAULT_LOCALE = 'en-US'; - - /** - * @var LoaderInterface the loader interface - */ - private $databaseLoader; - - /** - * @var string the resource directory - */ - protected $resourceDirectory; - - /** - * @var string the Catalogue locale - */ - protected $locale; - - /** - * @var string the Catalogue domain - */ - protected $domain; - - public function __construct(LoaderInterface $databaseLoader, $resourceDirectory) - { - $this->databaseLoader = $databaseLoader; - $this->resourceDirectory = $resourceDirectory; - $this->locale = self::DEFAULT_LOCALE; - } - - /** - * {@inheritdoc} - */ - public function getDirectories() - { - return [$this->getResourceDirectory()]; - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return []; - } - - /** - * {@inheritdoc} - */ - public function getTranslationDomains() - { - return ['']; - } - - /** - * {@inheritdoc} - */ - public function getLocale() - { - return $this->locale; - } - - /** - * {@inheritdoc} - */ - public function setLocale($locale) - { - $this->locale = $locale; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setDomain($domain) - { - $this->domain = $domain; - - return $this; - } - - /** - * Get the PrestaShop locale from real locale. - * - * @return string The PrestaShop locale - * - * @deprecated since 1.7.6, to be removed in the next major - */ - public function getPrestaShopLocale() - { - @trigger_error( - '`AbstractProvider::getPrestaShopLocale` function is deprecated and will be removed in the next major', - E_USER_DEPRECATED - ); - - return Converter::toPrestaShopLocale($this->locale); - } - - /** - * {@inheritdoc} - */ - public function getMessageCatalogue() - { - $messageCatalogue = $this->getDefaultCatalogue(); - - $xlfCatalogue = $this->getXliffCatalogue(); - $messageCatalogue->addCatalogue($xlfCatalogue); - - $databaseCatalogue = $this->getDatabaseCatalogue(); - - // Merge database catalogue to xliff catalogue - $messageCatalogue->addCatalogue($databaseCatalogue); - - return $messageCatalogue; - } - - /** - * {@inheritdoc} - * - * @throws FileNotFoundException - */ - public function getDefaultCatalogue($empty = true) - { - $defaultCatalogue = new MessageCatalogue($this->locale); - - foreach ($this->getFilters() as $filter) { - $filteredCatalogue = $this->getCatalogueFromPaths( - [$this->getDefaultResourceDirectory()], - $this->locale, - $filter - ); - $defaultCatalogue->addCatalogue($filteredCatalogue); - } - - if ($empty && $this->locale !== self::DEFAULT_LOCALE) { - $defaultCatalogue = $this->emptyCatalogue($defaultCatalogue); - } - - return $defaultCatalogue; - } - - /** - * {@inheritdoc} - * - * @throws FileNotFoundException - */ - public function getXliffCatalogue() - { - $xlfCatalogue = new MessageCatalogue($this->locale); - - foreach ($this->getFilters() as $filter) { - $filteredCatalogue = $this->getCatalogueFromPaths( - $this->getDirectories(), - $this->locale, - $filter - ); - $xlfCatalogue->addCatalogue($filteredCatalogue); - } - - return $xlfCatalogue; - } - - /** - * Get the Catalogue from database only. - * - * @param null $theme - * - * @return MessageCatalogue A MessageCatalogue instance - */ - public function getDatabaseCatalogue($theme = null) - { - $databaseCatalogue = new MessageCatalogue($this->locale); - - foreach ($this->getTranslationDomains() as $translationDomain) { - $domainCatalogue = $this->getDatabaseLoader()->load(null, $this->locale, $translationDomain, $theme); - - if ($domainCatalogue instanceof MessageCatalogue) { - $databaseCatalogue->addCatalogue($domainCatalogue); - } - } - - return $databaseCatalogue; - } - - /** - * @return string Path to app/Resources/translations/{locale} - */ - public function getResourceDirectory() - { - return $this->resourceDirectory . DIRECTORY_SEPARATOR . $this->locale; - } - - /** - * @return LoaderInterface The database loader - */ - public function getDatabaseLoader() - { - return $this->databaseLoader; - } - - /** - * Empties out the catalogue by removing translations but leaving keys - * - * @param MessageCatalogueInterface $messageCatalogue - * - * @return MessageCatalogueInterface Empty the catalogue - */ - public function emptyCatalogue(MessageCatalogueInterface $messageCatalogue) - { - foreach ($messageCatalogue->all() as $domain => $messages) { - foreach (array_keys($messages) as $translationKey) { - $messageCatalogue->set($translationKey, '', $domain); - } - } - - return $messageCatalogue; - } - - /** - * @param array $paths a list of paths when we can look for translations - * @param string $locale the Symfony (not the PrestaShop one) locale - * @param string|null $pattern a regular expression - * - * @return MessageCatalogue - * - * @throws FileNotFoundException - */ - public function getCatalogueFromPaths($paths, $locale, $pattern = null) - { - return (new TranslationFinder())->getCatalogueFromPaths($paths, $locale, $pattern); - } - - /** - * {@inheritdoc} - */ - abstract public function getDefaultResourceDirectory(); -} diff --git a/src/PrestaShopBundle/Translation/Provider/BackOfficeProvider.php b/src/PrestaShopBundle/Translation/Provider/BackOfficeProvider.php deleted file mode 100644 index 40c2e1b2..00000000 --- a/src/PrestaShopBundle/Translation/Provider/BackOfficeProvider.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -/** - * Main translation provider of the Back Office - */ -class BackOfficeProvider extends AbstractProvider implements UseDefaultCatalogueInterface -{ - /** - * {@inheritdoc} - */ - public function getTranslationDomains() - { - return [ - '^Admin[A-Z]', - '^Modules[A-Z](.*)Admin', - ]; - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return [ - '#^Admin[A-Z]#', - '#^Modules[A-Z](.*)Admin#', - ]; - } - - /** - * {@inheritdoc} - */ - public function getIdentifier() - { - return 'back'; - } - - /** - * {@inheritdoc} - */ - public function getDefaultResourceDirectory() - { - return $this->resourceDirectory . DIRECTORY_SEPARATOR . 'default'; - } -} diff --git a/src/PrestaShopBundle/Translation/Provider/DatabaseCatalogueInterface.php b/src/PrestaShopBundle/Translation/Provider/DatabaseCatalogueInterface.php deleted file mode 100644 index de369c9b..00000000 --- a/src/PrestaShopBundle/Translation/Provider/DatabaseCatalogueInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -use Symfony\Component\Translation\MessageCatalogue; - -/** - * Provide an Message Catalogue from the Database - */ -interface DatabaseCatalogueInterface -{ - /** - * @param string|null $themeName the Theme name - * - * @return MessageCatalogue - */ - public function getDatabaseCatalogue($themeName = null); -} diff --git a/src/PrestaShopBundle/Translation/Provider/ExternalModuleLegacySystemProvider.php b/src/PrestaShopBundle/Translation/Provider/ExternalModuleLegacySystemProvider.php deleted file mode 100644 index 02d25cb9..00000000 --- a/src/PrestaShopBundle/Translation/Provider/ExternalModuleLegacySystemProvider.php +++ /dev/null @@ -1,322 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -use InvalidArgumentException; -use PrestaShop\PrestaShop\Core\Exception\FileNotFoundException; -use PrestaShop\TranslationToolsBundle\Translation\Helper\DomainHelper; -use PrestaShopBundle\Translation\DomainNormalizer; -use PrestaShopBundle\Translation\Exception\UnsupportedLocaleException; -use PrestaShopBundle\Translation\Exception\UnsupportedModuleException; -use PrestaShopBundle\Translation\Extractor\LegacyModuleExtractorInterface; -use Symfony\Component\Translation\Loader\LoaderInterface; -use Symfony\Component\Translation\MessageCatalogue; -use Symfony\Component\Translation\MessageCatalogueInterface; - -/** - * Be able to retrieve information from legacy translation files - */ -class ExternalModuleLegacySystemProvider extends AbstractProvider implements UseDefaultCatalogueInterface, SearchProviderInterface, UseModuleInterface -{ - /** - * @var SearchProviderInterface|ModuleProvider the module provider - */ - private $moduleProvider; - - /** - * @var LoaderInterface the translation loader from legacy files - */ - private $legacyFileLoader; - - /** - * @var LegacyModuleExtractorInterface the extractor - */ - private $legacyModuleExtractor; - - /** - * @var string the module name - */ - private $moduleName; - - /** - * @var MessageCatalogue[] - */ - private $defaultCatalogueCache; - - public function __construct( - LoaderInterface $databaseLoader, - $resourceDirectory, - LoaderInterface $legacyFileLoader, - LegacyModuleExtractorInterface $legacyModuleExtractor, - SearchProviderInterface $moduleProvider - ) { - $this->moduleProvider = $moduleProvider; - $this->legacyFileLoader = $legacyFileLoader; - $this->legacyModuleExtractor = $legacyModuleExtractor; - - parent::__construct($databaseLoader, $resourceDirectory); - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return ['#^' . preg_quote($this->domain) . '([A-Z]|$)#']; - } - - /** - * {@inheritdoc} - */ - public function getTranslationDomains() - { - return ['^' . preg_quote($this->domain) . '([A-Z]|$)']; - } - - /** - * {@inheritdoc} - */ - public function getIdentifier() - { - return 'external_legacy_module'; - } - - /** - * {@inheritdoc} - */ - public function setModuleName($moduleName) - { - if (null === $this->moduleName || empty($this->moduleName)) { - UnsupportedModuleException::moduleNotProvided(self::getIdentifier()); - } - - $this->moduleName = $moduleName; - - // ugly hack, I know - $this->domain = DomainHelper::buildModuleBaseDomain($moduleName); - - return $this; - } - - /** - * @param string $domain - * - * @return AbstractProvider|SearchProviderInterface|void - */ - public function setDomain($domain) - { - throw new InvalidArgumentException(__CLASS__ . ' does not allow calls to setDomain()'); - } - - /** - * {@inheritdoc} - */ - public function getDefaultCatalogue($empty = true) - { - $defaultCatalogue = $this->getCachedDefaultCatalogue(); - - if ($empty && $this->locale !== self::DEFAULT_LOCALE) { - return $this->emptyCatalogue(clone $defaultCatalogue); - } - - return $defaultCatalogue; - } - - /** - * {@inheritdoc} - */ - public function getXliffCatalogue() - { - try { - $translationCatalogue = $this->moduleProvider - ->setModuleName($this->moduleName) - ->setLocale($this->locale) - ->getXliffCatalogue() - ; - } catch (FileNotFoundException $exception) { - $translationCatalogue = $this->buildTranslationCatalogueFromLegacyFiles(); - } - - return $translationCatalogue; - } - - /** - * {@inheritdoc} - */ - public function getDefaultResourceDirectory() - { - return $this->resourceDirectory . DIRECTORY_SEPARATOR . $this->moduleName . DIRECTORY_SEPARATOR . 'translations' . DIRECTORY_SEPARATOR; - } - - /** - * {@inheritdoc} - */ - public function getResourceDirectory() - { - return $this->getDefaultResourceDirectory(); - } - - /** - * Builds the catalogue including the translated wordings ONLY - * - * @return MessageCatalogueInterface - */ - private function buildTranslationCatalogueFromLegacyFiles() - { - // the message catalogue needs to be indexed by original wording, but legacy files are indexed by hash - // therefore, we need to build the default catalogue (by analyzing source code) - // then cross reference the wordings found in the default catalogue - // with the hashes found in the module's legacy translation file. - - $legacyFilesCatalogue = new MessageCatalogue($this->locale); - $catalogueFromPhpAndSmartyFiles = $this->getDefaultCatalogue(false); - - try { - $catalogueFromLegacyTranslationFiles = $this->legacyFileLoader->load( - $this->getDefaultResourceDirectory(), - $this->locale - ); - } catch (UnsupportedLocaleException $exception) { - // this happens when there no translation file is found for the desired locale - return $catalogueFromPhpAndSmartyFiles; - } - - foreach ($catalogueFromPhpAndSmartyFiles->all() as $currentDomain => $items) { - foreach (array_keys($items) as $translationKey) { - $legacyKey = md5($translationKey); - - if ($catalogueFromLegacyTranslationFiles->has($legacyKey, $currentDomain)) { - $legacyFilesCatalogue->set( - $translationKey, - $catalogueFromLegacyTranslationFiles->get($legacyKey, $currentDomain), - // use current domain and not module domain, otherwise we'd lose the third part from the domain - $currentDomain - ); - } - } - } - - return $legacyFilesCatalogue; - } - - /** - * {@inheritdoc} - */ - public function getMessageCatalogue() - { - $messageCatalogue = $this->getDefaultCatalogue(); - - $translatedCatalogue = $this->buildTranslationCatalogueFromLegacyFiles(); - $messageCatalogue->addCatalogue($translatedCatalogue); - - $databaseCatalogue = $this->getDatabaseCatalogue(); - $messageCatalogue->addCatalogue($databaseCatalogue); - - return $messageCatalogue; - } - - /** - * Replaces dots in the catalogue's domain names - * and filters out domains not corresponding to the one from this module - * - * @param MessageCatalogueInterface $catalogue - * - * @return MessageCatalogue - */ - private function filterDomains(MessageCatalogueInterface $catalogue) - { - $normalizer = new DomainNormalizer(); - $newCatalogue = new MessageCatalogue($catalogue->getLocale()); - - // add delimiter to - $validTranslationDomains = $this->getFilters(); - - foreach ($catalogue->getDomains() as $domain) { - // remove dots - $newDomain = $normalizer->normalize($domain); - - // only add if the domain is relevant to this module - foreach ($validTranslationDomains as $pattern) { - if (preg_match($pattern, $newDomain)) { - $newCatalogue->add( - $catalogue->all($domain), - $newDomain - ); - break; - } - } - } - - return $newCatalogue; - } - - /** - * Builds the default catalogue - * - * @return MessageCatalogue - */ - private function buildFreshDefaultCatalogue() - { - $defaultCatalogue = new MessageCatalogue($this->locale); - - try { - // look up files in the core translations - $defaultCatalogue = $this->moduleProvider - ->setModuleName($this->moduleName) - ->setLocale($this->locale) - ->getDefaultCatalogue(); - } catch (FileNotFoundException $exception) { - // there are no xliff files for this module in the core - } - - try { - // analyze files and extract wordings - $additionalDefaultCatalogue = $this->legacyModuleExtractor->extract($this->moduleName, $this->locale); - $defaultCatalogue = $this->filterDomains($additionalDefaultCatalogue); - } catch (UnsupportedLocaleException $exception) { - // Do nothing as support of legacy files is deprecated - } - - return $defaultCatalogue; - } - - /** - * Returns the cached default catalogue - * - * @return MessageCatalogue - */ - private function getCachedDefaultCatalogue() - { - $catalogueCacheKey = $this->moduleName . '|' . $this->locale; - - if (!isset($this->defaultCatalogueCache[$catalogueCacheKey])) { - $this->defaultCatalogueCache[$catalogueCacheKey] = $this->buildFreshDefaultCatalogue(); - } - - return $this->defaultCatalogueCache[$catalogueCacheKey]; - } -} diff --git a/src/PrestaShopBundle/Translation/Provider/FrontOfficeProvider.php b/src/PrestaShopBundle/Translation/Provider/FrontOfficeProvider.php deleted file mode 100644 index 4efe1e1b..00000000 --- a/src/PrestaShopBundle/Translation/Provider/FrontOfficeProvider.php +++ /dev/null @@ -1,88 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -use Symfony\Component\Translation\MessageCatalogue; - -/** - * Main translation provider for the Front Office - */ -class FrontOfficeProvider extends AbstractProvider implements UseDefaultCatalogueInterface -{ - const DEFAULT_THEME_NAME = 'classic'; - - /** - * {@inheritdoc} - */ - public function getTranslationDomains() - { - return [ - '^Shop*', - '^Modules(.*)Shop', - ]; - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return [ - '#^Shop*#', - '#^Modules(.*)Shop#', - ]; - } - - /** - * {@inheritdoc} - */ - public function getIdentifier() - { - return 'front'; - } - - /** - * @param null $themeName - * - * @return MessageCatalogue - */ - public function getDatabaseCatalogue($themeName = null) - { - if (null === $themeName) { - $themeName = self::DEFAULT_THEME_NAME; - } - - return parent::getDatabaseCatalogue($themeName); - } - - /**{@inheritdoc} - */ - public function getDefaultResourceDirectory() - { - return $this->resourceDirectory . DIRECTORY_SEPARATOR . 'default'; - } -} diff --git a/src/PrestaShopBundle/Translation/Provider/MailsBodyProvider.php b/src/PrestaShopBundle/Translation/Provider/MailsBodyProvider.php deleted file mode 100644 index 1de188a1..00000000 --- a/src/PrestaShopBundle/Translation/Provider/MailsBodyProvider.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -/** - * Translation provider specific to email subjects. - */ -class MailsBodyProvider extends AbstractProvider implements UseDefaultCatalogueInterface -{ - /** - * {@inheritdoc} - */ - public function getTranslationDomains() - { - return ['EmailsBody*']; - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return ['#EmailsBody*#']; - } - - /** - * {@inheritdoc} - */ - public function getIdentifier() - { - return 'mails_body'; - } - - /** - * {@inheritdoc} - */ - public function getDefaultResourceDirectory() - { - return $this->resourceDirectory . DIRECTORY_SEPARATOR . 'default'; - } -} diff --git a/src/PrestaShopBundle/Translation/Provider/MailsProvider.php b/src/PrestaShopBundle/Translation/Provider/MailsProvider.php deleted file mode 100644 index 703cdc10..00000000 --- a/src/PrestaShopBundle/Translation/Provider/MailsProvider.php +++ /dev/null @@ -1,65 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -/** - * Translation provider specific to email subjects. - */ -class MailsProvider extends AbstractProvider implements UseDefaultCatalogueInterface -{ - /** - * {@inheritdoc} - */ - public function getTranslationDomains() - { - return ['EmailsSubject*']; - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return ['#EmailsSubject*#']; - } - - /** - * {@inheritdoc} - */ - public function getIdentifier() - { - return 'mails'; - } - - /** - * {@inheritdoc} - */ - public function getDefaultResourceDirectory() - { - return $this->resourceDirectory . DIRECTORY_SEPARATOR . 'default'; - } -} diff --git a/src/PrestaShopBundle/Translation/Provider/ModuleProvider.php b/src/PrestaShopBundle/Translation/Provider/ModuleProvider.php deleted file mode 100644 index b92cb1f3..00000000 --- a/src/PrestaShopBundle/Translation/Provider/ModuleProvider.php +++ /dev/null @@ -1,83 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -use PrestaShop\TranslationToolsBundle\Translation\Helper\DomainHelper; - -/** - * Translation provider for a specific native module (maintained by the core team) - * Used mainly for the display in the Translations Manager of the Back Office. - */ -class ModuleProvider extends AbstractProvider implements SearchProviderInterface, UseModuleInterface -{ - /** - * @var string the module name - */ - private $moduleName; - - /** - * {@inheritdoc} - */ - public function getTranslationDomains() - { - return ['^' . preg_quote(DomainHelper::buildModuleBaseDomain($this->moduleName)) . '([A-Z]|$)']; - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return ['#^' . preg_quote(DomainHelper::buildModuleBaseDomain($this->moduleName)) . '([A-Z]|\.|$)#']; - } - - /** - * {@inheritdoc} - */ - public function getIdentifier() - { - return 'module'; - } - - /** - * {@inheritdoc} - */ - public function setModuleName($moduleName) - { - $this->moduleName = $moduleName; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getDefaultResourceDirectory() - { - return $this->resourceDirectory . DIRECTORY_SEPARATOR . 'default'; - } -} diff --git a/src/PrestaShopBundle/Translation/Provider/ModulesProvider.php b/src/PrestaShopBundle/Translation/Provider/ModulesProvider.php deleted file mode 100644 index f9006357..00000000 --- a/src/PrestaShopBundle/Translation/Provider/ModulesProvider.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -/** - * Translation provider for native modules (maintained by the core team) - * Translations are provided by Crowdin. - */ -class ModulesProvider extends AbstractProvider implements UseDefaultCatalogueInterface -{ - /** - * {@inheritdoc} - */ - public function getTranslationDomains() - { - return ['^Modules[A-Z]']; - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return ['#^Modules[A-Z]#']; - } - - /** - * {@inheritdoc} - */ - public function getIdentifier() - { - return 'modules'; - } - - /** - * {@inheritdoc} - */ - public function getDefaultResourceDirectory() - { - return $this->resourceDirectory . DIRECTORY_SEPARATOR . 'default'; - } -} diff --git a/src/PrestaShopBundle/Translation/Provider/OthersProvider.php b/src/PrestaShopBundle/Translation/Provider/OthersProvider.php deleted file mode 100644 index a244eadf..00000000 --- a/src/PrestaShopBundle/Translation/Provider/OthersProvider.php +++ /dev/null @@ -1,66 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -/** - * Translations provider for keys not yet put in the right domain. - * Equivalent to so-called main "messages" domain in the Symfony ecosystem. - */ -class OthersProvider extends AbstractProvider implements UseDefaultCatalogueInterface -{ - /** - * {@inheritdoc} - */ - public function getTranslationDomains() - { - return ['^messages*']; - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return ['#^messages*#']; - } - - /** - * {@inheritdoc} - */ - public function getIdentifier() - { - return 'others'; - } - - /** - * {@inheritdoc} - */ - public function getDefaultResourceDirectory() - { - return $this->resourceDirectory . DIRECTORY_SEPARATOR . 'default'; - } -} diff --git a/src/PrestaShopBundle/Translation/Provider/ProviderInterface.php b/src/PrestaShopBundle/Translation/Provider/ProviderInterface.php deleted file mode 100644 index dda2d27c..00000000 --- a/src/PrestaShopBundle/Translation/Provider/ProviderInterface.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -use Symfony\Component\Translation\MessageCatalogue; - -/** - * Define contract to retrieve translations. - */ -interface ProviderInterface -{ - /** - * @return string[] List of directories to parse - */ - public function getDirectories(); - - /** - * Returns a list of patterns for catalogue domain filtering (including XLF file lookup) - * - * @return string[] - */ - public function getFilters(); - - /** - * Returns a list of patterns for translation domains to get from database. - * - * @return string[] List of Mysql compatible regexes (no regex delimiter) - */ - public function getTranslationDomains(); - - /** - * @return string Locale used to build the MessageCatalogue - */ - public function getLocale(); - - /** - * @return MessageCatalogue A provider must return a MessageCatalogue - */ - public function getMessageCatalogue(); - - /** - * @return string Unique identifier - */ - public function getIdentifier(); -} diff --git a/src/PrestaShopBundle/Translation/Provider/SearchProvider.php b/src/PrestaShopBundle/Translation/Provider/SearchProvider.php deleted file mode 100644 index 6bd39641..00000000 --- a/src/PrestaShopBundle/Translation/Provider/SearchProvider.php +++ /dev/null @@ -1,196 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -use PrestaShop\PrestaShop\Core\Exception\FileNotFoundException; -use Symfony\Component\Translation\Loader\LoaderInterface; -use Symfony\Component\Translation\MessageCatalogue; -use Symfony\Component\Translation\MessageCatalogueInterface; - -/** - * Able to search translations for a specific translation domains across multiple sources - */ -class SearchProvider extends AbstractProvider implements UseDefaultCatalogueInterface, UseModuleInterface -{ - /** - * @var string the "modules" directory path - */ - private $modulesDirectory; - - /** - * @var ExternalModuleLegacySystemProvider - */ - private $externalModuleLegacySystemProvider; - - public function __construct( - LoaderInterface $databaseLoader, - ExternalModuleLegacySystemProvider $externalModuleLegacySystemProvider, - $resourceDirectory, - $modulesDirectory - ) { - $this->modulesDirectory = $modulesDirectory; - $this->externalModuleLegacySystemProvider = $externalModuleLegacySystemProvider; - - parent::__construct($databaseLoader, $resourceDirectory); - } - - /** - * Get domain. - * - * @deprecated since 1.7.6, to be removed in the next major - * - * @return mixed - */ - public function getDomain() - { - @trigger_error( - __METHOD__ . ' function is deprecated and will be removed in the next major', - E_USER_DEPRECATED - ); - - return $this->domain; - } - - /** - * {@inheritdoc} - */ - public function getTranslationDomains() - { - return ['^' . preg_quote($this->domain) . '([A-Z]|$)']; - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - return ['#^' . preg_quote($this->domain, '#') . '([A-Z]|\.|$)#']; - } - - /** - * {@inheritdoc} - */ - public function getIdentifier() - { - return 'search'; - } - - /** - * {@inheritdoc} - */ - public function getDefaultResourceDirectory() - { - return $this->resourceDirectory . DIRECTORY_SEPARATOR . 'default'; - } - - public function getDefaultCatalogue($empty = true) - { - try { - $defaultCatalogue = parent::getDefaultCatalogue($empty); - } catch (FileNotFoundException $e) { - $defaultCatalogue = $this->externalModuleLegacySystemProvider->getDefaultCatalogue($empty); - $defaultCatalogue = $this->filterCatalogue($defaultCatalogue); - } - - return $defaultCatalogue; - } - - /** - * {@inheritdoc} - */ - public function getXliffCatalogue() - { - try { - $xliffCatalogue = parent::getXliffCatalogue(); - } catch (\Exception $e) { - $xliffCatalogue = $this->externalModuleLegacySystemProvider->getXliffCatalogue(); - $xliffCatalogue = $this->filterCatalogue($xliffCatalogue); - } - - return $xliffCatalogue; - } - - /** - * @deprecated since 1.7.6, to be removed in the next major - * - * @return string - */ - public function getModuleDirectory() - { - @trigger_error( - __METHOD__ . ' function is deprecated and will be removed in the next major', - E_USER_DEPRECATED - ); - - return $this->modulesDirectory; - } - - /** - * {@inheritdoc} - */ - public function setLocale($locale) - { - $this->externalModuleLegacySystemProvider->setLocale($locale); - - return parent::setLocale($locale); - } - - /** - * {@inheritdoc} - */ - public function setModuleName($moduleName) - { - $this->externalModuleLegacySystemProvider->setModuleName($moduleName); - } - - /** - * Filters the catalogue so that only domains matching the filters are kept - * - * @param MessageCatalogueInterface $defaultCatalogue - * - * @return MessageCatalogueInterface - */ - private function filterCatalogue(MessageCatalogueInterface $defaultCatalogue) - { - // return only elements whose domain matches the filters - $filters = $this->getFilters(); - $allowedDomains = []; - - foreach ($defaultCatalogue->all() as $domain => $messages) { - foreach ($filters as $filter) { - if (preg_match($filter, $domain)) { - $allowedDomains[$domain] = $messages; - break; - } - } - } - - $defaultCatalogue = new MessageCatalogue($this->getLocale(), $allowedDomains); - - return $defaultCatalogue; - } -} diff --git a/src/PrestaShopBundle/Translation/Provider/SearchProviderInterface.php b/src/PrestaShopBundle/Translation/Provider/SearchProviderInterface.php deleted file mode 100644 index 2bd91ffd..00000000 --- a/src/PrestaShopBundle/Translation/Provider/SearchProviderInterface.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -interface SearchProviderInterface extends ProviderInterface, UseDefaultCatalogueInterface, XliffCatalogueInterface, DatabaseCatalogueInterface -{ - /** - * @param string $domain - * - * @return self - */ - public function setDomain($domain); - - /** - * @param string $locale - * - * @return self - */ - public function setLocale($locale); -} diff --git a/src/PrestaShopBundle/Translation/Provider/ThemeProvider.php b/src/PrestaShopBundle/Translation/Provider/ThemeProvider.php deleted file mode 100644 index 2329780b..00000000 --- a/src/PrestaShopBundle/Translation/Provider/ThemeProvider.php +++ /dev/null @@ -1,240 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -use PrestaShop\PrestaShop\Core\Addon\Theme\ThemeRepository; -use PrestaShop\TranslationToolsBundle\Translation\Extractor\Util\Flattenizer; -use PrestaShopBundle\Translation\Extractor\ThemeExtractor; -use Symfony\Component\Filesystem\Filesystem; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Translation\MessageCatalogueInterface; - -class ThemeProvider extends AbstractProvider -{ - /** - * @var string the theme name - */ - private $themeName; - - /** - * @var string the theme resources directory - */ - public $themeResourcesDirectory; - - /** - * @var Filesystem - */ - public $filesystem; - - /** - * @var ThemeRepository - */ - public $themeRepository; - - /** - * @var ThemeExtractor - */ - public $themeExtractor; - - /** - * @var string Path to app/Resources/translations/ - */ - public $defaultTranslationDir; - - /** - * Get domain. - * - * @deprecated since 1.7.6, to be removed in the next major - * - * @return mixed - */ - public function getDomain() - { - @trigger_error( - 'getDomain function is deprecated and will be removed in the next major', - E_USER_DEPRECATED - ); - - return $this->domain; - } - - /** - * {@inheritdoc} - */ - public function getTranslationDomains() - { - if (empty($this->domain)) { - return ['*']; - } - - return ['^' . $this->domain]; - } - - /** - * {@inheritdoc} - */ - public function getFilters() - { - if (empty($this->domain)) { - return ['*']; - } - - return ['#^' . $this->domain . '#']; - } - - /** - * {@inheritdoc} - */ - public function getIdentifier() - { - return 'theme'; - } - - /** - * {@inheritdoc} - */ - public function getMessageCatalogue() - { - $xlfCatalogue = $this->getXliffCatalogue(); - $databaseCatalogue = $this->getDatabaseCatalogue(); - - // Merge database catalogue to xliff catalogue - $xlfCatalogue->addCatalogue($databaseCatalogue); - - return $xlfCatalogue; - } - - /** - * @param string|null $baseDir - * - * @return string Path to app/themes/{themeName}/translations/{locale} - */ - public function getResourceDirectory($baseDir = null) - { - if (null === $baseDir) { - $baseDir = $this->resourceDirectory; - } - - $resourceDirectory = $baseDir . '/' . $this->themeName . '/translations/' . $this->getLocale(); - $this->filesystem->mkdir($resourceDirectory); - - return $resourceDirectory; - } - - /** - * {@inheritdoc} - */ - public function getDirectories() - { - return [ - $this->getResourceDirectory(), - $this->getThemeResourcesDirectory(), - ]; - } - - /** - * @return string the path to the Theme translations folder - */ - public function getThemeResourcesDirectory() - { - return $this->getResourceDirectory($this->themeResourcesDirectory); - } - - /** - * @param string $themeName The theme name - * - * @return self - */ - public function setThemeName($themeName) - { - $this->themeName = $themeName; - - return $this; - } - - /** - * @param string|null $themeName - * - * @return MessageCatalogueInterface - */ - public function getDatabaseCatalogue($themeName = null) - { - if (null === $themeName) { - $themeName = $this->themeName; - } - - return parent::getDatabaseCatalogue($themeName); - } - - /** - * @throws \Exception - * - * Will update translations files of the Theme - */ - public function synchronizeTheme() - { - $theme = $this->themeRepository->getInstanceByName($this->themeName); - - $path = $this->resourceDirectory . DIRECTORY_SEPARATOR . $this->themeName . DIRECTORY_SEPARATOR . 'translations'; - - $this->filesystem->remove($path); - $this->filesystem->mkdir($path); - - $this->themeExtractor - ->setOutputPath($path) - ->setThemeProvider($this) - ->extract($theme, $this->locale); - - $translationFilesPath = $path . DIRECTORY_SEPARATOR . $this->locale; - Flattenizer::flatten($translationFilesPath, $translationFilesPath, $this->locale, false); - - $finder = Finder::create(); - foreach ($finder->directories()->depth('== 0')->in($translationFilesPath) as $folder) { - $this->filesystem->remove($folder); - } - } - - /** - * @return MessageCatalogueInterface - * - * @throws \Exception - */ - public function getThemeCatalogue() - { - $path = $this->resourceDirectory . DIRECTORY_SEPARATOR . $this->themeName . DIRECTORY_SEPARATOR . 'translations'; - - return $this->getCatalogueFromPaths($path, $this->locale, current($this->getFilters())); - } - - /** - * {@inheritdoc} - */ - public function getDefaultResourceDirectory() - { - return $this->defaultTranslationDir . DIRECTORY_SEPARATOR . $this->locale; - } -} diff --git a/src/PrestaShopBundle/Translation/Provider/TranslationFinder.php b/src/PrestaShopBundle/Translation/Provider/TranslationFinder.php deleted file mode 100644 index 0673c8c6..00000000 --- a/src/PrestaShopBundle/Translation/Provider/TranslationFinder.php +++ /dev/null @@ -1,156 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -use PrestaShop\PrestaShop\Core\Exception\FileNotFoundException; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Finder\SplFileInfo; -use Symfony\Component\Translation\Loader\XliffFileLoader; -use Symfony\Component\Translation\MessageCatalogue; -use Symfony\Component\Translation\MessageCatalogueInterface; - -/** - * Helper used to build a MessageCataloguer from xliff files - */ -class TranslationFinder -{ - const ERR_NO_FILES_IN_DIRECTORY = 1; - const ERR_DIRECTORY_NOT_FOUND = 2; - - /** - * @param string|array $paths a list of paths when we can look for translations - * @param string $locale the Symfony (not the PrestaShop one) locale - * @param string|null $pattern a regular expression - * - * @return MessageCatalogue - * - * @throws FileNotFoundException - */ - public function getCatalogueFromPaths($paths, $locale, $pattern = null) - { - $translationFiles = $this->getTranslationFilesFromPath($paths, $pattern); - - return $this->buildCatalogueFromFiles($translationFiles, $locale); - } - - /** - * @param MessageCatalogueInterface $catalogue - * - * @return MessageCatalogue - */ - private function removeTrailingLocaleFromDomains(MessageCatalogueInterface $catalogue) - { - $messages = $catalogue->all(); - $locale = $catalogue->getLocale(); - $localeSuffix = '.' . $locale; - $suffixLength = strlen($localeSuffix); - - foreach ($catalogue->getDomains() as $domain) { - if (substr($domain, -$suffixLength) === $localeSuffix) { - $cleanDomain = substr($domain, 0, -$suffixLength); - $messages[$cleanDomain] = $messages[$domain]; - unset($messages[$domain]); - } - } - - return new MessageCatalogue($locale, $messages); - } - - /** - * @param $paths - * @param $pattern - * - * @return Finder - * - * @throws FileNotFoundException - */ - private function getTranslationFilesFromPath($paths, $pattern) - { - $finder = new Finder(); - - if (null !== $pattern) { - $finder->name($pattern); - } - - try { - $translationFiles = $finder->files()->notName('index.php')->in($paths); - } catch (\InvalidArgumentException $e) { - throw new FileNotFoundException(sprintf('Could not crawl for translation files: %s', $e->getMessage()), self::ERR_DIRECTORY_NOT_FOUND, $e); - } - - if (count($translationFiles) === 0) { - throw new FileNotFoundException('There are no translation file available.', self::ERR_NO_FILES_IN_DIRECTORY); - } - - return $translationFiles; - } - - /** - * @param Finder $translationFiles - * @param string $locale - * - * @return MessageCatalogue - */ - private function buildCatalogueFromFiles(Finder $translationFiles, $locale) - { - $messageCatalogue = new MessageCatalogue($locale); - $xliffFileLoader = new XliffFileLoader(); - - /** @var SplFileInfo $file */ - foreach ($translationFiles as $file) { - if ('xlf' === $file->getExtension()) { - $domain = $this->getDomainFromFile($file, $locale); - - $fileCatalogue = $xliffFileLoader->load($file->getPathname(), $locale, $domain); - $messageCatalogue->addCatalogue( - $this->removeTrailingLocaleFromDomains($fileCatalogue) - ); - } - } - - return $messageCatalogue; - } - - /** - * @param SplFileInfo $file - * @param string $locale - * - * @return string - */ - private function getDomainFromFile(SplFileInfo $file, $locale) - { - $basename = $file->getBasename('.xlf'); - - $domain = $basename; - if (strpos($basename, $locale) === false) { - $domain .= '.' . $locale; - } - - return $domain; - } -} diff --git a/src/PrestaShopBundle/Translation/Provider/TranslationFinderTrait.php b/src/PrestaShopBundle/Translation/Provider/TranslationFinderTrait.php deleted file mode 100644 index 27ba8f1b..00000000 --- a/src/PrestaShopBundle/Translation/Provider/TranslationFinderTrait.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -use PrestaShop\PrestaShop\Core\Exception\FileNotFoundException; -use Symfony\Component\Translation\MessageCatalogue; - -/** - * Helper used to retrieve a Symfony Catalogue object. - * - * @deprecated use TraslationFinder instead - */ -trait TranslationFinderTrait -{ - /** - * @param array $paths a list of paths when we can look for translations - * @param string $locale the Symfony (not the PrestaShop one) locale - * @param string|null $pattern a regular expression - * - * @return MessageCatalogue - * - * @throws FileNotFoundException - * - * @deprecated use TraslationFinder::getCatalogueFromPaths() instead - */ - public function getCatalogueFromPaths($paths, $locale, $pattern = null) - { - @trigger_error( - __FUNCTION__ . 'is deprecated since version 1.7.6.1 Use TranslationFinder::getCatalogueFromPaths() instead.', - E_USER_DEPRECATED - ); - - return (new TranslationFinder())->getCatalogueFromPaths($paths, $locale, $pattern); - } -} diff --git a/src/PrestaShopBundle/Translation/Provider/UseDefaultCatalogueInterface.php b/src/PrestaShopBundle/Translation/Provider/UseDefaultCatalogueInterface.php deleted file mode 100644 index 5bd86696..00000000 --- a/src/PrestaShopBundle/Translation/Provider/UseDefaultCatalogueInterface.php +++ /dev/null @@ -1,51 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -use Symfony\Component\Translation\MessageCatalogueInterface; - -/** - * Defines what should be the default catalogue, contains all the translations keys. - */ -interface UseDefaultCatalogueInterface -{ - /** - * Get the default (aka untranslated) catalogue - * - * @param bool $empty if true, empty the catalogue values (keep the keys) - * - * @return MessageCatalogueInterface Return a default catalogue with all keys - */ - public function getDefaultCatalogue($empty = true); - - /** - * @return string Path to the default directory - * Most of the time, it's `app/Resources/translations/default/{locale}` - */ - public function getDefaultResourceDirectory(); -} diff --git a/src/PrestaShopBundle/Translation/Provider/UseModuleInterface.php b/src/PrestaShopBundle/Translation/Provider/UseModuleInterface.php deleted file mode 100644 index 9511342a..00000000 --- a/src/PrestaShopBundle/Translation/Provider/UseModuleInterface.php +++ /dev/null @@ -1,45 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -use PrestaShopBundle\Translation\Exception\UnsupportedModuleException; - -/** - * Defines that this provider may need information from module. - */ -interface UseModuleInterface -{ - /** - * Set the module name - * - * @param string $moduleName the name of the module - * - * @throws UnsupportedModuleException if the module is not supported or invalid - */ - public function setModuleName($moduleName); -} diff --git a/src/PrestaShopBundle/Translation/Provider/XliffCatalogueInterface.php b/src/PrestaShopBundle/Translation/Provider/XliffCatalogueInterface.php deleted file mode 100644 index 510a290f..00000000 --- a/src/PrestaShopBundle/Translation/Provider/XliffCatalogueInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\Provider; - -use Symfony\Component\Translation\MessageCatalogue; - -/** - * Provide an Message Catalogue from Xliff files. - */ -interface XliffCatalogueInterface -{ - /** - * @return MessageCatalogue - */ - public function getXliffCatalogue(); -} diff --git a/src/PrestaShopBundle/Translation/Translator.php b/src/PrestaShopBundle/Translation/Translator.php deleted file mode 100644 index 87d523cb..00000000 --- a/src/PrestaShopBundle/Translation/Translator.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation; - -use Symfony\Bundle\FrameworkBundle\Translation\Translator as BaseTranslator; - -/** - * Replacement for the original Symfony FrameworkBundle translator - */ -class Translator extends BaseTranslator -{ - use PrestaShopTranslatorTrait; - use TranslatorLanguageTrait; - - /** - * {@inheritdoc} - */ - public function addResource($format, $resource, $locale, $domain = null) - { - parent::addResource($format, $resource, $locale, $domain); - parent::addResource('db', $domain . '.' . $locale . '.db', $locale, $domain); - } -} diff --git a/src/PrestaShopBundle/Translation/TranslatorAwareTrait.php b/src/PrestaShopBundle/Translation/TranslatorAwareTrait.php deleted file mode 100644 index 37d0e294..00000000 --- a/src/PrestaShopBundle/Translation/TranslatorAwareTrait.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation; - -use Symfony\Component\Translation\TranslatorInterface; - -/** - * Trait TranslatorAwareTrait is used for services that depends on translator. - */ -trait TranslatorAwareTrait -{ - /** - * @var TranslatorInterface - */ - protected $translator; - - /** - * Set translator instance. - * - * @param TranslatorInterface $translator - */ - public function setTranslator(TranslatorInterface $translator) - { - $this->translator = $translator; - } - - /** - * Shortcut method to translate text. - * - * @param string $id - * @param array $options - * @param string $domain - * - * @return string - */ - protected function trans($id, array $options, $domain) - { - return $this->translator->trans($id, $options, $domain); - } -} diff --git a/src/PrestaShopBundle/Translation/TranslatorComponent.php b/src/PrestaShopBundle/Translation/TranslatorComponent.php deleted file mode 100644 index 691b9844..00000000 --- a/src/PrestaShopBundle/Translation/TranslatorComponent.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation; - -use Symfony\Component\Translation\Translator as BaseTranslatorComponent; - -/** - * Translator used by Context - */ -class TranslatorComponent extends BaseTranslatorComponent -{ - use PrestaShopTranslatorTrait; - use TranslatorLanguageTrait; -} diff --git a/src/PrestaShopBundle/Translation/TranslatorLanguageLoader.php b/src/PrestaShopBundle/Translation/TranslatorLanguageLoader.php deleted file mode 100644 index f0161c03..00000000 --- a/src/PrestaShopBundle/Translation/TranslatorLanguageLoader.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation; - -use PrestaShop\PrestaShop\Core\Addon\Theme\Theme; -use PrestaShopBundle\Translation\Loader\SqlTranslationLoader; -use Symfony\Component\Finder\Finder; -use Symfony\Component\Translation\Loader\XliffFileLoader; -use Symfony\Component\Translation\TranslatorInterface; - -class TranslatorLanguageLoader -{ - const TRANSLATION_DIR = _PS_ROOT_DIR_ . '/app/Resources/translations'; - /** - * @var bool - */ - private $isAdminContext; - - /** - * TranslatorLanguageLoader constructor. - * - * @param $isAdminContext - */ - public function __construct($isAdminContext) - { - $this->isAdminContext = $isAdminContext; - } - - /** - * Loads a language into a translator - * - * @param TranslatorInterface $translator Translator to modifiy - * @param string $locale Locale code for the language to load - * @param bool $withDB [default=true] Whether to load translations from the database or not - * @param Theme|null $theme [default=false] Currently active theme (Front office only) - */ - public function loadLanguage(TranslatorInterface $translator, $locale, $withDB = true, Theme $theme = null) - { - if (!$translator->isLanguageLoaded($locale)) { - $translator->addLoader('xlf', new XliffFileLoader()); - - if ($withDB) { - $sqlTranslationLoader = new SqlTranslationLoader(); - if (null !== $theme) { - $sqlTranslationLoader->setTheme($theme); - } - $translator->addLoader('db', $sqlTranslationLoader); - } - - $finder = Finder::create() - ->files() - ->name('*.' . $locale . '.xlf') - ->notName($this->isAdminContext ? '^Shop*' : '^Admin*') - ->in($this->getTranslationResourcesDirectories($theme)); - - foreach ($finder as $file) { - list($domain, $locale, $format) = explode('.', $file->getBasename(), 3); - $translator->addResource($format, $file, $locale, $domain); - if ($withDB) { - $translator->addResource('db', $domain . '.' . $locale . '.db', $locale, $domain); - } - } - } - } - - /** - * @param Theme|null $theme - * - * @return array - */ - protected function getTranslationResourcesDirectories(Theme $theme = null) - { - $locations = [self::TRANSLATION_DIR]; - - if (null !== $theme) { - $activeThemeLocation = $theme->getDirectory() . '/translations'; - if (is_dir($activeThemeLocation)) { - $locations[] = $activeThemeLocation; - } - } - - return $locations; - } -} diff --git a/src/PrestaShopBundle/Translation/TranslatorLanguageTrait.php b/src/PrestaShopBundle/Translation/TranslatorLanguageTrait.php deleted file mode 100644 index a9c35098..00000000 --- a/src/PrestaShopBundle/Translation/TranslatorLanguageTrait.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation; - -/** - * Trait TranslatorLanguageTrait used to check if a language has been loaded and reset a language - */ -trait TranslatorLanguageTrait -{ - /** - * @param string $locale Locale code for the catalogue to check if loaded - * - * @return bool - */ - public function isLanguageLoaded($locale) - { - return !empty($this->catalogues[$locale]); - } - - /** - * @param string $locale Locale code for the catalogue to be cleared - */ - public function clearLanguage($locale) - { - unset($this->catalogues[$locale]); - } -} diff --git a/src/PrestaShopBundle/Translation/View/TreeBuilder.php b/src/PrestaShopBundle/Translation/View/TreeBuilder.php deleted file mode 100644 index 121db5c5..00000000 --- a/src/PrestaShopBundle/Translation/View/TreeBuilder.php +++ /dev/null @@ -1,316 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Translation\View; - -use Doctrine\Common\Util\Inflector; -use PrestaShopBundle\Translation\Provider\AbstractProvider; -use Symfony\Bundle\FrameworkBundle\Routing\Router; - -class TreeBuilder -{ - private $locale; - private $theme; - - public function __construct($locale, $theme) - { - $this->locale = $locale; - $this->theme = $theme; - } - - /** - * @param AbstractProvider $provider - * @param null $search - * - * @return array|mixed - */ - public function makeTranslationArray(AbstractProvider $provider, $search = null) - { - $provider->setLocale($this->locale); - - if ('theme' === $provider->getIdentifier()) { - $defaultCatalogue = $provider->getMessageCatalogue(); - } else { - $defaultCatalogue = $provider->getDefaultCatalogue(); - } - - $xliffCatalogue = $provider->getXliffCatalogue(); - $databaseCatalogue = $provider->getDatabaseCatalogue($this->theme); - - $translations = []; - - foreach ($defaultCatalogue->all() as $domain => $messages) { - $missingTranslations = 0; - - foreach ($messages as $translationKey => $translationValue) { - $data = [ - 'xlf' => $xliffCatalogue->defines($translationKey, $domain) - ? $xliffCatalogue->get($translationKey, $domain) - : null, - 'db' => $databaseCatalogue->defines($translationKey, $domain) - ? $databaseCatalogue->get($translationKey, $domain) - : null, - ]; - - // if search is empty or is in catalog default|xlf|database - if (empty($search) || $this->dataContainsSearchWord($search, array_merge(['default' => $translationKey], $data))) { - $translations[$domain][$translationKey] = $data; - - if (empty($data['xlf']) - && empty($data['db']) - ) { - ++$missingTranslations; - } - } - } - - $translations[$domain]['__metadata'] = ['missing_translations' => $missingTranslations]; - } - - ksort($translations); - - return $translations; - } - - /** - * Check if data contains search word. - * - * @param $search - * @param $data - * - * @return bool - */ - private function dataContainsSearchWord($search, $data) - { - if (is_string($search)) { - $search = strtolower($search); - - return false !== strpos(strtolower($data['default']), $search) || - false !== strpos(strtolower($data['xlf']), $search) || - false !== strpos(strtolower($data['db']), $search); - } - - if (is_array($search)) { - $contains = true; - foreach ($search as $s) { - $s = strtolower($s); - $contains &= false !== strpos(strtolower($data['default']), $s) || - false !== strpos(strtolower($data['xlf']), $s) || - false !== strpos(strtolower($data['db']), $s); - } - - return $contains; - } - - return false; - } - - /** - * @return array - */ - public function makeTranslationsTree($catalogue) - { - $translationsTree = []; - - foreach ($catalogue as $domain => $messages) { - $tableisedDomain = Inflector::tableize($domain); - // the third component of the domain may have underscores, so we need to limit pieces to 3 - $parts = explode('_', $tableisedDomain, 3); - $subtree = &$translationsTree; - - foreach ($parts as $part) { - $subdomain = ucfirst($part); - - if (!array_key_exists($subdomain, $subtree)) { - $subtree[$subdomain] = []; - } - - $subtree = &$subtree[$subdomain]; - } - - $subtree['__messages'] = [$domain => $messages]; - if (isset($messages['__metadata'])) { - $subtree['__fixed_length_id'] = '_' . sha1($domain); - list($subtree['__domain']) = explode('.', $domain); - $subtree['__metadata'] = $messages['__metadata']; - $subtree['__metadata']['domain'] = $subtree['__domain']; - unset($messages['__metadata']); - } - } - - return $translationsTree; - } - - /** - * Clean tree to use it with the new API system. - * - * @param $tree - * @param Router $router - * @param null $theme - * @param null $search - * @param null $module - * - * @return array - */ - public function cleanTreeToApi($tree, Router $router, $theme = null, $search = null, $module = null) - { - $rootTree = [ - 'tree' => [ - 'total_translations' => 0, - 'total_missing_translations' => 0, - 'children' => [], - ], - ]; - - $cleanTree = &$rootTree['tree']['children']; - - $index1 = 0; - foreach ($tree as $k1 => $t1) { - $index2 = 0; - if (is_array($t1) && '__' !== substr($k1, 0, 2)) { - $this->addTreeInfo($router, $cleanTree, $index1, $k1, $k1, $this->theme, $search, $module); - - if (array_key_exists('__messages', $t1)) { - $nbMessage = count(current($t1['__messages'])); - if (array_key_exists('__metadata', $t1)) { - --$nbMessage; - } - - $cleanTree[$index1]['total_translations'] += $nbMessage; - $rootTree['tree']['total_translations'] += $nbMessage; - - if (array_key_exists('__metadata', $t1) && array_key_exists('missing_translations', $t1['__metadata'])) { - $cleanTree[$index1]['total_missing_translations'] += (int) $t1['__metadata']['missing_translations']; - $rootTree['tree']['total_missing_translations'] += (int) $t1['__metadata']['missing_translations']; - } - } - - foreach ($t1 as $k2 => $t2) { - $index3 = 0; - if (is_array($t2) && '__' !== substr($k2, 0, 2)) { - $this->addTreeInfo($router, $cleanTree[$index1]['children'], $index2, $k2, $k1 . $k2, $this->theme, $search, $module); - - if (array_key_exists('__messages', $t2)) { - $nbMessage = count(current($t2['__messages'])); - if (array_key_exists('__metadata', $t2)) { - --$nbMessage; - } - - $cleanTree[$index1]['children'][$index2]['total_translations'] += $nbMessage; - $cleanTree[$index1]['total_translations'] += $nbMessage; - $rootTree['tree']['total_translations'] += $nbMessage; - - if (array_key_exists('__metadata', $t2) && array_key_exists('missing_translations', $t2['__metadata'])) { - $cleanTree[$index1]['children'][$index2]['total_missing_translations'] += (int) $t2['__metadata']['missing_translations']; - $cleanTree[$index1]['total_missing_translations'] += (int) $t2['__metadata']['missing_translations']; - $rootTree['tree']['total_missing_translations'] += (int) $t2['__metadata']['missing_translations']; - } - } - - foreach ($t2 as $k3 => $t3) { - if (is_array($t3) && '__' !== substr($k3, 0, 2)) { - $this->addTreeInfo($router, $cleanTree[$index1]['children'][$index2]['children'], $index3, $k3, $k1 . $k2 . $k3, $this->theme, $search, $module); - - if (array_key_exists('__messages', $t3)) { - $nbMessage = count(current($t3['__messages'])); - if (array_key_exists('__metadata', $t3)) { - --$nbMessage; - } - - $cleanTree[$index1]['children'][$index2]['children'][$index3]['total_translations'] += $nbMessage; - $cleanTree[$index1]['children'][$index2]['total_translations'] += $nbMessage; - $cleanTree[$index1]['total_translations'] += $nbMessage; - $rootTree['tree']['total_translations'] += $nbMessage; - } - - if (array_key_exists('__metadata', $t3) && array_key_exists('missing_translations', $t3['__metadata'])) { - $cleanTree[$index1]['children'][$index2]['children'][$index3]['total_missing_translations'] += (int) $t3['__metadata']['missing_translations']; - $cleanTree[$index1]['children'][$index2]['total_missing_translations'] += (int) $t3['__metadata']['missing_translations']; - $cleanTree[$index1]['total_missing_translations'] += (int) $t3['__metadata']['missing_translations']; - $rootTree['tree']['total_missing_translations'] += (int) $t3['__metadata']['missing_translations']; - } - - if (empty($cleanTree[$index1]['children'][$index2]['children'][$index3]['children'])) { - unset($cleanTree[$index1]['children'][$index2]['children'][$index3]['children']); - } - ++$index3; - } - } - - if (empty($cleanTree[$index1]['children'][$index2]['children'])) { - unset($cleanTree[$index1]['children'][$index2]['children']); - } - ++$index2; - } - } - - if (empty($cleanTree[$index1]['children'])) { - unset($cleanTree[$index1]['children']); - } - ++$index1; - } - } - - return $rootTree; - } - - /** - * @param Router $router - * @param $tree - * @param $index - * @param $name - * @param $fullName - * @param bool $theme - * @param null $search - * @param null $module - * - * @return mixed - */ - private function addTreeInfo(Router $router, &$tree, $index, $name, $fullName, $theme = false, $search = null, $module = false) - { - if (!isset($tree[$index])) { - $routeParams = [ - 'locale' => $this->locale, - 'domain' => $fullName, - 'theme' => $theme, - 'module' => $module, - ]; - - if (!empty($search)) { - $routeParams['search'] = $search; - } - - $tree[$index]['name'] = $name; - $tree[$index]['full_name'] = $fullName; - $tree[$index]['domain_catalog_link'] = $router->generate('api_translation_domain_catalog', $routeParams); - $tree[$index]['total_translations'] = 0; - $tree[$index]['total_missing_translations'] = 0; - $tree[$index]['children'] = []; - } - - return $tree; - } -} diff --git a/src/PrestaShopBundle/Twig/AdminExtension.php b/src/PrestaShopBundle/Twig/AdminExtension.php deleted file mode 100644 index d26aa99f..00000000 --- a/src/PrestaShopBundle/Twig/AdminExtension.php +++ /dev/null @@ -1,84 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Twig; - -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\HttpFoundation\RequestStack; - -/** - * Twig extension for the Symfony Asset component. - * - * @deprecated since 1.7.5.0 to be removed in 1.8.0.0 - * - * @author Mlanawo Mbechezi - */ -class AdminExtension extends \Twig_Extension implements \Twig_Extension_InitRuntimeInterface -{ - /** - * @var RequestStack - */ - private $requestStack; - - /** - * @var \Twig_Environment - */ - private $environment; - - /** - * @var \Symfony\Component\DependencyInjection\Container - */ - private $container; - - /** - * AdminExtension constructor. - * - * @param RequestStack|null $requestStack - * @param ContainerInterface $container - */ - public function __construct(RequestStack $requestStack = null, ContainerInterface $container) - { - $this->requestStack = $requestStack; - $this->container = $container; - } - - /** - * {@inheritdoc} - */ - public function initRuntime(\Twig_Environment $environment) - { - $this->environment = $environment; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'twig_admin_extension'; - } -} diff --git a/src/PrestaShopBundle/Twig/ContextIsoCodeProviderExtension.php b/src/PrestaShopBundle/Twig/ContextIsoCodeProviderExtension.php deleted file mode 100644 index f2eb2c7b..00000000 --- a/src/PrestaShopBundle/Twig/ContextIsoCodeProviderExtension.php +++ /dev/null @@ -1,64 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Twig; - -/** - * Provides context language iso code - */ -class ContextIsoCodeProviderExtension extends \Twig_Extension -{ - /** - * @var string - */ - private $isoCode; - - /** - * @param $isoCode - */ - public function __construct($isoCode) - { - $this->isoCode = $isoCode; - } - - /** - * {@inheritdoc} - */ - public function getFunctions() - { - return [ - new \Twig_SimpleFunction('get_context_iso_code', [$this, 'getIsoCode']), - ]; - } - - /** - * @return string - */ - public function getIsoCode() - { - return $this->isoCode; - } -} diff --git a/src/PrestaShopBundle/Twig/DataFormatterExtension.php b/src/PrestaShopBundle/Twig/DataFormatterExtension.php deleted file mode 100644 index 0b259320..00000000 --- a/src/PrestaShopBundle/Twig/DataFormatterExtension.php +++ /dev/null @@ -1,143 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Twig; - -/** - * This class is used by Twig_Environment and provide some methods callable from a twig template. - */ -class DataFormatterExtension extends \Twig_Extension -{ - /** - * Define available filters. - * - * @return array Twig_SimpleFilter - */ - public function getFilters() - { - return [ - new \Twig_SimpleFilter('arrayCast', [$this, 'arrayCast']), - new \Twig_SimpleFilter('intCast', [$this, 'intCast']), - new \Twig_SimpleFilter('unsetElement', [$this, 'unsetElement']), - new \Twig_SimpleFilter('array_pluck', [$this, 'arrayPluck']), - ]; - } - - /** - * Define available functions. - * - * @return array Twig_SimpleFunction - */ - public function getFunctions() - { - return [ - new \Twig_SimpleFunction('arrayCast', [$this, 'arrayCast']), - new \Twig_SimpleFunction('intCast', [$this, 'intCast']), - new \Twig_SimpleFunction('unsetElement', [$this, 'unsetElement']), - new \Twig_SimpleFunction('array_pluck', [$this, 'arrayPluck']), - ]; - } - - /** - * Cast to array the variable given. - * - * @param mixed $toCast Mixed value to be casted into an array - * - * @return array $toCast casted in array - */ - public function arrayCast($toCast) - { - return (array) $toCast; - } - - /** - * Cast to int the variable given. - * - * @param mixed $toCast Mixed value to be casted into an int - * - * @return int $toCast casted in int - */ - public function intCast($toCast) - { - return (int) $toCast; - } - - /** - * PHP 'unset()' exposed through twig template engine. - * - * @param string $array Array containing Element to unset - * @param string $key Element to be unset - */ - public function unsetElement($array, $key) - { - unset($array[$key]); - - return $array; - } - - /** - * Extract a subset of an array and returns only the wanted keys. - * If $extractedKeys is an associative array you can even rename the - * keys of the extracted array. - * - * ex: - * arrayPluck(['first_name' => 'John', 'last_name' => 'Doe'], ['first_name']) => ['first_name' => 'John'] - * arrayPluck(['first_name' => 'John', 'last_name' => 'Doe'], ['first_name' => 'name']) => ['name' => 'John'] - * - * @param array $array - * @param array $extractedKeys - * - * @return array - */ - public function arrayPluck(array $array, array $extractedKeys) - { - $extractedArray = []; - foreach ($extractedKeys as $key => $value) { - if (is_int($key)) { - $oldKey = $value; - $newKey = $value; - } else { - $oldKey = $key; - $newKey = $value; - } - if (isset($array[$oldKey])) { - $extractedArray[$newKey] = $array[$oldKey]; - } - } - - return $extractedArray; - } - - /** - * Returns the name of the extension. - * - * @return string The extension name - */ - public function getName() - { - return 'twig_data_formatter_extension'; - } -} diff --git a/src/PrestaShopBundle/Twig/Extension/ColorBrightnessCalculatorExtension.php b/src/PrestaShopBundle/Twig/Extension/ColorBrightnessCalculatorExtension.php deleted file mode 100644 index 54c1d51d..00000000 --- a/src/PrestaShopBundle/Twig/Extension/ColorBrightnessCalculatorExtension.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Twig\Extension; - -use PrestaShop\PrestaShop\Core\Util\ColorBrightnessCalculator; -use Twig\Extension\AbstractExtension; -use Twig_SimpleFunction; - -/** - * Adds color calculation functions to Twig. - */ -class ColorBrightnessCalculatorExtension extends AbstractExtension -{ - /** - * @var ColorBrightnessCalculator - */ - private $brightnessCalculator; - - /** - * @param ColorBrightnessCalculator $brightnessCalculator - */ - public function __construct(ColorBrightnessCalculator $brightnessCalculator) - { - $this->brightnessCalculator = $brightnessCalculator; - } - - /** - * {@inheritdoc} - */ - public function getFunctions() - { - return [ - new Twig_SimpleFunction( - 'is_color_bright', - [$this->brightnessCalculator, 'isBright'] - ), - ]; - } -} diff --git a/src/PrestaShopBundle/Twig/Extension/DocumentationLinkExtension.php b/src/PrestaShopBundle/Twig/Extension/DocumentationLinkExtension.php deleted file mode 100644 index f6b092a7..00000000 --- a/src/PrestaShopBundle/Twig/Extension/DocumentationLinkExtension.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Twig\Extension; - -use PrestaShop\PrestaShop\Core\Util\HelperCard\DocumentationLinkProviderInterface; -use Twig\Extension\AbstractExtension; -use Twig_SimpleFunction; - -/** - * Adds "documentation_link" function to Twig so documentation links can be generated in templates - */ -class DocumentationLinkExtension extends AbstractExtension -{ - /** - * @var DocumentationLinkProviderInterface - */ - private $documentationLinkProvider; - - /** - * @param DocumentationLinkProviderInterface $documentationLinkProvider - */ - public function __construct(DocumentationLinkProviderInterface $documentationLinkProvider) - { - $this->documentationLinkProvider = $documentationLinkProvider; - } - - /** - * {@inheritdoc} - */ - public function getFunctions() - { - return [ - new Twig_SimpleFunction( - 'documentation_link', - [$this->documentationLinkProvider, 'getLink'] - ), - ]; - } -} diff --git a/src/PrestaShopBundle/Twig/Extension/GridExtension.php b/src/PrestaShopBundle/Twig/Extension/GridExtension.php deleted file mode 100644 index 27eb4f09..00000000 --- a/src/PrestaShopBundle/Twig/Extension/GridExtension.php +++ /dev/null @@ -1,226 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Twig\Extension; - -use RuntimeException; -use Symfony\Component\Cache\Adapter\AdapterInterface; -use Twig\Environment; -use Twig\Extension\AbstractExtension; -use Twig_SimpleFunction as SimpleFunction; - -/** - * Class GridExtension is responsible for providing grid helpers functions. - * - * - column_content(column, record, grid): renders column content based on column type. - * - column_header(column, grid): renders column header based on column type. - */ -class GridExtension extends AbstractExtension -{ - const BASE_COLUMN_CONTENT_TEMPLATE_PATH = '@PrestaShop/Admin/Common/Grid/Columns/Content'; - const BASE_COLUMN_HEADER_TEMPLATE_PATH = '@PrestaShop/Admin/Common/Grid/Columns/Header/Content'; - - /** - * @var Environment - */ - private $twig; - - /** - * @var AdapterInterface - */ - private $cache; - - /** - * @param Environment $twig - * @param AdapterInterface $cache - */ - public function __construct(Environment $twig, AdapterInterface $cache) - { - $this->twig = $twig; - $this->cache = $cache; - } - - /** - * {@inheritdoc} - */ - public function getFunctions() - { - return [ - new SimpleFunction('column_content', [$this, 'renderColumnContent'], [ - 'is_safe' => ['html'], - ]), - new SimpleFunction('column_header', [$this, 'renderColumnHeader'], [ - 'is_safe' => ['html'], - ]), - new SimpleFunction('is_ordering_column', [$this, 'isOrderingColumn'], [ - 'is_safe' => ['html'], - ]), - ]; - } - - /** - * Render column content. - * - * @param array $record - * @param array $column - * @param array $grid - * - * @return string - * - * @throws RuntimeException when template cannot be found for column - */ - public function renderColumnContent(array $record, array $column, array $grid) - { - $templateCacheKey = sprintf('column_%s_%s_%s_content', $grid['id'], $column['id'], $column['type']); - - if (false === $this->cache->hasItem($templateCacheKey)) { - $template = $this->getTemplatePath( - $column, - $grid, - self::BASE_COLUMN_CONTENT_TEMPLATE_PATH - ); - - if (null === $template) { - throw new RuntimeException(sprintf('Content template for column type "%s" was not found', $column['type'])); - } - - $this->cache->save( - $this->cache - ->getItem($templateCacheKey) - ->set($template) - ); - } - - return $this->twig->render($this->cache->getItem($templateCacheKey)->get(), [ - 'column' => $column, - 'record' => $record, - 'grid' => $grid, - ]); - } - - /** - * Render column header. - * - * @param array $column - * @param array $grid - * - * @return string - */ - public function renderColumnHeader(array $column, array $grid) - { - $templateCacheKey = sprintf( - 'column_%s_%s_%s_header', - $grid['id'], - $column['id'], - $column['type'] - ); - - if (!$this->cache->hasItem($templateCacheKey)) { - $template = $this->getTemplatePath( - $column, - $grid, - self::BASE_COLUMN_HEADER_TEMPLATE_PATH, - 'default.html.twig' - ); - - $this->cache->save( - $this->cache - ->getItem($templateCacheKey) - ->set($template) - ); - } - - return $this->twig->render($this->cache->getItem($templateCacheKey)->get(), [ - 'column' => $column, - 'grid' => $grid, - ]); - } - - /** - * @param array $grid - * - * @return bool - */ - public function isOrderingColumn(array $grid) - { - if (empty($grid['columns']) - || empty($grid['sorting']['order_by']) - || empty($grid['sorting']['order_way']) - || 'asc' != strtolower($grid['sorting']['order_way'])) { - return false; - } - - foreach ($grid['columns'] as $column) { - if ('position' == $column['type']) { - $positionField = $column['id']; - if (strtolower($positionField) == strtolower($grid['sorting']['order_by'])) { - return true; - } - } - } - - return false; - } - - /** - * Get template for column. - * - * @param array $column - * @param array $grid - * @param string $basePath - * @param string|null $defaultTemplate - * - * @return string|null - */ - private function getTemplatePath(array $column, array $grid, $basePath, $defaultTemplate = null) - { - $gridId = $grid['id']; - $columnId = $column['id']; - $columnType = $column['type']; - - $columnGridTemplate = sprintf('%s/%s_%s_%s.html.twig', $basePath, $gridId, $columnId, $columnType); - $gridTemplate = sprintf('%s/%s_%s.html.twig', $basePath, $gridId, $columnType); - $columnTemplate = sprintf('%s/%s.html.twig', $basePath, $columnType); - - if ($this->twig->getLoader()->exists($columnGridTemplate)) { - return $columnGridTemplate; - } - - if ($this->twig->getLoader()->exists($gridTemplate)) { - return $gridTemplate; - } - - if ($this->twig->getLoader()->exists($columnTemplate)) { - return $columnTemplate; - } - - if (null !== $defaultTemplate) { - return sprintf('%s/%s', $basePath, $defaultTemplate); - } - - return null; - } -} diff --git a/src/PrestaShopBundle/Twig/Extension/JsRouterMetadataExtension.php b/src/PrestaShopBundle/Twig/Extension/JsRouterMetadataExtension.php deleted file mode 100644 index 0956ea5e..00000000 --- a/src/PrestaShopBundle/Twig/Extension/JsRouterMetadataExtension.php +++ /dev/null @@ -1,93 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Twig\Extension; - -use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; -use Twig\Extension\AbstractExtension; -use Twig_SimpleFunction; - -/** - * Provides data needed for Javascript router component - */ -class JsRouterMetadataExtension extends AbstractExtension -{ - /** - * @var RequestStack - */ - private $requestStack; - - /** - * @var CsrfTokenManagerInterface - */ - private $tokenManager; - - /** - * @var string - */ - private $username; - - /** - * @param RequestStack $requestStack - * @param CsrfTokenManagerInterface $tokenManager - * @param string $username - */ - public function __construct( - RequestStack $requestStack, - CsrfTokenManagerInterface $tokenManager, - string $username - ) { - $this->requestStack = $requestStack; - $this->tokenManager = $tokenManager; - $this->username = $username; - } - - /** - * {@inheritdoc} - */ - public function getFunctions() - { - return [ - new Twig_SimpleFunction('js_router_metadata', [$this, 'getJsRouterMetadata']), - ]; - } - - /** - * Get base url and security token used for javascript router component. - * - * @return array - */ - public function getJsRouterMetadata() - { - return [ - // base url for javascript router - 'base_url' => $this->requestStack->getCurrentRequest()->getBaseUrl(), - //security token for javascript router - 'token' => $this->tokenManager->getToken($this->username)->getValue(), - ]; - } -} diff --git a/src/PrestaShopBundle/Twig/Extension/LocalizationExtension.php b/src/PrestaShopBundle/Twig/Extension/LocalizationExtension.php deleted file mode 100644 index 3b5d0211..00000000 --- a/src/PrestaShopBundle/Twig/Extension/LocalizationExtension.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Twig\Extension; - -use DateTime; -use DateTimeInterface; -use Twig\Extension\AbstractExtension; -use Twig_SimpleFilter; - -class LocalizationExtension extends AbstractExtension -{ - /** - * @var string - */ - private $dateFormatFull; - - /** - * @var string - */ - private $dateFormatLight; - - /** - * @param string $contextDateFormatFull - * @param string $contextDateFormatLight - */ - public function __construct(string $contextDateFormatFull, string $contextDateFormatLight) - { - $this->dateFormatFull = $contextDateFormatFull; - $this->dateFormatLight = $contextDateFormatLight; - } - - public function getFilters(): array - { - return [ - new Twig_SimpleFilter('date_format_full', [$this, 'dateFormatFull']), - new Twig_SimpleFilter('date_format_lite', [$this, 'dateFormatLite']), - ]; - } - - /** - * @param DateTimeInterface|string $date - * - * @return string - */ - public function dateFormatFull($date): string - { - if (!$date instanceof DateTimeInterface) { - $date = new DateTime($date); - } - - return $date->format($this->dateFormatFull); - } - - /** - * @param DateTimeInterface|string $date - * - * @return string - */ - public function dateFormatLite($date): string - { - if (!$date instanceof DateTimeInterface) { - $date = new DateTime($date); - } - - return $date->format($this->dateFormatLight); - } -} diff --git a/src/PrestaShopBundle/Twig/Extension/NumberExtension.php b/src/PrestaShopBundle/Twig/Extension/NumberExtension.php deleted file mode 100644 index 3849cbf2..00000000 --- a/src/PrestaShopBundle/Twig/Extension/NumberExtension.php +++ /dev/null @@ -1,52 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -declare(strict_types=1); - -namespace PrestaShopBundle\Twig\Extension; - -use PrestaShop\Decimal\Number; -use Twig\Extension\AbstractExtension; -use Twig\TwigFunction; - -/** - * Class NumberExtension provides helper function to create Prestashop/Decimal in twig - */ -class NumberExtension extends AbstractExtension -{ - /** - * {@inheritdoc} - */ - public function getFunctions() - { - return [new TwigFunction('number', [$this, 'createNumber'])]; - } - - public function createNumber($number) - { - return new Number((string) $number); - } -} diff --git a/src/PrestaShopBundle/Twig/Extension/PathWithBackUrlExtension.php b/src/PrestaShopBundle/Twig/Extension/PathWithBackUrlExtension.php deleted file mode 100644 index 14deae26..00000000 --- a/src/PrestaShopBundle/Twig/Extension/PathWithBackUrlExtension.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Twig\Extension; - -use PrestaShop\PrestaShop\Core\Util\Url\BackUrlProvider; -use Symfony\Bridge\Twig\Extension\RoutingExtension; -use Symfony\Component\HttpFoundation\RequestStack; -use Twig\Extension\AbstractExtension; -use Twig\TwigFunction; - -/** - * This class adds a function to twig template which points to back url if such is found in current request. - */ -class PathWithBackUrlExtension extends AbstractExtension -{ - /** - * @var RoutingExtension - */ - private $routingExtension; - - /** - * @var BackUrlProvider - */ - private $backUrlProvider; - - /** - * @var RequestStack - */ - private $requestStack; - - /** - * @param RoutingExtension $routingExtension - * @param BackUrlProvider $backUrlProvider - * @param RequestStack|null $requestStack - */ - public function __construct( - RoutingExtension $routingExtension, - BackUrlProvider $backUrlProvider, - $requestStack - ) { - $this->routingExtension = $routingExtension; - $this->backUrlProvider = $backUrlProvider; - $this->requestStack = $requestStack; - } - - /** - * {@inheritdoc} - */ - public function getFunctions() - { - return [ - new TwigFunction( - 'pathWithBackUrl', - [$this, 'getPathWithBackUrl'] - ), - ]; - } - - /** - * Gets original path or back url path. - * - * @param string $name - route name - * @param array $parameters - route parameters - * @param bool $relative - * - * @return string - */ - public function getPathWithBackUrl($name, $parameters = [], $relative = false) - { - $fallbackPath = $this->routingExtension->getPath($name, $parameters, $relative); - - if (null === $this->requestStack) { - return $fallbackPath; - } - - $request = $this->requestStack->getCurrentRequest(); - - if (null === $request) { - return $fallbackPath; - } - - $backUrl = $this->backUrlProvider->getBackUrl($request); - - if (!$backUrl) { - return $fallbackPath; - } - - return $backUrl; - } -} diff --git a/src/PrestaShopBundle/Twig/HookExtension.php b/src/PrestaShopBundle/Twig/HookExtension.php deleted file mode 100644 index 6b2c4ff3..00000000 --- a/src/PrestaShopBundle/Twig/HookExtension.php +++ /dev/null @@ -1,208 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Twig; - -use PrestaShop\PrestaShop\Adapter\Module\ModuleDataProvider; -use PrestaShop\PrestaShop\Core\Addon\Module\ModuleRepository; -use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface; - -/** - * This class is used by Twig_Environment and provide some methods callable from a twig template. - */ -class HookExtension extends \Twig_Extension -{ - /** - * @var HookDispatcherInterface - */ - private $hookDispatcher; - - /** - * @var ModuleDataProvider - */ - private $moduleDataProvider; - - /** - * @var ModuleRepository - */ - private $moduleRepository; - - /** - * Constructor. - * - * @param HookDispatcherInterface $hookDispatcher - * @param ModuleDataProvider $moduleDataProvider - */ - public function __construct( - HookDispatcherInterface $hookDispatcher, - ModuleDataProvider $moduleDataProvider, - ModuleRepository $moduleRepository = null - ) { - $this->hookDispatcher = $hookDispatcher; - $this->moduleDataProvider = $moduleDataProvider; - $this->moduleRepository = $moduleRepository; - } - - /** - * Defines available filters. - * - * @return array Twig_SimpleFilter - */ - public function getFilters() - { - return [ - new \Twig_SimpleFilter('renderhook', [$this, 'renderHook'], ['is_safe' => ['html']]), - new \Twig_SimpleFilter('renderhooksarray', [$this, 'renderHooksArray'], ['is_safe' => ['html']]), - new \Twig_SimpleFilter('hooksarraycontent', [$this, 'hooksArrayContent']), - ]; - } - - /** - * Defines available functions. - * - * @return array Twig_SimpleFilter - */ - public function getFunctions() - { - return [ - new \Twig_SimpleFunction('renderhook', [$this, 'renderHook'], ['is_safe' => ['html']]), - new \Twig_SimpleFunction('renderhooksarray', [$this, 'renderHooksArray'], ['is_safe' => ['html']]), - new \Twig_SimpleFunction('hookcount', [$this, 'hookCount']), - new \Twig_SimpleFunction('hooksarraycontent', [$this, 'hooksArrayContent']), - ]; - } - - /** - * Returns the name of the extension. - * - * @return string The extension name - */ - public function getName() - { - return 'twig_hook_extension'; - } - - /** - * Calls the HookDispatcher, and dispatch a RenderingHookEvent. - * - * The listeners will then return html data to display in the Twig template. - * - * @param string $hookName the name of the hook to trigger - * @param array $hookParameters the parameters to send to the Hook - * - * @throws \Exception if the hookName is missing - * - * @return array[string] All listener's responses, ordered by the listeners' priorities - */ - public function renderHooksArray($hookName, $hookParameters = []) - { - if ('' == $hookName) { - throw new \Exception('Hook name missing'); - } - - // The call to the render of the hooks is encapsulated into a ob management to avoid any call of echo from the - // modules. - ob_start(); - $renderedHook = $this->hookDispatcher->dispatchRenderingWithParameters($hookName, $hookParameters); - $renderedHook->outputContent(); - ob_end_clean(); - - $render = []; - foreach ($renderedHook->getContent() as $module => $hookRender) { - $moduleAttributes = $this->moduleRepository->getModuleAttributes($module); - $render[] = [ - 'id' => $module, - 'name' => $this->moduleDataProvider->getModuleName($module), - 'content' => $hookRender, - 'attributes' => $moduleAttributes->all(), - ]; - } - - return $render; - } - - /** - * Calls the HookDispatcher, and dispatch a RenderingHookEvent. - * - * The listeners will then return html data to display in the Twig template. - * - * @param string $hookName the name of the hook to trigger - * @param array $hookParameters the parameters to send to the Hook - * - * @throws \Exception if the hookName is missing - * - * @return string all listener's responses, concatenated in a simple string, ordered by the listeners' priorities - */ - public function renderHook($hookName, array $hookParameters = []) - { - if ($hookName == '') { - throw new \Exception('Hook name missing'); - } - - return $this->hookDispatcher - ->dispatchRenderingWithParameters($hookName, $hookParameters) - ->outputContent(); - } - - /** - * Return the concatenated content of a renderHooksArray response - * - * @param array $hooksArray the array returned by the renderHooksArray function - * - * @return string - */ - public function hooksArrayContent($hooksArray) - { - if (!is_array($hooksArray)) { - return ''; - } - - $content = ''; - - foreach ($hooksArray as $hook) { - $content .= $hook['content'] ?? ''; - } - - return $content; - } - - /** - * Count how many listeners will respond to the hook name. - * Does not trigger the hook, so maybe some listeners could not add a response to the result. - * - * @deprecated since 1.7.7.0 - * - * @param string $hookName - * - * @return number the listeners count that will respond to the hook name - */ - public function hookCount($hookName) - { - @trigger_error('The ' . __METHOD__ . ' method is deprecated since version 1.7.7.0.', E_USER_DEPRECATED); - - return count($this->hookDispatcher->getListeners(strtolower($hookName))); - } -} diff --git a/src/PrestaShopBundle/Twig/LayoutExtension.php b/src/PrestaShopBundle/Twig/LayoutExtension.php deleted file mode 100644 index 29808cb7..00000000 --- a/src/PrestaShopBundle/Twig/LayoutExtension.php +++ /dev/null @@ -1,270 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Twig; - -use Exception; -use PrestaShop\PrestaShop\Adapter\Configuration; -use PrestaShop\PrestaShop\Adapter\Currency\CurrencyDataProvider; -use PrestaShop\PrestaShop\Adapter\LegacyContext; - -/** - * This class is used by Twig_Environment and provide layout methods callable from a twig template. - */ -class LayoutExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface -{ - /** @var LegacyContext */ - private $context; - - /** @var string */ - private $environment; - - /** @var Configuration */ - private $configuration; - - /** @var CurrencyDataProvider */ - private $currencyDataProvider; - - /** - * Constructor. - * - * Keeps the Context to look inside language settings. - * - * @param LegacyContext $context - * @param string $environment - * @param Configuration $configuration - * @param CurrencyDataProvider $currencyDataProvider - */ - public function __construct( - LegacyContext $context, - $environment, - Configuration $configuration, - CurrencyDataProvider $currencyDataProvider - ) { - $this->context = $context; - $this->environment = $environment; - $this->configuration = $configuration; - $this->currencyDataProvider = $currencyDataProvider; - } - - /** - * Provides globals for Twig templates. - * - * @return array the base globals available in twig templates - */ - public function getGlobals() - { - /* - * As this is a twig extension we need to be very resilient and prevent it from crashing - * the environment, for example the command debug:twig should not fail because of this extension - */ - - try { - $defaultCurrency = $this->context->getEmployeeCurrency() ?: $this->currencyDataProvider->getDefaultCurrency(); - } catch (\Exception $e) { - $defaultCurrency = null; - } - try { - $rootUrl = $this->context->getRootUrl(); - } catch (\Exception $e) { - $rootUrl = null; - } - - return [ - 'theme' => $this->context->getContext()->shop->theme, - 'default_currency' => $defaultCurrency, - 'root_url' => $rootUrl, - 'js_translatable' => [], - ]; - } - - /** - * Define available filters. - * - * @return array Twig_SimpleFilter - */ - public function getFilters() - { - return [ - new \Twig_SimpleFilter('configuration', [$this, 'getConfiguration']), - ]; - } - - /** - * Returns a list of functions to add to the existing list. - * - * @return array An array of functions - */ - public function getFunctions() - { - return [ - new \Twig_SimpleFunction('getLegacyLayout', [$this, 'getLegacyLayout']), - new \Twig_SimpleFunction('getAdminLink', [$this, 'getAdminLink']), - new \Twig_SimpleFunction('youtube_link', [$this, 'getYoutubeLink']), - ]; - } - - /** - * Returns a legacy configuration key. - * - * @param string $key - * - * @return array An array of functions - */ - public function getConfiguration($key) - { - return $this->configuration->get($key); - } - - /** - * Get admin legacy layout into old controller context. - * - * Parameters can be set manually into twig template or sent from controller - * For details : check Resources/views/Admin/Layout.html.twig - * - * @param string $controllerName The legacy controller name - * @param string $title The page title to override default one - * @param array $headerToolbarBtn The header toolbar to override - * @param string $displayType The legacy display type variable - * @param bool $showContentHeader Can force header toolbar (buttons and title) to be hidden with false value - * @param array|string $headerTabContent Tabs labels - * @param bool $enableSidebar Allow to use right sidebar to display docs for instance - * @param string $helpLink If specified, will be used instead of legacy one - * @param string $metaTitle - * @param bool $useRegularH1Structure allows complex

      structure if set to false - * - * @throws Exception if legacy layout has no $content var replacement - * - * @return string The html layout - */ - public function getLegacyLayout( - $controllerName = '', - $title = '', - $headerToolbarBtn = [], - $displayType = '', - $showContentHeader = true, - $headerTabContent = '', - $enableSidebar = false, - $helpLink = '', - $jsRouterMetadata = [], - $metaTitle = '', - $useRegularH1Structure = true - ) { - if ($this->environment == 'test') { - return <<<'EOF' - - - Test layout - {% block stylesheets %}{% endblock %}{% block extra_stylesheets %}{% endblock %} - - - {% block content_header %}{% endblock %} - {% block content %}{% endblock %} - {% block content_footer %}{% endblock %} - {% block javascripts %}{% endblock %} - {% block extra_javascripts %}{% endblock %} - {% block translate_javascripts %}{% endblock %} - - -EOF; - } - - $layout = $this->context->getLegacyLayout( - $controllerName, - $title, - $headerToolbarBtn, - $displayType, - $showContentHeader, - $headerTabContent, - $enableSidebar, - $helpLink, - $jsRouterMetadata, - $metaTitle, - $useRegularH1Structure - ); - - //test if legacy template from "content.tpl" has '{$content}' - if (false === strpos($layout, '{$content}')) { - throw new Exception('PrestaShopBundle\Twig\LayoutExtension cannot find the {$content} string in legacy layout template', 1); - } - - $content = str_replace( - [ - '{$content}', - 'var currentIndex = \'index.php\';', - '', - '', - ], - [ - '{% block content_header %}{% endblock %} - {% block content %}{% endblock %} - {% block content_footer %}{% endblock %} - {% block sidebar_right %}{% endblock %}', - 'var currentIndex = \'' . $this->context->getAdminLink($controllerName) . '\';', - '{% block stylesheets %}{% endblock %}{% block extra_stylesheets %}{% endblock %}', - '{% block javascripts %}{% endblock %}{% block extra_javascripts %}{% endblock %}{% block translate_javascripts %}{% endblock %}', - ], - $layout - ); - - return $content; - } - - /** - * This is a Twig port of the Smarty {$link->getAdminLink()} function. - * - * @param string $controller the controller name - * @param bool $withToken - * @param array[string] $extraParams - * - * @return string - */ - public function getAdminLink($controllerName, $withToken = true, $extraParams = []) - { - return $this->context->getAdminLink($controllerName, $withToken, $extraParams); - } - - /** - * KISS function to get an embeded iframe from Youtube. - */ - public function getYoutubeLink($watchUrl) - { - $embedUrl = str_replace(['watch?v=', 'youtu.be/'], ['embed/', 'youtube.com/embed/'], $watchUrl); - - return ''; - } - - /** - * Returns the name of the extension. - * - * @return string The extension name - */ - public function getName() - { - return 'twig_layout_extension'; - } -} diff --git a/src/PrestaShopBundle/Twig/Locator/ModuleTemplateIterator.php b/src/PrestaShopBundle/Twig/Locator/ModuleTemplateIterator.php deleted file mode 100644 index 6e9432de..00000000 --- a/src/PrestaShopBundle/Twig/Locator/ModuleTemplateIterator.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Twig\Locator; - -use Symfony\Bundle\TwigBundle\TemplateIterator; -use Symfony\Component\Finder\Finder; -use Symfony\Component\HttpKernel\KernelInterface; - -/** - * Extended class: Iterator for all templates in bundles and in the application Resources directory. - * This one applies a specific filter on the module folder, in order to take only *.twig - */ -class ModuleTemplateIterator extends TemplateIterator -{ - private $kernel; - private $rootDir; - private $templates; - private $paths; - private $defaultPath; - - /** - * @param KernelInterface $kernel A KernelInterface instance - * @param string $rootDir The directory where global templates can be stored - * @param array $paths Additional Twig paths to warm - * @param string $defaultPath The directory where global templates can be stored - */ - public function __construct(KernelInterface $kernel, $rootDir, array $paths = [], $defaultPath = null) - { - $this->paths = []; - $this->kernel = $kernel; - $this->rootDir = $rootDir; - $this->defaultPath = $defaultPath; - - $keyToRemove = array_search('Modules', $paths); - // If the key was found, move it in a new array - if (false !== $keyToRemove) { - $exceptionPath = $paths[$keyToRemove]; - unset($paths[$keyToRemove]); - $this->paths = [$keyToRemove => $exceptionPath]; - } - parent::__construct($kernel, $rootDir, $paths, $defaultPath); - } - - /** - * {@inheritdoc} - */ - public function getIterator() - { - if (null !== $this->templates) { - return $this->templates; - } - - // Not done yet, we need the array back - $this->templates = iterator_to_array(parent::getIterator()); - - foreach ($this->paths as $dir => $namespace) { - $this->templates = array_merge($this->templates, $this->findTemplatesInDirectory($dir, $namespace)); - } - - return $this->templates = new \ArrayIterator(array_unique($this->templates)); - } - - /** - * Find templates in the given directory. - * - * @param string $dir The directory where to look for templates - * @param string|null $namespace The template namespace - * - * @return array - */ - private function findTemplatesInDirectory($dir, $namespace = null, array $excludeDirs = []) - { - if (!is_dir($dir)) { - return []; - } - - $templates = []; - foreach (Finder::create()->files()->name('*.twig')->followLinks()->in($dir)->exclude($excludeDirs) as $file) { - $templates[] = (null !== $namespace ? '@' . $namespace . '/' : '') . str_replace('\\', '/', $file->getRelativePathname()); - } - - return $templates; - } -} diff --git a/src/PrestaShopBundle/Twig/Locator/ModuleTemplateLoader.php b/src/PrestaShopBundle/Twig/Locator/ModuleTemplateLoader.php deleted file mode 100644 index f378ef37..00000000 --- a/src/PrestaShopBundle/Twig/Locator/ModuleTemplateLoader.php +++ /dev/null @@ -1,67 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Twig\Locator; - -use Twig\Loader\FilesystemLoader; - -/** - * Loads templates from PrestaShop modules. - */ -class ModuleTemplateLoader extends FilesystemLoader -{ - /** - * @param array $namespaces a collection of path namespaces with namespace names - * @param array $modulePaths A path or an array of paths where to look for module templates - */ - public function __construct(array $namespaces, array $modulePaths = []) - { - if (!empty($modulePaths)) { - $this->registerNamespacesFromConfig($modulePaths, $namespaces); - } - } - - /** - * Register namespaces in module and link them to the right paths. - * - * @param array $modulePaths - * @param array $namespaces - */ - private function registerNamespacesFromConfig(array $modulePaths, array $namespaces) - { - foreach ($namespaces as $namespace => $namespacePath) { - $templatePaths = []; - - foreach ($modulePaths as $path) { - if (is_dir($dir = $path . '/views/PrestaShop/' . $namespacePath)) { - $templatePaths[] = $dir; - } - } - $this->setPaths($templatePaths, $namespace); - } - } -} diff --git a/src/PrestaShopBundle/Twig/TranslationsExtension.php b/src/PrestaShopBundle/Twig/TranslationsExtension.php deleted file mode 100644 index 5c70658f..00000000 --- a/src/PrestaShopBundle/Twig/TranslationsExtension.php +++ /dev/null @@ -1,573 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Twig; - -use Doctrine\Common\Util\Inflector; -use Symfony\Component\DependencyInjection\ContainerInterface; -use Symfony\Component\Routing\RouterInterface; - -class TranslationsExtension extends \Twig_Extension -{ - /** - * @var \Symfony\Component\Translation\TranslatorInterface - */ - public $translator; - - /** - * @var \Psr\Log\LoggerInterface - */ - public $logger; - - /** - * @var ContainerInterface - */ - private $container; - - /** - * @var RouterInterface - */ - private $router; - - /** - * @var string - */ - private $theme; - - public function __construct(ContainerInterface $container, RouterInterface $router) - { - $this->container = $container; - $this->router = $router; - } - - /** - * Returns a list of functions to add to the existing list. - * - * @return array An array of functions - */ - public function getFunctions() - { - return [ - new \Twig_SimpleFunction('getTranslationsTree', [$this, 'getTranslationsTree']), - new \Twig_SimpleFunction('getTranslationsForms', [$this, 'getTranslationsForms']), - ]; - } - - /** - * Returns concatenated edit translation forms. - * - * @param array $translationsTree - * @param null $themeName - * - * @return string - */ - public function getTranslationsForms(array $translationsTree, $themeName = null) - { - $output = ''; - $viewProperties = $this->getSharedEditFormViewProperties(); - $viewProperties['is_search_results'] = true; - $this->theme = $themeName; - - foreach ($translationsTree as $topLevelDomain => $tree) { - $output .= $this->concatenateEditTranslationForm($tree, $viewProperties); - } - - return $output; - } - - public function concatenateEditTranslationForm($subtree, $viewProperties) - { - $output = ''; - $hasMessages = $this->hasMessages($subtree); - - if ($hasMessages) { - $camelizedDomain = reset(array_keys($subtree['__messages'])); - $messages = $subtree['__messages'][$camelizedDomain]; - - foreach ($messages as $translationKey => $translation) { - $viewProperties['camelized_domain'] = $camelizedDomain; - $viewProperties['translation_key'] = $translationKey; - $viewProperties['translation'] = $translation; - - $output .= $this->renderEditTranslationForm($viewProperties); - } - } else { - foreach ($subtree as $tree) { - $output .= $this->concatenateEditTranslationForm($tree, $viewProperties); - } - } - - if ($hasMessages && count($subtree) > 1) { - unset($subtree['__messages']); - $output .= $this->concatenateEditTranslationForm($subtree, $viewProperties); - } - - return $output; - } - - /** - * Returns a tree of translations key values. - * - * @param array $translationsTree - * @param null $themeName - * - * @return string - */ - public function getTranslationsTree(array $translationsTree, $themeName = null) - { - $this->theme = $themeName; - - $output = ''; - - foreach ($translationsTree as $topLevelDomain => $tree) { - $output .= $this->concatenateSubtreeHeader($topLevelDomain, $tree); - } - - return $output; - } - - /** - * @param $tree - * @param int $level - * - * @return string - */ - public function makeSubtree($tree, $level = 3) - { - $output = ''; - $messagesSubtree = $this->hasMessages($tree); - - if ($messagesSubtree) { - $camelizedDomain = reset(array_keys($tree['__messages'])); - $messagesTree = $tree['__messages'][$camelizedDomain]; - - $formIndex = 0; - $pageIndex = 1; - $itemsPerPage = 25; - $output .= '
      '; - - $viewProperties = $this->getSharedEditFormViewProperties(); - - foreach ($messagesTree as $translationKey => $translation) { - $viewProperties['camelized_domain'] = $camelizedDomain; - $viewProperties['translation_key'] = $translationKey; - $viewProperties['translation'] = $translation; - - $output .= $this->renderEditTranslationForm($viewProperties); - - $isLastPage = $formIndex + 1 === count($messagesTree); - - if ($isLastPage) { - $output .= '
      '; - } elseif ((0 === $formIndex % $itemsPerPage) && ($formIndex > 0)) { - ++$pageIndex; - - // Close div with page class - $output .= '

      '; - $output .= '
      '; - } - - ++$formIndex; - } - - // Close div with page class when no message is available - if (count($messagesTree) === 0) { - $output .= '
      '; - } - } else { - foreach ($tree as $subdomain => $subtree) { - $output .= $this->concatenateSubtreeHeader($subdomain, $subtree, $level); - } - } - - return $output; - } - - /** - * @return array - */ - protected function getSharedEditFormViewProperties() - { - return [ - 'action' => $this->router->generate('admin_international_translations_edit'), - 'label_edit' => $this->translator->trans('Save', [], 'Admin.Actions'), - 'label_reset' => $this->translator->trans('Reset', [], 'Admin.Actions'), - 'notification_success' => $this->translator->trans( - 'Translation successfully updated', - [], - 'Admin.International.Notification' - ), - 'notification_error' => $this->translator->trans( - 'Failed to update translation', - [], - 'Admin.International.Notification' - ), - ]; - } - - /** - * @param $properties - * - * @return mixed|string - */ - protected function renderEditTranslationForm($properties) - { - list($domain, $locale) = explode('.', $properties['camelized_domain']); - $translationValue = $this->getTranslationValue($properties['translation']); - $defaultTranslationValue = $this->getDefaultTranslationValue( - $properties['translation_key'], - $domain, - $locale, - $properties['translation'] - ); - - $isSearchResults = false; - - if (array_key_exists('is_search_results', $properties)) { - $isSearchResults = $properties['is_search_results']; - } - - $breadcrumbParts = explode('_', Inflector::tableize($domain)); - - return $this->container->get('templating')->render( - '@PrestaShop/Admin/Translations/include/form-edit-message.html.twig', - [ - 'default_translation_value' => $defaultTranslationValue, - 'domain' => $domain, - 'edited_translation_value' => $translationValue, - 'is_translated' => '' !== $translationValue, - 'action' => $properties['action'], - 'label_edit' => $properties['label_edit'], - 'label_reset' => $properties['label_reset'], - 'locale' => $locale, - 'notification_error' => $properties['notification_error'], - 'notification_success' => $properties['notification_success'], - 'translation_key' => $properties['translation_key'], - 'hash' => $this->getTranslationHash($domain, $properties['translation_key']), - 'theme' => $this->theme, - 'breadcrumb_parts' => $breadcrumbParts, - 'is_search_results' => $isSearchResults, - ] - ); - } - - protected function getTranslationHash($domain, $translationKey) - { - return md5($domain . $translationKey); - } - - /** - * @param $translationKey - * @param $domain - * @param $locale - * @param $translationValue - * - * @return array - */ - protected function getDefaultTranslationValue($translationKey, $domain, $locale, $translationValue) - { - $defaultTranslationValue = $this->translator->trans($translationKey, [], $domain, $locale); - - // Extract default translation value from xliff files for reset - if (is_array($translationValue)) { - $defaultTranslationValue = $translationValue['xlf']; - } - - return $defaultTranslationValue; - } - - /** - * @param $translation - * - * @return mixed - */ - protected function getTranslationValue($translation) - { - return !empty($translation['db']) ? $translation['db'] : $translation['xlf']; - } - - /** - * @param $tree - * - * @return bool - */ - protected function hasMessages($tree) - { - return array_key_exists('__messages', $tree); - } - - /** - * Returns the name of the extension. - * - * @return string The extension name - */ - public function getName() - { - return 'twig_translations_extension'; - } - - /** - * @param $subdomain - * @param $subtree - * @param int $level - * - * @return string - */ - protected function concatenateSubtreeHeader($subdomain, $subtree, $level = 2) - { - $hasMessagesSubtree = $this->hasMessages($subtree); - $subject = $subdomain; - - $id = null; - if ($hasMessagesSubtree) { - $id = $this->parseDomain($subtree); - } - - $output = $this->tagSubject($subject, $hasMessagesSubtree, $id); - - if (!$hasMessagesSubtree) { - $output = str_replace( - '{{ missing translations warning }}', - $this->translator->trans('%d missing', [], 'Admin.International.Feature'), - $output - ); - } else { - $output = $this->replaceWarningPlaceholder($output, $subtree); - } - - if ($hasMessagesSubtree) { - $output .= $this->container->get('templating')->render( - '@PrestaShop/Admin/Translations/include/button-toggle-messages-visibility.html.twig', - [ - 'label_show_messages' => $this->translator->trans('Show messages', [], 'Admin.International.Feature'), - 'label_hide_messages' => $this->translator->trans('Hide messages', [], 'Admin.International.Feature'), - ] - ); - - $output .= $this->getNavigation($this->parseDomain($subtree)); - } - - $formStart = $this->getTranslationsFormStart($subtree, $output); - $output = $this->container->get('templating')->render( - '@PrestaShop/Admin/Translations/include/translations-form-end.html.twig', - [ - 'form_start' => $formStart, - 'subtree' => $this->makeSubtree($subtree, $level + 1), - ] - ); - - if ($hasMessagesSubtree) { - // Close div with translation-domain class - $output .= ''; - - // A subtree with messages contains at least a subdomain - if (count($subtree) > 1) { - unset($subtree['__messages']); - $output .= $this->concatenateSubtreeHeader($subdomain, $subtree, $level); - } - } - - return $output; - } - - /** - * @param $subtree - * @param $output - * - * @return string - */ - protected function getTranslationsFormStart(&$subtree, $output) - { - $id = ''; - $parentAttribute = ' class="subdomains hide"'; - if (array_key_exists('__fixed_length_id', $subtree)) { - $fixedLengthId = $subtree['__fixed_length_id']; - unset($subtree['__fixed_length_id']); - $id = ' id="' . $fixedLengthId . '" '; - $parentAttribute = ' data-parent-of="' . $fixedLengthId . '"'; - } - - $domainAttribute = ''; - if (array_key_exists('__domain', $subtree)) { - $domainAttribute = ' data-domain="' . $subtree['__domain'] . '" '; - unset($subtree['__domain']); - } - - $totalTranslationsAttribute = ''; - if (array_key_exists('__messages', $subtree)) { - $totalTranslations = count(array_values($subtree['__messages'])[0]); - $totalTranslationsAttribute = ' data-total-translations="' . $this->translator->trans( - '%nb_translations% expressions', - ['%nb_translations%' => $totalTranslations], - 'Admin.International.Feature' - ) . '"'; - } - - $missingTranslationsAttribute = ''; - if (array_key_exists('__metadata', $subtree)) { - $missingTranslations = $subtree['__metadata']['missing_translations']; - $missingTranslationsAttribute = ' data-missing-translations="' . $missingTranslations . '"'; - unset($subtree['__metadata']); - } - - return $this->container->get('templating')->render( - '@PrestaShop/Admin/Translations/include/translations-form-start.html.twig', - [ - 'id' => $id, - 'domain' => $domainAttribute, - 'parent' => $parentAttribute, - 'total_translations' => $totalTranslationsAttribute, - 'missing_translations' => $missingTranslationsAttribute, - 'title' => $output, - ] - ); - } - - /** - * @param $output - * @param $subtree - * - * @return string - */ - protected function replaceWarningPlaceholder($output, $subtree) - { - $missingTranslationsMessage = ''; - $missingTranslationsLongMessage = ''; - $missingTranslationsClass = ''; - if (array_key_exists('__metadata', $subtree) && $subtree['__metadata']['missing_translations'] > 0) { - $missingTranslationsCount = $subtree['__metadata']['missing_translations']; - $domain = $subtree['__metadata']['domain']; - - $missingTranslationsMessage = - '
      ' . - $this->translator->trans( - '%nb_translations% missing', - ['%nb_translations%' => $missingTranslationsCount], - 'Admin.International.Feature' - ) . - '
      '; - $missingTranslationsLongMessage = - '
      ' . - $this->translator->trans( - '%nb_translations% translations are missing in %domain%', - [ - '%nb_translations%' => $missingTranslationsCount, - '%domain%' => $domain, - ], - 'Admin.International.Feature' - ) . - '
      '; - $missingTranslationsClass = ' missing-translations'; - } - - $warning = str_replace( - [ - '{{ missing translations message }}', - '{{ missing translations long message }}', - ], - [ - $missingTranslationsMessage, - $missingTranslationsLongMessage, - ], - '{{ missing translations message }}{{ missing translations long message }}' - ); - - return str_replace( - [ - '{{ missing translations warning }}', - '{{ missing translations class }}', - ], - [ - $warning, - $missingTranslationsClass, - ], - $output - ); - } - - /** - * @param $subtree - * - * @return mixed - */ - protected function parseDomain($subtree) - { - list($camelizedDomain) = $subtree['__messages']; - list($domain) = explode('.', $camelizedDomain); - - return $domain; - } - - /** - * @param $id - * - * @return string - */ - protected function getNavigation($id) - { - return $this->container->get('templating')->render( - '@PrestaShop/Admin/Translations/include/pagination-bar.html.twig', - ['page_id' => $id] - ); - } - - /** - * @param $subject - * @param $isLastChild - * @param null $id - * - * @return string - */ - protected function tagSubject($subject, $isLastChild, $id = null) - { - if ($isLastChild) { - $openingTag = '

      ' . - ''; - $closingTag = '{{ missing translations warning }}

      '; - } else { - $openingTag = '

      '; - $closingTag = '' . - '
      ' . - '' . - '{{ missing translations warning }}' . - '' . - '
      ' . - '

      '; - } - - if ($id) { - $openingTag = ''; - $closingTag = ''; - - if (!$isLastChild) { - $openingTag = '

      ' . $openingTag; - $closingTag = $closingTag . '

      '; - } - } - - return $openingTag . $subject . $closingTag; - } -} diff --git a/src/PrestaShopBundle/Utils/FloatParser.php b/src/PrestaShopBundle/Utils/FloatParser.php deleted file mode 100644 index 0d9402a7..00000000 --- a/src/PrestaShopBundle/Utils/FloatParser.php +++ /dev/null @@ -1,103 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Utils; - -use PrestaShop\PrestaShop\Core\Util\ArabicToLatinDigitConverter; - -/** - * Converts strings into floats. - */ -class FloatParser -{ - /** - * @var ArabicToLatinDigitConverter - */ - private $arabicToLatinNumberConverter; - - public function __construct(ArabicToLatinDigitConverter $arabicToLatinDigitConverter = null) - { - $this->arabicToLatinNumberConverter = $arabicToLatinDigitConverter ?? new ArabicToLatinDigitConverter(); - } - - /** - * Constructs a float value from an arbitrarily-formatted string. - * - * This method supports any thousand and decimal separator. - * If the string is ambiguous (e.g. 123,456) the interpreter will interpret the last group of numbers - * as the decimal part. - * - * In order to prevent unexpected behavior, make sure that your value has a decimal part. - * - * Examples: - * - '123,456' --> 123.456 - * - '123,456,00' --> 123456.00 - * - '12,345,678 --> 12345.678 - * - * @param string $value - * - * @throws \InvalidArgumentException if the provided value is not a string - * or if it cannot be interpreted as a number - * - * @return float - */ - public function fromString($value) - { - if (!is_string($value)) { - throw new \InvalidArgumentException(sprintf('Invalid argument: string expected, got %s', gettype($value))); - } - - $value = trim($value); - if ('' === $value) { - return 0.0; - } - - // replace arabic numbers by latin - $value = $this->arabicToLatinNumberConverter->convert($value); - - // remove all non-digit characters - $split = preg_split('/[^\dE-]+/', $value); - - if (1 === count($split)) { - // there's no decimal part - return (float) $value; - } - - foreach ($split as $part) { - if ('' === $part) { - throw new \InvalidArgumentException(sprintf('Invalid argument: "%s" cannot be interpreted as a number', $value)); - } - } - - // use the last part as decimal - $decimal = array_pop($split); - - // reconstruct the number using dot as decimal separator - $value = implode('', $split) . '.' . $decimal; - - return (float) $value; - } -} diff --git a/src/PrestaShopBundle/Utils/ZipManager.php b/src/PrestaShopBundle/Utils/ZipManager.php deleted file mode 100644 index d72048fe..00000000 --- a/src/PrestaShopBundle/Utils/ZipManager.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -namespace PrestaShopBundle\Utils; - -use RecursiveDirectoryIterator; -use RecursiveIteratorIterator; -use ZipArchive; - -class ZipManager -{ - public function createArchive($filename, $folder) - { - $zip = new ZipArchive(); - - $zip->open($filename, ZipArchive::CREATE | ZipArchive::OVERWRITE); - - $files = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($folder), - RecursiveIteratorIterator::LEAVES_ONLY - ); - - foreach ($files as $filename => $file) { - if (!$file->isDir()) { - $filePath = $file->getRealPath(); - $relativePath = substr($filename, strlen($folder) + 1); - - $zip->addFile($filePath, $relativePath); - } - } - - $zip->close(); - } -} diff --git a/themes/classic/assets/css/012cf6a10129e2275d79d6adac7f3b02.woff b/themes/classic/assets/css/012cf6a10129e2275d79d6adac7f3b02.woff deleted file mode 100644 index b648a3ee..00000000 Binary files a/themes/classic/assets/css/012cf6a10129e2275d79d6adac7f3b02.woff and /dev/null differ diff --git a/themes/classic/assets/css/0266b05265f317a7409560b751cd61e8.svg b/themes/classic/assets/css/0266b05265f317a7409560b751cd61e8.svg deleted file mode 100644 index 5c2fae4a..00000000 --- a/themes/classic/assets/css/0266b05265f317a7409560b751cd61e8.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - diff --git a/themes/classic/assets/css/082a71677e756fb75817e8f262a07cb4.svg b/themes/classic/assets/css/082a71677e756fb75817e8f262a07cb4.svg deleted file mode 100644 index 119defaa..00000000 --- a/themes/classic/assets/css/082a71677e756fb75817e8f262a07cb4.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - - Artboard 3 - Created with Sketch. - - - - - - - - - - - - - \ No newline at end of file diff --git a/themes/classic/assets/css/154da4697acc779b55af0a67f1241e4e.ttf b/themes/classic/assets/css/154da4697acc779b55af0a67f1241e4e.ttf deleted file mode 100644 index dc93fea6..00000000 Binary files a/themes/classic/assets/css/154da4697acc779b55af0a67f1241e4e.ttf and /dev/null differ diff --git a/themes/classic/assets/css/199038f07312bfc6f0aabd3ed6a2b64d.woff2 b/themes/classic/assets/css/199038f07312bfc6f0aabd3ed6a2b64d.woff2 deleted file mode 100644 index 3fa1dbd0..00000000 Binary files a/themes/classic/assets/css/199038f07312bfc6f0aabd3ed6a2b64d.woff2 and /dev/null differ diff --git a/themes/classic/assets/css/19c1b868764c0e4d15a45d3f61250488.woff2 b/themes/classic/assets/css/19c1b868764c0e4d15a45d3f61250488.woff2 deleted file mode 100644 index 974e79bf..00000000 Binary files a/themes/classic/assets/css/19c1b868764c0e4d15a45d3f61250488.woff2 and /dev/null differ diff --git a/themes/classic/assets/css/22c0528acb6d9cd5bf4c8f96381bc05c.svg b/themes/classic/assets/css/22c0528acb6d9cd5bf4c8f96381bc05c.svg deleted file mode 100644 index 6cf1a7d4..00000000 --- a/themes/classic/assets/css/22c0528acb6d9cd5bf4c8f96381bc05c.svg +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/themes/classic/assets/css/2fd9c16b805724d590c0cff96da070a4.ttf b/themes/classic/assets/css/2fd9c16b805724d590c0cff96da070a4.ttf deleted file mode 100644 index 9dd10199..00000000 Binary files a/themes/classic/assets/css/2fd9c16b805724d590c0cff96da070a4.ttf and /dev/null differ diff --git a/themes/classic/assets/css/332f555bb44cdc394d6c799df0c03389.woff b/themes/classic/assets/css/332f555bb44cdc394d6c799df0c03389.woff deleted file mode 100644 index f9fefea1..00000000 Binary files a/themes/classic/assets/css/332f555bb44cdc394d6c799df0c03389.woff and /dev/null differ diff --git a/themes/classic/assets/css/36bff72dcba3098b4b70b482b22c29ab.svg b/themes/classic/assets/css/36bff72dcba3098b4b70b482b22c29ab.svg deleted file mode 100644 index fa59f8c3..00000000 --- a/themes/classic/assets/css/36bff72dcba3098b4b70b482b22c29ab.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - diff --git a/themes/classic/assets/css/3935e107ea61866e60d7946dc6a962f1.svg b/themes/classic/assets/css/3935e107ea61866e60d7946dc6a962f1.svg deleted file mode 100644 index 79dd127b..00000000 --- a/themes/classic/assets/css/3935e107ea61866e60d7946dc6a962f1.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - diff --git a/themes/classic/assets/css/3a2aeeba930cc29e4d31ebfa1b7cdaa2.svg b/themes/classic/assets/css/3a2aeeba930cc29e4d31ebfa1b7cdaa2.svg deleted file mode 100644 index 4211f857..00000000 --- a/themes/classic/assets/css/3a2aeeba930cc29e4d31ebfa1b7cdaa2.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - - Artboard 3 Copy - Created with Sketch. - - - - - - - - - - - - - \ No newline at end of file diff --git a/themes/classic/assets/css/3d34be670a7f15086e512282b97ae35e.svg b/themes/classic/assets/css/3d34be670a7f15086e512282b97ae35e.svg deleted file mode 100644 index a17acab1..00000000 --- a/themes/classic/assets/css/3d34be670a7f15086e512282b97ae35e.svg +++ /dev/null @@ -1,19092 +0,0 @@ - - - - -Copyright 2012 Google Inc. All Rights Reserved. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/themes/classic/assets/css/3d4a907b1b7a232654324a3dd7ae4aa3.eot b/themes/classic/assets/css/3d4a907b1b7a232654324a3dd7ae4aa3.eot deleted file mode 100644 index da280515..00000000 Binary files a/themes/classic/assets/css/3d4a907b1b7a232654324a3dd7ae4aa3.eot and /dev/null differ diff --git a/themes/classic/assets/css/3f81521029cc8a9a703419c4a74704a0.woff b/themes/classic/assets/css/3f81521029cc8a9a703419c4a74704a0.woff deleted file mode 100644 index f5ac220e..00000000 Binary files a/themes/classic/assets/css/3f81521029cc8a9a703419c4a74704a0.woff and /dev/null differ diff --git a/themes/classic/assets/css/4f6ff3639c1e5728b905b650c1a06e75.ttf b/themes/classic/assets/css/4f6ff3639c1e5728b905b650c1a06e75.ttf deleted file mode 100644 index 51b7b295..00000000 Binary files a/themes/classic/assets/css/4f6ff3639c1e5728b905b650c1a06e75.ttf and /dev/null differ diff --git a/themes/classic/assets/css/570eb83859dc23dd0eec423a49e147fe.woff2 b/themes/classic/assets/css/570eb83859dc23dd0eec423a49e147fe.woff2 deleted file mode 100644 index 9fa21125..00000000 Binary files a/themes/classic/assets/css/570eb83859dc23dd0eec423a49e147fe.woff2 and /dev/null differ diff --git a/themes/classic/assets/css/5dc400bcedda37b13f35cb44623193cf.svg b/themes/classic/assets/css/5dc400bcedda37b13f35cb44623193cf.svg deleted file mode 100644 index a8552d88..00000000 --- a/themes/classic/assets/css/5dc400bcedda37b13f35cb44623193cf.svg +++ /dev/null @@ -1,27050 +0,0 @@ - - - - -Copyright 2012 Google Inc. All Rights Reserved. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/themes/classic/assets/css/5ea9fdf2293930126fa9c544968009ae.svg b/themes/classic/assets/css/5ea9fdf2293930126fa9c544968009ae.svg deleted file mode 100644 index 2396312c..00000000 --- a/themes/classic/assets/css/5ea9fdf2293930126fa9c544968009ae.svg +++ /dev/null @@ -1,27184 +0,0 @@ - - - - -Copyright 2012 Google Inc. All Rights Reserved. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/themes/classic/assets/css/7988be8b63edf9c4accebf94d5db7927.svg b/themes/classic/assets/css/7988be8b63edf9c4accebf94d5db7927.svg deleted file mode 100644 index e6bc45c5..00000000 --- a/themes/classic/assets/css/7988be8b63edf9c4accebf94d5db7927.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - diff --git a/themes/classic/assets/css/7a3ebca0cba2e2c6090e84e1d77e0f94.woff2 b/themes/classic/assets/css/7a3ebca0cba2e2c6090e84e1d77e0f94.woff2 deleted file mode 100644 index 229d8699..00000000 Binary files a/themes/classic/assets/css/7a3ebca0cba2e2c6090e84e1d77e0f94.woff2 and /dev/null differ diff --git a/themes/classic/assets/css/7c24d4275efcbe8891f78378b7c808e0.svg b/themes/classic/assets/css/7c24d4275efcbe8891f78378b7c808e0.svg deleted file mode 100644 index 8b0b870a..00000000 --- a/themes/classic/assets/css/7c24d4275efcbe8891f78378b7c808e0.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - diff --git a/themes/classic/assets/css/80e74ff9406650e53bbec1e292c2c094.svg b/themes/classic/assets/css/80e74ff9406650e53bbec1e292c2c094.svg deleted file mode 100644 index 859d7dca..00000000 --- a/themes/classic/assets/css/80e74ff9406650e53bbec1e292c2c094.svg +++ /dev/null @@ -1,24745 +0,0 @@ - - - - -Copyright 2012 Google Inc. All Rights Reserved. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/themes/classic/assets/css/846c191efd3d0aacde5a916cf2ebf1a4.woff b/themes/classic/assets/css/846c191efd3d0aacde5a916cf2ebf1a4.woff deleted file mode 100644 index 07640c15..00000000 Binary files a/themes/classic/assets/css/846c191efd3d0aacde5a916cf2ebf1a4.woff and /dev/null differ diff --git a/themes/classic/assets/css/8b05d51ede908907d65695558974d86f.svg b/themes/classic/assets/css/8b05d51ede908907d65695558974d86f.svg deleted file mode 100644 index 60566132..00000000 --- a/themes/classic/assets/css/8b05d51ede908907d65695558974d86f.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - diff --git a/themes/classic/assets/css/99db8adec61e4fcf5586e1afa549b432.svg b/themes/classic/assets/css/99db8adec61e4fcf5586e1afa549b432.svg deleted file mode 100644 index bac31217..00000000 --- a/themes/classic/assets/css/99db8adec61e4fcf5586e1afa549b432.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - - Artboard 3 Copy 2 - Created with Sketch. - - - - - - - - - - - - - \ No newline at end of file diff --git a/themes/classic/assets/css/a165a42685795361b25593effb32fdb1.ttf b/themes/classic/assets/css/a165a42685795361b25593effb32fdb1.ttf deleted file mode 100644 index 6e00cdce..00000000 Binary files a/themes/classic/assets/css/a165a42685795361b25593effb32fdb1.ttf and /dev/null differ diff --git a/themes/classic/assets/css/a37b0c01c0baf1888ca812cc0508f6e2.ttf b/themes/classic/assets/css/a37b0c01c0baf1888ca812cc0508f6e2.ttf deleted file mode 100644 index 7015564a..00000000 Binary files a/themes/classic/assets/css/a37b0c01c0baf1888ca812cc0508f6e2.ttf and /dev/null differ diff --git a/themes/classic/assets/css/a67175d1ea11389d9107bd8c08f9d7d7.svg b/themes/classic/assets/css/a67175d1ea11389d9107bd8c08f9d7d7.svg deleted file mode 100644 index 0cf96aa4..00000000 --- a/themes/classic/assets/css/a67175d1ea11389d9107bd8c08f9d7d7.svg +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - diff --git a/themes/classic/assets/css/a68cfe9d548950edf5df102269877edd.woff2 b/themes/classic/assets/css/a68cfe9d548950edf5df102269877edd.woff2 deleted file mode 100644 index d21ed877..00000000 Binary files a/themes/classic/assets/css/a68cfe9d548950edf5df102269877edd.woff2 and /dev/null differ diff --git a/themes/classic/assets/css/a77ade19de3d3762dfbf1fe553b293cc.eot b/themes/classic/assets/css/a77ade19de3d3762dfbf1fe553b293cc.eot deleted file mode 100644 index 8c3f1064..00000000 Binary files a/themes/classic/assets/css/a77ade19de3d3762dfbf1fe553b293cc.eot and /dev/null differ diff --git a/themes/classic/assets/css/afb2ed6d67613a724a420a39b4fe5b0d.svg b/themes/classic/assets/css/afb2ed6d67613a724a420a39b4fe5b0d.svg deleted file mode 100644 index 6eb965ec..00000000 --- a/themes/classic/assets/css/afb2ed6d67613a724a420a39b4fe5b0d.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - diff --git a/themes/classic/assets/css/b1db819132e64a3e01911a1413c33acf.svg b/themes/classic/assets/css/b1db819132e64a3e01911a1413c33acf.svg deleted file mode 100644 index 16d3ec02..00000000 --- a/themes/classic/assets/css/b1db819132e64a3e01911a1413c33acf.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - diff --git a/themes/classic/assets/css/b467416c449eb823029e16347b2ea510.eot b/themes/classic/assets/css/b467416c449eb823029e16347b2ea510.eot deleted file mode 100644 index 81f65e42..00000000 Binary files a/themes/classic/assets/css/b467416c449eb823029e16347b2ea510.eot and /dev/null differ diff --git a/themes/classic/assets/css/c1a65805f759901a39d10eb854c1dcf2.svg b/themes/classic/assets/css/c1a65805f759901a39d10eb854c1dcf2.svg deleted file mode 100644 index 3ada3efb..00000000 --- a/themes/classic/assets/css/c1a65805f759901a39d10eb854c1dcf2.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - diff --git a/themes/classic/assets/css/c2183257e7a697769df4200c547551f1.woff b/themes/classic/assets/css/c2183257e7a697769df4200c547551f1.woff deleted file mode 100644 index fe87166b..00000000 Binary files a/themes/classic/assets/css/c2183257e7a697769df4200c547551f1.woff and /dev/null differ diff --git a/themes/classic/assets/css/cf2f3c1d5c7cb02c29f61964313148e1.svg b/themes/classic/assets/css/cf2f3c1d5c7cb02c29f61964313148e1.svg deleted file mode 100644 index 4359c669..00000000 --- a/themes/classic/assets/css/cf2f3c1d5c7cb02c29f61964313148e1.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - diff --git a/themes/classic/assets/css/custom.css b/themes/classic/assets/css/custom.css deleted file mode 100644 index e7e4bf84..00000000 --- a/themes/classic/assets/css/custom.css +++ /dev/null @@ -1,4 +0,0 @@ -/* - * Custom code goes here. - * A template should always ship with an empty custom.css - */ diff --git a/themes/classic/assets/css/custom_rtl.css b/themes/classic/assets/css/custom_rtl.css deleted file mode 100644 index e7e4bf84..00000000 --- a/themes/classic/assets/css/custom_rtl.css +++ /dev/null @@ -1,4 +0,0 @@ -/* - * Custom code goes here. - * A template should always ship with an empty custom.css - */ diff --git a/themes/classic/assets/css/d1a435fd2571e67858a31ee954b52278.svg b/themes/classic/assets/css/d1a435fd2571e67858a31ee954b52278.svg deleted file mode 100644 index 1a770a74..00000000 --- a/themes/classic/assets/css/d1a435fd2571e67858a31ee954b52278.svg +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - diff --git a/themes/classic/assets/css/d3fbae74a276a9f6cf1d6241f29b61a3.svg b/themes/classic/assets/css/d3fbae74a276a9f6cf1d6241f29b61a3.svg deleted file mode 100644 index 69bd6ab5..00000000 --- a/themes/classic/assets/css/d3fbae74a276a9f6cf1d6241f29b61a3.svg +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - diff --git a/themes/classic/assets/css/e049aeb07a2ae1627933e8e58d3886d2.svg b/themes/classic/assets/css/e049aeb07a2ae1627933e8e58d3886d2.svg deleted file mode 100644 index 31fe9125..00000000 --- a/themes/classic/assets/css/e049aeb07a2ae1627933e8e58d3886d2.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - - Artboard 3 Copy 3 - Created with Sketch. - - - - - - - - - - - - - \ No newline at end of file diff --git a/themes/classic/assets/css/e79bfd88537def476913f3ed52f4f4b3.eot b/themes/classic/assets/css/e79bfd88537def476913f3ed52f4f4b3.eot deleted file mode 100644 index 70508eba..00000000 Binary files a/themes/classic/assets/css/e79bfd88537def476913f3ed52f4f4b3.eot and /dev/null differ diff --git a/themes/classic/assets/css/eeb9224f85430652fd070e4e64129aa4.eot b/themes/classic/assets/css/eeb9224f85430652fd070e4e64129aa4.eot deleted file mode 100644 index fe764f86..00000000 Binary files a/themes/classic/assets/css/eeb9224f85430652fd070e4e64129aa4.eot and /dev/null differ diff --git a/themes/classic/assets/css/error.css b/themes/classic/assets/css/error.css deleted file mode 100644 index 93566a85..00000000 --- a/themes/classic/assets/css/error.css +++ /dev/null @@ -1,50 +0,0 @@ -#body { - background-color: #F7F7F7; } - -#layout-error { - text-align: center; - margin: 50px 0 0 0; - background-color: #fff; - -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); - -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); - box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); } -@media (min-width: 1200px) { - #layout-error { - margin: 126px 0 0 0; - padding: 50px; } } -#layout-error .logo { - margin: 0 0 31px 0; - text-align: center; } -#layout-error h1 { - font: 24px sans-serif; - color: #333; - padding: 0 0 14px 0; - margin: 0 0 19px 0; } -#layout-error h2 { - font: 20px sans-serif; - color: #333; - padding: 0 0 14px 0; - margin: 0 0 19px 0; } -#layout-error .page-content { - font: 16px sans-serif; - color: #555454; - text-align: center; } - -#layout-error { - padding: 50px 15px; - margin-right: auto; - margin-left: auto; } - -@media (min-width: 768px) { - #layout-error { - width: 500px; } } -@media (min-width: 992px) { - #layout-error { - width: 500px; } } -@media (min-width: 1200px) { - #layout-error { - width: 500px; } } -@media only screen and (min-width: 1200px) { - #layout-error { - padding-left: 0; - padding-right: 0; } } diff --git a/themes/classic/assets/css/error_rtl.css b/themes/classic/assets/css/error_rtl.css deleted file mode 100644 index 8d149b93..00000000 --- a/themes/classic/assets/css/error_rtl.css +++ /dev/null @@ -1,50 +0,0 @@ -#body { - background-color: #F7F7F7; } - -#layout-error { - text-align: center; - margin: 50px 0 0 0; - background-color: #fff; - -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); - -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); - box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); } -@media (min-width: 1200px) { - #layout-error { - margin: 126px 0 0 0; - padding: 50px; } } -#layout-error .logo { - margin: 0 0 31px 0; - text-align: center; } -#layout-error h1 { - font: 24px sans-serif; - color: #333; - padding: 0 0 14px 0; - margin: 0 0 19px 0; } -#layout-error h2 { - font: 20px sans-serif; - color: #333; - padding: 0 0 14px 0; - margin: 0 0 19px 0; } -#layout-error .page-content { - font: 16px sans-serif; - color: #555454; - text-align: center; } - -#layout-error { - padding: 50px 15px; - margin-left: auto; - margin-right: auto; } - -@media (min-width: 768px) { - #layout-error { - width: 500px; } } -@media (min-width: 992px) { - #layout-error { - width: 500px; } } -@media (min-width: 1200px) { - #layout-error { - width: 500px; } } -@media only screen and (min-width: 1200px) { - #layout-error { - padding-right: 0; - padding-left: 0; } } diff --git a/themes/classic/assets/css/f255af0bbbe837e79f7821827f9c6f10.svg b/themes/classic/assets/css/f255af0bbbe837e79f7821827f9c6f10.svg deleted file mode 100644 index 6cc507f6..00000000 --- a/themes/classic/assets/css/f255af0bbbe837e79f7821827f9c6f10.svg +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/themes/classic/assets/css/ffddcb3736980b23405b31142a324b62.svg b/themes/classic/assets/css/ffddcb3736980b23405b31142a324b62.svg deleted file mode 100644 index acc23889..00000000 --- a/themes/classic/assets/css/ffddcb3736980b23405b31142a324b62.svg +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - diff --git a/themes/classic/assets/css/theme.css b/themes/classic/assets/css/theme.css deleted file mode 100644 index 8193e1c1..00000000 --- a/themes/classic/assets/css/theme.css +++ /dev/null @@ -1,7 +0,0 @@ -.bootstrap-touchspin .input-group-btn-vertical{position:relative;white-space:nowrap;width:1%;vertical-align:middle;display:table-cell}.bootstrap-touchspin .input-group-btn-vertical>.btn{display:block;float:none;width:100%;max-width:100%;padding:8px 10px;margin-left:-1px;position:relative}.bootstrap-touchspin .input-group-btn-vertical .bootstrap-touchspin-up{border-radius:0;border-top-right-radius:4px}.bootstrap-touchspin .input-group-btn-vertical .bootstrap-touchspin-down{margin-top:-2px;border-radius:0;border-bottom-right-radius:4px}.bootstrap-touchspin .input-group-btn-vertical i{position:absolute;top:3px;left:5px;font-size:9px;font-weight:400}/*! - * Bootstrap v4.0.0-alpha.5 (https://getbootstrap.com) - * Copyright 2011-2016 The Bootstrap Authors - * Copyright 2011-2016 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - */ -/*! normalize.css v4.2.0 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block}audio:not([controls]){display:none;height:0}progress{vertical-align:baseline}[hidden],template{display:none}a{background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:inherit;font-weight:bolder}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}svg:not(:root){overflow:hidden}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;overflow:visible}button,input,optgroup,select,textarea{font:inherit;margin:0}optgroup{font-weight:700}button,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;white-space:normal}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-input-placeholder{color:inherit;opacity:.54}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}@media print{*,:after,:before,:first-letter,blockquote:first-line,div:first-line,li:first-line,p:first-line{text-shadow:none!important;box-shadow:none!important}a,a:visited{text-decoration:underline}abbr[title]:after{content:" (" attr(title) ")"}pre{white-space:pre-wrap!important}blockquote,pre{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}img,tr{page-break-inside:avoid}h2,h3,p{orphans:3;widows:3}h2,h3{page-break-after:avoid}.navbar{display:none}.btn>.caret,.dropup>.btn>.caret{border-top-color:#000!important}.tag{border:1px solid #000}.table{border-collapse:collapse!important}.table td,.table th{background-color:#fff!important}.table-bordered td,.table-bordered th{border:1px solid #ddd!important}}html{box-sizing:border-box}*,:after,:before{box-sizing:inherit}@-ms-viewport{width:device-width}html{font-size:16px;-ms-overflow-style:scrollbar;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;line-height:1.5;color:#363a42;background-color:#fff}[tabindex="-1"]:focus{outline:none!important}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{cursor:help;border-bottom:1px dotted #f1f1f1}address{font-style:normal;line-height:inherit}address,dl,ol,ul{margin-bottom:1rem}dl,ol,ul{margin-top:0}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}a{color:#2fb5d2;text-decoration:none}a:focus,a:hover{color:#208094;text-decoration:underline}a:focus{outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:not([href]):not([tabindex]),a:not([href]):not([tabindex]):focus,a:not([href]):not([tabindex]):hover{color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus{outline:none}pre{overflow:auto}figure{margin:0 0 1rem}img{vertical-align:middle}[role=button]{cursor:pointer}[role=button],a,area,button,input,label,select,summary,textarea{-ms-touch-action:manipulation;touch-action:manipulation}table{border-collapse:collapse;background-color:transparent}caption{padding-top:.75rem;padding-bottom:.75rem;color:#7a7a7a;caption-side:bottom}caption,th{text-align:left}label{display:inline-block;margin-bottom:.5rem}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,select,textarea{line-height:inherit}input[type=checkbox]:disabled,input[type=radio]:disabled{cursor:not-allowed}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit}input[type=search]{-webkit-appearance:none}output{display:inline-block}[hidden]{display:none!important}.h1,.h2,.h3,.h4,.h5,.h6,h1,h2,h3,h4,h5,h6{margin-bottom:.5rem;font-family:inherit;font-weight:700;line-height:1.1;color:inherit}.h1,h1{font-size:1.375rem}.h2,h2{font-size:1.25rem}.h3,.h4,h3,h4{font-size:1.125rem}.h5,h5{font-size:1rem}.h6,h6{font-size:.9375rem}.lead{font-size:1.25rem;font-weight:300}.display-1{font-size:3.125rem;font-weight:600}.display-2{font-size:2.188rem;font-weight:400}.display-3{font-size:1.563rem;font-weight:400}.display-4{font-size:1.25rem;font-weight:400}hr{margin-top:1rem;margin-bottom:1rem;border:0;border-top:1px solid rgba(0,0,0,.1)}.small,small{font-size:80%;font-weight:400}.mark,mark{padding:.2em;background-color:#fcf8e3}.list-inline,.list-unstyled{padding-left:0;list-style:none}.list-inline-item{display:inline-block}.list-inline-item:not(:last-child){margin-right:5px}.initialism{font-size:90%;text-transform:uppercase}.blockquote{padding:.5rem 1rem;margin-bottom:1rem;font-size:1.25rem;border-left:.25rem solid #f6f6f6}.blockquote-footer{display:block;font-size:80%;color:#f1f1f1}.blockquote-footer:before{content:"\2014 \A0"}.blockquote-reverse{padding-right:1rem;padding-left:0;text-align:right;border-right:.25rem solid #f6f6f6;border-left:0}.blockquote-reverse .blockquote-footer:before{content:""}.blockquote-reverse .blockquote-footer:after{content:"\A0 \2014"}dl.row>dd+dt{clear:left}.carousel-inner>.carousel-item>a>img,.carousel-inner>.carousel-item>img,.img-fluid,.img-thumbnail{max-width:100%;height:auto}.img-thumbnail{padding:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:0;transition:all .2s ease-in-out}.figure{display:inline-block}.figure-img{margin-bottom:.5rem;line-height:1}.figure-caption{font-size:90%;color:#f1f1f1}code,kbd,pre,samp{font-family:Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}code{color:#bd4147;background-color:#f7f7f9;border-radius:0}code,kbd{padding:.2rem .4rem;font-size:90%}kbd{color:#fff;background-color:#333;border-radius:.2rem}kbd kbd{padding:0;font-size:100%;font-weight:700}pre{display:block;margin-top:0;margin-bottom:1rem;font-size:90%;color:#363a42}pre code{padding:0;font-size:inherit;color:inherit;background-color:transparent;border-radius:0}.pre-scrollable{max-height:340px;overflow-y:scroll}.container{margin-left:auto;margin-right:auto;padding-left:15px;padding-right:15px}.container:after{content:"";display:table;clear:both}@media (min-width:576px){.container{width:540px;max-width:100%}}@media (min-width:768px){.container{width:720px;max-width:100%}}@media (min-width:992px){.container{width:960px;max-width:100%}}@media (min-width:1200px){.container{width:1140px;max-width:100%}}.container-fluid{margin-left:auto;margin-right:auto;padding-left:15px;padding-right:15px}.container-fluid:after{content:"";display:table;clear:both}.row{margin-right:-15px;margin-left:-15px}.row:after{content:"";display:table;clear:both}@media (min-width:576px){.row{margin-right:-15px;margin-left:-15px}}@media (min-width:768px){.row{margin-right:-15px;margin-left:-15px}}@media (min-width:992px){.row{margin-right:-15px;margin-left:-15px}}@media (min-width:1200px){.row{margin-right:-15px;margin-left:-15px}}.col-lg,.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11,.col-lg-12,.col-md,.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11,.col-md-12,.col-sm,.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11,.col-sm-12,.col-xl,.col-xl-1,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9,.col-xl-10,.col-xl-11,.col-xl-12,.col-xs,.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11,.col-xs-12{position:relative;min-height:1px;padding-right:15px;padding-left:15px}@media (min-width:576px){.col-lg,.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11,.col-lg-12,.col-md,.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11,.col-md-12,.col-sm,.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11,.col-sm-12,.col-xl,.col-xl-1,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9,.col-xl-10,.col-xl-11,.col-xl-12,.col-xs,.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11,.col-xs-12{padding-right:15px;padding-left:15px}}@media (min-width:768px){.col-lg,.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11,.col-lg-12,.col-md,.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11,.col-md-12,.col-sm,.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11,.col-sm-12,.col-xl,.col-xl-1,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9,.col-xl-10,.col-xl-11,.col-xl-12,.col-xs,.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11,.col-xs-12{padding-right:15px;padding-left:15px}}@media (min-width:992px){.col-lg,.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11,.col-lg-12,.col-md,.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11,.col-md-12,.col-sm,.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11,.col-sm-12,.col-xl,.col-xl-1,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9,.col-xl-10,.col-xl-11,.col-xl-12,.col-xs,.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11,.col-xs-12{padding-right:15px;padding-left:15px}}@media (min-width:1200px){.col-lg,.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11,.col-lg-12,.col-md,.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11,.col-md-12,.col-sm,.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11,.col-sm-12,.col-xl,.col-xl-1,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9,.col-xl-10,.col-xl-11,.col-xl-12,.col-xs,.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11,.col-xs-12{padding-right:15px;padding-left:15px}}.col-xs-1{float:left;width:8.33333%}.col-xs-2{float:left;width:16.66667%}.col-xs-3{float:left;width:25%}.col-xs-4{float:left;width:33.33333%}.col-xs-5{float:left;width:41.66667%}.col-xs-6{float:left;width:50%}.col-xs-7{float:left;width:58.33333%}.col-xs-8{float:left;width:66.66667%}.col-xs-9{float:left;width:75%}.col-xs-10{float:left;width:83.33333%}.col-xs-11{float:left;width:91.66667%}.col-xs-12{float:left;width:100%}.pull-xs-0{right:auto}.pull-xs-1{right:8.33333%}.pull-xs-2{right:16.66667%}.pull-xs-3{right:25%}.pull-xs-4{right:33.33333%}.pull-xs-5{right:41.66667%}.pull-xs-6{right:50%}.pull-xs-7{right:58.33333%}.pull-xs-8{right:66.66667%}.pull-xs-9{right:75%}.pull-xs-10{right:83.33333%}.pull-xs-11{right:91.66667%}.pull-xs-12{right:100%}.push-xs-0{left:auto}.push-xs-1{left:8.33333%}.push-xs-2{left:16.66667%}.push-xs-3{left:25%}.push-xs-4{left:33.33333%}.push-xs-5{left:41.66667%}.push-xs-6{left:50%}.push-xs-7{left:58.33333%}.push-xs-8{left:66.66667%}.push-xs-9{left:75%}.push-xs-10{left:83.33333%}.push-xs-11{left:91.66667%}.push-xs-12{left:100%}.offset-xs-1{margin-left:8.33333%}.offset-xs-2{margin-left:16.66667%}.offset-xs-3{margin-left:25%}.offset-xs-4{margin-left:33.33333%}.offset-xs-5{margin-left:41.66667%}.offset-xs-6{margin-left:50%}.offset-xs-7{margin-left:58.33333%}.offset-xs-8{margin-left:66.66667%}.offset-xs-9{margin-left:75%}.offset-xs-10{margin-left:83.33333%}.offset-xs-11{margin-left:91.66667%}@media (min-width:576px){.col-sm-1{float:left;width:8.33333%}.col-sm-2{float:left;width:16.66667%}.col-sm-3{float:left;width:25%}.col-sm-4{float:left;width:33.33333%}.col-sm-5{float:left;width:41.66667%}.col-sm-6{float:left;width:50%}.col-sm-7{float:left;width:58.33333%}.col-sm-8{float:left;width:66.66667%}.col-sm-9{float:left;width:75%}.col-sm-10{float:left;width:83.33333%}.col-sm-11{float:left;width:91.66667%}.col-sm-12{float:left;width:100%}.pull-sm-0{right:auto}.pull-sm-1{right:8.33333%}.pull-sm-2{right:16.66667%}.pull-sm-3{right:25%}.pull-sm-4{right:33.33333%}.pull-sm-5{right:41.66667%}.pull-sm-6{right:50%}.pull-sm-7{right:58.33333%}.pull-sm-8{right:66.66667%}.pull-sm-9{right:75%}.pull-sm-10{right:83.33333%}.pull-sm-11{right:91.66667%}.pull-sm-12{right:100%}.push-sm-0{left:auto}.push-sm-1{left:8.33333%}.push-sm-2{left:16.66667%}.push-sm-3{left:25%}.push-sm-4{left:33.33333%}.push-sm-5{left:41.66667%}.push-sm-6{left:50%}.push-sm-7{left:58.33333%}.push-sm-8{left:66.66667%}.push-sm-9{left:75%}.push-sm-10{left:83.33333%}.push-sm-11{left:91.66667%}.push-sm-12{left:100%}.offset-sm-0{margin-left:0}.offset-sm-1{margin-left:8.33333%}.offset-sm-2{margin-left:16.66667%}.offset-sm-3{margin-left:25%}.offset-sm-4{margin-left:33.33333%}.offset-sm-5{margin-left:41.66667%}.offset-sm-6{margin-left:50%}.offset-sm-7{margin-left:58.33333%}.offset-sm-8{margin-left:66.66667%}.offset-sm-9{margin-left:75%}.offset-sm-10{margin-left:83.33333%}.offset-sm-11{margin-left:91.66667%}}@media (min-width:768px){.col-md-1{float:left;width:8.33333%}.col-md-2{float:left;width:16.66667%}.col-md-3{float:left;width:25%}.col-md-4{float:left;width:33.33333%}.col-md-5{float:left;width:41.66667%}.col-md-6{float:left;width:50%}.col-md-7{float:left;width:58.33333%}.col-md-8{float:left;width:66.66667%}.col-md-9{float:left;width:75%}.col-md-10{float:left;width:83.33333%}.col-md-11{float:left;width:91.66667%}.col-md-12{float:left;width:100%}.pull-md-0{right:auto}.pull-md-1{right:8.33333%}.pull-md-2{right:16.66667%}.pull-md-3{right:25%}.pull-md-4{right:33.33333%}.pull-md-5{right:41.66667%}.pull-md-6{right:50%}.pull-md-7{right:58.33333%}.pull-md-8{right:66.66667%}.pull-md-9{right:75%}.pull-md-10{right:83.33333%}.pull-md-11{right:91.66667%}.pull-md-12{right:100%}.push-md-0{left:auto}.push-md-1{left:8.33333%}.push-md-2{left:16.66667%}.push-md-3{left:25%}.push-md-4{left:33.33333%}.push-md-5{left:41.66667%}.push-md-6{left:50%}.push-md-7{left:58.33333%}.push-md-8{left:66.66667%}.push-md-9{left:75%}.push-md-10{left:83.33333%}.push-md-11{left:91.66667%}.push-md-12{left:100%}.offset-md-0{margin-left:0}.offset-md-1{margin-left:8.33333%}.offset-md-2{margin-left:16.66667%}.offset-md-3{margin-left:25%}.offset-md-4{margin-left:33.33333%}.offset-md-5{margin-left:41.66667%}.offset-md-6{margin-left:50%}.offset-md-7{margin-left:58.33333%}.offset-md-8{margin-left:66.66667%}.offset-md-9{margin-left:75%}.offset-md-10{margin-left:83.33333%}.offset-md-11{margin-left:91.66667%}}@media (min-width:992px){.col-lg-1{float:left;width:8.33333%}.col-lg-2{float:left;width:16.66667%}.col-lg-3{float:left;width:25%}.col-lg-4{float:left;width:33.33333%}.col-lg-5{float:left;width:41.66667%}.col-lg-6{float:left;width:50%}.col-lg-7{float:left;width:58.33333%}.col-lg-8{float:left;width:66.66667%}.col-lg-9{float:left;width:75%}.col-lg-10{float:left;width:83.33333%}.col-lg-11{float:left;width:91.66667%}.col-lg-12{float:left;width:100%}.pull-lg-0{right:auto}.pull-lg-1{right:8.33333%}.pull-lg-2{right:16.66667%}.pull-lg-3{right:25%}.pull-lg-4{right:33.33333%}.pull-lg-5{right:41.66667%}.pull-lg-6{right:50%}.pull-lg-7{right:58.33333%}.pull-lg-8{right:66.66667%}.pull-lg-9{right:75%}.pull-lg-10{right:83.33333%}.pull-lg-11{right:91.66667%}.pull-lg-12{right:100%}.push-lg-0{left:auto}.push-lg-1{left:8.33333%}.push-lg-2{left:16.66667%}.push-lg-3{left:25%}.push-lg-4{left:33.33333%}.push-lg-5{left:41.66667%}.push-lg-6{left:50%}.push-lg-7{left:58.33333%}.push-lg-8{left:66.66667%}.push-lg-9{left:75%}.push-lg-10{left:83.33333%}.push-lg-11{left:91.66667%}.push-lg-12{left:100%}.offset-lg-0{margin-left:0}.offset-lg-1{margin-left:8.33333%}.offset-lg-2{margin-left:16.66667%}.offset-lg-3{margin-left:25%}.offset-lg-4{margin-left:33.33333%}.offset-lg-5{margin-left:41.66667%}.offset-lg-6{margin-left:50%}.offset-lg-7{margin-left:58.33333%}.offset-lg-8{margin-left:66.66667%}.offset-lg-9{margin-left:75%}.offset-lg-10{margin-left:83.33333%}.offset-lg-11{margin-left:91.66667%}}@media (min-width:1200px){.col-xl-1{float:left;width:8.33333%}.col-xl-2{float:left;width:16.66667%}.col-xl-3{float:left;width:25%}.col-xl-4{float:left;width:33.33333%}.col-xl-5{float:left;width:41.66667%}.col-xl-6{float:left;width:50%}.col-xl-7{float:left;width:58.33333%}.col-xl-8{float:left;width:66.66667%}.col-xl-9{float:left;width:75%}.col-xl-10{float:left;width:83.33333%}.col-xl-11{float:left;width:91.66667%}.col-xl-12{float:left;width:100%}.pull-xl-0{right:auto}.pull-xl-1{right:8.33333%}.pull-xl-2{right:16.66667%}.pull-xl-3{right:25%}.pull-xl-4{right:33.33333%}.pull-xl-5{right:41.66667%}.pull-xl-6{right:50%}.pull-xl-7{right:58.33333%}.pull-xl-8{right:66.66667%}.pull-xl-9{right:75%}.pull-xl-10{right:83.33333%}.pull-xl-11{right:91.66667%}.pull-xl-12{right:100%}.push-xl-0{left:auto}.push-xl-1{left:8.33333%}.push-xl-2{left:16.66667%}.push-xl-3{left:25%}.push-xl-4{left:33.33333%}.push-xl-5{left:41.66667%}.push-xl-6{left:50%}.push-xl-7{left:58.33333%}.push-xl-8{left:66.66667%}.push-xl-9{left:75%}.push-xl-10{left:83.33333%}.push-xl-11{left:91.66667%}.push-xl-12{left:100%}.offset-xl-0{margin-left:0}.offset-xl-1{margin-left:8.33333%}.offset-xl-2{margin-left:16.66667%}.offset-xl-3{margin-left:25%}.offset-xl-4{margin-left:33.33333%}.offset-xl-5{margin-left:41.66667%}.offset-xl-6{margin-left:50%}.offset-xl-7{margin-left:58.33333%}.offset-xl-8{margin-left:66.66667%}.offset-xl-9{margin-left:75%}.offset-xl-10{margin-left:83.33333%}.offset-xl-11{margin-left:91.66667%}}.table{width:100%;max-width:100%;margin-bottom:1rem}.table td,.table th{padding:.75rem;vertical-align:top;border-top:1px solid #f6f6f6}.table thead th{vertical-align:bottom;border-bottom:2px solid #f6f6f6}.table tbody+tbody{border-top:2px solid #f6f6f6}.table .table{background-color:#fff}.table-sm td,.table-sm th{padding:.3rem}.table-bordered,.table-bordered td,.table-bordered th{border:1px solid #f6f6f6}.table-bordered thead td,.table-bordered thead th{border-bottom-width:2px}.table-striped tbody tr:nth-of-type(odd){background-color:rgba(0,0,0,.05)}.table-active,.table-active>td,.table-active>th,.table-hover .table-active:hover,.table-hover .table-active:hover>td,.table-hover .table-active:hover>th,.table-hover tbody tr:hover{background-color:rgba(0,0,0,.075)}.table-success,.table-success>td,.table-success>th{background-color:#dff0d8}.table-hover .table-success:hover,.table-hover .table-success:hover>td,.table-hover .table-success:hover>th{background-color:#d0e9c6}.table-info,.table-info>td,.table-info>th{background-color:#d9edf7}.table-hover .table-info:hover,.table-hover .table-info:hover>td,.table-hover .table-info:hover>th{background-color:#c4e3f3}.table-warning,.table-warning>td,.table-warning>th{background-color:#fcf8e3}.table-hover .table-warning:hover,.table-hover .table-warning:hover>td,.table-hover .table-warning:hover>th{background-color:#faf2cc}.table-danger,.table-danger>td,.table-danger>th{background-color:#f2dede}.table-hover .table-danger:hover,.table-hover .table-danger:hover>td,.table-hover .table-danger:hover>th{background-color:#ebcccc}.thead-inverse th{color:#fff;background-color:#363a42}.thead-default th{color:#7a7a7a;background-color:#f6f6f6}.table-inverse{color:#f6f6f6;background-color:#363a42}.table-inverse td,.table-inverse th,.table-inverse thead th{border-color:#7a7a7a}.table-inverse.table-bordered{border:0}.table-responsive{display:block;width:100%;min-height:0;overflow-x:auto}.table-reflow thead{float:left}.table-reflow tbody{display:block;white-space:nowrap}.table-reflow td,.table-reflow th{border-top:1px solid #f6f6f6;border-left:1px solid #f6f6f6}.table-reflow td:last-child,.table-reflow th:last-child{border-right:1px solid #f6f6f6}.table-reflow tbody:last-child tr:last-child td,.table-reflow tbody:last-child tr:last-child th,.table-reflow tfoot:last-child tr:last-child td,.table-reflow tfoot:last-child tr:last-child th,.table-reflow thead:last-child tr:last-child td,.table-reflow thead:last-child tr:last-child th{border-bottom:1px solid #f6f6f6}.table-reflow tr{float:left}.table-reflow tr td,.table-reflow tr th{display:block!important;border:1px solid #f6f6f6}.form-control{display:block;width:100%;padding:.5rem .75rem;font-size:1rem;line-height:1.25;background-color:#fff;background-image:none;background-clip:padding-box;border-radius:0}.form-control::-ms-expand{background-color:transparent;border:0}.form-control:focus{color:#7a7a7a;border-color:#66afe9;outline:none}.form-control::-webkit-input-placeholder{color:#999;opacity:1}.form-control:-ms-input-placeholder{color:#999;opacity:1}.form-control::placeholder{color:#999;opacity:1}.form-control:disabled,.form-control[readonly]{background-color:#f6f6f6;opacity:1}.form-control:disabled{cursor:not-allowed}select.form-control:not([size]):not([multiple]){height:calc(2.5rem - 2px)}select.form-control:focus::-ms-value{color:#7a7a7a;background-color:#fff}.form-control-file,.form-control-range{display:block}.col-form-label{padding-top:.5rem;padding-bottom:.5rem;margin-bottom:0}.col-form-label-lg{padding-top:.75rem;padding-bottom:.75rem;font-size:.9375rem}.col-form-label-sm{padding-top:.25rem;padding-bottom:.25rem;font-size:.875rem}.col-form-legend{margin-bottom:0;font-size:1rem}.col-form-legend,.form-control-static{padding-top:.5rem;padding-bottom:.5rem}.form-control-static{line-height:1.25;border:solid transparent;border-width:1px 0}.form-control-static.form-control-lg,.form-control-static.form-control-sm,.input-group-lg>.form-control-static.form-control,.input-group-lg>.form-control-static.input-group-addon,.input-group-lg>.input-group-btn>.form-control-static.btn,.input-group-sm>.form-control-static.form-control,.input-group-sm>.form-control-static.input-group-addon,.input-group-sm>.input-group-btn>.form-control-static.btn{padding-right:0;padding-left:0}.form-control-sm,.input-group-sm>.form-control,.input-group-sm>.input-group-addon,.input-group-sm>.input-group-btn>.btn{padding:.25rem .5rem;font-size:.875rem;border-radius:.2rem}.input-group-sm>.input-group-btn>select.btn:not([size]):not([multiple]),.input-group-sm>select.form-control:not([size]):not([multiple]),.input-group-sm>select.input-group-addon:not([size]):not([multiple]),select.form-control-sm:not([size]):not([multiple]){height:1.8125rem}.form-control-lg,.input-group-lg>.form-control,.input-group-lg>.input-group-addon,.input-group-lg>.input-group-btn>.btn{padding:.75rem 1.5rem;font-size:.9375rem;border-radius:.3rem}.input-group-lg>.input-group-btn>select.btn:not([size]):not([multiple]),.input-group-lg>select.form-control:not([size]):not([multiple]),.input-group-lg>select.input-group-addon:not([size]):not([multiple]),select.form-control-lg:not([size]):not([multiple]){height:2.75rem}.form-group{margin-bottom:1rem}.form-text{display:block;margin-top:.25rem}.form-check{position:relative;display:block;margin-bottom:.75rem}.form-check+.form-check{margin-top:-.25rem}.form-check.disabled .form-check-label{color:#7a7a7a;cursor:not-allowed}.form-check-label{padding-left:1.25rem;margin-bottom:0;cursor:pointer}.form-check-input{position:absolute;margin-top:.25rem;margin-left:-1.25rem}.form-check-input:only-child{position:static}.form-check-inline{position:relative;display:inline-block;padding-left:1.25rem;margin-bottom:0;vertical-align:middle;cursor:pointer}.form-check-inline+.form-check-inline{margin-left:.75rem}.form-check-inline.disabled{color:#7a7a7a;cursor:not-allowed}.form-control-feedback{margin-top:.25rem}.form-control-danger,.form-control-success,.form-control-warning{padding-right:2.25rem;background-repeat:no-repeat;background-position:center right .625rem;background-size:1.25rem 1.25rem}.has-success .custom-control,.has-success .form-check-inline,.has-success .form-check-label,.has-success .form-control-feedback,.has-success .form-control-label{color:#4cbb6c}.has-success .form-control{border-color:#4cbb6c}.has-success .form-control:focus{box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #96d7a9}.has-success .input-group-addon{color:#4cbb6c;border-color:#4cbb6c;background-color:#e0f3e5}.has-success .form-control-success{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath fill='#4cbb6c' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3E%3C/svg%3E")}.has-warning .custom-control,.has-warning .form-check-inline,.has-warning .form-check-label,.has-warning .form-control-feedback,.has-warning .form-control-label{color:#ff9a52}.has-warning .form-control{border-color:#ff9a52}.has-warning .form-control:focus{box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ffd6b8}.has-warning .input-group-addon{color:#ff9a52;border-color:#ff9a52;background-color:#fff}.has-warning .form-control-warning{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath fill='#ff9a52' d='M4.4 5.324h-.8v-2.46h.8zm0 1.42h-.8V5.89h.8zM3.76.63L.04 7.075c-.115.2.016.425.26.426h7.397c.242 0 .372-.226.258-.426C6.726 4.924 5.47 2.79 4.253.63c-.113-.174-.39-.174-.494 0z'/%3E%3C/svg%3E")}.has-danger .custom-control,.has-danger .form-check-inline,.has-danger .form-check-label,.has-danger .form-control-feedback,.has-danger .form-control-label{color:#ff4c4c}.has-danger .form-control{border-color:#ff4c4c}.has-danger .form-control:focus{box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ffb2b2}.has-danger .input-group-addon{color:#ff4c4c;border-color:#ff4c4c;background-color:#fff}.has-danger .form-control-danger{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='#ff4c4c' viewBox='-2 -2 7 7'%3E%3Cpath stroke='%23d9534f' d='M0 0l3 3m0-3L0 3'/%3E%3Ccircle r='.5'/%3E%3Ccircle cx='3' r='.5'/%3E%3Ccircle cy='3' r='.5'/%3E%3Ccircle cx='3' cy='3' r='.5'/%3E%3C/svg%3E")}@media (min-width:576px){.form-inline .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.form-inline .form-control{display:inline-block;width:auto;vertical-align:middle}.form-inline .form-control-static{display:inline-block}.form-inline .input-group{display:inline-table;width:auto;vertical-align:middle}.form-inline .input-group .form-control,.form-inline .input-group .input-group-addon,.form-inline .input-group .input-group-btn{width:auto}.form-inline .input-group>.form-control{width:100%}.form-inline .form-check,.form-inline .form-control-label{margin-bottom:0;vertical-align:middle}.form-inline .form-check{display:inline-block;margin-top:0}.form-inline .form-check-label{padding-left:0}.form-inline .form-check-input{position:relative;margin-left:0}.form-inline .has-feedback .form-control-feedback{top:0}}.btn{display:inline-block;font-weight:400;line-height:1.25;text-align:center;white-space:nowrap;vertical-align:middle;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border:1px solid transparent;padding:.5rem 1rem;font-size:1rem;border-radius:0}.btn.active.focus,.btn.active:focus,.btn.focus,.btn:active.focus,.btn:active:focus,.btn:focus{outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.focus,.btn:focus,.btn:hover{text-decoration:none}.btn.active,.btn:active{background-image:none;outline:0}.btn.disabled,.btn:disabled{cursor:not-allowed;opacity:.65}a.btn.disabled,fieldset[disabled] a.btn{pointer-events:none}.btn-primary{color:#fff;background-color:#2fb5d2;border-color:transparent}.btn-primary.focus,.btn-primary:focus,.btn-primary:hover{color:#fff;background-color:#2592a9;border-color:transparent}.btn-primary.active,.btn-primary:active,.open>.btn-primary.dropdown-toggle{color:#fff;background-color:#2592a9;border-color:transparent;background-image:none}.btn-primary.active.focus,.btn-primary.active:focus,.btn-primary.active:hover,.btn-primary:active.focus,.btn-primary:active:focus,.btn-primary:active:hover,.open>.btn-primary.dropdown-toggle.focus,.open>.btn-primary.dropdown-toggle:focus,.open>.btn-primary.dropdown-toggle:hover{color:#fff;background-color:#1e788c;border-color:transparent}.btn-primary.disabled.focus,.btn-primary.disabled:focus,.btn-primary.disabled:hover,.btn-primary:disabled.focus,.btn-primary:disabled:focus,.btn-primary:disabled:hover{background-color:#2fb5d2;border-color:transparent}.btn-secondary,.btn-tertiary{color:#232323;background-color:#f6f6f6;border-color:transparent}.btn-secondary.focus,.btn-secondary:focus,.btn-secondary:hover,.btn-tertiary:focus,.btn-tertiary:hover,.focus.btn-tertiary{color:#232323;background-color:#ddd;border-color:transparent}.active.btn-tertiary,.btn-secondary.active,.btn-secondary:active,.btn-tertiary:active,.open>.btn-secondary.dropdown-toggle,.open>.dropdown-toggle.btn-tertiary{color:#232323;background-color:#ddd;border-color:transparent;background-image:none}.active.btn-tertiary:focus,.active.btn-tertiary:hover,.active.focus.btn-tertiary,.btn-secondary.active.focus,.btn-secondary.active:focus,.btn-secondary.active:hover,.btn-secondary:active.focus,.btn-secondary:active:focus,.btn-secondary:active:hover,.btn-tertiary:active.focus,.btn-tertiary:active:focus,.btn-tertiary:active:hover,.open>.btn-secondary.dropdown-toggle.focus,.open>.btn-secondary.dropdown-toggle:focus,.open>.btn-secondary.dropdown-toggle:hover,.open>.dropdown-toggle.btn-tertiary:focus,.open>.dropdown-toggle.btn-tertiary:hover,.open>.dropdown-toggle.focus.btn-tertiary{color:#232323;background-color:#cbcbcb;border-color:transparent}.btn-secondary.disabled.focus,.btn-secondary.disabled:focus,.btn-secondary.disabled:hover,.btn-secondary:disabled.focus,.btn-secondary:disabled:focus,.btn-secondary:disabled:hover,.btn-tertiary:disabled.focus,.btn-tertiary:disabled:focus,.btn-tertiary:disabled:hover,.disabled.btn-tertiary:focus,.disabled.btn-tertiary:hover,.disabled.focus.btn-tertiary{background-color:#f6f6f6;border-color:transparent}.btn-info{color:#fff;background-color:#5bc0de;border-color:#5bc0de}.btn-info.focus,.btn-info:focus,.btn-info:hover{color:#fff;background-color:#31b0d5;border-color:#2aabd2}.btn-info.active,.btn-info:active,.open>.btn-info.dropdown-toggle{color:#fff;background-color:#31b0d5;border-color:#2aabd2;background-image:none}.btn-info.active.focus,.btn-info.active:focus,.btn-info.active:hover,.btn-info:active.focus,.btn-info:active:focus,.btn-info:active:hover,.open>.btn-info.dropdown-toggle.focus,.open>.btn-info.dropdown-toggle:focus,.open>.btn-info.dropdown-toggle:hover{color:#fff;background-color:#269abc;border-color:#1f7e9a}.btn-info.disabled.focus,.btn-info.disabled:focus,.btn-info.disabled:hover,.btn-info:disabled.focus,.btn-info:disabled:focus,.btn-info:disabled:hover{background-color:#5bc0de;border-color:#5bc0de}.btn-success{color:#fff;background-color:#4cbb6c;border-color:#4cbb6c}.btn-success.focus,.btn-success:focus,.btn-success:hover{color:#fff;background-color:#3a9a56;border-color:#389252}.btn-success.active,.btn-success:active,.open>.btn-success.dropdown-toggle{color:#fff;background-color:#3a9a56;border-color:#389252;background-image:none}.btn-success.active.focus,.btn-success.active:focus,.btn-success.active:hover,.btn-success:active.focus,.btn-success:active:focus,.btn-success:active:hover,.open>.btn-success.dropdown-toggle.focus,.open>.btn-success.dropdown-toggle:focus,.open>.btn-success.dropdown-toggle:hover{color:#fff;background-color:#318047;border-color:#256237}.btn-success.disabled.focus,.btn-success.disabled:focus,.btn-success.disabled:hover,.btn-success:disabled.focus,.btn-success:disabled:focus,.btn-success:disabled:hover{background-color:#4cbb6c;border-color:#4cbb6c}.btn-warning{color:#fff;background-color:#ff9a52;border-color:#ff9a52}.btn-warning.focus,.btn-warning:focus,.btn-warning:hover{color:#fff;background-color:#ff7c1f;border-color:#ff7615}.btn-warning.active,.btn-warning:active,.open>.btn-warning.dropdown-toggle{color:#fff;background-color:#ff7c1f;border-color:#ff7615;background-image:none}.btn-warning.active.focus,.btn-warning.active:focus,.btn-warning.active:hover,.btn-warning:active.focus,.btn-warning:active:focus,.btn-warning:active:hover,.open>.btn-warning.dropdown-toggle.focus,.open>.btn-warning.dropdown-toggle:focus,.open>.btn-warning.dropdown-toggle:hover{color:#fff;background-color:#fa6800;border-color:#d25700}.btn-warning.disabled.focus,.btn-warning.disabled:focus,.btn-warning.disabled:hover,.btn-warning:disabled.focus,.btn-warning:disabled:focus,.btn-warning:disabled:hover{background-color:#ff9a52;border-color:#ff9a52}.btn-danger{color:#fff;background-color:#ff4c4c;border-color:#ff4c4c}.btn-danger.focus,.btn-danger:focus,.btn-danger:hover{color:#fff;background-color:#ff1919;border-color:#ff0f0f}.btn-danger.active,.btn-danger:active,.open>.btn-danger.dropdown-toggle{color:#fff;background-color:#ff1919;border-color:#ff0f0f;background-image:none}.btn-danger.active.focus,.btn-danger.active:focus,.btn-danger.active:hover,.btn-danger:active.focus,.btn-danger:active:focus,.btn-danger:active:hover,.open>.btn-danger.dropdown-toggle.focus,.open>.btn-danger.dropdown-toggle:focus,.open>.btn-danger.dropdown-toggle:hover{color:#fff;background-color:#f40000;border-color:#c00}.btn-danger.disabled.focus,.btn-danger.disabled:focus,.btn-danger.disabled:hover,.btn-danger:disabled.focus,.btn-danger:disabled:focus,.btn-danger:disabled:hover{background-color:#ff4c4c;border-color:#ff4c4c}.btn-outline-primary{color:#2fb5d2;background-image:none;background-color:transparent;border-color:#2fb5d2}.btn-outline-primary.active,.btn-outline-primary.focus,.btn-outline-primary:active,.btn-outline-primary:focus,.btn-outline-primary:hover,.open>.btn-outline-primary.dropdown-toggle{color:#fff;background-color:#2fb5d2;border-color:#2fb5d2}.btn-outline-primary.active.focus,.btn-outline-primary.active:focus,.btn-outline-primary.active:hover,.btn-outline-primary:active.focus,.btn-outline-primary:active:focus,.btn-outline-primary:active:hover,.open>.btn-outline-primary.dropdown-toggle.focus,.open>.btn-outline-primary.dropdown-toggle:focus,.open>.btn-outline-primary.dropdown-toggle:hover{color:#fff;background-color:#1e788c;border-color:#175c6a}.btn-outline-primary.disabled.focus,.btn-outline-primary.disabled:focus,.btn-outline-primary.disabled:hover,.btn-outline-primary:disabled.focus,.btn-outline-primary:disabled:focus,.btn-outline-primary:disabled:hover{border-color:#83d3e4}.btn-outline-secondary{color:transparent;background-image:none;background-color:transparent;border-color:transparent}.btn-outline-secondary.active,.btn-outline-secondary.active.focus,.btn-outline-secondary.active:focus,.btn-outline-secondary.active:hover,.btn-outline-secondary.focus,.btn-outline-secondary:active,.btn-outline-secondary:active.focus,.btn-outline-secondary:active:focus,.btn-outline-secondary:active:hover,.btn-outline-secondary:focus,.btn-outline-secondary:hover,.open>.btn-outline-secondary.dropdown-toggle,.open>.btn-outline-secondary.dropdown-toggle.focus,.open>.btn-outline-secondary.dropdown-toggle:focus,.open>.btn-outline-secondary.dropdown-toggle:hover{color:#fff;background-color:transparent;border-color:transparent}.btn-outline-secondary.disabled.focus,.btn-outline-secondary.disabled:focus,.btn-outline-secondary.disabled:hover,.btn-outline-secondary:disabled.focus,.btn-outline-secondary:disabled:focus,.btn-outline-secondary:disabled:hover{border-color:rgba(51,51,51,0)}.btn-outline-info{color:#5bc0de;background-image:none;background-color:transparent;border-color:#5bc0de}.btn-outline-info.active,.btn-outline-info.focus,.btn-outline-info:active,.btn-outline-info:focus,.btn-outline-info:hover,.open>.btn-outline-info.dropdown-toggle{color:#fff;background-color:#5bc0de;border-color:#5bc0de}.btn-outline-info.active.focus,.btn-outline-info.active:focus,.btn-outline-info.active:hover,.btn-outline-info:active.focus,.btn-outline-info:active:focus,.btn-outline-info:active:hover,.open>.btn-outline-info.dropdown-toggle.focus,.open>.btn-outline-info.dropdown-toggle:focus,.open>.btn-outline-info.dropdown-toggle:hover{color:#fff;background-color:#269abc;border-color:#1f7e9a}.btn-outline-info.disabled.focus,.btn-outline-info.disabled:focus,.btn-outline-info.disabled:hover,.btn-outline-info:disabled.focus,.btn-outline-info:disabled:focus,.btn-outline-info:disabled:hover{border-color:#b0e1ef}.btn-outline-success{color:#4cbb6c;background-image:none;background-color:transparent;border-color:#4cbb6c}.btn-outline-success.active,.btn-outline-success.focus,.btn-outline-success:active,.btn-outline-success:focus,.btn-outline-success:hover,.open>.btn-outline-success.dropdown-toggle{color:#fff;background-color:#4cbb6c;border-color:#4cbb6c}.btn-outline-success.active.focus,.btn-outline-success.active:focus,.btn-outline-success.active:hover,.btn-outline-success:active.focus,.btn-outline-success:active:focus,.btn-outline-success:active:hover,.open>.btn-outline-success.dropdown-toggle.focus,.open>.btn-outline-success.dropdown-toggle:focus,.open>.btn-outline-success.dropdown-toggle:hover{color:#fff;background-color:#318047;border-color:#256237}.btn-outline-success.disabled.focus,.btn-outline-success.disabled:focus,.btn-outline-success.disabled:hover,.btn-outline-success:disabled.focus,.btn-outline-success:disabled:focus,.btn-outline-success:disabled:hover{border-color:#96d7a9}.btn-outline-warning{color:#ff9a52;background-image:none;background-color:transparent;border-color:#ff9a52}.btn-outline-warning.active,.btn-outline-warning.focus,.btn-outline-warning:active,.btn-outline-warning:focus,.btn-outline-warning:hover,.open>.btn-outline-warning.dropdown-toggle{color:#fff;background-color:#ff9a52;border-color:#ff9a52}.btn-outline-warning.active.focus,.btn-outline-warning.active:focus,.btn-outline-warning.active:hover,.btn-outline-warning:active.focus,.btn-outline-warning:active:focus,.btn-outline-warning:active:hover,.open>.btn-outline-warning.dropdown-toggle.focus,.open>.btn-outline-warning.dropdown-toggle:focus,.open>.btn-outline-warning.dropdown-toggle:hover{color:#fff;background-color:#fa6800;border-color:#d25700}.btn-outline-warning.disabled.focus,.btn-outline-warning.disabled:focus,.btn-outline-warning.disabled:hover,.btn-outline-warning:disabled.focus,.btn-outline-warning:disabled:focus,.btn-outline-warning:disabled:hover{border-color:#ffd6b8}.btn-outline-danger{color:#ff4c4c;background-image:none;background-color:transparent;border-color:#ff4c4c}.btn-outline-danger.active,.btn-outline-danger.focus,.btn-outline-danger:active,.btn-outline-danger:focus,.btn-outline-danger:hover,.open>.btn-outline-danger.dropdown-toggle{color:#fff;background-color:#ff4c4c;border-color:#ff4c4c}.btn-outline-danger.active.focus,.btn-outline-danger.active:focus,.btn-outline-danger.active:hover,.btn-outline-danger:active.focus,.btn-outline-danger:active:focus,.btn-outline-danger:active:hover,.open>.btn-outline-danger.dropdown-toggle.focus,.open>.btn-outline-danger.dropdown-toggle:focus,.open>.btn-outline-danger.dropdown-toggle:hover{color:#fff;background-color:#f40000;border-color:#c00}.btn-outline-danger.disabled.focus,.btn-outline-danger.disabled:focus,.btn-outline-danger.disabled:hover,.btn-outline-danger:disabled.focus,.btn-outline-danger:disabled:focus,.btn-outline-danger:disabled:hover{border-color:#ffb2b2}.btn-link{font-weight:400;color:#2fb5d2;border-radius:0}.btn-link,.btn-link.active,.btn-link:active,.btn-link:disabled{background-color:transparent}.btn-link,.btn-link:active,.btn-link:focus,.btn-link:hover{border-color:transparent}.btn-link:focus,.btn-link:hover{color:#208094;text-decoration:underline;background-color:transparent}.btn-link:disabled:focus,.btn-link:disabled:hover{color:#f1f1f1;text-decoration:none}.btn-group-lg>.btn,.btn-lg{padding:.75rem 1.5rem;font-size:.9375rem;border-radius:.3rem}.btn-group-sm>.btn,.btn-sm{padding:.25rem .5rem;font-size:.875rem;border-radius:.2rem}.btn-block{display:block;width:100%}.btn-block+.btn-block{margin-top:.5rem}input[type=button].btn-block,input[type=reset].btn-block,input[type=submit].btn-block{width:100%}.fade{opacity:0;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{display:none}.collapse.in{display:block}tr.collapse.in{display:table-row}tbody.collapse.in{display:table-row-group}.collapsing{height:0;overflow:hidden;transition-timing-function:ease;transition-duration:.35s;transition-property:height}.collapsing,.dropdown,.dropup{position:relative}.dropdown-toggle:after{display:inline-block;width:0;height:0;margin-left:.3em;vertical-align:middle;content:"";border-top:.3em solid;border-right:.3em solid transparent;border-left:.3em solid transparent}.dropdown-toggle:focus{outline:0}.dropup .dropdown-toggle:after{border-top:0;border-bottom:.3em solid}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:10rem;padding:.5rem 0;margin:.125rem 0 0;font-size:1rem;color:#363a42;text-align:left;list-style:none;background-color:#fff;background-clip:padding-box;border:1px solid rgba(0,0,0,.15);border-radius:0}.dropdown-divider{height:1px;margin:.5rem 0;overflow:hidden;background-color:#e5e5e5}.dropdown-item{display:block;width:100%;padding:3px 1.5rem;clear:both;font-weight:400;color:#363a42;text-align:inherit;white-space:nowrap;background:none;border:0}.dropdown-item:focus,.dropdown-item:hover{color:#2b2e34;background-color:#f5f5f5}.dropdown-item.active,.dropdown-item.active:focus,.dropdown-item.active:hover{color:#fff;text-decoration:none;background-color:#2fb5d2;outline:0}.dropdown-item.disabled,.dropdown-item.disabled:focus,.dropdown-item.disabled:hover{color:#f1f1f1}.dropdown-item.disabled:focus,.dropdown-item.disabled:hover{text-decoration:none;cursor:not-allowed;background-color:transparent;background-image:none;filter:"progid:DXImageTransform.Microsoft.gradient(enabled = false)"}.open>.dropdown-menu{display:block}.open>a{outline:0}.dropdown-menu-right{right:0;left:auto}.dropdown-menu-left{right:auto;left:0}.dropdown-header{display:block;padding:.5rem 1.5rem;margin-bottom:0;font-size:.875rem;color:#f1f1f1;white-space:nowrap}.dropdown-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:990}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{content:"";border-top:0;border-bottom:.3em solid}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:.125rem}.btn-group,.btn-group-vertical{position:relative;display:inline-block;vertical-align:middle}.btn-group-vertical>.btn,.btn-group>.btn{position:relative;float:left;margin-bottom:0}.btn-group-vertical>.btn.active,.btn-group-vertical>.btn:active,.btn-group-vertical>.btn:focus,.btn-group-vertical>.btn:hover,.btn-group>.btn.active,.btn-group>.btn:active,.btn-group>.btn:focus,.btn-group>.btn:hover{z-index:2}.btn-group .btn+.btn,.btn-group .btn+.btn-group,.btn-group .btn-group+.btn,.btn-group .btn-group+.btn-group{margin-left:-1px}.btn-toolbar{margin-left:-.5rem}.btn-toolbar:after{content:"";display:table;clear:both}.btn-toolbar .btn-group,.btn-toolbar .input-group{float:left}.btn-toolbar>.btn,.btn-toolbar>.btn-group,.btn-toolbar>.input-group{margin-left:.5rem}.btn-group>.btn:not(:first-child):not(:last-child):not(.dropdown-toggle){border-radius:0}.btn-group>.btn:first-child{margin-left:0}.btn-group>.btn:first-child:not(:last-child):not(.dropdown-toggle){border-bottom-right-radius:0;border-top-right-radius:0}.btn-group>.btn:last-child:not(:first-child),.btn-group>.dropdown-toggle:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.btn-group>.btn-group{float:left}.btn-group>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group>.btn-group:first-child:not(:last-child)>.btn:last-child,.btn-group>.btn-group:first-child:not(:last-child)>.dropdown-toggle{border-bottom-right-radius:0;border-top-right-radius:0}.btn-group>.btn-group:last-child:not(:first-child)>.btn:first-child{border-bottom-left-radius:0;border-top-left-radius:0}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn+.dropdown-toggle-split{padding-right:.75rem;padding-left:.75rem}.btn+.dropdown-toggle-split:after{margin-left:0}.btn-group-sm>.btn+.dropdown-toggle-split,.btn-sm+.dropdown-toggle-split{padding-right:.375rem;padding-left:.375rem}.btn-group-lg>.btn+.dropdown-toggle-split,.btn-lg+.dropdown-toggle-split{padding-right:1.125rem;padding-left:1.125rem}.btn .caret{margin-left:0}.btn-group-lg>.btn .caret,.btn-lg .caret{border-width:.3em .3em 0;border-bottom-width:0}.dropup .btn-group-lg>.btn .caret,.dropup .btn-lg .caret{border-width:0 .3em .3em}.btn-group-vertical>.btn,.btn-group-vertical>.btn-group,.btn-group-vertical>.btn-group>.btn{display:block;float:none;width:100%;max-width:100%}.btn-group-vertical>.btn-group:after{content:"";display:table;clear:both}.btn-group-vertical>.btn-group>.btn{float:none}.btn-group-vertical>.btn+.btn,.btn-group-vertical>.btn+.btn-group,.btn-group-vertical>.btn-group+.btn,.btn-group-vertical>.btn-group+.btn-group{margin-top:-1px;margin-left:0}.btn-group-vertical>.btn:not(:first-child):not(:last-child){border-radius:0}.btn-group-vertical>.btn:first-child:not(:last-child){border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn:last-child:not(:first-child){border-top-right-radius:0;border-top-left-radius:0}.btn-group-vertical>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group-vertical>.btn-group:first-child:not(:last-child)>.btn:last-child,.btn-group-vertical>.btn-group:first-child:not(:last-child)>.dropdown-toggle{border-bottom-right-radius:0;border-bottom-left-radius:0}.btn-group-vertical>.btn-group:last-child:not(:first-child)>.btn:first-child{border-top-right-radius:0;border-top-left-radius:0}[data-toggle=buttons]>.btn-group>.btn input[type=checkbox],[data-toggle=buttons]>.btn-group>.btn input[type=radio],[data-toggle=buttons]>.btn input[type=checkbox],[data-toggle=buttons]>.btn input[type=radio]{position:absolute;clip:rect(0,0,0,0);pointer-events:none}.input-group{position:relative;width:100%;display:table;border-collapse:separate}.input-group .form-control{position:relative;z-index:2;float:left;width:100%;margin-bottom:0}.input-group .form-control:active,.input-group .form-control:focus,.input-group .form-control:hover{z-index:3}.input-group-addon,.input-group-btn,.input-group .form-control{display:table-cell}.input-group-addon:not(:first-child):not(:last-child),.input-group-btn:not(:first-child):not(:last-child),.input-group .form-control:not(:first-child):not(:last-child){border-radius:0}.input-group-addon,.input-group-btn{width:1%;white-space:nowrap;vertical-align:middle}.input-group-addon{padding:.5rem .75rem;margin-bottom:0;font-size:1rem;font-weight:400;line-height:1.25;color:#7a7a7a;text-align:center;background-color:#f6f6f6;border:1px solid rgba(0,0,0,.25);border-radius:0}.input-group-addon.form-control-sm,.input-group-sm>.input-group-addon,.input-group-sm>.input-group-btn>.input-group-addon.btn{padding:.25rem .5rem;font-size:.875rem;border-radius:.2rem}.input-group-addon.form-control-lg,.input-group-lg>.input-group-addon,.input-group-lg>.input-group-btn>.input-group-addon.btn{padding:.75rem 1.5rem;font-size:.9375rem;border-radius:.3rem}.input-group-addon input[type=checkbox],.input-group-addon input[type=radio]{margin-top:0}.input-group-addon:not(:last-child),.input-group-btn:not(:first-child)>.btn-group:not(:last-child)>.btn,.input-group-btn:not(:first-child)>.btn:not(:last-child):not(.dropdown-toggle),.input-group-btn:not(:last-child)>.btn,.input-group-btn:not(:last-child)>.btn-group>.btn,.input-group-btn:not(:last-child)>.dropdown-toggle,.input-group .form-control:not(:last-child){border-bottom-right-radius:0;border-top-right-radius:0}.input-group-addon:not(:last-child){border-right:0}.input-group-addon:not(:first-child),.input-group-btn:not(:first-child)>.btn,.input-group-btn:not(:first-child)>.btn-group>.btn,.input-group-btn:not(:first-child)>.dropdown-toggle,.input-group-btn:not(:last-child)>.btn-group:not(:first-child)>.btn,.input-group-btn:not(:last-child)>.btn:not(:first-child),.input-group .form-control:not(:first-child){border-bottom-left-radius:0;border-top-left-radius:0}.form-control+.input-group-addon:not(:first-child){border-left:0}.input-group-btn{font-size:0;white-space:nowrap}.input-group-btn,.input-group-btn>.btn{position:relative}.input-group-btn>.btn+.btn{margin-left:-1px}.input-group-btn>.btn:active,.input-group-btn>.btn:focus,.input-group-btn>.btn:hover{z-index:3}.input-group-btn:not(:last-child)>.btn,.input-group-btn:not(:last-child)>.btn-group{margin-right:-1px}.input-group-btn:not(:first-child)>.btn,.input-group-btn:not(:first-child)>.btn-group{z-index:2;margin-left:-1px}.input-group-btn:not(:first-child)>.btn-group:active,.input-group-btn:not(:first-child)>.btn-group:focus,.input-group-btn:not(:first-child)>.btn-group:hover,.input-group-btn:not(:first-child)>.btn:active,.input-group-btn:not(:first-child)>.btn:focus,.input-group-btn:not(:first-child)>.btn:hover{z-index:3}.custom-control{position:relative;display:inline-block;padding-left:1.5rem;cursor:pointer}.custom-control+.custom-control{margin-left:1rem}.custom-control-input{position:absolute;z-index:-1;opacity:0}.custom-control-input:checked~.custom-control-indicator{color:#fff;background-color:#0074d9}.custom-control-input:focus~.custom-control-indicator{box-shadow:0 0 0 .075rem #fff,0 0 0 .2rem #0074d9}.custom-control-input:active~.custom-control-indicator{color:#fff;background-color:#84c6ff}.custom-control-input:disabled~.custom-control-indicator{cursor:not-allowed;background-color:#eee}.custom-control-input:disabled~.custom-control-description{color:#767676;cursor:not-allowed}.custom-control-indicator{position:absolute;top:.25rem;left:0;display:block;width:1rem;height:1rem;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-color:#ddd;background-repeat:no-repeat;background-position:50%;background-size:50% 50%}.custom-checkbox .custom-control-indicator{border-radius:0}.custom-checkbox .custom-control-input:checked~.custom-control-indicator{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath fill='#fff' d='M6.564.75l-3.59 3.612-1.538-1.55L0 4.26 2.974 7.25 8 2.193z'/%3E%3C/svg%3E")}.custom-checkbox .custom-control-input:indeterminate~.custom-control-indicator{background-color:#0074d9;background-image:url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 4'%3E%3Cpath stroke='#fff' d='M0 2h4'/%3E%3C/svg%3E")}.custom-radio .custom-control-indicator{border-radius:50%}.custom-radio .custom-control-input:checked~.custom-control-indicator{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3E%3Ccircle r='3' fill='#fff'/%3E%3C/svg%3E")}.custom-controls-stacked .custom-control{float:left;clear:left}.custom-controls-stacked .custom-control+.custom-control{margin-left:0}.custom-select{display:inline-block;max-width:100%;height:calc(2.5rem - 2px);padding:.375rem 1.75rem .375rem .75rem;padding-right:.75rem\9;color:#7a7a7a;vertical-align:middle;background:#fff url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='#333' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E") no-repeat right .75rem center;background-image:none\9;background-size:8px 10px;border:1px solid rgba(0,0,0,.25);border-radius:0;-moz-appearance:none;-webkit-appearance:none}.custom-select:focus{border-color:#51a7e8;outline:none}.custom-select:focus::-ms-value{color:#7a7a7a;background-color:#fff}.custom-select:disabled{color:#f1f1f1;cursor:not-allowed;background-color:#f6f6f6}.custom-select::-ms-expand{opacity:0}.custom-select-sm{padding-top:.375rem;padding-bottom:.375rem;font-size:75%}.custom-file{position:relative;display:inline-block;max-width:100%;height:2.5rem;cursor:pointer}.custom-file-input{min-width:14rem;max-width:100%;margin:0;filter:alpha(opacity=0);opacity:0}.custom-file-control{position:absolute;top:0;right:0;left:0;z-index:5;height:2.5rem;padding:.5rem 1rem;line-height:1.5;color:#555;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-color:#fff;border:1px solid #ddd;border-radius:0}.custom-file-control:lang(en):after{content:"Choose file..."}.custom-file-control:before{position:absolute;top:-1px;right:-1px;bottom:-1px;z-index:6;display:block;height:2.5rem;padding:.5rem 1rem;line-height:1.5;color:#555;background-color:#eee;border:1px solid #ddd;border-radius:0 0 0 0}.custom-file-control:lang(en):before{content:"Browse"}.nav{padding-left:0;margin-bottom:0;list-style:none}.nav-link{display:inline-block}.nav-link:focus,.nav-link:hover{text-decoration:none}.nav-link.disabled{color:#f1f1f1}.nav-link.disabled,.nav-link.disabled:focus,.nav-link.disabled:hover{color:#f1f1f1;cursor:not-allowed;background-color:transparent}.nav-inline .nav-item{display:inline-block}.nav-inline .nav-item+.nav-item,.nav-inline .nav-link+.nav-link{margin-left:1rem}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs:after{content:"";display:table;clear:both}.nav-tabs .nav-item{float:left;margin-bottom:-1px}.nav-tabs .nav-item+.nav-item{margin-left:.2rem}.nav-tabs .nav-link{display:block;padding:.5em 1em;border:1px solid transparent;border-top-right-radius:0;border-top-left-radius:0}.nav-tabs .nav-link:focus,.nav-tabs .nav-link:hover{border-color:#f6f6f6 #f6f6f6 #ddd}.nav-tabs .nav-link.disabled,.nav-tabs .nav-link.disabled:focus,.nav-tabs .nav-link.disabled:hover{color:#f1f1f1;background-color:transparent;border-color:transparent}.nav-tabs .nav-item.open .nav-link,.nav-tabs .nav-item.open .nav-link:focus,.nav-tabs .nav-item.open .nav-link:hover,.nav-tabs .nav-link.active,.nav-tabs .nav-link.active:focus,.nav-tabs .nav-link.active:hover{color:#7a7a7a;background-color:#fff;border-color:#ddd #ddd transparent}.nav-tabs .dropdown-menu{margin-top:-1px;border-top-right-radius:0;border-top-left-radius:0}.nav-pills:after{content:"";display:table;clear:both}.nav-pills .nav-item{float:left}.nav-pills .nav-item+.nav-item{margin-left:.2rem}.nav-pills .nav-link{display:block;padding:.5em 1em;border-radius:0}.nav-pills .nav-item.open .nav-link,.nav-pills .nav-item.open .nav-link:focus,.nav-pills .nav-item.open .nav-link:hover,.nav-pills .nav-link.active,.nav-pills .nav-link.active:focus,.nav-pills .nav-link.active:hover{color:#fff;cursor:default;background-color:#2fb5d2}.nav-stacked .nav-item{display:block;float:none}.nav-stacked .nav-item+.nav-item{margin-top:.2rem;margin-left:0}.tab-content>.tab-pane{display:none}.tab-content>.active{display:block}.navbar{position:relative;padding:.5rem 1rem}.navbar:after{content:"";display:table;clear:both}@media (min-width:576px){.navbar{border-radius:0}}.navbar-full{z-index:1000}@media (min-width:576px){.navbar-full{border-radius:0}}.navbar-fixed-bottom,.navbar-fixed-top{position:fixed;right:0;left:0;z-index:1030}@media (min-width:576px){.navbar-fixed-bottom,.navbar-fixed-top{border-radius:0}}.navbar-fixed-top{top:0}.navbar-fixed-bottom{bottom:0}.navbar-sticky-top{position:-webkit-sticky;position:sticky;top:0;z-index:1030;width:100%}@media (min-width:576px){.navbar-sticky-top{border-radius:0}}.navbar-brand{float:left;padding-top:.25rem;padding-bottom:.25rem;margin-right:1rem;font-size:.9375rem;line-height:inherit}.navbar-brand:focus,.navbar-brand:hover{text-decoration:none}.navbar-divider{float:left;width:1px;padding-top:.425rem;padding-bottom:.425rem;margin-right:1rem;margin-left:1rem;overflow:hidden}.navbar-divider:before{content:"\A0"}.navbar-text{display:inline-block;padding-top:.425rem;padding-bottom:.425rem}.navbar-toggler{width:2.5em;height:2em;padding:.5rem .75rem;font-size:.9375rem;line-height:1;background:transparent no-repeat 50%;background-size:24px 24px;border:1px solid transparent;border-radius:0}.navbar-toggler:focus,.navbar-toggler:hover{text-decoration:none}@media (max-width:575px){.navbar-toggleable-xs .navbar-brand{display:block;float:none;margin-top:.5rem;margin-right:0}.navbar-toggleable-xs .navbar-nav{margin-top:.5rem;margin-bottom:.5rem}.navbar-toggleable-xs .navbar-nav .dropdown-menu{position:static;float:none}}@media (min-width:576px){.navbar-toggleable-xs{display:block}}@media (max-width:767px){.navbar-toggleable-sm .navbar-brand{display:block;float:none;margin-top:.5rem;margin-right:0}.navbar-toggleable-sm .navbar-nav{margin-top:.5rem;margin-bottom:.5rem}.navbar-toggleable-sm .navbar-nav .dropdown-menu{position:static;float:none}}@media (min-width:768px){.navbar-toggleable-sm{display:block}}@media (max-width:991px){.navbar-toggleable-md .navbar-brand{display:block;float:none;margin-top:.5rem;margin-right:0}.navbar-toggleable-md .navbar-nav{margin-top:.5rem;margin-bottom:.5rem}.navbar-toggleable-md .navbar-nav .dropdown-menu{position:static;float:none}}@media (min-width:992px){.navbar-toggleable-md{display:block}}.navbar-toggleable-lg:after{content:"";display:table;clear:both}@media (max-width:1199px){.navbar-toggleable-lg .navbar-brand{display:block;float:none;margin-top:.5rem;margin-right:0}.navbar-toggleable-lg .navbar-nav{margin-top:.5rem;margin-bottom:.5rem}.navbar-toggleable-lg .navbar-nav .dropdown-menu{position:static;float:none}}@media (min-width:1200px){.navbar-toggleable-lg{display:block}}.navbar-toggleable-xl{display:block}.navbar-toggleable-xl:after{content:"";display:table;clear:both}.navbar-toggleable-xl .navbar-brand{display:block;float:none;margin-top:.5rem;margin-right:0}.navbar-toggleable-xl .navbar-nav{margin-top:.5rem;margin-bottom:.5rem}.navbar-toggleable-xl .navbar-nav .dropdown-menu{position:static;float:none}.navbar-nav .nav-item{float:left}.navbar-nav .nav-link{display:block;padding-top:.425rem;padding-bottom:.425rem}.navbar-nav .nav-item+.nav-item,.navbar-nav .nav-link+.nav-link{margin-left:1rem}.navbar-light .navbar-brand,.navbar-light .navbar-brand:focus,.navbar-light .navbar-brand:hover,.navbar-light .navbar-toggler,.navbar-light .navbar-toggler:focus,.navbar-light .navbar-toggler:hover{color:rgba(0,0,0,.9)}.navbar-light .navbar-nav .nav-link{color:rgba(0,0,0,.5)}.navbar-light .navbar-nav .nav-link:focus,.navbar-light .navbar-nav .nav-link:hover{color:rgba(0,0,0,.7)}.navbar-light .navbar-nav .active>.nav-link,.navbar-light .navbar-nav .active>.nav-link:focus,.navbar-light .navbar-nav .active>.nav-link:hover,.navbar-light .navbar-nav .nav-link.active,.navbar-light .navbar-nav .nav-link.active:focus,.navbar-light .navbar-nav .nav-link.active:hover,.navbar-light .navbar-nav .nav-link.open,.navbar-light .navbar-nav .nav-link.open:focus,.navbar-light .navbar-nav .nav-link.open:hover,.navbar-light .navbar-nav .open>.nav-link,.navbar-light .navbar-nav .open>.nav-link:focus,.navbar-light .navbar-nav .open>.nav-link:hover{color:rgba(0,0,0,.9)}.navbar-light .navbar-toggler{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(0, 0, 0, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");border-color:rgba(0,0,0,.1)}.navbar-light .navbar-divider{background-color:rgba(0,0,0,.075)}.navbar-dark .navbar-brand,.navbar-dark .navbar-brand:focus,.navbar-dark .navbar-brand:hover,.navbar-dark .navbar-toggler,.navbar-dark .navbar-toggler:focus,.navbar-dark .navbar-toggler:hover{color:#fff}.navbar-dark .navbar-nav .nav-link{color:hsla(0,0%,100%,.5)}.navbar-dark .navbar-nav .nav-link:focus,.navbar-dark .navbar-nav .nav-link:hover{color:hsla(0,0%,100%,.75)}.navbar-dark .navbar-nav .active>.nav-link,.navbar-dark .navbar-nav .active>.nav-link:focus,.navbar-dark .navbar-nav .active>.nav-link:hover,.navbar-dark .navbar-nav .nav-link.active,.navbar-dark .navbar-nav .nav-link.active:focus,.navbar-dark .navbar-nav .nav-link.active:hover,.navbar-dark .navbar-nav .nav-link.open,.navbar-dark .navbar-nav .nav-link.open:focus,.navbar-dark .navbar-nav .nav-link.open:hover,.navbar-dark .navbar-nav .open>.nav-link,.navbar-dark .navbar-nav .open>.nav-link:focus,.navbar-dark .navbar-nav .open>.nav-link:hover{color:#fff}.navbar-dark .navbar-toggler{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(255, 255, 255, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");border-color:hsla(0,0%,100%,.1)}.navbar-dark .navbar-divider{background-color:hsla(0,0%,100%,.075)}.navbar-toggleable-xs:after{content:"";display:table;clear:both}@media (max-width:575px){.navbar-toggleable-xs .navbar-nav .nav-item{float:none;margin-left:0}}@media (min-width:576px){.navbar-toggleable-xs{display:block!important}}.navbar-toggleable-sm:after{content:"";display:table;clear:both}@media (max-width:767px){.navbar-toggleable-sm .navbar-nav .nav-item{float:none;margin-left:0}}@media (min-width:768px){.navbar-toggleable-sm{display:block!important}}.navbar-toggleable-md:after{content:"";display:table;clear:both}@media (max-width:991px){.navbar-toggleable-md .navbar-nav .nav-item{float:none;margin-left:0}}@media (min-width:992px){.navbar-toggleable-md{display:block!important}}.card{position:relative;display:block;margin-bottom:.75rem;background-color:#fff;border-radius:0;border:1px solid rgba(0,0,0,.125)}.card-block{padding:1.25rem}.card-block:after{content:"";display:table;clear:both}.card-title{margin-bottom:.75rem}.card-subtitle{margin-top:-.375rem}.card-subtitle,.card-text:last-child{margin-bottom:0}.card-link:hover{text-decoration:none}.card-link+.card-link{margin-left:1.25rem}.card>.list-group:first-child .list-group-item:first-child{border-top-right-radius:0;border-top-left-radius:0}.card>.list-group:last-child .list-group-item:last-child{border-bottom-right-radius:0;border-bottom-left-radius:0}.card-header{padding:.75rem 1.25rem;margin-bottom:0;background-color:#f5f5f5;border-bottom:1px solid rgba(0,0,0,.125)}.card-header:after{content:"";display:table;clear:both}.card-header:first-child{border-radius:-1px -1px 0 0}.card-footer{padding:.75rem 1.25rem;background-color:#f5f5f5;border-top:1px solid rgba(0,0,0,.125)}.card-footer:after{content:"";display:table;clear:both}.card-footer:last-child{border-radius:0 0 -1px -1px}.card-header-tabs{margin-bottom:-.75rem;border-bottom:0}.card-header-pills,.card-header-tabs{margin-right:-.625rem;margin-left:-.625rem}.card-primary{background-color:#2fb5d2;border-color:#2fb5d2}.card-primary .card-footer,.card-primary .card-header{background-color:transparent}.card-success{background-color:#4cbb6c;border-color:#4cbb6c}.card-success .card-footer,.card-success .card-header{background-color:transparent}.card-info{background-color:#5bc0de;border-color:#5bc0de}.card-info .card-footer,.card-info .card-header{background-color:transparent}.card-warning{background-color:#ff9a52;border-color:#ff9a52}.card-warning .card-footer,.card-warning .card-header{background-color:transparent}.card-danger{background-color:#ff4c4c;border-color:#ff4c4c}.card-danger .card-footer,.card-danger .card-header,.card-outline-primary{background-color:transparent}.card-outline-primary{border-color:#2fb5d2}.card-outline-secondary{background-color:transparent;border-color:transparent}.card-outline-info{background-color:transparent;border-color:#5bc0de}.card-outline-success{background-color:transparent;border-color:#4cbb6c}.card-outline-warning{background-color:transparent;border-color:#ff9a52}.card-outline-danger{background-color:transparent;border-color:#ff4c4c}.card-inverse .card-footer,.card-inverse .card-header{border-color:hsla(0,0%,100%,.2)}.card-inverse .card-blockquote,.card-inverse .card-footer,.card-inverse .card-header,.card-inverse .card-title{color:#fff}.card-inverse .card-blockquote .blockquote-footer,.card-inverse .card-link,.card-inverse .card-subtitle,.card-inverse .card-text{color:hsla(0,0%,100%,.65)}.card-inverse .card-link:focus,.card-inverse .card-link:hover{color:#fff}.card-blockquote{padding:0;margin-bottom:0;border-left:0}.card-img{border-radius:-1px}.card-img-overlay{position:absolute;top:0;right:0;bottom:0;left:0;padding:1.25rem}.card-img-top{border-top-right-radius:-1px;border-top-left-radius:-1px}.card-img-bottom{border-bottom-right-radius:-1px;border-bottom-left-radius:-1px}@media (min-width:576px){.card-deck{display:table;width:100%;margin-bottom:.75rem;table-layout:fixed;border-spacing:1.25rem 0}.card-deck .card{display:table-cell;margin-bottom:0;vertical-align:top}.card-deck-wrapper{margin-right:-1.25rem;margin-left:-1.25rem}}@media (min-width:576px){.card-group{display:table;width:100%;table-layout:fixed}.card-group .card{display:table-cell;vertical-align:top}.card-group .card+.card{margin-left:0;border-left:0}.card-group .card:first-child{border-bottom-right-radius:0;border-top-right-radius:0}.card-group .card:first-child .card-img-top{border-top-right-radius:0}.card-group .card:first-child .card-img-bottom{border-bottom-right-radius:0}.card-group .card:last-child{border-bottom-left-radius:0;border-top-left-radius:0}.card-group .card:last-child .card-img-top{border-top-left-radius:0}.card-group .card:last-child .card-img-bottom{border-bottom-left-radius:0}.card-group .card:not(:first-child):not(:last-child),.card-group .card:not(:first-child):not(:last-child) .card-img-bottom,.card-group .card:not(:first-child):not(:last-child) .card-img-top{border-radius:0}}@media (min-width:576px){.card-columns{-webkit-column-count:3;column-count:3;-webkit-column-gap:1.25rem;column-gap:1.25rem}.card-columns .card{display:inline-block;width:100%}}.breadcrumb{padding:.75rem 1rem;margin-bottom:1rem;list-style:none;background-color:#f6f6f6;border-radius:0}.breadcrumb:after{content:"";display:table;clear:both}.breadcrumb-item{float:left}.breadcrumb-item+.breadcrumb-item:before{display:inline-block;padding-right:.5rem;padding-left:.5rem;color:#f1f1f1;content:"/"}.breadcrumb-item+.breadcrumb-item:hover:before{text-decoration:underline;text-decoration:none}.breadcrumb-item.active{color:#f1f1f1}.pagination{display:inline-block;padding-left:0;margin-top:1rem;margin-bottom:1rem;border-radius:0}.page-item{display:inline}.page-item:first-child .page-link{margin-left:0;border-bottom-left-radius:0;border-top-left-radius:0}.page-item:last-child .page-link{border-bottom-right-radius:0;border-top-right-radius:0}.page-item.active .page-link,.page-item.active .page-link:focus,.page-item.active .page-link:hover{z-index:2;color:#fff;cursor:default;background-color:#2fb5d2;border-color:#2fb5d2}.page-item.disabled .page-link,.page-item.disabled .page-link:focus,.page-item.disabled .page-link:hover{color:#f1f1f1;pointer-events:none;cursor:not-allowed;background-color:#fff;border-color:#ddd}.page-link{position:relative;float:left;padding:.5rem .75rem;margin-left:-1px;color:#2fb5d2;text-decoration:none;background-color:#fff;border:1px solid #ddd}.page-link:focus,.page-link:hover{color:#208094;background-color:#f6f6f6;border-color:#ddd}.pagination-lg .page-link{padding:.75rem 1.5rem;font-size:.9375rem}.pagination-lg .page-item:first-child .page-link{border-bottom-left-radius:.3rem;border-top-left-radius:.3rem}.pagination-lg .page-item:last-child .page-link{border-bottom-right-radius:.3rem;border-top-right-radius:.3rem}.pagination-sm .page-link{padding:.275rem .75rem;font-size:.875rem}.pagination-sm .page-item:first-child .page-link{border-bottom-left-radius:.2rem;border-top-left-radius:.2rem}.pagination-sm .page-item:last-child .page-link{border-bottom-right-radius:.2rem;border-top-right-radius:.2rem}.tag{display:inline-block;padding:.25em .4em;font-size:75%;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:0}.tag:empty{display:none}.btn .tag{position:relative;top:-1px}a.tag:focus,a.tag:hover{color:#fff;text-decoration:none;cursor:pointer}.tag-pill{padding-right:.6em;padding-left:.6em;border-radius:10rem}.tag-default{background-color:#f1f1f1}.tag-default[href]:focus,.tag-default[href]:hover{background-color:#d8d8d8}.tag-primary{background-color:#2fb5d2}.tag-primary[href]:focus,.tag-primary[href]:hover{background-color:#2592a9}.tag-success{background-color:#4cbb6c}.tag-success[href]:focus,.tag-success[href]:hover{background-color:#3a9a56}.tag-info{background-color:#5bc0de}.tag-info[href]:focus,.tag-info[href]:hover{background-color:#31b0d5}.tag-warning{background-color:#ff9a52}.tag-warning[href]:focus,.tag-warning[href]:hover{background-color:#ff7c1f}.tag-danger{background-color:#ff4c4c}.tag-danger[href]:focus,.tag-danger[href]:hover{background-color:#ff1919}.jumbotron{padding:2rem 1rem;margin-bottom:2rem;background-color:#f6f6f6;border-radius:.3rem}@media (min-width:576px){.jumbotron{padding:4rem 2rem}}.jumbotron-hr{border-top-color:#ddd}.jumbotron-fluid{padding-right:0;padding-left:0;border-radius:0}.alert{padding:.75rem 1.25rem;margin-bottom:1rem;border:1px solid transparent;border-radius:0}.alert-heading{color:inherit}.alert-link{font-weight:700}.alert-dismissible{padding-right:2.5rem}.alert-dismissible .close{position:relative;top:-.125rem;right:-1.25rem;color:inherit}.alert-success{background-color:#dff0d8;border-color:#d0e9c6;color:#3c763d}.alert-success hr{border-top-color:#c1e2b3}.alert-success .alert-link{color:#2b542c}.alert-info{background-color:#d9edf7;border-color:#bcdff1;color:#31708f}.alert-info hr{border-top-color:#a6d5ec}.alert-info .alert-link{color:#245269}.alert-warning{background-color:rgba(255,154,82,.3);border-color:#ff9a52;color:#232323}.alert-warning hr{border-top-color:#ff8b39}.alert-warning .alert-link{color:#0a0a0a}.alert-danger{background-color:#f2dede;border-color:#ebcccc;color:#a94442}.alert-danger hr{border-top-color:#e4b9b9}.alert-danger .alert-link{color:#843534}@-webkit-keyframes progress-bar-stripes{0%{background-position:1rem 0}to{background-position:0 0}}@keyframes progress-bar-stripes{0%{background-position:1rem 0}to{background-position:0 0}}.progress{display:block;width:100%;height:1rem;margin-bottom:1rem}.progress[value]{background-color:#eee;border:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;border-radius:0}.progress[value]::-ms-fill{background-color:#0074d9;border:0}.progress[value]::-moz-progress-bar{background-color:#0074d9;border-bottom-left-radius:0;border-top-left-radius:0}.progress[value]::-webkit-progress-value{background-color:#0074d9;border-bottom-left-radius:0;border-top-left-radius:0}.progress[value="100"]::-moz-progress-bar{border-bottom-right-radius:0;border-top-right-radius:0}.progress[value="100"]::-webkit-progress-value{border-bottom-right-radius:0;border-top-right-radius:0}.progress[value]::-webkit-progress-bar{background-color:#eee;border-radius:0}.progress[value],base::-moz-progress-bar{background-color:#eee;border-radius:0}@media screen and (min-width:0\0){.progress{background-color:#eee;border-radius:0}.progress-bar{display:inline-block;height:1rem;text-indent:-999rem;background-color:#0074d9;border-bottom-left-radius:0;border-top-left-radius:0}.progress[width="100%"]{border-bottom-right-radius:0;border-top-right-radius:0}}.progress-striped[value]::-webkit-progress-value{background-image:linear-gradient(45deg,hsla(0,0%,100%,.15) 25%,transparent 0,transparent 50%,hsla(0,0%,100%,.15) 0,hsla(0,0%,100%,.15) 75%,transparent 0,transparent);background-size:1rem 1rem}.progress-striped[value]::-moz-progress-bar{background-image:linear-gradient(45deg,hsla(0,0%,100%,.15) 25%,transparent 0,transparent 50%,hsla(0,0%,100%,.15) 0,hsla(0,0%,100%,.15) 75%,transparent 0,transparent);background-size:1rem 1rem}.progress-striped[value]::-ms-fill{background-image:linear-gradient(45deg,hsla(0,0%,100%,.15) 25%,transparent 0,transparent 50%,hsla(0,0%,100%,.15) 0,hsla(0,0%,100%,.15) 75%,transparent 0,transparent);background-size:1rem 1rem}@media screen and (min-width:0\0){.progress-bar-striped{background-image:linear-gradient(45deg,hsla(0,0%,100%,.15) 25%,transparent 0,transparent 50%,hsla(0,0%,100%,.15) 0,hsla(0,0%,100%,.15) 75%,transparent 0,transparent);background-size:1rem 1rem}}.progress-animated[value]::-webkit-progress-value{-webkit-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-animated[value]::-moz-progress-bar{animation:progress-bar-stripes 2s linear infinite}@media screen and (min-width:0\0){.progress-animated .progress-bar-striped{-webkit-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}}.progress-success[value]::-webkit-progress-value{background-color:#4cbb6c}.progress-success[value]::-moz-progress-bar{background-color:#4cbb6c}.progress-success[value]::-ms-fill{background-color:#4cbb6c}@media screen and (min-width:0\0){.progress-success .progress-bar{background-color:#4cbb6c}}.progress-info[value]::-webkit-progress-value{background-color:#5bc0de}.progress-info[value]::-moz-progress-bar{background-color:#5bc0de}.progress-info[value]::-ms-fill{background-color:#5bc0de}@media screen and (min-width:0\0){.progress-info .progress-bar{background-color:#5bc0de}}.progress-warning[value]::-webkit-progress-value{background-color:#ff9a52}.progress-warning[value]::-moz-progress-bar{background-color:#ff9a52}.progress-warning[value]::-ms-fill{background-color:#ff9a52}@media screen and (min-width:0\0){.progress-warning .progress-bar{background-color:#ff9a52}}.progress-danger[value]::-webkit-progress-value{background-color:#ff4c4c}.progress-danger[value]::-moz-progress-bar{background-color:#ff4c4c}.progress-danger[value]::-ms-fill{background-color:#ff4c4c}@media screen and (min-width:0\0){.progress-danger .progress-bar{background-color:#ff4c4c}}.media,.media-body{overflow:hidden}.media-body{width:10000px}.media-body,.media-left,.media-right{display:table-cell;vertical-align:top}.media-middle{vertical-align:middle}.media-bottom{vertical-align:bottom}.media-object{display:block}.media-object.img-thumbnail{max-width:none}.media-right{padding-left:10px}.media-left{padding-right:10px}.media-heading{margin-top:0;margin-bottom:5px}.media-list{padding-left:0;list-style:none}.list-group{padding-left:0;margin-bottom:0}.list-group-item{position:relative;display:block;padding:.75rem 1.25rem;margin-bottom:-1px;background-color:#fff;border:1px solid #ddd}.list-group-item:first-child{border-top-right-radius:0;border-top-left-radius:0}.list-group-item:last-child{margin-bottom:0;border-bottom-right-radius:0;border-bottom-left-radius:0}.list-group-item.disabled,.list-group-item.disabled:focus,.list-group-item.disabled:hover{color:#f1f1f1;cursor:not-allowed;background-color:#f6f6f6}.list-group-item.disabled .list-group-item-heading,.list-group-item.disabled:focus .list-group-item-heading,.list-group-item.disabled:hover .list-group-item-heading{color:inherit}.list-group-item.disabled .list-group-item-text,.list-group-item.disabled:focus .list-group-item-text,.list-group-item.disabled:hover .list-group-item-text{color:#f1f1f1}.list-group-item.active,.list-group-item.active:focus,.list-group-item.active:hover{z-index:2;color:#fff;text-decoration:none;background-color:#2fb5d2;border-color:#2fb5d2}.list-group-item.active .list-group-item-heading,.list-group-item.active .list-group-item-heading>.small,.list-group-item.active .list-group-item-heading>small,.list-group-item.active:focus .list-group-item-heading,.list-group-item.active:focus .list-group-item-heading>.small,.list-group-item.active:focus .list-group-item-heading>small,.list-group-item.active:hover .list-group-item-heading,.list-group-item.active:hover .list-group-item-heading>.small,.list-group-item.active:hover .list-group-item-heading>small{color:inherit}.list-group-item.active .list-group-item-text,.list-group-item.active:focus .list-group-item-text,.list-group-item.active:hover .list-group-item-text{color:#d7f1f6}.list-group-flush .list-group-item{border-right:0;border-left:0;border-radius:0}.list-group-item-action{width:100%;color:#555;text-align:inherit}.list-group-item-action .list-group-item-heading{color:#333}.list-group-item-action:focus,.list-group-item-action:hover{color:#555;text-decoration:none;background-color:#f5f5f5}.list-group-item-success{color:#3c763d;background-color:#dff0d8}a.list-group-item-success,button.list-group-item-success{color:#3c763d}a.list-group-item-success .list-group-item-heading,button.list-group-item-success .list-group-item-heading{color:inherit}a.list-group-item-success:focus,a.list-group-item-success:hover,button.list-group-item-success:focus,button.list-group-item-success:hover{color:#3c763d;background-color:#d0e9c6}a.list-group-item-success.active,a.list-group-item-success.active:focus,a.list-group-item-success.active:hover,button.list-group-item-success.active,button.list-group-item-success.active:focus,button.list-group-item-success.active:hover{color:#fff;background-color:#3c763d;border-color:#3c763d}.list-group-item-info{color:#31708f;background-color:#d9edf7}a.list-group-item-info,button.list-group-item-info{color:#31708f}a.list-group-item-info .list-group-item-heading,button.list-group-item-info .list-group-item-heading{color:inherit}a.list-group-item-info:focus,a.list-group-item-info:hover,button.list-group-item-info:focus,button.list-group-item-info:hover{color:#31708f;background-color:#c4e3f3}a.list-group-item-info.active,a.list-group-item-info.active:focus,a.list-group-item-info.active:hover,button.list-group-item-info.active,button.list-group-item-info.active:focus,button.list-group-item-info.active:hover{color:#fff;background-color:#31708f;border-color:#31708f}.list-group-item-warning{color:#8a6d3b;background-color:#fcf8e3}a.list-group-item-warning,button.list-group-item-warning{color:#8a6d3b}a.list-group-item-warning .list-group-item-heading,button.list-group-item-warning .list-group-item-heading{color:inherit}a.list-group-item-warning:focus,a.list-group-item-warning:hover,button.list-group-item-warning:focus,button.list-group-item-warning:hover{color:#8a6d3b;background-color:#faf2cc}a.list-group-item-warning.active,a.list-group-item-warning.active:focus,a.list-group-item-warning.active:hover,button.list-group-item-warning.active,button.list-group-item-warning.active:focus,button.list-group-item-warning.active:hover{color:#fff;background-color:#8a6d3b;border-color:#8a6d3b}.list-group-item-danger{color:#a94442;background-color:#f2dede}a.list-group-item-danger,button.list-group-item-danger{color:#a94442}a.list-group-item-danger .list-group-item-heading,button.list-group-item-danger .list-group-item-heading{color:inherit}a.list-group-item-danger:focus,a.list-group-item-danger:hover,button.list-group-item-danger:focus,button.list-group-item-danger:hover{color:#a94442;background-color:#ebcccc}a.list-group-item-danger.active,a.list-group-item-danger.active:focus,a.list-group-item-danger.active:hover,button.list-group-item-danger.active,button.list-group-item-danger.active:focus,button.list-group-item-danger.active:hover{color:#fff;background-color:#a94442;border-color:#a94442}.list-group-item-heading{margin-top:0;margin-bottom:5px}.list-group-item-text{margin-bottom:0;line-height:1.3}.embed-responsive{position:relative;display:block;height:0;padding:0;overflow:hidden}.embed-responsive .embed-responsive-item,.embed-responsive embed,.embed-responsive iframe,.embed-responsive object,.embed-responsive video{position:absolute;top:0;bottom:0;left:0;width:100%;height:100%;border:0}.embed-responsive-21by9{padding-bottom:42.85714%}.embed-responsive-16by9{padding-bottom:56.25%}.embed-responsive-4by3{padding-bottom:75%}.embed-responsive-1by1{padding-bottom:100%}.close{float:right;font-size:1.5rem;font-weight:700;line-height:1;color:#000;text-shadow:0 1px 0 #fff;opacity:.2}.close:focus,.close:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.5}button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.modal,.modal-open{overflow:hidden}.modal{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1050;display:none;outline:0}.modal.fade .modal-dialog{transition:-webkit-transform .3s ease-out;transition:transform .3s ease-out;transition:transform .3s ease-out,-webkit-transform .3s ease-out;-webkit-transform:translateY(-25%);transform:translateY(-25%)}.modal.in .modal-dialog{-webkit-transform:translate(0);transform:translate(0)}.modal-open .modal{overflow-x:hidden;overflow-y:auto}.modal-dialog{position:relative;width:auto;margin:10px}.modal-content{position:relative;background-color:#fff;background-clip:padding-box;border:1px solid rgba(0,0,0,.2);border-radius:.3rem;outline:0}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000}.modal-backdrop.fade{opacity:0}.modal-backdrop.in{opacity:.5}.modal-header{padding:15px;border-bottom:1px solid #e5e5e5}.modal-header:after{content:"";display:table;clear:both}.modal-header .close{margin-top:-2px}.modal-title{margin:0;line-height:1.5}.modal-body{position:relative;padding:15px}.modal-footer{padding:15px;text-align:right;border-top:1px solid #e5e5e5}.modal-footer:after{content:"";display:table;clear:both}.modal-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}@media (min-width:576px){.modal-dialog{max-width:600px;margin:30px auto}.modal-sm{max-width:300px}}@media (min-width:992px){.modal-lg{max-width:900px}}.tooltip{position:absolute;z-index:1070;display:block;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-style:normal;font-weight:400;letter-spacing:normal;line-break:auto;line-height:1.5;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;white-space:normal;word-break:normal;word-spacing:normal;font-size:.875rem;word-wrap:break-word;opacity:0}.tooltip.in{opacity:.9}.tooltip.bs-tether-element-attached-bottom,.tooltip.tooltip-top{padding:5px 0;margin-top:-3px}.tooltip.bs-tether-element-attached-bottom .tooltip-inner:before,.tooltip.tooltip-top .tooltip-inner:before{bottom:0;left:50%;margin-left:-5px;content:"";border-width:5px 5px 0;border-top-color:#ff4c4c}.tooltip.bs-tether-element-attached-left,.tooltip.tooltip-right{padding:0 5px;margin-left:3px}.tooltip.bs-tether-element-attached-left .tooltip-inner:before,.tooltip.tooltip-right .tooltip-inner:before{top:50%;left:0;margin-top:-5px;content:"";border-width:5px 5px 5px 0;border-right-color:#ff4c4c}.tooltip.bs-tether-element-attached-top,.tooltip.tooltip-bottom{padding:5px 0;margin-top:3px}.tooltip.bs-tether-element-attached-top .tooltip-inner:before,.tooltip.tooltip-bottom .tooltip-inner:before{top:0;left:50%;margin-left:-5px;content:"";border-width:0 5px 5px;border-bottom-color:#ff4c4c}.tooltip.bs-tether-element-attached-right,.tooltip.tooltip-left{padding:0 5px;margin-left:-3px}.tooltip.bs-tether-element-attached-right .tooltip-inner:before,.tooltip.tooltip-left .tooltip-inner:before{top:50%;right:0;margin-top:-5px;content:"";border-width:5px 0 5px 5px;border-left-color:#ff4c4c}.tooltip-inner{max-width:200px;padding:3px 8px;color:#fff;text-align:center;background-color:#ff4c4c;border-radius:0}.tooltip-inner:before{position:absolute;width:0;height:0;border-color:transparent;border-style:solid}.popover{position:absolute;top:0;left:0;z-index:1060;display:block;max-width:276px;padding:1px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-style:normal;font-weight:400;letter-spacing:normal;line-break:auto;line-height:1.5;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;white-space:normal;word-break:normal;word-spacing:normal;font-size:.875rem;word-wrap:break-word;background-color:#fff;background-clip:padding-box;border:1px solid rgba(0,0,0,.2);border-radius:.3rem}.popover.bs-tether-element-attached-bottom,.popover.popover-top{margin-top:-10px}.popover.bs-tether-element-attached-bottom:after,.popover.bs-tether-element-attached-bottom:before,.popover.popover-top:after,.popover.popover-top:before{left:50%;border-bottom-width:0}.popover.bs-tether-element-attached-bottom:before,.popover.popover-top:before{bottom:-11px;margin-left:-11px;border-top-color:rgba(0,0,0,.25)}.popover.bs-tether-element-attached-bottom:after,.popover.popover-top:after{bottom:-10px;margin-left:-10px;border-top-color:#fff}.popover.bs-tether-element-attached-left,.popover.popover-right{margin-left:10px}.popover.bs-tether-element-attached-left:after,.popover.bs-tether-element-attached-left:before,.popover.popover-right:after,.popover.popover-right:before{top:50%;border-left-width:0}.popover.bs-tether-element-attached-left:before,.popover.popover-right:before{left:-11px;margin-top:-11px;border-right-color:rgba(0,0,0,.25)}.popover.bs-tether-element-attached-left:after,.popover.popover-right:after{left:-10px;margin-top:-10px;border-right-color:#fff}.popover.bs-tether-element-attached-top,.popover.popover-bottom{margin-top:10px}.popover.bs-tether-element-attached-top:after,.popover.bs-tether-element-attached-top:before,.popover.popover-bottom:after,.popover.popover-bottom:before{left:50%;border-top-width:0}.popover.bs-tether-element-attached-top:before,.popover.popover-bottom:before{top:-11px;margin-left:-11px;border-bottom-color:rgba(0,0,0,.25)}.popover.bs-tether-element-attached-top:after,.popover.popover-bottom:after{top:-10px;margin-left:-10px;border-bottom-color:#f7f7f7}.popover.bs-tether-element-attached-top .popover-title:before,.popover.popover-bottom .popover-title:before{position:absolute;top:0;left:50%;display:block;width:20px;margin-left:-10px;content:"";border-bottom:1px solid #f7f7f7}.popover.bs-tether-element-attached-right,.popover.popover-left{margin-left:-10px}.popover.bs-tether-element-attached-right:after,.popover.bs-tether-element-attached-right:before,.popover.popover-left:after,.popover.popover-left:before{top:50%;border-right-width:0}.popover.bs-tether-element-attached-right:before,.popover.popover-left:before{right:-11px;margin-top:-11px;border-left-color:rgba(0,0,0,.25)}.popover.bs-tether-element-attached-right:after,.popover.popover-left:after{right:-10px;margin-top:-10px;border-left-color:#fff}.popover-title{padding:8px 14px;margin:0;font-size:1rem;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;border-radius:.2375rem .2375rem 0 0}.popover-title:empty{display:none}.popover-content{padding:9px 14px}.popover:after,.popover:before{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.popover:before{content:"";border-width:11px}.popover:after{content:"";border-width:10px}.carousel,.carousel-inner{position:relative}.carousel-inner{width:100%;overflow:hidden}.carousel-inner>.carousel-item{position:relative;display:none;transition:left .6s ease-in-out}.carousel-inner>.carousel-item>a>img,.carousel-inner>.carousel-item>img{line-height:1}@media (-webkit-transform-3d),(transform-3d){.carousel-inner>.carousel-item{transition:-webkit-transform .6s ease-in-out;transition:transform .6s ease-in-out;transition:transform .6s ease-in-out,-webkit-transform .6s ease-in-out;-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-perspective:1000px;perspective:1000px}.carousel-inner>.carousel-item.active.right,.carousel-inner>.carousel-item.next{left:0;-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0)}.carousel-inner>.carousel-item.active.left,.carousel-inner>.carousel-item.prev{left:0;-webkit-transform:translate3d(-100%,0,0);transform:translate3d(-100%,0,0)}.carousel-inner>.carousel-item.active,.carousel-inner>.carousel-item.next.left,.carousel-inner>.carousel-item.prev.right{left:0;-webkit-transform:translateZ(0);transform:translateZ(0)}}.carousel-inner>.active,.carousel-inner>.next,.carousel-inner>.prev{display:block}.carousel-inner>.active{left:0}.carousel-inner>.next,.carousel-inner>.prev{position:absolute;top:0;width:100%}.carousel-inner>.next{left:100%}.carousel-inner>.prev{left:-100%}.carousel-inner>.next.left,.carousel-inner>.prev.right{left:0}.carousel-inner>.active.left{left:-100%}.carousel-inner>.active.right{left:100%}.carousel-control{position:absolute;top:0;bottom:0;left:0;width:15%;font-size:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,.6);opacity:.5}.carousel-control.left{background-image:linear-gradient(90deg,rgba(0,0,0,.5) 0,rgba(0,0,0,.0001));background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#80000000",endColorstr="#00000000",GradientType=1)}.carousel-control.right{right:0;left:auto;background-image:linear-gradient(90deg,rgba(0,0,0,.0001) 0,rgba(0,0,0,.5));background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#00000000",endColorstr="#80000000",GradientType=1)}.carousel-control:focus,.carousel-control:hover{color:#fff;text-decoration:none;outline:0;opacity:.9}.carousel-control .icon-next,.carousel-control .icon-prev{position:absolute;top:50%;z-index:5;display:inline-block;width:20px;height:20px;margin-top:-10px;font-family:serif;line-height:1}.carousel-control .icon-prev{left:50%;margin-left:-10px}.carousel-control .icon-next{right:50%;margin-right:-10px}.carousel-control .icon-prev:before{content:"\2039"}.carousel-control .icon-next:before{content:"\203A"}.carousel-indicators{position:absolute;bottom:10px;left:50%;z-index:15;width:60%;padding-left:0;margin-left:-30%;text-align:center;list-style:none}.carousel-indicators li{display:inline-block;width:10px;height:10px;margin:1px;text-indent:-999px;cursor:pointer;background-color:transparent;border:1px solid #fff;border-radius:10px}.carousel-indicators .active{width:12px;height:12px;margin:0;background-color:#fff}.carousel-caption{position:absolute;right:15%;bottom:20px;left:15%;z-index:10;padding-top:20px;padding-bottom:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,.6)}.carousel-caption .btn{text-shadow:none}@media (min-width:576px){.carousel-control .icon-next,.carousel-control .icon-prev{width:30px;height:30px;margin-top:-15px;font-size:30px}.carousel-control .icon-prev{margin-left:-15px}.carousel-control .icon-next{margin-right:-15px}.carousel-caption{right:20%;left:20%;padding-bottom:30px}.carousel-indicators{bottom:20px}}.align-baseline{vertical-align:baseline!important}.align-top{vertical-align:top!important}.align-middle{vertical-align:middle!important}.align-bottom{vertical-align:bottom!important}.align-text-bottom{vertical-align:text-bottom!important}.align-text-top{vertical-align:text-top!important}.bg-faded{background-color:#f7f7f9}.bg-primary{background-color:#2fb5d2!important}a.bg-primary:focus,a.bg-primary:hover{background-color:#2592a9!important}.bg-success{background-color:#4cbb6c!important}a.bg-success:focus,a.bg-success:hover{background-color:#3a9a56!important}.bg-info{background-color:#5bc0de!important}a.bg-info:focus,a.bg-info:hover{background-color:#31b0d5!important}.bg-warning{background-color:#ff9a52!important}a.bg-warning:focus,a.bg-warning:hover{background-color:#ff7c1f!important}.bg-danger{background-color:#ff4c4c!important}a.bg-danger:focus,a.bg-danger:hover{background-color:#ff1919!important}.bg-inverse{background-color:#363a42!important}a.bg-inverse:focus,a.bg-inverse:hover{background-color:#1f2126!important}.rounded{border-radius:0}.rounded-top{border-top-right-radius:0;border-top-left-radius:0}.rounded-right{border-bottom-right-radius:0;border-top-right-radius:0}.rounded-bottom{border-bottom-right-radius:0;border-bottom-left-radius:0}.rounded-left{border-bottom-left-radius:0;border-top-left-radius:0}.rounded-circle{border-radius:50%}.clearfix:after{content:"";display:table;clear:both}.d-block{display:block!important}.d-inline-block{display:inline-block!important}.d-inline{display:inline!important}.float-xs-left{float:left!important}.float-xs-right{float:right!important}.float-xs-none{float:none!important}@media (min-width:576px){.float-sm-left{float:left!important}.float-sm-right{float:right!important}.float-sm-none{float:none!important}}@media (min-width:768px){.float-md-left{float:left!important}.float-md-right{float:right!important}.float-md-none{float:none!important}}@media (min-width:992px){.float-lg-left{float:left!important}.float-lg-right{float:right!important}.float-lg-none{float:none!important}}@media (min-width:1200px){.float-xl-left{float:left!important}.float-xl-right{float:right!important}.float-xl-none{float:none!important}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}.w-100{width:100%!important}.h-100{height:100%!important}.mx-auto{margin-right:auto!important;margin-left:auto!important}.m-0{margin:0!important}.mt-0{margin-top:0!important}.mr-0{margin-right:0!important}.mb-0{margin-bottom:0!important}.ml-0,.mx-0{margin-left:0!important}.mx-0{margin-right:0!important}.my-0{margin-top:0!important;margin-bottom:0!important}.m-1{margin:1rem!important}.mt-1{margin-top:1rem!important}.mr-1{margin-right:1rem!important}.mb-1{margin-bottom:1rem!important}.ml-1,.mx-1{margin-left:1rem!important}.mx-1{margin-right:1rem!important}.my-1{margin-top:1rem!important;margin-bottom:1rem!important}.m-2{margin:1.5rem!important}.mt-2{margin-top:1.5rem!important}.mr-2{margin-right:1.5rem!important}.mb-2{margin-bottom:1.5rem!important}.ml-2,.mx-2{margin-left:1.5rem!important}.mx-2{margin-right:1.5rem!important}.my-2{margin-top:1.5rem!important;margin-bottom:1.5rem!important}.m-3{margin:3rem!important}.mt-3{margin-top:3rem!important}.mr-3{margin-right:3rem!important}.mb-3{margin-bottom:3rem!important}.ml-3,.mx-3{margin-left:3rem!important}.mx-3{margin-right:3rem!important}.my-3{margin-top:3rem!important;margin-bottom:3rem!important}.p-0{padding:0!important}.pt-0{padding-top:0!important}.pr-0{padding-right:0!important}.pb-0{padding-bottom:0!important}.pl-0,.px-0{padding-left:0!important}.px-0{padding-right:0!important}.py-0{padding-top:0!important;padding-bottom:0!important}.p-1{padding:1rem!important}.pt-1{padding-top:1rem!important}.pr-1{padding-right:1rem!important}.pb-1{padding-bottom:1rem!important}.pl-1,.px-1{padding-left:1rem!important}.px-1{padding-right:1rem!important}.py-1{padding-top:1rem!important;padding-bottom:1rem!important}.p-2{padding:1.5rem!important}.pt-2{padding-top:1.5rem!important}.pr-2{padding-right:1.5rem!important}.pb-2{padding-bottom:1.5rem!important}.pl-2,.px-2{padding-left:1.5rem!important}.px-2{padding-right:1.5rem!important}.py-2{padding-top:1.5rem!important;padding-bottom:1.5rem!important}.p-3{padding:3rem!important}.pt-3{padding-top:3rem!important}.pr-3{padding-right:3rem!important}.pb-3{padding-bottom:3rem!important}.pl-3,.px-3{padding-left:3rem!important}.px-3{padding-right:3rem!important}.py-3{padding-top:3rem!important;padding-bottom:3rem!important}.pos-f-t{position:fixed;top:0;right:0;left:0;z-index:1030}.text-justify{text-align:justify!important}.text-nowrap{white-space:nowrap!important}.text-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.text-xs-left{text-align:left!important}.text-xs-right{text-align:right!important}.text-xs-center{text-align:center!important}@media (min-width:576px){.text-sm-left{text-align:left!important}.text-sm-right{text-align:right!important}.text-sm-center{text-align:center!important}}@media (min-width:768px){.text-md-left{text-align:left!important}.text-md-right{text-align:right!important}.text-md-center{text-align:center!important}}@media (min-width:992px){.text-lg-left{text-align:left!important}.text-lg-right{text-align:right!important}.text-lg-center{text-align:center!important}}@media (min-width:1200px){.text-xl-left{text-align:left!important}.text-xl-right{text-align:right!important}.text-xl-center{text-align:center!important}}.text-lowercase{text-transform:lowercase!important}.text-uppercase{text-transform:uppercase!important}.text-capitalize{text-transform:capitalize!important}.font-weight-normal{font-weight:400}.font-weight-bold{font-weight:700}.font-italic{font-style:italic}.text-white{color:#fff!important}.text-muted{color:#7a7a7a!important}a.text-muted:focus,a.text-muted:hover{color:#616161!important}.text-primary{color:#2fb5d2!important}a.text-primary:focus,a.text-primary:hover{color:#2592a9!important}.text-success{color:#4cbb6c!important}a.text-success:focus,a.text-success:hover{color:#3a9a56!important}.text-info{color:#5bc0de!important}a.text-info:focus,a.text-info:hover{color:#31b0d5!important}.text-warning{color:#ff9a52!important}a.text-warning:focus,a.text-warning:hover{color:#ff7c1f!important}.text-danger{color:#ff4c4c!important}a.text-danger:focus,a.text-danger:hover{color:#ff1919!important}.text-gray-dark{color:#363a42!important}a.text-gray-dark:focus,a.text-gray-dark:hover{color:#1f2126!important}.text-hide{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.invisible{visibility:hidden!important}.hidden-xs-up{display:none!important}@media (max-width:575px){.hidden-xs-down{display:none!important}}@media (min-width:576px){.hidden-sm-up{display:none!important}}@media (max-width:767px){.hidden-sm-down{display:none!important}}@media (min-width:768px){.hidden-md-up{display:none!important}}@media (max-width:991px){.hidden-md-down{display:none!important}}@media (min-width:992px){.hidden-lg-up{display:none!important}}@media (max-width:1199px){.hidden-lg-down{display:none!important}}@media (min-width:1200px){.hidden-xl-up{display:none!important}}.hidden-xl-down,.visible-print-block{display:none!important}@media print{.visible-print-block{display:block!important}}.visible-print-inline{display:none!important}@media print{.visible-print-inline{display:inline!important}}.visible-print-inline-block{display:none!important}@media print{.visible-print-inline-block{display:inline-block!important}}@media print{.hidden-print{display:none!important}}@font-face{font-family:Noto Sans;src:url(../css/3d4a907b1b7a232654324a3dd7ae4aa3.eot);src:local("Noto Sans Regular"),local("NotoSans-Regular"),url(../css/3d4a907b1b7a232654324a3dd7ae4aa3.eot) format("embedded-opentype"),url(../css/19c1b868764c0e4d15a45d3f61250488.woff2) format("woff2"),url(../css/846c191efd3d0aacde5a916cf2ebf1a4.woff) format("woff"),url(../css/2fd9c16b805724d590c0cff96da070a4.ttf) format("truetype"),url(../css/5ea9fdf2293930126fa9c544968009ae.svg) format("svg");font-weight:400;font-style:normal}@font-face{font-family:Noto Sans;src:url(../css/eeb9224f85430652fd070e4e64129aa4.eot);src:local("Noto Sans Bold"),local("NotoSans-Bold"),url(../css/eeb9224f85430652fd070e4e64129aa4.eot) format("embedded-opentype"),url(../css/199038f07312bfc6f0aabd3ed6a2b64d.woff2) format("woff2"),url(../css/c2183257e7a697769df4200c547551f1.woff) format("woff"),url(../css/a165a42685795361b25593effb32fdb1.ttf) format("truetype"),url(../css/5dc400bcedda37b13f35cb44623193cf.svg) format("svg");font-weight:700;font-style:normal}@font-face{font-family:Noto Sans;src:url(../css/a77ade19de3d3762dfbf1fe553b293cc.eot);src:local("Noto Sans Italic"),local("NotoSans-Italic"),url(../css/a77ade19de3d3762dfbf1fe553b293cc.eot) format("embedded-opentype"),url(../css/7a3ebca0cba2e2c6090e84e1d77e0f94.woff2) format("woff2"),url(../css/332f555bb44cdc394d6c799df0c03389.woff) format("woff"),url(../css/154da4697acc779b55af0a67f1241e4e.ttf) format("truetype"),url(../css/3d34be670a7f15086e512282b97ae35e.svg) format("svg");font-weight:400;font-style:italic}@font-face{font-family:Noto Sans;src:url(../css/b467416c449eb823029e16347b2ea510.eot);src:local("Noto Sans BoldItalic"),local("NotoSans-BoldItalic"),url(../css/b467416c449eb823029e16347b2ea510.eot) format("embedded-opentype"),url(../css/a68cfe9d548950edf5df102269877edd.woff2) format("woff2"),url(../css/3f81521029cc8a9a703419c4a74704a0.woff) format("woff"),url(../css/4f6ff3639c1e5728b905b650c1a06e75.ttf) format("truetype"),url(../css/80e74ff9406650e53bbec1e292c2c094.svg) format("svg");font-weight:700;font-style:italic}@font-face{font-family:Material Icons;font-style:normal;font-weight:400;src:url(../css/e79bfd88537def476913f3ed52f4f4b3.eot);src:local("Material Icons"),local("MaterialIcons-Regular"),url(../css/570eb83859dc23dd0eec423a49e147fe.woff2) format("woff2"),url(../css/012cf6a10129e2275d79d6adac7f3b02.woff) format("woff"),url(../css/a37b0c01c0baf1888ca812cc0508f6e2.ttf) format("truetype")}.material-icons{font-family:Material Icons;font-weight:400;font-style:normal;font-size:24px;display:inline-block;vertical-align:middle;width:1em;height:1em;line-height:1;text-transform:none;letter-spacing:normal;word-wrap:normal;white-space:nowrap;direction:ltr;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;-webkit-font-feature-settings:"liga";font-feature-settings:"liga"}body,html{height:100%}body{direction:ltr;font-family:Noto Sans,sans-serif;font-size:1rem;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;color:#232323;line-height:1.25em}ul{list-style:none;padding-left:0}a:hover{color:#2fb5d2;text-decoration:none}p{font-size:.9375rem;color:#7a7a7a;font-weight:400}.color,.custom-checkbox input[type=checkbox]+span.color{width:1.25rem;height:1.25rem;display:inline-block;margin:.3125rem;box-shadow:2px 2px 4px 0 rgba(0,0,0,.2);border:1px solid rgba(0,0,0,.05);cursor:pointer;background-size:contain}.color.active,.color:hover,.custom-checkbox input[type=checkbox]+span.color.active,.custom-checkbox input[type=checkbox]+span.color:hover,.facet-label.active .custom-checkbox span.color,.facet-label:hover .custom-checkbox span.color{border:2px solid #232323}.h1,.h2,.h3{text-transform:uppercase;color:#232323}.h4{font-weight:700;color:#232323}.btn-primary,.btn-secondary,.btn-tertiary{box-shadow:2px 2px 4px 0 rgba(0,0,0,.2);text-transform:uppercase;font-weight:600;padding:.5rem 1.25rem}.btn-primary .material-icons,.btn-secondary .material-icons,.btn-tertiary .material-icons{margin-right:.625rem}.btn-tertiary{background-color:#f7f7f7;text-transform:lowercase;color:#7a7a7a;box-shadow:.0625rem .0625rem .0625rem 0 rgba(0,0,0,.1);padding:.25rem;margin:.25rem 0;font-weight:400;font-size:.875rem}.btn-tertiary .material-icons{font-size:1rem}.btn-tertiary:hover{box-shadow:.0625rem .0625rem .0625rem 0 rgba(0,0,0,.2);border:1px solid rgba(35,35,35,.2)}.btn-unstyle{background-color:transparent;border:none;padding:0;text-align:inherit}.btn-unstyle:focus{outline:0}.btn-unstyle:focus .expand-more{color:#2fb5d2}.card{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2)}.label,label{color:#232323;text-align:right;font-size:.875rem}small.label,small.value{font-size:.8125rem}.form-control-label{padding-top:.625rem}.form-control{background:#f1f1f1;color:#7a7a7a;border:1px solid rgba(0,0,0,.25);padding:.5rem 1rem}.form-control:focus{background-color:#fff;color:#232323}.form-control:focus,.input-group.focus{outline:.1875rem solid #2fb5d2}.input-group .form-control:focus{outline:none}.input-group .input-group-btn{height:100%}.input-group .input-group-btn>.btn{border:0;box-shadow:none;color:#fff;font-size:.6875rem;font-weight:400;margin-left:0;padding:.625rem 1rem;text-transform:uppercase}.input-group .input-group-btn>.btn[data-action=show-password]{background:#7a7a7a;padding:.78rem 1rem}input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{color:#7a7a7a}input::-moz-placeholder,textarea::-moz-placeholder{color:#7a7a7a}input:-ms-input-placeholder,textarea:-ms-input-placeholder{color:#7a7a7a}input:-moz-placeholder,textarea:-moz-placeholder{color:#7a7a7a}input:active::-webkit-input-placeholder,textarea:active::-webkit-input-placeholder{color:#232323}input:active::-moz-placeholder,textarea:active::-moz-placeholder{color:#232323}input:active:-ms-input-placeholder,textarea:active:-ms-input-placeholder{color:#232323}input:active:-moz-placeholder,textarea:active:-moz-placeholder{color:#232323}.form-control-select{height:2.625rem;-moz-appearance:none;-webkit-appearance:none;background:#f1f1f1 url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAQAAAD9CzEMAAAAPklEQVR4Ae3TwREAEBQD0V/6do4SXPZg7EsBhsQ8IEmSMOsiuEfg3gL3oXC7wK0bd1G4o8X9F4yIkyQfSrIByQBjp7QuND8AAAAASUVORK5CYII=") no-repeat scroll right .5rem center/1.25rem 1.25rem;padding:0 .5rem}.form-control-valign{padding-top:.5rem}.form-control-comment{font-size:.875rem;padding-top:.5rem;color:#7a7a7a}.form-control-submit.disabled{background:#5bc0de;color:#fff}.form-group.has-error input,.form-group.has-error select{outline:.1875rem solid #ff4c4c}.form-group.has-error .help-block{color:#ff4c4c}.group-span-filestyle label{margin:0}.bootstrap-touchspin .group-span-filestyle .btn-touchspin,.group-span-filestyle .bootstrap-touchspin .btn-touchspin,.group-span-filestyle .btn-default{background:#2fb5d2;color:#fff;text-transform:uppercase;border-radius:0;font-size:.875rem;padding:.5rem 1rem}.bootstrap-touchspin{width:auto;float:left;display:inline-block;box-shadow:2px 2px 4px 0 rgba(0,0,0,.2)}.bootstrap-touchspin input:focus{outline:none}.bootstrap-touchspin input.form-control,.bootstrap-touchspin input.input-group{color:#232323;background-color:#fff;height:2.5rem;padding:.175rem .5rem;width:3rem;border:1px solid rgba(0,0,0,.25);float:left}.bootstrap-touchspin .btn-touchspin{background-color:#fff;border:1px solid rgba(0,0,0,.25);height:1.3125rem}.bootstrap-touchspin .btn-touchspin:hover{background-color:#f1f1f1}.bootstrap-touchspin .input-group-btn-vertical{color:#232323;width:auto;float:left}.bootstrap-touchspin .input-group-btn-vertical .bootstrap-touchspin-down,.bootstrap-touchspin .input-group-btn-vertical .bootstrap-touchspin-up{border-radius:0}.bootstrap-touchspin .input-group-btn-vertical .touchspin-up:after{content:"\E5CE"}.bootstrap-touchspin .input-group-btn-vertical .touchspin-down:after{content:"\E5CF"}.bootstrap-touchspin .input-group-btn-vertical i{top:.0625rem;left:.1875rem;font-size:.9375rem}.custom-radio{display:inline-block;position:relative;width:20px;height:20px;vertical-align:middle;cursor:pointer;border-radius:50%;border:2px solid #7a7a7a;background:#fff;margin-right:1.25rem}.custom-radio input[type=radio]{opacity:0;cursor:pointer}.custom-radio input[type=radio]:checked+span{display:block;background-color:#2fb5d2;width:12px;height:12px;border-radius:50%;position:absolute;left:.125rem;top:.125rem}.custom-radio input[type=radio]:focus+span{border-color:#7a7a7a}.custom-checkbox{position:relative}.custom-checkbox input[type=checkbox]{margin-top:.25rem;opacity:0;cursor:pointer;position:absolute}.custom-checkbox input[type=checkbox]+span{margin-right:3px;display:inline-block;width:.9375rem;height:.9375rem;vertical-align:middle;cursor:pointer;border:2px solid #232323}.custom-checkbox input[type=checkbox]+span .checkbox-checked{display:none;margin:-.25rem -.125rem;font-size:1.1rem;color:#232323}.custom-checkbox input[type=checkbox]:checked+span .checkbox-checked{display:block}.custom-checkbox input[type=checkbox]:focus+span{border-color:#7a7a7a}.custom-checkbox label{text-align:left}.text-muted{font-size:.875rem}.done{color:#4cbb6c;display:inline-block;padding:0 .8125rem;margin-right:1.563rem}.thumb-mask>.mask{position:relative;width:3.438rem;height:3.438rem;overflow:hidden;border:1px solid #f1f1f1;margin:.625rem 0}.thumb-mask>.mask img{width:55px;height:55px}.definition-list dl{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}.definition-list dl dt{font-weight:400}.definition-list dl dd,.definition-list dl dt{-webkit-box-flex:0;-ms-flex:0 0 45%;flex:0 0 45%;background:#f1f1f1;padding:.625rem;margin:.125rem}.definition-list dl dd:nth-of-type(2n),.definition-list dl dt:nth-of-type(2n){background:#f6f6f6}.help-block{margin-top:.625rem}.btn.disabled,.btn.disabled:hover{background:#7a7a7a}.alert-warning .material-icons{color:#ff9a52;font-size:2rem;margin-right:.625rem;padding-top:.3125rem}.alert-warning .alert-text{font-size:.9375rem;padding-top:.625rem}.alert-warning .alert-link{border-radius:2px;border-width:2px;margin-left:.625rem;padding:.3125rem 1.25rem;font-weight:600;font-size:.8125rem;color:#6c868e}.alert-warning ul li:last-child .alert-link{color:#fff}.alert-warning .warning-buttons{margin-top:.3125rem}.btn-tertiary-outline{color:#6c868e;background-image:none;background-color:transparent;border-color:#6c868e;border:.15rem solid #6c868e}.btn-tertiary-outline:hover{border-color:#bbcdd2;color:#bbcdd2}.alert{font-size:.8125rem}.nav-item .nav-link,.nav-item .nav-separtor{color:#7a7a7a;font-weight:700}.nav-item .nav-link.active,.nav-item .nav-separtor.active{color:#232323}.separator{margin:0;border-color:rgba(0,0,0,.25)}.modal-dialog-centered{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;min-height:calc(100% - 60px)}.ps-alert-error{margin-bottom:0}.ps-alert-error .item,.ps-alert-success .item{-webkit-box-align:center;-ms-flex-align:center;align-items:center;border:2px solid #ff4c4c;display:-webkit-box;display:-ms-flexbox;display:flex;background-color:#ff4c4c;margin-bottom:1rem}.ps-alert-error .item i,.ps-alert-success .item i{border:15px solid #ff4c4c;display:-webkit-box;display:-ms-flexbox;display:flex}.ps-alert-error .item i svg,.ps-alert-success .item i svg{background-color:#ff4c4c;width:24px;height:24px}.ps-alert-error .item p,.ps-alert-success .item p{background-color:#fff;margin:0;padding:18px 20px;width:100%}.ps-alert-success{padding:.25rem .25rem 2.75rem}.ps-alert-success .item{border-color:#4cbb6c;background-color:#4cbb6c}.ps-alert-success .item i{border-color:#4cbb6c}.ps-alert-success .item i svg{background-color:#4cbb6c}.dropdown{color:#7a7a7a}.dropdown:hover .expand-more{color:#2fb5d2}.dropdown .expand-more{color:#232323;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.dropdown .active{max-height:200px;overflow-y:hidden;visibility:visible}.dropdown select{-moz-appearance:none;border:0 none;outline:0 none;color:#232323;background:#fff}.dropdown-item:focus,.dropdown-item:hover{background:none;text-decoration:none;color:#2fb5d2}.search-widget{display:inline-block}.search-widget form{position:relative}.search-widget form input[type=text]{border:none;padding:10px;min-width:255px;color:#7a7a7a;border:1px solid rgba(0,0,0,.25)}.search-widget form input[type=text]:focus{outline:3px solid #2fb5d2;color:#232323;background:#fff}.search-widget form input[type=text]:focus+button .search{color:#2fb5d2}.search-widget form button[type=submit]{position:absolute;background:none;border:none;bottom:.3125rem;right:.125rem;color:#7a7a7a}.search-widget form button[type=submit] .search:hover{color:#2fb5d2}.header-top .search-widget form input[type=text]{min-width:inherit;width:100%}#checkout #search_widget{display:none}#pagenotfound .page-content #search_widget{width:100%}.page-not-found .search-widget form{display:inline-block}@media (max-width:767px){.header-top .search-widget{float:none}.header-top .search-widget form{margin:0 auto}.header-top .search-widget form input[type=text]{min-width:inherit;background:#fff}}@media (min-width:768px){.search-widget{min-width:15.63rem}}.top-menu[data-depth="1"]{margin:.625rem}.top-menu a:not([data-depth="0"]){display:block;padding:.625rem;color:#7a7a7a;font-weight:400}.top-menu a.dropdown-submenu{color:#232323;text-transform:uppercase;font-weight:600}.top-menu a[data-depth="0"]{font-weight:600;padding:.1875rem .625rem .375rem}#header .top-menu a[data-depth="0"]:hover{color:#2fb5d2;text-decoration:none}.top-menu a[data-depth="1"],.top-menu a[data-depth="2"]{padding:0 .625rem .625rem 0}.top-menu .collapse{display:inherit}.top-menu .sub-menu{box-shadow:2px 1px 11px 2px rgba(0,0,0,.1);border:none;margin-left:.9375rem;width:calc(100% - 30px);min-width:calc(100% - 30px);z-index:18;display:none}.top-menu .sub-menu.collapse{display:none}.top-menu .sub-menu ul[data-depth="1"]>li{float:left;margin:0 1.25rem}.top-menu .sub-menu a:hover{color:#2fb5d2}.top-menu .popover{max-width:inherit;border-radius:0}.popover.bs-tether-element-attached-top{margin-top:0}#_desktop_top_menu .top-menu[data-depth="0"] li:hover .sub-menu{display:block!important}#mobile_top_menu_wrapper{padding:15px;background:#fff}#mobile_top_menu_wrapper #top-menu{margin-bottom:.625rem}#mobile_top_menu_wrapper .top-menu{color:#232323}#mobile_top_menu_wrapper .top-menu .collapse-icons[aria-expanded=true] .add{display:none}#mobile_top_menu_wrapper .top-menu .collapse-icons[aria-expanded=true] .remove{display:block}#mobile_top_menu_wrapper .top-menu .collapse-icons .remove{display:none}#mobile_top_menu_wrapper .top-menu .navbar-toggler{display:inline-block;padding:0}#mobile_top_menu_wrapper .top-menu a[data-depth="0"]{padding:.625rem;border-bottom:1px solid #f6f6f6}#mobile_top_menu_wrapper .top-menu .collapse{display:none}#mobile_top_menu_wrapper .top-menu .collapse.in{display:block}#mobile_top_menu_wrapper .top-menu .sub-menu{box-shadow:none;z-index:inherit;display:block;position:static;overflow:hidden;margin-left:0;width:100%;min-width:100%;background:#fff}#mobile_top_menu_wrapper .top-menu .sub-menu.collapse{display:none}#mobile_top_menu_wrapper .top-menu .sub-menu.collapse.in{display:block}#mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="0"]>li{border-bottom:1px solid #7a7a7a}#mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="1"]{margin:0}#mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="1"]>li{float:none;margin:0}#mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="1"]>li a{text-transform:none}#mobile_top_menu_wrapper .top-menu .sub-menu ul{padding:0}#mobile_top_menu_wrapper .top-menu .sub-menu li>a{padding:.625rem;border-bottom:1px solid #fff;font-weight:700}#mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="2"] li a{padding-left:1.25rem}#mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="3"] li a{padding-left:2.5rem}#mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="4"] li a{padding-left:3.75rem}#mobile_top_menu_wrapper .js-top-menu-bottom a{color:#7a7a7a}#mobile_top_menu_wrapper .js-top-menu-bottom .language-selector-wrapper{padding:.625rem}#mobile_top_menu_wrapper .js-top-menu-bottom .language-selector-wrapper .language-selector{display:inline}#mobile_top_menu_wrapper .js-top-menu-bottom #contact-link,#mobile_top_menu_wrapper .js-top-menu-bottom .currency-selector{padding:.625rem}#mobile_top_menu_wrapper .js-top-menu-bottom .user-info{padding:0 .625rem}#mobile_top_menu_wrapper .js-top-menu-bottom .user-info a{padding:.625rem 0;display:block;width:100%}body#checkout{color:#232323}body#checkout #header .header-nav{max-height:none;padding:.9375rem 0;border:none;margin-bottom:0;box-shadow:2px 2px 8px 0 rgba(0,0,0,.2)}body#checkout #header .header-nav .logo{max-height:4.375rem;width:auto}body#checkout #header .header-nav #_desktop_contact_link #contact-link{margin-top:0}body#checkout .custom-checkbox{display:-webkit-box;display:-ms-flexbox;display:flex}body#checkout .custom-checkbox span{-webkit-box-flex:0;-ms-flex:0 0 15px;flex:0 0 15px;margin-top:.1875rem}body#checkout a:hover{color:#1a8196}body#checkout section#content{margin-bottom:1.563rem}body#checkout .container{min-height:100%}body#checkout section.checkout-step{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2);background-color:#fff;border-bottom:1px solid rgba(0,0,0,.25);padding:.9375rem}body#checkout section.checkout-step:last-child{border:0}body#checkout section.checkout-step .step-title{text-transform:uppercase;cursor:pointer;margin-bottom:0}body#checkout section.checkout-step .content{padding:0 2.313rem}body#checkout section.checkout-step .step-edit{text-transform:lowercase;font-weight:400}body#checkout section.checkout-step .step-edit .edit{font-size:1rem}body#checkout section.checkout-step .not-allowed{cursor:not-allowed;opacity:.5}body#checkout section.checkout-step .content,body#checkout section.checkout-step .done,body#checkout section.checkout-step .step-edit{display:none}body#checkout section.checkout-step.-unreachable .step-title{cursor:not-allowed;opacity:.5}body#checkout section.checkout-step.-current .step-title{cursor:default}body#checkout section.checkout-step.-current .content{display:block}body#checkout section.checkout-step.-current.-reachable.-complete .done,body#checkout section.checkout-step.-current.-reachable.-complete .step-edit{display:none}body#checkout section.checkout-step.-current.-reachable.-complete .step-number{display:inline-block}body#checkout section.checkout-step.-current.-reachable.-complete .content{display:block}body#checkout section.checkout-step.-reachable.-complete h1 .done{display:inline-block}body#checkout section.checkout-step.-reachable.-complete h1 .step-number{display:none}body#checkout section.checkout-step.-reachable.-complete h1 .step-edit{cursor:pointer;display:block;float:right;margin-right:.125rem;color:#7a7a7a}body#checkout section.checkout-step.-reachable.-complete .content{display:none}body#checkout section.checkout-step small{color:#7a7a7a}body#checkout section.checkout-step .default-input{min-width:40%}body#checkout section.checkout-step .default-input[name=address1],body#checkout section.checkout-step .default-input[name=address2]{min-width:60%}body#checkout section.checkout-step .radio-field{margin-top:1.875rem}body#checkout section.checkout-step .radio-field label{display:inline}body#checkout section.checkout-step .checkbox-field div{margin-top:3.75rem}body#checkout section.checkout-step .checkbox-field+.checkbox-field div{margin-top:0}body#checkout section.checkout-step .select-field div{background:#f6f6f6;padding:.625rem 3.125rem}body#checkout section.checkout-step .form-footer{text-align:center}body#checkout section.checkout-step #conditions-to-approve{padding-top:1rem}body#checkout section.checkout-step .payment-options label{display:table-cell}body#checkout section.checkout-step .payment-options .custom-radio{margin-right:1.25rem}body#checkout section.checkout-step .payment-options .payment-option{margin-bottom:.5rem}body#checkout section.checkout-step .step-number{display:inline-block;padding:.625rem}body#checkout section.checkout-step .address-selector{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start;-ms-flex-wrap:wrap;flex-wrap:wrap}body#checkout section.checkout-step .address-item{background:#f6f6f6;-webkit-box-flex:0;-ms-flex:0 0 49%;flex:0 0 49%;margin-bottom:.625rem;border:3px solid transparent}body#checkout section.checkout-step .address-item.selected{background:#fff;border:3px solid #2fb5d2}body#checkout section.checkout-step .address-alias{display:inline-block;font-weight:600;margin-bottom:.625rem}body#checkout section.checkout-step .address{margin-left:1.563rem;font-weight:400}body#checkout section.checkout-step .radio-block{padding:.9375rem;text-align:left;cursor:pointer}body#checkout section.checkout-step .custom-radio{margin-right:0}body#checkout section.checkout-step .custom-radio input[type=radio]{height:1.25rem;width:1.25rem}body#checkout section.checkout-step .delete-address,body#checkout section.checkout-step .edit-address{color:#7a7a7a;display:inline-block;margin:0 .3125rem}body#checkout section.checkout-step .delete-address .delete,body#checkout section.checkout-step .delete-address .edit,body#checkout section.checkout-step .edit-address .delete,body#checkout section.checkout-step .edit-address .edit{font-size:1rem}body#checkout section.checkout-step hr{margin:0}body#checkout section.checkout-step .address-footer{text-align:center;padding:.625rem}body#checkout section.checkout-step #delivery-addresses,body#checkout section.checkout-step #invoice-addresses,body#checkout section.checkout-step .add-address{margin-top:1.25rem}body#checkout section.checkout-step .add-address a{color:#232323}body#checkout section.checkout-step .add-address a i{font-size:.9375rem}body#checkout section.checkout-step .delivery-option{background:#f6f6f6;padding:.9375rem 0;margin-bottom:.9375rem}body#checkout section.checkout-step .delivery-option label{text-align:inherit}body#checkout section.checkout-step .delivery-option img{width:3.125rem}body#checkout section.checkout-step .carrier-delay,body#checkout section.checkout-step .carrier-name{display:inline-block;word-break:break-word;text-align:left}body#checkout section.checkout-step #customer-form,body#checkout section.checkout-step #delivery-address,body#checkout section.checkout-step #invoice-address,body#checkout section.checkout-step #login-form{margin-left:.3125rem;margin-top:1.563rem}body#checkout section.checkout-step #customer-form .form-control-label,body#checkout section.checkout-step #delivery-address .form-control-label,body#checkout section.checkout-step #invoice-address .form-control-label,body#checkout section.checkout-step #login-form .form-control-label{text-align:left}body#checkout section.checkout-step #customer-form .radio-inline,body#checkout section.checkout-step #delivery-address .radio-inline,body#checkout section.checkout-step #invoice-address .radio-inline,body#checkout section.checkout-step #login-form .radio-inline{padding:0}body#checkout section.checkout-step .sign-in{font-size:.875rem}body#checkout section.checkout-step .forgot-password{margin-left:14.38rem}body#checkout .additional-information{font-size:.875rem;margin-left:2.875rem;margin-top:1.25rem}body#checkout .condition-label{margin-left:2.5rem;margin-top:.625rem}body#checkout .condition-label label{text-align:inherit}body#checkout .cancel-address{margin:.625rem;display:block;color:#7a7a7a;text-decoration:underline}body#checkout .modal-content{padding:1.25rem;background-color:#f1f1f1}body#checkout #cart-summary-product-list{font-size:.875rem}body#checkout #cart-summary-product-list img{border:1px solid #f1f1f1;width:3.125rem}body#checkout #cart-summary-product-list .media-body{vertical-align:middle}body#checkout #order-summary-content{padding-top:.9375rem}body#checkout #order-summary-content h4.h4{margin-top:.625rem;margin-bottom:1.25rem;color:#232323}body#checkout #order-summary-content h4.black{color:#000}body#checkout #order-summary-content h4.addresshead{margin-top:.1875rem}body#checkout #order-summary-content .noshadow{box-shadow:none}body#checkout #order-summary-content #order-items{border-right:0}body#checkout #order-summary-content #order-items h3.h3{color:#232323;margin-top:1.25rem}body#checkout #order-summary-content #order-items table tr:first-child td{border-top:0}body#checkout #order-summary-content .order-confirmation-table{padding:1rem;margin-bottom:2rem;background-color:#fff;border:3px solid #e5e5e5;border-radius:0}body#checkout #order-summary-content .summary-selected-carrier{margin-bottom:.75rem;background-color:#fff;border:1px solid #e5e5e5;border-radius:0;padding:1rem}body#checkout #order-summary-content .summary-selected-carrier .logo-container{text-align:center}body#checkout #order-summary-content .summary-selected-carrier .logo-container img{width:3.125rem}body#checkout #order-summary-content .step-edit{display:inline;color:#7a7a7a}body#checkout #order-summary-content .step-edit:hover{cursor:pointer}body#checkout #order-summary-content a .step-edit{color:#7a7a7a}body#checkout #delivery,body#checkout #gift_message{max-width:100%;border-color:#232323}body#checkout #delivery textarea,body#checkout #gift_message textarea{max-width:100%;margin-bottom:10px}body#checkout #footer{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2);padding:.9375rem;background:#fff;color:#7a7a7a}#order-details{padding-left:1.3rem;margin-top:1.25rem}#order-details>.card-title{margin-bottom:1.875rem}#order-details ul{margin-bottom:1.25rem}#order-details ul li{margin-bottom:.625rem}#order-items{border-right:1px solid #f1f1f1}#order-items .h3{font-size:1rem}@media (max-width:991px){#order-items .h3._desktop-title{display:none}}#order-items hr{border-top-color:#232323}#order-items table{width:100%}#order-items table tr{height:1.875rem}#order-items table tr td:last-child{text-align:right}#order-items table tr td{padding:.5rem;font-size:.875rem}#order-items table tr.total-value{background-color:#f1f1f1}#order-items table tr.taxes td{text-align:left}#order-items table tr.taxes td .value{padding-top:0}#order-items .order-line{margin-top:1rem}#order-items .image img{width:100%;border:1px solid gray-lighter;margin-bottom:1rem}#order-items .details{margin-bottom:1rem}#order-items .details .customizations{margin-top:.625rem}#order-items .qty{margin-bottom:1rem}#order-confirmation #registration-form{width:50%;margin:0 auto 1rem}@media (max-width:991px){.done{margin-right:.625rem;padding:0}body#checkout section.checkout-step .address-item{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1}body#checkout section.checkout-step .delivery-option-2{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.delivery-option{display:-webkit-box;display:-ms-flexbox;display:flex;margin:auto}.delivery-option .custom-radio{-webkit-box-flex:0;-ms-flex:0 0 auto;flex:0 0 auto}.condition-label label[for="conditions_to_approve[terms-and-conditions]"]{text-align:left}#order-confirmation #registration-form{width:100%}}@media (max-width:767px){body#checkout section.checkout-step.-reachable.-complete h1 .step-edit{float:none;margin-top:.25rem;margin-left:1.25rem}body#checkout #header .header-nav{max-height:none;padding:0}body#checkout section.checkout-step .content{padding:.9375rem}body#checkout .form-group{margin-bottom:.5rem}#order-items{border-right:0;margin-bottom:2.5rem}#order-items .card-title{border-bottom:1px solid #f1f1f1;margin-bottom:1rem;padding-bottom:1rem}#order-items hr{border-top-color:#f1f1f1}.bold{font-weight:700}#order-details{padding-left:.9375rem}#order-details .card-title{border-bottom:1px solid #f1f1f1;margin-bottom:1rem;padding-bottom:1rem}}@media (max-width:575px){body#checkout section.checkout-step .content{padding:.9375rem 0}#payment-confirmation button{font-size:.875rem}#payment-confirmation button.btn{white-space:normal}}.js-payment-binary,.js-payment-binary .accept-cgv{display:none}.js-payment-binary.disabled{opacity:.6;cursor:not-allowed}.js-payment-binary.disabled:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;pointer-events:none}.js-payment-binary.disabled .accept-cgv{display:block}.table-labeled td,.table-labeled th{vertical-align:middle}.table-labeled .label{font-weight:400;border-radius:3px;font-size:inherit;padding:.25rem .375rem;margin:.125rem;color:#fff;white-space:nowrap}.page-order .table{margin-bottom:0}.page-order table td,.page-order table th{padding:.5rem}.page-order table thead th{text-align:center}#authentication .tooltip.tooltip-bottom{padding:0;margin:0}#authentication .custom-checkbox{display:-webkit-box;display:-ms-flexbox;display:flex}#authentication .custom-checkbox span{-webkit-box-flex:0;-ms-flex:0 0 0.9375rem;flex:0 0 0.9375rem}#authentication .custom-checkbox label{padding-left:.625rem}#authentication .radio-inline,#identity .radio-inline{padding:0}#authentication .radio-inline .custom-radio,#identity .radio-inline .custom-radio{margin-right:0}.page-customer-account #content{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2);background:#fff;padding:1rem;font-size:.875rem;color:#7a7a7a}.page-customer-account #content .order-actions a{padding:0 .125rem}.page-customer-account #content .forgot-password{text-align:center;font-size:.875rem;margin-top:1rem;padding-bottom:.9375rem}.page-customer-account #content .no-account{text-align:center;font-size:1rem}.page-authentication #content{padding:1rem;max-width:640px;margin:0 auto}.page-addresses .address,.page-authentication #content{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2);background:#fff}.page-addresses .address{margin-bottom:1.875rem;font-size:.875rem;color:#232323}.page-addresses .address .address-body{padding:1rem}.page-addresses .address .address-body h4{font-size:1rem;font-weight:700}.page-addresses .address .address-body address{min-height:9rem}.page-addresses .address .address-footer{border-top:1px solid #7a7a7a;padding:.5rem 1rem}.page-addresses .address .address-footer a{color:#7a7a7a;margin-right:.5rem}.page-addresses .address .address-footer a:hover{color:#232323}.page-addresses .address .address-footer a i{font-size:1rem}.page-addresses .address .address-footer a span{font-size:.9375rem;vertical-align:middle}.page-addresses .addresses-footer{margin:0 .9375rem}.page-addresses .addresses-footer a,.page-addresses .addresses-footer a:hover{color:#232323}.page-addresses .addresses-footer a i{font-size:1rem}.page-addresses .addresses-footer a span{font-size:1rem;vertical-align:middle;margin-top:.625rem}.page-order-detail{font-size:.875rem;color:#7a7a7a}.page-order-detail .box{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2);background:#fff;padding:1rem;margin-bottom:1rem}.page-order-detail h3{font-size:1rem;font-weight:700;text-transform:uppercase;color:#232323;margin-bottom:1rem}.page-order-detail #order-infos ul{margin:0}.page-order-detail #order-history .history-lines .history-line{padding:.5rem 0;border-bottom:1px solid #f6f6f6}.page-order-detail #order-history .history-lines .history-line:last-child{border-bottom:0}.page-order-detail #order-history .history-lines .history-line .label{display:inline-block;margin:.25rem 0;padding:.25rem .375rem;color:#fff;border-radius:3px}.page-order-detail .addresses{margin:0 -.9375rem}.page-order-detail .addresses h4{font-size:1rem;font-weight:700}.page-order-detail #order-products.return{margin-bottom:1rem}.page-order-detail #order-products.return th.head-checkbox{width:30px}.page-order-detail #order-products.return td{padding:1.375rem .75rem}.page-order-detail #order-products.return td.qty{min-width:125px}.page-order-detail #order-products.return td.qty .current{width:30%;float:left;text-align:right;padding-right:.5rem}.page-order-detail #order-products.return td.qty .select{width:70%;float:left;margin:-.625rem 0;padding-left:.25rem}.page-order-detail #order-products.return td.qty .select select{text-align:center}.page-order-detail .order-items{padding:0!important}.page-order-detail .order-items .order-item{padding:1rem 1rem 0;border-bottom:1px solid #f6f6f6}.page-order-detail .order-items .order-item .checkbox{width:30px;float:left;padding:0 .9375rem}.page-order-detail .order-items .order-item .content{width:calc(100% - 30px);float:left;padding:0 .9375rem}.page-order-detail .order-items .order-item .desc{margin-bottom:1rem}.page-order-detail .order-items .order-item .desc .name{font-weight:700}.page-order-detail .order-items .order-item .qty{margin-bottom:1rem}.page-order-detail .order-items .order-item .qty .q,.page-order-detail .order-items .order-item .qty .s{margin-bottom:.25rem}.page-order-detail .messages .message{margin-top:.5rem;border-bottom:1px solid #f6f6f6}.page-order-detail .messages .message:last-child{border-bottom:0}.page-order-detail .messages .message>div{margin-bottom:.5rem}.page-order-detail .customization{margin-top:.75rem}#order-return-infos .thead-default th{color:#232323}#order-return-infos .customization{margin-top:.75rem}.page-my-account #content .links{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}.page-my-account #content .links a{text-align:center;display:inline-block;font-size:1rem;font-weight:700;text-transform:uppercase;color:#7a7a7a;padding:0 .9375rem;margin-bottom:1.875rem}.page-my-account #content .links a span.link-item{display:block;height:100%;box-shadow:2px 2px 8px 0 rgba(0,0,0,.2);background:#fff;padding:1rem}.page-my-account #content .links a i{display:block;font-size:2.6rem;width:100%;color:#232323;padding-bottom:3.4rem}.page-my-account #content .links a:hover{color:#232323}.page-my-account #content .links a:hover i{color:#2fb5d2}#history .orders{margin:0 -1rem}#history .orders .order{padding:.75rem 1rem;border-bottom:1px solid #f6f6f6}#history .orders .order a h3{color:#7a7a7a}#history .orders .order .label{display:inline-block;margin:.25rem 0;padding:.25rem .375rem;color:#fff;border-radius:3px}#history .orders .order:last-child{border-bottom:0}.page-footer .account-link{margin-right:1rem}.page-footer .account-link i{font-size:1rem}.page-footer .account-link span{font-size:.875rem;vertical-align:middle}.login-form{margin-top:15px}.forgotten-password{padding:4px}.forgotten-password .form-fields .center-email-fields{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}@media (max-width:767px){.forgotten-password .form-fields .center-email-fields{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.forgotten-password .form-fields .center-email-fields button{margin:10px;width:calc(100% - 20px)}}.forgotten-password .form-fields .center-email-fields button{height:38px}.forgotten-password .form-fields .email{padding-left:0;padding-right:0;width:430px}@media (max-width:767px){.forgotten-password .form-fields .email{padding-left:10px;padding-right:10px;width:100%}}.forgotten-password .form-fields .email input{height:38px}.forgotten-password .form-fields label.required{width:130px}.send-renew-password-link{padding-left:10px;padding-right:10px}.renew-password{margin-left:10px}.renew-password .email{padding-bottom:30px}.renew-password [type=submit]{margin-left:50px}.carousel{box-shadow:1px 1px 7px 0 rgba(0,0,0,.15);margin-bottom:1.5rem}.carousel .direction{z-index:auto}.carousel .carousel-inner{height:340px}.carousel .carousel-item{height:100%}.carousel .carousel-item img{width:100%;max-width:100%;height:auto}.carousel .carousel-item .caption{position:absolute;bottom:28px;left:90px;color:#fff;max-width:340px}.carousel .carousel-item .caption .caption-description p{color:#fff}.carousel .carousel-item figure{margin:0}.carousel .carousel-control{opacity:1}.carousel .carousel-control .icon-next:before,.carousel .carousel-control .icon-prev:before{content:""}.carousel .carousel-control .icon-next i,.carousel .carousel-control .icon-prev i{font-size:3.125rem;color:#fff}.carousel .carousel-control .icon-next:hover i,.carousel .carousel-control .icon-prev:hover i{color:#2fb5d2}.carousel .carousel-control .icon-prev{left:1rem}.carousel .carousel-control .icon-next{right:2rem}.carousel .carousel-control.left,.carousel .carousel-control.right{background:none}@media (max-width:1199px){.carousel .carousel-inner{height:auto}}@media (max-width:991px){.carousel .carousel-item .caption{bottom:calc(50% - 2rem);left:10%}.carousel .carousel-item .caption .display-1{font-size:2rem}.carousel .carousel-item .caption-description{display:none}}@media (max-width:767px){.carousel .carousel-item .caption{bottom:calc(50% - 1.5rem)}.carousel .carousel-item .caption .display-1{font-size:1.5rem}.carousel .carousel-control .icon-next i,.carousel .carousel-control .icon-prev i{font-size:2rem}}#products .products,.featured-products .products,.product-accessories .products,.product-miniature .products{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}#products .product-thumbnail,.featured-products .product-thumbnail,.product-accessories .product-thumbnail,.product-miniature .product-thumbnail{display:block}#products .product-title a,.featured-products .product-title a,.product-accessories .product-title a,.product-miniature .product-title a{color:#7a7a7a;font-size:.875rem;text-decoration:none;text-align:center;font-weight:400}#products .thumbnail-container,.featured-products .thumbnail-container,.product-accessories .thumbnail-container,.product-miniature .thumbnail-container{position:relative;margin-bottom:1.563rem;height:318px;width:250px;background:#fff;box-shadow:2px 2px 8px 0 rgba(0,0,0,.2)}#products .thumbnail-container:focus .highlighted-informations,#products .thumbnail-container:hover .highlighted-informations,.featured-products .thumbnail-container:focus .highlighted-informations,.featured-products .thumbnail-container:hover .highlighted-informations,.product-accessories .thumbnail-container:focus .highlighted-informations,.product-accessories .thumbnail-container:hover .highlighted-informations,.product-miniature .thumbnail-container:focus .highlighted-informations,.product-miniature .thumbnail-container:hover .highlighted-informations{bottom:5.5rem}#products .thumbnail-container:focus .highlighted-informations:after,#products .thumbnail-container:hover .highlighted-informations:after,.featured-products .thumbnail-container:focus .highlighted-informations:after,.featured-products .thumbnail-container:hover .highlighted-informations:after,.product-accessories .thumbnail-container:focus .highlighted-informations:after,.product-accessories .thumbnail-container:hover .highlighted-informations:after,.product-miniature .thumbnail-container:focus .highlighted-informations:after,.product-miniature .thumbnail-container:hover .highlighted-informations:after{opacity:1}#products .thumbnail-container:focus .highlighted-informations.no-variants,#products .thumbnail-container:hover .highlighted-informations.no-variants,.featured-products .thumbnail-container:focus .highlighted-informations.no-variants,.featured-products .thumbnail-container:hover .highlighted-informations.no-variants,.product-accessories .thumbnail-container:focus .highlighted-informations.no-variants,.product-accessories .thumbnail-container:hover .highlighted-informations.no-variants,.product-miniature .thumbnail-container:focus .highlighted-informations.no-variants,.product-miniature .thumbnail-container:hover .highlighted-informations.no-variants{bottom:4.2rem}#products .thumbnail-container:focus .product-description:after,#products .thumbnail-container:hover .product-description:after,.featured-products .thumbnail-container:focus .product-description:after,.featured-products .thumbnail-container:hover .product-description:after,.product-accessories .thumbnail-container:focus .product-description:after,.product-accessories .thumbnail-container:hover .product-description:after,.product-miniature .thumbnail-container:focus .product-description:after,.product-miniature .thumbnail-container:hover .product-description:after{content:"";border-top:1px solid #7a7a7a;position:absolute;width:80%;top:0;left:10%;opacity:.25}#products .thumbnail-container .product-thumbnail,.featured-products .thumbnail-container .product-thumbnail,.product-accessories .thumbnail-container .product-thumbnail,.product-miniature .thumbnail-container .product-thumbnail{position:relative;height:calc(100% - 70px)}#products .thumbnail-container .product-thumbnail img,.featured-products .thumbnail-container .product-thumbnail img,.product-accessories .thumbnail-container .product-thumbnail img,.product-miniature .thumbnail-container .product-thumbnail img{max-width:100%;position:absolute;top:0;bottom:0;left:0;right:0;margin:auto}#products .products-section-title,.featured-products .products-section-title,.product-accessories .products-section-title,.product-miniature .products-section-title{text-align:center;margin-bottom:1.5rem}#products .product-title,.featured-products .product-title,.product-accessories .product-title,.product-miniature .product-title{text-align:center;text-transform:capitalize;margin-top:.7rem}#products .product-price-and-shipping,.featured-products .product-price-and-shipping,.product-accessories .product-price-and-shipping,.product-miniature .product-price-and-shipping{color:#232323;font-weight:700;text-align:center}#products .product-price-and-shipping .discount-product,.featured-products .product-price-and-shipping .discount-product,.product-accessories .product-price-and-shipping .discount-product,.product-miniature .product-price-and-shipping .discount-product{display:none}#products .variant-links,.featured-products .variant-links,.product-accessories .variant-links,.product-miniature .variant-links{position:relative;text-align:center;width:100%;top:-.25em;padding-top:.1875rem;min-height:2.5rem;background:#fff}#products .highlighted-informations,.featured-products .highlighted-informations,.product-accessories .highlighted-informations,.product-miniature .highlighted-informations{position:absolute;bottom:1.25rem;padding-top:.625rem;z-index:2;background:#fff;text-align:center;width:250px;height:3.125rem;box-shadow:0 -5px 10px -5px rgba(0,0,0,.2);transition:bottom .3s}#products .highlighted-informations .quick-view,.featured-products .highlighted-informations .quick-view,.product-accessories .highlighted-informations .quick-view,.product-miniature .highlighted-informations .quick-view{color:#7a7a7a;font-size:1rem}#products .highlighted-informations .quick-view:hover,.featured-products .highlighted-informations .quick-view:hover,.product-accessories .highlighted-informations .quick-view:hover,.product-miniature .highlighted-informations .quick-view:hover{color:#2fb5d2}#products .product-description,.featured-products .product-description,.product-accessories .product-description,.product-miniature .product-description{position:absolute;z-index:3;background:#fff;width:250px;bottom:0;height:70px}#products .product-miniature,.featured-products .product-miniature,.product-accessories .product-miniature,.product-miniature .product-miniature{margin:0 .8125rem}#products .product-miniature .product-flags li.product-flag,.featured-products .product-miniature .product-flags li.product-flag,.product-accessories .product-miniature .product-flags li.product-flag,.product-miniature .product-miniature .product-flags li.product-flag{min-width:3.125rem;min-height:1.875rem;font-weight:600}#products .product-miniature .product-flags li.product-flag.online-only,.featured-products .product-miniature .product-flags li.product-flag.online-only,.product-accessories .product-miniature .product-flags li.product-flag.online-only,.product-miniature .product-miniature .product-flags li.product-flag.online-only{top:13.1rem}#products .comments_note,.featured-products .comments_note,.product-accessories .comments_note,.product-miniature .comments_note{text-align:center;color:#7a7a7a}#products .regular-price,.featured-products .regular-price,.product-accessories .regular-price,.product-miniature .regular-price{color:#7a7a7a;text-decoration:line-through;font-size:.875rem}#products .count,.featured-products .count,.product-accessories .count,.product-miniature .count{color:#7a7a7a;font-weight:700;position:relative;bottom:.5rem}#products .all-product-link,.featured-products .all-product-link,.product-accessories .all-product-link,.product-miniature .all-product-link{clear:both;color:#7a7a7a;font-weight:700;margin-top:1.5rem;margin-bottom:1.5rem}@media (max-width:767px){#products .thumbnail-container,.featured-products .thumbnail-container,.product-accessories .thumbnail-container{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2)}#products .thumbnail-container .product-description,.featured-products .thumbnail-container .product-description,.product-accessories .thumbnail-container .product-description{box-shadow:0 -5px 10px -5px rgba(0,0,0,.2)}}#custom-text{background:#fff;border-radius:2px;margin-bottom:1.5rem;padding:3.125rem;text-align:center}#custom-text h2{text-transform:uppercase;color:#232323;font-size:1.563rem;font-weight:700}#custom-text p{color:#232323;font-weight:400;font-size:1.1em}#custom-text p .dark{color:#7a7a7a;font-weight:400}.page-content.page-cms{background:#fff;padding:1.25rem;text-align:justify}.page-content.page-cms .cms-box img{max-width:100%}@media (max-width:991px){#block-cmsinfo{padding:1.25rem 1.875rem}}#products{color:#7a7a7a}#products .products-select{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:baseline;-ms-flex-align:baseline;align-items:baseline;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}#products .up{margin-bottom:1rem}#products .up .btn-secondary,#products .up .btn-tertiary{color:#7a7a7a;text-transform:inherit}#products .up .btn-secondary .material-icons,#products .up .btn-tertiary .material-icons{margin-right:0}.block-category{min-height:13.75rem;margin-bottom:1.563rem}.block-category .block-category-inner{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.block-category .block-category-inner #category-description p,.block-category .block-category-inner #category-description strong{font-weight:400;color:#7a7a7a}.block-category .block-category-inner #category-description p{color:#232323;margin-bottom:0;word-break:break-word}.block-category .block-category-inner #category-description p:first-child{margin-bottom:1.25rem}.block-category .block-category-inner .category-cover img{width:141px;height:180px}.products-selection .sort-by-row{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.products-selection .sort-by{white-space:normal;word-break:break-word;margin-right:-.9375rem;margin-left:.9375rem;text-align:right}.products-selection .total-products,.products-selection h1{padding-top:.625rem}.products-sort-order{color:#7a7a7a}.products-sort-order .select-title{display:inline-block;width:100%;color:#232323;background:#fff;padding:.625rem;cursor:pointer;border:1px solid rgba(0,0,0,.25);box-shadow:2px 2px 4px 0 rgba(0,0,0,.2)}.products-sort-order .select-list{display:block;color:#232323;padding:.625rem 1.25rem}.products-sort-order .select-list:hover{background:#2fb5d2;color:#fff;text-decoration:none}.products-sort-order .dropdown-menu{left:auto;width:16.88rem;background:#f6f6f6;border:none;border-radius:0;box-shadow:2px 2px 4px 0 rgba(0,0,0,.1);margin:0}.facet-dropdown{color:#7a7a7a;padding-left:0;padding-right:0;background:#f1f1f1;border:3px solid transparent;box-sizing:border-box;box-shadow:1px 1px 1px 1px #f1f1f1}.facet-dropdown.open{border:0}.facet-dropdown.open>.select-title{border:3px solid #2fb5d2;background:#f6f6f6}.facet-dropdown .select-title{display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;margin-left:0;width:100%;color:#232323;background:#f1f1f1;padding:.625rem .625rem .625rem 1.25rem;cursor:pointer}.facet-dropdown .select-title>i{margin-left:auto}.facet-dropdown .select-list{display:block;color:#232323;background:#f6f6f6;padding:.625rem 1.25rem}.facet-dropdown .select-list:hover{background:#2fb5d2;color:#fff;text-decoration:none}.facet-dropdown .dropdown-menu{padding:0;margin-top:3px;left:auto;width:100%;background:#f6f6f6;border:none;box-shadow:1px 1px 1px 1px #f1f1f1}#search_filters,#search_filters_brands,#search_filters_suppliers{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2);margin-bottom:1.563rem;background:#fff;padding:1.563rem 1.25rem}#search_filters .facet,#search_filters_brands .facet,#search_filters_suppliers .facet{padding-top:.625rem}#search_filters .facet .collapse,#search_filters_brands .facet .collapse,#search_filters_suppliers .facet .collapse{display:block}#search_filters .facet .facet-title,#search_filters_brands .facet .facet-title,#search_filters_suppliers .facet .facet-title{color:#7a7a7a}#search_filters .facet .facet-label,#search_filters_brands .facet .facet-label,#search_filters_suppliers .facet .facet-label{margin-bottom:0}#search_filters .facet .facet-label a,#search_filters_brands .facet .facet-label a,#search_filters_suppliers .facet .facet-label a{margin-top:.4375rem;color:#232323;display:inline-block;font-size:.9375rem}#search_filters_brands .facet,#search_filters_suppliers .facet{padding-top:0}#search_filters_brands .facet .facet-label,#search_filters_suppliers .facet .facet-label{margin-bottom:.3125rem}.pagination{width:100%}.pagination>div:first-child{line-height:2.5rem}.pagination .page-list{background:#fff;padding:.375rem;margin-bottom:0;box-shadow:2px 2px 4px 0 rgba(0,0,0,.2)}.pagination .page-list li{display:inline}.pagination a{color:#000;font-weight:600}.pagination a:not(.previous):not(.next){letter-spacing:.125rem}.pagination .previous{float:left}.pagination .next{float:right}.pagination .disabled{color:#7a7a7a}.pagination .current a{color:#2fb5d2;text-decoration:none;font-size:1.25rem}.active_filters{background:#dededd;padding:.625rem 1.875rem 0;margin-bottom:1.25rem}.active_filters .active-filter-title{display:inline;margin-right:.625rem;font-weight:600}.active_filters ul{display:inline}.active_filters .filter-block{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2);color:#232323;margin-right:.625rem;margin-bottom:.625rem;background:#fff;padding:.625rem;display:inline-block;font-size:.8125rem}.active_filters .filter-block .close{color:#232323;font-size:.9375rem;opacity:1;margin-top:.1875rem;margin-left:.3125rem}.block-categories{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2);background:#fff;padding:1.563rem 1.25rem;margin-bottom:1.563rem}.block-categories .category-sub-menu{margin-top:.625rem}.block-categories .category-sub-menu .category-sub-link{font-size:.875rem}.block-categories .category-sub-menu li{position:relative}.block-categories .category-sub-menu li[data-depth="1"]{margin-bottom:.625rem}.block-categories .category-sub-menu li[data-depth="0"]>a{font-weight:600;border-bottom:1px solid rgba(0,0,0,.25);width:100%;display:inline-block;margin:.3125rem 0 0;padding-bottom:.1875rem}.block-categories .category-sub-menu li:not([data-depth="0"]):not([data-depth="1"]){padding-left:.3125rem}.block-categories .category-sub-menu li:not([data-depth="0"]):not([data-depth="1"]):before{content:"-";margin-right:.3125rem}.block-categories a{color:#232323}.block-categories .collapse-icons{position:absolute;right:0;top:0;padding:0;cursor:pointer}.block-categories .collapse-icons[aria-expanded=true] .add{display:none}.block-categories .collapse-icons[aria-expanded=true] .remove{display:block}.block-categories .collapse-icons .add:hover,.block-categories .collapse-icons .remove:hover{color:#2fb5d2}.block-categories .collapse-icons .remove{display:none}.block-categories .arrows .arrow-down,.block-categories .arrows .arrow-right{font-size:.875rem;cursor:pointer;margin-left:2px}.block-categories .arrows .arrow-down:hover,.block-categories .arrows .arrow-right:hover{color:#2fb5d2}.block-categories .arrows .arrow-down,.block-categories .arrows[aria-expanded=true] .arrow-right{display:none}.block-categories .arrows[aria-expanded=true] .arrow-down{display:inline-block}.facets-title{color:#232323}.products-selection .filter-button .btn-secondary,.products-selection .filter-button .btn-tertiary{padding:.75rem .5rem .6875rem}.advertising-block{margin-bottom:1.563rem}.advertising-block img{width:100%}@media (max-width:767px){#category #left-column{width:100%}#category #left-column #search_filters_wrapper{margin-left:-30px;margin-right:-30px}#category #left-column #search_filter_controls{text-align:center;margin-bottom:1rem}#category #left-column #search_filter_controls button{margin:0 .5rem}#category #left-column #search_filters{margin-bottom:0;box-shadow:none;padding:0;border-top:1px solid #f6f6f6}#category #left-column #search_filters .facet{padding-top:0;border-bottom:1px solid #f6f6f6}#category #left-column #search_filters .facet .title{cursor:pointer}#category #left-column #search_filters .facet .title .collapse-icons .remove,#category #left-column #search_filters .facet .title[aria-expanded=true] .collapse-icons .add{display:none}#category #left-column #search_filters .facet .title[aria-expanded=true] .collapse-icons .remove{display:block}#category #left-column #search_filters .facet .facet-title{color:#232323;text-transform:uppercase}#category #left-column #search_filters .facet .h6{margin-bottom:0;padding:.625rem;display:inline-block}#category #left-column #search_filters .facet .navbar-toggler{display:inline-block;padding:.625rem .625rem 0 0}#category #left-column #search_filters .facet .collapse{display:none}#category #left-column #search_filters .facet .collapse.in{display:block}#category #left-column #search_filters .facet .facet-label a{margin-top:0}#category #left-column #search_filters .facet ul{margin-bottom:0}#category #left-column #search_filters .facet ul li{border-top:1px solid #f6f6f6;padding:.625rem}#category #content-wrapper,#category #search_filter_toggler{width:100%}.products-sort-order .select-title{margin-left:0}.products-selection h1{padding-top:0;text-align:center;margin-bottom:1rem}.products-selection .showing{padding-top:1rem}#best-sales #content-wrapper,#new-products #content-wrapper,#prices-drop #content-wrapper{width:100%}}@media (max-width:575px){.products-selection .filter-button{padding-left:0}#category #left-column #search_filters_wrapper{margin-left:-15px;margin-right:-15px}}@media screen and (max-width:767px){.category-cover{display:none}.block-category{min-height:0;margin-bottom:0}.card-block{padding:0}.card{box-shadow:none;background-color:inherit;border:none}}#product #content{position:relative;max-width:452px;margin:0 auto}.product-price{color:#2fb5d2;display:inline-block}#product-description-short{color:#232323}.product-information{font-size:.9375rem;color:#232323}.product-information .manufacturer-logo{height:35px}.product-information .product-description img{max-width:100%;height:auto}.input-color{position:absolute;opacity:0;cursor:pointer;height:1.25rem;width:1.25rem}.input-container{position:relative}.input-radio{position:absolute;top:0;cursor:pointer;opacity:0;width:100%;height:100%}.input-color:checked+span,.input-color:hover+span,.input-radio:checked+span,.input-radio:hover+span{border:2px solid #232323}.radio-label{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2);background:#fff;display:inline-block;padding:.125rem .625rem;font-weight:600;border:2px solid #fff}.product-actions .control-label{margin-bottom:.375rem;display:block;width:100%}.product-actions .add-to-cart{height:2.75rem;line-height:inherit;padding-top:.625rem}.product-actions .add-to-cart .material-icons{line-height:inherit}.product-quantity{display:-webkit-box;display:-ms-flexbox;display:flex}.product-quantity .add,.product-quantity .qty{float:left;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;margin-bottom:.5rem}.product-quantity .qty{margin-right:.4rem}.product-quantity #quantity_wanted{color:#232323;background-color:#fff;height:2.75rem;padding:.175rem .5rem;width:3rem}.product-quantity .input-group-btn-vertical{width:auto}.product-quantity .input-group-btn-vertical .btn{padding:.5rem .6875rem}.product-quantity .input-group-btn-vertical .btn i{font-size:1rem;top:.125rem;left:.1875rem}.product-quantity .btn-touchspin{height:1.438rem}.product-discounts{margin-bottom:1.5rem}.product-discounts>.product-discounts-title{font-weight:400;font-size:.875rem}.product-discounts>.table-product-discounts thead tr th{width:33%;padding:.625rem 1.25rem;background:#fff;border:.3125rem solid #f1f1f1;text-align:center}.product-discounts>.table-product-discounts tbody tr{background:#f6f6f6}.product-discounts>.table-product-discounts tbody tr:nth-of-type(2n){background:#fff}.product-discounts>.table-product-discounts tbody tr td{padding:.625rem 1.25rem;text-align:center;border:.3125rem solid #f1f1f1}.product-prices{margin-top:1.25rem}.product-prices div{margin-bottom:.625rem}.product-prices .tax-shipping-delivery-label{font-size:.8125rem;color:#7a7a7a}.product-prices .tax-shipping-delivery-label .delivery-information{padding:0 0 0 2px}.product-prices .tax-shipping-delivery-label .delivery-information:before{content:"-";padding:0 2px 0 0}.product-discount{color:#7a7a7a}.product-discount .regular-price{text-decoration:line-through;font-weight:400;margin-right:.625rem}.has-discount.product-price,.has-discount p{color:#f39d72}.has-discount .discount{background:#f39d72;color:#fff;font-weight:600;padding:.3125rem .625rem;font-size:1rem;margin-left:.625rem;text-transform:uppercase;display:inline-block}.product-unit-price{font-size:.8125rem;margin-bottom:0}.tabs{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2);margin-top:2rem;background:#fff;padding:1.25rem 1.875rem}.tabs .tab-pane{padding-top:1.25rem}.tabs .nav-tabs{border:none;border-bottom:2px solid #f1f1f1}.tabs .nav-tabs .nav-link{color:#7a7a7a;border:0 solid transparent}.tabs .nav-tabs .nav-link.active{color:#2fb5d2}.tabs .nav-tabs .nav-link.active,.tabs .nav-tabs .nav-link:hover{border:none;border-bottom:3px solid #2fb5d2}.tabs .nav-tabs .nav-item{float:left;margin-bottom:-.125rem}.product-cover{margin-bottom:1.25rem;position:relative}.product-cover img{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2);background:#fff}.product-cover .layer{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;width:100%;height:100%;background:#fff;position:absolute;left:0;top:0;opacity:0;background:hsla(0,0%,100%,.7);text-align:center;cursor:pointer}.product-cover .layer:hover{opacity:1}.product-cover .layer .zoom-in{font-size:6.25rem;color:#7a7a7a}#product-modal .modal-content{background:transparent;border:none;padding:0}#product-modal .modal-content .modal-body{display:-webkit-box;display:-ms-flexbox;display:flex;margin-left:-30%}#product-modal .modal-content .modal-body .product-cover-modal{background:#fff}#product-modal .modal-content .modal-body .image-caption{background:#fff;width:800px;padding:.625rem 1.25rem;border-top:1px solid #f1f1f1}#product-modal .modal-content .modal-body .image-caption p{margin-bottom:0}#product-modal .modal-content .modal-body .thumbnails{position:relative}#product-modal .modal-content .modal-body .mask{position:relative;overflow:hidden;max-height:49.38rem;margin-top:2.188rem;z-index:1}#product-modal .modal-content .modal-body .mask.nomargin{margin-top:0}#product-modal .modal-content .modal-body .product-images{margin-left:2.5rem}#product-modal .modal-content .modal-body .product-images img{width:9.25rem;cursor:pointer;background:#fff}#product-modal .modal-content .modal-body .product-images img:hover{border:3px solid #2fb5d2}#product-modal .modal-content .modal-body .arrows{height:100%;width:100%;text-align:center;position:absolute;top:0;color:#fff;right:1.875rem;z-index:0;cursor:pointer}#product-modal .modal-content .modal-body .arrows .arrow-up{position:absolute;top:-2rem;opacity:.2}#product-modal .modal-content .modal-body .arrows .arrow-down{position:absolute;bottom:-2rem}#product-modal .modal-content .modal-body .arrows i{font-size:6.25rem;display:inline}#blockcart-modal{color:#232323}#blockcart-modal .modal-header{background:#fff}#blockcart-modal .modal-header .close{opacity:1}#blockcart-modal .modal-header .close .material-icons{color:#363a42}#blockcart-modal .modal-body{background:#fff;padding:3.125rem 1.875rem}#blockcart-modal .modal-body .divide-right span{display:inline-block;margin-bottom:.3125rem}@media (max-width:767px){#blockcart-modal .modal-body .divide-right span{display:block;padding:0 .5rem}}#blockcart-modal .modal-dialog{max-width:1140px;width:100%}#blockcart-modal .product-image{width:100%;max-width:9.375rem;display:block;margin:0 0 0 auto}#blockcart-modal .modal-title{color:#353943;font-size:1rem;font-weight:400}#blockcart-modal .modal-title i.material-icons{margin-right:1.875rem;color:#4cbb6c}#blockcart-modal .product-name{color:#2fb5d2;font-size:1.125rem}@media (max-width:767px){#blockcart-modal .product-name{padding:0 .5rem}}#blockcart-modal .product-price{color:#363a42;display:block}@media (max-width:767px){#blockcart-modal .product-price{padding:0 .5rem}}#blockcart-modal .cart-content{padding-left:2.5rem}#blockcart-modal .cart-content p{color:#363a42;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;padding:0 .5rem}#blockcart-modal .cart-content p.product-total{background-color:#f1f1f1;padding:.5rem}#blockcart-modal .cart-content p.cart-products-count{font-size:1rem;color:#6c868e;font-weight:600}#blockcart-modal .cart-content p.product-tax{display:inherit;font-size:.875rem}#blockcart-modal .cart-content p .label,#blockcart-modal .cart-content p .value{font-weight:600}#blockcart-modal .cart-content .cart-content-btn{display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex}#blockcart-modal .cart-content .cart-content-btn button{margin-right:.9rem}#blockcart-modal .cart-content .cart-content-btn .btn{white-space:inherit}#blockcart-modal .divide-right{border-right:1px solid #dbdbdb}.product-images>li.thumb-container{display:inline}.product-images>li.thumb-container>.thumb{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2);cursor:pointer;margin-bottom:.625rem}.images-container .product-images>li.thumb-container>.thumb{margin-right:.8125rem}.product-images>li.thumb-container>.thumb.selected,.product-images>li.thumb-container>.thumb:hover{border:3px solid #2fb5d2}#main .images-container .js-qv-mask{white-space:nowrap;overflow:hidden}#main .images-container .js-qv-mask.scroll{width:calc(100% - 60px);margin:0 auto}.scroll-box-arrows{display:none}.scroll-box-arrows.scroll{display:block}.scroll-box-arrows i{position:absolute;bottom:1.625rem;height:100px;line-height:100px;cursor:pointer}.scroll-box-arrows .left{left:0}.scroll-box-arrows .right{right:0}#product-availability{margin-top:.625rem;display:inline-block;font-weight:700}#product-availability .material-icons{line-height:inherit}#product-availability .product-available{color:#4cbb6c}#product-availability .product-last-items,#product-availability .product-unavailable{color:#ff9a52}#product-details .label{font-size:1rem;color:#232323;font-weight:700}.product-features{margin-top:1.25rem;margin-left:.3125rem}.product-features>dl.data-sheet{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch}.product-features>dl.data-sheet dd.value,.product-features>dl.data-sheet dt.name{-webkit-box-flex:1;-ms-flex:1 0 40%;flex:1 0 40%;font-weight:400;background:#f1f1f1;padding:.625rem;margin-right:.625rem;min-height:2.5rem;word-break:normal;text-transform:capitalize;margin-bottom:.5rem}.product-features>dl.data-sheet dd.value:nth-of-type(2n),.product-features>dl.data-sheet dt.name:nth-of-type(2n){background:#f6f6f6}.product-variants>.product-variants-item{margin:1.25rem 0}.product-variants>.product-variants-item select{background-color:#fff;width:auto;padding-right:1.875rem;box-shadow:2px 2px 4px 0 rgba(0,0,0,.2)}.product-variants>.product-variants-item ul li{margin-right:.625rem}.product-variants>.product-variants-item .color{margin-left:0;margin-top:0}.product-flags{pointer-events:none;position:absolute;width:100%;top:0;left:0;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;z-index:2}.product-flags li.product-flag{pointer-events:auto;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;background:#2fb5d2;font-weight:700;padding:.3125rem .4375rem;text-transform:uppercase;color:#fff;margin-top:.625rem;font-size:1rem;box-shadow:2px 2px 4px 0 rgba(0,0,0,.2)}.product-flags li.product-flag.online-only{position:absolute;top:25rem;right:0;z-index:1;font-size:.8125rem;margin-top:0}.product-flags li.product-flag.online-only:before{content:"\E30A";font-family:Material Icons;vertical-align:middle;margin:.3125rem}.product-flags li.product-flag.discount,.product-flags li.product-flag.discount-amount,.product-flags li.product-flag.discount-percentage{background-color:#f39d72}.product-flags li.product-flag.on-sale{-webkit-box-ordinal-group:0;-ms-flex-order:-1;order:-1;background:#f39d72;width:100%;text-align:center;margin-top:0!important}.product-customization{margin:2.5rem 0}.product-customization .product-customization-item{margin:1.25rem 0}.product-customization .product-message{background:#f1f1f1;border:none;width:100%;height:3.125rem;resize:none;padding:.625rem}.product-customization .product-message:focus{background-color:#fff;outline:.1875rem solid #2fb5d2}.product-customization .file-input{width:100%;opacity:0;left:0;z-index:1;cursor:pointer;height:2.625rem;overflow:hidden;position:absolute}.product-customization .customization-message{margin-top:20px}.product-customization .custom-file{position:relative;background:#f1f1f1;width:100%;height:2.625rem;line-height:2.625rem;text-indent:.625rem;display:block;color:#7a7a7a;margin-top:1.25rem}.product-customization .custom-file button{z-index:0;position:absolute;right:0;top:0}.product-customization small{color:#7a7a7a}.product-pack{margin-top:2.5rem}.product-pack .pack-product-container{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-pack:distribute;justify-content:space-around}.product-pack .pack-product-container .pack-product-name{-webkit-box-flex:0;-ms-flex:0 0 50%;flex:0 0 50%;font-size:.875rem;color:#7a7a7a}.product-pack .pack-product-container .pack-product-quantity{border-left:2px solid #f1f1f1;padding-left:.625rem}.product-pack .pack-product-container .pack-product-name,.product-pack .pack-product-container .pack-product-price,.product-pack .pack-product-container .pack-product-quantity{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.product-refresh{margin-top:1.25rem}.social-sharing{width:100%;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;margin-top:1.5rem}.social-sharing ul{margin-bottom:0}.social-sharing li{box-shadow:2px 2px 4px 0 rgba(0,0,0,.2);height:2.5rem;width:2.5rem;border-radius:50%;display:inline-block;background-color:#fff;background-repeat:no-repeat;background-size:2rem 2rem;background-position:.25rem .25rem;cursor:pointer;margin-left:.5rem}.social-sharing li a{display:block;width:100%;height:100%;white-space:nowrap;text-indent:100%;overflow:hidden}.social-sharing li a:hover{color:transparent}.products-selection{margin-bottom:1.25rem}.products-selection .title{color:#7a7a7a}#blockcart-modal .cart-content .btn{margin-bottom:.625rem}@media (max-width:991px){.product-cover img{width:100%}#product-modal .modal-content .modal-body{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;margin-left:0}#product-modal .modal-content .modal-body img.product-cover-modal{width:100%}#product-modal .modal-content .modal-body .arrows{display:none}#product-modal .modal-content .modal-body .image-caption{width:100%}#blockcart-modal .modal-dialog{width:calc(100% - 20px)}#blockcart-modal .modal-body{padding:1.875rem}}@media (max-width:767px){#blockcart-modal .divide-right{border-right:none}#blockcart-modal .modal-body{padding:1rem}}.cart-grid{margin-bottom:1rem}.cart-items{margin-bottom:0}.cart-item{padding:1rem 0}.card-block{padding:1.25rem 1.25rem .5rem}.card-block.checkout{padding-bottom:1.75rem;padding-top:0;margin-top:1rem}.card-block.cart-summary-totals{padding:0 1rem 1rem}.card-block.cart-summary-totals .cart-summary-line{padding:.5rem .2rem 0}.card-block.cart-summary-totals .cart-summary-line:last-child{margin-bottom:0}.card-block.cart-summary-totals .cart-summary-line.cart-total{background-color:#f1f1f1;padding:.5rem}.card-block.cart-summary-totals .cart-summary-line.cart-total .label,.card-block.cart-summary-totals .cart-summary-line.cart-total .value{font-weight:700}.card-block.cart-summary-totals .cart-summary-line.cart-total .label{font-size:1rem}.card-block.cart-summary-totals .cart-summary-line.cart-total .value{font-size:1.125rem}.card-block.cart-summary-totals .cart-summary-line span.sub{text-align:left;font-size:.88rem;float:none}.cart-summary-line{clear:both;margin-bottom:.315rem}.cart-summary-line:after{content:"";display:table;clear:both}.cart-summary-line .label{padding-left:0;font-weight:400;white-space:inherit;color:#363a42}.cart-summary-line .value{color:#232323;float:right}.cart-summary-line.cart-summary-subtotals .label,.cart-summary-line.cart-summary-subtotals .value{font-weight:400}.cart-grid-body{margin-bottom:.75rem}.cart-grid-body a.label:hover{color:#2fb5d2}.cart-grid-body .card-block{padding:1rem}.cart-grid-body .card-block h1{margin-bottom:0}.cart-grid-body .cart-overview{padding:1rem}.cart-grid-right .promo-discounts{margin-bottom:0;text-align:center;padding-top:.5rem;padding-bottom:.5rem}.cart-grid-right .promo-discounts .cart-summary-line .label{font-size:1rem;color:#7a7a7a}.cart-grid-right .promo-discounts .cart-summary-line .label .code{color:#f49d6e;cursor:pointer}.cart-grid-right .cart-summary-line.cart-subtotal-products .label,.cart-grid-right .cart-summary-line.cart-subtotal-products .value{font-weight:600}.cart-grid-right .cart-summary-line.cart-subtotal-products .value{font-size:1rem}.block-promo{margin-bottom:1rem}.block-promo .promo-code{padding:1rem}.block-promo .promo-code .alert-danger{position:relative;margin-top:1.25rem;background:#ff4c4c;color:#fff;display:none}.block-promo .promo-code .alert-danger:after{bottom:100%;left:10%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none;border-bottom-color:#ff4c4c;border-width:10px;margin-left:-10px}.block-promo .promo-code form{text-align:center}.block-promo .promo-input{color:#232323;border:1px solid #7a7a7a;height:2.5rem;text-indent:.625rem;width:50%;margin-right:-.24rem}.block-promo .promo-input+button{margin-top:-4px;margin-left:-1px;text-transform:capitalize;border:2px solid #2fb5d2}.block-promo .cart-summary-line .label,.block-promo .promo-name{color:#ff9a52;font-weight:600;margin-bottom:0}.block-promo .cart-summary-line .label a,.block-promo .promo-name a{font-weight:400;color:#232323;display:inline-block}.block-promo .promo-name .cart-summary-line .label{font-weight:400;color:#363a42}.block-promo .promo-name .cart-summary-line span{color:#f49d6e}.block-promo .promo-name .material-icons{font-size:1.2rem;margin-left:.4rem}.block-promo .promo-code-button{display:block;text-align:center;padding:0 0 1rem}.block-promo .promo-code-button.with-discounts{display:none}.block-promo .promo-code-button.cancel-promo{color:#2fb5d2;margin-bottom:0}.block-promo .promo-code-button.cancel-promo[aria-expanded=true]{display:block;padding:0;margin-top:1rem}.block-promo.promo-highlighted{padding:0 1rem;margin-bottom:0;text-align:center}.block-promo p{margin-bottom:0}.product-line-grid-left img{max-width:100%}.product-line-grid-body>.product-line-info>.label{padding:0;line-height:inherit;text-align:left;white-space:inherit}.product-line-grid-body>.product-line-info>.out-of-stock{color:red}.product-line-grid-body>.product-line-info>.available{color:#4cbb6c}.product-line-grid-body>.product-line-info>.unit-price-cart{padding-left:.3125rem;font-size:.875rem;color:#7a7a7a}.product-line-grid-right .cart-line-product-actions,.product-line-grid-right .product-price{color:#232323;line-height:36px}.product-line-grid-right .cart-line-product-actions .remove-from-cart,.product-line-grid-right .product-price .remove-from-cart{color:#232323;display:inline-block;margin-top:.3125rem}@media (max-width:767px){.product-line-grid-body{margin-bottom:1rem}}@media (max-width:575px){.cart-items{padding:1rem 0}.cart-item{border-bottom:1px solid #f1f1f1}.cart-item:last-child{border-bottom:0}.cart-grid-body .cart-overview{padding:0}.cart-grid-body .no-items{padding:1rem;display:inline-block}.product-line-grid-left{padding-right:0!important}}@media (max-width:360px){.product-line-grid-right .price,.product-line-grid-right .qty{width:100%}}#block-reassurance{margin-top:2rem}#block-reassurance img{width:1.563rem;margin-right:.625rem}#block-reassurance li{border-bottom:1px solid rgba(0,0,0,.25)}#block-reassurance li:last-child{border:0}#block-reassurance li .block-reassurance-item{padding:1rem 1.5rem}#product #block-reassurance{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2);background:#fff}#product #block-reassurance span{font-weight:700}.quickview .modal-dialog{width:calc(100% - 30px);max-width:64rem}.quickview .modal-content{background:#f1f1f1;min-height:28.13rem}.quickview .modal-header{border:none;padding:.625rem}.quickview .modal-body{min-height:23.75rem}.quickview .modal-footer{border-top:1px solid hsla(0,0%,48%,.3)}.quickview .layer{display:none}.quickview .product-cover img{width:95%}.quickview .images-container{display:-webkit-box;display:-ms-flexbox;display:flex;z-index:1;min-height:21.88rem}.quickview .images-container .product-images>li.thumb-container>.thumb{width:100%;max-width:4.938rem;margin-bottom:.8125rem;background:#fff}.quickview .mask{width:35%;max-height:22.5rem;overflow:hidden;margin-left:.625rem}.quickview .arrows{position:absolute;top:0;bottom:0;max-height:22.5rem;right:5rem;z-index:0}.quickview .arrows .arrow-up{margin-top:-3.125rem;cursor:pointer;opacity:.2}.quickview .arrows .arrow-down{position:absolute;bottom:-1.875rem;cursor:pointer}.quickview .social-sharing{margin-top:0;margin-left:2.5rem}#stores .page-stores{width:85%;margin:0 auto}#stores .page-stores .store-item{padding-left:.75rem;padding-right:.75rem}#stores .page-stores .store-picture img{max-width:100%}#stores .page-stores .store-item-container{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-pack:distribute;justify-content:space-around;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:1.875rem 0}#stores .page-stores .store-item-container ul{margin-bottom:0;font-size:.9375rem}#stores .page-stores .store-item-container .divide-left{border-left:1px solid #f1f1f1}#stores .page-stores .store-item-container .divide-left tr{height:1.563rem}#stores .page-stores .store-item-container .divide-left td{padding-left:.375rem}#stores .page-stores .store-item-container .divide-left th{text-align:right}#stores .page-stores .store-item-container .store-description{font-size:1rem}#stores .page-stores .store-item-footer{margin-top:.5rem;padding-top:.5rem;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-pack:distribute;justify-content:space-around}#stores .page-stores .store-item-footer.divide-top{border-top:1px solid #f1f1f1}#stores .page-stores .store-item-footer div:first-child{-webkit-box-flex:0;-ms-flex:0 0 65%;flex:0 0 65%}#stores .page-stores .store-item-footer i.material-icons{margin-right:.625rem;color:#7a7a7a;font-size:1rem}#stores .page-stores .store-item-footer li{margin-bottom:.625rem}@media (max-width:767px){#stores .page-stores{width:100%}#stores .page-stores .store-item-container{padding:1rem 0}}@media (max-width:575px){#stores .page-stores .store-item-container{display:block}#stores .page-stores .store-item-container .divide-left{border-left:none}#stores .page-stores .store-item-container .store-description a,#stores .page-stores .store-item-container .store-description address{margin-bottom:.5rem}#stores .page-stores .store-item-footer{display:block}#stores .page-stores .store-item-footer.divide-top{border-top:1px solid #f1f1f1}#stores .page-stores .store-item-footer li{margin-bottom:.625rem}#stores .page-stores .store-item-footer .card-block{padding:.75rem .75rem 0}}.block_newsletter{font-size:.875rem;margin-bottom:.625rem}.block_newsletter form{position:relative}.block_newsletter form input[type=text]{border:none;padding:10px;min-width:255px;color:#7a7a7a;border:1px solid rgba(0,0,0,.25)}.block_newsletter form input[type=text]:focus{outline:3px solid #2fb5d2;color:#232323;background:#fff}.block_newsletter form input[type=text]:focus+button .search{color:#2fb5d2}.block_newsletter form button[type=submit]{position:absolute;background:none;border:none;bottom:.3125rem;right:.125rem;color:#7a7a7a}.block_newsletter form button[type=submit] .search:hover{color:#2fb5d2}.block_newsletter p{padding-top:.625rem}.block_newsletter form .input-wrapper{overflow:hidden}.block_newsletter form input[type=email]{padding:11px;width:100%}.block_newsletter form input[type=email]:focus{border:3px solid #2fb5d2;padding:8px 8px 9px;outline:0}.block_newsletter form input{height:42px;box-shadow:none}.block-contact{color:#7a7a7a}.block-contact .block-contact-title,.linklist .blockcms-title a{color:#232323}.account-list a{color:#7a7a7a}.account-list a:hover{color:#2fb5d2}.block-contact-title,.blockcms-title,.myaccount-title,.myaccount-title a{font-weight:700;font-size:1rem}.block-social{text-align:right}.block-social ul{display:-webkit-box;display:-ms-flexbox;display:flex}@media (max-width:767px){.block-social ul{-ms-flex-flow:wrap;flex-flow:wrap}}.block-social ul li{height:2.5rem;width:2.5rem;background-color:#f1f1f1;background-repeat:no-repeat;display:inline-block;margin:.125rem;cursor:pointer}@media (max-width:767px){.block-social ul li{height:2rem;width:2rem;margin-right:1.3rem;margin-bottom:1.3rem;background-size:contain}}.block-social ul li:hover{background-color:#2fb5d2}.block-social ul li a{display:block;height:100%;white-space:nowrap;text-indent:100%;overflow:hidden}.block-social ul li a:hover{color:transparent}.facebook{background-image:url(../css/3935e107ea61866e60d7946dc6a962f1.svg)}.facebook:before{content:"";background-image:url(../css/8b05d51ede908907d65695558974d86f.svg)}.facebook.icon-gray{background-image:url(../css/082a71677e756fb75817e8f262a07cb4.svg)}.facebook.icon-gray:hover{background-image:url(../css/8b05d51ede908907d65695558974d86f.svg)}.twitter{background-image:url(../css/a67175d1ea11389d9107bd8c08f9d7d7.svg)}.twitter:before{content:"";background-image:url(../css/ffddcb3736980b23405b31142a324b62.svg)}.twitter.icon-gray{background-image:url(../css/e049aeb07a2ae1627933e8e58d3886d2.svg)}.twitter.icon-gray:hover{background-image:url(../css/ffddcb3736980b23405b31142a324b62.svg)}.rss{background-image:url(../css/cf2f3c1d5c7cb02c29f61964313148e1.svg)}.youtube{background-image:url(../css/22c0528acb6d9cd5bf4c8f96381bc05c.svg)}.googleplus{background-image:url(../css/36bff72dcba3098b4b70b482b22c29ab.svg)}.googleplus:before{content:"";background-image:url(../css/c1a65805f759901a39d10eb854c1dcf2.svg)}.googleplus.icon-gray{background-image:url(../css/3a2aeeba930cc29e4d31ebfa1b7cdaa2.svg)}.googleplus.icon-gray:hover{background-image:url(../css/c1a65805f759901a39d10eb854c1dcf2.svg)}#block_myaccount_infos .myaccount-title a{color:#232323}.pinterest{background-image:url(../css/afb2ed6d67613a724a420a39b4fe5b0d.svg)}.pinterest:before{content:"";background-image:url(../css/b1db819132e64a3e01911a1413c33acf.svg)}.pinterest.icon-gray{background-image:url(../css/99db8adec61e4fcf5586e1afa549b432.svg)}.pinterest.icon-gray:hover{background-image:url(../css/b1db819132e64a3e01911a1413c33acf.svg)}.vimeo{background-image:url(../css/f255af0bbbe837e79f7821827f9c6f10.svg)}.instagram{background-image:url(../css/0266b05265f317a7409560b751cd61e8.svg)}.footer-container{margin-top:1.25rem;padding-top:1.25rem;overflow:hidden;box-shadow:2px 2px 11px 0 rgba(0,0,0,.3)}.footer-container li{margin-bottom:.3125rem}.footer-container li a{color:#7a7a7a;cursor:pointer;font-size:.875rem}.footer-container li a:hover{color:#2fb5d2}.links .collapse{display:inherit}@media (max-width:767px){.block_newsletter{padding-bottom:.625rem;border-bottom:1px solid #f6f6f6}.footer-container{box-shadow:none;margin-top:0}.footer-container .wrapper{padding-left:0!important;padding-right:0!important}.footer-container .links .h3{line-height:1.5;font-size:1rem}.footer-container .links ul{background-color:#f6f6f6;margin-bottom:0}.footer-container .links ul>li{padding:.625rem;border-bottom:1px solid #fff;font-weight:700}.footer-container .links ul>li a{color:#232323}.links .collapse{display:none}.links .collapse.in{display:block}.links .title{padding:.625rem;border-bottom:1px solid #f6f6f6;cursor:pointer}.links .title .collapse-icons .remove,.links .title[aria-expanded=true] .collapse-icons .add{display:none}.links .title[aria-expanded=true] .collapse-icons .remove{display:block}.links .navbar-toggler{display:inline-block;padding:0}}@media (max-width:991px){.block-social{text-align:center}.block-contact{padding-left:1.5rem}}.contact-rich{color:#7a7a7a;margin-bottom:2rem;word-wrap:break-word}.contact-rich h4{text-transform:uppercase;color:#232323;margin-bottom:2rem}.contact-rich .block{height:auto;overflow:hidden}.contact-rich .block .icon{float:left;width:3.5rem}.contact-rich .block .icon i{font-size:2rem}.contact-rich .block .data{color:#232323;font-size:.875rem;width:auto;overflow:hidden}.contact-rich .block .data.email{padding-top:.375rem}.contact-rich .block a[href^="mailto:"]{clear:both;margin-top:1rem}@media (min-width:576px){.contact-rich .block a[href^="mailto:"]{font-size:.815rem}}.contact-form{background:#fff;padding:1rem;color:#7a7a7a;width:100%}.contact-form h3{text-transform:uppercase;color:#232323}#pagenotfound #main .page-header,#products #main .page-header{margin:2rem 0 3rem}#pagenotfound #main .page-content,#products #main .page-content{margin-bottom:10rem}#pagenotfound .page-not-found,#products .page-not-found{box-shadow:2px 2px 8px 0 rgba(0,0,0,.2);background:#fff;padding:1rem;font-size:.875rem;color:#7a7a7a;max-width:570px;margin:0 auto}#pagenotfound .page-not-found h4,#products .page-not-found h4{font-size:1rem;font-weight:700;margin:.5rem 0 1rem}#pagenotfound .page-not-found .search-widget,#products .page-not-found .search-widget{float:none}#pagenotfound .page-not-found .search-widget input,#products .page-not-found .search-widget input{width:100%}.customization-modal .modal-content{border-radius:0;border:1px solid #f6f6f6}.customization-modal .modal-content .modal-body{padding-top:0}.customization-modal .modal-content .modal-body .product-customization-line{padding-bottom:.9375rem;padding-top:.9375rem;border-bottom:1px solid #f6f6f6}.customization-modal .modal-content .modal-body .product-customization-line .label{font-weight:700;text-align:right}.customization-modal .modal-content .modal-body .product-customization-line:last-child{padding-bottom:0;border-bottom:0}.sitemap-title{text-transform:capitalize}.sitemap{margin-top:.9375rem}.sitemap h2{color:#232323;text-transform:uppercase;font-size:1.1rem;font-weight:600;border-bottom:1px solid #7a7a7a;margin-left:-15px;width:100%;height:35px}.sitemap ul{margin-left:-15px;margin-top:20px}.sitemap ul.nested{margin-left:20px}.sitemap ul li{font-size:.9rem;margin-bottom:1rem}@media (max-width:575px){.sitemap{margin-top:0}}#header{background:#fff;color:#7a7a7a}#header .logo{max-width:100%}#header a{color:#232323}#header a:hover{text-decoration:none;color:#2fb5d2}#header .menu,#header .menu>ul>li{display:inline-block}#header .header-nav{border-bottom:2px solid #f1f1f1;max-height:50px;margin-bottom:30px}#header .header-nav #menu-icon{vertical-align:middle;cursor:pointer;margin:0 1rem}#header .header-nav #menu-icon .material-icons{line-height:50px}#header .header-nav .right-nav{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end}#header .header-nav .currency-selector{margin-top:.9375rem;margin-left:.9375rem;white-space:nowrap}#header .header-nav .user-info{margin-left:2.5rem;margin-top:.9375rem;text-align:right;white-space:nowrap}#header .header-nav .user-info .account{margin-left:.625rem}#header .header-nav .language-selector{margin-top:.9375rem;white-space:nowrap}#header .header-nav .cart-preview.active{background:#2fb5d2}#header .header-nav .cart-preview.active a,#header .header-nav .cart-preview.active i{color:#fff}#header .header-nav .cart-preview .shopping-cart{vertical-align:middle;color:#7a7a7a}#header .header-nav .cart-preview .body{display:none}#header .header-nav .blockcart{background:#f1f1f1;height:3rem;padding:.75rem;margin-left:.9375rem;text-align:center;white-space:nowrap}#header .header-nav .blockcart a{color:#7a7a7a}#header .header-nav .blockcart a:hover{color:#2fb5d2}#header .header-nav .blockcart.active a:hover{color:#fff}#header .header-nav .blockcart .header{margin-top:.125rem}#header .header-nav #_desktop_contact_link{display:inline-block}#header .header-nav #_desktop_contact_link #contact-link{margin-top:.9375rem}#header .header-nav .search-widget{margin-top:.2rem}#header .header-nav .material-icons{line-height:inherit}#header .header-nav .material-icons.expand-more{margin-left:-.375rem}#header .header-top{padding-bottom:1.25rem}#header .header-top>.container{position:relative}#header .header-top .menu{padding-left:15px;margin-bottom:.375rem}#header .header-top .position-static{position:static}#header .header-top a[data-depth="0"]{color:#7a7a7a;text-transform:uppercase}#header .header-top .search-widget{float:right}#header .top-menu-link{margin-left:1.25rem}.popover{font-family:inherit}#wrapper{background:#f1f1f1;box-shadow:inset 0 2px 5px 0 rgba(0,0,0,.11);padding-top:1.563rem}#wrapper .banner{margin-bottom:1.5rem;display:block}#wrapper .banner img{box-shadow:1px 1px 7px 0 rgba(0,0,0,.15)}#wrapper .breadcrumb{background:transparent;padding:0}#wrapper .breadcrumb[data-depth="1"]{display:none}#wrapper .breadcrumb ol{padding-left:0;margin-bottom:0}#wrapper .breadcrumb li{display:inline}#wrapper .breadcrumb li:after{content:"/";color:#7a7a7a;margin:.3125rem}#wrapper .breadcrumb li:last-child{content:"/";color:#7a7a7a;margin:0}#wrapper .breadcrumb li:last-child:after{content:""}#wrapper .breadcrumb li a{color:#232323}#main .page-content,#main .page-header{margin-bottom:1.563rem}#main .page-content h6{margin-bottom:1.125rem}#main .page-content #notifications{margin-left:-15px;margin-right:-15px}#main .page-footer{margin-bottom:1.563rem}#notifications ul{margin-bottom:0}#footer{padding-top:2.5rem}@media (max-width:1199px){#header .header-nav{max-height:inherit}#header .header-nav .search-widget{float:none;width:15.63rem}}@media (max-width:991px){.container{max-width:100%}#header .logo{width:auto}#header .header-top .search-widget{min-width:inherit}#products .product-miniature,.featured-products .product-miniature{margin:0 auto}.sub-menu{left:0;min-width:100%}#blockcart-modal .product-image{width:100%;display:block;max-width:15.63rem;margin:0 auto .9375rem}#blockcart-modal .cart-content{padding-left:0}#blockcart-modal .product-name,#product-availability{margin-top:.625rem}#search_filters .facet .facet-label{text-align:left}.block-category .category-cover{position:relative;text-align:center}.block-category{padding-bottom:0}}@media (max-width:767px){#wrapper{box-shadow:none}#checkout-cart-summary{float:none;width:100%;margin-top:1rem}#header{background:#f1f1f1}#header .header-nav{background:#fff;margin-bottom:.625rem;color:#232323}#header .header-nav .top-logo{padding-top:11px}#header .header-nav .top-logo a img{max-height:50px;max-width:100%}#header .header-nav .right-nav{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}#header .header-nav .user-info{text-align:left;margin-left:0}#header .header-nav .user-info .logged{color:#2fb5d2}#header .header-nav .blockcart{margin-left:0;background:inherit}#header .header-nav .blockcart.active{margin-left:.5rem}#header .header-nav .blockcart.inactive .cart-products-count{display:none}#header .header-top{background:#f1f1f1;padding-bottom:0}#header .header-top a[data-depth="0"]{color:#232323}#header .header-top .search-widget{width:100%}#header.is-open,#header.is-open .header-top{background-color:#fff}section.checkout-step{width:100%}.default-input{min-width:100%}label{clear:both}#products .product-miniature,.featured-products .product-miniature{margin:0 auto}.block-contact{padding-left:.9375rem;border:none}.dropdown-item,.menu{padding-left:0}#footer{padding-top:.5rem}}@media (max-width:575px){#content-wrapper,#left-column{padding-left:0!important;padding-right:0!important}}input[type=number]{-moz-appearance:textfield}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0} \ No newline at end of file diff --git a/themes/classic/assets/css/theme.rtlfix b/themes/classic/assets/css/theme.rtlfix deleted file mode 100644 index d7e46956..00000000 --- a/themes/classic/assets/css/theme.rtlfix +++ /dev/null @@ -1,41 +0,0 @@ -@font-face { - font-family: Vazir; - src: url('https://res.cloudinary.com/ipresta/raw/upload/v1522045380/vazir_v18.0.0/Vazir.eot'); - src: url('https://res.cloudinary.com/ipresta/raw/upload/v1522045380/vazir_v18.0.0/Vazir.eot?#iefix') format('embedded-opentype'), - url('https://res.cloudinary.com/ipresta/raw/upload/v1522045380/vazir_v18.0.0/Vazir.woff') format('woff'), - url('https://res.cloudinary.com/ipresta/raw/upload/v1522044764/vazir_v18.0.0/Vazir.ttf') format('truetype'); - font-weight: normal; -} - -@font-face { - font-family: Vazir; - src: url('https://res.cloudinary.com/ipresta/raw/upload/v1522045523/vazir_v18.0.0/Vazir-Bold.eot'); - src: url('https://res.cloudinary.com/ipresta/raw/upload/v1522045523/vazir_v18.0.0/Vazir-Bold.eot?#iefix') format('embedded-opentype'), - url('https://res.cloudinary.com/ipresta/raw/upload/v1522045380/vazir_v18.0.0/Vazir.woff') format('woff'), - url('https://res.cloudinary.com/ipresta/raw/upload/v1522045523/vazir_v18.0.0/Vazir-Bold.ttf') format('truetype'); - font-weight: bold; -} - -@font-face { - font-family: Vazir; - src: url('https://res.cloudinary.com/ipresta/raw/upload/v1522044764/vazir_v18.0.0/Vazir-Light.eot'); - src: url('https://res.cloudinary.com/ipresta/raw/upload/v1522044764/vazir_v18.0.0/Vazir-Light.eot?#iefix') format('embedded-opentype'), - url('https://res.cloudinary.com/ipresta/raw/upload/v1522044764/vazir_v18.0.0/Vazir-Light.woff') format('woff'), - url('https://res.cloudinary.com/ipresta/raw/upload/v1522044764/vazir_v18.0.0/Vazir-Light.ttf') format('truetype'); - font-weight: 300; -} -body.lang-fa{ - font-family: "Vazir",sans-serif; -} -.rtl-flip:not(.rtl-no-flip), .material-icons:not(.rtl-no-flip) { - -moz-transform: scaleX(-1); - -o-transform: scaleX(-1); - -webkit-transform: scaleX(-1); - transform: scaleX(-1); - filter: FlipH; - -ms-filter: "FlipH"; -} -.magnitude:before { - content: "?"; - opacity: 0; -} diff --git a/themes/classic/assets/css/theme_rtl.css b/themes/classic/assets/css/theme_rtl.css deleted file mode 100644 index e9d83a92..00000000 --- a/themes/classic/assets/css/theme_rtl.css +++ /dev/null @@ -1,48 +0,0 @@ -.bootstrap-touchspin .input-group-btn-vertical{position:relative;white-space:nowrap;width:1%;vertical-align:middle;display:table-cell}.bootstrap-touchspin .input-group-btn-vertical>.btn{display:block;float:none;width:100%;max-width:100%;padding:8px 10px;margin-right:-1px;position:relative}.bootstrap-touchspin .input-group-btn-vertical .bootstrap-touchspin-up{border-radius:0;border-top-left-radius:4px}.bootstrap-touchspin .input-group-btn-vertical .bootstrap-touchspin-down{margin-top:-2px;border-radius:0;border-bottom-left-radius:4px}.bootstrap-touchspin .input-group-btn-vertical i{position:absolute;top:3px;right:5px;font-size:9px;font-weight:400}/*! - * Bootstrap v4.0.0-alpha.5 (https://getbootstrap.com) - * Copyright 2011-2016 The Bootstrap Authors - * Copyright 2011-2016 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - */ -/*! normalize.css v4.2.0 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block}audio:not([controls]){display:none;height:0}progress{vertical-align:baseline}[hidden],template{display:none}a{background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:inherit;font-weight:bolder}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}svg:not(:root){overflow:hidden}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;overflow:visible}button,input,optgroup,select,textarea{font:inherit;margin:0}optgroup{font-weight:700}button,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;white-space:normal}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-input-placeholder{color:inherit;opacity:.54}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}@media print{*,:after,:before,:first-letter,blockquote:first-line,div:first-line,li:first-line,p:first-line{text-shadow:none!important;box-shadow:none!important}a,a:visited{text-decoration:underline}abbr[title]:after{content:" (" attr(title) ")"}pre{white-space:pre-wrap!important}blockquote,pre{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}img,tr{page-break-inside:avoid}h2,h3,p{orphans:3;widows:3}h2,h3{page-break-after:avoid}.navbar{display:none}.btn>.caret,.dropup>.btn>.caret{border-top-color:#000!important}.tag{border:1px solid #000}.table{border-collapse:collapse!important}.table td,.table th{background-color:#fff!important}.table-bordered td,.table-bordered th{border:1px solid #ddd!important}}html{box-sizing:border-box}*,:after,:before{box-sizing:inherit}@-ms-viewport{width:device-width}html{font-size:16px;-ms-overflow-style:scrollbar;-webkit-tap-highlight-color:rgba(0,0,0,0)}body{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;line-height:1.5;color:#363a42;background-color:#fff}[tabindex="-1"]:focus{outline:none!important}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{cursor:help;border-bottom:1px dotted #f1f1f1}address{font-style:normal;line-height:inherit}address,dl,ol,ul{margin-bottom:1rem}dl,ol,ul{margin-top:0}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-right:0}blockquote{margin:0 0 1rem}a{color:#2fb5d2;text-decoration:none}a:focus,a:hover{color:#208094;text-decoration:underline}a:focus{outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:not([href]):not([tabindex]),a:not([href]):not([tabindex]):focus,a:not([href]):not([tabindex]):hover{color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus{outline:none}pre{overflow:auto}figure{margin:0 0 1rem}img{vertical-align:middle}[role=button]{cursor:pointer}[role=button],a,area,button,input,label,select,summary,textarea{-ms-touch-action:manipulation;touch-action:manipulation}table{border-collapse:collapse;background-color:transparent}caption{padding-top:.75rem;padding-bottom:.75rem;color:#7a7a7a;caption-side:bottom}caption,th{text-align:right}label{display:inline-block;margin-bottom:.5rem}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,select,textarea{line-height:inherit}input[type=checkbox]:disabled,input[type=radio]:disabled{cursor:not-allowed}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit}input[type=search]{-webkit-appearance:none}output{display:inline-block}[hidden]{display:none!important}.h1,.h2,.h3,.h4,.h5,.h6,h1,h2,h3,h4,h5,h6{margin-bottom:.5rem;font-family:inherit;font-weight:700;line-height:1.1;color:inherit}.h1,h1{font-size:1.375rem}.h2,h2{font-size:1.25rem}.h3,.h4,h3,h4{font-size:1.125rem}.h5,h5{font-size:1rem}.h6,h6{font-size:.9375rem}.lead{font-size:1.25rem;font-weight:300}.display-1{font-size:3.125rem;font-weight:600}.display-2{font-size:2.188rem;font-weight:400}.display-3{font-size:1.563rem;font-weight:400}.display-4{font-size:1.25rem;font-weight:400}hr{margin-top:1rem;margin-bottom:1rem;border:0;border-top:1px solid rgba(0,0,0,.1)}.small,small{font-size:80%;font-weight:400}.mark,mark{padding:.2em;background-color:#fcf8e3}.list-inline,.list-unstyled{padding-right:0;list-style:none}.list-inline-item{display:inline-block}.list-inline-item:not(:last-child){margin-left:5px}.initialism{font-size:90%;text-transform:uppercase}.blockquote{padding:.5rem 1rem;margin-bottom:1rem;font-size:1.25rem;border-right:.25rem solid #f6f6f6}.blockquote-footer{display:block;font-size:80%;color:#f1f1f1}.blockquote-footer:before{content:"\2014 \A0"}.blockquote-reverse{padding-left:1rem;padding-right:0;text-align:left;border-left:.25rem solid #f6f6f6;border-right:0}.blockquote-reverse .blockquote-footer:before{content:""}.blockquote-reverse .blockquote-footer:after{content:"\A0 \2014"}dl.row>dd+dt{clear:right}.carousel-inner>.carousel-item>a>img,.carousel-inner>.carousel-item>img,.img-fluid,.img-thumbnail{max-width:100%;height:auto}.img-thumbnail{padding:.25rem;background-color:#fff;border:1px solid #ddd;border-radius:0;transition:all .2s ease-in-out}.figure{display:inline-block}.figure-img{margin-bottom:.5rem;line-height:1}.figure-caption{font-size:90%;color:#f1f1f1}code,kbd,pre,samp{font-family:Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}code{color:#bd4147;background-color:#f7f7f9;border-radius:0}code,kbd{padding:.2rem .4rem;font-size:90%}kbd{color:#fff;background-color:#333;border-radius:.2rem}kbd kbd{padding:0;font-size:100%;font-weight:700}pre{display:block;margin-top:0;margin-bottom:1rem;font-size:90%;color:#363a42}pre code{padding:0;font-size:inherit;color:inherit;background-color:transparent;border-radius:0}.pre-scrollable{max-height:340px;overflow-y:scroll}.container{margin-right:auto;margin-left:auto;padding-right:15px;padding-left:15px}.container:after{content:"";display:table;clear:both}@media (min-width:576px){.container{width:540px;max-width:100%}}@media (min-width:768px){.container{width:720px;max-width:100%}}@media (min-width:992px){.container{width:960px;max-width:100%}}@media (min-width:1200px){.container{width:1140px;max-width:100%}}.container-fluid{margin-right:auto;margin-left:auto;padding-right:15px;padding-left:15px}.container-fluid:after{content:"";display:table;clear:both}.row{margin-left:-15px;margin-right:-15px}.row:after{content:"";display:table;clear:both}@media (min-width:576px){.row{margin-left:-15px;margin-right:-15px}}@media (min-width:768px){.row{margin-left:-15px;margin-right:-15px}}@media (min-width:992px){.row{margin-left:-15px;margin-right:-15px}}@media (min-width:1200px){.row{margin-left:-15px;margin-right:-15px}}.col-lg,.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11,.col-lg-12,.col-md,.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11,.col-md-12,.col-sm,.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11,.col-sm-12,.col-xl,.col-xl-1,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9,.col-xl-10,.col-xl-11,.col-xl-12,.col-xs,.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11,.col-xs-12{position:relative;min-height:1px;padding-left:15px;padding-right:15px}@media (min-width:576px){.col-lg,.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11,.col-lg-12,.col-md,.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11,.col-md-12,.col-sm,.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11,.col-sm-12,.col-xl,.col-xl-1,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9,.col-xl-10,.col-xl-11,.col-xl-12,.col-xs,.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11,.col-xs-12{padding-left:15px;padding-right:15px}}@media (min-width:768px){.col-lg,.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11,.col-lg-12,.col-md,.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11,.col-md-12,.col-sm,.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11,.col-sm-12,.col-xl,.col-xl-1,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9,.col-xl-10,.col-xl-11,.col-xl-12,.col-xs,.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11,.col-xs-12{padding-left:15px;padding-right:15px}}@media (min-width:992px){.col-lg,.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11,.col-lg-12,.col-md,.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11,.col-md-12,.col-sm,.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11,.col-sm-12,.col-xl,.col-xl-1,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9,.col-xl-10,.col-xl-11,.col-xl-12,.col-xs,.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11,.col-xs-12{padding-left:15px;padding-right:15px}}@media (min-width:1200px){.col-lg,.col-lg-1,.col-lg-2,.col-lg-3,.col-lg-4,.col-lg-5,.col-lg-6,.col-lg-7,.col-lg-8,.col-lg-9,.col-lg-10,.col-lg-11,.col-lg-12,.col-md,.col-md-1,.col-md-2,.col-md-3,.col-md-4,.col-md-5,.col-md-6,.col-md-7,.col-md-8,.col-md-9,.col-md-10,.col-md-11,.col-md-12,.col-sm,.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4,.col-sm-5,.col-sm-6,.col-sm-7,.col-sm-8,.col-sm-9,.col-sm-10,.col-sm-11,.col-sm-12,.col-xl,.col-xl-1,.col-xl-2,.col-xl-3,.col-xl-4,.col-xl-5,.col-xl-6,.col-xl-7,.col-xl-8,.col-xl-9,.col-xl-10,.col-xl-11,.col-xl-12,.col-xs,.col-xs-1,.col-xs-2,.col-xs-3,.col-xs-4,.col-xs-5,.col-xs-6,.col-xs-7,.col-xs-8,.col-xs-9,.col-xs-10,.col-xs-11,.col-xs-12{padding-left:15px;padding-right:15px}}.col-xs-1{float:right;width:8.33333%}.col-xs-2{float:right;width:16.66667%}.col-xs-3{float:right;width:25%}.col-xs-4{float:right;width:33.33333%}.col-xs-5{float:right;width:41.66667%}.col-xs-6{float:right;width:50%}.col-xs-7{float:right;width:58.33333%}.col-xs-8{float:right;width:66.66667%}.col-xs-9{float:right;width:75%}.col-xs-10{float:right;width:83.33333%}.col-xs-11{float:right;width:91.66667%}.col-xs-12{float:right;width:100%}.pull-xs-0{left:auto}.pull-xs-1{left:8.33333%}.pull-xs-2{left:16.66667%}.pull-xs-3{left:25%}.pull-xs-4{left:33.33333%}.pull-xs-5{left:41.66667%}.pull-xs-6{left:50%}.pull-xs-7{left:58.33333%}.pull-xs-8{left:66.66667%}.pull-xs-9{left:75%}.pull-xs-10{left:83.33333%}.pull-xs-11{left:91.66667%}.pull-xs-12{left:100%}.push-xs-0{right:auto}.push-xs-1{right:8.33333%}.push-xs-2{right:16.66667%}.push-xs-3{right:25%}.push-xs-4{right:33.33333%}.push-xs-5{right:41.66667%}.push-xs-6{right:50%}.push-xs-7{right:58.33333%}.push-xs-8{right:66.66667%}.push-xs-9{right:75%}.push-xs-10{right:83.33333%}.push-xs-11{right:91.66667%}.push-xs-12{right:100%}.offset-xs-1{margin-right:8.33333%}.offset-xs-2{margin-right:16.66667%}.offset-xs-3{margin-right:25%}.offset-xs-4{margin-right:33.33333%}.offset-xs-5{margin-right:41.66667%}.offset-xs-6{margin-right:50%}.offset-xs-7{margin-right:58.33333%}.offset-xs-8{margin-right:66.66667%}.offset-xs-9{margin-right:75%}.offset-xs-10{margin-right:83.33333%}.offset-xs-11{margin-right:91.66667%}@media (min-width:576px){.col-sm-1{float:right;width:8.33333%}.col-sm-2{float:right;width:16.66667%}.col-sm-3{float:right;width:25%}.col-sm-4{float:right;width:33.33333%}.col-sm-5{float:right;width:41.66667%}.col-sm-6{float:right;width:50%}.col-sm-7{float:right;width:58.33333%}.col-sm-8{float:right;width:66.66667%}.col-sm-9{float:right;width:75%}.col-sm-10{float:right;width:83.33333%}.col-sm-11{float:right;width:91.66667%}.col-sm-12{float:right;width:100%}.pull-sm-0{left:auto}.pull-sm-1{left:8.33333%}.pull-sm-2{left:16.66667%}.pull-sm-3{left:25%}.pull-sm-4{left:33.33333%}.pull-sm-5{left:41.66667%}.pull-sm-6{left:50%}.pull-sm-7{left:58.33333%}.pull-sm-8{left:66.66667%}.pull-sm-9{left:75%}.pull-sm-10{left:83.33333%}.pull-sm-11{left:91.66667%}.pull-sm-12{left:100%}.push-sm-0{right:auto}.push-sm-1{right:8.33333%}.push-sm-2{right:16.66667%}.push-sm-3{right:25%}.push-sm-4{right:33.33333%}.push-sm-5{right:41.66667%}.push-sm-6{right:50%}.push-sm-7{right:58.33333%}.push-sm-8{right:66.66667%}.push-sm-9{right:75%}.push-sm-10{right:83.33333%}.push-sm-11{right:91.66667%}.push-sm-12{right:100%}.offset-sm-0{margin-right:0}.offset-sm-1{margin-right:8.33333%}.offset-sm-2{margin-right:16.66667%}.offset-sm-3{margin-right:25%}.offset-sm-4{margin-right:33.33333%}.offset-sm-5{margin-right:41.66667%}.offset-sm-6{margin-right:50%}.offset-sm-7{margin-right:58.33333%}.offset-sm-8{margin-right:66.66667%}.offset-sm-9{margin-right:75%}.offset-sm-10{margin-right:83.33333%}.offset-sm-11{margin-right:91.66667%}}@media (min-width:768px){.col-md-1{float:right;width:8.33333%}.col-md-2{float:right;width:16.66667%}.col-md-3{float:right;width:25%}.col-md-4{float:right;width:33.33333%}.col-md-5{float:right;width:41.66667%}.col-md-6{float:right;width:50%}.col-md-7{float:right;width:58.33333%}.col-md-8{float:right;width:66.66667%}.col-md-9{float:right;width:75%}.col-md-10{float:right;width:83.33333%}.col-md-11{float:right;width:91.66667%}.col-md-12{float:right;width:100%}.pull-md-0{left:auto}.pull-md-1{left:8.33333%}.pull-md-2{left:16.66667%}.pull-md-3{left:25%}.pull-md-4{left:33.33333%}.pull-md-5{left:41.66667%}.pull-md-6{left:50%}.pull-md-7{left:58.33333%}.pull-md-8{left:66.66667%}.pull-md-9{left:75%}.pull-md-10{left:83.33333%}.pull-md-11{left:91.66667%}.pull-md-12{left:100%}.push-md-0{right:auto}.push-md-1{right:8.33333%}.push-md-2{right:16.66667%}.push-md-3{right:25%}.push-md-4{right:33.33333%}.push-md-5{right:41.66667%}.push-md-6{right:50%}.push-md-7{right:58.33333%}.push-md-8{right:66.66667%}.push-md-9{right:75%}.push-md-10{right:83.33333%}.push-md-11{right:91.66667%}.push-md-12{right:100%}.offset-md-0{margin-right:0}.offset-md-1{margin-right:8.33333%}.offset-md-2{margin-right:16.66667%}.offset-md-3{margin-right:25%}.offset-md-4{margin-right:33.33333%}.offset-md-5{margin-right:41.66667%}.offset-md-6{margin-right:50%}.offset-md-7{margin-right:58.33333%}.offset-md-8{margin-right:66.66667%}.offset-md-9{margin-right:75%}.offset-md-10{margin-right:83.33333%}.offset-md-11{margin-right:91.66667%}}@media (min-width:992px){.col-lg-1{float:right;width:8.33333%}.col-lg-2{float:right;width:16.66667%}.col-lg-3{float:right;width:25%}.col-lg-4{float:right;width:33.33333%}.col-lg-5{float:right;width:41.66667%}.col-lg-6{float:right;width:50%}.col-lg-7{float:right;width:58.33333%}.col-lg-8{float:right;width:66.66667%}.col-lg-9{float:right;width:75%}.col-lg-10{float:right;width:83.33333%}.col-lg-11{float:right;width:91.66667%}.col-lg-12{float:right;width:100%}.pull-lg-0{left:auto}.pull-lg-1{left:8.33333%}.pull-lg-2{left:16.66667%}.pull-lg-3{left:25%}.pull-lg-4{left:33.33333%}.pull-lg-5{left:41.66667%}.pull-lg-6{left:50%}.pull-lg-7{left:58.33333%}.pull-lg-8{left:66.66667%}.pull-lg-9{left:75%}.pull-lg-10{left:83.33333%}.pull-lg-11{left:91.66667%}.pull-lg-12{left:100%}.push-lg-0{right:auto}.push-lg-1{right:8.33333%}.push-lg-2{right:16.66667%}.push-lg-3{right:25%}.push-lg-4{right:33.33333%}.push-lg-5{right:41.66667%}.push-lg-6{right:50%}.push-lg-7{right:58.33333%}.push-lg-8{right:66.66667%}.push-lg-9{right:75%}.push-lg-10{right:83.33333%}.push-lg-11{right:91.66667%}.push-lg-12{right:100%}.offset-lg-0{margin-right:0}.offset-lg-1{margin-right:8.33333%}.offset-lg-2{margin-right:16.66667%}.offset-lg-3{margin-right:25%}.offset-lg-4{margin-right:33.33333%}.offset-lg-5{margin-right:41.66667%}.offset-lg-6{margin-right:50%}.offset-lg-7{margin-right:58.33333%}.offset-lg-8{margin-right:66.66667%}.offset-lg-9{margin-right:75%}.offset-lg-10{margin-right:83.33333%}.offset-lg-11{margin-right:91.66667%}}@media (min-width:1200px){.col-xl-1{float:right;width:8.33333%}.col-xl-2{float:right;width:16.66667%}.col-xl-3{float:right;width:25%}.col-xl-4{float:right;width:33.33333%}.col-xl-5{float:right;width:41.66667%}.col-xl-6{float:right;width:50%}.col-xl-7{float:right;width:58.33333%}.col-xl-8{float:right;width:66.66667%}.col-xl-9{float:right;width:75%}.col-xl-10{float:right;width:83.33333%}.col-xl-11{float:right;width:91.66667%}.col-xl-12{float:right;width:100%}.pull-xl-0{left:auto}.pull-xl-1{left:8.33333%}.pull-xl-2{left:16.66667%}.pull-xl-3{left:25%}.pull-xl-4{left:33.33333%}.pull-xl-5{left:41.66667%}.pull-xl-6{left:50%}.pull-xl-7{left:58.33333%}.pull-xl-8{left:66.66667%}.pull-xl-9{left:75%}.pull-xl-10{left:83.33333%}.pull-xl-11{left:91.66667%}.pull-xl-12{left:100%}.push-xl-0{right:auto}.push-xl-1{right:8.33333%}.push-xl-2{right:16.66667%}.push-xl-3{right:25%}.push-xl-4{right:33.33333%}.push-xl-5{right:41.66667%}.push-xl-6{right:50%}.push-xl-7{right:58.33333%}.push-xl-8{right:66.66667%}.push-xl-9{right:75%}.push-xl-10{right:83.33333%}.push-xl-11{right:91.66667%}.push-xl-12{right:100%}.offset-xl-0{margin-right:0}.offset-xl-1{margin-right:8.33333%}.offset-xl-2{margin-right:16.66667%}.offset-xl-3{margin-right:25%}.offset-xl-4{margin-right:33.33333%}.offset-xl-5{margin-right:41.66667%}.offset-xl-6{margin-right:50%}.offset-xl-7{margin-right:58.33333%}.offset-xl-8{margin-right:66.66667%}.offset-xl-9{margin-right:75%}.offset-xl-10{margin-right:83.33333%}.offset-xl-11{margin-right:91.66667%}}.table{width:100%;max-width:100%;margin-bottom:1rem}.table td,.table th{padding:.75rem;vertical-align:top;border-top:1px solid #f6f6f6}.table thead th{vertical-align:bottom;border-bottom:2px solid #f6f6f6}.table tbody+tbody{border-top:2px solid #f6f6f6}.table .table{background-color:#fff}.table-sm td,.table-sm th{padding:.3rem}.table-bordered,.table-bordered td,.table-bordered th{border:1px solid #f6f6f6}.table-bordered thead td,.table-bordered thead th{border-bottom-width:2px}.table-striped tbody tr:nth-of-type(odd){background-color:rgba(0,0,0,.05)}.table-active,.table-active>td,.table-active>th,.table-hover .table-active:hover,.table-hover .table-active:hover>td,.table-hover .table-active:hover>th,.table-hover tbody tr:hover{background-color:rgba(0,0,0,.075)}.table-success,.table-success>td,.table-success>th{background-color:#dff0d8}.table-hover .table-success:hover,.table-hover .table-success:hover>td,.table-hover .table-success:hover>th{background-color:#d0e9c6}.table-info,.table-info>td,.table-info>th{background-color:#d9edf7}.table-hover .table-info:hover,.table-hover .table-info:hover>td,.table-hover .table-info:hover>th{background-color:#c4e3f3}.table-warning,.table-warning>td,.table-warning>th{background-color:#fcf8e3}.table-hover .table-warning:hover,.table-hover .table-warning:hover>td,.table-hover .table-warning:hover>th{background-color:#faf2cc}.table-danger,.table-danger>td,.table-danger>th{background-color:#f2dede}.table-hover .table-danger:hover,.table-hover .table-danger:hover>td,.table-hover .table-danger:hover>th{background-color:#ebcccc}.thead-inverse th{color:#fff;background-color:#363a42}.thead-default th{color:#7a7a7a;background-color:#f6f6f6}.table-inverse{color:#f6f6f6;background-color:#363a42}.table-inverse td,.table-inverse th,.table-inverse thead th{border-color:#7a7a7a}.table-inverse.table-bordered{border:0}.table-responsive{display:block;width:100%;min-height:0;overflow-x:auto}.table-reflow thead{float:right}.table-reflow tbody{display:block;white-space:nowrap}.table-reflow td,.table-reflow th{border-top:1px solid #f6f6f6;border-right:1px solid #f6f6f6}.table-reflow td:last-child,.table-reflow th:last-child{border-left:1px solid #f6f6f6}.table-reflow tbody:last-child tr:last-child td,.table-reflow tbody:last-child tr:last-child th,.table-reflow tfoot:last-child tr:last-child td,.table-reflow tfoot:last-child tr:last-child th,.table-reflow thead:last-child tr:last-child td,.table-reflow thead:last-child tr:last-child th{border-bottom:1px solid #f6f6f6}.table-reflow tr{float:right}.table-reflow tr td,.table-reflow tr th{display:block!important;border:1px solid #f6f6f6}.form-control{display:block;width:100%;padding:.5rem .75rem;font-size:1rem;line-height:1.25;background-color:#fff;background-image:none;background-clip:padding-box;border-radius:0}.form-control::-ms-expand{background-color:transparent;border:0}.form-control:focus{color:#7a7a7a;border-color:#66afe9;outline:none}.form-control::-webkit-input-placeholder{color:#999;opacity:1}.form-control:-ms-input-placeholder{color:#999;opacity:1}.form-control::placeholder{color:#999;opacity:1}.form-control:disabled,.form-control[readonly]{background-color:#f6f6f6;opacity:1}.form-control:disabled{cursor:not-allowed}select.form-control:not([size]):not([multiple]){height:calc(2.5rem - 2px)}select.form-control:focus::-ms-value{color:#7a7a7a;background-color:#fff}.form-control-file,.form-control-range{display:block}.col-form-label{padding-top:.5rem;padding-bottom:.5rem;margin-bottom:0}.col-form-label-lg{padding-top:.75rem;padding-bottom:.75rem;font-size:.9375rem}.col-form-label-sm{padding-top:.25rem;padding-bottom:.25rem;font-size:.875rem}.col-form-legend{margin-bottom:0;font-size:1rem}.col-form-legend,.form-control-static{padding-top:.5rem;padding-bottom:.5rem}.form-control-static{line-height:1.25;border:solid transparent;border-width:1px 0}.form-control-static.form-control-lg,.form-control-static.form-control-sm,.input-group-lg>.form-control-static.form-control,.input-group-lg>.form-control-static.input-group-addon,.input-group-lg>.input-group-btn>.form-control-static.btn,.input-group-sm>.form-control-static.form-control,.input-group-sm>.form-control-static.input-group-addon,.input-group-sm>.input-group-btn>.form-control-static.btn{padding-left:0;padding-right:0}.form-control-sm,.input-group-sm>.form-control,.input-group-sm>.input-group-addon,.input-group-sm>.input-group-btn>.btn{padding:.25rem .5rem;font-size:.875rem;border-radius:.2rem}.input-group-sm>.input-group-btn>select.btn:not([size]):not([multiple]),.input-group-sm>select.form-control:not([size]):not([multiple]),.input-group-sm>select.input-group-addon:not([size]):not([multiple]),select.form-control-sm:not([size]):not([multiple]){height:1.8125rem}.form-control-lg,.input-group-lg>.form-control,.input-group-lg>.input-group-addon,.input-group-lg>.input-group-btn>.btn{padding:.75rem 1.5rem;font-size:.9375rem;border-radius:.3rem}.input-group-lg>.input-group-btn>select.btn:not([size]):not([multiple]),.input-group-lg>select.form-control:not([size]):not([multiple]),.input-group-lg>select.input-group-addon:not([size]):not([multiple]),select.form-control-lg:not([size]):not([multiple]){height:2.75rem}.form-group{margin-bottom:1rem}.form-text{display:block;margin-top:.25rem}.form-check{position:relative;display:block;margin-bottom:.75rem}.form-check+.form-check{margin-top:-.25rem}.form-check.disabled .form-check-label{color:#7a7a7a;cursor:not-allowed}.form-check-label{padding-right:1.25rem;margin-bottom:0;cursor:pointer}.form-check-input{position:absolute;margin-top:.25rem;margin-right:-1.25rem}.form-check-input:only-child{position:static}.form-check-inline{position:relative;display:inline-block;padding-right:1.25rem;margin-bottom:0;vertical-align:middle;cursor:pointer}.form-check-inline+.form-check-inline{margin-right:.75rem}.form-check-inline.disabled{color:#7a7a7a;cursor:not-allowed}.form-control-feedback{margin-top:.25rem}.form-control-danger,.form-control-success,.form-control-warning{padding-left:2.25rem;background-repeat:no-repeat;background-position:center left .625rem;background-size:1.25rem 1.25rem}.has-success .custom-control,.has-success .form-check-inline,.has-success .form-check-label,.has-success .form-control-feedback,.has-success .form-control-label{color:#4cbb6c}.has-success .form-control{border-color:#4cbb6c}.has-success .form-control:focus{box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #96d7a9}.has-success .input-group-addon{color:#4cbb6c;border-color:#4cbb6c;background-color:#e0f3e5}.has-success .form-control-success{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath fill='#4cbb6c' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3E%3C/svg%3E")}.has-warning .custom-control,.has-warning .form-check-inline,.has-warning .form-check-label,.has-warning .form-control-feedback,.has-warning .form-control-label{color:#ff9a52}.has-warning .form-control{border-color:#ff9a52}.has-warning .form-control:focus{box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ffd6b8}.has-warning .input-group-addon{color:#ff9a52;border-color:#ff9a52;background-color:#fff}.has-warning .form-control-warning{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath fill='#ff9a52' d='M4.4 5.324h-.8v-2.46h.8zm0 1.42h-.8V5.89h.8zM3.76.63L.04 7.075c-.115.2.016.425.26.426h7.397c.242 0 .372-.226.258-.426C6.726 4.924 5.47 2.79 4.253.63c-.113-.174-.39-.174-.494 0z'/%3E%3C/svg%3E")}.has-danger .custom-control,.has-danger .form-check-inline,.has-danger .form-check-label,.has-danger .form-control-feedback,.has-danger .form-control-label{color:#ff4c4c}.has-danger .form-control{border-color:#ff4c4c}.has-danger .form-control:focus{box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 6px #ffb2b2}.has-danger .input-group-addon{color:#ff4c4c;border-color:#ff4c4c;background-color:#fff}.has-danger .form-control-danger{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='#ff4c4c' viewBox='-2 -2 7 7'%3E%3Cpath stroke='%23d9534f' d='M0 0l3 3m0-3L0 3'/%3E%3Ccircle r='.5'/%3E%3Ccircle cx='3' r='.5'/%3E%3Ccircle cy='3' r='.5'/%3E%3Ccircle cx='3' cy='3' r='.5'/%3E%3C/svg%3E")}@media (min-width:576px){.form-inline .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.form-inline .form-control{display:inline-block;width:auto;vertical-align:middle}.form-inline .form-control-static{display:inline-block}.form-inline .input-group{display:inline-table;width:auto;vertical-align:middle}.form-inline .input-group .form-control,.form-inline .input-group .input-group-addon,.form-inline .input-group .input-group-btn{width:auto}.form-inline .input-group>.form-control{width:100%}.form-inline .form-check,.form-inline .form-control-label{margin-bottom:0;vertical-align:middle}.form-inline .form-check{display:inline-block;margin-top:0}.form-inline .form-check-label{padding-right:0}.form-inline .form-check-input{position:relative;margin-right:0}.form-inline .has-feedback .form-control-feedback{top:0}}.btn{display:inline-block;font-weight:400;line-height:1.25;text-align:center;white-space:nowrap;vertical-align:middle;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border:1px solid transparent;padding:.5rem 1rem;font-size:1rem;border-radius:0}.btn.active.focus,.btn.active:focus,.btn.focus,.btn:active.focus,.btn:active:focus,.btn:focus{outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.focus,.btn:focus,.btn:hover{text-decoration:none}.btn.active,.btn:active{background-image:none;outline:0}.btn.disabled,.btn:disabled{cursor:not-allowed;opacity:.65}a.btn.disabled,fieldset[disabled] a.btn{pointer-events:none}.btn-primary{color:#fff;background-color:#2fb5d2;border-color:transparent}.btn-primary.focus,.btn-primary:focus,.btn-primary:hover{color:#fff;background-color:#2592a9;border-color:transparent}.btn-primary.active,.btn-primary:active,.open>.btn-primary.dropdown-toggle{color:#fff;background-color:#2592a9;border-color:transparent;background-image:none}.btn-primary.active.focus,.btn-primary.active:focus,.btn-primary.active:hover,.btn-primary:active.focus,.btn-primary:active:focus,.btn-primary:active:hover,.open>.btn-primary.dropdown-toggle.focus,.open>.btn-primary.dropdown-toggle:focus,.open>.btn-primary.dropdown-toggle:hover{color:#fff;background-color:#1e788c;border-color:transparent}.btn-primary.disabled.focus,.btn-primary.disabled:focus,.btn-primary.disabled:hover,.btn-primary:disabled.focus,.btn-primary:disabled:focus,.btn-primary:disabled:hover{background-color:#2fb5d2;border-color:transparent}.btn-secondary,.btn-tertiary{color:#232323;background-color:#f6f6f6;border-color:transparent}.btn-secondary.focus,.btn-secondary:focus,.btn-secondary:hover,.btn-tertiary:focus,.btn-tertiary:hover,.focus.btn-tertiary{color:#232323;background-color:#ddd;border-color:transparent}.active.btn-tertiary,.btn-secondary.active,.btn-secondary:active,.btn-tertiary:active,.open>.btn-secondary.dropdown-toggle,.open>.dropdown-toggle.btn-tertiary{color:#232323;background-color:#ddd;border-color:transparent;background-image:none}.active.btn-tertiary:focus,.active.btn-tertiary:hover,.active.focus.btn-tertiary,.btn-secondary.active.focus,.btn-secondary.active:focus,.btn-secondary.active:hover,.btn-secondary:active.focus,.btn-secondary:active:focus,.btn-secondary:active:hover,.btn-tertiary:active.focus,.btn-tertiary:active:focus,.btn-tertiary:active:hover,.open>.btn-secondary.dropdown-toggle.focus,.open>.btn-secondary.dropdown-toggle:focus,.open>.btn-secondary.dropdown-toggle:hover,.open>.dropdown-toggle.btn-tertiary:focus,.open>.dropdown-toggle.btn-tertiary:hover,.open>.dropdown-toggle.focus.btn-tertiary{color:#232323;background-color:#cbcbcb;border-color:transparent}.btn-secondary.disabled.focus,.btn-secondary.disabled:focus,.btn-secondary.disabled:hover,.btn-secondary:disabled.focus,.btn-secondary:disabled:focus,.btn-secondary:disabled:hover,.btn-tertiary:disabled.focus,.btn-tertiary:disabled:focus,.btn-tertiary:disabled:hover,.disabled.btn-tertiary:focus,.disabled.btn-tertiary:hover,.disabled.focus.btn-tertiary{background-color:#f6f6f6;border-color:transparent}.btn-info{color:#fff;background-color:#5bc0de;border-color:#5bc0de}.btn-info.focus,.btn-info:focus,.btn-info:hover{color:#fff;background-color:#31b0d5;border-color:#2aabd2}.btn-info.active,.btn-info:active,.open>.btn-info.dropdown-toggle{color:#fff;background-color:#31b0d5;border-color:#2aabd2;background-image:none}.btn-info.active.focus,.btn-info.active:focus,.btn-info.active:hover,.btn-info:active.focus,.btn-info:active:focus,.btn-info:active:hover,.open>.btn-info.dropdown-toggle.focus,.open>.btn-info.dropdown-toggle:focus,.open>.btn-info.dropdown-toggle:hover{color:#fff;background-color:#269abc;border-color:#1f7e9a}.btn-info.disabled.focus,.btn-info.disabled:focus,.btn-info.disabled:hover,.btn-info:disabled.focus,.btn-info:disabled:focus,.btn-info:disabled:hover{background-color:#5bc0de;border-color:#5bc0de}.btn-success{color:#fff;background-color:#4cbb6c;border-color:#4cbb6c}.btn-success.focus,.btn-success:focus,.btn-success:hover{color:#fff;background-color:#3a9a56;border-color:#389252}.btn-success.active,.btn-success:active,.open>.btn-success.dropdown-toggle{color:#fff;background-color:#3a9a56;border-color:#389252;background-image:none}.btn-success.active.focus,.btn-success.active:focus,.btn-success.active:hover,.btn-success:active.focus,.btn-success:active:focus,.btn-success:active:hover,.open>.btn-success.dropdown-toggle.focus,.open>.btn-success.dropdown-toggle:focus,.open>.btn-success.dropdown-toggle:hover{color:#fff;background-color:#318047;border-color:#256237}.btn-success.disabled.focus,.btn-success.disabled:focus,.btn-success.disabled:hover,.btn-success:disabled.focus,.btn-success:disabled:focus,.btn-success:disabled:hover{background-color:#4cbb6c;border-color:#4cbb6c}.btn-warning{color:#fff;background-color:#ff9a52;border-color:#ff9a52}.btn-warning.focus,.btn-warning:focus,.btn-warning:hover{color:#fff;background-color:#ff7c1f;border-color:#ff7615}.btn-warning.active,.btn-warning:active,.open>.btn-warning.dropdown-toggle{color:#fff;background-color:#ff7c1f;border-color:#ff7615;background-image:none}.btn-warning.active.focus,.btn-warning.active:focus,.btn-warning.active:hover,.btn-warning:active.focus,.btn-warning:active:focus,.btn-warning:active:hover,.open>.btn-warning.dropdown-toggle.focus,.open>.btn-warning.dropdown-toggle:focus,.open>.btn-warning.dropdown-toggle:hover{color:#fff;background-color:#fa6800;border-color:#d25700}.btn-warning.disabled.focus,.btn-warning.disabled:focus,.btn-warning.disabled:hover,.btn-warning:disabled.focus,.btn-warning:disabled:focus,.btn-warning:disabled:hover{background-color:#ff9a52;border-color:#ff9a52}.btn-danger{color:#fff;background-color:#ff4c4c;border-color:#ff4c4c}.btn-danger.focus,.btn-danger:focus,.btn-danger:hover{color:#fff;background-color:#ff1919;border-color:#ff0f0f}.btn-danger.active,.btn-danger:active,.open>.btn-danger.dropdown-toggle{color:#fff;background-color:#ff1919;border-color:#ff0f0f;background-image:none}.btn-danger.active.focus,.btn-danger.active:focus,.btn-danger.active:hover,.btn-danger:active.focus,.btn-danger:active:focus,.btn-danger:active:hover,.open>.btn-danger.dropdown-toggle.focus,.open>.btn-danger.dropdown-toggle:focus,.open>.btn-danger.dropdown-toggle:hover{color:#fff;background-color:#f40000;border-color:#c00}.btn-danger.disabled.focus,.btn-danger.disabled:focus,.btn-danger.disabled:hover,.btn-danger:disabled.focus,.btn-danger:disabled:focus,.btn-danger:disabled:hover{background-color:#ff4c4c;border-color:#ff4c4c}.btn-outline-primary{color:#2fb5d2;background-image:none;background-color:transparent;border-color:#2fb5d2}.btn-outline-primary.active,.btn-outline-primary.focus,.btn-outline-primary:active,.btn-outline-primary:focus,.btn-outline-primary:hover,.open>.btn-outline-primary.dropdown-toggle{color:#fff;background-color:#2fb5d2;border-color:#2fb5d2}.btn-outline-primary.active.focus,.btn-outline-primary.active:focus,.btn-outline-primary.active:hover,.btn-outline-primary:active.focus,.btn-outline-primary:active:focus,.btn-outline-primary:active:hover,.open>.btn-outline-primary.dropdown-toggle.focus,.open>.btn-outline-primary.dropdown-toggle:focus,.open>.btn-outline-primary.dropdown-toggle:hover{color:#fff;background-color:#1e788c;border-color:#175c6a}.btn-outline-primary.disabled.focus,.btn-outline-primary.disabled:focus,.btn-outline-primary.disabled:hover,.btn-outline-primary:disabled.focus,.btn-outline-primary:disabled:focus,.btn-outline-primary:disabled:hover{border-color:#83d3e4}.btn-outline-secondary{color:transparent;background-image:none;background-color:transparent;border-color:transparent}.btn-outline-secondary.active,.btn-outline-secondary.active.focus,.btn-outline-secondary.active:focus,.btn-outline-secondary.active:hover,.btn-outline-secondary.focus,.btn-outline-secondary:active,.btn-outline-secondary:active.focus,.btn-outline-secondary:active:focus,.btn-outline-secondary:active:hover,.btn-outline-secondary:focus,.btn-outline-secondary:hover,.open>.btn-outline-secondary.dropdown-toggle,.open>.btn-outline-secondary.dropdown-toggle.focus,.open>.btn-outline-secondary.dropdown-toggle:focus,.open>.btn-outline-secondary.dropdown-toggle:hover{color:#fff;background-color:transparent;border-color:transparent}.btn-outline-secondary.disabled.focus,.btn-outline-secondary.disabled:focus,.btn-outline-secondary.disabled:hover,.btn-outline-secondary:disabled.focus,.btn-outline-secondary:disabled:focus,.btn-outline-secondary:disabled:hover{border-color:rgba(51,51,51,0)}.btn-outline-info{color:#5bc0de;background-image:none;background-color:transparent;border-color:#5bc0de}.btn-outline-info.active,.btn-outline-info.focus,.btn-outline-info:active,.btn-outline-info:focus,.btn-outline-info:hover,.open>.btn-outline-info.dropdown-toggle{color:#fff;background-color:#5bc0de;border-color:#5bc0de}.btn-outline-info.active.focus,.btn-outline-info.active:focus,.btn-outline-info.active:hover,.btn-outline-info:active.focus,.btn-outline-info:active:focus,.btn-outline-info:active:hover,.open>.btn-outline-info.dropdown-toggle.focus,.open>.btn-outline-info.dropdown-toggle:focus,.open>.btn-outline-info.dropdown-toggle:hover{color:#fff;background-color:#269abc;border-color:#1f7e9a}.btn-outline-info.disabled.focus,.btn-outline-info.disabled:focus,.btn-outline-info.disabled:hover,.btn-outline-info:disabled.focus,.btn-outline-info:disabled:focus,.btn-outline-info:disabled:hover{border-color:#b0e1ef}.btn-outline-success{color:#4cbb6c;background-image:none;background-color:transparent;border-color:#4cbb6c}.btn-outline-success.active,.btn-outline-success.focus,.btn-outline-success:active,.btn-outline-success:focus,.btn-outline-success:hover,.open>.btn-outline-success.dropdown-toggle{color:#fff;background-color:#4cbb6c;border-color:#4cbb6c}.btn-outline-success.active.focus,.btn-outline-success.active:focus,.btn-outline-success.active:hover,.btn-outline-success:active.focus,.btn-outline-success:active:focus,.btn-outline-success:active:hover,.open>.btn-outline-success.dropdown-toggle.focus,.open>.btn-outline-success.dropdown-toggle:focus,.open>.btn-outline-success.dropdown-toggle:hover{color:#fff;background-color:#318047;border-color:#256237}.btn-outline-success.disabled.focus,.btn-outline-success.disabled:focus,.btn-outline-success.disabled:hover,.btn-outline-success:disabled.focus,.btn-outline-success:disabled:focus,.btn-outline-success:disabled:hover{border-color:#96d7a9}.btn-outline-warning{color:#ff9a52;background-image:none;background-color:transparent;border-color:#ff9a52}.btn-outline-warning.active,.btn-outline-warning.focus,.btn-outline-warning:active,.btn-outline-warning:focus,.btn-outline-warning:hover,.open>.btn-outline-warning.dropdown-toggle{color:#fff;background-color:#ff9a52;border-color:#ff9a52}.btn-outline-warning.active.focus,.btn-outline-warning.active:focus,.btn-outline-warning.active:hover,.btn-outline-warning:active.focus,.btn-outline-warning:active:focus,.btn-outline-warning:active:hover,.open>.btn-outline-warning.dropdown-toggle.focus,.open>.btn-outline-warning.dropdown-toggle:focus,.open>.btn-outline-warning.dropdown-toggle:hover{color:#fff;background-color:#fa6800;border-color:#d25700}.btn-outline-warning.disabled.focus,.btn-outline-warning.disabled:focus,.btn-outline-warning.disabled:hover,.btn-outline-warning:disabled.focus,.btn-outline-warning:disabled:focus,.btn-outline-warning:disabled:hover{border-color:#ffd6b8}.btn-outline-danger{color:#ff4c4c;background-image:none;background-color:transparent;border-color:#ff4c4c}.btn-outline-danger.active,.btn-outline-danger.focus,.btn-outline-danger:active,.btn-outline-danger:focus,.btn-outline-danger:hover,.open>.btn-outline-danger.dropdown-toggle{color:#fff;background-color:#ff4c4c;border-color:#ff4c4c}.btn-outline-danger.active.focus,.btn-outline-danger.active:focus,.btn-outline-danger.active:hover,.btn-outline-danger:active.focus,.btn-outline-danger:active:focus,.btn-outline-danger:active:hover,.open>.btn-outline-danger.dropdown-toggle.focus,.open>.btn-outline-danger.dropdown-toggle:focus,.open>.btn-outline-danger.dropdown-toggle:hover{color:#fff;background-color:#f40000;border-color:#c00}.btn-outline-danger.disabled.focus,.btn-outline-danger.disabled:focus,.btn-outline-danger.disabled:hover,.btn-outline-danger:disabled.focus,.btn-outline-danger:disabled:focus,.btn-outline-danger:disabled:hover{border-color:#ffb2b2}.btn-link{font-weight:400;color:#2fb5d2;border-radius:0}.btn-link,.btn-link.active,.btn-link:active,.btn-link:disabled{background-color:transparent}.btn-link,.btn-link:active,.btn-link:focus,.btn-link:hover{border-color:transparent}.btn-link:focus,.btn-link:hover{color:#208094;text-decoration:underline;background-color:transparent}.btn-link:disabled:focus,.btn-link:disabled:hover{color:#f1f1f1;text-decoration:none}.btn-group-lg>.btn,.btn-lg{padding:.75rem 1.5rem;font-size:.9375rem;border-radius:.3rem}.btn-group-sm>.btn,.btn-sm{padding:.25rem .5rem;font-size:.875rem;border-radius:.2rem}.btn-block{display:block;width:100%}.btn-block+.btn-block{margin-top:.5rem}input[type=button].btn-block,input[type=reset].btn-block,input[type=submit].btn-block{width:100%}.fade{opacity:0;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{display:none}.collapse.in{display:block}tr.collapse.in{display:table-row}tbody.collapse.in{display:table-row-group}.collapsing{height:0;overflow:hidden;transition-timing-function:ease;transition-duration:.35s;transition-property:height}.collapsing,.dropdown,.dropup{position:relative}.dropdown-toggle:after{display:inline-block;width:0;height:0;margin-right:.3em;vertical-align:middle;content:"";border-top:.3em solid;border-left:.3em solid transparent;border-right:.3em solid transparent}.dropdown-toggle:focus{outline:0}.dropup .dropdown-toggle:after{border-top:0;border-bottom:.3em solid}.dropdown-menu{position:absolute;top:100%;right:0;z-index:1000;display:none;float:right;min-width:10rem;padding:.5rem 0;margin:.125rem 0 0;font-size:1rem;color:#363a42;text-align:right;list-style:none;background-color:#fff;background-clip:padding-box;border:1px solid rgba(0,0,0,.15);border-radius:0}.dropdown-divider{height:1px;margin:.5rem 0;overflow:hidden;background-color:#e5e5e5}.dropdown-item{display:block;width:100%;padding:3px 1.5rem;clear:both;font-weight:400;color:#363a42;text-align:inherit;white-space:nowrap;background:none;border:0}.dropdown-item:focus,.dropdown-item:hover{color:#2b2e34;background-color:#f5f5f5}.dropdown-item.active,.dropdown-item.active:focus,.dropdown-item.active:hover{color:#fff;text-decoration:none;background-color:#2fb5d2;outline:0}.dropdown-item.disabled,.dropdown-item.disabled:focus,.dropdown-item.disabled:hover{color:#f1f1f1}.dropdown-item.disabled:focus,.dropdown-item.disabled:hover{text-decoration:none;cursor:not-allowed;background-color:transparent;background-image:none;filter:"progid:DXImageTransform.Microsoft.gradient(enabled = false)"}.open>.dropdown-menu{display:block}.open>a{outline:0}.dropdown-menu-right{left:0;right:auto}.dropdown-menu-left{left:auto;right:0}.dropdown-header{display:block;padding:.5rem 1.5rem;margin-bottom:0;font-size:.875rem;color:#f1f1f1;white-space:nowrap}.dropdown-backdrop{position:fixed;top:0;left:0;bottom:0;right:0;z-index:990}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{content:"";border-top:0;border-bottom:.3em solid}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:.125rem}.btn-group,.btn-group-vertical{position:relative;display:inline-block;vertical-align:middle}.btn-group-vertical>.btn,.btn-group>.btn{position:relative;float:right;margin-bottom:0}.btn-group-vertical>.btn.active,.btn-group-vertical>.btn:active,.btn-group-vertical>.btn:focus,.btn-group-vertical>.btn:hover,.btn-group>.btn.active,.btn-group>.btn:active,.btn-group>.btn:focus,.btn-group>.btn:hover{z-index:2}.btn-group .btn+.btn,.btn-group .btn+.btn-group,.btn-group .btn-group+.btn,.btn-group .btn-group+.btn-group{margin-right:-1px}.btn-toolbar{margin-right:-.5rem}.btn-toolbar:after{content:"";display:table;clear:both}.btn-toolbar .btn-group,.btn-toolbar .input-group{float:right}.btn-toolbar>.btn,.btn-toolbar>.btn-group,.btn-toolbar>.input-group{margin-right:.5rem}.btn-group>.btn:not(:first-child):not(:last-child):not(.dropdown-toggle){border-radius:0}.btn-group>.btn:first-child{margin-right:0}.btn-group>.btn:first-child:not(:last-child):not(.dropdown-toggle){border-bottom-left-radius:0;border-top-left-radius:0}.btn-group>.btn:last-child:not(:first-child),.btn-group>.dropdown-toggle:not(:first-child){border-bottom-right-radius:0;border-top-right-radius:0}.btn-group>.btn-group{float:right}.btn-group>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group>.btn-group:first-child:not(:last-child)>.btn:last-child,.btn-group>.btn-group:first-child:not(:last-child)>.dropdown-toggle{border-bottom-left-radius:0;border-top-left-radius:0}.btn-group>.btn-group:last-child:not(:first-child)>.btn:first-child{border-bottom-right-radius:0;border-top-right-radius:0}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn+.dropdown-toggle-split{padding-left:.75rem;padding-right:.75rem}.btn+.dropdown-toggle-split:after{margin-right:0}.btn-group-sm>.btn+.dropdown-toggle-split,.btn-sm+.dropdown-toggle-split{padding-left:.375rem;padding-right:.375rem}.btn-group-lg>.btn+.dropdown-toggle-split,.btn-lg+.dropdown-toggle-split{padding-left:1.125rem;padding-right:1.125rem}.btn .caret{margin-right:0}.btn-group-lg>.btn .caret,.btn-lg .caret{border-width:.3em .3em 0;border-bottom-width:0}.dropup .btn-group-lg>.btn .caret,.dropup .btn-lg .caret{border-width:0 .3em .3em}.btn-group-vertical>.btn,.btn-group-vertical>.btn-group,.btn-group-vertical>.btn-group>.btn{display:block;float:none;width:100%;max-width:100%}.btn-group-vertical>.btn-group:after{content:"";display:table;clear:both}.btn-group-vertical>.btn-group>.btn{float:none}.btn-group-vertical>.btn+.btn,.btn-group-vertical>.btn+.btn-group,.btn-group-vertical>.btn-group+.btn,.btn-group-vertical>.btn-group+.btn-group{margin-top:-1px;margin-right:0}.btn-group-vertical>.btn:not(:first-child):not(:last-child){border-radius:0}.btn-group-vertical>.btn:first-child:not(:last-child){border-bottom-left-radius:0;border-bottom-right-radius:0}.btn-group-vertical>.btn:last-child:not(:first-child){border-top-left-radius:0;border-top-right-radius:0}.btn-group-vertical>.btn-group:not(:first-child):not(:last-child)>.btn{border-radius:0}.btn-group-vertical>.btn-group:first-child:not(:last-child)>.btn:last-child,.btn-group-vertical>.btn-group:first-child:not(:last-child)>.dropdown-toggle{border-bottom-left-radius:0;border-bottom-right-radius:0}.btn-group-vertical>.btn-group:last-child:not(:first-child)>.btn:first-child{border-top-left-radius:0;border-top-right-radius:0}[data-toggle=buttons]>.btn-group>.btn input[type=checkbox],[data-toggle=buttons]>.btn-group>.btn input[type=radio],[data-toggle=buttons]>.btn input[type=checkbox],[data-toggle=buttons]>.btn input[type=radio]{position:absolute;clip:rect(0,0,0,0);pointer-events:none}.input-group{position:relative;width:100%;display:table;border-collapse:separate}.input-group .form-control{position:relative;z-index:2;float:right;width:100%;margin-bottom:0}.input-group .form-control:active,.input-group .form-control:focus,.input-group .form-control:hover{z-index:3}.input-group-addon,.input-group-btn,.input-group .form-control{display:table-cell}.input-group-addon:not(:first-child):not(:last-child),.input-group-btn:not(:first-child):not(:last-child),.input-group .form-control:not(:first-child):not(:last-child){border-radius:0}.input-group-addon,.input-group-btn{width:1%;white-space:nowrap;vertical-align:middle}.input-group-addon{padding:.5rem .75rem;margin-bottom:0;font-size:1rem;font-weight:400;line-height:1.25;color:#7a7a7a;text-align:center;background-color:#f6f6f6;border:1px solid rgba(0,0,0,.25);border-radius:0}.input-group-addon.form-control-sm,.input-group-sm>.input-group-addon,.input-group-sm>.input-group-btn>.input-group-addon.btn{padding:.25rem .5rem;font-size:.875rem;border-radius:.2rem}.input-group-addon.form-control-lg,.input-group-lg>.input-group-addon,.input-group-lg>.input-group-btn>.input-group-addon.btn{padding:.75rem 1.5rem;font-size:.9375rem;border-radius:.3rem}.input-group-addon input[type=checkbox],.input-group-addon input[type=radio]{margin-top:0}.input-group-addon:not(:last-child),.input-group-btn:not(:first-child)>.btn-group:not(:last-child)>.btn,.input-group-btn:not(:first-child)>.btn:not(:last-child):not(.dropdown-toggle),.input-group-btn:not(:last-child)>.btn,.input-group-btn:not(:last-child)>.btn-group>.btn,.input-group-btn:not(:last-child)>.dropdown-toggle,.input-group .form-control:not(:last-child){border-bottom-left-radius:0;border-top-left-radius:0}.input-group-addon:not(:last-child){border-left:0}.input-group-addon:not(:first-child),.input-group-btn:not(:first-child)>.btn,.input-group-btn:not(:first-child)>.btn-group>.btn,.input-group-btn:not(:first-child)>.dropdown-toggle,.input-group-btn:not(:last-child)>.btn-group:not(:first-child)>.btn,.input-group-btn:not(:last-child)>.btn:not(:first-child),.input-group .form-control:not(:first-child){border-bottom-right-radius:0;border-top-right-radius:0}.form-control+.input-group-addon:not(:first-child){border-right:0}.input-group-btn{font-size:0;white-space:nowrap}.input-group-btn,.input-group-btn>.btn{position:relative}.input-group-btn>.btn+.btn{margin-right:-1px}.input-group-btn>.btn:active,.input-group-btn>.btn:focus,.input-group-btn>.btn:hover{z-index:3}.input-group-btn:not(:last-child)>.btn,.input-group-btn:not(:last-child)>.btn-group{margin-left:-1px}.input-group-btn:not(:first-child)>.btn,.input-group-btn:not(:first-child)>.btn-group{z-index:2;margin-right:-1px}.input-group-btn:not(:first-child)>.btn-group:active,.input-group-btn:not(:first-child)>.btn-group:focus,.input-group-btn:not(:first-child)>.btn-group:hover,.input-group-btn:not(:first-child)>.btn:active,.input-group-btn:not(:first-child)>.btn:focus,.input-group-btn:not(:first-child)>.btn:hover{z-index:3}.custom-control{position:relative;display:inline-block;padding-right:1.5rem;cursor:pointer}.custom-control+.custom-control{margin-right:1rem}.custom-control-input{position:absolute;z-index:-1;opacity:0}.custom-control-input:checked~.custom-control-indicator{color:#fff;background-color:#0074d9}.custom-control-input:focus~.custom-control-indicator{box-shadow:0 0 0 .075rem #fff,0 0 0 .2rem #0074d9}.custom-control-input:active~.custom-control-indicator{color:#fff;background-color:#84c6ff}.custom-control-input:disabled~.custom-control-indicator{cursor:not-allowed;background-color:#eee}.custom-control-input:disabled~.custom-control-description{color:#767676;cursor:not-allowed}.custom-control-indicator{position:absolute;top:.25rem;right:0;display:block;width:1rem;height:1rem;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-color:#ddd;background-repeat:no-repeat;background-position:50%;background-size:50% 50%}.custom-checkbox .custom-control-indicator{border-radius:0}.custom-checkbox .custom-control-input:checked~.custom-control-indicator{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath fill='#fff' d='M6.564.75l-3.59 3.612-1.538-1.55L0 4.26 2.974 7.25 8 2.193z'/%3E%3C/svg%3E")}.custom-checkbox .custom-control-input:indeterminate~.custom-control-indicator{background-color:#0074d9;background-image:url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 4'%3E%3Cpath stroke='#fff' d='M0 2h4'/%3E%3C/svg%3E")}.custom-radio .custom-control-indicator{border-radius:50%}.custom-radio .custom-control-input:checked~.custom-control-indicator{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3E%3Ccircle r='3' fill='#fff'/%3E%3C/svg%3E")}.custom-controls-stacked .custom-control{float:right;clear:right}.custom-controls-stacked .custom-control+.custom-control{margin-right:0}.custom-select{display:inline-block;max-width:100%;height:calc(2.5rem - 2px);padding:.375rem .75rem .375rem 1.75rem;padding-left:.75rem\9;color:#7a7a7a;vertical-align:middle;background:#fff url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='#333' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E") no-repeat left .75rem center;background-image:none\9;background-size:8px 10px;border:1px solid rgba(0,0,0,.25);border-radius:0;-moz-appearance:none;-webkit-appearance:none}.custom-select:focus{border-color:#51a7e8;outline:none}.custom-select:focus::-ms-value{color:#7a7a7a;background-color:#fff}.custom-select:disabled{color:#f1f1f1;cursor:not-allowed;background-color:#f6f6f6}.custom-select::-ms-expand{opacity:0}.custom-select-sm{padding-top:.375rem;padding-bottom:.375rem;font-size:75%}.custom-file{position:relative;display:inline-block;max-width:100%;height:2.5rem;cursor:pointer}.custom-file-input{min-width:14rem;max-width:100%;margin:0;filter:alpha(opacity=0);opacity:0}.custom-file-control{position:absolute;top:0;left:0;right:0;z-index:5;height:2.5rem;padding:.5rem 1rem;line-height:1.5;color:#555;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;background-color:#fff;border:1px solid #ddd;border-radius:0}.custom-file-control:lang(en):after{content:"Choose file..."}.custom-file-control:before{position:absolute;top:-1px;left:-1px;bottom:-1px;z-index:6;display:block;height:2.5rem;padding:.5rem 1rem;line-height:1.5;color:#555;background-color:#eee;border:1px solid #ddd;border-radius:0 0 0 0}.custom-file-control:lang(en):before{content:"Browse"}.nav{padding-right:0;margin-bottom:0;list-style:none}.nav-link{display:inline-block}.nav-link:focus,.nav-link:hover{text-decoration:none}.nav-link.disabled{color:#f1f1f1}.nav-link.disabled,.nav-link.disabled:focus,.nav-link.disabled:hover{color:#f1f1f1;cursor:not-allowed;background-color:transparent}.nav-inline .nav-item{display:inline-block}.nav-inline .nav-item+.nav-item,.nav-inline .nav-link+.nav-link{margin-right:1rem}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs:after{content:"";display:table;clear:both}.nav-tabs .nav-item{float:right;margin-bottom:-1px}.nav-tabs .nav-item+.nav-item{margin-right:.2rem}.nav-tabs .nav-link{display:block;padding:.5em 1em;border:1px solid transparent;border-top-left-radius:0;border-top-right-radius:0}.nav-tabs .nav-link:focus,.nav-tabs .nav-link:hover{border-color:#f6f6f6 #f6f6f6 #ddd}.nav-tabs .nav-link.disabled,.nav-tabs .nav-link.disabled:focus,.nav-tabs .nav-link.disabled:hover{color:#f1f1f1;background-color:transparent;border-color:transparent}.nav-tabs .nav-item.open .nav-link,.nav-tabs .nav-item.open .nav-link:focus,.nav-tabs .nav-item.open .nav-link:hover,.nav-tabs .nav-link.active,.nav-tabs .nav-link.active:focus,.nav-tabs .nav-link.active:hover{color:#7a7a7a;background-color:#fff;border-color:#ddd #ddd transparent}.nav-tabs .dropdown-menu{margin-top:-1px;border-top-left-radius:0;border-top-right-radius:0}.nav-pills:after{content:"";display:table;clear:both}.nav-pills .nav-item{float:right}.nav-pills .nav-item+.nav-item{margin-right:.2rem}.nav-pills .nav-link{display:block;padding:.5em 1em;border-radius:0}.nav-pills .nav-item.open .nav-link,.nav-pills .nav-item.open .nav-link:focus,.nav-pills .nav-item.open .nav-link:hover,.nav-pills .nav-link.active,.nav-pills .nav-link.active:focus,.nav-pills .nav-link.active:hover{color:#fff;cursor:default;background-color:#2fb5d2}.nav-stacked .nav-item{display:block;float:none}.nav-stacked .nav-item+.nav-item{margin-top:.2rem;margin-right:0}.tab-content>.tab-pane{display:none}.tab-content>.active{display:block}.navbar{position:relative;padding:.5rem 1rem}.navbar:after{content:"";display:table;clear:both}@media (min-width:576px){.navbar{border-radius:0}}.navbar-full{z-index:1000}@media (min-width:576px){.navbar-full{border-radius:0}}.navbar-fixed-bottom,.navbar-fixed-top{position:fixed;left:0;right:0;z-index:1030}@media (min-width:576px){.navbar-fixed-bottom,.navbar-fixed-top{border-radius:0}}.navbar-fixed-top{top:0}.navbar-fixed-bottom{bottom:0}.navbar-sticky-top{position:-webkit-sticky;position:sticky;top:0;z-index:1030;width:100%}@media (min-width:576px){.navbar-sticky-top{border-radius:0}}.navbar-brand{float:right;padding-top:.25rem;padding-bottom:.25rem;margin-left:1rem;font-size:.9375rem;line-height:inherit}.navbar-brand:focus,.navbar-brand:hover{text-decoration:none}.navbar-divider{float:right;width:1px;padding-top:.425rem;padding-bottom:.425rem;margin-left:1rem;margin-right:1rem;overflow:hidden}.navbar-divider:before{content:"\A0"}.navbar-text{display:inline-block;padding-top:.425rem;padding-bottom:.425rem}.navbar-toggler{width:2.5em;height:2em;padding:.5rem .75rem;font-size:.9375rem;line-height:1;background:transparent no-repeat 50%;background-size:24px 24px;border:1px solid transparent;border-radius:0}.navbar-toggler:focus,.navbar-toggler:hover{text-decoration:none}@media (max-width:575px){.navbar-toggleable-xs .navbar-brand{display:block;float:none;margin-top:.5rem;margin-left:0}.navbar-toggleable-xs .navbar-nav{margin-top:.5rem;margin-bottom:.5rem}.navbar-toggleable-xs .navbar-nav .dropdown-menu{position:static;float:none}}@media (min-width:576px){.navbar-toggleable-xs{display:block}}@media (max-width:767px){.navbar-toggleable-sm .navbar-brand{display:block;float:none;margin-top:.5rem;margin-left:0}.navbar-toggleable-sm .navbar-nav{margin-top:.5rem;margin-bottom:.5rem}.navbar-toggleable-sm .navbar-nav .dropdown-menu{position:static;float:none}}@media (min-width:768px){.navbar-toggleable-sm{display:block}}@media (max-width:991px){.navbar-toggleable-md .navbar-brand{display:block;float:none;margin-top:.5rem;margin-left:0}.navbar-toggleable-md .navbar-nav{margin-top:.5rem;margin-bottom:.5rem}.navbar-toggleable-md .navbar-nav .dropdown-menu{position:static;float:none}}@media (min-width:992px){.navbar-toggleable-md{display:block}}.navbar-toggleable-lg:after{content:"";display:table;clear:both}@media (max-width:1199px){.navbar-toggleable-lg .navbar-brand{display:block;float:none;margin-top:.5rem;margin-left:0}.navbar-toggleable-lg .navbar-nav{margin-top:.5rem;margin-bottom:.5rem}.navbar-toggleable-lg .navbar-nav .dropdown-menu{position:static;float:none}}@media (min-width:1200px){.navbar-toggleable-lg{display:block}}.navbar-toggleable-xl{display:block}.navbar-toggleable-xl:after{content:"";display:table;clear:both}.navbar-toggleable-xl .navbar-brand{display:block;float:none;margin-top:.5rem;margin-left:0}.navbar-toggleable-xl .navbar-nav{margin-top:.5rem;margin-bottom:.5rem}.navbar-toggleable-xl .navbar-nav .dropdown-menu{position:static;float:none}.navbar-nav .nav-item{float:right}.navbar-nav .nav-link{display:block;padding-top:.425rem;padding-bottom:.425rem}.navbar-nav .nav-item+.nav-item,.navbar-nav .nav-link+.nav-link{margin-right:1rem}.navbar-light .navbar-brand,.navbar-light .navbar-brand:focus,.navbar-light .navbar-brand:hover,.navbar-light .navbar-toggler,.navbar-light .navbar-toggler:focus,.navbar-light .navbar-toggler:hover{color:rgba(0,0,0,.9)}.navbar-light .navbar-nav .nav-link{color:rgba(0,0,0,.5)}.navbar-light .navbar-nav .nav-link:focus,.navbar-light .navbar-nav .nav-link:hover{color:rgba(0,0,0,.7)}.navbar-light .navbar-nav .active>.nav-link,.navbar-light .navbar-nav .active>.nav-link:focus,.navbar-light .navbar-nav .active>.nav-link:hover,.navbar-light .navbar-nav .nav-link.active,.navbar-light .navbar-nav .nav-link.active:focus,.navbar-light .navbar-nav .nav-link.active:hover,.navbar-light .navbar-nav .nav-link.open,.navbar-light .navbar-nav .nav-link.open:focus,.navbar-light .navbar-nav .nav-link.open:hover,.navbar-light .navbar-nav .open>.nav-link,.navbar-light .navbar-nav .open>.nav-link:focus,.navbar-light .navbar-nav .open>.nav-link:hover{color:rgba(0,0,0,.9)}.navbar-light .navbar-toggler{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(0, 0, 0, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");border-color:rgba(0,0,0,.1)}.navbar-light .navbar-divider{background-color:rgba(0,0,0,.075)}.navbar-dark .navbar-brand,.navbar-dark .navbar-brand:focus,.navbar-dark .navbar-brand:hover,.navbar-dark .navbar-toggler,.navbar-dark .navbar-toggler:focus,.navbar-dark .navbar-toggler:hover{color:#fff}.navbar-dark .navbar-nav .nav-link{color:hsla(0,0%,100%,.5)}.navbar-dark .navbar-nav .nav-link:focus,.navbar-dark .navbar-nav .nav-link:hover{color:hsla(0,0%,100%,.75)}.navbar-dark .navbar-nav .active>.nav-link,.navbar-dark .navbar-nav .active>.nav-link:focus,.navbar-dark .navbar-nav .active>.nav-link:hover,.navbar-dark .navbar-nav .nav-link.active,.navbar-dark .navbar-nav .nav-link.active:focus,.navbar-dark .navbar-nav .nav-link.active:hover,.navbar-dark .navbar-nav .nav-link.open,.navbar-dark .navbar-nav .nav-link.open:focus,.navbar-dark .navbar-nav .nav-link.open:hover,.navbar-dark .navbar-nav .open>.nav-link,.navbar-dark .navbar-nav .open>.nav-link:focus,.navbar-dark .navbar-nav .open>.nav-link:hover{color:#fff}.navbar-dark .navbar-toggler{background-image:url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 32 32' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(255, 255, 255, 0.5)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 8h24M4 16h24M4 24h24'/%3E%3C/svg%3E");border-color:hsla(0,0%,100%,.1)}.navbar-dark .navbar-divider{background-color:hsla(0,0%,100%,.075)}.navbar-toggleable-xs:after{content:"";display:table;clear:both}@media (max-width:575px){.navbar-toggleable-xs .navbar-nav .nav-item{float:none;margin-right:0}}@media (min-width:576px){.navbar-toggleable-xs{display:block!important}}.navbar-toggleable-sm:after{content:"";display:table;clear:both}@media (max-width:767px){.navbar-toggleable-sm .navbar-nav .nav-item{float:none;margin-right:0}}@media (min-width:768px){.navbar-toggleable-sm{display:block!important}}.navbar-toggleable-md:after{content:"";display:table;clear:both}@media (max-width:991px){.navbar-toggleable-md .navbar-nav .nav-item{float:none;margin-right:0}}@media (min-width:992px){.navbar-toggleable-md{display:block!important}}.card{position:relative;display:block;margin-bottom:.75rem;background-color:#fff;border-radius:0;border:1px solid rgba(0,0,0,.125)}.card-block{padding:1.25rem}.card-block:after{content:"";display:table;clear:both}.card-title{margin-bottom:.75rem}.card-subtitle{margin-top:-.375rem}.card-subtitle,.card-text:last-child{margin-bottom:0}.card-link:hover{text-decoration:none}.card-link+.card-link{margin-right:1.25rem}.card>.list-group:first-child .list-group-item:first-child{border-top-left-radius:0;border-top-right-radius:0}.card>.list-group:last-child .list-group-item:last-child{border-bottom-left-radius:0;border-bottom-right-radius:0}.card-header{padding:.75rem 1.25rem;margin-bottom:0;background-color:#f5f5f5;border-bottom:1px solid rgba(0,0,0,.125)}.card-header:after{content:"";display:table;clear:both}.card-header:first-child{border-radius:-1px -1px 0 0}.card-footer{padding:.75rem 1.25rem;background-color:#f5f5f5;border-top:1px solid rgba(0,0,0,.125)}.card-footer:after{content:"";display:table;clear:both}.card-footer:last-child{border-radius:0 0 -1px -1px}.card-header-tabs{margin-bottom:-.75rem;border-bottom:0}.card-header-pills,.card-header-tabs{margin-left:-.625rem;margin-right:-.625rem}.card-primary{background-color:#2fb5d2;border-color:#2fb5d2}.card-primary .card-footer,.card-primary .card-header{background-color:transparent}.card-success{background-color:#4cbb6c;border-color:#4cbb6c}.card-success .card-footer,.card-success .card-header{background-color:transparent}.card-info{background-color:#5bc0de;border-color:#5bc0de}.card-info .card-footer,.card-info .card-header{background-color:transparent}.card-warning{background-color:#ff9a52;border-color:#ff9a52}.card-warning .card-footer,.card-warning .card-header{background-color:transparent}.card-danger{background-color:#ff4c4c;border-color:#ff4c4c}.card-danger .card-footer,.card-danger .card-header,.card-outline-primary{background-color:transparent}.card-outline-primary{border-color:#2fb5d2}.card-outline-secondary{background-color:transparent;border-color:transparent}.card-outline-info{background-color:transparent;border-color:#5bc0de}.card-outline-success{background-color:transparent;border-color:#4cbb6c}.card-outline-warning{background-color:transparent;border-color:#ff9a52}.card-outline-danger{background-color:transparent;border-color:#ff4c4c}.card-inverse .card-footer,.card-inverse .card-header{border-color:hsla(0,0%,100%,.2)}.card-inverse .card-blockquote,.card-inverse .card-footer,.card-inverse .card-header,.card-inverse .card-title{color:#fff}.card-inverse .card-blockquote .blockquote-footer,.card-inverse .card-link,.card-inverse .card-subtitle,.card-inverse .card-text{color:hsla(0,0%,100%,.65)}.card-inverse .card-link:focus,.card-inverse .card-link:hover{color:#fff}.card-blockquote{padding:0;margin-bottom:0;border-right:0}.card-img{border-radius:-1px}.card-img-overlay{position:absolute;top:0;left:0;bottom:0;right:0;padding:1.25rem}.card-img-top{border-top-left-radius:-1px;border-top-right-radius:-1px}.card-img-bottom{border-bottom-left-radius:-1px;border-bottom-right-radius:-1px}@media (min-width:576px){.card-deck{display:table;width:100%;margin-bottom:.75rem;table-layout:fixed;border-spacing:1.25rem 0}.card-deck .card{display:table-cell;margin-bottom:0;vertical-align:top}.card-deck-wrapper{margin-left:-1.25rem;margin-right:-1.25rem}}@media (min-width:576px){.card-group{display:table;width:100%;table-layout:fixed}.card-group .card{display:table-cell;vertical-align:top}.card-group .card+.card{margin-right:0;border-right:0}.card-group .card:first-child{border-bottom-left-radius:0;border-top-left-radius:0}.card-group .card:first-child .card-img-top{border-top-left-radius:0}.card-group .card:first-child .card-img-bottom{border-bottom-left-radius:0}.card-group .card:last-child{border-bottom-right-radius:0;border-top-right-radius:0}.card-group .card:last-child .card-img-top{border-top-right-radius:0}.card-group .card:last-child .card-img-bottom{border-bottom-right-radius:0}.card-group .card:not(:first-child):not(:last-child),.card-group .card:not(:first-child):not(:last-child) .card-img-bottom,.card-group .card:not(:first-child):not(:last-child) .card-img-top{border-radius:0}}@media (min-width:576px){.card-columns{-webkit-column-count:3;column-count:3;-webkit-column-gap:1.25rem;column-gap:1.25rem}.card-columns .card{display:inline-block;width:100%}}.breadcrumb{padding:.75rem 1rem;margin-bottom:1rem;list-style:none;background-color:#f6f6f6;border-radius:0}.breadcrumb:after{content:"";display:table;clear:both}.breadcrumb-item{float:right}.breadcrumb-item+.breadcrumb-item:before{display:inline-block;padding-left:.5rem;padding-right:.5rem;color:#f1f1f1;content:"/"}.breadcrumb-item+.breadcrumb-item:hover:before{text-decoration:underline;text-decoration:none}.breadcrumb-item.active{color:#f1f1f1}.pagination{display:inline-block;padding-right:0;margin-top:1rem;margin-bottom:1rem;border-radius:0}.page-item{display:inline}.page-item:first-child .page-link{margin-right:0;border-bottom-right-radius:0;border-top-right-radius:0}.page-item:last-child .page-link{border-bottom-left-radius:0;border-top-left-radius:0}.page-item.active .page-link,.page-item.active .page-link:focus,.page-item.active .page-link:hover{z-index:2;color:#fff;cursor:default;background-color:#2fb5d2;border-color:#2fb5d2}.page-item.disabled .page-link,.page-item.disabled .page-link:focus,.page-item.disabled .page-link:hover{color:#f1f1f1;pointer-events:none;cursor:not-allowed;background-color:#fff;border-color:#ddd}.page-link{position:relative;float:right;padding:.5rem .75rem;margin-right:-1px;color:#2fb5d2;text-decoration:none;background-color:#fff;border:1px solid #ddd}.page-link:focus,.page-link:hover{color:#208094;background-color:#f6f6f6;border-color:#ddd}.pagination-lg .page-link{padding:.75rem 1.5rem;font-size:.9375rem}.pagination-lg .page-item:first-child .page-link{border-bottom-right-radius:.3rem;border-top-right-radius:.3rem}.pagination-lg .page-item:last-child .page-link{border-bottom-left-radius:.3rem;border-top-left-radius:.3rem}.pagination-sm .page-link{padding:.275rem .75rem;font-size:.875rem}.pagination-sm .page-item:first-child .page-link{border-bottom-right-radius:.2rem;border-top-right-radius:.2rem}.pagination-sm .page-item:last-child .page-link{border-bottom-left-radius:.2rem;border-top-left-radius:.2rem}.tag{display:inline-block;padding:.25em .4em;font-size:75%;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:0}.tag:empty{display:none}.btn .tag{position:relative;top:-1px}a.tag:focus,a.tag:hover{color:#fff;text-decoration:none;cursor:pointer}.tag-pill{padding-left:.6em;padding-right:.6em;border-radius:10rem}.tag-default{background-color:#f1f1f1}.tag-default[href]:focus,.tag-default[href]:hover{background-color:#d8d8d8}.tag-primary{background-color:#2fb5d2}.tag-primary[href]:focus,.tag-primary[href]:hover{background-color:#2592a9}.tag-success{background-color:#4cbb6c}.tag-success[href]:focus,.tag-success[href]:hover{background-color:#3a9a56}.tag-info{background-color:#5bc0de}.tag-info[href]:focus,.tag-info[href]:hover{background-color:#31b0d5}.tag-warning{background-color:#ff9a52}.tag-warning[href]:focus,.tag-warning[href]:hover{background-color:#ff7c1f}.tag-danger{background-color:#ff4c4c}.tag-danger[href]:focus,.tag-danger[href]:hover{background-color:#ff1919}.jumbotron{padding:2rem 1rem;margin-bottom:2rem;background-color:#f6f6f6;border-radius:.3rem}@media (min-width:576px){.jumbotron{padding:4rem 2rem}}.jumbotron-hr{border-top-color:#ddd}.jumbotron-fluid{padding-left:0;padding-right:0;border-radius:0}.alert{padding:.75rem 1.25rem;margin-bottom:1rem;border:1px solid transparent;border-radius:0}.alert-heading{color:inherit}.alert-link{font-weight:700}.alert-dismissible{padding-left:2.5rem}.alert-dismissible .close{position:relative;top:-.125rem;left:-1.25rem;color:inherit}.alert-success{background-color:#dff0d8;border-color:#d0e9c6;color:#3c763d}.alert-success hr{border-top-color:#c1e2b3}.alert-success .alert-link{color:#2b542c}.alert-info{background-color:#d9edf7;border-color:#bcdff1;color:#31708f}.alert-info hr{border-top-color:#a6d5ec}.alert-info .alert-link{color:#245269}.alert-warning{background-color:rgba(255,154,82,.3);border-color:#ff9a52;color:#232323}.alert-warning hr{border-top-color:#ff8b39}.alert-warning .alert-link{color:#0a0a0a}.alert-danger{background-color:#f2dede;border-color:#ebcccc;color:#a94442}.alert-danger hr{border-top-color:#e4b9b9}.alert-danger .alert-link{color:#843534}@-webkit-keyframes progress-bar-stripes{0%{background-position:1rem 0}to{background-position:0 0}}@keyframes progress-bar-stripes{0%{background-position:1rem 0}to{background-position:0 0}}.progress{display:block;width:100%;height:1rem;margin-bottom:1rem}.progress[value]{background-color:#eee;border:0;-webkit-appearance:none;-moz-appearance:none;appearance:none;border-radius:0}.progress[value]::-ms-fill{background-color:#0074d9;border:0}.progress[value]::-moz-progress-bar{background-color:#0074d9;border-bottom-right-radius:0;border-top-right-radius:0}.progress[value]::-webkit-progress-value{background-color:#0074d9;border-bottom-right-radius:0;border-top-right-radius:0}.progress[value="100"]::-moz-progress-bar{border-bottom-left-radius:0;border-top-left-radius:0}.progress[value="100"]::-webkit-progress-value{border-bottom-left-radius:0;border-top-left-radius:0}.progress[value]::-webkit-progress-bar{background-color:#eee;border-radius:0}.progress[value],base::-moz-progress-bar{background-color:#eee;border-radius:0}@media screen and (min-width:0\0){.progress{background-color:#eee;border-radius:0}.progress-bar{display:inline-block;height:1rem;text-indent:-999rem;background-color:#0074d9;border-bottom-right-radius:0;border-top-right-radius:0}.progress[width="100%"]{border-bottom-left-radius:0;border-top-left-radius:0}}.progress-striped[value]::-webkit-progress-value{background-image:linear-gradient(45deg,hsla(0,0%,100%,.15) 25%,transparent 0,transparent 50%,hsla(0,0%,100%,.15) 0,hsla(0,0%,100%,.15) 75%,transparent 0,transparent);background-size:1rem 1rem}.progress-striped[value]::-moz-progress-bar{background-image:linear-gradient(45deg,hsla(0,0%,100%,.15) 25%,transparent 0,transparent 50%,hsla(0,0%,100%,.15) 0,hsla(0,0%,100%,.15) 75%,transparent 0,transparent);background-size:1rem 1rem}.progress-striped[value]::-ms-fill{background-image:linear-gradient(45deg,hsla(0,0%,100%,.15) 25%,transparent 0,transparent 50%,hsla(0,0%,100%,.15) 0,hsla(0,0%,100%,.15) 75%,transparent 0,transparent);background-size:1rem 1rem}@media screen and (min-width:0\0){.progress-bar-striped{background-image:linear-gradient(45deg,hsla(0,0%,100%,.15) 25%,transparent 0,transparent 50%,hsla(0,0%,100%,.15) 0,hsla(0,0%,100%,.15) 75%,transparent 0,transparent);background-size:1rem 1rem}}.progress-animated[value]::-webkit-progress-value{-webkit-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-animated[value]::-moz-progress-bar{animation:progress-bar-stripes 2s linear infinite}@media screen and (min-width:0\0){.progress-animated .progress-bar-striped{-webkit-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}}.progress-success[value]::-webkit-progress-value{background-color:#4cbb6c}.progress-success[value]::-moz-progress-bar{background-color:#4cbb6c}.progress-success[value]::-ms-fill{background-color:#4cbb6c}@media screen and (min-width:0\0){.progress-success .progress-bar{background-color:#4cbb6c}}.progress-info[value]::-webkit-progress-value{background-color:#5bc0de}.progress-info[value]::-moz-progress-bar{background-color:#5bc0de}.progress-info[value]::-ms-fill{background-color:#5bc0de}@media screen and (min-width:0\0){.progress-info .progress-bar{background-color:#5bc0de}}.progress-warning[value]::-webkit-progress-value{background-color:#ff9a52}.progress-warning[value]::-moz-progress-bar{background-color:#ff9a52}.progress-warning[value]::-ms-fill{background-color:#ff9a52}@media screen and (min-width:0\0){.progress-warning .progress-bar{background-color:#ff9a52}}.progress-danger[value]::-webkit-progress-value{background-color:#ff4c4c}.progress-danger[value]::-moz-progress-bar{background-color:#ff4c4c}.progress-danger[value]::-ms-fill{background-color:#ff4c4c}@media screen and (min-width:0\0){.progress-danger .progress-bar{background-color:#ff4c4c}}.media,.media-body{overflow:hidden}.media-body{width:10000px}.media-body,.media-left,.media-right{display:table-cell;vertical-align:top}.media-middle{vertical-align:middle}.media-bottom{vertical-align:bottom}.media-object{display:block}.media-object.img-thumbnail{max-width:none}.media-right{padding-right:10px}.media-left{padding-left:10px}.media-heading{margin-top:0;margin-bottom:5px}.media-list{padding-right:0;list-style:none}.list-group{padding-right:0;margin-bottom:0}.list-group-item{position:relative;display:block;padding:.75rem 1.25rem;margin-bottom:-1px;background-color:#fff;border:1px solid #ddd}.list-group-item:first-child{border-top-left-radius:0;border-top-right-radius:0}.list-group-item:last-child{margin-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0}.list-group-item.disabled,.list-group-item.disabled:focus,.list-group-item.disabled:hover{color:#f1f1f1;cursor:not-allowed;background-color:#f6f6f6}.list-group-item.disabled .list-group-item-heading,.list-group-item.disabled:focus .list-group-item-heading,.list-group-item.disabled:hover .list-group-item-heading{color:inherit}.list-group-item.disabled .list-group-item-text,.list-group-item.disabled:focus .list-group-item-text,.list-group-item.disabled:hover .list-group-item-text{color:#f1f1f1}.list-group-item.active,.list-group-item.active:focus,.list-group-item.active:hover{z-index:2;color:#fff;text-decoration:none;background-color:#2fb5d2;border-color:#2fb5d2}.list-group-item.active .list-group-item-heading,.list-group-item.active .list-group-item-heading>.small,.list-group-item.active .list-group-item-heading>small,.list-group-item.active:focus .list-group-item-heading,.list-group-item.active:focus .list-group-item-heading>.small,.list-group-item.active:focus .list-group-item-heading>small,.list-group-item.active:hover .list-group-item-heading,.list-group-item.active:hover .list-group-item-heading>.small,.list-group-item.active:hover .list-group-item-heading>small{color:inherit}.list-group-item.active .list-group-item-text,.list-group-item.active:focus .list-group-item-text,.list-group-item.active:hover .list-group-item-text{color:#d7f1f6}.list-group-flush .list-group-item{border-left:0;border-right:0;border-radius:0}.list-group-item-action{width:100%;color:#555;text-align:inherit}.list-group-item-action .list-group-item-heading{color:#333}.list-group-item-action:focus,.list-group-item-action:hover{color:#555;text-decoration:none;background-color:#f5f5f5}.list-group-item-success{color:#3c763d;background-color:#dff0d8}a.list-group-item-success,button.list-group-item-success{color:#3c763d}a.list-group-item-success .list-group-item-heading,button.list-group-item-success .list-group-item-heading{color:inherit}a.list-group-item-success:focus,a.list-group-item-success:hover,button.list-group-item-success:focus,button.list-group-item-success:hover{color:#3c763d;background-color:#d0e9c6}a.list-group-item-success.active,a.list-group-item-success.active:focus,a.list-group-item-success.active:hover,button.list-group-item-success.active,button.list-group-item-success.active:focus,button.list-group-item-success.active:hover{color:#fff;background-color:#3c763d;border-color:#3c763d}.list-group-item-info{color:#31708f;background-color:#d9edf7}a.list-group-item-info,button.list-group-item-info{color:#31708f}a.list-group-item-info .list-group-item-heading,button.list-group-item-info .list-group-item-heading{color:inherit}a.list-group-item-info:focus,a.list-group-item-info:hover,button.list-group-item-info:focus,button.list-group-item-info:hover{color:#31708f;background-color:#c4e3f3}a.list-group-item-info.active,a.list-group-item-info.active:focus,a.list-group-item-info.active:hover,button.list-group-item-info.active,button.list-group-item-info.active:focus,button.list-group-item-info.active:hover{color:#fff;background-color:#31708f;border-color:#31708f}.list-group-item-warning{color:#8a6d3b;background-color:#fcf8e3}a.list-group-item-warning,button.list-group-item-warning{color:#8a6d3b}a.list-group-item-warning .list-group-item-heading,button.list-group-item-warning .list-group-item-heading{color:inherit}a.list-group-item-warning:focus,a.list-group-item-warning:hover,button.list-group-item-warning:focus,button.list-group-item-warning:hover{color:#8a6d3b;background-color:#faf2cc}a.list-group-item-warning.active,a.list-group-item-warning.active:focus,a.list-group-item-warning.active:hover,button.list-group-item-warning.active,button.list-group-item-warning.active:focus,button.list-group-item-warning.active:hover{color:#fff;background-color:#8a6d3b;border-color:#8a6d3b}.list-group-item-danger{color:#a94442;background-color:#f2dede}a.list-group-item-danger,button.list-group-item-danger{color:#a94442}a.list-group-item-danger .list-group-item-heading,button.list-group-item-danger .list-group-item-heading{color:inherit}a.list-group-item-danger:focus,a.list-group-item-danger:hover,button.list-group-item-danger:focus,button.list-group-item-danger:hover{color:#a94442;background-color:#ebcccc}a.list-group-item-danger.active,a.list-group-item-danger.active:focus,a.list-group-item-danger.active:hover,button.list-group-item-danger.active,button.list-group-item-danger.active:focus,button.list-group-item-danger.active:hover{color:#fff;background-color:#a94442;border-color:#a94442}.list-group-item-heading{margin-top:0;margin-bottom:5px}.list-group-item-text{margin-bottom:0;line-height:1.3}.embed-responsive{position:relative;display:block;height:0;padding:0;overflow:hidden}.embed-responsive .embed-responsive-item,.embed-responsive embed,.embed-responsive iframe,.embed-responsive object,.embed-responsive video{position:absolute;top:0;bottom:0;right:0;width:100%;height:100%;border:0}.embed-responsive-21by9{padding-bottom:42.85714%}.embed-responsive-16by9{padding-bottom:56.25%}.embed-responsive-4by3{padding-bottom:75%}.embed-responsive-1by1{padding-bottom:100%}.close{float:left;font-size:1.5rem;font-weight:700;line-height:1;color:#000;text-shadow:0 1px 0 #fff;opacity:.2}.close:focus,.close:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.5}button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.modal,.modal-open{overflow:hidden}.modal{position:fixed;top:0;left:0;bottom:0;right:0;z-index:1050;display:none;outline:0}.modal.fade .modal-dialog{transition:-webkit-transform .3s ease-out;transition:transform .3s ease-out;transition:transform .3s ease-out,-webkit-transform .3s ease-out;-webkit-transform:translateY(-25%);transform:translateY(-25%)}.modal.in .modal-dialog{-webkit-transform:translate(0);transform:translate(0)}.modal-open .modal{overflow-x:hidden;overflow-y:auto}.modal-dialog{position:relative;width:auto;margin:10px}.modal-content{position:relative;background-color:#fff;background-clip:padding-box;border:1px solid rgba(0,0,0,.2);border-radius:.3rem;outline:0}.modal-backdrop{position:fixed;top:0;left:0;bottom:0;right:0;z-index:1040;background-color:#000}.modal-backdrop.fade{opacity:0}.modal-backdrop.in{opacity:.5}.modal-header{padding:15px;border-bottom:1px solid #e5e5e5}.modal-header:after{content:"";display:table;clear:both}.modal-header .close{margin-top:-2px}.modal-title{margin:0;line-height:1.5}.modal-body{position:relative;padding:15px}.modal-footer{padding:15px;text-align:left;border-top:1px solid #e5e5e5}.modal-footer:after{content:"";display:table;clear:both}.modal-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}@media (min-width:576px){.modal-dialog{max-width:600px;margin:30px auto}.modal-sm{max-width:300px}}@media (min-width:992px){.modal-lg{max-width:900px}}.tooltip{position:absolute;z-index:1070;display:block;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-style:normal;font-weight:400;letter-spacing:normal;line-break:auto;line-height:1.5;text-align:right;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;white-space:normal;word-break:normal;word-spacing:normal;font-size:.875rem;word-wrap:break-word;opacity:0}.tooltip.in{opacity:.9}.tooltip.bs-tether-element-attached-bottom,.tooltip.tooltip-top{padding:5px 0;margin-top:-3px}.tooltip.bs-tether-element-attached-bottom .tooltip-inner:before,.tooltip.tooltip-top .tooltip-inner:before{bottom:0;right:50%;margin-right:-5px;content:"";border-width:5px 5px 0;border-top-color:#ff4c4c}.tooltip.bs-tether-element-attached-left,.tooltip.tooltip-right{padding:0 5px;margin-right:3px}.tooltip.bs-tether-element-attached-left .tooltip-inner:before,.tooltip.tooltip-right .tooltip-inner:before{top:50%;right:0;margin-top:-5px;content:"";border-width:5px 0 5px 5px;border-left-color:#ff4c4c}.tooltip.bs-tether-element-attached-top,.tooltip.tooltip-bottom{padding:5px 0;margin-top:3px}.tooltip.bs-tether-element-attached-top .tooltip-inner:before,.tooltip.tooltip-bottom .tooltip-inner:before{top:0;right:50%;margin-right:-5px;content:"";border-width:0 5px 5px;border-bottom-color:#ff4c4c}.tooltip.bs-tether-element-attached-right,.tooltip.tooltip-left{padding:0 5px;margin-right:-3px}.tooltip.bs-tether-element-attached-right .tooltip-inner:before,.tooltip.tooltip-left .tooltip-inner:before{top:50%;left:0;margin-top:-5px;content:"";border-width:5px 5px 5px 0;border-right-color:#ff4c4c}.tooltip-inner{max-width:200px;padding:3px 8px;color:#fff;text-align:center;background-color:#ff4c4c;border-radius:0}.tooltip-inner:before{position:absolute;width:0;height:0;border-color:transparent;border-style:solid}.popover{position:absolute;top:0;right:0;z-index:1060;display:block;max-width:276px;padding:1px;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;font-style:normal;font-weight:400;letter-spacing:normal;line-break:auto;line-height:1.5;text-align:right;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;white-space:normal;word-break:normal;word-spacing:normal;font-size:.875rem;word-wrap:break-word;background-color:#fff;background-clip:padding-box;border:1px solid rgba(0,0,0,.2);border-radius:.3rem}.popover.bs-tether-element-attached-bottom,.popover.popover-top{margin-top:-10px}.popover.bs-tether-element-attached-bottom:after,.popover.bs-tether-element-attached-bottom:before,.popover.popover-top:after,.popover.popover-top:before{right:50%;border-bottom-width:0}.popover.bs-tether-element-attached-bottom:before,.popover.popover-top:before{bottom:-11px;margin-right:-11px;border-top-color:rgba(0,0,0,.25)}.popover.bs-tether-element-attached-bottom:after,.popover.popover-top:after{bottom:-10px;margin-right:-10px;border-top-color:#fff}.popover.bs-tether-element-attached-left,.popover.popover-right{margin-right:10px}.popover.bs-tether-element-attached-left:after,.popover.bs-tether-element-attached-left:before,.popover.popover-right:after,.popover.popover-right:before{top:50%;border-right-width:0}.popover.bs-tether-element-attached-left:before,.popover.popover-right:before{right:-11px;margin-top:-11px;border-left-color:rgba(0,0,0,.25)}.popover.bs-tether-element-attached-left:after,.popover.popover-right:after{right:-10px;margin-top:-10px;border-left-color:#fff}.popover.bs-tether-element-attached-top,.popover.popover-bottom{margin-top:10px}.popover.bs-tether-element-attached-top:after,.popover.bs-tether-element-attached-top:before,.popover.popover-bottom:after,.popover.popover-bottom:before{right:50%;border-top-width:0}.popover.bs-tether-element-attached-top:before,.popover.popover-bottom:before{top:-11px;margin-right:-11px;border-bottom-color:rgba(0,0,0,.25)}.popover.bs-tether-element-attached-top:after,.popover.popover-bottom:after{top:-10px;margin-right:-10px;border-bottom-color:#f7f7f7}.popover.bs-tether-element-attached-top .popover-title:before,.popover.popover-bottom .popover-title:before{position:absolute;top:0;right:50%;display:block;width:20px;margin-right:-10px;content:"";border-bottom:1px solid #f7f7f7}.popover.bs-tether-element-attached-right,.popover.popover-left{margin-right:-10px}.popover.bs-tether-element-attached-right:after,.popover.bs-tether-element-attached-right:before,.popover.popover-left:after,.popover.popover-left:before{top:50%;border-left-width:0}.popover.bs-tether-element-attached-right:before,.popover.popover-left:before{left:-11px;margin-top:-11px;border-right-color:rgba(0,0,0,.25)}.popover.bs-tether-element-attached-right:after,.popover.popover-left:after{left:-10px;margin-top:-10px;border-right-color:#fff}.popover-title{padding:8px 14px;margin:0;font-size:1rem;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;border-radius:.2375rem .2375rem 0 0}.popover-title:empty{display:none}.popover-content{padding:9px 14px}.popover:after,.popover:before{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.popover:before{content:"";border-width:11px}.popover:after{content:"";border-width:10px}.carousel,.carousel-inner{position:relative}.carousel-inner{width:100%;overflow:hidden}.carousel-inner>.carousel-item{position:relative;display:none;transition:right .6s ease-in-out}.carousel-inner>.carousel-item>a>img,.carousel-inner>.carousel-item>img{line-height:1}@media (-webkit-transform-3d),(transform-3d){.carousel-inner>.carousel-item{transition:-webkit-transform .6s ease-in-out;transition:transform .6s ease-in-out;transition:transform .6s ease-in-out,-webkit-transform .6s ease-in-out;-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-perspective:1000px;perspective:1000px}.carousel-inner>.carousel-item.active.right,.carousel-inner>.carousel-item.next{right:0;-webkit-transform:translate3d(100%,0,0);transform:translate3d(100%,0,0)}.carousel-inner>.carousel-item.active.left,.carousel-inner>.carousel-item.prev{right:0;-webkit-transform:translate3d(-100%,0,0);transform:translate3d(-100%,0,0)}.carousel-inner>.carousel-item.active,.carousel-inner>.carousel-item.next.left,.carousel-inner>.carousel-item.prev.right{right:0;-webkit-transform:translateZ(0);transform:translateZ(0)}}.carousel-inner>.active,.carousel-inner>.next,.carousel-inner>.prev{display:block}.carousel-inner>.active{right:0}.carousel-inner>.next,.carousel-inner>.prev{position:absolute;top:0;width:100%}.carousel-inner>.next{right:100%}.carousel-inner>.prev{right:-100%}.carousel-inner>.next.left,.carousel-inner>.prev.right{right:0}.carousel-inner>.active.left{right:-100%}.carousel-inner>.active.right{right:100%}.carousel-control{position:absolute;top:0;bottom:0;right:0;width:15%;font-size:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,.6);opacity:.5}.carousel-control.left{background-image:linear-gradient(90deg,rgba(0,0,0,.5) 0,rgba(0,0,0,.0001));background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#80000000",endColorstr="#00000000",GradientType=1)}.carousel-control.right{left:0;right:auto;background-image:linear-gradient(90deg,rgba(0,0,0,.0001) 0,rgba(0,0,0,.5));background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr="#00000000",endColorstr="#80000000",GradientType=1)}.carousel-control:focus,.carousel-control:hover{color:#fff;text-decoration:none;outline:0;opacity:.9}.carousel-control .icon-next,.carousel-control .icon-prev{position:absolute;top:50%;z-index:5;display:inline-block;width:20px;height:20px;margin-top:-10px;font-family:serif;line-height:1}.carousel-control .icon-prev{right:50%;margin-right:-10px}.carousel-control .icon-next{left:50%;margin-left:-10px}.carousel-control .icon-prev:before{content:"\2039"}.carousel-control .icon-next:before{content:"\203A"}.carousel-indicators{position:absolute;bottom:10px;right:50%;z-index:15;width:60%;padding-right:0;margin-right:-30%;text-align:center;list-style:none}.carousel-indicators li{display:inline-block;width:10px;height:10px;margin:1px;text-indent:-999px;cursor:pointer;background-color:transparent;border:1px solid #fff;border-radius:10px}.carousel-indicators .active{width:12px;height:12px;margin:0;background-color:#fff}.carousel-caption{position:absolute;left:15%;bottom:20px;right:15%;z-index:10;padding-top:20px;padding-bottom:20px;color:#fff;text-align:center;text-shadow:0 1px 2px rgba(0,0,0,.6)}.carousel-caption .btn{text-shadow:none}@media (min-width:576px){.carousel-control .icon-next,.carousel-control .icon-prev{width:30px;height:30px;margin-top:-15px;font-size:30px}.carousel-control .icon-prev{margin-right:-15px}.carousel-control .icon-next{margin-left:-15px}.carousel-caption{left:20%;right:20%;padding-bottom:30px}.carousel-indicators{bottom:20px}}.align-baseline{vertical-align:baseline!important}.align-top{vertical-align:top!important}.align-middle{vertical-align:middle!important}.align-bottom{vertical-align:bottom!important}.align-text-bottom{vertical-align:text-bottom!important}.align-text-top{vertical-align:text-top!important}.bg-faded{background-color:#f7f7f9}.bg-primary{background-color:#2fb5d2!important}a.bg-primary:focus,a.bg-primary:hover{background-color:#2592a9!important}.bg-success{background-color:#4cbb6c!important}a.bg-success:focus,a.bg-success:hover{background-color:#3a9a56!important}.bg-info{background-color:#5bc0de!important}a.bg-info:focus,a.bg-info:hover{background-color:#31b0d5!important}.bg-warning{background-color:#ff9a52!important}a.bg-warning:focus,a.bg-warning:hover{background-color:#ff7c1f!important}.bg-danger{background-color:#ff4c4c!important}a.bg-danger:focus,a.bg-danger:hover{background-color:#ff1919!important}.bg-inverse{background-color:#363a42!important}a.bg-inverse:focus,a.bg-inverse:hover{background-color:#1f2126!important}.rounded{border-radius:0}.rounded-top{border-top-left-radius:0;border-top-right-radius:0}.rounded-right{border-bottom-left-radius:0;border-top-left-radius:0}.rounded-bottom{border-bottom-left-radius:0;border-bottom-right-radius:0}.rounded-left{border-bottom-right-radius:0;border-top-right-radius:0}.rounded-circle{border-radius:50%}.clearfix:after{content:"";display:table;clear:both}.d-block{display:block!important}.d-inline-block{display:inline-block!important}.d-inline{display:inline!important}.float-xs-left{float:right!important}.float-xs-right{float:left!important}.float-xs-none{float:none!important}@media (min-width:576px){.float-sm-left{float:right!important}.float-sm-right{float:left!important}.float-sm-none{float:none!important}}@media (min-width:768px){.float-md-left{float:right!important}.float-md-right{float:left!important}.float-md-none{float:none!important}}@media (min-width:992px){.float-lg-left{float:right!important}.float-lg-right{float:left!important}.float-lg-none{float:none!important}}@media (min-width:1200px){.float-xl-left{float:right!important}.float-xl-right{float:left!important}.float-xl-none{float:none!important}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}.w-100{width:100%!important}.h-100{height:100%!important}.mx-auto{margin-left:auto!important;margin-right:auto!important}.m-0{margin:0!important}.mt-0{margin-top:0!important}.mr-0{margin-left:0!important}.mb-0{margin-bottom:0!important}.ml-0,.mx-0{margin-right:0!important}.mx-0{margin-left:0!important}.my-0{margin-top:0!important;margin-bottom:0!important}.m-1{margin:1rem!important}.mt-1{margin-top:1rem!important}.mr-1{margin-left:1rem!important}.mb-1{margin-bottom:1rem!important}.ml-1,.mx-1{margin-right:1rem!important}.mx-1{margin-left:1rem!important}.my-1{margin-top:1rem!important;margin-bottom:1rem!important}.m-2{margin:1.5rem!important}.mt-2{margin-top:1.5rem!important}.mr-2{margin-left:1.5rem!important}.mb-2{margin-bottom:1.5rem!important}.ml-2,.mx-2{margin-right:1.5rem!important}.mx-2{margin-left:1.5rem!important}.my-2{margin-top:1.5rem!important;margin-bottom:1.5rem!important}.m-3{margin:3rem!important}.mt-3{margin-top:3rem!important}.mr-3{margin-left:3rem!important}.mb-3{margin-bottom:3rem!important}.ml-3,.mx-3{margin-right:3rem!important}.mx-3{margin-left:3rem!important}.my-3{margin-top:3rem!important;margin-bottom:3rem!important}.p-0{padding:0!important}.pt-0{padding-top:0!important}.pr-0{padding-left:0!important}.pb-0{padding-bottom:0!important}.pl-0,.px-0{padding-right:0!important}.px-0{padding-left:0!important}.py-0{padding-top:0!important;padding-bottom:0!important}.p-1{padding:1rem!important}.pt-1{padding-top:1rem!important}.pr-1{padding-left:1rem!important}.pb-1{padding-bottom:1rem!important}.pl-1,.px-1{padding-right:1rem!important}.px-1{padding-left:1rem!important}.py-1{padding-top:1rem!important;padding-bottom:1rem!important}.p-2{padding:1.5rem!important}.pt-2{padding-top:1.5rem!important}.pr-2{padding-left:1.5rem!important}.pb-2{padding-bottom:1.5rem!important}.pl-2,.px-2{padding-right:1.5rem!important}.px-2{padding-left:1.5rem!important}.py-2{padding-top:1.5rem!important;padding-bottom:1.5rem!important}.p-3{padding:3rem!important}.pt-3{padding-top:3rem!important}.pr-3{padding-left:3rem!important}.pb-3{padding-bottom:3rem!important}.pl-3,.px-3{padding-right:3rem!important}.px-3{padding-left:3rem!important}.py-3{padding-top:3rem!important;padding-bottom:3rem!important}.pos-f-t{position:fixed;top:0;left:0;right:0;z-index:1030}.text-justify{text-align:justify!important}.text-nowrap{white-space:nowrap!important}.text-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.text-xs-left{text-align:right!important}.text-xs-right{text-align:left!important}.text-xs-center{text-align:center!important}@media (min-width:576px){.text-sm-left{text-align:right!important}.text-sm-right{text-align:left!important}.text-sm-center{text-align:center!important}}@media (min-width:768px){.text-md-left{text-align:right!important}.text-md-right{text-align:left!important}.text-md-center{text-align:center!important}}@media (min-width:992px){.text-lg-left{text-align:right!important}.text-lg-right{text-align:left!important}.text-lg-center{text-align:center!important}}@media (min-width:1200px){.text-xl-left{text-align:right!important}.text-xl-right{text-align:left!important}.text-xl-center{text-align:center!important}}.text-lowercase{text-transform:lowercase!important}.text-uppercase{text-transform:uppercase!important}.text-capitalize{text-transform:capitalize!important}.font-weight-normal{font-weight:400}.font-weight-bold{font-weight:700}.font-italic{font-style:italic}.text-white{color:#fff!important}.text-muted{color:#7a7a7a!important}a.text-muted:focus,a.text-muted:hover{color:#616161!important}.text-primary{color:#2fb5d2!important}a.text-primary:focus,a.text-primary:hover{color:#2592a9!important}.text-success{color:#4cbb6c!important}a.text-success:focus,a.text-success:hover{color:#3a9a56!important}.text-info{color:#5bc0de!important}a.text-info:focus,a.text-info:hover{color:#31b0d5!important}.text-warning{color:#ff9a52!important}a.text-warning:focus,a.text-warning:hover{color:#ff7c1f!important}.text-danger{color:#ff4c4c!important}a.text-danger:focus,a.text-danger:hover{color:#ff1919!important}.text-gray-dark{color:#363a42!important}a.text-gray-dark:focus,a.text-gray-dark:hover{color:#1f2126!important}.text-hide{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.invisible{visibility:hidden!important}.hidden-xs-up{display:none!important}@media (max-width:575px){.hidden-xs-down{display:none!important}}@media (min-width:576px){.hidden-sm-up{display:none!important}}@media (max-width:767px){.hidden-sm-down{display:none!important}}@media (min-width:768px){.hidden-md-up{display:none!important}}@media (max-width:991px){.hidden-md-down{display:none!important}}@media (min-width:992px){.hidden-lg-up{display:none!important}}@media (max-width:1199px){.hidden-lg-down{display:none!important}}@media (min-width:1200px){.hidden-xl-up{display:none!important}}.hidden-xl-down,.visible-print-block{display:none!important}@media print{.visible-print-block{display:block!important}}.visible-print-inline{display:none!important}@media print{.visible-print-inline{display:inline!important}}.visible-print-inline-block{display:none!important}@media print{.visible-print-inline-block{display:inline-block!important}}@media print{.hidden-print{display:none!important}}@font-face{font-family:Noto Sans;src:url(../css/3d4a907b1b7a232654324a3dd7ae4aa3.eot);src:local("Noto Sans Regular"),local("NotoSans-Regular"),url(../css/3d4a907b1b7a232654324a3dd7ae4aa3.eot) format("embedded-opentype"),url(../css/19c1b868764c0e4d15a45d3f61250488.woff2) format("woff2"),url(../css/846c191efd3d0aacde5a916cf2ebf1a4.woff) format("woff"),url(../css/2fd9c16b805724d590c0cff96da070a4.ttf) format("truetype"),url(../css/5ea9fdf2293930126fa9c544968009ae.svg) format("svg");font-weight:400;font-style:normal}@font-face{font-family:Noto Sans;src:url(../css/eeb9224f85430652fd070e4e64129aa4.eot);src:local("Noto Sans Bold"),local("NotoSans-Bold"),url(../css/eeb9224f85430652fd070e4e64129aa4.eot) format("embedded-opentype"),url(../css/199038f07312bfc6f0aabd3ed6a2b64d.woff2) format("woff2"),url(../css/c2183257e7a697769df4200c547551f1.woff) format("woff"),url(../css/a165a42685795361b25593effb32fdb1.ttf) format("truetype"),url(../css/5dc400bcedda37b13f35cb44623193cf.svg) format("svg");font-weight:700;font-style:normal}@font-face{font-family:Noto Sans;src:url(../css/a77ade19de3d3762dfbf1fe553b293cc.eot);src:local("Noto Sans Italic"),local("NotoSans-Italic"),url(../css/a77ade19de3d3762dfbf1fe553b293cc.eot) format("embedded-opentype"),url(../css/7a3ebca0cba2e2c6090e84e1d77e0f94.woff2) format("woff2"),url(../css/332f555bb44cdc394d6c799df0c03389.woff) format("woff"),url(../css/154da4697acc779b55af0a67f1241e4e.ttf) format("truetype"),url(../css/3d34be670a7f15086e512282b97ae35e.svg) format("svg");font-weight:400;font-style:italic}@font-face{font-family:Noto Sans;src:url(../css/b467416c449eb823029e16347b2ea510.eot);src:local("Noto Sans BoldItalic"),local("NotoSans-BoldItalic"),url(../css/b467416c449eb823029e16347b2ea510.eot) format("embedded-opentype"),url(../css/a68cfe9d548950edf5df102269877edd.woff2) format("woff2"),url(../css/3f81521029cc8a9a703419c4a74704a0.woff) format("woff"),url(../css/4f6ff3639c1e5728b905b650c1a06e75.ttf) format("truetype"),url(../css/80e74ff9406650e53bbec1e292c2c094.svg) format("svg");font-weight:700;font-style:italic}@font-face{font-family:Material Icons;font-style:normal;font-weight:400;src:url(../css/e79bfd88537def476913f3ed52f4f4b3.eot);src:local("Material Icons"),local("MaterialIcons-Regular"),url(../css/570eb83859dc23dd0eec423a49e147fe.woff2) format("woff2"),url(../css/012cf6a10129e2275d79d6adac7f3b02.woff) format("woff"),url(../css/a37b0c01c0baf1888ca812cc0508f6e2.ttf) format("truetype")}.material-icons{font-family:Material Icons;font-weight:400;font-style:normal;font-size:24px;display:inline-block;vertical-align:middle;width:1em;height:1em;line-height:1;text-transform:none;letter-spacing:normal;word-wrap:normal;white-space:nowrap;direction:rtl;-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;-moz-osx-font-smoothing:grayscale;-webkit-font-feature-settings:"liga";font-feature-settings:"liga"}body,html{height:100%}body{direction:rtl;font-family:Noto Sans,sans-serif;font-size:1rem;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;color:#232323;line-height:1.25em}ul{list-style:none;padding-right:0}a:hover{color:#2fb5d2;text-decoration:none}p{font-size:.9375rem;color:#7a7a7a;font-weight:400}.color,.custom-checkbox input[type=checkbox]+span.color{width:1.25rem;height:1.25rem;display:inline-block;margin:.3125rem;box-shadow:-2px 2px 4px 0 rgba(0,0,0,.2);border:1px solid rgba(0,0,0,.05);cursor:pointer;background-size:contain}.color.active,.color:hover,.custom-checkbox input[type=checkbox]+span.color.active,.custom-checkbox input[type=checkbox]+span.color:hover,.facet-label.active .custom-checkbox span.color,.facet-label:hover .custom-checkbox span.color{border:2px solid #232323}.h1,.h2,.h3{text-transform:uppercase;color:#232323}.h4{font-weight:700;color:#232323}.btn-primary,.btn-secondary,.btn-tertiary{box-shadow:-2px 2px 4px 0 rgba(0,0,0,.2);text-transform:uppercase;font-weight:600;padding:.5rem 1.25rem}.btn-primary .material-icons,.btn-secondary .material-icons,.btn-tertiary .material-icons{margin-left:.625rem}.btn-tertiary{background-color:#f7f7f7;text-transform:lowercase;color:#7a7a7a;box-shadow:-.0625rem .0625rem .0625rem 0 rgba(0,0,0,.1);padding:.25rem;margin:.25rem 0;font-weight:400;font-size:.875rem}.btn-tertiary .material-icons{font-size:1rem}.btn-tertiary:hover{box-shadow:-.0625rem .0625rem .0625rem 0 rgba(0,0,0,.2);border:1px solid rgba(35,35,35,.2)}.btn-unstyle{background-color:transparent;border:none;padding:0;text-align:inherit}.btn-unstyle:focus{outline:0}.btn-unstyle:focus .expand-more{color:#2fb5d2}.card{box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2)}.label,label{color:#232323;text-align:left;font-size:.875rem}small.label,small.value{font-size:.8125rem}.form-control-label{padding-top:.625rem}.form-control{background:#f1f1f1;color:#7a7a7a;border:1px solid rgba(0,0,0,.25);padding:.5rem 1rem}.form-control:focus{background-color:#fff;color:#232323}.form-control:focus,.input-group.focus{outline:.1875rem solid #2fb5d2}.input-group .form-control:focus{outline:none}.input-group .input-group-btn{height:100%}.input-group .input-group-btn>.btn{border:0;box-shadow:none;color:#fff;font-size:.6875rem;font-weight:400;margin-right:0;padding:.625rem 1rem;text-transform:uppercase}.input-group .input-group-btn>.btn[data-action=show-password]{background:#7a7a7a;padding:.78rem 1rem}input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{color:#7a7a7a}input::-moz-placeholder,textarea::-moz-placeholder{color:#7a7a7a}input:-ms-input-placeholder,textarea:-ms-input-placeholder{color:#7a7a7a}input:-moz-placeholder,textarea:-moz-placeholder{color:#7a7a7a}input:active::-webkit-input-placeholder,textarea:active::-webkit-input-placeholder{color:#232323}input:active::-moz-placeholder,textarea:active::-moz-placeholder{color:#232323}input:active:-ms-input-placeholder,textarea:active:-ms-input-placeholder{color:#232323}input:active:-moz-placeholder,textarea:active:-moz-placeholder{color:#232323}.form-control-select{height:2.625rem;-moz-appearance:none;-webkit-appearance:none;background:#f1f1f1 url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAQAAAD9CzEMAAAAPklEQVR4Ae3TwREAEBQD0V/6do4SXPZg7EsBhsQ8IEmSMOsiuEfg3gL3oXC7wK0bd1G4o8X9F4yIkyQfSrIByQBjp7QuND8AAAAASUVORK5CYII=") no-repeat scroll left .5rem center/1.25rem 1.25rem;padding:0 .5rem}.form-control-valign{padding-top:.5rem}.form-control-comment{font-size:.875rem;padding-top:.5rem;color:#7a7a7a}.form-control-submit.disabled{background:#5bc0de;color:#fff}.form-group.has-error input,.form-group.has-error select{outline:.1875rem solid #ff4c4c}.form-group.has-error .help-block{color:#ff4c4c}.group-span-filestyle label{margin:0}.bootstrap-touchspin .group-span-filestyle .btn-touchspin,.group-span-filestyle .bootstrap-touchspin .btn-touchspin,.group-span-filestyle .btn-default{background:#2fb5d2;color:#fff;text-transform:uppercase;border-radius:0;font-size:.875rem;padding:.5rem 1rem}.bootstrap-touchspin{width:auto;float:right;display:inline-block;box-shadow:-2px 2px 4px 0 rgba(0,0,0,.2)}.bootstrap-touchspin input:focus{outline:none}.bootstrap-touchspin input.form-control,.bootstrap-touchspin input.input-group{color:#232323;background-color:#fff;height:2.5rem;padding:.175rem .5rem;width:3rem;border:1px solid rgba(0,0,0,.25);float:right}.bootstrap-touchspin .btn-touchspin{background-color:#fff;border:1px solid rgba(0,0,0,.25);height:1.3125rem}.bootstrap-touchspin .btn-touchspin:hover{background-color:#f1f1f1}.bootstrap-touchspin .input-group-btn-vertical{color:#232323;width:auto;float:right}.bootstrap-touchspin .input-group-btn-vertical .bootstrap-touchspin-down,.bootstrap-touchspin .input-group-btn-vertical .bootstrap-touchspin-up{border-radius:0}.bootstrap-touchspin .input-group-btn-vertical .touchspin-up:after{content:"\E5CE"}.bootstrap-touchspin .input-group-btn-vertical .touchspin-down:after{content:"\E5CF"}.bootstrap-touchspin .input-group-btn-vertical i{top:.0625rem;right:.1875rem;font-size:.9375rem}.custom-radio{display:inline-block;position:relative;width:20px;height:20px;vertical-align:middle;cursor:pointer;border-radius:50%;border:2px solid #7a7a7a;background:#fff;margin-left:1.25rem}.custom-radio input[type=radio]{opacity:0;cursor:pointer}.custom-radio input[type=radio]:checked+span{display:block;background-color:#2fb5d2;width:12px;height:12px;border-radius:50%;position:absolute;right:.125rem;top:.125rem}.custom-radio input[type=radio]:focus+span{border-color:#7a7a7a}.custom-checkbox{position:relative}.custom-checkbox input[type=checkbox]{margin-top:.25rem;opacity:0;cursor:pointer;position:absolute}.custom-checkbox input[type=checkbox]+span{margin-left:3px;display:inline-block;width:.9375rem;height:.9375rem;vertical-align:middle;cursor:pointer;border:2px solid #232323}.custom-checkbox input[type=checkbox]+span .checkbox-checked{display:none;margin:-.25rem -.125rem;font-size:1.1rem;color:#232323}.custom-checkbox input[type=checkbox]:checked+span .checkbox-checked{display:block}.custom-checkbox input[type=checkbox]:focus+span{border-color:#7a7a7a}.custom-checkbox label{text-align:right}.text-muted{font-size:.875rem}.done{color:#4cbb6c;display:inline-block;padding:0 .8125rem;margin-left:1.563rem}.thumb-mask>.mask{position:relative;width:3.438rem;height:3.438rem;overflow:hidden;border:1px solid #f1f1f1;margin:.625rem 0}.thumb-mask>.mask img{width:55px;height:55px}.definition-list dl{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap}.definition-list dl dt{font-weight:400}.definition-list dl dd,.definition-list dl dt{-webkit-box-flex:0;-ms-flex:0 0 45%;flex:0 0 45%;background:#f1f1f1;padding:.625rem;margin:.125rem}.definition-list dl dd:nth-of-type(2n),.definition-list dl dt:nth-of-type(2n){background:#f6f6f6}.help-block{margin-top:.625rem}.btn.disabled,.btn.disabled:hover{background:#7a7a7a}.alert-warning .material-icons{color:#ff9a52;font-size:2rem;margin-left:.625rem;padding-top:.3125rem}.alert-warning .alert-text{font-size:.9375rem;padding-top:.625rem}.alert-warning .alert-link{border-radius:2px;border-width:2px;margin-right:.625rem;padding:.3125rem 1.25rem;font-weight:600;font-size:.8125rem;color:#6c868e}.alert-warning ul li:last-child .alert-link{color:#fff}.alert-warning .warning-buttons{margin-top:.3125rem}.btn-tertiary-outline{color:#6c868e;background-image:none;background-color:transparent;border-color:#6c868e;border:.15rem solid #6c868e}.btn-tertiary-outline:hover{border-color:#bbcdd2;color:#bbcdd2}.alert{font-size:.8125rem}.nav-item .nav-link,.nav-item .nav-separtor{color:#7a7a7a;font-weight:700}.nav-item .nav-link.active,.nav-item .nav-separtor.active{color:#232323}.separator{margin:0;border-color:rgba(0,0,0,.25)}.modal-dialog-centered{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;min-height:calc(100% - 60px)}.ps-alert-error{margin-bottom:0}.ps-alert-error .item,.ps-alert-success .item{-webkit-box-align:center;-ms-flex-align:center;align-items:center;border:2px solid #ff4c4c;display:-webkit-box;display:-ms-flexbox;display:flex;background-color:#ff4c4c;margin-bottom:1rem}.ps-alert-error .item i,.ps-alert-success .item i{border:15px solid #ff4c4c;display:-webkit-box;display:-ms-flexbox;display:flex}.ps-alert-error .item i svg,.ps-alert-success .item i svg{background-color:#ff4c4c;width:24px;height:24px}.ps-alert-error .item p,.ps-alert-success .item p{background-color:#fff;margin:0;padding:18px 20px;width:100%}.ps-alert-success{padding:.25rem .25rem 2.75rem}.ps-alert-success .item{border-color:#4cbb6c;background-color:#4cbb6c}.ps-alert-success .item i{border-color:#4cbb6c}.ps-alert-success .item i svg{background-color:#4cbb6c}.dropdown{color:#7a7a7a}.dropdown:hover .expand-more{color:#2fb5d2}.dropdown .expand-more{color:#232323;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.dropdown .active{max-height:200px;overflow-y:hidden;visibility:visible}.dropdown select{-moz-appearance:none;border:0 none;outline:0 none;color:#232323;background:#fff}.dropdown-item:focus,.dropdown-item:hover{background:none;text-decoration:none;color:#2fb5d2}.search-widget{display:inline-block}.search-widget form{position:relative}.search-widget form input[type=text]{border:none;padding:10px;min-width:255px;color:#7a7a7a;border:1px solid rgba(0,0,0,.25)}.search-widget form input[type=text]:focus{outline:3px solid #2fb5d2;color:#232323;background:#fff}.search-widget form input[type=text]:focus+button .search{color:#2fb5d2}.search-widget form button[type=submit]{position:absolute;background:none;border:none;bottom:.3125rem;left:.125rem;color:#7a7a7a}.search-widget form button[type=submit] .search:hover{color:#2fb5d2}.header-top .search-widget form input[type=text]{min-width:inherit;width:100%}#checkout #search_widget{display:none}#pagenotfound .page-content #search_widget{width:100%}.page-not-found .search-widget form{display:inline-block}@media (max-width:767px){.header-top .search-widget{float:none}.header-top .search-widget form{margin:0 auto}.header-top .search-widget form input[type=text]{min-width:inherit;background:#fff}}@media (min-width:768px){.search-widget{min-width:15.63rem}}.top-menu[data-depth="1"]{margin:.625rem}.top-menu a:not([data-depth="0"]){display:block;padding:.625rem;color:#7a7a7a;font-weight:400}.top-menu a.dropdown-submenu{color:#232323;text-transform:uppercase;font-weight:600}.top-menu a[data-depth="0"]{font-weight:600;padding:.1875rem .625rem .375rem}#header .top-menu a[data-depth="0"]:hover{color:#2fb5d2;text-decoration:none}.top-menu a[data-depth="1"],.top-menu a[data-depth="2"]{padding:0 0 .625rem .625rem}.top-menu .collapse{display:inherit}.top-menu .sub-menu{box-shadow:-2px 1px 11px 2px rgba(0,0,0,.1);border:none;margin-right:.9375rem;width:calc(100% - 30px);min-width:calc(100% - 30px);z-index:18;display:none}.top-menu .sub-menu.collapse{display:none}.top-menu .sub-menu ul[data-depth="1"]>li{float:right;margin:0 1.25rem}.top-menu .sub-menu a:hover{color:#2fb5d2}.top-menu .popover{max-width:inherit;border-radius:0}.popover.bs-tether-element-attached-top{margin-top:0}#_desktop_top_menu .top-menu[data-depth="0"] li:hover .sub-menu{display:block!important}#mobile_top_menu_wrapper{padding:15px;background:#fff}#mobile_top_menu_wrapper #top-menu{margin-bottom:.625rem}#mobile_top_menu_wrapper .top-menu{color:#232323}#mobile_top_menu_wrapper .top-menu .collapse-icons[aria-expanded=true] .add{display:none}#mobile_top_menu_wrapper .top-menu .collapse-icons[aria-expanded=true] .remove{display:block}#mobile_top_menu_wrapper .top-menu .collapse-icons .remove{display:none}#mobile_top_menu_wrapper .top-menu .navbar-toggler{display:inline-block;padding:0}#mobile_top_menu_wrapper .top-menu a[data-depth="0"]{padding:.625rem;border-bottom:1px solid #f6f6f6}#mobile_top_menu_wrapper .top-menu .collapse{display:none}#mobile_top_menu_wrapper .top-menu .collapse.in{display:block}#mobile_top_menu_wrapper .top-menu .sub-menu{box-shadow:none;z-index:inherit;display:block;position:static;overflow:hidden;margin-right:0;width:100%;min-width:100%;background:#fff}#mobile_top_menu_wrapper .top-menu .sub-menu.collapse{display:none}#mobile_top_menu_wrapper .top-menu .sub-menu.collapse.in{display:block}#mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="0"]>li{border-bottom:1px solid #7a7a7a}#mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="1"]{margin:0}#mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="1"]>li{float:none;margin:0}#mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="1"]>li a{text-transform:none}#mobile_top_menu_wrapper .top-menu .sub-menu ul{padding:0}#mobile_top_menu_wrapper .top-menu .sub-menu li>a{padding:.625rem;border-bottom:1px solid #fff;font-weight:700}#mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="2"] li a{padding-right:1.25rem}#mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="3"] li a{padding-right:2.5rem}#mobile_top_menu_wrapper .top-menu .sub-menu ul[data-depth="4"] li a{padding-right:3.75rem}#mobile_top_menu_wrapper .js-top-menu-bottom a{color:#7a7a7a}#mobile_top_menu_wrapper .js-top-menu-bottom .language-selector-wrapper{padding:.625rem}#mobile_top_menu_wrapper .js-top-menu-bottom .language-selector-wrapper .language-selector{display:inline}#mobile_top_menu_wrapper .js-top-menu-bottom #contact-link,#mobile_top_menu_wrapper .js-top-menu-bottom .currency-selector{padding:.625rem}#mobile_top_menu_wrapper .js-top-menu-bottom .user-info{padding:0 .625rem}#mobile_top_menu_wrapper .js-top-menu-bottom .user-info a{padding:.625rem 0;display:block;width:100%}body#checkout{color:#232323}body#checkout #header .header-nav{max-height:none;padding:.9375rem 0;border:none;margin-bottom:0;box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2)}body#checkout #header .header-nav .logo{max-height:4.375rem;width:auto}body#checkout #header .header-nav #_desktop_contact_link #contact-link{margin-top:0}body#checkout .custom-checkbox{display:-webkit-box;display:-ms-flexbox;display:flex}body#checkout .custom-checkbox span{-webkit-box-flex:0;-ms-flex:0 0 15px;flex:0 0 15px;margin-top:.1875rem}body#checkout a:hover{color:#1a8196}body#checkout section#content{margin-bottom:1.563rem}body#checkout .container{min-height:100%}body#checkout section.checkout-step{box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2);background-color:#fff;border-bottom:1px solid rgba(0,0,0,.25);padding:.9375rem}body#checkout section.checkout-step:last-child{border:0}body#checkout section.checkout-step .step-title{text-transform:uppercase;cursor:pointer;margin-bottom:0}body#checkout section.checkout-step .content{padding:0 2.313rem}body#checkout section.checkout-step .step-edit{text-transform:lowercase;font-weight:400}body#checkout section.checkout-step .step-edit .edit{font-size:1rem}body#checkout section.checkout-step .not-allowed{cursor:not-allowed;opacity:.5}body#checkout section.checkout-step .content,body#checkout section.checkout-step .done,body#checkout section.checkout-step .step-edit{display:none}body#checkout section.checkout-step.-unreachable .step-title{cursor:not-allowed;opacity:.5}body#checkout section.checkout-step.-current .step-title{cursor:default}body#checkout section.checkout-step.-current .content{display:block}body#checkout section.checkout-step.-current.-reachable.-complete .done,body#checkout section.checkout-step.-current.-reachable.-complete .step-edit{display:none}body#checkout section.checkout-step.-current.-reachable.-complete .step-number{display:inline-block}body#checkout section.checkout-step.-current.-reachable.-complete .content{display:block}body#checkout section.checkout-step.-reachable.-complete h1 .done{display:inline-block}body#checkout section.checkout-step.-reachable.-complete h1 .step-number{display:none}body#checkout section.checkout-step.-reachable.-complete h1 .step-edit{cursor:pointer;display:block;float:left;margin-left:.125rem;color:#7a7a7a}body#checkout section.checkout-step.-reachable.-complete .content{display:none}body#checkout section.checkout-step small{color:#7a7a7a}body#checkout section.checkout-step .default-input{min-width:40%}body#checkout section.checkout-step .default-input[name=address1],body#checkout section.checkout-step .default-input[name=address2]{min-width:60%}body#checkout section.checkout-step .radio-field{margin-top:1.875rem}body#checkout section.checkout-step .radio-field label{display:inline}body#checkout section.checkout-step .checkbox-field div{margin-top:3.75rem}body#checkout section.checkout-step .checkbox-field+.checkbox-field div{margin-top:0}body#checkout section.checkout-step .select-field div{background:#f6f6f6;padding:.625rem 3.125rem}body#checkout section.checkout-step .form-footer{text-align:center}body#checkout section.checkout-step #conditions-to-approve{padding-top:1rem}body#checkout section.checkout-step .payment-options label{display:table-cell}body#checkout section.checkout-step .payment-options .custom-radio{margin-left:1.25rem}body#checkout section.checkout-step .payment-options .payment-option{margin-bottom:.5rem}body#checkout section.checkout-step .step-number{display:inline-block;padding:.625rem}body#checkout section.checkout-step .address-selector{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start;-ms-flex-wrap:wrap;flex-wrap:wrap}body#checkout section.checkout-step .address-item{background:#f6f6f6;-webkit-box-flex:0;-ms-flex:0 0 49%;flex:0 0 49%;margin-bottom:.625rem;border:3px solid transparent}body#checkout section.checkout-step .address-item.selected{background:#fff;border:3px solid #2fb5d2}body#checkout section.checkout-step .address-alias{display:inline-block;font-weight:600;margin-bottom:.625rem}body#checkout section.checkout-step .address{margin-right:1.563rem;font-weight:400}body#checkout section.checkout-step .radio-block{padding:.9375rem;text-align:right;cursor:pointer}body#checkout section.checkout-step .custom-radio{margin-left:0}body#checkout section.checkout-step .custom-radio input[type=radio]{height:1.25rem;width:1.25rem}body#checkout section.checkout-step .delete-address,body#checkout section.checkout-step .edit-address{color:#7a7a7a;display:inline-block;margin:0 .3125rem}body#checkout section.checkout-step .delete-address .delete,body#checkout section.checkout-step .delete-address .edit,body#checkout section.checkout-step .edit-address .delete,body#checkout section.checkout-step .edit-address .edit{font-size:1rem}body#checkout section.checkout-step hr{margin:0}body#checkout section.checkout-step .address-footer{text-align:center;padding:.625rem}body#checkout section.checkout-step #delivery-addresses,body#checkout section.checkout-step #invoice-addresses,body#checkout section.checkout-step .add-address{margin-top:1.25rem}body#checkout section.checkout-step .add-address a{color:#232323}body#checkout section.checkout-step .add-address a i{font-size:.9375rem}body#checkout section.checkout-step .delivery-option{background:#f6f6f6;padding:.9375rem 0;margin-bottom:.9375rem}body#checkout section.checkout-step .delivery-option label{text-align:inherit}body#checkout section.checkout-step .delivery-option img{width:3.125rem}body#checkout section.checkout-step .carrier-delay,body#checkout section.checkout-step .carrier-name{display:inline-block;word-break:break-word;text-align:right}body#checkout section.checkout-step #customer-form,body#checkout section.checkout-step #delivery-address,body#checkout section.checkout-step #invoice-address,body#checkout section.checkout-step #login-form{margin-right:.3125rem;margin-top:1.563rem}body#checkout section.checkout-step #customer-form .form-control-label,body#checkout section.checkout-step #delivery-address .form-control-label,body#checkout section.checkout-step #invoice-address .form-control-label,body#checkout section.checkout-step #login-form .form-control-label{text-align:right}body#checkout section.checkout-step #customer-form .radio-inline,body#checkout section.checkout-step #delivery-address .radio-inline,body#checkout section.checkout-step #invoice-address .radio-inline,body#checkout section.checkout-step #login-form .radio-inline{padding:0}body#checkout section.checkout-step .sign-in{font-size:.875rem}body#checkout section.checkout-step .forgot-password{margin-right:14.38rem}body#checkout .additional-information{font-size:.875rem;margin-right:2.875rem;margin-top:1.25rem}body#checkout .condition-label{margin-right:2.5rem;margin-top:.625rem}body#checkout .condition-label label{text-align:inherit}body#checkout .cancel-address{margin:.625rem;display:block;color:#7a7a7a;text-decoration:underline}body#checkout .modal-content{padding:1.25rem;background-color:#f1f1f1}body#checkout #cart-summary-product-list{font-size:.875rem}body#checkout #cart-summary-product-list img{border:1px solid #f1f1f1;width:3.125rem}body#checkout #cart-summary-product-list .media-body{vertical-align:middle}body#checkout #order-summary-content{padding-top:.9375rem}body#checkout #order-summary-content h4.h4{margin-top:.625rem;margin-bottom:1.25rem;color:#232323}body#checkout #order-summary-content h4.black{color:#000}body#checkout #order-summary-content h4.addresshead{margin-top:.1875rem}body#checkout #order-summary-content .noshadow{box-shadow:none}body#checkout #order-summary-content #order-items{border-left:0}body#checkout #order-summary-content #order-items h3.h3{color:#232323;margin-top:1.25rem}body#checkout #order-summary-content #order-items table tr:first-child td{border-top:0}body#checkout #order-summary-content .order-confirmation-table{padding:1rem;margin-bottom:2rem;background-color:#fff;border:3px solid #e5e5e5;border-radius:0}body#checkout #order-summary-content .summary-selected-carrier{margin-bottom:.75rem;background-color:#fff;border:1px solid #e5e5e5;border-radius:0;padding:1rem}body#checkout #order-summary-content .summary-selected-carrier .logo-container{text-align:center}body#checkout #order-summary-content .summary-selected-carrier .logo-container img{width:3.125rem}body#checkout #order-summary-content .step-edit{display:inline;color:#7a7a7a}body#checkout #order-summary-content .step-edit:hover{cursor:pointer}body#checkout #order-summary-content a .step-edit{color:#7a7a7a}body#checkout #delivery,body#checkout #gift_message{max-width:100%;border-color:#232323}body#checkout #delivery textarea,body#checkout #gift_message textarea{max-width:100%;margin-bottom:10px}body#checkout #footer{box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2);padding:.9375rem;background:#fff;color:#7a7a7a}#order-details{padding-right:1.3rem;margin-top:1.25rem}#order-details>.card-title{margin-bottom:1.875rem}#order-details ul{margin-bottom:1.25rem}#order-details ul li{margin-bottom:.625rem}#order-items{border-left:1px solid #f1f1f1}#order-items .h3{font-size:1rem}@media (max-width:991px){#order-items .h3._desktop-title{display:none}}#order-items hr{border-top-color:#232323}#order-items table{width:100%}#order-items table tr{height:1.875rem}#order-items table tr td:last-child{text-align:left}#order-items table tr td{padding:.5rem;font-size:.875rem}#order-items table tr.total-value{background-color:#f1f1f1}#order-items table tr.taxes td{text-align:right}#order-items table tr.taxes td .value{padding-top:0}#order-items .order-line{margin-top:1rem}#order-items .image img{width:100%;border:1px solid gray-lighter;margin-bottom:1rem}#order-items .details{margin-bottom:1rem}#order-items .details .customizations{margin-top:.625rem}#order-items .qty{margin-bottom:1rem}#order-confirmation #registration-form{width:50%;margin:0 auto 1rem}@media (max-width:991px){.done{margin-left:.625rem;padding:0}body#checkout section.checkout-step .address-item{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1}body#checkout section.checkout-step .delivery-option-2{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.delivery-option{display:-webkit-box;display:-ms-flexbox;display:flex;margin:auto}.delivery-option .custom-radio{-webkit-box-flex:0;-ms-flex:0 0 auto;flex:0 0 auto}.condition-label label[for="conditions_to_approve[terms-and-conditions]"]{text-align:right}#order-confirmation #registration-form{width:100%}}@media (max-width:767px){body#checkout section.checkout-step.-reachable.-complete h1 .step-edit{float:none;margin-top:.25rem;margin-right:1.25rem}body#checkout #header .header-nav{max-height:none;padding:0}body#checkout section.checkout-step .content{padding:.9375rem}body#checkout .form-group{margin-bottom:.5rem}#order-items{border-left:0;margin-bottom:2.5rem}#order-items .card-title{border-bottom:1px solid #f1f1f1;margin-bottom:1rem;padding-bottom:1rem}#order-items hr{border-top-color:#f1f1f1}.bold{font-weight:700}#order-details{padding-right:.9375rem}#order-details .card-title{border-bottom:1px solid #f1f1f1;margin-bottom:1rem;padding-bottom:1rem}}@media (max-width:575px){body#checkout section.checkout-step .content{padding:.9375rem 0}#payment-confirmation button{font-size:.875rem}#payment-confirmation button.btn{white-space:normal}}.js-payment-binary,.js-payment-binary .accept-cgv{display:none}.js-payment-binary.disabled{opacity:.6;cursor:not-allowed}.js-payment-binary.disabled:before{content:"";position:absolute;top:0;left:0;bottom:0;right:0;pointer-events:none}.js-payment-binary.disabled .accept-cgv{display:block}.table-labeled td,.table-labeled th{vertical-align:middle}.table-labeled .label{font-weight:400;border-radius:3px;font-size:inherit;padding:.25rem .375rem;margin:.125rem;color:#fff;white-space:nowrap}.page-order .table{margin-bottom:0}.page-order table td,.page-order table th{padding:.5rem}.page-order table thead th{text-align:center}#authentication .tooltip.tooltip-bottom{padding:0;margin:0}#authentication .custom-checkbox{display:-webkit-box;display:-ms-flexbox;display:flex}#authentication .custom-checkbox span{-webkit-box-flex:0;-ms-flex:0 0 0.9375rem;flex:0 0 0.9375rem}#authentication .custom-checkbox label{padding-right:.625rem}#authentication .radio-inline,#identity .radio-inline{padding:0}#authentication .radio-inline .custom-radio,#identity .radio-inline .custom-radio{margin-left:0}.page-customer-account #content{box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2);background:#fff;padding:1rem;font-size:.875rem;color:#7a7a7a}.page-customer-account #content .order-actions a{padding:0 .125rem}.page-customer-account #content .forgot-password{text-align:center;font-size:.875rem;margin-top:1rem;padding-bottom:.9375rem}.page-customer-account #content .no-account{text-align:center;font-size:1rem}.page-authentication #content{padding:1rem;max-width:640px;margin:0 auto}.page-addresses .address,.page-authentication #content{box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2);background:#fff}.page-addresses .address{margin-bottom:1.875rem;font-size:.875rem;color:#232323}.page-addresses .address .address-body{padding:1rem}.page-addresses .address .address-body h4{font-size:1rem;font-weight:700}.page-addresses .address .address-body address{min-height:9rem}.page-addresses .address .address-footer{border-top:1px solid #7a7a7a;padding:.5rem 1rem}.page-addresses .address .address-footer a{color:#7a7a7a;margin-left:.5rem}.page-addresses .address .address-footer a:hover{color:#232323}.page-addresses .address .address-footer a i{font-size:1rem}.page-addresses .address .address-footer a span{font-size:.9375rem;vertical-align:middle}.page-addresses .addresses-footer{margin:0 .9375rem}.page-addresses .addresses-footer a,.page-addresses .addresses-footer a:hover{color:#232323}.page-addresses .addresses-footer a i{font-size:1rem}.page-addresses .addresses-footer a span{font-size:1rem;vertical-align:middle;margin-top:.625rem}.page-order-detail{font-size:.875rem;color:#7a7a7a}.page-order-detail .box{box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2);background:#fff;padding:1rem;margin-bottom:1rem}.page-order-detail h3{font-size:1rem;font-weight:700;text-transform:uppercase;color:#232323;margin-bottom:1rem}.page-order-detail #order-infos ul{margin:0}.page-order-detail #order-history .history-lines .history-line{padding:.5rem 0;border-bottom:1px solid #f6f6f6}.page-order-detail #order-history .history-lines .history-line:last-child{border-bottom:0}.page-order-detail #order-history .history-lines .history-line .label{display:inline-block;margin:.25rem 0;padding:.25rem .375rem;color:#fff;border-radius:3px}.page-order-detail .addresses{margin:0 -.9375rem}.page-order-detail .addresses h4{font-size:1rem;font-weight:700}.page-order-detail #order-products.return{margin-bottom:1rem}.page-order-detail #order-products.return th.head-checkbox{width:30px}.page-order-detail #order-products.return td{padding:1.375rem .75rem}.page-order-detail #order-products.return td.qty{min-width:125px}.page-order-detail #order-products.return td.qty .current{width:30%;float:right;text-align:left;padding-left:.5rem}.page-order-detail #order-products.return td.qty .select{width:70%;float:right;margin:-.625rem 0;padding-right:.25rem}.page-order-detail #order-products.return td.qty .select select{text-align:center}.page-order-detail .order-items{padding:0!important}.page-order-detail .order-items .order-item{padding:1rem 1rem 0;border-bottom:1px solid #f6f6f6}.page-order-detail .order-items .order-item .checkbox{width:30px;float:right;padding:0 .9375rem}.page-order-detail .order-items .order-item .content{width:calc(100% - 30px);float:right;padding:0 .9375rem}.page-order-detail .order-items .order-item .desc{margin-bottom:1rem}.page-order-detail .order-items .order-item .desc .name{font-weight:700}.page-order-detail .order-items .order-item .qty{margin-bottom:1rem}.page-order-detail .order-items .order-item .qty .q,.page-order-detail .order-items .order-item .qty .s{margin-bottom:.25rem}.page-order-detail .messages .message{margin-top:.5rem;border-bottom:1px solid #f6f6f6}.page-order-detail .messages .message:last-child{border-bottom:0}.page-order-detail .messages .message>div{margin-bottom:.5rem}.page-order-detail .customization{margin-top:.75rem}#order-return-infos .thead-default th{color:#232323}#order-return-infos .customization{margin-top:.75rem}.page-my-account #content .links{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}.page-my-account #content .links a{text-align:center;display:inline-block;font-size:1rem;font-weight:700;text-transform:uppercase;color:#7a7a7a;padding:0 .9375rem;margin-bottom:1.875rem}.page-my-account #content .links a span.link-item{display:block;height:100%;box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2);background:#fff;padding:1rem}.page-my-account #content .links a i{display:block;font-size:2.6rem;width:100%;color:#232323;padding-bottom:3.4rem}.page-my-account #content .links a:hover{color:#232323}.page-my-account #content .links a:hover i{color:#2fb5d2}#history .orders{margin:0 -1rem}#history .orders .order{padding:.75rem 1rem;border-bottom:1px solid #f6f6f6}#history .orders .order a h3{color:#7a7a7a}#history .orders .order .label{display:inline-block;margin:.25rem 0;padding:.25rem .375rem;color:#fff;border-radius:3px}#history .orders .order:last-child{border-bottom:0}.page-footer .account-link{margin-left:1rem}.page-footer .account-link i{font-size:1rem}.page-footer .account-link span{font-size:.875rem;vertical-align:middle}.login-form{margin-top:15px}.forgotten-password{padding:4px}.forgotten-password .form-fields .center-email-fields{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}@media (max-width:767px){.forgotten-password .form-fields .center-email-fields{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}.forgotten-password .form-fields .center-email-fields button{margin:10px;width:calc(100% - 20px)}}.forgotten-password .form-fields .center-email-fields button{height:38px}.forgotten-password .form-fields .email{padding-right:0;padding-left:0;width:430px}@media (max-width:767px){.forgotten-password .form-fields .email{padding-right:10px;padding-left:10px;width:100%}}.forgotten-password .form-fields .email input{height:38px}.forgotten-password .form-fields label.required{width:130px}.send-renew-password-link{padding-right:10px;padding-left:10px}.renew-password{margin-right:10px}.renew-password .email{padding-bottom:30px}.renew-password [type=submit]{margin-right:50px}.carousel{box-shadow:-1px 1px 7px 0 rgba(0,0,0,.15);margin-bottom:1.5rem}.carousel .direction{z-index:auto}.carousel .carousel-inner{height:340px}.carousel .carousel-item{height:100%}.carousel .carousel-item img{width:100%;max-width:100%;height:auto}.carousel .carousel-item .caption{position:absolute;bottom:28px;right:90px;color:#fff;max-width:340px}.carousel .carousel-item .caption .caption-description p{color:#fff}.carousel .carousel-item figure{margin:0}.carousel .carousel-control{opacity:1}.carousel .carousel-control .icon-next:before,.carousel .carousel-control .icon-prev:before{content:""}.carousel .carousel-control .icon-next i,.carousel .carousel-control .icon-prev i{font-size:3.125rem;color:#fff}.carousel .carousel-control .icon-next:hover i,.carousel .carousel-control .icon-prev:hover i{color:#2fb5d2}.carousel .carousel-control .icon-prev{right:1rem}.carousel .carousel-control .icon-next{left:2rem}.carousel .carousel-control.left,.carousel .carousel-control.right{background:none}@media (max-width:1199px){.carousel .carousel-inner{height:auto}}@media (max-width:991px){.carousel .carousel-item .caption{bottom:calc(50% - 2rem);right:10%}.carousel .carousel-item .caption .display-1{font-size:2rem}.carousel .carousel-item .caption-description{display:none}}@media (max-width:767px){.carousel .carousel-item .caption{bottom:calc(50% - 1.5rem)}.carousel .carousel-item .caption .display-1{font-size:1.5rem}.carousel .carousel-control .icon-next i,.carousel .carousel-control .icon-prev i{font-size:2rem}}#products .products,.featured-products .products,.product-accessories .products,.product-miniature .products{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}#products .product-thumbnail,.featured-products .product-thumbnail,.product-accessories .product-thumbnail,.product-miniature .product-thumbnail{display:block}#products .product-title a,.featured-products .product-title a,.product-accessories .product-title a,.product-miniature .product-title a{color:#7a7a7a;font-size:.875rem;text-decoration:none;text-align:center;font-weight:400}#products .thumbnail-container,.featured-products .thumbnail-container,.product-accessories .thumbnail-container,.product-miniature .thumbnail-container{position:relative;margin-bottom:1.563rem;height:318px;width:250px;background:#fff;box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2)}#products .thumbnail-container:focus .highlighted-informations,#products .thumbnail-container:hover .highlighted-informations,.featured-products .thumbnail-container:focus .highlighted-informations,.featured-products .thumbnail-container:hover .highlighted-informations,.product-accessories .thumbnail-container:focus .highlighted-informations,.product-accessories .thumbnail-container:hover .highlighted-informations,.product-miniature .thumbnail-container:focus .highlighted-informations,.product-miniature .thumbnail-container:hover .highlighted-informations{bottom:5.5rem}#products .thumbnail-container:focus .highlighted-informations:after,#products .thumbnail-container:hover .highlighted-informations:after,.featured-products .thumbnail-container:focus .highlighted-informations:after,.featured-products .thumbnail-container:hover .highlighted-informations:after,.product-accessories .thumbnail-container:focus .highlighted-informations:after,.product-accessories .thumbnail-container:hover .highlighted-informations:after,.product-miniature .thumbnail-container:focus .highlighted-informations:after,.product-miniature .thumbnail-container:hover .highlighted-informations:after{opacity:1}#products .thumbnail-container:focus .highlighted-informations.no-variants,#products .thumbnail-container:hover .highlighted-informations.no-variants,.featured-products .thumbnail-container:focus .highlighted-informations.no-variants,.featured-products .thumbnail-container:hover .highlighted-informations.no-variants,.product-accessories .thumbnail-container:focus .highlighted-informations.no-variants,.product-accessories .thumbnail-container:hover .highlighted-informations.no-variants,.product-miniature .thumbnail-container:focus .highlighted-informations.no-variants,.product-miniature .thumbnail-container:hover .highlighted-informations.no-variants{bottom:4.2rem}#products .thumbnail-container:focus .product-description:after,#products .thumbnail-container:hover .product-description:after,.featured-products .thumbnail-container:focus .product-description:after,.featured-products .thumbnail-container:hover .product-description:after,.product-accessories .thumbnail-container:focus .product-description:after,.product-accessories .thumbnail-container:hover .product-description:after,.product-miniature .thumbnail-container:focus .product-description:after,.product-miniature .thumbnail-container:hover .product-description:after{content:"";border-top:1px solid #7a7a7a;position:absolute;width:80%;top:0;right:10%;opacity:.25}#products .thumbnail-container .product-thumbnail,.featured-products .thumbnail-container .product-thumbnail,.product-accessories .thumbnail-container .product-thumbnail,.product-miniature .thumbnail-container .product-thumbnail{position:relative;height:calc(100% - 70px)}#products .thumbnail-container .product-thumbnail img,.featured-products .thumbnail-container .product-thumbnail img,.product-accessories .thumbnail-container .product-thumbnail img,.product-miniature .thumbnail-container .product-thumbnail img{max-width:100%;position:absolute;top:0;bottom:0;right:0;left:0;margin:auto}#products .products-section-title,.featured-products .products-section-title,.product-accessories .products-section-title,.product-miniature .products-section-title{text-align:center;margin-bottom:1.5rem}#products .product-title,.featured-products .product-title,.product-accessories .product-title,.product-miniature .product-title{text-align:center;text-transform:capitalize;margin-top:.7rem}#products .product-price-and-shipping,.featured-products .product-price-and-shipping,.product-accessories .product-price-and-shipping,.product-miniature .product-price-and-shipping{color:#232323;font-weight:700;text-align:center}#products .product-price-and-shipping .discount-product,.featured-products .product-price-and-shipping .discount-product,.product-accessories .product-price-and-shipping .discount-product,.product-miniature .product-price-and-shipping .discount-product{display:none}#products .variant-links,.featured-products .variant-links,.product-accessories .variant-links,.product-miniature .variant-links{position:relative;text-align:center;width:100%;top:-.25em;padding-top:.1875rem;min-height:2.5rem;background:#fff}#products .highlighted-informations,.featured-products .highlighted-informations,.product-accessories .highlighted-informations,.product-miniature .highlighted-informations{position:absolute;bottom:1.25rem;padding-top:.625rem;z-index:2;background:#fff;text-align:center;width:250px;height:3.125rem;box-shadow:0 -5px 10px -5px rgba(0,0,0,.2);transition:bottom .3s}#products .highlighted-informations .quick-view,.featured-products .highlighted-informations .quick-view,.product-accessories .highlighted-informations .quick-view,.product-miniature .highlighted-informations .quick-view{color:#7a7a7a;font-size:1rem}#products .highlighted-informations .quick-view:hover,.featured-products .highlighted-informations .quick-view:hover,.product-accessories .highlighted-informations .quick-view:hover,.product-miniature .highlighted-informations .quick-view:hover{color:#2fb5d2}#products .product-description,.featured-products .product-description,.product-accessories .product-description,.product-miniature .product-description{position:absolute;z-index:3;background:#fff;width:250px;bottom:0;height:70px}#products .product-miniature,.featured-products .product-miniature,.product-accessories .product-miniature,.product-miniature .product-miniature{margin:0 .8125rem}#products .product-miniature .product-flags li.product-flag,.featured-products .product-miniature .product-flags li.product-flag,.product-accessories .product-miniature .product-flags li.product-flag,.product-miniature .product-miniature .product-flags li.product-flag{min-width:3.125rem;min-height:1.875rem;font-weight:600}#products .product-miniature .product-flags li.product-flag.online-only,.featured-products .product-miniature .product-flags li.product-flag.online-only,.product-accessories .product-miniature .product-flags li.product-flag.online-only,.product-miniature .product-miniature .product-flags li.product-flag.online-only{top:13.1rem}#products .comments_note,.featured-products .comments_note,.product-accessories .comments_note,.product-miniature .comments_note{text-align:center;color:#7a7a7a}#products .regular-price,.featured-products .regular-price,.product-accessories .regular-price,.product-miniature .regular-price{color:#7a7a7a;text-decoration:line-through;font-size:.875rem}#products .count,.featured-products .count,.product-accessories .count,.product-miniature .count{color:#7a7a7a;font-weight:700;position:relative;bottom:.5rem}#products .all-product-link,.featured-products .all-product-link,.product-accessories .all-product-link,.product-miniature .all-product-link{clear:both;color:#7a7a7a;font-weight:700;margin-top:1.5rem;margin-bottom:1.5rem}@media (max-width:767px){#products .thumbnail-container,.featured-products .thumbnail-container,.product-accessories .thumbnail-container{box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2)}#products .thumbnail-container .product-description,.featured-products .thumbnail-container .product-description,.product-accessories .thumbnail-container .product-description{box-shadow:0 -5px 10px -5px rgba(0,0,0,.2)}}#custom-text{background:#fff;border-radius:2px;margin-bottom:1.5rem;padding:3.125rem;text-align:center}#custom-text h2{text-transform:uppercase;color:#232323;font-size:1.563rem;font-weight:700}#custom-text p{color:#232323;font-weight:400;font-size:1.1em}#custom-text p .dark{color:#7a7a7a;font-weight:400}.page-content.page-cms{background:#fff;padding:1.25rem;text-align:justify}.page-content.page-cms .cms-box img{max-width:100%}@media (max-width:991px){#block-cmsinfo{padding:1.25rem 1.875rem}}#products{color:#7a7a7a}#products .products-select{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:baseline;-ms-flex-align:baseline;align-items:baseline;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}#products .up{margin-bottom:1rem}#products .up .btn-secondary,#products .up .btn-tertiary{color:#7a7a7a;text-transform:inherit}#products .up .btn-secondary .material-icons,#products .up .btn-tertiary .material-icons{margin-left:0}.block-category{min-height:13.75rem;margin-bottom:1.563rem}.block-category .block-category-inner{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between}.block-category .block-category-inner #category-description p,.block-category .block-category-inner #category-description strong{font-weight:400;color:#7a7a7a}.block-category .block-category-inner #category-description p{color:#232323;margin-bottom:0;word-break:break-word}.block-category .block-category-inner #category-description p:first-child{margin-bottom:1.25rem}.block-category .block-category-inner .category-cover img{width:141px;height:180px}.products-selection .sort-by-row{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.products-selection .sort-by{white-space:normal;word-break:break-word;margin-left:-.9375rem;margin-right:.9375rem;text-align:left}.products-selection .total-products,.products-selection h1{padding-top:.625rem}.products-sort-order{color:#7a7a7a}.products-sort-order .select-title{display:inline-block;width:100%;color:#232323;background:#fff;padding:.625rem;cursor:pointer;border:1px solid rgba(0,0,0,.25);box-shadow:-2px 2px 4px 0 rgba(0,0,0,.2)}.products-sort-order .select-list{display:block;color:#232323;padding:.625rem 1.25rem}.products-sort-order .select-list:hover{background:#2fb5d2;color:#fff;text-decoration:none}.products-sort-order .dropdown-menu{right:auto;width:16.88rem;background:#f6f6f6;border:none;border-radius:0;box-shadow:-2px 2px 4px 0 rgba(0,0,0,.1);margin:0}.facet-dropdown{color:#7a7a7a;padding-right:0;padding-left:0;background:#f1f1f1;border:3px solid transparent;box-sizing:border-box;box-shadow:-1px 1px 1px 1px #f1f1f1}.facet-dropdown.open{border:0}.facet-dropdown.open>.select-title{border:3px solid #2fb5d2;background:#f6f6f6}.facet-dropdown .select-title{display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;margin-right:0;width:100%;color:#232323;background:#f1f1f1;padding:.625rem 1.25rem .625rem .625rem;cursor:pointer}.facet-dropdown .select-title>i{margin-right:auto}.facet-dropdown .select-list{display:block;color:#232323;background:#f6f6f6;padding:.625rem 1.25rem}.facet-dropdown .select-list:hover{background:#2fb5d2;color:#fff;text-decoration:none}.facet-dropdown .dropdown-menu{padding:0;margin-top:3px;right:auto;width:100%;background:#f6f6f6;border:none;box-shadow:-1px 1px 1px 1px #f1f1f1}#search_filters,#search_filters_brands,#search_filters_suppliers{box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2);margin-bottom:1.563rem;background:#fff;padding:1.563rem 1.25rem}#search_filters .facet,#search_filters_brands .facet,#search_filters_suppliers .facet{padding-top:.625rem}#search_filters .facet .collapse,#search_filters_brands .facet .collapse,#search_filters_suppliers .facet .collapse{display:block}#search_filters .facet .facet-title,#search_filters_brands .facet .facet-title,#search_filters_suppliers .facet .facet-title{color:#7a7a7a}#search_filters .facet .facet-label,#search_filters_brands .facet .facet-label,#search_filters_suppliers .facet .facet-label{margin-bottom:0}#search_filters .facet .facet-label a,#search_filters_brands .facet .facet-label a,#search_filters_suppliers .facet .facet-label a{margin-top:.4375rem;color:#232323;display:inline-block;font-size:.9375rem}#search_filters_brands .facet,#search_filters_suppliers .facet{padding-top:0}#search_filters_brands .facet .facet-label,#search_filters_suppliers .facet .facet-label{margin-bottom:.3125rem}.pagination{width:100%}.pagination>div:first-child{line-height:2.5rem}.pagination .page-list{background:#fff;padding:.375rem;margin-bottom:0;box-shadow:-2px 2px 4px 0 rgba(0,0,0,.2)}.pagination .page-list li{display:inline}.pagination a{color:#000;font-weight:600}.pagination a:not(.previous):not(.next){letter-spacing:.125rem}.pagination .previous{float:right}.pagination .next{float:left}.pagination .disabled{color:#7a7a7a}.pagination .current a{color:#2fb5d2;text-decoration:none;font-size:1.25rem}.active_filters{background:#dededd;padding:.625rem 1.875rem 0;margin-bottom:1.25rem}.active_filters .active-filter-title{display:inline;margin-left:.625rem;font-weight:600}.active_filters ul{display:inline}.active_filters .filter-block{box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2);color:#232323;margin-left:.625rem;margin-bottom:.625rem;background:#fff;padding:.625rem;display:inline-block;font-size:.8125rem}.active_filters .filter-block .close{color:#232323;font-size:.9375rem;opacity:1;margin-top:.1875rem;margin-right:.3125rem}.block-categories{box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2);background:#fff;padding:1.563rem 1.25rem;margin-bottom:1.563rem}.block-categories .category-sub-menu{margin-top:.625rem}.block-categories .category-sub-menu .category-sub-link{font-size:.875rem}.block-categories .category-sub-menu li{position:relative}.block-categories .category-sub-menu li[data-depth="1"]{margin-bottom:.625rem}.block-categories .category-sub-menu li[data-depth="0"]>a{font-weight:600;border-bottom:1px solid rgba(0,0,0,.25);width:100%;display:inline-block;margin:.3125rem 0 0;padding-bottom:.1875rem}.block-categories .category-sub-menu li:not([data-depth="0"]):not([data-depth="1"]){padding-right:.3125rem}.block-categories .category-sub-menu li:not([data-depth="0"]):not([data-depth="1"]):before{content:"-";margin-left:.3125rem}.block-categories a{color:#232323}.block-categories .collapse-icons{position:absolute;left:0;top:0;padding:0;cursor:pointer}.block-categories .collapse-icons[aria-expanded=true] .add{display:none}.block-categories .collapse-icons[aria-expanded=true] .remove{display:block}.block-categories .collapse-icons .add:hover,.block-categories .collapse-icons .remove:hover{color:#2fb5d2}.block-categories .collapse-icons .remove{display:none}.block-categories .arrows .arrow-down,.block-categories .arrows .arrow-right{font-size:.875rem;cursor:pointer;margin-right:2px}.block-categories .arrows .arrow-down:hover,.block-categories .arrows .arrow-right:hover{color:#2fb5d2}.block-categories .arrows .arrow-down,.block-categories .arrows[aria-expanded=true] .arrow-right{display:none}.block-categories .arrows[aria-expanded=true] .arrow-down{display:inline-block}.facets-title{color:#232323}.products-selection .filter-button .btn-secondary,.products-selection .filter-button .btn-tertiary{padding:.75rem .5rem .6875rem}.advertising-block{margin-bottom:1.563rem}.advertising-block img{width:100%}@media (max-width:767px){#category #left-column{width:100%}#category #left-column #search_filters_wrapper{margin-right:-30px;margin-left:-30px}#category #left-column #search_filter_controls{text-align:center;margin-bottom:1rem}#category #left-column #search_filter_controls button{margin:0 .5rem}#category #left-column #search_filters{margin-bottom:0;box-shadow:none;padding:0;border-top:1px solid #f6f6f6}#category #left-column #search_filters .facet{padding-top:0;border-bottom:1px solid #f6f6f6}#category #left-column #search_filters .facet .title{cursor:pointer}#category #left-column #search_filters .facet .title .collapse-icons .remove,#category #left-column #search_filters .facet .title[aria-expanded=true] .collapse-icons .add{display:none}#category #left-column #search_filters .facet .title[aria-expanded=true] .collapse-icons .remove{display:block}#category #left-column #search_filters .facet .facet-title{color:#232323;text-transform:uppercase}#category #left-column #search_filters .facet .h6{margin-bottom:0;padding:.625rem;display:inline-block}#category #left-column #search_filters .facet .navbar-toggler{display:inline-block;padding:.625rem 0 0 .625rem}#category #left-column #search_filters .facet .collapse{display:none}#category #left-column #search_filters .facet .collapse.in{display:block}#category #left-column #search_filters .facet .facet-label a{margin-top:0}#category #left-column #search_filters .facet ul{margin-bottom:0}#category #left-column #search_filters .facet ul li{border-top:1px solid #f6f6f6;padding:.625rem}#category #content-wrapper,#category #search_filter_toggler{width:100%}.products-sort-order .select-title{margin-right:0}.products-selection h1{padding-top:0;text-align:center;margin-bottom:1rem}.products-selection .showing{padding-top:1rem}#best-sales #content-wrapper,#new-products #content-wrapper,#prices-drop #content-wrapper{width:100%}}@media (max-width:575px){.products-selection .filter-button{padding-right:0}#category #left-column #search_filters_wrapper{margin-right:-15px;margin-left:-15px}}@media screen and (max-width:767px){.category-cover{display:none}.block-category{min-height:0;margin-bottom:0}.card-block{padding:0}.card{box-shadow:none;background-color:inherit;border:none}}#product #content{position:relative;max-width:452px;margin:0 auto}.product-price{color:#2fb5d2;display:inline-block}#product-description-short{color:#232323}.product-information{font-size:.9375rem;color:#232323}.product-information .manufacturer-logo{height:35px}.product-information .product-description img{max-width:100%;height:auto}.input-color{position:absolute;opacity:0;cursor:pointer;height:1.25rem;width:1.25rem}.input-container{position:relative}.input-radio{position:absolute;top:0;cursor:pointer;opacity:0;width:100%;height:100%}.input-color:checked+span,.input-color:hover+span,.input-radio:checked+span,.input-radio:hover+span{border:2px solid #232323}.radio-label{box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2);background:#fff;display:inline-block;padding:.125rem .625rem;font-weight:600;border:2px solid #fff}.product-actions .control-label{margin-bottom:.375rem;display:block;width:100%}.product-actions .add-to-cart{height:2.75rem;line-height:inherit;padding-top:.625rem}.product-actions .add-to-cart .material-icons{line-height:inherit}.product-quantity{display:-webkit-box;display:-ms-flexbox;display:flex}.product-quantity .add,.product-quantity .qty{float:right;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;margin-bottom:.5rem}.product-quantity .qty{margin-left:.4rem}.product-quantity #quantity_wanted{color:#232323;background-color:#fff;height:2.75rem;padding:.175rem .5rem;width:3rem}.product-quantity .input-group-btn-vertical{width:auto}.product-quantity .input-group-btn-vertical .btn{padding:.5rem .6875rem}.product-quantity .input-group-btn-vertical .btn i{font-size:1rem;top:.125rem;right:.1875rem}.product-quantity .btn-touchspin{height:1.438rem}.product-discounts{margin-bottom:1.5rem}.product-discounts>.product-discounts-title{font-weight:400;font-size:.875rem}.product-discounts>.table-product-discounts thead tr th{width:33%;padding:.625rem 1.25rem;background:#fff;border:.3125rem solid #f1f1f1;text-align:center}.product-discounts>.table-product-discounts tbody tr{background:#f6f6f6}.product-discounts>.table-product-discounts tbody tr:nth-of-type(2n){background:#fff}.product-discounts>.table-product-discounts tbody tr td{padding:.625rem 1.25rem;text-align:center;border:.3125rem solid #f1f1f1}.product-prices{margin-top:1.25rem}.product-prices div{margin-bottom:.625rem}.product-prices .tax-shipping-delivery-label{font-size:.8125rem;color:#7a7a7a}.product-prices .tax-shipping-delivery-label .delivery-information{padding:0 2px 0 0}.product-prices .tax-shipping-delivery-label .delivery-information:before{content:"-";padding:0 0 0 2px}.product-discount{color:#7a7a7a}.product-discount .regular-price{text-decoration:line-through;font-weight:400;margin-left:.625rem}.has-discount.product-price,.has-discount p{color:#f39d72}.has-discount .discount{background:#f39d72;color:#fff;font-weight:600;padding:.3125rem .625rem;font-size:1rem;margin-right:.625rem;text-transform:uppercase;display:inline-block}.product-unit-price{font-size:.8125rem;margin-bottom:0}.tabs{box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2);margin-top:2rem;background:#fff;padding:1.25rem 1.875rem}.tabs .tab-pane{padding-top:1.25rem}.tabs .nav-tabs{border:none;border-bottom:2px solid #f1f1f1}.tabs .nav-tabs .nav-link{color:#7a7a7a;border:0 solid transparent}.tabs .nav-tabs .nav-link.active{color:#2fb5d2}.tabs .nav-tabs .nav-link.active,.tabs .nav-tabs .nav-link:hover{border:none;border-bottom:3px solid #2fb5d2}.tabs .nav-tabs .nav-item{float:right;margin-bottom:-.125rem}.product-cover{margin-bottom:1.25rem;position:relative}.product-cover img{box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2);background:#fff}.product-cover .layer{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;width:100%;height:100%;background:#fff;position:absolute;right:0;top:0;opacity:0;background:hsla(0,0%,100%,.7);text-align:center;cursor:pointer}.product-cover .layer:hover{opacity:1}.product-cover .layer .zoom-in{font-size:6.25rem;color:#7a7a7a}#product-modal .modal-content{background:transparent;border:none;padding:0}#product-modal .modal-content .modal-body{display:-webkit-box;display:-ms-flexbox;display:flex;margin-right:-30%}#product-modal .modal-content .modal-body .product-cover-modal{background:#fff}#product-modal .modal-content .modal-body .image-caption{background:#fff;width:800px;padding:.625rem 1.25rem;border-top:1px solid #f1f1f1}#product-modal .modal-content .modal-body .image-caption p{margin-bottom:0}#product-modal .modal-content .modal-body .thumbnails{position:relative}#product-modal .modal-content .modal-body .mask{position:relative;overflow:hidden;max-height:49.38rem;margin-top:2.188rem;z-index:1}#product-modal .modal-content .modal-body .mask.nomargin{margin-top:0}#product-modal .modal-content .modal-body .product-images{margin-right:2.5rem}#product-modal .modal-content .modal-body .product-images img{width:9.25rem;cursor:pointer;background:#fff}#product-modal .modal-content .modal-body .product-images img:hover{border:3px solid #2fb5d2}#product-modal .modal-content .modal-body .arrows{height:100%;width:100%;text-align:center;position:absolute;top:0;color:#fff;left:1.875rem;z-index:0;cursor:pointer}#product-modal .modal-content .modal-body .arrows .arrow-up{position:absolute;top:-2rem;opacity:.2}#product-modal .modal-content .modal-body .arrows .arrow-down{position:absolute;bottom:-2rem}#product-modal .modal-content .modal-body .arrows i{font-size:6.25rem;display:inline}#blockcart-modal{color:#232323}#blockcart-modal .modal-header{background:#fff}#blockcart-modal .modal-header .close{opacity:1}#blockcart-modal .modal-header .close .material-icons{color:#363a42}#blockcart-modal .modal-body{background:#fff;padding:3.125rem 1.875rem}#blockcart-modal .modal-body .divide-right span{display:inline-block;margin-bottom:.3125rem}@media (max-width:767px){#blockcart-modal .modal-body .divide-right span{display:block;padding:0 .5rem}}#blockcart-modal .modal-dialog{max-width:1140px;width:100%}#blockcart-modal .product-image{width:100%;max-width:9.375rem;display:block;margin:0 auto 0 0}#blockcart-modal .modal-title{color:#353943;font-size:1rem;font-weight:400}#blockcart-modal .modal-title i.material-icons{margin-left:1.875rem;color:#4cbb6c}#blockcart-modal .product-name{color:#2fb5d2;font-size:1.125rem}@media (max-width:767px){#blockcart-modal .product-name{padding:0 .5rem}}#blockcart-modal .product-price{color:#363a42;display:block}@media (max-width:767px){#blockcart-modal .product-price{padding:0 .5rem}}#blockcart-modal .cart-content{padding-right:2.5rem}#blockcart-modal .cart-content p{color:#363a42;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;padding:0 .5rem}#blockcart-modal .cart-content p.product-total{background-color:#f1f1f1;padding:.5rem}#blockcart-modal .cart-content p.cart-products-count{font-size:1rem;color:#6c868e;font-weight:600}#blockcart-modal .cart-content p.product-tax{display:inherit;font-size:.875rem}#blockcart-modal .cart-content p .label,#blockcart-modal .cart-content p .value{font-weight:600}#blockcart-modal .cart-content .cart-content-btn{display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex}#blockcart-modal .cart-content .cart-content-btn button{margin-left:.9rem}#blockcart-modal .cart-content .cart-content-btn .btn{white-space:inherit}#blockcart-modal .divide-right{border-left:1px solid #dbdbdb}.product-images>li.thumb-container{display:inline}.product-images>li.thumb-container>.thumb{box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2);cursor:pointer;margin-bottom:.625rem}.images-container .product-images>li.thumb-container>.thumb{margin-left:.8125rem}.product-images>li.thumb-container>.thumb.selected,.product-images>li.thumb-container>.thumb:hover{border:3px solid #2fb5d2}#main .images-container .js-qv-mask{white-space:nowrap;overflow:hidden}#main .images-container .js-qv-mask.scroll{width:calc(100% - 60px);margin:0 auto}.scroll-box-arrows{display:none}.scroll-box-arrows.scroll{display:block}.scroll-box-arrows i{position:absolute;bottom:1.625rem;height:100px;line-height:100px;cursor:pointer}.scroll-box-arrows .left{right:0}.scroll-box-arrows .right{left:0}#product-availability{margin-top:.625rem;display:inline-block;font-weight:700}#product-availability .material-icons{line-height:inherit}#product-availability .product-available{color:#4cbb6c}#product-availability .product-last-items,#product-availability .product-unavailable{color:#ff9a52}#product-details .label{font-size:1rem;color:#232323;font-weight:700}.product-features{margin-top:1.25rem;margin-right:.3125rem}.product-features>dl.data-sheet{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-webkit-box-align:stretch;-ms-flex-align:stretch;align-items:stretch}.product-features>dl.data-sheet dd.value,.product-features>dl.data-sheet dt.name{-webkit-box-flex:1;-ms-flex:1 0 40%;flex:1 0 40%;font-weight:400;background:#f1f1f1;padding:.625rem;margin-left:.625rem;min-height:2.5rem;word-break:normal;text-transform:capitalize;margin-bottom:.5rem}.product-features>dl.data-sheet dd.value:nth-of-type(2n),.product-features>dl.data-sheet dt.name:nth-of-type(2n){background:#f6f6f6}.product-variants>.product-variants-item{margin:1.25rem 0}.product-variants>.product-variants-item select{background-color:#fff;width:auto;padding-left:1.875rem;box-shadow:-2px 2px 4px 0 rgba(0,0,0,.2)}.product-variants>.product-variants-item ul li{margin-left:.625rem}.product-variants>.product-variants-item .color{margin-right:0;margin-top:0}.product-flags{pointer-events:none;position:absolute;width:100%;top:0;right:0;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;z-index:2}.product-flags li.product-flag{pointer-events:auto;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;background:#2fb5d2;font-weight:700;padding:.3125rem .4375rem;text-transform:uppercase;color:#fff;margin-top:.625rem;font-size:1rem;box-shadow:-2px 2px 4px 0 rgba(0,0,0,.2)}.product-flags li.product-flag.online-only{position:absolute;top:25rem;left:0;z-index:1;font-size:.8125rem;margin-top:0}.product-flags li.product-flag.online-only:before{content:"\E30A";font-family:Material Icons;vertical-align:middle;margin:.3125rem}.product-flags li.product-flag.discount,.product-flags li.product-flag.discount-amount,.product-flags li.product-flag.discount-percentage{background-color:#f39d72}.product-flags li.product-flag.on-sale{-webkit-box-ordinal-group:0;-ms-flex-order:-1;order:-1;background:#f39d72;width:100%;text-align:center;margin-top:0!important}.product-customization{margin:2.5rem 0}.product-customization .product-customization-item{margin:1.25rem 0}.product-customization .product-message{background:#f1f1f1;border:none;width:100%;height:3.125rem;resize:none;padding:.625rem}.product-customization .product-message:focus{background-color:#fff;outline:.1875rem solid #2fb5d2}.product-customization .file-input{width:100%;opacity:0;right:0;z-index:1;cursor:pointer;height:2.625rem;overflow:hidden;position:absolute}.product-customization .customization-message{margin-top:20px}.product-customization .custom-file{position:relative;background:#f1f1f1;width:100%;height:2.625rem;line-height:2.625rem;text-indent:.625rem;display:block;color:#7a7a7a;margin-top:1.25rem}.product-customization .custom-file button{z-index:0;position:absolute;left:0;top:0}.product-customization small{color:#7a7a7a}.product-pack{margin-top:2.5rem}.product-pack .pack-product-container{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-pack:distribute;justify-content:space-around}.product-pack .pack-product-container .pack-product-name{-webkit-box-flex:0;-ms-flex:0 0 50%;flex:0 0 50%;font-size:.875rem;color:#7a7a7a}.product-pack .pack-product-container .pack-product-quantity{border-right:2px solid #f1f1f1;padding-right:.625rem}.product-pack .pack-product-container .pack-product-name,.product-pack .pack-product-container .pack-product-price,.product-pack .pack-product-container .pack-product-quantity{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.product-refresh{margin-top:1.25rem}.social-sharing{width:100%;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;margin-top:1.5rem}.social-sharing ul{margin-bottom:0}.social-sharing li{box-shadow:-2px 2px 4px 0 rgba(0,0,0,.2);height:2.5rem;width:2.5rem;border-radius:50%;display:inline-block;background-color:#fff;background-repeat:no-repeat;background-size:2rem 2rem;background-position:.25rem .25rem;cursor:pointer;margin-right:.5rem}.social-sharing li a{display:block;width:100%;height:100%;white-space:nowrap;text-indent:100%;overflow:hidden}.social-sharing li a:hover{color:transparent}.products-selection{margin-bottom:1.25rem}.products-selection .title{color:#7a7a7a}#blockcart-modal .cart-content .btn{margin-bottom:.625rem}@media (max-width:991px){.product-cover img{width:100%}#product-modal .modal-content .modal-body{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;margin-right:0}#product-modal .modal-content .modal-body img.product-cover-modal{width:100%}#product-modal .modal-content .modal-body .arrows{display:none}#product-modal .modal-content .modal-body .image-caption{width:100%}#blockcart-modal .modal-dialog{width:calc(100% - 20px)}#blockcart-modal .modal-body{padding:1.875rem}}@media (max-width:767px){#blockcart-modal .divide-right{border-left:none}#blockcart-modal .modal-body{padding:1rem}}.cart-grid{margin-bottom:1rem}.cart-items{margin-bottom:0}.cart-item{padding:1rem 0}.card-block{padding:1.25rem 1.25rem .5rem}.card-block.checkout{padding-bottom:1.75rem;padding-top:0;margin-top:1rem}.card-block.cart-summary-totals{padding:0 1rem 1rem}.card-block.cart-summary-totals .cart-summary-line{padding:.5rem .2rem 0}.card-block.cart-summary-totals .cart-summary-line:last-child{margin-bottom:0}.card-block.cart-summary-totals .cart-summary-line.cart-total{background-color:#f1f1f1;padding:.5rem}.card-block.cart-summary-totals .cart-summary-line.cart-total .label,.card-block.cart-summary-totals .cart-summary-line.cart-total .value{font-weight:700}.card-block.cart-summary-totals .cart-summary-line.cart-total .label{font-size:1rem}.card-block.cart-summary-totals .cart-summary-line.cart-total .value{font-size:1.125rem}.card-block.cart-summary-totals .cart-summary-line span.sub{text-align:right;font-size:.88rem;float:none}.cart-summary-line{clear:both;margin-bottom:.315rem}.cart-summary-line:after{content:"";display:table;clear:both}.cart-summary-line .label{padding-right:0;font-weight:400;white-space:inherit;color:#363a42}.cart-summary-line .value{color:#232323;float:left}.cart-summary-line.cart-summary-subtotals .label,.cart-summary-line.cart-summary-subtotals .value{font-weight:400}.cart-grid-body{margin-bottom:.75rem}.cart-grid-body a.label:hover{color:#2fb5d2}.cart-grid-body .card-block{padding:1rem}.cart-grid-body .card-block h1{margin-bottom:0}.cart-grid-body .cart-overview{padding:1rem}.cart-grid-right .promo-discounts{margin-bottom:0;text-align:center;padding-top:.5rem;padding-bottom:.5rem}.cart-grid-right .promo-discounts .cart-summary-line .label{font-size:1rem;color:#7a7a7a}.cart-grid-right .promo-discounts .cart-summary-line .label .code{color:#f49d6e;cursor:pointer}.cart-grid-right .cart-summary-line.cart-subtotal-products .label,.cart-grid-right .cart-summary-line.cart-subtotal-products .value{font-weight:600}.cart-grid-right .cart-summary-line.cart-subtotal-products .value{font-size:1rem}.block-promo{margin-bottom:1rem}.block-promo .promo-code{padding:1rem}.block-promo .promo-code .alert-danger{position:relative;margin-top:1.25rem;background:#ff4c4c;color:#fff;display:none}.block-promo .promo-code .alert-danger:after{bottom:100%;right:10%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none;border-bottom-color:#ff4c4c;border-width:10px;margin-right:-10px}.block-promo .promo-code form{text-align:center}.block-promo .promo-input{color:#232323;border:1px solid #7a7a7a;height:2.5rem;text-indent:.625rem;width:50%;margin-left:-.24rem}.block-promo .promo-input+button{margin-top:-4px;margin-right:-1px;text-transform:capitalize;border:2px solid #2fb5d2}.block-promo .cart-summary-line .label,.block-promo .promo-name{color:#ff9a52;font-weight:600;margin-bottom:0}.block-promo .cart-summary-line .label a,.block-promo .promo-name a{font-weight:400;color:#232323;display:inline-block}.block-promo .promo-name .cart-summary-line .label{font-weight:400;color:#363a42}.block-promo .promo-name .cart-summary-line span{color:#f49d6e}.block-promo .promo-name .material-icons{font-size:1.2rem;margin-right:.4rem}.block-promo .promo-code-button{display:block;text-align:center;padding:0 0 1rem}.block-promo .promo-code-button.with-discounts{display:none}.block-promo .promo-code-button.cancel-promo{color:#2fb5d2;margin-bottom:0}.block-promo .promo-code-button.cancel-promo[aria-expanded=true]{display:block;padding:0;margin-top:1rem}.block-promo.promo-highlighted{padding:0 1rem;margin-bottom:0;text-align:center}.block-promo p{margin-bottom:0}.product-line-grid-left img{max-width:100%}.product-line-grid-body>.product-line-info>.label{padding:0;line-height:inherit;text-align:right;white-space:inherit}.product-line-grid-body>.product-line-info>.out-of-stock{color:red}.product-line-grid-body>.product-line-info>.available{color:#4cbb6c}.product-line-grid-body>.product-line-info>.unit-price-cart{padding-right:.3125rem;font-size:.875rem;color:#7a7a7a}.product-line-grid-right .cart-line-product-actions,.product-line-grid-right .product-price{color:#232323;line-height:36px}.product-line-grid-right .cart-line-product-actions .remove-from-cart,.product-line-grid-right .product-price .remove-from-cart{color:#232323;display:inline-block;margin-top:.3125rem}@media (max-width:767px){.product-line-grid-body{margin-bottom:1rem}}@media (max-width:575px){.cart-items{padding:1rem 0}.cart-item{border-bottom:1px solid #f1f1f1}.cart-item:last-child{border-bottom:0}.cart-grid-body .cart-overview{padding:0}.cart-grid-body .no-items{padding:1rem;display:inline-block}.product-line-grid-left{padding-left:0!important}}@media (max-width:360px){.product-line-grid-right .price,.product-line-grid-right .qty{width:100%}}#block-reassurance{margin-top:2rem}#block-reassurance img{width:1.563rem;margin-left:.625rem}#block-reassurance li{border-bottom:1px solid rgba(0,0,0,.25)}#block-reassurance li:last-child{border:0}#block-reassurance li .block-reassurance-item{padding:1rem 1.5rem}#product #block-reassurance{box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2);background:#fff}#product #block-reassurance span{font-weight:700}.quickview .modal-dialog{width:calc(100% - 30px);max-width:64rem}.quickview .modal-content{background:#f1f1f1;min-height:28.13rem}.quickview .modal-header{border:none;padding:.625rem}.quickview .modal-body{min-height:23.75rem}.quickview .modal-footer{border-top:1px solid hsla(0,0%,48%,.3)}.quickview .layer{display:none}.quickview .product-cover img{width:95%}.quickview .images-container{display:-webkit-box;display:-ms-flexbox;display:flex;z-index:1;min-height:21.88rem}.quickview .images-container .product-images>li.thumb-container>.thumb{width:100%;max-width:4.938rem;margin-bottom:.8125rem;background:#fff}.quickview .mask{width:35%;max-height:22.5rem;overflow:hidden;margin-right:.625rem}.quickview .arrows{position:absolute;top:0;bottom:0;max-height:22.5rem;left:5rem;z-index:0}.quickview .arrows .arrow-up{margin-top:-3.125rem;cursor:pointer;opacity:.2}.quickview .arrows .arrow-down{position:absolute;bottom:-1.875rem;cursor:pointer}.quickview .social-sharing{margin-top:0;margin-right:2.5rem}#stores .page-stores{width:85%;margin:0 auto}#stores .page-stores .store-item{padding-right:.75rem;padding-left:.75rem}#stores .page-stores .store-picture img{max-width:100%}#stores .page-stores .store-item-container{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-pack:distribute;justify-content:space-around;-webkit-box-align:center;-ms-flex-align:center;align-items:center;padding:1.875rem 0}#stores .page-stores .store-item-container ul{margin-bottom:0;font-size:.9375rem}#stores .page-stores .store-item-container .divide-left{border-right:1px solid #f1f1f1}#stores .page-stores .store-item-container .divide-left tr{height:1.563rem}#stores .page-stores .store-item-container .divide-left td{padding-right:.375rem}#stores .page-stores .store-item-container .divide-left th{text-align:left}#stores .page-stores .store-item-container .store-description{font-size:1rem}#stores .page-stores .store-item-footer{margin-top:.5rem;padding-top:.5rem;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-pack:distribute;justify-content:space-around}#stores .page-stores .store-item-footer.divide-top{border-top:1px solid #f1f1f1}#stores .page-stores .store-item-footer div:first-child{-webkit-box-flex:0;-ms-flex:0 0 65%;flex:0 0 65%}#stores .page-stores .store-item-footer i.material-icons{margin-left:.625rem;color:#7a7a7a;font-size:1rem}#stores .page-stores .store-item-footer li{margin-bottom:.625rem}@media (max-width:767px){#stores .page-stores{width:100%}#stores .page-stores .store-item-container{padding:1rem 0}}@media (max-width:575px){#stores .page-stores .store-item-container{display:block}#stores .page-stores .store-item-container .divide-left{border-right:none}#stores .page-stores .store-item-container .store-description a,#stores .page-stores .store-item-container .store-description address{margin-bottom:.5rem}#stores .page-stores .store-item-footer{display:block}#stores .page-stores .store-item-footer.divide-top{border-top:1px solid #f1f1f1}#stores .page-stores .store-item-footer li{margin-bottom:.625rem}#stores .page-stores .store-item-footer .card-block{padding:.75rem .75rem 0}}.block_newsletter{font-size:.875rem;margin-bottom:.625rem}.block_newsletter form{position:relative}.block_newsletter form input[type=text]{border:none;padding:10px;min-width:255px;color:#7a7a7a;border:1px solid rgba(0,0,0,.25)}.block_newsletter form input[type=text]:focus{outline:3px solid #2fb5d2;color:#232323;background:#fff}.block_newsletter form input[type=text]:focus+button .search{color:#2fb5d2}.block_newsletter form button[type=submit]{position:absolute;background:none;border:none;bottom:.3125rem;left:.125rem;color:#7a7a7a}.block_newsletter form button[type=submit] .search:hover{color:#2fb5d2}.block_newsletter p{padding-top:.625rem}.block_newsletter form .input-wrapper{overflow:hidden}.block_newsletter form input[type=email]{padding:11px;width:100%}.block_newsletter form input[type=email]:focus{border:3px solid #2fb5d2;padding:8px 8px 9px;outline:0}.block_newsletter form input{height:42px;box-shadow:none}.block-contact{color:#7a7a7a}.block-contact .block-contact-title,.linklist .blockcms-title a{color:#232323}.account-list a{color:#7a7a7a}.account-list a:hover{color:#2fb5d2}.block-contact-title,.blockcms-title,.myaccount-title,.myaccount-title a{font-weight:700;font-size:1rem}.block-social{text-align:left}.block-social ul{display:-webkit-box;display:-ms-flexbox;display:flex}@media (max-width:767px){.block-social ul{-ms-flex-flow:wrap;flex-flow:wrap}}.block-social ul li{height:2.5rem;width:2.5rem;background-color:#f1f1f1;background-repeat:no-repeat;display:inline-block;margin:.125rem;cursor:pointer}@media (max-width:767px){.block-social ul li{height:2rem;width:2rem;margin-left:1.3rem;margin-bottom:1.3rem;background-size:contain}}.block-social ul li:hover{background-color:#2fb5d2}.block-social ul li a{display:block;height:100%;white-space:nowrap;text-indent:100%;overflow:hidden}.block-social ul li a:hover{color:transparent}.facebook{background-image:url(../css/3935e107ea61866e60d7946dc6a962f1.svg)}.facebook:before{content:"";background-image:url(../css/8b05d51ede908907d65695558974d86f.svg)}.facebook.icon-gray{background-image:url(../css/082a71677e756fb75817e8f262a07cb4.svg)}.facebook.icon-gray:hover{background-image:url(../css/8b05d51ede908907d65695558974d86f.svg)}.twitter{background-image:url(../css/a67175d1ea11389d9107bd8c08f9d7d7.svg)}.twitter:before{content:"";background-image:url(../css/ffddcb3736980b23405b31142a324b62.svg)}.twitter.icon-gray{background-image:url(../css/e049aeb07a2ae1627933e8e58d3886d2.svg)}.twitter.icon-gray:hover{background-image:url(../css/ffddcb3736980b23405b31142a324b62.svg)}.rss{background-image:url(../css/cf2f3c1d5c7cb02c29f61964313148e1.svg)}.youtube{background-image:url(../css/22c0528acb6d9cd5bf4c8f96381bc05c.svg)}.googleplus{background-image:url(../css/36bff72dcba3098b4b70b482b22c29ab.svg)}.googleplus:before{content:"";background-image:url(../css/c1a65805f759901a39d10eb854c1dcf2.svg)}.googleplus.icon-gray{background-image:url(../css/3a2aeeba930cc29e4d31ebfa1b7cdaa2.svg)}.googleplus.icon-gray:hover{background-image:url(../css/c1a65805f759901a39d10eb854c1dcf2.svg)}#block_myaccount_infos .myaccount-title a{color:#232323}.pinterest{background-image:url(../css/afb2ed6d67613a724a420a39b4fe5b0d.svg)}.pinterest:before{content:"";background-image:url(../css/b1db819132e64a3e01911a1413c33acf.svg)}.pinterest.icon-gray{background-image:url(../css/99db8adec61e4fcf5586e1afa549b432.svg)}.pinterest.icon-gray:hover{background-image:url(../css/b1db819132e64a3e01911a1413c33acf.svg)}.vimeo{background-image:url(../css/f255af0bbbe837e79f7821827f9c6f10.svg)}.instagram{background-image:url(../css/0266b05265f317a7409560b751cd61e8.svg)}.footer-container{margin-top:1.25rem;padding-top:1.25rem;overflow:hidden;box-shadow:-2px 2px 11px 0 rgba(0,0,0,.3)}.footer-container li{margin-bottom:.3125rem}.footer-container li a{color:#7a7a7a;cursor:pointer;font-size:.875rem}.footer-container li a:hover{color:#2fb5d2}.links .collapse{display:inherit}@media (max-width:767px){.block_newsletter{padding-bottom:.625rem;border-bottom:1px solid #f6f6f6}.footer-container{box-shadow:none;margin-top:0}.footer-container .wrapper{padding-right:0!important;padding-left:0!important}.footer-container .links .h3{line-height:1.5;font-size:1rem}.footer-container .links ul{background-color:#f6f6f6;margin-bottom:0}.footer-container .links ul>li{padding:.625rem;border-bottom:1px solid #fff;font-weight:700}.footer-container .links ul>li a{color:#232323}.links .collapse{display:none}.links .collapse.in{display:block}.links .title{padding:.625rem;border-bottom:1px solid #f6f6f6;cursor:pointer}.links .title .collapse-icons .remove,.links .title[aria-expanded=true] .collapse-icons .add{display:none}.links .title[aria-expanded=true] .collapse-icons .remove{display:block}.links .navbar-toggler{display:inline-block;padding:0}}@media (max-width:991px){.block-social{text-align:center}.block-contact{padding-right:1.5rem}}.contact-rich{color:#7a7a7a;margin-bottom:2rem;word-wrap:break-word}.contact-rich h4{text-transform:uppercase;color:#232323;margin-bottom:2rem}.contact-rich .block{height:auto;overflow:hidden}.contact-rich .block .icon{float:right;width:3.5rem}.contact-rich .block .icon i{font-size:2rem}.contact-rich .block .data{color:#232323;font-size:.875rem;width:auto;overflow:hidden}.contact-rich .block .data.email{padding-top:.375rem}.contact-rich .block a[href^="mailto:"]{clear:both;margin-top:1rem}@media (min-width:576px){.contact-rich .block a[href^="mailto:"]{font-size:.815rem}}.contact-form{background:#fff;padding:1rem;color:#7a7a7a;width:100%}.contact-form h3{text-transform:uppercase;color:#232323}#pagenotfound #main .page-header,#products #main .page-header{margin:2rem 0 3rem}#pagenotfound #main .page-content,#products #main .page-content{margin-bottom:10rem}#pagenotfound .page-not-found,#products .page-not-found{box-shadow:-2px 2px 8px 0 rgba(0,0,0,.2);background:#fff;padding:1rem;font-size:.875rem;color:#7a7a7a;max-width:570px;margin:0 auto}#pagenotfound .page-not-found h4,#products .page-not-found h4{font-size:1rem;font-weight:700;margin:.5rem 0 1rem}#pagenotfound .page-not-found .search-widget,#products .page-not-found .search-widget{float:none}#pagenotfound .page-not-found .search-widget input,#products .page-not-found .search-widget input{width:100%}.customization-modal .modal-content{border-radius:0;border:1px solid #f6f6f6}.customization-modal .modal-content .modal-body{padding-top:0}.customization-modal .modal-content .modal-body .product-customization-line{padding-bottom:.9375rem;padding-top:.9375rem;border-bottom:1px solid #f6f6f6}.customization-modal .modal-content .modal-body .product-customization-line .label{font-weight:700;text-align:left}.customization-modal .modal-content .modal-body .product-customization-line:last-child{padding-bottom:0;border-bottom:0}.sitemap-title{text-transform:capitalize}.sitemap{margin-top:.9375rem}.sitemap h2{color:#232323;text-transform:uppercase;font-size:1.1rem;font-weight:600;border-bottom:1px solid #7a7a7a;margin-right:-15px;width:100%;height:35px}.sitemap ul{margin-right:-15px;margin-top:20px}.sitemap ul.nested{margin-right:20px}.sitemap ul li{font-size:.9rem;margin-bottom:1rem}@media (max-width:575px){.sitemap{margin-top:0}}#header{background:#fff;color:#7a7a7a}#header .logo{max-width:100%}#header a{color:#232323}#header a:hover{text-decoration:none;color:#2fb5d2}#header .menu,#header .menu>ul>li{display:inline-block}#header .header-nav{border-bottom:2px solid #f1f1f1;max-height:50px;margin-bottom:30px}#header .header-nav #menu-icon{vertical-align:middle;cursor:pointer;margin:0 1rem}#header .header-nav #menu-icon .material-icons{line-height:50px}#header .header-nav .right-nav{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end}#header .header-nav .currency-selector{margin-top:.9375rem;margin-right:.9375rem;white-space:nowrap}#header .header-nav .user-info{margin-right:2.5rem;margin-top:.9375rem;text-align:left;white-space:nowrap}#header .header-nav .user-info .account{margin-right:.625rem}#header .header-nav .language-selector{margin-top:.9375rem;white-space:nowrap}#header .header-nav .cart-preview.active{background:#2fb5d2}#header .header-nav .cart-preview.active a,#header .header-nav .cart-preview.active i{color:#fff}#header .header-nav .cart-preview .shopping-cart{vertical-align:middle;color:#7a7a7a}#header .header-nav .cart-preview .body{display:none}#header .header-nav .blockcart{background:#f1f1f1;height:3rem;padding:.75rem;margin-right:.9375rem;text-align:center;white-space:nowrap}#header .header-nav .blockcart a{color:#7a7a7a}#header .header-nav .blockcart a:hover{color:#2fb5d2}#header .header-nav .blockcart.active a:hover{color:#fff}#header .header-nav .blockcart .header{margin-top:.125rem}#header .header-nav #_desktop_contact_link{display:inline-block}#header .header-nav #_desktop_contact_link #contact-link{margin-top:.9375rem}#header .header-nav .search-widget{margin-top:.2rem}#header .header-nav .material-icons{line-height:inherit}#header .header-nav .material-icons.expand-more{margin-right:-.375rem}#header .header-top{padding-bottom:1.25rem}#header .header-top>.container{position:relative}#header .header-top .menu{padding-right:15px;margin-bottom:.375rem}#header .header-top .position-static{position:static}#header .header-top a[data-depth="0"]{color:#7a7a7a;text-transform:uppercase}#header .header-top .search-widget{float:left}#header .top-menu-link{margin-right:1.25rem}.popover{font-family:inherit}#wrapper{background:#f1f1f1;box-shadow:inset 0 2px 5px 0 rgba(0,0,0,.11);padding-top:1.563rem}#wrapper .banner{margin-bottom:1.5rem;display:block}#wrapper .banner img{box-shadow:-1px 1px 7px 0 rgba(0,0,0,.15)}#wrapper .breadcrumb{background:transparent;padding:0}#wrapper .breadcrumb[data-depth="1"]{display:none}#wrapper .breadcrumb ol{padding-right:0;margin-bottom:0}#wrapper .breadcrumb li{display:inline}#wrapper .breadcrumb li:after{content:"/";color:#7a7a7a;margin:.3125rem}#wrapper .breadcrumb li:last-child{content:"/";color:#7a7a7a;margin:0}#wrapper .breadcrumb li:last-child:after{content:""}#wrapper .breadcrumb li a{color:#232323}#main .page-content,#main .page-header{margin-bottom:1.563rem}#main .page-content h6{margin-bottom:1.125rem}#main .page-content #notifications{margin-right:-15px;margin-left:-15px}#main .page-footer{margin-bottom:1.563rem}#notifications ul{margin-bottom:0}#footer{padding-top:2.5rem}@media (max-width:1199px){#header .header-nav{max-height:inherit}#header .header-nav .search-widget{float:none;width:15.63rem}}@media (max-width:991px){.container{max-width:100%}#header .logo{width:auto}#header .header-top .search-widget{min-width:inherit}#products .product-miniature,.featured-products .product-miniature{margin:0 auto}.sub-menu{right:0;min-width:100%}#blockcart-modal .product-image{width:100%;display:block;max-width:15.63rem;margin:0 auto .9375rem}#blockcart-modal .cart-content{padding-right:0}#blockcart-modal .product-name,#product-availability{margin-top:.625rem}#search_filters .facet .facet-label{text-align:right}.block-category .category-cover{position:relative;text-align:center}.block-category{padding-bottom:0}}@media (max-width:767px){#wrapper{box-shadow:none}#checkout-cart-summary{float:none;width:100%;margin-top:1rem}#header{background:#f1f1f1}#header .header-nav{background:#fff;margin-bottom:.625rem;color:#232323}#header .header-nav .top-logo{padding-top:11px}#header .header-nav .top-logo a img{max-height:50px;max-width:100%}#header .header-nav .right-nav{-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column}#header .header-nav .user-info{text-align:right;margin-right:0}#header .header-nav .user-info .logged{color:#2fb5d2}#header .header-nav .blockcart{margin-right:0;background:inherit}#header .header-nav .blockcart.active{margin-right:.5rem}#header .header-nav .blockcart.inactive .cart-products-count{display:none}#header .header-top{background:#f1f1f1;padding-bottom:0}#header .header-top a[data-depth="0"]{color:#232323}#header .header-top .search-widget{width:100%}#header.is-open,#header.is-open .header-top{background-color:#fff}section.checkout-step{width:100%}.default-input{min-width:100%}label{clear:both}#products .product-miniature,.featured-products .product-miniature{margin:0 auto}.block-contact{padding-right:.9375rem;border:none}.dropdown-item,.menu{padding-right:0}#footer{padding-top:.5rem}}@media (max-width:575px){#content-wrapper,#left-column{padding-right:0!important;padding-left:0!important}}input[type=number]{-moz-appearance:textfield}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0} -@font-face { - font-family: Vazir; - src: url('https://res.cloudinary.com/ipresta/raw/upload/v1522045380/vazir_v18.0.0/Vazir.eot'); - src: url('https://res.cloudinary.com/ipresta/raw/upload/v1522045380/vazir_v18.0.0/Vazir.eot?#iefix') format('embedded-opentype'), - url('https://res.cloudinary.com/ipresta/raw/upload/v1522045380/vazir_v18.0.0/Vazir.woff') format('woff'), - url('https://res.cloudinary.com/ipresta/raw/upload/v1522044764/vazir_v18.0.0/Vazir.ttf') format('truetype'); - font-weight: normal; -} - -@font-face { - font-family: Vazir; - src: url('https://res.cloudinary.com/ipresta/raw/upload/v1522045523/vazir_v18.0.0/Vazir-Bold.eot'); - src: url('https://res.cloudinary.com/ipresta/raw/upload/v1522045523/vazir_v18.0.0/Vazir-Bold.eot?#iefix') format('embedded-opentype'), - url('https://res.cloudinary.com/ipresta/raw/upload/v1522045380/vazir_v18.0.0/Vazir.woff') format('woff'), - url('https://res.cloudinary.com/ipresta/raw/upload/v1522045523/vazir_v18.0.0/Vazir-Bold.ttf') format('truetype'); - font-weight: bold; -} - -@font-face { - font-family: Vazir; - src: url('https://res.cloudinary.com/ipresta/raw/upload/v1522044764/vazir_v18.0.0/Vazir-Light.eot'); - src: url('https://res.cloudinary.com/ipresta/raw/upload/v1522044764/vazir_v18.0.0/Vazir-Light.eot?#iefix') format('embedded-opentype'), - url('https://res.cloudinary.com/ipresta/raw/upload/v1522044764/vazir_v18.0.0/Vazir-Light.woff') format('woff'), - url('https://res.cloudinary.com/ipresta/raw/upload/v1522044764/vazir_v18.0.0/Vazir-Light.ttf') format('truetype'); - font-weight: 300; -} -body.lang-fa{ - font-family: "Vazir",sans-serif; -} -.rtl-flip:not(.rtl-no-flip), .material-icons:not(.rtl-no-flip) { - -moz-transform: scaleX(-1); - -o-transform: scaleX(-1); - -webkit-transform: scaleX(-1); - transform: scaleX(-1); - filter: FlipH; - -ms-filter: "FlipH"; -} -.magnitude:before { - content: "?"; - opacity: 0; -} diff --git a/themes/classic/assets/img/modules/index.php b/themes/classic/assets/img/modules/index.php deleted file mode 100644 index 6bf70e95..00000000 --- a/themes/classic/assets/img/modules/index.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @copyright 2007-2012 PrestaShop SA -* @version Release: $Revision: 13573 $ -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/themes/classic/assets/img/modules/leoblog/1/b/b-blog-1.jpg b/themes/classic/assets/img/modules/leoblog/1/b/b-blog-1.jpg deleted file mode 100644 index b805fa69..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/1/b/b-blog-1.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/1/b/b-blog-2.jpg b/themes/classic/assets/img/modules/leoblog/1/b/b-blog-2.jpg deleted file mode 100644 index b805fa69..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/1/b/b-blog-2.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/1/b/b-blog-3.jpg b/themes/classic/assets/img/modules/leoblog/1/b/b-blog-3.jpg deleted file mode 100644 index b805fa69..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/1/b/b-blog-3.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/1/b/b-blog-4.jpg b/themes/classic/assets/img/modules/leoblog/1/b/b-blog-4.jpg deleted file mode 100644 index b805fa69..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/1/b/b-blog-4.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/1/b/b-blog-5.jpg b/themes/classic/assets/img/modules/leoblog/1/b/b-blog-5.jpg deleted file mode 100644 index b805fa69..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/1/b/b-blog-5.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/1/b/b-blog-6.jpg b/themes/classic/assets/img/modules/leoblog/1/b/b-blog-6.jpg deleted file mode 100644 index b805fa69..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/1/b/b-blog-6.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/1/b/b-blog-7.jpg b/themes/classic/assets/img/modules/leoblog/1/b/b-blog-7.jpg deleted file mode 100644 index b805fa69..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/1/b/b-blog-7.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/1/b/index.php b/themes/classic/assets/img/modules/leoblog/1/b/index.php deleted file mode 100644 index 6bf70e95..00000000 --- a/themes/classic/assets/img/modules/leoblog/1/b/index.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @copyright 2007-2012 PrestaShop SA -* @version Release: $Revision: 13573 $ -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/themes/classic/assets/img/modules/leoblog/1/c/[themeforest]_Floral_banner.jpg b/themes/classic/assets/img/modules/leoblog/1/c/[themeforest]_Floral_banner.jpg deleted file mode 100644 index 47c4d677..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/1/c/[themeforest]_Floral_banner.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/1/c/category-1.jpg b/themes/classic/assets/img/modules/leoblog/1/c/category-1.jpg deleted file mode 100644 index 82fd1c1a..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/1/c/category-1.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/1/c/category-2.jpg b/themes/classic/assets/img/modules/leoblog/1/c/category-2.jpg deleted file mode 100644 index 82fd1c1a..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/1/c/category-2.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/1/c/category-3.jpg b/themes/classic/assets/img/modules/leoblog/1/c/category-3.jpg deleted file mode 100644 index 82fd1c1a..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/1/c/category-3.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/1/c/index.php b/themes/classic/assets/img/modules/leoblog/1/c/index.php deleted file mode 100644 index 6bf70e95..00000000 --- a/themes/classic/assets/img/modules/leoblog/1/c/index.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @copyright 2007-2012 PrestaShop SA -* @version Release: $Revision: 13573 $ -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/themes/classic/assets/img/modules/leoblog/1/index.php b/themes/classic/assets/img/modules/leoblog/1/index.php deleted file mode 100644 index 6bf70e95..00000000 --- a/themes/classic/assets/img/modules/leoblog/1/index.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @copyright 2007-2012 PrestaShop SA -* @version Release: $Revision: 13573 $ -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/themes/classic/assets/img/modules/leoblog/index.php b/themes/classic/assets/img/modules/leoblog/index.php deleted file mode 100644 index 6bf70e95..00000000 --- a/themes/classic/assets/img/modules/leoblog/index.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @copyright 2007-2012 PrestaShop SA -* @version Release: $Revision: 13573 $ -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-1.jpg b/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-1.jpg deleted file mode 100644 index b805fa69..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-1.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-2.jpg b/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-2.jpg deleted file mode 100644 index b805fa69..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-2.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-3.jpg b/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-3.jpg deleted file mode 100644 index b805fa69..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-3.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-4.jpg b/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-4.jpg deleted file mode 100644 index b805fa69..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-4.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-5.jpg b/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-5.jpg deleted file mode 100644 index b805fa69..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-5.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-6.jpg b/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-6.jpg deleted file mode 100644 index b805fa69..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-6.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-7.jpg b/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-7.jpg deleted file mode 100644 index b805fa69..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/sample/b/b-blog-7.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/sample/b/index.php b/themes/classic/assets/img/modules/leoblog/sample/b/index.php deleted file mode 100644 index 6bf70e95..00000000 --- a/themes/classic/assets/img/modules/leoblog/sample/b/index.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @copyright 2007-2012 PrestaShop SA -* @version Release: $Revision: 13573 $ -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/themes/classic/assets/img/modules/leoblog/sample/c/[themeforest]_Floral_banner.jpg b/themes/classic/assets/img/modules/leoblog/sample/c/[themeforest]_Floral_banner.jpg deleted file mode 100644 index 47c4d677..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/sample/c/[themeforest]_Floral_banner.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/sample/c/category-1.jpg b/themes/classic/assets/img/modules/leoblog/sample/c/category-1.jpg deleted file mode 100644 index 82fd1c1a..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/sample/c/category-1.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/sample/c/category-2.jpg b/themes/classic/assets/img/modules/leoblog/sample/c/category-2.jpg deleted file mode 100644 index 82fd1c1a..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/sample/c/category-2.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/sample/c/category-3.jpg b/themes/classic/assets/img/modules/leoblog/sample/c/category-3.jpg deleted file mode 100644 index 82fd1c1a..00000000 Binary files a/themes/classic/assets/img/modules/leoblog/sample/c/category-3.jpg and /dev/null differ diff --git a/themes/classic/assets/img/modules/leoblog/sample/c/index.php b/themes/classic/assets/img/modules/leoblog/sample/c/index.php deleted file mode 100644 index 6bf70e95..00000000 --- a/themes/classic/assets/img/modules/leoblog/sample/c/index.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @copyright 2007-2012 PrestaShop SA -* @version Release: $Revision: 13573 $ -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/themes/classic/assets/img/modules/leoblog/sample/index.php b/themes/classic/assets/img/modules/leoblog/sample/index.php deleted file mode 100644 index 6bf70e95..00000000 --- a/themes/classic/assets/img/modules/leoblog/sample/index.php +++ /dev/null @@ -1,36 +0,0 @@ - -* @copyright 2007-2012 PrestaShop SA -* @version Release: $Revision: 13573 $ -* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -* International Registered Trademark & Property of PrestaShop SA -*/ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; \ No newline at end of file diff --git a/themes/classic/assets/js/custom.js b/themes/classic/assets/js/custom.js deleted file mode 100644 index f4c0bc88..00000000 --- a/themes/classic/assets/js/custom.js +++ /dev/null @@ -1,4 +0,0 @@ -/* - * Custom code goes here. - * A template should always ship with an empty custom.js - */ diff --git a/themes/classic/assets/js/theme.js b/themes/classic/assets/js/theme.js deleted file mode 100644 index d1b0e878..00000000 --- a/themes/classic/assets/js/theme.js +++ /dev/null @@ -1 +0,0 @@ -!function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=26)}([function(t,e){t.exports=jQuery},function(t,e){t.exports=prestashop},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var n=0;n5&&function(){var t=0;(0,a.default)(e).find(".color").each(function(e,n){e>4&&((0,a.default)(n).hide(),t++)}),(0,a.default)(e).find(".js-count").append("+"+t)}()})}}]),t}();e.default=s,t.exports=e.default},function(t,e,n){"use strict";var i,r;!function(t){function e(t){var e=t.length,i=n.type(t);return"function"!==i&&!n.isWindow(t)&&(!(1!==t.nodeType||!e)||("array"===i||0===e||"number"==typeof e&&e>0&&e-1 in t))}if(!t.jQuery){var n=function t(e,n){return new t.fn.init(e,n)};n.isWindow=function(t){return t&&t===t.window},n.type=function(t){return t?"object"==typeof t||"function"==typeof t?r[a.call(t)]||"object":typeof t:t+""},n.isArray=Array.isArray||function(t){return"array"===n.type(t)},n.isPlainObject=function(t){var e;if(!t||"object"!==n.type(t)||t.nodeType||n.isWindow(t))return!1;try{if(t.constructor&&!o.call(t,"constructor")&&!o.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch(t){return!1}for(e in t);return void 0===e||o.call(t,e)},n.each=function(t,n,i){var r=0,o=t.length,a=e(t);if(i){if(a)for(;r0?r=a:n=a}while(Math.abs(o)>v&&++s=g?c(e,s):0===l?s:d(e,n,n+_)}function h(){E=!0,t===n&&i===r||f()}var m=4,g=.001,v=1e-7,y=10,b=11,_=1/(b-1),x="Float32Array"in e;if(4!==arguments.length)return!1;for(var w=0;w<4;++w)if("number"!=typeof arguments[w]||isNaN(arguments[w])||!isFinite(arguments[w]))return!1;t=Math.min(t,1),i=Math.min(i,1),t=Math.max(t,0),i=Math.max(i,0);var S=x?new Float32Array(b):new Array(b),E=!1,C=function(e){return E||h(),t===n&&i===r?e:0===e?0:1===e?1:l(p(e),n,r)};C.getControlPoints=function(){return[{x:t,y:n},{x:i,y:r}]};var T="generateBezier("+[t,n,i,r]+")";return C.toString=function(){return T},C}function f(t,e){var n=t;return _.isString(t)?E.Easings[t]||(n=!1):n=_.isArray(t)&&1===t.length?u.apply(null,t):_.isArray(t)&&2===t.length?C.apply(null,t.concat([e])):!(!_.isArray(t)||4!==t.length)&&c.apply(null,t),!1===n&&(n=E.Easings[E.defaults.easing]?E.defaults.easing:S),n}function d(t){if(t){var e=E.timestamp&&!0!==t?t:v.now(),n=E.State.calls.length;n>1e4&&(E.State.calls=r(E.State.calls),n=E.State.calls.length);for(var o=0;o4;t--){var e=n.createElement("div");if(e.innerHTML="\x3c!--[if IE "+t+"]>=0?e:Math.max(0,i+e),s=n<0?i+n:Math.min(n,i),l=s-a;if(l>0)if(o=new Array(l),this.charAt)for(r=0;r=0}:function(t,e){for(var n=0;n1e-4&&Math.abs(s.v)>1e-4))break;return o?function(t){return u[t*(u.length-1)|0]}:c}}();E.Easings={linear:function(t){return t},swing:function(t){return.5-Math.cos(t*Math.PI)/2},spring:function(t){return 1-Math.cos(4.5*t*Math.PI)*Math.exp(6*-t)}},h.each([["ease",[.25,.1,.25,1]],["ease-in",[.42,0,1,1]],["ease-out",[0,0,.58,1]],["ease-in-out",[.42,0,.58,1]],["easeInSine",[.47,0,.745,.715]],["easeOutSine",[.39,.575,.565,1]],["easeInOutSine",[.445,.05,.55,.95]],["easeInQuad",[.55,.085,.68,.53]],["easeOutQuad",[.25,.46,.45,.94]],["easeInOutQuad",[.455,.03,.515,.955]],["easeInCubic",[.55,.055,.675,.19]],["easeOutCubic",[.215,.61,.355,1]],["easeInOutCubic",[.645,.045,.355,1]],["easeInQuart",[.895,.03,.685,.22]],["easeOutQuart",[.165,.84,.44,1]],["easeInOutQuart",[.77,0,.175,1]],["easeInQuint",[.755,.05,.855,.06]],["easeOutQuint",[.23,1,.32,1]],["easeInOutQuint",[.86,0,.07,1]],["easeInExpo",[.95,.05,.795,.035]],["easeOutExpo",[.19,1,.22,1]],["easeInOutExpo",[1,0,0,1]],["easeInCirc",[.6,.04,.98,.335]],["easeOutCirc",[.075,.82,.165,1]],["easeInOutCirc",[.785,.135,.15,.86]]],function(t,e){E.Easings[e[0]]=c.apply(null,e[1])});var T=E.CSS={RegEx:{isHex:/^#([A-f\d]{3}){1,2}$/i,valueUnwrap:/^[A-z]+\((.*)\)$/i,wrappedValueAlreadyExtracted:/[0-9.]+ [0-9.]+ [0-9.]+( [0-9.]+)?/,valueSplit:/([A-z]+\(.+\))|(([A-z0-9#-.]+?)(?=\s|$))/gi},Lists:{colors:["fill","stroke","stopColor","color","backgroundColor","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor","outlineColor"],transformsBase:["translateX","translateY","scale","scaleX","scaleY","skewX","skewY","rotateZ"],transforms3D:["transformPerspective","translateZ","scaleZ","rotateX","rotateY"],units:["%","em","ex","ch","rem","vw","vh","vmin","vmax","cm","mm","Q","in","pc","pt","px","deg","grad","rad","turn","s","ms"],colorNames:{aliceblue:"240,248,255",antiquewhite:"250,235,215",aquamarine:"127,255,212",aqua:"0,255,255",azure:"240,255,255",beige:"245,245,220",bisque:"255,228,196",black:"0,0,0",blanchedalmond:"255,235,205",blueviolet:"138,43,226",blue:"0,0,255",brown:"165,42,42",burlywood:"222,184,135",cadetblue:"95,158,160",chartreuse:"127,255,0",chocolate:"210,105,30",coral:"255,127,80",cornflowerblue:"100,149,237",cornsilk:"255,248,220",crimson:"220,20,60",cyan:"0,255,255",darkblue:"0,0,139",darkcyan:"0,139,139",darkgoldenrod:"184,134,11",darkgray:"169,169,169",darkgrey:"169,169,169",darkgreen:"0,100,0",darkkhaki:"189,183,107",darkmagenta:"139,0,139",darkolivegreen:"85,107,47",darkorange:"255,140,0",darkorchid:"153,50,204",darkred:"139,0,0",darksalmon:"233,150,122",darkseagreen:"143,188,143",darkslateblue:"72,61,139",darkslategray:"47,79,79",darkturquoise:"0,206,209",darkviolet:"148,0,211",deeppink:"255,20,147",deepskyblue:"0,191,255",dimgray:"105,105,105",dimgrey:"105,105,105",dodgerblue:"30,144,255",firebrick:"178,34,34",floralwhite:"255,250,240",forestgreen:"34,139,34",fuchsia:"255,0,255",gainsboro:"220,220,220",ghostwhite:"248,248,255",gold:"255,215,0",goldenrod:"218,165,32",gray:"128,128,128",grey:"128,128,128",greenyellow:"173,255,47",green:"0,128,0",honeydew:"240,255,240",hotpink:"255,105,180",indianred:"205,92,92",indigo:"75,0,130",ivory:"255,255,240",khaki:"240,230,140",lavenderblush:"255,240,245",lavender:"230,230,250",lawngreen:"124,252,0",lemonchiffon:"255,250,205",lightblue:"173,216,230",lightcoral:"240,128,128",lightcyan:"224,255,255",lightgoldenrodyellow:"250,250,210",lightgray:"211,211,211",lightgrey:"211,211,211",lightgreen:"144,238,144",lightpink:"255,182,193",lightsalmon:"255,160,122",lightseagreen:"32,178,170",lightskyblue:"135,206,250",lightslategray:"119,136,153",lightsteelblue:"176,196,222",lightyellow:"255,255,224",limegreen:"50,205,50",lime:"0,255,0",linen:"250,240,230",magenta:"255,0,255",maroon:"128,0,0",mediumaquamarine:"102,205,170",mediumblue:"0,0,205",mediumorchid:"186,85,211",mediumpurple:"147,112,219",mediumseagreen:"60,179,113",mediumslateblue:"123,104,238",mediumspringgreen:"0,250,154",mediumturquoise:"72,209,204",mediumvioletred:"199,21,133",midnightblue:"25,25,112",mintcream:"245,255,250",mistyrose:"255,228,225",moccasin:"255,228,181",navajowhite:"255,222,173",navy:"0,0,128",oldlace:"253,245,230",olivedrab:"107,142,35",olive:"128,128,0",orangered:"255,69,0",orange:"255,165,0",orchid:"218,112,214",palegoldenrod:"238,232,170",palegreen:"152,251,152",paleturquoise:"175,238,238",palevioletred:"219,112,147",papayawhip:"255,239,213",peachpuff:"255,218,185",peru:"205,133,63",pink:"255,192,203",plum:"221,160,221",powderblue:"176,224,230",purple:"128,0,128",red:"255,0,0",rosybrown:"188,143,143",royalblue:"65,105,225",saddlebrown:"139,69,19",salmon:"250,128,114",sandybrown:"244,164,96",seagreen:"46,139,87",seashell:"255,245,238",sienna:"160,82,45",silver:"192,192,192",skyblue:"135,206,235",slateblue:"106,90,205",slategray:"112,128,144",snow:"255,250,250",springgreen:"0,255,127",steelblue:"70,130,180",tan:"210,180,140",teal:"0,128,128",thistle:"216,191,216",tomato:"255,99,71",turquoise:"64,224,208",violet:"238,130,238",wheat:"245,222,179",whitesmoke:"245,245,245",white:"255,255,255",yellowgreen:"154,205,50",yellow:"255,255,0"}},Hooks:{templates:{textShadow:["Color X Y Blur","black 0px 0px 0px"],boxShadow:["Color X Y Blur Spread","black 0px 0px 0px 0px"],clip:["Top Right Bottom Left","0px 0px 0px 0px"],backgroundPosition:["X Y","0% 0%"],transformOrigin:["X Y Z","50% 50% 0px"],perspectiveOrigin:["X Y","50% 50%"]},registered:{},register:function(){for(var t=0;t=1?"":"alpha(opacity="+parseInt(100*parseFloat(n),10)+")"}else switch(t){case"name":return"opacity";case"extract":case"inject":return n}}},register:function(){function t(t,e,n){if("border-box"===T.getPropertyValue(e,"boxSizing").toString().toLowerCase()===(n||!1)){var i,r,o=0,a="width"===t?["Left","Right"]:["Top","Bottom"],s=["padding"+a[0],"padding"+a[1],"border"+a[0]+"Width","border"+a[1]+"Width"];for(i=0;i9)||E.State.isGingerbread||(T.Lists.transformsBase=T.Lists.transformsBase.concat(T.Lists.transforms3D));for(var n=0;n8)&&3===o.split(" ").length&&(o+=" 1"),o;case"inject":return/^rgb/.test(r)?r:(m<=8?4===r.split(" ").length&&(r=r.split(/\s+/).slice(0,3).join(" ")):3===r.split(" ").length&&(r+=" 1"),(m<=8?"rgb":"rgba")+"("+r.replace(/\s+/g,",").replace(/\.(\d)+(?=,)/g,"")+")")}}}();T.Normalizations.registered.innerWidth=e("width",!0),T.Normalizations.registered.innerHeight=e("height",!0),T.Normalizations.registered.outerWidth=e("width"),T.Normalizations.registered.outerHeight=e("height")}},Names:{camelCase:function(t){return t.replace(/-(\w)/g,function(t,e){return e.toUpperCase()})},SVGAttribute:function(t){var e="width|height|x|y|cx|cy|r|rx|ry|x1|x2|y1|y2";return(m||E.State.isAndroid&&!E.State.isChrome)&&(e+="|transform"),new RegExp("^("+e+")$","i").test(t)},prefixCheck:function(t){if(E.State.prefixMatches[t])return[E.State.prefixMatches[t],!0];for(var e=["","Webkit","Moz","ms","O"],n=0,i=e.length;n=4&&"("===P?k++:(k&&k<5||k>=4&&")"===P&&--k<5)&&(k=0),0===D&&"r"===P||1===D&&"g"===P||2===D&&"b"===P||3===D&&"a"===P||D>=3&&"("===P?(3===D&&"a"===P&&(N=1),D++):N&&","===P?++N>3&&(D=N=0):(N&&D<(N?5:4)||D>=(N?4:3)&&")"===P&&--D<(N?5:4))&&(D=N=0)}}C===v.length&&A===m.length||(E.debug,a=i),a&&(I.length?(E.debug,v=I,m=O,b=x=""):a=i)}a||(y=S(r,v),v=y[0],x=y[1],y=S(r,m),m=y[0].replace(/^([+-\/*])=/,function(t,e){return w=e,""}),b=y[1],v=parseFloat(v)||0,m=parseFloat(m)||0,"%"===b&&(/^(fontSize|lineHeight)$/.test(r)?(m/=100,b="em"):/^scale/.test(r)?(m/=100,b=""):/(Red|Green|Blue)$/i.test(r)&&(m=m/100*255,b="")));if(/[\/*]/.test(w))b=x;else if(x!==b&&0!==v)if(0===m)b=x;else{s=s||function(){var i={myParent:t.parentNode||n.body,position:T.getPropertyValue(t,"position"),fontSize:T.getPropertyValue(t,"fontSize")},r=i.position===F.lastPosition&&i.myParent===F.lastParent,o=i.fontSize===F.lastFontSize;F.lastParent=i.myParent,F.lastPosition=i.position,F.lastFontSize=i.fontSize;var a={};if(o&&r)a.emToPx=F.lastEmToPx,a.percentToPxWidth=F.lastPercentToPxWidth,a.percentToPxHeight=F.lastPercentToPxHeight;else{var s=c&&c.isSVG?n.createElementNS("http://www.w3.org/2000/svg","rect"):n.createElement("div");E.init(s),i.myParent.appendChild(s),h.each(["overflow","overflowX","overflowY"],function(t,e){E.CSS.setPropertyValue(s,e,"hidden")}),E.CSS.setPropertyValue(s,"position",i.position),E.CSS.setPropertyValue(s,"fontSize",i.fontSize),E.CSS.setPropertyValue(s,"boxSizing","content-box"),h.each(["minWidth","maxWidth","width","minHeight","maxHeight","height"],function(t,e){E.CSS.setPropertyValue(s,e,"100%")}),E.CSS.setPropertyValue(s,"paddingLeft","100em"),a.percentToPxWidth=F.lastPercentToPxWidth=(parseFloat(T.getPropertyValue(s,"width",null,!0))||1)/100,a.percentToPxHeight=F.lastPercentToPxHeight=(parseFloat(T.getPropertyValue(s,"height",null,!0))||1)/100,a.emToPx=F.lastEmToPx=(parseFloat(T.getPropertyValue(s,"paddingLeft"))||1)/100,i.myParent.removeChild(s)}return null===F.remToPx&&(F.remToPx=parseFloat(T.getPropertyValue(n.body,"fontSize"))||16),null===F.vwToPx&&(F.vwToPx=parseFloat(e.innerWidth)/100,F.vhToPx=parseFloat(e.innerHeight)/100),a.remToPx=F.remToPx,a.vwToPx=F.vwToPx,a.vhToPx=F.vhToPx,E.debug,a}();var q=/margin|padding|left|right|width|text|word|letter/i.test(r)||/X$/.test(r)||"x"===r?"x":"y";switch(x){case"%":v*="x"===q?s.percentToPxWidth:s.percentToPxHeight;break;case"px":break;default:v*=s[x+"ToPx"]}switch(b){case"%":v*=1/("x"===q?s.percentToPxWidth:s.percentToPxHeight);break;case"px":break;default:v*=1/s[b+"ToPx"]}}switch(w){case"+":m=v+m;break;case"-":m=v-m;break;case"*":m*=v;break;case"/":m=v/m}u[r]={rootPropertyValue:d,startValue:v,currentValue:v,endValue:m,unitType:b,easing:g},a&&(u[r].pattern=a),E.debug};for(var L in x)if(x.hasOwnProperty(L)){var j=T.Names.camelCase(L),B=function(e,n){var i,o,a;return _.isFunction(e)&&(e=e.call(t,r,I)),_.isArray(e)?(i=e[0],!_.isArray(e[1])&&/^[\d-]/.test(e[1])||_.isFunction(e[1])||T.RegEx.isHex.test(e[1])?a=e[1]:_.isString(e[1])&&!T.RegEx.isHex.test(e[1])&&E.Easings[e[1]]||_.isArray(e[1])?(o=n?e[1]:f(e[1],l.duration),a=e[2]):a=e[1]||e[2]):i=e,n||(o=o||l.easing),_.isFunction(i)&&(i=i.call(t,r,I)),_.isFunction(a)&&(a=a.call(t,r,I)),[i||0,o,a]}(x[L]);if(b(T.Lists.colors,j)){var V=B[0],M=B[1],H=B[2];if(T.RegEx.isHex.test(V)){for(var W=["Red","Green","Blue"],U=T.Values.hexToRgb(V),q=H?T.Values.hexToRgb(H):i,z=0;z0?"up":"down"}function d(t){var e=(0,a.default)(t.currentTarget),n=e.data("update-url"),i=e.attr("value"),r=e.val();if(r!=parseInt(r)||r<0||isNaN(r))return void e.val(i);var o=r-i;0!==o&&(e.attr("value",r),s(n,c(o),e))}var h=".js-cart-line-product-quantity",m=[];l.default.on("updateCart",function(){(0,a.default)(".quickview").modal("hide")}),l.default.on("updatedCart",function(){r()}),r();var g=(0,a.default)("body"),v=function(){for(var t;m.length>0;)t=m.pop(),t.abort()},y=function(t){return(0,a.default)(t.parents(".bootstrap-touchspin").find("input"))},b=function(t){t.preventDefault();var e=(0,a.default)(t.currentTarget),n=t.currentTarget.dataset,i=o(e,t.namespace),r={ajax:"1",action:"update"};void 0!==i&&(v(),a.default.ajax({url:i.url,method:"POST",data:r,dataType:"json",beforeSend:function(t){m.push(t)}}).then(function(t){p.checkUpdateOpertation(t),y(e).val(t.quantity),l.default.emit("updateCart",{reason:n})}).fail(function(t){l.default.emit("handleError",{eventType:"updateProductInCart",resp:t,cartAction:i.type})}))};g.on("click",'[data-link-action="delete-from-cart"], [data-link-action="remove-voucher"]',b),g.on("touchspin.on.startdownspin",u,b),g.on("touchspin.on.startupspin",u,b),g.on("focusout keyup",h,function(t){if("keyup"===t.type)return 13===t.keyCode&&d(t),!1;d(t)});g.on("hidden.bs.collapse","#promo-code",function(){(0,a.default)(".display-promo").show(400)}),g.on("click",".promo-code-button",function(t){t.preventDefault(),(0,a.default)("#promo-code").collapse("toggle")}),g.on("click",".display-promo",function(t){(0,a.default)(t.currentTarget).hide(400)}),g.on("click",".js-discount .code",function(t){t.stopPropagation();var e=(0,a.default)(t.currentTarget);return(0,a.default)("[name=discount_name]").val(e.text()),(0,a.default)("#promo-code").collapse("show"),(0,a.default)(".display-promo").hide(400),!1})});var p={switchErrorStat:function(){var t=(0,a.default)(".checkout a");if(((0,a.default)("#notifications article.alert-danger").length||""!==d&&!c)&&t.addClass("disabled"),""!==d){var e=' ";(0,a.default)("#notifications .container").html(e),d="",f=!1,c&&t.removeClass("disabled")}else!c&&f&&(c=!1,f=!1,(0,a.default)("#notifications .container").html(""),t.removeClass("disabled"))},checkUpdateOpertation:function(t){c=t.hasOwnProperty("hasError");var e=t.errors||"";d=e instanceof Array?e.join(" "):e,f=!0}}},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function r(){(0,s.default)(".js-terms a").on("click",function(t){t.preventDefault();var e=(0,s.default)(t.target).attr("href");e&&(e+="?content_only=1",s.default.get(e,function(t){(0,s.default)("#modal").find(".js-modal-content").html((0,s.default)(t).find(".page-cms").contents())}).fail(function(t){u.default.emit("handleError",{eventType:"clickTerms",resp:t})})),(0,s.default)("#modal").modal("show")}),(0,s.default)(".js-gift-checkbox").on("click",function(t){(0,s.default)("#gift").collapse("toggle")})}function o(){(0,s.default)(".card-block .cart-summary-products p a").on("click",function(t){t=(0,s.default)(this).find("i.material-icons"),"expand_more"==t.text()?t.text("expand_less"):t.text("expand_more")})}var a=n(0),s=i(a),l=n(1),u=i(l);(0,s.default)(document).ready(function(){1===(0,s.default)("body#checkout").length&&(r(),o()),u.default.on("updatedDeliveryForm",function(t){void 0!==t.deliveryOption&&0!==t.deliveryOption.length&&((0,s.default)(".carrier-extra-content").hide(),t.deliveryOption.next(".carrier-extra-content").slideDown())})})},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}var r=n(1),o=i(r),a=n(0),s=i(a);o.default.blockcart=o.default.blockcart||{},o.default.blockcart.showModal=function(t){function e(){return(0,s.default)("#blockcart-modal")}var n=e();n.length&&n.remove(),(0,s.default)("body").append(t),n=e(),n.modal("show").on("hidden.bs.modal",function(t){o.default.emit("updateProduct",{reason:t.currentTarget.dataset,event:t})})}},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){for(var n=0;n(0,a.default)(".js-modal-mask").height()&&(t.move("down"),(0,a.default)(".js-modal-arrow-up").css("opacity","1"))})}},{key:"move",value:function(t){var e=(0,a.default)(".js-modal-product-images"),n=(0,a.default)(".js-modal-product-images li img").height()+10,i=e.position().top;e.velocity({translateY:"up"===t?i+n:i-n},function(){e.position().top>=0?(0,a.default)(".js-modal-arrow-up").css("opacity",".2"):e.position().top+e.height()<=(0,a.default)(".js-modal-mask").height()&&(0,a.default)(".js-modal-arrow-down").css("opacity",".2")})}}]),t}();e.default=s,t.exports=e.default},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;n0&&this.options.badge&&this.$elementFilestyle.find("label").append(' '+e.length+""),this.$elementFilestyle.find(".group-span-filestyle").removeClass("input-group-btn")}}},size:function(t){if(void 0===t)return this.options.size;var e=this.$elementFilestyle.find("label"),n=this.$elementFilestyle.find("input");e.removeClass("btn-lg btn-sm"),n.removeClass("input-lg input-sm"),"nr"!=t&&(e.addClass("btn-"+t),n.addClass("input-"+t))},placeholder:function(t){if(void 0===t)return this.options.placeholder;this.options.placeholder=t,this.$elementFilestyle.find("input").attr("placeholder",t)},buttonText:function(t){if(void 0===t)return this.options.buttonText;this.options.buttonText=t,this.$elementFilestyle.find("label .buttonText").html(this.options.buttonText)},buttonName:function(t){if(void 0===t)return this.options.buttonName;this.options.buttonName=t,this.$elementFilestyle.find("label").attr({class:"btn "+this.options.buttonName})},iconName:function(t){if(void 0===t)return this.options.iconName;this.$elementFilestyle.find(".icon-span-filestyle").attr({class:"icon-span-filestyle "+this.options.iconName})},htmlIcon:function(){return this.options.icon?' ':""},htmlInput:function(){return this.options.input?' ':""},pushNameFiles:function(){var t="",e=[];void 0===this.$element[0].files?e[0]={name:this.$element[0]&&this.$element[0].value}:e=this.$element[0].files;for(var n=0;n",i=n.options.buttonBefore?o+n.htmlInput():n.htmlInput()+o,n.$elementFilestyle=t('
      '+i+"
      "),n.$elementFilestyle.find(".group-span-filestyle").attr("tabindex","0").keypress(function(t){if(13===t.keyCode||32===t.charCode)return n.$elementFilestyle.find("label").click(),!1}),n.$element.css({position:"absolute",clip:"rect(0px 0px 0px 0px)"}).attr("tabindex","-1").after(n.$elementFilestyle),n.options.disabled&&n.$element.attr("disabled","true"),n.$element.change(function(){var t=n.pushNameFiles();0==n.options.input&&n.options.badge?0==n.$elementFilestyle.find(".badge").length?n.$elementFilestyle.find("label").append(' '+t.length+""):0==t.length?n.$elementFilestyle.find(".badge").remove():n.$elementFilestyle.find(".badge").html(t.length):n.$elementFilestyle.find(".badge").remove()}),window.navigator.userAgent.search(/firefox/i)>-1&&n.$elementFilestyle.find("label").click(function(){return n.$element.click(),!1})}};var i=t.fn.filestyle;t.fn.filestyle=function(e,i){var r="",o=this.each(function(){if("file"===t(this).attr("type")){var o=t(this),a=o.data("filestyle"),s=t.extend({},t.fn.filestyle.defaults,e,"object"==typeof e&&e);a||(o.data("filestyle",a=new n(this,s)),a.constructor()),"string"==typeof e&&(r=a[e](i))}});return void 0!==typeof r?r:o},t.fn.filestyle.defaults={buttonText:"Choose file",iconName:"glyphicon glyphicon-folder-open",buttonName:"btn-default",size:"nr",input:!0,badge:!0,icon:!0,buttonBefore:!1,disabled:!1,placeholder:""},t.fn.filestyle.noConflict=function(){return t.fn.filestyle=i,this},t(function(){t(".filestyle").each(function(){var e=t(this),n={input:"false"!==e.attr("data-input"),icon:"false"!==e.attr("data-icon"),buttonBefore:"true"===e.attr("data-buttonBefore"),disabled:"true"===e.attr("data-disabled"),size:e.attr("data-size"),buttonText:e.attr("data-buttonText"),buttonName:e.attr("data-buttonName"),iconName:e.attr("data-iconName"),badge:"false"!==e.attr("data-badge"),placeholder:e.attr("data-placeholder")};e.filestyle(n)})})}(window.jQuery)},function(t,e,n){"use strict";!function(t){t.fn.scrollbox=function(e){var n={linear:!1,startDelay:2,delay:3,step:5,speed:32,switchItems:1,direction:"vertical",distance:"auto",autoPlay:!0,onMouseOverPause:!0,paused:!1,queue:null,listElement:"ul",listItemElement:"li",infiniteLoop:!0,switchAmount:0,afterForward:null,afterBackward:null,triggerStackable:!1};return e=t.extend(n,e),e.scrollOffset="vertical"===e.direction?"scrollTop":"scrollLeft",e.queue&&(e.queue=t("#"+e.queue)),this.each(function(){var n,i,r,o,a,s,l,u,c,f=t(this),d=null,p=null,h=!1,m=0,g=0;e.onMouseOverPause&&(f.bind("mouseover",function(){h=!0}),f.bind("mouseout",function(){h=!1})),n=f.children(e.listElement+":first-child"),!1===e.infiniteLoop&&0===e.switchAmount&&(e.switchAmount=n.children().length),s=function(){if(!h){var r,a,s,l,u;if(r=n.children(e.listItemElement+":first-child"),l="auto"!==e.distance?e.distance:"vertical"===e.direction?r.outerHeight(!0):r.outerWidth(!0),e.linear?s=Math.min(f[0][e.scrollOffset]+e.step,l):(u=Math.max(3,parseInt(.3*(l-f[0][e.scrollOffset]),10)),s=Math.min(f[0][e.scrollOffset]+u,l)),f[0][e.scrollOffset]=s,s>=l){for(a=0;a0?(n.append(e.queue.find(e.listItemElement)[0]),n.children(e.listItemElement+":first-child").remove()):n.append(n.children(e.listItemElement+":first-child")),++m;if(f[0][e.scrollOffset]=0,clearInterval(d),d=null,t.isFunction(e.afterForward)&&e.afterForward.call(f,{switchCount:m,currentFirstChild:n.children(e.listItemElement+":first-child")}),e.triggerStackable&&0!==g)return void i();if(!1===e.infiniteLoop&&m>=e.switchAmount)return;e.autoPlay&&(p=setTimeout(o,1e3*e.delay))}}},l=function(){if(!h){var r,a,s,l,u;if(0===f[0][e.scrollOffset]){for(a=0;a0?(g--,p=setTimeout(o,0)):(g++,p=setTimeout(r,0)))},o=function(){clearInterval(d),d=setInterval(s,e.speed)},r=function(){clearInterval(d),d=setInterval(l,e.speed)},u=function(){e.autoPlay=!0,h=!1,clearInterval(d),d=setInterval(s,e.speed)},c=function(){h=!0},a=function(t){e.delay=t||e.delay,clearTimeout(p),e.autoPlay&&(p=setTimeout(o,1e3*e.delay))},e.autoPlay&&(p=setTimeout(o,1e3*e.startDelay)),f.bind("resetClock",function(t){a(t)}),f.bind("forward",function(){e.triggerStackable?null!==d?g++:o():(clearTimeout(p),o())}),f.bind("backward",function(){e.triggerStackable?null!==d?g--:r():(clearTimeout(p),r())}),f.bind("pauseHover",function(){c()}),f.bind("forwardHover",function(){u()}),f.bind("speedUp",function(t,n){"undefined"===n&&(n=Math.max(1,parseInt(e.speed/2,10))),e.speed=n}),f.bind("speedDown",function(t,n){"undefined"===n&&(n=2*e.speed),e.speed=n}),f.bind("updateConfig",function(n,i){e=t.extend(e,i)})})}}(jQuery)},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function r(t){(0,a.default)("#search_filters").replaceWith(t.rendered_facets),(0,a.default)("#js-active-search-filters").replaceWith(t.rendered_active_filters),(0,a.default)("#js-product-list-top").replaceWith(t.rendered_products_top),(0,a.default)("#js-product-list").replaceWith(t.rendered_products),(0,a.default)("#js-product-list-bottom").replaceWith(t.rendered_products_bottom),t.rendered_products_header&&(0,a.default)("#js-product-list-header").replaceWith(t.rendered_products_header),(new c.default).init()}var o=n(0),a=i(o),s=n(1),l=i(s);n(4);var u=n(3),c=i(u);(0,a.default)(document).ready(function(){l.default.on("clickQuickView",function(e){var n={action:"quickview",id_product:e.dataset.idProduct,id_product_attribute:e.dataset.idProductAttribute};a.default.post(l.default.urls.pages.product,n,null,"json").then(function(e){(0,a.default)("body").append(e.quickview_html);var n=(0,a.default)("#quickview-modal-"+e.product.id+"-"+e.product.id_product_attribute);n.modal("show"),t(n),n.on("hidden.bs.modal",function(){n.remove()})}).fail(function(t){l.default.emit("handleError",{eventType:"clickQuickView",resp:t})})});var t=function(t){var n=(0,a.default)(".js-arrows"),i=t.find(".js-qv-product-images");(0,a.default)(".js-thumb").on("click",function(t){(0,a.default)(".js-thumb").hasClass("selected")&&(0,a.default)(".js-thumb").removeClass("selected"),(0,a.default)(t.currentTarget).addClass("selected"),(0,a.default)(".js-qv-product-cover").attr("src",(0,a.default)(t.target).data("image-large-src"))}),i.find("li").length<=4?n.hide():n.on("click",function(t){(0,a.default)(t.target).hasClass("arrow-up")&&(0,a.default)(".js-qv-product-images").position().top<0?(e("up"),(0,a.default)(".arrow-down").css("opacity","1")):(0,a.default)(t.target).hasClass("arrow-down")&&i.position().top+i.height()>(0,a.default)(".js-qv-mask").height()&&(e("down"),(0,a.default)(".arrow-up").css("opacity","1"))}),t.find("#quantity_wanted").TouchSpin({verticalbuttons:!0,verticalupclass:"material-icons touchspin-up",verticaldownclass:"material-icons touchspin-down",buttondown_class:"btn btn-touchspin js-touchspin",buttonup_class:"btn btn-touchspin js-touchspin",min:1,max:1e6})},e=function(t){var e=(0,a.default)(".js-qv-product-images"),n=(0,a.default)(".js-qv-product-images li img").height()+20,i=e.position().top;e.velocity({translateY:"up"===t?i+n:i-n},function(){e.position().top>=0?(0,a.default)(".arrow-up").css("opacity",".2"):e.position().top+e.height()<=(0,a.default)(".js-qv-mask").height()&&(0,a.default)(".arrow-down").css("opacity",".2")})};(0,a.default)("body").on("click","#search_filter_toggler",function(){(0,a.default)("#search_filters_wrapper").removeClass("hidden-sm-down"),(0,a.default)("#content-wrapper").addClass("hidden-sm-down"),(0,a.default)("#footer").addClass("hidden-sm-down")}),(0,a.default)("#search_filter_controls .clear").on("click",function(){(0,a.default)("#search_filters_wrapper").addClass("hidden-sm-down"),(0,a.default)("#content-wrapper").removeClass("hidden-sm-down"),(0,a.default)("#footer").removeClass("hidden-sm-down")}),(0,a.default)("#search_filter_controls .ok").on("click",function(){(0,a.default)("#search_filters_wrapper").addClass("hidden-sm-down"),(0,a.default)("#content-wrapper").removeClass("hidden-sm-down"),(0,a.default)("#footer").removeClass("hidden-sm-down")});var n=function(t){if(void 0!==t.target.dataset.searchUrl)return t.target.dataset.searchUrl;if(void 0===(0,a.default)(t.target).parent()[0].dataset.searchUrl)throw new Error("Can not parse search URL");return(0,a.default)(t.target).parent()[0].dataset.searchUrl};(0,a.default)("body").on("change","#search_filters input[data-search-url]",function(t){l.default.emit("updateFacets",n(t))}),(0,a.default)("body").on("click",".js-search-filters-clear-all",function(t){l.default.emit("updateFacets",n(t))}),(0,a.default)("body").on("click",".js-search-link",function(t){t.preventDefault(),l.default.emit("updateFacets",(0,a.default)(t.target).closest("a").get(0).href)}),(0,a.default)("body").on("change","#search_filters select",function(t){var e=(0,a.default)(t.target).closest("form");l.default.emit("updateFacets","?"+e.serialize())}),l.default.on("updateProductList",function(t){r(t),window.scrollTo(0,0)})})},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}var r=n(0),o=i(r),a=n(1),s=i(a);(0,o.default)(document).ready(function(){function t(){(0,o.default)(".js-thumb").on("click",function(t){(0,o.default)(".js-modal-product-cover").attr("src",(0,o.default)(t.target).data("image-large-src")),(0,o.default)(".selected").removeClass("selected"),(0,o.default)(t.target).addClass("selected"),(0,o.default)(".js-qv-product-cover").prop("src",(0,o.default)(t.currentTarget).data("image-large-src"))})}function e(){(0,o.default)("#main .js-qv-product-images li").length>2?((0,o.default)("#main .js-qv-mask").addClass("scroll"),(0,o.default)(".scroll-box-arrows").addClass("scroll"),(0,o.default)("#main .js-qv-mask").scrollbox({direction:"h",distance:113,autoPlay:!1}),(0,o.default)(".scroll-box-arrows .left").click(function(){(0,o.default)("#main .js-qv-mask").trigger("backward")}),(0,o.default)(".scroll-box-arrows .right").click(function(){(0,o.default)("#main .js-qv-mask").trigger("forward")})):((0,o.default)("#main .js-qv-mask").removeClass("scroll"),(0,o.default)(".scroll-box-arrows").removeClass("scroll"))}function n(){(0,o.default)(".js-file-input").on("change",function(t){var e=void 0,n=void 0;(e=(0,o.default)(t.currentTarget)[0])&&(n=e.files[0])&&(0,o.default)(e).prev().text(n.name)})}!function(){var t=(0,o.default)("#quantity_wanted");t.TouchSpin({verticalbuttons:!0,verticalupclass:"material-icons touchspin-up",verticaldownclass:"material-icons touchspin-down",buttondown_class:"btn btn-touchspin js-touchspin",buttonup_class:"btn btn-touchspin js-touchspin",min:parseInt(t.attr("min"),10),max:1e6}),(0,o.default)("body").on("change keyup","#quantity_wanted",function(t){(0,o.default)(t.currentTarget).trigger("touchspin.stopspin"),s.default.emit("updateProduct",{eventType:"updatedProductQuantity",event:t})})}(),n(),t(),e(),s.default.on("updatedProduct",function(i){if(n(),t(),i&&i.product_minimal_quantity){var r=parseInt(i.product_minimal_quantity,10);(0,o.default)("#quantity_wanted").trigger("touchspin.updatesettings",{min:r})}e(),(0,o.default)((0,o.default)(".tabs .nav-link.active").attr("href")).addClass("active").removeClass("fade"),(0,o.default)(".js-product-images-modal").replaceWith(i.product_images_modal)})})},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function r(t,e){var n=e.children().detach();e.empty().append(t.children().detach()),t.append(n)}function o(){u.default.responsive.mobile?(0,s.default)("*[id^='_desktop_']").each(function(t,e){var n=(0,s.default)("#"+e.id.replace("_desktop_","_mobile_"));n.length&&r((0,s.default)(e),n)}):(0,s.default)("*[id^='_mobile_']").each(function(t,e){var n=(0,s.default)("#"+e.id.replace("_mobile_","_desktop_"));n.length&&r((0,s.default)(e),n)}),u.default.emit("responsive update",{mobile:u.default.responsive.mobile})}var a=n(0),s=i(a),l=n(1),u=i(l);u.default.responsive=u.default.responsive||{},u.default.responsive.current_width=window.innerWidth,u.default.responsive.min_width=768,u.default.responsive.mobile=u.default.responsive.current_width=e&&n=e;u.default.responsive.current_width=n,u.default.responsive.mobile=u.default.responsive.current_width'+T.prefix+"",s=''+T.postfix+"";r.hasClass("input-group-btn")?(n='",r.append(n)):(n='",t(n).insertBefore(L)),o.hasClass("input-group-btn")?(i='",o.prepend(i)):(i='",t(i).insertAfter(L)),t(a).insertBefore(L),t(s).insertAfter(L),A=e}function p(){var e;e=T.verticalbuttons?'
      '+T.prefix+''+T.postfix+'
      ':'
      '+T.prefix+''+T.postfix+'
      ",A=t(e).insertBefore(L),t(".bootstrap-touchspin-prefix",A).after(L),L.hasClass("input-sm")?A.addClass("input-group-sm"):L.hasClass("input-lg")&&A.addClass("input-group-lg")}function h(){I={down:t(".bootstrap-touchspin-down",A),up:t(".bootstrap-touchspin-up",A),input:t("input",A),prefix:t(".bootstrap-touchspin-prefix",A).addClass(T.prefix_extraclass),postfix:t(".bootstrap-touchspin-postfix",A).addClass(T.postfix_extraclass)}}function m(){""===T.prefix&&I.prefix.hide(),""===T.postfix&&I.postfix.hide()}function g(){L.on("keydown",function(t){var e=t.keyCode||t.which;38===e?("up"!==V&&(x(),E()),t.preventDefault()):40===e&&("down"!==V&&(w(),S()),t.preventDefault())}),L.on("keyup",function(t){var e=t.keyCode||t.which;38===e?C():40===e&&C()}),L.on("blur",function(){b()}),I.down.on("keydown",function(t){var e=t.keyCode||t.which;32!==e&&13!==e||("down"!==V&&(w(),S()),t.preventDefault())}),I.down.on("keyup",function(t){var e=t.keyCode||t.which;32!==e&&13!==e||C()}),I.up.on("keydown",function(t){var e=t.keyCode||t.which;32!==e&&13!==e||("up"!==V&&(x(),E()),t.preventDefault())}),I.up.on("keyup",function(t){var e=t.keyCode||t.which;32!==e&&13!==e||C()}),I.down.on("mousedown.touchspin",function(t){I.down.off("touchstart.touchspin"),L.is(":disabled")||(w(),S(),t.preventDefault(),t.stopPropagation())}),I.down.on("touchstart.touchspin",function(t){I.down.off("mousedown.touchspin"),L.is(":disabled")||(w(),S(),t.preventDefault(),t.stopPropagation())}),I.up.on("mousedown.touchspin",function(t){I.up.off("touchstart.touchspin"),L.is(":disabled")||(x(),E(),t.preventDefault(),t.stopPropagation())}),I.up.on("touchstart.touchspin",function(t){I.up.off("mousedown.touchspin"),L.is(":disabled")||(x(),E(),t.preventDefault(),t.stopPropagation())}),I.up.on("mouseout touchleave touchend touchcancel",function(t){V&&(t.stopPropagation(),C())}),I.down.on("mouseout touchleave touchend touchcancel",function(t){V&&(t.stopPropagation(),C())}),I.down.on("mousemove touchmove",function(t){V&&(t.stopPropagation(),t.preventDefault())}),I.up.on("mousemove touchmove",function(t){V&&(t.stopPropagation(),t.preventDefault())}),t(document).on(n(["mouseup","touchend","touchcancel"],i).join(" "),function(t){V&&(t.preventDefault(),C())}),t(document).on(n(["mousemove","touchmove","scroll","scrollstart"],i).join(" "),function(t){V&&(t.preventDefault(),C())}),L.on("mousewheel DOMMouseScroll",function(t){if(T.mousewheel&&L.is(":focus")){var e=t.originalEvent.wheelDelta||-t.originalEvent.deltaY||-t.originalEvent.detail;t.stopPropagation(),t.preventDefault(),e<0?w():x()}})}function v(){L.on("touchspin.uponce",function(){C(),x()}),L.on("touchspin.downonce",function(){C(),w()}),L.on("touchspin.startupspin",function(){E()}),L.on("touchspin.startdownspin",function(){S()}),L.on("touchspin.stopspin",function(){C()}),L.on("touchspin.updatesettings",function(t,e){s(e)})}function y(t){switch(T.forcestepdivisibility){case"round":return(Math.round(t/T.step)*T.step).toFixed(T.decimals);case"floor":return(Math.floor(t/T.step)*T.step).toFixed(T.decimals);case"ceil":return(Math.ceil(t/T.step)*T.step).toFixed(T.decimals);default:return t}}function b(){var t,e,n;if(""===(t=L.val()))return void(""!==T.replacementval&&(L.val(T.replacementval),L.trigger("change")));T.decimals>0&&"."===t||(e=parseFloat(t),isNaN(e)&&(e=""!==T.replacementval?T.replacementval:0),n=e,e.toString()!==t&&(n=e),eT.max&&(n=T.max),n=y(n),Number(t).toString()!==n.toString()&&(L.val(n),L.trigger("change")))}function _(){if(T.booster){var t=Math.pow(2,Math.floor(B/T.boostat))*T.step;return T.maxboostedstep&&t>T.maxboostedstep&&(t=T.maxboostedstep,O=Math.round(O/t)*t),Math.max(T.step,t)}return T.step}function x(){b(),O=parseFloat(I.input.val()),isNaN(O)&&(O=0);var t=O,e=_();O+=e,O>T.max&&(O=T.max,L.trigger("touchspin.on.max"),C()),I.input.val(Number(O).toFixed(T.decimals)),t!==O&&L.trigger("change")}function w(){b(),O=parseFloat(I.input.val()),isNaN(O)&&(O=0);var t=O,e=_();O-=e,O=4)throw new Error("Bootstrap's JavaScript requires at least jQuery v1.9.1 but less than v4.0.0")}(jQuery),function(){function t(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function e(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r=function(){function t(t,e){for(var n=0;nthis._items.length-1||e<0)){if(this._isSliding)return void t(this._element).one(p.SLID,function(){return n.to(e)});if(i===e)return this.pause(),void this.cycle();var r=e>i?d.NEXT:d.PREVIOUS;this._slide(r,this._items[e])}},l.prototype.dispose=function(){t(this._element).off(s),t.removeData(this._element,a),this._items=null,this._config=null,this._element=null,this._interval=null,this._isPaused=null,this._isSliding=null,this._activeElement=null,this._indicatorsElement=null},l.prototype._getConfig=function(n){return n=t.extend({},c,n),o.typeCheckConfig(e,n,f),n},l.prototype._addEventListeners=function(){this._config.keyboard&&t(this._element).on(p.KEYDOWN,t.proxy(this._keydown,this)),"hover"!==this._config.pause||"ontouchstart"in document.documentElement||t(this._element).on(p.MOUSEENTER,t.proxy(this.pause,this)).on(p.MOUSELEAVE,t.proxy(this.cycle,this))},l.prototype._keydown=function(t){if(t.preventDefault(),!/input|textarea/i.test(t.target.tagName))switch(t.which){case 37:this.prev();break;case 39:this.next();break;default:return}},l.prototype._getItemIndex=function(e){return this._items=t.makeArray(t(e).parent().find(m.ITEM)),this._items.indexOf(e)},l.prototype._getItemByDirection=function(t,e){var n=t===d.NEXT,i=t===d.PREVIOUS,r=this._getItemIndex(e),o=this._items.length-1;if((i&&0===r||n&&r===o)&&!this._config.wrap)return e;var a=t===d.PREVIOUS?-1:1,s=(r+a)%this._items.length;return-1===s?this._items[this._items.length-1]:this._items[s]},l.prototype._triggerSlideEvent=function(e,n){var i=t.Event(p.SLIDE,{relatedTarget:e,direction:n});return t(this._element).trigger(i),i},l.prototype._setActiveIndicatorElement=function(e){if(this._indicatorsElement){t(this._indicatorsElement).find(m.ACTIVE).removeClass(h.ACTIVE);var n=this._indicatorsElement.children[this._getItemIndex(e)];n&&t(n).addClass(h.ACTIVE)}},l.prototype._slide=function(e,n){var i=this,r=t(this._element).find(m.ACTIVE_ITEM)[0],a=n||r&&this._getItemByDirection(e,r),s=Boolean(this._interval),l=e===d.NEXT?h.LEFT:h.RIGHT;if(a&&t(a).hasClass(h.ACTIVE))return void(this._isSliding=!1);if(!this._triggerSlideEvent(a,l).isDefaultPrevented()&&r&&a){this._isSliding=!0,s&&this.pause(),this._setActiveIndicatorElement(a);var u=t.Event(p.SLID,{relatedTarget:a,direction:l});o.supportsTransitionEnd()&&t(this._element).hasClass(h.SLIDE)?(t(a).addClass(e),o.reflow(a),t(r).addClass(l),t(a).addClass(l),t(r).one(o.TRANSITION_END,function(){t(a).removeClass(l).removeClass(e),t(a).addClass(h.ACTIVE),t(r).removeClass(h.ACTIVE).removeClass(e).removeClass(l),i._isSliding=!1,setTimeout(function(){return t(i._element).trigger(u)},0)}).emulateTransitionEnd(600)):(t(r).removeClass(h.ACTIVE),t(a).addClass(h.ACTIVE),this._isSliding=!1,t(this._element).trigger(u)),s&&this.cycle()}},l._jQueryInterface=function(e){return this.each(function(){var n=t(this).data(a),r=t.extend({},c,t(this).data());"object"===(void 0===e?"undefined":i(e))&&t.extend(r,e);var o="string"==typeof e?e:r.slide;if(n||(n=new l(this,r),t(this).data(a,n)),"number"==typeof e)n.to(e);else if("string"==typeof o){if(void 0===n[o])throw new Error('No method named "'+o+'"');n[o]()}else r.interval&&(n.pause(),n.cycle())})},l._dataApiClickHandler=function(e){var n=o.getSelectorFromElement(this);if(n){var i=t(n)[0];if(i&&t(i).hasClass(h.CAROUSEL)){var r=t.extend({},t(i).data(),t(this).data()),s=this.getAttribute("data-slide-to");s&&(r.interval=!1),l._jQueryInterface.call(t(i),r),s&&t(i).data(a).to(s),e.preventDefault()}}},r(l,null,[{key:"VERSION",get:function(){return"4.0.0-alpha.5"}},{key:"Default",get:function(){return c}}]),l}();t(document).on(p.CLICK_DATA_API,m.DATA_SLIDE,g._dataApiClickHandler),t(window).on(p.LOAD_DATA_API,function(){t(m.DATA_RIDE).each(function(){var e=t(this);g._jQueryInterface.call(e,e.data())})}),t.fn[e]=g._jQueryInterface,t.fn[e].Constructor=g,t.fn[e].noConflict=function(){return t.fn[e]=u,g._jQueryInterface}}(jQuery),function(t){var e="collapse",a="bs.collapse",s="."+a,l=t.fn[e],u={toggle:!0,parent:""},c={toggle:"boolean",parent:"string"},f={SHOW:"show"+s,SHOWN:"shown"+s,HIDE:"hide"+s,HIDDEN:"hidden"+s,CLICK_DATA_API:"click"+s+".data-api"},d={IN:"in",COLLAPSE:"collapse",COLLAPSING:"collapsing",COLLAPSED:"collapsed"},p={WIDTH:"width",HEIGHT:"height"},h={ACTIVES:".card > .in, .card > .collapsing",DATA_TOGGLE:'[data-toggle="collapse"]'},m=function(){function s(e,i){n(this,s),this._isTransitioning=!1,this._element=e,this._config=this._getConfig(i),this._triggerArray=t.makeArray(t('[data-toggle="collapse"][href="#'+e.id+'"],[data-toggle="collapse"][data-target="#'+e.id+'"]')),this._parent=this._config.parent?this._getParent():null,this._config.parent||this._addAriaAndCollapsedClass(this._element,this._triggerArray),this._config.toggle&&this.toggle()}return s.prototype.toggle=function(){t(this._element).hasClass(d.IN)?this.hide():this.show()},s.prototype.show=function(){var e=this;if(!this._isTransitioning&&!t(this._element).hasClass(d.IN)){var n=void 0,i=void 0;if(this._parent&&(n=t.makeArray(t(h.ACTIVES)),n.length||(n=null)),!(n&&(i=t(n).data(a))&&i._isTransitioning)){var r=t.Event(f.SHOW);if(t(this._element).trigger(r),!r.isDefaultPrevented()){n&&(s._jQueryInterface.call(t(n),"hide"),i||t(n).data(a,null));var l=this._getDimension();t(this._element).removeClass(d.COLLAPSE).addClass(d.COLLAPSING),this._element.style[l]=0,this._element.setAttribute("aria-expanded",!0),this._triggerArray.length&&t(this._triggerArray).removeClass(d.COLLAPSED).attr("aria-expanded",!0),this.setTransitioning(!0);var u=function(){t(e._element).removeClass(d.COLLAPSING).addClass(d.COLLAPSE).addClass(d.IN),e._element.style[l]="",e.setTransitioning(!1),t(e._element).trigger(f.SHOWN)};if(!o.supportsTransitionEnd())return void u();var c=l[0].toUpperCase()+l.slice(1),p="scroll"+c;t(this._element).one(o.TRANSITION_END,u).emulateTransitionEnd(600),this._element.style[l]=this._element[p]+"px"}}}},s.prototype.hide=function(){var e=this;if(!this._isTransitioning&&t(this._element).hasClass(d.IN)){var n=t.Event(f.HIDE);if(t(this._element).trigger(n),!n.isDefaultPrevented()){var i=this._getDimension(),r=i===p.WIDTH?"offsetWidth":"offsetHeight";this._element.style[i]=this._element[r]+"px",o.reflow(this._element),t(this._element).addClass(d.COLLAPSING).removeClass(d.COLLAPSE).removeClass(d.IN),this._element.setAttribute("aria-expanded",!1),this._triggerArray.length&&t(this._triggerArray).addClass(d.COLLAPSED).attr("aria-expanded",!1),this.setTransitioning(!0);var a=function(){e.setTransitioning(!1),t(e._element).removeClass(d.COLLAPSING).addClass(d.COLLAPSE).trigger(f.HIDDEN)};return this._element.style[i]="",o.supportsTransitionEnd()?void t(this._element).one(o.TRANSITION_END,a).emulateTransitionEnd(600):void a()}}},s.prototype.setTransitioning=function(t){this._isTransitioning=t},s.prototype.dispose=function(){t.removeData(this._element,a),this._config=null,this._parent=null,this._element=null,this._triggerArray=null,this._isTransitioning=null},s.prototype._getConfig=function(n){return n=t.extend({},u,n),n.toggle=Boolean(n.toggle),o.typeCheckConfig(e,n,c),n},s.prototype._getDimension=function(){return t(this._element).hasClass(p.WIDTH)?p.WIDTH:p.HEIGHT},s.prototype._getParent=function(){var e=this,n=t(this._config.parent)[0],i='[data-toggle="collapse"][data-parent="'+this._config.parent+'"]';return t(n).find(i).each(function(t,n){e._addAriaAndCollapsedClass(s._getTargetFromElement(n),[n])}),n},s.prototype._addAriaAndCollapsedClass=function(e,n){if(e){var i=t(e).hasClass(d.IN);e.setAttribute("aria-expanded",i),n.length&&t(n).toggleClass(d.COLLAPSED,!i).attr("aria-expanded",i)}},s._getTargetFromElement=function(e){var n=o.getSelectorFromElement(e);return n?t(n)[0]:null},s._jQueryInterface=function(e){return this.each(function(){var n=t(this),r=n.data(a),o=t.extend({},u,n.data(),"object"===(void 0===e?"undefined":i(e))&&e);if(!r&&o.toggle&&/show|hide/.test(e)&&(o.toggle=!1),r||(r=new s(this,o),n.data(a,r)),"string"==typeof e){if(void 0===r[e])throw new Error('No method named "'+e+'"');r[e]()}})},r(s,null,[{key:"VERSION",get:function(){return"4.0.0-alpha.5"}},{key:"Default",get:function(){return u}}]),s}();t(document).on(f.CLICK_DATA_API,h.DATA_TOGGLE,function(e){e.preventDefault();var n=m._getTargetFromElement(this),i=t(n).data(a),r=i?"toggle":t(this).data();m._jQueryInterface.call(t(n),r)}),t.fn[e]=m._jQueryInterface,t.fn[e].Constructor=m,t.fn[e].noConflict=function(){return t.fn[e]=l,m._jQueryInterface}}(jQuery),function(t){var e="dropdown",i="bs.dropdown",a="."+i,s=".data-api",l=t.fn[e],u={HIDE:"hide"+a,HIDDEN:"hidden"+a,SHOW:"show"+a,SHOWN:"shown"+a,CLICK:"click"+a,CLICK_DATA_API:"click"+a+s,KEYDOWN_DATA_API:"keydown"+a+s},c={BACKDROP:"dropdown-backdrop",DISABLED:"disabled",OPEN:"open"},f={BACKDROP:".dropdown-backdrop",DATA_TOGGLE:'[data-toggle="dropdown"]',FORM_CHILD:".dropdown form",ROLE_MENU:'[role="menu"]',ROLE_LISTBOX:'[role="listbox"]',NAVBAR_NAV:".navbar-nav",VISIBLE_ITEMS:'[role="menu"] li:not(.disabled) a, [role="listbox"] li:not(.disabled) a'},d=function(){function e(t){n(this,e),this._element=t,this._addEventListeners()}return e.prototype.toggle=function(){if(this.disabled||t(this).hasClass(c.DISABLED))return!1;var n=e._getParentFromElement(this),i=t(n).hasClass(c.OPEN);if(e._clearMenus(),i)return!1;if("ontouchstart"in document.documentElement&&!t(n).closest(f.NAVBAR_NAV).length){var r=document.createElement("div");r.className=c.BACKDROP,t(r).insertBefore(this),t(r).on("click",e._clearMenus)}var o={relatedTarget:this},a=t.Event(u.SHOW,o);return t(n).trigger(a),!a.isDefaultPrevented()&&(this.focus(),this.setAttribute("aria-expanded","true"),t(n).toggleClass(c.OPEN),t(n).trigger(t.Event(u.SHOWN,o)),!1)},e.prototype.dispose=function(){t.removeData(this._element,i),t(this._element).off(a),this._element=null},e.prototype._addEventListeners=function(){t(this._element).on(u.CLICK,this.toggle)},e._jQueryInterface=function(n){return this.each(function(){var r=t(this).data(i);if(r||t(this).data(i,r=new e(this)),"string"==typeof n){if(void 0===r[n])throw new Error('No method named "'+n+'"');r[n].call(this)}})},e._clearMenus=function(n){if(!n||3!==n.which){var i=t(f.BACKDROP)[0];i&&i.parentNode.removeChild(i);for(var r=t.makeArray(t(f.DATA_TOGGLE)),o=0;o0&&s--,40===n.which&&sdocument.documentElement.clientHeight;!this._isBodyOverflowing&&t&&(this._element.style.paddingLeft=this._scrollbarWidth+"px"),this._isBodyOverflowing&&!t&&(this._element.style.paddingRight=this._scrollbarWidth+"px")},l.prototype._resetAdjustments=function(){this._element.style.paddingLeft="",this._element.style.paddingRight=""},l.prototype._checkScrollbar=function(){this._isBodyOverflowing=document.body.clientWidth=n){var i=this._targets[this._targets.length-1];this._activeTarget!==i&&this._activate(i)}if(this._activeTarget&&t=this._offsets[r]&&(void 0===this._offsets[r+1]||t .nav-item .fade, > .fade",ACTIVE:".active",ACTIVE_CHILD:"> .nav-item > .active, > .active",DATA_TOGGLE:'[data-toggle="tab"], [data-toggle="pill"]',DROPDOWN_TOGGLE:".dropdown-toggle",DROPDOWN_ACTIVE_CHILD:"> .dropdown-menu .active"},f=function(){function e(t){n(this,e),this._element=t}return e.prototype.show=function(){var e=this;if(!this._element.parentNode||this._element.parentNode.nodeType!==Node.ELEMENT_NODE||!t(this._element).hasClass(u.ACTIVE)){var n=void 0,i=void 0,r=t(this._element).closest(c.UL)[0],a=o.getSelectorFromElement(this._element);r&&(i=t.makeArray(t(r).find(c.ACTIVE)),i=i[i.length-1]);var s=t.Event(l.HIDE,{relatedTarget:this._element}),f=t.Event(l.SHOW,{relatedTarget:i});if(i&&t(i).trigger(s),t(this._element).trigger(f),!f.isDefaultPrevented()&&!s.isDefaultPrevented()){a&&(n=t(a)[0]),this._activate(this._element,r);var d=function(){var n=t.Event(l.HIDDEN,{relatedTarget:e._element}),r=t.Event(l.SHOWN,{relatedTarget:i});t(i).trigger(n),t(e._element).trigger(r)};n?this._activate(n,n.parentNode,d):d()}}},e.prototype.dispose=function(){t.removeClass(this._element,i),this._element=null},e.prototype._activate=function(e,n,i){var r=t(n).find(c.ACTIVE_CHILD)[0],a=i&&o.supportsTransitionEnd()&&(r&&t(r).hasClass(u.FADE)||Boolean(t(n).find(c.FADE_CHILD)[0])),s=t.proxy(this._transitionComplete,this,e,r,a,i);r&&a?t(r).one(o.TRANSITION_END,s).emulateTransitionEnd(150):s(),r&&t(r).removeClass(u.IN)},e.prototype._transitionComplete=function(e,n,i,r){if(n){t(n).removeClass(u.ACTIVE);var a=t(n).find(c.DROPDOWN_ACTIVE_CHILD)[0];a&&t(a).removeClass(u.ACTIVE),n.setAttribute("aria-expanded",!1)}if(t(e).addClass(u.ACTIVE),e.setAttribute("aria-expanded",!0),i?(o.reflow(e),t(e).addClass(u.IN)):t(e).removeClass(u.FADE),e.parentNode&&t(e.parentNode).hasClass(u.DROPDOWN_MENU)){var s=t(e).closest(c.DROPDOWN)[0];s&&t(s).find(c.DROPDOWN_TOGGLE).addClass(u.ACTIVE),e.setAttribute("aria-expanded",!0)}r&&r()},e._jQueryInterface=function(n){return this.each(function(){var r=t(this),o=r.data(i);if(o||(o=o=new e(this),r.data(i,o)),"string"==typeof n){if(void 0===o[n])throw new Error('No method named "'+n+'"');o[n]()}})},r(e,null,[{key:"VERSION",get:function(){return"4.0.0-alpha.5"}}]),e}();t(document).on(l.CLICK_DATA_API,c.DATA_TOGGLE,function(e){e.preventDefault(),f._jQueryInterface.call(t(this),"show")}),t.fn[e]=f._jQueryInterface,t.fn[e].Constructor=f,t.fn[e].noConflict=function(){return t.fn[e]=s,f._jQueryInterface}}(jQuery),function(t){if(void 0===window.Tether)throw new Error("Bootstrap tooltips require Tether (http://tether.io/)");var e="tooltip",a="bs.tooltip",s="."+a,l=t.fn[e],u={animation:!0,template:'',trigger:"hover focus",title:"",delay:0,html:!1,selector:!1,placement:"top",offset:"0 0",constraints:[]},c={animation:"boolean",template:"string",title:"(string|element|function)",trigger:"string",delay:"(number|object)",html:"boolean",selector:"(string|boolean)",placement:"(string|function)",offset:"string",constraints:"array"},f={TOP:"bottom center",RIGHT:"middle left",BOTTOM:"top center",LEFT:"middle right"},d={IN:"in",OUT:"out"},p={HIDE:"hide"+s,HIDDEN:"hidden"+s,SHOW:"show"+s,SHOWN:"shown"+s,INSERTED:"inserted"+s,CLICK:"click"+s,FOCUSIN:"focusin"+s,FOCUSOUT:"focusout"+s,MOUSEENTER:"mouseenter"+s,MOUSELEAVE:"mouseleave"+s},h={FADE:"fade",IN:"in"},m={TOOLTIP:".tooltip",TOOLTIP_INNER:".tooltip-inner"},g={element:!1,enabled:!1},v={HOVER:"hover",FOCUS:"focus",CLICK:"click",MANUAL:"manual"},y=function(){function l(t,e){n(this,l),this._isEnabled=!0,this._timeout=0,this._hoverState="",this._activeTrigger={},this._tether=null,this.element=t,this.config=this._getConfig(e),this.tip=null,this._setListeners()}return l.prototype.enable=function(){this._isEnabled=!0},l.prototype.disable=function(){this._isEnabled=!1},l.prototype.toggleEnabled=function(){this._isEnabled=!this._isEnabled},l.prototype.toggle=function(e){if(e){var n=this.constructor.DATA_KEY,i=t(e.currentTarget).data(n);i||(i=new this.constructor(e.currentTarget,this._getDelegateConfig()),t(e.currentTarget).data(n,i)),i._activeTrigger.click=!i._activeTrigger.click,i._isWithActiveTrigger()?i._enter(null,i):i._leave(null,i)}else{if(t(this.getTipElement()).hasClass(h.IN))return void this._leave(null,this);this._enter(null,this)}},l.prototype.dispose=function(){clearTimeout(this._timeout),this.cleanupTether(),t.removeData(this.element,this.constructor.DATA_KEY),t(this.element).off(this.constructor.EVENT_KEY),this.tip&&t(this.tip).remove(),this._isEnabled=null,this._timeout=null,this._hoverState=null,this._activeTrigger=null,this._tether=null,this.element=null,this.config=null,this.tip=null},l.prototype.show=function(){var e=this,n=t.Event(this.constructor.Event.SHOW);if(this.isWithContent()&&this._isEnabled){t(this.element).trigger(n);var i=t.contains(this.element.ownerDocument.documentElement,this.element);if(n.isDefaultPrevented()||!i)return;var r=this.getTipElement(),a=o.getUID(this.constructor.NAME);r.setAttribute("id",a),this.element.setAttribute("aria-describedby",a),this.setContent(),this.config.animation&&t(r).addClass(h.FADE);var s="function"==typeof this.config.placement?this.config.placement.call(this,r,this.element):this.config.placement,u=this._getAttachment(s);t(r).data(this.constructor.DATA_KEY,this).appendTo(document.body),t(this.element).trigger(this.constructor.Event.INSERTED),this._tether=new Tether({attachment:u,element:r,target:this.element,classes:g,classPrefix:"bs-tether",offset:this.config.offset,constraints:this.config.constraints,addTargetClasses:!1}),o.reflow(r),this._tether.position(),t(r).addClass(h.IN);var c=function(){var n=e._hoverState;e._hoverState=null,t(e.element).trigger(e.constructor.Event.SHOWN),n===d.OUT&&e._leave(null,e)};if(o.supportsTransitionEnd()&&t(this.tip).hasClass(h.FADE))return void t(this.tip).one(o.TRANSITION_END,c).emulateTransitionEnd(l._TRANSITION_DURATION);c()}},l.prototype.hide=function(e){var n=this,i=this.getTipElement(),r=t.Event(this.constructor.Event.HIDE),a=function(){n._hoverState!==d.IN&&i.parentNode&&i.parentNode.removeChild(i),n.element.removeAttribute("aria-describedby"),t(n.element).trigger(n.constructor.Event.HIDDEN),n.cleanupTether(),e&&e()};t(this.element).trigger(r),r.isDefaultPrevented()||(t(i).removeClass(h.IN),o.supportsTransitionEnd()&&t(this.tip).hasClass(h.FADE)?t(i).one(o.TRANSITION_END,a).emulateTransitionEnd(150):a(),this._hoverState="")},l.prototype.isWithContent=function(){return Boolean(this.getTitle())},l.prototype.getTipElement=function(){return this.tip=this.tip||t(this.config.template)[0]},l.prototype.setContent=function(){var e=t(this.getTipElement());this.setElementContent(e.find(m.TOOLTIP_INNER),this.getTitle()),e.removeClass(h.FADE).removeClass(h.IN),this.cleanupTether()},l.prototype.setElementContent=function(e,n){var r=this.config.html;"object"===(void 0===n?"undefined":i(n))&&(n.nodeType||n.jquery)?r?t(n).parent().is(e)||e.empty().append(n):e.text(t(n).text()):e[r?"html":"text"](n)},l.prototype.getTitle=function(){var t=this.element.getAttribute("data-original-title");return t||(t="function"==typeof this.config.title?this.config.title.call(this.element):this.config.title),t},l.prototype.cleanupTether=function(){this._tether&&this._tether.destroy()},l.prototype._getAttachment=function(t){return f[t.toUpperCase()]},l.prototype._setListeners=function(){var e=this;this.config.trigger.split(" ").forEach(function(n){if("click"===n)t(e.element).on(e.constructor.Event.CLICK,e.config.selector,t.proxy(e.toggle,e));else if(n!==v.MANUAL){var i=n===v.HOVER?e.constructor.Event.MOUSEENTER:e.constructor.Event.FOCUSIN,r=n===v.HOVER?e.constructor.Event.MOUSELEAVE:e.constructor.Event.FOCUSOUT;t(e.element).on(i,e.config.selector,t.proxy(e._enter,e)).on(r,e.config.selector,t.proxy(e._leave,e))}}),this.config.selector?this.config=t.extend({},this.config,{trigger:"manual",selector:""}):this._fixTitle()},l.prototype._fixTitle=function(){var t=i(this.element.getAttribute("data-original-title"));(this.element.getAttribute("title")||"string"!==t)&&(this.element.setAttribute("data-original-title",this.element.getAttribute("title")||""),this.element.setAttribute("title",""))},l.prototype._enter=function(e,n){var i=this.constructor.DATA_KEY;return n=n||t(e.currentTarget).data(i),n||(n=new this.constructor(e.currentTarget,this._getDelegateConfig()),t(e.currentTarget).data(i,n)),e&&(n._activeTrigger["focusin"===e.type?v.FOCUS:v.HOVER]=!0),t(n.getTipElement()).hasClass(h.IN)||n._hoverState===d.IN?void(n._hoverState=d.IN):(clearTimeout(n._timeout),n._hoverState=d.IN,n.config.delay&&n.config.delay.show?void(n._timeout=setTimeout(function(){n._hoverState===d.IN&&n.show()},n.config.delay.show)):void n.show())},l.prototype._leave=function(e,n){var i=this.constructor.DATA_KEY;if(n=n||t(e.currentTarget).data(i),n||(n=new this.constructor(e.currentTarget,this._getDelegateConfig()),t(e.currentTarget).data(i,n)),e&&(n._activeTrigger["focusout"===e.type?v.FOCUS:v.HOVER]=!1),!n._isWithActiveTrigger())return clearTimeout(n._timeout),n._hoverState=d.OUT,n.config.delay&&n.config.delay.hide?void(n._timeout=setTimeout(function(){n._hoverState===d.OUT&&n.hide()},n.config.delay.hide)):void n.hide()},l.prototype._isWithActiveTrigger=function(){for(var t in this._activeTrigger)if(this._activeTrigger[t])return!0;return!1},l.prototype._getConfig=function(n){return n=t.extend({},this.constructor.Default,t(this.element).data(),n),n.delay&&"number"==typeof n.delay&&(n.delay={show:n.delay,hide:n.delay}),o.typeCheckConfig(e,n,this.constructor.DefaultType),n},l.prototype._getDelegateConfig=function(){var t={};if(this.config)for(var e in this.config)this.constructor.Default[e]!==this.config[e]&&(t[e]=this.config[e]);return t},l._jQueryInterface=function(e){return this.each(function(){var n=t(this).data(a),r="object"===(void 0===e?"undefined":i(e))?e:null;if((n||!/dispose|hide/.test(e))&&(n||(n=new l(this,r),t(this).data(a,n)),"string"==typeof e)){if(void 0===n[e])throw new Error('No method named "'+e+'"');n[e]()}})},r(l,null,[{key:"VERSION",get:function(){return"4.0.0-alpha.5"}},{key:"Default",get:function(){return u}},{key:"NAME",get:function(){return e}},{key:"DATA_KEY",get:function(){return a}},{key:"Event",get:function(){return p}},{key:"EVENT_KEY",get:function(){return s}},{key:"DefaultType",get:function(){return c}}]),l}();return t.fn[e]=y._jQueryInterface,t.fn[e].Constructor=y,t.fn[e].noConflict=function(){return t.fn[e]=l,y._jQueryInterface},y}(jQuery));!function(o){var s="popover",l="bs.popover",u="."+l,c=o.fn[s],f=o.extend({},a.Default,{placement:"right",trigger:"click",content:"",template:''}),d=o.extend({},a.DefaultType,{content:"(string|element|function)"}),p={FADE:"fade",IN:"in"},h={TITLE:".popover-title",CONTENT:".popover-content"},m={HIDE:"hide"+u,HIDDEN:"hidden"+u,SHOW:"show"+u,SHOWN:"shown"+u,INSERTED:"inserted"+u,CLICK:"click"+u,FOCUSIN:"focusin"+u,FOCUSOUT:"focusout"+u,MOUSEENTER:"mouseenter"+u,MOUSELEAVE:"mouseleave"+u},g=function(a){function c(){return n(this,c),t(this,a.apply(this,arguments))}return e(c,a),c.prototype.isWithContent=function(){return this.getTitle()||this._getContent()},c.prototype.getTipElement=function(){return this.tip=this.tip||o(this.config.template)[0]},c.prototype.setContent=function(){var t=o(this.getTipElement());this.setElementContent(t.find(h.TITLE),this.getTitle()),this.setElementContent(t.find(h.CONTENT),this._getContent()),t.removeClass(p.FADE).removeClass(p.IN),this.cleanupTether()},c.prototype._getContent=function(){return this.element.getAttribute("data-content")||("function"==typeof this.config.content?this.config.content.call(this.element):this.config.content)},c._jQueryInterface=function(t){return this.each(function(){var e=o(this).data(l),n="object"===(void 0===t?"undefined":i(t))?t:null;if((e||!/destroy|hide/.test(t))&&(e||(e=new c(this,n),o(this).data(l,e)),"string"==typeof t)){if(void 0===e[t])throw new Error('No method named "'+t+'"');e[t]()}})},r(c,null,[{key:"VERSION",get:function(){return"4.0.0-alpha.5"}},{key:"Default",get:function(){return f}},{key:"NAME",get:function(){return s}},{key:"DATA_KEY",get:function(){return l}},{key:"Event",get:function(){return m}},{key:"EVENT_KEY",get:function(){return u}},{key:"DefaultType",get:function(){return d}}]),c}(a);o.fn[s]=g._jQueryInterface,o.fn[s].Constructor=g,o.fn[s].noConflict=function(){return o.fn[s]=c,g._jQueryInterface}}(jQuery)}()},function(t,e,n){"use strict";function i(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(t){return"function"==typeof t}function o(t){return"number"==typeof t}function a(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}t.exports=i,i.EventEmitter=i,i.prototype._events=void 0,i.prototype._maxListeners=void 0,i.defaultMaxListeners=10,i.prototype.setMaxListeners=function(t){if(!o(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},i.prototype.emit=function(t){var e,n,i,o,l,u;if(this._events||(this._events={}),"error"===t&&(!this._events.error||a(this._events.error)&&!this._events.error.length)){if((e=arguments[1])instanceof Error)throw e;var c=new Error('Uncaught, unspecified "error" event. ('+e+")");throw c.context=e,c}if(n=this._events[t],s(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:o=Array.prototype.slice.call(arguments,1),n.apply(this,o)}else if(a(n))for(o=Array.prototype.slice.call(arguments,1),u=n.slice(),i=u.length,l=0;l0&&this._events[t].length>n&&(this._events[t].warned=!0,console.trace),this},i.prototype.on=i.prototype.addListener,i.prototype.once=function(t,e){function n(){this.removeListener(t,n),i||(i=!0,e.apply(this,arguments))}if(!r(e))throw TypeError("listener must be a function");var i=!1;return n.listener=e,this.on(t,n),this},i.prototype.removeListener=function(t,e){var n,i,o,s;if(!r(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],o=n.length,i=-1,n===e||r(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(a(n)){for(s=o;s-- >0;)if(n[s]===e||n[s].listener&&n[s].listener===e){i=s;break}if(i<0)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},i.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],r(n))this.removeListener(t,n);else if(n)for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},i.prototype.listeners=function(t){return this._events&&this._events[t]?r(this._events[t])?[this._events[t]]:this._events[t].slice():[]},i.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(r(e))return 1;if(e)return e.length}return 0},i.listenerCount=function(t,e){return t.listenerCount(e)}},function(t,e,n){"use strict";var i,i;!function(e){t.exports=e()}(function(){return function t(e,n,r){function o(s,l){if(!n[s]){if(!e[s]){var u="function"==typeof i&&i;if(!l&&u)return i(s,!0);if(a)return a(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var f=n[s]={exports:{}};e[s][0].call(f.exports,function(t){var n=e[s][1][t];return o(n||t)},f,f.exports,t,e,n,r)}return n[s].exports}for(var a="function"==typeof i&&i,s=0;s1&&"flex-start"===t.style.alignContent)for(e=0;i=t.lines[++r];)i.crossStart=e,e+=i.cross;else if(t.lines.length>1&&"flex-end"===t.style.alignContent)for(e=t.flexStyle.crossSpace;i=t.lines[++r];)i.crossStart=e,e+=i.cross;else if(t.lines.length>1&&"center"===t.style.alignContent)for(e=t.flexStyle.crossSpace/2;i=t.lines[++r];)i.crossStart=e,e+=i.cross;else if(t.lines.length>1&&"space-between"===t.style.alignContent)for(n=t.flexStyle.crossSpace/(t.lines.length-1),e=0;i=t.lines[++r];)i.crossStart=e,e+=i.cross+n;else if(t.lines.length>1&&"space-around"===t.style.alignContent)for(n=2*t.flexStyle.crossSpace/(2*t.lines.length),e=n/2;i=t.lines[++r];)i.crossStart=e,e+=i.cross+n;else for(n=t.flexStyle.crossSpace/t.lines.length,e=t.flexStyle.crossInnerBefore;i=t.lines[++r];)i.crossStart=e,i.cross+=n,e+=i.cross}},{}],2:[function(t,e,n){e.exports=function(t){for(var e,n=-1;line=t.lines[++n];)for(e=-1;child=line.children[++e];){var i=child.style.alignSelf;"auto"===i&&(i=t.style.alignItems),"flex-start"===i?child.flexStyle.crossStart=line.crossStart:"flex-end"===i?child.flexStyle.crossStart=line.crossStart+line.cross-child.flexStyle.crossOuter:"center"===i?child.flexStyle.crossStart=line.crossStart+(line.cross-child.flexStyle.crossOuter)/2:(child.flexStyle.crossStart=line.crossStart,child.flexStyle.crossOuter=line.cross,child.flexStyle.cross=child.flexStyle.crossOuter-child.flexStyle.crossBefore-child.flexStyle.crossAfter)}}},{}],3:[function(t,e,n){e.exports=function(t,e){var n="row"===e||"row-reverse"===e,i=t.mainAxis;if(i){n&&"inline"===i||!n&&"block"===i||(t.flexStyle={main:t.flexStyle.cross,cross:t.flexStyle.main,mainOffset:t.flexStyle.crossOffset,crossOffset:t.flexStyle.mainOffset,mainBefore:t.flexStyle.crossBefore,mainAfter:t.flexStyle.crossAfter,crossBefore:t.flexStyle.mainBefore,crossAfter:t.flexStyle.mainAfter,mainInnerBefore:t.flexStyle.crossInnerBefore,mainInnerAfter:t.flexStyle.crossInnerAfter,crossInnerBefore:t.flexStyle.mainInnerBefore,crossInnerAfter:t.flexStyle.mainInnerAfter,mainBorderBefore:t.flexStyle.crossBorderBefore,mainBorderAfter:t.flexStyle.crossBorderAfter,crossBorderBefore:t.flexStyle.mainBorderBefore,crossBorderAfter:t.flexStyle.mainBorderAfter})}else t.flexStyle=n?{main:t.style.width,cross:t.style.height,mainOffset:t.style.offsetWidth,crossOffset:t.style.offsetHeight,mainBefore:t.style.marginLeft,mainAfter:t.style.marginRight,crossBefore:t.style.marginTop,crossAfter:t.style.marginBottom,mainInnerBefore:t.style.paddingLeft,mainInnerAfter:t.style.paddingRight,crossInnerBefore:t.style.paddingTop,crossInnerAfter:t.style.paddingBottom,mainBorderBefore:t.style.borderLeftWidth,mainBorderAfter:t.style.borderRightWidth,crossBorderBefore:t.style.borderTopWidth,crossBorderAfter:t.style.borderBottomWidth}:{main:t.style.height,cross:t.style.width,mainOffset:t.style.offsetHeight,crossOffset:t.style.offsetWidth,mainBefore:t.style.marginTop,mainAfter:t.style.marginBottom,crossBefore:t.style.marginLeft,crossAfter:t.style.marginRight,mainInnerBefore:t.style.paddingTop,mainInnerAfter:t.style.paddingBottom,crossInnerBefore:t.style.paddingLeft,crossInnerAfter:t.style.paddingRight,mainBorderBefore:t.style.borderTopWidth,mainBorderAfter:t.style.borderBottomWidth,crossBorderBefore:t.style.borderLeftWidth,crossBorderAfter:t.style.borderRightWidth},"content-box"===t.style.boxSizing&&("number"==typeof t.flexStyle.main&&(t.flexStyle.main+=t.flexStyle.mainInnerBefore+t.flexStyle.mainInnerAfter+t.flexStyle.mainBorderBefore+t.flexStyle.mainBorderAfter),"number"==typeof t.flexStyle.cross&&(t.flexStyle.cross+=t.flexStyle.crossInnerBefore+t.flexStyle.crossInnerAfter+t.flexStyle.crossBorderBefore+t.flexStyle.crossBorderAfter));t.mainAxis=n?"inline":"block",t.crossAxis=n?"block":"inline","number"==typeof t.style.flexBasis&&(t.flexStyle.main=t.style.flexBasis+t.flexStyle.mainInnerBefore+t.flexStyle.mainInnerAfter+t.flexStyle.mainBorderBefore+t.flexStyle.mainBorderAfter),t.flexStyle.mainOuter=t.flexStyle.main,t.flexStyle.crossOuter=t.flexStyle.cross,"auto"===t.flexStyle.mainOuter&&(t.flexStyle.mainOuter=t.flexStyle.mainOffset),"auto"===t.flexStyle.crossOuter&&(t.flexStyle.crossOuter=t.flexStyle.crossOffset),"number"==typeof t.flexStyle.mainBefore&&(t.flexStyle.mainOuter+=t.flexStyle.mainBefore),"number"==typeof t.flexStyle.mainAfter&&(t.flexStyle.mainOuter+=t.flexStyle.mainAfter),"number"==typeof t.flexStyle.crossBefore&&(t.flexStyle.crossOuter+=t.flexStyle.crossBefore),"number"==typeof t.flexStyle.crossAfter&&(t.flexStyle.crossOuter+=t.flexStyle.crossAfter)}},{}],4:[function(t,e,n){var i=t("../reduce");e.exports=function(t){if(t.mainSpace>0){var e=i(t.children,function(t,e){return t+parseFloat(e.style.flexGrow)},0);e>0&&(t.main=i(t.children,function(n,i){return"auto"===i.flexStyle.main?i.flexStyle.main=i.flexStyle.mainOffset+parseFloat(i.style.flexGrow)/e*t.mainSpace:i.flexStyle.main+=parseFloat(i.style.flexGrow)/e*t.mainSpace,i.flexStyle.mainOuter=i.flexStyle.main+i.flexStyle.mainBefore+i.flexStyle.mainAfter,n+i.flexStyle.mainOuter},0),t.mainSpace=0)}}},{"../reduce":12}],5:[function(t,e,n){var i=t("../reduce");e.exports=function(t){if(t.mainSpace<0){var e=i(t.children,function(t,e){return t+parseFloat(e.style.flexShrink)},0);e>0&&(t.main=i(t.children,function(n,i){return i.flexStyle.main+=parseFloat(i.style.flexShrink)/e*t.mainSpace,i.flexStyle.mainOuter=i.flexStyle.main+i.flexStyle.mainBefore+i.flexStyle.mainAfter,n+i.flexStyle.mainOuter},0),t.mainSpace=0)}}},{"../reduce":12}],6:[function(t,e,n){var i=t("../reduce");e.exports=function(t){var e;t.lines=[e={main:0,cross:0,children:[]}];for(var n,r=-1;n=t.children[++r];)"nowrap"===t.style.flexWrap||0===e.children.length||"auto"===t.flexStyle.main||t.flexStyle.main-t.flexStyle.mainInnerBefore-t.flexStyle.mainInnerAfter-t.flexStyle.mainBorderBefore-t.flexStyle.mainBorderAfter>=e.main+n.flexStyle.mainOuter?(e.main+=n.flexStyle.mainOuter,e.cross=Math.max(e.cross,n.flexStyle.crossOuter)):t.lines.push(e={main:n.flexStyle.mainOuter,cross:n.flexStyle.crossOuter,children:[]}),e.children.push(n);t.flexStyle.mainLines=i(t.lines,function(t,e){return Math.max(t,e.main)},0),t.flexStyle.crossLines=i(t.lines,function(t,e){return t+e.cross},0),"auto"===t.flexStyle.main&&(t.flexStyle.main=Math.max(t.flexStyle.mainOffset,t.flexStyle.mainLines+t.flexStyle.mainInnerBefore+t.flexStyle.mainInnerAfter+t.flexStyle.mainBorderBefore+t.flexStyle.mainBorderAfter)),"auto"===t.flexStyle.cross&&(t.flexStyle.cross=Math.max(t.flexStyle.crossOffset,t.flexStyle.crossLines+t.flexStyle.crossInnerBefore+t.flexStyle.crossInnerAfter+t.flexStyle.crossBorderBefore+t.flexStyle.crossBorderAfter)),t.flexStyle.crossSpace=t.flexStyle.cross-t.flexStyle.crossInnerBefore-t.flexStyle.crossInnerAfter-t.flexStyle.crossBorderBefore-t.flexStyle.crossBorderAfter-t.flexStyle.crossLines,t.flexStyle.mainOuter=t.flexStyle.main+t.flexStyle.mainBefore+t.flexStyle.mainAfter,t.flexStyle.crossOuter=t.flexStyle.cross+t.flexStyle.crossBefore+t.flexStyle.crossAfter}},{"../reduce":12}],7:[function(t,e,n){function i(e){for(var n,i=-1;n=e.children[++i];)t("./flex-direction")(n,e.style.flexDirection);t("./flex-direction")(e,e.style.flexDirection),t("./order")(e),t("./flexbox-lines")(e),t("./align-content")(e),i=-1;for(var r;r=e.lines[++i];)r.mainSpace=e.flexStyle.main-e.flexStyle.mainInnerBefore-e.flexStyle.mainInnerAfter-e.flexStyle.mainBorderBefore-e.flexStyle.mainBorderAfter-r.main,t("./flex-grow")(r),t("./flex-shrink")(r),t("./margin-main")(r),t("./margin-cross")(r),t("./justify-content")(r,e.style.justifyContent,e);t("./align-items")(e)}e.exports=i},{"./align-content":1,"./align-items":2,"./flex-direction":3,"./flex-grow":4,"./flex-shrink":5,"./flexbox-lines":6,"./justify-content":8,"./margin-cross":9,"./margin-main":10,"./order":11}],8:[function(t,e,n){e.exports=function(t,e,n){var i,r,o,a=n.flexStyle.mainInnerBefore,s=-1;if("flex-end"===e)for(i=t.mainSpace,i+=a;o=t.children[++s];)o.flexStyle.mainStart=i,i+=o.flexStyle.mainOuter;else if("center"===e)for(i=t.mainSpace/2,i+=a;o=t.children[++s];)o.flexStyle.mainStart=i,i+=o.flexStyle.mainOuter;else if("space-between"===e)for(r=t.mainSpace/(t.children.length-1),i=0,i+=a;o=t.children[++s];)o.flexStyle.mainStart=i,i+=o.flexStyle.mainOuter+r;else if("space-around"===e)for(r=2*t.mainSpace/(2*t.children.length),i=r/2,i+=a;o=t.children[++s];)o.flexStyle.mainStart=i,i+=o.flexStyle.mainOuter+r;else for(i=0,i+=a;o=t.children[++s];)o.flexStyle.mainStart=i,i+=o.flexStyle.mainOuter}},{}],9:[function(t,e,n){e.exports=function(t){for(var e,n=-1;e=t.children[++n];){var i=0;"auto"===e.flexStyle.crossBefore&&++i,"auto"===e.flexStyle.crossAfter&&++i;var r=t.cross-e.flexStyle.crossOuter;"auto"===e.flexStyle.crossBefore&&(e.flexStyle.crossBefore=r/i),"auto"===e.flexStyle.crossAfter&&(e.flexStyle.crossAfter=r/i),"auto"===e.flexStyle.cross?e.flexStyle.crossOuter=e.flexStyle.crossOffset+e.flexStyle.crossBefore+e.flexStyle.crossAfter:e.flexStyle.crossOuter=e.flexStyle.cross+e.flexStyle.crossBefore+e.flexStyle.crossAfter}}},{}],10:[function(t,e,n){e.exports=function(t){for(var e,n=0,i=-1;e=t.children[++i];)"auto"===e.flexStyle.mainBefore&&++n,"auto"===e.flexStyle.mainAfter&&++n;if(n>0){for(i=-1;e=t.children[++i];)"auto"===e.flexStyle.mainBefore&&(e.flexStyle.mainBefore=t.mainSpace/n),"auto"===e.flexStyle.mainAfter&&(e.flexStyle.mainAfter=t.mainSpace/n),"auto"===e.flexStyle.main?e.flexStyle.mainOuter=e.flexStyle.mainOffset+e.flexStyle.mainBefore+e.flexStyle.mainAfter:e.flexStyle.mainOuter=e.flexStyle.main+e.flexStyle.mainBefore+e.flexStyle.mainAfter;t.mainSpace=0}}},{}],11:[function(t,e,n){var i=/^(column|row)-reverse$/;e.exports=function(t){t.children.sort(function(t,e){return t.style.order-e.style.order||t.index-e.index}),i.test(t.style.flexDirection)&&t.children.reverse()}},{}],12:[function(t,e,n){function i(t,e,n){for(var i=t.length,r=-1;++r=0)&&i.push(r)}return i.push(t.ownerDocument.body),t.ownerDocument!==document&&i.push(t.ownerDocument.defaultView),i}function a(){C&&document.body.removeChild(C),C=null}function s(t){var e=void 0;t===document?(e=document,t=document.documentElement):e=t.ownerDocument;var n=e.documentElement,i=r(t),o=I();return i.top-=o.top,i.left-=o.left,void 0===i.width&&(i.width=document.body.scrollWidth-i.left-i.right),void 0===i.height&&(i.height=document.body.scrollHeight-i.top-i.bottom),i.top=i.top-n.clientTop,i.left=i.left-n.clientLeft,i.right=e.body.clientWidth-i.width-i.left,i.bottom=e.body.clientHeight-i.height-i.top,i}function l(t){return t.offsetParent||document.documentElement}function u(){if(O)return O;var t=document.createElement("div");t.style.width="100%",t.style.height="200px";var e=document.createElement("div");c(e.style,{position:"absolute",top:0,left:0,pointerEvents:"none",visibility:"hidden",width:"200px",height:"150px",overflow:"hidden"}),e.appendChild(t),document.body.appendChild(e);var n=t.offsetWidth;e.style.overflow="scroll";var i=t.offsetWidth;n===i&&(i=e.clientWidth),document.body.removeChild(e);var r=n-i;return O={width:r,height:r}}function c(){var t=arguments.length<=0||void 0===arguments[0]?{}:arguments[0],e=[];return Array.prototype.push.apply(e,arguments),e.slice(1).forEach(function(e){if(e)for(var n in e)({}).hasOwnProperty.call(e,n)&&(t[n]=e[n])}),t}function f(t,e){if(void 0!==t.classList)e.split(" ").forEach(function(e){e.trim()&&t.classList.remove(e)});else{var n=new RegExp("(^| )"+e.split(" ").join("|")+"( |$)","gi"),i=h(t).replace(n," ");m(t,i)}}function d(t,e){if(void 0!==t.classList)e.split(" ").forEach(function(e){e.trim()&&t.classList.add(e)});else{f(t,e);var n=h(t)+" "+e;m(t,n)}}function p(t,e){if(void 0!==t.classList)return t.classList.contains(e);var n=h(t);return new RegExp("(^| )"+e+"( |$)","gi").test(n)}function h(t){return t.className instanceof t.ownerDocument.defaultView.SVGAnimatedString?t.className.baseVal:t.className}function m(t,e){t.setAttribute("class",e)}function g(t,e,n){n.forEach(function(n){-1===e.indexOf(n)&&p(t,n)&&f(t,n)}),e.forEach(function(e){p(t,e)||d(t,e)})}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function v(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function y(t,e){var n=arguments.length<=2||void 0===arguments[2]?1:arguments[2];return t+n>=e&&e>=t-n}function b(){return"undefined"!=typeof performance&&void 0!==performance.now?performance.now():+new Date}function _(){for(var t={top:0,left:0},e=arguments.length,n=Array(e),i=0;i1?n-1:0),r=1;r16)return e=Math.min(e-16,250),void(n=setTimeout(i,250));void 0!==t&&b()-t<10||(null!=n&&(clearTimeout(n),n=null),t=b(),R(),e=b()-t)};"undefined"!=typeof window&&void 0!==window.addEventListener&&["resize","scroll","touchmove"].forEach(function(t){window.addEventListener(t,i)})}();var M={center:"center",left:"right",right:"left"},H={middle:"middle",top:"bottom",bottom:"top"},W={top:0,left:0,middle:"50%",center:"50%",bottom:"100%",right:"100%"},U=function(t,e){var n=t.left,i=t.top;return"auto"===n&&(n=M[e.left]),"auto"===i&&(i=H[e.top]),{left:n,top:i}},q=function(t){var e=t.left,n=t.top;return void 0!==W[t.left]&&(e=W[t.left]),void 0!==W[t.top]&&(n=W[t.top]),{left:e,top:n}},z=function(t){var e=t.split(" "),n=L(e,2);return{top:n[0],left:n[1]}},$=z,Q=function(t){function e(t){var n=this;i(this,e),j(Object.getPrototypeOf(e.prototype),"constructor",this).call(this),this.position=this.position.bind(this),F.push(this),this.history=[],this.setOptions(t,!1),E.modules.forEach(function(t){void 0!==t.initialize&&t.initialize.call(n)}),this.position()}return v(e,t),S(e,[{key:"getClass",value:function(){var t=arguments.length<=0||void 0===arguments[0]?"":arguments[0],e=this.options.classes;return void 0!==e&&e[t]?this.options.classes[t]:this.options.classPrefix?this.options.classPrefix+"-"+t:t}},{key:"setOptions",value:function(t){var e=this,n=arguments.length<=1||void 0===arguments[1]||arguments[1],i={offset:"0 0",targetOffset:"0 0",targetAttachment:"auto auto",classPrefix:"tether"};this.options=c(i,t);var r=this.options,a=r.element,s=r.target,l=r.targetModifier;if(this.element=a,this.target=s,this.targetModifier=l,"viewport"===this.target?(this.target=document.body,this.targetModifier="visible"):"scroll-handle"===this.target&&(this.target=document.body,this.targetModifier="scroll-handle"),["element","target"].forEach(function(t){if(void 0===e[t])throw new Error("Tether Error: Both element and target must be defined");void 0!==e[t].jquery?e[t]=e[t][0]:"string"==typeof e[t]&&(e[t]=document.querySelector(e[t]))}),d(this.element,this.getClass("element")),!1!==this.options.addTargetClasses&&d(this.target,this.getClass("target")),!this.options.attachment)throw new Error("Tether Error: You must provide an attachment");this.targetAttachment=$(this.options.targetAttachment),this.attachment=$(this.options.attachment),this.offset=z(this.options.offset),this.targetOffset=z(this.options.targetOffset),void 0!==this.scrollParents&&this.disable(),"scroll-handle"===this.targetModifier?this.scrollParents=[this.target]:this.scrollParents=o(this.target),!1!==this.options.enabled&&this.enable(n)}},{key:"getTargetBounds",value:function(){if(void 0===this.targetModifier)return s(this.target);if("visible"===this.targetModifier){if(this.target===document.body)return{top:pageYOffset,left:pageXOffset,height:innerHeight,width:innerWidth};var t=s(this.target),e={height:t.height,width:t.width,top:t.top,left:t.left};return e.height=Math.min(e.height,t.height-(pageYOffset-t.top)),e.height=Math.min(e.height,t.height-(t.top+t.height-(pageYOffset+innerHeight))),e.height=Math.min(innerHeight,e.height),e.height-=2,e.width=Math.min(e.width,t.width-(pageXOffset-t.left)),e.width=Math.min(e.width,t.width-(t.left+t.width-(pageXOffset+innerWidth))),e.width=Math.min(innerWidth,e.width),e.width-=2,e.topn.clientWidth||[i.overflow,i.overflowX].indexOf("scroll")>=0||this.target!==document.body,o=0;r&&(o=15);var a=t.height-parseFloat(i.borderTopWidth)-parseFloat(i.borderBottomWidth)-o,e={width:15,height:.975*a*(a/n.scrollHeight),left:t.left+t.width-parseFloat(i.borderLeftWidth)-15},l=0;a<408&&this.target===document.body&&(l=-11e-5*Math.pow(a,2)-.00727*a+22.58),this.target!==document.body&&(e.height=Math.max(e.height,24));var u=this.target.scrollTop/(n.scrollHeight-a);return e.top=u*(a-e.height-l)+t.top+parseFloat(i.borderTopWidth),this.target===document.body&&(e.height=Math.max(e.height,24)),e}}},{key:"clearCache",value:function(){this._cache={}}},{key:"cache",value:function(t,e){return void 0===this._cache&&(this._cache={}),void 0===this._cache[t]&&(this._cache[t]=e.call(this)),this._cache[t]}},{key:"enable",value:function(){var t=this,e=arguments.length<=0||void 0===arguments[0]||arguments[0];!1!==this.options.addTargetClasses&&d(this.target,this.getClass("enabled")),d(this.element,this.getClass("enabled")),this.enabled=!0,this.scrollParents.forEach(function(e){e!==t.target.ownerDocument&&e.addEventListener("scroll",t.position)}),e&&this.position()}},{key:"disable",value:function(){var t=this;f(this.target,this.getClass("enabled")),f(this.element,this.getClass("enabled")),this.enabled=!1,void 0!==this.scrollParents&&this.scrollParents.forEach(function(e){e.removeEventListener("scroll",t.position)})}},{key:"destroy",value:function(){var t=this;this.disable(),F.forEach(function(e,n){e===t&&F.splice(n,1)}),0===F.length&&a()}},{key:"updateAttachClasses",value:function(t,e){var n=this;t=t||this.attachment,e=e||this.targetAttachment;var i=["left","top","bottom","right","middle","center"];void 0!==this._addAttachClasses&&this._addAttachClasses.length&&this._addAttachClasses.splice(0,this._addAttachClasses.length),void 0===this._addAttachClasses&&(this._addAttachClasses=[]);var r=this._addAttachClasses;t.top&&r.push(this.getClass("element-attached")+"-"+t.top),t.left&&r.push(this.getClass("element-attached")+"-"+t.left),e.top&&r.push(this.getClass("target-attached")+"-"+e.top),e.left&&r.push(this.getClass("target-attached")+"-"+e.left);var o=[];i.forEach(function(t){o.push(n.getClass("element-attached")+"-"+t),o.push(n.getClass("target-attached")+"-"+t)}),D(function(){void 0!==n._addAttachClasses&&(g(n.element,n._addAttachClasses,o),!1!==n.options.addTargetClasses&&g(n.target,n._addAttachClasses,o),delete n._addAttachClasses)})}},{key:"position",value:function(){var t=this,e=arguments.length<=0||void 0===arguments[0]||arguments[0];if(this.enabled){this.clearCache();var n=U(this.targetAttachment,this.attachment);this.updateAttachClasses(this.attachment,n);var i=this.cache("element-bounds",function(){return s(t.element)}),r=i.width,o=i.height;if(0===r&&0===o&&void 0!==this.lastSize){var a=this.lastSize;r=a.width,o=a.height}else this.lastSize={width:r,height:o};var c=this.cache("target-bounds",function(){return t.getTargetBounds()}),f=c,d=x(q(this.attachment),{width:r,height:o}),p=x(q(n),f),h=x(this.offset,{width:r,height:o}),m=x(this.targetOffset,f);d=_(d,h),p=_(p,m);for(var g=c.left+p.left-d.left,v=c.top+p.top-d.top,y=0;yC.documentElement.clientHeight&&(A=this.cache("scrollbar-size",u),S.viewport.bottom-=A.height),T.innerWidth>C.documentElement.clientWidth&&(A=this.cache("scrollbar-size",u),S.viewport.right-=A.width),-1!==["","static"].indexOf(C.body.style.position)&&-1!==["","static"].indexOf(C.body.parentElement.style.position)||(S.page.bottom=C.body.scrollHeight-v-o,S.page.right=C.body.scrollWidth-g-r),void 0!==this.options.optimizations&&!1!==this.options.optimizations.moveElement&&void 0===this.targetModifier&&function(){var e=t.cache("target-offsetparent",function(){return l(t.target)}),n=t.cache("target-offsetparent-bounds",function(){return s(e)}),i=getComputedStyle(e),r=n,o={};if(["Top","Left","Bottom","Right"].forEach(function(t){o[t.toLowerCase()]=parseFloat(i["border"+t+"Width"])}),n.right=C.body.scrollWidth-n.left-r.width+o.right,n.bottom=C.body.scrollHeight-n.top-r.height+o.bottom,S.page.top>=n.top+o.top&&S.page.bottom>=n.bottom&&S.page.left>=n.left+o.left&&S.page.right>=n.right){var a=e.scrollTop,u=e.scrollLeft;S.offset={top:S.page.top-n.top+a-o.top,left:S.page.left-n.left+u-o.left}}}(),this.move(S),this.history.unshift(S),this.history.length>3&&this.history.pop(),e&&N(),!0}}},{key:"move",value:function(t){var e=this;if(void 0!==this.element.parentNode){var n={};for(var i in t){n[i]={};for(var r in t[i]){for(var o=!1,a=0;a=0){var h=s.split(" "),g=L(h,2);f=g[0],c=g[1]}else c=f=s;var b=w(e,o);"target"!==f&&"both"!==f||(nb[3]&&"bottom"===v.top&&(n-=d,v.top="top")),"together"===f&&("top"===v.top&&("bottom"===y.top&&nb[3]&&n-(a-d)>=b[1]&&(n-=a-d,v.top="bottom",y.top="bottom")),"bottom"===v.top&&("top"===y.top&&n+a>b[3]?(n-=d,v.top="top",n-=a,y.top="bottom"):"bottom"===y.top&&nb[3]&&"top"===y.top?(n-=a,y.top="bottom"):nb[2]&&"right"===v.left&&(i-=p,v.left="left")),"together"===c&&(ib[2]&&"right"===v.left?"left"===y.left?(i-=p,v.left="left",i-=l,y.left="right"):"right"===y.left&&(i-=p,v.left="left",i+=l,y.left="left"):"center"===v.left&&(i+l>b[2]&&"left"===y.left?(i-=l,y.left="right"):ib[3]&&"top"===y.top&&(n-=a,y.top="bottom")),"element"!==c&&"both"!==c||(ib[2]&&("left"===y.left?(i-=l,y.left="right"):"center"===y.left&&(i-=l/2,y.left="right"))),"string"==typeof u?u=u.split(",").map(function(t){return t.trim()}):!0===u&&(u=["top","left","right","bottom"]),u=u||[];var _=[],x=[];n=0?(n=b[1],_.push("top")):x.push("top")),n+a>b[3]&&(u.indexOf("bottom")>=0?(n=b[3]-a,_.push("bottom")):x.push("bottom")),i=0?(i=b[0],_.push("left")):x.push("left")),i+l>b[2]&&(u.indexOf("right")>=0?(i=b[2]-l,_.push("right")):x.push("right")),_.length&&function(){var t=void 0;t=void 0!==e.options.pinnedClass?e.options.pinnedClass:e.getClass("pinned"),m.push(t),_.forEach(function(e){m.push(t+"-"+e)})}(),x.length&&function(){var t=void 0;t=void 0!==e.options.outOfBoundsClass?e.options.outOfBoundsClass:e.getClass("out-of-bounds"),m.push(t),x.forEach(function(e){m.push(t+"-"+e)})}(),(_.indexOf("left")>=0||_.indexOf("right")>=0)&&(y.left=v.left=!1),(_.indexOf("top")>=0||_.indexOf("bottom")>=0)&&(y.top=v.top=!1),v.top===r.top&&v.left===r.left&&y.top===e.attachment.top&&y.left===e.attachment.left||(e.updateAttachClasses(y,v),e.trigger("update",{attachment:y,targetAttachment:v}))}),D(function(){!1!==e.options.addTargetClasses&&g(e.target,m,h),g(e.element,m,h)}),{top:n,left:i}}});var B=E.Utils,s=B.getBounds,g=B.updateClasses,D=B.defer;E.modules.push({position:function(t){var e=this,n=t.top,i=t.left,r=this.cache("element-bounds",function(){return s(e.element)}),o=r.height,a=r.width,l=this.getTargetBounds(),u=n+o,c=i+a,f=[];n<=l.bottom&&u>=l.top&&["left","right"].forEach(function(t){var e=l[t];e!==i&&e!==c||f.push(t)}),i<=l.right&&c>=l.left&&["top","bottom"].forEach(function(t){var e=l[t];e!==n&&e!==u||f.push(t)});var d=[],p=[],h=["left","top","right","bottom"];return d.push(this.getClass("abutted")),h.forEach(function(t){d.push(e.getClass("abutted")+"-"+t)}),f.length&&p.push(this.getClass("abutted")),f.forEach(function(t){p.push(e.getClass("abutted")+"-"+t)}),D(function(){!1!==e.options.addTargetClasses&&g(e.target,p,d),g(e.element,p,d)}),!0}});var L=function(){function t(t,e){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);i=!0);}catch(t){r=!0,o=t}finally{try{!i&&s.return&&s.return()}finally{if(r)throw o}}return n}return function(e,n){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();return E.modules.push({position:function(t){var e=t.top,n=t.left;if(this.options.shift){var i=this.options.shift;"function"==typeof this.options.shift&&(i=this.options.shift.call(this,{top:e,left:n}));var r=void 0,o=void 0;if("string"==typeof i){i=i.split(" "),i[1]=i[1]||i[0];var a=i,s=L(a,2);r=s[0],o=s[1],r=parseFloat(r,10),o=parseFloat(o,10)}else r=i.top,o=i.left;return e+=r,n+=o,{top:e,left:n}}}}),G})},function(t,e,n){"use strict";var i;i=function(){return this}();try{i=i||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(i=window)}t.exports=i},function(t,e,n){(function(e){t.exports=e.Tether=n(23)}).call(e,n(24))},function(t,e,n){n(5),t.exports=n(6)}]); \ No newline at end of file diff --git a/themes/classic/config/.htaccess b/themes/classic/config/.htaccess deleted file mode 100644 index 3de9e400..00000000 --- a/themes/classic/config/.htaccess +++ /dev/null @@ -1,10 +0,0 @@ -# Apache 2.2 - - Order deny,allow - Deny from all - - -# Apache 2.4 - - Require all denied - diff --git a/themes/classic/config/theme.yml b/themes/classic/config/theme.yml deleted file mode 100644 index 91c487d2..00000000 --- a/themes/classic/config/theme.yml +++ /dev/null @@ -1,131 +0,0 @@ -name: classic -display_name: Classic -version: 1.0.0 -author: - name: "PrestaShop Team" - email: "pub@prestashop.com" - url: "http://www.prestashop.com" - -meta: - compatibility: - from: 1.7.0.0 - to: ~ - - available_layouts: - layout-full-width: - name: Full Width - description: No side columns, ideal for distraction-free pages such as product pages. - layout-both-columns: - name: Three Columns - description: One large central column and 2 side columns. - layout-left-column: - name: Two Columns, small left column - description: Two columns with a small left column - layout-right-column: - name: Two Columns, small right column - description: Two columns with a small right column - -assets: - # If you're using this theme as child and you want to load - # the parent theme assets, uncomment this line. -# use_parent_assets: true - - # The following lines are showing how to load assets in your page - # Uncomment and change value to start loading css or js files -# css: -# all: -# - id: custom-lib-style -# path: assets/css/custom-lib.css -# product: -# - id: product-style -# path: assets/css/product.css -# media: all -# priority: 200 -# js: -# cart: -# - id: cat-extra-lib -# path: assets/js/cart-lib.js - - -global_settings: - configuration: - PS_IMAGE_QUALITY: png - modules: - to_enable: - - ps_linklist - hooks: - modules_to_hook: - displayNav1: - - ps_contactinfo - displayNav2: - - ps_languageselector - - ps_currencyselector - - ps_customersignin - - ps_shoppingcart - displayTop: - - ps_mainmenu - - ps_searchbar - displayHome: - - ps_imageslider - - ps_featuredproducts - - ps_banner - - ps_customtext - displayFooterBefore: - - ps_emailsubscription - - ps_socialfollow - displayFooter: - - ps_linklist - - ps_customeraccountlinks - - ps_contactinfo - displayLeftColumn: - - ps_categorytree - - ps_facetedsearch - displaySearch: - - ps_searchbar - displayProductAdditionalInfo: - - ps_sharebuttons - displayReassurance: - - blockreassurance - displayOrderConfirmation2: - - ps_featuredproducts - displayCrossSellingShoppingCart: - - ps_featuredproducts - - image_types: - cart_default: - width: 125 - height: 125 - scope: [products] - small_default: - width: 98 - height: 98 - scope: [products, categories, manufacturers, suppliers] - medium_default: - width: 452 - height: 452 - scope: [products, manufacturers, suppliers] - home_default: - width: 250 - height: 250 - scope: [products] - large_default: - width: 800 - height: 800 - scope: [products, manufacturers, suppliers] - category_default: - width: 141 - height: 180 - scope: [categories] - stores_default: - width: 170 - height: 115 - scope: [stores] - -theme_settings: - default_layout: layout-full-width - layouts: - category: layout-left-column - best-sales: layout-left-column - new-products: layout-left-column - prices-drop: layout-left-column - contact: layout-left-column diff --git a/themes/classic/lang/pl.php b/themes/classic/lang/pl.php deleted file mode 100644 index e69de29b..00000000 diff --git a/themes/classic/modules/blockreassurance/views/templates/hook/blockreassurance.tpl b/themes/classic/modules/blockreassurance/views/templates/hook/blockreassurance.tpl deleted file mode 100644 index 196ea011..00000000 --- a/themes/classic/modules/blockreassurance/views/templates/hook/blockreassurance.tpl +++ /dev/null @@ -1,38 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{if $elements} -
      -
        - {foreach from=$elements item=element} -
      • -
        - {$element.text} - {$element.text} -
        -
      • - {/foreach} -
      -
      -{/if} diff --git a/themes/classic/modules/contactform/views/templates/widget/contactform.tpl b/themes/classic/modules/contactform/views/templates/widget/contactform.tpl deleted file mode 100644 index 18849f01..00000000 --- a/themes/classic/modules/contactform/views/templates/widget/contactform.tpl +++ /dev/null @@ -1,135 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      -
      - - {if $notifications} -
      -
        - {foreach $notifications.messages as $notif} -
      • {$notif}
      • - {/foreach} -
      -
      - {/if} - - {if !$notifications || $notifications.nw_error} -
      - -
      -
      -

      {l s='Contact us' d='Shop.Theme.Global'}

      -
      -
      - -
      - -
      - -
      -
      - -
      - -
      - -
      -
      - - {if $contact.orders} -
      - -
      - -
      - - {l s='optional' d='Shop.Forms.Help'} - -
      - {/if} - - {if $contact.allow_file_upload} -
      - -
      - -
      - - {l s='optional' d='Shop.Forms.Help'} - -
      - {/if} - -
      - -
      - -
      -
      - - {if isset($id_module)} -
      -
      - {hook h='displayGDPRConsent' id_module=$id_module} -
      -
      - {/if} - -
      - -
      - - - - -
      - {/if} - -
      -
      diff --git a/themes/classic/modules/ps_advertising/index.php b/themes/classic/modules/ps_advertising/index.php deleted file mode 100644 index 99e1f250..00000000 --- a/themes/classic/modules/ps_advertising/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/themes/classic/modules/ps_advertising/ps_advertising.tpl b/themes/classic/modules/ps_advertising/ps_advertising.tpl deleted file mode 100644 index 88537787..00000000 --- a/themes/classic/modules/ps_advertising/ps_advertising.tpl +++ /dev/null @@ -1,28 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -
      - {$adv_title} -
      diff --git a/themes/classic/modules/ps_banner/ps_banner.tpl b/themes/classic/modules/ps_banner/ps_banner.tpl deleted file mode 100644 index 04f6ca4d..00000000 --- a/themes/classic/modules/ps_banner/ps_banner.tpl +++ /dev/null @@ -1,31 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - diff --git a/themes/classic/modules/ps_bestsellers/views/index.php b/themes/classic/modules/ps_bestsellers/views/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_bestsellers/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_bestsellers/views/templates/hook/index.php b/themes/classic/modules/ps_bestsellers/views/templates/hook/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_bestsellers/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_bestsellers/views/templates/hook/ps_bestsellers.tpl b/themes/classic/modules/ps_bestsellers/views/templates/hook/ps_bestsellers.tpl deleted file mode 100644 index 66f12860..00000000 --- a/themes/classic/modules/ps_bestsellers/views/templates/hook/ps_bestsellers.tpl +++ /dev/null @@ -1,37 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - diff --git a/themes/classic/modules/ps_bestsellers/views/templates/index.php b/themes/classic/modules/ps_bestsellers/views/templates/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_bestsellers/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_brandlist/views/index.php b/themes/classic/modules/ps_brandlist/views/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_brandlist/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_brandlist/views/templates/_partials/brand_form.tpl b/themes/classic/modules/ps_brandlist/views/templates/_partials/brand_form.tpl deleted file mode 100644 index cbd1fb57..00000000 --- a/themes/classic/modules/ps_brandlist/views/templates/_partials/brand_form.tpl +++ /dev/null @@ -1,33 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -
      - -
      diff --git a/themes/classic/modules/ps_brandlist/views/templates/_partials/brand_text.tpl b/themes/classic/modules/ps_brandlist/views/templates/_partials/brand_text.tpl deleted file mode 100644 index 23996307..00000000 --- a/themes/classic/modules/ps_brandlist/views/templates/_partials/brand_text.tpl +++ /dev/null @@ -1,36 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -
        - {foreach from=$brands item=brand name=brand_list} - {if $smarty.foreach.brand_list.iteration <= $text_list_nb} -
      • - - {$brand['name']} - -
      • - {/if} - {/foreach} -
      diff --git a/themes/classic/modules/ps_brandlist/views/templates/_partials/index.php b/themes/classic/modules/ps_brandlist/views/templates/_partials/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_brandlist/views/templates/_partials/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_brandlist/views/templates/hook/index.php b/themes/classic/modules/ps_brandlist/views/templates/hook/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_brandlist/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_brandlist/views/templates/hook/ps_brandlist.tpl b/themes/classic/modules/ps_brandlist/views/templates/hook/ps_brandlist.tpl deleted file mode 100644 index 624a1743..00000000 --- a/themes/classic/modules/ps_brandlist/views/templates/hook/ps_brandlist.tpl +++ /dev/null @@ -1,41 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -
      -
      -

      - {if $display_link_brand}{/if} - {l s='Brands' d='Shop.Theme.Catalog'} - {if $display_link_brand}{/if} -

      -
      - {if $brands} - {include file="module:ps_brandlist/views/templates/_partials/$brand_display_type.tpl" brands=$brands} - {else} -

      {l s='No brand' d='Shop.Theme.Catalog'}

      - {/if} -
      -
      -
      diff --git a/themes/classic/modules/ps_brandlist/views/templates/index.php b/themes/classic/modules/ps_brandlist/views/templates/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_brandlist/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_categoryproducts/views/index.php b/themes/classic/modules/ps_categoryproducts/views/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_categoryproducts/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_categoryproducts/views/templates/hook/index.php b/themes/classic/modules/ps_categoryproducts/views/templates/hook/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_categoryproducts/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_categoryproducts/views/templates/hook/ps_categoryproducts.tpl b/themes/classic/modules/ps_categoryproducts/views/templates/hook/ps_categoryproducts.tpl deleted file mode 100644 index 31394448..00000000 --- a/themes/classic/modules/ps_categoryproducts/views/templates/hook/ps_categoryproducts.tpl +++ /dev/null @@ -1,38 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - diff --git a/themes/classic/modules/ps_categoryproducts/views/templates/index.php b/themes/classic/modules/ps_categoryproducts/views/templates/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_categoryproducts/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_categorytree/views/templates/hook/ps_categorytree.tpl b/themes/classic/modules/ps_categorytree/views/templates/hook/ps_categorytree.tpl deleted file mode 100644 index 90e78c7b..00000000 --- a/themes/classic/modules/ps_categorytree/views/templates/hook/ps_categorytree.tpl +++ /dev/null @@ -1,67 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -{function name="categories" nodes=[] depth=0} - {strip} - {if $nodes|count} -
        - {foreach from=$nodes item=node} -
      • - {if $depth===0} - {$node.name} - {if $node.children} - -
        - {categories nodes=$node.children depth=$depth+1} -
        - {/if} - {else} - {$node.name} - {if $node.children} - - - - -
        - {categories nodes=$node.children depth=$depth+1} -
        - {/if} - {/if} -
      • - {/foreach} -
      - {/if} - {/strip} -{/function} - -
      - -
      diff --git a/themes/classic/modules/ps_contactinfo/nav.tpl b/themes/classic/modules/ps_contactinfo/nav.tpl deleted file mode 100644 index c3255174..00000000 --- a/themes/classic/modules/ps_contactinfo/nav.tpl +++ /dev/null @@ -1,42 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - diff --git a/themes/classic/modules/ps_contactinfo/ps_contactinfo-rich.tpl b/themes/classic/modules/ps_contactinfo/ps_contactinfo-rich.tpl deleted file mode 100644 index ae79bc0a..00000000 --- a/themes/classic/modules/ps_contactinfo/ps_contactinfo-rich.tpl +++ /dev/null @@ -1,62 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -
      -

      {l s='Store information' d='Shop.Theme.Global'}

      -
      -
      -
      {$contact_infos.address.formatted nofilter}
      -
      - {if $contact_infos.phone} -
      -
      -
      -
      - {l s='Call us:' d='Shop.Theme.Global'}
      - {$contact_infos.phone} -
      -
      - {/if} - {if $contact_infos.fax} -
      -
      -
      -
      - {l s='Fax:' d='Shop.Theme.Global'}
      - {$contact_infos.fax} -
      -
      - {/if} - {if $contact_infos.email} -
      -
      -
      - - {$contact_infos.email} -
      - {/if} -
      diff --git a/themes/classic/modules/ps_contactinfo/ps_contactinfo.tpl b/themes/classic/modules/ps_contactinfo/ps_contactinfo.tpl deleted file mode 100644 index e7bda1b3..00000000 --- a/themes/classic/modules/ps_contactinfo/ps_contactinfo.tpl +++ /dev/null @@ -1,74 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - - diff --git a/themes/classic/modules/ps_crossselling/views/index.php b/themes/classic/modules/ps_crossselling/views/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_crossselling/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_crossselling/views/templates/hook/index.php b/themes/classic/modules/ps_crossselling/views/templates/hook/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_crossselling/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_crossselling/views/templates/hook/ps_crossselling.tpl b/themes/classic/modules/ps_crossselling/views/templates/hook/ps_crossselling.tpl deleted file mode 100644 index 020b16d5..00000000 --- a/themes/classic/modules/ps_crossselling/views/templates/hook/ps_crossselling.tpl +++ /dev/null @@ -1,33 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - - diff --git a/themes/classic/modules/ps_crossselling/views/templates/index.php b/themes/classic/modules/ps_crossselling/views/templates/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_crossselling/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_currencyselector/ps_currencyselector.tpl b/themes/classic/modules/ps_currencyselector/ps_currencyselector.tpl deleted file mode 100644 index aaf9c7be..00000000 --- a/themes/classic/modules/ps_currencyselector/ps_currencyselector.tpl +++ /dev/null @@ -1,46 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -
      - -
      diff --git a/themes/classic/modules/ps_customeraccountlinks/ps_customeraccountlinks.tpl b/themes/classic/modules/ps_customeraccountlinks/ps_customeraccountlinks.tpl deleted file mode 100644 index ee8832e8..00000000 --- a/themes/classic/modules/ps_customeraccountlinks/ps_customeraccountlinks.tpl +++ /dev/null @@ -1,51 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - - diff --git a/themes/classic/modules/ps_customersignin/ps_customersignin.tpl b/themes/classic/modules/ps_customersignin/ps_customersignin.tpl deleted file mode 100644 index 7e15e4ea..00000000 --- a/themes/classic/modules/ps_customersignin/ps_customersignin.tpl +++ /dev/null @@ -1,56 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - diff --git a/themes/classic/modules/ps_emailalerts/views/index.php b/themes/classic/modules/ps_emailalerts/views/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_emailalerts/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_emailalerts/views/templates/hook/index.php b/themes/classic/modules/ps_emailalerts/views/templates/hook/index.php deleted file mode 100644 index 96ed9b88..00000000 --- a/themes/classic/modules/ps_emailalerts/views/templates/hook/index.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_emailalerts/views/templates/hook/my-account-footer.tpl b/themes/classic/modules/ps_emailalerts/views/templates/hook/my-account-footer.tpl deleted file mode 100644 index 12968341..00000000 --- a/themes/classic/modules/ps_emailalerts/views/templates/hook/my-account-footer.tpl +++ /dev/null @@ -1,30 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -
    • - - {l s='My alerts' d='Shop.Theme.Catalog'} - -
    • diff --git a/themes/classic/modules/ps_emailalerts/views/templates/hook/my-account.tpl b/themes/classic/modules/ps_emailalerts/views/templates/hook/my-account.tpl deleted file mode 100644 index 50369607..00000000 --- a/themes/classic/modules/ps_emailalerts/views/templates/hook/my-account.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - - - - - {l s='My alerts' d='Shop.Theme.Catalog'} - - diff --git a/themes/classic/modules/ps_emailalerts/views/templates/index.php b/themes/classic/modules/ps_emailalerts/views/templates/index.php deleted file mode 100644 index 96ed9b88..00000000 --- a/themes/classic/modules/ps_emailalerts/views/templates/index.php +++ /dev/null @@ -1,34 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_emailsubscription/views/templates/hook/ps_emailsubscription.tpl b/themes/classic/modules/ps_emailsubscription/views/templates/hook/ps_emailsubscription.tpl deleted file mode 100644 index f304091c..00000000 --- a/themes/classic/modules/ps_emailsubscription/views/templates/hook/ps_emailsubscription.tpl +++ /dev/null @@ -1,74 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -
      -
      -

      {l s='Get our latest news and special sales' d='Shop.Theme.Global'}

      -
      -
      -
      -
      - - -
      - -
      - -
      -
      -
      - {if $conditions} -

      {$conditions}

      - {/if} - {if $msg} -

      - {$msg} -

      - {/if} - {if isset($id_module)} - {hook h='displayGDPRConsent' id_module=$id_module} - {/if} -
      -
      -
      -
      -
      -
      diff --git a/themes/classic/modules/ps_facetedsearch/ps_facetedsearch.tpl b/themes/classic/modules/ps_facetedsearch/ps_facetedsearch.tpl deleted file mode 100644 index f4295286..00000000 --- a/themes/classic/modules/ps_facetedsearch/ps_facetedsearch.tpl +++ /dev/null @@ -1,36 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{if isset($listing.rendered_facets)} -
      -
      - - -
      - {$listing.rendered_facets nofilter} -
      -{/if} diff --git a/themes/classic/modules/ps_featuredproducts/views/templates/hook/ps_featuredproducts.tpl b/themes/classic/modules/ps_featuredproducts/views/templates/hook/ps_featuredproducts.tpl deleted file mode 100644 index a3213fbc..00000000 --- a/themes/classic/modules/ps_featuredproducts/views/templates/hook/ps_featuredproducts.tpl +++ /dev/null @@ -1,37 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - diff --git a/themes/classic/modules/ps_imageslider/views/templates/hook/slider.tpl b/themes/classic/modules/ps_imageslider/views/templates/hook/slider.tpl deleted file mode 100644 index fd98f815..00000000 --- a/themes/classic/modules/ps_imageslider/views/templates/hook/slider.tpl +++ /dev/null @@ -1,60 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -{if $homeslider.slides} - -{/if} diff --git a/themes/classic/modules/ps_languageselector/ps_languageselector.tpl b/themes/classic/modules/ps_languageselector/ps_languageselector.tpl deleted file mode 100644 index d016e39a..00000000 --- a/themes/classic/modules/ps_languageselector/ps_languageselector.tpl +++ /dev/null @@ -1,49 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      -
      - {l s='Language:' d='Shop.Theme.Global'} - -
      -
      diff --git a/themes/classic/modules/ps_legalcompliance/views/templates/hook/hookDisplayFooter.tpl b/themes/classic/modules/ps_legalcompliance/views/templates/hook/hookDisplayFooter.tpl deleted file mode 100644 index 6f4ca3a6..00000000 --- a/themes/classic/modules/ps_legalcompliance/views/templates/hook/hookDisplayFooter.tpl +++ /dev/null @@ -1,44 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - - diff --git a/themes/classic/modules/ps_linklist/views/templates/hook/linkblock.tpl b/themes/classic/modules/ps_linklist/views/templates/hook/linkblock.tpl deleted file mode 100644 index 8d538471..00000000 --- a/themes/classic/modules/ps_linklist/views/templates/hook/linkblock.tpl +++ /dev/null @@ -1,58 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - diff --git a/themes/classic/modules/ps_mainmenu/ps_mainmenu.tpl b/themes/classic/modules/ps_mainmenu/ps_mainmenu.tpl deleted file mode 100644 index 3aa86034..00000000 --- a/themes/classic/modules/ps_mainmenu/ps_mainmenu.tpl +++ /dev/null @@ -1,39 +0,0 @@ -{assign var=_counter value=0} -{function name="menu" nodes=[] depth=0 parent=null} - {if $nodes|count} - - {/if} -{/function} - - diff --git a/themes/classic/modules/ps_newproducts/views/index.php b/themes/classic/modules/ps_newproducts/views/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_newproducts/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_newproducts/views/templates/hook/index.php b/themes/classic/modules/ps_newproducts/views/templates/hook/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_newproducts/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_newproducts/views/templates/hook/ps_newproducts.tpl b/themes/classic/modules/ps_newproducts/views/templates/hook/ps_newproducts.tpl deleted file mode 100644 index 0bb97794..00000000 --- a/themes/classic/modules/ps_newproducts/views/templates/hook/ps_newproducts.tpl +++ /dev/null @@ -1,39 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - - - diff --git a/themes/classic/modules/ps_newproducts/views/templates/index.php b/themes/classic/modules/ps_newproducts/views/templates/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_newproducts/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_productinfo/views/index.php b/themes/classic/modules/ps_productinfo/views/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_productinfo/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_productinfo/views/templates/hook/index.php b/themes/classic/modules/ps_productinfo/views/templates/hook/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_productinfo/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_productinfo/views/templates/hook/ps_productinfo.tpl b/themes/classic/modules/ps_productinfo/views/templates/hook/ps_productinfo.tpl deleted file mode 100644 index 471f3bb5..00000000 --- a/themes/classic/modules/ps_productinfo/views/templates/hook/ps_productinfo.tpl +++ /dev/null @@ -1,43 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      - {if isset($vars_nb_people)} -

      - {if $vars_nb_people['%nb_people%'] == 1} - {l s='1 person is currently watching this product.' d='Shop.Theme.Catalog'} - {else} - {l s='%nb_people% people are currently watching this product.' sprintf=$vars_nb_people d='Shop.Theme.Catalog'} - {/if} -

      - {/if} - - {if isset($vars_date_last_order)} -

      {l s='Last time this product was bought: %date_last_order%' sprintf=$vars_date_last_order d='Shop.Theme.Catalog'}

      - {/if} - - {if isset($vars_date_last_cart)} -

      {l s='Last time this product was added to a cart: %date_last_cart%' sprintf=$vars_date_last_cart d='Shop.Theme.Catalog'}

      - {/if} -
      diff --git a/themes/classic/modules/ps_productinfo/views/templates/index.php b/themes/classic/modules/ps_productinfo/views/templates/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_productinfo/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_rssfeed/views/index.php b/themes/classic/modules/ps_rssfeed/views/index.php deleted file mode 100644 index 99e1f250..00000000 --- a/themes/classic/modules/ps_rssfeed/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/themes/classic/modules/ps_rssfeed/views/templates/hook/index.php b/themes/classic/modules/ps_rssfeed/views/templates/hook/index.php deleted file mode 100644 index 99e1f250..00000000 --- a/themes/classic/modules/ps_rssfeed/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/themes/classic/modules/ps_rssfeed/views/templates/hook/ps_rssfeed.tpl b/themes/classic/modules/ps_rssfeed/views/templates/hook/ps_rssfeed.tpl deleted file mode 100644 index 54dfe8e7..00000000 --- a/themes/classic/modules/ps_rssfeed/views/templates/hook/ps_rssfeed.tpl +++ /dev/null @@ -1,39 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - - diff --git a/themes/classic/modules/ps_rssfeed/views/templates/index.php b/themes/classic/modules/ps_rssfeed/views/templates/index.php deleted file mode 100644 index 99e1f250..00000000 --- a/themes/classic/modules/ps_rssfeed/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/themes/classic/modules/ps_searchbar/ps_searchbar.tpl b/themes/classic/modules/ps_searchbar/ps_searchbar.tpl deleted file mode 100644 index fb1d5fdd..00000000 --- a/themes/classic/modules/ps_searchbar/ps_searchbar.tpl +++ /dev/null @@ -1,36 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -
      -
      - - - -
      -
      - diff --git a/themes/classic/modules/ps_sharebuttons/views/templates/hook/ps_sharebuttons.tpl b/themes/classic/modules/ps_sharebuttons/views/templates/hook/ps_sharebuttons.tpl deleted file mode 100644 index 7d2127ab..00000000 --- a/themes/classic/modules/ps_sharebuttons/views/templates/hook/ps_sharebuttons.tpl +++ /dev/null @@ -1,37 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -{block name='social_sharing'} - {if $social_share_links} - - {/if} -{/block} diff --git a/themes/classic/modules/ps_shoppingcart/modal.tpl b/themes/classic/modules/ps_shoppingcart/modal.tpl deleted file mode 100644 index 8145ec1a..00000000 --- a/themes/classic/modules/ps_shoppingcart/modal.tpl +++ /dev/null @@ -1,83 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - diff --git a/themes/classic/modules/ps_shoppingcart/ps_shoppingcart-product-line.tpl b/themes/classic/modules/ps_shoppingcart/ps_shoppingcart-product-line.tpl deleted file mode 100644 index 49db6716..00000000 --- a/themes/classic/modules/ps_shoppingcart/ps_shoppingcart-product-line.tpl +++ /dev/null @@ -1,59 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{$product.quantity} -{$product.name} -{$product.price} - - {l s='Remove' d='Shop.Theme.Actions'} - -{if $product.customizations|count} -
      -
        - {foreach from=$product.customizations item='customization'} -
      • - {$customization.quantity} - {l s='Remove' d='Shop.Theme.Actions'} -
          - {foreach from=$customization.fields item='field'} -
        • - {$field.label} - {if $field.type == 'text'} - {$field.text nofilter} - {elseif $field.type == 'image'} - - {/if} -
        • - {/foreach} -
        -
      • - {/foreach} -
      -
      -{/if} diff --git a/themes/classic/modules/ps_shoppingcart/ps_shoppingcart.tpl b/themes/classic/modules/ps_shoppingcart/ps_shoppingcart.tpl deleted file mode 100644 index 4274f954..00000000 --- a/themes/classic/modules/ps_shoppingcart/ps_shoppingcart.tpl +++ /dev/null @@ -1,39 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - diff --git a/themes/classic/modules/ps_socialfollow/ps_socialfollow.tpl b/themes/classic/modules/ps_socialfollow/ps_socialfollow.tpl deleted file mode 100644 index 5379ffda..00000000 --- a/themes/classic/modules/ps_socialfollow/ps_socialfollow.tpl +++ /dev/null @@ -1,34 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -{block name='block_social'} -
      - -
      -{/block} diff --git a/themes/classic/modules/ps_specials/views/index.php b/themes/classic/modules/ps_specials/views/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_specials/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_specials/views/templates/hook/index.php b/themes/classic/modules/ps_specials/views/templates/hook/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_specials/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_specials/views/templates/hook/ps_specials.tpl b/themes/classic/modules/ps_specials/views/templates/hook/ps_specials.tpl deleted file mode 100644 index 0671ada3..00000000 --- a/themes/classic/modules/ps_specials/views/templates/hook/ps_specials.tpl +++ /dev/null @@ -1,38 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - - diff --git a/themes/classic/modules/ps_specials/views/templates/index.php b/themes/classic/modules/ps_specials/views/templates/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_specials/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_supplierlist/views/index.php b/themes/classic/modules/ps_supplierlist/views/index.php deleted file mode 100644 index 99e1f250..00000000 --- a/themes/classic/modules/ps_supplierlist/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/themes/classic/modules/ps_supplierlist/views/templates/_partials/index.php b/themes/classic/modules/ps_supplierlist/views/templates/_partials/index.php deleted file mode 100644 index 99e1f250..00000000 --- a/themes/classic/modules/ps_supplierlist/views/templates/_partials/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/themes/classic/modules/ps_supplierlist/views/templates/_partials/supplier_form.tpl b/themes/classic/modules/ps_supplierlist/views/templates/_partials/supplier_form.tpl deleted file mode 100644 index a1e3da5a..00000000 --- a/themes/classic/modules/ps_supplierlist/views/templates/_partials/supplier_form.tpl +++ /dev/null @@ -1,33 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -
      - -
      diff --git a/themes/classic/modules/ps_supplierlist/views/templates/_partials/supplier_text.tpl b/themes/classic/modules/ps_supplierlist/views/templates/_partials/supplier_text.tpl deleted file mode 100644 index 9df7c8be..00000000 --- a/themes/classic/modules/ps_supplierlist/views/templates/_partials/supplier_text.tpl +++ /dev/null @@ -1,36 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -
        - {foreach from=$suppliers item=supplier name=supplier_list} - {if $smarty.foreach.supplier_list.iteration <= $text_list_nb} -
      • - - {$supplier['name']} - -
      • - {/if} - {/foreach} -
      diff --git a/themes/classic/modules/ps_supplierlist/views/templates/hook/index.php b/themes/classic/modules/ps_supplierlist/views/templates/hook/index.php deleted file mode 100644 index 99e1f250..00000000 --- a/themes/classic/modules/ps_supplierlist/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/themes/classic/modules/ps_supplierlist/views/templates/hook/ps_supplierlist.tpl b/themes/classic/modules/ps_supplierlist/views/templates/hook/ps_supplierlist.tpl deleted file mode 100644 index 26aabffc..00000000 --- a/themes/classic/modules/ps_supplierlist/views/templates/hook/ps_supplierlist.tpl +++ /dev/null @@ -1,41 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -
      -
      -

      - {if $display_link_supplier}{/if} - {l s='Suppliers' d='Shop.Theme.Catalog'} - {if $display_link_supplier}{/if} -

      -
      - {if $suppliers} - {include file="module:ps_supplierlist/views/templates/_partials/$supplier_display_type.tpl" suppliers=$suppliers} - {else} -

      {l s='No supplier' d='Shop.Theme.Catalog'}

      - {/if} -
      -
      -
      diff --git a/themes/classic/modules/ps_supplierlist/views/templates/index.php b/themes/classic/modules/ps_supplierlist/views/templates/index.php deleted file mode 100644 index 99e1f250..00000000 --- a/themes/classic/modules/ps_supplierlist/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/themes/classic/modules/ps_viewedproduct/views/index.php b/themes/classic/modules/ps_viewedproduct/views/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_viewedproduct/views/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_viewedproduct/views/templates/hook/index.php b/themes/classic/modules/ps_viewedproduct/views/templates/hook/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_viewedproduct/views/templates/hook/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/modules/ps_viewedproduct/views/templates/hook/ps_viewedproduct.tpl b/themes/classic/modules/ps_viewedproduct/views/templates/hook/ps_viewedproduct.tpl deleted file mode 100644 index a8be2f3d..00000000 --- a/themes/classic/modules/ps_viewedproduct/views/templates/hook/ps_viewedproduct.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - diff --git a/themes/classic/modules/ps_viewedproduct/views/templates/index.php b/themes/classic/modules/ps_viewedproduct/views/templates/index.php deleted file mode 100644 index e261c47d..00000000 --- a/themes/classic/modules/ps_viewedproduct/views/templates/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - */ - -header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); -header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); - -header('Cache-Control: no-store, no-cache, must-revalidate'); -header('Cache-Control: post-check=0, pre-check=0', false); -header('Pragma: no-cache'); - -header('Location: ../'); -exit; diff --git a/themes/classic/preview.png b/themes/classic/preview.png deleted file mode 100644 index b439058c..00000000 Binary files a/themes/classic/preview.png and /dev/null differ diff --git a/themes/classic/preview.webp b/themes/classic/preview.webp deleted file mode 100644 index 3e9758ff..00000000 Binary files a/themes/classic/preview.webp and /dev/null differ diff --git a/themes/classic/templates/_partials/breadcrumb.tpl b/themes/classic/templates/_partials/breadcrumb.tpl deleted file mode 100644 index c3431e46..00000000 --- a/themes/classic/templates/_partials/breadcrumb.tpl +++ /dev/null @@ -1,40 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - diff --git a/themes/classic/templates/_partials/footer.tpl b/themes/classic/templates/_partials/footer.tpl deleted file mode 100644 index 7508b286..00000000 --- a/themes/classic/templates/_partials/footer.tpl +++ /dev/null @@ -1,56 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      -
      - {block name='hook_footer_before'} - {hook h='displayFooterBefore'} - {/block} -
      -
      - diff --git a/themes/classic/templates/_partials/form-errors.tpl b/themes/classic/templates/_partials/form-errors.tpl deleted file mode 100644 index 73e39484..00000000 --- a/themes/classic/templates/_partials/form-errors.tpl +++ /dev/null @@ -1,35 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{if $errors|count} -
      - {block name='form_errors'} -
        - {foreach $errors as $error} -
      • {$error|nl2br nofilter}
      • - {/foreach} -
      - {/block} -
      -{/if} diff --git a/themes/classic/templates/_partials/form-fields.tpl b/themes/classic/templates/_partials/form-fields.tpl deleted file mode 100644 index 32ffe5a0..00000000 --- a/themes/classic/templates/_partials/form-fields.tpl +++ /dev/null @@ -1,195 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{if $field.type == 'hidden'} - - {block name='form_field_item_hidden'} - - {/block} - -{else} - -
      - -
      - - {if $field.type === 'select'} - - {block name='form_field_item_select'} - - {/block} - - {elseif $field.type === 'countrySelect'} - - {block name='form_field_item_country'} - - {/block} - - {elseif $field.type === 'radio-buttons'} - - {block name='form_field_item_radio'} - {foreach from=$field.availableValues item="label" key="value"} - - {/foreach} - {/block} - - {elseif $field.type === 'checkbox'} - - {block name='form_field_item_checkbox'} - - - - {/block} - - {elseif $field.type === 'date'} - - {block name='form_field_item_date'} - - {if isset($field.availableValues.comment)} - - {$field.availableValues.comment} - - {/if} - {/block} - - {elseif $field.type === 'birthday'} - - {block name='form_field_item_birthday'} -
      - {html_select_date - field_order=DMY - time={$field.value} - field_array={$field.name} - prefix=false - reverse_years=true - field_separator='
      ' - day_extra='class="form-control form-control-select"' - month_extra='class="form-control form-control-select"' - year_extra='class="form-control form-control-select"' - day_empty={l s='-- day --' d='Shop.Forms.Labels'} - month_empty={l s='-- month --' d='Shop.Forms.Labels'} - year_empty={l s='-- year --' d='Shop.Forms.Labels'} - start_year={'Y'|date}-100 end_year={'Y'|date} - } -
      - {/block} - - {elseif $field.type === 'password'} - - {block name='form_field_item_password'} -
      - - - - -
      - {/block} - - {else} - - {block name='form_field_item_other'} - - {if isset($field.availableValues.comment)} - - {$field.availableValues.comment} - - {/if} - {/block} - - {/if} - - {block name='form_field_errors'} - {include file='_partials/form-errors.tpl' errors=$field.errors} - {/block} - -
      - -
      - {block name='form_field_comment'} - {if (!$field.required && !in_array($field.type, ['radio-buttons', 'checkbox']))} - {l s='Optional' d='Shop.Forms.Labels'} - {/if} - {/block} -
      -
      - -{/if} diff --git a/themes/classic/templates/_partials/head.tpl b/themes/classic/templates/_partials/head.tpl deleted file mode 100644 index ceb262a4..00000000 --- a/themes/classic/templates/_partials/head.tpl +++ /dev/null @@ -1,70 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='head_charset'} - -{/block} -{block name='head_ie_compatibility'} - -{/block} - -{block name='head_seo'} - {block name='head_seo_title'}{$page.meta.title}{/block} - - - {if $page.meta.robots !== 'index'} - - {/if} - {if $page.canonical} - - {/if} - {block name='head_hreflang'} - {foreach from=$urls.alternative_langs item=pageUrl key=code} - - {/foreach} - {/block} -{/block} - -{block name='head_viewport'} - -{/block} - -{block name='head_icons'} - - -{/block} - -{block name='stylesheets'} - {include file="_partials/stylesheets.tpl" stylesheets=$stylesheets} -{/block} - -{block name='javascript_head'} - {include file="_partials/javascript.tpl" javascript=$javascript.head vars=$js_custom_vars} -{/block} - -{block name='hook_header'} - {$HOOK_HEADER nofilter} -{/block} - -{block name='hook_extra'}{/block} diff --git a/themes/classic/templates/_partials/header.tpl b/themes/classic/templates/_partials/header.tpl deleted file mode 100644 index 8f41c9b7..00000000 --- a/themes/classic/templates/_partials/header.tpl +++ /dev/null @@ -1,90 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='header_banner'} -
      - {hook h='displayBanner'} -
      -{/block} - -{block name='header_nav'} - -{/block} - -{block name='header_top'} -
      -
      -
      - -
      - {hook h='displayTop'} -
      -
      -
      - -
      -
      - {hook h='displayNavFullWidth'} -{/block} diff --git a/themes/classic/templates/_partials/javascript.tpl b/themes/classic/templates/_partials/javascript.tpl deleted file mode 100644 index 49c65619..00000000 --- a/themes/classic/templates/_partials/javascript.tpl +++ /dev/null @@ -1,41 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{foreach $javascript.external as $js} - -{/foreach} - -{foreach $javascript.inline as $js} - -{/foreach} - -{if isset($vars) && $vars|@count} - -{/if} diff --git a/themes/classic/templates/_partials/notifications.tpl b/themes/classic/templates/_partials/notifications.tpl deleted file mode 100644 index 10392bf9..00000000 --- a/themes/classic/templates/_partials/notifications.tpl +++ /dev/null @@ -1,78 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -{if isset($notifications)} - -{/if} diff --git a/themes/classic/templates/_partials/pagination.tpl b/themes/classic/templates/_partials/pagination.tpl deleted file mode 100644 index 717115e1..00000000 --- a/themes/classic/templates/_partials/pagination.tpl +++ /dev/null @@ -1,64 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - diff --git a/themes/classic/templates/_partials/stylesheets.tpl b/themes/classic/templates/_partials/stylesheets.tpl deleted file mode 100644 index 5886bc76..00000000 --- a/themes/classic/templates/_partials/stylesheets.tpl +++ /dev/null @@ -1,33 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{foreach $stylesheets.external as $stylesheet} - -{/foreach} - -{foreach $stylesheets.inline as $stylesheet} - -{/foreach} diff --git a/themes/classic/templates/catalog/_partials/active_filters.tpl b/themes/classic/templates/catalog/_partials/active_filters.tpl deleted file mode 100644 index 40dd5536..00000000 --- a/themes/classic/templates/catalog/_partials/active_filters.tpl +++ /dev/null @@ -1,43 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      - {block name='active_filters_title'} -

      {l s='Active filters' d='Shop.Theme.Global'}

      - {/block} - - {if $activeFilters|count} -
        - {foreach from=$activeFilters item="filter"} - {block name='active_filters_item'} -
      • - {l s='%1$s: ' d='Shop.Theme.Catalog' sprintf=[$filter.facetLabel]} - {$filter.label} - -
      • - {/block} - {/foreach} -
      - {/if} -
      diff --git a/themes/classic/templates/catalog/_partials/category-header.tpl b/themes/classic/templates/catalog/_partials/category-header.tpl deleted file mode 100644 index 554b82c4..00000000 --- a/themes/classic/templates/catalog/_partials/category-header.tpl +++ /dev/null @@ -1,41 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      - {if $listing.pagination.items_shown_from == 1} -
      -

      {$category.name}

      -
      - {if $category.description} -
      {$category.description nofilter}
      - {/if} - {if $category.image.large.url} -
      - {if !empty($category.image.legend)}{$category.image.legend}{else}{$category.name}{/if} -
      - {/if} -
      -
      - {/if} -
      diff --git a/themes/classic/templates/catalog/_partials/facets.tpl b/themes/classic/templates/catalog/_partials/facets.tpl deleted file mode 100644 index 413047b6..00000000 --- a/themes/classic/templates/catalog/_partials/facets.tpl +++ /dev/null @@ -1,168 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{if $facets|count} -
      - {block name='facets_title'} -

      {l s='Filter By' d='Shop.Theme.Actions'}

      - {/block} - - {block name='facets_clearall_button'} - {if $activeFilters|count} -
      - -
      - {/if} - {/block} - - {foreach from=$facets item="facet"} - {if !$facet.displayed} - {continue} - {/if} - -
      -

      {$facet.label}

      - {assign var=_expand_id value=10|mt_rand:100000} - {assign var=_collapse value=true} - {foreach from=$facet.filters item="filter"} - {if $filter.active}{assign var=_collapse value=false}{/if} - {/foreach} - -
      -

      {$facet.label}

      - - - - - - -
      - - {if $facet.widgetType !== 'dropdown'} - {block name='facet_item_other'} -
        - {foreach from=$facet.filters key=filter_key item="filter"} - {if !$filter.displayed} - {continue} - {/if} - -
      • - -
      • - {/foreach} -
      - {/block} - - {else} - - {block name='facet_item_dropdown'} - - {/block} - {/if} -
      - {/foreach} -
      -{/if} diff --git a/themes/classic/templates/catalog/_partials/miniatures/brand.tpl b/themes/classic/templates/catalog/_partials/miniatures/brand.tpl deleted file mode 100644 index ff272fda..00000000 --- a/themes/classic/templates/catalog/_partials/miniatures/brand.tpl +++ /dev/null @@ -1,37 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='brand_miniature_item'} -
    • -
      {$brand.name}
      -
      -

      {$brand.name}

      - {$brand.text nofilter} -
      - -
    • -{/block} diff --git a/themes/classic/templates/catalog/_partials/miniatures/category.tpl b/themes/classic/templates/catalog/_partials/miniatures/category.tpl deleted file mode 100644 index e925ad0e..00000000 --- a/themes/classic/templates/catalog/_partials/miniatures/category.tpl +++ /dev/null @@ -1,37 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='category_miniature_item'} -
      - - {$category.image.legend} - - -

      - {$category.name} -

      - -
      {$category.description nofilter}
      -
      -{/block} diff --git a/themes/classic/templates/catalog/_partials/miniatures/pack-product.tpl b/themes/classic/templates/catalog/_partials/miniatures/pack-product.tpl deleted file mode 100644 index 854c47e7..00000000 --- a/themes/classic/templates/catalog/_partials/miniatures/pack-product.tpl +++ /dev/null @@ -1,54 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='pack_miniature_item'} - -{/block} diff --git a/themes/classic/templates/catalog/_partials/miniatures/product.tpl b/themes/classic/templates/catalog/_partials/miniatures/product.tpl deleted file mode 100644 index d1428d5a..00000000 --- a/themes/classic/templates/catalog/_partials/miniatures/product.tpl +++ /dev/null @@ -1,109 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='product_miniature_item'} -
      -
      - {block name='product_thumbnail'} - {if $product.cover} - - {if !empty($product.cover.legend)}{$product.cover.legend}{else}{$product.name}{/if} - - {else} - - - - {/if} - {/block} - -
      - {block name='product_name'} - {if $page.page_name == 'index'} -

      {$product.name}

      - {else} -

      {$product.name}

      - {/if} - {/block} - - {block name='product_price_and_shipping'} - {if $product.show_price} -
      - {if $product.has_discount} - {hook h='displayProductPriceBlock' product=$product type="old_price"} - - {l s='Regular price' d='Shop.Theme.Catalog'} - {$product.regular_price} - {if $product.discount_type === 'percentage'} - {$product.discount_percentage} - {elseif $product.discount_type === 'amount'} - {$product.discount_amount_to_display} - {/if} - {/if} - - {hook h='displayProductPriceBlock' product=$product type="before_price"} - - {l s='Price' d='Shop.Theme.Catalog'} - {$product.price} - - {hook h='displayProductPriceBlock' product=$product type='unit_price'} - - {hook h='displayProductPriceBlock' product=$product type='weight'} -
      - {/if} - {/block} - - {block name='product_reviews'} - {hook h='displayProductListReviews' product=$product} - {/block} -
      - - - {block name='product_flags'} -
        - {foreach from=$product.flags item=flag} -
      • {$flag.label}
      • - {/foreach} -
      - {/block} - -
      - {block name='quick_view'} - - {l s='Quick view' d='Shop.Theme.Actions'} - - {/block} - - {block name='product_variants'} - {if $product.main_variants} - {include file='catalog/_partials/variant-links.tpl' variants=$product.main_variants} - {/if} - {/block} -
      -
      -
      -{/block} diff --git a/themes/classic/templates/catalog/_partials/product-activation.tpl b/themes/classic/templates/catalog/_partials/product-activation.tpl deleted file mode 100644 index 0732958c..00000000 --- a/themes/classic/templates/catalog/_partials/product-activation.tpl +++ /dev/null @@ -1,38 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{if $page.admin_notifications} - -{/if} diff --git a/themes/classic/templates/catalog/_partials/product-add-to-cart.tpl b/themes/classic/templates/catalog/_partials/product-add-to-cart.tpl deleted file mode 100644 index 279e7003..00000000 --- a/themes/classic/templates/catalog/_partials/product-add-to-cart.tpl +++ /dev/null @@ -1,88 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      - {if !$configuration.is_catalog} - {l s='Quantity' d='Shop.Theme.Catalog'} - - {block name='product_quantity'} -
      -
      - -
      - -
      - -
      - - {hook h='displayProductActions' product=$product} -
      - {/block} - - {block name='product_availability'} - - {if $product.show_availability && $product.availability_message} - {if $product.availability == 'available'} - - {elseif $product.availability == 'last_remaining_items'} - - {else} - - {/if} - {$product.availability_message} - {/if} - - {/block} - - {block name='product_minimal_quantity'} -

      - {if $product.minimal_quantity > 1} - {l - s='The minimum purchase order quantity for the product is %quantity%.' - d='Shop.Theme.Checkout' - sprintf=['%quantity%' => $product.minimal_quantity] - } - {/if} -

      - {/block} - {/if} -
      diff --git a/themes/classic/templates/catalog/_partials/product-additional-info.tpl b/themes/classic/templates/catalog/_partials/product-additional-info.tpl deleted file mode 100644 index f4fd6b5d..00000000 --- a/themes/classic/templates/catalog/_partials/product-additional-info.tpl +++ /dev/null @@ -1,27 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      - {hook h='displayProductAdditionalInfo' product=$product} -
      diff --git a/themes/classic/templates/catalog/_partials/product-cover-thumbnails.tpl b/themes/classic/templates/catalog/_partials/product-cover-thumbnails.tpl deleted file mode 100644 index b6553cd3..00000000 --- a/themes/classic/templates/catalog/_partials/product-cover-thumbnails.tpl +++ /dev/null @@ -1,60 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      - {block name='product_cover'} -
      - {if $product.cover} - {$product.cover.legend} -
      - -
      - {else} - - {/if} -
      - {/block} - - {block name='product_images'} -
      -
        - {foreach from=$product.images item=image} -
      • - {$image.legend} -
      • - {/foreach} -
      -
      - {/block} -
      -{hook h='displayAfterProductThumbs'} diff --git a/themes/classic/templates/catalog/_partials/product-customization.tpl b/themes/classic/templates/catalog/_partials/product-customization.tpl deleted file mode 100644 index efda2b5f..00000000 --- a/themes/classic/templates/catalog/_partials/product-customization.tpl +++ /dev/null @@ -1,69 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      - {if !$configuration.is_catalog} -
      -

      {l s='Product customization' d='Shop.Theme.Catalog'}

      - {l s='Don\'t forget to save your customization to be able to add to cart' d='Shop.Forms.Help'} - - {block name='product_customization_form'} -
      -
        - {foreach from=$customizations.fields item="field"} -
      • - - {if $field.type == 'text'} - - {l s='250 char. max' d='Shop.Forms.Help'} - {if $field.text !== ''} -
        {l s='Your customization:' d='Shop.Theme.Catalog'} - -
        - {/if} - {elseif $field.type == 'image'} - {if $field.is_customized} -
        - - {l s='Remove Image' d='Shop.Theme.Actions'} - {/if} - - {l s='No selected file' d='Shop.Forms.Help'} - - - - {l s='.png .jpg .gif' d='Shop.Forms.Help'} - {/if} -
      • - {/foreach} -
      -
      - -
      -
      - {/block} - -
      - {/if} -
      diff --git a/themes/classic/templates/catalog/_partials/product-details.tpl b/themes/classic/templates/catalog/_partials/product-details.tpl deleted file mode 100644 index 0e5b62dd..00000000 --- a/themes/classic/templates/catalog/_partials/product-details.tpl +++ /dev/null @@ -1,91 +0,0 @@ -
      - {block name='product_reference'} - {if isset($product_manufacturer->id)} -
      - {if isset($manufacturer_image_url)} - - - - {else} - - - {$product_manufacturer->name} - - {/if} -
      - {/if} - {if isset($product.reference_to_display) && $product.reference_to_display neq ''} -
      - - {$product.reference_to_display} -
      - {/if} - {/block} - - {block name='product_quantities'} - {if $product.show_quantities} -
      - - {$product.quantity} {$product.quantity_label} -
      - {/if} - {/block} - - {block name='product_availability_date'} - {if $product.availability_date} -
      - - {$product.availability_date} -
      - {/if} - {/block} - - {block name='product_out_of_stock'} -
      - {hook h='actionProductOutOfStock' product=$product} -
      - {/block} - - {block name='product_features'} - {if $product.grouped_features} -
      -

      {l s='Data sheet' d='Shop.Theme.Catalog'}

      -
      - {foreach from=$product.grouped_features item=feature} -
      {$feature.name}
      -
      {$feature.value|escape:'htmlall'|nl2br nofilter}
      - {/foreach} -
      -
      - {/if} - {/block} - - {* if product have specific references, a table will be added to product details section *} - {block name='product_specific_references'} - {if !empty($product.specific_references)} -
      -

      {l s='Specific References' d='Shop.Theme.Catalog'}

      -
      - {foreach from=$product.specific_references item=reference key=key} -
      {$key}
      -
      {$reference}
      - {/foreach} -
      -
      - {/if} - {/block} - - {block name='product_condition'} - {if $product.condition} -
      - - - {$product.condition.label} -
      - {/if} - {/block} -
      diff --git a/themes/classic/templates/catalog/_partials/product-discounts.tpl b/themes/classic/templates/catalog/_partials/product-discounts.tpl deleted file mode 100644 index 4e5153e1..00000000 --- a/themes/classic/templates/catalog/_partials/product-discounts.tpl +++ /dev/null @@ -1,49 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      - {if $product.quantity_discounts} -

      {l s='Volume discounts' d='Shop.Theme.Catalog'}

      - {block name='product_discount_table'} - - - - - - - - - - {foreach from=$product.quantity_discounts item='quantity_discount' name='quantity_discounts'} - - - - - - {/foreach} - -
      {l s='Quantity' d='Shop.Theme.Catalog'}{$configuration.quantity_discount.label}{l s='You Save' d='Shop.Theme.Catalog'}
      {$quantity_discount.quantity}{$quantity_discount.discount}{l s='Up to %discount%' d='Shop.Theme.Catalog' sprintf=['%discount%' => $quantity_discount.save]}
      - {/block} - {/if} -
      diff --git a/themes/classic/templates/catalog/_partials/product-flags.tpl b/themes/classic/templates/catalog/_partials/product-flags.tpl deleted file mode 100644 index 2f5b14cb..00000000 --- a/themes/classic/templates/catalog/_partials/product-flags.tpl +++ /dev/null @@ -1,31 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='product_flags'} -
        - {foreach from=$product.flags item=flag} -
      • {$flag.label}
      • - {/foreach} -
      -{/block} diff --git a/themes/classic/templates/catalog/_partials/product-images-modal.tpl b/themes/classic/templates/catalog/_partials/product-images-modal.tpl deleted file mode 100644 index 2500cc79..00000000 --- a/themes/classic/templates/catalog/_partials/product-images-modal.tpl +++ /dev/null @@ -1,60 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - diff --git a/themes/classic/templates/catalog/_partials/product-prices.tpl b/themes/classic/templates/catalog/_partials/product-prices.tpl deleted file mode 100644 index 7b6c0b50..00000000 --- a/themes/classic/templates/catalog/_partials/product-prices.tpl +++ /dev/null @@ -1,114 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{if $product.show_price} -
      - {block name='product_discount'} - {if $product.has_discount} -
      - {hook h='displayProductPriceBlock' product=$product type="old_price"} - {$product.regular_price} -
      - {/if} - {/block} - - {block name='product_price'} -
      - - - -
      - {$product.price} - - {if $product.has_discount} - {if $product.discount_type === 'percentage'} - {l s='Save %percentage%' d='Shop.Theme.Catalog' sprintf=['%percentage%' => $product.discount_percentage_absolute]} - {else} - - {l s='Save %amount%' d='Shop.Theme.Catalog' sprintf=['%amount%' => $product.discount_to_display]} - - {/if} - {/if} -
      - - {block name='product_unit_price'} - {if $displayUnitPrice} -

      {l s='(%unit_price%)' d='Shop.Theme.Catalog' sprintf=['%unit_price%' => $product.unit_price_full]}

      - {/if} - {/block} -
      - {/block} - - {block name='product_without_taxes'} - {if $priceDisplay == 2} -

      {l s='%price% tax excl.' d='Shop.Theme.Catalog' sprintf=['%price%' => $product.price_tax_exc]}

      - {/if} - {/block} - - {block name='product_pack_price'} - {if $displayPackPrice} -

      {l s='Instead of %price%' d='Shop.Theme.Catalog' sprintf=['%price%' => $noPackPrice]}

      - {/if} - {/block} - - {block name='product_ecotax'} - {if $product.ecotax.amount > 0} -

      {l s='Including %amount% for ecotax' d='Shop.Theme.Catalog' sprintf=['%amount%' => $product.ecotax.value]} - {if $product.has_discount} - {l s='(not impacted by the discount)' d='Shop.Theme.Catalog'} - {/if} -

      - {/if} - {/block} - - {hook h='displayProductPriceBlock' product=$product type="weight" hook_origin='product_sheet'} - -
      - {if !$configuration.taxes_enabled} - {l s='No tax' d='Shop.Theme.Catalog'} - {elseif $configuration.display_taxes_label} - {$product.labels.tax_long} - {/if} - {hook h='displayProductPriceBlock' product=$product type="price"} - {hook h='displayProductPriceBlock' product=$product type="after_price"} - {if $product.additional_delivery_times == 1} - {if $product.delivery_information} - {$product.delivery_information} - {/if} - {elseif $product.additional_delivery_times == 2} - {if $product.quantity > 0} - {$product.delivery_in_stock} - {* Out of stock message should not be displayed if customer can't order the product. *} - {elseif $product.quantity <= 0 && $product.add_to_cart_url} - {$product.delivery_out_stock} - {/if} - {/if} -
      -
      -{/if} diff --git a/themes/classic/templates/catalog/_partials/product-variants.tpl b/themes/classic/templates/catalog/_partials/product-variants.tpl deleted file mode 100644 index fd0bdada..00000000 --- a/themes/classic/templates/catalog/_partials/product-variants.tpl +++ /dev/null @@ -1,69 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      - {foreach from=$groups key=id_attribute_group item=group} - {if !empty($group.attributes)} -
      - {$group.name} - {if $group.group_type == 'select'} - - {elseif $group.group_type == 'color'} -
        - {foreach from=$group.attributes key=id_attribute item=group_attribute} -
      • - -
      • - {/foreach} -
      - {elseif $group.group_type == 'radio'} -
        - {foreach from=$group.attributes key=id_attribute item=group_attribute} -
      • - -
      • - {/foreach} -
      - {/if} -
      - {/if} - {/foreach} -
      diff --git a/themes/classic/templates/catalog/_partials/products-bottom.tpl b/themes/classic/templates/catalog/_partials/products-bottom.tpl deleted file mode 100644 index 9188f7f5..00000000 --- a/themes/classic/templates/catalog/_partials/products-bottom.tpl +++ /dev/null @@ -1,6 +0,0 @@ -{* - * Classic theme doesn't use this subtemplate, feel free to do whatever you need here. - * This template is generated at each ajax calls. - * See ProductListingFrontController::getAjaxProductSearchVariables() - *} -
      diff --git a/themes/classic/templates/catalog/_partials/products-top.tpl b/themes/classic/templates/catalog/_partials/products-top.tpl deleted file mode 100644 index 6ef70677..00000000 --- a/themes/classic/templates/catalog/_partials/products-top.tpl +++ /dev/null @@ -1,56 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      -
      - {if $listing.pagination.total_items > 1} -

      {l s='There are %product_count% products.' d='Shop.Theme.Catalog' sprintf=['%product_count%' => $listing.pagination.total_items]}

      - {elseif $listing.pagination.total_items > 0} -

      {l s='There is 1 product.' d='Shop.Theme.Catalog'}

      - {/if} -
      -
      -
      - - {block name='sort_by'} - {include file='catalog/_partials/sort-orders.tpl' sort_orders=$listing.sort_orders} - {/block} - - {if !empty($listing.rendered_facets)} -
      - -
      - {/if} -
      -
      -
      - {l s='Showing %from%-%to% of %total% item(s)' d='Shop.Theme.Catalog' sprintf=[ - '%from%' => $listing.pagination.items_shown_from , - '%to%' => $listing.pagination.items_shown_to, - '%total%' => $listing.pagination.total_items - ]} -
      -
      diff --git a/themes/classic/templates/catalog/_partials/products.tpl b/themes/classic/templates/catalog/_partials/products.tpl deleted file mode 100644 index 6089cf71..00000000 --- a/themes/classic/templates/catalog/_partials/products.tpl +++ /dev/null @@ -1,44 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      -
      - {foreach from=$listing.products item="product"} - {block name='product_miniature'} - {include file='catalog/_partials/miniatures/product.tpl' product=$product} - {/block} - {/foreach} -
      - - {block name='pagination'} - {include file='_partials/pagination.tpl' pagination=$listing.pagination} - {/block} - - -
      diff --git a/themes/classic/templates/catalog/_partials/quickview.tpl b/themes/classic/templates/catalog/_partials/quickview.tpl deleted file mode 100644 index 43fbb8ef..00000000 --- a/themes/classic/templates/catalog/_partials/quickview.tpl +++ /dev/null @@ -1,79 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - diff --git a/themes/classic/templates/catalog/_partials/sort-orders.tpl b/themes/classic/templates/catalog/_partials/sort-orders.tpl deleted file mode 100644 index b9c40e87..00000000 --- a/themes/classic/templates/catalog/_partials/sort-orders.tpl +++ /dev/null @@ -1,47 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{l s='Sort by:' d='Shop.Theme.Global'} - diff --git a/themes/classic/templates/catalog/_partials/variant-links.tpl b/themes/classic/templates/catalog/_partials/variant-links.tpl deleted file mode 100644 index 54f52638..00000000 --- a/themes/classic/templates/catalog/_partials/variant-links.tpl +++ /dev/null @@ -1,16 +0,0 @@ - diff --git a/themes/classic/templates/catalog/brands.tpl b/themes/classic/templates/catalog/brands.tpl deleted file mode 100644 index 62783347..00000000 --- a/themes/classic/templates/catalog/brands.tpl +++ /dev/null @@ -1,44 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file=$layout} - -{block name='content'} -
      - - {block name='brand_header'} -

      {l s='Brands' d='Shop.Theme.Catalog'}

      - {/block} - - {block name='brand_miniature'} -
        - {foreach from=$brands item=brand} - {include file='catalog/_partials/miniatures/brand.tpl' brand=$brand} - {/foreach} -
      - {/block} - -
      - -{/block} diff --git a/themes/classic/templates/catalog/listing/best-sales.tpl b/themes/classic/templates/catalog/listing/best-sales.tpl deleted file mode 100644 index 3b34af8f..00000000 --- a/themes/classic/templates/catalog/listing/best-sales.tpl +++ /dev/null @@ -1,5 +0,0 @@ -{* - * This file allows you to customize your best-sales page. - * You can safely remove it if you want it to appear exactly like all other product listing pages - *} -{extends file='catalog/listing/product-list.tpl'} diff --git a/themes/classic/templates/catalog/listing/category.tpl b/themes/classic/templates/catalog/listing/category.tpl deleted file mode 100644 index 37eb25b9..00000000 --- a/themes/classic/templates/catalog/listing/category.tpl +++ /dev/null @@ -1,29 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='catalog/listing/product-list.tpl'} - -{block name='product_list_header'} - {include file='catalog/_partials/category-header.tpl' listing=$listing category=$category} -{/block} diff --git a/themes/classic/templates/catalog/listing/manufacturer.tpl b/themes/classic/templates/catalog/listing/manufacturer.tpl deleted file mode 100644 index acfa00c9..00000000 --- a/themes/classic/templates/catalog/listing/manufacturer.tpl +++ /dev/null @@ -1,31 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='catalog/listing/product-list.tpl'} - -{block name='product_list_header'} -

      {l s='List of products by brand %brand_name%' sprintf=['%brand_name%' => $manufacturer.name] d='Shop.Theme.Catalog'}

      -
      {$manufacturer.short_description nofilter}
      -
      {$manufacturer.description nofilter}
      -{/block} diff --git a/themes/classic/templates/catalog/listing/new-products.tpl b/themes/classic/templates/catalog/listing/new-products.tpl deleted file mode 100644 index b42d05c5..00000000 --- a/themes/classic/templates/catalog/listing/new-products.tpl +++ /dev/null @@ -1,5 +0,0 @@ -{* - * This file allows you to customize your new-product page. - * You can safely remove it if you want it to appear exactly like all other product listing pages - *} -{extends file='catalog/listing/product-list.tpl'} diff --git a/themes/classic/templates/catalog/listing/prices-drop.tpl b/themes/classic/templates/catalog/listing/prices-drop.tpl deleted file mode 100644 index 21639402..00000000 --- a/themes/classic/templates/catalog/listing/prices-drop.tpl +++ /dev/null @@ -1,5 +0,0 @@ -{* - * This file allows you to customize your price-drop page. - * You can safely remove it if you want it to appear exactly like all other product listing pages - *} -{extends file='catalog/listing/product-list.tpl'} diff --git a/themes/classic/templates/catalog/listing/product-list.tpl b/themes/classic/templates/catalog/listing/product-list.tpl deleted file mode 100644 index 4ebfbf6c..00000000 --- a/themes/classic/templates/catalog/listing/product-list.tpl +++ /dev/null @@ -1,73 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file=$layout} - -{block name='content'} -
      - - {block name='product_list_header'} -

      {$listing.label}

      - {/block} - -
      - {if $listing.products|count} - -
      - {block name='product_list_top'} - {include file='catalog/_partials/products-top.tpl' listing=$listing} - {/block} -
      - - {block name='product_list_active_filters'} -
      - {$listing.rendered_active_filters nofilter} -
      - {/block} - -
      - {block name='product_list'} - {include file='catalog/_partials/products.tpl' listing=$listing} - {/block} -
      - -
      - {block name='product_list_bottom'} - {include file='catalog/_partials/products-bottom.tpl' listing=$listing} - {/block} -
      - - {else} -
      - -
      - {include file='errors/not-found.tpl'} -
      - -
      - {/if} -
      - -
      -{/block} diff --git a/themes/classic/templates/catalog/listing/search.tpl b/themes/classic/templates/catalog/listing/search.tpl deleted file mode 100644 index d745e42f..00000000 --- a/themes/classic/templates/catalog/listing/search.tpl +++ /dev/null @@ -1,5 +0,0 @@ -{* - * This file allows you to customize your search page. - * You can safely remove it if you want it to appear exactly like all other product listing pages - *} -{extends file='catalog/listing/product-list.tpl'} diff --git a/themes/classic/templates/catalog/listing/supplier.tpl b/themes/classic/templates/catalog/listing/supplier.tpl deleted file mode 100644 index ec63ada1..00000000 --- a/themes/classic/templates/catalog/listing/supplier.tpl +++ /dev/null @@ -1,30 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='catalog/listing/product-list.tpl'} - -{block name='product_list_header'} -

      {l s='List of products by supplier %s' sprintf=[$supplier.name] d='Shop.Theme.Catalog'}

      -
      {$supplier.description nofilter}
      -{/block} diff --git a/themes/classic/templates/catalog/manufacturers.tpl b/themes/classic/templates/catalog/manufacturers.tpl deleted file mode 100644 index c85bab0e..00000000 --- a/themes/classic/templates/catalog/manufacturers.tpl +++ /dev/null @@ -1,25 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='catalog/brands.tpl'} diff --git a/themes/classic/templates/catalog/product.tpl b/themes/classic/templates/catalog/product.tpl deleted file mode 100644 index e3eb87a0..00000000 --- a/themes/classic/templates/catalog/product.tpl +++ /dev/null @@ -1,268 +0,0 @@ -{** - * 2007-2020 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2020 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file=$layout} - -{block name='head_seo' prepend} - -{/block} - -{block name='head' append} - - - - - - - {if $product.show_price} - - - - - {/if} - {if isset($product.weight) && ($product.weight != 0)} - - - {/if} -{/block} - -{block name='content'} - -
      - - -
      -
      - {block name='page_content_container'} -
      - {block name='page_content'} - - {block name='product_flags'} -
        - {foreach from=$product.flags item=flag} -
      • {$flag.label}
      • - {/foreach} -
      - {/block} - - {block name='product_cover_thumbnails'} - {include file='catalog/_partials/product-cover-thumbnails.tpl'} - {/block} -
      - - -
      - - {/block} -
      - {/block} -
      -
      - {block name='page_header_container'} - {block name='page_header'} -

      {block name='page_title'}{$product.name}{/block}

      - {/block} - {/block} - {block name='product_prices'} - {include file='catalog/_partials/product-prices.tpl'} - {/block} - -
      - {block name='product_description_short'} -
      {$product.description_short nofilter}
      - {/block} - - {if $product.is_customizable && count($product.customizations.fields)} - {block name='product_customization'} - {include file="catalog/_partials/product-customization.tpl" customizations=$product.customizations} - {/block} - {/if} - -
      - {block name='product_buy'} -
      - - - - - {block name='product_variants'} - {include file='catalog/_partials/product-variants.tpl'} - {/block} - - {block name='product_pack'} - {if $packItems} -
      -

      {l s='This pack contains' d='Shop.Theme.Catalog'}

      - {foreach from=$packItems item="product_pack"} - {block name='product_miniature'} - {include file='catalog/_partials/miniatures/pack-product.tpl' product=$product_pack} - {/block} - {/foreach} -
      - {/if} - {/block} - - {block name='product_discounts'} - {include file='catalog/_partials/product-discounts.tpl'} - {/block} - - {block name='product_add_to_cart'} - {include file='catalog/_partials/product-add-to-cart.tpl'} - {/block} - - {block name='product_additional_info'} - {include file='catalog/_partials/product-additional-info.tpl'} - {/block} - - {* Input to refresh product HTML removed, block kept for compatibility with themes *} - {block name='product_refresh'}{/block} -
      - {/block} - -
      - - {block name='hook_display_reassurance'} - {hook h='displayReassurance'} - {/block} - - {block name='product_tabs'} -
      - - -
      -
      - {block name='product_description'} -
      {$product.description nofilter}
      - {/block} -
      - - {block name='product_details'} - {include file='catalog/_partials/product-details.tpl'} - {/block} - - {block name='product_attachments'} - {if $product.attachments} -
      -
      -

      {l s='Download' d='Shop.Theme.Actions'}

      - {foreach from=$product.attachments item=attachment} -
      -

      {$attachment.name}

      -

      {$attachment.description}

      - {l s='Download' d='Shop.Theme.Actions'} ({$attachment.file_size_formatted}) - -
      - {/foreach} -
      -
      - {/if} - {/block} - - {foreach from=$product.extraContent item=extra key=extraKey} -
      $val} {$key}="{$val}"{/foreach}> - {$extra.content nofilter} -
      - {/foreach} -
      -
      - {/block} -
      -
      -
      - - {block name='product_accessories'} - {if $accessories} -
      -

      {l s='You might also like' d='Shop.Theme.Catalog'}

      -
      - {foreach from=$accessories item="product_accessory"} - {block name='product_miniature'} - {include file='catalog/_partials/miniatures/product.tpl' product=$product_accessory} - {/block} - {/foreach} -
      -
      - {/if} - {/block} - - {block name='product_footer'} - {hook h='displayFooterProduct' product=$product category=$category} - {/block} - - {block name='product_images_modal'} - {include file='catalog/_partials/product-images-modal.tpl'} - {/block} - - {block name='page_footer_container'} -
      - {block name='page_footer'} - - {/block} -
      - {/block} -
      - -{/block} diff --git a/themes/classic/templates/catalog/suppliers.tpl b/themes/classic/templates/catalog/suppliers.tpl deleted file mode 100644 index 84992fcd..00000000 --- a/themes/classic/templates/catalog/suppliers.tpl +++ /dev/null @@ -1,29 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='catalog/brands.tpl'} - -{block name='brand_header'} -

      {l s='Suppliers' d='Shop.Theme.Catalog'}

      -{/block} diff --git a/themes/classic/templates/checkout/_partials/address-form.tpl b/themes/classic/templates/checkout/_partials/address-form.tpl deleted file mode 100644 index 435d5f45..00000000 --- a/themes/classic/templates/checkout/_partials/address-form.tpl +++ /dev/null @@ -1,46 +0,0 @@ -{extends file='customer/_partials/address-form.tpl'} - -{block name='form_field'} - {if $field.name eq "alias"} - {* we don't ask for alias here *} - {else} - {$smarty.block.parent} - {/if} -{/block} - -{block name="address_form_url"} -
      -{/block} - -{block name='form_fields' append} - - {if $type === "delivery"} -
      -
      - - -
      -
      - {/if} -{/block} - -{block name='form_buttons'} - {if !$form_has_continue_button} - - {l s='Cancel' d='Shop.Theme.Actions'} - {else} - - - {if $customer.addresses|count > 0} - {l s='Cancel' d='Shop.Theme.Actions'} - {/if} -
      - {/if} -{/block} diff --git a/themes/classic/templates/checkout/_partials/address-selector-block.tpl b/themes/classic/templates/checkout/_partials/address-selector-block.tpl deleted file mode 100644 index d46347e6..00000000 --- a/themes/classic/templates/checkout/_partials/address-selector-block.tpl +++ /dev/null @@ -1,72 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='address_selector_blocks'} - {foreach $addresses as $address} - - {/foreach} - {if $interactive} -

      - -

      - {/if} -{/block} diff --git a/themes/classic/templates/checkout/_partials/cart-detailed-actions.tpl b/themes/classic/templates/checkout/_partials/cart-detailed-actions.tpl deleted file mode 100644 index 130410ce..00000000 --- a/themes/classic/templates/checkout/_partials/cart-detailed-actions.tpl +++ /dev/null @@ -1,45 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='cart_detailed_actions'} -
      - {if $cart.minimalPurchaseRequired} - -
      - -
      - {elseif empty($cart.products) } -
      - -
      - {else} -
      - {l s='Proceed to checkout' d='Shop.Theme.Actions'} - {hook h='displayExpressCheckout'} -
      - {/if} -
      -{/block} diff --git a/themes/classic/templates/checkout/_partials/cart-detailed-product-line.tpl b/themes/classic/templates/checkout/_partials/cart-detailed-product-line.tpl deleted file mode 100644 index 2761364f..00000000 --- a/themes/classic/templates/checkout/_partials/cart-detailed-product-line.tpl +++ /dev/null @@ -1,175 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      - -
      - - {$product.name|escape:'quotes'} - -
      - - -
      - - -
      - {if $product.has_discount} -
      - {$product.regular_price} - {if $product.discount_type === 'percentage'} - - -{$product.discount_percentage_absolute} - - {else} - - -{$product.discount_to_display} - - {/if} -
      - {/if} -
      - {$product.price} - {if $product.unit_price_full} -
      {$product.unit_price_full}
      - {/if} -
      -
      - -
      - - {foreach from=$product.attributes key="attribute" item="value"} -
      - {$attribute}: - {$value} -
      - {/foreach} - - {if is_array($product.customizations) && $product.customizations|count} -
      - {block name='cart_detailed_product_line_customization'} - {foreach from=$product.customizations item="customization"} - {l s='Product customization' d='Shop.Theme.Catalog'} - - {/foreach} - {/block} - {/if} -
      - - -
      -
      -
      -
      -
      -
      - {if isset($product.is_gift) && $product.is_gift} - {$product.quantity} - {else} - - {/if} -
      -
      - - - {if isset($product.is_gift) && $product.is_gift} - {l s='Gift' d='Shop.Theme.Checkout'} - {else} - {$product.total} - {/if} - - -
      -
      -
      -
      -
      - - {if !isset($product.is_gift) || !$product.is_gift} - delete - {/if} - - - {block name='hook_cart_extra_product_actions'} - {hook h='displayCartExtraProductActions' product=$product} - {/block} - -
      -
      -
      -
      - -
      -
      diff --git a/themes/classic/templates/checkout/_partials/cart-detailed-totals.tpl b/themes/classic/templates/checkout/_partials/cart-detailed-totals.tpl deleted file mode 100644 index b15aaae1..00000000 --- a/themes/classic/templates/checkout/_partials/cart-detailed-totals.tpl +++ /dev/null @@ -1,58 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='cart_detailed_totals'} -
      - -
      - {foreach from=$cart.subtotals item="subtotal"} - {if $subtotal.value && $subtotal.type !== 'tax'} -
      - - {if 'products' == $subtotal.type} - {$cart.summary_string} - {else} - {$subtotal.label} - {/if} - - - {if 'discount' == $subtotal.type}- {/if}{$subtotal.value} - - {if $subtotal.type === 'shipping'} -
      {hook h='displayCheckoutSubtotalDetails' subtotal=$subtotal}
      - {/if} -
      - {/if} - {/foreach} -
      - - {block name='cart_summary_totals'} - {include file='checkout/_partials/cart-summary-totals.tpl' cart=$cart} - {/block} - - {block name='cart_voucher'} - {include file='checkout/_partials/cart-voucher.tpl'} - {/block} -
      -{/block} diff --git a/themes/classic/templates/checkout/_partials/cart-detailed.tpl b/themes/classic/templates/checkout/_partials/cart-detailed.tpl deleted file mode 100644 index f04ca4b5..00000000 --- a/themes/classic/templates/checkout/_partials/cart-detailed.tpl +++ /dev/null @@ -1,42 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='cart_detailed_product'} -
      - {if $cart.products} -
        - {foreach from=$cart.products item=product} -
      • - {block name='cart_detailed_product_line'} - {include file='checkout/_partials/cart-detailed-product-line.tpl' product=$product} - {/block} -
      • - {if is_array($product.customizations) && $product.customizations|count >1}
        {/if} - {/foreach} -
      - {else} - {l s='There are no more items in your cart' d='Shop.Theme.Checkout'} - {/if} -
      -{/block} diff --git a/themes/classic/templates/checkout/_partials/cart-summary-items-subtotal.tpl b/themes/classic/templates/checkout/_partials/cart-summary-items-subtotal.tpl deleted file mode 100644 index 4f3d99da..00000000 --- a/themes/classic/templates/checkout/_partials/cart-summary-items-subtotal.tpl +++ /dev/null @@ -1,30 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='cart_summary_items_subtotal'} -
      - {$cart.summary_string} - {$cart.subtotals.products.amount} -
      -{/block} diff --git a/themes/classic/templates/checkout/_partials/cart-summary-product-line.tpl b/themes/classic/templates/checkout/_partials/cart-summary-product-line.tpl deleted file mode 100644 index bea5fa0d..00000000 --- a/themes/classic/templates/checkout/_partials/cart-summary-product-line.tpl +++ /dev/null @@ -1,44 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='cart_summary_product_line'} -
      - - {$product.name} - -
      -
      - {$product.name} - x{$product.quantity} - {$product.price} - {hook h='displayProductPriceBlock' product=$product type="unit_price"} - {foreach from=$product.attributes key="attribute" item="value"} -
      - {$attribute}: - {$value} -
      - {/foreach} -
      -
      -{/block} diff --git a/themes/classic/templates/checkout/_partials/cart-summary-subtotals.tpl b/themes/classic/templates/checkout/_partials/cart-summary-subtotals.tpl deleted file mode 100644 index f1fab19a..00000000 --- a/themes/classic/templates/checkout/_partials/cart-summary-subtotals.tpl +++ /dev/null @@ -1,44 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - -
      - - {foreach from=$cart.subtotals item="subtotal"} - {if $subtotal.value && $subtotal.type !== 'tax'} -
      - - - {$subtotal.label} - - - - {$subtotal.value} - -
      - {/if} - {/foreach} - -
      - diff --git a/themes/classic/templates/checkout/_partials/cart-summary-totals.tpl b/themes/classic/templates/checkout/_partials/cart-summary-totals.tpl deleted file mode 100644 index 903817c8..00000000 --- a/themes/classic/templates/checkout/_partials/cart-summary-totals.tpl +++ /dev/null @@ -1,54 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      - - {block name='cart_summary_total'} - {if !$configuration.display_prices_tax_incl && $configuration.taxes_enabled} -
      - {$cart.totals.total.label} {$cart.labels.tax_short} - {$cart.totals.total.value} -
      -
      - {$cart.totals.total_including_tax.label} - {$cart.totals.total_including_tax.value} -
      - {else} -
      - {$cart.totals.total.label} {if $configuration.taxes_enabled}{$cart.labels.tax_short}{/if} - {$cart.totals.total.value} -
      - {/if} - {/block} - - {block name='cart_summary_tax'} - {if $cart.subtotals.tax} -
      - {l s='%label%:' sprintf=['%label%' => $cart.subtotals.tax.label] d='Shop.Theme.Global'} - {$cart.subtotals.tax.value} -
      - {/if} - {/block} - -
      diff --git a/themes/classic/templates/checkout/_partials/cart-summary.tpl b/themes/classic/templates/checkout/_partials/cart-summary.tpl deleted file mode 100644 index 6c07ff69..00000000 --- a/themes/classic/templates/checkout/_partials/cart-summary.tpl +++ /dev/null @@ -1,69 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      -
      - {block name='hook_checkout_summary_top'} - {hook h='displayCheckoutSummaryTop'} - {/block} - - {block name='cart_summary_products'} -
      - -

      {$cart.summary_string}

      - -

      - - {l s='show details' d='Shop.Theme.Actions'} - expand_more - -

      - - {block name='cart_summary_product_list'} -
      -
        - {foreach from=$cart.products item=product} -
      • {include file='checkout/_partials/cart-summary-product-line.tpl' product=$product}
      • - {/foreach} -
      -
      - {/block} -
      - {/block} - - {block name='cart_summary_subtotals'} - {include file='checkout/_partials/cart-summary-subtotals.tpl' cart=$cart} - {/block} - -
      - - {block name='cart_summary_totals'} - {include file='checkout/_partials/cart-summary-totals.tpl' cart=$cart} - {/block} - - {block name='cart_summary_voucher'} - {include file='checkout/_partials/cart-voucher.tpl'} - {/block} - -
      diff --git a/themes/classic/templates/checkout/_partials/cart-voucher.tpl b/themes/classic/templates/checkout/_partials/cart-voucher.tpl deleted file mode 100644 index f1f95ad6..00000000 --- a/themes/classic/templates/checkout/_partials/cart-voucher.tpl +++ /dev/null @@ -1,91 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{if $cart.vouchers.allowed} - {block name='cart_voucher'} -
      -
      - {if $cart.vouchers.added} - {block name='cart_voucher_list'} -
        - {foreach from=$cart.vouchers.added item=voucher} -
      • - {$voucher.name} -
        - {$voucher.reduction_formatted} - -
        -
      • - {/foreach} -
      - {/block} - {/if} - -

      - - {l s='Have a promo code?' d='Shop.Theme.Checkout'} - -

      - -
      -
      - {block name='cart_voucher_form'} -
      - - - - -
      - {/block} - - {block name='cart_voucher_notifications'} - - {/block} - - - {l s='Close' d='Shop.Theme.Checkout'} - -
      -
      - - {if $cart.discounts|count > 0} -

      - {l s='Take advantage of our exclusive offers:' d='Shop.Theme.Actions'} -

      -
        - {foreach from=$cart.discounts item=discount} -
      • - - {$discount.code} - {$discount.name} - -
      • - {/foreach} -
      - {/if} -
      -
      - {/block} -{/if} diff --git a/themes/classic/templates/checkout/_partials/customer-form.tpl b/themes/classic/templates/checkout/_partials/customer-form.tpl deleted file mode 100644 index cbd7b4fc..00000000 --- a/themes/classic/templates/checkout/_partials/customer-form.tpl +++ /dev/null @@ -1,50 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends "customer/_partials/customer-form.tpl"} - -{block "form_field"} - {if $field.name === 'password' and $guest_allowed} -

      - {l s='Create an account' d='Shop.Theme.Checkout'} {l s='(optional)' d='Shop.Theme.Checkout'} -
      - {l s='And save time on your next order!' d='Shop.Theme.Checkout'} -

      - {$smarty.block.parent} - {else} - {$smarty.block.parent} - {/if} -{/block} - -{block "form_buttons"} - -{/block} diff --git a/themes/classic/templates/checkout/_partials/footer.tpl b/themes/classic/templates/checkout/_partials/footer.tpl deleted file mode 100644 index 853c4d11..00000000 --- a/themes/classic/templates/checkout/_partials/footer.tpl +++ /dev/null @@ -1,29 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='footer'} -
      - {l s='%copyright% %year% - Ecommerce software by %prestashop%' sprintf=['%prestashop%' => 'PrestaShop™', '%year%' => 'Y'|date, '%copyright%' => '©'] d='Shop.Theme.Global'} -
      -{/block} diff --git a/themes/classic/templates/checkout/_partials/header.tpl b/themes/classic/templates/checkout/_partials/header.tpl deleted file mode 100644 index 54df9a1e..00000000 --- a/themes/classic/templates/checkout/_partials/header.tpl +++ /dev/null @@ -1,76 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='header'} - {block name='header_nav'} - - {/block} - - {block name='header_top'} -
      -
      -
      -
      -
      - {hook h='displayTop'} -
      -
      -
      -
      - -
      -
      - {hook h='displayNavFullWidth'} - {/block} -{/block} diff --git a/themes/classic/templates/checkout/_partials/login-form.tpl b/themes/classic/templates/checkout/_partials/login-form.tpl deleted file mode 100644 index 45b49d6e..00000000 --- a/themes/classic/templates/checkout/_partials/login-form.tpl +++ /dev/null @@ -1,37 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='customer/_partials/login-form.tpl'} - -{block name='form_buttons'} - -{/block} diff --git a/themes/classic/templates/checkout/_partials/order-confirmation-table.tpl b/themes/classic/templates/checkout/_partials/order-confirmation-table.tpl deleted file mode 100644 index 8708cea5..00000000 --- a/themes/classic/templates/checkout/_partials/order-confirmation-table.tpl +++ /dev/null @@ -1,136 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      -
      - {block name='order_items_table_head'} -

      {l s='Order items' d='Shop.Theme.Checkout'}

      -

      {l s='Unit price' d='Shop.Theme.Checkout'}

      -

      {l s='Quantity' d='Shop.Theme.Checkout'}

      -

      {l s='Total products' d='Shop.Theme.Checkout'}

      - {/block} -
      - -
      - - {block name='order_confirmation_table'} - {foreach from=$products item=product} -
      -
      - - - -
      -
      - {if $add_product_link}{/if} - {$product.name} - {if $add_product_link}{/if} - {if is_array($product.customizations) && $product.customizations|count} - {foreach from=$product.customizations item="customization"} - - - {/foreach} - {/if} - {hook h='displayProductPriceBlock' product=$product type="unit_price"} -
      -
      -
      -
      {$product.price}
      -
      {$product.quantity}
      -
      {$product.total}
      -
      -
      -
      - {/foreach} - -
      - - - {foreach $subtotals as $subtotal} - {if $subtotal.type !== 'tax' && $subtotal.label !== null} - - - - - {/if} - {/foreach} - - {if !$configuration.display_prices_tax_incl && $configuration.taxes_enabled} - - - - - - - - - {else} - - - - - {/if} - {if $subtotals.tax.label !== null} - - - - {/if} -
      {$subtotal.label}{if 'discount' == $subtotal.type}- {/if}{$subtotal.value}
      {$totals.total.label} {$labels.tax_short}{$totals.total.value}
      {$totals.total_including_tax.label}{$totals.total_including_tax.value}
      {$totals.total.label} {if $configuration.taxes_enabled}{$labels.tax_short}{/if}{$totals.total.value}
      {l s='%label%:' sprintf=['%label%' => $subtotals.tax.label] d='Shop.Theme.Global'} {$subtotals.tax.value}
      - {/block} - -
      -
      diff --git a/themes/classic/templates/checkout/_partials/order-final-summary-table.tpl b/themes/classic/templates/checkout/_partials/order-final-summary-table.tpl deleted file mode 100644 index a1cf3185..00000000 --- a/themes/classic/templates/checkout/_partials/order-final-summary-table.tpl +++ /dev/null @@ -1,38 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='checkout/_partials/order-confirmation-table.tpl'} - -{block name='order-items-table-head'} -
      -

      - {if $products_count == 1} - {l s='%product_count% item in your cart' sprintf=['%product_count%' => $products_count] d='Shop.Theme.Checkout'} - {else} - {l s='%products_count% items in your cart' sprintf=['%products_count%' => $products_count] d='Shop.Theme.Checkout'} - {/if} - mode_edit {l s='edit' d='Shop.Theme.Actions'} -

      -
      -{/block} diff --git a/themes/classic/templates/checkout/_partials/order-final-summary.tpl b/themes/classic/templates/checkout/_partials/order-final-summary.tpl deleted file mode 100644 index e67a4a51..00000000 --- a/themes/classic/templates/checkout/_partials/order-final-summary.tpl +++ /dev/null @@ -1,103 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      -
      -
      -

      {l s='Please check your order before payment' d='Shop.Theme.Checkout'}

      -
      -
      - -
      -
      -

      - {l s='Addresses' d='Shop.Theme.Checkout'} - mode_edit {l s='edit' d='Shop.Theme.Actions'} -

      -
      -
      -
      -
      -
      -
      -

      {l s='Your Delivery Address' d='Shop.Theme.Checkout'}

      - {$customer.addresses[$cart.id_address_delivery]['formatted'] nofilter} -
      -
      -
      -
      -
      -
      -

      {l s='Your Invoice Address' d='Shop.Theme.Checkout'}

      - {$customer.addresses[$cart.id_address_invoice]['formatted'] nofilter} -
      -
      -
      -
      - -
      -
      -

      - {l s='Shipping Method' d='Shop.Theme.Checkout'} - mode_edit {l s='edit' d='Shop.Theme.Actions'} -

      - -
      -
      -
      -
      - {if $selected_delivery_option.logo} - {$selected_delivery_option.name} - {else} -   - {/if} -
      -
      -
      - {$selected_delivery_option.name} -
      -
      - {$selected_delivery_option.delay} -
      -
      - {$selected_delivery_option.price} -
      -
      -
      -
      -
      - -
      - {block name='order_confirmation_table'} - {include file='checkout/_partials/order-final-summary-table.tpl' - products=$cart.products - products_count=$cart.products_count - subtotals=$cart.subtotals - totals=$cart.totals - labels=$cart.labels - add_product_link=true - } - {/block} -
      -
      diff --git a/themes/classic/templates/checkout/_partials/steps/addresses.tpl b/themes/classic/templates/checkout/_partials/steps/addresses.tpl deleted file mode 100644 index 2dc14b61..00000000 --- a/themes/classic/templates/checkout/_partials/steps/addresses.tpl +++ /dev/null @@ -1,137 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='checkout/_partials/steps/checkout-step.tpl'} - -{block name='step_content'} -
      -
      - - {if !$use_same_address} -

      {l s='Shipping Address' d='Shop.Theme.Checkout'}

      - {/if} - - {if $use_same_address && !$cart.is_virtual} -

      - {l s='The selected address will be used both as your personal address (for invoice) and as your delivery address.' d='Shop.Theme.Checkout'} -

      - {elseif $use_same_address && $cart.is_virtual} -

      - {l s='The selected address will be used as your personal address (for invoice).' d='Shop.Theme.Checkout'} -

      - {/if} - - {if $show_delivery_address_form} -
      - {render file = 'checkout/_partials/address-form.tpl' - ui = $address_form - use_same_address = $use_same_address - type = "delivery" - form_has_continue_button = $form_has_continue_button - } -
      - {elseif $customer.addresses|count > 0} -
      - {include file = 'checkout/_partials/address-selector-block.tpl' - addresses = $customer.addresses - name = "id_address_delivery" - selected = $id_address_delivery - type = "delivery" - interactive = !$show_delivery_address_form and !$show_invoice_address_form - } -
      - - {if isset($delivery_address_error)} -

      {$delivery_address_error.exception}

      - {else} - - {/if} - -

      - {l s='add new address' d='Shop.Theme.Actions'} -

      - - {if $use_same_address && !$cart.is_virtual} -

      - - {l s='Billing address differs from shipping address' d='Shop.Theme.Checkout'} - -

      - {/if} - - {/if} - - {if !$use_same_address} - -

      {l s='Your Invoice Address' d='Shop.Theme.Checkout'}

      - - {if $show_invoice_address_form} -
      - {render file = 'checkout/_partials/address-form.tpl' - ui = $address_form - use_same_address = $use_same_address - type = "invoice" - form_has_continue_button = $form_has_continue_button - } -
      - {else} -
      - {include file = 'checkout/_partials/address-selector-block.tpl' - addresses = $customer.addresses - name = "id_address_invoice" - selected = $id_address_invoice - type = "invoice" - interactive = !$show_delivery_address_form and !$show_invoice_address_form - } -
      - - {if isset($invoice_address_error)} -

      {$invoice_address_error.exception}

      - {else} - - {/if} - -

      - {l s='add new address' d='Shop.Theme.Actions'} -

      - {/if} - - {/if} - - {if !$form_has_continue_button} -
      - - -
      - {/if} - -
      -
      -{/block} diff --git a/themes/classic/templates/checkout/_partials/steps/checkout-step.tpl b/themes/classic/templates/checkout/_partials/steps/checkout-step.tpl deleted file mode 100644 index 47773c82..00000000 --- a/themes/classic/templates/checkout/_partials/steps/checkout-step.tpl +++ /dev/null @@ -1,46 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='step'} -
      -

      - - {$position} - {$title} - mode_edit {l s='Edit' d='Shop.Theme.Actions'} -

      - -
      - {block name='step_content'}DUMMY STEP CONTENT{/block} -
      -
      -{/block} diff --git a/themes/classic/templates/checkout/_partials/steps/payment.tpl b/themes/classic/templates/checkout/_partials/steps/payment.tpl deleted file mode 100644 index 2f14dfda..00000000 --- a/themes/classic/templates/checkout/_partials/steps/payment.tpl +++ /dev/null @@ -1,167 +0,0 @@ -{extends file='checkout/_partials/steps/checkout-step.tpl'} - -{block name='step_content'} - - {hook h='displayPaymentTop'} - - {* used by javascript to correctly handle cart updates when we are on payment step (eg vouchers added) *} - - - {if !empty($display_transaction_updated_info)} -

      - {l s='Transaction amount has been correctly updated' d='Shop.Theme.Checkout'} -

      - {/if} - - {if $is_free} -

      {l s='No payment needed for this order' d='Shop.Theme.Checkout'}

      - {/if} -
      - {foreach from=$payment_options item="module_options"} - {foreach from=$module_options item="option"} -
      -
      - {* This is the way an option should be selected when Javascript is enabled *} - - - - - {* This is the way an option should be selected when Javascript is disabled *} -
      - {if $option.id === $selected_payment_option} - {l s='Selected' d='Shop.Theme.Checkout'} - {else} - - {/if} -
      - - - -
      -
      - - {if $option.additionalInformation} -
      - {$option.additionalInformation nofilter} -
      - {/if} - -
      - {if $option.form} - {$option.form nofilter} - {else} -
      - {foreach from=$option.inputs item=input} - - {/foreach} - -
      - {/if} -
      - {/foreach} - {foreachelse} -

      {l s='Unfortunately, there are no payment method available.' d='Shop.Theme.Checkout'}

      - {/foreach} -
      - - {if $conditions_to_approve|count} -

      - {* At the moment, we're not showing the checkboxes when JS is disabled - because it makes ensuring they were checked very tricky and overcomplicates - the template. Might change later. - *} - {l s='By confirming the order, you certify that you have read and agree with all of the conditions below:' d='Shop.Theme.Checkout'} -

      - -
      -
        - {foreach from=$conditions_to_approve item="condition" key="condition_name"} -
      • -
        - - - - -
        -
        - -
        -
      • - {/foreach} -
      -
      - {/if} - - {if $show_final_summary} - {include file='checkout/_partials/order-final-summary.tpl'} - {/if} - -
      -
      - - {if $show_final_summary} - - {/if} -
      -
      - {if $selected_payment_option and $all_conditions_approved} - - {/if} -
      -
      - - {hook h='displayPaymentByBinaries'} - - -{/block} diff --git a/themes/classic/templates/checkout/_partials/steps/personal-information.tpl b/themes/classic/templates/checkout/_partials/steps/personal-information.tpl deleted file mode 100644 index 13b6b101..00000000 --- a/themes/classic/templates/checkout/_partials/steps/personal-information.tpl +++ /dev/null @@ -1,98 +0,0 @@ -{extends file='checkout/_partials/steps/checkout-step.tpl'} - -{block name='step_content'} - {hook h='displayPersonalInformationTop' customer=$customer} - - {if $customer.is_logged && !$customer.is_guest} - -

      - {* [1][/1] is for a HTML tag. *} - {l s='Connected as [1]%firstname% %lastname%[/1].' - d='Shop.Theme.Customeraccount' - sprintf=[ - '[1]' => "", - '[/1]' => "", - '%firstname%' => $customer.firstname, - '%lastname%' => $customer.lastname - ] - } -

      -

      - {* [1][/1] is for a HTML tag. *} - {l - s='Not you? [1]Log out[/1]' - d='Shop.Theme.Customeraccount' - sprintf=[ - '[1]' => "", - '[/1]' => "" - ] - } -

      - {if !isset($empty_cart_on_logout) || $empty_cart_on_logout} -

      {l s='If you sign out now, your cart will be emptied.' d='Shop.Theme.Checkout'}

      - {/if} - -
      -
      - -
      - -
      - - {else} - - -
      - - -
      - - - {/if} -{/block} diff --git a/themes/classic/templates/checkout/_partials/steps/shipping.tpl b/themes/classic/templates/checkout/_partials/steps/shipping.tpl deleted file mode 100644 index d6b5182c..00000000 --- a/themes/classic/templates/checkout/_partials/steps/shipping.tpl +++ /dev/null @@ -1,124 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='checkout/_partials/steps/checkout-step.tpl'} - -{block name='step_content'} -
      - {$hookDisplayBeforeCarrier nofilter} -
      - -
      - {if $delivery_options|count} -
      -
      - {block name='delivery_options'} -
      - {foreach from=$delivery_options item=carrier key=carrier_id} -
      -
      - - - - -
      - -
      - -
      - {/foreach} -
      - {/block} -
      -
      - - -
      - - {if $recyclablePackAllowed} - - - - - - {/if} - - {if $gift.allowed} - - - - - - -
      - - -
      - {/if} - -
      -
      - -
      - {else} -

      {l s='Unfortunately, there are no carriers available for your delivery address.' d='Shop.Theme.Checkout'}

      - {/if} -
      - -
      - {$hookDisplayAfterCarrier nofilter} -
      - -
      -{/block} diff --git a/themes/classic/templates/checkout/_partials/steps/unreachable.tpl b/themes/classic/templates/checkout/_partials/steps/unreachable.tpl deleted file mode 100644 index 158efa3e..00000000 --- a/themes/classic/templates/checkout/_partials/steps/unreachable.tpl +++ /dev/null @@ -1,31 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='step'} -
      -

      - {$position} {$title} -

      -
      -{/block} diff --git a/themes/classic/templates/checkout/cart-empty.tpl b/themes/classic/templates/checkout/cart-empty.tpl deleted file mode 100644 index 70d0d7d0..00000000 --- a/themes/classic/templates/checkout/cart-empty.tpl +++ /dev/null @@ -1,45 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='checkout/cart.tpl'} - -{block name='content' append} - {hook h='displayCrossSellingShoppingCart'} -{/block} - -{block name='continue_shopping' append} - - chevron_left{l s='Continue shopping' d='Shop.Theme.Actions'} - -{/block} - -{block name='cart_actions'} -
      - -
      -{/block} - -{block name='continue_shopping'}{/block} -{block name='cart_voucher'}{/block} -{block name='display_reassurance'}{/block} diff --git a/themes/classic/templates/checkout/cart.tpl b/themes/classic/templates/checkout/cart.tpl deleted file mode 100644 index fb0a4d5c..00000000 --- a/themes/classic/templates/checkout/cart.tpl +++ /dev/null @@ -1,87 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file=$layout} - -{block name='content'} - -
      -
      - - -
      - - -
      -
      -

      {l s='Shopping Cart' d='Shop.Theme.Checkout'}

      -
      -
      - {block name='cart_overview'} - {include file='checkout/_partials/cart-detailed.tpl' cart=$cart} - {/block} -
      - - {block name='continue_shopping'} - - chevron_left{l s='Continue shopping' d='Shop.Theme.Actions'} - - {/block} - - - {block name='hook_shopping_cart_footer'} - {hook h='displayShoppingCartFooter'} - {/block} -
      - - -
      - - {block name='cart_summary'} -
      - - {block name='hook_shopping_cart'} - {hook h='displayShoppingCart'} - {/block} - - {block name='cart_totals'} - {include file='checkout/_partials/cart-detailed-totals.tpl' cart=$cart} - {/block} - - {block name='cart_actions'} - {include file='checkout/_partials/cart-detailed-actions.tpl' cart=$cart} - {/block} - -
      - {/block} - - {block name='hook_reassurance'} - {hook h='displayReassurance'} - {/block} - -
      - -
      -
      -{/block} diff --git a/themes/classic/templates/checkout/checkout-process.tpl b/themes/classic/templates/checkout/checkout-process.tpl deleted file mode 100644 index 98065b20..00000000 --- a/themes/classic/templates/checkout/checkout-process.tpl +++ /dev/null @@ -1,30 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{foreach from=$steps item="step" key="index"} - {render identifier = $step.identifier - position = ($index + 1) - ui = $step.ui - } -{/foreach} diff --git a/themes/classic/templates/checkout/checkout.tpl b/themes/classic/templates/checkout/checkout.tpl deleted file mode 100644 index ed0134ab..00000000 --- a/themes/classic/templates/checkout/checkout.tpl +++ /dev/null @@ -1,94 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - - - - - {block name='head'} - {include file='_partials/head.tpl'} - {/block} - - - - - {block name='hook_after_body_opening_tag'} - {hook h='displayAfterBodyOpeningTag'} - {/block} - - - - {block name='notifications'} - {include file='_partials/notifications.tpl'} - {/block} - -
      - {hook h="displayWrapperTop"} -
      - - {block name='content'} -
      -
      -
      - {block name='cart_summary'} - {render file='checkout/checkout-process.tpl' ui=$checkout_process} - {/block} -
      - -
      - - {block name='cart_summary'} - {include file='checkout/_partials/cart-summary.tpl' cart = $cart} - {/block} - - {hook h='displayReassurance'} -
      -
      -
      - {/block} -
      - {hook h="displayWrapperBottom"} -
      - -
      - {block name='footer'} - {include file='checkout/_partials/footer.tpl'} - {/block} -
      - - {block name='javascript_bottom'} - {include file="_partials/javascript.tpl" javascript=$javascript.bottom} - {/block} - - {block name='hook_before_body_closing_tag'} - {hook h='displayBeforeBodyClosingTag'} - {/block} - - - - diff --git a/themes/classic/templates/checkout/order-confirmation.tpl b/themes/classic/templates/checkout/order-confirmation.tpl deleted file mode 100644 index d73a9707..00000000 --- a/themes/classic/templates/checkout/order-confirmation.tpl +++ /dev/null @@ -1,110 +0,0 @@ -{extends file='page.tpl'} - -{block name='page_content_container' prepend} -
      -
      -
      -
      - - {block name='order_confirmation_header'} -

      - {l s='Your order is confirmed' d='Shop.Theme.Checkout'} -

      - {/block} - -

      - {l s='An email has been sent to your mail address %email%.' d='Shop.Theme.Checkout' sprintf=['%email%' => $customer.email]} - {if $order.details.invoice_url} - {* [1][/1] is for a HTML tag. *} - {l - s='You can also [1]download your invoice[/1]' - d='Shop.Theme.Checkout' - sprintf=[ - '[1]' => "", - '[/1]' => "" - ] - } - {/if} -

      - - {block name='hook_order_confirmation'} - {$HOOK_ORDER_CONFIRMATION nofilter} - {/block} - -
      -
      -
      -
      -{/block} - -{block name='page_content_container'} -
      -
      -
      - - {block name='order_confirmation_table'} - {include - file='checkout/_partials/order-confirmation-table.tpl' - products=$order.products - subtotals=$order.subtotals - totals=$order.totals - labels=$order.labels - add_product_link=false - } - {/block} - - {block name='order_details'} -
      -

      {l s='Order details' d='Shop.Theme.Checkout'}:

      -
        -
      • {l s='Order reference: %reference%' d='Shop.Theme.Checkout' sprintf=['%reference%' => $order.details.reference]}
      • -
      • {l s='Payment method: %method%' d='Shop.Theme.Checkout' sprintf=['%method%' => $order.details.payment]}
      • - {if !$order.details.is_virtual} -
      • - {l s='Shipping method: %method%' d='Shop.Theme.Checkout' sprintf=['%method%' => $order.carrier.name]}
        - {$order.carrier.delay} -
      • - {/if} -
      -
      - {/block} - -
      -
      -
      - - {block name='hook_payment_return'} - {if ! empty($HOOK_PAYMENT_RETURN)} -
      -
      -
      -
      - {$HOOK_PAYMENT_RETURN nofilter} -
      -
      -
      -
      - {/if} - {/block} - - {block name='customer_registration_form'} - {if $customer.is_guest} -
      -
      -

      {l s='Save time on your next order, sign up now' d='Shop.Theme.Checkout'}

      - {render file='customer/_partials/customer-form.tpl' ui=$register_form} -
      -
      - {/if} - {/block} - - {block name='hook_order_confirmation_1'} - {hook h='displayOrderConfirmation1'} - {/block} - - {block name='hook_order_confirmation_2'} - - {/block} -{/block} diff --git a/themes/classic/templates/cms/_partials/sitemap-nested-list.tpl b/themes/classic/templates/cms/_partials/sitemap-nested-list.tpl deleted file mode 100644 index cf6044f3..00000000 --- a/themes/classic/templates/cms/_partials/sitemap-nested-list.tpl +++ /dev/null @@ -1,38 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='sitemap_item'} - - {foreach $links as $link} -
    • - - {$link.label} - - {if isset($link.children) && $link.children|@count > 0} - {include file='cms/_partials/sitemap-nested-list.tpl' links=$link.children is_nested=true} - {/if} -
    • - {/foreach} - -{/block} diff --git a/themes/classic/templates/cms/category.tpl b/themes/classic/templates/cms/category.tpl deleted file mode 100644 index d62e1b2b..00000000 --- a/themes/classic/templates/cms/category.tpl +++ /dev/null @@ -1,53 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='page.tpl'} - -{block name='page_title'} - {$cms_category.name} -{/block} - -{block name='page_content'} - {block name='cms_sub_categories'} - {if $sub_categories} -

      {l s='List of sub categories in %name%:' d='Shop.Theme.Global' sprintf=['%name%' => $cms_category.name]}

      - - {/if} - {/block} - - {block name='cms_sub_pages'} - {if $cms_pages} -

      {l s='List of pages in %category_name%:' d='Shop.Theme.Global' sprintf=['%category_name%' => $cms_category.name]}

      - - {/if} - {/block} -{/block} diff --git a/themes/classic/templates/cms/page.tpl b/themes/classic/templates/cms/page.tpl deleted file mode 100644 index 4839ab7a..00000000 --- a/themes/classic/templates/cms/page.tpl +++ /dev/null @@ -1,47 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='page.tpl'} - -{block name='page_title'} - {$cms.meta_title} -{/block} - -{block name='page_content_container'} -
      - - {block name='cms_content'} - {$cms.content nofilter} - {/block} - - {block name='hook_cms_dispute_information'} - {hook h='displayCMSDisputeInformation'} - {/block} - - {block name='hook_cms_print_button'} - {hook h='displayCMSPrintButton'} - {/block} - -
      -{/block} diff --git a/themes/classic/templates/cms/sitemap.tpl b/themes/classic/templates/cms/sitemap.tpl deleted file mode 100644 index 1a924724..00000000 --- a/themes/classic/templates/cms/sitemap.tpl +++ /dev/null @@ -1,52 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='page.tpl'} - -{block name='page_title'} - {l s='Sitemap' d='Shop.Theme.Global'} -{/block} - -{block name='page_content_container'} -
      -
      -
      -

      {$our_offers}

      - {include file='cms/_partials/sitemap-nested-list.tpl' links=$links.offers} -
      -
      -

      {$categories}

      - {include file='cms/_partials/sitemap-nested-list.tpl' links=$links.categories} -
      -
      -

      {$your_account}

      - {include file='cms/_partials/sitemap-nested-list.tpl' links=$links.user_account} -
      -
      -

      {$pages}

      - {include file='cms/_partials/sitemap-nested-list.tpl' links=$links.pages} -
      -
      -
      -{/block} diff --git a/themes/classic/templates/cms/stores.tpl b/themes/classic/templates/cms/stores.tpl deleted file mode 100644 index bb3c9923..00000000 --- a/themes/classic/templates/cms/stores.tpl +++ /dev/null @@ -1,88 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='page.tpl'} - -{block name='page_title'} - {l s='Our stores' d='Shop.Theme.Global'} -{/block} - -{block name='page_content_container'} -
      - - {foreach $stores as $store} -
      -
      -
      - {$store.image.legend} -
      -
      -

      {$store.name}

      -
      {$store.address.formatted nofilter}
      - {if $store.note || $store.phone || $store.fax || $store.email} - - {/if} -
      -
      - - {foreach $store.business_hours as $day} - - - - - {/foreach} -
      {$day.day|truncate:4:'.'} -
        - {foreach $day.hours as $h} -
      • {$h}
      • - {/foreach} -
      -
      -
      -
      -
      - -
      -
      - {/foreach} - -
      -{/block} diff --git a/themes/classic/templates/contact.tpl b/themes/classic/templates/contact.tpl deleted file mode 100644 index fc228c09..00000000 --- a/themes/classic/templates/contact.tpl +++ /dev/null @@ -1,37 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='page.tpl'} - -{block name='page_header_container'}{/block} - -{block name='left_column'} -
      - {widget name="ps_contactinfo" hook='displayLeftColumn'} -
      -{/block} - -{block name='page_content'} - {widget name="contactform"} -{/block} diff --git a/themes/classic/templates/customer/_partials/address-form.tpl b/themes/classic/templates/customer/_partials/address-form.tpl deleted file mode 100644 index 3f30e0f7..00000000 --- a/themes/classic/templates/customer/_partials/address-form.tpl +++ /dev/null @@ -1,63 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name="address_form"} -
      - {include file='_partials/form-errors.tpl' errors=$errors['']} - - {block name="address_form_url"} -
      - {/block} - - {block name="address_form_fields"} -
      - {block name='form_fields'} - {foreach from=$formFields item="field"} - {block name='form_field'} - {form_field field=$field} - {/block} - {/foreach} - {/block} -
      - {/block} - - {block name="address_form_footer"} -
      - - {block name='form_buttons'} - - {/block} -
      - {/block} - -
      -
      -{/block} diff --git a/themes/classic/templates/customer/_partials/block-address.tpl b/themes/classic/templates/customer/_partials/block-address.tpl deleted file mode 100644 index 433672db..00000000 --- a/themes/classic/templates/customer/_partials/block-address.tpl +++ /dev/null @@ -1,45 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='address_block_item'} - -{/block} diff --git a/themes/classic/templates/customer/_partials/customer-form.tpl b/themes/classic/templates/customer/_partials/customer-form.tpl deleted file mode 100644 index dba04d00..00000000 --- a/themes/classic/templates/customer/_partials/customer-form.tpl +++ /dev/null @@ -1,54 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='customer_form'} - {block name='customer_form_errors'} - {include file='_partials/form-errors.tpl' errors=$errors['']} - {/block} - -
      -
      - {block "form_fields"} - {foreach from=$formFields item="field"} - {block "form_field"} - {form_field field=$field} - {/block} - {/foreach} - {$hook_create_account_form nofilter} - {/block} -
      - - {block name='customer_form_footer'} -
      - - {block "form_buttons"} - - {/block} -
      - {/block} - -
      -{/block} diff --git a/themes/classic/templates/customer/_partials/login-form.tpl b/themes/classic/templates/customer/_partials/login-form.tpl deleted file mode 100644 index 932480e4..00000000 --- a/themes/classic/templates/customer/_partials/login-form.tpl +++ /dev/null @@ -1,60 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='login_form'} - - {block name='login_form_errors'} - {include file='_partials/form-errors.tpl' errors=$errors['']} - {/block} - -
      - -
      - {block name='login_form_fields'} - {foreach from=$formFields item="field"} - {block name='form_field'} - {form_field field=$field} - {/block} - {/foreach} - {/block} - -
      - - {block name='login_form_footer'} -
      - - {block name='form_buttons'} - - {/block} -
      - {/block} - -
      -{/block} diff --git a/themes/classic/templates/customer/_partials/my-account-links.tpl b/themes/classic/templates/customer/_partials/my-account-links.tpl deleted file mode 100644 index 18920171..00000000 --- a/themes/classic/templates/customer/_partials/my-account-links.tpl +++ /dev/null @@ -1,34 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='my_account_links'} - - -{/block} diff --git a/themes/classic/templates/customer/_partials/order-detail-no-return.tpl b/themes/classic/templates/customer/_partials/order-detail-no-return.tpl deleted file mode 100644 index 005af9b4..00000000 --- a/themes/classic/templates/customer/_partials/order-detail-no-return.tpl +++ /dev/null @@ -1,175 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='order_products_table'} -
      - - - - - - - - - - {foreach from=$order.products item=product} - - - - - - - {/foreach} - - {foreach $order.subtotals as $line} - {if $line.value} - - - - - {/if} - {/foreach} - - - - - -
      {l s='Product' d='Shop.Theme.Catalog'}{l s='Quantity' d='Shop.Theme.Catalog'}{l s='Unit price' d='Shop.Theme.Catalog'}{l s='Total price' d='Shop.Theme.Catalog'}
      - - - {$product.name} - -
      - {if $product.reference} - {l s='Reference' d='Shop.Theme.Catalog'}: {$product.reference}
      - {/if} - {if $product.customizations} - {foreach from=$product.customizations item="customization"} - -
      - -
      - {/foreach} - {/if} -
      - {if $product.customizations} - {foreach $product.customizations as $customization} - {$customization.quantity} - {/foreach} - {else} - {$product.quantity} - {/if} - {$product.price}{$product.total}
      {$line.label}{$line.value}
      {$order.totals.total.label}{$order.totals.total.value}
      -
      - -
      - {foreach from=$order.products item=product} -
      -
      -
      -
      {$product.name}
      - {if $product.reference} -
      {l s='Reference' d='Shop.Theme.Catalog'}: {$product.reference}
      - {/if} - {if $product.customizations} - {foreach $product.customizations as $customization} - -
      -
      - {/foreach} - {/if} -
      -
      -
      -
      - {$product.price} -
      -
      - {if $product.customizations} - {foreach $product.customizations as $customization} - {$customization.quantity} - {/foreach} - {else} - {$product.quantity} - {/if} -
      -
      - {$product.total} -
      -
      -
      -
      -
      - {/foreach} -
      -
      - {foreach $order.subtotals as $line} - {if $line.value} -
      -
      {$line.label}
      -
      {$line.value}
      -
      - {/if} - {/foreach} -
      -
      {$order.totals.total.label}
      -
      {$order.totals.total.value}
      -
      -
      -{/block} diff --git a/themes/classic/templates/customer/_partials/order-detail-return.tpl b/themes/classic/templates/customer/_partials/order-detail-return.tpl deleted file mode 100644 index 1156ec37..00000000 --- a/themes/classic/templates/customer/_partials/order-detail-return.tpl +++ /dev/null @@ -1,253 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='order_products_table'} -
      - -
      - - - - - - - - - - - - {foreach from=$order.products item=product name=products} - - - - - - - - - {/foreach} - - {foreach $order.subtotals as $line} - {if $line.value} - - - - - {/if} - {/foreach} - - - - - -
      {l s='Product' d='Shop.Theme.Catalog'}{l s='Quantity' d='Shop.Theme.Catalog'}{l s='Returned' d='Shop.Theme.Customeraccount'}{l s='Unit price' d='Shop.Theme.Catalog'}{l s='Total price' d='Shop.Theme.Catalog'}
      - {if !$product.customizations} - - - - {else} - {foreach $product.customizations as $customization} - - - - {/foreach} - {/if} - - {$product.name}
      - {if $product.reference} - {l s='Reference' d='Shop.Theme.Catalog'}: {$product.reference}
      - {/if} - {if $product.customizations} - {foreach from=$product.customizations item="customization"} - -
      - -
      - {/foreach} - {/if} -
      - {if !$product.customizations} -
      - {$product.quantity} -
      - {if $product.quantity > $product.qty_returned} -
      - -
      - {/if} - {else} - {foreach $product.customizations as $customization} -
      - {$customization.quantity} -
      -
      - -
      - {/foreach} -
      - {/if} -
      {$product.qty_returned}{$product.price}{$product.total}
      {$line.label}{$line.value}
      {$order.totals.total.label}{$order.totals.total.value}
      -
      - -
      - {foreach from=$order.products item=product} -
      -
      -
      - {if !$product.customizations} - - {else} - {foreach $product.customizations as $customization} - - {/foreach} - {/if} -
      -
      -
      -
      -
      {$product.name}
      - {if $product.reference} -
      {l s='Reference' d='Shop.Theme.Catalog'}: {$product.reference}
      - {/if} - {if $product.customizations} - {foreach $product.customizations as $customization} - -
      -
      - {/foreach} - {/if} -
      -
      -
      -
      - {$product.price} -
      -
      - {if $product.customizations} - {foreach $product.customizations as $customization} -
      {l s='Quantity' d='Shop.Theme.Catalog'}: {$customization.quantity}
      -
      - {/foreach} - {else} -
      {l s='Quantity' d='Shop.Theme.Catalog'}: {$product.quantity}
      - {if $product.quantity > $product.qty_returned} -
      - {/if} - {/if} - {if $product.qty_returned > 0} -
      {l s='Returned' d='Shop.Theme.Customeraccount'}: {$product.qty_returned}
      - {/if} -
      -
      - {$product.total} -
      -
      -
      -
      -
      -
      -
      - {/foreach} -
      -
      - {foreach $order.subtotals as $line} - {if $line.value} -
      -
      {$line.label}
      -
      {$line.value}
      -
      - {/if} - {/foreach} -
      -
      {$order.totals.total.label}
      -
      {$order.totals.total.value}
      -
      -
      - -
      -
      -

      {l s='Merchandise return' d='Shop.Theme.Customeraccount'}

      -

      {l s='If you wish to return one or more products, please mark the corresponding boxes and provide an explanation for the return. When complete, click the button below.' d='Shop.Theme.Customeraccount'}

      -
      -
      -
      - -
      -
      -
      - - -
      -
      - -
      -{/block} diff --git a/themes/classic/templates/customer/_partials/order-messages.tpl b/themes/classic/templates/customer/_partials/order-messages.tpl deleted file mode 100644 index daf71a57..00000000 --- a/themes/classic/templates/customer/_partials/order-messages.tpl +++ /dev/null @@ -1,85 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{block name='order_messages_table'} - {if $order.messages} -
      -

      {l s='Messages' d='Shop.Theme.Customeraccount'}

      - {foreach from=$order.messages item=message} -
      -
      - {$message.name}
      - {$message.message_date} -
      -
      - {$message.message nofilter} -
      -
      - {/foreach} -
      - {/if} -{/block} - -{block name='order_message_form'} -
      -
      - -
      -

      {l s='Add a message' d='Shop.Theme.Customeraccount'}

      -

      {l s='If you would like to add a comment about your order, please write it in the field below.' d='Shop.Theme.Customeraccount'}

      -
      - -
      - -
      - -
      - -
      -
      - -
      - -
      - -
      -
      - -
      - -
      - - -
      - -
      -
      -{/block} diff --git a/themes/classic/templates/customer/address.tpl b/themes/classic/templates/customer/address.tpl deleted file mode 100644 index c97eb94e..00000000 --- a/themes/classic/templates/customer/address.tpl +++ /dev/null @@ -1,39 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='customer/page.tpl'} - -{block name='page_title'} - {if $editing} - {l s='Update your address' d='Shop.Theme.Customeraccount'} - {else} - {l s='New address' d='Shop.Theme.Customeraccount'} - {/if} -{/block} - -{block name='page_content'} -
      - {render template="customer/_partials/address-form.tpl" ui=$address_form} -
      -{/block} diff --git a/themes/classic/templates/customer/addresses.tpl b/themes/classic/templates/customer/addresses.tpl deleted file mode 100644 index 8d59bc7e..00000000 --- a/themes/classic/templates/customer/addresses.tpl +++ /dev/null @@ -1,46 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='customer/page.tpl'} - -{block name='page_title'} - {l s='Your addresses' d='Shop.Theme.Customeraccount'} -{/block} - -{block name='page_content'} - {foreach $customer.addresses as $address} -
      - {block name='customer_address'} - {include file='customer/_partials/block-address.tpl' address=$address} - {/block} -
      - {/foreach} -
      - -{/block} diff --git a/themes/classic/templates/customer/authentication.tpl b/themes/classic/templates/customer/authentication.tpl deleted file mode 100644 index 3d940b92..00000000 --- a/themes/classic/templates/customer/authentication.tpl +++ /dev/null @@ -1,46 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='page.tpl'} - -{block name='page_title'} - {l s='Log in to your account' d='Shop.Theme.Customeraccount'} -{/block} - -{block name='page_content'} - {block name='login_form_container'} - -
      - {block name='display_after_login_form'} - {hook h='displayCustomerLoginFormAfter'} - {/block} - - {/block} -{/block} diff --git a/themes/classic/templates/customer/discount.tpl b/themes/classic/templates/customer/discount.tpl deleted file mode 100644 index c434a52f..00000000 --- a/themes/classic/templates/customer/discount.tpl +++ /dev/null @@ -1,96 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='customer/page.tpl'} - -{block name='page_title'} - {l s='Your vouchers' d='Shop.Theme.Customeraccount'} -{/block} - -{block name='page_content'} - {if $cart_rules} - - - - - - - - - - - - - - {foreach from=$cart_rules item=cart_rule} - - - - - - - - - - {/foreach} - -
      {l s='Code' d='Shop.Theme.Checkout'}{l s='Description' d='Shop.Theme.Checkout'}{l s='Quantity' d='Shop.Theme.Checkout'}{l s='Value' d='Shop.Theme.Checkout'}{l s='Minimum' d='Shop.Theme.Checkout'}{l s='Cumulative' d='Shop.Theme.Checkout'}{l s='Expiration date' d='Shop.Theme.Checkout'}
      {$cart_rule.code}{$cart_rule.name}{$cart_rule.quantity_for_user}{$cart_rule.value}{$cart_rule.voucher_minimal}{$cart_rule.voucher_cumulable}{$cart_rule.voucher_date}
      -
      - {foreach from=$cart_rules item=cart_rule} -
      -
        -
      • - {l s='Code' d='Shop.Theme.Checkout'} - {$cart_rule.code} -
      • -
      • - {l s='Description' d='Shop.Theme.Checkout'} - {$cart_rule.name} -
      • -
      • - {l s='Quantity' d='Shop.Theme.Checkout'} - {$cart_rule.quantity_for_user} -
      • -
      • - {l s='Value' d='Shop.Theme.Checkout'} - {$cart_rule.value} -
      • -
      • - {l s='Minimum' d='Shop.Theme.Checkout'} - {$cart_rule.voucher_minimal} -
      • -
      • - {l s='Cumulative' d='Shop.Theme.Checkout'} - {$cart_rule.voucher_cumulable} -
      • -
      • - {l s='Expiration date' d='Shop.Theme.Checkout'} - {$cart_rule.voucher_date} -
      • -
      -
      - {/foreach} -
      - {/if} -{/block} diff --git a/themes/classic/templates/customer/guest-login.tpl b/themes/classic/templates/customer/guest-login.tpl deleted file mode 100644 index 356e81b7..00000000 --- a/themes/classic/templates/customer/guest-login.tpl +++ /dev/null @@ -1,79 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='page.tpl'} - -{block name='page_title'} - {l s='Guest Order Tracking' d='Shop.Theme.Customeraccount'} -{/block} - -{block name='page_content'} -
      -
      -

      {l s='To track your order, please enter the following information:' d='Shop.Theme.Customeraccount'}

      -
      - -
      - -
      - -
      - -
      - {l s='For example: QIIXJXNUI or QIIXJXNUI#1' d='Shop.Theme.Customeraccount'} -
      -
      -
      - -
      - -
      - -
      -
      - -
      - -
      - -
      -
      -{/block} diff --git a/themes/classic/templates/customer/guest-tracking.tpl b/themes/classic/templates/customer/guest-tracking.tpl deleted file mode 100644 index 52a149bd..00000000 --- a/themes/classic/templates/customer/guest-tracking.tpl +++ /dev/null @@ -1,70 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='customer/order-detail.tpl'} - -{block name='page_title'} - {l s='Guest Tracking' d='Shop.Theme.Customeraccount'} -{/block} - -{block name='order_detail'} - {include file='customer/_partials/order-detail-no-return.tpl'} -{/block} - -{block name='order_messages'} -{/block} - -{block name='page_content' append} - {block name='guest_to_customer'} -
      -
      -

      {l s='Transform your guest account into a customer account and enjoy:' d='Shop.Theme.Customeraccount'}

      -
        -
      • -{l s='Personalized and secure access' d='Shop.Theme.Customeraccount'}
      • -
      • -{l s='Fast and easy checkout' d='Shop.Theme.Customeraccount'}
      • -
      • -{l s='Easier merchandise return' d='Shop.Theme.Customeraccount'}
      • -
      -
      - -
      - - - -
      - -
      - - - - - - -
      - -
      - {/block} -{/block} diff --git a/themes/classic/templates/customer/history.tpl b/themes/classic/templates/customer/history.tpl deleted file mode 100644 index 422757f9..00000000 --- a/themes/classic/templates/customer/history.tpl +++ /dev/null @@ -1,119 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='customer/page.tpl'} - -{block name='page_title'} - {l s='Order history' d='Shop.Theme.Customeraccount'} -{/block} - -{block name='page_content'} -
      {l s='Here are the orders you\'ve placed since your account was created.' d='Shop.Theme.Customeraccount'}
      - - {if $orders} - - - - - - - - - - - - - - {foreach from=$orders item=order} - - - - - - - - - - {/foreach} - -
      {l s='Order reference' d='Shop.Theme.Checkout'}{l s='Date' d='Shop.Theme.Checkout'}{l s='Total price' d='Shop.Theme.Checkout'}{l s='Payment' d='Shop.Theme.Checkout'}{l s='Status' d='Shop.Theme.Checkout'}{l s='Invoice' d='Shop.Theme.Checkout'} 
      {$order.details.reference}{$order.details.order_date}{$order.totals.total.value}{$order.details.payment} - - {$order.history.current.ostate_name} - - - {if $order.details.invoice_url} - - {else} - - - {/if} - - - {l s='Details' d='Shop.Theme.Customeraccount'} - - {if $order.details.reorder_url} - {l s='Reorder' d='Shop.Theme.Actions'} - {/if} -
      - -
      - {foreach from=$orders item=order} -
      -
      -
      -

      {$order.details.reference}

      -
      {$order.details.order_date}
      -
      {$order.totals.total.value}
      -
      - - {$order.history.current.ostate_name} - -
      -
      -
      - - {if $order.details.reorder_url} - - {/if} -
      -
      -
      - {/foreach} -
      - - {/if} -{/block} diff --git a/themes/classic/templates/customer/identity.tpl b/themes/classic/templates/customer/identity.tpl deleted file mode 100644 index 646668bb..00000000 --- a/themes/classic/templates/customer/identity.tpl +++ /dev/null @@ -1,33 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends 'customer/page.tpl'} - -{block name='page_title'} - {l s='Your personal information' d='Shop.Theme.Customeraccount'} -{/block} - -{block name='page_content'} - {render file='customer/_partials/customer-form.tpl' ui=$customer_form} -{/block} diff --git a/themes/classic/templates/customer/my-account.tpl b/themes/classic/templates/customer/my-account.tpl deleted file mode 100644 index 7ef5e760..00000000 --- a/themes/classic/templates/customer/my-account.tpl +++ /dev/null @@ -1,111 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='customer/page.tpl'} - -{block name='page_title'} - {l s='Your account' d='Shop.Theme.Customeraccount'} -{/block} - -{block name='page_content'} -
      - -
      -{/block} - - -{block name='page_footer'} - {block name='my_account_links'} - - {/block} -{/block} diff --git a/themes/classic/templates/customer/order-detail.tpl b/themes/classic/templates/customer/order-detail.tpl deleted file mode 100644 index 44b9afc2..00000000 --- a/themes/classic/templates/customer/order-detail.tpl +++ /dev/null @@ -1,213 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='customer/page.tpl'} - -{block name='page_title'} - {l s='Order details' d='Shop.Theme.Customeraccount'} -{/block} - -{block name='page_content'} - {block name='order_infos'} -
      -
      -
      -
      - - {l - s='Order Reference %reference% - placed on %date%' - d='Shop.Theme.Customeraccount' - sprintf=['%reference%' => $order.details.reference, '%date%' => $order.details.order_date] - } - -
      - {if $order.details.reorder_url} - - {/if} -
      -
      -
      - -
      -
        -
      • {l s='Carrier' d='Shop.Theme.Checkout'} {$order.carrier.name}
      • -
      • {l s='Payment method' d='Shop.Theme.Checkout'} {$order.details.payment}
      • - - {if $order.details.invoice_url} -
      • - - {l s='Download your invoice as a PDF file.' d='Shop.Theme.Customeraccount'} - -
      • - {/if} - - {if $order.details.recyclable} -
      • - {l s='You have given permission to receive your order in recycled packaging.' d='Shop.Theme.Customeraccount'} -
      • - {/if} - - {if $order.details.gift_message} -
      • {l s='You have requested gift wrapping for this order.' d='Shop.Theme.Customeraccount'}
      • -
      • {l s='Message' d='Shop.Theme.Customeraccount'} {$order.details.gift_message nofilter}
      • - {/if} -
      -
      -
      - {/block} - - {block name='order_history'} -
      -

      {l s='Follow your order\'s status step-by-step' d='Shop.Theme.Customeraccount'}

      - - - - - - - - - {foreach from=$order.history item=state} - - - - - {/foreach} - -
      {l s='Date' d='Shop.Theme.Global'}{l s='Status' d='Shop.Theme.Global'}
      {$state.history_date} - - {$state.ostate_name} - -
      -
      - {foreach from=$order.history item=state} -
      -
      {$state.history_date}
      -
      - - {$state.ostate_name} - -
      -
      - {/foreach} -
      -
      - {/block} - - {if $order.follow_up} -
      -

      {l s='Click the following link to track the delivery of your order' d='Shop.Theme.Customeraccount'}

      - {$order.follow_up} -
      - {/if} - - {block name='addresses'} -
      - {if $order.addresses.delivery} -
      -
      -

      {l s='Delivery address %alias%' d='Shop.Theme.Checkout' sprintf=['%alias%' => $order.addresses.delivery.alias]}

      -
      {$order.addresses.delivery.formatted nofilter}
      -
      -
      - {/if} - -
      -
      -

      {l s='Invoice address %alias%' d='Shop.Theme.Checkout' sprintf=['%alias%' => $order.addresses.invoice.alias]}

      -
      {$order.addresses.invoice.formatted nofilter}
      -
      -
      -
      -
      - {/block} - - {$HOOK_DISPLAYORDERDETAIL nofilter} - - {block name='order_detail'} - {if $order.details.is_returnable} - {include file='customer/_partials/order-detail-return.tpl'} - {else} - {include file='customer/_partials/order-detail-no-return.tpl'} - {/if} - {/block} - - {block name='order_carriers'} - {if $order.shipping} -
      - - - - - - - - - - - - {foreach from=$order.shipping item=line} - - - - - - - - {/foreach} - -
      {l s='Date' d='Shop.Theme.Global'}{l s='Carrier' d='Shop.Theme.Checkout'}{l s='Weight' d='Shop.Theme.Checkout'}{l s='Shipping cost' d='Shop.Theme.Checkout'}{l s='Tracking number' d='Shop.Theme.Checkout'}
      {$line.shipping_date}{$line.carrier_name}{$line.shipping_weight}{$line.shipping_cost}{$line.tracking nofilter}
      -
      - {foreach from=$order.shipping item=line} -
      -
        -
      • - {l s='Date' d='Shop.Theme.Global'} {$line.shipping_date} -
      • -
      • - {l s='Carrier' d='Shop.Theme.Checkout'} {$line.carrier_name} -
      • -
      • - {l s='Weight' d='Shop.Theme.Checkout'} {$line.shipping_weight} -
      • -
      • - {l s='Shipping cost' d='Shop.Theme.Checkout'} {$line.shipping_cost} -
      • -
      • - {l s='Tracking number' d='Shop.Theme.Checkout'} {$line.tracking nofilter} -
      • -
      -
      - {/foreach} -
      -
      - {/if} - {/block} - - {block name='order_messages'} - {include file='customer/_partials/order-messages.tpl'} - {/block} -{/block} diff --git a/themes/classic/templates/customer/order-follow.tpl b/themes/classic/templates/customer/order-follow.tpl deleted file mode 100644 index 9006b891..00000000 --- a/themes/classic/templates/customer/order-follow.tpl +++ /dev/null @@ -1,98 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='customer/page.tpl'} - -{block name='page_title'} - {l s='Merchandise returns' d='Shop.Theme.Customeraccount'} -{/block} - -{block name='page_content'} - - {if $ordersReturn && count($ordersReturn)} - -
      {l s='Here is a list of pending merchandise returns' d='Shop.Theme.Customeraccount'}
      - - - - - - - - - - - - - {foreach from=$ordersReturn item=return} - - - - - - - - {/foreach} - -
      {l s='Order' d='Shop.Theme.Customeraccount'}{l s='Return' d='Shop.Theme.Customeraccount'}{l s='Package status' d='Shop.Theme.Customeraccount'}{l s='Date issued' d='Shop.Theme.Customeraccount'}{l s='Returns form' d='Shop.Theme.Customeraccount'}
      {$return.reference}{$return.return_number}{$return.state_name}{$return.return_date} - {if $return.print_url} - {l s='Print out' d='Shop.Theme.Actions'} - {else} - - - {/if} -
      -
      - {foreach from=$ordersReturn item=return} -
      -
        -
      • - {l s='Order' d='Shop.Theme.Customeraccount'} - {$return.reference} -
      • -
      • - {l s='Return' d='Shop.Theme.Customeraccount'} - {$return.return_number} -
      • -
      • - {l s='Package status' d='Shop.Theme.Customeraccount'} - {$return.state_name} -
      • -
      • - {l s='Date issued' d='Shop.Theme.Customeraccount'} - {$return.return_date} -
      • - {if $return.print_url} -
      • - {l s='Returns form' d='Shop.Theme.Customeraccount'} - {l s='Print out' d='Shop.Theme.Actions'} -
      • - {/if} -
      -
      - {/foreach} -
      - - {/if} - -{/block} diff --git a/themes/classic/templates/customer/order-return.tpl b/themes/classic/templates/customer/order-return.tpl deleted file mode 100644 index 6aa23651..00000000 --- a/themes/classic/templates/customer/order-return.tpl +++ /dev/null @@ -1,151 +0,0 @@ -{extends file='customer/page.tpl'} - -{block name='page_title'} -

      {l s='Return details' d='Shop.Theme.Customeraccount'}

      -{/block} - -{block name='page_content'} - {block name='order_return_infos'} -
      -
      -

      - {l - s='%number% on %date%' - d='Shop.Theme.Customeraccount' - sprintf=['%number%' => $return.return_number, '%date%' => $return.return_date]} - -

      -

      {l s='We have logged your return request.' d='Shop.Theme.Customeraccount'}

      -

      {l - s='Your package must be returned to us within %number% days of receiving your order.' - d='Shop.Theme.Customeraccount' - sprintf=['%number%' => $configuration.number_of_days_for_return]}

      -

      - {* [1][/1] is for a HTML tag. *} - {l - s='The current status of your merchandise return is: [1] %status% [/1]' - d='Shop.Theme.Customeraccount' - sprintf=[ - '[1]' => '', - '[/1]' => '', - '%status%' => $return.state_name - ] - } -

      -

      {l s='List of items to be returned:' d='Shop.Theme.Customeraccount'}

      - - - - - - - - - {foreach from=$products item=product} - - - - - {/foreach} - -
      {l s='Product' d='Shop.Theme.Catalog'}{l s='Quantity' d='Shop.Theme.Checkout'}
      - {$product.product_name} - {if $product.product_reference} -
      - {l s='Reference' d='Shop.Theme.Catalog'}: {$product.product_reference} - {/if} - {if $product.customizations} - {foreach from=$product.customizations item="customization"} - - - {/foreach} - {/if} -
      - {$product.product_quantity} -
      -
      -
      - {/block} - - {if $return.state == 2} -
      -
      -

      {l s='Reminder' d='Shop.Theme.Customeraccount'}

      -

      - {l - s='All merchandise must be returned in its original packaging and in its original state.' - d='Shop.Theme.Customeraccount' - }
      - {* [1][/1] is for a HTML tag. *} - {l - s='Please print out the [1]returns form[/1] and include it with your package.' - d='Shop.Theme.Customeraccount' - sprintf=[ - '[1]' => '', - '[/1]' => '' - ] - } -
      - {* [1][/1] is for a HTML tag. *} - {l - s='Please check the [1]returns form[/1] for the correct address.' - d='Shop.Theme.Customeraccount' - sprintf=[ - '[1]' => '', - '[/1]' => '' - ] - } -

      -

      - {l - s='When we receive your package, we will notify you by email. We will then begin processing order reimbursement.' - d='Shop.Theme.Customeraccount' - }
      - - {l - s='Please let us know if you have any questions.' - d='Shop.Theme.Customeraccount' - } -
      - {l - s='If the conditions of return listed above are not respected, we reserve the right to refuse your package and/or reimbursement.' - d='Shop.Theme.Customeraccount' - } -

      -
      -
      - {/if} -{/block} diff --git a/themes/classic/templates/customer/order-slip.tpl b/themes/classic/templates/customer/order-slip.tpl deleted file mode 100644 index feb56629..00000000 --- a/themes/classic/templates/customer/order-slip.tpl +++ /dev/null @@ -1,80 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='customer/page.tpl'} - -{block name='page_title'} - {l s='Credit slips' d='Shop.Theme.Customeraccount'} -{/block} - -{block name='page_content'} -
      {l s='Credit slips you have received after canceled orders.' d='Shop.Theme.Customeraccount'}
      - {if $credit_slips} - - - - - - - - - - - {foreach from=$credit_slips item=slip} - - - - - - - {/foreach} - -
      {l s='Order' d='Shop.Theme.Customeraccount'}{l s='Credit slip' d='Shop.Theme.Customeraccount'}{l s='Date issued' d='Shop.Theme.Customeraccount'}{l s='View credit slip' d='Shop.Theme.Customeraccount'}
      {$slip.order_reference}{$slip.credit_slip_number}{$slip.credit_slip_date} - -
      -
      - {foreach from=$credit_slips item=slip} -
      - -
      - {/foreach} -
      - {/if} -{/block} diff --git a/themes/classic/templates/customer/page.tpl b/themes/classic/templates/customer/page.tpl deleted file mode 100644 index 099c1f82..00000000 --- a/themes/classic/templates/customer/page.tpl +++ /dev/null @@ -1,46 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='page.tpl'} - -{block name='notifications'}{/block} - -{block name='page_content_container'} -
      - {block name='page_content_top'} - {block name='customer_notifications'} - {include file='_partials/notifications.tpl'} - {/block} - {/block} - {block name='page_content'} - - {/block} -
      -{/block} - -{block name='page_footer'} - {block name='my_account_links'} - {include file='customer/_partials/my-account-links.tpl'} - {/block} -{/block} diff --git a/themes/classic/templates/customer/password-email.tpl b/themes/classic/templates/customer/password-email.tpl deleted file mode 100644 index dcfbc605..00000000 --- a/themes/classic/templates/customer/password-email.tpl +++ /dev/null @@ -1,74 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='page.tpl'} - -{block name='page_title'} - {l s='Forgot your password?' d='Shop.Theme.Customeraccount'} -{/block} - -{block name='page_content'} -
      - -
        - {foreach $errors as $error} -
      • - - - - - -

        {$error}

        -
      • - {/foreach} -
      - -
      - -
      - -
      -
      - - - - -
      -
      - -
      -{/block} - -{block name='page_footer'} - -{/block} diff --git a/themes/classic/templates/customer/password-infos.tpl b/themes/classic/templates/customer/password-infos.tpl deleted file mode 100644 index d829349e..00000000 --- a/themes/classic/templates/customer/password-infos.tpl +++ /dev/null @@ -1,50 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='page.tpl'} - -{block name='page_title'} - {l s='Forgot your password?' d='Shop.Theme.Customeraccount'} -{/block} - -{block name='page_content'} -
        - {foreach $successes as $success} -
      • - - - - - -

        {$success}

        -
      • - {/foreach} -
      -{/block} - -{block name='page_footer'} - -{/block} diff --git a/themes/classic/templates/customer/password-new.tpl b/themes/classic/templates/customer/password-new.tpl deleted file mode 100644 index fc376407..00000000 --- a/themes/classic/templates/customer/password-new.tpl +++ /dev/null @@ -1,90 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='page.tpl'} - -{block name='page_title'} - {l s='Reset your password' d='Shop.Theme.Customeraccount'} -{/block} - -{block name='page_content'} -
      -
        - {foreach $errors as $error} -
      • - - - - - -

        {$error}

        -
      • - {/foreach} -
      -
      - - - -
      -
      - -
      - -
      -
      - -
      - -
      - -
      -
      - - - - - -
      -
      - -
      -
      -
      - -
      -
      -{/block} - -{block name='page_footer'} - -{/block} diff --git a/themes/classic/templates/customer/registration.tpl b/themes/classic/templates/customer/registration.tpl deleted file mode 100644 index 9f717033..00000000 --- a/themes/classic/templates/customer/registration.tpl +++ /dev/null @@ -1,39 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='page.tpl'} - -{block name='page_title'} - {l s='Create an account' d='Shop.Theme.Customeraccount'} -{/block} - -{block name='page_content'} - {block name='register_form_container'} - {$hook_create_account_top nofilter} -
      -

      {l s='Already have an account?' d='Shop.Theme.Customeraccount'} {l s='Log in instead!' d='Shop.Theme.Customeraccount'}

      - {render file='customer/_partials/customer-form.tpl' ui=$register_form} -
      - {/block} -{/block} diff --git a/themes/classic/templates/errors/404.tpl b/themes/classic/templates/errors/404.tpl deleted file mode 100644 index 022157f2..00000000 --- a/themes/classic/templates/errors/404.tpl +++ /dev/null @@ -1,33 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='page.tpl'} - -{block name='page_title'} - {$page.title} -{/block} - -{block name='page_content_container'} - {include file='errors/not-found.tpl'} -{/block} diff --git a/themes/classic/templates/errors/forbidden.tpl b/themes/classic/templates/errors/forbidden.tpl deleted file mode 100644 index 90dacff4..00000000 --- a/themes/classic/templates/errors/forbidden.tpl +++ /dev/null @@ -1,30 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file=$layout} - -{block name='content'} -
      -
      -{/block} diff --git a/themes/classic/templates/errors/maintenance.tpl b/themes/classic/templates/errors/maintenance.tpl deleted file mode 100644 index de7bea89..00000000 --- a/themes/classic/templates/errors/maintenance.tpl +++ /dev/null @@ -1,61 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='layouts/layout-error.tpl'} - -{block name='content'} - -
      - - {block name='page_header_container'} - - {/block} - - {block name='page_content_container'} -
      - {block name='page_content'} - {$maintenance_text nofilter} - {/block} -
      - {/block} - - {block name='page_footer_container'} - - {/block} - -
      - -{/block} diff --git a/themes/classic/templates/errors/not-found.tpl b/themes/classic/templates/errors/not-found.tpl deleted file mode 100644 index 8a932e81..00000000 --- a/themes/classic/templates/errors/not-found.tpl +++ /dev/null @@ -1,40 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -
      - {block name='page_content'} - -

      {l s='Sorry for the inconvenience.' d='Shop.Theme.Global'}

      -

      {l s='Search again what you are looking for' d='Shop.Theme.Global'}

      - - {block name='search'} - {hook h='displaySearch'} - {/block} - - {block name='hook_not_found'} - {hook h='displayNotFound'} - {/block} - - {/block} -
      diff --git a/themes/classic/templates/errors/restricted-country.tpl b/themes/classic/templates/errors/restricted-country.tpl deleted file mode 100644 index beb1095e..00000000 --- a/themes/classic/templates/errors/restricted-country.tpl +++ /dev/null @@ -1,55 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='layouts/layout-error.tpl'} - -{block name='content'} - -
      - - {block name='page_header_container'} - - {/block} - - {block name='page_content_container'} -
      - {block name='page_content'} -

      {l s='403 Forbidden' d='Shop.Theme.Global'}

      -

      {l s='You cannot access this store from your country. We apologize for the inconvenience.' d='Shop.Theme.Global'}

      - {/block} -
      - {/block} - - {block name='page_footer_container'} - - {/block} - -
      - -{/block} diff --git a/themes/classic/templates/errors/static/500.html b/themes/classic/templates/errors/static/500.html deleted file mode 100644 index e69de29b..00000000 diff --git a/themes/classic/templates/errors/static/503.html b/themes/classic/templates/errors/static/503.html deleted file mode 100644 index e69de29b..00000000 diff --git a/themes/classic/templates/index.tpl b/themes/classic/templates/index.tpl deleted file mode 100644 index 5a8535d2..00000000 --- a/themes/classic/templates/index.tpl +++ /dev/null @@ -1,37 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='page.tpl'} - - {block name='page_content_container'} -
      - {block name='page_content_top'}{/block} - - {block name='page_content'} - {block name='hook_home'} - {$HOOK_HOME nofilter} - {/block} - {/block} -
      - {/block} diff --git a/themes/classic/templates/layouts/layout-both-columns.tpl b/themes/classic/templates/layouts/layout-both-columns.tpl deleted file mode 100644 index 4a2ddfbb..00000000 --- a/themes/classic/templates/layouts/layout-both-columns.tpl +++ /dev/null @@ -1,112 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - - - - - {block name='head'} - {include file='_partials/head.tpl'} - {/block} - - - - - {block name='hook_after_body_opening_tag'} - {hook h='displayAfterBodyOpeningTag'} - {/block} - -
      - {block name='product_activation'} - {include file='catalog/_partials/product-activation.tpl'} - {/block} - - - - {block name='notifications'} - {include file='_partials/notifications.tpl'} - {/block} - -
      - {hook h="displayWrapperTop"} -
      - {block name='breadcrumb'} - {include file='_partials/breadcrumb.tpl'} - {/block} - - {block name="left_column"} -
      - {if $page.page_name == 'product'} - {hook h='displayLeftColumnProduct'} - {else} - {hook h="displayLeftColumn"} - {/if} -
      - {/block} - - {block name="content_wrapper"} -
      - {hook h="displayContentWrapperTop"} - {block name="content"} -

      Hello world! This is HTML5 Boilerplate.

      - {/block} - {hook h="displayContentWrapperBottom"} -
      - {/block} - - {block name="right_column"} -
      - {if $page.page_name == 'product'} - {hook h='displayRightColumnProduct'} - {else} - {hook h="displayRightColumn"} - {/if} -
      - {/block} -
      - {hook h="displayWrapperBottom"} -
      - -
      - {block name="footer"} - {include file="_partials/footer.tpl"} - {/block} -
      - -
      - - {block name='javascript_bottom'} - {include file="_partials/javascript.tpl" javascript=$javascript.bottom} - {/block} - - {block name='hook_before_body_closing_tag'} - {hook h='displayBeforeBodyClosingTag'} - {/block} - - - diff --git a/themes/classic/templates/layouts/layout-content-only.tpl b/themes/classic/templates/layouts/layout-content-only.tpl deleted file mode 100644 index a3f38dc4..00000000 --- a/themes/classic/templates/layouts/layout-content-only.tpl +++ /dev/null @@ -1,41 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='layouts/layout-both-columns.tpl'} - -{block name='header'}{/block} -{block name='left_column'}{/block} -{block name='right_column'}{/block} - -{block name='content_wrapper'} -
      - {hook h="displayContentWrapperTop"} - {block name='content'} -

      Hello world! This is HTML5 Boilerplate.

      - {/block} - {hook h="displayContentWrapperBottom"} -
      -{/block} - -{block name='footer'}{/block} diff --git a/themes/classic/templates/layouts/layout-error.tpl b/themes/classic/templates/layouts/layout-error.tpl deleted file mode 100644 index 35f221ea..00000000 --- a/themes/classic/templates/layouts/layout-error.tpl +++ /dev/null @@ -1,55 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} - - - - - - - - {block name='head_seo'} - {block name='head_seo_title'}{/block} - - - {/block} - - - {block name='stylesheets'} - {include file="_partials/stylesheets.tpl" stylesheets=$stylesheets} - {/block} - - - - - -
      - {block name='content'} -

      Hello world! This is HTML5 Boilerplate.

      - {/block} -
      - - - - diff --git a/themes/classic/templates/layouts/layout-full-width.tpl b/themes/classic/templates/layouts/layout-full-width.tpl deleted file mode 100644 index bb0d0273..00000000 --- a/themes/classic/templates/layouts/layout-full-width.tpl +++ /dev/null @@ -1,38 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='layouts/layout-both-columns.tpl'} - -{block name='left_column'}{/block} -{block name='right_column'}{/block} - -{block name='content_wrapper'} -
      - {hook h="displayContentWrapperTop"} - {block name='content'} -

      Hello world! This is HTML5 Boilerplate.

      - {/block} - {hook h="displayContentWrapperBottom"} -
      -{/block} diff --git a/themes/classic/templates/layouts/layout-left-column.tpl b/themes/classic/templates/layouts/layout-left-column.tpl deleted file mode 100644 index 242d95c8..00000000 --- a/themes/classic/templates/layouts/layout-left-column.tpl +++ /dev/null @@ -1,37 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='layouts/layout-both-columns.tpl'} - -{block name='right_column'}{/block} - -{block name='content_wrapper'} -
      - {hook h="displayContentWrapperTop"} - {block name='content'} -

      Hello world! This is HTML5 Boilerplate.

      - {/block} - {hook h="displayContentWrapperBottom"} -
      -{/block} diff --git a/themes/classic/templates/layouts/layout-right-column.tpl b/themes/classic/templates/layouts/layout-right-column.tpl deleted file mode 100644 index e1fdb524..00000000 --- a/themes/classic/templates/layouts/layout-right-column.tpl +++ /dev/null @@ -1,37 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file='layouts/layout-both-columns.tpl'} - -{block name='left_column'}{/block} - -{block name='content_wrapper'} -
      - {hook h="displayContentWrapperTop"} - {block name='content'} -

      Hello world! This is HTML5 Boilerplate.

      - {/block} - {hook h="displayContentWrapperBottom"} -
      -{/block} diff --git a/themes/classic/templates/page.tpl b/themes/classic/templates/page.tpl deleted file mode 100644 index 0438a397..00000000 --- a/themes/classic/templates/page.tpl +++ /dev/null @@ -1,58 +0,0 @@ -{** - * 2007-2019 PrestaShop and Contributors - * - * NOTICE OF LICENSE - * - * This source file is subject to the Academic Free License 3.0 (AFL-3.0) - * that is bundled with this package in the file LICENSE.txt. - * It is also available through the world-wide-web at this URL: - * https://opensource.org/licenses/AFL-3.0 - * If you did not receive a copy of the license and are unable to - * obtain it through the world-wide-web, please send an email - * to license@prestashop.com so we can send you a copy immediately. - * - * DISCLAIMER - * - * Do not edit or add to this file if you wish to upgrade PrestaShop to newer - * versions in the future. If you wish to customize PrestaShop for your - * needs please refer to https://www.prestashop.com for more information. - * - * @author PrestaShop SA - * @copyright 2007-2019 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) - * International Registered Trademark & Property of PrestaShop SA - *} -{extends file=$layout} - -{block name='content'} - -
      - - {block name='page_header_container'} - {block name='page_title' hide} - - {/block} - {/block} - - {block name='page_content_container'} -
      - {block name='page_content_top'}{/block} - {block name='page_content'} - - {/block} -
      - {/block} - - {block name='page_footer_container'} -
      - {block name='page_footer'} - - {/block} -
      - {/block} - -
      - -{/block} diff --git a/tools/.htaccess b/tools/.htaccess deleted file mode 100644 index 228b4239..00000000 --- a/tools/.htaccess +++ /dev/null @@ -1,9 +0,0 @@ - -RewriteEngine on - -RewriteCond %{REQUEST_FILENAME} -s [OR] -RewriteCond %{REQUEST_FILENAME} -l [OR] -RewriteCond %{REQUEST_FILENAME} -d -RewriteRule ^.*$ - [NC,L] -RewriteRule ^.*$ ../index.php [NC,L] - diff --git a/tools/index.php b/tools/index.php deleted file mode 100644 index 76cd9dd3..00000000 --- a/tools/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/tools/profiling/.htaccess b/tools/profiling/.htaccess deleted file mode 100644 index 3de9e400..00000000 --- a/tools/profiling/.htaccess +++ /dev/null @@ -1,10 +0,0 @@ -# Apache 2.2 - - Order deny,allow - Deny from all - - -# Apache 2.4 - - Require all denied - diff --git a/tools/profiling/Controller.php b/tools/profiling/Controller.php deleted file mode 100644 index 872bab5f..00000000 --- a/tools/profiling/Controller.php +++ /dev/null @@ -1,759 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -abstract class Controller extends ControllerCore -{ - protected $total_filesize = 0; - protected $total_query_time = 0; - protected $total_global_var_size = 0; - protected $total_modules_time = 0; - protected $total_modules_memory = 0; - protected $global_var_size = array(); - - protected $modules_perfs = array(); - protected $hooks_perfs = array(); - - protected $array_queries = array(); - - protected $profiler = array(); - - private function getMemoryColor($n) - { - $n /= 1048576; - if ($n > 3) { - return ''.sprintf('%0.2f', $n).''; - } elseif ($n > 1) { - return ''.sprintf('%0.2f', $n).''; - } elseif (round($n, 2) > 0) { - return ''.sprintf('%0.2f', $n).''; - } - - return '-'; - } - - private function getPeakMemoryColor($n) - { - $n /= 1048576; - if ($n > 16) { - return ''.sprintf('%0.1f', $n).''; - } - if ($n > 12) { - return ''.sprintf('%0.1f', $n).''; - } - - return ''.sprintf('%0.1f', $n).''; - } - - private function displaySQLQueries($n) - { - if ($n > 150) { - return ''.$n.' queries'; - } - if ($n > 100) { - return ''.$n.' queries'; - } - - return ''.$n.' quer'.($n == 1 ? 'y' : 'ies').''; - } - - private function displayRowsBrowsed($n) - { - if ($n > 400) { - return ''.$n.' rows browsed'; - } - if ($n > 100) { - return ''.$n.' rows browsed'; - } - - return ''.$n.' row'.($n == 1 ? '' : 's').' browsed'; - } - - private function getPhpVersionColor($version) - { - if (version_compare($version, '5.6') < 0) { - return ''.$version.' (Upgrade strongly recommended)'; - } elseif (version_compare($version, '7.1') < 0) { - return ''.$version.' (Consider upgrading)'; - } - - return ''.$version.' (OK)'; - } - - private function getMySQLVersionColor($version) - { - if (version_compare($version, '5.5') < 0) { - return ''.$version.' (Upgrade strongly recommended)'; - } elseif (version_compare($version, '5.6') < 0) { - return ''.$version.' (Consider upgrading)'; - } - - return ''.$version.' (OK)'; - } - - private function getLoadTimeColor($n, $kikoo = false) - { - if ($n > 1.6) { - return ''.round($n * 1000).''.($kikoo ? ' ms - You\'d better run your shop on a toaster' : ''); - } elseif ($n > 0.8) { - return ''.round($n * 1000).''.($kikoo ? ' ms - OK... for a shared hosting' : ''); - } elseif ($n > 0) { - return ''.round($n * 1000).''.($kikoo ? ' ms - Unicorn powered webserver!' : ''); - } - - return '-'.($kikoo ? ' ms - Faster than light' : ''); - } - - private function getTotalQueriyingTimeColor($n) - { - if ($n >= 100) { - return ''.$n.''; - } elseif ($n >= 50) { - return ''.$n.''; - } - - return ''.$n.''; - } - - private function getNbQueriesColor($n) - { - if ($n >= 100) { - return ''.$n.''; - } elseif ($n >= 50) { - return ''.$n.''; - } - - return ''.$n.''; - } - - private function getTimeColor($n) - { - if ($n > 4) { - return 'style="color:red"'; - } - if ($n > 2) { - return 'style="color:#EF8B00"'; - } - - return 'style="color:green"'; - } - - private function getQueryColor($n) - { - if ($n > 5) { - return 'style="color:red"'; - } - if ($n > 2) { - return 'style="color:#EF8B00"'; - } - - return 'style="color:green"'; - } - - private function getTableColor($n) - { - if ($n > 30) { - return 'style="color:red"'; - } - if ($n > 20) { - return 'style="color:#EF8B00"'; - } - - return 'style="color:green"'; - } - - private function getObjectModelColor($n) - { - if ($n > 50) { - return 'style="color:red"'; - } - if ($n > 10) { - return 'style="color:#EF8B00"'; - } - - return 'style="color:green"'; - } - - protected function stamp($block) - { - return array('block' => $block, 'memory_usage' => memory_get_usage(), 'peak_memory_usage' => memory_get_peak_usage(), 'time' => microtime(true)); - } - - public function __construct() - { - $this->profiler[] = $this->stamp('config'); - - parent::__construct(); - $this->profiler[] = $this->stamp('__construct'); - } - - public function run() - { - $this->init(); - $this->profiler[] = $this->stamp('init'); - - if ($this->checkAccess()) { - $this->profiler[] = $this->stamp('checkAccess'); - - if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) { - $this->setMedia(); - $this->profiler[] = $this->stamp('setMedia'); - } - - $this->postProcess(); - $this->profiler[] = $this->stamp('postProcess'); - - if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) { - $this->initHeader(); - $this->profiler[] = $this->stamp('initHeader'); - } - - $this->initContent(); - $this->profiler[] = $this->stamp('initContent'); - - if (!$this->content_only && ($this->display_footer || (isset($this->className) && $this->className))) { - $this->initFooter(); - $this->profiler[] = $this->stamp('initFooter'); - } - - if ($this->ajax) { - $action = Tools::toCamelCase(Tools::getValue('action'), true); - if (!empty($action) && method_exists($this, 'displayAjax'.$action)) { - $this->{'displayAjax'.$action}(); - } elseif (method_exists($this, 'displayAjax')) { - $this->displayAjax(); - } - - return; - } - } else { - $this->initCursedPage(); - } - - $this->displayProfiling(); - } - - private function getVarSize($var) - { - $start_memory = memory_get_usage(); - - try { - $tmp = Tools::unSerialize(serialize($var)); - } catch (Exception $e) { - $tmp = $this->getVarData($var); - } - $size = memory_get_usage() - $start_memory; - - return $size; - } - - private function getVarData($var) - { - if (is_object($var)) { - return $var; - } - - return (string)$var; - } - - protected function processProfilingData() - { - global $start_time; - - // Including a lot of files uses memory - foreach (get_included_files() as $file) { - $this->total_filesize += filesize($file); - } - - // Sum querying time - foreach (Db::getInstance()->queries as $data) { - $this->total_query_time += $data['time']; - } - - foreach ($GLOBALS as $key => $value) { - if ($key != 'GLOBALS') { - $this->total_global_var_size += ($size = $this->getVarSize($value)); - if ($size > 1024) { - $this->global_var_size[$key] = round($size / 1024); - } - } - } - arsort($this->global_var_size); - - $cache = Cache::retrieveAll(); - $this->total_cache_size = $this->getVarSize($cache); - - $queries = Db::getInstance()->queries; - uasort($queries, 'prestashop_querytime_sort'); - foreach ($queries as $data) { - $query_row = array( - 'time' => $data['time'], - 'query' => $data['query'], - 'location' => str_replace('\\', '/', substr($data['stack'][0]['file'], strlen(_PS_ROOT_DIR_))).':'.$data['stack'][0]['line'], - 'filesort' => false, - 'rows' => 1, - 'group_by' => false, - 'stack' => array(), - ); - if (preg_match('/^\s*select\s+/i', $data['query'])) { - $explain = Db::getInstance()->executeS('explain '.$data['query']); - if (stristr($explain[0]['Extra'], 'filesort')) { - $query_row['filesort'] = true; - } - foreach ($explain as $row) { - $query_row['rows'] *= $row['rows']; - } - if (stristr($data['query'], 'group by') && !preg_match('/(avg|count|min|max|group_concat|sum)\s*\(/i', $data['query'])) { - $query_row['group_by'] = true; - } - } - - array_shift($data['stack']); - foreach ($data['stack'] as $call) { - $query_row['stack'][] = str_replace('\\', '/', substr($call['file'], strlen(_PS_ROOT_DIR_))).':'.$call['line']; - } - - $this->array_queries[] = $query_row; - } - - uasort(ObjectModel::$debug_list, function ($a, $b) { return (count($a) < count($b)) ? 1 : -1; }); - arsort(Db::getInstance()->tables); - arsort(Db::getInstance()->uniqQueries); - } - - protected function displayProfilingLinks() - { - echo ' -
      -
        -
      1. Stopwatch SQL
      2. -
      3. Doubles
      4. -
      5. Tables stress
      6. - '.(isset(ObjectModel::$debug_list) ? '
      7. ObjectModel instances
      8. ' : '').' -
      9. Included Files
      10. -
      -
      '; - } - - protected function displayProfilingStyle() - { - echo ' - - '; - } - - protected function displayProfilingSummary() - { - global $start_time; - - echo ' -
      - - - - - - - '; - foreach ($this->global_var_size as $global => $size) { - echo ''; - } - echo ' -
      Load Time'.$this->getLoadTimeColor($this->profiler[count($this->profiler) - 1]['time'] - $start_time, true).'
      Querying Time'.$this->getTotalQueriyingTimeColor(round(1000 * $this->total_query_time)).' ms -
      Queries'.$this->getNbQueriesColor(count($this->array_queries)).'
      Memory Peak Usage'.$this->getPeakMemoryColor($this->profiler[count($this->profiler) - 1]['peak_memory_usage']).' Mb
      Included Files'.count(get_included_files()).' files - '.$this->getMemoryColor($this->total_filesize).' Mb
      PrestaShop Cache'.$this->getMemoryColor($this->total_cache_size).' Mb
      Global vars'.$this->getMemoryColor($this->total_global_var_size).' Mb
      -
      '; - } - - protected function displayProfilingConfiguration() - { - echo ' -
      - - - - - - - - -
      PrestaShop Version'._PS_VERSION_.'
      PHP Version'.$this->getPhpVersionColor(PHP_VERSION).'
      MySQL Version'.$this->getMySQLVersionColor(Db::getInstance()->getVersion()).'
      Memory Limit'.ini_get('memory_limit').'
      Max Execution Time'.ini_get('max_execution_time').'s
      Smarty Cacheenabled' : 'red">disabled').'
      Smarty Compilationnever recompile' : (Configuration::get('PS_SMARTY_FORCE_COMPILE') == 1 ? '#EF8B00">auto' : 'red">force compile')).'
      -
      '; - } - - protected function displayProfilingRun() - { - global $start_time; - - echo ' -
      - - '; - $last = array('time' => $start_time, 'memory_usage' => 0); - foreach ($this->profiler as $row) { - if ($row['block'] == 'checkAccess' && $row['time'] == $last['time']) { - continue; - } - echo ' - - - - - - '; - $last = $row; - } - echo ' -
       TimeCumulated TimeMemory UsageMemory Peak Usage
      '.$row['block'].''.$this->getLoadTimeColor($row['time'] - $last['time']).' ms'.$this->getLoadTimeColor($row['time'] - $start_time).' ms'.$this->getMemoryColor($row['memory_usage'] - $last['memory_usage']).' Mb'.$this->getMemoryColor($row['peak_memory_usage']).' Mb
      -
      '; - } - - protected function displayProfilingHooks() - { - $count_hooks = count($this->hooks_perfs); - - echo ' -
      - - - - - - '; - foreach ($this->hooks_perfs as $hook => $hooks_perfs) { - echo ' - - - - - '; - foreach ($hooks_perfs['modules'] as $module => $perfs) { - echo ' - - - - - '; - } - } - echo ' - - - - -
      HookTimeMemory Usage
      - '.$hook.' - - '.$this->getLoadTimeColor($hooks_perfs['time']).' ms - - '.$this->getMemoryColor($hooks_perfs['memory']).' Mb -
      '.($count_hooks == 1 ? '1 hook' : (int)$count_hooks.' hooks').''.$this->getLoadTimeColor($this->total_modules_time).' ms'.$this->getMemoryColor($this->total_modules_memory).' Mb
      -
      '; - } - - protected function displayProfilingModules() - { - $count_modules = count($this->modules_perfs); - - echo ' -
      - - - - - - '; - foreach ($this->modules_perfs as $module => $modules_perfs) { - echo ' - - - - - '; - foreach ($modules_perfs['methods'] as $hook => $perfs) { - echo ' - - - - - '; - } - } - echo ' - - - - -
      ModuleTimeMemory Usage
      - '.$module.' - - '.$this->getLoadTimeColor($modules_perfs['time']).' ms - - '.$this->getMemoryColor($modules_perfs['memory']).' Mb -
      '.($count_modules == 1 ? '1 module' : (int)$count_modules.' modules').''.$this->getLoadTimeColor($this->total_modules_time).' ms'.$this->getMemoryColor($this->total_modules_memory).' Mb
      -
      '; - } - - protected function displayProfilingStopwatch() - { - echo ' -
      -

      Stopwatch SQL - '.count($this->array_queries).' queries

      - - - - - - - - - - - - '; - foreach ($this->array_queries as $data) { - $callstack = implode('
      ', $data['stack']); - $callstack_md5 = md5($callstack); - - echo ' - - - - - - - - '; - } - echo '
      QueryTime (ms)RowsFilesortGroup ByLocation
      '.preg_replace("/(^[\s]*)/m", "", htmlspecialchars($data['query'], ENT_NOQUOTES, 'utf-8', false)).'
      getTimeColor($data['time'] * 1000).'>'.(round($data['time'] * 1000, 1) < 0.1 ? '< 1' : round($data['time'] * 1000, 1)).''.(int)$data['rows'].''.($data['filesort'] ? 'Yes' : '').''.($data['group_by'] ? 'Yes' : '').' - '.$data['location'].' - -
      -
      '; - } - - protected function displayProfilingDoubles() - { - echo '
      -

      Doubles

      - '; - foreach (Db::getInstance()->uniqQueries as $q => $nb) { - if ($nb > 1) { - echo ''; - } - } - echo '
      getQueryColor($nb).'>'.$nb.'
      '.$q.'
      -
      '; - } - - protected function displayProfilingTableStress() - { - echo '
      -

      Tables stress

      - '; - foreach (Db::getInstance()->tables as $table => $nb) { - echo ''; - } - echo '
      getTableColor($nb).'>'.$nb.' '.$table.'
      -
      '; - } - - protected function displayProfilingObjectModel() - { - echo ' -
      -

      ObjectModel instances

      - - '; - foreach (ObjectModel::$debug_list as $class => $info) { - echo ' - - - - '; - } - echo '
      NameInstancesSource
      '.$class.'getObjectModelColor(count($info)).'>'.count($info).''; - foreach ($info as $trace) { - echo str_replace(array(_PS_ROOT_DIR_, '\\'), array('', '/'), $trace['file']).' ['.$trace['line'].']
      '; - } - echo '
      -
      '; - } - - protected function displayProfilingFiles() - { - $i = 0; - - echo '
      -

      Included Files

      - - '; - foreach (get_included_files() as $file) { - $file = str_replace('\\', '/', str_replace(_PS_ROOT_DIR_, '', $file)); - if (strpos($file, '/tools/profiling/') === 0) { - continue; - } - echo ''; - } - echo '
      #Filename
      '.(++$i).''.$file.'
      -
      '; - } - - public function displayProfiling() - { - if (!empty($this->redirect_after)) { - echo ' - - - - - - - - -
      -
      - -
      '; - } else { - // Call original display method - $this->display(); - $this->profiler[] = $this->stamp('display'); - } - - // Process all profiling data - $this->processProfilingData(); - - // Add some specific style for profiling information - $this->displayProfilingStyle(); - - echo '
      '; - - echo '
      '; - $this->displayProfilingSummary(); - $this->displayProfilingConfiguration(); - $this->displayProfilingRun(); - echo '
      '; - $this->displayProfilingHooks(); - $this->displayProfilingModules(); - $this->displayProfilingLinks(); - echo '
      '; - - $this->displayProfilingStopwatch(); - $this->displayProfilingDoubles(); - $this->displayProfilingTableStress(); - if (isset(ObjectModel::$debug_list)) { - $this->displayProfilingObjectModel(); - } - $this->displayProfilingFiles(); - - if (!empty($this->redirect_after)) { - echo '
      '; - } - } -} - -function prestashop_querytime_sort($a, $b) -{ - if ($a['time'] == $b['time']) { - return 0; - } - - return ($a['time'] > $b['time']) ? -1 : 1; -} diff --git a/tools/profiling/Db.php b/tools/profiling/Db.php deleted file mode 100644 index 2872d71c..00000000 --- a/tools/profiling/Db.php +++ /dev/null @@ -1,125 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -abstract class Db extends DbCore -{ - /** - * Add SQL_NO_CACHE in SELECT queries - * - * @var bool - */ - public $disableCache = true; - - /** - * Total of queries - * - * @var int - */ - public $count = 0; - - /** - * List of queries - * - * @var array - */ - public $queries = array(); - - /** - * List of uniq queries (replace numbers by XX) - * - * @var array - */ - public $uniqQueries = array(); - - /** - * List of tables - * - * @var array - */ - public $tables = array(); - - /** - * Execute the query and log some informations - * - * @see DbCore::query() - */ - public function query($sql) - { - $explain = false; - if (preg_match('/^\s*explain\s+/i', $sql)) { - $explain = true; - } - - if (!$explain) { - $uniqSql = preg_replace('/[\'"][a-f0-9]{32}[\'"]/', 'XX', $sql); - $uniqSql = preg_replace('/[0-9]+/', 'XX', $uniqSql); - if (!isset($this->uniqQueries[$uniqSql])) { - $this->uniqQueries[$uniqSql] = 0; - } - $this->uniqQueries[$uniqSql]++; - - // No cache for query - if ($this->disableCache && !stripos($sql, 'SQL_NO_CACHE')) { - $sql = preg_replace('/^\s*select\s+/i', 'SELECT SQL_NO_CACHE ', trim($sql)); - } - - // Get tables in query - preg_match_all('/(from|join)\s+`?'._DB_PREFIX_.'([a-z0-9_-]+)/ui', $sql, $matches); - foreach ($matches[2] as $table) { - if (!isset($this->tables[$table])) { - $this->tables[$table] = 0; - } - $this->tables[$table]++; - } - - $start = microtime(true); - } - - // Execute query - $result = parent::query($sql); - - if (!$explain) { - $end = microtime(true); - - $stack = debug_backtrace(false); - while (preg_match('@[/\\\\]classes[/\\\\]db[/\\\\]@i', $stack[0]['file'])) { - array_shift($stack); - } - $stack_light = array(); - foreach ($stack as $call) { - $stack_light[] = array('file' => isset($call['file']) ? $call['file'] : 'undefined', 'line' => isset($call['line']) ? $call['line'] : 'undefined'); - } - - $this->queries[] = array( - 'query' => $sql, - 'time' => $end - $start, - 'stack' => $stack_light, - ); - } - - return $result; - } -} diff --git a/tools/profiling/ObjectModel.php b/tools/profiling/ObjectModel.php deleted file mode 100644 index ec5a2bb0..00000000 --- a/tools/profiling/ObjectModel.php +++ /dev/null @@ -1,54 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -abstract class ObjectModel extends ObjectModelCore -{ - public static $debug_list = array(); - - public function __construct($id = null, $id_lang = null, $id_shop = null) - { - parent::__construct($id, $id_lang, $id_shop); - - $classname = get_class($this); - if (!isset(self::$debug_list[$classname])) { - self::$debug_list[$classname] = array(); - } - - $class_list = array('ObjectModel', 'ObjectModelCore', $classname, $classname.'Core'); - $backtrace = debug_backtrace(); - foreach ($backtrace as $trace_id => $row) { - if (!isset($backtrace[$trace_id]['class']) || !in_array($backtrace[$trace_id]['class'], $class_list)) { - break; - } - } - $trace_id--; - - self::$debug_list[$classname][] = array( - 'file' => @$backtrace[$trace_id]['file'], - 'line' => @$backtrace[$trace_id]['line'], - ); - } -} diff --git a/tools/profiling/Tools.php b/tools/profiling/Tools.php deleted file mode 100644 index d2ad7ed0..00000000 --- a/tools/profiling/Tools.php +++ /dev/null @@ -1,117 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -class Tools extends ToolsCore -{ - public static function redirect($url, $base_uri = __PS_BASE_URI__, Link $link = null, $headers = null) - { - if (!$link) { - $link = Context::getContext()->link; - } - - if (strpos($url, 'http://') === false && strpos($url, 'https://') === false && $link) { - if (strpos($url, $base_uri) === 0) { - $url = substr($url, strlen($base_uri)); - } - if (strpos($url, 'index.php?controller=') !== false && strpos($url, 'index.php/') == 0) { - $url = substr($url, strlen('index.php?controller=')); - if (Configuration::get('PS_REWRITING_SETTINGS')) { - $url = static::strReplaceFirst('&', '?', $url); - } - } - - $explode = explode('?', $url); - // don't use ssl if url is home page - // used when logout for example - $use_ssl = !empty($url); - $url = $link->getPageLink($explode[0], $use_ssl); - if (isset($explode[1])) { - $url .= '?'.$explode[1]; - } - } - - // Send additional headers - if ($headers) { - if (!is_array($headers)) { - $headers = array($headers); - } - - foreach ($headers as $header) { - header($header); - } - } - - Context::getContext()->controller->setRedirectAfter($url); - } - - public static function getDefaultControllerClass() - { - if (isset(Context::getContext()->employee) && Validate::isLoadedObject(Context::getContext()->employee) && isset(Context::getContext()->employee->default_tab)) { - $default_controller = Tab::getClassNameById((int)Context::getContext()->employee->default_tab); - } - if (empty($default_controller)) { - $default_controller = 'AdminDashboard'; - } - $controllers = Dispatcher::getControllers(array(_PS_ADMIN_DIR_.'/tabs/', _PS_ADMIN_CONTROLLER_DIR_, _PS_OVERRIDE_DIR_.'controllers/admin/')); - if (!isset($controllers[strtolower($default_controller)])) { - $default_controller = 'adminnotfound'; - } - $controller_class = $controllers[strtolower($default_controller)]; - - return $controller_class; - } - - public static function redirectLink($url) - { - if (!preg_match('@^https?://@i', $url)) { - if (strpos($url, __PS_BASE_URI__) !== false && strpos($url, __PS_BASE_URI__) == 0) { - $url = substr($url, strlen(__PS_BASE_URI__)); - } - $explode = explode('?', $url); - $url = Context::getContext()->link->getPageLink($explode[0]); - if (isset($explode[1])) { - $url .= '?'.$explode[1]; - } - } - } - - public static function redirectAdmin($url) - { - if (!is_object(Context::getContext()->controller)) { - try { - $controller = Controller::getController(static::getDefaultControllerClass()); - $controller->setRedirectAfter($url); - $controller->run(); - Context::getContext()->controller = $controller; - die(); - } catch (PrestaShopException $e) { - $e->displayMessage(); - } - } else { - Context::getContext()->controller->setRedirectAfter($url); - } - } -} diff --git a/tools/profiling/index.php b/tools/profiling/index.php deleted file mode 100644 index 76cd9dd3..00000000 --- a/tools/profiling/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/translations/.DS_Store b/translations/.DS_Store deleted file mode 100644 index de70136f..00000000 Binary files a/translations/.DS_Store and /dev/null differ diff --git a/translations/cldr/.htaccess b/translations/cldr/.htaccess deleted file mode 100644 index ec2b13ce..00000000 --- a/translations/cldr/.htaccess +++ /dev/null @@ -1,10 +0,0 @@ -# Apache 2.2 - - Order deny,allow - Allow from all - - -# Apache 2.4 - - Require all granted - diff --git a/translations/export/index.php b/translations/export/index.php deleted file mode 100644 index 76cd9dd3..00000000 --- a/translations/export/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/translations/index.php b/translations/index.php deleted file mode 100644 index 76cd9dd3..00000000 --- a/translations/index.php +++ /dev/null @@ -1,35 +0,0 @@ - - * @copyright Since 2007 PrestaShop SA and Contributors - * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - */ - -header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); -header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); - -header("Cache-Control: no-store, no-cache, must-revalidate"); -header("Cache-Control: post-check=0, pre-check=0", false); -header("Pragma: no-cache"); - -header("Location: ../"); -exit; diff --git a/translations/sf-en-GB.zip b/translations/sf-en-GB.zip deleted file mode 100644 index 09526331..00000000 Binary files a/translations/sf-en-GB.zip and /dev/null differ diff --git a/translations/sf-pl-PL.zip b/translations/sf-pl-PL.zip deleted file mode 100644 index 3a08f473..00000000 Binary files a/translations/sf-pl-PL.zip and /dev/null differ